@univerjs/core 1.0.0-rc.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/cjs/facade.js +96 -40
  2. package/lib/cjs/index.js +985 -362
  3. package/lib/es/facade.js +97 -41
  4. package/lib/es/index.js +979 -362
  5. package/lib/facade.js +97 -41
  6. package/lib/index.js +979 -362
  7. package/lib/types/docs/data-model/text-x/action-types.d.ts +19 -1
  8. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
  9. package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +1 -1
  10. package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +1 -1
  11. package/lib/types/docs/data-model/text-x/apply.d.ts +1 -1
  12. package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +2 -1
  13. package/lib/types/docs/data-model/text-x/custom-range-update.d.ts +30 -0
  14. package/lib/types/docs/data-model/text-x/structure-validator.d.ts +1 -1
  15. package/lib/types/docs/data-model/text-x/text-x.d.ts +7 -3
  16. package/lib/types/docs/data-model/text-x/utils.d.ts +7 -1
  17. package/lib/types/docs/sdt-binding.d.ts +19 -0
  18. package/lib/types/facade/f-blob.d.ts +11 -11
  19. package/lib/types/facade/f-enum.d.ts +9 -1
  20. package/lib/types/facade/f-event-registry.d.ts +18 -6
  21. package/lib/types/facade/f-event.d.ts +4 -0
  22. package/lib/types/facade/f-univer.d.ts +43 -19
  23. package/lib/types/index.d.ts +2 -0
  24. package/lib/types/sheets/typedef.d.ts +38 -7
  25. package/lib/types/sheets/workbook.d.ts +1 -1
  26. package/lib/types/sheets/worksheet.d.ts +8 -7
  27. package/lib/types/types/enum/record-filter.d.ts +30 -0
  28. package/lib/types/types/interfaces/i-document-data.d.ts +256 -9
  29. package/lib/types/types/interfaces/i-drawing.d.ts +9 -1
  30. package/lib/umd/facade.js +1 -1
  31. package/lib/umd/index.js +26 -26
  32. package/package.json +7 -7
package/lib/umd/index.js CHANGED
@@ -1,26 +1,26 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("rxjs"),require("@univerjs/protocol"),require("rxjs/operators"),require("@wendellhu/redi"),require("@univerjs/themes")):typeof define==`function`&&define.amd?define([`exports`,`rxjs`,`@univerjs/protocol`,`rxjs/operators`,`@wendellhu/redi`,`@univerjs/themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore={},e.rxjs,e.UniverProtocol,e.rxjs.operators,e[`@wendellhu/redi`],e.UniverThemes))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t)=>{let n={};for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t||s(n,Symbol.toStringTag,{value:`Module`}),n},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:o(u(e)),m(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));let g=typeof global<`u`?global:typeof self<`u`?self:window;function _(){let e=new Map,t=0;typeof g.requestIdleCallback!=`function`&&(g.requestIdleCallback=function(n){let r=Date.now(),i=++t,a=setTimeout(function(){e.delete(i);let t=Math.max(0,50-(Date.now()-r));n({didTimeout:t===0,timeRemaining(){return t}})},1);return e.set(i,a),i}),typeof g.cancelIdleCallback!=`function`&&(g.cancelIdleCallback=function(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))})}function v(){typeof g.queueMicrotask!=`function`&&(g.queueMicrotask=function(e){Promise.resolve().then(e).catch(e=>{setTimeout(()=>{throw e},0)})})}function y(){typeof g.Array.prototype.findLastIndex!=`function`&&(g.Array.prototype.findLastIndex=function(e,t){if(this==null)throw TypeError(`Array.prototype.findLastIndex called on null or undefined`);if(typeof e!=`function`)throw TypeError(`callback must be a function`);let n=this.length>>>0;for(let r=n-1;r>=0;r--)if(r in this&&e.call(t,this[r],r,this))return r;return-1}),typeof g.Array.prototype.findLast!=`function`&&(g.Array.prototype.findLast=function(e,t){let n=this.findLastIndex(e,t);return n===-1?void 0:this[n]})}function b(){typeof g.String.prototype.at!=`function`&&(g.String.prototype.at=function(e){if(this==null)throw TypeError(`String.prototype.at called on null or undefined`);let t=this.length;if(e<0&&(e=t+e),!(e<0||e>=t))return this.charAt(e)})}function x(){_(),v(),y(),b()}function S(e){"@babel/helpers - typeof";return S=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},S(e)}function C(e,t){if(S(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(S(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function w(e){var t=C(e,`string`);return S(t)==`symbol`?t:t+``}function T(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){return e instanceof t.Subscription||e instanceof t.Subject||e&&`closed`in e&&e.unsubscribe!==void 0}function D(e){let t=!1;return e?E(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:D(()=>{})}var O=class{constructor(){T(this,`_disposables`,new Set)}add(e){let t=D(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},k=class{constructor(){T(this,`_disposed`,!1),T(this,`_collection`,new O)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},A=class extends k{constructor(...e){super(...e),T(this,`dispose$`,new t.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},j=class extends k{constructor(e){super(),this._rootDisposable=e,T(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},M=class extends k{};let N=new Set(`ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),P=RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function F(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:5173`)||e.startsWith(`localhost:5173`))return!0;if(P.test(e)){if(I(e))return!0;try{let t=new URL(R(e)).hostname.split(`.`).pop();if(t&&N.has(t))return!0}catch{return!1}}return!1}function I(e){return/^[a-zA-Z]+:\/\//.test(e)}function L(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function R(e){return I(e)?e:L(e)?`mailto://${e}`:`https://${e}`}function z(e){if(!e||typeof e!=`string`)return!1;try{let t=typeof window<`u`&&window.location?window.location.origin:`http://localhost`,n=new URL(e,t);return[`http:`,`https:`,`mailto:`].includes(n.protocol)}catch{return!1}}function ee(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function te(e,t){return B.getValueType(e)===B.getValueType(t)?B.isArray(e)?ne(e,t):B.isObject(e)?re(e,t):B.isDate(e)?e.getTime()===t.getTime():B.isRegExp(e)?e.toString()===t.toString():e===t:!1}function ne(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!te(r,i))return!1}return!0}function re(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(t,r))return!1;let n=e[r],i=t[r];if(!te(n,i))return!1}return!0}var B=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=navigator.platform===`Win32`||navigator.platform===`Windows`,n=navigator.platform===`Mac68K`||navigator.platform===`MacPPC`||navigator.platform===`Macintosh`||navigator.platform===`MacIntel`;if(n)return`Mac`;if(navigator.platform===`X11`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){if(e.indexOf(`Windows NT 5.0`)>-1||e.indexOf(`Windows 2000`)>-1)return`Windows 2000`;if(e.indexOf(`Windows NT 5.1`)>-1||e.indexOf(`Windows XP`)>-1)return`Windows XP`;if(e.indexOf(`Windows NT 5.2`)>-1||e.indexOf(`Windows 2003`)>-1)return`Windows 2003`;if(e.indexOf(`Windows NT 6.0`)>-1||e.indexOf(`Windows Vista`)>-1)return`Windows Vista`;if(e.indexOf(`Windows NT 6.1`)>-1||e.indexOf(`Windows 7`)>-1)return`Windows 7`;if(e.indexOf(`Windows NT 10`)>-1||e.indexOf(`Windows 10`)>-1)return`Windows 10`;if(e.indexOf(`Windows NT 11`)>-1||e.indexOf(`Windows 11`)>-1)return`Windows 11`}return`Unknown system`}static getBrowserType(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){RegExp(`MSIE (\\d+\\.\\d+);`).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static diffValue(e,t){return te(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n=t,r={};for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=e.deepClone(n[t]));return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}return t}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()===``:!1:!0}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isDate(e){return this.getValueType(e)===`[object Date]`}static isRegExp(e){return this.getValueType(e)===`[object RegExp]`}static isArray(e){return this.getValueType(e)===`[object Array]`}static isString(e){return this.getValueType(e)===`[object String]`}static isNumber(e){return this.getValueType(e)===`[object Number]`}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isEmptyObject(e){for(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return F(e)}static normalizeUrl(e){return R(e)}static topLevelDomainCombiningString(){return[...N].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function ie(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}let ae=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,oe=function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),se=function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),ce=function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),le=function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),ue=function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),de=function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),fe=function(e){return e.Date1900=`date1900`,e.Date1904=`date1904`,e}({}),pe=function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),me=function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),he=function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),ge=function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function _e(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}let ve=function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),ye=function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.ZH_HK=`zhHK`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e.PT_BR=`ptBR`,e.DE_DE=`deDE`,e.IT_IT=`itIT`,e.ID_ID=`idID`,e.PL_PL=`plPL`,e.AR_SA=`arSA`,e}({}),be={enUS:{name:`English`,tag:`en-US`,direction:`ltr`},frFR:{name:`Français`,tag:`fr-FR`,direction:`ltr`},zhCN:{name:`简体中文`,tag:`zh-CN`,direction:`ltr`},ruRU:{name:`Русский`,tag:`ru-RU`,direction:`ltr`},zhTW:{name:`繁體中文`,tag:`zh-TW`,direction:`ltr`},zhHK:{name:`繁體中文(香港)`,tag:`zh-HK`,direction:`ltr`},viVN:{name:`Tiếng Việt`,tag:`vi-VN`,direction:`ltr`},faIR:{name:`فارسی`,tag:`fa-IR`,direction:`rtl`,numberingSystem:`arabext`},jaJP:{name:`日本語`,tag:`ja-JP`,direction:`ltr`},koKR:{name:`한국어`,tag:`ko-KR`,direction:`ltr`},esES:{name:`Español`,tag:`es-ES`,direction:`ltr`},caES:{name:`Català`,tag:`ca-ES`,direction:`ltr`},skSK:{name:`Slovenčina`,tag:`sk-SK`,direction:`ltr`},ptBR:{name:`Português (Brasil)`,tag:`pt-BR`,direction:`ltr`},deDE:{name:`Deutsch`,tag:`de-DE`,direction:`ltr`},itIT:{name:`Italiano`,tag:`it-IT`,direction:`ltr`},idID:{name:`Bahasa Indonesia`,tag:`id-ID`,direction:`ltr`},plPL:{name:`Polski`,tag:`pl-PL`,direction:`ltr`},arSA:{name:`العربية`,tag:`ar-SA`,direction:`rtl`,numberingSystem:`arab`}},xe=function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Se=function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),Ce=function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),we=function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e}({}),Te=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),Ee=function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e[e.SINGLE_ACCOUNTING=18]=`SINGLE_ACCOUNTING`,e[e.DOUBLE_ACCOUNTING=19]=`DOUBLE_ACCOUNTING`,e}({}),De=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),Oe=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),ke=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),Ae=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),je=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),Me=function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),Ne=function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),Pe=function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),Fe=function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),Ie=function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({});var Le=`@univerjs/core`,Re=`1.0.0-rc.0`;function ze(e,t){let n=e.indexOf(t);return n>-1?(e.splice(n,1),!0):!1}function Be(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function Ve(e,t){let n=new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function He(e,t){for(let n=e.length-1;n>-1;n--){let r=e[n];if(t(r,n))return r}return null}function Ue(e,t){if(e.length===0)return e;let n=t%e.length;return e.slice(n).concat(e.slice(0,n))}function We(e,t){let n=new Map;return e.forEach(e=>{let r=t(e),i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(e)}),n}function Ge(e){return Array.isArray(e)?e:[e]}function Ke(e,t){t.forEach(t=>e.add(t))}function qe(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}var Je=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Ye=class extends Je{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};async function Xe(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function Ze(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}var Qe=typeof global==`object`&&global&&global.Object===Object&&global,$e=typeof self==`object`&&self&&self.Object===Object&&self,et=Qe||$e||Function(`return this`)(),tt=et.Symbol,nt=Object.prototype,rt=nt.hasOwnProperty,it=nt.toString,at=tt?tt.toStringTag:void 0;function ot(e){var t=rt.call(e,at),n=e[at];try{e[at]=void 0;var r=!0}catch{}var i=it.call(e);return r&&(t?e[at]=n:delete e[at]),i}var st=Object.prototype.toString;function ct(e){return st.call(e)}var lt=`[object Null]`,ut=`[object Undefined]`,dt=tt?tt.toStringTag:void 0;function ft(e){return e==null?e===void 0?ut:lt:dt&&dt in Object(e)?ot(e):ct(e)}function pt(e){return typeof e==`object`&&!!e}var mt=`[object Symbol]`;function ht(e){return typeof e==`symbol`||pt(e)&&ft(e)==mt}function gt(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var _t=Array.isArray,vt=1/0,yt=tt?tt.prototype:void 0,bt=yt?yt.toString:void 0;function xt(e){if(typeof e==`string`)return e;if(_t(e))return gt(e,xt)+``;if(ht(e))return bt?bt.call(e):``;var t=e+``;return t==`0`&&1/e==-vt?`-0`:t}var St=/\s/;function Ct(e){for(var t=e.length;t--&&St.test(e.charAt(t)););return t}var wt=/^\s+/;function Tt(e){return e&&e.slice(0,Ct(e)+1).replace(wt,``)}function Et(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Dt=NaN,Ot=/^[-+]0x[0-9a-f]+$/i,kt=/^0b[01]+$/i,At=/^0o[0-7]+$/i,jt=parseInt;function Mt(e){if(typeof e==`number`)return e;if(ht(e))return Dt;if(Et(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Et(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Tt(e);var n=kt.test(e);return n||At.test(e)?jt(e.slice(2),n?2:8):Ot.test(e)?Dt:+e}function Nt(e){return e}var Pt=`[object AsyncFunction]`,Ft=`[object Function]`,It=`[object GeneratorFunction]`,Lt=`[object Proxy]`;function Rt(e){if(!Et(e))return!1;var t=ft(e);return t==Ft||t==It||t==Pt||t==Lt}var zt=et[`__core-js_shared__`],Bt=function(){var e=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Vt(e){return!!Bt&&Bt in e}var Ht=Function.prototype.toString;function Ut(e){if(e!=null){try{return Ht.call(e)}catch{}try{return e+``}catch{}}return``}var Wt=/[\\^$.*+?()[\]{}|]/g,Gt=/^\[object .+?Constructor\]$/,Kt=Function.prototype,qt=Object.prototype,Jt=Kt.toString,Yt=qt.hasOwnProperty,Xt=RegExp(`^`+Jt.call(Yt).replace(Wt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Zt(e){return!Et(e)||Vt(e)?!1:(Rt(e)?Xt:Gt).test(Ut(e))}function Qt(e,t){return e==null?void 0:e[t]}function $t(e,t){var n=Qt(e,t);return Zt(n)?n:void 0}var en=Object.create,tn=function(){function e(){}return function(t){if(!Et(t))return{};if(en)return en(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function nn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function rn(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var an=800,on=16,sn=Date.now;function cn(e){var t=0,n=0;return function(){var r=sn(),i=on-(r-n);if(n=r,i>0){if(++t>=an)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function ln(e){return function(){return e}}var un=function(){try{var e=$t(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),dn=cn(un?function(e,t){return un(e,`toString`,{configurable:!0,enumerable:!1,value:ln(t),writable:!0})}:Nt),fn=9007199254740991,pn=/^(?:0|[1-9]\d*)$/;function mn(e,t){var n=typeof e;return t??=fn,!!t&&(n==`number`||n!=`symbol`&&pn.test(e))&&e>-1&&e%1==0&&e<t}function hn(e,t,n){t==`__proto__`&&un?un(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function gn(e,t){return e===t||e!==e&&t!==t}var _n=Object.prototype.hasOwnProperty;function vn(e,t,n){var r=e[t];(!(_n.call(e,t)&&gn(r,n))||n===void 0&&!(t in e))&&hn(e,t,n)}function yn(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?hn(n,s,c):vn(n,s,c)}return n}var bn=Math.max;function xn(e,t,n){return t=bn(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=bn(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),nn(e,this,s)}}function Sn(e,t){return dn(xn(e,t,Nt),e+``)}var Cn=9007199254740991;function wn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Cn}function Tn(e){return e!=null&&wn(e.length)&&!Rt(e)}function En(e,t,n){if(!Et(n))return!1;var r=typeof t;return(r==`number`?Tn(n)&&mn(t,n.length):r==`string`&&t in n)?gn(n[t],e):!1}function Dn(e){return Sn(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&En(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var On=Object.prototype;function kn(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||On)}function An(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var jn=`[object Arguments]`;function Mn(e){return pt(e)&&ft(e)==jn}var Nn=Object.prototype,Pn=Nn.hasOwnProperty,Fn=Nn.propertyIsEnumerable,In=Mn(function(){return arguments}())?Mn:function(e){return pt(e)&&Pn.call(e,`callee`)&&!Fn.call(e,`callee`)};function Ln(){return!1}var Rn=typeof e==`object`&&e&&!e.nodeType&&e,zn=Rn&&typeof module==`object`&&module&&!module.nodeType&&module,Bn=zn&&zn.exports===Rn?et.Buffer:void 0,Vn=(Bn?Bn.isBuffer:void 0)||Ln,Hn=`[object Arguments]`,Un=`[object Array]`,Wn=`[object Boolean]`,Gn=`[object Date]`,Kn=`[object Error]`,qn=`[object Function]`,Jn=`[object Map]`,Yn=`[object Number]`,Xn=`[object Object]`,Zn=`[object RegExp]`,Qn=`[object Set]`,$n=`[object String]`,er=`[object WeakMap]`,tr=`[object ArrayBuffer]`,nr=`[object DataView]`,rr=`[object Float32Array]`,ir=`[object Float64Array]`,ar=`[object Int8Array]`,or=`[object Int16Array]`,sr=`[object Int32Array]`,cr=`[object Uint8Array]`,lr=`[object Uint8ClampedArray]`,ur=`[object Uint16Array]`,dr=`[object Uint32Array]`,V={};V[rr]=V[ir]=V[ar]=V[or]=V[sr]=V[cr]=V[lr]=V[ur]=V[dr]=!0,V[Hn]=V[Un]=V[tr]=V[Wn]=V[nr]=V[Gn]=V[Kn]=V[qn]=V[Jn]=V[Yn]=V[Xn]=V[Zn]=V[Qn]=V[$n]=V[er]=!1;function fr(e){return pt(e)&&wn(e.length)&&!!V[ft(e)]}function pr(e){return function(t){return e(t)}}var mr=typeof e==`object`&&e&&!e.nodeType&&e,hr=mr&&typeof module==`object`&&module&&!module.nodeType&&module,gr=hr&&hr.exports===mr&&Qe.process,_r=function(){try{return hr&&hr.require&&hr.require(`util`).types||gr&&gr.binding&&gr.binding(`util`)}catch{}}(),vr=_r&&_r.isTypedArray,yr=vr?pr(vr):fr,br=Object.prototype.hasOwnProperty;function xr(e,t){var n=_t(e),r=!n&&In(e),i=!n&&!r&&Vn(e),a=!n&&!r&&!i&&yr(e),o=n||r||i||a,s=o?An(e.length,String):[],c=s.length;for(var l in e)(t||br.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||mn(l,c)))&&s.push(l);return s}function Sr(e,t){return function(n){return e(t(n))}}function Cr(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var wr=Object.prototype.hasOwnProperty;function Tr(e){if(!Et(e))return Cr(e);var t=kn(e),n=[];for(var r in e)r==`constructor`&&(t||!wr.call(e,r))||n.push(r);return n}function Er(e){return Tn(e)?xr(e,!0):Tr(e)}var Dr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Or=/^\w*$/;function kr(e,t){if(_t(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||ht(e)?!0:Or.test(e)||!Dr.test(e)||t!=null&&e in Object(t)}var Ar=$t(Object,`create`);function jr(){this.__data__=Ar?Ar(null):{},this.size=0}function Mr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Nr=`__lodash_hash_undefined__`,Pr=Object.prototype.hasOwnProperty;function Fr(e){var t=this.__data__;if(Ar){var n=t[e];return n===Nr?void 0:n}return Pr.call(t,e)?t[e]:void 0}var Ir=Object.prototype.hasOwnProperty;function Lr(e){var t=this.__data__;return Ar?t[e]!==void 0:Ir.call(t,e)}var Rr=`__lodash_hash_undefined__`;function zr(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Ar&&t===void 0?Rr:t,this}function Br(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Br.prototype.clear=jr,Br.prototype.delete=Mr,Br.prototype.get=Fr,Br.prototype.has=Lr,Br.prototype.set=zr;function Vr(){this.__data__=[],this.size=0}function Hr(e,t){for(var n=e.length;n--;)if(gn(e[n][0],t))return n;return-1}var Ur=Array.prototype.splice;function Wr(e){var t=this.__data__,n=Hr(t,e);return n<0?!1:(n==t.length-1?t.pop():Ur.call(t,n,1),--this.size,!0)}function Gr(e){var t=this.__data__,n=Hr(t,e);return n<0?void 0:t[n][1]}function Kr(e){return Hr(this.__data__,e)>-1}function qr(e,t){var n=this.__data__,r=Hr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Jr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Jr.prototype.clear=Vr,Jr.prototype.delete=Wr,Jr.prototype.get=Gr,Jr.prototype.has=Kr,Jr.prototype.set=qr;var Yr=$t(et,`Map`);function Xr(){this.size=0,this.__data__={hash:new Br,map:new(Yr||Jr),string:new Br}}function Zr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Qr(e,t){var n=e.__data__;return Zr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function $r(e){var t=Qr(this,e).delete(e);return this.size-=+!!t,t}function ei(e){return Qr(this,e).get(e)}function ti(e){return Qr(this,e).has(e)}function ni(e,t){var n=Qr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ri(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ri.prototype.clear=Xr,ri.prototype.delete=$r,ri.prototype.get=ei,ri.prototype.has=ti,ri.prototype.set=ni;var ii=`Expected a function`;function ai(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ii);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ai.Cache||ri),n}ai.Cache=ri;var oi=500;function si(e){var t=ai(e,function(e){return n.size===oi&&n.clear(),e}),n=t.cache;return t}var ci=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,li=/\\(\\)?/g,ui=si(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(ci,function(e,n,r,i){t.push(r?i.replace(li,`$1`):n||e)}),t});function di(e){return e==null?``:xt(e)}function fi(e,t){return _t(e)?e:kr(e,t)?[e]:ui(di(e))}var pi=1/0;function mi(e){if(typeof e==`string`||ht(e))return e;var t=e+``;return t==`0`&&1/e==-pi?`-0`:t}function hi(e,t){t=fi(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[mi(t[n++])];return n&&n==r?e:void 0}function gi(e,t,n){var r=e==null?void 0:hi(e,t);return r===void 0?n:r}var _i=Sr(Object.getPrototypeOf,Object),vi=`[object Object]`,yi=Function.prototype,bi=Object.prototype,xi=yi.toString,Si=bi.hasOwnProperty,Ci=xi.call(Object);function wi(e){if(!pt(e)||ft(e)!=vi)return!1;var t=_i(e);if(t===null)return!0;var n=Si.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&xi.call(n)==Ci}function Ti(){this.__data__=new Jr,this.size=0}function Ei(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Di(e){return this.__data__.get(e)}function Oi(e){return this.__data__.has(e)}var ki=200;function Ai(e,t){var n=this.__data__;if(n instanceof Jr){var r=n.__data__;if(!Yr||r.length<ki-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ri(r)}return n.set(e,t),this.size=n.size,this}function ji(e){var t=this.__data__=new Jr(e);this.size=t.size}ji.prototype.clear=Ti,ji.prototype.delete=Ei,ji.prototype.get=Di,ji.prototype.has=Oi,ji.prototype.set=Ai;var Mi=typeof e==`object`&&e&&!e.nodeType&&e,Ni=Mi&&typeof module==`object`&&module&&!module.nodeType&&module,Pi=Ni&&Ni.exports===Mi?et.Buffer:void 0,Fi=Pi?Pi.allocUnsafe:void 0;function Ii(e,t){if(t)return e.slice();var n=e.length,r=Fi?Fi(n):new e.constructor(n);return e.copy(r),r}var Li=et.Uint8Array;function Ri(e){var t=new e.constructor(e.byteLength);return new Li(t).set(new Li(e)),t}function zi(e,t){var n=t?Ri(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Bi(e){return typeof e.constructor==`function`&&!kn(e)?tn(_i(e)):{}}function Vi(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Hi=Vi(),Ui=function(){return et.Date.now()},Wi=`Expected a function`,Gi=Math.max,Ki=Math.min;function qi(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Wi);t=Mt(t)||0,Et(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Gi(Mt(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?Ki(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Ui();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Ui())}function x(){var e=Ui(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Ji(e,t,n){(n!==void 0&&!gn(e[t],n)||n===void 0&&!(t in e))&&hn(e,t,n)}function Yi(e){return pt(e)&&Tn(e)}function Xi(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}function Zi(e){return yn(e,Er(e))}function Qi(e,t,n,r,i,a,o){var s=Xi(e,n),c=Xi(t,n),l=o.get(c);if(l){Ji(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=_t(c),p=!f&&Vn(c),m=!f&&!p&&yr(c);u=c,f||p||m?_t(s)?u=s:Yi(s)?u=rn(s):p?(d=!1,u=Ii(c,!0)):m?(d=!1,u=zi(c,!0)):u=[]:wi(c)||In(c)?(u=s,In(s)?u=Zi(s):(!Et(s)||Rt(s))&&(u=Bi(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Ji(e,n,u)}function $i(e,t,n,r,i){e!==t&&Hi(t,function(a,o){if(i||=new ji,Et(a))Qi(e,t,o,n,$i,r,i);else{var s=r?r(Xi(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Ji(e,o,s)}},Er)}var ea=Dn(function(e,t,n,r){$i(e,t,n,r)}),ta=Dn(function(e,t,n){$i(e,t,n)});function na(e,t,n,r){if(!Et(e))return e;t=fi(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=mi(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=Et(u)?u:mn(t[i+1])?[]:{})}vn(s,c,l),s=s[c]}return e}function ra(e,t,n){return e==null?e:na(e,t,n)}function ia(e,t,n,r){return r=typeof r==`function`?r:void 0,e==null?e:na(e,t,n,r)}let aa=(0,i.createIdentifier)(`univer.config-service`);var oa=class{constructor(){T(this,`_configChanged$`,new t.Subject),T(this,`configChanged$`,this._configChanged$.asObservable()),T(this,`_config`,new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){let{merge:r=!1}=n||{},i=this._config.get(e)??{};i=r?ta(i,t):t,this._config.set(e,i),this._configChanged$.next({[e]:i})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new t.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,e)&&n.next(this._config.get(e));let r=this.configChanged$.pipe((0,t.filter)(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(t=>n.next(t[e]));return()=>r.unsubscribe()})}};let sa=(0,i.createIdentifier)(`univer.context-service`);var ca=class extends k{constructor(...e){super(...e),T(this,`_contextChanged$`,new t.Subject),T(this,`contextChanged$`,this._contextChanged$.asObservable()),T(this,`_contextMap`,new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){return this._contextMap.get(e)??!1}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new t.Observable(n=>{let r=this._contextChanged$.pipe((0,t.filter)(t=>t[e]!==void 0)).subscribe(t=>n.next(t[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}};let la=function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({}),ua=(0,i.createIdentifier)(`univer.log`);var da=class extends k{constructor(...e){super(...e),T(this,`_logLevel`,3),T(this,`_deduction`,new Set)}dispose(){super.dispose(),this._logLevel=3,this._deduction.clear()}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}deprecate(...e){this._logLevel>=2&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=fa(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function fa(...e){return e.map(e=>JSON.stringify(e)).join(``)}function H(e,t){return function(n,r){t(n,r,e)}}function pa(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let ma=`command.logExecution`,ha=function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({}),ga=(0,i.createIdentifier)(`univer.core.command-service`);var _a=class{constructor(){T(this,`_commands`,new Map),T(this,`_commandTypes`,new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),D(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};let va={id:`nil`,type:0,handler:()=>!0},ya=class extends k{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,T(this,`_commandRegistry`,void 0),T(this,`_beforeCommandExecutionListeners`,[]),T(this,`_commandExecutedListeners`,[]),T(this,`_collabMutationListeners`,[]),T(this,`_multiCommandDisposables`,new Map),T(this,`_commandExecutingLevel`,0),T(this,`_commandExecutionStack`,[]),this._commandRegistry=new _a,this.registerCommand(va)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}_warnCommandSkippedAfterDisposed(e){this._logService.warn(`[CommandService]`,`command "${e}" skipped because CommandService is disposed.`)}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),D(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),D(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),D(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=await this._execute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Je)return!1;throw e}}syncExecuteCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=this._syncExecute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Je)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),D(()=>ze(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(t){let e=t[0];if(!(e instanceof ba))throw TypeError(`Command has registered as a single command.`);n=e}else{n=new ba(e.id);let t=new O;t.add(this._commandRegistry.registerCommand(n)),t.add(D(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}let r=n.registerImplementation(e);return D(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}_attachMutationTrigger(e,t){if(e.type!==2||!t)return;let n=He(this._commandExecutionStack,e=>e.type===0);if(n){this._setMutationTrigger(t,n.id);return}if(`trigger`in t&&t.trigger!==void 0)return;let r=He(this._commandExecutionStack,e=>e.type===1);r&&this._setMutationTrigger(t,r.id)}_setMutationTrigger(e,t){Object.assign(e,{trigger:t})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};ya=pa([H(0,(0,i.Inject)(i.Injector)),H(1,ua),H(2,aa)],ya);var ba=class{constructor(e){this.id=e,T(this,`name`,void 0),T(this,`multi`,!0),T(this,`type`,0),T(this,`priority`,0),T(this,`_implementations`,[]),T(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(ua),r=e.get(sa),a=e.get(i.Injector);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),D(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function xa(e,t,n){return Ze(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function Sa(e,t,n){return Xe(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function Ca(e){return new t.Observable(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function wa(e){return function(n){return n.pipe((0,t.takeWhile)(t=>!e(t),!0))}}function Ta(e=0){return n=>{let r=[];return n.pipe((0,t.tap)(e=>r.push(e)),(0,t.debounceTime)(e),(0,t.map)(()=>r),(0,t.tap)(()=>r=[]))}}function Ea(e){let n=new t.ReplaySubject(1);return setTimeout(()=>n.next(),e),n.pipe((0,t.take)(1))}function Da(e,n){let r=new t.BehaviorSubject(n),i=e.subscribe(r),a=r.complete.bind(r);return r.complete=()=>{i.unsubscribe(),a()},r}let Oa=e=>new Promise(n=>{(0,t.merge)(Ca(e.onCommandExecuted.bind(e)).pipe((0,r.filter)(([e])=>e.type===2)),(0,t.timer)(300)).pipe((0,r.debounceTime)(16),(0,r.first)()).subscribe(()=>{n()})});function ka(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function Aa(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function ja(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function Ma(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?ka(e,t):ja(e,t),n){let t=e[r];return e.indexOf(t)}return r}function Na(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}function Pa(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}let Fa={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchealmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],darkyellow:[139,128,0],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midbightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]};var Ia=class e{static mix(t,n,r){r=Math.min(1,Math.max(0,r));let i=new e(t).toRgb(),a=new e(n).toRgb(),o=i.a??1,s=a.a??1,c={r:(a.r-i.r)*r+i.r,g:(a.g-i.g)*r+i.g,b:(a.b-i.b)*r+i.b,a:(s-o)*r+o};return new e(c)}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(T(this,`_color`,void 0),T(this,`_rgbColor`,void 0),T(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=za(t);if(n==null){this._setNullColor();return}this._color=n;let r=Wa(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[La(Math.round(t).toString(16)),La(Math.round(n).toString(16)),La(Math.round(r).toString(16)),La(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Ya(this.toRgb())}toHsl(){return Ja(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=Ra(e),t=Ra(t),n=Ra(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){return this._color.a??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}}};let La=e=>e.length===1?`0${e}`:e,Ra=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),za=e=>{if(Za(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(Fa[t]){let e=Fa[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(t.startsWith(`#`))return Ba(t);if(t.startsWith(`rgb`))return Va(t);if(t.startsWith(`hsl`))return Ha(t);if(t.startsWith(`hsv`))return Ua(t)},Ba=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Va=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ha=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ua=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Wa=e=>{let t=za(e);if(t!=null)return`r`in t?t:`l`in t?Ka(t):qa(t)},Ga=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Ka=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=Ga(s,e,t+1/3),a=Ga(s,e,t),o=Ga(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},qa=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Ja=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4;break}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Ya=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4;break}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Xa=e=>e==null,Za=e=>!Xa(e)&&typeof e==`object`;function Qa(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function $a(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}let eo=function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({});function to(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.si!==void 0||e.custom!==void 0)}function no(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return 1;if(typeof e.v==`number`)return 2;if(typeof e.v==`boolean`)return 3}function ro(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null)}function io(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let ao=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),oo=function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function so(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let co=function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),lo=function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({}),uo=function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({}),fo={Office:{4:`#4472C4`,5:`#ED7D31`,6:`#A5A5A5`,7:`#70AD47`,8:`#5B9BD5`,9:`#70AD47`,0:`#000000`,2:`#44546A`,1:`#FFFFFF`,3:`#E7E6E6`,10:`#0563C1`,11:`#954F72`}},po=`general`,mo=`hash`,ho=`zero`,go=`qmark`,_o=`slash`,vo=`group`,yo=`scale`,bo=`comma`,xo=`break`,So=`text`,Co=`plus`,wo=`minus`,To=`point`,Eo=`space`,Do=`percent`,Oo=`digit`,ko=`calendar`,Ao=`error`,jo=`datetime`,Mo=`duration`,No=`condition`,Po=`dbnum`,Fo=`natnum`,Io=`locale`,Lo=`color`,Ro=`modifier`,zo=`ampm`,Bo=`escaped`,Vo=`string`,Ho=`skip`,Uo=`fill`,Wo=`paren`,Go=`char`,Ko=`#000000.#FFFFFF.#FF0000.#00FF00.#0000FF.#FFFF00.#FF00FF.#00FFFF.#800000.#008000.#000080.#808000.#800080.#008080.#C0C0C0.#808080.#9999FF.#993366.#FFFFCC.#CCFFFF.#660066.#FF8080.#0066CC.#CCCCFF.#000080.#FF00FF.#FFFF00.#00FFFF.#800080.#800000.#008080.#0000FF.#00CCFF.#CCFFFF.#CCFFCC.#FFFF99.#99CCFF.#FF99CC.#CC99FF.#FFCC99.#3366FF.#33CCCC.#99CC00.#FFCC00.#FF9900.#FF6600.#666699.#969696.#003366.#339966.#003300.#333300.#993300.#993366.#333399.#333333`.split(`.`),qo=`¤.$.£.¥.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿`.split(`.`),Jo=RegExp(`[${qo.join(``)}]`);function Yo(e){if(!Number.isFinite(e))throw RangeError(`decimalFromNumber requires a finite number`);let t=e<0||Object.is(e,-0);if(e===0)return{negative:t,digits:`0`,exponent:0};let[n,r]=Math.abs(e).toExponential(14).split(`e`);return{negative:t,digits:n.replace(`.`,``).replace(/0+$/,``)||`0`,exponent:Number(r)}}function Xo(e,t){return{...e,exponent:e.digits===`0`?0:e.exponent+Math.trunc(t)}}function Zo(e){let t=[...e];for(let e=t.length-1;e>=0;e--){if(t[e]!==`9`)return t[e]=String(Number(t[e])+1),t.join(``);t[e]=`0`}return`1${t.join(``)}`}function Qo(e,t=0){let n=Math.trunc(t),r=e.exponent+1+n,i;if(r<0?i=`0`:r===0?i=e.digits[0]>=`5`?`1`:`0`:(i=e.digits.slice(0,r).padEnd(r,`0`)||`0`,r<e.digits.length&&e.digits[r]>=`5`&&(i=Zo(i))),/^0+$/.test(i))return{negative:e.negative,integer:`0`,fraction:``,zero:!0};if(n<=0)return{negative:e.negative,integer:i+`0`.repeat(-n),fraction:``,zero:!1};let a=i.padStart(n+1,`0`);return{negative:e.negative,integer:a.slice(0,-n),fraction:a.slice(-n).replace(/0+$/,``),zero:!1}}function $o(e){let t=Number(e.fraction?`${e.integer}.${e.fraction}`:e.integer);return e.negative&&!e.zero?-t:t}function es(e){return`${e.negative&&!e.zero?`-`:``}${e.integer}${e.fraction?`.${e.fraction}`:``}`}function ts(e,t,n,r){if(e.digits===`0`)return{exponent:0,rounded:Qo(e,r)};let i=t>1?Math.floor(e.exponent/t)*t:e.exponent;n||i++;let a=Qo(Xo(e,-i),r);return t===1&&a.integer.length>1&&(i++,a=Qo(Xo(e,-i),r)),{exponent:i,rounded:a}}let ns=Object.freeze({1078:`af`,1052:`sq`,1118:`am`,5121:`ar_DZ`,15361:`ar_BH`,3073:`ar_EG`,2049:`ar_IQ`,11265:`ar_JO`,13313:`ar_KW`,12289:`ar_LB`,4097:`ar_LY`,6145:`ar_MA`,8193:`ar_OM`,16385:`ar_QA`,1025:`ar_SA`,10241:`ar_SY`,7169:`ar_TN`,14337:`ar_AE`,9217:`ar_YE`,1067:`hy`,1101:`as`,2092:`az_AZ`,1068:`az_AZ`,1069:`eu`,1059:`be`,2117:`bn`,1093:`bn_IN`,5146:`bs`,1026:`bg`,1109:`my`,1027:`ca`,2052:`zh_CN`,3076:`zh_HK`,5124:`zh_MO`,4100:`zh_SG`,1028:`zh_TW`,1050:`hr`,1029:`cs`,1030:`da`,1125:`dv`,2067:`nl_BE`,1043:`nl_NL`,1126:`bin`,3081:`en_AU`,10249:`en_BZ`,4105:`en_CA`,9225:`en_CB`,2057:`en_GB`,16393:`en_IN`,6153:`en_IE`,8201:`en_JM`,5129:`en_NZ`,13321:`en_PH`,7177:`en_ZA`,11273:`en_TT`,1033:`en_US`,12297:`en_ZW`,1061:`et`,1071:`mk`,1080:`fo`,1065:`fa`,1124:`fil`,1035:`fi`,2060:`fr_BE`,11276:`fr_CM`,3084:`fr_CA`,9228:`fr_CG`,12300:`fr_CI`,1036:`fr_FR`,5132:`fr_LU`,13324:`fr_ML`,6156:`fr_MC`,14348:`fr_MA`,10252:`fr_SN`,4108:`fr_CH`,7180:`fr`,1122:`fy_NL`,2108:`gd_IE`,1084:`gd`,1110:`gl`,1079:`ka`,3079:`de_AT`,1031:`de_DE`,5127:`de_LI`,4103:`de_LU`,2055:`de_CH`,1032:`el`,1140:`gn`,1095:`gu`,1279:`en`,1037:`he`,1081:`hi`,1038:`hu`,1039:`is`,1136:`ig_NG`,1057:`id`,1040:`it_IT`,2064:`it_CH`,1041:`ja`,1099:`kn`,1120:`ks`,1087:`kk`,1107:`km`,1111:`kok`,1042:`ko`,1088:`ky`,1108:`lo`,1142:`la`,1062:`lv`,1063:`lt`,2110:`ms_BN`,1086:`ms_MY`,1100:`ml`,1082:`mt`,1112:`mni`,1153:`mi`,1102:`mr`,1104:`mn`,2128:`mn`,1121:`ne`,1044:`no_NO`,2068:`no_NO`,1096:`or`,1045:`pl`,1046:`pt_BR`,2070:`pt_PT`,1094:`pa`,1047:`rm`,2072:`ro_MO`,1048:`ro_RO`,1049:`ru`,2073:`ru_MO`,1083:`se`,1103:`sa`,3098:`sr_SP`,2074:`sr_SP`,1072:`st`,1074:`tn`,1113:`sd`,1115:`si`,1051:`sk`,1060:`sl`,1143:`so`,1070:`sb`,11274:`es_AR`,16394:`es_BO`,13322:`es_CL`,9226:`es_CO`,5130:`es_CR`,7178:`es_DO`,12298:`es_EC`,17418:`es_SV`,4106:`es_GT`,18442:`es_HN`,2058:`es_MX`,19466:`es_NI`,6154:`es_PA`,15370:`es_PY`,10250:`es_PE`,20490:`es_PR`,1034:`es_ES`,14346:`es_UY`,8202:`es_VE`,1089:`sw`,2077:`sv_FI`,1053:`sv_SE`,1114:`syc`,1064:`tg`,1097:`ta`,1092:`tt`,1098:`te`,1054:`th`,1105:`bo`,1073:`ts`,1055:`tr`,1090:`tk`,1058:`uk`,1056:`ur`,2115:`uz_UZ`,1091:`uz_UZ`,1075:`ve`,1066:`vi`,1106:`cy`,1076:`xh`,1085:`yi`,1077:`zu`}),rs=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,is={},U=(e,t=``)=>e.replace(/~/g,t).split(`;`),W=(e,t=0,n=0)=>(e.mmm||=t<1?e.mmmm.concat():e.mmmm.map(e=>{let n=e.slice(0,t%10);return n+(t<10||e===n?``:`.`)}),e.ddd||=n<1?e.dddd.concat():e.dddd.map(e=>{let t=e.slice(0,n%10);return t+(n<10||e===t?``:`.`)}),!e.mmm6&&e.mmmm6&&(e.mmm6=e.mmmm6),e),as={group:`\xA0`,decimal:`.`,positive:`+`,negative:`-`,percent:`%`,exponent:`E`,nan:`NaN`,infinity:`∞`,ampm:U(`AM;PM`),mmmm6:U(`Muharram;Safar;Rabiʻ I;Rabiʻ II;Jumada I;Jumada II;Rajab;Shaʻban;Ramadan;Shawwal;Dhuʻl-Qiʻdah;Dhuʻl-Hijjah`),mmm6:U(`Muh.;Saf.;Rab. I;Rab. II;Jum. I;Jum. II;Raj.;Sha.;Ram.;Shaw.;Dhuʻl-Q.;Dhuʻl-H.`),mmmm:U(`January;February;March;April;May;June;July;August;September;October;November;December`),mmm:U(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec`),dddd:U(`Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday`),ddd:U(`Sun;Mon;Tue;Wed;Thu;Fri;Sat`),bool:U(`TRUE;FALSE`),preferMDY:!1};function os(e){let t=rs.exec(e);if(!t)throw SyntaxError(`Malformed locale: ${e}`);return{lang:t[1]+(t[2]?`_${t[2]}`:``),language:t[1],territory:t[2]||``}}function ss(e){if(typeof e==`number`)return ns[e&65535]||null;let t=Number.parseInt(e,16);return Number.isFinite(t)&&ns[t&65535]?ns[t&65535]||null:rs.test(e)?e:null}function cs(e){let t=ss(e),n=null;if(t){let e=os(t);n=is[e.lang]||is[e.language]||null}return n}function ls(e){return Object.assign({},as,e)}function G(e,t){let n=typeof t==`object`?t:os(t);return is[n.lang]=ls(e),n.language!==n.lang&&!is[n.language]&&(is[n.language]=ls(e)),is[n.lang]}let us=ls({group:`,`,preferMDY:!0});us.isDefault=!0,G({group:`,`,ampm:U(`上午;下午`),mmmm:U(`一月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月`),mmm:U(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:U(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:U(`周日;周一;周二;周三;周四;周五;周六`)},`zh_CN`);let ds={group:`,`,ampm:U(`上午;下午`),mmmm:U(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),mmm:U(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:U(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:U(`周日;周一;周二;周三;周四;周五;周六`)};G({...ds,nan:`非數值`,dddd:U(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_TW`),G({...ds,dddd:U(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_HK`),G({...ds,ampm:U(`午前;午後`),dddd:U(`日~;月~;火~;水~;木~;金~;土~`,`曜日`),ddd:U(`日;月;火;水;木;金;土`)},`ja`),G({group:`,`,ampm:U(`오전;오후`),mmmm:U(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),mmm:U(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),dddd:U(`일요일;월요일;화요일;수요일;목요일;금요일;토요일`),ddd:U(`일;월;화;수;목;금;토`)},`ko`),G({group:`,`,ampm:U(`ก่อนเที่ยง;หลังเที่ยง`),mmmm:U(`มกร~;กุมภาพันธ์;มีน~;เมษายน;พฤษภ~;มิถุนายน;กรกฎ~;สิงห~;กันยายน;ตุล~;พฤศจิกายน;ธันว~`,`าคม`),mmm:U(`ม.ค.;ก.พ.;มี.ค.;เม.ย.;พ.ค.;มิ.ย.;ก.ค.;ส.ค.;ก.ย.;ต.ค.;พ.ย.;ธ.ค.`),dddd:U(`วันอาทิตย์;วันจันทร์;วันอังคาร;วันพุธ;วันพฤหัสบดี;วันศุกร์;วันเสาร์`),ddd:U(`อา.;จ.;อ.;พ.;พฤ.;ศ.;ส.`)},`th`),G(W({decimal:`,`,ampm:U(`dop.;odp.`),mmmm:U(`ledna;února;března;dubna;května;června;července;srpna;září;října;listopadu;prosince`),mmm:U(`I;II;III;IV;V;VI;VII;VIII;IX;X;XI;XII`),dddd:U(`neděle;pondělí;úterý;středa;čtvrtek;pátek;sobota`),bool:U(`PRAVDA;NEPRAVDA`)},-1,2),`cs`),G(W({group:`.`,decimal:`,`,mmmm:U(`januar;februar;marts;april;maj;juni;juli;august;september;oktober;november;december`),dddd:U(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:U(`SAND;FALSK`)},13,13),`da`),G(W({group:`.`,decimal:`,`,ampm:U(`a.m.;p.m.`),mmmm:U(`januari;februari;maart;april;mei;juni;juli;augustus;september;oktober;november;december`),mmm:U(`jan.;feb.;mrt.;apr.;mei;jun.;jul.;aug.;sep.;okt.;nov.;dec.`),dddd:U(`zondag;maandag;dinsdag;woensdag;donderdag;vrijdag;zaterdag`),bool:U(`WAAR;ONWAAR`)},-1,2),`nl`),G({group:`,`,preferMDY:!0},`en`),G({group:`,`,preferMDY:!0},`en_US`),G({group:`,`},`en_AU`),G({group:`,`},`en_CA`),G({group:`,`},`en_GB`),G({group:`,`,mmm:U(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sept;Oct;Nov;Dec`)},`en_IE`),G(W({decimal:`,`,nan:`epäluku`,ampm:U(`ap.;ip.`),mmmm:U(`tammi~;helmi~;maalis~;huhti~;touko~;kesä~;heinä~;elo~;syys~;loka~;marras~;joulu~`,`kuuta`),mmm:U(`tammik.;helmik.;maalisk.;huhtik.;toukok.;kesäk.;heinäk.;elok.;syysk.;lokak.;marrask.;jouluk.`),dddd:U(`sunnun~;maanan~;tiis~;keskiviikkona;tors~;perjan~;lauan~`,`taina`),bool:U(`TOSI;EPÄTOSI`)},-1,2),`fi`);let fs=W({group:` `,decimal:`,`,mmmm:U(`janvier;février;mars;avril;mai;juin;juillet;août;septembre;octobre;novembre;décembre`),mmm:U(`janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.`),dddd:U(`~manche;lun~;mar~;mercre~;jeu~;vendre~;same~`,`di`),bool:U(`VRAI;FAUX`)},-1,13);G({...fs},`fr`),G({...fs,mmm:U(`janv.;févr.;mars;avr.;mai;juin;juill.;août;sept.;oct.;nov.;déc.`)},`fr_CA`),G({group:`'`,decimal:`.`,...fs},`fr_CH`);let ps=W({mmmm:U(`Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember`),mmm:U(`Jan.;Feb.;März;Apr.;Mai;Juni;Juli;Aug.;Sept.;Okt.;Nov.;Dez.`),dddd:U(`Sonn~;Mon~;Diens~;Mittwoch;Donners~;Frei~;Sams~`,`tag`),bool:U(`WAHR;FALSCH`)},-1,12);G({group:`.`,decimal:`,`,...ps},`de`),G({group:`'`,decimal:`.`,...ps},`de_CH`),G(W({group:`.`,decimal:`,`,ampm:U(`π.μ.;μ.μ.`),mmmm:U(`Ιανουαρ~;Φεβρουαρ~;Μαρτ~;Απριλ~;Μαΐου;Ιουν~;Ιουλ~;Αυγούστου;Σεπτεμβρ~;Οκτωβρ~;Νοεμβρ~;Δεκεμβρ~`,`ίου`),mmm:U(`Ιαν;Φεβ;Μαρ;Απρ;Μαΐ;Ιουν;Ιουλ;Αυγ;Σεπ;Οκτ;Νοε;Δεκ`),dddd:U(`Κυριακή;Δευτέρα;Τρίτη;Τετάρτη;Πέμπτη;Παρασκευή;Σάββατο`)},-1,3),`el`),G({decimal:`,`,ampm:U(`de.;du.`),mmmm:U(`január;február;március;április;május;június;július;augusztus;szeptember;október;november;december`),mmm:U(`jan.;febr.;márc.;ápr.;máj.;jún.;júl.;aug.;szept.;okt.;nov.;dec.`),dddd:U(`vasárnap;hétfő;kedd;szerda;csütörtök;péntek;szombat`),ddd:U(`V;H;K;Sze;Cs;P;Szo`),bool:U(`IGAZ;HAMIS`)},`hu`),G(W({group:`.`,decimal:`,`,ampm:U(`f.h.;e.h.`),mmmm:U(`janúar;febrúar;mars;apríl;maí;júní;júlí;ágúst;september;október;nóvember;desember`),dddd:U(`sunnu~;mánu~;þriðju~;miðviku~;fimmtu~;föstu~;laugar~`,`dagur`)},13,13),`is`),G(W({group:`.`,decimal:`,`,mmmm:U(`Januari;Februari;Maret;April;Mei;Juni;Juli;Agustus;September;Oktober;November;Desember`),dddd:U(`Minggu;Senin;Selasa;Rabu;Kamis;Jumat;Sabtu`)},3,3),`id`);let ms=W({mmmm:U(`gennaio;febbraio;marzo;aprile;maggio;giugno;luglio;agosto;settembre;ottobre;novembre;dicembre`),dddd:U(`domenica;lunedì;martedì;mercoledì;giovedì;venerdì;sabato`),bool:U(`VERO;FALSO`)},3,3);G({group:`.`,decimal:`,`,...ms},`it`),G({group:`'`,decimal:`.`,...ms},`it_CH`);let hs={decimal:`,`,ampm:U(`a.m.;p.m.`),mmmm:U(`januar;februar;mars;april;mai;juni;juli;august;september;oktober;november;desember`),mmm:U(`jan.;feb.;mar.;apr.;mai;jun.;jul.;aug.;sep.;okt.;nov.;des.`),dddd:U(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:U(`SANN;USANN`)};G(W({...hs},-1,13),`nb`),G(W({...hs},-1,13),`no`),G(W({decimal:`,`,mmmm:U(`stycznia;lutego;marca;kwietnia;maja;czerwca;lipca;sierpnia;września;października;listopada;grudnia`),dddd:U(`niedziela;poniedziałek;wtorek;środa;czwartek;piątek;sobota`),ddd:U(`niedz.;pon.;wt.;śr.;czw.;pt.;sob.`),bool:U(`PRAWDA;FAŁSZ`)},3,-1),`pl`);let gs={group:`.`,decimal:`,`,mmmm:U(`janeiro;fevereiro;março;abril;maio;junho;julho;agosto;setembro;outubro;novembro;dezembro`),dddd:U(`domingo;segunda-feira;terça-feira;quarta-feira;quinta-feira;sexta-feira;sábado`),bool:U(`VERDADEIRO;FALSO`)};G(W(gs,13,13),`pt`),G(W(gs,13,13),`pt_BR`),G({decimal:`,`,nan:`не\xA0число`,mmmm:U(`января;февраля;марта;апреля;мая;июня;июля;августа;сентября;октября;ноября;декабря`),mmm:U(`янв.;февр.;мар.;апр.;мая;июн.;июл.;авг.;сент.;окт.;нояб.;дек.`),dddd:U(`воскресенье;понедельник;вторник;среда;четверг;пятница;суббота`),ddd:U(`вс;пн;вт;ср;чт;пт;сб`),mmmm6:U(`рамадан;шавваль;зуль-каада;зуль-хиджжа;мухаррам;раби-уль-авваль;раби-уль-ахир;джумад-уль-авваль;джумад-уль-ахир;раджаб;шаабан;рамадан`),mmm6:U(`рам.;шав.;зуль-к.;зуль-х.;мух.;раб. I;раб. II;джум. I;джум. II;радж.;шааб.;рам.`),bool:U(`ИСТИНА;ЛОЖЬ`)},`ru`),G(W({decimal:`,`,mmmm:U(`januára;februára;marca;apríla;mája;júna;júla;augusta;septembra;októbra;novembra;decembra`),dddd:U(`nedeľa;pondelok;utorok;streda;štvrtok;piatok;sobota`)},3,2),`sk`);let _s={group:`.`,decimal:`,`,ampm:U(`a.\xA0m.;p.\xA0m.`),mmmm:U(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;septiem~;octu~;noviem~;diciem~`,`bre`),mmm:U(`ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic`),dddd:U(`domingo;lunes;martes;miércoles;jueves;viernes;sábado`),ddd:U(`dom;lun;mar;mié;jue;vie;sáb`),bool:U(`VERDADERO;FALSO`)},vs=U(`ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic`),ys=U(`ene.;feb.;mar.;abr.;may.;jun.;jul.;ago.;sept.;oct.;nov.;dic.`);G({..._s},`es`),G({..._s},`es_AR`),G({..._s},`es_BO`),G({..._s},`es_CL`),G({..._s},`es_CO`),G({..._s},`es_EC`),G({..._s,mmm:vs,ampm:U(`a.m.;p.m.`)},`es_MX`),G({..._s,mmm:ys},`es_PY`),G({..._s,mmm:ys},`es_UY`),G({..._s,mmm:ys,mmmm:U(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;setiembre;octubre;noviembre;diciembre`)},`es_VE`),G({decimal:`,`,ampm:U(`fm;em`),mmmm:U(`januari;februari;mars;april;maj;juni;juli;augusti;september;oktober;november;december`),mmm:U(`jan.;feb.;mars;apr.;maj;juni;juli;aug.;sep.;okt.;nov.;dec.`),dddd:U(`sön~;mån~;tis~;ons~;tors~;fre~;lör~`,`dag`),ddd:U(`sön;mån;tis;ons;tors;fre;lör`)},`sv`),G(W({group:`.`,decimal:`,`,ampm:U(`ÖÖ;ÖS`),mmmm:U(`Ocak;Şubat;Mart;Nisan;Mayıs;Haziran;Temmuz;Ağustos;Eylül;Ekim;Kasım;Aralık`),mmm:U(`Oca;Şub;Mar;Nis;May;Haz;Tem;Ağu;Eyl;Eki;Kas;Ara`),dddd:U(`Pazar;Pazartesi;Salı;Çarşamba;Perşembe;Cuma;Cumartesi`),ddd:U(`Paz;Pzt;Sal;Çar;Per;Cum;Cmt`),bool:U(`DOĞRU;YANLIŞ`)},3,-1),`tr`),G({group:`,`,ampm:U(`yb;yh`),mmmm:U(`Ionawr;Chwefror;Mawrth;Ebrill;Mai;Mehefin;Gorffennaf;Awst;Medi;Hydref;Tachwedd;Rhagfyr`),mmm:U(`Ion;Chwef;Maw;Ebr;Mai;Meh;Gorff;Awst;Medi;Hyd;Tach;Rhag`),dddd:U(`Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn`),ddd:U(`Sul;Llun;Maw;Mer;Iau;Gwen;Sad`)},`cy`),G({group:`.`,decimal:`,`,mmmm:U(`yanvar;fevral;mart;aprel;may;iyun;iyul;avqust;sentyabr;oktyabr;noyabr;dekabr`),mmm:U(`yan;fev;mar;apr;may;iyn;iyl;avq;sen;okt;noy;dek`),dddd:U(`bazar;bazar ertəsi;çərşənbə axşamı;çərşənbə;cümə axşamı;cümə;şənbə`),ddd:U(`B.;B.e.;Ç.a.;Ç.;C.a.;C.;Ş.`)},`az`),G(W({decimal:`,`,mmmm:U(`студзеня;лютага;сакавіка;красавіка;мая;чэрвеня;ліпеня;жніўня;верасня;кастрычніка;лістапада;снежня`),dddd:U(`нядзеля;панядзелак;аўторак;серада;чацвер;пятніца;субота`),ddd:U(`нд;пн;аў;ср;чц;пт;сб`)},3,-1),`be`),G({decimal:`,`,ampm:U(`пр.об.;сл.об.`),mmmm:U(`януари;февруари;март;април;май;юни;юли;август;септември;октомври;ноември;декември`),mmm:U(`яну;фев;март;апр;май;юни;юли;авг;сеп;окт;ное;дек`),dddd:U(`неделя;понеделник;вторник;сряда;четвъртък;петък;събота`),ddd:U(`нд;пн;вт;ср;чт;пт;сб`),bool:U(`ИСТИНА;ЛОЖЬ`)},`bg`),G({group:`.`,decimal:`,`,mmmm:U(`de gener;de febrer;de març;d’abril;de maig;de juny;de juliol;d’agost;de setembre;d’octubre;de novembre;de desembre`),mmm:U(`de gen.;de febr.;de març;d’abr.;de maig;de juny;de jul.;d’ag.;de set.;d’oct.;de nov.;de des.`),dddd:U(`diumenge;dilluns;dimarts;dimecres;dijous;divendres;dissabte`),ddd:U(`dg.;dl.;dt.;dc.;dj.;dv.;ds.`),ampm:U(`a.\xA0m.;p.\xA0m.`)},`ca`),G(W({group:`,`,decimal:`.`,mmmm:U(`Enero;Pebrero;Marso;Abril;Mayo;Hunyo;Hulyo;Agosto;Setyembre;Oktubre;Nobyembre;Disyembre`),dddd:U(`Linggo;Lunes;Martes;Miyerkules;Huwebes;Biyernes;Sabado`)},3,3),`fil`),G({group:`,`,decimal:`.`,mmmm:U(`જાન્યુઆરી;ફેબ્રુઆરી;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટેમ્બર;ઑક્ટોબર;નવેમ્બર;ડિસેમ્બર`),mmm:U(`જાન્યુ;ફેબ્રુ;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટે;ઑક્ટો;નવે;ડિસે`),dddd:U(`રવિ~;સોમ~;મંગળ~;બુધ~;ગુરુ~;શુક્ર~;શનિ~`,`વાર`),ddd:U(`રવિ;સોમ;મંગળ;બુધ;ગુરુ;શુક્ર;શનિ`)},`gu`),G({group:`,`,decimal:`.`,ampm:U(`לפנה״צ;אחה״צ`),dddd:U(`~ראשון;~שני;~שלישי;~רביעי;~חמישי;~שישי;~שבת`,`יום `),ddd:U(`~א׳;~ב׳;~ג׳;~ד׳;~ה׳;~ו׳;שבת`,`יום `),mmmm:U(`ינואר;פברואר;מרץ;אפריל;מאי;יוני;יולי;אוגוסט;ספטמבר;אוקטובר;נובמבר;דצמבר`),mmm:U(`ינו׳;פבר׳;מרץ;אפר׳;מאי;יוני;יולי;אוג׳;ספט׳;אוק׳;נוב׳;דצמ׳`),mmmm6:U(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע אל־אוול;רביע א־ת׳אני;ג׳ומאדא אל־אולא;ג׳ומאדא א־ת׳אניה;רג׳ב;שעבאן;רמדאן`),mmm6:U(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע א׳;רביע ב׳;ג׳ומאדא א׳;ג׳ומאדא ב׳;רג׳ב;שעבאן;רמדאן`)},`he`),G(W({group:`.`,decimal:`,`,mmmm:U(`siječnja;veljače;ožujka;travnja;svibnja;lipnja;srpnja;kolovoza;rujna;listopada;studenoga;prosinca`),mmm:U(`sij;velj;ožu;tra;svi;lip;srp;kol;ruj;lis;stu;pro`),dddd:U(`nedjelja;ponedjeljak;utorak;srijeda;četvrtak;petak;subota`)},-1,3),`hr`),G({decimal:`,`,mmmm:U(`հունվարի;փետրվարի;մարտի;ապրիլի;մայիսի;հունիսի;հուլիսի;օգոստոսի;սեպտեմբերի;հոկտեմբերի;նոյեմբերի;դեկտեմբերի`),mmm:U(`հնվ;փտվ;մրտ;ապր;մյս;հնս;հլս;օգս;սեպ;հոկ;նոյ;դեկ`),dddd:U(`կիրակի;երկուշաբթի;երեքշաբթի;չորեքշաբթի;հինգշաբթի;ուրբաթ;շաբաթ`),ddd:U(`կիր;երկ;երք;չրք;հնգ;ուր;շբթ`)},`hy`),G(W({decimal:`,`,mmmm:U(`იანვარი;თებერვალი;მარტი;აპრილი;მაისი;ივნისი;ივლისი;აგვისტო;სექტემბერი;ოქტომბერი;ნოემბერი;დეკემბერი`),dddd:U(`კვირა;ორშაბათი;სამშაბათი;ოთხშაბათი;ხუთშაბათი;პარასკევი;შაბათი`)},3,3),`ka`),G(W({decimal:`,`,mmmm:U(`қаңтар;ақпан;наурыз;сәуір;мамыр;маусым;шілде;тамыз;қыркүйек;қазан;қараша;желтоқсан`),dddd:U(`жексенбі;дүйсенбі;сейсенбі;сәрсенбі;бейсенбі;жұма;сенбі`),ddd:U(`жс;дс;сс;ср;бс;жм;сб`)},13,-1),`kk`),G({group:`,`,mmmm:U(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿಲ್;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂಬರ್;ಅಕ್ಟೋಬರ್;ನವೆಂಬರ್;ಡಿಸೆಂಬರ್`),mmm:U(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿ;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂ;ಅಕ್ಟೋ;ನವೆಂ;ಡಿಸೆಂ`),dddd:U(`ಭಾನು~;ಸೋಮ~;ಮಂಗಳ~;ಬುಧ~;ಗುರು~;ಶುಕ್ರ~;ಶನಿ~`,`ವಾರ`),ddd:U(`ಭಾನು;ಸೋಮ;ಮಂಗಳ;ಬುಧ;ಗುರು;ಶುಕ್ರ;ಶನಿ`),ampm:U(`ಪೂರ್ವಾಹ್ನ;ಅಪರಾಹ್ನ`)},`kn`),G({decimal:`,`,mmmm:U(`sausio;vasario;kovo;balandžio;gegužės;birželio;liepos;rugpjūčio;rugsėjo;spalio;lapkričio;gruodžio`),mmm:U(`saus.;vas.;kov.;bal.;geg.;birž.;liep.;rugp.;rugs.;spal.;lapkr.;gruod.`),dddd:U(`sekmadienis;pirmadienis;antradienis;trečiadienis;ketvirtadienis;penktadienis;šeštadienis`),ddd:U(`sk;pr;an;tr;kt;pn;št`),ampm:U(`priešpiet;popiet`)},`lt`),G({decimal:`,`,mmmm:U(`janvāris;februāris;marts;aprīlis;maijs;jūnijs;jūlijs;augusts;septembris;oktobris;novembris;decembris`),mmm:U(`janv.;febr.;marts;apr.;maijs;jūn.;jūl.;aug.;sept.;okt.;nov.;dec.`),dddd:U(`svētdiena;pirmdiena;otrdiena;trešdiena;ceturtdiena;piektdiena;sestdiena`),ddd:U(`svētd.;pirmd.;otrd.;trešd.;ceturtd.;piektd.;sestd.`),ampm:U(`priekšpusdienā;pēcpusdienā`)},`lv`),G({group:`,`,decimal:`.`,mmmm:U(`ജനുവരി;ഫെബ്രുവരി;മാർച്ച്;ഏപ്രിൽ;മേയ്;ജൂൺ;ജൂലൈ;ഓഗസ്റ്റ്;സെപ്റ്റംബർ;ഒക്‌ടോബർ;നവംബർ;ഡിസംബർ`),mmm:U(`ജനു;ഫെബ്രു;മാർ;ഏപ്രി;മേയ്;ജൂൺ;ജൂലൈ;ഓഗ;സെപ്റ്റം;ഒക്ടോ;നവം;ഡിസം`),dddd:U(`ഞായറാഴ്‌ച;തിങ്കളാഴ്‌ച;ചൊവ്വാഴ്ച;ബുധനാഴ്‌ച;വ്യാഴാഴ്‌ച;വെള്ളിയാഴ്‌ച;ശനിയാഴ്‌ച`),ddd:U(`ഞായർ;തിങ്കൾ;ചൊവ്വ;ബുധൻ;വ്യാഴം;വെള്ളി;ശനി`)},`ml`),G({group:`,`,decimal:`.`,mmmm:U(`нэгдүгээ~;хоёрдугаа~;гуравдугаа~;дөрөвдүгээ~;тавдугаа~;зургаадугаа~;долоодугаа~;наймдугаа~;есдүгээ~;аравдугаа~;арван нэгдүгээ~;арван хоёрдугаа~`,`р сар`),mmm:U(`1~;2~;3~;4~;5~;6~;7~;8~;9~;10~;11~;12~`,`-р сар`),dddd:U(`ням;даваа;мягмар;лхагва;пүрэв;баасан;бямба`),ddd:U(`Ня;Да;Мя;Лх;Пү;Ба;Бя`),ampm:U(`ү.ө.;ү.х.`)},`mn`),G({group:`,`,decimal:`.`,mmmm:U(`जानेवारी;फेब्रुवारी;मार्च;एप्रिल;मे;जून;जुलै;ऑगस्ट;सप्टेंबर;ऑक्टोबर;नोव्हेंबर;डिसेंबर`),mmm:U(`जाने;फेब्रु;मार्च;एप्रि;मे;जून;जुलै;ऑग;सप्टें;ऑक्टो;नोव्हें;डिसें`),dddd:U(`रविवार;सोमवार;मंगळवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:U(`रवि;सोम;मंगळ;बुध;गुरु;शुक्र;शनि`)},`mr`),G(W({group:`,`,decimal:`.`,mmmm:U(`ဇန်နဝါရီ;ဖေဖော်ဝါရီ;မတ်;ဧပြီ;မေ;ဇွန်;ဇူလိုင်;ဩဂုတ်;စက်တင်ဘာ;အောက်တိုဘာ;နိုဝင်ဘာ;ဒီဇင်ဘာ`),mmm:U(`ဇန်;ဖေ;မတ်;ဧ;မေ;ဇွန်;ဇူ;ဩ;စက်;အောက်;နို;ဒီ`),dddd:U(`တနင်္ဂနွေ;တနင်္လာ;အင်္ဂါ;ဗုဒ္ဓဟူး;ကြာသပတေး;သောကြာ;စနေ`),ampm:U(`နံနက်;ညနေ`)},-1,0),`my`),G({group:`,`,decimal:`.`,mmmm:U(`ਜਨਵਰੀ;ਫ਼ਰਵਰੀ;ਮਾਰਚ;ਅਪ੍ਰੈਲ;ਮਈ;ਜੂਨ;ਜੁਲਾਈ;ਅਗਸਤ;ਸਤੰਬਰ;ਅਕਤੂਬਰ;ਨਵੰਬਰ;ਦਸੰਬਰ`),mmm:U(`ਜਨ;ਫ਼ਰ;ਮਾਰਚ;ਅਪ੍ਰੈ;ਮਈ;ਜੂਨ;ਜੁਲਾ;ਅਗ;ਸਤੰ;ਅਕਤੂ;ਨਵੰ;ਦਸੰ`),dddd:U(`ਐਤਵਾਰ;ਸੋਮਵਾਰ;ਮੰਗਲਵਾਰ;ਬੁੱਧਵਾਰ;ਵੀਰਵਾਰ;ਸ਼ੁੱਕਰਵਾਰ;ਸ਼ਨਿੱਚਰਵਾਰ`),ddd:U(`ਐਤ;ਸੋਮ;ਮੰਗਲ;ਬੁੱਧ;ਵੀਰ;ਸ਼ੁੱਕਰ;ਸ਼ਨਿੱਚਰ`),ampm:U(`ਪੂ.ਦੁ.;ਬਾ.ਦੁ.`)},`pa`),G({group:`.`,decimal:`,`,mmmm:U(`ianuarie;februarie;martie;aprilie;mai;iunie;iulie;august;septem~;octom~;noiem~;decem~`,`brie`),mmm:U(`ian.;feb.;mar.;apr.;mai;iun.;iul.;aug.;sept.;oct.;nov.;dec.`),dddd:U(`duminică;luni;marți;miercuri;joi;vineri;sâmbătă`),ddd:U(`dum.;lun.;mar.;mie.;joi;vin.;sâm.`),ampm:U(`a.m.;p.m.`)},`ro`),G(W({group:`.`,decimal:`,`,mmmm:U(`januar;februar;marec;april;maj;junij;julij;avgust;september;oktober;november;december`),mmm:U(`jan.;feb.;mar.;apr.;maj;jun.;jul.;avg.;sep.;okt.;nov.;dec.`),dddd:U(`nedelja;ponedeljek;torek;sreda;četrtek;petek;sobota`),ampm:U(`dop.;pop.`)},-1,13),`sl`),G(W({group:`.`,decimal:`,`,mmmm:U(`јануар;фебруар;март;април;мај;јун;јул;август;септембар;октобар;новембар;децембар`),dddd:U(`недеља;понедељак;уторак;среда;четвртак;петак;субота`)},3,3),`sr`),G({group:`,`,decimal:`.`,mmmm:U(`ஜனவரி;பிப்ரவரி;மார்ச்;ஏப்ரல்;மே;ஜூன்;ஜூலை;ஆகஸ்ட்;செப்டம்பர்;அக்டோபர்;நவம்பர்;டிசம்பர்`),mmm:U(`ஜன.;பிப்.;மார்.;ஏப்.;மே;ஜூன்;ஜூலை;ஆக.;செப்.;அக்.;நவ.;டிச.`),dddd:U(`ஞாயிறு;திங்கள்;செவ்வாய்;புதன்;வியாழன்;வெள்ளி;சனி`),ddd:U(`ஞாயி.;திங்.;செவ்.;புத.;வியா.;வெள்.;சனி`)},`ta`),G({group:`,`,decimal:`.`,mmmm:U(`జనవరి;ఫిబ్రవరి;మార్చి;ఏప్రిల్;మే;జూన్;జులై;ఆగస్టు;సెప్టెంబర్;అక్టోబర్;నవంబర్;డిసెంబర్`),mmm:U(`జన;ఫిబ్ర;మార్చి;ఏప్రి;మే;జూన్;జులై;ఆగ;సెప్టెం;అక్టో;నవం;డిసెం`),dddd:U(`ఆదివారం;సోమవారం;మంగళవారం;బుధవారం;గురువారం;శుక్రవారం;శనివారం`),ddd:U(`ఆది;సోమ;మంగళ;బుధ;గురు;శుక్ర;శని`)},`te`),G({decimal:`,`,mmmm:U(`січня;лютого;березня;квітня;травня;червня;липня;серпня;вересня;жовтня;листопада;грудня`),mmm:U(`січ.;лют.;бер.;квіт.;трав.;черв.;лип.;серп.;вер.;жовт.;лист.;груд.`),dddd:U(`неділю;понеділок;вівторок;середу;четвер;пʼятницю;суботу`),ddd:U(`нд;пн;вт;ср;чт;пт;сб`),ampm:U(`дп;пп`)},`uk`),G({group:`.`,decimal:`,`,mmmm:U(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`tháng `),mmm:U(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`thg `),dddd:U(`Chủ Nhật;Thứ Hai;Thứ Ba;Thứ Tư;Thứ Năm;Thứ Sáu;Thứ Bảy`),ddd:U(`CN;Th 2;Th 3;Th 4;Th 5;Th 6;Th 7`),ampm:U(`SA;CH`)},`vi`),G(W({group:`٬`,decimal:`٫`,ampm:U(`ص;م`),mmmm:U(`يناير;فبراير;مارس;أبريل;مايو;يونيو;يوليو;أغسطس;سبتمبر;أكتوبر;نوفمبر;ديسمبر`),dddd:U(`الأحد;الاثنين;الثلاثاء;الأربعاء;الخميس;الجمعة;السبت`),mmmm6:U(`رمضان;شوال;ذو القعدة;ذو الحجة;محرم;ربيع الأول;ربيع الآخرة;جمادى الأولى;جمادى الآخرة;رجب;شعبان;رمضان`)},0,0),`ar`),G({group:`,`,decimal:`.`,mmmm:U(`জানুয়ারী;ফেব্রুয়ারী;মার্চ;এপ্রিল;মে;জুন;জুলাই;আগস্ট;সেপ্টেম্বর;অক্টোবর;নভেম্বর;ডিসেম্বর`),mmm:U(`জানু;ফেব;মার্চ;এপ্রি;মে;জুন;জুল;আগ;সেপ্টেঃ;অক্টোঃ;নভেঃ;ডিসেঃ`),dddd:U(`রবিবার;সোমবার;মঙ্গলবার;বুধবার;বৃহস্পতিবার;শুক্রবার;শনিবার`),ddd:U(`রবি;সোম;মঙ্গল;বুধ;বৃহস্পতি;শুক্র;শনি`)},`bn`),G({group:`,`,decimal:`.`,mmmm:U(`जनवरी;फ़रवरी;मार्च;अप्रैल;मई;जून;जुलाई;अगस्त;सितंबर;अक्तूबर;नवंबर;दिसंबर`),mmm:U(`जन॰;फ़र॰;मार्च;अप्रैल;मई;जून;जुल॰;अग॰;सित॰;अक्तू॰;नव॰;दिस॰`),dddd:U(`रविवार;सोमवार;मंगलवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:U(`रवि;सोम;मंगल;बुध;गुरु;शुक्र;शनि`),ampm:U(`am;pm`)},`hi`);function bs(e,t){switch(t){case`int`:return e.int_pattern;case`frac`:return e.frac_pattern;case`man`:return e.man_pattern;case`den`:return e.den_pattern;case`num`:return e.num_pattern}}function xs(e,t,n){let r=e.length,i=e.replace(/#/g,``).length;switch(n){case`int`:t.int_max=r,t.int_min=i;break;case`frac`:t.frac_max=r,t.frac_min=i;break;case`man`:t.man_max=r,t.man_min=i;break;case`den`:t.den_max=r,t.den_min=i;break;case`num`:t.num_max=r,t.num_min=i;break}return t}function K(e,t){typeof e==`string`?t.push({type:`string`,value:e}):t.push(e)}function Ss(e,t){let n=e==null?void 0:e.type;return n===`hash`||n===`zero`||n===`qmark`||n===`digit`&&t===`den`}function Cs(e){if(e===null)throw TypeError(`Cannot read properties of null (reading 'num')`)}function ws(e){let t=[],n={scale:1,scaleExponent:0,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:t,tokensUsed:0,pattern:``,int_max:0,int_min:0,frac_max:0,frac_min:0,man_max:0,man_min:0,num_max:0,num_min:0,den_max:0,den_min:0,int_p:``,man_p:``,num_p:``,den_p:``,integer:!1},r=`int`,i=null,a=[],o,s=!1,c=-1,l=!1,u=``,d=!1;for(;++c<e.length&&!l;){var f;let h=e[c],g=h.type||`error`;if(u+=h.raw,g===`general`)n.general=!0,K(h,t);else if(Ss(h,r)){let e=bs(n,r);Ss(o,r)||(o==null?void 0:o.type)===`group`?(e.push((e.pop()||``)+h.value),Cs(i),i.num+=h.value):(e.push(h.value),i={type:r,num:h.value},K(i,t))}else if(g===`paren`)h.value===`(`&&(n.parens=!0),K(h.value,t);else if(g===`digit`)K(h.value,t);else if(g===`slash`){d=!0;let e=bs(n,r);if(e.length){if(!i)throw SyntaxError(`Format pattern is missing a numerator`);n.fractions=!0;let a=e.pop();if(a===void 0)throw SyntaxError(`Format pattern is missing a numerator`);n.num_pattern.push(a),i.type=`num`,r=`den`,K({type:`div`},t)}else K(h.value,t)}else if(g===`comma`)K(`,`,t);else if(g===`scale`)n.scale=.001**h.raw.length,n.scaleExponent=-3*h.raw.length;else if(g===`group`){if(r===`int`&&(n.grouping=!0),r===`den`)throw SyntaxError(`Cannot group denominator digits`)}else if(g===`space`)K(h,t);else if(g===`break`){l=!0;break}else if(g===`text`)n.text=!0,K(h,t);else if(g===`plus`||g===`minus`)K(h,t);else if(g===`duration`){let e=h.value.toLowerCase(),r=e[0],i={type:``,size:0,date:1,pad:e.length};r===`h`?(i.size=16,i.type=`hour-elap`):r===`m`?(i.size=32,i.type=`min-elap`):(i.size=64,i.type=`sec-elap`),n.date|=i.size,a.push(i),K(i,t)}else if(n.date&&g===`point`&&((f=e[c+1])==null?void 0:f.type)===`zero`){var p,m;let r=1;c++;let i=`0`;((p=e[c+1])==null?void 0:p.type)===`zero`&&(i+=`0`,r=2,c++),((m=e[c+1])==null?void 0:m.type)===`zero`&&(i+=`0`,r=3,c++),u+=i;let a=[64,128,256,512][r];n.date|=a,n.date_eval=!0,n.sec_decimals=Math.max(n.sec_decimals,r),K({type:`subsec`,size:a,decimals:r,date:1},t)}else if(g===`calendar`)s||(h.value===`B2`||h.value===`b2`?n.date_system=6:n.date_system=1);else if(g===`datetime`){let e={type:``,size:0,date:1},r=h.value.toLowerCase(),i=r[0];if(r===`y`||r===`yy`)e.size=2,e.type=`year-short`;else if(i===`y`||i===`e`)e.size=2,e.type=`year`;else if(r===`b`||r===`bb`)e.size=2,e.type=`b-year-short`;else if(i===`b`)e.size=2,e.type=`b-year`;else if(r===`d`||r===`dd`)e.size=8,e.type=`day`,e.pad=/dd/.test(r);else if(r===`ddd`||r===`aaa`)e.size=8,e.type=`weekday-short`;else if(i===`d`||i===`a`)e.size=8,e.type=`weekday`;else if(i===`h`)e.size=16,e.type=`hour`,e.pad=/hh/i.test(r);else if(i===`m`){r.length===3?(e.size=4,e.type=`monthname-short`):r.length===5?(e.size=4,e.type=`monthname-single`):r.length>=4&&(e.size=4,e.type=`monthname`);let t=a[a.length-1];!e.type&&t&&!t.used&&t.size&80&&(t.used=!0,e.size=32,e.type=`min`,e.pad=/mm/.test(r)),e.type||(e.size=4,e.type=`month`,e.pad=/mm/.test(r),e.indeterminate=!0)}else if(i===`s`){e.size=64,e.type=`sec`,e.pad=/ss/.test(r);let t=a[a.length-1];t&&t.size&32?e.used=!0:t!=null&&t.indeterminate&&(delete t.indeterminate,t.size=32,t.type=`min`,e.used=!0)}n.date|=e.size,n.date_eval=!0,a.push(e),K(e,t)}else if(g===`ampm`)n.clock=12,n.date|=16,n.date_eval=!0,h.short=h.value===`A/P`,K(h,t);else if(g===`string`||g===`escaped`||g===`char`)K(h.value,t);else if(g===`condition`)n.condition=[h.value[0],Number.parseFloat(h.value[1])];else if(g===`locale`){let e=h.value.split(`-`),r=e.length<2?``:e.slice(1).join(`-`),i=e[0];i&&K(i,t);let a=ss(r);a&&(n.locale=a);let o=Number.parseInt(r,16);Number.isFinite(o)&&o&16711680&&(o>>16&255)==6&&(n.date_system=6),s=!0}else if(g===`color`){let e=h.value.toLowerCase(),t=e,r=/^color\s*(\d+)$/i.exec(e);r&&(t=Number.parseInt(r[1],10)),n.color=t}else if(g===`percent`)n.scale=100,n.scaleExponent=2,n.percent=!0,K(`%`,t);else if(g===`point`)K(h,t),n.date||(n.dec_fractions=!0,r=`frac`);else if(g===`exp`)n.exponential=!0,n.exp_plus=h.value.includes(`+`),r=`man`,K({type:`exp`,plus:n.exp_plus},t);else if(g===`skip`||g===`fill`)K(h,t);else if(g!==`dbnum`&&g!==`natnum`)throw SyntaxError(g===`error`?`Illegal character: ${u}`:`Unknown token ${g} in ${u}`);o=h}if(n.tokensUsed=c,n.pattern=u,/^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(n.pattern)&&K({type:`text`},t),n.fractions&&n.dec_fractions||n.grouping&&!n.int_pattern.length||n.fractions&&n.exponential||n.fractions&&n.den_pattern.length*n.num_pattern.length===0||d&&!n.fractions&&!n.date||n.exponential&&(n.int_pattern.length||n.frac_pattern.length)*n.man_pattern.length===0)throw SyntaxError(`Invalid pattern: ${u}`);let h=n.int_pattern.join(``),g=n.man_pattern.join(``),_=n.frac_pattern.join(``);xs(h,n,`int`);let v=0;for(let e=0;e<h.length;e++){let t=h[h.length-1-e];/^[0-9?]/.test(t)&&(v=e+1)}n.int_min=v,xs(_,n,`frac`),xs(g,n,`man`);let y=n.num_pattern.join(``),b=n.den_pattern[0]||``;if(b.includes(`?`)||y.includes(`?`)?(b=b.replace(/\d/g,`?`),b=b.replace(/#$/g,`?`),xs(y,n,`num`),xs(b,n,`den`),y=y.replace(/#$/g,`?`)):(xs(y,n,`num`),xs(b,n,`den`)),n.int_p=h,n.man_p=g,n.num_p=y,n.den_p=b,n.den_pattern.length&&(n.denominator=Number.parseInt(n.den_pattern.join(``).replace(/\D/g,``),10)),n.integer=!!h.length,!n.integer&&!n.exponential&&_.length){let e=n.tokens.findIndex(e=>e.type===`point`);n.tokens.splice(e,0,{type:`int`,value:`#`}),n.integer=!0,n.int_pattern=[`#`],n.int_p=`#`}if(n.fractions)for(let e=0;e<t.length-1;e++){let n=t[e];if(n.type!==`string`&&n.type!==`space`)continue;let r=t[e+1].type;r===`num`?n.rule=`num+int`:r===`div`?n.rule=`num`:r===`den`&&(n.rule=`den`)}return n.grouping&&n.int_pattern.length>1&&(n.grouping=!1),n}function Ts(e){if(e===0)return e;let t=Math.ceil(Math.log10(e<0?-e:e)),n=10**(16-Math.floor(t));return isFinite(n)?Math.round(e*n)/n:0}function Es(e,t=2,n=2){let r=e<0?-1:1,i=10**(t||2),a=10**(n||2),o=Math.abs(e),s=0,c=0,l=0,u=1,d,f;if(e=o,e%1==0)f=[e*r,1];else if(e<1e-19)f=[r,0x8ac7230489e80000];else if(e>0x8ac7230489e80000)f=[0x8ac7230489e80000*r,1];else{do if(o=1/(o-Math.floor(o)),d=u,u=u*Math.floor(o)+s,s=d,c=l,l=Math.floor(e*u+.5),l>=i||u>=a)return[r*c,s];while(Math.abs(e-l/u)>=1e-13&&o!==Math.floor(o));f=[r*l,u]}return f}let Ds={total:1,sign:0,period:0,int:1,frac:0};function Os(e,t=!0){let n=Yo(e);if(n.digits===`0`)return Ds;let r=n.exponent+1,i=Math.max(r,1),a=Math.max(0,n.digits.length-r),o=t&&n.negative?1:0,s=+(a>0);return{total:o+i+s+a,digits:Math.max(r,0)+a,sign:o,period:s,int:i,frac:a}}function ks(e,t=0){let n=Math.floor(Math.log10(e));return t>1?Math.floor(n/t)*t:n}function As(e,t=1){return t<-300?Number.parseFloat(e.toExponential().split(`e`)[0]):e*10**-t}function js(e,t=0){if(e<0)return-js(-e,t);if(t){let n=10**t||1;return js(e*n,0)/n}return Math.round(e)}function Ms(e,t=0){if(typeof e!=`number`)return e;if(!Number.isFinite(e)||e===0)return e===0?0:e;if(!Number.isFinite(t))return js(e,t);let n=Math.trunc(t);if(Number.isInteger(e)&&n>=0||n>324)return e;let r=$o(Qo(Yo(e),n));return Number.isFinite(r)?r:e}function Ns(e,t){return e.replace(/\./,t.decimal)}function Ps(e){return e?e.negative?{...e,negative:!1}:e:null}function Fs(e){return(e==null?void 0:e.exponent)??0}function Is(e){return!e||e.exponent<-308}function Ls(e,t){let n=ts(e,1,!0,5),r=n.exponent,i=Math.abs(r);return[Ns(es(n.rounded),t),t.exponent,r<0?t.negative:t.positive,i<10?`0`:``,i]}function Rs(e,t,n){let r=Math.abs(t),i=e===1?e:Math.round(e*1e5)/1e5;return[Ns(String(i),n),n.exponent,t<0?n.negative:n.positive,r<10?`0`:``,r]}function zs(e,t,n,r,i=null){let a=typeof n==`number`?n|0:0;if(typeof n==`string`)e.push(n);else if(n===a)e.push(Math.abs(a));else{let t=Math.abs(n),a=Ps(i),o=Fs(a),s=null;Is(a)&&(o=ks(t),s=As(t,o),s===10&&(s=1,o++));let c=Os(t);if(o>=-4&&o<=-1){let n=t.toPrecision(10+o).replace(/\.?0+$/,``);e.push(Ns(n,r))}else if(o===10){let n=t.toFixed(10).slice(0,12).replace(/\.$/,``);e.push(Ns(n,r))}else if(Math.abs(o)<=9)if(c.total<=11){let n=Ms(t,9).toFixed(c.frac);e.push(Ns(n,r))}else o===9?e.push(Math.floor(t)):o>=0&&o<9?e.push(Ns(String(Ms(t,9-o)),r)):e.push(...s===null?Ls(a,r):Rs(s,o,r));else c.total>=12?e.push(...s===null?Ls(a,r):Rs(s,o,r)):e.push(Ns(Ms(t,9).toFixed(c.frac),r))}return e}function Bs(e,t=!1){return e===`0`?`0`:e===`?`?t?`\xA0`:` `:``}let Vs=Math.floor;function Hs(e,t=!0){if(t&&e>=0){if(e===0)return[1900,1,0];if(e===60)return[1900,2,29];if(e<60)return[1900,e<32?1:2,(e-1)%31+1]}let n=e+68569+2415019,r=Vs(4*n/146097);n-=Vs((146097*r+3)/4);let i=Vs(4e3*(n+1)/1461001);n=n-Vs(1461*i/4)+31;let a=Vs(80*n/2447),o=n-Vs(2447*a/80);n=Vs(a/11);let s=a+2-12*n;return[100*(r-49)+i+n|0,s|0,o|0]}function Us(e){return Hs(e+1462)}function Ws(e){if(e===60)throw Error(`#VALUE!`);if(e<=1)return[1317,8,29];if(e<60)return[1317,e<32?9:10,1+(e-2)%30];let t=10631/30,n=8.01/60,r=e+466935,i=Vs(r/10631);r-=10631*i;let a=Vs((r-n)/t);r-=Vs(a*t+n);let o=Vs((r+28.5001)/29.5);return o===13?[30*i+a,12,30]:[30*i+a,o,r-Vs(29.5001*o-29)]}function Gs(e,t=0,n=!0){let r=Vs(e);return t===6?Ws(r):t===-1?Us(r):Hs(r,n)}let Ks=Math.floor,qs=86400,Js=Date.UTC,Ys=1462,Xs=2958465,Zs=9999;function Qs(e=`date1900`){return e===`date1904`?Xs-Ys:Xs}function $s(e){return e%4==0&&(e%100!=0||e%400==0)}function ec(e,t,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||e<1||e>Zs||t<1||t>12)return!1;let r=[31,$s(e)?29:28,31,30,31,30,31,31,30,31,30,31];return n>=1&&n<=r[t-1]}function tc(e,t,n){let r=e-+(t<=2),i=Math.floor(r/400),a=r-i*400,o=t+(t>2?-3:9),s=Math.floor((153*o+2)/5)+n-1,c=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return i*146097+c-719468}function nc(e,t,n){if(e===1900&&t===1&&n===0)return 0;if(e===1900&&t===2&&n===29)return 60;if(!ec(e,t,n))return null;let r=tc(e,t,n);return r+(r<=-25509?25568:25569)}function rc(e,t){if(!Number.isFinite(e)||e<0)return null;let n=Math.floor(e),[r,i,a]=Gs(t.dateSystem===`date1904`?n+Ys:n,0,!0);if(r>Zs)return null;let o=(e-n)*qs,s=Math.floor(o);return{year:r,month:i,day:a,hours:Math.floor(s/3600),minutes:Math.floor(s/60)%60,seconds:s%60,fractionalSecond:o-s}}function ic(e,t){let n=e.year===1900&&e.month===2&&e.day===29?28:e.day;return new Date(Date.UTC(e.year,e.month-1,n,t?e.hours:0,t?e.minutes:0,t?e.seconds:0,t?Math.round(e.fractionalSecond*1e3):0))}function ac(e,t=`date1900`){let n=rc(e,{dateSystem:t});return n?ic(n,!1):new Date(NaN)}function oc(e,t=`date1900`){let n=rc(e,{dateSystem:t});return n?ic(n,!0):new Date(NaN)}function sc(e,t){let{year:n,month:r,day:i,hours:a,minutes:o,seconds:s,fractionalSecond:c}=e;if(!Number.isInteger(a)||a<0||a>23||!Number.isInteger(o)||o<0||o>59||!Number.isInteger(s)||s<0||s>59||!Number.isFinite(c)||c<0||c>=1||t.dateSystem===`date1900`&&n<1900)return null;let l=nc(n,r,i);if(l==null)return null;if(t.dateSystem===`date1904`){if(n===1900&&r===1&&i===0||n===1900&&r===2&&i===29)return null;l-=Ys}return l<0?null:l+(a*3600+o*60+s+c)/qs}function cc(e,t,n){return Number.isFinite(e.getTime())?sc({year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hours:t?e.getUTCHours():0,minutes:t?e.getUTCMinutes():0,seconds:t?e.getUTCSeconds():0,fractionalSecond:t?e.getUTCMilliseconds()/1e3:0},{dateSystem:n})??((t?e.getTime():Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))-(n===`date1904`?Date.UTC(1904,0,1):Date.UTC(1899,11,31)))/864e5:NaN}function lc(e,t=`date1900`){return cc(e,!1,t)}function uc(e,t=`date1900`){return cc(e,!0,t)}function dc(e,t){let n=null;if(Array.isArray(e)){let[t,r,i,a,o,s]=e;n=Js(t,r==null?0:r-1,i??1,a||0,o||0,s||0)}else if(e instanceof Date&&(n=e.getTime(),!(t!=null&&t.ignoreTimezone))){let t=new Date;t.setUTCFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t.setUTCHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n=t.getTime()}if(n!=null&&Number.isFinite(n)){let e=n/864e5;return e-(e<=-25509?-25568:-25569)}return null}function fc(e,t){let n=e|0,r=qs*(e-n),i=Ks(r);r-i>.9999&&(i+=1,i===qs&&(i=0,n+=1));let a=i<0?qs+i:i,[o,s,c]=Gs(e,0,t==null?void 0:t.leap1900);return[o,s,c,Ks(a/60/60)%60,Ks(a/60)%60,Ks(a)%60]}let pc=86400;function mc(e,t,n,r){if(n)return e<-694324||t>=35830291;let i=Qs(r)+1;return e<0||t>=i}function hc(e,t=0){if(e<0)return-hc(-e,t);if(t){let n=10**t||1;return hc(e*n,0)/n}return Math.round(e)}function gc(e,t,n,r,i=null){let a=t,o=e,s=e,c=``,l=``,u=``,d=``,f=``,p=``,m=0,h=null,g=0;if(typeof o==`bigint`){if(o<=2**53-1&&o>=-(2**53-1))s=Number(o),o=s;else return n.bigintErrorNumber?String(o):n.overflow;g=s}else g=Math.trunc(s);let _=0,v=0,y=1,b=0,x=0,S=0,C=0,w=0,T=0,E=r||us,D=i;if(!D&&typeof e==`number`&&Number.isFinite(e)&&(D=Yo(e)),D&&!a.text&&a.scaleExponent&&(D=Xo(D,a.scaleExponent)),!a.text&&Number.isFinite(a.scale)&&a.scale!==1&&(s=Ts(s*a.scale),o=s),a.exponential&&D&&D.exponent>=-308){let e=ts(D,a.int_max,!!a.integer,a.frac_max);m=e.exponent,h=e.rounded,c+=Math.abs(m)}else if(a.exponential){let e=Math.abs(s);e&&(m=ks(e,a.int_max)),s&&!a.integer&&m++,e=As(e,m),a.int_max===1&&hc(e,a.frac_max)===10&&(e=1,m++),s=s<0?-e:e,o=s,c+=Math.abs(m)}let O=!Number.isSafeInteger(s)||!!a.scaleExponent;if(h||=D&&O&&!a.date&&!a.fractions&&!a.exponential&&(a.integer||a.dec_fractions)?Qo(D,a.frac_max):null,a.integer)if(h)p=h.integer===`0`?``:h.integer;else{let e=a.fractions?1:a.frac_max,t=Math.abs(Number.isSafeInteger(s)&&e===0?s:hc(s,e));p+=t<1?``:Math.floor(t)}let k=n.grouping[0]??3,A=n.grouping[1]??k;a.dec_fractions&&(f=h?h.fraction:String(hc(s,a.frac_max)).split(`.`)[1]||``);let j=!a.error&&(a.num_p.includes(`0`)||a.den_p.includes(`0`)),M=j;if(a.fractions){M=j||!!(s%1);let e=Math.abs(a.integer?s%1:s);if(e)if(M=!0,a.denominator&&Number.isFinite(a.denominator))d+=a.denominator,u+=hc(e*a.denominator),u===`0`&&(u=``,d=``,M=j);else{let t=Es(e,1/0,a.den_max);u+=t[0],d+=t[1],a.integer&&u===`0`&&(u=``,d=``,M=j)}else!s&&!a.integer&&(M=!0,u=`0`,d=`1`);a.integer&&!M&&!Math.trunc(s)&&(p=`0`)}if(a.date){g=Math.trunc(s);let e=pc*(s-g);if(_=Math.floor(e),T=e-_,Math.abs(T)<1e-6?T=0:T>.9999&&(T=0,_+=1,_===pc&&(_=0,g+=1)),T){let e=a.date&512||a.date&256||a.date&128;(e===512&&T>.9995||e===256&&T>.995||e===128&&T>.95||!e&&T>=.5)&&(_++,T=0)}let t=a.date_system===6?6:n.dateSystem===`date1904`?-1:a.date_system;if(g||a.date_system){let e=Gs(s,t,n.leap1900);v=e[0],y=e[1],b=e[2]}if(_){let e=_<0?pc+_:_;w=Math.floor(e)%60,C=Math.floor(e/60)%60,S=Math.floor(e/60/60)%60}if(x=((t===-1?5:6)+g)%7,a.date_eval&&mc(s,g+_/pc,n.dateSpanLarge,n.dateSystem)){if(n.dateErrorThrows)throw Error(`Date out of bounds`);return n.dateErrorNumber?zs(s<0?[E.negative]:[],{},s,E,D).join(``):n.overflow}}let N=Bs(`?`,n.nbsp);m<0?l=`-`:a.exp_plus&&(l=`+`);let P=[],F=(e,t,r,i)=>{let a=i,o=!a&&e.length>t.length?r.length+e.length-t.length:r.length;e.length<t.length&&(a+=e.length-t.length);for(let t=0;t<o;t++)P.push(e[t+a]||Bs(r[t],n.nbsp));return o},I=!1,L={int:0,frac:0,man:0,num:0,den:0};for(let e=0,t=a.tokens.length;e<t;e++){let t=a.tokens[e],i=t.type,m=t.num?t.num.length:0;if(i===`string`){let e=t.value;t.rule?t.rule===`num`?M?P.push(e.replace(/ /g,N)):(a.num_min>0||a.den_min>0)&&P.push(e.replace(/./g,N)):t.rule===`num+int`?M&&p?P.push(e.replace(/ /g,N)):a.den_min>0&&(p||a.num_min)&&P.push(e.replace(/./g,N)):t.rule===`den`&&(M?P.push(e.replace(/ /g,N)):a.den_min>0&&P.push(e.replace(/./g,N))):P.push(e.replace(/ /g,N))}else if(i===`space`)t.rule===`num+int`?(M||a.num_min||a.den_min)&&(p||a.num_min)&&P.push(N):P.push(N);else if(i===`error`)P.push(n.invalid);else if(i===`point`)P.push(a.date?t.value:E.decimal);else if(i===`general`)zs(P,a,o,E,D);else if(i===`exp`)P.push(E.exponent);else if(i===`minus`)t.volatile&&a.date||(t.volatile&&h?h.negative&&!h.zero&&P.push(E.negative):t.volatile&&(s>=0||typeof o!=`number`)||(t.volatile&&!a.fractions&&(a.integer||a.dec_fractions)?(s<0&&p&&p!==`0`||f)&&P.push(E.negative):P.push(E.negative)));else if(i===`plus`)P.push(E.positive);else if(i===`text`)P.push(o);else if(i===`fill`)n.fillChar&&P.push(n.fillChar,t.value);else if(i===`skip`)n.skipChar?P.push(n.skipChar,t.value):P.push(n.nbsp?`\xA0`:` `);else if(i===`div`)M?P.push(`/`):a.num_min>0||a.den_min>0?P.push(N):P.push(Bs(`#`,n.nbsp));else if(i===`int`)if(a.int_pattern.length===1){let e=a.int_p,t=Math.max(a.int_min,p.length),r=``;for(let i=t;i>0;i--){let t=p.charAt(p.length-i),o=t?``:e.charAt(e.length-i)||e[0],s=``;if(a.grouping){let e=i-1-k;e>=0&&!(e%A)&&(s=t||o===`0`?E.group:Bs(`?`,n.nbsp))}r+=(t||Bs(o,n.nbsp))+s}P.push(r)}else L.int+=F(p,a.int_p,t.num,L.int);else if(i===`frac`){let e=L.frac;for(let r=0;r<m;r++)P.push(f[r+e]||Bs(t.num[r],n.nbsp));L.frac+=m}else if(i===`man`)!L[i]&&!L.man&&P.push(l),L.man+=F(c,a.man_p,t.num,L.man);else if(i===`num`)L.num+=F(u,a.num_p,t.num,L.num);else if(i===`den`){let e=L.den;for(let r=0;r<m;r++){let i=d[r+e];if(!i){let e=t.num[r];`123456789`.includes(e)||I&&e===`0`?(I=!0,i=n.nbsp?`\xA0`:` `):i=!I&&r===m-1&&e===`0`&&!d?`1`:Bs(e,n.nbsp)}P.push(i)}L.den+=m}else if(i===`year`)v<0&&P.push(E.negative),P.push(String(Math.abs(v)).padStart(4,`0`));else if(i===`year-short`){let e=v%100;P.push(e<10?`0`:``,e)}else if(i===`month`)P.push(t.pad&&y<10?`0`:``,y);else if(i===`monthname-single`)a.date_system===6?P.push(E.mmmm6[y-1].charAt(0)):P.push(E.mmmm[y-1].charAt(0));else if(i===`monthname-short`)a.date_system===6?P.push(E.mmm6[y-1]):P.push(E.mmm[y-1]);else if(i===`monthname`)a.date_system===6?P.push(E.mmmm6[y-1]):P.push(E.mmmm[y-1]);else if(t.type===`weekday-short`)P.push(E.ddd[x]);else if(i===`weekday`)P.push(E.dddd[x]);else if(i===`day`)P.push(t.pad&&b<10?`0`:``,b);else if(i===`hour`){let e=S%a.clock||(a.clock<24?a.clock:0);P.push(t.pad&&e<10?`0`:``,e)}else if(i===`min`)P.push(t.pad&&C<10?`0`:``,C);else if(i===`sec`)P.push(t.pad&&w<10?`0`:``,w);else if(i===`subsec`){P.push(E.decimal);let e=T.toFixed(a.sec_decimals);P.push(e.slice(2,2+t.decimals))}else if(i===`ampm`){let e=S<12?0:1;t.short&&!r?P.push(`AP`[e]):P.push(E.ampm[e])}else if(i===`hour-elap`){s<0&&P.push(E.negative);let e=g*24+Math.floor(Math.abs(_)/3600);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`min-elap`){s<0&&P.push(E.negative);let e=g*1440+Math.floor(Math.abs(_)/60);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`sec-elap`){s<0&&P.push(E.negative);let e=g*pc+Math.abs(_);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`b-year`)P.push(v+543);else if(i===`b-year-short`){let e=(v+543)%100;P.push(e<10?`0`:``,e)}}return P.join(``)}let _c=ws([{type:So,value:`@`,raw:`@`}]);function vc(e){return!!e&&`scale`in e}function yc(e,t){for(let n=0;n<3;n++){let r=t[n];if(vc(r)){let t;if(r.condition){let n=r.condition[0],i=r.condition[1];n===`=`?t=e===i:n===`>`?t=e>i:n===`<`?t=e<i:n===`>=`?t=e>=i:n===`<=`?t=e<=i:n===`<>`&&(t=e!==i)}else t=!0;if(t)return r}else if(r)return r}}function bc(e,t,n){let r=t.partitions,i=r[3],a=null;return(typeof e==`number`||typeof e==`bigint`)&&isFinite(e)&&(i=yc(e,r)),vc(i)&&i.color&&(a=i.color),a&&typeof a==`number`&&n.indexColors&&(a=Ko[a-1]||`#000`),a}function xc(e,t,n){let r=t.partitions,i=cs(t.locale||n.locale),a=e,o=r[3]?r[3]:_c;if(typeof a==`boolean`&&(a=(i||us).bool[+!a]),a==null)return``;let s=typeof a==`bigint`;if(typeof a!=`number`&&!s)return gc(a,o,n,i);if(!s&&!Number.isFinite(a)){let e=i||us;return Number.isNaN(a)?e.nan:(a<0?e.negative:``)+e.infinity}let c=yc(e,r),l=c&&typeof e==`number`&&Number.isFinite(e)?Yo(e):null;return c?gc(e,c,n,i,l):n.overflow}function Sc(e){return!!e&&`scale`in e}function Cc(e,t){return e.type===`year`||e.type===`year-short`?{type:`year`,pattern:`yyyy`,tokenIndex:t}:e.type===`month`?{type:`month`,pattern:e.pad?`mm`:`m`,tokenIndex:t}:e.type===`day`?{type:`day`,pattern:e.pad?`dd`:`d`,tokenIndex:t}:null}function wc(e){return e.type.startsWith(`b-year`)||e.type.startsWith(`monthname`)||e.type.startsWith(`weekday`)}function Tc(e,t,n){if(n!==t+2)return null;let r=e[t+1];return r.value===`-`||r.value===`/`?r.value:null}function Ec(e,t){let n=e.find(e=>e.type===(t===`day`?`month`:`day`)),r=(n==null?void 0:n.pattern.length)===2;return t===`day`?r?`dd`:`d`:r?`mm`:`m`}function Dc(e,t){let n=e.map(e=>e.type).join(``);if(new Set(e.map(e=>e.type)).size!==e.length)return null;let r=new Map(e.map(e=>[e.type,e.pattern]));r.set(`year`,`yyyy`),r.has(`month`)||r.set(`month`,Ec(e,`month`)),r.has(`day`)||r.set(`day`,Ec(e,`day`));let i={daymonth:[`day`,`month`,`year`],daymonthyear:[`day`,`month`,`year`],dayyear:[`day`,`month`,`year`],monthday:[`year`,`month`,`day`],monthdayyear:[`month`,`day`,`year`],monthyear:[`month`,`day`,`year`],yearmonth:[`year`,`month`,`day`],yearmonthday:[`year`,`month`,`day`],yearday:[`year`,`month`,`day`]}[n];return i?i.map(e=>r.get(e)).join(t):null}function Oc(e){let t=e.tokens.map((e,t)=>Cc(e,t)).filter(e=>e!==null);if(!t.length)return null;if(t.length<2||t.length>3||e.locale||e.date_system!==1||e.tokens.some(wc))return`yyyy/mm/dd`;let n=t.slice(1).map((n,r)=>Tc(e.tokens,t[r].tokenIndex,n.tokenIndex)),r=n[0];return!r||n.some(e=>e!==r)?`yyyy/mm/dd`:Dc(t,r)??`yyyy/mm/dd`}function kc(e){let t=e.tokens.findIndex(e=>e.type===`hour`),n=e.tokens.find(e=>e.type===`min`),r=e.tokens.findIndex(e=>e.type===`ampm`),i=r<0?void 0:e.tokens[r];if(!(t>=0||n||e.tokens.some(e=>e.type===`sec`)||i))return null;let a=t<0?void 0:e.tokens[t],o=`${a!=null&&a.pad?`hh`:`h`}:${(n==null?void 0:n.pad)===!1?`m`:`mm`}:ss`;return!i||typeof i.value!=`string`?o:r<t?`${i.value} ${o}`:`${o} ${i.value}`}function Ac(e,t){let n=yc(t,e);if(!Sc(n)||n.tokens.some(e=>e.type.endsWith(`-elap`)))return null;let r=Oc(n),i=kc(n);return r&&i?`${r} ${i}`:r??i}function jc(e){return!!e&&`scale`in e}function Mc(e){return!!e&&`generated`in e&&!!e.generated}function Nc(e){return!!(jc(e[0])&&e[0].percent||jc(e[1])&&e[1].percent||jc(e[2])&&e[2].percent||jc(e[3])&&e[3].percent)}function Pc(e){return!!(jc(e[0])&&e[0].date||jc(e[1])&&e[1].date||jc(e[2])&&e[2].date||jc(e[3])&&e[3].date)}function Fc(e){let[t,n,r,i]=e;return!!((!t||Mc(t))&&(!n||Mc(n))&&(!r||Mc(r))&&jc(i)&&i.text&&!Mc(i))}let Ic={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},Lc=[[`DMY`,1],[`DM`,2],[`MY`,3],[`MDY`,4],[`MD`,5],[`hmsa`,6],[`hma`,7],[`hms`,8],[`hm`,9]];function Rc(e,t=null){let[n,r]=e;if(!n)throw TypeError(`Cannot read properties of undefined (reading 'frac_max')`);let i=jc(n)?n:void 0,a=jc(r)?r:void 0,o=`error`in n,s=i==null?void 0:i.frac_max,c={type:`general`,isDate:Pc(e),isText:Fc(e),isPercent:Nc(e),maxDecimals:i!=null&&i.general?9:s??0,scale:(i==null?void 0:i.scale)??1,color:0,parentheses:0,grouped:i!=null&&i.grouping?1:0,code:``,level:0},l=!c.isDate&&!c.isText&&!o&&n.tokens.some(e=>e.type===`string`&&typeof e.value==`string`&&(t?e.value===t:Jo.test(e.value))),u=`G`,d=s!==void 0&&s>=0?Math.min(15,s):``,f=``,p=``;if(a!=null&&a.color&&(p=`-`,c.color=1),i!=null&&i.parens&&(f=`()`,c.parentheses=1),l)u=`C`,c.type=`currency`;else if(o)c.type=`error`,c.maxDecimals=0;else if(c.isDate){let e=0,t=0,r=``;n.tokens.forEach(n=>{let i=n.type;/^(b-)?year/.test(i)?(r+=`Y`,t++):i.startsWith(`month`)?(r+=`M`,t++):/^(week)?day/.test(i)?(r+=`D`,t++):(i===`hour`||i===`min`||i===`sec`||i===`ampm`)&&(r+=i[0],e++)}),c.type=`date`,t&&e?c.type=`datetime`:!t&&e&&(c.type=`time`);let i=Lc.find(([e])=>r.startsWith(e));u=i?`D`:`G`,d=i?i[1]:``}else c.isText?(u=`G`,c.type=`text`,d=``,c.maxDecimals=0):i!=null&&i.general?(u=`G`,c.type=`general`,d=``):i!=null&&i.fractions?(u=`G`,c.type=`fraction`,d=``):i!=null&&i.exponential?(u=`S`,c.type=`scientific`):c.isPercent?(u=`P`,c.type=`percent`):i!=null&&i.grouping?(u=`,`,c.type=`grouped`):i&&(i.int_max||s)&&(u=`F`,c.type=`number`);return c.code=u+d+p+f,c.level=Ic[c.type],Object.freeze(c)}function zc(e){let[t]=e;if(!t)throw TypeError(`Cannot read properties of undefined (reading 'date')`);let n=jc(t)?t:void 0,r=(n==null?void 0:n.date)??0;return{year:!!(r&2),month:!!(r&4),day:!!(r&8),hours:!!(r&16),minutes:!!(r&32),seconds:!!(r&64),isDuration:(n==null?void 0:n.tokens.some(e=>e.type.endsWith(`-elap`)))??!1,clockType:(n==null?void 0:n.clock)===12?12:24}}let Bc={overflow:`######`,dateErrorThrows:!1,dateErrorNumber:!1,bigintErrorNumber:!1,dateSpanLarge:!1,leap1900:!0,dateSystem:`date1900`,nbsp:!1,throws:!0,invalid:`######`,locale:``,ignoreTimezone:!1,grouping:[3,3],indexColors:!0,skipChar:``,fillChar:``},Vc=[[po,/^General/i,0],[mo,/^#/,0],[ho,/^0/,0],[go,/^\?/,0],[_o,/^\//,0],[xo,/^;/,0],[So,/^@/,0],[Co,/^\+/,0],[wo,/^-/,0],[To,/^\./,0],[Eo,/^ /,0],[Do,/^%/,0],[Oo,/^[1-9]/,0],[ko,/^(?:B[12])/i,0],[Ao,/^B$/,0],[jo,/^(?:[hH]+|[mM]+|[sS]+|[yY]+|[bB]+|[dD]+|[gG]+|[aA]{3,}|e+)/,0],[Mo,/^(?:\[(h+|m+|s+)\])/i,1],[No,/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/,[1,2]],[Po,/^\[(DBNum[0-4]?\d)\]/i,1],[Fo,/^\[(NatNum[0-4]?\d)\]/i,1],[Io,/^\[\$([^\]]+)\]/,1],[Lo,/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*\d+)\]/i,1],[Ro,/^\[([^\]]+)\]/,1],[zo,/^(?:AM\/PM|am\/pm|A\/P)/,0],[Bo,/^\\(.)/,1],[Vo,/^"([^"]*?)"/,1],[Ho,/^_(\\.|.)/,1],[`exp`,/^[Ee]([+-])/,1],[Uo,/^\*(\\.|.)/,1],[Wo,/^[()]/,0],[Ao,/^[EÈÉÊËèéêëĒēĔĕĖėĘęĚěȄȅȆȇȨȩNnÑñŃńŅņŇňǸǹ["*/\\_]/,0],[Go,/^./,0]],Hc=e=>{let t=(e||`\0`).charCodeAt(0);return t===63||t===35||t>=48&&t<=57};function Uc(e){let t=0,n=[],r=[];for(;t<e.length;){let i=e.slice(t),a=0,o=/^(,+)(.)?/.exec(i);if(o){let i=o[1];a=i.length;let s=e[t-1]||``,c=!1,l=!1;Hc(s)?(c=!0,l=!0):s===`.`&&(l=!0);let u=o[2]||``;if(c&&(!u||u===`;`)&&(c=!1),l&&Hc(u)&&(l=!1),c&&!l)n.push({type:vo,value:`,`,raw:i});else if(!c&&l)n.push({type:yo,value:`,`,raw:i});else if(c&&l){let e={type:yo,value:`,`,raw:i};n.push(e),r.push(e)}else n.push({type:bo,value:`,`,raw:i})}else{let e;for(let[t,r,o]of Vc){let s=r.exec(i);if(s){e={type:t,value:typeof o==`number`?s[o||0]:o.map(e=>s[e]),raw:s[0]},n.push(e),a=s[0].length;break}}r.length&&(e==null?void 0:e.raw)===`;`&&(r.length=0),r.length&&Hc(e==null?void 0:e.raw)&&(r.forEach(e=>e.type=vo),r.length=0)}if(!a){let e=i[0];a=1,n.push({type:Go,value:e,raw:e})}t+=a}return n}function Wc(e){var t,n;let r=(t=e.condition)==null?void 0:t[0],i=(n=e.condition)==null?void 0:n[1];typeof i==`number`&&i<0&&(r===`<`||r===`<=`||r===`=`)||i===0&&r===`<`||e.tokens.unshift({type:`minus`,volatile:!0})}function Gc(e,t=null){let n={...e,int_pattern:[...e.int_pattern],frac_pattern:[...e.frac_pattern],man_pattern:[...e.man_pattern],den_pattern:[...e.den_pattern],num_pattern:[...e.num_pattern],tokens:[...e.tokens]};return e.condition&&(n.condition=[...e.condition]),t&&n.tokens.unshift(t),n.generated=!0,n}function Kc(e){let t=[],n=!1,r,i=null,a=0,o=0,s=0,c=Uc(e);do{var l;let e=ws(c);if((e.date||e.general)&&(e.int_pattern.length||e.frac_pattern.length||e.scale!==1||e.text))throw Error(`Illegal format`);if(e.condition&&(s++,n=!0),e.text){if(i)throw Error(`Unexpected partition`);i=e}e.locale&&(r=ss(e.locale)),t.push(e),a=+(((l=c[e.tokensUsed])==null?void 0:l.type)===`break`),c=c.slice(e.tokensUsed+a),o++}while(a&&o<4&&s<3);if(a)throw Error(`Unexpected partition`);if(s>2)throw Error(`Unexpected condition`);let u=t[3];if(u&&(u.int_pattern.length||u.frac_pattern.length||u.date))throw Error(`Unexpected partition`);if(n){t[0].condition||(t[0].condition=[`>`,0]);let e=t.length;if(e===1){let e=ws(Uc(`General`));e.generated=!0,t[1]=e}if(e<3){let e=t[0],n=t[1];if(Wc(e),n.condition)Wc(n);else{let t=e.condition;((t==null?void 0:t[0])===`=`||typeof(t==null?void 0:t[1])==`number`&&t[1]>=0&&(t[0]===`>`||t[0]===`>=`))&&n.tokens.unshift({type:`minus`,volatile:!0})}}else t.forEach(Wc)}else{if(t.length<4&&i)for(let e=0,n=t.length;e<n;e++)t[e]===i&&t.splice(e,1);if(t.length<1&&i){let e=ws(Uc(`General`));e.generated=!0,t[0]=e}if(t.length<2&&t.push(Gc(t[0],{type:`minus`,volatile:!0})),t.length<3&&t.push(Gc(t[0])),t.length<4)if(i)t.push(i);else{let e=ws(Uc(`@`));e.generated=!0,t.push(e)}t[0].condition=[`>`,0],t[1].condition=[`<`,0],t[2].condition=null}return{pattern:e,partitions:t,locale:r}}let qc=`!d-m-y.!d-m-Y.!j-m-y.!j-m-Y.!d-n-y.!d-n-Y.!j-n-y.!j-n-Y.?m-d-y.?m-d-Y.?m-j-y.?m-j-Y.?n-d-y.?n-d-Y.?n-j-y.?n-j-Y.d-M-y.d-M-Y.j-M-y.j-M-Y.M-d-y.M-d-Y.M-j-y.M-j-Y.d-F-y.d-F-Y.F-d-y.F-d-Y.F-j-y.F-j-Y.j-F-y.j-F-Y.y-F-d.y-F-j.y-M-d.y-M-j.Y-F-d.Y-F-j.Y-M-d.Y-m-d.Y-M-j.Y-m-j.Y-n-d.Y-n-j.j-F.j-M.d-F.d-M.n-d.n-j.n-Y.m-d.m-j.m-Y.M-Y.M-y.F-y.F-Y.Y-M.Y-n.Y-m.Y-F.Y-M`.split(`.`),Jc={j:`d`,d:`d`,D:`ddd`,l:`dddd`,n:`m`,m:`m`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Yc={j:`dd`,d:`dd`,D:`ddd`,l:`dddd`,n:`mm`,m:`mm`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Xc={},Zc={};function Qc(e,t,n=1){if(e){let r=e[0],i=e.slice(1);if(r===`!`)Qc(i,t,4);else if(r===`?`)Qc(i,t,2);else{let e=t[r];typeof e!=`object`&&(e={},t[r]=e),Qc(i,e,n)}}else t.$=n}function $c(e,t){Qc(e,t),Qc(`${e} x`,t),Qc(`${e} l`,t),Qc(`${e} l x`,t),Qc(`l ${e}`,t),Qc(`l ${e} x`,t),Qc(`${e} D`,t),Qc(`${e} D x`,t),Qc(`D ${e}`,t),Qc(`D ${e} x`,t)}qc.forEach(e=>{e.startsWith(`?`)||$c(e,Xc),e.startsWith(`!`)||$c(e,Zc)});let el={".":[`,`,`\xA0`,` `,`'`,`٬`],",":[`.`,`\xA0`,` `,`'`,`٬`],"٫":[`.`,`\xA0`,` `,`'`,`٬`]},tl=e=>(e==null?void 0:e.length)===1&&e>=`0`&&e<=`9`;function nl(e,t={}){let n=cs(t.locale||``)||us,r=n.decimal,i=[...el[r]||[`'`,`٬`]];!i.includes(n.group)&&n.group!==` `&&n.group!==r&&i.push(n.group);let a=``,o=``,s=1,c=``,l=!1,u=!1,d=!1,f=!1,p=!1,m=``,h=!1,g=0,_=[` `,`\xA0`,` `,`+`,`%`,`(`,`-`].concat(qo);for(;_.includes(e.charAt(g));){let t=e.charAt(g);if(t===`-`){if(l||u)return null;l=!0,s=-1}else if(Jo.test(t)){if(p)return null;p=!0,m=t}else if(t===`(`){if(u||l)return null;u=!0,s=-1}else if(t===`%`){if(f)return null;f=!0}g++}let v=!1,y;if(e.charAt(g)===r||tl(e.charAt(g)))for(;g<e.length;){let t=e.charAt(g);if(!y&&i.includes(t))y=t;else if(!(y&&y===t))if(t===r){if(v)break;a+=`.`,v=!0}else if(tl(t))a+=t;else break;g++}if(e.charAt(g)===`e`||e.charAt(g)===`E`){o+=e.charAt(g),g++,(e.charAt(g)===`+`||e.charAt(g)===`-`)&&(o+=e.charAt(g),g++);let t=g;for(;tl(e.charAt(g));)o+=e.charAt(g),g++;if(t===g)return null}let b=[` `,`\xA0`,` `,`%`,`$`,`)`].concat(qo);for(;b.includes(e.charAt(g));){let t=e.charAt(g);if(Jo.test(t)){if(p)return null;p=!0,m=t,h=!0}else if(t===`)`){if(d||!u)return null;d=!0}else if(t===`%`){if(f)return null;f=!0}g++}if(g!==e.length)return null;let x=Number.parseFloat(a+o);if(!Number.isFinite(x))return null;if(o){if(f||p)return null;c=`0.00E+00`}else if(f){if(p)return null;c=a.includes(`.`)?`0.00%`:`0%`,x*=.01}else if(p){let e=a.includes(`.`)?`#,##0.00`:`#,##0`;c=h?e+m:m+e}else y&&(c=a.includes(`.`)?`#,##0.00`:`#,##0`);let S={v:x*s};return c&&(S.z=c),S}function rl(e,t,n){if(n<1||t<1||t>12)return!1;if(t===2){if(n>(e%4==0&&e%100!=0||e%400==0||e===1900?29:28))return!1}else if((t===4||t===6||t===9||t===11)&&n>30||(t===1||t===3||t===5||t===7||t===8||t===10||t===12)&&n>31)return!1;return!0}let il=new WeakMap,al=(e,t,n=!1)=>{for(let r of t)if(e.startsWith(r[0])){let t=r[0].length;return n&&(r[2]===`D`||r[2]===`M`)&&e[t]===`.`&&t++,[e.slice(0,t),r]}return[``,null]},ol=(e,t,n,r)=>{let i=n.path||``,a=Object.keys(t);for(let o of a){let a=t[o],s;if(!a)continue;if(o===`$`||o===`€`)e||(s=n);else{if(typeof a!=`object`)continue;if(o===`-`){let t=/^(\s*([./-]|,\s)\s*|\s+)/.exec(e);if(t){let o=t[1]===`-`||t[1]===`/`||t[1]===`.`?t[1]:` `;if(!n.sep||n.sep===o){let c=t[0].replace(/\s+/g,` `);s=ol(e.slice(t[0].length),a,{...n,sep:o,path:i+c},r)}}}else if(o===` `){let t=/^[,.]?\s+/.exec(e);if(t){let o=t[0].replace(/\s+/g,` `);s=ol(e.slice(t[0].length),a,{...n,path:i+o},r)}}else if(o===`j`||o===`d`){let t=/^(0{1,2}|0?[1-9]|1\d|2\d|3[01])\b/.exec(e);t&&(s=ol(e.slice(t[0].length),a,{...n,day:t[0],path:i+o},r))}else if(o===`n`||o===`m`){let t=/^(0?[1-9]|1[012])\b/.exec(e);t&&(s=ol(e.slice(t[0].length),a,{...n,month:+t[0],_mon:t[0],path:i+o},r))}else if(o===`F`||o===`M`){let[t,c]=al(e,r.mon,r.mp);(c==null?void 0:c[2])===o&&(s=ol(e.slice(t.length),a,{...n,month:c[1],_mon:t,path:i+o},r))}else if(o===`l`||o===`D`){let[t,c]=al(e,r.day,r.dp);(c==null?void 0:c[2])===o&&(s=ol(e.slice(t.length),a,{...n,path:i+o},r))}else if(o===`y`){let t=/^\d\d\b/.exec(e);if(t){let c=+t[0]>=30?+t[0]+1900:+t[0]+2e3;s=ol(e.slice(t[0].length),a,{...n,year:c,path:i+o},r)}}else if(o===`Y`){let t=/^\d\d\d\d\b/.exec(e);t&&(s=ol(e.slice(t[0].length),a,{...n,year:+t[0],path:i+o},r))}else if(o===`x`){let t=pl(e,{locale:r.locale});t&&(s=ol(``,a,{...n,time:t.v,tf:t.z,path:i+o},r))}else throw Error(`Unknown date token "${o}"`)}let c=(s==null?void 0:s.year)||1916,l=(s==null?void 0:s.month)||1,u=s!=null&&s.day?+s.day:1,d=r.dateSystem===`date1900`&&c===1900&&l===1&&u===0;if(s&&(d||rl(c,l,u)))return s}},sl=e=>e.replace(/\s+/g,` `).trim().replace(/’/,`'`).replace(/\.$/,``).toLowerCase(),cl=(e,t)=>{let n=e.map((e,n)=>[sl(e),n+1,t]);return n.sort((e,t)=>t[0].length-e[0].length),n},ll=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),ul=e=>{let t=il.get(e);return(!t||!ll(e.mmmm,t.mmmm)||!ll(e.mmm,t.mmm)||!ll(e.dddd,t.dddd)||!ll(e.ddd,t.ddd))&&(t={lookups:{mon:cl(e.mmmm,`F`).concat(cl(e.mmm,`M`)),mp:e.mmm[0].endsWith(`.`),day:cl(e.dddd,`l`).concat(cl(e.ddd,`D`)),dp:e.ddd[0].endsWith(`.`)},mmmm:[...e.mmmm],mmm:[...e.mmm],dddd:[...e.dddd],ddd:[...e.ddd]},il.set(e,t)),t.lookups};function dl(e,t={}){let n=cs(t.locale||``)||us,r={...ul(n),locale:t.locale,dateSystem:t.dateSystem??`date1900`},i=ol(sl(e),n.preferMDY?Zc:Xc,{path:``},r);if(!i||i.sep===`.`&&i.path.length===3||i.month==null||i._mon==null)return null;let a=+(i.year??new Date().getUTCFullYear()),o=i.day??`1`,s=t.dateSystem??`date1900`,c=sc({year:a,month:i.month,day:+o,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s});if(c==null)return null;let l=c+(i.time||0);if(l>=sc({year:9999,month:12,day:31,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s})+1)return null;let u=i._mon[0]===`0`||o[0]===`0`||i._mon.length===2&&o.length===2;return{v:l,z:i.path.replace(/[jdlDnmMFyYx]/g,e=>e===`x`?i.tf||``:(u?Yc[e]:Jc[e])||e)}}let fl=e=>e.replace(/\s+/g,``).trim().replace(/\./g,``).toLowerCase();function pl(e,t={}){let n=cs(t.locale||``)||us,r=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?=\s*[^\s\d]|$)/.exec(e),i=``;if(r){let t=fl(e.slice(r[0].length));if(t===fl(n.ampm[0])||t===`a`||t===`am`)i=`a`;else if(t===fl(n.ampm[1])||t===`p`||t===`pm`)i=`p`;else if(t===`:`)r[3]||=`0`,r[2]||=`0`;else if(t)return null}if(!r)return null;let[,a,o,s,c]=r;if(c&&!s||!i&&!o&&!s)return null;let l=+(a||0);if(i){if(l>=13)return null;i===`a`?l===12&&(l=0):i===`p`&&l!==12&&(l+=12)}let u=+(o||0),d=+(s||0),f=+(c||0),p=a.length===2?`hh`:`h`,m=s?`:ss`:``,h=i?` AM/PM`:``;return{v:(l*60*60+u*60+d+f)/(3600*24),z:`${p}:mm${m}${h}`}}function ml(e,t={}){let n=cs(t.locale||``)||us,r=e.trim().toLowerCase(),i=n.bool[0].toLowerCase();if(r===`true`||r===i)return{v:!0};let a=n.bool[1].toLowerCase();return r===`false`||r===a?{v:!1}:null}function hl(e,t){return nl(e,t)??dl(e,t)??pl(e,t)??ml(e,t)}var gl=p({addLocale:()=>G,dateFromSerial:()=>fc,dateToSerial:()=>dc,dec2frac:()=>Es,format:()=>yl,formatColor:()=>bl,getDateTimeEditPattern:()=>Dl,getFormatDateInfo:()=>El,getFormatInfo:()=>Tl,getLocale:()=>cs,isDateFormat:()=>xl,isPercentFormat:()=>Sl,isTextFormat:()=>Cl,isValidFormat:()=>wl,parseBool:()=>ml,parseDate:()=>dl,parseLocale:()=>os,parseNumber:()=>nl,parseTime:()=>pl,parseValue:()=>hl,round:()=>Ms,tokenTypes:()=>Ol,tokenize:()=>Uc});let _l=Object.create({});function vl(e,t=!1){let n=e||`General`,r=_l[n];if(!r)try{r=Kc(n),_l[n]=r}catch(e){if(t)throw e;let i=e instanceof Error?e.message:String(e),a={tokens:[{type:`error`}],error:i};r={pattern:n,partitions:[a,a,a,a],error:i,locale:null}}return r}function yl(e,t,n={}){let r=Object.assign({},Bc,n),i=vl(e,r.throws);return xc(dc(t,r)??t,i,r)}function bl(e,t,n){let r=Object.assign({},Bc,n),i=vl(e,r.throws);return bc(dc(t,r)??t,i,r)}function xl(e){return Pc(vl(e,!1).partitions)}function Sl(e){return Nc(vl(e,!1).partitions)}function Cl(e){return Fc(vl(e,!1).partitions)}function wl(e){try{return vl(e,!0),!0}catch{return!1}}function Tl(e,t={}){let n=vl(e,!1);return n.info||=Rc(n.partitions,t==null?void 0:t.currency),n.info}function El(e){let t=vl(e,!1);return t.dateInfo||=zc(t.partitions),t.dateInfo}function Dl(e,t){return Ac(vl(e,!1).partitions,t)}let Ol=Object.freeze({AMPM:zo,BREAK:xo,CALENDAR:ko,CHAR:Go,COLOR:Lo,COMMA:bo,CONDITION:No,DATETIME:jo,DBNUM:Po,DIGIT:Oo,DURATION:Mo,ERROR:Ao,ESCAPED:Bo,EXP:`exp`,FILL:Uo,GENERAL:po,GROUP:vo,HASH:mo,LOCALE:Io,MINUS:wo,MODIFIER:Ro,NATNUM:Fo,PAREN:Wo,PERCENT:Do,PLUS:Co,POINT:To,QMARK:go,SCALE:yo,SKIP:Ho,SLASH:_o,SPACE:Eo,STRING:Vo,TEXT:So,ZERO:ho}),kl=new Set([`d`,`g`,`i`,`m`,`s`,`u`,`v`,`y`]);function Al(e,t){let n=jl(t);return new RegExp(e,n)}function jl(e){if(e===void 0)return;let t=new Set;for(let n of e){if(!kl.has(n)||t.has(n))throw SyntaxError(`Invalid regular expression flags: ${e}`);t.add(n)}return e}var Ml=class e{constructor(...e){T(this,`data`,void 0),this.data=Il(e.flatMap(e=>Pl(e)))}union(...t){return new e(this,...t)}subtract(...t){let n=Il(t.flatMap(e=>Pl(e))),r=this.data.slice();for(let[e,t]of n){let n=[];for(let[i,a]of r){if(t<i||e>a){n.push([i,a]);continue}e>i&&n.push([i,e-1]),t<a&&n.push([t+1,a])}r=n}return new e(...r)}intersect(...t){let n=Il(t.flatMap(e=>Pl(e))),r=[];for(let[e,t]of this.data)for(let[i,a]of n){let n=Math.max(e,i),o=Math.min(t,a);n<=o&&r.push([n,o])}return new e(...r)}isEmpty(){return this.data.length===0}toString(){return this.isEmpty()?`(?!)`:`[${this.data.map(Ll).join(``)}]`}toRegExp(e){return Al(this.toString(),e)}};let Nl=(...e)=>new Ml(...e);function Pl(e){if(e instanceof Ml)return e.data;if(Array.isArray(e)){let t=Fl(e[0]),n=Fl(e[1]);return[[Math.min(t,n),Math.max(t,n)]]}let t=Fl(e);return[[t,t]]}function Fl(e){if(typeof e==`number`){if(!Number.isInteger(e)||e<0||e>1114111)throw RangeError(`Invalid code point: ${e}`);return e}let t=e.codePointAt(0);if(t==null||String.fromCodePoint(t)!==e)throw RangeError(`Charset string inputs must contain exactly one code point: ${e}`);return t}function Il(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]),n=[];for(let[e,r]of t){let t=n[n.length-1];!t||e>t[1]+1?n.push([e,r]):t[1]=Math.max(t[1],r)}return n}function Ll([e,t]){return e===t?Rl(e):`${Rl(e)}-${Rl(t)}`}function Rl(e){let t=String.fromCodePoint(e);return t===`\\`||t===`]`||t===`-`||t===`^`?`\\${t}`:e<=31||e===127?`\\u${e.toString(16).padStart(4,`0`)}`:t}function zl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Bl(e,t){return Al(zl(e),t)}function Vl(e){return Al(`^${zl(e).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`)}$`,`i`)}var Hl=class e{constructor(...t){T(this,`charset`,void 0),T(this,`strings`,void 0);let n=[],r=[];for(let i of t)i instanceof e?(n.push(i.charset),r.push(...i.strings)):i instanceof Ml||typeof i==`number`||Array.isArray(i)?n.push(i):r.push(i);this.charset=Nl(...n),this.strings=Array.from(new Set(r))}union(...t){return new e(this,...t)}subtract(...t){let n=new e(...t),r=this.strings.filter(e=>!n.strings.includes(e));return new e(this.charset.subtract(n.charset),...r)}isEmpty(){return this.charset.isEmpty()&&this.strings.length===0}toString(){if(this.isEmpty())return`(?!)`;let e=[...this.charset.isEmpty()?[]:[this.charset.toString()],...this.strings.map(zl)];return e.length===1?e[0]:`(?:${e.join(`|`)})`}toRegExp(e){return Al(this.toString(),e)}};let Ul={Charset:Ml,Or:Hl,charset:Nl,or:(...e)=>new Hl(...e),createRegExpFromSafeFragment:Al,escapeRegExp:zl,createLiteralRegExp:Bl,createFromWildcard:Vl};function Wl(e){return e===`@@@`||e===`@`}function Gl(e){return e==null||e===`General`}function Kl(e){switch(e){case`frFR`:return`fr`;case`ruRU`:return`ru`;case`viVN`:return`vi`;case`zhCN`:return`zh-CN`;case`koKR`:return`ko`;case`zhTW`:return`zh-TW`;case`zhHK`:return`zh-HK`;case`esES`:case`caES`:return`es`;case`skSK`:return`sk`;case`jaJP`:return`ja`;case`ptBR`:return`pt`;case`deDE`:return`de`;case`itIT`:return`it`;case`idID`:return`id`;case`plPL`:return`pl`;case`arSA`:return`ar`;default:return`en`}}let ql=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Uc(e),n=``,r=!1,i=!1;for(let e of t){if(e.type===Ol.POINT){r=!0;continue}if(!(i&&e.type===Ol.MINUS)&&e.type!==Ol.SKIP){if(e.type===Ol.COLOR){i=!0;continue}else i=!1;r&&e.type===Ol.ZERO||(r=!1,r||(n+=e.value||``))}}return n};return n(e)===n(t)},Jl=new Set([`m d`]),Yl=new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),Xl=`Rp.zł.NT$.R$.HK$.$.£.¥.¤.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿.﷼`.split(`.`),Zl=RegExp(`^${Ul.charset(...Array.from(new Set(Xl.join(``))))}+`),Ql=(e,t={})=>{let n=dl(e,t)??pl(e,t)??nl(e,t);if(!n)return null;let{z:r}=n;if(r){if(Jl.has(r)||Yl.has(r)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(r.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e.replace(Zl,``).trim();if(t.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(t))return null}}return n};function $l(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function eu(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}let tu=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function nu(e,t,n){let r=eu(n),i=n;for(let t=r-1;t>=e;t--)tu(i[t])?delete i[t+1]:i[t+1]=i[t];tu(t)||(i[e]=t)}function ru(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function iu(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++)c[l]=n[r[e]];for(let e=0;e<s;e++,l++)c[l]=a[o[e]];return c}function au(e,t,n){let r=n;if(eu(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function ou(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?su(e,t,n,r):cu(e,t,n,r)}function su(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function cu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var lu=class e{constructor(e={}){T(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t??(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){ou(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{ou(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){ru(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&ru(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++)t[n]=this.getValue(e,a),n++;a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,B.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return eu(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=eu(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]??(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.clone()}getStartEndScope(){let e=-1,t=-1,n=-1,r=-1,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=n===-1?+t[0]:Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=eu(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function uu(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}function du(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function fu(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function pu(e){return fu(e)&&(e==null?void 0:e.coverable)!==!1}function mu(e){if(e){if(e.rgb)return new Ia(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=fo.Office)==null?void 0:t[e.th];if(n)return new Ia(n).toRgbString()}}return null}function hu(e){return B.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function gu(e){return B.isString(e)&&e.length>0}function _u(e,t=!1){let n=``,r=new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${mu(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${mu(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${mu(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${mu(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o;n+=`border-bottom: ${vu((o=e.bd)==null?void 0:o.b.s)} ${mu(e.bd.b.cl)??``}; `}if((r=e.bd)!=null&&r.t){var s;n+=`border-top: ${vu((s=e.bd)==null?void 0:s.t.s)} ${mu(e.bd.t.cl)??``}; `}if((i=e.bd)!=null&&i.r){var c;n+=`border-right: ${vu((c=e.bd)==null?void 0:c.r.s)} ${mu(e.bd.r.cl)??``}; `}if((a=e.bd)!=null&&a.l){var l;n+=`border-left: ${vu((l=e.bd)==null?void 0:l.l.s)} ${mu(e.bd.l.cl)??``}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${mu(e.cl)}; `)}],[`va`,()=>{e.va===2?n+=`vertical-align: sub; `:e.va===3&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===1?n+=`direction: ltr; `:e.td===2&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===1?n+=`text-align: left; `:e.ht===3?n+=`text-align: right; `:e.ht===2?n+=`text-align: center; `:e.ht===4&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===3?n+=`vertical-align: bottom; `:e.vt===1?n+=`vertical-align: top; `:e.vt===2&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===2?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===3&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function vu(e){let t=``;return e===0?t=`none`:e===1?t=`0.5pt solid`:e===2?t=`0.5pt double`:e===3?t=`0.5pt dotted`:e===4||e===5?t=`0.5pt dashed`:e===6?t=`0.5pt dotted`:e===7?t=`0.5pt double`:e===8?t=`1pt solid`:e===9||e===10?t=`1pt dashed`:e===11?t=`1pt dotted`:e===12?t=`0.5pt dashed`:e===13&&(t=`1.5pt solid`),t}function yu(e){let t=0;if(e=e.trim(),e===`none`)t=0;else if(e===`0.5pt solid`)t=1;else if(e===`0.5pt double`)t=2;else if(e===`0.5pt dotted`)t=3;else if(e===`0.5pt dashed`)t=4;else if(e===`1pt solid`)t=8;else if(e===`1pt dashed`)t=9;else if(e===`1pt dotted`)t=11;else if(e===`1.5pt solid`)t=13;else if(!e.includes(`none`))t=1;else return 0;return t}function bu(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function xu(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===2||!(Number.isNaN(i)&&Number.isNaN(a))&&o===1||o!==1&&o!==2&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function Su(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function Cu(e){if(hu(e))return{f:e,v:null,p:null};if(io(e)){if(typeof e==`string`){let t=Ql(e);if(t&&t.z)return{v:t.v,p:null,f:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null}}return to(e),e}function wu(e,t){let n=new lu,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(B.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,Cu(e[t][a]));else new lu(e).forValue((e,t,r)=>{n.setValue(e,t,Cu(r))});return n.getMatrix()}function Tu(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Tu(e[n],t[n])):e===t:!1}function Eu(e,t){let n=e.ts||{},r=t.ts||{};return e.sId===t.sId&&Tu(n,r)}function Du(e,t){return t.some(t=>e.indexOf(t)>-1)}let Ou=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],ku=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Au=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],ju=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Mu=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],Nu={L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`,l:`M/D/YYYY`,ll:`MMM D, YYYY`,lll:`MMM D, YYYY h:mm A`,llll:`ddd, MMM D, YYYY h:mm A`},Pu={millisecond:`millisecond`,milliseconds:`millisecond`,ms:`millisecond`,second:`second`,seconds:`second`,s:`second`,minute:`minute`,minutes:`minute`,m:`minute`,hour:`hour`,hours:`hour`,h:`hour`,day:`day`,days:`day`,d:`day`,week:`week`,weeks:`week`,w:`week`,month:`month`,months:`month`,M:`month`,year:`year`,years:`year`,y:`year`};var Fu=class e{constructor(e,t){this._date=e,this._isUTC=t}isValid(){return!Number.isNaN(this._date.getTime())}format(e=`YYYY-MM-DDTHH:mm:ssZ`){return this.isValid()?Xu(this._date,e,this._isUTC):`Invalid Date`}formatIntl(e,t={}){if(!this.isValid())return`Invalid Date`;if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)return this.format();let n=this._isUTC&&!t.timeZone?{...t,timeZone:`UTC`}:t;return new Intl.DateTimeFormat(e,n).format(this._date)}valueOf(){return this._date.getTime()}toDate(){return new Date(this.valueOf())}_clone(){return new e(this.toDate(),this._isUTC)}add(t,n=`millisecond`){let r=Vu(n);return!this.isValid()||!r||!Number.isFinite(t)?this._clone():new e(Wu(this._date,t,r,this._isUTC),this._isUTC)}subtract(e,t=`millisecond`){return this.add(-e,t)}startOf(t){let n=Vu(t);return!n||!this.isValid()?this._clone():new e(Gu(this._date,n,this._isUTC),this._isUTC)}endOf(e){let t=Vu(e);return!t||!this.isValid()||t===`millisecond`?this._clone():this.startOf(t).add(1,t).subtract(1,`millisecond`)}utc(){return new e(this.toDate(),!0)}local(){return new e(this.toDate(),!1)}weekday(e){let t=(Lu(this._date,this._isUTC).dayOfWeek-0+7)%7;return e===void 0?t:this.add(e-t,`day`)}week(e){let t=Ku(this._date,this._isUTC);return e===void 0?t:this.add((e-t)*7,`day`)}};function Iu(e,t=2){return String(Math.abs(e)).padStart(t,`0`)}function Lu(e,t){return t?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),millisecond:e.getUTCMilliseconds(),dayOfWeek:e.getUTCDay()}:{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),dayOfWeek:e.getDay()}}function Ru(e,t){return e instanceof Fu?e.toDate():e===void 0?new Date:e===null?new Date(NaN):e instanceof Date?new Date(e.getTime()):typeof e==`number`?new Date(e):typeof e==`string`?Bu(e,t):new Date(NaN)}function zu(e,t,n,r,i,a,o,s){let c=s?new Date(Date.UTC(e,t-1,n,r,i,a,o)):new Date(e,t-1,n,r,i,a,o),l=Lu(c,s);return l.year!==e||l.month!==t||l.day!==n||l.hour!==r||l.minute!==i||l.second!==a?new Date(NaN):c}function Bu(e,t){let n=e.trim();if(!n)return new Date(NaN);let r=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})日(?:\s+(\d{1,2})(?::(\d{1,2})(?::(\d{1,2}))?)?)?$/);if(r){let[,e,n,i,a=`0`,o=`0`,s=`0`]=r;return zu(Number(e),Number(n),Number(i),Number(a),Number(o),Number(s),0,t)}let i=n.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[ T](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?)?$/);if(i){let[,e,n,r,a=`0`,o=`0`,s=`0`,c=`0`]=i;return zu(Number(e),Number(n),Number(r),Number(a),Number(o),Number(s),Number(c),t)}return/^-?\d+(\.\d+)?$/.test(n)?new Date(Number(n)):new Date(n)}function Vu(e){return Pu[e]??Pu[String(e).toLowerCase()]}function Hu(e,t,n){return n?new Date(Date.UTC(e,t,0)).getUTCDate():new Date(e,t,0).getDate()}function Uu(e,t,n,r){let i=new Date(e.getTime());if(t){switch(n){case`year`:i.setUTCFullYear(r);break;case`month`:i.setUTCMonth(r);break;case`day`:i.setUTCDate(r);break;case`hour`:i.setUTCHours(r);break;case`minute`:i.setUTCMinutes(r);break;case`second`:i.setUTCSeconds(r);break;case`millisecond`:i.setUTCMilliseconds(r);break}return i}switch(n){case`year`:i.setFullYear(r);break;case`month`:i.setMonth(r);break;case`day`:i.setDate(r);break;case`hour`:i.setHours(r);break;case`minute`:i.setMinutes(r);break;case`second`:i.setSeconds(r);break;case`millisecond`:i.setMilliseconds(r);break}return i}function Wu(e,t,n,r){switch(n){case`millisecond`:return new Date(e.getTime()+t);case`second`:return new Date(e.getTime()+t*1e3);case`minute`:return new Date(e.getTime()+t*6e4);case`hour`:return new Date(e.getTime()+t*36e5);case`day`:return Uu(e,r,`day`,(r?e.getUTCDate():e.getDate())+t);case`week`:return Uu(e,r,`day`,(r?e.getUTCDate():e.getDate())+t*7);case`month`:{let n=Lu(e,r),i=zu(n.year,n.month,1,n.hour,n.minute,n.second,n.millisecond,r),a=Uu(i,r,`month`,(r?i.getUTCMonth():i.getMonth())+t),o=Lu(a,r),s=Hu(o.year,o.month,r);return Uu(a,r,`day`,Math.min(n.day,s))}case`year`:return Wu(e,t*12,`month`,r)}}function Gu(e,t,n){let r=Lu(e,n);switch(t){case`year`:return zu(r.year,1,1,0,0,0,0,n);case`month`:return zu(r.year,r.month,1,0,0,0,0,n);case`week`:{let e=(r.dayOfWeek-0+7)%7,t=zu(r.year,r.month,r.day,0,0,0,0,n);return Uu(t,n,`day`,(n?t.getUTCDate():t.getDate())-e)}case`day`:return zu(r.year,r.month,r.day,0,0,0,0,n);case`hour`:return zu(r.year,r.month,r.day,r.hour,0,0,0,n);case`minute`:return zu(r.year,r.month,r.day,r.hour,r.minute,0,0,n);case`second`:return zu(r.year,r.month,r.day,r.hour,r.minute,r.second,0,n);default:return new Date(e.getTime())}}function Ku(e,t){let n=Gu(e,`week`,t),r=Gu(Gu(e,`year`,t),`week`,t);return Math.floor((n.getTime()-r.getTime())/864e5/7)+1}function qu(e,t,n=!1){if(t)return n?`+0000`:`+00:00`;let r=-e.getTimezoneOffset(),i=r>=0?`+`:`-`,a=Math.abs(r),o=Iu(Math.floor(a/60),2),s=Iu(a%60,2);return n?`${i}${o}${s}`:`${i}${o}:${s}`}function Ju(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Yu(e){return e.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g,e=>Nu[e]??e)}function Xu(e,t,n){let r=Lu(e,n),i=r.hour%12,a=i===0?12:i,o=Math.ceil(r.month/3),s={YYYY:String(r.year),YY:Iu(r.year%100,2),MMMM:Ou[r.month-1],MMM:ku[r.month-1],MM:Iu(r.month,2),M:String(r.month),DD:Iu(r.day,2),D:String(r.day),Do:Ju(r.day),dddd:Au[r.dayOfWeek],ddd:ju[r.dayOfWeek],dd:Mu[r.dayOfWeek],d:String(r.dayOfWeek),HH:Iu(r.hour,2),H:String(r.hour),hh:Iu(a,2),h:String(a),mm:Iu(r.minute,2),m:String(r.minute),ss:Iu(r.second,2),s:String(r.second),SSS:Iu(r.millisecond,3),A:r.hour>=12?`PM`:`AM`,a:r.hour>=12?`pm`:`am`,Q:String(o),Qo:Ju(o),X:String(Math.floor(e.getTime()/1e3)),x:String(e.getTime()),Z:qu(e,n,!1),ZZ:qu(e,n,!0)},c=[];return Yu(t.replace(/\[([^\]]+)]/g,(e,t)=>`\u0000${c.push(t)-1}\u0000`)).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g,e=>s[e]??e).replace(/\u0000(\d+)\u0000/g,(e,t)=>c[Number(t)]??``)}function Zu(e){return new Fu(Ru(e,!1),!1)}let Qu=Object.assign(Zu,{utc:e=>new Fu(Ru(e,!0),!0),isDateKit:e=>e instanceof Fu,unix:e=>Zu(e*1e3)});function $u(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function ed(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function td(e){if(e==null)return!1;let t=e.paragraphStyle;return nd(t)}function nd(e){var t;return e!=null&&(e.indentStart!=null&&e.indentStart.v!==0||e.hanging!=null)&&((t=e.hanging)==null?void 0:t.v)!==0}function rd(e,t,n){return e.slice(0,t)+n+e.slice(t)}function id(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function ad(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t!==``&&!isNaN(Number(t))}return!1}function od(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function sd(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function cd(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function ld(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,Object.assign({},...t)}let ud,dd,fd,pd,q=Symbol(`newer`),J=Symbol(`older`);ud=Symbol.iterator;var md=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[ud](){return this}next(){let e=this.entry;return e?(this.entry=e[q],{done:!1,value:e.key}):{done:!0,value:void 0}}};dd=Symbol.iterator;var hd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[dd](){return this}next(){let e=this.entry;return e?(this.entry=e[q],{done:!1,value:e.value}):{done:!0,value:void 0}}};fd=Symbol.iterator;var gd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[fd](){return this}next(){let e=this.entry;return e?(this.entry=e[q],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},_d=class{constructor(e,t){T(this,`key`,void 0),T(this,`value`,void 0),T(this,q,void 0),T(this,J,void 0),this.key=e,this.value=t,this[q]=void 0,this[J]=void 0}toJSON(){return{key:this.key,value:this.value}}};pd=Symbol.iterator;var vd=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),D(()=>ze(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(T(this,`_keymap`,void 0),T(this,`size`,0),T(this,`limit`,void 0),T(this,`oldest`,void 0),T(this,`newest`,void 0),T(this,`_onShiftListeners`,[]),yd.hasLength(e,1)){if(yd.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(yd.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}return}if(yd.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[q]&&(e===this.oldest&&(this.oldest=e[q]),e[q][J]=e[J]),e[J]&&(e[J][q]=e[q]),e[q]=void 0,e[J]=this.newest,this.newest&&(this.newest[q]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new _d(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[q]=r,r[J]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new _d(e,t)),this.newest?(this.newest[q]=n,n[J]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[q]?(this.oldest=this.oldest[q],this.oldest[J]=void 0):(this.oldest=void 0,this.newest=void 0),e[q]=e[J]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[q]&&t[J]?(t[J][q]=t[q],t[q][J]=t[J]):t[q]?(t[q][J]=void 0,this.oldest=t[q]):t[J]?(t[J][q]=void 0,this.newest=t[J]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new md(this.oldest)}values(){return new hd(this.oldest)}entries(){return this[Symbol.iterator]()}[pd](){return new gd(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[q]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[q];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[q],t&&(e+=` < `);return e}},yd=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function bd(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}let xd=1048576,Sd=16384;function Cd(){let e=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`?crypto:typeof self<`u`&&self.crypto&&typeof self.crypto.getRandomValues==`function`?self.crypto:typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`?window.crypto:void 0;return e==null?void 0:e.getRandomValues.bind(e)}function wd(e,t){let n=``;for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Td(e,t,n){let r=256-256%t.length,i=Math.ceil(1.6*256*e/r),a=``;for(;a.length<e;){let o=n(new Uint8Array(i));for(let n=0;n<i&&a.length<e;n++){let e=o[n];e<r&&(a+=t[e%t.length])}}return a}function Ed(e=21,t=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`){if(!e)return``;let n=Cd();return n?Td(e,t,n):wd(e,t)}function Y(e=21,t){return Ed(e,t)}function Dd(e,t,n=0,r=e.length-1,i=kd){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);Dd(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(Od(e,n,t),i(e[r],a)>0&&Od(e,n,r);o<s;){for(Od(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?Od(e,n,s):(s++,Od(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function Od(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function kd(e,t){return e<t?-1:+(e>t)}var Ad=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!Hd(e,t))return n;let r=this.toBBox,i=[];for(;t;){for(let a=0;a<t.children.length;a++){let o=t.children[a],s=t.leaf?r(o):o;Hd(e,s)&&(t.leaf?n.push(o):Vd(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n}collides(e){let t=this.data;if(!Hd(e,t))return!1;let n=[];for(;t;){for(let r=0;r<t.children.length;r++){let i=t.children[r],a=t.leaf?this.toBBox(i):i;if(Hd(e,a)){if(t.leaf||Vd(e,a))return!0;n.push(i)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Ud([]),this}remove(e,t){if(!e)return this;let n=this.data,r=this.toBBox(e),i=[],a=[],o,s,c;for(;n||i.length;){if(n||(n=i.pop(),s=i[i.length-1],o=a.pop(),c=!0),n.leaf){let r=jd(e,n.children,t);if(r!==-1)return n.children.splice(r,1),i.push(n),this._condense(i),this}!c&&!n.leaf&&Vd(n,r)?(i.push(n),a.push(o),o=0,s=n,n=n.children[0]):s?(o++,n=s.children[o],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){let i=n-t+1,a=this._maxEntries,o;if(i<=a)return o=Ud(e.slice(t,n+1)),Md(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(a)),a=Math.ceil(i/a**(r-1))),o=Ud([]),o.leaf=!1,o.height=r;let s=Math.ceil(i/a),c=s*Math.ceil(Math.sqrt(a));Wd(e,t,n,c,this.compareMinX);for(let i=t;i<=n;i+=c){let t=Math.min(i+c-1,n);Wd(e,i,t,s,this.compareMinY);for(let n=i;n<=t;n+=s){let i=Math.min(n+s-1,t);o.children.push(this._build(e,n,i,r-1))}}return Md(o,this.toBBox),o}_chooseSubtree(e,t,n,r){for(;r.push(t),!(t.leaf||r.length-1===n);){let n=1/0,r=1/0,i;for(let a=0;a<t.children.length;a++){let o=t.children[a],s=Ld(o),c=zd(e,o)-s;c<r?(r=c,n=s<n?s:n,i=o):c===r&&s<n&&(n=s,i=o)}t=i||t.children[0]}return t}_insert(e,t,n){let r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),Pd(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)}_split(e,t){let n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);let a=this._chooseSplitIndex(n,i,r),o=Ud(n.children.splice(a,n.children.length-a));o.height=n.height,o.leaf=n.leaf,Md(n,this.toBBox),Md(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)}_splitRoot(e,t){this.data=Ud([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Md(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,i=1/0,a=1/0;for(let o=t;o<=n-t;o++){let t=Nd(e,0,o,this.toBBox),s=Nd(e,o,n,this.toBBox),c=Bd(t,s),l=Ld(t)+Ld(s);c<i?(i=c,r=o,a=l<a?l:a):c===i&&l<a&&(a=l,r=o)}return r||n-t}_chooseSplitAxis(e,t,n){let r=e.leaf?this.compareMinX:Fd,i=e.leaf?this.compareMinY:Id;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);let i=this.toBBox,a=Nd(e,0,t,i),o=Nd(e,n-t,n,i),s=Rd(a)+Rd(o);for(let r=t;r<n-t;r++){let t=e.children[r];Pd(a,e.leaf?i(t):t),s+=Rd(a)}for(let r=n-t-1;r>=t;r--){let t=e.children[r];Pd(o,e.leaf?i(t):t),s+=Rd(o)}return s}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Pd(t[r],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():Md(e[t],this.toBBox)}};function jd(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Md(e,t){Nd(e,0,e.children.length,t,e)}function Nd(e,t,n,r,i){i||=Ud(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let a=t;a<n;a++){let t=e.children[a];Pd(i,e.leaf?r(t):t)}return i}function Pd(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Fd(e,t){return e.minX-t.minX}function Id(e,t){return e.minY-t.minY}function Ld(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Rd(e){return e.maxX-e.minX+(e.maxY-e.minY)}function zd(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Bd(e,t){let n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,a-r)}function Vd(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Hd(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ud(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Wd(e,t,n,r,i){let a=[t,n];for(;a.length;){if(n=a.pop(),t=a.pop(),n-t<=r)continue;let o=t+Math.ceil((n-t)/r/2)*r;Dd(e,o,t,n,i),a.push(t,o,o,n)}}var Gd=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===0||t.rangeType===void 0&&e.rangeType===0)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===1&&t.rangeType===2||e.rangeType===2&&t.rangeType===1)return!0;if(e.rangeType===1&&t.rangeType===1)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===2&&t.rangeType===2)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?xd-1:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?Sd-1:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?xd-1:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?Sd-1:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new Ad;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:0}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===2),r=t.some(e=>e.rangeType===1),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?1:n?2:0}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return Zd(e)}static splitIntoGrid(e){return Jd(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=Qd(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};T(Gd,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),T(Gd,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[1,3].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[1,3].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[2,3].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[2,3].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),T(Gd,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),T(Gd,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),T(Gd,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case 1:r.startColumn+=t;break;case 2:r.startRow+=n;break;case 3:break;default:r.startRow+=n,r.startColumn+=t;break}switch(e.endAbsoluteRefType){case 1:r.endColumn+=t;break;case 2:r.endRow+=n;break;case 3:break;default:r.endRow+=n,r.endColumn+=t;break}return r});function Kd(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||0,o=i.endAbsoluteRefType||0,s=i.rangeType||0;if(!r&&a===3&&o===3)return i;let c=qd(i.startRow,n,i.startColumn,t,s),l=qd(i.endRow,n,i.endColumn,t,s);return r||a===0&&o===0?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===0?i={...i,startRow:c.row,startColumn:c.column}:a===2?i={...i,startRow:c.row}:a===1&&(i={...i,startColumn:c.column}),o===0?i={...i,endRow:l.row,endColumn:l.column}:o===2?i={...i,endRow:l.row}:o===1&&(i={...i,endColumn:l.column}),i)}function qd(e,t,n,r,i){return i===0?{row:e+t,column:n+r}:i===1?{row:e+t,column:n}:i===2?{row:e,column:n+r}:{row:e,column:n}}function Jd(e){let t=new Set,n=new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function Yd(e){e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let t={};for(let n of e)t[n.startRow]||(t[n.startRow]=[]),t[n.startRow].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startColumn-t.startColumn);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startColumn<=i.endColumn+1&&t.startRow===i.startRow&&t.endRow===i.endRow?i.endColumn=Math.max(i.endColumn,t.endColumn):(n.push(i),i=t)}n.push(i)}return n}function Xd(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function Zd(e){return Xd(Yd(Jd(e)))}function Qd(e,t){let n=[];return e.forEach(e=>{n.push(...Gd.subtract(e,t))}),Gd.mergeRanges(n)}function $d(e,t){let n=ef(e.startRow,e.endRow,t.startRow,t.endRow),r=ef(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:tf(e.rangeType,t.rangeType,i,a,o,s)}}function ef(e,t,n,r){let i=isNaN(e)?-1/0:e,a=isNaN(t)?1/0:t,o=isNaN(n)?-1/0:n,s=isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function tf(e,t,n,r,i,a){let o=e===void 0?nf(n,r,i,a):e,s=t===void 0?nf(n,r,i,a):t;return o===3||s===3?o===s?o:o===3?s:o:o===s?o:0}function nf(e,t,n,r){let i=!isNaN(e)&&!isNaN(t),a=!isNaN(n)&&!isNaN(r);return i&&a?0:i?1:a?2:3}var rf=class{constructor(e,t){T(this,`_values`,[]),T(this,`_keys`,[]),T(this,`_keyMaps`,new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function af(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function of(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function sf(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function cf(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function lf(e,t=!1){let n=97;return t&&(n=65),cf(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function uf(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function df(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function ff(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}let pf=function(e){return e.Text=`text`,e.SingleSelect=`singleSelect`,e.MultiSelect=`multiSelect`,e.Person=`person`,e.Group=`group`,e.Date=`date`,e.Attachment=`attachment`,e.Number=`number`,e.Checkbox=`checkbox`,e.Link=`link`,e.Formula=`formula`,e.Numbering=`numbering`,e.Phone=`phone`,e.Email=`email`,e.Progress=`progress`,e.Currency=`currency`,e.Rating=`rating`,e.RecordLink=`recordLink`,e.RecordId=`recordId`,e.CreatedBy=`createdBy`,e.UpdatedBy=`updatedBy`,e.CreatedAt=`createdAt`,e.UpdatedAt=`updatedAt`,e}({}),mf=function(e){return e.Parent=`parent`,e}({}),hf=function(e){return e.Grid=`grid`,e.Kanban=`kanban`,e.Calendar=`calendar`,e.Gantt=`gantt`,e.Gallery=`gallery`,e.Pivot=`pivot`,e}({}),gf={CELL:`cell`,ROW:`row`,COLUMN:`column`},_f={IS:`is`,IS_NOT:`isNot`,CONTAINS:`contains`,NOT_CONTAINS:`notContains`,IS_EMPTY:`isEmpty`,IS_NOT_EMPTY:`isNotEmpty`,GREATER_THAN:`greaterThan`,LESS_THAN:`lessThan`,BEFORE:`before`,AFTER:`after`},vf={EXACT:`exact`,TODAY:`today`,TOMORROW:`tomorrow`,YESTERDAY:`yesterday`,THIS_WEEK:`thisWeek`,LAST_WEEK:`lastWeek`,THIS_MONTH:`thisMonth`,LAST_MONTH:`lastMonth`,PAST_7_DAYS:`past7`,NEXT_7_DAYS:`next7`,PAST_30_DAYS:`past30`,NEXT_30_DAYS:`next30`},yf=function(e){return e.IS=`is`,e.IS_NOT=`isNot`,e.CONTAINS=`contains`,e.NOT_CONTAINS=`notContains`,e.IS_EMPTY=`isEmpty`,e.IS_NOT_EMPTY=`isNotEmpty`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.BEFORE=`before`,e.AFTER=`after`,e}({}),bf=function(e){return e.AND=`and`,e.OR=`or`,e}({}),xf=function(e){return e.ASC=`asc`,e.DESC=`desc`,e}({}),Sf=function(e){return e.MissingParent=`missingParent`,e.SelfParent=`selfParent`,e.Cycle=`cycle`,e.MaxDepth=`maxDepth`,e}({}),Cf=`__record_id`,wf=`record-id`,Tf=/^[A-Za-z0-9_-]+$/;function Ef(){return{id:Cf,name:wf,type:`recordId`,config:{},system:!0,readonly:!0}}function Df(e){return Tf.test(e)}function Of(e){return e.trim().toLowerCase()===wf}function kf(e){let t=e.fields[Cf],n=Object.values(e.fields).filter(e=>e.type===`recordId`);if(!t||n.length!==1||t.type!==`recordId`||t.name!==`record-id`||t.system!==!0||t.readonly!==!0||e.fieldOrder[0]!==`__record_id`||e.primaryFieldId===`__record_id`||!e.fields[e.primaryFieldId])throw Error(`[BaseDataModel]: table "${e.id}" has an invalid record-id system field.`);let r=Object.values(e.fields).find(e=>e.id!==`__record_id`&&Of(e.name));if(r)throw Error(`[BaseDataModel]: field name "${r.name}" is reserved for the record-id system field.`);for(let[t,n]of Object.entries(e.records))if(n.id!==t||!Df(n.id)||n.values.__record_id!==n.id)throw Error(`[BaseDataModel]: record "${t}" has an invalid record-id projection.`)}function Af(e){let t=e.now??Date.now(),n=e.primaryFieldId??Y(6),r=e.gridViewId??Y(6),i=e.recordCount??0,a=Ef(),o={id:n,name:e.primaryFieldName??`Name`,type:`text`,config:{placeholder:`bases.fieldConfig.textPlaceholder`}},s={},c=[],l={},u={},d={};for(let n=0;n<i;n++){let r=`${e.id}-record-${n+1}`;s[r]={id:r,values:{[Cf]:r},orderKey:String(n+1).padStart(4,`0`),createdAt:t,updatedAt:t},c.push(r),l[r]=n,u[n]=r,d[n]={0:{v:r,t:1}}}let f={id:r,tableId:e.id,name:`Grid`,type:`grid`,fieldOrder:[Cf,n],fieldSettings:{[Cf]:{hidden:!0}},config:{frozenFieldCount:1}};return{id:e.id,name:e.name,primaryFieldId:n,fieldOrder:[Cf,n],fields:{[Cf]:a,[n]:o},records:s,recordOrder:c,rowIndex:l,rowId:u,colIndex:{[Cf]:0,[n]:1},colId:{0:Cf,1:n},cellData:d,resources:{attachmentSets:{},attachments:{}},views:{[r]:f},viewOrder:[r]}}function jf(e=Y(),t=``,n=`zhCN`){let r=Date.now(),i=`table-1`;return{id:e,name:t,locale:n,appVersion:Re,schemaVersion:2,tableOrder:[i],tables:{[i]:Af({id:i,name:`Table 1`,now:r,recordCount:0})},createdAt:r,updatedAt:r}}var Mf=class extends M{constructor(e={}){super(),T(this,`type`,n.UniverType.UNIVER_BASE),T(this,`_name$`,void 0),T(this,`name$`,void 0),T(this,`_snapshot`,void 0);let r=jf();this._snapshot=Nf(B.commonExtend(r,e)),this._snapshot.id||(this._snapshot.id=`base-${Math.random().toString(36).slice(2,10)}`),this._name$=new t.BehaviorSubject(this._snapshot.name),this.name$=this._name$.asObservable()}getUnitId(){return this._snapshot.id}setName(e){this._snapshot.name=e,this._snapshot.updatedAt=Date.now(),this._name$.next(e)}getSnapshot(){return this._snapshot}checkTableName(e){return Object.values(this._snapshot.tables).some(t=>t.name.toLowerCase()===e.toLowerCase())}uniqueTableName(e){let t=e,n=1;for(;this.checkTableName(t);)t=`${e}${n}`,n++;return t}setSnapshot(e){Pf(e)?this._snapshot=e:this._snapshot=Nf(e),this._name$.next(e.name)}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}dispose(){super.dispose(),this._name$.complete()}};function Nf(e){return delete e.compress,delete e.kind,Object.values(e.tables??{}).forEach(e=>{kf(e),If(e),Gf(e)}),e}function Pf(e){return Object.values(e.tables??{}).every(e=>Ff(e))}function Ff(e){let t=e.records??{},n=e.fields??{};if(kf(e),!Array.isArray(e.recordOrder)||!e.rowIndex||!e.rowId||!e.colIndex||!e.colId||!e.cellData||!e.resources||!e.resources.attachmentSets||!e.resources.attachments||Object.keys(t).length!==e.recordOrder.length)return!1;for(let n=0;n<e.recordOrder.length;n++){var r;let i=e.recordOrder[n];if(!t[i]||e.rowIndex[i]!==n||e.rowId[n]!==i||((r=e.cellData[n])==null||(r=r[0])==null?void 0:r.v)!==i)return!1}for(let t=0;t<e.fieldOrder.length;t++){let r=e.fieldOrder[t];if(n[r]&&(e.colIndex[r]!==t||e.colId[t]!==r))return!1}return!0}function If(e){Lf(e);let t=e.records??{},n=e.fields??{},r=Rf(e,t),i=zf(e,n);e.recordOrder=r,Bf(e),Vf(e,n),Hf(e,t,r),Uf(e,n,i),Wf(e,t,n)}function Lf(e){let t=e.cd;t&&!e.cellData&&(e.cellData=Object.create(null),t.forEach(([t,n,r])=>{e.cellData[t]=e.cellData[t]??{};let{c:i,...a}=r;e.cellData[t][n]=a}),delete e.cd)}function Rf(e,t){var n;let r=((n=e.recordOrder)==null?void 0:n.filter(e=>t[e]))??[],i=new Set(r),a=Object.values(t).filter(e=>!i.has(e.id));return a.length?[...r,...a.sort((e,t)=>e.orderKey.localeCompare(t.orderKey)).map(e=>e.id)]:r}function zf(e,t){return e.fieldOrder.filter(e=>t[e])}function Bf(e){e.rowIndex={...e.rowIndex},e.rowId={...e.rowId},e.colIndex={...e.colIndex},e.colId={...e.colId},e.cellData={...e.cellData},e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments}}function Vf(e,t){Object.entries(e.cellData??{}).forEach(([n,r])=>{let i=Number(n);e.cellData[i]={...r},Object.entries(e.cellData[i]??{}).forEach(([n,r])=>{var a;let o=Number(n),s=(a=e.colId)==null?void 0:a[o];e.cellData[i][o]=qf(r,s?t[s]:void 0)})})}function Hf(e,t,n){n.forEach((t,n)=>{e.rowIndex[t]??(e.rowIndex[t]=n)}),Object.entries(e.rowIndex??{}).forEach(([n,r])=>{t[n]&&(e.rowId[r]=n)})}function Uf(e,t,n){n.forEach((t,n)=>{e.colIndex[t]??(e.colIndex[t]=n)}),Object.entries(e.colIndex??{}).forEach(([n,r])=>{t[n]&&(e.colId[r]=n)})}function Wf(e,t,n){let r=e.rowIndex??{},i=e.colIndex??{},a=e.cellData??{};e.rowIndex=r,e.colIndex=i,e.cellData=a,Object.values(t).forEach(t=>{let o=r[t.id];o!=null&&(a[o]={...a[o]},a[o][0]={v:t.id,t:1},Object.entries(t.values??{}).forEach(([r,s])=>{let c=n[r];(c==null?void 0:c.type)===`attachment`&&Yf(e,t.id,r,s);let l=i[r];if(l==null)return;let u=a[o][l];if(u!=null){a[o][l]=qf(u,c),Zf(u,c,s)&&(a[o][l]=Kf(s,c));return}a[o][l]=Kf(s,c)}))})}function Gf(e){for(let a of Object.values(e.records)){var t,n,r,i;let o=(t=e.rowIndex)==null?void 0:t[a.id];if(o==null||((n=e.colIndex)==null?void 0:n.__record_id)!==0||((r=e.colId)==null?void 0:r[0])!==`__record_id`||((i=e.cellData)==null||(i=i[o])==null||(i=i[0])==null?void 0:i.v)!==a.id)throw Error(`[BaseDataModel]: record "${a.id}" is missing its record-id cell projection.`)}}function Kf(e,t){if(Jf(e))return(t==null?void 0:t.type)===`attachment`?{...e,v:``,t:1}:qf(e,t);if((t==null?void 0:t.type)===`attachment`)return{v:``,t:1};if(Qf(t))return{v:$f(e).join(`, `),t:1};if((t==null?void 0:t.type)===`link`&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return{v:String(t.text??t.url??``),t:1}}return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?{v:e,t:tp(e)}:{v:null,t:null}}function qf(e,t){let n=np(e.t,e.v);if(n===void 0){let{t,...n}=e;return n}return{...e,t:n}}function Jf(e){return!!e&&typeof e==`object`&&(Object.prototype.hasOwnProperty.call(e,`v`)||Object.prototype.hasOwnProperty.call(e,`t`)||Object.prototype.hasOwnProperty.call(e,`p`)||Object.prototype.hasOwnProperty.call(e,`f`)||Object.prototype.hasOwnProperty.call(e,`si`))}function Yf(e,t,n,r){let i=Xf(r);e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments};let a=`${n}${t}`;e.resources.attachmentSets[a]=i.map((t,n)=>{let r=String(t.id??`${a}${n}`),i={...t,id:r};return e.resources.attachments[r]=i,r})}function Xf(e){if(e==null||e===``||Jf(e)&&!(`id`in e)&&!(`name`in e))return[];let t=Array.isArray(e)?e:[e],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`){let e={...r};Object.keys(e).length>0&&n.push(e);continue}n.push({id:`attachment-${e}`,name:String(r)})}return n}function Zf(e,t,n){return(t==null?void 0:t.type)===`recordId`?e.v!==n:(t==null?void 0:t.type)===`attachment`?e.v!==``:Qf(t)?Array.isArray(n)&&(e.v==null||e.v===``):!1}function Qf(e){return(e==null?void 0:e.type)===`multiSelect`||(e==null?void 0:e.type)===`person`||(e==null?void 0:e.type)===`group`}function $f(e){if(e==null||e===``)return[];let t=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++){let r=ep(e[n]);r&&t.push(r)}return t}let n=String(e).split(`,`);for(let e=0;e<n.length;e++){let r=n[e].trim();r&&t.push(r)}return t}function ep(e){if(e==null)return``;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`){let t=e;return String(t.id??t.name??t.text??``)}return String(e)}function tp(e){return e==null?null:typeof e==`number`?2:typeof e==`boolean`?3:1}function np(e,t){return e===1||e===2||e===3||e===4||e==null?e:tp(t??null)}function rp(e){let t=e.trim().replace(/[^A-Za-z0-9_.]+/g,`_`),n=/[A-Za-z0-9]/.test(t)?t:`Table`,r=/^[A-Za-z_]/.test(n)?n:`_${n}`;return(/^[RC]$/i.test(r)||/^[A-Za-z]{1,3}[1-9]\d*$/.test(r)||/^R(?:\d+)?C(?:\d+)?$/i.test(r)?`_${r}`:r).slice(0,255)}function ip(e){let t=new Map,n=new Set,r=new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let r=pp(e.formulaName);!r||n.has(r.toLowerCase())||(n.add(r.toLowerCase()),t.set(e.id,r))}for(let e of i){if(t.has(e.id))continue;let i=op(e.name,n,e.formulaName,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function ap(e,t,n){return op(e,new Set(Array.from(t,e=>e.toLowerCase())),n)}function op(e,t,n,r=new Map){let i=pp(n);if(i&&!t.has(i.toLowerCase()))return i;let a=rp(e),o=a.toLowerCase();if(!t.has(o))return a;let s=r.get(o)??2;for(;;){let e=`_${s++}`,n=`${a.slice(0,255-e.length)}${e}`;if(!t.has(n.toLowerCase()))return r.set(o,s),n}}function sp(e,t){return ip(t).get(e.id)??rp(e.name)}function cp(e,t){return lp(t)(e)}function lp(e,t=ip(e)){let n=gp(dp(e,t));return e=>vp(e,n)}function up(e){let t=ip(e),n=lp(e,t);for(let n of Object.values(e.tables))n.formulaName=t.get(n.id)??rp(n.name);for(let t of Object.values(e.tables)){for(let e of Object.values(t.fields)){var r;e.type===`formula`&&typeof((r=e.config)==null?void 0:r.formula)==`string`&&(e.config.formula=n(e.config.formula))}for(let e of Object.values(t.cellData??{}))for(let t of Object.values(e??{}))t&&typeof t.f==`string`&&(t.f=n(t.f))}}function dp(e,t=ip(e)){let n=fp(e),r=new Map(Array.from(t,([e,t])=>[t.toLowerCase(),e])),i=new Map;for(let t of Object.values(e.tables)){let e=t.name.toLowerCase();i.set(e,(i.get(e)??0)+1)}return Object.values(e.tables).flatMap(e=>{let a=t.get(e.id)??rp(e.name),o=[e.id,_p(e.id),n.get(e.id),e.formulaName];return i.get(e.name.toLowerCase())===1&&o.push(e.name),o.filter(e=>!!e).flatMap(e=>[e,mp(e)]).filter(e=>!!e).filter(e=>e.toLowerCase()!==a.toLowerCase()).filter(t=>{let n=r.get(hp(t).toLowerCase());return n==null||n===e.id}).map(e=>({alias:e,formulaName:a}))}).sort((e,t)=>t.alias.length-e.alias.length)}function fp(e){let t=new Map,n=new Set,r=new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let i=op(e.name,n,void 0,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function pp(e){let t=e==null?void 0:e.trim();return t&&rp(t)===t?t:void 0}function mp(e){return/[^A-Za-z0-9_.]/.test(e)?`'${e.replaceAll(`'`,`''`)}'`:void 0}function hp(e){return e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1).replaceAll(`''`,`'`):e}function gp(e){let t=new Map;for(let{alias:n,formulaName:r}of e){let e=n.toLowerCase();t.has(e)||t.set(e,r)}let n=Array.from(t.keys()).sort((e,t)=>t.length-e.length);return{formulaNameByAlias:t,pattern:n.length?RegExp(`(${n.map(yp).join(`|`)})(\\s*)\\[`,`gi`):void 0}}function _p(e){return`_T_${Array.from(e,e=>{var t;return/[A-Za-z0-9]/.test(e)?e:`_x${((t=e.codePointAt(0))==null?void 0:t.toString(16))??`0`}_`}).join(``)}`}function vp(e,t){if(!t.pattern)return e;let n=0,r=!1;return t.pattern.lastIndex=0,e.replace(t.pattern,(i,a,o,s)=>{r=bp(e,n,s,r),n=s;let c=e[s-1];if(c!=null&&/[A-Za-z0-9_.]/.test(c)||c===`!`||r)return i;let l=t.formulaNameByAlias.get(a.toLowerCase());return l?`${l}${o}[`:i})}function yp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bp(e,t,n,r){let i=r;for(let r=t;r<n;r++)if(e[r]===`"`){if(i&&e[r+1]===`"`){r++;continue}i=!i}return i}var xp=f(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?this.maxPending=e.maxPending:this.maxPending=n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)f(!1,Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),Sp=h(f(((e,t)=>{t.exports=xp()}))());let Cp=new Set([`true`,`false`]);function wp(e){return Cp.has(e.toLowerCase())}let Tp=`__INTERNAL_EDITOR__`,Ep=`${Tp}DOCS_NORMAL`,Dp=`${Tp}DOCS_FORMULA_BAR`,Op=`${Tp}COMMENT_EDITOR`,kp=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`);function Ap(e){return`${Tp}${e}`}function jp(e){return e.startsWith(Tp)}function Mp(e){return e.startsWith(Op)}let Np=function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Pp=function(e){return e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e[e.DRAWING_IMAGE=0]=`DRAWING_IMAGE`,e[e.DRAWING_SHAPE=1]=`DRAWING_SHAPE`,e[e.DRAWING_CHART=2]=`DRAWING_CHART`,e[e.DRAWING_TABLE=3]=`DRAWING_TABLE`,e[e.DRAWING_SMART_ART=4]=`DRAWING_SMART_ART`,e[e.DRAWING_VIDEO=5]=`DRAWING_VIDEO`,e[e.DRAWING_GROUP=6]=`DRAWING_GROUP`,e[e.DRAWING_UNIT=7]=`DRAWING_UNIT`,e[e.DRAWING_DOM=8]=`DRAWING_DOM`,e[e.DRAWING_BLOCK=9]=`DRAWING_BLOCK`,e}({});function Fp(e,t){let n=Math.max(0,t-1);return Math.max(0,Math.min(Math.floor(e),n))||0}function Ip(e,t,n){let r=Fp(e,t);return n===2?Fp(t-1,t):n===0?Fp(r+1,t):n===1?Fp(r-1,t):0}function Lp(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}function Rp(){}function zp(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(n=a,e.apply(this,i))}}let Bp=function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function Vp(e){return`sheet_interceptor_${e}`}let Hp=e=>function(t,n){let r=-1,i=t,a=!1,o=e=>(a=!0,e);for(let t=0;t<e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);r=t;let s=e[t];if(a=!1,i=s.handler(i,n,o),!a)break}return i};var Up=class{constructor(e){T(this,`_interceptorsByName`,new Map),T(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){let n=e,r=this._interceptorsByName.get(n);return t&&(r=r.filter(t)),Hp(r||[])}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);return r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0))),()=>ze(this._interceptorsByName.get(n),t)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}};function Wp(e){return`sheet_async_interceptor_${e}`}let Gp=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var Kp=class{constructor(e){T(this,`_asyncInterceptorsByName`,new Map),T(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){let n=e,r=this._asyncInterceptorsByName.get(n);return t&&(r=r.filter(t)),Gp(r||[])}async interceptAsync(e,t){let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);return r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0))),()=>ze(this._asyncInterceptorsByName.get(n),t)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}};function qp(e){return e.map(e=>e/255)}function Jp(e){return e.map(e=>Math.round(e*255))}function Yp([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4;break}o/=6}return[o,s,a]}function Xp(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Zp(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Qp(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}let $p={r:1,g:1,b:1},em={r:0,g:0,b:0},tm=Xp($p.r,$p.g,$p.b),nm=Xp(em.r,em.g,em.b);function rm(e){let t=Xp(e[0],e[1],e[2]),n=Zp(tm,t),r=Yp(e),i=1-r[2],a,o,s;do a=Qp(r[0],r[1],i),o=Xp(a[0],a[1],a[2]),s=Zp(o,nm),i+=.01;while(i<=1&&i>=0&&Math.abs(s-n)<.01);return a}function im(e){return Jp(rm(qp(e)))}let am=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function om(e){let t=e[0],n=e[1],r=e[2],i=[am[0][0]*t+am[0][1]*n+am[0][2]*r+am[0][4],am[1][0]*t+am[1][1]*n+am[1][2]*r+am[1][4],am[2][0]*t+am[2][1]*n+am[2][2]*r+am[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function sm(e){return Jp(om(qp(e)))}var cm=class{constructor(){T(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function lm(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function um(e){return/^-?\d+(\.\d+)?$/.test(e)}function dm(e){return um(e)?Number(e)<=2**53-1:!1}function fm(e){return Number(e)>2**53-1||e.length>=18}var pm=class e{constructor(){T(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},mm=class e{constructor(){T(this,`_data`,new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function hm(e){let t=new MessageChannel,n=!1,r=()=>{t.port1.onmessage=null,t.port1.close(),t.port2.close()},i=()=>{n||(n=!0,r(),e())};return t.port1.onmessage=i,t.port2.postMessage(null),()=>{n||(n=!0,r())}}function gm(e,t){return t.forEach(t=>e.add(t)),e}let _m=`section_`;function vm(e){let t=`${_m}${Y(12)}`;for(;e.has(t);)t=`${_m}${Y(12)}`;return e.add(t),t}function ym(e,t,n=!0){let r=B.deepClone(e);return n&&bm(r.sectionId)&&!t.has(r.sectionId)?(t.add(r.sectionId),r):(r.sectionId=vm(t),r)}function bm(e){return typeof e==`string`&&e.startsWith(`section_`)&&e.length>8}let xm=function(e){return e.PARAGRAPH=`PARAGRAPH`,e.SECTION_BREAK=`SECTION_BREAK`,e.TABLE=`TABLE`,e.TABLE_ROW=`TABLE_ROW`,e.TABLE_CELL=`TABLE_CELL`,e.COLUMN_GROUP=`COLUMN_GROUP`,e.COLUMN=`COLUMN`,e.BLOCK=`BLOCK`,e.CUSTOM_BLOCK=`CUSTOM_BLOCK`,e}({}),Sm=function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
2
- `,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.COLUMN_GROUP_START=``,e.COLUMN_START=``,e.COLUMN_END=``,e.COLUMN_GROUP_END=``,e.BLOCK_START=``,e.BLOCK_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({}),Cm=new Set([`\r`,`
3
- `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\v`,`\f`,`\0`,`\b`]),wm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Bopomofo}\u3000-\u303F\uFF00-\uFFEF]/u,Tm=/\p{Script=Hangul}/u,Em=2e4;function Dm(){return{words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0}}function Om(e){if(e!=null&&e.aborted)throw Error(`Document statistics calculation aborted`)}function km(e){return Om(e),new Promise(e=>{setTimeout(e,0)})}function Am(e,t){if(!(t!=null&&t.length))return[e];let n=t.filter(e=>!e.collapsed).map(t=>({startOffset:Math.max(0,Math.min(t.startOffset,t.endOffset)),endOffset:Math.min(e.length,Math.max(t.startOffset,t.endOffset))})).filter(e=>e.startOffset<e.endOffset).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),r=[];for(let e of n){let t=r.at(-1);t&&e.startOffset<=t.endOffset?t.endOffset=Math.max(t.endOffset,e.endOffset):r.push({...e})}return r.map(t=>e.slice(t.startOffset,t.endOffset))}function jm(e){return Array.from(e).every(e=>Cm.has(e))}async function Mm(e,t){let{locale:n,ranges:r,signal:i}=t,a=n==null?void 0:be[n].tag,o=new Intl.Segmenter(a,{granularity:`grapheme`}),s=new Intl.Segmenter(a,{granularity:`word`}),c=Dm();await km(i),Om(i);for(let t of Am(e,r)){let e=0,n=!1;for(let{segment:r}of o.segment(t))Om(i),r.includes(`\r`)&&(n&&(c.paragraphs+=1),n=!1),jm(r)||(c.charactersWithSpaces+=1,/^\s+$/u.test(r)||(c.charactersWithoutSpaces+=1,n=!0),wm.test(r)&&(c.asianCharactersAndKoreanWords+=1)),e+=r.length,e>=Em&&(e=0,await km(i));let r=0;for(let e of s.segment(t))Om(i),e.isWordLike&&!wm.test(e.segment)&&(Tm.test(e.segment)?c.asianCharactersAndKoreanWords+=1:c.nonAsianWords+=1),r+=e.segment.length,r>=Em&&(r=0,await km(i))}return Om(i),c.words=c.nonAsianWords+c.asianCharactersAndKoreanWords,c}let Nm=function(e){return e.PARAGRAPH=`paragraph`,e.BLOCK_RANGE=`blockRange`,e.TABLE=`table`,e.CUSTOM_BLOCK=`customBlock`,e.COLUMN_GROUP=`columnGroup`,e}({}),Pm=function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),Fm=function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),Im=function(e){return e[e.BULLET=0]=`BULLET`,e[e.NONE=1]=`NONE`,e[e.DECIMAL=2]=`DECIMAL`,e[e.DECIMAL_ZERO=3]=`DECIMAL_ZERO`,e[e.UPPER_LETTER=4]=`UPPER_LETTER`,e[e.LOWER_LETTER=5]=`LOWER_LETTER`,e[e.UPPER_ROMAN=6]=`UPPER_ROMAN`,e[e.LOWER_ROMAN=7]=`LOWER_ROMAN`,e[e.ORDINAL=8]=`ORDINAL`,e[e.CARDINAL_TEXT=9]=`CARDINAL_TEXT`,e[e.ORDINAL_TEXT=10]=`ORDINAL_TEXT`,e[e.HEX=11]=`HEX`,e[e.CHICAGO=12]=`CHICAGO`,e[e.IDEOGRAPH_DIGITAL=13]=`IDEOGRAPH_DIGITAL`,e[e.JAPANESE_COUNTING=14]=`JAPANESE_COUNTING`,e[e.AIUEO=15]=`AIUEO`,e[e.IROHA=16]=`IROHA`,e[e.DECIMAL_FULL_WIDTH=17]=`DECIMAL_FULL_WIDTH`,e[e.DECIMAL_HALF_WIDTH=18]=`DECIMAL_HALF_WIDTH`,e[e.JAPANESE_LEGAL=19]=`JAPANESE_LEGAL`,e[e.JAPANESE_DIGITAL_TEN_THOUSAND=20]=`JAPANESE_DIGITAL_TEN_THOUSAND`,e[e.DECIMAL_ENCLOSED_CIRCLE=21]=`DECIMAL_ENCLOSED_CIRCLE`,e[e.DECIMAL_FULL_WIDTH2=22]=`DECIMAL_FULL_WIDTH2`,e[e.AIUEO_FULL_WIDTH=23]=`AIUEO_FULL_WIDTH`,e[e.IROHA_FULL_WIDTH=24]=`IROHA_FULL_WIDTH`,e[e.GANADA=25]=`GANADA`,e[e.CHOSUNG=26]=`CHOSUNG`,e[e.DECIMAL_ENCLOSED_FULLSTOP=27]=`DECIMAL_ENCLOSED_FULLSTOP`,e[e.DECIMAL_ENCLOSED_PAREN=28]=`DECIMAL_ENCLOSED_PAREN`,e[e.DECIMAL_ENCLOSED_CIRCLE_CHINESE=29]=`DECIMAL_ENCLOSED_CIRCLE_CHINESE`,e[e.IDEOGRAPH_ENCLOSED_CIRCLE=30]=`IDEOGRAPH_ENCLOSED_CIRCLE`,e[e.IDEOGRAPH_TRADITIONAL=31]=`IDEOGRAPH_TRADITIONAL`,e[e.IDEOGRAPH_ZODIAC=32]=`IDEOGRAPH_ZODIAC`,e[e.IDEOGRAPH_ZODIAC_TRADITIONAL=33]=`IDEOGRAPH_ZODIAC_TRADITIONAL`,e[e.TAIWANESE_COUNTING=34]=`TAIWANESE_COUNTING`,e[e.IDEOGRAPH_LEGAL_TRADITIONAL=35]=`IDEOGRAPH_LEGAL_TRADITIONAL`,e[e.TAIWANESE_COUNTING_THOUSAND=36]=`TAIWANESE_COUNTING_THOUSAND`,e[e.TAIWANESE_DIGITAL=37]=`TAIWANESE_DIGITAL`,e[e.CHINESE_COUNTING=38]=`CHINESE_COUNTING`,e[e.CHINESE_LEGAL_SIMPLIFIED=39]=`CHINESE_LEGAL_SIMPLIFIED`,e[e.CHINESE_COUNTING_THOUSAND=40]=`CHINESE_COUNTING_THOUSAND`,e[e.KOREAN_DIGITAL=41]=`KOREAN_DIGITAL`,e[e.KOREAN_COUNTING=42]=`KOREAN_COUNTING`,e[e.KOREAN_LEGAL=43]=`KOREAN_LEGAL`,e[e.KOREAN_DIGITAL2=44]=`KOREAN_DIGITAL2`,e[e.VIETNAMESE_COUNTING=45]=`VIETNAMESE_COUNTING`,e[e.RUSSIAN_LOWER=46]=`RUSSIAN_LOWER`,e[e.RUSSIAN_UPPER=47]=`RUSSIAN_UPPER`,e[e.NUMBER_IN_DASH=48]=`NUMBER_IN_DASH`,e[e.HEBREW1=49]=`HEBREW1`,e[e.HEBREW2=50]=`HEBREW2`,e[e.ARABIC_ALPHA=51]=`ARABIC_ALPHA`,e[e.ARABIC_ABJAD=52]=`ARABIC_ABJAD`,e[e.HINDI_VOWELS=53]=`HINDI_VOWELS`,e[e.HINDI_CONSONANTS=54]=`HINDI_CONSONANTS`,e[e.HINDI_NUMBERS=55]=`HINDI_NUMBERS`,e[e.HINDI_COUNTING=56]=`HINDI_COUNTING`,e[e.THAI_LETTERS=57]=`THAI_LETTERS`,e[e.THAI_NUMBERS=58]=`THAI_NUMBERS`,e[e.THAI_COUNTING=59]=`THAI_COUNTING`,e[e.CUSTOM=60]=`CUSTOM`,e}({}),Lm=function(e){return e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]=`BULLET_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e[e.BOTH=4]=`BOTH`,e}({}),Rm=function(e){return e.CALLOUT=`callout`,e.QUOTE=`quote`,e.CODE=`code`,e}({}),zm=function(e){return e[e.HYPERLINK=0]=`HYPERLINK`,e[e.FIELD=1]=`FIELD`,e[e.SDT=2]=`SDT`,e[e.BOOKMARK=3]=`BOOKMARK`,e[e.COMMENT=4]=`COMMENT`,e[e.CUSTOM=5]=`CUSTOM`,e[e.MENTION=6]=`MENTION`,e[e.UNI_FORMULA=7]=`UNI_FORMULA`,e[e.FOOTNOTE=8]=`FOOTNOTE`,e[e.ENDNOTE=9]=`ENDNOTE`,e[e.DELTED=9999]=`DELTED`,e}({}),Bm=function(e){return e.COLUMN=`column`,e.TEXT_WRAPPING=`textWrapping`,e}({}),Vm=function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),Hm=function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),Um=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e}({}),Wm=function(e){return e[e.DEFAULT=0]=`DEFAULT`,e[e.LINES=1]=`LINES`,e[e.LINES_AND_CHARS=2]=`LINES_AND_CHARS`,e[e.SNAP_TO_CHARS=3]=`SNAP_TO_CHARS`,e}({}),Gm=function(e){return e[e.SECTION_TYPE_UNSPECIFIED=0]=`SECTION_TYPE_UNSPECIFIED`,e[e.CONTINUOUS=1]=`CONTINUOUS`,e[e.NEXT_COLUMN=2]=`NEXT_COLUMN`,e[e.NEXT_PAGE=3]=`NEXT_PAGE`,e[e.EVEN_PAGE=4]=`EVEN_PAGE`,e[e.ODD_PAGE=5]=`ODD_PAGE`,e}({}),Km=function(e){return e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]=`COLUMN_SEPARATOR_STYLE_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.BETWEEN_EACH_COLUMN=2]=`BETWEEN_EACH_COLUMN`,e}({}),qm=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),Jm=function(e){return e[e.TEXT_RUN=0]=`TEXT_RUN`,e[e.AUTO_TEXT=1]=`AUTO_TEXT`,e[e.PAGE_BREAK=2]=`PAGE_BREAK`,e[e.COLUMN_BREAK=3]=`COLUMN_BREAK`,e[e.FOOT_NOTE_REFERENCE=4]=`FOOT_NOTE_REFERENCE`,e[e.HORIZONTAL_RULE=5]=`HORIZONTAL_RULE`,e[e.EQUATION=6]=`EQUATION`,e[e.DRAWING=7]=`DRAWING`,e[e.PERSON=8]=`PERSON`,e[e.RICH_LINK=9]=`RICH_LINK`,e}({}),Ym=function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),Xm=function(e){return e[e.INLINE=0]=`INLINE`,e[e.WRAP_NONE=1]=`WRAP_NONE`,e[e.WRAP_POLYGON=2]=`WRAP_POLYGON`,e[e.WRAP_SQUARE=3]=`WRAP_SQUARE`,e[e.WRAP_THROUGH=4]=`WRAP_THROUGH`,e[e.WRAP_TIGHT=5]=`WRAP_TIGHT`,e[e.WRAP_TOP_AND_BOTTOM=6]=`WRAP_TOP_AND_BOTTOM`,e}({}),Zm=function(e){return e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]=`NAMED_STYLE_TYPE_UNSPECIFIED`,e[e.NORMAL_TEXT=1]=`NORMAL_TEXT`,e[e.TITLE=2]=`TITLE`,e[e.SUBTITLE=3]=`SUBTITLE`,e[e.HEADING_1=4]=`HEADING_1`,e[e.HEADING_2=5]=`HEADING_2`,e[e.HEADING_3=6]=`HEADING_3`,e[e.HEADING_4=7]=`HEADING_4`,e[e.HEADING_5=8]=`HEADING_5`,e}({}),Qm=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),$m=function(e){return e[e.DASH_STYLE_UNSPECIFIED=0]=`DASH_STYLE_UNSPECIFIED`,e[e.SOLID=1]=`SOLID`,e[e.DOT=2]=`DOT`,e[e.DASH=3]=`DASH`,e}({}),eh=function(e){return e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]=`TAB_STOP_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e}({}),th=function(e){return e[e.TAB_STOP_LEADER_UNSPECIFIED=0]=`TAB_STOP_LEADER_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.DOT=2]=`DOT`,e[e.HYPHEN=3]=`HYPHEN`,e[e.UNDERSCORE=4]=`UNDERSCORE`,e[e.HEAVY=5]=`HEAVY`,e[e.MIDDLE_DOT=6]=`MIDDLE_DOT`,e}({}),nh=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),rh=function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),ih=function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),ah=function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),oh=function(e){return e.FIXED=`fixed`,e.AUTO=`auto`,e}({}),sh=function(e){return e.STACK=`stack`,e.SHRINK=`shrink`,e}({}),ch=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),lh=function(e){return e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]=`CONTENT_ALIGNMENT_UNSPECIFIED`,e[e.BOTH=1]=`BOTH`,e[e.TOP=2]=`TOP`,e[e.CENTER=3]=`CENTER`,e[e.BOTTOM=4]=`BOTTOM`,e}({}),uh=function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),dh=function(e){return e[e.PAGE=0]=`PAGE`,e[e.COLUMN=1]=`COLUMN`,e[e.CHARACTER=2]=`CHARACTER`,e[e.MARGIN=3]=`MARGIN`,e[e.INSIDE_MARGIN=4]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=5]=`OUTSIDE_MARGIN`,e[e.LEFT_MARGIN=6]=`LEFT_MARGIN`,e[e.RIGHT_MARGIN=7]=`RIGHT_MARGIN`,e}({}),fh=function(e){return e[e.PAGE=0]=`PAGE`,e[e.PARAGRAPH=1]=`PARAGRAPH`,e[e.LINE=2]=`LINE`,e[e.MARGIN=3]=`MARGIN`,e[e.TOP_MARGIN=4]=`TOP_MARGIN`,e[e.BOTTOM_MARGIN=5]=`BOTTOM_MARGIN`,e[e.INSIDE_MARGIN=6]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=7]=`OUTSIDE_MARGIN`,e}({}),ph=function(e){return e[e.POINT=0]=`POINT`,e[e.LINE=1]=`LINE`,e[e.CHARACTER=2]=`CHARACTER`,e[e.PIXEL=3]=`PIXEL`,e[e.PERCENT=4]=`PERCENT`,e}({}),mh=function(e){return e[e.CENTER=0]=`CENTER`,e[e.INSIDE=1]=`INSIDE`,e[e.LEFT=2]=`LEFT`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.RIGHT=4]=`RIGHT`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTE=6]=`DISTRIBUTE`,e}({}),hh=function(e){return e[e.BOTTOM=0]=`BOTTOM`,e[e.CENTER=1]=`CENTER`,e[e.INSIDE=2]=`INSIDE`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.TOP=4]=`TOP`,e}({}),gh=function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),_h=function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),vh=function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({}),yh=[`A3`,`A4`,`A5`,`B4`,`B5`,`Letter`,`Tabloid`,`Legal`,`Statement`,`Executive`,`Folio`];function bh(){return e=>e}let xh=bh()([`s`,`c`,`cl`,`t`]),Sh=bh()([`rgb`,`th`]),Ch=bh()([`s`,`cl`]),wh=bh()([`t`,`r`,`b`,`l`,`tl_br`,`tl_bc`,`tl_mr`,`bl_tr`,`ml_tr`,`bc_tr`]),Th=bh()([`a`,`v`]),Eh=bh()([`t`,`r`,`b`,`l`]),Dh=bh()([`ff`,`eastAsiaFontFamily`,`fs`,`it`,`bl`,`ul`,`bbl`,`st`,`ol`,`bg`,`bd`,`cl`,`va`,`n`,`stf`,`tr`,`td`,`ht`,`vt`,`tb`,`pd`]),Oh={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},kh={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ah={startRow:0,startColumn:0,endRow:0,endColumn:0},jh={row:0,column:0},Mh={ff:`Arial`,fs:11,it:0,bl:0,ul:{s:0},st:{s:0},ol:{s:0},tr:{a:0,v:0},td:0,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:0,vt:0,tb:0,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},Nh=[Ep,Dp],Ph={4:{fs:20,bl:1},5:{fs:18,bl:1},6:{fs:16,bl:1},7:{fs:14,bl:1},8:{fs:12,bl:1},1:null,2:{fs:26,bl:1},3:{fs:15,cl:{rgb:`#999999`}},0:null},Fh=1.5,Ih={4:{spaceAbove:{v:20},spaceBelow:{v:10}},5:{spaceAbove:{v:18},spaceBelow:{v:10}},6:{spaceAbove:{v:16},spaceBelow:{v:10}},7:{spaceAbove:{v:14},spaceBelow:{v:8}},8:{spaceAbove:{v:12},spaceBelow:{v:8}},1:{spaceAbove:{v:0},spaceBelow:{v:12}},2:{spaceAbove:{v:0},spaceBelow:{v:7}},3:{spaceAbove:{v:0},spaceBelow:{v:16}},0:null},Lh=function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({}),Rh={A3:{width:1123,height:1587},A4:{width:794,height:1124},A5:{width:559,height:794},B4:{width:944,height:1344},B5:{width:665,height:944},Executive:{width:696,height:1008},Folio:{width:816,height:1248},Legal:{width:816,height:1344},Letter:{width:816,height:1056},Statement:{width:528,height:816},Tabloid:{width:1056,height:1632}},zh=function(e){return e.NARROW=`narrow`,e.MEDIUM=`medium`,e.WIDE=`wide`,e}({}),Bh={narrow:Rh.A4.width,medium:960,wide:Rh.A3.width},Vh=`para_`;function Hh(e){let t=`${Vh}${Y(12)}`;for(;e.has(t);)t=`${Vh}${Y(12)}`;return e.add(t),t}function Uh(e,t){let n=Kh(e),r=new Set;for(let e of n.paragraphs??[])e.paragraphId=Hh(r);return n}function Wh(e,t,n){let r=qh(e);return n!==!1&&Gh(r.paragraphId)&&!t.has(r.paragraphId)?(t.add(r.paragraphId),r):(r.paragraphId=Hh(t),r)}function Gh(e){return typeof e==`string`&&e.startsWith(`para_`)&&e.length>5}function Kh(e){return JSON.parse(JSON.stringify(e))}function qh(e){return JSON.parse(JSON.stringify(e))}function Jh(e=Y(6),t=`enUS`,n=``,r=2){let i={id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},notes:{},noteSettings:{},body:{dataStream:`\r
4
- `,textRuns:[],customBlocks:[],tables:[],columnGroups:[],blockRanges:[],customRanges:[],customDecorations:[],paragraphs:[{startIndex:0,paragraphId:Hh(new Set),paragraphStyle:{lineSpacing:1}}],sectionBreaks:[{sectionId:vm(new Set),startIndex:1}]},documentStyle:{pageSize:Rh.A4,documentFlavor:r,marginTop:72,marginBottom:72,marginRight:72,marginLeft:72,autoHyphenation:1,doNotHyphenateCaps:0,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:0,useFirstPageHeaderFooter:0,marginHeader:30,marginFooter:30},settings:{}};return r===2&&(i.body.paragraphs[0].paragraphStyle={},i.documentStyle.defaultParagraphStyle={spaceAbove:{v:0},lineSpacing:Fh,spaceBelow:{v:12}},i.documentStyle.pageSize={width:Bh.medium,height:842/.75},i.documentStyle.marginTop=50,i.documentStyle.marginBottom=50,i.documentStyle.marginRight=50,i.documentStyle.marginLeft=50,i.documentStyle.renderConfig={zeroWidthParagraphBreak:0,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}}),i}var Yh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),Xh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}else return e}e.default=t})),Zh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a??s,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),Qh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||={})})),$h=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),eg=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=$h(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`);break}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s;break}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(!(!n||n.d===0||n.d===``))if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1])if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n;else t.push(n)},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}else if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;else{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}break}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}break}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i);break}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d));break}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),tg=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=eg(),n=$h();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),ng=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)Object.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;let a=$h(),o=r(eg()),s=i(tg()),c={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=a.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(a.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:o.uniSlice},l=o.default(c);e.type=Object.assign(Object.assign({},l),{api:s.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>o.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var u=eg();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})})),rg=f((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let n=t(Yh()),r=t(Xh()),i=Zh(),a=Qh(),o=()=>{};function s(e,t){if(!e)throw Error(t)}let c=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:i.readCursor,writeCursor:i.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){c=e,o.quiet=!e},registerSubtype:y,checkValidOp:D,normalize:O,apply:k,transformPosition:A,compose:j,tryTransform:L,transform:z,makeInvertible:P,invert:M,invertWithDoc:F,RM_UNEXPECTED_CONTENT:a.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:a.ConflictType.DROP_COLLISION,BLACKHOLE:a.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>ne(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>ne(t,e,n,r)})};let l=e=>e?e.getComponent():null;function u(e){return e&&typeof e==`object`&&!Array.isArray(e)}let d=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,f=e=>e&&(e.p!=null||e.r!==void 0),p=e=>e&&(e.d!=null||e.i!==void 0);function m(e,t){return s(e!=null),typeof t==`number`?(s(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(s(u(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function h(e,t,n){return typeof t==`number`?(s(e!=null,`Container is missing for key`),s(Array.isArray(e),`Cannot use numerical key for object container`),s(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(s(u(e),`Cannot insert into missing item`),s(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>i.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>i.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>i.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>i.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>i.writeCursor().at(e,e=>w(e,t,n,r)).get();let g=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),_=(e,t)=>g(e,t)?e[t]:void 0,v={};function y(e){let t=e.type?e.type:e;t.name&&(v[t.name]=t),t.uri&&(v[t.uri]=t)}let b=e=>{let t=v[e];if(t)return t;throw Error(`Missing type: `+e)};y(ng());let x=(e,t)=>e+t;y({name:`number`,apply:x,compose:x,invert:e=>-e,transform:e=>e});let S=e=>e==null?null:e.et?b(e.et):e.es?v[`text-unicode`]:e.ena==null?null:v.number,C=e=>e.es?e.es:e.ena==null?e.e:e.ena,w=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[b(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function T(e){s(typeof e==`number`),s(e>=0),s(e===(0|e))}function E(e){typeof e==`number`?T(e):s(typeof e==`string`)}function D(e){if(e===null)return;let t=new Set,n=new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,s(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)T(o),s(!t.has(o)),t.add(o),s(e.r===void 0);else if(a===`d`)T(o),s(!n.has(o)),n.add(o),s(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){s(!i),i=!0;let t=S(e);s(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(C(e))}}s(!r)},a=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||E(e[0]);let o=1,c=0,l=0;for(let t=0;t<e.length;t++){let u=e[t];if(s(u!=null),Array.isArray(u)){let e=a(u,!1,n);if(c){let t=typeof l,n=typeof e;t===n?s(l<e,`descent keys are not in order`):s(t===`number`&&n===`string`)}l=e,c++,o=3}else typeof u==`object`?(s(o===1,`Prev not scalar - instead ${o}`),r(u),o=2):(s(o!==3),E(u),s(i.isValidPathItem(u),`Invalid path key`),o=1)}return s(c!==1,`Operation makes multiple descents. Remove some []`),s(o===2||o===3),e[0]};a(e,!0,!1),s(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)s(t.has(e)),s(n.has(e))}function O(e){let t=0,n=[],r=i.writeCursor();return r.mergeTree(e,(e,r)=>{let i=S(e);if(i){let t=C(e);w(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]??(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function k(e,t){if(o.quiet=!c,D(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},c=0,l=o,u=`root`;function f(){for(;c<a;c++){let e=r[c];typeof e!=`object`&&(s(g(l,u)),l=l[u]=d(l[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(f(),i=l[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(f(),i=h(l,u,t.i)):(f(),i=h(l,u,n[t.d]));let e=S(t);if(e)f(),i=l[u]=e.apply(i,C(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=_(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=_(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===_(n,e)?n:t===void 0?m(n,e):(c=e,l=t,(o=d(o=n))[c]=l,o)}else f(e)&&(s(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,c,l;return t}(e,t),t)}function A(e,t){e=e.slice(),D(t);let n=i.readCursor(t),r,a,o=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(o=!1,r=l.p,a=t):o=!0),t>=e.length)break;let u=0,d=i.advancer(n,void 0,(e,t)=>{f(t)&&u++});s.unshift(d);let p=d(c);if(typeof c==`number`&&(e[t]-=u),!p)break}if(s.forEach(e=>e.end()),o)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(a))}for(;t<e.length;t++){let r=e[t],a=l(n),o=S(a);if(o){let n=C(a);o.transformPosition&&(e[t]=o.transformPosition(e[t],n));break}let s=0,c=i.advancer(n,(e,t)=>p(t)?~(e-s):e-s,(e,t)=>{p(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function j(e,t){if(D(e),D(t),e==null)return t;if(t==null)return e;let n=0,r=i.readCursor(e),a=i.readCursor(t),o=i.writeCursor(),c=[],u=[],d=[],m=[],h=[],g=[],_=new Set;r.traverse(null,e=>{e.p!=null&&(d[e.p]=r.clone())}),a.traverse(null,e=>{e.d!=null&&(m[e.d]=a.clone())});let v=i.writeCursor();return function e(t,r,a,o,v,y,b,x){s(r||a);let T=l(r),E=l(a),D=!!E&&E.r!==void 0,O=!!T&&T.i!==void 0,k=T?T.d:null,A=E?E.p:null,j=(y||D)&&A==null;if(A!=null)o=m[A],b=u[A]=new i.WriteCursor;else if(E&&E.r!==void 0)o=null;else{let e=l(o);e&&e.d!=null&&(o=null)}let M=l(o);if(k!=null)if(t=d[k],x=c[k]=new i.WriteCursor,j)y&&!D&&x.write(`r`,!0);else{let e=h[k]=n++;b.write(`d`,e)}else if(T&&T.i!==void 0)t=null;else{let e=l(t);e&&e.p!=null&&(t=null)}let N;O?(s(v===void 0),N=T.i):N=v;let P=(A==null?!O||y||D:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||O)){let e=k==null?n++:h[k];g[A]=e,x.write(`p`,e)}}else D&&(O||v!==void 0||(E.r,x.write(`r`,E.r)));let F=j?null:S(T),I=S(M);if((F||I)&&(F&&F.name,I&&I.name),F&&I){s(F===I);let e=C(T),t=C(M),n=F.compose(e,t);w(b,F,n),_.add(M)}else F?w(b,F,C(T)):I&&(w(b,I,C(M)),_.add(M));let L=typeof N==`object`&&!!N,R=!1,z=0,ee=0,te=0,ne=0,re=0,B=i.advancer(o,(e,t)=>p(t)?ne-e-1:e-ne,(e,t)=>{p(t)&&ne++}),ie=i.advancer(t,(e,t)=>f(t)?z-e-1:e-z,(e,t)=>{f(t)&&z++});if(i.eachChildOf(r,a,(t,n,r)=>{let i,a,o=t,c=t,u=t;if(typeof t==`number`){let e=t+te;a=B(e),c=e+ne;let d=t+ee;i=ie(d),p(l(a))&&(i=null),o=d+z,u=t+re,s(o>=0,`p1PickKey is negative`),s(c>=0,`p2DropKey is negative`);let m=p(l(n)),h=f(l(r));(m||h&&!j)&&re--,m&&ee--,h&&te--}else i=ie(t),a=B(t);x.descend(o),b.descend(c);let d=L&&!p(l(n))?N[u]:void 0,m=e(i,n,r,a,d,j,b,x);var h,g,_;L&&!j?d!==m&&(R||=(N=Array.isArray(N)?N.slice():Object.assign({},N),!0),h=N,_=m,typeof(g=u)==`number`?(s(Array.isArray(h)),s(g<h.length)):(s(!Array.isArray(h)),s(h[g]!==void 0)),_===void 0?typeof g==`number`?h.splice(g,1):delete h[g]:h[g]=_):s(m===void 0),b.ascend(),x.ascend()}),ie.end(),B.end(),P!=null)P.i=N;else if(!y&&!D&&A==null)return N}(r,r.clone(),a,a.clone(),void 0,!1,o,v),o.reset(),o.mergeTree(v.get()),o.reset(),o.get(),c.map(e=>e.get()),u.map(e=>e.get()),r.traverse(o,(e,t)=>{let n=e.p;if(n!=null){let e=h[n];e!=null&&t.write(`p`,e);let r=c[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),o.reset(),o.get(),a.traverse(o,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=u[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=S(e);r&&!_.has(e)&&w(t,r,C(e))}),o.get()}function M(e){if(e==null)return null;let t=new i.ReadCursor(e),n=new i.WriteCursor,r,a=[],o=[];return function e(t,n,i){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),a[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),i=void 0),o.i!==void 0&&(i=s=o.i);let e=S(o);e&&(i===void 0?(r||=new Set,r.add(o)):(C(o),i=e.apply(i,C(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let a=typeof r==`number`?r-l:r,o=_(i,a);p(t.getComponent())&&l++;let s=e(t,n,o);if(i!==void 0&&s!==void 0){if(c||(c=!0,i=d(i)),!g(i,a))throw Error(`Cannot modify child - invalid operation`);i[a]=s}n.ascend()}if(s===void 0)return c?i:void 0;n.write(`r`,i)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=a[e],s=o[e]=i.writeCursor()),r.has(c)){let e=S(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);w(s,e,e.invert(C(c)))}}let l=0,u=0,d=i.advancer(t,(e,t)=>f(t)?l-e-1:e-l,(e,t)=>{f(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),p(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),o.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=o[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let N=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?N(e,t):t(e)));function P(e,t){if(e==null||!N(e,e=>{var t;return e.r!==void 0||((t=S(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new i.ReadCursor(e),a=new i.WriteCursor,o=!1,c=[],l=[],u=(e,t,n)=>{let i=e.getComponent(),a=!1;if(i){i.d!=null&&t.write(`d`,i.d),i.i!==void 0&&t.write(`i`,i.i);let r=i.p;if(r!=null&&(c[r]=e.clone(),s(n!==void 0,`Operation picks up at an invalid key`),l[r]=n,t.write(`p`,i.p)),i.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let a=S(i);a&&(a.makeInvertible?o=!0:w(t,a,C(i),!0))}let f=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-f:r,o=_(n,i),s=u(e,t,o);o!==s&&(a||(a=!0,n=d(n)),s===void 0?(n=m(n,i),typeof r==`number`&&f++):n[i]=s),t.ascend()}return i&&(i.r===void 0?i.p!=null&&(n=void 0):(t.write(`r`,r.default(n)),n=void 0)),n};return u(n,a,t),a.get(),o&&(a.reset(),function e(t,n,r,a,o){let s=n.getComponent();if(s){s.i===void 0?s.d!=null&&(a=l[s.d],t=c[s.d],o=!1,s.d):(a=s.i,o=!0);let e=S(s);if(e&&e.makeInvertible){let t=C(s);w(r,e,e.makeInvertible(t,a),!0)}}let u=0,d=0,m=i.advancer(t,(e,t)=>f(t)?u-e-1:e-u,(e,t)=>{f(t)&&u++});for(let t of n)if(typeof t==`number`){let i=t-d,s=m(i),c=i+u,l=_(a,o?i:c);r.descend(t),e(s,n,r,l,o),p(n.getComponent())&&d++,r.ascend()}else{let i=_(a,t);r.descend(t),e(m(t),n,r,i,o),r.ascend()}m.end()}(n.clone(),n,a,t,!1)),a.get()}function F(e,t){return M(P(e,t))}let I=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=I(e))}return t};function L(t,u,d){s(d===`left`||d===`right`,`Direction must be left or right`);let m=d===`left`?0:1;if(o.quiet=!c,o.prefix=0,u==null)return{ok:!0,result:t};D(t),D(u);let h=null,g=[],_=[],v=[],y=[],b=[],x=[],T=[],E=[],O=[],k=[],A=[],j=[],M=[],N=[],P=[],F=0,L=i.readCursor(t),R=i.readCursor(u),z=i.writeCursor();if(function e(t,n=null,r){let a=l(n);a&&(a.r===void 0?a.p!=null&&(r=null,x[a.p]=t.clone()):r=n.clone());let o=t.getComponent(),s;o&&(s=o.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(k[s]=!0,O[s]=r),a&&a.p!=null&&(N[s]=a.p));let c=i.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(R,L,null),function t(n,r,o,s,c){let u=o.getComponent(),d,p=!1;u&&((d=u.d)==null?u.i!==void 0&&(n=r=null,p=!0,c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(o.getPath(),u.i)})):(y[d]=o.clone(),s!=null&&(P[s]??(P[s]=[]),P[s].push(d)),k[d],n=b[d]||null,r=v[d]||null,k[d]?(c&&(A[d]=!0),c=O[d]||null):!c||m!==1&&N[d]!=null||(h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),o.getPath())}),p=!0));let g=l(n);g&&(g.r===void 0?g.p!=null&&(g.p,s=g.p,c=null):c=n.clone());let _=S(u);_&&c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(o.getPath(),_,C(u),!0)});let x=0,w=0,T=i.advancer(r,(e,t)=>f(t)?x-e-1:e-x,(e,t)=>{f(t)&&x++}),E=i.advancer(n);for(let e of o)if(typeof e==`number`){let n=e-w,r=T(n);w+=+t(E(n+x),r,o,s,c)}else{let n=T(e);t(E(e),n,o,s,c)}return T.end(),E.end(),p}(L,R,R.clone(),null,null),y.map(e=>e&&e.get()),h)return{ok:!1,conflict:h};A.map(e=>!!e);let ee=[],te=null;(function e(t,n,r,a,o){let c=!1,u=l(n);if(f(u)){let e=u.p;e==null?(r=null,o=n.clone()):(r=y[e],a=j[e]=i.writeCursor(),c=!0,o=null)}else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e=d.p;e==null?d.r!==void 0&&(o||a.write(`r`,!0),(o||c)&&(te??=new Set,te.add(d))):(o&&(E[e]=o),ee[e]=o||m===1&&c?null:a.getComponent(),g[e]=t.clone(),r&&(T[e]=r.clone()))}let h=0,_=0,v=i.advancer(n,void 0,(e,t)=>{f(t)&&h++}),b=i.advancer(r,(e,t)=>p(t)?~(e-_):e-_,(e,t)=>{p(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),i=b(n);a.descend(n),e(t,r,i,a,o),a.ascend()}else{let r=v(n),i=n-h,c=f(l(r))?null:b(i),u=i+_;s(u>=0),a.descend(u),e(t,r,c,a,o),a.ascend()}v.end(),b.end()})(L,R,R.clone(),z,null),z.reset();let ne=[];if(function t(o,c,u,b,D,O){s(c);let A=c.getComponent(),j=l(b),P=!1,I=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(p(A)){let t=A.d;t!=null&&(_[t]=c.clone());let i=t==null?null:ee[t],s=!1;if(A.i!==void 0||t!=null&&i){let o;j&&(j.i!==void 0||(o=j.d)!=null&&!k[o])&&(s=o==null?n.default(j.i,A.i):t!=null&&t===N[o],s||o!=null&&m!==1&&N[o]!=null||(h??={type:a.ConflictType.DROP_COLLISION,op1:I(t==null?null:g[t],c,A),op2:I(o==null?null:v[o],b,j)})),s||(O?h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(O.getPath())}:(t==null?D.write(`i`,r.default(A.i)):(ne[F]=t,D.write(`d`,i.p=F++)),P=!0))}else if(t!=null&&!i){let e=E[t];e&&(O=e.clone())}t==null?A.i!==void 0&&(o=u=null,s||(b=null)):(o=g[t],u=x[t],b=T[t])}else f(l(o))&&(o=u=b=null);let L=l(o),R=l(u);if(f(R)){let e=R.p;R.r!==void 0&&(!L||L.r===void 0)||k[e]?(b=null,O=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((D=M[e])||(D=M[e]=i.writeCursor()),D.reset(),O=null))}else!p(A)&&p(j)&&(b=null);j=b==null?null:b.getComponent();let z=S(A);if(z){let t=C(A);if(O)h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),z,t,!0),op2:e.removeOp(O.getPath())};else{let e=S(j),n;if(e){if(z!==e)throw Error(`Transforming incompatible types`);let r=C(j);n=z.transform(t,r,d)}else n=r.default(t);w(D,z,n)}}let re=0,B=0,ie=0,ae=0,oe=0,se=0,ce=o!=null&&o.descendFirst(),le=ce,ue=i.advancer(u,void 0,(e,t)=>{f(t)&&ie++}),de=b!=null&&b.descendFirst(),fe=de;for(let e of c)if(typeof e==`number`){let n,r=p(c.getComponent()),i=e-B;{let e;for(;ce&&typeof(e=o.getKey())==`number`;){e+=re;let t=o.getComponent(),n=f(t);if(e>i||e===i&&(!n||m===0&&r))break;if(n){re--;let e=t.p;ee[e],N.includes(e),t.d,l(M[t.d]),f(l(M[t.d])),(t.r===void 0||te&&te.has(t))&&(e==null||!ee[e]||m!==1&&N.includes(e))||oe--}ce=o.nextSibling()}n=ce&&e===i?o:null}let a=i-re,u=ue(a),d=a-ie,h=null;{let e,t;for(;de&&typeof(e=b.getKey())==`number`;){t=e-ae;let n=b.getComponent(),i=p(n);if(t>d)break;if(t===d){if(!i){h=b;break}{if(m===0&&r){h=b;break}let e=u&&f(u.getComponent());if(m===0&&e)break}}if(i){let e=n.d;k[e],N[e],n.i===void 0&&(k[e]||N[e]!=null&&m!==1)?(k[e]||N[e]!=null&&m===0)&&(ae++,se--):ae++}de=b.nextSibling()}}let g=d+ae+oe+se;s(g>=0,`trying to descend to a negative index`),D.descend(g),r&&(n=u=h=null,B++),t(n,c,u,h,D,O)&&se++,D.ascend()}else{let n;for(;ce&&(n=o.getKey(),typeof n!=`string`||!(n>e||n===e));)ce=o.nextSibling();let r=ce&&n===e?o:null,i=ue(e),a;for(;de&&(a=b.getKey(),typeof a!=`string`||!(a>e||a===e));)de=b.nextSibling();let s=de&&a===e?b:null;D.descend(e),t(r,c,i,s,D,O),D.ascend()}return ue.end(),le&&o.ascend(),fe&&b.ascend(),P}(L,L.clone(),R,R.clone(),z,null),h)return{ok:!1,conflict:h};z.reset();let re=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(k.length||j.length)&&(re(R,z,(e,t,n)=>{k[e]&&!A[e]&&n.write(`r`,!0),j[e]&&n.mergeTree(j[e].get())}),z.reset());let B=[],ie=[];if((M.length||k.length)&&!h){let e=i.readCursor(I(z.get()));if(re(e,null,(e,t)=>{B[e]=t.clone()}),M.forEach(e=>{e&&re(i.readCursor(e.get()),null,(e,t)=>{B[e]=t.clone()})}),function e(t,n,r,a,s,c){o.prefix++;let u=l(n);if(u&&f(u))if(u.p!=null){s=u;let e=u.p;B[e].getPath(),r=B[e],a=ie[e]=i.writeCursor()}else u.r!==void 0&&(r=null,c=!0);else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e;if((e=d.d)!=null){let t=M[e];t&&(t.get(),a.mergeTree(t.get()),r=i.readCursor(t.get()))}}let m=0,h=0,g=i.advancer(n,void 0,(e,t)=>{f(t)&&m--}),_=i.advancer(r,(e,t)=>p(t)?-(e-h)-1:e-h,(e,t)=>{p(t)&&h++});for(let n of t)if(typeof n==`number`){let r=g(n),i=n+m,o=_(i),l=i+h;a.descend(l),e(t,r,o,a,s,c),a.ascend()}else a.descend(n),e(t,g(n),_(n),a,s,c),a.ascend();g.end(),_.end()}(R,e,e.clone(),z,null,!1),z.reset(),h)return{ok:!1,conflict:h};if(z.get(),ie.length){let e=ie.map(e=>e?e.get():null);if(re(i.readCursor(I(z.get())),z,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=i.writeCursor(),n=i.writeCursor(),r=0,o=0;e.forEach(e=>{e!=null&&re(i.readCursor(e),null,e=>{let i=ne[e];t.writeMove(g[i].getPath(),_[i].getPath(),r++);let a=P[i];a&&a.forEach(e=>{k[e]||m!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),o++)})})}),h={type:a.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return h?{ok:!1,conflict:h}:{ok:!0,result:z.get()}}let R=e=>{let t=Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function z(e,t,n){let r=L(e,t,n);if(r.ok)return r.result;R(r.conflict)}let ee=e=>{let t=i.writeCursor();return i.readCursor(e).traverse(t,(e,t)=>{(p(e)||S(e))&&t.write(`r`,!0)}),t.get()},te=(e,t)=>{let{type:n,op1:r,op2:o}=e;switch(n){case a.ConflictType.DROP_COLLISION:return t===`left`?[null,ee(o)]:[ee(r),null];case a.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return i.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,ee(o)]:[ee(r),null];case a.ConflictType.BLACKHOLE:return[ee(r),ee(o)];default:throw Error(`Unrecognised conflict: `+n)}};function ne(e,t,n,r){let i=null;for(;;){let a=L(t,n,r);if(a.ok)return j(i,a.result);{let{conflict:o}=a;e(o)||R(o);let[s,c]=te(o,r);t=j(O(t),s),n=j(O(n),c),i=j(i,c)}}}})),ig=h(f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!n.hasOwnProperty(r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(rg(),e);var r=Zh();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var i=Qh();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}))());let ag=`__textXPreserveParagraphIds`,og=function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});function sg(e){return{startOffset:e.startIndex,endOffset:e.endIndex+1}}function cg(e){return{startOffset:e.startIndex,endOffset:e.endIndex}}function lg(e){return cg(e)}function ug(e){return sg(e)}function dg(e){return sg(e)}function fg(e){return sg(e)}function pg(e){return{startOffset:e.startIndex,endOffset:e.startIndex+1}}function mg(e,t){return Cg(e,t,`\x1B`,``)}function hg(e,t){return Cg(e,t,``,``)}function gg(e,t){return e.startOffset<=t&&t<e.endOffset}function _g(e,t){return e.startOffset<t&&t<e.endOffset}function vg(e,t){return Math.max(e.startOffset,t.startOffset)<Math.min(e.endOffset,t.endOffset)}function yg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>=t?{...e,endIndex:e.endIndex+n}:e}function bg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>t?{...e,endIndex:e.endIndex+n}:e}function xg(e,t,n){if(n<=0||e.endIndex<t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>=r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t-1;return s>=o?{...e,startIndex:o,endIndex:s}:null}function Sg(e,t,n){if(n<=0||e.endIndex<=t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t;return s>o?{...e,startIndex:o,endIndex:s}:null}function Cg(e,t,n,r){if(!Number.isInteger(t)||t<0||e[t]!==n)return null;let i=0;for(let a=t;a<e.length;a++){let o=e[a];if(o===n)i++;else if(o===r&&(i--,i===0))return{startOffset:t,endOffset:a+1}}return null}let wg=`__textXRestoreParagraphIds`;function Tg(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&B.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();Eu(r,o)&&B.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function Eg(e,t,n,r){let{textRuns:i}=e;if(i==null)return;let a=[],o=i.length,s=!1,c=t.textRuns??[];if(c.length)for(let e of c)e.st+=r,e.ed+=r;for(let e=0;e<o;e++){let t=i[e],{st:o,ed:l}=t;if(l<=r)a.push(t);else if(r>o&&r<l){s=!0;let e={...t,ed:r};a.push(e),c.length&&a.push(...c);let i={...t,st:r+n,ed:l+n};a.push(i)}else t.st+=n,t.ed+=n,s||(s=!0,a.push(...c)),a.push(t)}s||(s=!0,a.push(...c)),e.textRuns=Tg(a)}function Dg(e,t,n,r,i=!1,a=e.dataStream){var o;if(!e.paragraphs&&!((o=t.paragraphs)!=null&&o.length))return;e.paragraphs??=[];let{paragraphs:s}=e,{paragraphs:c}=t;Og(s,c,r,{freshenSplitParagraph:!0,preserveMissingParagraphIds:i,preserveExplicitSplitParagraphIds:!!t[wg],preserveExplicitParagraphIds:!!t[ag],dataStream:a});let l=[],u=-1;for(let e=0,t=s.length;e<t;e++){let t=s[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n),u===-1&&i>=r&&(u=e),l.push(t.startIndex)}let d=-1;if(c){for(let e=0,t=c.length;e<t;e++){let t=c[e];t.startIndex+=r;let n=t.startIndex;d=l.indexOf(n)}d!==-1&&s.splice(d,1),s.push(...c),s.sort(ff(`startIndex`))}}function Og(e,t,n,r){if(!e||!(t!=null&&t.length))return;let i=Mg(e,n,r.dataStream),a=i?Ng(t):-1,o=i==null?void 0:i.paragraphId,s=a===-1?void 0:t[a].paragraphId,c=(r.preserveExplicitSplitParagraphIds||r.preserveExplicitParagraphIds)&&s!=null&&s!==o,l=kg(e),u=new Set;o&&l.delete(o);for(let e of r.reservedParagraphIds??[])l.add(e);let d;if(o&&a!==-1&&!c){let e=t[a];d=s!=null&&s!==o?Ag(e,l,r.preserveMissingParagraphIds??!1):Wh(e,l,!1),r.freshenSplitParagraph&&d.paragraphId&&(i.paragraphId=d.paragraphId)}for(let e=0,n=t.length;e<n;e++){let n=t[e].paragraphId;if(r.preserveExplicitParagraphIds&&n&&!u.has(n)){t[e]={...t[e]},u.add(n);continue}if(e!==a||o==null||c){t[e]=Ag(t[e],l,r.preserveMissingParagraphIds??!1);continue}t[e]=r.freshenSplitParagraph||s==null||s===o?Wh({...t[e],paragraphId:o},l):d}for(let e of t)if(e.paragraphId){var f;(f=r.reservedParagraphIds)==null||f.add(e.paragraphId)}}function kg(e){let t=new Set;for(let n of e??[])n.paragraphId&&t.add(n.paragraphId);return t}function Ag(e,t,n){return n&&e.paragraphId==null?B.deepClone(e):Wh(e,t)}let jg=new Set([`
5
- `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function Mg(e,t,n){let r=[...e].sort((e,t)=>e.startIndex-t.startIndex);for(let e=0;e<r.length;e++){let i=r[e],a=e>0?r[e-1].startIndex+1:0;for(;a<i.startIndex;){let e=n==null?void 0:n[a];if(!e||!jg.has(e))break;a++}if(t>a&&t<i.startIndex)return i}}function Ng(e){let t=0;for(let n=1;n<e.length;n++)e[n].startIndex<e[t].startIndex&&(t=n);return t}function Pg(e,t,n,r){var i;if(!e.sectionBreaks&&!((i=t.sectionBreaks)!=null&&i.length))return;e.sectionBreaks??=[];let{sectionBreaks:a}=e,o=t.sectionBreaks;Fg(a,o);for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Fg(e,t,n=new Set){if(!(t!=null&&t.length))return;let r=new Set((e==null?void 0:e.map(e=>e.sectionId))??[]);for(let e of n)r.add(e);for(let e=0;e<t.length;e++)t[e]=ym(t[e],r),n.add(t[e].sectionId)}function Ig(e,t,n,r,i){if(e[i]==null&&t[i]==null)return;let a=e[i]??[];for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}let o=t[i];if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}a.length&&!e[i]&&(e[i]=a)}function Lg(e,t,n,r){Ig(e,t,n,r,`customBlocks`)}function Rg(e,t,n,r){Ig(e,t,n,r,`docxRawCustomBlocks`)}function zg(e,t,n,r){if(e.docxRawBlocks==null&&t.docxRawBlocks==null)return;let i=e.docxRawBlocks??[];i.forEach(e=>{e.startIndex>=r&&(e.startIndex+=n)}),i.push(...(t.docxRawBlocks??[]).map(e=>({...e,startIndex:e.startIndex+r}))),i.sort(ff(`startIndex`)),e.docxRawBlocks=i}function Bg(e){let t=[...e].sort((e,t)=>e.start-t.start||e.end-t.end),n=[];for(let e of t){let t=n[n.length-1];t&&e.start<=t.end?t.end=Math.max(t.end,e.end):e.end>e.start&&n.push({...e})}return n}function Vg(e,t,n,r){if(e.docxExportExcludedRanges==null&&t.docxExportExcludedRanges==null)return;let i=(e.docxExportExcludedRanges??[]).map(e=>{let t=bg({startIndex:e.start,endIndex:e.end},r,n);return{start:t.startIndex,end:t.endIndex}}),a=(t.docxExportExcludedRanges??[]).map(e=>({start:e.start+r,end:e.end+r}));e.docxExportExcludedRanges=Bg([...i,...a])}function Hg(e,t,n,r){var i;if(!e.tables&&!((i=t.tables)!=null&&i.length))return;e.tables||=[];let{tables:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,bg(t,r,n))}let o=t.tables;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Ug(e,t,n,r){var i;if(!e.columnGroups&&!((i=t.columnGroups)!=null&&i.length))return;e.columnGroups||=[];let{columnGroups:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,yg(t,r,n))}let o=t.columnGroups;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Wg(e,t,n,r){var i;if(!e.blockRanges&&!((i=t.blockRanges)!=null&&i.length))return;e.blockRanges||=[];let{blockRanges:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,yg(t,r,n))}let o=t.blockRanges;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}let Gg=e=>e.split(`$`)[0];function Kg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};n.rangeId=Gg(n.rangeId);for(let r=1;r<e.length;r++){let i=e[r];i.rangeId=Gg(i.rangeId),i.rangeId===n.rangeId&&Lp(n.properties,i.properties)&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}t.push(n);let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}\$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function qg(e,t){let n=e.findIndex(e=>e.startIndex<t&&e.endIndex>=t),r=e[n];r&&e.splice(n,1,{...r,startIndex:r.startIndex,endIndex:t-1,properties:{...r.properties}},{...r,startIndex:t,endIndex:r.endIndex,properties:{...r.properties}})}function Jg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function Yg(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function Xg(e,t,n,r){e.customRanges||=[];let{customRanges:i}=e;qg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customRanges=Kg(i)}function Zg(e,t,n,r){e.customDecorations||=[];let{customDecorations:i}=e;Yg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customDecorations=Jg(i)}function Qg(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;if(i<=c&&a>=l){o.push({...s,st:c-i,ed:l-i});continue}else c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t);n.push(s)}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function $g(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;if(d>=i&&d<a){o.push({...u,startIndex:d-n}),c=!0;continue}else d>=a&&(u.startIndex-=t);l.push(u),s==null&&c&&(s=u)}e.paragraphs=l}return o}function e_(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}else l>a&&(c.startIndex-=t);s.push(c)}e.sectionBreaks=s}return o}function t_(e,t,n,r){let i=e[r];if(i==null)return;let a=n,o=n+t-1,s=[],c=[];for(let e=0,r=i.length;e<r;e++){let r=i[e],{startIndex:l}=r;if(l>=a&&l<=o){s.push({...r,startIndex:l-n});continue}else l>o&&(r.startIndex-=t);c.push(r)}return e[r]=c,i.length&&!e[r]&&(e[r]=i),s}function n_(e,t,n){return e.customBlocks??=[],t_(e,t,n,`customBlocks`)}function r_(e,t,n){return t_(e,t,n,`docxRawCustomBlocks`)}function i_(e,t,n){if(e.docxRawBlocks==null)return;let r=n+t,i=[],a=[];for(let o of e.docxRawBlocks)o.startIndex>=n&&o.startIndex<r?i.push({...o,startIndex:o.startIndex-n}):a.push(o.startIndex>=r?{...o,startIndex:o.startIndex-t}:o);return e.docxRawBlocks=a,i}function a_(e,t,n){if(e.docxExportExcludedRanges==null)return;let r=n+t,i=[],a=[];for(let o of e.docxExportExcludedRanges){let e=Math.max(o.start,n),s=Math.min(o.end,r);s>e&&i.push({start:e-n,end:s-n});let c=Sg({startIndex:o.start,endIndex:o.end},n,t);c&&a.push({start:c.startIndex,end:c.endIndex})}return e.docxExportExcludedRanges=Bg(a),i}function o_(e,t,n){let{tables:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=Sg(o,n,t);if(!s){i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n});continue}Object.assign(o,s),a.push(o)}e.tables=a}return i}function s_(e,t,n){let{columnGroups:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=xg(o,n,t);if(!s){i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n});continue}Object.assign(o,s),a.push(o)}e.columnGroups=a}return i}function c_(e,t,n){let{customRanges:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=xg(o,n,t);if(!s){i.push(o);continue}Object.assign(o,s),a.push(o)}e.customRanges=Kg(a)}return i}function l_(e,t,n){let{blockRanges:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=xg(o,n,t);if(!s){i.push(o);continue}Object.assign(o,s),a.push(o)}e.blockRanges=a}return i}function u_(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o){s.push(c);continue}else if(Math.max(a,l)<=Math.min(o,u)){let e=$u(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}e.customDecorations=n}return s}let d_=function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),f_=function(e){return e.BULLET_LIST=`BULLET_LIST`,e.BULLET_LIST_1=`BULLET_LIST_1`,e.BULLET_LIST_2=`BULLET_LIST_2`,e.BULLET_LIST_3=`BULLET_LIST_3`,e.BULLET_LIST_4=`BULLET_LIST_4`,e.BULLET_LIST_5=`BULLET_LIST_5`,e.ORDER_LIST=`ORDER_LIST`,e.ORDER_LIST_1=`ORDER_LIST_1`,e.ORDER_LIST_2=`ORDER_LIST_2`,e.ORDER_LIST_3=`ORDER_LIST_3`,e.ORDER_LIST_4=`ORDER_LIST_4`,e.ORDER_LIST_5=`ORDER_LIST_5`,e.ORDER_LIST_QUICK_2=`ORDER_LIST_QUICK_2`,e.ORDER_LIST_QUICK_3=`ORDER_LIST_QUICK_3`,e.ORDER_LIST_QUICK_4=`ORDER_LIST_QUICK_4`,e.ORDER_LIST_QUICK_5=`ORDER_LIST_QUICK_5`,e.ORDER_LIST_QUICK_6=`ORDER_LIST_QUICK_6`,e.CHECK_LIST=`CHECK_LIST`,e.CHECK_LIST_CHECKED=`CHECK_LIST_CHECKED`,e}({}),p_={"a)":{glyphFormat:`%1)`,glyphType:2},"1.":{glyphFormat:`%1.`,glyphType:2},"a.":{glyphFormat:`%1.`,glyphType:5},"A.":{glyphFormat:`%1.`,glyphType:4},"i.":{glyphFormat:`%1.`,glyphType:7},"I.":{glyphFormat:`%1.`,glyphType:4}},m_=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),h_=e=>e.map((e,t)=>({...e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),g_=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(r+1)},textStyle:t}})),__={BULLET_LIST:{listType:`BULLET_LIST`,nestingLevel:m_([`●`,`○`,`■`])},BULLET_LIST_1:{listType:`BULLET_LIST`,nestingLevel:m_([`❖`,`➢`,`■`])},BULLET_LIST_2:{listType:`BULLET_LIST`,nestingLevel:m_([`✔`,`●`,`◆`])},BULLET_LIST_3:{listType:`BULLET_LIST`,nestingLevel:m_([`■`,`◆`,`○`])},BULLET_LIST_4:{listType:`BULLET_LIST`,nestingLevel:m_([`✦`,`○`,`■`])},BULLET_LIST_5:{listType:`BULLET_LIST`,nestingLevel:m_([`➢`,`○`,`◆`])},ORDER_LIST:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:2},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:2},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:2},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_1:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1)`,glyphType:2},{glyphFormat:`%2)`,glyphType:5},{glyphFormat:`%3)`,glyphType:7},{glyphFormat:`%4)`,glyphType:2},{glyphFormat:`%5)`,glyphType:5},{glyphFormat:`%6)`,glyphType:7},{glyphFormat:`%7)`,glyphType:2},{glyphFormat:`%8)`,glyphType:5},{glyphFormat:`%9)`,glyphType:7}])},ORDER_LIST_2:{listType:`ORDER_LIST`,nestingLevel:h_([`%1.`,`%1.%2.`,`%1.%2.%3.`,`%1.%2.%3.%4.`,`%1.%2.%3.%4.%5.`,`%1.%2.%3.%4.%5.%6.`,`%1.%2.%3.%4.%5.%6.%7.`].map(e=>({glyphFormat:e,glyphType:2})))},ORDER_LIST_3:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_4:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:2},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:2},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:2},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_5:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:3},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:3},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:3},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},CHECK_LIST:{listType:`CHECK_LIST`,nestingLevel:g_(`☐`)},CHECK_LIST_CHECKED:{listType:`CHECK_LIST_CHECKED`,nestingLevel:g_(`☑`,{st:{s:1}})}},v_=e=>{let{glyphFormat:t,glyphType:n}=e,r=B.deepClone(__.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},y_={ORDER_LIST_QUICK_2:v_(p_[`a)`]),ORDER_LIST_QUICK_3:v_(p_[`a.`]),ORDER_LIST_QUICK_4:v_(p_[`i.`]),ORDER_LIST_QUICK_6:v_(p_[`I.`])};Object.assign(__,y_);let b_={"1.":`ORDER_LIST`,"a)":`ORDER_LIST_QUICK_2`,"a.":`ORDER_LIST_QUICK_3`,"i.":`ORDER_LIST_QUICK_4`,"A.":`ORDER_LIST_3`,"I.":`ORDER_LIST_QUICK_6`,"01.":`ORDER_LIST_5`,"*":`BULLET_LIST`};function x_(e,t,n,r,i){return{dataStream:``,textRuns:S_(e,t,n,r,i),paragraphs:w_(e,t,n,r,i),sectionBreaks:T_(e,t,n,r,i),customBlocks:E_(e,t,n,r,i),docxRawCustomBlocks:D_(e,t,n,r,i),tables:O_(e,t,n,r,i),columnGroups:k_(e,t,n,r,i),blockRanges:A_(e,t,n,r,i),customRanges:j_(e,t,n,r,i),customDecorations:M_(e,t,n,r,i)}}function S_(e,t,n,r,i){let{textRuns:a}=e,{textRuns:o}=t;if(a==null||o==null)return;let s=Qg(e,n,r);return i!==1&&(t.textRuns=C_(o,s,i)),Eg(e,t,n,r),s}function C_(e,t,n){if(t.length===0)return e;e=B.deepClone(e),t=B.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===0?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Tg(r)}function w_(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=$g(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,paragraphId:r,paragraphStyle:a,bullet:o}=t,c=[];for(let e of s){let{startIndex:t,paragraphId:s,paragraphStyle:l,bullet:u}=e,d,f;if(i===0?(d={...l,...a},f={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...u,...o}):(d={...a,...l},f={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...o,...u}),n===t){c.push({startIndex:n,paragraphId:r??s,paragraphStyle:d,bullet:f});break}}e.push(...c),c=[]}t.paragraphs=e}else for(let e of o){let t=s.find(t=>t.startIndex===e.startIndex);t&&e.paragraphId==null&&(e.paragraphId=t.paragraphId)}return Dg(e,t,n,r,!0),s}function T_(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=e_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e})}else t.sectionBreaks=o.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e});return Pg(e,t,n,r),s}function E_(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=n_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return Lg(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function D_(e,t,n,r,i){let a=e.docxRawCustomBlocks,o=t.docxRawCustomBlocks;if(a==null||o==null)return;let s=r_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let n=s.find(e=>e.startIndex===t.startIndex);n&&e.push(i===0?{...n,...t}:{...t,...n})}t.docxRawCustomBlocks=e}return Rg(e,t,n,r),a.length&&!e.docxRawCustomBlocks&&(e.docxRawCustomBlocks=a),s}function O_(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=o_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return Hg(e,t,n,r),s}function k_(e,t,n,r,i){let{columnGroups:a}=e,{columnGroups:o}=t;if(a==null||o==null)return;let s=s_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.columnGroups=e}return Ug(e,t,n,r),s}function A_(e,t,n,r,i){let{blockRanges:a}=e,{blockRanges:o}=t;if(a==null||o==null)return;let s=l_(e,n,r);return i!==1&&(t.blockRanges=o.map(e=>{let t=s.find(t=>t.blockId===e.blockId);return t?{...t,...e}:e})),Wg(e,t,n,r),s}function j_(e,t,n,r,i){e.customRanges||=[],qg(e.customRanges,r),qg(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=new Map;return e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)}),s?(s.forEach(e=>{let{startIndex:t,endIndex:n}=e;c.push({...e,startIndex:t+r,endIndex:n+r})}),e.customRanges=Kg(c),[]):[]}function M_(e,t,n,r,i){e.customDecorations||=[],Yg(e.customDecorations,r),Yg(e.customDecorations,r+n);let a=[],{customDecorations:o}=e,{customDecorations:s=[]}=t;if(i===1){for(let e=0;e<o.length;e++){let t=o[e],{startIndex:i,endIndex:s}=t;i>=r&&s<=r+n-1&&a.push(t)}s.forEach(e=>{let{startIndex:t,endIndex:n}=e;o.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of s){let{id:t}=e;if(e.type===9999){let e=o.filter(e=>e.id===t);e.length&&a.push(...e)}else o.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of a){let{id:t}=e,n=o.findIndex(e=>e.id===t);n!==-1&&o.splice(n,1)}return e.customDecorations=Jg(o),a}function N_(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function P_(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function F_(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function I_(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r??z_(t,n),s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function L_(e,t,n){let r=[],i=z_(t,n);for(let a of e){let e=I_(a,t,n,i);r.push(...e)}return r}let R_=[`\r`,``,``,`\x1B`,``,``];function z_(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!R_.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}let B_=e=>{var t;let{paragraphs:n,segmentId:r,document:i}=e,a=e.listType,o=((t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs)??[],s=n.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(a))===0}),c=Y(6);if(n.length===1){let e=o.indexOf(n[0]),t=o[e-1],r=o[e+1];t&&t.bullet&&t.bullet.listType.indexOf(a)===0?(c=t.bullet.listId,a!==`CHECK_LIST`&&(a=t.bullet.listType)):r&&r.bullet&&r.bullet.listType.indexOf(a)===0&&(c=r.bullet.listId,a!==`CHECK_LIST`&&(a=r.bullet.listType))}let l=new cm;l.reset();let u=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:i}=e;u.push({t:`r`,len:t-l.cursor}),u.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[s?{paragraphId:n,paragraphStyle:r,startIndex:0}:{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{nestingLevel:(i==null?void 0:i.nestingLevel)??0,listType:a,listId:c}}]},coverType:1}),l.moveCursorTo(t+1)}return u},V_=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(`CHECK_LIST`)===-1)return!1;let s=new cm;s.reset();let c=new X,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===`CHECK_LIST`?`CHECK_LIST_CHECKED`:`CHECK_LIST`;return c.push({t:`r`,len:l-s.cursor}),c.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:1}),s.moveCursorTo(l+1),c},H_=e=>{var t;let{paragraphs:n,listType:r,listId:i,segmentId:a,document:o}=e;if(((t=o.getSelfOrHeaderFooterModel(a))==null||(t=t.getBody())==null?void 0:t.paragraphs)==null)return!1;let s=i??Y(6),c=new cm;c.reset();let l=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:i={},bullet:a}=e;l.push({t:`r`,len:t-c.cursor}),l.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:i,bullet:{nestingLevel:(a==null?void 0:a.nestingLevel)??0,...(a==null?void 0:a.listType)===r&&a.textStyle?{textStyle:a.textStyle}:{},listType:r,listId:s}}]},coverType:1}),c.moveCursorTo(t+1)}return l};function U_(e,t){return t.some(t=>{let n=lg(t);return e.startIndex>n.startOffset&&gg(n,e.startIndex)})}let W_=new Set([`
6
- `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function G_(e,t){let n;for(let r of e.paragraphs??[])r.startIndex<t.startIndex&&(!n||r.startIndex>n.startIndex)&&(n=r);let r=n?n.startIndex+1:0;for(;r<t.startIndex&&W_.has(e.dataStream[r]);)r++;return r}function K_(e){let t=new Map,n=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex);for(let r=0;r<n.length;r++){let i=n[r],a=r>0?n[r-1].startIndex+1:0;for(;a<i.startIndex&&W_.has(e.dataStream[a]);)a++;t.set(i.startIndex,a)}return t}function q_(e,t){let n=(e.blockRanges??[]).find(e=>{let n=ug(e);return t.startIndex>n.startOffset&&t.startIndex<n.endOffset-1});return n?ug(n).endOffset:t.startIndex+1}let J_=e=>{var t;let{paragraphs:n,document:r,type:i}=e,a=new cm;a.reset();let o=new X,s=r.getSnapshot().lists??{},c=((t=r.getBody())==null?void 0:t.tables)??[],l={...__,...s};for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:s}=e,u=U_(e,c);if(o.push({t:`r`,len:t-a.cursor}),s){let e=l[s.listType].nestingLevel.length-1;u&&(e=Math.min(e,2)),o.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{...s,nestingLevel:Math.max(Math.min(s.nestingLevel+i,e),0)}}]},coverType:1})}else o.push({t:`r`,len:1});a.moveCursorTo(t+1)}return o},Y_=e=>{var t,n;let{textRanges:r,segmentId:i,document:a,style:o,paragraphTextRun:s,cursor:c,deleteLen:l,textX:u}=e,d=a.getSelfOrHeaderFooterModel(i),f=L_(r,(d==null||(t=d.getBody())==null?void 0:t.paragraphs)??[],(d==null||(n=d.getBody())==null?void 0:n.dataStream)??``),p=new cm;c&&p.moveCursorTo(c);let m=u??new X;f.sort((e,t)=>e.startIndex-t.startIndex);let h=Math.max(0,f[0].paragraphStart-1);h>p.cursor&&(m.push({t:`r`,len:h-p.cursor}),p.moveCursorTo(h)),l&&m.push({t:`d`,len:l});for(let e of f){let{startIndex:t,paragraphId:n,paragraphStyle:r={}}=e,i=t-p.cursor;m.push({t:`r`,len:i,...s?{body:{dataStream:``,textRuns:[{ts:s,st:0,ed:i}]},coverType:1}:null}),m.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r,...o}}]},coverType:1}),p.moveCursorTo(t+1)}return m},X_=function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function Z_(e,t,n,r,i){return i===1?e>=n&&t<=r:i===2?e<r&&t>n&&t<=r:Math.max(e,n)<Math.min(t,r)}function Q_(e,t,n,r,i){return i===0?{startIndex:Math.max(e,n)-n,endIndex:Math.min(t,r)-n}:{startIndex:e-n,endIndex:t-n}}function $_(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let{st:i,ed:a}=r;if(B.hasIntersectionBetweenTwoRanges(i,a,t,n)){let o=B.deepClone(r);t>=i&&t<=a?e.push({...o,st:t,ed:Math.min(n,a)}):n>=i&&n<=a?e.push({...o,st:Math.max(t,i),ed:n}):e.push(o)}}return Tg(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}else if(r)return[{st:0,ed:n-t,ts:{}}]}function ev(e,t,n,r=0){let{tables:i=[]}=e,a=[];for(let e of i){let i=B.deepClone(e),{startIndex:o,endIndex:s}=i;Z_(o,s,t,n,r)&&a.push({...i,...Q_(o,s,t,n,r)})}return a}function tv(e,t,n,r=0){let{blockRanges:i=[]}=e,a=[];for(let e of i){let i=B.deepClone(e),{startIndex:o,endIndex:s}=i;Z_(o,s,t,n,r)&&a.push({...i,...Q_(o,s,t,n,r)})}return a}function nv(e,t,n,r=0){let{columnGroups:i=[]}=e,a=[];for(let o of i){let i=B.deepClone(o),{startIndex:s,endIndex:c}=i;e.dataStream[s]===``&&Z_(s,c,t,n,r)&&a.push({...i,...Q_(s,c,t,n,r)})}return a}function rv(e,t,n,r=1){let{paragraphs:i=[]}=e,a=[];if(r===1){for(let e of i){let{startIndex:r}=e;r>=t&&r<n&&a.push(B.deepClone(e))}return a.length?a.map(e=>({...e,startIndex:e.startIndex-t})):void 0}let o=[...i].sort((e,t)=>e.startIndex-t.startIndex),s=K_(e);for(let e of o){let r=s.get(e.startIndex)??0,i=e.startIndex;if(i>=t&&i<n||Math.max(r,t)<Math.min(i,n)){let r=B.deepClone(e);r.startIndex=Math.min(Math.max(i,t),n),a.push(r)}}if(a.length)return a.map(e=>({...e,startIndex:e.startIndex-t}))}function iv(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(B.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function av(e,t,n){return sv(e.customBlocks??[],t,n)}function ov(e,t,n){return sv(e.docxRawCustomBlocks??[],t,n)}function sv(e,t,n){let r=[];for(let i of e){let{startIndex:e}=i;e>=t&&e<n&&r.push(B.deepClone(i))}if(r.length)return r.map(e=>({...e,startIndex:e.startIndex-t}))}function cv(e,t,n){return(e.docxRawBlocks??[]).filter(e=>e.startIndex>=t&&e.startIndex<n).map(e=>({...B.deepClone(e),startIndex:e.startIndex-t}))}function lv(e,t,n){return(e.docxExportExcludedRanges??[]).flatMap(e=>{let r=Math.max(e.start,t),i=Math.min(e.end,n);return i>r?[{start:r-t,end:i-t}]:[]})}function uv(e,t,n,r=!0,i=1,a=0){let{dataStream:o}=e,s={dataStream:o.slice(t,n)};e.__textXPreserveParagraphIds&&(s[ag]=!0),s.textRuns=$_(e,t,n,r);let c=ev(e,t,n,a);c.length&&(s.tables=c);let l=tv(e,t,n,a);l.length&&(s.blockRanges=l);let u=nv(e,t,n,a);u.length&&(s.columnGroups=u),s.paragraphs=rv(e,t,n,i);let d=iv(e,t,n-1);if(d?s.sectionBreaks=d:r&&(s.sectionBreaks=[]),i===1){let i=gv(e,t,n);i?s.customDecorations=i:r&&(s.customDecorations=[])}let{customRanges:f}=hv(e,t,n);return f?s.customRanges=f:r&&(s.customRanges=[]),s.customBlocks=av(e,t,n),e.docxRawCustomBlocks!=null&&(s.docxRawCustomBlocks=ov(e,t,n)??[]),e.docxRawBlocks!=null&&(s.docxRawBlocks=cv(e,t,n)),e.docxExportExcludedRanges!=null&&(s.docxExportExcludedRanges=lv(e,t,n)),s}function dv(e,t,n,r=!0,i=1){return uv(e,t,n,r,i,1)}function fv(e,t,n,r=!0,i=1){return uv(e,t,n,r,i,2)}function pv(e,t,n){var r,i,a,o,s,c,l,u,d,f;(r=e.textRuns)==null||r.forEach(e=>{e.st+=t,e.ed+=t}),(i=e.paragraphs)==null||i.forEach(e=>{e.startIndex+=t}),(a=e.customBlocks)==null||a.forEach(e=>{e.startIndex+=t}),(o=e.docxRawCustomBlocks)==null||o.forEach(e=>{e.startIndex+=t}),(s=e.docxRawBlocks)==null||s.forEach(e=>{e.startIndex+=t}),(c=e.docxExportExcludedRanges)==null||c.forEach(e=>{e.start+=t,e.end+=t}),(l=e.customRanges)==null||l.forEach(e=>{e.startIndex+=t,e.endIndex+=t}),(u=e.customDecorations)==null||u.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(d=e.tables)==null||d.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(f=e.columnGroups)==null||f.forEach(e=>{e.startIndex+=t,e.endIndex+=n})}function mv(e){let{dataStream:t,textRuns:n,customRanges:r}=e,i=0,a=0;r==null||r.forEach(e=>{e.startIndex<0&&(i=Math.max(i,-e.startIndex)),e.endIndex>t.length-1&&(a=Math.max(a,e.endIndex-t.length+1))});let o=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-i),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+a)),pv(e,i,a),{...e,dataStream:o}}function hv(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function gv(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=B.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function _v(e,t,n){return e==null||t==null?e??t:C_(e,t,n)}function vv(e,t,n){if(e==null||t==null)return e??t;if(t.length===0||e.length===0)return e;if(t.length>1||e.length>1)throw Error(`Cannot cover multiple customRanges`);return n===1?[{...e[0]}]:[{...t[0],...e[0]}]}function yv(e,t,n){return t.length===0||e.length===0||n===1?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function bv(e,t,n=0){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream};(e.__textXPreserveParagraphIds||t.__textXPreserveParagraphIds)&&(r[ag]=!0);let{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[],columnGroups:c=[],blockRanges:l=[]}=e,{textRuns:u,paragraphs:d=[],customRanges:f,customDecorations:p=[],columnGroups:m=[],blockRanges:h=[]}=t;r.textRuns=_v(u,i,n),r.customRanges=vv(f,o,n);let g=yv(p,s,n);g.length&&(r.customDecorations=g);let _=[],v=0,y=0;for(;v<a.length&&y<d.length;){let e=a[v],t=d[y],{startIndex:n}=e,{startIndex:r}=t;n===r?(_.push(ta(e,t)),v++,y++):n<r?(_.push(B.deepClone(e)),v++):(_.push(B.deepClone(t)),y++)}v<a.length&&_.push(...a.slice(v)),y<d.length&&_.push(...d.slice(y)),_.length&&(r.paragraphs=_);let b=xv(l,h);b.length&&(r.blockRanges=b);let x=Sv(c,m);return x.length&&(r.columnGroups=x),r}function xv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.blockId,B.deepClone(e)]));return t.forEach(e=>n.set(e.blockId,B.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Sv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.columnGroupId,B.deepClone(e)]));return t.forEach(e=>n.set(e.columnGroupId,B.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Cv(e){let{body:t}=e;if(t==null)return!0;let{textRuns:n,paragraphs:r,customRanges:i,customBlocks:a,docxRawCustomBlocks:o,docxRawBlocks:s,docxExportExcludedRanges:c,customDecorations:l,tables:u,columnGroups:d,blockRanges:f}=t;return n==null&&r==null&&i==null&&a==null&&o==null&&s==null&&c==null&&l==null&&u==null&&d==null&&f==null}function wv(e,t=``){var n;if(!t)return[`body`];let{headers:r,footers:i}=e.getSnapshot();if(((n=e.getSnapshot().notes)==null?void 0:n[t])!=null)return[`notes`,t,`body`];if(r==null&&i==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((r==null?void 0:r[t])!=null)return[`headers`,t,`body`];if((i==null?void 0:i[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}var Tv=class{constructor(e){this._actions=e,T(this,`_index`,0),T(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e||=1/0;let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===`d`||t.t===`r`&&t.body==null?B.deepClone({...t,len:e}):B.deepClone({...t,len:e,body:fv(t.body,n,n+e,!1)})}else return{t:`r`,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:`r`}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function Ev(e,t,n){let{dataStream:r}=e,i=n,a=n+t,o=Qg(e,t,n),s=$g(e,t,n),c=e_(e,t,n),l=n_(e,t,n),u=r_(e,t,n),d=i_(e,t,n),f=a_(e,t,n),p=o_(e,t,n),m=s_(e,t,n),h=l_(e,t,n),g=c_(e,t,n),_=u_(e,t,n),v=``;return r&&(e.dataStream=id(r,i,a),v=r.slice(i,a)),{dataStream:v,textRuns:o,paragraphs:s,sectionBreaks:c,customBlocks:l,docxRawCustomBlocks:u,docxRawBlocks:d,docxExportExcludedRanges:f,tables:p,columnGroups:m,blockRanges:h,customRanges:g,customDecorations:_}}function Dv(e,t,n,r){let i=e.dataStream;e.dataStream=rd(e.dataStream,r,t.dataStream),Eg(e,t,n,r),Dg(e,t,n,r,!1,i),Pg(e,t,n,r),Lg(e,t,n,r),Rg(e,t,n,r),zg(e,t,n,r),Vg(e,t,n,r),Hg(e,t,n,r),Ug(e,t,n,r),Wg(e,t,n,r),Xg(e,t,n,r),Zg(e,t,n,r)}function Ov(e,t,n,r,i=0){return x_(e,t,n,r,i)}function kv(e,t,n){return t<=0?{dataStream:``}:Ev(e,t,n)}function Av(e,t,n,r){n!==0&&Dv(e,t,n,r)}function jv(e,t){let n=new cm;return n.reset(),t.forEach(t=>{switch(t.t){case`r`:{let{coverType:r,body:i,len:a}=t;i!=null&&Ov(e,B.deepClone(i),a,n.cursor,r),n.moveCursor(a);break}case`i`:{let{body:r,len:i}=t;Av(e,Mv(r)?r:B.deepClone(r),i,n.cursor),n.moveCursor(i);break}case`d`:{let{len:r}=t;kv(e,r,n.cursor);break}default:throw Error(`Unknown action type for action: ${t}.`)}}),e}function Mv(e){return Object.keys(e).length===1&&typeof e.dataStream==`string`}function Nv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=B.deepClone(t),e=B.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===0)_={...f},n===0&&r===1&&h&&(_=Object.assign({},h,_));else if(_={...f},n===1){if(r===1)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===1){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Tg(a,!0)}function Pv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===1)return i===1?[B.deepClone(a)]:[B.deepClone(o)];if(r===1){let e=B.deepClone(o);return i===1&&Object.assign(e,B.deepClone(a)),[e]}else{let e=B.deepClone(o);return i===1&&Object.assign(e,B.deepClone(a)),[e]}}function Fv(e,t,n,r,i){let a={startIndex:t.startIndex,paragraphId:t.paragraphId};if(t.paragraphStyle&&(a.paragraphStyle=B.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===1)if(r===1)i===1&&(a.paragraphStyle={...e.paragraphStyle});else if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(r===1)if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else if(i===1){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}return n===1&&r===1?a.bullet=i===1?B.deepClone(e.bullet):B.deepClone(t.bullet):e.bullet===void 0?a.bullet=B.deepClone(t.bullet):n===1||r===1?a.bullet=i===0&&t.bullet?B.deepClone(t.bullet):B.deepClone(e.bullet):i===0&&t.bullet!==void 0&&(a.bullet=B.deepClone(t.bullet)),a.bullet===void 0&&delete a.bullet,a}function Iv(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return B.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===9999||i===9999)&&(a=!0,n.push({...r,type:9999}));break}a||n.push(r)}return n}function Lv(e,t,n=!1){let{body:r,coverType:i=0}=e,{body:a,coverType:o=0}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],blockRanges:d=[],customRanges:f,customDecorations:p}=r,{textRuns:m,paragraphs:h=[],blockRanges:g=[],customRanges:_,customDecorations:v}=a,y=Nv(l,m,i,o,+!!n);y&&(s.textRuns=y);let b=Pv(f,_,i,o,+!!n);b&&(s.customRanges=b);let x=Iv(p,v);x&&(s.customDecorations=x);let S=[],C=0,w=0;for(;C<u.length&&w<h.length;){let e=u[C],t=h[w],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r,paragraphId:t.paragraphId};a=n?Fv(e,t,i,o,1):Fv(e,t,i,o,0),S.push(a),C++,w++}else r<a?C++:(S.push(B.deepClone(t)),w++)}w<h.length&&S.push(...h.slice(w)),S.length&&(s.paragraphs=S);let T=Rv(d,g,n);return T.length&&(s.blockRanges=T),{coverType:c,body:s}}function Rv(e,t,n){return e.length?t.length?t.map(t=>{let r=e.find(e=>e.blockId===t.blockId);return r&&n?ta(t,r):t}):[]:t}function zv(e){return Object.keys(e).length===1}function Bv(e,t,n,r){Og(t.paragraphs,e.paragraphs,n,{freshenSplitParagraph:!1,preserveExplicitParagraphIds:!!e[ag],reservedParagraphIds:r,dataStream:t.dataStream})}var X=class e{constructor(){T(this,`_actions`,[])}static apply(e,t){return jv(e,t)}static compose(t,n){let r=new Tv(t),i=new Tv(n),a=new e;for(;r.hasNext()||i.hasNext();)if(i.peekType()===`i`)a.push(i.next());else if(r.peekType()===`d`)a.push(r.next());else{let e=Math.min(r.peekLength(),i.peekLength()),t=r.next(e),n=i.next(e);if(t.t===`i`&&n.t===`r`)n.body==null?a.push(t):a.push({...t,body:bv(t.body,n.body,n.coverType)});else if(t.t===`r`&&n.t===`r`)if(t.body==null&&n.body==null)a.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=+(t.coverType===1||n.coverType===1);a.push({...t,t:`r`,coverType:e,body:bv(t.body,n.body,n.coverType)})}else a.push(t.body?t:n);else t.t===`r`&&n.t===`d`?a.push(n):t.t===`i`&&n.t}return a.trimEndUselessRetainAction(),a.serialize()}static transform(e,t,n=`right`){return this._transform(t,e,n===`left`?`right`:`left`)}static _transform(t,n,r=`right`){let i=new Tv(t),a=new Tv(n),o=new e;for(;i.hasNext()||a.hasNext();)if(i.peekType()===`i`&&(r===`left`||a.peekType()!==`i`)){let e=i.next();o.retain(e.len)}else if(a.peekType()===`i`)o.push(a.next());else{let e=Math.min(i.peekLength(),a.peekLength()),t=i.next(e),n=a.next(e);if(t.t===`d`)continue;if(n.t===`d`){o.push(n);continue}if(t.body==null||n.body==null)o.push(n);else{let{coverType:e,body:i}=Lv(t,n,r===`left`);o.push({...n,t:`r`,coverType:e,body:i})}}return o.trimEndUselessRetainAction(),o.serialize()}static transformPosition(e,t,n=!1){let r=new Tv(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();if(r.next(),a===`d`){t-=Math.min(e,t-i);continue}else a===`i`&&(i<t||!n)&&(t+=e);i+=e}return t}static isNoop(e){return e.length===0}static invert(e){let t=[];for(let r of e)if(r.t===`i`)t.push({t:`d`,len:r.len,body:r.body});else if(r.t===`d`){var n;if(r.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);(n=r.body.paragraphs)!=null&&n.length&&(r.body[wg]=!0,Reflect.set(r.body,ag,!0)),t.push({t:`i`,body:r.body,len:r.len})}else if(r.body!=null){if(r.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);t.push({t:`r`,body:r.oldBody,oldBody:r.body,len:r.len,coverType:1})}else t.push(r);return t}static makeInvertible(e,t){let n=[],r=0,i=new Set,a=new Set;for(let o of e){if(o.t===`i`&&(Bv(o.body,t,r,i),Fg(t.sectionBreaks,o.body.sectionBreaks,a)),o.t===`d`&&(o.body==null||o.body&&o.body.dataStream.length!==o.len)){let e=dv(t,r,r+o.len,!1);o.len=e.dataStream.length,o.body=e}if(o.t===`r`&&o.body!=null){let e=uv(t,r,r+o.len,!0);for(let t of[`tables`,`columnGroups`,`blockRanges`])o.body[t]??delete e[t];o.oldBody={...e,dataStream:``},o.len=e.dataStream.length}n.push(o),o.t!==`i`&&(r+=o.len)}return n}insert(e,t){let n={t:`i`,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:`r`,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:`d`,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=B.deepClone(e[0]);if(r.t===`r`&&r.len===0&&r.body==null)return this;if(typeof n==`object`){if(n.t===`d`&&r.t===`d`)return n.len+=r.len,this;if(n.t===`d`&&r.t===`i`&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===`r`&&r.t===`r`&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===`i`&&zv(n.body)&&r.t===`i`&&zv(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===`r`&&Cv(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};T(X,`id`,`text-x`),T(X,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(X,"name",{value:`text-x`});var Vv=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==X.id||(this._subTypes.set(e.name,e),ig.type.registerSubtype(e))}static apply(e,t){if(!ig.type.isNoop(t))return ig.type.apply(e,t)}static compose(e,t){return ig.type.compose(e,t)}static transform(e,t,n){return ig.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===X.name?X.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return ig.type.invertWithDoc(e,t)}static isNoop(e){return ig.type.isNoop(e)}static getInstance(){return this._instance??=new e,this._instance}removeOp(e,t){return ig.removeOp(e,t)}moveOp(e,t){return ig.moveOp(e,t)}insertOp(e,t){return ig.insertOp(e,t)}replaceOp(e,t,n){return ig.replaceOp(e,t,n)}editOp(e,t=[`body`]){return ig.editOp(t,X.name,e)}};T(Vv,`uri`,`https://github.com/dream-num/univer#json-x`),T(Vv,`_subTypes`,new Map),T(Vv,`_instance`,null),Vv.registerSubtype(X);let Hv=[``,`\x1B`,``,``,``,``,``,``],Uv=e=>{let t=Hv.reduce((e,t)=>e.replaceAll(t,``),e);return t.endsWith(`\r
7
- `)?t.slice(0,-2):t},Wv=e=>!e||Uv(e).replaceAll(`\r`,``)===``,Gv=e=>{let t=e.replace(/\r\n?|\n/g,`\r`),n=[],r=new Set,i=[],a=0,o=``,s=(s,c=!0)=>{let l=t.slice(a,s);if(B.isLegalUrl(l)){let t=Y(),u=`${l}`,d={startIndex:a,endIndex:a+u.length-1,rangeId:t,rangeType:0,properties:{url:e}};i.push(d),o+=u,a=s+1,c&&(o+=`\r`,n.push({startIndex:s,paragraphId:Hh(r)}))}else o+=t.slice(a,s+1),a=s+1,c&&n.push({startIndex:s,paragraphId:Hh(r)})},c=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(s(e),c=e);return(c!==t.length-1||t.length===1)&&s(t.length,!1),{dataStream:o,paragraphs:n,customRanges:i}},Kv={id:`default_doc`,documentStyle:{}};function qv(e){if((e==null?void 0:e.dataStream)==null||e.sectionBreaks==null)return e;let t=e.sectionBreaks.filter(({startIndex:t})=>e.dataStream[t]===`
8
- `||t<=0||e.dataStream[t-1]!==`\f`),n=new Set,r=t.length!==e.sectionBreaks.length,i=t.map(e=>e.sectionId&&!n.has(e.sectionId)?(n.add(e.sectionId),e):(r=!0,{...e,sectionId:vm(n)}));return r?{...e,sectionBreaks:i}:e}function Jv(e){var t,n;if(e.id!=null&&jp(e.id))return{...Kv,...e};let r=Jh(e.id,e.locale,e.title,(t=e.documentStyle)==null?void 0:t.documentFlavor);if(B.isEmptyObject(e))return r;let i=ea({},r,e,(e,t,n)=>{if(Array.isArray(t)||n===`body`&&typeof t==`object`&&t)return t});return e.body!=null&&((n=e.documentStyle)==null?void 0:n.defaultParagraphStyle)===void 0&&delete i.documentStyle.defaultParagraphStyle,i.body=qv(i.body),i}var Yv=class extends M{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){super(),T(this,`type`,n.UniverType.UNIVER_DOC),T(this,`_name$`,new t.BehaviorSubject(``)),T(this,`name$`,this._name$.asObservable()),T(this,`snapshot`,void 0),T(this,`_mutationRevision`,0),this.snapshot=Jv(e),this._name$.next(this.snapshot.title??`No Title`)}getRev(){return this.snapshot.rev??1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._markMutation(),this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t,this._markMutation()}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){let e=this.snapshot.lists??{};return{...__,...e}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig==null?t.renderConfig=e:t.renderConfig={...t.renderConfig,...e},this._markMutation()}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e},this._markMutation()}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i),this._markMutation()}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e??1/0,height:t??1/0},this._markMutation();return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t),this._markMutation()}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o,this._markMutation()}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e},this._markMutation()}setDisabled(e){this.snapshot.disabled=e,this._markMutation()}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}getMutationRevision(){return this._mutationRevision}_markMutation(){this._mutationRevision++}},Xv=class e extends Yv{constructor(e){super(B.isEmptyObject(e)?Jh():e),T(this,`_unitId`,void 0),T(this,`headerModelMap`,new Map),T(this,`footerModelMap`,new Map),T(this,`noteModelMap`,new Map),T(this,`change$`,new t.BehaviorSubject(0)),this._unitId=this.snapshot.id??Y(6),this._initializeHeaderFooterModel(),this._name$.next(this.snapshot.title??``)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this.noteModelMap.forEach(e=>e.dispose()),this.noteModelMap.clear(),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot=Jv(e),this._initializeHeaderFooterModel(),this._markMutation(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){return e==null||e===``?this:this.headerModelMap.has(e)?this.headerModelMap.get(e):this.footerModelMap.has(e)?this.footerModelMap.get(e):this.noteModelMap.has(e)?this.noteModelMap.get(e):null}getUnitId(){return this._unitId}apply(e){if(Vv.isNoop(e))return;let t=this.snapshot.notes,n=new Set,r=!1,i=ig.type.readCursor(e);return i.traverse(null,()=>{let e=i.getPath();e[0]===`notes`&&typeof e[1]==`string`&&n.add(e[1]),(e[0]===`styles`||e[0]===`documentStyle`)&&(r=!0)}),this.snapshot=Vv.apply(this.snapshot,e),this._markMutation(),(r||t!==this.snapshot.notes||n.size>0)&&this._initializeNoteModels(r?void 0:t,n),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=0){let r=this.getBody();if(r!=null)return uv(r,e,t,!1,n)}_initializeHeaderFooterModel(){this._initializeNoteModels();let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}_initializeNoteModels(t,n){for(let[e,i]of this.noteModelMap){var r;(n!=null&&n.has(e)||(t==null?void 0:t[e])!==((r=this.snapshot.notes)==null?void 0:r[e])||!(t!=null&&t[e]))&&(i.dispose(),this.noteModelMap.delete(e))}for(let[t,n]of Object.entries(this.snapshot.notes??{})){if(this.noteModelMap.has(t))continue;let r=new e({...n,id:this.getUnitId(),documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles});this.noteModelMap.set(t,r)}}updateDocumentStyle(e){super.updateDocumentStyle(e),this._initializeNoteModels()}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e;return Uv(((e=this.getBody())==null?void 0:e.dataStream)??``)}getStatistics(e={}){var t;return Mm(((t=this.getBody())==null?void 0:t.dataStream)??``,e)}};function Zv(e){if(e==null)return{};let t=B.deepClone(e);return B.removeNull(t),t}function Qv(e,t){if(!e||!t)return{};let n=new Set,r=t=>{if(n.has(t))return{};let i=e[t];if(!i||i.type!==1)return{};n.add(t);let a=i.basedOn?r(i.basedOn):{};return n.delete(t),{...a,...Zv(i.paragraphStyle)}};return r(t)}function $v(e,t,n={}){let r=n.useLegacyModernDefaults??(e==null?void 0:e.documentFlavor)===2?{lineSpacing:Fh,spaceAbove:{v:0},spaceBelow:{v:12}}:{},i={...(e==null?void 0:e.documentFlavor)===1?{widowControl:1}:{},...r,...Zv(e==null?void 0:e.defaultParagraphStyle)};n.excludeDocumentOuterSpacing&&(delete i.spaceAbove,delete i.spaceBelow);let a=Zv(t),o=Qv(n.styles,n.paragraphStyleId),s=a.namedStyleType??o.namedStyleType,c=s==null?null:Ih[s];return B.deepClone({...i,...c,...o,...a})}function ey(e,t,n,r){if(t===``)return e;let i=new Xv({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new X,t=Vv.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),t!=null&&(s=t.customRanges)!=null&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function ty(e){let{ranges:t,id:n,type:r}=e,i=new X,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:`r`,len:o-a}),i.push({t:`r`,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function ny(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new X,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:`r`,len:c}),s.push({t:`r`,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:9999}]}}),s}function ry(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function iy(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?_g(fg(i),e.startOffset)&&n.push(i):vg({startOffset:e.startOffset,endOffset:e.endOffset},fg(i))&&n.push(i)}return n}function ay(e){return{...B.deepClone(e),rangeId:Y()}}function oy(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function sy(e,t,n,r){let i=[],a=sg({startIndex:e,endIndex:t});for(let e=0,o=n.length;e<o;e++){let o=n[e];if((r===void 0||o.rangeType===r)&&vg(a,fg(o))&&i.push({...o}),o.startIndex>t)break}return i}function cy(e,t){var n,r;let i=sy(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,t.customRanges??[]),a=Math.min(e.startOffset,((n=i[0])==null?void 0:n.startIndex)??1/0),o=Math.max(e.endOffset,(((r=i[i.length-1])==null?void 0:r.endIndex)??-1/0)+1);return{startOffset:a,endOffset:o,collapsed:a===o}}var ly=h(f(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;){if(a<e.length-1&&!e[a][1]){e.splice(a,1);continue}switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``;break}}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O}))());function uy(e){var t;let{rangeId:n,segmentId:r,documentDataModel:i,insert:a}=e,o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===n);if(!o)return!1;let{startIndex:s,endIndex:c}=o,l=new X,u=c-s+1;l.push({t:`r`,len:s}),l.push({t:`r`,len:u,body:{dataStream:``,customRanges:[]}}),a&&l.push({t:`i`,body:a,len:a.dataStream.length});let d=c+1+((a==null?void 0:a.dataStream.length)??0);return l.selections=[{startOffset:d,endOffset:d,collapsed:!0}],l}function dy(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new X,l=!1;return t.forEach(e=>{let t=cy(e,o);if(!t||!o)return!1;let{startOffset:u,endOffset:d}=t,f=o.customRanges??[],p=(e,t,o)=>{var l,u;let d=sy(e,t,f,r),p=Math.min(((l=d[0])==null?void 0:l.startIndex)??1/0,e),m=Math.max(((u=d[d.length-1])==null?void 0:u.endIndex)??-1/0,t),h={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:m-p,wholeEntity:i,properties:{...a}};c.push({t:`r`,len:p-s}),c.push({t:`r`,len:m-p+1,body:{dataStream:``,customRanges:[h]},coverType:0}),s=m+1},m=(o.paragraphs??[]).filter(e=>e.startIndex<d&&e.startIndex>u),h=(o.customBlocks??[]).filter(e=>e.startIndex<d&&e.startIndex>u);oy([u,d-1],[...m.map(e=>e.startIndex),...h.map(e=>e.startIndex)]).forEach(([e,t],n)=>p(e,t,n)),l=!0,c.selections=[{startOffset:t.endOffset,endOffset:t.endOffset,collapsed:!0}]}),l?c:!1}function fy(e,t){return!!(e.atomicRange&&t.some(t=>t.startOffset<=e.atomicRange.startOffset&&t.endOffset>=e.atomicRange.endOffset))}let py=new Set([`\r`,`
9
- `]),my=new Set([...py,``,``,``,``]);function hy(e){let t=e.filter(e=>e.endOffset>e.startOffset).map(e=>({...e,collapsed:!1})).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),n=[];for(let e of t){let t=n[n.length-1];if(t&&e.startOffset<=t.endOffset){t.endOffset=Math.max(t.endOffset,e.endOffset);continue}n.push(e)}return n}function gy(e,t,n,r){let i=e.startOffset;for(let a of t){if(a.endOffset<=i||a.startOffset>=e.endOffset)continue;let t=Math.max(a.startOffset,e.startOffset),o=Math.min(a.endOffset,e.endOffset);for(let e=i;e<t;e++)if(!r.has(n.dataStream[e]))return!1;if(i=Math.max(i,o),i>=e.endOffset)return!0}for(let t=i;t<e.endOffset;t++)if(!r.has(n.dataStream[t]))return!1;return!0}function _y(e,t,n,r){let i=[...e],a=e[0];for(let e of t)gy(e,i,n,r)&&i.push({...a,...e,collapsed:!1});return hy(i)}function vy(e,t){let n=hy(e);n=_y(n,(t.blockRanges??[]).map(ug),t,py),n=_y(n,(t.customRanges??[]).map(fg),t,py),n=_y(n,(t.columnGroups??[]).map(dg),t,my);let r=Math.max(0,t.dataStream.length-2);return r>0&&(n=_y(n,[{startOffset:0,endOffset:r}],t,py)),n}function yy(e,t){return t.some(t=>e>=t.startOffset&&e<t.endOffset)}function by(e,t){return e>=t.startOffset&&e<=t.endOffset}function xy(e,t,n){e.length&&e.every(e=>yy(e,t))&&n.add(e[e.length-1])}function Sy(e,t,n){let r=(e.columnGroups??[]).map(dg).filter(e=>t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset));for(let i=0;i<e.dataStream.length;i++){let a=e.dataStream[i];(a===``||a===``||a===``||a===``)&&yy(i,t)&&!r.some(e=>i>=e.startOffset&&i<e.endOffset)&&n.add(i)}}function Cy(e,t,n){for(let r of e.blockRanges??[]){let e=ug(r);t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset)||(yy(r.startIndex,t)&&n.add(r.startIndex),yy(r.endIndex,t)&&n.add(r.endIndex))}}function wy(e){let t=[...e.blockRanges??[]].sort((e,t)=>e.startIndex-t.startIndex),n=t.map(e=>{let t=ug(e);return{atomicRange:t,startOffset:t.startOffset+1,endOffset:t.endOffset-1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`}}),r=(e,r)=>{let i=0,a=t.length-1,o=-1;for(;i<=a;){let n=Math.floor((i+a)/2),r=t[n];if(e<=r.startIndex)a=n-1;else if(e>=r.endIndex)i=n+1;else{o=n;break}}o>=0&&n[o][r].push(e)};return(e.paragraphs??[]).forEach(e=>r(e.startIndex,`paragraphs`)),(e.sectionBreaks??[]).forEach(e=>r(e.startIndex,`sectionBreaks`)),n}function Ty(e){let t=[{startOffset:0,endOffset:e.dataStream.length,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`}],n=[],r=[],i=()=>r.length?r[r.length-1]:n.length?n[n.length-1]:t[0];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)n.push({atomicRange:{startOffset:a,endOffset:a+1},startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`});else if(o===``){let e=n.pop();e&&(e.endOffset=a,e.atomicRange&&(e.atomicRange.endOffset=a+1),t.push(e))}else if(o===``)r.push({startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`});else if(o===``){let e=r.pop();e&&(e.endOffset=a,t.push(e))}else o===`\r`?i().paragraphs.push(a):o===`
10
- `&&i().sectionBreaks.push(a)}return t.push(...wy(e)),t}function Ey(e,t,n,r,i){if(fy(e,t))return;let a=n&&by(r,e),o=(n==null?void 0:n.dataStream)??``,s=o.includes(`\r`),c=o.includes(`
11
- `);if(e.require===`paragraph-or-section`){let n=[...e.paragraphs,...e.sectionBreaks].sort((e,t)=>e-t);(!a||!s&&!c)&&xy(n,t,i);return}(!a||!s)&&xy(e.paragraphs,t,i),(!a||!c)&&xy(e.sectionBreaks,t,i)}function Dy(e,t,n){if(!e.length)return e;let r=n==null?vy(e,t):e;if(!r.length)return e;let i=r[0].startOffset,a=new Set;if(Ty(t).forEach(e=>{Ey(e,r,n,i,a)}),Sy(t,r,a),Cy(t,r,a),!a.size)return r;let o=[];return r.forEach(e=>{let t=e.startOffset;for(let n=e.startOffset;n<e.endOffset;n++)a.has(n)&&(t<n&&o.push({...e,startOffset:t,endOffset:n,collapsed:!1}),t=n+1);t<e.endOffset&&o.push({...e,startOffset:t,endOffset:e.endOffset,collapsed:!1})}),o.length?o:[{...r[0],endOffset:r[0].startOffset,collapsed:!0}]}function Oy(e,t,n=0,r=null,i=!0){let a=Dy([...e].sort((e,t)=>e.startOffset-t.startOffset),t,r),o=[],{paragraphs:s=[]}=t,c=s==null?void 0:s.find(e=>e.startIndex>=a[0].startOffset&&e.startIndex<a[0].endOffset),l=n;if(a.forEach(e=>{let{startOffset:t,endOffset:n}=e;t>l&&(o.push({t:`r`,len:t-l}),l=t),l<n&&(o.push({t:`d`,len:n-l}),l=n)}),r&&o.push({t:`i`,body:r,len:r.dataStream.length}),c!=null&&c.bullet&&i){let e=s.find(e=>e.startIndex-n>=a[a.length-1].endOffset-1);e&&(e.startIndex>l&&(o.push({t:`r`,len:e.startIndex-l}),l=e.startIndex),o.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...e,startIndex:0,bullet:c==null?void 0:c.bullet}]},coverType:0}))}return o}function ky(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:`r`,len:n-i}),i=n),a>i&&(r.push({t:`r`,len:a-i,body:{...B.deepClone(t),dataStream:``}}),i=a)}),r}let Ay=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=Dy([n],o,r);if(s.length!==1||s[0].startOffset!==n.startOffset||s[0].endOffset!==n.endOffset){let e=new X;return e.push(...Oy([n],o,0,r)),e}let c=n.collapsed?null:uv(o,n.startOffset,n.endOffset),l=(0,ly.default)(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e={t:`r`,body:{...dv(r,u,u+t.length,!1),dataStream:``},len:t.length};return u+=t.length,e}case 1:{let e={t:`i`,body:dv(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:`d`,len:t.length}}}),f=new X;return f.push({t:`r`,len:n.startOffset}),f.push(...d),f};function jy(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}let My=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=Dy([n],s,r);if(c.length!==1||c[0].startOffset!==n.startOffset||c[0].endOffset!==n.endOffset){let e=new X;return e.push(...Oy([n],s,0,r)),e}let l=n.collapsed?null:uv(s,n.startOffset,n.endOffset),u=(0,ly.default)(l?l.dataStream:``,r.dataStream),d=0,f=u.map(([e,t])=>{switch(e){case 0:{let e=$_(r,d,d+t.length,!1),n={t:`r`,body:jy(e,$_(l,d,d+t.length,!1))?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r;return{...e,ts:{...e.ts,cl:(t=e.ts)!=null&&(t=t.cl)!=null&&(t=t.rgb)!=null&&t.includes(`.`)?{rgb:a.getColorFromTheme(((n=e.ts)==null||(n=n.cl)==null?void 0:n.rgb)??``)}:(r=e.ts)==null?void 0:r.cl}}}),dataStream:``},len:t.length};return d+=t.length,n}case 1:{let e={t:`i`,body:dv(r,d,d+t.length),len:t.length};return d+=t.length,e}default:return{t:`d`,len:t.length}}});if(f.every(e=>e.t===`r`&&!e.body))return!1;let p=new X;return p.push({t:`r`,len:n.startOffset}),p.push(...f),p};function Ny(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(t!=null&&i!=null)for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Py(e,t,n=e.body,r=``){var i;if(!n)return[];let a=(i=e.notes)==null?void 0:i[r],o=a??e,s=a?[`notes`,r]:[],c=o.drawings??{},l=o.drawingsOrder??[],u=[...new Set(Ny(n,t))].sort((e,t)=>l.indexOf(t)-l.indexOf(e)),d=Vv.getInstance(),f=[];for(let e of u){let t=c[e];if(t!=null){let n=d.removeOp([...s,`drawings`,e],t);n&&f.push(n)}let n=l.indexOf(e);if(n>=0){let t=d.removeOp([...s,`drawingsOrder`,n],e);t&&f.push(t)}}return f}let Fy=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new X,u=Vv.getInstance(),d=[],f=(t=i.getSelfOrHeaderFooterModel(c))==null?void 0:t.getBody();if(!f)return!1;let p=i.getSnapshot(),m=(n=p.notes)==null?void 0:n[c??``],h=m??p,g=m?[`notes`,c]:[],_=h.drawingsOrder??[],v=_.length;h.drawings??d.push(u.insertOp([...g,`drawings`],{})),h.drawingsOrder??d.push(u.insertOp([...g,`drawingsOrder`],[]));let y=o?Iy(f,s??0):s??0;if(o)y>0&&l.push({t:`r`,len:y});else{let e=Oy([r],f,0,null,!1);l.push(...e);let t=new Set(Ny(f,[r]));v-=_.filter(e=>t.has(e)).length;for(let e of Py(p,[r],f,c))e&&d.push(e)}let b=Ry(f,a,y);l.push({t:`i`,body:b,len:b.dataStream.length});let x=wv(i,c),S=u.editOp(l.serialize(),x);d.push(S);for(let e of a){let{drawingId:t}=e,n=u.insertOp([...g,`drawings`,t],e),r=u.insertOp([...g,`drawingsOrder`,v++],t);d.push(n),d.push(r)}return d.reduce((e,t)=>Vv.compose(e,t),null)};function Iy(e,t){let{dataStream:n}=e;return t===0&&n[0]===`\r`?1:n[t]===`
12
- `&&n[t-1]===`\r`&&Ly(n,t)?t-1:t}function Ly(e,t){let n=0;for(let r=0;r<t;r++)e[r]===``?n++:e[r]===``&&(n=Math.max(0,n-1));return n>0}function Ry(e,t,n){var r;let i=`\b`.repeat(t.length),a=e.dataStream[n]===`
13
- `||e.dataStream[n]===void 0;return{dataStream:a?`${i}\r`:i,customBlocks:t.map((e,t)=>({startIndex:t,blockId:e.drawingId})),...a?{paragraphs:[{startIndex:i.length,paragraphId:Hh(new Set((r=e.paragraphs)==null?void 0:r.map(e=>e.paragraphId)))}]}:{}}}function zy(e,t){if(e==null||t==null)return null;let n=e.dataStream,r=t.dataStream;if(n===r)return null;let i=r.length-n.length;if(i>0){let a=Vy(e,t,n,r,i);if(a)return a}else if(i<0){let a=By(e,t,n,r,-i);if(a)return a}let a=0;for(;a<n.length&&a<r.length&&n[a]===r[a];)a++;let o=n.length,s=r.length;for(;o>a&&s>a&&n[o-1]===r[s-1];)o--,s--;return{start:a,deleteLength:o-a,insertLength:s-a}}function By(e,t,n,r,i){for(let a of Hy(t,e))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a+i)===r.slice(a))return{start:a,deleteLength:i,insertLength:0};return null}function Vy(e,t,n,r,i){for(let a of Hy(e,t))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a)===r.slice(a+i))return{start:a,deleteLength:0,insertLength:i};return null}function Hy(e,t){let n=[...Uy(e.blockRanges,t.blockRanges,e=>e.blockId),...Uy(e.tables,t.tables,e=>e.tableId),...Uy(e.columnGroups,t.columnGroups,e=>e.columnGroupId),...Uy(e.customBlocks,t.customBlocks,e=>e.blockId)];return Array.from(new Set(n)).sort((e,t)=>e-t)}function Uy(e,t,n){let r=new Set((e??[]).map(n));return(t??[]).filter(e=>!r.has(n(e))).map(e=>e.startIndex)}var Z=class{};T(Z,`customRange`,{add:dy,delete:uy,copyCustomRange:ay,getCustomRangesInterestsWithSelection:iy,isIntersecting:ry}),T(Z,`customDecoration`,{add:ty,delete:ny}),T(Z,`selection`,{replace:Ay,makeSelection:N_,normalizeSelection:P_,delete:Oy,replaceTextRuns:My,retain:ky}),T(Z,`range`,{isIntersects:F_,getParagraphsInRange:I_,getParagraphsInRanges:L_}),T(Z,`transform`,{getPlainText:Uv,fromPlainText:Gv,isEmptyDocument:Wv}),T(Z,`paragraph`,{bullet:{set:H_,switch:B_,toggleChecklist:V_,changeNestLevel:J_},style:{set:Y_},util:{transform:z_,getParagraphsInRange:I_,getParagraphsInRanges:L_}}),T(Z,`drawing`,{add:Fy,remove:Py});let Wy=new Set(Object.values(Sm).filter(e=>e!==``&&e!==` `));function Gy(e){if(e.customRanges||=[],!e.paragraphs){e.paragraphs=[];let t=new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`\r`&&e.paragraphs.push({startIndex:n,paragraphId:Hh(t)})}if(e.customBlocks||=[],e.textRuns||=[],e.customDecorations||=[],!e.sectionBreaks){e.sectionBreaks=[];let t=new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`
14
- `&&e.sectionBreaks.push({startIndex:n,sectionId:vm(t)})}return e.tables||=[],e}function Ky(e){return e.body=Gy(e.body??{dataStream:``}),e.drawingsOrder||=[],e.drawings||={},e.documentStyle||={},e}function qy(e){return typeof e==`string`?{rgb:e}:e}function Jy(e){let{bold:t,italic:n,fontFamily:r,fontSize:i,color:a,background:o,...s}=e,c={...s};return t!==void 0&&(c.bl=+!!t),n!==void 0&&(c.it=+!!n),r!==void 0&&(c.ff=r),i!==void 0&&(c.fs=i),a!==void 0&&(c.cl=qy(a)),o!==void 0&&(c.bg=qy(o)),c}function Yy(e){return typeof e==`number`?{v:e}:e}function Xy(e){if(e)return e instanceof nb?e.build():{horizontalAlign:e.align,lineSpacing:e.lineHeight,spacingRule:e.lineHeightRule,indentFirstLine:Yy(e.firstLineIndent),hanging:Yy(e.hangingIndent),indentStart:Yy(e.indentStart),indentEnd:Yy(e.indentEnd),spaceAbove:Yy(e.spaceBefore),spaceBelow:Yy(e.spaceAfter),direction:e.direction,wordWrap:e.wordWrap===void 0?void 0:+!!e.wordWrap,keepLines:e.keepLines===void 0?void 0:+!!e.keepLines,keepNext:e.keepNext===void 0?void 0:+!!e.keepNext}}function Zy(e){var t;return(((t=e.body)==null?void 0:t.dataStream)??``).replace(/\r|\n/g,``).length>0}var Qy=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===1}get bold(){return this._style.bl===1}get underline(){return this._style.ul&&eb.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&eb.create(this._style.bbl)}get strikethrough(){return this._style.st&&eb.create(this._style.st)}get overline(){return this._style.ol&&eb.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return $y.create(B.deepClone(this._style))}getValue(){return{...this._style}}},$y=class e extends Qy{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=+!!e,this}setBold(e){return this._style.bl=+!!e,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(B.deepClone(this._style))}build(){return this.getValue()}},eb=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){T(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===1}get followFontColor(){return this._decoration.c===1}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=+!!e,this}setFollowFontColor(e){return this._decoration.c=+!!e,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(B.deepClone(this._decoration))}build(){return{...this._decoration}}},tb=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===1}get keepNext(){return this._style.keepNext===1}get wordWrap(){return this._style.wordWrap===1}get widowControl(){return this._style.widowControl===1}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===1}copy(){return nb.create(B.deepClone(this._style))}getValue(){return this._style}},nb=class e extends tb{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=+!!e,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=+!!e,this}setKeepNext(e){return this._style.keepNext=+!!e,this}setWordWrap(e){return this._style.wordWrap=+!!e,this}setWidowControl(e){return this._style.widowControl=+!!e,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=+!!e,this}copy(){return e.create(B.deepClone(this._style))}build(){return this.getValue()}},rb=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(T(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=Ky(e)}copy(){return ib.create(B.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return ib.create({...B.deepClone(r),body:uv(n,e,t)})}toPlainText(){var e;return Z.transform.getPlainText(((e=this._data.body)==null?void 0:e.dataStream)??``).replaceAll(`\r`,`
15
- `)}getParagraphStyle(){var e;return tb.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){let e=this._data.body;if(!e)return[];let t=K_(e);return(e.paragraphs??[]).map(e=>ib.create(sb(this._data,e.paragraphId,{startOffset:t.get(e.startIndex)??0,endOffset:e.startIndex})))}getTextRuns(){var e;return(((e=this._data.body)==null?void 0:e.textRuns)??[]).map(e=>({...e,ts:e.ts?Qy.create(e.ts):null}))}getLinks(){var e;return((e=this._data.body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getData(){return this._data}},ib=class e extends rb{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`constructor`)return;let n=Object.getOwnPropertyDescriptor(e.prototype,t);n&&Object.defineProperty(this.prototype,t,n)})}static newEmptyData(){return Ky({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
16
- `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0,paragraphId:Hh(new Set)}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t??e.newEmptyData())}constructor(e){super(e),T(this,`_doc`,void 0),T(this,`_trackedRanges`,new Set),T(this,`_childHandleRevision`,0),this._doc=new Xv(e)}getParagraphs(){let e=this._data.body;if(!e)return[];let t=K_(e);return(e.paragraphs??[]).map(e=>this._createParagraphBuilder(e.paragraphId,t.get(e.startIndex)??0,e.startIndex))}getTextRuns(){return this.getParagraphs().flatMap(e=>e.getTextRuns())}_createTextRunBuilders(e){let t=this._data.body;if(!t||e.startOffset>=e.endOffset)return[];let n=new Set([e.startOffset,e.endOffset]),r=(t,r)=>{let i=Math.max(t,e.startOffset),a=Math.min(r,e.endOffset);i<a&&(n.add(i),n.add(a))};for(let e of t.textRuns??[])r(e.st,e.ed);for(let e of t.customRanges??[])r(e.startIndex,e.endIndex+1);for(let e of t.customDecorations??[])r(e.startIndex,e.endIndex+1);for(let r=e.startOffset;r<e.endOffset;r++)Wy.has(t.dataStream[r])&&(n.add(r),n.add(r+1));let i=[...n].sort((e,t)=>e-t),a=[];for(let e=0;e<i.length-1;e++){let n=i[e],r=i[e+1];if(n>=r||r-n===1&&Wy.has(t.dataStream[n]))continue;let o=(t.textRuns??[]).find(e=>e.st<=n&&e.ed>=r);a.push(new ob(this,this._trackRange(n,r),o==null?void 0:o.ts,o==null?void 0:o.sId,!!o,this._childHandleRevision))}return a}_replaceTextRun(e,t,n,r,i){var a,o;if(t.includes(`\r`)||t.includes(`
17
- `))throw RangeError(`Rich text run replacement cannot contain paragraph or section breaks.`);let s=this._doc.getBody();if(!s)throw Error(`Rich text body is not available.`);let{startOffset:c,endOffset:l}=e;if(s.dataStream.slice(c,l)===t)return;let u=uv(s,c,l),d={dataStream:t};t&&i&&(d.textRuns=[{st:0,ed:t.length,sId:r,ts:B.deepClone(n)}]),t&&(a=u.customRanges)!=null&&a.length&&(d.customRanges=u.customRanges.map(e=>({...B.deepClone(e),startIndex:0,endIndex:t.length-1}))),t&&(o=u.customDecorations)!=null&&o.length&&(d.customDecorations=u.customDecorations.map(e=>({...B.deepClone(e),startIndex:0,endIndex:t.length-1})));let f=Z.selection.replace({doc:this._doc,selection:{startOffset:c,endOffset:l,collapsed:c===l},body:d});if(!f)throw Error(`Replace rich text run failed.`);X.apply(s,f.serialize()),this._rebaseTrackedRanges(c,l,t.length)}_createParagraphBuilder(e,t,n){return new ab(this,e,this._trackRange(t,n),this._childHandleRevision)}_assertChildHandleRevision(e){if(e!==this._childHandleRevision)throw Error(`Rich text child handle is no longer valid.`)}_trackRange(e,t){let n={startOffset:e,endOffset:t};return this._trackedRanges.add(n),n}_rebaseTrackedRanges(e,t,n){let r=n-(t-e),i=n=>n<=e?n:n>=t?n+r:e,a=i=>i<=e?i:i>=t?i+r:e+n;for(let e of this._trackedRanges)e.startOffset=i(e.startOffset),e.endOffset=a(e.endOffset)}_invalidateChildHandles(){this._childHandleRevision++,this._trackedRanges.clear()}text(e){return this.insertText(e)}align(e){let t=this._data.documentStyle??={},n=t.renderConfig??={};if(e.horizontal!==void 0){var r;n.horizontalAlign=e.horizontal;for(let t of((r=this._data.body)==null?void 0:r.paragraphs)??[])t.paragraphStyle={...t.paragraphStyle,horizontalAlign:e.horizontal}}return e.vertical!==void 0&&(n.verticalAlign=e.vertical),this}columns(e){if(!Number.isInteger(e.count)||e.count<1)throw RangeError(`Rich text column count must be a positive integer.`);let t=this._data.body??={dataStream:`\r
18
- `},n=t.sectionBreaks??=[];if(!n.length){var r;n.push({sectionId:vm(new Set),startIndex:Math.max(0,(((r=t.dataStream)==null?void 0:r.length)??0)-1)})}let i=Math.max(0,e.spacing??0),a=e.count===1?void 0:Array.from({length:e.count},(t,n)=>({width:0,paddingEnd:n===e.count-1?0:i}));for(let e of n)a?e.columnProperties=a.map(e=>({...e})):delete e.columnProperties;return this}span(e,t){return e?t?this.insertText(e,Jy(t)):this.insertText(e):this}bold(e){return this.span(e,{bold:!0})}italic(e){return this.span(e,{italic:!0})}code(e){return this.span(e,{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,background:`#f3f4f6`})}link(e,t){return e?this.insertLink(e,t):this}listItem(e,t={}){var n,r,i;let a=t.type??`BULLET_LIST`,o=(n=this._data.body)==null||(n=n.paragraphs)==null?void 0:n.slice(-1)[0],s=o==null?void 0:o.bullet,c=((r=t.listId)==null?void 0:r.trim())||((s==null?void 0:s.listType)===a?s.listId:Y());(Zy(this._data)||t.paragraphStyle)&&this.paragraph(t.paragraphStyle);let l=(i=this._data.body)==null||(i=i.paragraphs)==null?void 0:i.slice(-1)[0];return l&&(l.bullet={listId:c,listType:a,nestingLevel:Math.max(0,Math.trunc(t.level??0))}),this.text(e)}paragraph(e){var t,n,r;let i=Xy(e);if(!Zy(this._data)){if(i){var a;let e=(a=this._data.body)==null||(a=a.paragraphs)==null?void 0:a[0];e&&(e.paragraphStyle=i)}return this}let o=(t=this._data.body)==null||(t=t.paragraphs)==null?void 0:t.slice(-1)[0],s=B.deepClone(o==null?void 0:o.paragraphStyle),c=B.deepClone(o==null?void 0:o.bullet),l=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2);this.insertRichText(l,rb.create({id:`d`,documentStyle:{},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Hh(new Set),paragraphStyle:s,bullet:c}]}}));let u=(r=this._data.body)==null||(r=r.paragraphs)==null?void 0:r.slice(-1)[0];return i?u&&(u.paragraphStyle=i):u&&delete u.paragraphStyle,u&&delete u.bullet,this}insertText(e,t,n){var r;let i=(((r=this._data.body)==null?void 0:r.dataStream.length)??2)-2,a,o;if(typeof e==`string`?a=e:(i=Math.min(e,i),a=typeof t==`string`?t:``),o=typeof t==`object`?t instanceof $y?t.build():t:n instanceof $y?n.build():n,!a)return this;let s=Z.transform.fromPlainText(a),c={dataStream:s.dataStream,paragraphs:s.paragraphs,textRuns:o?[{ts:o,st:0,ed:s.dataStream.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),l.serialize()),this._invalidateChildHandles(),this}insertRichText(e,t){var n;let r=(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2,i;typeof e==`object`?i=e instanceof rb?e.getData():e:(r=Math.min(e,r),i=t instanceof rb?t.getData():t);let a=Z.selection.replace({doc:this._doc,selection:{startOffset:r,endOffset:r,collapsed:!0},body:i.body});if(!a)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),a.serialize()),this._invalidateChildHandles(),this}delete(e,t){var n;let r=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2),i,a;if(t===void 0){if(e<0)throw RangeError(`Delete count cannot be negative.`);a=Math.min(e,r),i=r-a}else{if(e<0||t<0)throw RangeError(`Delete range cannot be negative.`);i=Math.min(e,r),a=Math.min(t,r-i)}if(a>0){let e=Z.selection.delete([{startOffset:i,endOffset:i+a,collapsed:!0}],this._data.body);X.apply(this._doc.getBody(),e),this._invalidateChildHandles()}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof $y?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return X.apply(this._doc.getBody(),i),this._invalidateChildHandles(),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:0,rangeId:Y(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),r.serialize()),this._invalidateChildHandles(),this}cancelLink(e,t){let n=!1;if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0});return n&&this._invalidateChildHandles(),this}removeLink(e){return this.cancelLink(e)}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Hh(new Set),paragraphStyle:e.build()}]},r=(((i=this._data.body)==null?void 0:i.dataStream.length)??2)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Hh(new Set),paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,rb.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:0,rangeId:Y(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}},ab=class extends rb{constructor(e,t,n,r){super(sb(e.getData(),t,n)),this._owner=e,this._paragraphId=t,this._range=n,this._revision=r}getId(){return this._assertActive(),this._paragraphId}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}toPlainText(){return this.getText()}getTextRuns(){return this._assertActive(),this._owner._createTextRunBuilders(this._range)}getParagraphStyle(){return this._assertActive(),tb.create(this._getParagraph().paragraphStyle)}getParagraphBullet(){return this._assertActive(),this._getParagraph().bullet}getLinks(){var e;return this._assertActive(),((e=this.getData().body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getBullet(){return this.getParagraphBullet()}getData(){return this._assertActive(),sb(this._owner.getData(),this._paragraphId,this._range)}copy(){return ib.create(B.deepClone(this.getData()))}_getParagraph(){var e;let t=(e=this._owner.getData().body)==null||(e=e.paragraphs)==null?void 0:e.find(e=>e.paragraphId===this._paragraphId);if(!t)throw Error(`Rich text paragraph "${this._paragraphId}" was not found.`);return t}_assertActive(){this._owner._assertChildHandleRevision(this._revision)}},ob=class{constructor(e,t,n,r,i,a){this._owner=e,this._range=t,this._textStyle=n,this._styleId=r,this._hasExplicitTextStyle=i,this._revision=a,T(this,`_active`,!0)}get st(){return this._assertActive(),this._range.startOffset}get ed(){return this._assertActive(),this._range.endOffset}get sId(){return this._assertActive(),this._styleId}get ts(){return this._assertActive(),this._textStyle?Qy.create(this._textStyle):null}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}getTextStyle(){return this.ts}hasTextStyle(){return this._assertActive(),this._hasExplicitTextStyle}setText(e){return this._assertActive(),this._owner._replaceTextRun(this._range,e,this._textStyle,this._styleId,this._hasExplicitTextStyle),e||(this._active=!1),this}_assertActive(){if(!this._active)throw Error(`Rich text run handle is no longer valid.`);this._owner._assertChildHandleRevision(this._revision)}};function sb(e,t,n){var r;let{body:i,...a}=e;if(!i)throw Error(`Rich text body is not available.`);let o=(r=i.paragraphs)==null?void 0:r.find(e=>e.paragraphId===t);if(!o)throw Error(`Rich text paragraph "${t}" was not found.`);let s=uv(i,n.startOffset,n.endOffset);return s.paragraphs=[{...B.deepClone(o),startIndex:n.endOffset-n.startOffset}],{...B.deepClone(a),body:s}}let cb=`[${[`\r`,`
19
- `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\b`].join(``)}]`;function Q(e,t,n,r){return{...e,code:t,index:r,message:n}}function lb(e,t,n){e.hasRootParagraph||t.push(Q(n,`missing-root-paragraph`,`Document body must contain at least one paragraph sentinel.`)),e.hasRootSectionBreak||t.push(Q(n,`missing-root-section-break`,`Document body must contain at least one section break sentinel.`))}function ub(e,t,n){let r=new Map;for(let i of e.paragraphs??[])e.dataStream[i.startIndex]===`\r`?r.set(i.startIndex,(r.get(i.startIndex)??0)+1):t.push(Q(n,`paragraph-token-mismatch`,`Paragraph metadata must point to a paragraph sentinel.`,i.startIndex));fb(r,{context:n,duplicateCode:`duplicate-paragraph-metadata`,duplicateMessage:`Paragraph sentinel must have exactly one paragraph metadata entry.`},t)}function db(e,t,n){let r=new Map,i=new Map;for(let a of e.sectionBreaks??[])a.sectionId?i.set(a.sectionId,(i.get(a.sectionId)??0)+1):t.push(Q(n,`missing-section-id`,`Section break metadata must have a stable section id.`,a.startIndex)),e.dataStream[a.startIndex]===`
20
- `?r.set(a.startIndex,(r.get(a.startIndex)??0)+1):t.push(Q(n,`section-break-token-mismatch`,`Section break metadata must point to a section break sentinel.`,a.startIndex));fb(r,{context:n,duplicateCode:`duplicate-section-break-metadata`,duplicateMessage:`Section break sentinel must have exactly one section break metadata entry.`},t);for(let[e,r]of i)r>1&&t.push(Q(n,`duplicate-section-id`,`Section id "${e}" must be unique within a document segment.`))}function fb(e,t,n){for(let[r,i]of e)i>1&&n.push(Q(t.context,t.duplicateCode,t.duplicateMessage,r))}function pb(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(r.startIndex<n.startIndex||r.startIndex===n.startIndex&&r.endIndex<n.endIndex)return[...e].sort((e,t)=>e.startIndex-t.startIndex||e.endIndex-t.endIndex)}return e}function mb(){return{pairs:new Map,unmatchedEnds:[],unmatchedStarts:[]}}function hb(e,t,n){let r=e.unmatchedStarts.pop();if(r===void 0){e.unmatchedEnds.push(t);return}e.pairs.set(r,n?t+1:t)}function gb(e){let t={hasRootParagraph:!1,hasRootSectionBreak:!1,tableRanges:mb(),blockRanges:mb(),columnGroupRanges:mb(),customBlockIndexes:new Set},n=new RegExp(cb,`g`);for(let r of e.matchAll(n)){let e=r.index,n=r[0];n===`\r`?t.hasRootParagraph=!0:n===`
21
- `?t.hasRootSectionBreak=!0:n===``?t.tableRanges.unmatchedStarts.push(e):n===``?hb(t.tableRanges,e,!0):n===``?t.blockRanges.unmatchedStarts.push(e):n===``?hb(t.blockRanges,e,!1):n===``?t.columnGroupRanges.unmatchedStarts.push(e):n===``?hb(t.columnGroupRanges,e,!1):n===`\b`&&t.customBlockIndexes.add(e)}return t}function _b(e,t,n,r){let i=t.tableRanges.pairs,a=new Set,o,s=pb(e.tables??[]);for(let t of s)a.add(t.startIndex),(!Number.isInteger(t.startIndex)||e.dataStream[t.startIndex]!==``)&&n.push(Q(r,`table-start-token-mismatch`,`Table startIndex must point to a table start sentinel.`,t.startIndex)),(!Number.isInteger(t.endIndex)||t.endIndex<=t.startIndex||t.endIndex>e.dataStream.length||e.dataStream[t.endIndex-1]!==``||i.get(t.startIndex)!==t.endIndex)&&n.push(Q(r,`table-end-token-mismatch`,`Table endIndex must be the exclusive boundary immediately after a table end sentinel.`,t.endIndex)),o&&vg(lg(o),lg(t))&&n.push(Q(r,`overlapping-table`,`Table ranges must not overlap.`,t.startIndex)),o=t;for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-table-metadata`,`Table token range must have a table metadata entry.`,e))}function vb(e,t,n,r){let i=t.blockRanges;for(let e of[...i.unmatchedStarts,...i.unmatchedEnds])n.push(Q(r,`unbalanced-block`,`Block sentinel has no matching boundary.`,e));let a=pb(e.blockRanges??[]),o=new Set,s;for(let e=0;e<a.length;e++){let t=a[e];o.add(t.startIndex),i.pairs.get(t.startIndex)!==t.endIndex&&n.push(Q(r,`block-range-token-mismatch`,`Block range must point to its matching block start and end sentinels.`,t.startIndex)),s&&vg(ug(s),ug(t))&&n.push(Q(r,`overlapping-block-range`,`Block ranges must not overlap or share structural sentinels.`,t.startIndex)),s=t}for(let e of i.pairs.keys())o.has(e)||n.push(Q(r,`missing-block-range-metadata`,`Block token range must have a block metadata entry.`,e))}function yb(e,t,n,r){let i=t.columnGroupRanges.pairs,a=new Set,o=pb(e.columnGroups??[]),s;for(let t of o){a.add(t.startIndex);let o=i.get(t.startIndex);if(o!==t.endIndex&&n.push(Q(r,`column-group-range-token-mismatch`,`Column group range must point to its matching start and end sentinels.`,t.startIndex)),s&&vg(dg(s),dg(t))&&n.push(Q(r,`overlapping-column-group`,`Column group ranges must not overlap.`,t.startIndex)),s=t,Array.isArray(t.columns)){let i=0,a=o??t.endIndex;for(let n=t.startIndex+1;n<a;n++)e.dataStream[n]===``&&i++;i!==t.columns.length&&n.push(Q(r,`column-group-column-count-mismatch`,`Column group metadata column count must match the data stream.`,t.startIndex))}}for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-column-group-metadata`,`Column group token range must have a metadata entry.`,e))}function bb(e,t,n,r){let i=new Map,a=[...e.customBlocks??[],...e.docxRawCustomBlocks??[]];for(let t of a){let{startIndex:a}=t;if(!Number.isInteger(a)||e.dataStream[a]!==`\b`){n.push(Q(r,`custom-block-token-mismatch`,`Custom block startIndex must point to a custom block sentinel.`,a));continue}i.set(a,(i.get(a)??0)+1)}fb(i,{context:r,duplicateCode:`duplicate-custom-block-metadata`,duplicateMessage:`Custom block sentinel must have exactly one custom block metadata entry.`},n);for(let e of t.customBlockIndexes)i.has(e)||n.push(Q(r,`missing-custom-block-metadata`,`Custom block sentinel must have a custom block metadata entry.`,e))}function xb(e,t,n){let r=[],i=[],a=[],o=[],s=[],c=new RegExp(cb,`g`);for(let l of e.dataStream.matchAll(c)){let e=l.index,c=l[0],u=i[i.length-1],d=s[s.length-1];if(c===`\r`)u&&(u.hasChild=!0),d&&(d.hasParagraph=!0);else if(c===`
22
- `)u&&(u.hasChild=!0),d&&(d.hasSectionBreak=!0);else if(c===``)r.push(e);else if(c===``)i.push({startIndex:e,hasChild:!1});else if(c===``){let r=i.pop();r?r.hasChild||t.push(Q(n,`empty-column`,`Column must contain at least one paragraph or section child.`,r.startIndex)):t.push(Q(n,`unbalanced-column-group`,`Column end token has no matching column start.`,e))}else if(c===``)i.length>0||r.length===0?(t.push(Q(n,`unbalanced-column-group`,`Column group closes while a column is still open.`,e)),i.length=0):r.pop();else if(c===``)a.push(e);else if(c===`\x1B`)o.push(e);else if(c===``)s.push({startIndex:e,hasParagraph:!1,hasSectionBreak:!1});else if(c===``){let r=s.pop();r?(!r.hasParagraph||!r.hasSectionBreak)&&t.push(Q(n,`empty-table-cell`,`Table cell must contain a paragraph and section break child.`,r.startIndex)):t.push(Q(n,`unbalanced-table`,`Table cell end token has no matching start.`,e))}else c===``?s.length>0||o.length===0?(t.push(Q(n,`unbalanced-table`,`Table row closes while a cell is still open.`,e)),s.length=0):o.pop():c===``&&(s.length>0||o.length>0||a.length===0?(t.push(Q(n,`unbalanced-table`,`Table closes while a row or cell is still open.`,e)),s.length=0,o.length=0):a.pop())}(r.length>0||i.length>0)&&t.push(Q(n,`unbalanced-column-group`,`Column group or column token is not closed.`,e.dataStream.length)),(a.length>0||o.length>0||s.length>0)&&t.push(Q(n,`unbalanced-table`,`Table, row, or cell token is not closed.`,e.dataStream.length))}function Sb(e,t={segmentType:`body`}){let n=[],r=gb(e.dataStream);if(lb(r,n,t),ub(e,n,t),db(e,n,t),_b(e,r,n,t),vb(e,r,n,t),yb(e,r,n,t),bb(e,r,n,t),xb(e,n,t),t.segmentType===`header`||t.segmentType===`footer`)for(let r of e.customRanges??[])(r.rangeType===8||r.rangeType===9)&&n.push(Q(t,`invalid-note-reference`,`Note references are only supported in the document body.`,r.startIndex));return n}function Cb(e,t){var n,r,i;let a={segmentType:`note`,segmentId:e},o=Sb(t.body,a);(t.noteId!==e||e.length===0||![`footnote`,`endnote`].includes(t.type))&&o.push({...a,code:`invalid-note-id`,message:`Note identity must match its segment key.`}),(n=t.body.customRanges)!=null&&n.some(e=>e.rangeType===8||e.rangeType===9)&&o.push({...a,code:`nested-note`,message:`A note cannot contain another note reference.`});let s=((r=t.body.sectionBreaks)==null?void 0:r.filter(e=>{var n;return!((n=t.body.tables)!=null&&n.some(t=>e.startIndex>=t.startIndex&&e.startIndex<t.endIndex))}))??[],c=s.some(e=>Object.keys(e).some(e=>e!==`sectionId`&&e!==`startIndex`)),l=Object.values(t.drawings??{}).some(e=>e.layoutType!==0),u=Object.values(t.tableSource??{}).some(e=>e.textWrap===1);return(s.length>1||c||(i=t.body.columnGroups)!=null&&i.length||l||u)&&o.push({...a,code:`invalid-note-body`,message:`Notes support paragraphs, inline drawings and flow tables without independent sections or columns.`}),o}function wb(e){let t=[];if(e.body){t.push(...Sb(e.body,{segmentType:`body`}));let i=new Set;for(let a of e.body.customRanges??[]){var n,r;if(a.rangeType!==8&&a.rangeType!==9)continue;let o=(n=a.properties)==null?void 0:n.noteId;typeof o!=`string`||((r=e.notes)==null?void 0:r[o])==null?t.push({code:`missing-note`,segmentType:`body`,index:a.startIndex,message:`Note reference must resolve to a note segment.`}):e.notes[o].type===(a.rangeType===9?`endnote`:`footnote`)?i.has(o)?t.push({code:`duplicate-note-reference`,segmentType:`body`,index:a.startIndex,message:`Each note must have its own reference identity.`}):i.add(o):t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference kind must match its target.`}),(a.startIndex!==a.endIndex||e.body.dataStream[a.startIndex]!==``||!a.wholeEntity)&&t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference must cover one whole-entity reference character.`})}}for(let[n,r]of Object.entries(e.headers??{}))t.push(...Sb(r.body,{segmentType:`header`,segmentId:n}));for(let[n,r]of Object.entries(e.footers??{}))t.push(...Sb(r.body,{segmentType:`footer`,segmentId:n}));for(let[n,r]of Object.entries(e.notes??{})){var i,a;t.push(...Cb(n,r)),((i=e.headers)!=null&&i[n]||(a=e.footers)!=null&&a[n])&&t.push({code:`invalid-note-id`,segmentType:`note`,segmentId:n,message:`Notes must not share a segment identity with a header or footer.`})}return t}function Tb(e,t){return`${t==="default"?`default`:t===`first`?`firstPage`:`evenPage`}${e===`header`?`Header`:`Footer`}Id`}function Eb(e,t,n,r){if(n<0||n>=t.length)return{linkedToPrevious:!1};let i=t[n],a=i[r];if(typeof a==`string`&&a)return{segmentId:a,linkedToPrevious:!1,sourceSectionId:i.sectionId};if(n===0){let t=e[r];return{...typeof t==`string`&&t?{segmentId:t}:{},linkedToPrevious:!1}}let o=Eb(e,t,n-1,r);return{...o.segmentId?{segmentId:o.segmentId}:{},linkedToPrevious:!0,sourceSectionId:o.sourceSectionId}}function Db(e,t,n){let r={};for(let i of[`defaultHeaderId`,`defaultFooterId`,`firstPageHeaderId`,`firstPageFooterId`,`evenPageHeaderId`,`evenPageFooterId`]){let{segmentId:a}=Eb(e,t,n,i);a&&(r[i]=a)}return r}var Ob=class{constructor(){T(this,`skipNextObservers`,!1),T(this,`lastReturnValue`,void 0),T(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},kb=class extends t.Subject{constructor(...e){super(...e),T(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>(e.priority??0)-(t.priority??0)),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Ob;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function Ab(e){return new t.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let jb=(0,i.createIdentifier)(`core.resource-manager.service`),Mb={[n.UnitRole.Editor]:`Editor`,[n.UnitRole.Owner]:`Owner`,[n.UnitRole.Reader]:`Reader`,[n.UnitRole.UNRECOGNIZED]:`UNRECOGNIZED`},Nb=e=>e?{userID:`${Mb[e]}_${Y(8)}`,name:Mb[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},Pb=(e,t)=>e.startsWith(Mb[t]);var Fb=class extends k{constructor(...e){super(...e),T(this,`_model`,new Map),T(this,`_userChange$`,new t.Subject),T(this,`userChange$`,this._userChange$.asObservable()),T(this,`_currentUser$`,new t.BehaviorSubject(Nb())),T(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let Ib=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,T(this,`_permissionMap`,new Map([])),T(this,`_permissionOverrides`,new Map),T(this,`_cfgEnableObjInherit`,!1),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(Nb(n.UnitRole.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?Pb(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[n.UniverType.UNIVER_SHEET,n.UniverType.UNIVER_DOC,n.UniverType.UNIVER_SLIDE,n.UniverType.UNIVER_BOARD],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=Y(8),{objectType:r,selectRangeObject:i,worksheetObject:a}=e,o=i||a,s={objectType:r,unitID:(o==null?void 0:o.unitID)||``,name:(o==null?void 0:o.name)||``,strategies:[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}],selectRangeObject:i};return this._permissionMap.set(t,s),t}async allowed(e){let{objectID:t,actions:r}=e,i=this._permissionMap.get(t);return i?r.map(e=>{let r=`${t}:${e}`;if(this._permissionOverrides.has(r))return{action:e,allowed:this._permissionOverrides.get(r)};let a=i.strategies.find(t=>t.action===e);return a?{action:e,allowed:this._getRole(a.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}}):r.map(e=>({action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],r=[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}];return e.objectIDs.forEach(i=>{let a=this._permissionMap.get(i),o=(a==null?void 0:a.strategies)||r,s={objectID:i,unitID:e.unitID,objectType:(a==null?void 0:a.objectType)||3,name:(a==null?void 0:a.name)||``,shareOn:!1,shareRole:n.UnitRole.Owner,shareScope:-1,scope:{read:n.ObjectScope.AllCollaborator,edit:n.ObjectScope.AllCollaborator},creator:Nb(n.UnitRole.Owner),strategies:o.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${i}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let r=o.find(t=>t.action===e);return r?{action:e,allowed:this._getRole(r.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}})};t.push(s)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:r}=e,i=this._permissionMap.get(t);i&&r&&(i.strategies=r.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,i),r.forEach(e=>{e.role===n.UnitRole.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===n.UnitRole.Owner||e.role===n.UnitRole.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}setCfgEnableObjInherit(e){this._cfgEnableObjInherit=e}getCfgEnableObjInherit(){return this._cfgEnableObjInherit}};Ib=pa([H(0,jb),H(1,(0,i.Inject)(Fb))],Ib);let Lb=(0,i.createIdentifier)(`IAuthzIoIoService`),Rb=(0,i.createIdentifier)(`univer.confirm-service`);var zb=class{constructor(){T(this,`confirmOptions$`,new t.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let Bb=`FOCUSING_UNIT`,Vb=`FOCUSING_SHEET`,Hb=`FOCUSING_DOC`,Ub=`FOCUSING_SLIDE`,Wb=`FOCUSING_BOARD`,Gb=`EDITOR_ACTIVATED`,Kb=`FOCUSING_FX_BAR_EDITOR`;var qb=class extends k{constructor(...e){super(...e),T(this,`_error$`,new t.Subject),T(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emitPermissionDenied(e,t=[]){this._error$.next({errorKey:`Permission denied.`,code:`PERMISSION_DENIED`,permissionTarget:JSON.stringify([e,[...new Set(t)].sort()])})}emit(e){this._error$.next({errorKey:e})}};let Jb=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Yb=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),Xb=(0,i.createIdentifier)(`core.image-io.service`),Zb=(0,i.createIdentifier)(`core.url-image.service`);function Qb(e=``,t=`zhCN`,n=``){return{id:e,sheetOrder:[],name:n,appVersion:Re,locale:t,dateSystem:`date1900`,styles:{},sheets:{},resources:[]}}var $b=class{constructor(e={}){T(this,`_styles`,void 0),T(this,`_cacheMap`,new vd(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=Y(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&B.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(B.diffValue(t[n],e))return n;return null}};let ex=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Gd.equals(t,e))),tx=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Gd.equals(e.range,r.range)}),nx={t:0,b:2,l:2,r:2},rx=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function ix(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=0,verticalAlign:s=0,wrapStrategy:c=0,cellValueType:l}=n,u=(a==null?void 0:a.t)??nx.t,d=(a==null?void 0:a.r)??nx.r,f=(a==null?void 0:a.b)??nx.b,p=(a==null?void 0:a.l)??nx.l,{vertexAngle:m,centerAngle:h}=px(i);return new Xv({id:`d`,body:{dataStream:`${e}\r
23
- `,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphId:Hh(new Set),paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{sectionId:vm(new Set),startIndex:r+1}]},documentStyle:{textStyle:B.deepClone(t),defaultParagraphStyle:{horizontalAlign:o},pageSize:{width:1/0,height:1/0},documentFlavor:0,marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function ax(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function ox(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function sx(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===0))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:0,body:i,properties:{url:t,refId:n}});a&&X.apply(i,a.serialize())}function cx(e){return e!=null}function lx(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function ux(e){let t=Mh.ff,n=Mh.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=`italic`;(e.it===0||e.it===void 0)&&(r=`normal`);let i=`bold`;(e.bl===0||e.bl===void 0)&&(i=`normal`);let a=n;e.fs&&(a=e.fs);let o=dx(e.ff,t),{va:s}=e,c=a;if(s===2||s===3){let{sbr:e,spr:t}=fx(o,c);c*=s===2?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function dx(e,t){return e!=null&&e.trim()?e.split(`,`).map(e=>{let t=e.trim().replace(/^['"]|['"]$/g,``);return t.includes(` `)?`"${t}"`:t}).filter(Boolean).join(`, `):t}function fx(e,t){return rx(t)}function px(e){let{a:t=0,v:n=0}=e||{a:0,v:0},r=0,i=t;return n===1&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}var mx=class{constructor(e,t){this._config=e,T(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return!n||n.hd!==1}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++)n[r]=this.getColumn(i)??{w:this._config.defaultColumnWidth,hd:0},r++;return n}getSize(){return eu(this._columnData)}getColumnWidth(e){var t;return((t=this._columnData[e])==null?void 0:t.w)??this._config.defaultColumnWidth}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}};function hx(e,t){let{textRuns:n=[]}=t,r=0;for(let t of n){let{ts:n={},st:i,ed:a}=t;if(n[e]==null)return 0;switch(e){case`bl`:case`it`:if(n[e]===0)return 0;break;case`ul`:case`st`:if(n[e].s===0)return 0;break;default:throw Error(`unknown style key: ${e} in IStyleBase`)}r+=a-i}return+(t.dataStream.indexOf(`\r
24
- `)===r)}var gx=class e{constructor(e,t,n){this._deps=n,T(this,`_range`,void 0),T(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new lu;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new lu;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=B.numToWord(n+1)+(e+1),a=B.numToWord(r+1)+(t+1)):(i=B.numToWord(r+1)+(t+1),a=B.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||Mh.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).clone();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||Mh.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?hx(`ul`,t.body)===1?{s:1}:{s:0}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?hx(`st`,t.body)===1?{s:1}:{s:0}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(hx(`it`,t.body)===1):this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(hx(`bl`,t.body)===1):this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(e=>(e==null?void 0:e.p)||``))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles(`td`)}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles(`tr`)}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return+(this.getWrapStrategy()===3)}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||Mh[e]}))}};T(gx,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===3?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===2?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===1?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});var _x=class{constructor(e,t,n){this._config=e,this._viewModel=t,T(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++)n[r]=this.getRow(i)??{h:this._config.defaultRowHeight,hd:0},r++;return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:0,h:r.defaultRowHeight};i+=(t==null||t===1)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getRowRawVisible(e){let t=this.getRow(e);return!t||t.hd!==1}getSize(){return eu(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};let vx=1e3;function yx(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:0,rowCount:vx,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:1,rowHeader:{width:46,hidden:0},columnHeader:{height:20,hidden:0},rightToLeft:0};Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])});let n=e.freeze;return n.xSplit=n.xSplit??t.freeze.xSplit,n.ySplit=n.ySplit??t.freeze.ySplit,n.startRow=n.ySplit===0?t.freeze.startRow:n.startRow??t.freeze.startRow,n.startColumn=n.xSplit===0?t.freeze.startColumn:n.startColumn??t.freeze.startColumn,e}var bx=class extends k{constructor(e){super(),T(this,`_cellCache`,new Map),T(this,`_rowCache`,new Map),T(this,`_columnCache`,new Map),T(this,`_hasRow`,!1),T(this,`_hasColumn`,!1),T(this,`_hasAll`,!1),T(this,`_allIndex`,-1),T(this,`_mergeData`,void 0),T(this,`_rangeMap`,new vd(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===1?this._createRowCache(n,t):e===2?this._createColumnCache(n,t):e===3?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r??(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!B.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!B.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Gd.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},xx=class extends k{constructor(e){super(),this.getRawCell=e,T(this,`_cellContentInterceptor`,null),T(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,3,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,2):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,1):this.getRawCell(e,t)}getRowFiltered(e){var t;return((t=this._rowFilteredInterceptor)==null?void 0:t.getRowFiltered(e))??!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,D(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,D(()=>this._rowFilteredInterceptor=null)}};let Sx={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Cx=class{constructor(e,t,n){this.unitId=e,this._styles=n,T(this,`_sheetId`,void 0),T(this,`_snapshot`,void 0),T(this,`_cellData`,void 0),T(this,`_rowManager`,void 0),T(this,`_columnManager`,void 0),T(this,`_viewModel`,void 0),T(this,`_spanModel`,void 0),T(this,`_isRowStylePrecedeColumnStyle`,!0),T(this,`_getCellHeight`,void 0),this._snapshot=yx(t);let{columnData:r,rowData:i,cellData:a}=this._snapshot;this._sheetId=this._snapshot.id??Y(6),this._cellData=new lu(a),this._viewModel=new xx((e,t)=>this.getCellRaw(e,t)),this._rowManager=new _x(this._snapshot,this._viewModel,i),this._columnManager=new mx(this._snapshot,r),this._spanModel=new bx(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,D(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this.getRowHeight(e)}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return n??this._isRowStylePrecedeColumnStyle?ie(r,a,i,o==null?void 0:o.themeStyle,s):ie(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return r??this._isRowStylePrecedeColumnStyle?ie(i,o,a,n==null?void 0:n.themeStyle,s):ie(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=`raw`){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new lu;return af(e,n,t,r).forEach((e,t)=>{let n;if(i===`raw`)n=this.getCellRaw(e,t);else if(i===`intercepted`)n=this.getCell(e,t);else if(i===`both`){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;cx(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;af(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new gx(this,e,{getStyles:()=>this._styles}):new gx(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Sx){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Sx,...n},s,c=`document`,l=ax(t),u=o?Mh.tr:l.textRotation||Mh.tr,d=l.horizontalAlign||Mh.ht,f=l.verticalAlign||Mh.vt,p=l.wrapStrategy||Mh.tb,m=l.paddingData||nx;if(e.f&&a)s=ix(e.f.toString(),{},{verticalAlign:f}),d=Mh.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=px(u);s=this._updateConfigAndGetDocumentModel(i?B.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=ox(t);c=ux(n).fontCache;let r=wx(e);e.t===4&&a&&(r=`'${r}`),s=ix(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&sx(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new Xv(e)}getBlankCellDocumentModel(e,t,n){var r;let i=this.getComposedCellStyleByCellData(t,n,e),a=ox(i),o=this.getCellDocumentModel(e,i,{ignoreTextRotation:!0});if(o!=null)return o.documentModel??=ix(``,a),o;let s=ax(i),c=Mh.tr,l=s.horizontalAlign??Mh.ht,u=s.verticalAlign??Mh.vt,d=s.wrapStrategy??Mh.tb,f=s.paddingData??nx,p=ux(a).fontCache;return{documentModel:ix(``,a),fontString:p,textRotation:c,wrapStrategy:d,verticalAlign:u,horizontalAlign:l,paddingData:f,fill:i==null||(r=i.bg)==null?void 0:r.rgb}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function wx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===3?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===3?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Tx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;if(r==null)return``;if(e.t===3){if(typeof r==`string`)return r.toUpperCase();if(typeof r==`number`)return r?`TRUE`:`FALSE`}return typeof r==`boolean`?r?`TRUE`:`FALSE`:String(r)}function Ex(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function Dx(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Ox=class extends M{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},r){super(),this._logService=r,T(this,`type`,n.UniverType.UNIVER_SHEET),T(this,`_sheetCreated$`,new t.Subject),T(this,`sheetCreated$`,this._sheetCreated$.asObservable()),T(this,`_sheetDisposed$`,new t.Subject),T(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),T(this,`_activeSheet$`,new t.BehaviorSubject(null)),T(this,`activeSheet$`,this._activeSheet$.asObservable()),T(this,`_worksheets`,void 0),T(this,`_styles`,void 0),T(this,`_snapshot`,void 0),T(this,`_unitId`,void 0),T(this,`_count`,void 0),T(this,`_name$`,void 0),T(this,`name$`,void 0);let i=Qb();B.isEmptyObject(e)?this._snapshot=i:(this._snapshot=B.commonExtend(i,e),e.dateSystem==null?delete this._snapshot.dateSystem:e.dateSystem!==`date1900`&&e.dateSystem!==`date1904`&&(this._logService.warn(`[Workbook]`,`Unknown date system "${String(e.dateSystem)}"; falling back to Excel 1900.`),this._snapshot.dateSystem=`date1900`));let{styles:a}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=Y(6)),this._unitId=this._snapshot.id,this._styles=new $b(a),this._count=1,this._worksheets=new Map,this._name$=new t.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return B.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getDateSystem(){return this._snapshot.dateSystem===`date1904`?`date1904`:`date1900`}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Cx(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==1)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===1).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==1).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(B.isEmptyObject(n)){let e=Y();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Cx(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Ox=pa([H(1,ua)],Ox);let kx=(0,i.createIdentifier)(`univer.current`),Ax=class extends k{constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._logService=r,T(this,`_unitsByType`,new Map),T(this,`_unitCreateOptions`,new Map),T(this,`_createHandler`,void 0),T(this,`_ctorByType`,new Map),T(this,`_currentUnits`,new Map),T(this,`_currentUnits$`,new t.BehaviorSubject(this._currentUnits)),T(this,`currentUnits$`,this._currentUnits$.asObservable()),T(this,`_unitAdded$`,new t.Subject),T(this,`unitAdded$`,this._unitAdded$.asObservable()),T(this,`_unitDisposed$`,new t.Subject),T(this,`unitDisposed$`,this._unitDisposed$.asObservable()),T(this,`_focused$`,new t.BehaviorSubject(null)),T(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear(),this._unitCreateOptions.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}__getCtorByType(e){return this._ctorByType.get(e)}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,t.map)(t=>t.get(e)??null),(0,t.distinctUntilChanged)())}getCurrentUnitOfType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.get(t[1])!==t[0]&&(this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits))}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,t.filter)(t=>t.unit.type===e))}__addUnit(e,t){this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let n=e.type;this._unitsByType.has(n)||this._unitsByType.set(n,[]);let r=this._unitsByType.get(n),i=e.getUnitId();if(r.findIndex(e=>e.getUnitId()===i)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${i}.`);r.push(e),t&&this._unitCreateOptions.set(i,{...t}),this._unitAdded$.next({unit:e,options:t}),((t==null?void 0:t.makeCurrent)??!0)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,t.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getUnitCreateOptions(e){return this._unitCreateOptions.get(e)??null}getAllUnitsForType(e){return this._unitsByType.get(e)??[]}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){var t,r;this._focused$.getValue()!==e&&(this._focused$.next(e),this.focused instanceof Ox?(this._contextService.setContextValue(Bb,!0),this._contextService.setContextValue(Hb,!1),this._contextService.setContextValue(Vb,!0),this._contextService.setContextValue(Ub,!1),this._contextService.setContextValue(Wb,!1),this.setCurrentUnitForType(e)):this.focused instanceof Xv?(this._contextService.setContextValue(Bb,!0),this._contextService.setContextValue(Hb,!0),this._contextService.setContextValue(Vb,!1),this._contextService.setContextValue(Ub,!1),this._contextService.setContextValue(Wb,!1),this.setCurrentUnitForType(e)):((t=this.focused)==null?void 0:t.type)===n.UniverType.UNIVER_SLIDE?(this._contextService.setContextValue(Bb,!0),this._contextService.setContextValue(Hb,!1),this._contextService.setContextValue(Vb,!1),this._contextService.setContextValue(Ub,!0),this._contextService.setContextValue(Wb,!1),this.setCurrentUnitForType(e)):((r=this.focused)==null?void 0:r.type)===n.UniverType.UNIVER_BOARD?(this._contextService.setContextValue(Bb,!0),this._contextService.setContextValue(Hb,!1),this._contextService.setContextValue(Vb,!1),this._contextService.setContextValue(Ub,!1),this._contextService.setContextValue(Wb,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(Bb,!1),this._contextService.setContextValue(Hb,!1),this._contextService.setContextValue(Vb,!1),this._contextService.setContextValue(Ub,!1),this._contextService.setContextValue(Wb,!1)))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:n.UniverType.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),this._unitCreateOptions.delete(e),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitOfType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};Ax=pa([H(0,(0,i.Inject)(i.Injector)),H(1,sa),H(2,(0,i.Inject)(ua))],Ax);let jx=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),Mx={0:`Starting`,1:`Ready`,2:`Rendered`,3:`Steady`};var Nx=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Mx[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Px=class extends k{constructor(e){super(),this._logService=e,T(this,`_lifecycle$`,new t.BehaviorSubject(0)),T(this,`lifecycle$`,this._lifecycle$.asObservable()),T(this,`_lock`,!1),this._reportProgress(0)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,t.firstValueFrom)(this.lifecycle$.pipe((0,t.filter)(t=>t>=e),wa(t=>t===e),(0,t.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Nx(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,t.merge)(Fx(this.stage),this._lifecycle$.pipe((0,t.skip)(1))).pipe(wa(e=>e===3))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Mx[e]}".`)}};Px=pa([H(0,ua)],Px);function Fx(e){switch(e){case 0:return(0,t.of)(0);case 1:return(0,t.of)(0,1);case 2:return(0,t.of)(0,1,2);default:return(0,t.of)(0,1,2,3)}}let Ix=(0,i.createIdentifier)(`ILocalStorageService`);var Lx=class extends k{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),T(this,`_currentLocale$`,new t.BehaviorSubject(`zhCN`)),T(this,`currentLocale$`,this._currentLocale$.asObservable()),T(this,`_direction$`,new t.BehaviorSubject(`ltr`)),T(this,`direction$`,this._direction$.asObservable()),T(this,`_locales`,null),T(this,`localeChanged$`,new t.Subject),T(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}else return e}),this.disposeWithMe(D(()=>{this._locales=null,this._currentLocale$.complete(),this._direction$.complete(),this.localeChanged$.complete()}))}load(e){this._locales=ta(this._locales??{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}setDirection(e){this._direction$.next(e)}getDirection(){return this._direction$.value}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let Rx=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:0,mentions:[{objectType:0,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};Rx=pa([H(0,(0,i.Inject)(Fb))],Rx);let zx=(0,i.createIdentifier)(`univer.service.mention-io`);var Bx=class extends k{constructor(e,n,r,i){super(),this._objectTypes=i,T(this,`_rules`,new Map),T(this,`_changes`,new t.Subject),T(this,`changed$`,this._changes.asObservable()),this.disposeWithMe(e.registerPluginResource({pluginName:n,businesses:[r],toJson:e=>JSON.stringify(this.getRules(e)),parseJson:e=>{let t=JSON.parse(e);if(!Array.isArray(t)||t.some(e=>!e||typeof e.objectId!=`string`||typeof e.permissionId!=`string`||!e.permissionId||!this._objectTypes.includes(e.objectType)))throw Error(`Invalid object permission resource.`);return t},onLoad:(e,t)=>{this._rules.set(e,new Map(t.map(e=>[this._key(e.objectType,e.objectId),B.deepClone(e)]))),this._changes.next(e)},onUnLoad:e=>{this._rules.delete(e),this._changes.next(e)}})),this.disposeWithMe(()=>{this._rules.clear(),this._changes.complete()})}getRules(e){var t;return[...((t=this._rules.get(e))==null?void 0:t.values())??[]].map(e=>B.deepClone(e))}getRule(e,t,n){var r;let i=(r=this._rules.get(e))==null?void 0:r.get(this._key(t,n));return i&&B.deepClone(i)}setRule(e,t,n,r){return this.setRules(e,[{objectId:n,objectType:t,rule:r}])}setRules(e,t){if(typeof e!=`string`||!e||!Array.isArray(t)||t.length===0)return!1;let n=new Set;for(let e of t){if(!e)return!1;let{objectId:t,objectType:r,rule:i}=e,a=this._key(r,t);if(typeof t!=`string`||!t||!this._objectTypes.includes(r)||n.has(a)||i!==null&&(!i||i.objectId!==t||i.objectType!==r||typeof i.permissionId!=`string`||!i.permissionId))return!1;n.add(a)}let r=B.deepClone(t),i=this._rules.get(e)??new Map;for(let{objectId:e,objectType:t,rule:n}of r)n?i.set(this._key(t,e),n):i.delete(this._key(t,e));return this._rules.set(e,i),this._changes.next(e),!0}_key(e,t){return`${e}/${t}`}};let Vx=(0,i.createIdentifier)(`univer.undo-redo.service`);var Hx=class{dispose(){}async dispatchToHandlers(){return!1}};let Ux=`univer.command.redo`,Wx=`univer.command.undo`,Gx=new class extends Hx{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,Wx)}handler(e){let t=e.get(Vx),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(ga);return xa(n.undoMutations,r).result?(t.popUndoToRedo(),!0):!1}},Kx=new class extends Hx{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,Ux)}handler(e){let t=e.get(Vx),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(ga);return xa(n.redoMutations,r).result?(t.popRedoToUndo(),!0):!1}},qx=class extends k{constructor(e,n,r,i){super(),this._univerInstanceService=e,this._commandService=n,this._contextService=r,T(this,`undoRedoStatus$`,void 0),T(this,`_undoRedoStatus$`,new t.BehaviorSubject({undos:0,redos:0})),T(this,`_undoStacks`,new Map),T(this,`_redoStacks`,new Map),T(this,`_batchingStatus`,new Map),T(this,`_activeGroups`,new Map),T(this,`_itemGroups`,new WeakMap),T(this,`_historyLimit`,void 0),this._historyLimit=i.getConfig(`undoRedo.historyLimit`)??50,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Gx)),this.disposeWithMe(this._commandService.registerCommand(Kx)),this.disposeWithMe(D(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(D(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}getUndoRedoStatus(e){var t,n;return{undos:((t=this._undoStacks.get(e))==null?void 0:t.length)??0,redos:((n=this._redoStacks.get(e))==null?void 0:n.length)??0}}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0),i=this._historyLimit;n.length=0;let a=this._activeGroups.get(t),o=this._pitchUndoElement(t);a?o&&this._itemGroups.get(o)===a.id?a.mode===`replace`?o.redoMutations=e.redoMutations:(o.redoMutations.push(...e.redoMutations),o.undoMutations.unshift(...e.undoMutations)):(s(e),this._itemGroups.set(e,a.id)):this._batchingStatus.has(e.unitID)?this._batchingStatus.get(e.unitID)===0||!o?(s(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(o,e):s(e);function s(e){r.push(e),r.length>i&&r.splice(0,1)}this._updateStatus()}beginUndoRedoGroup(e,t,n=`replace`){if(this._activeGroups.has(e)||this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot group undo redo twice at the same time!`);let r={id:t,mode:n};return this._activeGroups.set(e,r),D(()=>{this._activeGroups.get(e)===r&&this._activeGroups.delete(e)})}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(this._itemGroups.delete(e),e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._itemGroups.delete(e),this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),this._itemGroups.delete(i),xa(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e)||this._activeGroups.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,0),D(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(Vb),n=this._contextService.getContextValue(Kb),r=this._contextService.getContextValue(Gb);if(t)if(n)e=Dp;else if(r)e=Ep;else{var i;e=((i=this._univerInstanceService.getFocusedUnit())==null?void 0:i.getUnitId())??``}else{var a;e=((a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())??``}return e}};qx=pa([H(0,kx),H(1,ga),H(2,sa),H(3,aa)],qx);let Jx=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),Yx=(0,i.createIdentifier)(`univer.permission-service`),Xx={[n.UnitObject.Document]:n.UnitObject.Document,[n.UnitObject.DocumentSection]:n.UnitObject.Document,[n.UnitObject.DocumentParagraph]:n.UnitObject.Document,[n.UnitObject.DocumentEntity]:n.UnitObject.Document,[n.UnitObject.Slide]:n.UnitObject.Slide,[n.UnitObject.SlidePage]:n.UnitObject.Slide,[n.UnitObject.SlideElement]:n.UnitObject.Slide,[n.UnitObject.SlideMaster]:n.UnitObject.Slide,[n.UnitObject.Base]:n.UnitObject.Base,[n.UnitObject.BaseTable]:n.UnitObject.Base,[n.UnitObject.BaseField]:n.UnitObject.Base,[n.UnitObject.BaseRecord]:n.UnitObject.Base,[n.UnitObject.BaseView]:n.UnitObject.Base,[n.UnitObject.BaseDashboard]:n.UnitObject.Base,[n.UnitObject.Board]:n.UnitObject.Board,[n.UnitObject.BoardElement]:n.UnitObject.Board},Zx=class extends k{constructor(e,r,i,a,o,s){super(),this._injector=e,this._permissions=r,this._logService=i,this._users=a,this._config=o,this._commands=s,T(this,`_models`,new Map),T(this,`_initialized`,new Set),T(this,`_policies`,new Map),T(this,`_generations`,new Map),T(this,`_nextGeneration`,0),T(this,`_revision`,new t.BehaviorSubject(0)),T(this,`changed$`,this._revision.asObservable()),T(this,`_unitChanges`,new t.Subject),T(this,`unitChanges$`,this._unitChanges.asObservable()),this.disposeWithMe(this._permissions.permissionPointUpdate$.subscribe(e=>{e.subType===n.UnitAction.Edit&&Xx[e.type]===e.type&&this._revision.next(this._revision.value+1)})),this.disposeWithMe(()=>{this._initialized.clear(),this._policies.clear(),this._generations.clear(),this._revision.complete(),this._unitChanges.complete()})}get _authz(){return this._injector.get(Lb)}registerRuleModel(e,t,r,i){if(this._models.has(e))throw Error(`Object permission rule model already registered.`);this._models.set(e,{model:t,mutationId:r,batchMutationId:i});let a=t.changed$.subscribe(e=>{this._generations.delete(e),this._policies.delete(e),t.getRules(e).forEach(t=>{if(!this.supports({unitId:e,objectId:t.objectId,objectType:t.objectType}))return;let r=`${t.objectType}.${n.UnitAction.Edit}_${e}_${t.objectId}`;this._permissions.getPermissionPoint(r)?this._permissions.updatePermissionPoint(r,!1):this._permissions.addPermissionPoint({id:r,type:t.objectType,subType:n.UnitAction.Edit,value:!1,status:`init`,unitId:e,objectId:t.objectId})}),this._revision.next(this._revision.value+1),this._initialized.has(e)&&this.refreshUnit(e).catch(e=>this._logService.error(e))});return this.disposeWithMe(D(()=>{a.unsubscribe(),this._models.delete(e)}))}_getRule(e){var t;return(t=this._models.get(Xx[e.objectType]))==null?void 0:t.model.getRule(e.unitId,e.objectType,e.objectId)}_getAuthzId(e){var t;return e.objectId===e.unitId?e.unitId:(t=this._getRule(e))==null?void 0:t.permissionId}initializeUnit(e){if(!this.supports(e)||this._initialized.has(e.unitId))return;this._initialized.add(e.unitId);let t=[];this._permissions.getAllPermissionPoint().forEach(n=>{n.subscribe(n=>{`unitId`in n&&n.unitId===e.unitId&&t.push(n.id)}).unsubscribe()}),t.forEach(e=>this._permissions.updatePermissionPoint(e,!1)),this.refreshUnit(e.unitId).catch(e=>{this._logService.error(e)})}supports(e){var t;return((t=this._config.getConfig(`objectPermissionTypes`))==null?void 0:t.includes(e.objectType))===!0&&this._models.has(Xx[e.objectType])}getPolicies(e){return this._policies.get(e)??[]}hasPolicy(e){var t,r;let i=this.getPolicies(e.unitId).find(t=>t.objectID===e.objectId&&t.objectType===e.objectType);return!!i&&(((t=i.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf||((r=i.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator||i.strategies.some(e=>e.role===n.UnitRole.Owner))}canView(e){var t;let r=Xx[e.objectType];return this.supports(e)&&r!==void 0&&((t=this._permissions.getPermissionPoint(`${r}.${n.UnitAction.Edit}_${e.unitId}`))==null?void 0:t.value)===!0}async canManage(e){if(!this.supports(e))return!1;let t=await this._getPolicy(e);if(!this._getRule(e)&&e.objectId!==e.unitId){let t=Xx[e.objectType];return t!==void 0&&this._allowed({...e,objectId:e.unitId,objectType:t},n.UnitAction.CreatePermissionObject)}return(e.objectId===e.unitId||!!t)&&this._canChangeRule(e,t,n.UnitAction.ManageCollaborator)}async canDelete(e){if(!this.supports(e)||e.objectId===e.unitId)return!1;let t=await this._getPolicy(e);return!!t&&this._canChangeRule(e,t,n.UnitAction.Delete)}async remove(e){var t;let n=(t=this._getRule(e))==null?void 0:t.permissionId;if(!await this.canDelete(e))throw Error(`Object permission deletion denied.`);await this._commitRule(e,null,n),await this.refreshUnit(e.unitId)}async _commitRule(e,t,n){let r=this._models.get(Xx[e.objectType]);if(!r)throw Error(`Object permission rule model is not registered.`);let i=this._getRule(e)??null;if((i==null?void 0:i.permissionId)!==n)throw Error(`Object permission binding changed during the request.`);let a={id:r.mutationId,params:{...e,rule:t}},o={id:r.mutationId,params:{...e,rule:i}};if(!await this._commands.executeCommand(a.id,a.params))throw Error(`Could not update the object permission binding.`);this._injector.get(Vx).pushUndoRedo({unitID:e.unitId,redoMutations:[a],undoMutations:[o]})}async _getPolicy(e){let t=this._getAuthzId(e);if(t)return(await this._authz.list({unitID:e.unitId,objectIDs:[t],actions:[]})).find(n=>n.unitID===e.unitId&&n.objectID===t&&n.objectType===e.objectType)}async _allowed(e,t){let n=this._getAuthzId(e);return n?(await this._authz.allowed({unitID:e.unitId,objectID:n,objectType:e.objectType,actions:[t]})).some(e=>e.action===t&&e.allowed===!0):!1}async _canChangeRule(e,t,n){var r;if(await this._allowed(e,n))return!0;let i=t==null||(r=t.creator)==null?void 0:r.userID;return!!i&&i===this._users.getCurrentUser().userID}async read(e){var t,r;let i=this._getAuthzId(e);if(!i)return{edit:`all`,collaborators:[],strategies:[]};let[a,o]=await Promise.all([this._getPolicy(e),e.objectId===e.unitId?[]:this._authz.listCollaborators({unitID:e.unitId,objectID:i})]),s=`all`;return(a==null||(t=a.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf?s=`owner`:(a==null||(r=a.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator?s=`members`:a!=null&&a.strategies.some(e=>e.action===n.UnitAction.Edit&&e.role===n.UnitRole.Owner)&&(s=`owner`),{edit:s,collaborators:o,strategies:(a==null?void 0:a.strategies)??[]}}async setPoint(e,t,r){if(!this.supports(e)){this._permissions.getPermissionPoint(t.id)||this._permissions.addPermissionPoint(t),this._permissions.updatePermissionPoint(t.id,r);return}this._assertSupported(e);let i=await this.read(e);i.strategies=i.strategies.filter(e=>e.action!==t.subType),i.strategies.push({action:t.subType,role:r?n.UnitRole.Editor:n.UnitRole.Owner}),t.subType===n.UnitAction.Edit&&(i.edit=r?`all`:`owner`),await this.save(e,i)}async save(e,t){var n;let r=(n=this._getRule(e))==null?void 0:n.permissionId,i=await this._writePolicy(e,t,r);i&&await this._commitRule(e,i,r),await this.refreshUnit(e.unitId)}async _writePolicy(e,t,r){var i,a;if(this._assertSupported(e),!await this.canManage(e))throw Error(`Object permission management denied.`);if(e.objectId===e.unitId&&t.edit===`members`)throw Error(`File membership must be managed through the sharing service.`);if(t.edit===`members`&&!t.collaborators.length)throw Error(`Select at least one collaborator.`);let o=await this._getPolicy(e),s=t.strategies.filter(e=>e.action!==n.UnitAction.Edit);s.push({action:n.UnitAction.Edit,role:t.edit===`owner`?n.UnitRole.Owner:n.UnitRole.Editor});let c=n.ObjectScope.AllCollaborator;t.edit===`members`?c=n.ObjectScope.SomeCollaborator:t.edit===`owner`&&(c=n.ObjectScope.OneSelf);let l={read:(o==null||(i=o.scope)==null?void 0:i.read)??n.ObjectScope.AllCollaborator,edit:c};if(((a=this._getRule(e))==null?void 0:a.permissionId)!==r)throw Error(`Object permission binding changed during the request.`);let u=this._getAuthzId(e);if(u)await this._authz.update({unitID:e.unitId,objectID:u,objectType:e.objectType,name:(o==null?void 0:o.name)??e.objectId,share:void 0,strategies:s,scope:l,collaborators:e.objectId===e.unitId?void 0:{collaborators:t.edit===`members`?t.collaborators:[]}});else{let r={unitID:e.unitId,name:e.objectId,strategies:s,scope:l,collaborators:t.edit===`members`?t.collaborators:[]},i={objectType:e.objectType};switch(Xx[e.objectType]){case n.UnitObject.Document:i.documentObject=r;break;case n.UnitObject.Slide:i.slideObject=r;break;case n.UnitObject.Base:i.baseObject=r;break;case n.UnitObject.Board:i.boardObject=r;break;default:throw Error(`Unsupported object permission type.`)}if(u=await this._authz.create(i),!u)throw Error(`Authz did not return a permission ID.`);return{objectId:e.objectId,objectType:e.objectType,permissionId:u}}}async saveMany(e){let t=e[0],n=t&&this._models.get(Xx[t.objectType]);if(!t||!(n!=null&&n.batchMutationId)||e.some(e=>e.unitId!==t.unitId||e.objectId===t.unitId||Xx[e.objectType]!==Xx[t.objectType]||!this.supports(e))||new Set(e.map(e=>`${e.objectType}/${e.objectId}`)).size!==e.length)throw Error(`Invalid object permission batch.`);let r={succeeded:[],failed:[]},i=[];for(let t of e){let e=this._getRule(t)??null;try{let n;if(t.policy===null){if(!await this.canDelete(t))throw Error(`Object permission deletion denied.`);n=null}else n=await this._writePolicy(t,t.policy,e==null?void 0:e.permissionId);if(n===void 0){var a;if(((a=this._getRule(t))==null?void 0:a.permissionId)!==(e==null?void 0:e.permissionId))throw Error(`Object permission binding changed during the request.`);r.succeeded.push(t.objectId)}else i.push({target:t,rule:n,previous:e})}catch(e){r.failed.push({objectId:t.objectId,error:e})}}let o=i.filter(({target:e,previous:t})=>{var n;return((n=this._getRule(e))==null?void 0:n.permissionId)===(t==null?void 0:t.permissionId)?!0:(r.failed.push({objectId:e.objectId,error:Error(`Object permission binding changed during the request.`)}),!1)});if(o.length){let e={unitId:t.unitId,rules:o.map(({target:e,rule:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))},i={unitId:t.unitId,rules:o.map(({target:e,previous:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))};try{if(!await this._commands.executeCommand(n.batchMutationId,e))throw Error(`Could not update the object permission bindings.`);this._injector.get(Vx).pushUndoRedo({unitID:t.unitId,redoMutations:[{id:n.batchMutationId,params:e}],undoMutations:[{id:n.batchMutationId,params:i}]}),r.succeeded.push(...o.map(({target:e})=>e.objectId))}catch(e){r.failed.push(...o.map(({target:t})=>({objectId:t.objectId,error:e})))}}try{await this.refreshUnit(t.unitId)}catch(e){r.refreshError=e}return r}async refreshUnit(e){if(this._disposed)return;let t=[...this._models.values()].flatMap(({model:t})=>t.getRules(e)),r=new Map(t.map(e=>[`${e.objectType}/${e.objectId}`,e])),i=new Map,a=(t,n,r,a)=>{if(!this.supports({unitId:e,objectId:r,objectType:n}))return;let o=`${n}/${t}`,s=i.get(o);i.set(o,{unitID:e,objectID:t,objectType:n,targetId:r,actions:[...new Set([...(s==null?void 0:s.actions)??[],...a])]})},o=[];t.forEach(e=>a(e.permissionId,e.objectType,e.objectId,[n.UnitAction.Edit])),this._permissions.getAllPermissionPoint().forEach(t=>{t.subscribe(t=>{if(!(`unitId`in t)||t.unitId!==e)return;let n=`objectId`in t&&typeof t.objectId==`string`?t.objectId:e,i=r.get(`${t.type}/${n}`);n===e?a(e,t.type,e,[t.subType]):i?a(i.permissionId,t.type,n,[t.subType]):this.supports({unitId:e,objectId:n,objectType:t.type})&&o.push(t.id)}).unsubscribe()}),o.forEach(e=>this._permissions.updatePermissionPoint(e,!0));let s=++this._nextGeneration;this._generations.set(e,s);let c=[...i.values()];c.length&&this._initialized.add(e);let l=[],u=[];for(let t=0;t<c.length;t+=100){let n=c.slice(t,t+100),r=await this._authz.list({unitID:e,objectIDs:n.map(e=>e.objectID),actions:[]});l.push(...r),n.forEach(e=>{let t=r.find(t=>t.objectID===e.objectID&&t.objectType===e.objectType);e.actions=[...new Set([...e.actions,...(t==null?void 0:t.strategies.map(e=>e.action))??[]])]}),u.push(...await this._authz.batchAllowed(n.map(({targetId:e,...t})=>t)))}if(this._disposed||this._generations.get(e)!==s)return;let d=new Map(u.filter(t=>t.unitID===e).map(e=>[e.objectID,e])),f=new Map(l.filter(t=>t.unitID===e).map(e=>[`${e.objectType}/${e.objectID}`,e]));c.forEach(t=>{let n=d.get(t.objectID),r=f.get(`${t.objectType}/${t.objectID}`);[...new Set([...t.actions,...(r==null?void 0:r.strategies.map(e=>e.action))??[]])].forEach(r=>{let i=`${t.objectType}.${r}_${e}${t.targetId===e?``:`_${t.targetId}`}`;this._permissions.getPermissionPoint(i)||this._permissions.addPermissionPoint({id:i,type:t.objectType,subType:r,status:`done`,value:!1,unitId:e,objectId:t.targetId}),this._permissions.updatePermissionPoint(i,(n==null?void 0:n.actions.some(e=>e.action===r&&e.allowed===!0))??!1)})}),this._policies.set(e,l.filter(t=>t.unitID===e).map(e=>{var t;return{...e,objectID:((t=i.get(`${e.objectType}/${e.objectID}`))==null?void 0:t.targetId)??e.objectID}})),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}clearUnit(e){this._initialized.delete(e),this._generations.delete(e),this._policies.delete(e),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}_assertSupported(e){if(!this.supports(e))throw Error(`Object permission management is not supported by this Authz provider.`)}};Zx=pa([H(0,(0,i.Inject)(i.Injector)),H(1,Yx),H(2,ua),H(3,(0,i.Inject)(Fb)),H(4,aa),H(5,ga)],Zx);var Qx=class extends k{constructor(...e){super(...e),T(this,`_permissionPointMap`,new Map),T(this,`_permissionPointUpdate$`,new t.Subject),T(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),T(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let n=e instanceof t.BehaviorSubject,r=n?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,n?e:new t.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=`done`,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){return(0,t.combineLatest)(e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()})).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function $x(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let eS=Symbol(`DependentOn`);var tS=class extends k{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};T(tS,`pluginName`,void 0),T(tS,`packageName`,Le),T(tS,`version`,Re),T(tS,`type`,n.UniverType.UNIVER_UNKNOWN);var nS=class{constructor(){T(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function rS(...e){return function(t){t[eS]=e}}let iS=class{constructor(e,t,r){this._injector=e,this._lifecycleService=t,this._logService=r,T(this,`_pluginRegistry`,new Map),T(this,`_pluginStore`,new nS),T(this,`_seenPlugins`,new Set),T(this,`_loadedPlugins`,new Set),T(this,`_loadedPluginTypes`,new Set([n.UniverType.UNIVER_UNKNOWN])),T(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let r={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,r),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:i}=e;this._loadedPluginTypes.has(i)&&(i===n.UniverType.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(i))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:r,packageName:i,version:a}=e;if(t===n.UniverType.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!r)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(a&&a!==tS.version&&this._logService.error(`[PluginService]`,[`Plugin version mismatch.`,` plugin: "${r||e.name}"`,` package: "${i}"`,` plugin version: "${a}"`,` core version: "${tS.version}"`,` registration will continue, but please make sure all @univerjs packages use the same version.`].join(`
25
- `)),this._seenPlugins.has(r))throw Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],r=new Set,i=e=>{let{plugin:a}=e,{pluginName:o}=a;if(this._loadedPlugins.has(o)||r.has(o))return;r.add(o),this._pluginRegistry.delete(o);let s=a[eS];s&&s.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)i(t);else if(!this._seenPlugins.has(e.pluginName)&&!r.has(e.pluginName)){if(a.type===n.UniverType.UNIVER_UNKNOWN&&e.type!==n.UniverType.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${e.pluginName}.`);a.type!==e.type&&e.type!==n.UniverType.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),i({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>i(e));let a=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(a)}_pluginsRunLifecycle(e){let n=this._lifecycleService.stage;if(Fx(n).subscribe(t=>this._runStage(e,t)),n!==3){let n=this._lifecycleService.lifecycle$.pipe((0,t.skip)(1)).subscribe(t=>{this._runStage(e,t),t===3&&n.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case 0:e.onStarting();break;case 1:e.onReady();break;case 2:e.onRendered();break;case 3:e.onSteady();break}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};iS=pa([H(0,(0,i.Inject)(i.Injector)),H(1,(0,i.Inject)(Px)),H(2,ua)],iS);let aS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_currentRegion$`,void 0),T(this,`currentRegion$`,void 0),T(this,`_hasExplicitRegion`,!1),this._currentRegion$=new t.BehaviorSubject(this._localeService.getCurrentLocale()),this.currentRegion$=this._currentRegion$.asObservable(),this.disposeWithMe(this._localeService.currentLocale$.subscribe(e=>{!this._hasExplicitRegion&&e!==this._currentRegion$.value&&this._currentRegion$.next(e)})),this.disposeWithMe(D(()=>this._currentRegion$.complete()))}setRegion(e){this._hasExplicitRegion=!0,this._currentRegion$.next(e)}getCurrentRegion(){return this._currentRegion$.value}};aS=pa([H(0,(0,i.Inject)(Lx))],aS);let oS=(0,i.createIdentifier)(`resource-loader-service`),sS=class extends k{constructor(e){super(),this._logService=e,T(this,`_resourceMap`,new Map),T(this,`_register$`,new t.Subject),T(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){let n=this.getAllResourceHooks(),r=[];for(let i=0;i<n.length;i++){let a=n[i];if(!a.businesses.includes(t))continue;let o=a.toJson(e);r.push({name:a.pluginName,data:o})}return r}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),D(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){let n=this.getAllResourceHooks();for(let i=0;i<n.length;i++){var r;let a=n[i],o=t==null||(r=t.find(e=>e.name===a.pluginName))==null?void 0:r.data;if(o)try{let t=a.parseJson(o);a.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}}}unloadResources(e,t){let n=this.getAllResourceHooks();for(let r=0;r<n.length;r++){let i=n[r];i.businesses.includes(t)&&i.onUnLoad(e)}}dispose(){this._register$.complete(),this._resourceMap.clear()}};sS=pa([H(0,ua)],sS);var cS=class extends k{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),T(this,`_darkMode$`,new t.BehaviorSubject(!1)),T(this,`darkMode$`,this._darkMode$.asObservable()),T(this,`_validColorCache`,new Map),T(this,`_currentTheme`,a.defaultTheme),T(this,`_currentTheme$`,new t.BehaviorSubject(this._currentTheme)),T(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(D(()=>{this._currentTheme=a.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in a.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in a.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return gi(this._currentTheme,e)}},lS=class{constructor(e,t=1e3){this._injector=e,T(this,`_imageCacheMap`,void 0),this._imageCacheMap=new vd(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(Xb)?this._injector.get(Xb):null,s=this._injector.has(Zb)?this._injector.get(Zb):null;if(e===`UUID`)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===`URL`)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function uS(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function dS(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}let fS=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],$=new Uint32Array(96);var pS=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=fS[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=fS.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return mS(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=[];for(;s>0;){let l=$[--s],u=$[--s],d=$[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&($[s++]=d,$[s++]=f-1,$[s++]=1-l),(l===0?n>=p:r>=m)&&($[s++]=f+1,$[s++]=u,$[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=$[--s],d=$[--s],f=$[--s];if(d-f<=o){for(let n=f;n<=d;n++)vS(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];vS(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&($[s++]=f,$[s++]=p-1,$[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&($[s++]=p+1,$[s++]=d,$[s++]=1-u)}return c}};function mS(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;hS(e,t,o,r,i,a),mS(e,t,n,r,o-1,1-a),mS(e,t,n,o+1,i,1-a)}function hS(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);hS(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(gS(e,t,r,n),t[2*i+a]>o&&gS(e,t,r,i);s<c;){for(gS(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?gS(e,t,r,c):(c++,gS(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function gS(e,t,n,r){_S(e,n,r),_S(t,2*n,2*r),_S(t,2*n+1,2*r+1)}function _S(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function vS(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var yS=class{constructor(e=!1){this._enableOneCellCache=e,T(this,`_tree`,new Map),T(this,`_oneCellCache`,new Map),T(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ad),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new pS(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ad;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function bS(e){return new Promise(t=>setTimeout(t,e))}function xS(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}function SS(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=SS(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=SS(e[i])}return t}function CS(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:SS(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=SS(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:SS(e.custom)),t}function wS(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:SS(e.p)),e.s!==void 0&&(e.s===null||typeof e.s==`string`?t.s=e.s:t.s=SS(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:SS(e.custom)),e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function TS(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=CS(r))}t[a]=s}return t}function ES(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(o.s===null||typeof o.s==`string`?s.s=o.s:s.s=SS(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:SS(o.custom)),t[a]=s}return t}function DS(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function OS(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:DS(e.mergeData),cellData:TS(e.cellData),rowData:ES(e.rowData),columnData:ES(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(e.defaultStyle===null||typeof e.defaultStyle==`string`?t.defaultStyle=e.defaultStyle:t.defaultStyle=SS(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:SS(e.custom)),t}let kS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_fontLocale`,void 0),T(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};kS=pa([H(0,(0,i.Inject)(Lx))],kS);function AS(e={}){let t={defaultBackgroundColor:`rgba(24, 119, 242, 0.08)`,defaultStripeColor:`rgba(24, 119, 242, 0.25)`,rowGaps:{1:{size:6},3:{size:10,color:`rgba(245, 158, 11, 0.14)`},6:{size:14,color:`rgba(16, 185, 129, 0.12)`,stripeColor:`rgba(5, 150, 105, 0.35)`}},colGaps:{1:{size:5},2:{size:8,stripeColor:`rgba(59, 130, 246, 0.35)`},4:{size:12,color:`rgba(244, 63, 94, 0.12)`,stripeColor:`rgba(225, 29, 72, 0.30)`}}};return{...t,...e,rowGaps:{...t.rowGaps,...e.rowGaps},colGaps:{...t.colGaps,...e.colGaps}}}let jS=class extends kS{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,T(this,`_worksheetData`,void 0),T(this,`_renderRawFormula`,!1),T(this,`_cellData`,void 0),T(this,`_imageCacheMap`,void 0),T(this,`_skipAutoHeightForMergedCells`,!0),T(this,`_rowTotalHeight`,0),T(this,`_columnTotalWidth`,0),T(this,`_rowHeaderWidth`,0),T(this,`_columnHeaderHeight`,0),T(this,`_rowHeightAccumulation`,[]),T(this,`_columnWidthAccumulation`,[]),T(this,`_marginTop`,0),T(this,`_marginLeft`,0),T(this,`_gapConfig`,{}),T(this,`_scaleX`,1),T(this,`_scaleY`,1),T(this,`_scrollX`,0),T(this,`_scrollY`,0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new lS(this._injector),this.initConfig()}initConfig(){this._skipAutoHeightForMergedCells=!(this._configService.getConfig(kp)??!1),this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig(`isRowStylePrecedeColumnStyle`)??!1)}resetCache(){}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){B.isDefine(e)&&(this._scrollX=e),B.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}get gapConfig(){return this._gapConfig}setGapConfig(e){this._gapConfig=this._fillDefaultGapThemeColors(e),this.makeDirty(!0),this._updateLayout()}_fillDefaultGapThemeColors(e){if(e.defaultBackgroundColor&&e.defaultStripeColor)return e;let{r:t,g:n,b:r}=new Ia(this._injector.get(cS).getColorFromTheme(`primary.500`)).toRgb();return{...e,defaultBackgroundColor:e.defaultBackgroundColor??`rgba(${t}, ${n}, ${r}, 0.025)`,defaultStripeColor:e.defaultStripeColor??`rgba(${t}, ${n}, ${r}, 0.08)`}}getRowGapSize(e){var t;return((t=this._gapConfig.rowGaps)==null||(t=t[e])==null?void 0:t.size)??0}getColGapSize(e){var t;return((t=this._gapConfig.colGaps)==null||(t=t[e])==null?void 0:t.size)??0}getGapSizeGetter(){if(!(!this._gapConfig.rowGaps&&!this._gapConfig.colGaps))return{row:e=>this.getRowGapSize(e),col:e=>this.getColGapSize(e)}}getRowGapAtPosition(e){let{rowGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._rowHeightAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}getColGapAtPosition(e){let{colGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._columnWidthAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){var o;let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===1)&&typeof o==`number`&&o>0?o:i,r.hd===1&&(e=0)}let s=((o=this._gapConfig.rowGaps)==null||(o=o[t])==null?void 0:o.size)??0;r+=s,r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){var o;let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===1&&(e=0)}let s=((o=this._gapConfig.colGaps)==null||(o=o[t])==null?void 0:o.size)??0;r+=s,r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=1){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!pu(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=NS(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(i===2&&n===t?a+=(l-c)/2:a+=l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!pu(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=NS(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(i===2&&n===t?a+=(c-s)/2:a+=c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===1?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===1?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new lu,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};$d(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&Gd.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=NS(e,t,r,i,void 0,this.getGapSizeGetter());return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=FS(e,t,n,this.columnHeaderHeightAndMarginTop);let a=Ma(i,e,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(i[a]-e)<Math.abs(e-(i[a-1]??0))&&(a+=1),a}getColumnIndexByOffsetX(e,t,n,r){let i=PS(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=Ma(a,i,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(a[o]-i)<Math.abs(i-(a[o-1]??0))&&(o+=1),o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=NS(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t),this.getGapSizeGetter()),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=Ma(this.columnWidthAccumulation,e),r=e-((this._columnWidthAccumulation[n-1]||0)+this.getColGapSize(n)),i=Ma(this.rowHeightAccumulation,t);return{row:i,column:n,columnOffset:r,rowOffset:t-((this._rowHeightAccumulation[i-1]||0)+this.getRowGapSize(i))}}getCellIndexAndOffsetByPosition(e,t){let{actualRow:n,actualColumn:r,startX:i,startY:a}=this.getCellWithCoordByOffset(e,t,this._scaleX,this._scaleY,{x:this._scrollX,y:this._scrollY});return{row:n,rowOffset:t-a,column:r,columnOffset:e-i}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new Xv(e)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};jS=pa([H(2,(0,i.Inject)(Lx)),H(3,sa),H(4,aa),H(5,(0,i.Inject)(i.Injector))],jS);function MS(e,t,n,r,i=0,a=0){let o=e-1,s=t-1,c=(n[o]||0)+i,l=n[e];l??=n[n.length-1];let u=(r[s]||0)+a,d=r[t];return d??=r[r.length-1],{startY:c,endY:l,startX:u,endX:d}}function NS(e,t,n,r,i,a){e=B.clamp(e,0,n.length-1),t=B.clamp(t,0,r.length-1);let{startY:o,endY:s,startX:c,endX:l}=MS(e,t,n,r,(a==null?void 0:a.row(e))??0,(a==null?void 0:a.col(t))??0);if(!i)return{startY:o,endY:s,startX:c,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:o,endY:s,startX:c,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:u,isMergedMainCell:d,startRow:f,startColumn:p,endRow:m,endColumn:h}=i,g={startRow:f,startColumn:p,endRow:m,endColumn:h,startY:o,endY:s,startX:c,endX:l},_=n.length-1,v=r.length-1;if(u&&f!==-1&&p!==-1){let e=(a==null?void 0:a.row(f))??0,t=(a==null?void 0:a.col(p))??0,i=(n[f-1]||0)+e,o=n[m]||n[_],s=(r[p-1]||0)+t,c=r[h]||r[v];g={...g,startY:i,endY:o,startX:s,endX:c}}else if(!u&&m!==-1&&h!==-1){let e=n[m]||n[_],t=r[h]||r[v];g={...g,startY:o,endY:e,startX:c,endX:t}}return{isMerged:u,isMergedMainCell:d,actualRow:e,actualColumn:t,startY:o,endY:s,startX:c,endX:l,mergeInfo:g}}function PS(e,t,n,r){let{x:i}=n;return e/t+i-r}function FS(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}let IS=[`script`,`style`,`meta`,`comment`,`link`],LS=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),RS=function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),zS=function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),BS=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),VS=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),HS=function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),US=class extends k{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=(e,t,n=[],r)=>{let i=n.find(t=>t.name===e.pluginName);if(i)try{let n=e.parseJson(i.data);e.onLoad(t,n)}catch{console.error(`Load ${r}{${t}} Resources{${e.pluginName}} Data Error.`)}},t=t=>{t.businesses.forEach(r=>{switch(r){case n.UniverType.UNRECOGNIZED:case n.UniverType.UNIVER_UNKNOWN:case n.UniverType.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_DOC).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Document`)});break;case n.UniverType.UNIVER_SLIDE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SLIDE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Slide`)});break;case n.UniverType.UNIVER_BOARD:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BOARD).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Board`)});break;case n.UniverType.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SHEET).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Workbook`)});break;case n.UniverType.UNIVER_BASE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BASE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Base`)});break}})};this._resourceManagerService.getAllResourceHooks().forEach(e=>t(e)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(e=>t(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SHEET).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_DOC).subscribe(e=>{let{unit:t}=e;jp(t.getUnitId())||this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BOARD).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BASE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_DOC)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BASE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BASE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SLIDE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BOARD).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BOARD)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=B.deepClone(t.getSnapshot());return r.resources=n,r}};US=pa([H(0,(0,i.Inject)(jb)),H(1,(0,i.Inject)(kx))],US);var WS=class extends M{constructor(...e){super(...e),T(this,`type`,void 0),T(this,`name$`,void 0)}getUnitId(){throw Error(`Method not implemented.`)}setName(e){throw Error(`Method not implemented.`)}getSnapshot(){throw Error(`Method not implemented.`)}getRev(){throw Error(`Method not implemented.`)}incrementRev(){throw Error(`Method not implemented.`)}setRev(e){throw Error(`Method not implemented.`)}},GS=class{get _univerInstanceService(){return this._injector.get(kx)}get _pluginService(){return this._injector.get(iS)}constructor(e={},t){T(this,`_startedTypes`,new Set),T(this,`_injector`,void 0),T(this,`_disposingCallbacks`,new O);let n=this._injector=KS(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,region:o,locales:s,direction:c,logLevel:l,logCommandExecution:u,undoRedoHistoryLimit:d}=e,f=this._injector.get(aa);r&&this._injector.get(cS).setTheme(r),i&&this._injector.get(cS).setDarkMode(i),s&&this._injector.get(Lx).load(s),a&&this._injector.get(Lx).setLocale(a),o&&this._injector.get(aS).setRegion(o),c&&this._injector.get(Lx).setDirection(c),l&&this._injector.get(ua).setLogLevel(l),u!==void 0&&f.setConfig(ma,u),f.setConfig(`undoRedo.historyLimit`,d??50),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(D(e));return D(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(Lx).setLocale(e)}setRegion(e){this._injector.get(aS).setRegion(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}_init(e){this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SHEET,Ox),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_DOC,Xv),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SLIDE,WS);let t=e.get(kx);t.__setCreateHandler((n,r,i,a)=>{let o=!this._startedTypes.has(n);o&&(this._pluginService.startPluginsForType(n),this._startedTypes.add(n));let s=t.__getCtorByType(n)??i;if(!s)throw Error(`[Univer]: No constructor registered for unit type ${n}.`);let c=e.createInstance(s,r);return t.__addUnit(c,a),o&&this._tryProgressToReady(),c})}_tryProgressToReady(){this._injector.get(Px).stage<1&&(this._injector.get(Px).stage=1)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function KS(e,t){let n=$x([[qb],[Lx],[aS],[cS],[Px],[iS],[Fb],[kx,{useClass:Ax}],[Yx,{useClass:Qx}],[Zx],[ua,{useClass:da,lazy:!0}],[ga,{useClass:ya}],[Vx,{useClass:qx,lazy:!0}],[aa,{useClass:oa}],[sa,{useClass:ca}],[jb,{useClass:sS,lazy:!0}],[oS,{useClass:US,lazy:!0}],[Lb,{useClass:Ib}],[zx,{useClass:Rx,lazy:!0}]],t),r=e?e.createChild(n):new i.Injector(n);return qe(r,[[Fb],[oS]]),r}x(),e.ABCToNumber=of,e.AUTO_HEIGHT_FOR_MERGED_CELLS=kp,e.AbsoluteRefType=oo,e.ActionIterator=Tv,e.AlignTypeH=mh,e.AlignTypeV=hh,e.ArrangeTypeEnum=Np,e.AsyncInterceptorManager=Kp,e.AsyncLock=Sp.default,Object.defineProperty(e,"AuthzIoLocalService",{enumerable:!0,get:function(){return Ib}}),e.AutoFillSeries=oe,e.BASE_RECORD_ID_FIELD_ID=Cf,e.BASE_RECORD_ID_FIELD_NAME=wf,e.BORDER_KEYS=wh,e.BORDER_STYLE_KEYS=Ch,e.BaseConditionalColorOperator=_f,e.BaseConditionalColorTarget=gf,e.BaseConditionalDateMode=vf,e.BaseDataModel=Mf,e.BaseFieldType=pf,e.BaseFilterConjunction=bf,e.BaseFilterOperator=yf,e.BaseHierarchyInvalidReason=Sf,e.BaseRecordLinkRole=mf,e.BaseSortDirection=xf,e.BaseViewType=hf,e.BaselineOffset=Me,e.BlockType=Hm,e.BooleanNumber=Ne,e.BorderStyleTypes=se,e.BorderType=ce,e.BuildTextUtils=Z,e.BulletAlignment=Lm,e.COLORS=Fa,e.COLOR_STYLE_KEYS=Sh,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=ma,e.CanceledError=Ye,e.CellModeEnum=uo,e.CellValueType=Pe,e.ColorKit=Ia,e.ColorType=le,e.ColumnLayoutType=oh,e.ColumnResponsiveType=sh,e.ColumnSeparatorType=Km,Object.defineProperty(e,"CommandService",{enumerable:!0,get:function(){return ya}}),e.CommandType=ha,e.CommonHideTypes=ue,e.ConfigService=oa,e.ContextService=ca,e.CopyPasteType=de,e.CustomCommandExecutionError=Je,e.CustomDecorationType=Vm,e.CustomRangeType=zm,e.DEFAULT_CELL=jh,e.DEFAULT_DOC=Kv,e.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING=Fh,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE=0,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW=12,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
26
- `,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=kh,e.DEFAULT_RANGE_ARRAY=Oh,e.DEFAULT_SELECTION=Ah,e.DEFAULT_STYLES=Mh,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=vx,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Op,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Dp,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ep,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=lo,e.DashStyleType=$m,e.DataStreamTreeNodeType=xm,e.DataStreamTreeTokenType=Sm,e.DataValidationErrorStyle=LS,e.DataValidationImeMode=RS,e.DataValidationOperator=zS,e.DataValidationRenderMode=BS,e.DataValidationStatus=VS,e.DataValidationType=HS,e.DateSystem=fe,e.DeleteDirection=pe,e.DependentOn=rS,e.DesktopLogService=da,e.DeveloperMetadataVisibility=me,e.Dimension=he,e.Direction=ge,e.Disposable=k,e.DisposableCollection=O,e.DocStyleType=Pm,e.DocumentBlockRangeType=Rm,e.DocumentBlockType=Nm,e.DocumentDataModel=Xv,e.DocumentFlavor=Um,e.DocxBreakType=Bm,e.DrawingTypeEnum=Pp,e.EDITOR_ACTIVATED=Gb,e.EXCEL_1904_OFFSET=Ys,e.EXTENSION_NAMES=Lh,e.ErrorService=qb,e.EventState=Ob,e.EventSubject=kb,e.FOCUSING_BOARD=Wb,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=Hb,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=Kb,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=`FOCUSING_SHAPE_TEXT_EDITOR`,e.FOCUSING_SHEET=Vb,e.FOCUSING_SLIDE=Ub,e.FOCUSING_UNIT=Bb,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FollowNumberWithType=Fm,e.FontItalic=Ae,e.FontStyleType=uh,e.FontWeight=je,e.GridType=Wm,e.HorizontalAlign=De,e.IAuthzIoService=Lb,e.ICommandService=ga,e.IConfigService=aa,e.IConfirmService=Rb,e.IContextService=sa,e.IImageIoService=Xb,e.ILocalStorageService=Ix,e.ILogService=ua,e.IMentionIOService=zx,e.IPermissionService=Yx,e.IResourceLoaderService=oS,e.IResourceManagerService=jb,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=Zb,e.IUndoRedoService=Vx,e.IUniverInstanceService=kx,e.ImageCacheMap=lS,e.ImageSourceType=Jb,e.ImageUploadStatusType=Yb,Object.defineProperty(e,"Inject",{enumerable:!0,get:function(){return i.Inject}}),Object.defineProperty(e,"InjectSelf",{enumerable:!0,get:function(){return i.InjectSelf}}),Object.defineProperty(e,"Injector",{enumerable:!0,get:function(){return i.Injector}}),e.InterceptorEffectEnum=Bp,e.InterceptorManager=Up,e.InterpolationPointType=ve,Object.defineProperty(e,"JSON1",{enumerable:!0,get:function(){return ig}}),e.JSONX=Vv,e.LOCALE_META=be,e.LRUHelper=yd,e.LRUMap=vd,Object.defineProperty(e,"LifecycleService",{enumerable:!0,get:function(){return Px}}),e.LifecycleStages=jx,e.LifecycleUnreachableError=Nx,e.ListGlyphType=Im,Object.defineProperty(e,"LocalUndoRedoService",{enumerable:!0,get:function(){return qx}}),e.LocaleService=Lx,e.LocaleType=ye,e.LogLevel=la,Object.defineProperty(e,"LookUp",{enumerable:!0,get:function(){return i.LookUp}}),e.MAX_COLUMN_COUNT=Sd,e.MAX_ROW_COUNT=xd,e.MODERN_DOCUMENT_DEFAULT_MARGIN=66.66666666666667,e.MODERN_DOCUMENT_WIDTH=Bh,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,"Many",{enumerable:!0,get:function(){return i.Many}}),e.MemoryCursor=cm,Object.defineProperty(e,"MentionIOLocalService",{enumerable:!0,get:function(){return Rx}}),e.MentionType=xe,e.ModernDocumentWidthMode=zh,e.NAMED_STYLE_MAP=Ph,e.NAMED_STYLE_SPACE_MAP=Ih,e.NamedStyleType=Zm,e.NilCommand=va,e.NumberUnitType=ph,e.OBJECT_PERMISSION_CONFIG_KEY=`objectPermissionTypes`,e.ObjectMatrix=lu,e.ObjectPermissionRuleModel=Bx,Object.defineProperty(e,"ObjectPermissionService",{enumerable:!0,get:function(){return Zx}}),e.ObjectRelativeFromH=dh,e.ObjectRelativeFromV=fh,Object.defineProperty(e,"Optional",{enumerable:!0,get:function(){return i.Optional}}),e.PADDING_KEYS=Eh,e.PAGE_SIZE=Rh,e.PAPER_TYPES=yh,e.PARAGRAPH_ID_PREFIX=Vh,e.PRESERVE_INSERTED_PARAGRAPH_IDS=ag,e.PRESET_LIST_TYPE=__,e.PageOrientType=_h,e.PaperType=vh,e.ParagraphElementType=Jm,e.ParagraphStyleBuilder=nb,e.ParagraphStyleValue=tb,e.PermissionService=Qx,e.PermissionStatus=Jx,e.Plugin=tS,Object.defineProperty(e,"PluginService",{enumerable:!0,get:function(){return iS}}),e.PositionedObjectLayoutType=Xm,e.PresetListType=f_,e.ProtectionType=Se,Object.defineProperty(e,"Quantity",{enumerable:!0,get:function(){return i.Quantity}}),e.QuickListType=d_,e.QuickListTypeMap=b_,e.RANGE_DIRECTION=co,e.RANGE_TYPE=ao,e.RBush=Ad,e.RCDisposable=j,e.RESTORE_INSERTED_PARAGRAPH_IDS=wg,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=yS,e.Range=gx,e.Rectangle=Gd,Object.defineProperty(e,"RediError",{enumerable:!0,get:function(){return i.RediError}}),e.RedoCommand=Kx,e.RedoCommandId=Ux,e.RefAlias=rf,Object.defineProperty(e,"RegionService",{enumerable:!0,get:function(){return aS}}),e.Registry=pm,e.RegistryAsMap=mm,e.RelativeDate=Ce,Object.defineProperty(e,"ResourceManagerService",{enumerable:!0,get:function(){return sS}}),e.RichTextBuilder=ib,e.RichTextParagraphBuilder=ab,e.RichTextRunBuilder=ob,e.RichTextValue=rb,e.RxDisposable=A,e.SECTION_ID_PREFIX=_m,e.SHEET_EDITOR_UNITS=Nh,e.STYLE_KEYS=Dh,e.SectionType=Gm,Object.defineProperty(e,"Self",{enumerable:!0,get:function(){return i.Self}}),Object.defineProperty(e,"SheetSkeleton",{enumerable:!0,get:function(){return jS}}),e.SheetTypes=we,e.SheetViewModel=xx,Object.defineProperty(e,"Skeleton",{enumerable:!0,get:function(){return kS}}),Object.defineProperty(e,"SkipSelf",{enumerable:!0,get:function(){return i.SkipSelf}}),e.SliceBodyType=X_,e.SpacingRule=Qm,e.Styles=$b,e.TEXT_DECORATION_KEYS=xh,e.TEXT_ROTATION_KEYS=Th,e.THEME_COLORS=fo,e.TRADITIONAL_DOCUMENT_DEFAULT_MARGIN=72,e.TabStopAlignment=eh,e.TabStopLeader=th,e.TableAlignmentType=rh,e.TableLayoutType=ih,e.TableRowHeightRule=ch,e.TableSizeType=nh,e.TableTextWrapType=ah,e.TestConfirmService=zb,e.TextDecoration=Ee,e.TextDecorationBuilder=eb,e.TextDirection=Te,e.TextDirectionType=qm,e.TextStyleBuilder=$y,e.TextStyleValue=Qy,e.TextX=X,e.TextXActionType=og,e.ThemeColorType=Fe,e.ThemeColors=Ie,e.ThemeService=cS,e.Tools=B,e.UndoCommand=Gx,e.UndoCommandId=Wx,e.UnitModel=M,e.Univer=GS,Object.defineProperty(e,"UniverInstanceService",{enumerable:!0,get:function(){return Ax}}),e.UniverInstanceType=n.UniverType,e.UpdateDocsAttributeType=eo,e.UserManagerService=Fb,e.VerticalAlign=Oe,e.VerticalAlignmentType=lh,Object.defineProperty(e,"WithNew",{enumerable:!0,get:function(){return i.WithNew}}),Object.defineProperty(e,"Workbook",{enumerable:!0,get:function(){return Ox}}),e.Worksheet=Cx,e.WrapStrategy=ke,e.WrapTextType=Ym,e.addLinkToDocumentModel=sx,e.afterInitApply=Oa,e.afterTime=Ea,e.allocateBaseFormulaTableName=ap,e.assertBaseTableRecordIdentity=kf,e.awaitTime=bS,e.binSearchFirstGreaterThanTarget=ja,e.binarySearchArray=Aa,e.bufferDebounceTime=Ta,e.cellToRange=Su,e.characterSpacingControlType=gh,e.checkForSubstrings=Du,e.checkIfMove=Pa,e.checkParagraphHasBullet=ed,e.checkParagraphHasIndent=td,e.checkParagraphHasIndentByStyle=nd,e.cloneBodyWithFreshParagraphIds=Uh,e.cloneCellData=CS,e.cloneCellDataMatrix=TS,e.cloneCellDataWithSpanAndDisplay=wS,e.cloneParagraphWithId=Wh,e.cloneSectionBreakWithId=ym,e.cloneValue=SS,e.cloneWorksheetData=OS,e.codeToBlob=Na,e.columnLabelToNumber=bd,e.composeBody=bv,e.composeInterceptors=Hp,e.composeStyles=ie,e.concatMatrixArray=iu,e.containsInteriorInsertionOffset=_g,e.containsStreamIndex=gg,e.convertCellToRange=uu,e.convertObservableToBehaviorSubject=Da,e.covertCellValue=Cu,e.covertCellValues=wu,e.createAsyncInterceptorKey=Wp,e.createBaseFormulaTableNameMap=ip,e.createBaseFormulaTableReferenceNormalizer=lp,e.createBaseRecordIdField=Ef,e.createDefaultBaseTableSnapshot=Af,e.createDefaultUser=Nb,e.createDocumentModelWithStyle=ix,Object.defineProperty(e,"createIdentifier",{enumerable:!0,get:function(){return i.createIdentifier}}),e.createInterceptorKey=Vp,e.createInternalEditorID=Ap,e.createParagraphId=Hh,e.createRandomId=Ed,e.createRowColIter=af,e.createSectionId=vm,e.createSheetGapTestConfig=AS,e.currencySymbols=Xl,e.customNameCharacterCheck=dS,e.dateKit=Qu,e.debounce=qi,e.dedupe=Be,e.dedupeBy=Ve,e.deepCompare=Tu,e.delayAnimationFrame=xS,e.deleteContent=id,e.excelDateSerial=lc,e.excelDateTimePartsToSerial=sc,e.excelDateTimeSerial=uc,e.excelSerialToDate=ac,e.excelSerialToDateTime=oc,e.excelSerialToDateTimeParts=rc,e.extractPureTextFromCell=wx,Object.defineProperty(e,"forwardRef",{enumerable:!0,get:function(){return i.forwardRef}}),e.fromCallback=Ca,e.fromEventSubject=Ab,e.generateIntervalsByPoints=sd,e.generateRandomId=Y,e.get=gi,e.getArrayLength=eu,e.getBaseFormulaTableName=sp,e.getBasesEmptySnapshot=jf,e.getBlockRangeInterval=ug,e.getBodySlice=uv,e.getBodySliceForSplitTextXAction=fv,e.getBodySliceForTextXAction=dv,e.getBorderStyleType=yu,e.getCellCoordByIndexSimple=MS,e.getCellValueType=no,e.getCellWithCoordByIndexCore=NS,e.getColorStyle=mu,e.getColumnGroupRangeInterval=dg,e.getCustomBlockIdsInSelections=Ny,e.getCustomBlockInterval=pg,e.getCustomBlockSlice=av,e.getCustomDecorationSlice=gv,e.getCustomRangeInterval=fg,e.getCustomRangeSlice=hv,e.getDateSystemMaxSerial=Qs,e.getDisplayValueFromCell=Tx,e.getDocsEmptySnapshot=Jh,e.getDocsUpdateBody=bu,e.getDrawingOrderIndex=Ip,e.getEmptyCell=lx,e.getExclusiveRangeInterval=cg,e.getInclusiveRangeInterval=sg,e.getIntersectRange=$d,e.getNumfmtLocaleTag=Kl,e.getNumfmtParseValueFilter=Ql,e.getOriginCellValue=Ex,e.getParagraphContentStartOffset=G_,e.getParagraphContentStartOffsets=K_,e.getParagraphFollowingBlockOffset=q_,e.getParagraphsSlice=rv,e.getPlainText=Uv,e.getReverseDirection=_e,e.getRichTextEditPath=wv,e.getSectionBreakSlice=iv,e.getSectionHeaderFooterReferenceKey=Tb,e.getSheetsEmptySnapshot=Qb,e.getSingleDataStreamChange=zy,e.getTableCellTokenInterval=hg,e.getTableRangeInterval=lg,e.getTableRowTokenInterval=mg,e.getTableSlice=ev,e.getTextRunSlice=$_,e.getTransformOffsetX=PS,e.getTransformOffsetY=FS,e.getWorksheetUID=Dx,e.groupBy=We,e.handleStyleToString=_u,e.hashAlgorithm=od,e.horizontalLineSegmentsSubtraction=$u,e.insertMatrixArray=nu,e.insertTextToContent=rd,e.intersectsOperationalIntervals=vg,e.invertColorByHSL=im,e.invertColorByMatrix=sm,Object.defineProperty(e,"isAsyncDependencyItem",{enumerable:!0,get:function(){return i.isAsyncDependencyItem}}),Object.defineProperty(e,"isAsyncHook",{enumerable:!0,get:function(){return i.isAsyncHook}}),e.isBaseRecordIdFieldName=Of,e.isBlackColor=Qa,e.isBooleanString=wp,e.isCellCoverable=pu,e.isCellV=io,Object.defineProperty(e,"isClassDependencyItem",{enumerable:!0,get:function(){return i.isClassDependencyItem}}),e.isCommentEditorID=Mp,Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i.isCtor}}),e.isDefaultFormat=Gl,Object.defineProperty(e,"isDisposable",{enumerable:!0,get:function(){return i.isDisposable}}),e.isEmptyCell=fu,Object.defineProperty(e,"isFactoryDependencyItem",{enumerable:!0,get:function(){return i.isFactoryDependencyItem}}),e.isFormulaId=gu,e.isFormulaString=hu,e.isICellData=to,e.isInternalEditorID=jp,e.isNodeEnv=ae,e.isNotNullOrUndefined=cx,e.isNullCell=ro,e.isNumeric=um,e.isPatternEqualWithoutDecimal=ql,e.isRangesEqual=ex,e.isRealNum=ad,e.isSafeNumeric=dm,e.isSafeUrl=z,e.isSameStyleTextRun=Eu,e.isTextFormat=Wl,e.isUnitRangesEqual=tx,e.isValidBaseRecordId=Df,e.isValidRange=xu,Object.defineProperty(e,"isValueDependencyItem",{enumerable:!0,get:function(){return i.isValueDependencyItem}}),e.isWhiteColor=$a,e.makeArray=Ge,e.makeCellRangeToRangeData=du,e.mapObjectMatrix=$l,e.merge=ta,e.mergeIntervals=cd,e.mergeLocales=ld,e.mergeOverrideWithDependencies=$x,e.mergeSets=gm,e.mergeWith=ea,e.mergeWorksheetSnapshotWithDefault=yx,e.migrateBaseFormulaTableNames=up,e.mixinClass=lm,e.moveMatrixArray=ou,e.moveRangeByOffset=Kd,e.nameCharacterCheck=uS,e.noop=Rp,e.normalizeBaseFormulaTableName=rp,e.normalizeBaseFormulaTableReferences=cp,e.normalizeBody=mv,e.normalizeDrawingOrderIndex=Fp,e.normalizeInsertedSectionIdsForDocument=Fg,e.normalizeTextRuns=Tg,e.normalizeUrl=R,e.numberToABC=sf,e.numberToListABC=lf,Object.defineProperty(e,"numfmt",{enumerable:!0,get:function(){return gl}}),e.regexp=Ul,e.registerDependencies=Ke,e.remove=ze,e.repeatStringNumTimes=cf,e.replaceInDocumentBody=ey,e.requestImmediateMacroTask=hm,e.resolveDocumentParagraphStyle=$v,e.resolveSectionHeaderFooterReference=Eb,e.resolveSectionHeaderFooterReferences=Db,e.resolveWithBasePath=ee,e.rotate=Ue,e.searchArray=Ma,e.searchInOrderedArray=ka,e.selectionToArray=so,e.sequence=Ze,e.sequenceAsync=Xe,e.sequenceExecute=xa,e.sequenceExecuteAsync=Sa,e.set=ra,Object.defineProperty(e,"setDependencies",{enumerable:!0,get:function(){return i.setDependencies}}),e.setWith=ia,e.shallowEqual=Lp,e.shiftExclusiveRangeOnDelete=Sg,e.shiftExclusiveRangeOnInsert=bg,e.shiftInclusiveRangeOnDelete=xg,e.shiftInclusiveRangeOnInsert=yg,e.skipParseTagNames=IS,e.sliceMatrixArray=au,e.sortRules=uf,e.sortRulesByDesc=df,e.sortRulesFactory=ff,e.spliceArray=ru,e.splitIntoGrid=Jd,e.takeAfter=wa,e.throttle=zp,e.toDisposable=D,e.touchDependencies=qe,e.updateAttributeByDelete=Ev,e.updateAttributeByInsert=Dv,e.validateDocBodyStructure=Sb,e.validateDocumentStructure=wb,e.willLoseNumericPrecision=fm});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("rxjs"),require("@univerjs/protocol"),require("rxjs/operators"),require("@wendellhu/redi"),require("@univerjs/themes")):typeof define==`function`&&define.amd?define([`exports`,`rxjs`,`@univerjs/protocol`,`rxjs/operators`,`@wendellhu/redi`,`@univerjs/themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore={},e.rxjs,e.UniverProtocol,e.rxjs.operators,e[`@wendellhu/redi`],e.UniverThemes))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t)=>{let n={};for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t||s(n,Symbol.toStringTag,{value:`Module`}),n},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:o(u(e)),m(t||!e||!e.__esModule||!d.call(e,`default`)?s(n,`default`,{value:e,enumerable:!0}):n,e));let g=typeof global<`u`?global:typeof self<`u`?self:window;function _(){let e=new Map,t=0;typeof g.requestIdleCallback!=`function`&&(g.requestIdleCallback=function(n){let r=Date.now(),i=++t,a=setTimeout(function(){e.delete(i);let t=Math.max(0,50-(Date.now()-r));n({didTimeout:t===0,timeRemaining(){return t}})},1);return e.set(i,a),i}),typeof g.cancelIdleCallback!=`function`&&(g.cancelIdleCallback=function(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))})}function v(){typeof g.queueMicrotask!=`function`&&(g.queueMicrotask=function(e){Promise.resolve().then(e).catch(e=>{setTimeout(()=>{throw e},0)})})}function y(){typeof g.Array.prototype.findLastIndex!=`function`&&(g.Array.prototype.findLastIndex=function(e,t){if(this==null)throw TypeError(`Array.prototype.findLastIndex called on null or undefined`);if(typeof e!=`function`)throw TypeError(`callback must be a function`);let n=this.length>>>0;for(let r=n-1;r>=0;r--)if(r in this&&e.call(t,this[r],r,this))return r;return-1}),typeof g.Array.prototype.findLast!=`function`&&(g.Array.prototype.findLast=function(e,t){let n=this.findLastIndex(e,t);return n===-1?void 0:this[n]})}function b(){typeof g.String.prototype.at!=`function`&&(g.String.prototype.at=function(e){if(this==null)throw TypeError(`String.prototype.at called on null or undefined`);let t=this.length;if(e<0&&(e=t+e),!(e<0||e>=t))return this.charAt(e)})}function x(){_(),v(),y(),b()}function S(e){"@babel/helpers - typeof";return S=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},S(e)}function C(e,t){if(S(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(S(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function w(e){var t=C(e,`string`);return S(t)==`symbol`?t:t+``}function T(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){return e instanceof t.Subscription||e instanceof t.Subject||e&&`closed`in e&&e.unsubscribe!==void 0}function D(e){let t=!1;return e?E(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:D(()=>{})}var O=class{constructor(){T(this,`_disposables`,new Set)}add(e){let t=D(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},k=class{constructor(){T(this,`_disposed`,!1),T(this,`_collection`,new O)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},A=class extends k{constructor(...e){super(...e),T(this,`dispose$`,new t.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},j=class extends k{constructor(e){super(),this._rootDisposable=e,T(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},M=class extends k{};let N=new Set(`ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),P=RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function ee(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:5173`)||e.startsWith(`localhost:5173`))return!0;if(P.test(e)){if(F(e))return!0;try{let t=new URL(L(e)).hostname.split(`.`).pop();if(t&&N.has(t))return!0}catch{return!1}}return!1}function F(e){return/^[a-zA-Z]+:\/\//.test(e)}function I(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function L(e){return F(e)?e:I(e)?`mailto://${e}`:`https://${e}`}function R(e){if(!e||typeof e!=`string`)return!1;try{let t=typeof window<`u`&&window.location?window.location.origin:`http://localhost`,n=new URL(e,t);return[`http:`,`https:`,`mailto:`].includes(n.protocol)}catch{return!1}}function te(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function ne(e,t){return z.getValueType(e)===z.getValueType(t)?z.isArray(e)?re(e,t):z.isObject(e)?ie(e,t):z.isDate(e)?e.getTime()===t.getTime():z.isRegExp(e)?e.toString()===t.toString():e===t:!1}function re(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!ne(r,i))return!1}return!0}function ie(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(t,r))return!1;let n=e[r],i=t[r];if(!ne(n,i))return!1}return!0}var z=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=navigator.platform===`Win32`||navigator.platform===`Windows`,n=navigator.platform===`Mac68K`||navigator.platform===`MacPPC`||navigator.platform===`Macintosh`||navigator.platform===`MacIntel`;if(n)return`Mac`;if(navigator.platform===`X11`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){if(e.indexOf(`Windows NT 5.0`)>-1||e.indexOf(`Windows 2000`)>-1)return`Windows 2000`;if(e.indexOf(`Windows NT 5.1`)>-1||e.indexOf(`Windows XP`)>-1)return`Windows XP`;if(e.indexOf(`Windows NT 5.2`)>-1||e.indexOf(`Windows 2003`)>-1)return`Windows 2003`;if(e.indexOf(`Windows NT 6.0`)>-1||e.indexOf(`Windows Vista`)>-1)return`Windows Vista`;if(e.indexOf(`Windows NT 6.1`)>-1||e.indexOf(`Windows 7`)>-1)return`Windows 7`;if(e.indexOf(`Windows NT 10`)>-1||e.indexOf(`Windows 10`)>-1)return`Windows 10`;if(e.indexOf(`Windows NT 11`)>-1||e.indexOf(`Windows 11`)>-1)return`Windows 11`}return`Unknown system`}static getBrowserType(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){RegExp(`MSIE (\\d+\\.\\d+);`).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static diffValue(e,t){return ne(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n=t,r={};for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=e.deepClone(n[t]));return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}return t}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()===``:!1:!0}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isDate(e){return this.getValueType(e)===`[object Date]`}static isRegExp(e){return this.getValueType(e)===`[object RegExp]`}static isArray(e){return this.getValueType(e)===`[object Array]`}static isString(e){return this.getValueType(e)===`[object String]`}static isNumber(e){return this.getValueType(e)===`[object Number]`}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isEmptyObject(e){for(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return ee(e)}static normalizeUrl(e){return L(e)}static topLevelDomainCombiningString(){return[...N].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function ae(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}let oe=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,se=function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),ce=function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),le=function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),ue=function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),de=function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),fe=function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),pe=function(e){return e.Date1900=`date1900`,e.Date1904=`date1904`,e}({}),me=function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),he=function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),ge=function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),_e=function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function ve(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}let ye=function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),be=function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.ZH_HK=`zhHK`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e.PT_BR=`ptBR`,e.DE_DE=`deDE`,e.IT_IT=`itIT`,e.ID_ID=`idID`,e.PL_PL=`plPL`,e.AR_SA=`arSA`,e}({}),xe={enUS:{name:`English`,tag:`en-US`,direction:`ltr`},frFR:{name:`Français`,tag:`fr-FR`,direction:`ltr`},zhCN:{name:`简体中文`,tag:`zh-CN`,direction:`ltr`},ruRU:{name:`Русский`,tag:`ru-RU`,direction:`ltr`},zhTW:{name:`繁體中文`,tag:`zh-TW`,direction:`ltr`},zhHK:{name:`繁體中文(香港)`,tag:`zh-HK`,direction:`ltr`},viVN:{name:`Tiếng Việt`,tag:`vi-VN`,direction:`ltr`},faIR:{name:`فارسی`,tag:`fa-IR`,direction:`rtl`,numberingSystem:`arabext`},jaJP:{name:`日本語`,tag:`ja-JP`,direction:`ltr`},koKR:{name:`한국어`,tag:`ko-KR`,direction:`ltr`},esES:{name:`Español`,tag:`es-ES`,direction:`ltr`},caES:{name:`Català`,tag:`ca-ES`,direction:`ltr`},skSK:{name:`Slovenčina`,tag:`sk-SK`,direction:`ltr`},ptBR:{name:`Português (Brasil)`,tag:`pt-BR`,direction:`ltr`},deDE:{name:`Deutsch`,tag:`de-DE`,direction:`ltr`},itIT:{name:`Italiano`,tag:`it-IT`,direction:`ltr`},idID:{name:`Bahasa Indonesia`,tag:`id-ID`,direction:`ltr`},plPL:{name:`Polski`,tag:`pl-PL`,direction:`ltr`},arSA:{name:`العربية`,tag:`ar-SA`,direction:`rtl`,numberingSystem:`arab`}},Se=function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Ce=function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),we=function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),Te=function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e}({}),Ee=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),De=function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e[e.SINGLE_ACCOUNTING=18]=`SINGLE_ACCOUNTING`,e[e.DOUBLE_ACCOUNTING=19]=`DOUBLE_ACCOUNTING`,e}({}),Oe=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),ke=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),Ae=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),je=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),Me=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),Ne=function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),Pe=function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),Fe=function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),Ie=function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),Le=function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({});var Re=`@univerjs/core`,ze=`1.0.0`;function Be(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}function Ve(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function He(e,t){let n=new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function Ue(e,t){for(let n=e.length-1;n>-1;n--){let r=e[n];if(t(r,n))return r}return null}function We(e,t){if(e.length===0)return e;let n=t%e.length;return e.slice(n).concat(e.slice(0,n))}function Ge(e,t){let n=new Map;return e.forEach(e=>{let r=t(e),i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(e)}),n}function Ke(e){return Array.isArray(e)?e:[e]}function qe(e,t){t.forEach(t=>e.add(t))}function Je(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}var Ye=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Xe=class extends Ye{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};async function Ze(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function Qe(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}var $e=typeof global==`object`&&global&&global.Object===Object&&global,et=typeof self==`object`&&self&&self.Object===Object&&self,tt=$e||et||Function(`return this`)(),nt=tt.Symbol,rt=Object.prototype,it=rt.hasOwnProperty,at=rt.toString,ot=nt?nt.toStringTag:void 0;function st(e){var t=it.call(e,ot),n=e[ot];try{e[ot]=void 0;var r=!0}catch{}var i=at.call(e);return r&&(t?e[ot]=n:delete e[ot]),i}var ct=Object.prototype.toString;function lt(e){return ct.call(e)}var ut=`[object Null]`,dt=`[object Undefined]`,ft=nt?nt.toStringTag:void 0;function pt(e){return e==null?e===void 0?dt:ut:ft&&ft in Object(e)?st(e):lt(e)}function mt(e){return typeof e==`object`&&!!e}var ht=`[object Symbol]`;function gt(e){return typeof e==`symbol`||mt(e)&&pt(e)==ht}function _t(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var vt=Array.isArray,yt=1/0,bt=nt?nt.prototype:void 0,xt=bt?bt.toString:void 0;function St(e){if(typeof e==`string`)return e;if(vt(e))return _t(e,St)+``;if(gt(e))return xt?xt.call(e):``;var t=e+``;return t==`0`&&1/e==-yt?`-0`:t}var Ct=/\s/;function wt(e){for(var t=e.length;t--&&Ct.test(e.charAt(t)););return t}var Tt=/^\s+/;function Et(e){return e&&e.slice(0,wt(e)+1).replace(Tt,``)}function Dt(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Ot=NaN,kt=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,jt=/^0o[0-7]+$/i,Mt=parseInt;function Nt(e){if(typeof e==`number`)return e;if(gt(e))return Ot;if(Dt(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Dt(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Et(e);var n=At.test(e);return n||jt.test(e)?Mt(e.slice(2),n?2:8):kt.test(e)?Ot:+e}function Pt(e){return e}var Ft=`[object AsyncFunction]`,It=`[object Function]`,Lt=`[object GeneratorFunction]`,Rt=`[object Proxy]`;function zt(e){if(!Dt(e))return!1;var t=pt(e);return t==It||t==Lt||t==Ft||t==Rt}var Bt=tt[`__core-js_shared__`],Vt=function(){var e=/[^.]+$/.exec(Bt&&Bt.keys&&Bt.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Ht(e){return!!Vt&&Vt in e}var Ut=Function.prototype.toString;function Wt(e){if(e!=null){try{return Ut.call(e)}catch{}try{return e+``}catch{}}return``}var Gt=/[\\^$.*+?()[\]{}|]/g,Kt=/^\[object .+?Constructor\]$/,qt=Function.prototype,Jt=Object.prototype,Yt=qt.toString,Xt=Jt.hasOwnProperty,Zt=RegExp(`^`+Yt.call(Xt).replace(Gt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Qt(e){return!Dt(e)||Ht(e)?!1:(zt(e)?Zt:Kt).test(Wt(e))}function $t(e,t){return e==null?void 0:e[t]}function en(e,t){var n=$t(e,t);return Qt(n)?n:void 0}var tn=Object.create,nn=function(){function e(){}return function(t){if(!Dt(t))return{};if(tn)return tn(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function rn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function an(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var on=800,sn=16,cn=Date.now;function ln(e){var t=0,n=0;return function(){var r=cn(),i=sn-(r-n);if(n=r,i>0){if(++t>=on)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function un(e){return function(){return e}}var dn=function(){try{var e=en(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),fn=ln(dn?function(e,t){return dn(e,`toString`,{configurable:!0,enumerable:!1,value:un(t),writable:!0})}:Pt),pn=9007199254740991,mn=/^(?:0|[1-9]\d*)$/;function hn(e,t){var n=typeof e;return t??=pn,!!t&&(n==`number`||n!=`symbol`&&mn.test(e))&&e>-1&&e%1==0&&e<t}function gn(e,t,n){t==`__proto__`&&dn?dn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function _n(e,t){return e===t||e!==e&&t!==t}var vn=Object.prototype.hasOwnProperty;function yn(e,t,n){var r=e[t];(!(vn.call(e,t)&&_n(r,n))||n===void 0&&!(t in e))&&gn(e,t,n)}function bn(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?gn(n,s,c):yn(n,s,c)}return n}var xn=Math.max;function Sn(e,t,n){return t=xn(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=xn(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),rn(e,this,s)}}function Cn(e,t){return fn(Sn(e,t,Pt),e+``)}var wn=9007199254740991;function Tn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=wn}function En(e){return e!=null&&Tn(e.length)&&!zt(e)}function Dn(e,t,n){if(!Dt(n))return!1;var r=typeof t;return(r==`number`?En(n)&&hn(t,n.length):r==`string`&&t in n)?_n(n[t],e):!1}function On(e){return Cn(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Dn(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var kn=Object.prototype;function An(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||kn)}function jn(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Mn=`[object Arguments]`;function Nn(e){return mt(e)&&pt(e)==Mn}var Pn=Object.prototype,Fn=Pn.hasOwnProperty,In=Pn.propertyIsEnumerable,Ln=Nn(function(){return arguments}())?Nn:function(e){return mt(e)&&Fn.call(e,`callee`)&&!In.call(e,`callee`)};function Rn(){return!1}var zn=typeof e==`object`&&e&&!e.nodeType&&e,Bn=zn&&typeof module==`object`&&module&&!module.nodeType&&module,Vn=Bn&&Bn.exports===zn?tt.Buffer:void 0,Hn=(Vn?Vn.isBuffer:void 0)||Rn,Un=`[object Arguments]`,Wn=`[object Array]`,Gn=`[object Boolean]`,Kn=`[object Date]`,qn=`[object Error]`,Jn=`[object Function]`,Yn=`[object Map]`,Xn=`[object Number]`,Zn=`[object Object]`,Qn=`[object RegExp]`,$n=`[object Set]`,er=`[object String]`,tr=`[object WeakMap]`,nr=`[object ArrayBuffer]`,rr=`[object DataView]`,ir=`[object Float32Array]`,ar=`[object Float64Array]`,or=`[object Int8Array]`,sr=`[object Int16Array]`,cr=`[object Int32Array]`,lr=`[object Uint8Array]`,ur=`[object Uint8ClampedArray]`,dr=`[object Uint16Array]`,fr=`[object Uint32Array]`,B={};B[ir]=B[ar]=B[or]=B[sr]=B[cr]=B[lr]=B[ur]=B[dr]=B[fr]=!0,B[Un]=B[Wn]=B[nr]=B[Gn]=B[rr]=B[Kn]=B[qn]=B[Jn]=B[Yn]=B[Xn]=B[Zn]=B[Qn]=B[$n]=B[er]=B[tr]=!1;function pr(e){return mt(e)&&Tn(e.length)&&!!B[pt(e)]}function mr(e){return function(t){return e(t)}}var hr=typeof e==`object`&&e&&!e.nodeType&&e,gr=hr&&typeof module==`object`&&module&&!module.nodeType&&module,_r=gr&&gr.exports===hr&&$e.process,vr=function(){try{return gr&&gr.require&&gr.require(`util`).types||_r&&_r.binding&&_r.binding(`util`)}catch{}}(),yr=vr&&vr.isTypedArray,br=yr?mr(yr):pr,xr=Object.prototype.hasOwnProperty;function Sr(e,t){var n=vt(e),r=!n&&Ln(e),i=!n&&!r&&Hn(e),a=!n&&!r&&!i&&br(e),o=n||r||i||a,s=o?jn(e.length,String):[],c=s.length;for(var l in e)(t||xr.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||hn(l,c)))&&s.push(l);return s}function Cr(e,t){return function(n){return e(t(n))}}function wr(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Tr=Object.prototype.hasOwnProperty;function Er(e){if(!Dt(e))return wr(e);var t=An(e),n=[];for(var r in e)(r!=`constructor`||!t&&Tr.call(e,r))&&n.push(r);return n}function Dr(e){return En(e)?Sr(e,!0):Er(e)}var Or=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kr=/^\w*$/;function Ar(e,t){if(vt(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||gt(e)?!0:kr.test(e)||!Or.test(e)||t!=null&&e in Object(t)}var jr=en(Object,`create`);function Mr(){this.__data__=jr?jr(null):{},this.size=0}function Nr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Pr=`__lodash_hash_undefined__`,Fr=Object.prototype.hasOwnProperty;function Ir(e){var t=this.__data__;if(jr){var n=t[e];return n===Pr?void 0:n}return Fr.call(t,e)?t[e]:void 0}var Lr=Object.prototype.hasOwnProperty;function Rr(e){var t=this.__data__;return jr?t[e]!==void 0:Lr.call(t,e)}var zr=`__lodash_hash_undefined__`;function Br(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=jr&&t===void 0?zr:t,this}function Vr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Vr.prototype.clear=Mr,Vr.prototype.delete=Nr,Vr.prototype.get=Ir,Vr.prototype.has=Rr,Vr.prototype.set=Br;function Hr(){this.__data__=[],this.size=0}function Ur(e,t){for(var n=e.length;n--;)if(_n(e[n][0],t))return n;return-1}var Wr=Array.prototype.splice;function Gr(e){var t=this.__data__,n=Ur(t,e);return n<0?!1:(n==t.length-1?t.pop():Wr.call(t,n,1),--this.size,!0)}function Kr(e){var t=this.__data__,n=Ur(t,e);return n<0?void 0:t[n][1]}function qr(e){return Ur(this.__data__,e)>-1}function Jr(e,t){var n=this.__data__,r=Ur(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Yr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Yr.prototype.clear=Hr,Yr.prototype.delete=Gr,Yr.prototype.get=Kr,Yr.prototype.has=qr,Yr.prototype.set=Jr;var Xr=en(tt,`Map`);function Zr(){this.size=0,this.__data__={hash:new Vr,map:new(Xr||Yr),string:new Vr}}function Qr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function $r(e,t){var n=e.__data__;return Qr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function ei(e){var t=$r(this,e).delete(e);return this.size-=+!!t,t}function ti(e){return $r(this,e).get(e)}function ni(e){return $r(this,e).has(e)}function ri(e,t){var n=$r(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ii(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ii.prototype.clear=Zr,ii.prototype.delete=ei,ii.prototype.get=ti,ii.prototype.has=ni,ii.prototype.set=ri;var ai=`Expected a function`;function oi(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ai);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(oi.Cache||ii),n}oi.Cache=ii;var si=500;function ci(e){var t=oi(e,function(e){return n.size===si&&n.clear(),e}),n=t.cache;return t}var li=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ui=/\\(\\)?/g,di=ci(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(li,function(e,n,r,i){t.push(r?i.replace(ui,`$1`):n||e)}),t});function fi(e){return e==null?``:St(e)}function pi(e,t){return vt(e)?e:Ar(e,t)?[e]:di(fi(e))}var mi=1/0;function hi(e){if(typeof e==`string`||gt(e))return e;var t=e+``;return t==`0`&&1/e==-mi?`-0`:t}function gi(e,t){t=pi(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[hi(t[n++])];return n&&n==r?e:void 0}function _i(e,t,n){var r=e==null?void 0:gi(e,t);return r===void 0?n:r}var vi=Cr(Object.getPrototypeOf,Object),yi=`[object Object]`,bi=Function.prototype,xi=Object.prototype,Si=bi.toString,Ci=xi.hasOwnProperty,wi=Si.call(Object);function Ti(e){if(!mt(e)||pt(e)!=yi)return!1;var t=vi(e);if(t===null)return!0;var n=Ci.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Si.call(n)==wi}function Ei(){this.__data__=new Yr,this.size=0}function Di(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Oi(e){return this.__data__.get(e)}function ki(e){return this.__data__.has(e)}var Ai=200;function ji(e,t){var n=this.__data__;if(n instanceof Yr){var r=n.__data__;if(!Xr||r.length<Ai-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ii(r)}return n.set(e,t),this.size=n.size,this}function Mi(e){var t=this.__data__=new Yr(e);this.size=t.size}Mi.prototype.clear=Ei,Mi.prototype.delete=Di,Mi.prototype.get=Oi,Mi.prototype.has=ki,Mi.prototype.set=ji;var Ni=typeof e==`object`&&e&&!e.nodeType&&e,Pi=Ni&&typeof module==`object`&&module&&!module.nodeType&&module,Fi=Pi&&Pi.exports===Ni?tt.Buffer:void 0,Ii=Fi?Fi.allocUnsafe:void 0;function Li(e,t){if(t)return e.slice();var n=e.length,r=Ii?Ii(n):new e.constructor(n);return e.copy(r),r}var Ri=tt.Uint8Array;function zi(e){var t=new e.constructor(e.byteLength);return new Ri(t).set(new Ri(e)),t}function Bi(e,t){var n=t?zi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Vi(e){return typeof e.constructor==`function`&&!An(e)?nn(vi(e)):{}}function Hi(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Ui=Hi(),Wi=function(){return tt.Date.now()},Gi=`Expected a function`,Ki=Math.max,qi=Math.min;function Ji(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Gi);t=Nt(t)||0,Dt(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Ki(Nt(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?qi(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Wi();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Wi())}function x(){var e=Wi(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Yi(e,t,n){(n!==void 0&&!_n(e[t],n)||n===void 0&&!(t in e))&&gn(e,t,n)}function Xi(e){return mt(e)&&En(e)}function Zi(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}function Qi(e){return bn(e,Dr(e))}function $i(e,t,n,r,i,a,o){var s=Zi(e,n),c=Zi(t,n),l=o.get(c);if(l){Yi(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=vt(c),p=!f&&Hn(c),m=!f&&!p&&br(c);u=c,f||p||m?vt(s)?u=s:Xi(s)?u=an(s):p?(d=!1,u=Li(c,!0)):m?(d=!1,u=Bi(c,!0)):u=[]:Ti(c)||Ln(c)?(u=s,Ln(s)?u=Qi(s):(!Dt(s)||zt(s))&&(u=Vi(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Yi(e,n,u)}function ea(e,t,n,r,i){e!==t&&Ui(t,function(a,o){if(i||=new Mi,Dt(a))$i(e,t,o,n,ea,r,i);else{var s=r?r(Zi(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Yi(e,o,s)}},Dr)}var ta=On(function(e,t,n,r){ea(e,t,n,r)}),na=On(function(e,t,n){ea(e,t,n)});function ra(e,t,n,r){if(!Dt(e))return e;t=pi(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=hi(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=Dt(u)?u:hn(t[i+1])?[]:{})}yn(s,c,l),s=s[c]}return e}function ia(e,t,n){return e==null?e:ra(e,t,n)}function aa(e,t,n,r){return r=typeof r==`function`?r:void 0,e==null?e:ra(e,t,n,r)}let oa=(0,i.createIdentifier)(`univer.config-service`);var sa=class{constructor(){T(this,`_configChanged$`,new t.Subject),T(this,`configChanged$`,this._configChanged$.asObservable()),T(this,`_config`,new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){let{merge:r=!1}=n||{},i=this._config.get(e)??{};i=r?na(i,t):t,this._config.set(e,i),this._configChanged$.next({[e]:i})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new t.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,e)&&n.next(this._config.get(e));let r=this.configChanged$.pipe((0,t.filter)(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(t=>n.next(t[e]));return()=>r.unsubscribe()})}};let ca=(0,i.createIdentifier)(`univer.context-service`);var la=class extends k{constructor(...e){super(...e),T(this,`_contextChanged$`,new t.Subject),T(this,`contextChanged$`,this._contextChanged$.asObservable()),T(this,`_contextMap`,new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){return this._contextMap.get(e)??!1}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new t.Observable(n=>{let r=this._contextChanged$.pipe((0,t.filter)(t=>t[e]!==void 0)).subscribe(t=>n.next(t[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}};let ua=function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({}),da=(0,i.createIdentifier)(`univer.log`);var fa=class extends k{constructor(...e){super(...e),T(this,`_logLevel`,3),T(this,`_deduction`,new Set)}dispose(){super.dispose(),this._logLevel=3,this._deduction.clear()}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}deprecate(...e){this._logLevel>=2&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=pa(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function pa(...e){return e.map(e=>JSON.stringify(e)).join(``)}function V(e,t){return function(n,r){t(n,r,e)}}function ma(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let ha=`command.logExecution`,ga=function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({}),_a=(0,i.createIdentifier)(`univer.core.command-service`);var va=class{constructor(){T(this,`_commands`,new Map),T(this,`_commandTypes`,new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),D(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};let ya={id:`nil`,type:0,handler:()=>!0},ba=class extends k{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,T(this,`_commandRegistry`,void 0),T(this,`_beforeCommandExecutionListeners`,[]),T(this,`_commandExecutedListeners`,[]),T(this,`_collabMutationListeners`,[]),T(this,`_multiCommandDisposables`,new Map),T(this,`_commandExecutingLevel`,0),T(this,`_commandExecutionStack`,[]),this._commandRegistry=new va,this.registerCommand(ya)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}_warnCommandSkippedAfterDisposed(e){this._logService.warn(`[CommandService]`,`command "${e}" skipped because CommandService is disposed.`)}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),D(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),D(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),D(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=await this._execute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}syncExecuteCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=this._syncExecute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),D(()=>Be(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(t){let e=t[0];if(!(e instanceof xa))throw TypeError(`Command has registered as a single command.`);n=e}else{n=new xa(e.id);let t=new O;t.add(this._commandRegistry.registerCommand(n)),t.add(D(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}let r=n.registerImplementation(e);return D(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}_attachMutationTrigger(e,t){if(e.type!==2||!t)return;let n=Ue(this._commandExecutionStack,e=>e.type===0);if(n){this._setMutationTrigger(t,n.id);return}if(`trigger`in t&&t.trigger!==void 0)return;let r=Ue(this._commandExecutionStack,e=>e.type===1);r&&this._setMutationTrigger(t,r.id)}_setMutationTrigger(e,t){Object.assign(e,{trigger:t})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};ba=ma([V(0,(0,i.Inject)(i.Injector)),V(1,da),V(2,oa)],ba);var xa=class{constructor(e){this.id=e,T(this,`name`,void 0),T(this,`multi`,!0),T(this,`type`,0),T(this,`priority`,0),T(this,`_implementations`,[]),T(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(da),r=e.get(ca),a=e.get(i.Injector);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),D(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function Sa(e,t,n){return Qe(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function Ca(e,t,n){return Ze(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function wa(e){return new t.Observable(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function Ta(e){return function(n){return n.pipe((0,t.takeWhile)(t=>!e(t),!0))}}function Ea(e=0){return n=>{let r=[];return n.pipe((0,t.tap)(e=>r.push(e)),(0,t.debounceTime)(e),(0,t.map)(()=>r),(0,t.tap)(()=>r=[]))}}function Da(e){let n=new t.ReplaySubject(1);return setTimeout(()=>n.next(),e),n.pipe((0,t.take)(1))}function Oa(e,n){let r=new t.BehaviorSubject(n),i=e.subscribe(r),a=r.complete.bind(r);return r.complete=()=>{i.unsubscribe(),a()},r}let ka=e=>new Promise(n=>{(0,t.merge)(wa(e.onCommandExecuted.bind(e)).pipe((0,r.filter)(([e])=>e.type===2)),(0,t.timer)(300)).pipe((0,r.debounceTime)(16),(0,r.first)()).subscribe(()=>{n()})});function Aa(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function ja(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function Ma(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function Na(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?Aa(e,t):Ma(e,t),n){let t=e[r];return e.indexOf(t)}return r}function Pa(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}function Fa(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}let Ia={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchealmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],darkyellow:[139,128,0],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midbightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]};var La=class e{static mix(t,n,r){r=Math.min(1,Math.max(0,r));let i=new e(t).toRgb(),a=new e(n).toRgb(),o=i.a??1,s=a.a??1,c={r:(a.r-i.r)*r+i.r,g:(a.g-i.g)*r+i.g,b:(a.b-i.b)*r+i.b,a:(s-o)*r+o};return new e(c)}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(T(this,`_color`,void 0),T(this,`_rgbColor`,void 0),T(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=Ba(t);if(n==null){this._setNullColor();return}this._color=n;let r=Ga(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[Ra(Math.round(t).toString(16)),Ra(Math.round(n).toString(16)),Ra(Math.round(r).toString(16)),Ra(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Xa(this.toRgb())}toHsl(){return Ya(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=za(e),t=za(t),n=za(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){return this._color.a??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}}};let Ra=e=>e.length===1?`0${e}`:e,za=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),Ba=e=>{if(Qa(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(Ia[t]){let e=Ia[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(t.startsWith(`#`))return Va(t);if(t.startsWith(`rgb`))return Ha(t);if(t.startsWith(`hsl`))return Ua(t);if(t.startsWith(`hsv`))return Wa(t)},Va=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Ha=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ua=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Wa=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ga=e=>{let t=Ba(e);if(t!=null)return`r`in t?t:`l`in t?qa(t):Ja(t)},Ka=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),qa=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=Ka(s,e,t+1/3),a=Ka(s,e,t),o=Ka(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},Ja=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Ya=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Xa=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Za=e=>e==null,Qa=e=>!Za(e)&&typeof e==`object`;function $a(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function eo(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}let to=function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({}),no=function(e){return e[e.VISIBLE=0]=`VISIBLE`,e[e.HIDDEN=1]=`HIDDEN`,e[e.VERY_HIDDEN=2]=`VERY_HIDDEN`,e}({}),ro=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.SHARED=1]=`SHARED`,e[e.ARRAY=2]=`ARRAY`,e[e.DATA_TABLE=3]=`DATA_TABLE`,e}({});function io(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.ft!==void 0||e.fd!==void 0||e.si!==void 0||e.custom!==void 0)}function ao(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return 1;if(typeof e.v==`number`)return 2;if(typeof e.v==`boolean`)return 3}function oo(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null)}function so(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let co=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),lo=function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function uo(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let fo=function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),po=function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({}),mo=function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({}),ho={Office:{4:`#4472C4`,5:`#ED7D31`,6:`#A5A5A5`,7:`#70AD47`,8:`#5B9BD5`,9:`#70AD47`,0:`#000000`,2:`#44546A`,1:`#FFFFFF`,3:`#E7E6E6`,10:`#0563C1`,11:`#954F72`}},go=`general`,_o=`hash`,vo=`zero`,yo=`qmark`,bo=`slash`,xo=`group`,So=`scale`,Co=`comma`,wo=`break`,To=`text`,Eo=`plus`,Do=`minus`,Oo=`point`,ko=`space`,Ao=`percent`,jo=`digit`,Mo=`calendar`,No=`error`,Po=`datetime`,Fo=`duration`,Io=`condition`,Lo=`dbnum`,Ro=`natnum`,zo=`locale`,Bo=`color`,Vo=`modifier`,Ho=`ampm`,Uo=`escaped`,Wo=`string`,Go=`skip`,Ko=`fill`,qo=`paren`,Jo=`char`,Yo=`#000000.#FFFFFF.#FF0000.#00FF00.#0000FF.#FFFF00.#FF00FF.#00FFFF.#800000.#008000.#000080.#808000.#800080.#008080.#C0C0C0.#808080.#9999FF.#993366.#FFFFCC.#CCFFFF.#660066.#FF8080.#0066CC.#CCCCFF.#000080.#FF00FF.#FFFF00.#00FFFF.#800080.#800000.#008080.#0000FF.#00CCFF.#CCFFFF.#CCFFCC.#FFFF99.#99CCFF.#FF99CC.#CC99FF.#FFCC99.#3366FF.#33CCCC.#99CC00.#FFCC00.#FF9900.#FF6600.#666699.#969696.#003366.#339966.#003300.#333300.#993300.#993366.#333399.#333333`.split(`.`),Xo=`¤.$.£.¥.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿`.split(`.`),Zo=RegExp(`[${Xo.join(``)}]`);function Qo(e){if(!Number.isFinite(e))throw RangeError(`decimalFromNumber requires a finite number`);let t=e<0||Object.is(e,-0);if(e===0)return{negative:t,digits:`0`,exponent:0};let[n,r]=Math.abs(e).toExponential(14).split(`e`);return{negative:t,digits:n.replace(`.`,``).replace(/0+$/,``)||`0`,exponent:Number(r)}}function $o(e,t){return{...e,exponent:e.digits===`0`?0:e.exponent+Math.trunc(t)}}function es(e){let t=[...e];for(let e=t.length-1;e>=0;e--){if(t[e]!==`9`)return t[e]=String(Number(t[e])+1),t.join(``);t[e]=`0`}return`1${t.join(``)}`}function ts(e,t=0){let n=Math.trunc(t),r=e.exponent+1+n,i;if(r<0?i=`0`:r===0?i=e.digits[0]>=`5`?`1`:`0`:(i=e.digits.slice(0,r).padEnd(r,`0`)||`0`,r<e.digits.length&&e.digits[r]>=`5`&&(i=es(i))),/^0+$/.test(i))return{negative:e.negative,integer:`0`,fraction:``,zero:!0};if(n<=0)return{negative:e.negative,integer:i+`0`.repeat(-n),fraction:``,zero:!1};let a=i.padStart(n+1,`0`);return{negative:e.negative,integer:a.slice(0,-n),fraction:a.slice(-n).replace(/0+$/,``),zero:!1}}function ns(e){let t=Number(e.fraction?`${e.integer}.${e.fraction}`:e.integer);return e.negative&&!e.zero?-t:t}function rs(e){return`${e.negative&&!e.zero?`-`:``}${e.integer}${e.fraction?`.${e.fraction}`:``}`}function is(e,t,n,r){if(e.digits===`0`)return{exponent:0,rounded:ts(e,r)};let i=t>1?Math.floor(e.exponent/t)*t:e.exponent;n||i++;let a=ts($o(e,-i),r);return t===1&&a.integer.length>1&&(i++,a=ts($o(e,-i),r)),{exponent:i,rounded:a}}let as=Object.freeze({1078:`af`,1052:`sq`,1118:`am`,5121:`ar_DZ`,15361:`ar_BH`,3073:`ar_EG`,2049:`ar_IQ`,11265:`ar_JO`,13313:`ar_KW`,12289:`ar_LB`,4097:`ar_LY`,6145:`ar_MA`,8193:`ar_OM`,16385:`ar_QA`,1025:`ar_SA`,10241:`ar_SY`,7169:`ar_TN`,14337:`ar_AE`,9217:`ar_YE`,1067:`hy`,1101:`as`,2092:`az_AZ`,1068:`az_AZ`,1069:`eu`,1059:`be`,2117:`bn`,1093:`bn_IN`,5146:`bs`,1026:`bg`,1109:`my`,1027:`ca`,2052:`zh_CN`,3076:`zh_HK`,5124:`zh_MO`,4100:`zh_SG`,1028:`zh_TW`,1050:`hr`,1029:`cs`,1030:`da`,1125:`dv`,2067:`nl_BE`,1043:`nl_NL`,1126:`bin`,3081:`en_AU`,10249:`en_BZ`,4105:`en_CA`,9225:`en_CB`,2057:`en_GB`,16393:`en_IN`,6153:`en_IE`,8201:`en_JM`,5129:`en_NZ`,13321:`en_PH`,7177:`en_ZA`,11273:`en_TT`,1033:`en_US`,12297:`en_ZW`,1061:`et`,1071:`mk`,1080:`fo`,1065:`fa`,1124:`fil`,1035:`fi`,2060:`fr_BE`,11276:`fr_CM`,3084:`fr_CA`,9228:`fr_CG`,12300:`fr_CI`,1036:`fr_FR`,5132:`fr_LU`,13324:`fr_ML`,6156:`fr_MC`,14348:`fr_MA`,10252:`fr_SN`,4108:`fr_CH`,7180:`fr`,1122:`fy_NL`,2108:`gd_IE`,1084:`gd`,1110:`gl`,1079:`ka`,3079:`de_AT`,1031:`de_DE`,5127:`de_LI`,4103:`de_LU`,2055:`de_CH`,1032:`el`,1140:`gn`,1095:`gu`,1279:`en`,1037:`he`,1081:`hi`,1038:`hu`,1039:`is`,1136:`ig_NG`,1057:`id`,1040:`it_IT`,2064:`it_CH`,1041:`ja`,1099:`kn`,1120:`ks`,1087:`kk`,1107:`km`,1111:`kok`,1042:`ko`,1088:`ky`,1108:`lo`,1142:`la`,1062:`lv`,1063:`lt`,2110:`ms_BN`,1086:`ms_MY`,1100:`ml`,1082:`mt`,1112:`mni`,1153:`mi`,1102:`mr`,1104:`mn`,2128:`mn`,1121:`ne`,1044:`no_NO`,2068:`no_NO`,1096:`or`,1045:`pl`,1046:`pt_BR`,2070:`pt_PT`,1094:`pa`,1047:`rm`,2072:`ro_MO`,1048:`ro_RO`,1049:`ru`,2073:`ru_MO`,1083:`se`,1103:`sa`,3098:`sr_SP`,2074:`sr_SP`,1072:`st`,1074:`tn`,1113:`sd`,1115:`si`,1051:`sk`,1060:`sl`,1143:`so`,1070:`sb`,11274:`es_AR`,16394:`es_BO`,13322:`es_CL`,9226:`es_CO`,5130:`es_CR`,7178:`es_DO`,12298:`es_EC`,17418:`es_SV`,4106:`es_GT`,18442:`es_HN`,2058:`es_MX`,19466:`es_NI`,6154:`es_PA`,15370:`es_PY`,10250:`es_PE`,20490:`es_PR`,1034:`es_ES`,14346:`es_UY`,8202:`es_VE`,1089:`sw`,2077:`sv_FI`,1053:`sv_SE`,1114:`syc`,1064:`tg`,1097:`ta`,1092:`tt`,1098:`te`,1054:`th`,1105:`bo`,1073:`ts`,1055:`tr`,1090:`tk`,1058:`uk`,1056:`ur`,2115:`uz_UZ`,1091:`uz_UZ`,1075:`ve`,1066:`vi`,1106:`cy`,1076:`xh`,1085:`yi`,1077:`zu`}),os=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,ss={},H=(e,t=``)=>e.replace(/~/g,t).split(`;`),U=(e,t=0,n=0)=>(e.mmm||=t<1?e.mmmm.concat():e.mmmm.map(e=>{let n=e.slice(0,t%10);return n+(t<10||e===n?``:`.`)}),e.ddd||=n<1?e.dddd.concat():e.dddd.map(e=>{let t=e.slice(0,n%10);return t+(n<10||e===t?``:`.`)}),!e.mmm6&&e.mmmm6&&(e.mmm6=e.mmmm6),e),cs={group:`\xA0`,decimal:`.`,positive:`+`,negative:`-`,percent:`%`,exponent:`E`,nan:`NaN`,infinity:`∞`,ampm:H(`AM;PM`),mmmm6:H(`Muharram;Safar;Rabiʻ I;Rabiʻ II;Jumada I;Jumada II;Rajab;Shaʻban;Ramadan;Shawwal;Dhuʻl-Qiʻdah;Dhuʻl-Hijjah`),mmm6:H(`Muh.;Saf.;Rab. I;Rab. II;Jum. I;Jum. II;Raj.;Sha.;Ram.;Shaw.;Dhuʻl-Q.;Dhuʻl-H.`),mmmm:H(`January;February;March;April;May;June;July;August;September;October;November;December`),mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec`),dddd:H(`Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday`),ddd:H(`Sun;Mon;Tue;Wed;Thu;Fri;Sat`),bool:H(`TRUE;FALSE`),preferMDY:!1};function ls(e){let t=os.exec(e);if(!t)throw SyntaxError(`Malformed locale: ${e}`);return{lang:t[1]+(t[2]?`_${t[2]}`:``),language:t[1],territory:t[2]||``}}function us(e){if(typeof e==`number`)return as[e&65535]||null;let t=Number.parseInt(e,16);return Number.isFinite(t)&&as[t&65535]?as[t&65535]||null:os.test(e)?e:null}function ds(e){let t=us(e),n=null;if(t){let e=ls(t);n=ss[e.lang]||ss[e.language]||null}return n}function fs(e){return Object.assign({},cs,e)}function W(e,t){let n=typeof t==`object`?t:ls(t);return ss[n.lang]=fs(e),n.language!==n.lang&&!ss[n.language]&&(ss[n.language]=fs(e)),ss[n.lang]}let ps=fs({group:`,`,preferMDY:!0});ps.isDefault=!0,W({group:`,`,ampm:H(`上午;下午`),mmmm:H(`一月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)},`zh_CN`);let ms={group:`,`,ampm:H(`上午;下午`),mmmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)};W({...ms,nan:`非數值`,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_TW`),W({...ms,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_HK`),W({...ms,ampm:H(`午前;午後`),dddd:H(`日~;月~;火~;水~;木~;金~;土~`,`曜日`),ddd:H(`日;月;火;水;木;金;土`)},`ja`),W({group:`,`,ampm:H(`오전;오후`),mmmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),mmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),dddd:H(`일요일;월요일;화요일;수요일;목요일;금요일;토요일`),ddd:H(`일;월;화;수;목;금;토`)},`ko`),W({group:`,`,ampm:H(`ก่อนเที่ยง;หลังเที่ยง`),mmmm:H(`มกร~;กุมภาพันธ์;มีน~;เมษายน;พฤษภ~;มิถุนายน;กรกฎ~;สิงห~;กันยายน;ตุล~;พฤศจิกายน;ธันว~`,`าคม`),mmm:H(`ม.ค.;ก.พ.;มี.ค.;เม.ย.;พ.ค.;มิ.ย.;ก.ค.;ส.ค.;ก.ย.;ต.ค.;พ.ย.;ธ.ค.`),dddd:H(`วันอาทิตย์;วันจันทร์;วันอังคาร;วันพุธ;วันพฤหัสบดี;วันศุกร์;วันเสาร์`),ddd:H(`อา.;จ.;อ.;พ.;พฤ.;ศ.;ส.`)},`th`),W(U({decimal:`,`,ampm:H(`dop.;odp.`),mmmm:H(`ledna;února;března;dubna;května;června;července;srpna;září;října;listopadu;prosince`),mmm:H(`I;II;III;IV;V;VI;VII;VIII;IX;X;XI;XII`),dddd:H(`neděle;pondělí;úterý;středa;čtvrtek;pátek;sobota`),bool:H(`PRAVDA;NEPRAVDA`)},-1,2),`cs`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marts;april;maj;juni;juli;august;september;oktober;november;december`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SAND;FALSK`)},13,13),`da`),W(U({group:`.`,decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januari;februari;maart;april;mei;juni;juli;augustus;september;oktober;november;december`),mmm:H(`jan.;feb.;mrt.;apr.;mei;jun.;jul.;aug.;sep.;okt.;nov.;dec.`),dddd:H(`zondag;maandag;dinsdag;woensdag;donderdag;vrijdag;zaterdag`),bool:H(`WAAR;ONWAAR`)},-1,2),`nl`),W({group:`,`,preferMDY:!0},`en`),W({group:`,`,preferMDY:!0},`en_US`),W({group:`,`},`en_AU`),W({group:`,`},`en_CA`),W({group:`,`},`en_GB`),W({group:`,`,mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sept;Oct;Nov;Dec`)},`en_IE`),W(U({decimal:`,`,nan:`epäluku`,ampm:H(`ap.;ip.`),mmmm:H(`tammi~;helmi~;maalis~;huhti~;touko~;kesä~;heinä~;elo~;syys~;loka~;marras~;joulu~`,`kuuta`),mmm:H(`tammik.;helmik.;maalisk.;huhtik.;toukok.;kesäk.;heinäk.;elok.;syysk.;lokak.;marrask.;jouluk.`),dddd:H(`sunnun~;maanan~;tiis~;keskiviikkona;tors~;perjan~;lauan~`,`taina`),bool:H(`TOSI;EPÄTOSI`)},-1,2),`fi`);let hs=U({group:` `,decimal:`,`,mmmm:H(`janvier;février;mars;avril;mai;juin;juillet;août;septembre;octobre;novembre;décembre`),mmm:H(`janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.`),dddd:H(`~manche;lun~;mar~;mercre~;jeu~;vendre~;same~`,`di`),bool:H(`VRAI;FAUX`)},-1,13);W({...hs},`fr`),W({...hs,mmm:H(`janv.;févr.;mars;avr.;mai;juin;juill.;août;sept.;oct.;nov.;déc.`)},`fr_CA`),W({group:`'`,decimal:`.`,...hs},`fr_CH`);let gs=U({mmmm:H(`Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember`),mmm:H(`Jan.;Feb.;März;Apr.;Mai;Juni;Juli;Aug.;Sept.;Okt.;Nov.;Dez.`),dddd:H(`Sonn~;Mon~;Diens~;Mittwoch;Donners~;Frei~;Sams~`,`tag`),bool:H(`WAHR;FALSCH`)},-1,12);W({group:`.`,decimal:`,`,...gs},`de`),W({group:`'`,decimal:`.`,...gs},`de_CH`),W(U({group:`.`,decimal:`,`,ampm:H(`π.μ.;μ.μ.`),mmmm:H(`Ιανουαρ~;Φεβρουαρ~;Μαρτ~;Απριλ~;Μαΐου;Ιουν~;Ιουλ~;Αυγούστου;Σεπτεμβρ~;Οκτωβρ~;Νοεμβρ~;Δεκεμβρ~`,`ίου`),mmm:H(`Ιαν;Φεβ;Μαρ;Απρ;Μαΐ;Ιουν;Ιουλ;Αυγ;Σεπ;Οκτ;Νοε;Δεκ`),dddd:H(`Κυριακή;Δευτέρα;Τρίτη;Τετάρτη;Πέμπτη;Παρασκευή;Σάββατο`)},-1,3),`el`),W({decimal:`,`,ampm:H(`de.;du.`),mmmm:H(`január;február;március;április;május;június;július;augusztus;szeptember;október;november;december`),mmm:H(`jan.;febr.;márc.;ápr.;máj.;jún.;júl.;aug.;szept.;okt.;nov.;dec.`),dddd:H(`vasárnap;hétfő;kedd;szerda;csütörtök;péntek;szombat`),ddd:H(`V;H;K;Sze;Cs;P;Szo`),bool:H(`IGAZ;HAMIS`)},`hu`),W(U({group:`.`,decimal:`,`,ampm:H(`f.h.;e.h.`),mmmm:H(`janúar;febrúar;mars;apríl;maí;júní;júlí;ágúst;september;október;nóvember;desember`),dddd:H(`sunnu~;mánu~;þriðju~;miðviku~;fimmtu~;föstu~;laugar~`,`dagur`)},13,13),`is`),W(U({group:`.`,decimal:`,`,mmmm:H(`Januari;Februari;Maret;April;Mei;Juni;Juli;Agustus;September;Oktober;November;Desember`),dddd:H(`Minggu;Senin;Selasa;Rabu;Kamis;Jumat;Sabtu`)},3,3),`id`);let _s=U({mmmm:H(`gennaio;febbraio;marzo;aprile;maggio;giugno;luglio;agosto;settembre;ottobre;novembre;dicembre`),dddd:H(`domenica;lunedì;martedì;mercoledì;giovedì;venerdì;sabato`),bool:H(`VERO;FALSO`)},3,3);W({group:`.`,decimal:`,`,..._s},`it`),W({group:`'`,decimal:`.`,..._s},`it_CH`);let vs={decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januar;februar;mars;april;mai;juni;juli;august;september;oktober;november;desember`),mmm:H(`jan.;feb.;mar.;apr.;mai;jun.;jul.;aug.;sep.;okt.;nov.;des.`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SANN;USANN`)};W(U({...vs},-1,13),`nb`),W(U({...vs},-1,13),`no`),W(U({decimal:`,`,mmmm:H(`stycznia;lutego;marca;kwietnia;maja;czerwca;lipca;sierpnia;września;października;listopada;grudnia`),dddd:H(`niedziela;poniedziałek;wtorek;środa;czwartek;piątek;sobota`),ddd:H(`niedz.;pon.;wt.;śr.;czw.;pt.;sob.`),bool:H(`PRAWDA;FAŁSZ`)},3,-1),`pl`);let ys={group:`.`,decimal:`,`,mmmm:H(`janeiro;fevereiro;março;abril;maio;junho;julho;agosto;setembro;outubro;novembro;dezembro`),dddd:H(`domingo;segunda-feira;terça-feira;quarta-feira;quinta-feira;sexta-feira;sábado`),bool:H(`VERDADEIRO;FALSO`)};W(U(ys,13,13),`pt`),W(U(ys,13,13),`pt_BR`),W({decimal:`,`,nan:`не\xA0число`,mmmm:H(`января;февраля;марта;апреля;мая;июня;июля;августа;сентября;октября;ноября;декабря`),mmm:H(`янв.;февр.;мар.;апр.;мая;июн.;июл.;авг.;сент.;окт.;нояб.;дек.`),dddd:H(`воскресенье;понедельник;вторник;среда;четверг;пятница;суббота`),ddd:H(`вс;пн;вт;ср;чт;пт;сб`),mmmm6:H(`рамадан;шавваль;зуль-каада;зуль-хиджжа;мухаррам;раби-уль-авваль;раби-уль-ахир;джумад-уль-авваль;джумад-уль-ахир;раджаб;шаабан;рамадан`),mmm6:H(`рам.;шав.;зуль-к.;зуль-х.;мух.;раб. I;раб. II;джум. I;джум. II;радж.;шааб.;рам.`),bool:H(`ИСТИНА;ЛОЖЬ`)},`ru`),W(U({decimal:`,`,mmmm:H(`januára;februára;marca;apríla;mája;júna;júla;augusta;septembra;októbra;novembra;decembra`),dddd:H(`nedeľa;pondelok;utorok;streda;štvrtok;piatok;sobota`)},3,2),`sk`);let bs={group:`.`,decimal:`,`,ampm:H(`a.\xA0m.;p.\xA0m.`),mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;septiem~;octu~;noviem~;diciem~`,`bre`),mmm:H(`ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic`),dddd:H(`domingo;lunes;martes;miércoles;jueves;viernes;sábado`),ddd:H(`dom;lun;mar;mié;jue;vie;sáb`),bool:H(`VERDADERO;FALSO`)},xs=H(`ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic`),Ss=H(`ene.;feb.;mar.;abr.;may.;jun.;jul.;ago.;sept.;oct.;nov.;dic.`);W({...bs},`es`),W({...bs},`es_AR`),W({...bs},`es_BO`),W({...bs},`es_CL`),W({...bs},`es_CO`),W({...bs},`es_EC`),W({...bs,mmm:xs,ampm:H(`a.m.;p.m.`)},`es_MX`),W({...bs,mmm:Ss},`es_PY`),W({...bs,mmm:Ss},`es_UY`),W({...bs,mmm:Ss,mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;setiembre;octubre;noviembre;diciembre`)},`es_VE`),W({decimal:`,`,ampm:H(`fm;em`),mmmm:H(`januari;februari;mars;april;maj;juni;juli;augusti;september;oktober;november;december`),mmm:H(`jan.;feb.;mars;apr.;maj;juni;juli;aug.;sep.;okt.;nov.;dec.`),dddd:H(`sön~;mån~;tis~;ons~;tors~;fre~;lör~`,`dag`),ddd:H(`sön;mån;tis;ons;tors;fre;lör`)},`sv`),W(U({group:`.`,decimal:`,`,ampm:H(`ÖÖ;ÖS`),mmmm:H(`Ocak;Şubat;Mart;Nisan;Mayıs;Haziran;Temmuz;Ağustos;Eylül;Ekim;Kasım;Aralık`),mmm:H(`Oca;Şub;Mar;Nis;May;Haz;Tem;Ağu;Eyl;Eki;Kas;Ara`),dddd:H(`Pazar;Pazartesi;Salı;Çarşamba;Perşembe;Cuma;Cumartesi`),ddd:H(`Paz;Pzt;Sal;Çar;Per;Cum;Cmt`),bool:H(`DOĞRU;YANLIŞ`)},3,-1),`tr`),W({group:`,`,ampm:H(`yb;yh`),mmmm:H(`Ionawr;Chwefror;Mawrth;Ebrill;Mai;Mehefin;Gorffennaf;Awst;Medi;Hydref;Tachwedd;Rhagfyr`),mmm:H(`Ion;Chwef;Maw;Ebr;Mai;Meh;Gorff;Awst;Medi;Hyd;Tach;Rhag`),dddd:H(`Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn`),ddd:H(`Sul;Llun;Maw;Mer;Iau;Gwen;Sad`)},`cy`),W({group:`.`,decimal:`,`,mmmm:H(`yanvar;fevral;mart;aprel;may;iyun;iyul;avqust;sentyabr;oktyabr;noyabr;dekabr`),mmm:H(`yan;fev;mar;apr;may;iyn;iyl;avq;sen;okt;noy;dek`),dddd:H(`bazar;bazar ertəsi;çərşənbə axşamı;çərşənbə;cümə axşamı;cümə;şənbə`),ddd:H(`B.;B.e.;Ç.a.;Ç.;C.a.;C.;Ş.`)},`az`),W(U({decimal:`,`,mmmm:H(`студзеня;лютага;сакавіка;красавіка;мая;чэрвеня;ліпеня;жніўня;верасня;кастрычніка;лістапада;снежня`),dddd:H(`нядзеля;панядзелак;аўторак;серада;чацвер;пятніца;субота`),ddd:H(`нд;пн;аў;ср;чц;пт;сб`)},3,-1),`be`),W({decimal:`,`,ampm:H(`пр.об.;сл.об.`),mmmm:H(`януари;февруари;март;април;май;юни;юли;август;септември;октомври;ноември;декември`),mmm:H(`яну;фев;март;апр;май;юни;юли;авг;сеп;окт;ное;дек`),dddd:H(`неделя;понеделник;вторник;сряда;четвъртък;петък;събота`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),bool:H(`ИСТИНА;ЛОЖЬ`)},`bg`),W({group:`.`,decimal:`,`,mmmm:H(`de gener;de febrer;de març;d’abril;de maig;de juny;de juliol;d’agost;de setembre;d’octubre;de novembre;de desembre`),mmm:H(`de gen.;de febr.;de març;d’abr.;de maig;de juny;de jul.;d’ag.;de set.;d’oct.;de nov.;de des.`),dddd:H(`diumenge;dilluns;dimarts;dimecres;dijous;divendres;dissabte`),ddd:H(`dg.;dl.;dt.;dc.;dj.;dv.;ds.`),ampm:H(`a.\xA0m.;p.\xA0m.`)},`ca`),W(U({group:`,`,decimal:`.`,mmmm:H(`Enero;Pebrero;Marso;Abril;Mayo;Hunyo;Hulyo;Agosto;Setyembre;Oktubre;Nobyembre;Disyembre`),dddd:H(`Linggo;Lunes;Martes;Miyerkules;Huwebes;Biyernes;Sabado`)},3,3),`fil`),W({group:`,`,decimal:`.`,mmmm:H(`જાન્યુઆરી;ફેબ્રુઆરી;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટેમ્બર;ઑક્ટોબર;નવેમ્બર;ડિસેમ્બર`),mmm:H(`જાન્યુ;ફેબ્રુ;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટે;ઑક્ટો;નવે;ડિસે`),dddd:H(`રવિ~;સોમ~;મંગળ~;બુધ~;ગુરુ~;શુક્ર~;શનિ~`,`વાર`),ddd:H(`રવિ;સોમ;મંગળ;બુધ;ગુરુ;શુક્ર;શનિ`)},`gu`),W({group:`,`,decimal:`.`,ampm:H(`לפנה״צ;אחה״צ`),dddd:H(`~ראשון;~שני;~שלישי;~רביעי;~חמישי;~שישי;~שבת`,`יום `),ddd:H(`~א׳;~ב׳;~ג׳;~ד׳;~ה׳;~ו׳;שבת`,`יום `),mmmm:H(`ינואר;פברואר;מרץ;אפריל;מאי;יוני;יולי;אוגוסט;ספטמבר;אוקטובר;נובמבר;דצמבר`),mmm:H(`ינו׳;פבר׳;מרץ;אפר׳;מאי;יוני;יולי;אוג׳;ספט׳;אוק׳;נוב׳;דצמ׳`),mmmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע אל־אוול;רביע א־ת׳אני;ג׳ומאדא אל־אולא;ג׳ומאדא א־ת׳אניה;רג׳ב;שעבאן;רמדאן`),mmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע א׳;רביע ב׳;ג׳ומאדא א׳;ג׳ומאדא ב׳;רג׳ב;שעבאן;רמדאן`)},`he`),W(U({group:`.`,decimal:`,`,mmmm:H(`siječnja;veljače;ožujka;travnja;svibnja;lipnja;srpnja;kolovoza;rujna;listopada;studenoga;prosinca`),mmm:H(`sij;velj;ožu;tra;svi;lip;srp;kol;ruj;lis;stu;pro`),dddd:H(`nedjelja;ponedjeljak;utorak;srijeda;četvrtak;petak;subota`)},-1,3),`hr`),W({decimal:`,`,mmmm:H(`հունվարի;փետրվարի;մարտի;ապրիլի;մայիսի;հունիսի;հուլիսի;օգոստոսի;սեպտեմբերի;հոկտեմբերի;նոյեմբերի;դեկտեմբերի`),mmm:H(`հնվ;փտվ;մրտ;ապր;մյս;հնս;հլս;օգս;սեպ;հոկ;նոյ;դեկ`),dddd:H(`կիրակի;երկուշաբթի;երեքշաբթի;չորեքշաբթի;հինգշաբթի;ուրբաթ;շաբաթ`),ddd:H(`կիր;երկ;երք;չրք;հնգ;ուր;շբթ`)},`hy`),W(U({decimal:`,`,mmmm:H(`იანვარი;თებერვალი;მარტი;აპრილი;მაისი;ივნისი;ივლისი;აგვისტო;სექტემბერი;ოქტომბერი;ნოემბერი;დეკემბერი`),dddd:H(`კვირა;ორშაბათი;სამშაბათი;ოთხშაბათი;ხუთშაბათი;პარასკევი;შაბათი`)},3,3),`ka`),W(U({decimal:`,`,mmmm:H(`қаңтар;ақпан;наурыз;сәуір;мамыр;маусым;шілде;тамыз;қыркүйек;қазан;қараша;желтоқсан`),dddd:H(`жексенбі;дүйсенбі;сейсенбі;сәрсенбі;бейсенбі;жұма;сенбі`),ddd:H(`жс;дс;сс;ср;бс;жм;сб`)},13,-1),`kk`),W({group:`,`,mmmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿಲ್;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂಬರ್;ಅಕ್ಟೋಬರ್;ನವೆಂಬರ್;ಡಿಸೆಂಬರ್`),mmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿ;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂ;ಅಕ್ಟೋ;ನವೆಂ;ಡಿಸೆಂ`),dddd:H(`ಭಾನು~;ಸೋಮ~;ಮಂಗಳ~;ಬುಧ~;ಗುರು~;ಶುಕ್ರ~;ಶನಿ~`,`ವಾರ`),ddd:H(`ಭಾನು;ಸೋಮ;ಮಂಗಳ;ಬುಧ;ಗುರು;ಶುಕ್ರ;ಶನಿ`),ampm:H(`ಪೂರ್ವಾಹ್ನ;ಅಪರಾಹ್ನ`)},`kn`),W({decimal:`,`,mmmm:H(`sausio;vasario;kovo;balandžio;gegužės;birželio;liepos;rugpjūčio;rugsėjo;spalio;lapkričio;gruodžio`),mmm:H(`saus.;vas.;kov.;bal.;geg.;birž.;liep.;rugp.;rugs.;spal.;lapkr.;gruod.`),dddd:H(`sekmadienis;pirmadienis;antradienis;trečiadienis;ketvirtadienis;penktadienis;šeštadienis`),ddd:H(`sk;pr;an;tr;kt;pn;št`),ampm:H(`priešpiet;popiet`)},`lt`),W({decimal:`,`,mmmm:H(`janvāris;februāris;marts;aprīlis;maijs;jūnijs;jūlijs;augusts;septembris;oktobris;novembris;decembris`),mmm:H(`janv.;febr.;marts;apr.;maijs;jūn.;jūl.;aug.;sept.;okt.;nov.;dec.`),dddd:H(`svētdiena;pirmdiena;otrdiena;trešdiena;ceturtdiena;piektdiena;sestdiena`),ddd:H(`svētd.;pirmd.;otrd.;trešd.;ceturtd.;piektd.;sestd.`),ampm:H(`priekšpusdienā;pēcpusdienā`)},`lv`),W({group:`,`,decimal:`.`,mmmm:H(`ജനുവരി;ഫെബ്രുവരി;മാർച്ച്;ഏപ്രിൽ;മേയ്;ജൂൺ;ജൂലൈ;ഓഗസ്റ്റ്;സെപ്റ്റംബർ;ഒക്‌ടോബർ;നവംബർ;ഡിസംബർ`),mmm:H(`ജനു;ഫെബ്രു;മാർ;ഏപ്രി;മേയ്;ജൂൺ;ജൂലൈ;ഓഗ;സെപ്റ്റം;ഒക്ടോ;നവം;ഡിസം`),dddd:H(`ഞായറാഴ്‌ച;തിങ്കളാഴ്‌ച;ചൊവ്വാഴ്ച;ബുധനാഴ്‌ച;വ്യാഴാഴ്‌ച;വെള്ളിയാഴ്‌ച;ശനിയാഴ്‌ച`),ddd:H(`ഞായർ;തിങ്കൾ;ചൊവ്വ;ബുധൻ;വ്യാഴം;വെള്ളി;ശനി`)},`ml`),W({group:`,`,decimal:`.`,mmmm:H(`нэгдүгээ~;хоёрдугаа~;гуравдугаа~;дөрөвдүгээ~;тавдугаа~;зургаадугаа~;долоодугаа~;наймдугаа~;есдүгээ~;аравдугаа~;арван нэгдүгээ~;арван хоёрдугаа~`,`р сар`),mmm:H(`1~;2~;3~;4~;5~;6~;7~;8~;9~;10~;11~;12~`,`-р сар`),dddd:H(`ням;даваа;мягмар;лхагва;пүрэв;баасан;бямба`),ddd:H(`Ня;Да;Мя;Лх;Пү;Ба;Бя`),ampm:H(`ү.ө.;ү.х.`)},`mn`),W({group:`,`,decimal:`.`,mmmm:H(`जानेवारी;फेब्रुवारी;मार्च;एप्रिल;मे;जून;जुलै;ऑगस्ट;सप्टेंबर;ऑक्टोबर;नोव्हेंबर;डिसेंबर`),mmm:H(`जाने;फेब्रु;मार्च;एप्रि;मे;जून;जुलै;ऑग;सप्टें;ऑक्टो;नोव्हें;डिसें`),dddd:H(`रविवार;सोमवार;मंगळवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगळ;बुध;गुरु;शुक्र;शनि`)},`mr`),W(U({group:`,`,decimal:`.`,mmmm:H(`ဇန်နဝါရီ;ဖေဖော်ဝါရီ;မတ်;ဧပြီ;မေ;ဇွန်;ဇူလိုင်;ဩဂုတ်;စက်တင်ဘာ;အောက်တိုဘာ;နိုဝင်ဘာ;ဒီဇင်ဘာ`),mmm:H(`ဇန်;ဖေ;မတ်;ဧ;မေ;ဇွန်;ဇူ;ဩ;စက်;အောက်;နို;ဒီ`),dddd:H(`တနင်္ဂနွေ;တနင်္လာ;အင်္ဂါ;ဗုဒ္ဓဟူး;ကြာသပတေး;သောကြာ;စနေ`),ampm:H(`နံနက်;ညနေ`)},-1,0),`my`),W({group:`,`,decimal:`.`,mmmm:H(`ਜਨਵਰੀ;ਫ਼ਰਵਰੀ;ਮਾਰਚ;ਅਪ੍ਰੈਲ;ਮਈ;ਜੂਨ;ਜੁਲਾਈ;ਅਗਸਤ;ਸਤੰਬਰ;ਅਕਤੂਬਰ;ਨਵੰਬਰ;ਦਸੰਬਰ`),mmm:H(`ਜਨ;ਫ਼ਰ;ਮਾਰਚ;ਅਪ੍ਰੈ;ਮਈ;ਜੂਨ;ਜੁਲਾ;ਅਗ;ਸਤੰ;ਅਕਤੂ;ਨਵੰ;ਦਸੰ`),dddd:H(`ਐਤਵਾਰ;ਸੋਮਵਾਰ;ਮੰਗਲਵਾਰ;ਬੁੱਧਵਾਰ;ਵੀਰਵਾਰ;ਸ਼ੁੱਕਰਵਾਰ;ਸ਼ਨਿੱਚਰਵਾਰ`),ddd:H(`ਐਤ;ਸੋਮ;ਮੰਗਲ;ਬੁੱਧ;ਵੀਰ;ਸ਼ੁੱਕਰ;ਸ਼ਨਿੱਚਰ`),ampm:H(`ਪੂ.ਦੁ.;ਬਾ.ਦੁ.`)},`pa`),W({group:`.`,decimal:`,`,mmmm:H(`ianuarie;februarie;martie;aprilie;mai;iunie;iulie;august;septem~;octom~;noiem~;decem~`,`brie`),mmm:H(`ian.;feb.;mar.;apr.;mai;iun.;iul.;aug.;sept.;oct.;nov.;dec.`),dddd:H(`duminică;luni;marți;miercuri;joi;vineri;sâmbătă`),ddd:H(`dum.;lun.;mar.;mie.;joi;vin.;sâm.`),ampm:H(`a.m.;p.m.`)},`ro`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marec;april;maj;junij;julij;avgust;september;oktober;november;december`),mmm:H(`jan.;feb.;mar.;apr.;maj;jun.;jul.;avg.;sep.;okt.;nov.;dec.`),dddd:H(`nedelja;ponedeljek;torek;sreda;četrtek;petek;sobota`),ampm:H(`dop.;pop.`)},-1,13),`sl`),W(U({group:`.`,decimal:`,`,mmmm:H(`јануар;фебруар;март;април;мај;јун;јул;август;септембар;октобар;новембар;децембар`),dddd:H(`недеља;понедељак;уторак;среда;четвртак;петак;субота`)},3,3),`sr`),W({group:`,`,decimal:`.`,mmmm:H(`ஜனவரி;பிப்ரவரி;மார்ச்;ஏப்ரல்;மே;ஜூன்;ஜூலை;ஆகஸ்ட்;செப்டம்பர்;அக்டோபர்;நவம்பர்;டிசம்பர்`),mmm:H(`ஜன.;பிப்.;மார்.;ஏப்.;மே;ஜூன்;ஜூலை;ஆக.;செப்.;அக்.;நவ.;டிச.`),dddd:H(`ஞாயிறு;திங்கள்;செவ்வாய்;புதன்;வியாழன்;வெள்ளி;சனி`),ddd:H(`ஞாயி.;திங்.;செவ்.;புத.;வியா.;வெள்.;சனி`)},`ta`),W({group:`,`,decimal:`.`,mmmm:H(`జనవరి;ఫిబ్రవరి;మార్చి;ఏప్రిల్;మే;జూన్;జులై;ఆగస్టు;సెప్టెంబర్;అక్టోబర్;నవంబర్;డిసెంబర్`),mmm:H(`జన;ఫిబ్ర;మార్చి;ఏప్రి;మే;జూన్;జులై;ఆగ;సెప్టెం;అక్టో;నవం;డిసెం`),dddd:H(`ఆదివారం;సోమవారం;మంగళవారం;బుధవారం;గురువారం;శుక్రవారం;శనివారం`),ddd:H(`ఆది;సోమ;మంగళ;బుధ;గురు;శుక్ర;శని`)},`te`),W({decimal:`,`,mmmm:H(`січня;лютого;березня;квітня;травня;червня;липня;серпня;вересня;жовтня;листопада;грудня`),mmm:H(`січ.;лют.;бер.;квіт.;трав.;черв.;лип.;серп.;вер.;жовт.;лист.;груд.`),dddd:H(`неділю;понеділок;вівторок;середу;четвер;пʼятницю;суботу`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),ampm:H(`дп;пп`)},`uk`),W({group:`.`,decimal:`,`,mmmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`tháng `),mmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`thg `),dddd:H(`Chủ Nhật;Thứ Hai;Thứ Ba;Thứ Tư;Thứ Năm;Thứ Sáu;Thứ Bảy`),ddd:H(`CN;Th 2;Th 3;Th 4;Th 5;Th 6;Th 7`),ampm:H(`SA;CH`)},`vi`),W(U({group:`٬`,decimal:`٫`,ampm:H(`ص;م`),mmmm:H(`يناير;فبراير;مارس;أبريل;مايو;يونيو;يوليو;أغسطس;سبتمبر;أكتوبر;نوفمبر;ديسمبر`),dddd:H(`الأحد;الاثنين;الثلاثاء;الأربعاء;الخميس;الجمعة;السبت`),mmmm6:H(`رمضان;شوال;ذو القعدة;ذو الحجة;محرم;ربيع الأول;ربيع الآخرة;جمادى الأولى;جمادى الآخرة;رجب;شعبان;رمضان`)},0,0),`ar`),W({group:`,`,decimal:`.`,mmmm:H(`জানুয়ারী;ফেব্রুয়ারী;মার্চ;এপ্রিল;মে;জুন;জুলাই;আগস্ট;সেপ্টেম্বর;অক্টোবর;নভেম্বর;ডিসেম্বর`),mmm:H(`জানু;ফেব;মার্চ;এপ্রি;মে;জুন;জুল;আগ;সেপ্টেঃ;অক্টোঃ;নভেঃ;ডিসেঃ`),dddd:H(`রবিবার;সোমবার;মঙ্গলবার;বুধবার;বৃহস্পতিবার;শুক্রবার;শনিবার`),ddd:H(`রবি;সোম;মঙ্গল;বুধ;বৃহস্পতি;শুক্র;শনি`)},`bn`),W({group:`,`,decimal:`.`,mmmm:H(`जनवरी;फ़रवरी;मार्च;अप्रैल;मई;जून;जुलाई;अगस्त;सितंबर;अक्तूबर;नवंबर;दिसंबर`),mmm:H(`जन॰;फ़र॰;मार्च;अप्रैल;मई;जून;जुल॰;अग॰;सित॰;अक्तू॰;नव॰;दिस॰`),dddd:H(`रविवार;सोमवार;मंगलवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगल;बुध;गुरु;शुक्र;शनि`),ampm:H(`am;pm`)},`hi`);function Cs(e,t){switch(t){case`int`:return e.int_pattern;case`frac`:return e.frac_pattern;case`man`:return e.man_pattern;case`den`:return e.den_pattern;case`num`:return e.num_pattern}}function ws(e,t,n){let r=e.length,i=e.replace(/#/g,``).length;switch(n){case`int`:t.int_max=r,t.int_min=i;break;case`frac`:t.frac_max=r,t.frac_min=i;break;case`man`:t.man_max=r,t.man_min=i;break;case`den`:t.den_max=r,t.den_min=i;break;case`num`:t.num_max=r,t.num_min=i}return t}function G(e,t){typeof e==`string`?t.push({type:`string`,value:e}):t.push(e)}function Ts(e,t){let n=e==null?void 0:e.type;return n===`hash`||n===`zero`||n===`qmark`||n===`digit`&&t===`den`}function Es(e){if(e===null)throw TypeError(`Cannot read properties of null (reading 'num')`)}function Ds(e){let t=[],n={scale:1,scaleExponent:0,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:t,tokensUsed:0,pattern:``,int_max:0,int_min:0,frac_max:0,frac_min:0,man_max:0,man_min:0,num_max:0,num_min:0,den_max:0,den_min:0,int_p:``,man_p:``,num_p:``,den_p:``,integer:!1},r=`int`,i=null,a=[],o,s=!1,c=-1,l=!1,u=``,d=!1;for(;++c<e.length&&!l;){var f;let h=e[c],g=h.type||`error`;if(u+=h.raw,g===`general`)n.general=!0,G(h,t);else if(Ts(h,r)){let e=Cs(n,r);Ts(o,r)||(o==null?void 0:o.type)===`group`?(e.push((e.pop()||``)+h.value),Es(i),i.num+=h.value):(e.push(h.value),i={type:r,num:h.value},G(i,t))}else if(g===`paren`)h.value===`(`&&(n.parens=!0),G(h.value,t);else if(g===`digit`)G(h.value,t);else if(g===`slash`){d=!0;let e=Cs(n,r);if(e.length){if(!i)throw SyntaxError(`Format pattern is missing a numerator`);n.fractions=!0;let a=e.pop();if(a===void 0)throw SyntaxError(`Format pattern is missing a numerator`);n.num_pattern.push(a),i.type=`num`,r=`den`,G({type:`div`},t)}else G(h.value,t)}else if(g===`comma`)G(`,`,t);else if(g===`scale`)n.scale=.001**h.raw.length,n.scaleExponent=-3*h.raw.length;else if(g===`group`){if(r===`int`&&(n.grouping=!0),r===`den`)throw SyntaxError(`Cannot group denominator digits`)}else if(g===`space`)G(h,t);else if(g===`break`){l=!0;break}else if(g===`text`)n.text=!0,G(h,t);else if(g===`plus`||g===`minus`)G(h,t);else if(g===`duration`){let e=h.value.toLowerCase(),r=e[0],i={type:``,size:0,date:1,pad:e.length};r===`h`?(i.size=16,i.type=`hour-elap`):r===`m`?(i.size=32,i.type=`min-elap`):(i.size=64,i.type=`sec-elap`),n.date|=i.size,a.push(i),G(i,t)}else if(n.date&&g===`point`&&((f=e[c+1])==null?void 0:f.type)===`zero`){var p,m;let r=1;c++;let i=`0`;((p=e[c+1])==null?void 0:p.type)===`zero`&&(i+=`0`,r=2,c++),((m=e[c+1])==null?void 0:m.type)===`zero`&&(i+=`0`,r=3,c++),u+=i;let a=[64,128,256,512][r];n.date|=a,n.date_eval=!0,n.sec_decimals=Math.max(n.sec_decimals,r),G({type:`subsec`,size:a,decimals:r,date:1},t)}else if(g===`calendar`)s||(n.date_system=h.value===`B2`||h.value===`b2`?6:1);else if(g===`datetime`){let e={type:``,size:0,date:1},r=h.value.toLowerCase(),i=r[0];if(r===`y`||r===`yy`)e.size=2,e.type=`year-short`;else if(i===`y`||i===`e`)e.size=2,e.type=`year`;else if(r===`b`||r===`bb`)e.size=2,e.type=`b-year-short`;else if(i===`b`)e.size=2,e.type=`b-year`;else if(r===`d`||r===`dd`)e.size=8,e.type=`day`,e.pad=/dd/.test(r);else if(r===`ddd`||r===`aaa`)e.size=8,e.type=`weekday-short`;else if(i===`d`||i===`a`)e.size=8,e.type=`weekday`;else if(i===`h`)e.size=16,e.type=`hour`,e.pad=/hh/i.test(r);else if(i===`m`){r.length===3?(e.size=4,e.type=`monthname-short`):r.length===5?(e.size=4,e.type=`monthname-single`):r.length>=4&&(e.size=4,e.type=`monthname`);let t=a[a.length-1];!e.type&&t&&!t.used&&t.size&80&&(t.used=!0,e.size=32,e.type=`min`,e.pad=/mm/.test(r)),e.type||(e.size=4,e.type=`month`,e.pad=/mm/.test(r),e.indeterminate=!0)}else if(i===`s`){e.size=64,e.type=`sec`,e.pad=/ss/.test(r);let t=a[a.length-1];t&&t.size&32?e.used=!0:t!=null&&t.indeterminate&&(delete t.indeterminate,t.size=32,t.type=`min`,e.used=!0)}n.date|=e.size,n.date_eval=!0,a.push(e),G(e,t)}else if(g===`ampm`)n.clock=12,n.date|=16,n.date_eval=!0,h.short=h.value===`A/P`,G(h,t);else if(g===`string`||g===`escaped`||g===`char`)G(h.value,t);else if(g===`condition`)n.condition=[h.value[0],Number.parseFloat(h.value[1])];else if(g===`locale`){let e=h.value.split(`-`),r=e.length<2?``:e.slice(1).join(`-`),i=e[0];i&&G(i,t);let a=us(r);a&&(n.locale=a);let o=Number.parseInt(r,16);Number.isFinite(o)&&o&16711680&&(o>>16&255)==6&&(n.date_system=6),s=!0}else if(g===`color`){let e=h.value.toLowerCase(),t=e,r=/^color\s*(\d+)$/i.exec(e);r&&(t=Number.parseInt(r[1],10)),n.color=t}else if(g===`percent`)n.scale=100,n.scaleExponent=2,n.percent=!0,G(`%`,t);else if(g===`point`)G(h,t),n.date||(n.dec_fractions=!0,r=`frac`);else if(g===`exp`)n.exponential=!0,n.exp_plus=h.value.includes(`+`),r=`man`,G({type:`exp`,plus:n.exp_plus},t);else if(g===`skip`||g===`fill`)G(h,t);else if(g!==`dbnum`&&g!==`natnum`)throw SyntaxError(g===`error`?`Illegal character: ${u}`:`Unknown token ${g} in ${u}`);o=h}if(n.tokensUsed=c,n.pattern=u,/^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(n.pattern)&&G({type:`text`},t),n.fractions&&n.dec_fractions||n.grouping&&!n.int_pattern.length||n.fractions&&n.exponential||n.fractions&&n.den_pattern.length*n.num_pattern.length===0||d&&!n.fractions&&!n.date||n.exponential&&(n.int_pattern.length||n.frac_pattern.length)*n.man_pattern.length===0)throw SyntaxError(`Invalid pattern: ${u}`);let h=n.int_pattern.join(``),g=n.man_pattern.join(``),_=n.frac_pattern.join(``);ws(h,n,`int`);let v=0;for(let e=0;e<h.length;e++){let t=h[h.length-1-e];/^[0-9?]/.test(t)&&(v=e+1)}n.int_min=v,ws(_,n,`frac`),ws(g,n,`man`);let y=n.num_pattern.join(``),b=n.den_pattern[0]||``;if(b.includes(`?`)||y.includes(`?`)?(b=b.replace(/\d/g,`?`),b=b.replace(/#$/g,`?`),ws(y,n,`num`),ws(b,n,`den`),y=y.replace(/#$/g,`?`)):(ws(y,n,`num`),ws(b,n,`den`)),n.int_p=h,n.man_p=g,n.num_p=y,n.den_p=b,n.den_pattern.length&&(n.denominator=Number.parseInt(n.den_pattern.join(``).replace(/\D/g,``),10)),n.integer=!!h.length,!n.integer&&!n.exponential&&_.length){let e=n.tokens.findIndex(e=>e.type===`point`);n.tokens.splice(e,0,{type:`int`,value:`#`}),n.integer=!0,n.int_pattern=[`#`],n.int_p=`#`}if(n.fractions)for(let e=0;e<t.length-1;e++){let n=t[e];if(n.type!==`string`&&n.type!==`space`)continue;let r=t[e+1].type;r===`num`?n.rule=`num+int`:r===`div`?n.rule=`num`:r===`den`&&(n.rule=`den`)}return n.grouping&&n.int_pattern.length>1&&(n.grouping=!1),n}function Os(e){if(e===0)return e;let t=Math.ceil(Math.log10(e<0?-e:e)),n=10**(16-Math.floor(t));return isFinite(n)?Math.round(e*n)/n:0}function ks(e,t=2,n=2){let r=e<0?-1:1,i=10**(t||2),a=10**(n||2),o=Math.abs(e),s=0,c=0,l=0,u=1,d,f;if(e=o,e%1==0)f=[e*r,1];else if(e<1e-19)f=[r,0x8ac7230489e80000];else if(e>0x8ac7230489e80000)f=[0x8ac7230489e80000*r,1];else{do if(o=1/(o-Math.floor(o)),d=u,u=u*Math.floor(o)+s,s=d,c=l,l=Math.floor(e*u+.5),l>=i||u>=a)return[r*c,s];while(Math.abs(e-l/u)>=1e-13&&o!==Math.floor(o));f=[r*l,u]}return f}let As={total:1,sign:0,period:0,int:1,frac:0};function js(e,t=!0){let n=Qo(e);if(n.digits===`0`)return As;let r=n.exponent+1,i=Math.max(r,1),a=Math.max(0,n.digits.length-r),o=t&&n.negative?1:0,s=+(a>0);return{total:o+i+s+a,digits:Math.max(r,0)+a,sign:o,period:s,int:i,frac:a}}function Ms(e,t=0){let n=Math.floor(Math.log10(e));return t>1?Math.floor(n/t)*t:n}function Ns(e,t=1){return t<-300?Number.parseFloat(e.toExponential().split(`e`)[0]):e*10**-t}function Ps(e,t=0){if(e<0)return-Ps(-e,t);if(t){let n=10**t||1;return Ps(e*n,0)/n}return Math.round(e)}function Fs(e,t=0){if(typeof e!=`number`)return e;if(!Number.isFinite(e)||e===0)return e===0?0:e;if(!Number.isFinite(t))return Ps(e,t);let n=Math.trunc(t);if(Number.isInteger(e)&&n>=0||n>324)return e;let r=ns(ts(Qo(e),n));return Number.isFinite(r)?r:e}function Is(e,t){return e.replace(/\./,t.decimal)}function Ls(e){return e?e.negative?{...e,negative:!1}:e:null}function Rs(e){return(e==null?void 0:e.exponent)??0}function zs(e){return!e||e.exponent<-308}function Bs(e,t){let n=is(e,1,!0,5),r=n.exponent,i=Math.abs(r);return[Is(rs(n.rounded),t),t.exponent,r<0?t.negative:t.positive,i<10?`0`:``,i]}function Vs(e,t,n){let r=Math.abs(t),i=e===1?e:Math.round(e*1e5)/1e5;return[Is(String(i),n),n.exponent,t<0?n.negative:n.positive,r<10?`0`:``,r]}function Hs(e,t,n,r,i=null){let a=typeof n==`number`?n|0:0;if(typeof n==`string`)e.push(n);else if(n===a)e.push(Math.abs(a));else{let t=Math.abs(n),a=Ls(i),o=Rs(a),s=null;zs(a)&&(o=Ms(t),s=Ns(t,o),s===10&&(s=1,o++));let c=js(t);if(o>=-4&&o<=-1){let n=t.toPrecision(10+o).replace(/\.?0+$/,``);e.push(Is(n,r))}else if(o===10){let n=t.toFixed(10).slice(0,12).replace(/\.$/,``);e.push(Is(n,r))}else if(Math.abs(o)<=9){if(c.total<=11){let n=Fs(t,9).toFixed(c.frac);e.push(Is(n,r))}else o===9?e.push(Math.floor(t)):o>=0&&o<9?e.push(Is(String(Fs(t,9-o)),r)):e.push(...s===null?Bs(a,r):Vs(s,o,r))}else c.total>=12?e.push(...s===null?Bs(a,r):Vs(s,o,r)):e.push(Is(Fs(t,9).toFixed(c.frac),r))}return e}function Us(e,t=!1){return e===`0`?`0`:e===`?`?t?`\xA0`:` `:``}let Ws=Math.floor;function Gs(e,t=!0){if(t&&e>=0){if(e===0)return[1900,1,0];if(e===60)return[1900,2,29];if(e<60)return[1900,e<32?1:2,(e-1)%31+1]}let n=e+68569+2415019,r=Ws(4*n/146097);n-=Ws((146097*r+3)/4);let i=Ws(4e3*(n+1)/1461001);n=n-Ws(1461*i/4)+31;let a=Ws(80*n/2447),o=n-Ws(2447*a/80);n=Ws(a/11);let s=a+2-12*n;return[100*(r-49)+i+n|0,s|0,o|0]}function Ks(e){return Gs(e+1462)}function qs(e){if(e===60)throw Error(`#VALUE!`);if(e<=1)return[1317,8,29];if(e<60)return[1317,e<32?9:10,1+(e-2)%30];let t=10631/30,n=8.01/60,r=e+466935,i=Ws(r/10631);r-=10631*i;let a=Ws((r-n)/t);r-=Ws(a*t+n);let o=Ws((r+28.5001)/29.5);return o===13?[30*i+a,12,30]:[30*i+a,o,r-Ws(29.5001*o-29)]}function Js(e,t=0,n=!0){let r=Ws(e);return t===6?qs(r):t===-1?Ks(r):Gs(r,n)}let Ys=Math.floor,Xs=86400,Zs=Date.UTC,Qs=1462,$s=9999;function ec(e=`date1900`){return e===`date1904`?2957003:2958465}function tc(e){return e%4==0&&(e%100!=0||e%400==0)}function nc(e,t,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||e<1||e>$s||t<1||t>12)return!1;let r=[31,tc(e)?29:28,31,30,31,30,31,31,30,31,30,31];return n>=1&&n<=r[t-1]}function rc(e,t,n){let r=e-+(t<=2),i=Math.floor(r/400),a=r-i*400,o=t+(t>2?-3:9),s=Math.floor((153*o+2)/5)+n-1,c=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return i*146097+c-719468}function ic(e,t,n){if(e===1900&&t===1&&n===0)return 0;if(e===1900&&t===2&&n===29)return 60;if(!nc(e,t,n))return null;let r=rc(e,t,n);return r+(r<=-25509?25568:25569)}function ac(e,t){if(!Number.isFinite(e)||e<0)return null;let n=Math.floor(e),[r,i,a]=Js(t.dateSystem===`date1904`?n+Qs:n,0,!0);if(r>$s)return null;let o=(e-n)*Xs,s=Math.floor(o);return{year:r,month:i,day:a,hours:Math.floor(s/3600),minutes:Math.floor(s/60)%60,seconds:s%60,fractionalSecond:o-s}}function oc(e,t){let n=e.year===1900&&e.month===2&&e.day===29?28:e.day;return new Date(Date.UTC(e.year,e.month-1,n,t?e.hours:0,t?e.minutes:0,t?e.seconds:0,t?Math.round(e.fractionalSecond*1e3):0))}function sc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!1):new Date(NaN)}function cc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!0):new Date(NaN)}function lc(e,t){let{year:n,month:r,day:i,hours:a,minutes:o,seconds:s,fractionalSecond:c}=e;if(!Number.isInteger(a)||a<0||a>23||!Number.isInteger(o)||o<0||o>59||!Number.isInteger(s)||s<0||s>59||!Number.isFinite(c)||c<0||c>=1||t.dateSystem===`date1900`&&n<1900)return null;let l=ic(n,r,i);if(l==null)return null;if(t.dateSystem===`date1904`){if(n===1900&&r===1&&i===0||n===1900&&r===2&&i===29)return null;l-=Qs}return l<0?null:l+(a*3600+o*60+s+c)/Xs}function uc(e,t,n){return Number.isFinite(e.getTime())?lc({year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hours:t?e.getUTCHours():0,minutes:t?e.getUTCMinutes():0,seconds:t?e.getUTCSeconds():0,fractionalSecond:t?e.getUTCMilliseconds()/1e3:0},{dateSystem:n})??((t?e.getTime():Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))-(n===`date1904`?Date.UTC(1904,0,1):Date.UTC(1899,11,31)))/864e5:NaN}function dc(e,t=`date1900`){return uc(e,!1,t)}function fc(e,t=`date1900`){return uc(e,!0,t)}function pc(e,t){let n=null;if(Array.isArray(e)){let[t,r,i,a,o,s]=e;n=Zs(t,r==null?0:r-1,i??1,a||0,o||0,s||0)}else if(e instanceof Date&&(n=e.getTime(),!(t!=null&&t.ignoreTimezone))){let t=new Date;t.setUTCFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t.setUTCHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n=t.getTime()}if(n!=null&&Number.isFinite(n)){let e=n/864e5;return e-(e<=-25509?-25568:-25569)}return null}function mc(e,t){let n=e|0,r=Xs*(e-n),i=Ys(r);r-i>.9999&&(i+=1,i===Xs&&(i=0,n+=1));let a=i<0?Xs+i:i,[o,s,c]=Js(e,0,t==null?void 0:t.leap1900);return[o,s,c,Ys(a/60/60)%60,Ys(a/60)%60,Ys(a)%60]}let hc=86400;function gc(e,t,n,r){if(n)return e<-694324||t>=35830291;let i=ec(r)+1;return e<0||t>=i}function _c(e,t=0){if(e<0)return-_c(-e,t);if(t){let n=10**t||1;return _c(e*n,0)/n}return Math.round(e)}function vc(e,t,n,r,i=null){let a=t,o=e,s=e,c=``,l=``,u=``,d=``,f=``,p=``,m=0,h=null,g=0;if(typeof o==`bigint`){if(o<=2**53-1&&o>=-(2**53-1))s=Number(o),o=s;else return n.bigintErrorNumber?String(o):n.overflow;g=s}else g=Math.trunc(s);let _=0,v=0,y=1,b=0,x=0,S=0,C=0,w=0,T=0,E=r||ps,D=i;if(!D&&typeof e==`number`&&Number.isFinite(e)&&(D=Qo(e)),D&&!a.text&&a.scaleExponent&&(D=$o(D,a.scaleExponent)),!a.text&&Number.isFinite(a.scale)&&a.scale!==1&&(s=Os(s*a.scale),o=s),a.exponential&&D&&D.exponent>=-308){let e=is(D,a.int_max,!!a.integer,a.frac_max);m=e.exponent,h=e.rounded,c+=Math.abs(m)}else if(a.exponential){let e=Math.abs(s);e&&(m=Ms(e,a.int_max)),s&&!a.integer&&m++,e=Ns(e,m),a.int_max===1&&_c(e,a.frac_max)===10&&(e=1,m++),s=s<0?-e:e,o=s,c+=Math.abs(m)}let O=!Number.isSafeInteger(s)||!!a.scaleExponent;if(h||=D&&O&&!a.date&&!a.fractions&&!a.exponential&&(a.integer||a.dec_fractions)?ts(D,a.frac_max):null,a.integer){if(h)p=h.integer===`0`?``:h.integer;else{let e=a.fractions?1:a.frac_max,t=Math.abs(Number.isSafeInteger(s)&&e===0?s:_c(s,e));p+=t<1?``:Math.floor(t)}}let k=n.grouping[0]??3,A=n.grouping[1]??k;a.dec_fractions&&(f=h?h.fraction:String(_c(s,a.frac_max)).split(`.`)[1]||``);let j=!a.error&&(a.num_p.includes(`0`)||a.den_p.includes(`0`)),M=j;if(a.fractions){M=j||!!(s%1);let e=Math.abs(a.integer?s%1:s);if(e){if(M=!0,a.denominator&&Number.isFinite(a.denominator))d+=a.denominator,u+=_c(e*a.denominator),u===`0`&&(u=``,d=``,M=j);else{let t=ks(e,1/0,a.den_max);u+=t[0],d+=t[1],a.integer&&u===`0`&&(u=``,d=``,M=j)}}else!s&&!a.integer&&(M=!0,u=`0`,d=`1`);a.integer&&!M&&!Math.trunc(s)&&(p=`0`)}if(a.date){g=Math.trunc(s);let e=hc*(s-g);if(_=Math.floor(e),T=e-_,Math.abs(T)<1e-6?T=0:T>.9999&&(T=0,_+=1,_===hc&&(_=0,g+=1)),T){let e=a.date&512||a.date&256||a.date&128;(e===512&&T>.9995||e===256&&T>.995||e===128&&T>.95||!e&&T>=.5)&&(_++,T=0)}let t=a.date_system===6?6:n.dateSystem===`date1904`?-1:a.date_system;if(g||a.date_system){let e=Js(s,t,n.leap1900);v=e[0],y=e[1],b=e[2]}if(_){let e=_<0?hc+_:_;w=Math.floor(e)%60,C=Math.floor(e/60)%60,S=Math.floor(e/60/60)%60}if(x=((t===-1?5:6)+g)%7,a.date_eval&&gc(s,g+_/hc,n.dateSpanLarge,n.dateSystem)){if(n.dateErrorThrows)throw Error(`Date out of bounds`);return n.dateErrorNumber?Hs(s<0?[E.negative]:[],{},s,E,D).join(``):n.overflow}}let N=Us(`?`,n.nbsp);m<0?l=`-`:a.exp_plus&&(l=`+`);let P=[],ee=(e,t,r,i)=>{let a=i,o=!a&&e.length>t.length?r.length+e.length-t.length:r.length;e.length<t.length&&(a+=e.length-t.length);for(let t=0;t<o;t++)P.push(e[t+a]||Us(r[t],n.nbsp));return o},F=!1,I={int:0,frac:0,man:0,num:0,den:0};for(let e=0,t=a.tokens.length;e<t;e++){let t=a.tokens[e],i=t.type,m=t.num?t.num.length:0;if(i===`string`){let e=t.value;t.rule?t.rule===`num`?M?P.push(e.replace(/ /g,N)):(a.num_min>0||a.den_min>0)&&P.push(e.replace(/./g,N)):t.rule===`num+int`?M&&p?P.push(e.replace(/ /g,N)):a.den_min>0&&(p||a.num_min)&&P.push(e.replace(/./g,N)):t.rule===`den`&&(M?P.push(e.replace(/ /g,N)):a.den_min>0&&P.push(e.replace(/./g,N))):P.push(e.replace(/ /g,N))}else if(i===`space`)t.rule===`num+int`?(M||a.num_min||a.den_min)&&(p||a.num_min)&&P.push(N):P.push(N);else if(i===`error`)P.push(n.invalid);else if(i===`point`)P.push(a.date?t.value:E.decimal);else if(i===`general`)Hs(P,a,o,E,D);else if(i===`exp`)P.push(E.exponent);else if(i===`minus`)t.volatile&&a.date||(t.volatile&&h?h.negative&&!h.zero&&P.push(E.negative):t.volatile&&(s>=0||typeof o!=`number`)||(t.volatile&&!a.fractions&&(a.integer||a.dec_fractions)?(s<0&&p&&p!==`0`||f)&&P.push(E.negative):P.push(E.negative)));else if(i===`plus`)P.push(E.positive);else if(i===`text`)P.push(o);else if(i===`fill`)n.fillChar&&P.push(n.fillChar,t.value);else if(i===`skip`)n.skipChar?P.push(n.skipChar,t.value):P.push(n.nbsp?`\xA0`:` `);else if(i===`div`)M?P.push(`/`):a.num_min>0||a.den_min>0?P.push(N):P.push(Us(`#`,n.nbsp));else if(i===`int`){if(a.int_pattern.length===1){let e=a.int_p,t=Math.max(a.int_min,p.length),r=``;for(let i=t;i>0;i--){let t=p.charAt(p.length-i),o=t?``:e.charAt(e.length-i)||e[0],s=``;if(a.grouping){let e=i-1-k;e>=0&&!(e%A)&&(s=t||o===`0`?E.group:Us(`?`,n.nbsp))}r+=(t||Us(o,n.nbsp))+s}P.push(r)}else I.int+=ee(p,a.int_p,t.num,I.int)}else if(i===`frac`){let e=I.frac;for(let r=0;r<m;r++)P.push(f[r+e]||Us(t.num[r],n.nbsp));I.frac+=m}else if(i===`man`)!I[i]&&!I.man&&P.push(l),I.man+=ee(c,a.man_p,t.num,I.man);else if(i===`num`)I.num+=ee(u,a.num_p,t.num,I.num);else if(i===`den`){let e=I.den;for(let r=0;r<m;r++){let i=d[r+e];if(!i){let e=t.num[r];`123456789`.includes(e)||F&&e===`0`?(F=!0,i=n.nbsp?`\xA0`:` `):i=!F&&r===m-1&&e===`0`&&!d?`1`:Us(e,n.nbsp)}P.push(i)}I.den+=m}else if(i===`year`)v<0&&P.push(E.negative),P.push(String(Math.abs(v)).padStart(4,`0`));else if(i===`year-short`){let e=v%100;P.push(e<10?`0`:``,e)}else if(i===`month`)P.push(t.pad&&y<10?`0`:``,y);else if(i===`monthname-single`)a.date_system===6?P.push(E.mmmm6[y-1].charAt(0)):P.push(E.mmmm[y-1].charAt(0));else if(i===`monthname-short`)a.date_system===6?P.push(E.mmm6[y-1]):P.push(E.mmm[y-1]);else if(i===`monthname`)a.date_system===6?P.push(E.mmmm6[y-1]):P.push(E.mmmm[y-1]);else if(t.type===`weekday-short`)P.push(E.ddd[x]);else if(i===`weekday`)P.push(E.dddd[x]);else if(i===`day`)P.push(t.pad&&b<10?`0`:``,b);else if(i===`hour`){let e=S%a.clock||(a.clock<24?a.clock:0);P.push(t.pad&&e<10?`0`:``,e)}else if(i===`min`)P.push(t.pad&&C<10?`0`:``,C);else if(i===`sec`)P.push(t.pad&&w<10?`0`:``,w);else if(i===`subsec`){P.push(E.decimal);let e=T.toFixed(a.sec_decimals);P.push(e.slice(2,2+t.decimals))}else if(i===`ampm`){let e=S<12?0:1;t.short&&!r?P.push(`AP`[e]):P.push(E.ampm[e])}else if(i===`hour-elap`){s<0&&P.push(E.negative);let e=g*24+Math.floor(Math.abs(_)/3600);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`min-elap`){s<0&&P.push(E.negative);let e=g*1440+Math.floor(Math.abs(_)/60);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`sec-elap`){s<0&&P.push(E.negative);let e=g*hc+Math.abs(_);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`b-year`)P.push(v+543);else if(i===`b-year-short`){let e=(v+543)%100;P.push(e<10?`0`:``,e)}}return P.join(``)}let yc=Ds([{type:To,value:`@`,raw:`@`}]);function bc(e){return!!e&&`scale`in e}function xc(e,t){for(let n=0;n<3;n++){let r=t[n];if(bc(r)){let t;if(r.condition){let n=r.condition[0],i=r.condition[1];n===`=`?t=e===i:n===`>`?t=e>i:n===`<`?t=e<i:n===`>=`?t=e>=i:n===`<=`?t=e<=i:n===`<>`&&(t=e!==i)}else t=!0;if(t)return r}else if(r)return r}}function Sc(e,t,n){let r=t.partitions,i=r[3],a=null;return(typeof e==`number`||typeof e==`bigint`)&&isFinite(e)&&(i=xc(e,r)),bc(i)&&i.color&&(a=i.color),a&&typeof a==`number`&&n.indexColors&&(a=Yo[a-1]||`#000`),a}function Cc(e,t,n){let r=t.partitions,i=ds(t.locale||n.locale),a=e,o=r[3]?r[3]:yc;if(typeof a==`boolean`&&(a=(i||ps).bool[+!a]),a==null)return``;let s=typeof a==`bigint`;if(typeof a!=`number`&&!s)return vc(a,o,n,i);if(!s&&!Number.isFinite(a)){let e=i||ps;return Number.isNaN(a)?e.nan:(a<0?e.negative:``)+e.infinity}let c=xc(e,r),l=c&&typeof e==`number`&&Number.isFinite(e)?Qo(e):null;return c?vc(e,c,n,i,l):n.overflow}function wc(e){return!!e&&`scale`in e}function Tc(e,t){return e.type===`year`||e.type===`year-short`?{type:`year`,pattern:`yyyy`,tokenIndex:t}:e.type===`month`?{type:`month`,pattern:e.pad?`mm`:`m`,tokenIndex:t}:e.type===`day`?{type:`day`,pattern:e.pad?`dd`:`d`,tokenIndex:t}:null}function Ec(e){return e.type.startsWith(`b-year`)||e.type.startsWith(`monthname`)||e.type.startsWith(`weekday`)}function Dc(e,t,n){if(n!==t+2)return null;let r=e[t+1];return r.value===`-`||r.value===`/`?r.value:null}function Oc(e,t){let n=e.find(e=>e.type===(t===`day`?`month`:`day`)),r=(n==null?void 0:n.pattern.length)===2;return t===`day`?r?`dd`:`d`:r?`mm`:`m`}function kc(e,t){let n=e.map(e=>e.type).join(``);if(new Set(e.map(e=>e.type)).size!==e.length)return null;let r=new Map(e.map(e=>[e.type,e.pattern]));r.set(`year`,`yyyy`),r.has(`month`)||r.set(`month`,Oc(e,`month`)),r.has(`day`)||r.set(`day`,Oc(e,`day`));let i={daymonth:[`day`,`month`,`year`],daymonthyear:[`day`,`month`,`year`],dayyear:[`day`,`month`,`year`],monthday:[`year`,`month`,`day`],monthdayyear:[`month`,`day`,`year`],monthyear:[`month`,`day`,`year`],yearmonth:[`year`,`month`,`day`],yearmonthday:[`year`,`month`,`day`],yearday:[`year`,`month`,`day`]}[n];return i?i.map(e=>r.get(e)).join(t):null}function Ac(e){let t=e.tokens.map((e,t)=>Tc(e,t)).filter(e=>e!==null);if(!t.length)return null;if(t.length<2||t.length>3||e.locale||e.date_system!==1||e.tokens.some(Ec))return`yyyy/mm/dd`;let n=t.slice(1).map((n,r)=>Dc(e.tokens,t[r].tokenIndex,n.tokenIndex)),r=n[0];return!r||n.some(e=>e!==r)?`yyyy/mm/dd`:kc(t,r)??`yyyy/mm/dd`}function jc(e){let t=e.tokens.findIndex(e=>e.type===`hour`),n=e.tokens.find(e=>e.type===`min`),r=e.tokens.findIndex(e=>e.type===`ampm`),i=r<0?void 0:e.tokens[r];if(!(t>=0||n||e.tokens.some(e=>e.type===`sec`)||i))return null;let a=t<0?void 0:e.tokens[t],o=`${a!=null&&a.pad?`hh`:`h`}:${(n==null?void 0:n.pad)===!1?`m`:`mm`}:ss`;return!i||typeof i.value!=`string`?o:r<t?`${i.value} ${o}`:`${o} ${i.value}`}function Mc(e,t){let n=xc(t,e);if(!wc(n)||n.tokens.some(e=>e.type.endsWith(`-elap`)))return null;let r=Ac(n),i=jc(n);return r&&i?`${r} ${i}`:r??i}function Nc(e){return!!e&&`scale`in e}function Pc(e){return!!e&&`generated`in e&&!!e.generated}function Fc(e){return!!(Nc(e[0])&&e[0].percent||Nc(e[1])&&e[1].percent||Nc(e[2])&&e[2].percent||Nc(e[3])&&e[3].percent)}function Ic(e){return!!(Nc(e[0])&&e[0].date||Nc(e[1])&&e[1].date||Nc(e[2])&&e[2].date||Nc(e[3])&&e[3].date)}function Lc(e){let[t,n,r,i]=e;return!(t&&!Pc(t)||n&&!Pc(n)||r&&!Pc(r)||!Nc(i)||!i.text||Pc(i))}let Rc={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},zc=[[`DMY`,1],[`DM`,2],[`MY`,3],[`MDY`,4],[`MD`,5],[`hmsa`,6],[`hma`,7],[`hms`,8],[`hm`,9]];function Bc(e,t=null){let[n,r]=e;if(!n)throw TypeError(`Cannot read properties of undefined (reading 'frac_max')`);let i=Nc(n)?n:void 0,a=Nc(r)?r:void 0,o=`error`in n,s=i==null?void 0:i.frac_max,c={type:`general`,isDate:Ic(e),isText:Lc(e),isPercent:Fc(e),maxDecimals:i!=null&&i.general?9:s??0,scale:(i==null?void 0:i.scale)??1,color:0,parentheses:0,grouped:i!=null&&i.grouping?1:0,code:``,level:0},l=!c.isDate&&!c.isText&&!o&&n.tokens.some(e=>e.type===`string`&&typeof e.value==`string`&&(t?e.value===t:Zo.test(e.value))),u=`G`,d=s!==void 0&&s>=0?Math.min(15,s):``,f=``,p=``;if(a!=null&&a.color&&(p=`-`,c.color=1),i!=null&&i.parens&&(f=`()`,c.parentheses=1),l)u=`C`,c.type=`currency`;else if(o)c.type=`error`,c.maxDecimals=0;else if(c.isDate){let e=0,t=0,r=``;n.tokens.forEach(n=>{let i=n.type;/^(b-)?year/.test(i)?(r+=`Y`,t++):i.startsWith(`month`)?(r+=`M`,t++):/^(week)?day/.test(i)?(r+=`D`,t++):(i===`hour`||i===`min`||i===`sec`||i===`ampm`)&&(r+=i[0],e++)}),c.type=`date`,t&&e?c.type=`datetime`:!t&&e&&(c.type=`time`);let i=zc.find(([e])=>r.startsWith(e));u=i?`D`:`G`,d=i?i[1]:``}else c.isText?(u=`G`,c.type=`text`,d=``,c.maxDecimals=0):i!=null&&i.general?(u=`G`,c.type=`general`,d=``):i!=null&&i.fractions?(u=`G`,c.type=`fraction`,d=``):i!=null&&i.exponential?(u=`S`,c.type=`scientific`):c.isPercent?(u=`P`,c.type=`percent`):i!=null&&i.grouping?(u=`,`,c.type=`grouped`):i&&(i.int_max||s)&&(u=`F`,c.type=`number`);return c.code=u+d+p+f,c.level=Rc[c.type],Object.freeze(c)}function Vc(e){let[t]=e;if(!t)throw TypeError(`Cannot read properties of undefined (reading 'date')`);let n=Nc(t)?t:void 0,r=(n==null?void 0:n.date)??0;return{year:!!(r&2),month:!!(r&4),day:!!(r&8),hours:!!(r&16),minutes:!!(r&32),seconds:!!(r&64),isDuration:(n==null?void 0:n.tokens.some(e=>e.type.endsWith(`-elap`)))??!1,clockType:(n==null?void 0:n.clock)===12?12:24}}let Hc={overflow:`######`,dateErrorThrows:!1,dateErrorNumber:!1,bigintErrorNumber:!1,dateSpanLarge:!1,leap1900:!0,dateSystem:`date1900`,nbsp:!1,throws:!0,invalid:`######`,locale:``,ignoreTimezone:!1,grouping:[3,3],indexColors:!0,skipChar:``,fillChar:``},Uc=[[go,/^General/i,0],[_o,/^#/,0],[vo,/^0/,0],[yo,/^\?/,0],[bo,/^\//,0],[wo,/^;/,0],[To,/^@/,0],[Eo,/^\+/,0],[Do,/^-/,0],[Oo,/^\./,0],[ko,/^ /,0],[Ao,/^%/,0],[jo,/^[1-9]/,0],[Mo,/^(?:B[12])/i,0],[No,/^B$/,0],[Po,/^(?:[hH]+|[mM]+|[sS]+|[yY]+|[bB]+|[dD]+|[gG]+|[aA]{3,}|e+)/,0],[Fo,/^(?:\[(h+|m+|s+)\])/i,1],[Io,/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/,[1,2]],[Lo,/^\[(DBNum[0-4]?\d)\]/i,1],[Ro,/^\[(NatNum[0-4]?\d)\]/i,1],[zo,/^\[\$([^\]]+)\]/,1],[Bo,/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*\d+)\]/i,1],[Vo,/^\[([^\]]+)\]/,1],[Ho,/^(?:AM\/PM|am\/pm|A\/P)/,0],[Uo,/^\\([\s\S])/,1],[Wo,/^"([^"]*?)"/,1],[Go,/^_(\\.|.)/,1],[`exp`,/^[Ee]([+-])/,1],[Ko,/^\*(\\.|.)/,1],[qo,/^[()]/,0],[No,/^[EÈÉÊËèéêëĒēĔĕĖėĘęĚěȄȅȆȇȨȩNnÑñŃńŅņŇňǸǹ["*/\\_]/,0],[Jo,/^./,0]],Wc=e=>{let t=(e||`\0`).charCodeAt(0);return t===63||t===35||t>=48&&t<=57};function Gc(e){let t=0,n=[],r=[];for(;t<e.length;){let i=e.slice(t),a=0,o=/^(,+)(.)?/.exec(i);if(o){let i=o[1];a=i.length;let s=e[t-1]||``,c=!1,l=!1;Wc(s)?(c=!0,l=!0):s===`.`&&(l=!0);let u=o[2]||``;if(c&&(!u||u===`;`)&&(c=!1),l&&Wc(u)&&(l=!1),c&&!l)n.push({type:xo,value:`,`,raw:i});else if(!c&&l)n.push({type:So,value:`,`,raw:i});else if(c&&l){let e={type:So,value:`,`,raw:i};n.push(e),r.push(e)}else n.push({type:Co,value:`,`,raw:i})}else{let e;for(let[t,r,o]of Uc){let s=r.exec(i);if(s){e={type:t,value:typeof o==`number`?s[o||0]:o.map(e=>s[e]),raw:s[0]},n.push(e),a=s[0].length;break}}r.length&&(e==null?void 0:e.raw)===`;`&&(r.length=0),r.length&&Wc(e==null?void 0:e.raw)&&(r.forEach(e=>e.type=xo),r.length=0)}if(!a){let e=i[0];a=1,n.push({type:Jo,value:e,raw:e})}t+=a}return n}function Kc(e){var t,n;let r=(t=e.condition)==null?void 0:t[0],i=(n=e.condition)==null?void 0:n[1];typeof i==`number`&&i<0&&(r===`<`||r===`<=`||r===`=`)||i===0&&r===`<`||e.tokens.unshift({type:`minus`,volatile:!0})}function qc(e,t=null){let n={...e,int_pattern:[...e.int_pattern],frac_pattern:[...e.frac_pattern],man_pattern:[...e.man_pattern],den_pattern:[...e.den_pattern],num_pattern:[...e.num_pattern],tokens:[...e.tokens]};return e.condition&&(n.condition=[...e.condition]),t&&n.tokens.unshift(t),n.generated=!0,n}function Jc(e){let t=[],n=!1,r,i=null,a=0,o=0,s=0,c=Gc(e);do{var l;let e=Ds(c);if((e.date||e.general)&&(e.int_pattern.length||e.frac_pattern.length||e.scale!==1||e.text))throw Error(`Illegal format`);if(e.condition&&(s++,n=!0),e.text){if(i)throw Error(`Unexpected partition`);i=e}e.locale&&(r=us(e.locale)),t.push(e),a=+(((l=c[e.tokensUsed])==null?void 0:l.type)===`break`),c=c.slice(e.tokensUsed+a),o++}while(a&&o<4&&s<3);if(a)throw Error(`Unexpected partition`);if(s>2)throw Error(`Unexpected condition`);let u=t[3];if(u&&(u.int_pattern.length||u.frac_pattern.length||u.date))throw Error(`Unexpected partition`);if(n){t[0].condition||(t[0].condition=[`>`,0]);let e=t.length;if(e===1){let e=Ds(Gc(`General`));e.generated=!0,t[1]=e}if(e<3){let e=t[0],n=t[1];if(Kc(e),n.condition)Kc(n);else{let t=e.condition;((t==null?void 0:t[0])===`=`||typeof(t==null?void 0:t[1])==`number`&&t[1]>=0&&(t[0]===`>`||t[0]===`>=`))&&n.tokens.unshift({type:`minus`,volatile:!0})}}else t.forEach(Kc)}else{if(t.length<4&&i)for(let e=0,n=t.length;e<n;e++)t[e]===i&&t.splice(e,1);if(t.length<1&&i){let e=Ds(Gc(`General`));e.generated=!0,t[0]=e}if(t.length<2&&t.push(qc(t[0],{type:`minus`,volatile:!0})),t.length<3&&t.push(qc(t[0])),t.length<4){if(i)t.push(i);else{let e=Ds(Gc(`@`));e.generated=!0,t.push(e)}}t[0].condition=[`>`,0],t[1].condition=[`<`,0],t[2].condition=null}return{pattern:e,partitions:t,locale:r}}let Yc=`!d-m-y.!d-m-Y.!j-m-y.!j-m-Y.!d-n-y.!d-n-Y.!j-n-y.!j-n-Y.?m-d-y.?m-d-Y.?m-j-y.?m-j-Y.?n-d-y.?n-d-Y.?n-j-y.?n-j-Y.d-M-y.d-M-Y.j-M-y.j-M-Y.M-d-y.M-d-Y.M-j-y.M-j-Y.d-F-y.d-F-Y.F-d-y.F-d-Y.F-j-y.F-j-Y.j-F-y.j-F-Y.y-F-d.y-F-j.y-M-d.y-M-j.Y-F-d.Y-F-j.Y-M-d.Y-m-d.Y-M-j.Y-m-j.Y-n-d.Y-n-j.j-F.j-M.d-F.d-M.n-d.n-j.n-Y.m-d.m-j.m-Y.M-Y.M-y.F-y.F-Y.Y-M.Y-n.Y-m.Y-F.Y-M`.split(`.`),Xc={j:`d`,d:`d`,D:`ddd`,l:`dddd`,n:`m`,m:`m`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Zc={j:`dd`,d:`dd`,D:`ddd`,l:`dddd`,n:`mm`,m:`mm`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Qc={},$c={};function el(e,t,n=1){if(e){let r=e[0],i=e.slice(1);if(r===`!`)el(i,t,4);else if(r===`?`)el(i,t,2);else{let e=t[r];typeof e!=`object`&&(e={},t[r]=e),el(i,e,n)}}else t.$=n}function tl(e,t){el(e,t),el(`${e} x`,t),el(`${e} l`,t),el(`${e} l x`,t),el(`l ${e}`,t),el(`l ${e} x`,t),el(`${e} D`,t),el(`${e} D x`,t),el(`D ${e}`,t),el(`D ${e} x`,t)}Yc.forEach(e=>{e.startsWith(`?`)||tl(e,Qc),e.startsWith(`!`)||tl(e,$c)});let nl={".":[`,`,`\xA0`,` `,`'`,`٬`],",":[`.`,`\xA0`,` `,`'`,`٬`],"٫":[`.`,`\xA0`,` `,`'`,`٬`]},rl=e=>(e==null?void 0:e.length)===1&&e>=`0`&&e<=`9`;function il(e,t={}){let n=ds(t.locale||``)||ps,r=n.decimal,i=[...nl[r]||[`'`,`٬`]];!i.includes(n.group)&&n.group!==` `&&n.group!==r&&i.push(n.group);let a=``,o=``,s=1,c=``,l=!1,u=!1,d=!1,f=!1,p=!1,m=``,h=!1,g=0,_=[` `,`\xA0`,` `,`+`,`%`,`(`,`-`].concat(Xo);for(;_.includes(e.charAt(g));){let t=e.charAt(g);if(t===`-`){if(l||u)return null;l=!0,s=-1}else if(Zo.test(t)){if(p)return null;p=!0,m=t}else if(t===`(`){if(u||l)return null;u=!0,s=-1}else if(t===`%`){if(f)return null;f=!0}g++}let v=!1,y;if(e.charAt(g)===r||rl(e.charAt(g)))for(;g<e.length;){let t=e.charAt(g);if(!y&&i.includes(t))y=t;else if(!(y&&y===t)){if(t===r){if(v)break;a+=`.`,v=!0}else if(rl(t))a+=t;else break}g++}if(e.charAt(g)===`e`||e.charAt(g)===`E`){o+=e.charAt(g),g++,(e.charAt(g)===`+`||e.charAt(g)===`-`)&&(o+=e.charAt(g),g++);let t=g;for(;rl(e.charAt(g));)o+=e.charAt(g),g++;if(t===g)return null}let b=[` `,`\xA0`,` `,`%`,`$`,`)`].concat(Xo);for(;b.includes(e.charAt(g));){let t=e.charAt(g);if(Zo.test(t)){if(p)return null;p=!0,m=t,h=!0}else if(t===`)`){if(d||!u)return null;d=!0}else if(t===`%`){if(f)return null;f=!0}g++}if(g!==e.length)return null;let x=Number.parseFloat(a+o);if(!Number.isFinite(x))return null;if(o){if(f||p)return null;c=`0.00E+00`}else if(f){if(p)return null;c=a.includes(`.`)?`0.00%`:`0%`,x*=.01}else if(p){let e=a.includes(`.`)?`#,##0.00`:`#,##0`;c=h?e+m:m+e}else y&&(c=a.includes(`.`)?`#,##0.00`:`#,##0`);let S={v:x*s};return c&&(S.z=c),S}function al(e,t,n){if(n<1||t<1||t>12)return!1;if(t===2){if(n>(e%4==0&&e%100!=0||e%400==0||e===1900?29:28))return!1}else if((t===4||t===6||t===9||t===11)&&n>30||(t===1||t===3||t===5||t===7||t===8||t===10||t===12)&&n>31)return!1;return!0}let ol=new WeakMap,sl=(e,t,n=!1)=>{for(let r of t)if(e.startsWith(r[0])){let t=r[0].length;return n&&(r[2]===`D`||r[2]===`M`)&&e[t]===`.`&&t++,[e.slice(0,t),r]}return[``,null]},cl=(e,t,n,r)=>{let i=n.path||``,a=Object.keys(t);for(let o of a){let a=t[o],s;if(!a)continue;if(o===`$`||o===`€`)e||(s=n);else{if(typeof a!=`object`)continue;if(o===`-`){let t=/^(\s*([./-]|,\s)\s*|\s+)/.exec(e);if(t){let o=t[1]===`-`||t[1]===`/`||t[1]===`.`?t[1]:` `;if(!n.sep||n.sep===o){let c=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,sep:o,path:i+c},r)}}}else if(o===` `){let t=/^[,.]?\s+/.exec(e);if(t){let o=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,path:i+o},r)}}else if(o===`j`||o===`d`){let t=/^(0{1,2}|0?[1-9]|1\d|2\d|3[01])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,day:t[0],path:i+o},r))}else if(o===`n`||o===`m`){let t=/^(0?[1-9]|1[012])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,month:+t[0],_mon:t[0],path:i+o},r))}else if(o===`F`||o===`M`){let[t,c]=sl(e,r.mon,r.mp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,month:c[1],_mon:t,path:i+o},r))}else if(o===`l`||o===`D`){let[t,c]=sl(e,r.day,r.dp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,path:i+o},r))}else if(o===`y`){let t=/^\d\d\b/.exec(e);if(t){let c=+t[0]>=30?+t[0]+1900:+t[0]+2e3;s=cl(e.slice(t[0].length),a,{...n,year:c,path:i+o},r)}}else if(o===`Y`){let t=/^\d\d\d\d\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,year:+t[0],path:i+o},r))}else if(o===`x`){let t=hl(e,{locale:r.locale});t&&(s=cl(``,a,{...n,time:t.v,tf:t.z,path:i+o},r))}else throw Error(`Unknown date token "${o}"`)}let c=(s==null?void 0:s.year)||1916,l=(s==null?void 0:s.month)||1,u=s!=null&&s.day?+s.day:1,d=r.dateSystem===`date1900`&&c===1900&&l===1&&u===0;if(s&&(d||al(c,l,u)))return s}},ll=e=>e.replace(/\s+/g,` `).trim().replace(/’/,`'`).replace(/\.$/,``).toLowerCase(),ul=(e,t)=>{let n=e.map((e,n)=>[ll(e),n+1,t]);return n.sort((e,t)=>t[0].length-e[0].length),n},dl=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),fl=e=>{let t=ol.get(e);return(!t||!dl(e.mmmm,t.mmmm)||!dl(e.mmm,t.mmm)||!dl(e.dddd,t.dddd)||!dl(e.ddd,t.ddd))&&(t={lookups:{mon:ul(e.mmmm,`F`).concat(ul(e.mmm,`M`)),mp:e.mmm[0].endsWith(`.`),day:ul(e.dddd,`l`).concat(ul(e.ddd,`D`)),dp:e.ddd[0].endsWith(`.`)},mmmm:[...e.mmmm],mmm:[...e.mmm],dddd:[...e.dddd],ddd:[...e.ddd]},ol.set(e,t)),t.lookups};function pl(e,t={}){let n=ds(t.locale||``)||ps,r={...fl(n),locale:t.locale,dateSystem:t.dateSystem??`date1900`},i=cl(ll(e),n.preferMDY?$c:Qc,{path:``},r);if(!i||i.sep===`.`&&i.path.length===3||i.month==null||i._mon==null)return null;let a=+(i.year??new Date().getUTCFullYear()),o=i.day??`1`,s=t.dateSystem??`date1900`,c=lc({year:a,month:i.month,day:+o,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s});if(c==null)return null;let l=c+(i.time||0);if(l>=lc({year:9999,month:12,day:31,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s})+1)return null;let u=i._mon[0]===`0`||o[0]===`0`||i._mon.length===2&&o.length===2;return{v:l,z:i.path.replace(/[jdlDnmMFyYx]/g,e=>e===`x`?i.tf||``:(u?Zc[e]:Xc[e])||e)}}let ml=e=>e.replace(/\s+/g,``).trim().replace(/\./g,``).toLowerCase();function hl(e,t={}){let n=ds(t.locale||``)||ps,r=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?=\s*[^\s\d]|$)/.exec(e),i=``;if(r){let t=ml(e.slice(r[0].length));if(t===ml(n.ampm[0])||t===`a`||t===`am`)i=`a`;else if(t===ml(n.ampm[1])||t===`p`||t===`pm`)i=`p`;else if(t===`:`)r[3]||=`0`,r[2]||=`0`;else if(t)return null}if(!r)return null;let[,a,o,s,c]=r;if(c&&!s||!i&&!o&&!s)return null;let l=+(a||0);if(i){if(l>=13)return null;i===`a`?l===12&&(l=0):i===`p`&&l!==12&&(l+=12)}let u=+(o||0),d=+(s||0),f=+(c||0),p=a.length===2?`hh`:`h`,m=s?`:ss`:``,h=i?` AM/PM`:``;return{v:(l*60*60+u*60+d+f)/86400,z:`${p}:mm${m}${h}`}}function gl(e,t={}){let n=ds(t.locale||``)||ps,r=e.trim().toLowerCase(),i=n.bool[0].toLowerCase();if(r===`true`||r===i)return{v:!0};let a=n.bool[1].toLowerCase();return r===`false`||r===a?{v:!1}:null}function _l(e,t){return il(e,t)??pl(e,t)??hl(e,t)??gl(e,t)}var vl=p({addLocale:()=>W,dateFromSerial:()=>mc,dateToSerial:()=>pc,dec2frac:()=>ks,format:()=>xl,formatColor:()=>Sl,getDateTimeEditPattern:()=>kl,getFormatDateInfo:()=>Ol,getFormatInfo:()=>Dl,getLocale:()=>ds,isDateFormat:()=>Cl,isPercentFormat:()=>wl,isTextFormat:()=>Tl,isValidFormat:()=>El,parseBool:()=>gl,parseDate:()=>pl,parseLocale:()=>ls,parseNumber:()=>il,parseTime:()=>hl,parseValue:()=>_l,round:()=>Fs,tokenTypes:()=>Al,tokenize:()=>Gc});let yl=Object.create({});function bl(e,t=!1){let n=e||`General`,r=yl[n];if(!r)try{r=Jc(n),yl[n]=r}catch(e){if(t)throw e;let i=e instanceof Error?e.message:String(e),a={tokens:[{type:`error`}],error:i};r={pattern:n,partitions:[a,a,a,a],error:i,locale:null}}return r}function xl(e,t,n={}){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Cc(pc(t,r)??t,i,r)}function Sl(e,t,n){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Sc(pc(t,r)??t,i,r)}function Cl(e){return Ic(bl(e,!1).partitions)}function wl(e){return Fc(bl(e,!1).partitions)}function Tl(e){return Lc(bl(e,!1).partitions)}function El(e){try{return bl(e,!0),!0}catch{return!1}}function Dl(e,t={}){let n=bl(e,!1);return n.info||=Bc(n.partitions,t==null?void 0:t.currency),n.info}function Ol(e){let t=bl(e,!1);return t.dateInfo||=Vc(t.partitions),t.dateInfo}function kl(e,t){return Mc(bl(e,!1).partitions,t)}let Al=Object.freeze({AMPM:Ho,BREAK:wo,CALENDAR:Mo,CHAR:Jo,COLOR:Bo,COMMA:Co,CONDITION:Io,DATETIME:Po,DBNUM:Lo,DIGIT:jo,DURATION:Fo,ERROR:No,ESCAPED:Uo,EXP:`exp`,FILL:Ko,GENERAL:go,GROUP:xo,HASH:_o,LOCALE:zo,MINUS:Do,MODIFIER:Vo,NATNUM:Ro,PAREN:qo,PERCENT:Ao,PLUS:Eo,POINT:Oo,QMARK:yo,SCALE:So,SKIP:Go,SLASH:bo,SPACE:ko,STRING:Wo,TEXT:To,ZERO:vo}),jl=new Set([`d`,`g`,`i`,`m`,`s`,`u`,`v`,`y`]);function Ml(e,t){let n=Nl(t);return new RegExp(e,n)}function Nl(e){if(e===void 0)return;let t=new Set;for(let n of e){if(!jl.has(n)||t.has(n))throw SyntaxError(`Invalid regular expression flags: ${e}`);t.add(n)}return e}var Pl=class e{constructor(...e){T(this,`data`,void 0),this.data=Rl(e.flatMap(e=>Il(e)))}union(...t){return new e(this,...t)}subtract(...t){let n=Rl(t.flatMap(e=>Il(e))),r=this.data.slice();for(let[e,t]of n){let n=[];for(let[i,a]of r){if(t<i||e>a){n.push([i,a]);continue}e>i&&n.push([i,e-1]),t<a&&n.push([t+1,a])}r=n}return new e(...r)}intersect(...t){let n=Rl(t.flatMap(e=>Il(e))),r=[];for(let[e,t]of this.data)for(let[i,a]of n){let n=Math.max(e,i),o=Math.min(t,a);n<=o&&r.push([n,o])}return new e(...r)}isEmpty(){return this.data.length===0}toString(){return this.isEmpty()?`(?!)`:`[${this.data.map(zl).join(``)}]`}toRegExp(e){return Ml(this.toString(),e)}};let Fl=(...e)=>new Pl(...e);function Il(e){if(e instanceof Pl)return e.data;if(Array.isArray(e)){let t=Ll(e[0]),n=Ll(e[1]);return[[Math.min(t,n),Math.max(t,n)]]}let t=Ll(e);return[[t,t]]}function Ll(e){if(typeof e==`number`){if(!Number.isInteger(e)||e<0||e>1114111)throw RangeError(`Invalid code point: ${e}`);return e}let t=e.codePointAt(0);if(t==null||String.fromCodePoint(t)!==e)throw RangeError(`Charset string inputs must contain exactly one code point: ${e}`);return t}function Rl(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]),n=[];for(let[e,r]of t){let t=n[n.length-1];!t||e>t[1]+1?n.push([e,r]):t[1]=Math.max(t[1],r)}return n}function zl([e,t]){return e===t?Bl(e):`${Bl(e)}-${Bl(t)}`}function Bl(e){let t=String.fromCodePoint(e);return t===`\\`||t===`]`||t===`-`||t===`^`?`\\${t}`:e<=31||e===127?`\\u${e.toString(16).padStart(4,`0`)}`:t}function Vl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hl(e,t){return Ml(Vl(e),t)}function Ul(e){return Ml(`^${Vl(e).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`)}$`,`i`)}var Wl=class e{constructor(...t){T(this,`charset`,void 0),T(this,`strings`,void 0);let n=[],r=[];for(let i of t)i instanceof e?(n.push(i.charset),r.push(...i.strings)):i instanceof Pl||typeof i==`number`||Array.isArray(i)?n.push(i):r.push(i);this.charset=Fl(...n),this.strings=Array.from(new Set(r))}union(...t){return new e(this,...t)}subtract(...t){let n=new e(...t),r=this.strings.filter(e=>!n.strings.includes(e));return new e(this.charset.subtract(n.charset),...r)}isEmpty(){return this.charset.isEmpty()&&this.strings.length===0}toString(){if(this.isEmpty())return`(?!)`;let e=[...this.charset.isEmpty()?[]:[this.charset.toString()],...this.strings.map(Vl)];return e.length===1?e[0]:`(?:${e.join(`|`)})`}toRegExp(e){return Ml(this.toString(),e)}};let Gl={Charset:Pl,Or:Wl,charset:Fl,or:(...e)=>new Wl(...e),createRegExpFromSafeFragment:Ml,escapeRegExp:Vl,createLiteralRegExp:Hl,createFromWildcard:Ul};function Kl(e){return e===`@@@`||e===`@`}function ql(e){return e==null||e===`General`}function Jl(e){switch(e){case`frFR`:return`fr`;case`ruRU`:return`ru`;case`viVN`:return`vi`;case`zhCN`:return`zh-CN`;case`koKR`:return`ko`;case`zhTW`:return`zh-TW`;case`zhHK`:return`zh-HK`;case`esES`:case`caES`:return`es`;case`skSK`:return`sk`;case`jaJP`:return`ja`;case`ptBR`:return`pt`;case`deDE`:return`de`;case`itIT`:return`it`;case`idID`:return`id`;case`plPL`:return`pl`;case`arSA`:return`ar`;default:return`en`}}let Yl=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Gc(e),n=``,r=!1,i=!1;for(let e of t){if(e.type===Al.POINT){r=!0;continue}if(!(i&&e.type===Al.MINUS)&&e.type!==Al.SKIP){if(e.type===Al.COLOR){i=!0;continue}i=!1,!(r&&e.type===Al.ZERO)&&(r=!1,r||(n+=e.value||``))}}return n};return n(e)===n(t)},Xl=new Set([`m d`]),Zl=new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),Ql=`Rp.zł.NT$.R$.HK$.$.£.¥.¤.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿.﷼`.split(`.`),$l=RegExp(`^${Gl.charset(...Array.from(new Set(Ql.join(``))))}+`),eu=(e,t={})=>{let n=pl(e,t)??hl(e,t)??il(e,t);if(!n)return null;let{z:r}=n;if(r){if(Xl.has(r)||Zl.has(r)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(r.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e.replace($l,``).trim();if(t.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(t))return null}}return n};function tu(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function nu(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}let ru=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function iu(e,t,n){let r=nu(n),i=n;for(let t=r-1;t>=e;t--)ru(i[t])?delete i[t+1]:i[t+1]=i[t];ru(t)||(i[e]=t)}function au(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function ou(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++){let t=r[e];c[l]=n[t]}for(let e=0;e<s;e++,l++){let t=o[e];c[l]=a[t]}return c}function su(e,t,n){let r=n;if(nu(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function cu(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?lu(e,t,n,r):uu(e,t,n,r)}function lu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function uu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var du=class e{constructor(e={}){T(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t??(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){cu(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{cu(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){au(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&au(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++){let r=this.getValue(e,a);t[n]=r,n++}a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,z.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return nu(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=nu(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]??(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.clone()}getStartEndScope(){let e=-1,t=-1,n=-1,r=-1,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=n===-1?+t[0]:Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=nu(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function fu(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}function pu(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function mu(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function hu(e){return mu(e)&&(e==null?void 0:e.coverable)!==!1}function gu(e){if(e){if(e.rgb)return new La(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=ho.Office)==null?void 0:t[e.th];if(n)return new La(n).toRgbString()}}return null}function _u(e){return z.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function vu(e){return z.isString(e)&&e.length>0}function yu(e,t=!1){let n=``,r=new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${gu(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o;n+=`border-bottom: ${bu((o=e.bd)==null?void 0:o.b.s)} ${gu(e.bd.b.cl)??``}; `}if((r=e.bd)!=null&&r.t){var s;n+=`border-top: ${bu((s=e.bd)==null?void 0:s.t.s)} ${gu(e.bd.t.cl)??``}; `}if((i=e.bd)!=null&&i.r){var c;n+=`border-right: ${bu((c=e.bd)==null?void 0:c.r.s)} ${gu(e.bd.r.cl)??``}; `}if((a=e.bd)!=null&&a.l){var l;n+=`border-left: ${bu((l=e.bd)==null?void 0:l.l.s)} ${gu(e.bd.l.cl)??``}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${gu(e.cl)}; `)}],[`va`,()=>{e.va===2?n+=`vertical-align: sub; `:e.va===3&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===1?n+=`direction: ltr; `:e.td===2&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===1?n+=`text-align: left; `:e.ht===3?n+=`text-align: right; `:e.ht===2?n+=`text-align: center; `:e.ht===4&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===3?n+=`vertical-align: bottom; `:e.vt===1?n+=`vertical-align: top; `:e.vt===2&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===2?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===3&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function bu(e){let t=``;return e===0?t=`none`:e===1?t=`0.5pt solid`:e===2?t=`0.5pt double`:e===3?t=`0.5pt dotted`:e===4||e===5?t=`0.5pt dashed`:e===6?t=`0.5pt dotted`:e===7?t=`0.5pt double`:e===8?t=`1pt solid`:e===9||e===10?t=`1pt dashed`:e===11?t=`1pt dotted`:e===12?t=`0.5pt dashed`:e===13&&(t=`1.5pt solid`),t}function xu(e){let t=0;if(e=e.trim(),e===`none`)t=0;else if(e===`0.5pt solid`)t=1;else if(e===`0.5pt double`)t=2;else if(e===`0.5pt dotted`)t=3;else if(e===`0.5pt dashed`)t=4;else if(e===`1pt solid`)t=8;else if(e===`1pt dashed`)t=9;else if(e===`1pt dotted`)t=11;else if(e===`1.5pt solid`)t=13;else if(!e.includes(`none`))t=1;else return 0;return t}function Su(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function Cu(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===2||!(Number.isNaN(i)&&Number.isNaN(a))&&o===1||o!==1&&o!==2&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function wu(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function Tu(e){if(_u(e))return{f:e,v:null,p:null};if(so(e)){if(typeof e==`string`){let t=eu(e);if(t&&t.z)return{v:t.v,p:null,f:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null}}return io(e),e}function Eu(e,t){let n=new du,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(z.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,Tu(e[t][a]));else new du(e).forValue((e,t,r)=>{n.setValue(e,t,Tu(r))});return n.getMatrix()}function Du(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Du(e[n],t[n])):e===t:!1}function Ou(e,t){let n=e.ts||{},r=t.ts||{};if(e.sId!==t.sId||!Du(n,r))return!1;let i=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of i)if(n!==`st`&&n!==`ed`&&n!==`ts`&&n!==`sId`&&!Du(e[n],t[n]))return!1;return!0}function ku(e,t){return t.some(t=>e.indexOf(t)>-1)}let Au=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],ju=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Mu=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Nu=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Pu=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],Fu={L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`,l:`M/D/YYYY`,ll:`MMM D, YYYY`,lll:`MMM D, YYYY h:mm A`,llll:`ddd, MMM D, YYYY h:mm A`},Iu={millisecond:`millisecond`,milliseconds:`millisecond`,ms:`millisecond`,second:`second`,seconds:`second`,s:`second`,minute:`minute`,minutes:`minute`,m:`minute`,hour:`hour`,hours:`hour`,h:`hour`,day:`day`,days:`day`,d:`day`,week:`week`,weeks:`week`,w:`week`,month:`month`,months:`month`,M:`month`,year:`year`,years:`year`,y:`year`};var Lu=class e{constructor(e,t){this._date=e,this._isUTC=t}isValid(){return!Number.isNaN(this._date.getTime())}format(e=`YYYY-MM-DDTHH:mm:ssZ`){return this.isValid()?Qu(this._date,e,this._isUTC):`Invalid Date`}formatIntl(e,t={}){if(!this.isValid())return`Invalid Date`;if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)return this.format();let n=this._isUTC&&!t.timeZone?{...t,timeZone:`UTC`}:t;return new Intl.DateTimeFormat(e,n).format(this._date)}valueOf(){return this._date.getTime()}toDate(){return new Date(this.valueOf())}_clone(){return new e(this.toDate(),this._isUTC)}add(t,n=`millisecond`){let r=Uu(n);return!this.isValid()||!r||!Number.isFinite(t)?this._clone():new e(Ku(this._date,t,r,this._isUTC),this._isUTC)}subtract(e,t=`millisecond`){return this.add(-e,t)}startOf(t){let n=Uu(t);return!n||!this.isValid()?this._clone():new e(qu(this._date,n,this._isUTC),this._isUTC)}endOf(e){let t=Uu(e);return!t||!this.isValid()||t===`millisecond`?this._clone():this.startOf(t).add(1,t).subtract(1,`millisecond`)}utc(){return new e(this.toDate(),!0)}local(){return new e(this.toDate(),!1)}weekday(e){let t=(zu(this._date,this._isUTC).dayOfWeek-0+7)%7;return e===void 0?t:this.add(e-t,`day`)}week(e){let t=Ju(this._date,this._isUTC);return e===void 0?t:this.add((e-t)*7,`day`)}};function Ru(e,t=2){return String(Math.abs(e)).padStart(t,`0`)}function zu(e,t){return t?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),millisecond:e.getUTCMilliseconds(),dayOfWeek:e.getUTCDay()}:{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),dayOfWeek:e.getDay()}}function Bu(e,t){return e instanceof Lu?e.toDate():e===void 0?new Date:e===null?new Date(NaN):e instanceof Date?new Date(e.getTime()):typeof e==`number`?new Date(e):typeof e==`string`?Hu(e,t):new Date(NaN)}function Vu(e,t,n,r,i,a,o,s){let c=s?new Date(Date.UTC(e,t-1,n,r,i,a,o)):new Date(e,t-1,n,r,i,a,o),l=zu(c,s);return l.year!==e||l.month!==t||l.day!==n||l.hour!==r||l.minute!==i||l.second!==a?new Date(NaN):c}function Hu(e,t){let n=e.trim();if(!n)return new Date(NaN);let r=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})日(?:\s+(\d{1,2})(?::(\d{1,2})(?::(\d{1,2}))?)?)?$/);if(r){let[,e,n,i,a=`0`,o=`0`,s=`0`]=r;return Vu(Number(e),Number(n),Number(i),Number(a),Number(o),Number(s),0,t)}let i=n.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[ T](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?)?$/);if(i){let[,e,n,r,a=`0`,o=`0`,s=`0`,c=`0`]=i;return Vu(Number(e),Number(n),Number(r),Number(a),Number(o),Number(s),Number(c),t)}return/^-?\d+(\.\d+)?$/.test(n)?new Date(Number(n)):new Date(n)}function Uu(e){return Iu[e]??Iu[String(e).toLowerCase()]}function Wu(e,t,n){return n?new Date(Date.UTC(e,t,0)).getUTCDate():new Date(e,t,0).getDate()}function Gu(e,t,n,r){let i=new Date(e.getTime());if(t){switch(n){case`year`:i.setUTCFullYear(r);break;case`month`:i.setUTCMonth(r);break;case`day`:i.setUTCDate(r);break;case`hour`:i.setUTCHours(r);break;case`minute`:i.setUTCMinutes(r);break;case`second`:i.setUTCSeconds(r);break;case`millisecond`:i.setUTCMilliseconds(r)}return i}switch(n){case`year`:i.setFullYear(r);break;case`month`:i.setMonth(r);break;case`day`:i.setDate(r);break;case`hour`:i.setHours(r);break;case`minute`:i.setMinutes(r);break;case`second`:i.setSeconds(r);break;case`millisecond`:i.setMilliseconds(r)}return i}function Ku(e,t,n,r){switch(n){case`millisecond`:return new Date(e.getTime()+t);case`second`:return new Date(e.getTime()+t*1e3);case`minute`:return new Date(e.getTime()+t*6e4);case`hour`:return new Date(e.getTime()+t*36e5);case`day`:return Gu(e,r,`day`,(r?e.getUTCDate():e.getDate())+t);case`week`:return Gu(e,r,`day`,(r?e.getUTCDate():e.getDate())+t*7);case`month`:{let n=zu(e,r),i=Vu(n.year,n.month,1,n.hour,n.minute,n.second,n.millisecond,r),a=Gu(i,r,`month`,(r?i.getUTCMonth():i.getMonth())+t),o=zu(a,r),s=Wu(o.year,o.month,r);return Gu(a,r,`day`,Math.min(n.day,s))}case`year`:return Ku(e,t*12,`month`,r)}}function qu(e,t,n){let r=zu(e,n);switch(t){case`year`:return Vu(r.year,1,1,0,0,0,0,n);case`month`:return Vu(r.year,r.month,1,0,0,0,0,n);case`week`:{let e=(r.dayOfWeek-0+7)%7,t=Vu(r.year,r.month,r.day,0,0,0,0,n);return Gu(t,n,`day`,(n?t.getUTCDate():t.getDate())-e)}case`day`:return Vu(r.year,r.month,r.day,0,0,0,0,n);case`hour`:return Vu(r.year,r.month,r.day,r.hour,0,0,0,n);case`minute`:return Vu(r.year,r.month,r.day,r.hour,r.minute,0,0,n);case`second`:return Vu(r.year,r.month,r.day,r.hour,r.minute,r.second,0,n);default:return new Date(e.getTime())}}function Ju(e,t){let n=qu(e,`week`,t),r=qu(qu(e,`year`,t),`week`,t);return Math.floor((n.getTime()-r.getTime())/864e5/7)+1}function Yu(e,t,n=!1){if(t)return n?`+0000`:`+00:00`;let r=-e.getTimezoneOffset(),i=r>=0?`+`:`-`,a=Math.abs(r),o=Ru(Math.floor(a/60),2),s=Ru(a%60,2);return n?`${i}${o}${s}`:`${i}${o}:${s}`}function Xu(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Zu(e){return e.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g,e=>Fu[e]??e)}function Qu(e,t,n){let r=zu(e,n),i=r.hour%12,a=i===0?12:i,o=Math.ceil(r.month/3),s={YYYY:String(r.year),YY:Ru(r.year%100,2),MMMM:Au[r.month-1],MMM:ju[r.month-1],MM:Ru(r.month,2),M:String(r.month),DD:Ru(r.day,2),D:String(r.day),Do:Xu(r.day),dddd:Mu[r.dayOfWeek],ddd:Nu[r.dayOfWeek],dd:Pu[r.dayOfWeek],d:String(r.dayOfWeek),HH:Ru(r.hour,2),H:String(r.hour),hh:Ru(a,2),h:String(a),mm:Ru(r.minute,2),m:String(r.minute),ss:Ru(r.second,2),s:String(r.second),SSS:Ru(r.millisecond,3),A:r.hour>=12?`PM`:`AM`,a:r.hour>=12?`pm`:`am`,Q:String(o),Qo:Xu(o),X:String(Math.floor(e.getTime()/1e3)),x:String(e.getTime()),Z:Yu(e,n,!1),ZZ:Yu(e,n,!0)},c=[];return Zu(t.replace(/\[([^\]]+)]/g,(e,t)=>`\u0000${c.push(t)-1}\u0000`)).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g,e=>s[e]??e).replace(/\u0000(\d+)\u0000/g,(e,t)=>c[Number(t)]??``)}function $u(e){return new Lu(Bu(e,!1),!1)}let ed=Object.assign($u,{utc:e=>new Lu(Bu(e,!0),!0),isDateKit:e=>e instanceof Lu,unix:e=>$u(e*1e3)});function td(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function nd(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function rd(e){if(e==null)return!1;let t=e.paragraphStyle;return id(t)}function id(e){var t;return e!=null&&(e.indentStart!=null&&e.indentStart.v!==0||e.hanging!=null)&&((t=e.hanging)==null?void 0:t.v)!==0}function ad(e,t,n){return e.slice(0,t)+n+e.slice(t)}function od(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function sd(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t!==``&&!isNaN(Number(t))}return!1}function cd(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function ld(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function ud(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function dd(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,Object.assign({},...t)}let fd,pd,md,hd,K=Symbol(`newer`),q=Symbol(`older`);fd=Symbol.iterator;var gd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[fd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.key}):{done:!0,value:void 0}}};pd=Symbol.iterator;var _d=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[pd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.value}):{done:!0,value:void 0}}};md=Symbol.iterator;var vd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[md](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},yd=class{constructor(e,t){T(this,`key`,void 0),T(this,`value`,void 0),T(this,K,void 0),T(this,q,void 0),this.key=e,this.value=t,this[K]=void 0,this[q]=void 0}toJSON(){return{key:this.key,value:this.value}}};hd=Symbol.iterator;var bd=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),D(()=>Be(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(T(this,`_keymap`,void 0),T(this,`size`,0),T(this,`limit`,void 0),T(this,`oldest`,void 0),T(this,`newest`,void 0),T(this,`_onShiftListeners`,[]),xd.hasLength(e,1)){if(xd.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(xd.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}return}if(xd.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[K]&&(e===this.oldest&&(this.oldest=e[K]),e[K][q]=e[q]),e[q]&&(e[q][K]=e[K]),e[K]=void 0,e[q]=this.newest,this.newest&&(this.newest[K]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new yd(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[K]=r,r[q]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new yd(e,t)),this.newest?(this.newest[K]=n,n[q]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[K]?(this.oldest=this.oldest[K],this.oldest[q]=void 0):(this.oldest=void 0,this.newest=void 0),e[K]=e[q]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[K]&&t[q]?(t[q][K]=t[K],t[K][q]=t[q]):t[K]?(t[K][q]=void 0,this.oldest=t[K]):t[q]?(t[q][K]=void 0,this.newest=t[q]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new gd(this.oldest)}values(){return new _d(this.oldest)}entries(){return this[Symbol.iterator]()}[hd](){return new vd(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[K]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[K];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[K],t&&(e+=` < `);return e}},xd=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function Sd(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}function Cd(){let e=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`?crypto:typeof self<`u`&&self.crypto&&typeof self.crypto.getRandomValues==`function`?self.crypto:typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`?window.crypto:void 0;return e==null?void 0:e.getRandomValues.bind(e)}function wd(e,t){let n=``;for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Td(e,t,n){let r=256-256%t.length,i=Math.ceil(409.6*e/r),a=``;for(;a.length<e;){let o=n(new Uint8Array(i));for(let n=0;n<i&&a.length<e;n++){let e=o[n];e<r&&(a+=t[e%t.length])}}return a}function Ed(e=21,t=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`){if(!e)return``;let n=Cd();return n?Td(e,t,n):wd(e,t)}function J(e=21,t){return Ed(e,t)}function Dd(e,t,n=0,r=e.length-1,i=kd){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);Dd(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(Od(e,n,t),i(e[r],a)>0&&Od(e,n,r);o<s;){for(Od(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?Od(e,n,s):(s++,Od(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function Od(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function kd(e,t){return e<t?-1:+(e>t)}var Ad=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!Hd(e,t))return n;let r=this.toBBox,i=[];for(;t;){for(let a=0;a<t.children.length;a++){let o=t.children[a],s=t.leaf?r(o):o;Hd(e,s)&&(t.leaf?n.push(o):Vd(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n}collides(e){let t=this.data;if(!Hd(e,t))return!1;let n=[];for(;t;){for(let r=0;r<t.children.length;r++){let i=t.children[r],a=t.leaf?this.toBBox(i):i;if(Hd(e,a)){if(t.leaf||Vd(e,a))return!0;n.push(i)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Ud([]),this}remove(e,t){if(!e)return this;let n=this.data,r=this.toBBox(e),i=[],a=[],o,s,c;for(;n||i.length;){if(n||(n=i.pop(),s=i[i.length-1],o=a.pop(),c=!0),n.leaf){let r=jd(e,n.children,t);if(r!==-1)return n.children.splice(r,1),i.push(n),this._condense(i),this}!c&&!n.leaf&&Vd(n,r)?(i.push(n),a.push(o),o=0,s=n,n=n.children[0]):s?(o++,n=s.children[o],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){let i=n-t+1,a=this._maxEntries,o;if(i<=a)return o=Ud(e.slice(t,n+1)),Md(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(a)),a=Math.ceil(i/a**(r-1))),o=Ud([]),o.leaf=!1,o.height=r;let s=Math.ceil(i/a),c=s*Math.ceil(Math.sqrt(a));Wd(e,t,n,c,this.compareMinX);for(let i=t;i<=n;i+=c){let t=Math.min(i+c-1,n);Wd(e,i,t,s,this.compareMinY);for(let n=i;n<=t;n+=s){let i=Math.min(n+s-1,t);o.children.push(this._build(e,n,i,r-1))}}return Md(o,this.toBBox),o}_chooseSubtree(e,t,n,r){for(;r.push(t),!(t.leaf||r.length-1===n);){let n=1/0,r=1/0,i;for(let a=0;a<t.children.length;a++){let o=t.children[a],s=Ld(o),c=zd(e,o)-s;c<r?(r=c,n=s<n?s:n,i=o):c===r&&s<n&&(n=s,i=o)}t=i||t.children[0]}return t}_insert(e,t,n){let r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),Pd(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)}_split(e,t){let n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);let a=this._chooseSplitIndex(n,i,r),o=Ud(n.children.splice(a,n.children.length-a));o.height=n.height,o.leaf=n.leaf,Md(n,this.toBBox),Md(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)}_splitRoot(e,t){this.data=Ud([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Md(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,i=1/0,a=1/0;for(let o=t;o<=n-t;o++){let t=Nd(e,0,o,this.toBBox),s=Nd(e,o,n,this.toBBox),c=Bd(t,s),l=Ld(t)+Ld(s);c<i?(i=c,r=o,a=l<a?l:a):c===i&&l<a&&(a=l,r=o)}return r||n-t}_chooseSplitAxis(e,t,n){let r=e.leaf?this.compareMinX:Fd,i=e.leaf?this.compareMinY:Id;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);let i=this.toBBox,a=Nd(e,0,t,i),o=Nd(e,n-t,n,i),s=Rd(a)+Rd(o);for(let r=t;r<n-t;r++){let t=e.children[r];Pd(a,e.leaf?i(t):t),s+=Rd(a)}for(let r=n-t-1;r>=t;r--){let t=e.children[r];Pd(o,e.leaf?i(t):t),s+=Rd(o)}return s}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Pd(t[r],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():Md(e[t],this.toBBox)}};function jd(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Md(e,t){Nd(e,0,e.children.length,t,e)}function Nd(e,t,n,r,i){i||=Ud(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let a=t;a<n;a++){let t=e.children[a];Pd(i,e.leaf?r(t):t)}return i}function Pd(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Fd(e,t){return e.minX-t.minX}function Id(e,t){return e.minY-t.minY}function Ld(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Rd(e){return e.maxX-e.minX+(e.maxY-e.minY)}function zd(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Bd(e,t){let n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,a-r)}function Vd(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Hd(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ud(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Wd(e,t,n,r,i){let a=[t,n];for(;a.length;){if(n=a.pop(),t=a.pop(),n-t<=r)continue;let o=t+Math.ceil((n-t)/r/2)*r;Dd(e,o,t,n,i),a.push(t,o,o,n)}}var Gd=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===0||t.rangeType===void 0&&e.rangeType===0)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===1&&t.rangeType===2||e.rangeType===2&&t.rangeType===1)return!0;if(e.rangeType===1&&t.rangeType===1)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===2&&t.rangeType===2)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?1048575:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?16383:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?1048575:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?16383:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new Ad;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:0}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===2),r=t.some(e=>e.rangeType===1),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?1:n?2:0}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return Xd(e)}static splitIntoGrid(e){return Jd(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=Zd(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};T(Gd,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),T(Gd,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[1,3].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[1,3].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[2,3].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[2,3].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),T(Gd,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),T(Gd,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),T(Gd,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case 1:r.startColumn+=t;break;case 2:r.startRow+=n;break;case 3:break;default:r.startRow+=n,r.startColumn+=t}switch(e.endAbsoluteRefType){case 1:r.endColumn+=t;break;case 2:r.endRow+=n;break;case 3:break;default:r.endRow+=n,r.endColumn+=t}return r});function Kd(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||0,o=i.endAbsoluteRefType||0,s=i.rangeType||0;if(!r&&a===3&&o===3)return i;let c=qd(i.startRow,n,i.startColumn,t,s),l=qd(i.endRow,n,i.endColumn,t,s);return r||a===0&&o===0?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===0?i={...i,startRow:c.row,startColumn:c.column}:a===2?i={...i,startRow:c.row}:a===1&&(i={...i,startColumn:c.column}),o===0?i={...i,endRow:l.row,endColumn:l.column}:o===2?i={...i,endRow:l.row}:o===1&&(i={...i,endColumn:l.column}),i)}function qd(e,t,n,r,i){return i===0?{row:e+t,column:n+r}:i===1?{row:e+t,column:n}:i===2?{row:e,column:n+r}:{row:e,column:n}}function Jd(e){let t=new Set,n=new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function Yd(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function Xd(e){let t=new Map;for(let n of e)for(let[e,r]of[[n.startRow,!0],[n.endRow+1,!1]]){let i=t.get(e)??[];i.push({range:n,add:r}),t.set(e,i)}let n=[...t.keys()].sort((e,t)=>e-t),r=new Set,i=[];for(let e=0;e<n.length-1;e++){let a=n[e],o=n[e+1]-1;for(let{range:e,add:n}of t.get(a))n?r.add(e):r.delete(e);let s=[...r].sort((e,t)=>e.startColumn-t.startColumn||e.endColumn-t.endColumn),c;for(let e of s)c&&e.startColumn<=c.endColumn+1?c.endColumn=Math.max(c.endColumn,e.endColumn):(c={startRow:a,endRow:o,startColumn:e.startColumn,endColumn:e.endColumn},i.push(c))}return Yd(i)}function Zd(e,t){let n=[];return e.forEach(e=>{n.push(...Gd.subtract(e,t))}),Gd.mergeRanges(n)}function Qd(e,t){let n=$d(e.startRow,e.endRow,t.startRow,t.endRow),r=$d(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:ef(e.rangeType,t.rangeType,i,a,o,s)}}function $d(e,t,n,r){let i=Number.isNaN(e)?-1/0:e,a=Number.isNaN(t)?1/0:t,o=Number.isNaN(n)?-1/0:n,s=Number.isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function ef(e,t,n,r,i,a){let o=e===void 0?tf(n,r,i,a):e,s=t===void 0?tf(n,r,i,a):t;return o===3||s===3?o===s?o:o===3?s:o:o===s?o:0}function tf(e,t,n,r){let i=!Number.isNaN(e)&&!Number.isNaN(t),a=!Number.isNaN(n)&&!Number.isNaN(r);return i&&a?0:i?1:a?2:3}var nf=class{constructor(e,t){T(this,`_values`,[]),T(this,`_keys`,[]),T(this,`_keyMaps`,new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function rf(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function af(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function of(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function sf(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function cf(e,t=!1){let n=97;return t&&(n=65),sf(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function lf(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function uf(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function df(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}let ff=function(e){return e.Text=`text`,e.SingleSelect=`singleSelect`,e.MultiSelect=`multiSelect`,e.Person=`person`,e.Group=`group`,e.Date=`date`,e.Attachment=`attachment`,e.Number=`number`,e.Checkbox=`checkbox`,e.Link=`link`,e.Formula=`formula`,e.Numbering=`numbering`,e.Phone=`phone`,e.Email=`email`,e.Progress=`progress`,e.Currency=`currency`,e.Rating=`rating`,e.RecordLink=`recordLink`,e.RecordId=`recordId`,e.CreatedBy=`createdBy`,e.UpdatedBy=`updatedBy`,e.CreatedAt=`createdAt`,e.UpdatedAt=`updatedAt`,e}({}),pf=function(e){return e.Parent=`parent`,e}({}),mf=function(e){return e.Grid=`grid`,e.Kanban=`kanban`,e.Calendar=`calendar`,e.Gantt=`gantt`,e.Gallery=`gallery`,e.Pivot=`pivot`,e}({}),hf={CELL:`cell`,ROW:`row`,COLUMN:`column`},gf={IS:`is`,IS_NOT:`isNot`,CONTAINS:`contains`,NOT_CONTAINS:`notContains`,IS_EMPTY:`isEmpty`,IS_NOT_EMPTY:`isNotEmpty`,GREATER_THAN:`greaterThan`,LESS_THAN:`lessThan`,BEFORE:`before`,AFTER:`after`},_f={EXACT:`exact`,TODAY:`today`,TOMORROW:`tomorrow`,YESTERDAY:`yesterday`,THIS_WEEK:`thisWeek`,LAST_WEEK:`lastWeek`,THIS_MONTH:`thisMonth`,LAST_MONTH:`lastMonth`,PAST_7_DAYS:`past7`,NEXT_7_DAYS:`next7`,PAST_30_DAYS:`past30`,NEXT_30_DAYS:`next30`},vf=function(e){return e.IS=`is`,e.IS_NOT=`isNot`,e.CONTAINS=`contains`,e.NOT_CONTAINS=`notContains`,e.IS_EMPTY=`isEmpty`,e.IS_NOT_EMPTY=`isNotEmpty`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.BEFORE=`before`,e.AFTER=`after`,e}({}),yf=function(e){return e.AND=`and`,e.OR=`or`,e}({}),bf=function(e){return e.ASC=`asc`,e.DESC=`desc`,e}({}),xf=function(e){return e.MissingParent=`missingParent`,e.SelfParent=`selfParent`,e.Cycle=`cycle`,e.MaxDepth=`maxDepth`,e}({}),Sf=`__record_id`,Cf=`record-id`,wf=/^[A-Za-z0-9_-]+$/;function Tf(){return{id:Sf,name:Cf,type:`recordId`,config:{},system:!0,readonly:!0}}function Ef(e){return wf.test(e)}function Df(e){return e.trim().toLowerCase()===Cf}function Of(e){let t=e.fields[Sf],n=Object.values(e.fields).filter(e=>e.type===`recordId`);if(!t||n.length!==1||t.type!==`recordId`||t.name!==`record-id`||t.system!==!0||t.readonly!==!0||e.fieldOrder[0]!==`__record_id`||e.primaryFieldId===`__record_id`||!e.fields[e.primaryFieldId])throw Error(`[BaseDataModel]: table "${e.id}" has an invalid record-id system field.`);let r=Object.values(e.fields).find(e=>e.id!==`__record_id`&&Df(e.name));if(r)throw Error(`[BaseDataModel]: field name "${r.name}" is reserved for the record-id system field.`);for(let[t,n]of Object.entries(e.records))if(n.id!==t||!Ef(n.id)||n.values.__record_id!==n.id)throw Error(`[BaseDataModel]: record "${t}" has an invalid record-id projection.`)}function kf(e){let t=e.now??Date.now(),n=e.primaryFieldId??J(6),r=e.gridViewId??J(6),i=e.recordCount??0,a=Tf(),o={id:n,name:e.primaryFieldName??`Name`,type:`text`,config:{placeholder:`bases.fieldConfig.textPlaceholder`}},s={},c=[],l={},u={},d={};for(let n=0;n<i;n++){let r=`${e.id}-record-${n+1}`;s[r]={id:r,values:{[Sf]:r},orderKey:String(n+1).padStart(4,`0`),createdAt:t,updatedAt:t},c.push(r),l[r]=n,u[n]=r,d[n]={0:{v:r,t:1}}}let f={id:r,tableId:e.id,name:`Grid`,type:`grid`,fieldOrder:[Sf,n],fieldSettings:{[Sf]:{hidden:!0}},config:{frozenFieldCount:1}};return{id:e.id,name:e.name,primaryFieldId:n,fieldOrder:[Sf,n],fields:{[Sf]:a,[n]:o},records:s,recordOrder:c,rowIndex:l,rowId:u,colIndex:{[Sf]:0,[n]:1},colId:{0:Sf,1:n},cellData:d,resources:{attachmentSets:{},attachments:{}},views:{[r]:f},viewOrder:[r]}}function Af(e=J(),t=``,n=`zhCN`){let r=Date.now(),i=`table-1`;return{id:e,name:t,locale:n,appVersion:ze,schemaVersion:2,tableOrder:[i],tables:{[i]:kf({id:i,name:`Table 1`,now:r,recordCount:0})},createdAt:r,updatedAt:r}}var jf=class extends M{constructor(e={}){super(),T(this,`type`,n.UniverType.UNIVER_BASE),T(this,`_name$`,void 0),T(this,`name$`,void 0),T(this,`_snapshot`,void 0);let r=Af();this._snapshot=Mf(z.commonExtend(r,e)),this._snapshot.id||(this._snapshot.id=`base-${Math.random().toString(36).slice(2,10)}`),this._name$=new t.BehaviorSubject(this._snapshot.name),this.name$=this._name$.asObservable()}getUnitId(){return this._snapshot.id}setName(e){this._snapshot.name=e,this._snapshot.updatedAt=Date.now(),this._name$.next(e)}getSnapshot(){return this._snapshot}checkTableName(e){return Object.values(this._snapshot.tables).some(t=>t.name.toLowerCase()===e.toLowerCase())}uniqueTableName(e){let t=e,n=1;for(;this.checkTableName(t);)t=`${e}${n}`,n++;return t}setSnapshot(e){this._snapshot=Nf(e)?e:Mf(e),this._name$.next(e.name)}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}dispose(){super.dispose(),this._name$.complete()}};function Mf(e){return delete e.compress,delete e.kind,Object.values(e.tables??{}).forEach(e=>{Of(e),Ff(e),Wf(e)}),e}function Nf(e){return Object.values(e.tables??{}).every(e=>Pf(e))}function Pf(e){let t=e.records??{},n=e.fields??{};if(Of(e),!Array.isArray(e.recordOrder)||!e.rowIndex||!e.rowId||!e.colIndex||!e.colId||!e.cellData||!e.resources||!e.resources.attachmentSets||!e.resources.attachments||Object.keys(t).length!==e.recordOrder.length)return!1;for(let n=0;n<e.recordOrder.length;n++){var r;let i=e.recordOrder[n];if(!t[i]||e.rowIndex[i]!==n||e.rowId[n]!==i||((r=e.cellData[n])==null||(r=r[0])==null?void 0:r.v)!==i)return!1}for(let t=0;t<e.fieldOrder.length;t++){let r=e.fieldOrder[t];if(n[r]&&(e.colIndex[r]!==t||e.colId[t]!==r))return!1}return!0}function Ff(e){If(e);let t=e.records??{},n=e.fields??{},r=Lf(e,t),i=Rf(e,n);e.recordOrder=r,zf(e),Bf(e,n),Vf(e,t,r),Hf(e,n,i),Uf(e,t,n)}function If(e){let t=e.cd;t&&!e.cellData&&(e.cellData=Object.create(null),t.forEach(([t,n,r])=>{e.cellData[t]=e.cellData[t]??{};let{c:i,...a}=r;e.cellData[t][n]=a}),delete e.cd)}function Lf(e,t){var n;let r=((n=e.recordOrder)==null?void 0:n.filter(e=>t[e]))??[],i=new Set(r),a=Object.values(t).filter(e=>!i.has(e.id));return a.length?[...r,...a.sort((e,t)=>e.orderKey.localeCompare(t.orderKey)).map(e=>e.id)]:r}function Rf(e,t){return e.fieldOrder.filter(e=>t[e])}function zf(e){e.rowIndex={...e.rowIndex},e.rowId={...e.rowId},e.colIndex={...e.colIndex},e.colId={...e.colId},e.cellData={...e.cellData},e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments}}function Bf(e,t){Object.entries(e.cellData??{}).forEach(([n,r])=>{let i=Number(n);e.cellData[i]={...r},Object.entries(e.cellData[i]??{}).forEach(([n,r])=>{var a;let o=Number(n),s=(a=e.colId)==null?void 0:a[o];e.cellData[i][o]=Kf(r,s?t[s]:void 0)})})}function Vf(e,t,n){n.forEach((t,n)=>{e.rowIndex[t]??(e.rowIndex[t]=n)}),Object.entries(e.rowIndex??{}).forEach(([n,r])=>{t[n]&&(e.rowId[r]=n)})}function Hf(e,t,n){n.forEach((t,n)=>{e.colIndex[t]??(e.colIndex[t]=n)}),Object.entries(e.colIndex??{}).forEach(([n,r])=>{t[n]&&(e.colId[r]=n)})}function Uf(e,t,n){let r=e.rowIndex??{},i=e.colIndex??{},a=e.cellData??{};e.rowIndex=r,e.colIndex=i,e.cellData=a,Object.values(t).forEach(t=>{let o=r[t.id];o!=null&&(a[o]={...a[o]},a[o][0]={v:t.id,t:1},Object.entries(t.values??{}).forEach(([r,s])=>{let c=n[r];(c==null?void 0:c.type)===`attachment`&&Jf(e,t.id,r,s);let l=i[r];if(l==null)return;let u=a[o][l];if(u!=null){a[o][l]=Kf(u,c),Xf(u,c,s)&&(a[o][l]=Gf(s,c));return}a[o][l]=Gf(s,c)}))})}function Wf(e){for(let a of Object.values(e.records)){var t,n,r,i;let o=(t=e.rowIndex)==null?void 0:t[a.id];if(o==null||((n=e.colIndex)==null?void 0:n.__record_id)!==0||((r=e.colId)==null?void 0:r[0])!==`__record_id`||((i=e.cellData)==null||(i=i[o])==null||(i=i[0])==null?void 0:i.v)!==a.id)throw Error(`[BaseDataModel]: record "${a.id}" is missing its record-id cell projection.`)}}function Gf(e,t){if(qf(e))return(t==null?void 0:t.type)===`attachment`?{...e,v:``,t:1}:Kf(e,t);if((t==null?void 0:t.type)===`attachment`)return{v:``,t:1};if(Zf(t))return{v:Qf(e).join(`, `),t:1};if((t==null?void 0:t.type)===`link`&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return{v:String(t.text??t.url??``),t:1}}return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?{v:e,t:ep(e)}:{v:null,t:null}}function Kf(e,t){let n=tp(e.t,e.v);if(n===void 0){let{t,...n}=e;return n}return{...e,t:n}}function qf(e){return!!e&&typeof e==`object`&&(Object.prototype.hasOwnProperty.call(e,`v`)||Object.prototype.hasOwnProperty.call(e,`t`)||Object.prototype.hasOwnProperty.call(e,`p`)||Object.prototype.hasOwnProperty.call(e,`f`)||Object.prototype.hasOwnProperty.call(e,`si`))}function Jf(e,t,n,r){let i=Yf(r);e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments};let a=`${n}${t}`;e.resources.attachmentSets[a]=i.map((t,n)=>{let r=String(t.id??`${a}${n}`),i={...t,id:r};return e.resources.attachments[r]=i,r})}function Yf(e){if(e==null||e===``||qf(e)&&!(`id`in e)&&!(`name`in e))return[];let t=Array.isArray(e)?e:[e],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`){let e={...r};Object.keys(e).length>0&&n.push(e);continue}n.push({id:`attachment-${e}`,name:String(r)})}return n}function Xf(e,t,n){return(t==null?void 0:t.type)===`recordId`?e.v!==n:(t==null?void 0:t.type)===`attachment`?e.v!==``:Zf(t)?Array.isArray(n)&&(e.v==null||e.v===``):!1}function Zf(e){return(e==null?void 0:e.type)===`multiSelect`||(e==null?void 0:e.type)===`person`||(e==null?void 0:e.type)===`group`}function Qf(e){if(e==null||e===``)return[];let t=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++){let r=$f(e[n]);r&&t.push(r)}return t}let n=String(e).split(`,`);for(let e=0;e<n.length;e++){let r=n[e].trim();r&&t.push(r)}return t}function $f(e){if(e==null)return``;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`){let t=e;return String(t.id??t.name??t.text??``)}return String(e)}function ep(e){return e==null?null:typeof e==`number`?2:typeof e==`boolean`?3:1}function tp(e,t){return e===1||e===2||e===3||e===4||e==null?e:ep(t??null)}function np(e){let t=e.trim().replace(/[^A-Za-z0-9_.]+/g,`_`),n=/[A-Za-z0-9]/.test(t)?t:`Table`,r=/^[A-Za-z_]/.test(n)?n:`_${n}`;return(/^[RC]$/i.test(r)||/^[A-Za-z]{1,3}[1-9]\d*$/.test(r)||/^R(?:\d+)?C(?:\d+)?$/i.test(r)?`_${r}`:r).slice(0,255)}function rp(e){let t=new Map,n=new Set,r=new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let r=fp(e.formulaName);r&&!n.has(r.toLowerCase())&&(n.add(r.toLowerCase()),t.set(e.id,r))}for(let e of i){if(t.has(e.id))continue;let i=ap(e.name,n,e.formulaName,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function ip(e,t,n){return ap(e,new Set(Array.from(t,e=>e.toLowerCase())),n)}function ap(e,t,n,r=new Map){let i=fp(n);if(i&&!t.has(i.toLowerCase()))return i;let a=np(e),o=a.toLowerCase();if(!t.has(o))return a;let s=r.get(o)??2;for(;;){let e=`_${s++}`,n=`${a.slice(0,255-e.length)}${e}`;if(!t.has(n.toLowerCase()))return r.set(o,s),n}}function op(e,t){return rp(t).get(e.id)??np(e.name)}function sp(e,t){return cp(t)(e)}function cp(e,t=rp(e)){let n=hp(up(e,t));return e=>_p(e,n)}function lp(e){let t=rp(e),n=cp(e,t);for(let n of Object.values(e.tables))n.formulaName=t.get(n.id)??np(n.name);for(let t of Object.values(e.tables)){for(let e of Object.values(t.fields)){var r;e.type===`formula`&&typeof((r=e.config)==null?void 0:r.formula)==`string`&&(e.config.formula=n(e.config.formula))}for(let e of Object.values(t.cellData??{}))for(let t of Object.values(e??{}))t&&typeof t.f==`string`&&(t.f=n(t.f))}}function up(e,t=rp(e)){let n=dp(e),r=new Map(Array.from(t,([e,t])=>[t.toLowerCase(),e])),i=new Map;for(let t of Object.values(e.tables)){let e=t.name.toLowerCase();i.set(e,(i.get(e)??0)+1)}return Object.values(e.tables).flatMap(e=>{let a=t.get(e.id)??np(e.name),o=[e.id,gp(e.id),n.get(e.id),e.formulaName];return i.get(e.name.toLowerCase())===1&&o.push(e.name),o.filter(e=>!!e).flatMap(e=>[e,pp(e)]).filter(e=>!!e).filter(e=>e.toLowerCase()!==a.toLowerCase()).filter(t=>{let n=r.get(mp(t).toLowerCase());return n==null||n===e.id}).map(e=>({alias:e,formulaName:a}))}).sort((e,t)=>t.alias.length-e.alias.length)}function dp(e){let t=new Map,n=new Set,r=new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let i=ap(e.name,n,void 0,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function fp(e){let t=e==null?void 0:e.trim();return t&&np(t)===t?t:void 0}function pp(e){return/[^A-Za-z0-9_.]/.test(e)?`'${e.replaceAll(`'`,`''`)}'`:void 0}function mp(e){return e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1).replaceAll(`''`,`'`):e}function hp(e){let t=new Map;for(let{alias:n,formulaName:r}of e){let e=n.toLowerCase();t.has(e)||t.set(e,r)}let n=Array.from(t.keys()).sort((e,t)=>t.length-e.length);return{formulaNameByAlias:t,pattern:n.length?RegExp(`(${n.map(vp).join(`|`)})(\\s*)\\[`,`gi`):void 0}}function gp(e){return`_T_${Array.from(e,e=>{var t;return/[A-Za-z0-9]/.test(e)?e:`_x${((t=e.codePointAt(0))==null?void 0:t.toString(16))??`0`}_`}).join(``)}`}function _p(e,t){if(!t.pattern)return e;let n=0,r=!1;return t.pattern.lastIndex=0,e.replace(t.pattern,(i,a,o,s)=>{r=yp(e,n,s,r),n=s;let c=e[s-1];if(c!=null&&/[A-Za-z0-9_.]/.test(c)||c===`!`||r)return i;let l=t.formulaNameByAlias.get(a.toLowerCase());return l?`${l}${o}[`:i})}function vp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function yp(e,t,n,r){let i=r;for(let r=t;r<n;r++)if(e[r]===`"`){if(i&&e[r+1]===`"`){r++;continue}i=!i}return i}var bp=f(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,this.maxPending=e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)f(!1,Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),xp=h(f(((e,t)=>{t.exports=bp()}))());let Sp=new Set([`true`,`false`]);function Cp(e){return Sp.has(e.toLowerCase())}let wp=`__INTERNAL_EDITOR__`,Tp=`${wp}DOCS_NORMAL`,Ep=`${wp}DOCS_FORMULA_BAR`,Dp=`${wp}COMMENT_EDITOR`,Op=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`);function kp(e){return`${wp}${e}`}function Ap(e){return e.startsWith(wp)}function jp(e){return e.startsWith(Dp)}let Mp=function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Np=function(e){return e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e[e.DRAWING_IMAGE=0]=`DRAWING_IMAGE`,e[e.DRAWING_SHAPE=1]=`DRAWING_SHAPE`,e[e.DRAWING_CHART=2]=`DRAWING_CHART`,e[e.DRAWING_TABLE=3]=`DRAWING_TABLE`,e[e.DRAWING_SMART_ART=4]=`DRAWING_SMART_ART`,e[e.DRAWING_VIDEO=5]=`DRAWING_VIDEO`,e[e.DRAWING_GROUP=6]=`DRAWING_GROUP`,e[e.DRAWING_UNIT=7]=`DRAWING_UNIT`,e[e.DRAWING_DOM=8]=`DRAWING_DOM`,e[e.DRAWING_BLOCK=9]=`DRAWING_BLOCK`,e[e.DRAWING_SLICER=10]=`DRAWING_SLICER`,e[e.DRAWING_TIMELINE=11]=`DRAWING_TIMELINE`,e}({});function Pp(e,t){let n=Math.max(0,t-1);return Math.max(0,Math.min(Math.floor(e),n))||0}function Fp(e,t,n){let r=Pp(e,t);return n===2?Pp(t-1,t):n===0?Pp(r+1,t):n===1?Pp(r-1,t):0}function Ip(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}function Lp(){}function Rp(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(r&&=(clearTimeout(r),null),n=a,e.apply(this,i))}}let zp=function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function Bp(e){return`sheet_interceptor_${e}`}let Vp=e=>function(t,n){let r=-1,i=t,a=!1,o=e=>(a=!0,e);for(let t=0;t<e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);r=t;let s=e[t];if(a=!1,i=s.handler(i,n,o),!a)break}return i};var Hp=class{constructor(e){T(this,`_interceptorsByName`,new Map),T(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){let n=e,r=this._interceptorsByName.get(n);return t&&(r=r.filter(t)),Vp(r||[])}intercept(e,t){let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);return r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0))),()=>Be(this._interceptorsByName.get(n),t)}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear()}};function Up(e){return`sheet_async_interceptor_${e}`}let Wp=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var Gp=class{constructor(e){T(this,`_asyncInterceptorsByName`,new Map),T(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){let n=e,r=this._asyncInterceptorsByName.get(n);return t&&(r=r.filter(t)),Wp(r||[])}async interceptAsync(e,t){let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);return r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0))),()=>Be(this._asyncInterceptorsByName.get(n),t)}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear()}};function Kp(e){return e.map(e=>e/255)}function qp(e){return e.map(e=>Math.round(e*255))}function Jp([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4}o/=6}return[o,s,a]}function Yp(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Xp(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Zp(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}let Qp={r:1,g:1,b:1},$p={r:0,g:0,b:0},em=Yp(Qp.r,Qp.g,Qp.b),tm=Yp($p.r,$p.g,$p.b);function nm(e){let t=Yp(e[0],e[1],e[2]),n=Xp(em,t),r=Jp(e),i=1-r[2],a,o,s;do a=Zp(r[0],r[1],i),o=Yp(a[0],a[1],a[2]),s=Xp(o,tm),i+=.01;while(i<=1&&i>=0&&Math.abs(s-n)<.01);return a}function rm(e){return qp(nm(Kp(e)))}let im=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function am(e){let t=e[0],n=e[1],r=e[2],i=[im[0][0]*t+im[0][1]*n+im[0][2]*r+im[0][4],im[1][0]*t+im[1][1]*n+im[1][2]*r+im[1][4],im[2][0]*t+im[2][1]*n+im[2][2]*r+im[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function om(e){return qp(am(Kp(e)))}var sm=class{constructor(){T(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function cm(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function lm(e){return/^-?\d+(\.\d+)?$/.test(e)}function um(e){return lm(e)?Number(e)<=2**53-1:!1}function dm(e){return Number(e)>2**53-1||e.length>=18}var fm=class e{constructor(){T(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},pm=class e{constructor(){T(this,`_data`,new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function mm(e){let t=new MessageChannel,n=!1,r=()=>{t.port1.onmessage=null,t.port1.close(),t.port2.close()},i=()=>{n||(n=!0,r(),e())};return t.port1.onmessage=i,t.port2.postMessage(null),()=>{n||(n=!0,r())}}function hm(e,t){return t.forEach(t=>e.add(t)),e}let gm=`section_`;function _m(e){let t=`${gm}${J(12)}`;for(;e.has(t);)t=`${gm}${J(12)}`;return e.add(t),t}function vm(e,t,n=!0){let r=z.deepClone(e);return n&&ym(r.sectionId)&&!t.has(r.sectionId)?(t.add(r.sectionId),r):(r.sectionId=_m(t),r)}function ym(e){return typeof e==`string`&&e.startsWith(`section_`)&&e.length>8}let bm=function(e){return e.PARAGRAPH=`PARAGRAPH`,e.SECTION_BREAK=`SECTION_BREAK`,e.TABLE=`TABLE`,e.TABLE_ROW=`TABLE_ROW`,e.TABLE_CELL=`TABLE_CELL`,e.COLUMN_GROUP=`COLUMN_GROUP`,e.COLUMN=`COLUMN`,e.BLOCK=`BLOCK`,e.CUSTOM_BLOCK=`CUSTOM_BLOCK`,e}({}),xm=function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
2
+ `,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.COLUMN_GROUP_START=``,e.COLUMN_START=``,e.COLUMN_END=``,e.COLUMN_GROUP_END=``,e.BLOCK_START=``,e.BLOCK_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({}),Sm=new Set([`\r`,`
3
+ `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\v`,`\f`,`\0`,`\b`]),Cm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Bopomofo}\u3000-\u303F\uFF00-\uFFEF]/u,wm=/\p{Script=Hangul}/u,Tm=2e4;function Em(){return{words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0}}function Dm(e){if(e!=null&&e.aborted)throw Error(`Document statistics calculation aborted`)}function Om(e){return Dm(e),new Promise(e=>{setTimeout(e,0)})}function km(e,t){if(!(t!=null&&t.length))return[e];let n=t.filter(e=>!e.collapsed).map(t=>({startOffset:Math.max(0,Math.min(t.startOffset,t.endOffset)),endOffset:Math.min(e.length,Math.max(t.startOffset,t.endOffset))})).filter(e=>e.startOffset<e.endOffset).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),r=[];for(let e of n){let t=r.at(-1);t&&e.startOffset<=t.endOffset?t.endOffset=Math.max(t.endOffset,e.endOffset):r.push({...e})}return r.map(t=>e.slice(t.startOffset,t.endOffset))}function Am(e){return Array.from(e).every(e=>Sm.has(e))}async function jm(e,t){let{locale:n,ranges:r,signal:i}=t,a=n==null?void 0:xe[n].tag,o=new Intl.Segmenter(a,{granularity:`grapheme`}),s=new Intl.Segmenter(a,{granularity:`word`}),c=Em();await Om(i),Dm(i);for(let t of km(e,r)){let e=0,n=!1;for(let{segment:r}of o.segment(t))Dm(i),r.includes(`\r`)&&(n&&(c.paragraphs+=1),n=!1),Am(r)||(c.charactersWithSpaces+=1,/^\s+$/u.test(r)||(c.charactersWithoutSpaces+=1,n=!0),Cm.test(r)&&(c.asianCharactersAndKoreanWords+=1)),e+=r.length,e>=Tm&&(e=0,await Om(i));let r=0;for(let e of s.segment(t))Dm(i),e.isWordLike&&!Cm.test(e.segment)&&(wm.test(e.segment)?c.asianCharactersAndKoreanWords+=1:c.nonAsianWords+=1),r+=e.segment.length,r>=Tm&&(r=0,await Om(i))}return Dm(i),c.words=c.nonAsianWords+c.asianCharactersAndKoreanWords,c}let Mm=function(e){return e.PARAGRAPH=`paragraph`,e.BLOCK_RANGE=`blockRange`,e.TABLE=`table`,e.CUSTOM_BLOCK=`customBlock`,e.COLUMN_GROUP=`columnGroup`,e}({}),Nm=function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),Pm=function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),Fm=function(e){return e[e.BULLET=0]=`BULLET`,e[e.NONE=1]=`NONE`,e[e.DECIMAL=2]=`DECIMAL`,e[e.DECIMAL_ZERO=3]=`DECIMAL_ZERO`,e[e.UPPER_LETTER=4]=`UPPER_LETTER`,e[e.LOWER_LETTER=5]=`LOWER_LETTER`,e[e.UPPER_ROMAN=6]=`UPPER_ROMAN`,e[e.LOWER_ROMAN=7]=`LOWER_ROMAN`,e[e.ORDINAL=8]=`ORDINAL`,e[e.CARDINAL_TEXT=9]=`CARDINAL_TEXT`,e[e.ORDINAL_TEXT=10]=`ORDINAL_TEXT`,e[e.HEX=11]=`HEX`,e[e.CHICAGO=12]=`CHICAGO`,e[e.IDEOGRAPH_DIGITAL=13]=`IDEOGRAPH_DIGITAL`,e[e.JAPANESE_COUNTING=14]=`JAPANESE_COUNTING`,e[e.AIUEO=15]=`AIUEO`,e[e.IROHA=16]=`IROHA`,e[e.DECIMAL_FULL_WIDTH=17]=`DECIMAL_FULL_WIDTH`,e[e.DECIMAL_HALF_WIDTH=18]=`DECIMAL_HALF_WIDTH`,e[e.JAPANESE_LEGAL=19]=`JAPANESE_LEGAL`,e[e.JAPANESE_DIGITAL_TEN_THOUSAND=20]=`JAPANESE_DIGITAL_TEN_THOUSAND`,e[e.DECIMAL_ENCLOSED_CIRCLE=21]=`DECIMAL_ENCLOSED_CIRCLE`,e[e.DECIMAL_FULL_WIDTH2=22]=`DECIMAL_FULL_WIDTH2`,e[e.AIUEO_FULL_WIDTH=23]=`AIUEO_FULL_WIDTH`,e[e.IROHA_FULL_WIDTH=24]=`IROHA_FULL_WIDTH`,e[e.GANADA=25]=`GANADA`,e[e.CHOSUNG=26]=`CHOSUNG`,e[e.DECIMAL_ENCLOSED_FULLSTOP=27]=`DECIMAL_ENCLOSED_FULLSTOP`,e[e.DECIMAL_ENCLOSED_PAREN=28]=`DECIMAL_ENCLOSED_PAREN`,e[e.DECIMAL_ENCLOSED_CIRCLE_CHINESE=29]=`DECIMAL_ENCLOSED_CIRCLE_CHINESE`,e[e.IDEOGRAPH_ENCLOSED_CIRCLE=30]=`IDEOGRAPH_ENCLOSED_CIRCLE`,e[e.IDEOGRAPH_TRADITIONAL=31]=`IDEOGRAPH_TRADITIONAL`,e[e.IDEOGRAPH_ZODIAC=32]=`IDEOGRAPH_ZODIAC`,e[e.IDEOGRAPH_ZODIAC_TRADITIONAL=33]=`IDEOGRAPH_ZODIAC_TRADITIONAL`,e[e.TAIWANESE_COUNTING=34]=`TAIWANESE_COUNTING`,e[e.IDEOGRAPH_LEGAL_TRADITIONAL=35]=`IDEOGRAPH_LEGAL_TRADITIONAL`,e[e.TAIWANESE_COUNTING_THOUSAND=36]=`TAIWANESE_COUNTING_THOUSAND`,e[e.TAIWANESE_DIGITAL=37]=`TAIWANESE_DIGITAL`,e[e.CHINESE_COUNTING=38]=`CHINESE_COUNTING`,e[e.CHINESE_LEGAL_SIMPLIFIED=39]=`CHINESE_LEGAL_SIMPLIFIED`,e[e.CHINESE_COUNTING_THOUSAND=40]=`CHINESE_COUNTING_THOUSAND`,e[e.KOREAN_DIGITAL=41]=`KOREAN_DIGITAL`,e[e.KOREAN_COUNTING=42]=`KOREAN_COUNTING`,e[e.KOREAN_LEGAL=43]=`KOREAN_LEGAL`,e[e.KOREAN_DIGITAL2=44]=`KOREAN_DIGITAL2`,e[e.VIETNAMESE_COUNTING=45]=`VIETNAMESE_COUNTING`,e[e.RUSSIAN_LOWER=46]=`RUSSIAN_LOWER`,e[e.RUSSIAN_UPPER=47]=`RUSSIAN_UPPER`,e[e.NUMBER_IN_DASH=48]=`NUMBER_IN_DASH`,e[e.HEBREW1=49]=`HEBREW1`,e[e.HEBREW2=50]=`HEBREW2`,e[e.ARABIC_ALPHA=51]=`ARABIC_ALPHA`,e[e.ARABIC_ABJAD=52]=`ARABIC_ABJAD`,e[e.HINDI_VOWELS=53]=`HINDI_VOWELS`,e[e.HINDI_CONSONANTS=54]=`HINDI_CONSONANTS`,e[e.HINDI_NUMBERS=55]=`HINDI_NUMBERS`,e[e.HINDI_COUNTING=56]=`HINDI_COUNTING`,e[e.THAI_LETTERS=57]=`THAI_LETTERS`,e[e.THAI_NUMBERS=58]=`THAI_NUMBERS`,e[e.THAI_COUNTING=59]=`THAI_COUNTING`,e[e.CUSTOM=60]=`CUSTOM`,e}({}),Im=function(e){return e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]=`BULLET_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e[e.BOTH=4]=`BOTH`,e}({}),Lm=function(e){return e.CALLOUT=`callout`,e.QUOTE=`quote`,e.CODE=`code`,e}({}),Rm=function(e){return e[e.HYPERLINK=0]=`HYPERLINK`,e[e.FIELD=1]=`FIELD`,e[e.SDT=2]=`SDT`,e[e.BOOKMARK=3]=`BOOKMARK`,e[e.COMMENT=4]=`COMMENT`,e[e.CUSTOM=5]=`CUSTOM`,e[e.MENTION=6]=`MENTION`,e[e.UNI_FORMULA=7]=`UNI_FORMULA`,e[e.FOOTNOTE=8]=`FOOTNOTE`,e[e.ENDNOTE=9]=`ENDNOTE`,e[e.DELTED=9999]=`DELTED`,e}({}),zm=function(e){return e.COLUMN=`column`,e.TEXT_WRAPPING=`textWrapping`,e}({}),Bm=function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),Vm=function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),Hm=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e[e.DRAWINGML=3]=`DRAWINGML`,e}({}),Um=function(e){return e[e.DEFAULT=0]=`DEFAULT`,e[e.LINES=1]=`LINES`,e[e.LINES_AND_CHARS=2]=`LINES_AND_CHARS`,e[e.SNAP_TO_CHARS=3]=`SNAP_TO_CHARS`,e}({}),Wm=function(e){return e[e.SECTION_TYPE_UNSPECIFIED=0]=`SECTION_TYPE_UNSPECIFIED`,e[e.CONTINUOUS=1]=`CONTINUOUS`,e[e.NEXT_COLUMN=2]=`NEXT_COLUMN`,e[e.NEXT_PAGE=3]=`NEXT_PAGE`,e[e.EVEN_PAGE=4]=`EVEN_PAGE`,e[e.ODD_PAGE=5]=`ODD_PAGE`,e}({}),Gm=function(e){return e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]=`COLUMN_SEPARATOR_STYLE_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.BETWEEN_EACH_COLUMN=2]=`BETWEEN_EACH_COLUMN`,e}({}),Km=function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),qm=function(e){return e[e.TEXT_RUN=0]=`TEXT_RUN`,e[e.AUTO_TEXT=1]=`AUTO_TEXT`,e[e.PAGE_BREAK=2]=`PAGE_BREAK`,e[e.COLUMN_BREAK=3]=`COLUMN_BREAK`,e[e.FOOT_NOTE_REFERENCE=4]=`FOOT_NOTE_REFERENCE`,e[e.HORIZONTAL_RULE=5]=`HORIZONTAL_RULE`,e[e.EQUATION=6]=`EQUATION`,e[e.DRAWING=7]=`DRAWING`,e[e.PERSON=8]=`PERSON`,e[e.RICH_LINK=9]=`RICH_LINK`,e}({}),Jm=function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),Ym=function(e){return e[e.INLINE=0]=`INLINE`,e[e.WRAP_NONE=1]=`WRAP_NONE`,e[e.WRAP_POLYGON=2]=`WRAP_POLYGON`,e[e.WRAP_SQUARE=3]=`WRAP_SQUARE`,e[e.WRAP_THROUGH=4]=`WRAP_THROUGH`,e[e.WRAP_TIGHT=5]=`WRAP_TIGHT`,e[e.WRAP_TOP_AND_BOTTOM=6]=`WRAP_TOP_AND_BOTTOM`,e}({}),Xm=function(e){return e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]=`NAMED_STYLE_TYPE_UNSPECIFIED`,e[e.NORMAL_TEXT=1]=`NORMAL_TEXT`,e[e.TITLE=2]=`TITLE`,e[e.SUBTITLE=3]=`SUBTITLE`,e[e.HEADING_1=4]=`HEADING_1`,e[e.HEADING_2=5]=`HEADING_2`,e[e.HEADING_3=6]=`HEADING_3`,e[e.HEADING_4=7]=`HEADING_4`,e[e.HEADING_5=8]=`HEADING_5`,e}({}),Zm=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),Qm=function(e){return e[e.DASH_STYLE_UNSPECIFIED=0]=`DASH_STYLE_UNSPECIFIED`,e[e.SOLID=1]=`SOLID`,e[e.DOT=2]=`DOT`,e[e.DASH=3]=`DASH`,e}({}),$m=function(e){return e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]=`TAB_STOP_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e}({}),eh=function(e){return e[e.TAB_STOP_LEADER_UNSPECIFIED=0]=`TAB_STOP_LEADER_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.DOT=2]=`DOT`,e[e.HYPHEN=3]=`HYPHEN`,e[e.UNDERSCORE=4]=`UNDERSCORE`,e[e.HEAVY=5]=`HEAVY`,e[e.MIDDLE_DOT=6]=`MIDDLE_DOT`,e}({}),th=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),nh=function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),rh=function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),ih=function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),ah=function(e){return e.FIXED=`fixed`,e.AUTO=`auto`,e}({}),oh=function(e){return e.STACK=`stack`,e.SHRINK=`shrink`,e}({}),sh=function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),ch=function(e){return e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]=`CONTENT_ALIGNMENT_UNSPECIFIED`,e[e.BOTH=1]=`BOTH`,e[e.TOP=2]=`TOP`,e[e.CENTER=3]=`CENTER`,e[e.BOTTOM=4]=`BOTTOM`,e}({}),lh=function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),uh=function(e){return e[e.PAGE=0]=`PAGE`,e[e.COLUMN=1]=`COLUMN`,e[e.CHARACTER=2]=`CHARACTER`,e[e.MARGIN=3]=`MARGIN`,e[e.INSIDE_MARGIN=4]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=5]=`OUTSIDE_MARGIN`,e[e.LEFT_MARGIN=6]=`LEFT_MARGIN`,e[e.RIGHT_MARGIN=7]=`RIGHT_MARGIN`,e}({}),dh=function(e){return e[e.PAGE=0]=`PAGE`,e[e.PARAGRAPH=1]=`PARAGRAPH`,e[e.LINE=2]=`LINE`,e[e.MARGIN=3]=`MARGIN`,e[e.TOP_MARGIN=4]=`TOP_MARGIN`,e[e.BOTTOM_MARGIN=5]=`BOTTOM_MARGIN`,e[e.INSIDE_MARGIN=6]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=7]=`OUTSIDE_MARGIN`,e}({}),fh=function(e){return e[e.POINT=0]=`POINT`,e[e.LINE=1]=`LINE`,e[e.CHARACTER=2]=`CHARACTER`,e[e.PIXEL=3]=`PIXEL`,e[e.PERCENT=4]=`PERCENT`,e}({}),ph=function(e){return e[e.CENTER=0]=`CENTER`,e[e.INSIDE=1]=`INSIDE`,e[e.LEFT=2]=`LEFT`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.RIGHT=4]=`RIGHT`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTE=6]=`DISTRIBUTE`,e}({}),mh=function(e){return e[e.BOTTOM=0]=`BOTTOM`,e[e.CENTER=1]=`CENTER`,e[e.INSIDE=2]=`INSIDE`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.TOP=4]=`TOP`,e}({}),hh=function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),gh=function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),_h=function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({}),vh=[`A3`,`A4`,`A5`,`B4`,`B5`,`Letter`,`Tabloid`,`Legal`,`Statement`,`Executive`,`Folio`];function yh(){return e=>e}let bh=yh()([`s`,`c`,`cl`,`t`]),xh=yh()([`rgb`,`th`]),Sh=yh()([`s`,`cl`]),Ch=yh()([`t`,`r`,`b`,`l`,`tl_br`,`tl_bc`,`tl_mr`,`bl_tr`,`ml_tr`,`bc_tr`]),wh=yh()([`a`,`v`]),Th=yh()([`t`,`r`,`b`,`l`]),Eh=yh()([`ff`,`eastAsiaFontFamily`,`fs`,`it`,`bl`,`ul`,`bbl`,`st`,`ol`,`bg`,`bd`,`cl`,`va`,`n`,`stf`,`tr`,`td`,`ht`,`vt`,`tb`,`pd`]),Dh={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Oh={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},kh={startRow:0,startColumn:0,endRow:0,endColumn:0},Ah={row:0,column:0},Y={ff:`Arial`,fs:11,it:0,bl:0,ul:{s:0},st:{s:0},ol:{s:0},tr:{a:0,v:0},td:0,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:0,vt:0,tb:0,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},jh=[Tp,Ep],Mh={4:{fs:20,bl:1},5:{fs:18,bl:1},6:{fs:16,bl:1},7:{fs:14,bl:1},8:{fs:12,bl:1},1:null,2:{fs:26,bl:1},3:{fs:15,cl:{rgb:`#999999`}},0:null},Nh=1.5,Ph={4:{spaceAbove:{v:20},spaceBelow:{v:10}},5:{spaceAbove:{v:18},spaceBelow:{v:10}},6:{spaceAbove:{v:16},spaceBelow:{v:10}},7:{spaceAbove:{v:14},spaceBelow:{v:8}},8:{spaceAbove:{v:12},spaceBelow:{v:8}},1:{spaceAbove:{v:0},spaceBelow:{v:12}},2:{spaceAbove:{v:0},spaceBelow:{v:7}},3:{spaceAbove:{v:0},spaceBelow:{v:16}},0:null},Fh=function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({}),Ih={A3:{width:1123,height:1587},A4:{width:794,height:1124},A5:{width:559,height:794},B4:{width:944,height:1344},B5:{width:665,height:944},Executive:{width:696,height:1008},Folio:{width:816,height:1248},Legal:{width:816,height:1344},Letter:{width:816,height:1056},Statement:{width:528,height:816},Tabloid:{width:1056,height:1632}},Lh=function(e){return e.NARROW=`narrow`,e.MEDIUM=`medium`,e.WIDE=`wide`,e}({}),Rh={narrow:Ih.A4.width,medium:960,wide:Ih.A3.width},zh=`para_`;function Bh(e){let t=`${zh}${J(12)}`;for(;e.has(t);)t=`${zh}${J(12)}`;return e.add(t),t}function Vh(e,t){let n=Wh(e),r=new Set;for(let e of n.paragraphs??[])e.paragraphId=Bh(r);return n}function Hh(e,t,n){let r=Gh(e);return n!==!1&&Uh(r.paragraphId)&&!t.has(r.paragraphId)?(t.add(r.paragraphId),r):(r.paragraphId=Bh(t),r)}function Uh(e){return typeof e==`string`&&e.startsWith(`para_`)&&e.length>5}function Wh(e){return JSON.parse(JSON.stringify(e))}function Gh(e){return JSON.parse(JSON.stringify(e))}function Kh(e=J(6),t=`enUS`,n=``,r=2){let i={id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},notes:{},noteSettings:{},body:{dataStream:`\r
4
+ `,textRuns:[],customBlocks:[],tables:[],columnGroups:[],blockRanges:[],customRanges:[],customDecorations:[],paragraphs:[{startIndex:0,paragraphId:Bh(new Set),paragraphStyle:{lineSpacing:1}}],sectionBreaks:[{sectionId:_m(new Set),startIndex:1}]},documentStyle:{pageSize:Ih.A4,documentFlavor:r,marginTop:72,marginBottom:72,marginRight:72,marginLeft:72,autoHyphenation:r===3?0:1,doNotHyphenateCaps:0,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:0,useFirstPageHeaderFooter:0,marginHeader:30,marginFooter:30},settings:{}};return r===2&&(i.body.paragraphs[0].paragraphStyle={},i.documentStyle.defaultParagraphStyle={spaceAbove:{v:0},lineSpacing:Nh,spaceBelow:{v:12}},i.documentStyle.pageSize={width:Rh.medium,height:842/.75},i.documentStyle.marginTop=50,i.documentStyle.marginBottom=50,i.documentStyle.marginRight=50,i.documentStyle.marginLeft=50,i.documentStyle.renderConfig={zeroWidthParagraphBreak:0,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}}),i}var qh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),Jh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}return e}e.default=t})),Yh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a??s,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),Xh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||={})})),Zh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),Qh=f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=Zh(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`)}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(n&&n.d!==0&&n.d!==``){if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1]){if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n}else t.push(n)}},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i)}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d))}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),$h=f((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Qh(),n=Zh();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),eg=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)Object.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;let a=Zh(),o=r(Qh()),s=i($h()),c={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=a.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(a.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:o.uniSlice},l=o.default(c);e.type=Object.assign(Object.assign({},l),{api:s.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>o.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var u=Qh();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})})),tg=f((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let n=t(qh()),r=t(Jh()),i=Yh(),a=Xh(),o=()=>{};function s(e,t){if(!e)throw Error(t)}let c=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:i.readCursor,writeCursor:i.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){c=e,o.quiet=!e},registerSubtype:y,checkValidOp:D,normalize:O,apply:k,transformPosition:A,compose:j,tryTransform:I,transform:R,makeInvertible:P,invert:M,invertWithDoc:ee,RM_UNEXPECTED_CONTENT:a.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:a.ConflictType.DROP_COLLISION,BLACKHOLE:a.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>re(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>re(t,e,n,r)})};let l=e=>e?e.getComponent():null;function u(e){return e&&typeof e==`object`&&!Array.isArray(e)}let d=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,f=e=>e&&(e.p!=null||e.r!==void 0),p=e=>e&&(e.d!=null||e.i!==void 0);function m(e,t){return s(e!=null),typeof t==`number`?(s(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(s(u(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function h(e,t,n){return typeof t==`number`?(s(e!=null,`Container is missing for key`),s(Array.isArray(e),`Cannot use numerical key for object container`),s(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(s(u(e),`Cannot insert into missing item`),s(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>i.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>i.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>i.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>i.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>i.writeCursor().at(e,e=>w(e,t,n,r)).get();let g=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),_=(e,t)=>g(e,t)?e[t]:void 0,v={};function y(e){let t=e.type?e.type:e;t.name&&(v[t.name]=t),t.uri&&(v[t.uri]=t)}let b=e=>{let t=v[e];if(t)return t;throw Error(`Missing type: `+e)};y(eg());let x=(e,t)=>e+t;y({name:`number`,apply:x,compose:x,invert:e=>-e,transform:e=>e});let S=e=>e==null?null:e.et?b(e.et):e.es?v[`text-unicode`]:e.ena==null?null:v.number,C=e=>e.es?e.es:e.ena==null?e.e:e.ena,w=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[b(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function T(e){s(typeof e==`number`),s(e>=0),s(e===(0|e))}function E(e){typeof e==`number`?T(e):s(typeof e==`string`)}function D(e){if(e===null)return;let t=new Set,n=new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,s(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)T(o),s(!t.has(o)),t.add(o),s(e.r===void 0);else if(a===`d`)T(o),s(!n.has(o)),n.add(o),s(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){s(!i),i=!0;let t=S(e);s(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(C(e))}}s(!r)},a=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||E(e[0]);let o=1,c=0,l=0;for(let t=0;t<e.length;t++){let u=e[t];if(s(u!=null),Array.isArray(u)){let e=a(u,!1,n);if(c){let t=typeof l,n=typeof e;t===n?s(l<e,`descent keys are not in order`):s(t===`number`&&n===`string`)}l=e,c++,o=3}else typeof u==`object`?(s(o===1,`Prev not scalar - instead ${o}`),r(u),o=2):(s(o!==3),E(u),s(i.isValidPathItem(u),`Invalid path key`),o=1)}return s(c!==1,`Operation makes multiple descents. Remove some []`),s(o===2||o===3),e[0]};a(e,!0,!1),s(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)s(t.has(e)),s(n.has(e))}function O(e){let t=0,n=[],r=i.writeCursor();return r.mergeTree(e,(e,r)=>{let i=S(e);if(i){let t=C(e);w(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]??(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function k(e,t){if(o.quiet=!c,D(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},c=0,l=o,u=`root`;function f(){for(;c<a;c++){let e=r[c];typeof e!=`object`&&(s(g(l,u)),l=l[u]=d(l[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(f(),i=l[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(f(),i=h(l,u,t.i)):(f(),i=h(l,u,n[t.d]));let e=S(t);if(e)f(),i=l[u]=e.apply(i,C(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=_(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=_(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===_(n,e)?n:t===void 0?m(n,e):(c=e,l=t,(o=d(o=n))[c]=l,o)}else f(e)&&(s(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,c,l;return t}(e,t),t)}function A(e,t){e=e.slice(),D(t);let n=i.readCursor(t),r,a,o=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(o=!1,r=l.p,a=t):o=!0),t>=e.length)break;let u=0,d=i.advancer(n,void 0,(e,t)=>{f(t)&&u++});s.unshift(d);let p=d(c);if(typeof c==`number`&&(e[t]-=u),!p)break}if(s.forEach(e=>e.end()),o)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(a))}for(;t<e.length;t++){let r=e[t],a=l(n),o=S(a);if(o){let n=C(a);o.transformPosition&&(e[t]=o.transformPosition(e[t],n));break}let s=0,c=i.advancer(n,(e,t)=>p(t)?~(e-s):e-s,(e,t)=>{p(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function j(e,t){if(D(e),D(t),e==null)return t;if(t==null)return e;let n=0,r=i.readCursor(e),a=i.readCursor(t),o=i.writeCursor(),c=[],u=[],d=[],m=[],h=[],g=[],_=new Set;r.traverse(null,e=>{e.p!=null&&(d[e.p]=r.clone())}),a.traverse(null,e=>{e.d!=null&&(m[e.d]=a.clone())});let v=i.writeCursor();return function e(t,r,a,o,v,y,b,x){s(r||a);let T=l(r),E=l(a),D=!!E&&E.r!==void 0,O=!!T&&T.i!==void 0,k=T?T.d:null,A=E?E.p:null,j=(y||D)&&A==null;if(A!=null)o=m[A],b=u[A]=new i.WriteCursor;else if(E&&E.r!==void 0)o=null;else{let e=l(o);e&&e.d!=null&&(o=null)}let M=l(o);if(k!=null){if(t=d[k],x=c[k]=new i.WriteCursor,j)y&&!D&&x.write(`r`,!0);else{let e=h[k]=n++;b.write(`d`,e)}}else if(T&&T.i!==void 0)t=null;else{let e=l(t);e&&e.p!=null&&(t=null)}let N;O?(s(v===void 0),N=T.i):N=v;let P=(A==null?!O||y||D:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||O)){let e=k==null?n++:h[k];g[A]=e,x.write(`p`,e)}}else D&&(O||v!==void 0||(E.r,x.write(`r`,E.r)));let ee=j?null:S(T),F=S(M);if((ee||F)&&(ee&&ee.name,F&&F.name),ee&&F){s(ee===F);let e=C(T),t=C(M),n=ee.compose(e,t);w(b,ee,n),_.add(M)}else ee?w(b,ee,C(T)):F&&(w(b,F,C(M)),_.add(M));let I=typeof N==`object`&&!!N,L=!1,R=0,te=0,ne=0,re=0,ie=0,z=i.advancer(o,(e,t)=>p(t)?re-e-1:e-re,(e,t)=>{p(t)&&re++}),ae=i.advancer(t,(e,t)=>f(t)?R-e-1:e-R,(e,t)=>{f(t)&&R++});if(i.eachChildOf(r,a,(t,n,r)=>{let i,a,o=t,c=t,u=t;if(typeof t==`number`){let e=t+ne;a=z(e),c=e+re;let d=t+te;i=ae(d),p(l(a))&&(i=null),o=d+R,u=t+ie,s(o>=0,`p1PickKey is negative`),s(c>=0,`p2DropKey is negative`);let m=p(l(n)),h=f(l(r));(m||h&&!j)&&ie--,m&&te--,h&&ne--}else i=ae(t),a=z(t);x.descend(o),b.descend(c);let d=I&&!p(l(n))?N[u]:void 0,m=e(i,n,r,a,d,j,b,x);var h,g,_;I&&!j?d!==m&&(L||=(N=Array.isArray(N)?N.slice():Object.assign({},N),!0),h=N,_=m,typeof(g=u)==`number`?(s(Array.isArray(h)),s(g<h.length)):(s(!Array.isArray(h)),s(h[g]!==void 0)),_===void 0?typeof g==`number`?h.splice(g,1):delete h[g]:h[g]=_):s(m===void 0),b.ascend(),x.ascend()}),ae.end(),z.end(),P!=null)P.i=N;else if(!y&&!D&&A==null)return N}(r,r.clone(),a,a.clone(),void 0,!1,o,v),o.reset(),o.mergeTree(v.get()),o.reset(),o.get(),c.map(e=>e.get()),u.map(e=>e.get()),r.traverse(o,(e,t)=>{let n=e.p;if(n!=null){let e=h[n];e!=null&&t.write(`p`,e);let r=c[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),o.reset(),o.get(),a.traverse(o,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=u[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=S(e);r&&!_.has(e)&&w(t,r,C(e))}),o.get()}function M(e){if(e==null)return null;let t=new i.ReadCursor(e),n=new i.WriteCursor,r,a=[],o=[];return function e(t,n,i){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),a[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),i=void 0),o.i!==void 0&&(i=s=o.i);let e=S(o);e&&(i===void 0?(r||=new Set,r.add(o)):(C(o),i=e.apply(i,C(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let a=typeof r==`number`?r-l:r,o=_(i,a);p(t.getComponent())&&l++;let s=e(t,n,o);if(i!==void 0&&s!==void 0){if(c||(c=!0,i=d(i)),!g(i,a))throw Error(`Cannot modify child - invalid operation`);i[a]=s}n.ascend()}if(s===void 0)return c?i:void 0;n.write(`r`,i)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=a[e],s=o[e]=i.writeCursor()),r.has(c)){let e=S(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);w(s,e,e.invert(C(c)))}}let l=0,u=0,d=i.advancer(t,(e,t)=>f(t)?l-e-1:e-l,(e,t)=>{f(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),p(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),o.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=o[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let N=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?N(e,t):t(e)));function P(e,t){if(e==null||!N(e,e=>{var t;return e.r!==void 0||((t=S(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new i.ReadCursor(e),a=new i.WriteCursor,o=!1,c=[],l=[],u=(e,t,n)=>{let i=e.getComponent(),a=!1;if(i){i.d!=null&&t.write(`d`,i.d),i.i!==void 0&&t.write(`i`,i.i);let r=i.p;if(r!=null&&(c[r]=e.clone(),s(n!==void 0,`Operation picks up at an invalid key`),l[r]=n,t.write(`p`,i.p)),i.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let a=S(i);a&&(a.makeInvertible?o=!0:w(t,a,C(i),!0))}let f=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-f:r,o=_(n,i),s=u(e,t,o);o!==s&&(a||(a=!0,n=d(n)),s===void 0?(n=m(n,i),typeof r==`number`&&f++):n[i]=s),t.ascend()}return i&&(i.r===void 0?i.p!=null&&(n=void 0):(t.write(`r`,r.default(n)),n=void 0)),n};return u(n,a,t),a.get(),o&&(a.reset(),function e(t,n,r,a,o){let s=n.getComponent();if(s){s.i===void 0?s.d!=null&&(a=l[s.d],t=c[s.d],o=!1,s.d):(a=s.i,o=!0);let e=S(s);if(e&&e.makeInvertible){let t=C(s);w(r,e,e.makeInvertible(t,a),!0)}}let u=0,d=0,m=i.advancer(t,(e,t)=>f(t)?u-e-1:e-u,(e,t)=>{f(t)&&u++});for(let t of n)if(typeof t==`number`){let i=t-d,s=m(i),c=i+u,l=_(a,o?i:c);r.descend(t),e(s,n,r,l,o),p(n.getComponent())&&d++,r.ascend()}else{let i=_(a,t);r.descend(t),e(m(t),n,r,i,o),r.ascend()}m.end()}(n.clone(),n,a,t,!1)),a.get()}function ee(e,t){return M(P(e,t))}let F=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=F(e))}return t};function I(t,u,d){s(d===`left`||d===`right`,`Direction must be left or right`);let m=d===`left`?0:1;if(o.quiet=!c,o.prefix=0,u==null)return{ok:!0,result:t};D(t),D(u);let h=null,g=[],_=[],v=[],y=[],b=[],x=[],T=[],E=[],O=[],k=[],A=[],j=[],M=[],N=[],P=[],ee=0,I=i.readCursor(t),L=i.readCursor(u),R=i.writeCursor();if(function e(t,n=null,r){let a=l(n);a&&(a.r===void 0?a.p!=null&&(r=null,x[a.p]=t.clone()):r=n.clone());let o=t.getComponent(),s;o&&(s=o.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(k[s]=!0,O[s]=r),a&&a.p!=null&&(N[s]=a.p));let c=i.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(L,I,null),function t(n,r,o,s,c){let u=o.getComponent(),d,p=!1;u&&((d=u.d)==null?u.i!==void 0&&(n=r=null,p=!0,c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(o.getPath(),u.i)})):(y[d]=o.clone(),s!=null&&(P[s]??(P[s]=[]),P[s].push(d)),k[d],n=b[d]||null,r=v[d]||null,k[d]?(c&&(A[d]=!0),c=O[d]||null):!c||m!==1&&N[d]!=null||(h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),o.getPath())}),p=!0));let g=l(n);g&&(g.r===void 0?g.p!=null&&(g.p,s=g.p,c=null):c=n.clone());let _=S(u);_&&c&&h==null&&(h={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(o.getPath(),_,C(u),!0)});let x=0,w=0,T=i.advancer(r,(e,t)=>f(t)?x-e-1:e-x,(e,t)=>{f(t)&&x++}),E=i.advancer(n);for(let e of o)if(typeof e==`number`){let n=e-w,r=T(n);w+=+t(E(n+x),r,o,s,c)}else{let n=T(e);t(E(e),n,o,s,c)}return T.end(),E.end(),p}(I,L,L.clone(),null,null),y.map(e=>e&&e.get()),h)return{ok:!1,conflict:h};A.map(e=>!!e);let te=[],ne=null;(function e(t,n,r,a,o){let c=!1,u=l(n);if(f(u)){let e=u.p;e==null?(r=null,o=n.clone()):(r=y[e],a=j[e]=i.writeCursor(),c=!0,o=null)}else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e=d.p;e==null?d.r!==void 0&&(o||a.write(`r`,!0),(o||c)&&(ne??=new Set,ne.add(d))):(o&&(E[e]=o),te[e]=o||m===1&&c?null:a.getComponent(),g[e]=t.clone(),r&&(T[e]=r.clone()))}let h=0,_=0,v=i.advancer(n,void 0,(e,t)=>{f(t)&&h++}),b=i.advancer(r,(e,t)=>p(t)?~(e-_):e-_,(e,t)=>{p(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),i=b(n);a.descend(n),e(t,r,i,a,o),a.ascend()}else{let r=v(n),i=n-h,c=f(l(r))?null:b(i),u=i+_;s(u>=0),a.descend(u),e(t,r,c,a,o),a.ascend()}v.end(),b.end()})(I,L,L.clone(),R,null),R.reset();let re=[];if(function t(o,c,u,b,D,O){s(c);let A=c.getComponent(),j=l(b),P=!1,F=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(p(A)){let t=A.d;t!=null&&(_[t]=c.clone());let i=t==null?null:te[t],s=!1;if(A.i!==void 0||t!=null&&i){let o;j&&(j.i!==void 0||(o=j.d)!=null&&!k[o])&&(s=o==null?n.default(j.i,A.i):t!=null&&t===N[o],s||o!=null&&m!==1&&N[o]!=null||(h??={type:a.ConflictType.DROP_COLLISION,op1:F(t==null?null:g[t],c,A),op2:F(o==null?null:v[o],b,j)})),s||(O?h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:F(t==null?null:g[t],c,A),op2:e.removeOp(O.getPath())}:(t==null?D.write(`i`,r.default(A.i)):(re[ee]=t,D.write(`d`,i.p=ee++)),P=!0))}else if(t!=null&&!i){let e=E[t];e&&(O=e.clone())}t==null?A.i!==void 0&&(o=u=null,s||(b=null)):(o=g[t],u=x[t],b=T[t])}else f(l(o))&&(o=u=b=null);let I=l(o),L=l(u);if(f(L)){let e=L.p;L.r!==void 0&&(!I||I.r===void 0)||k[e]?(b=null,O=u.clone()):e!=null&&(b=y[e],m!==1&&N[e]!=null||((D=M[e])||(D=M[e]=i.writeCursor()),D.reset(),O=null))}else!p(A)&&p(j)&&(b=null);j=b==null?null:b.getComponent();let R=S(A);if(R){let t=C(A);if(O)h??={type:a.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),R,t,!0),op2:e.removeOp(O.getPath())};else{let e=S(j),n;if(e){if(R!==e)throw Error(`Transforming incompatible types`);let r=C(j);n=R.transform(t,r,d)}else n=r.default(t);w(D,R,n)}}let ie=0,z=0,ae=0,oe=0,se=0,ce=0,le=o!=null&&o.descendFirst(),ue=le,de=i.advancer(u,void 0,(e,t)=>{f(t)&&ae++}),fe=b!=null&&b.descendFirst(),pe=fe;for(let e of c)if(typeof e==`number`){let n,r=p(c.getComponent()),i=e-z;{let e;for(;le&&typeof(e=o.getKey())==`number`;){e+=ie;let t=o.getComponent(),n=f(t);if(e>i||e===i&&(!n||m===0&&r))break;if(n){ie--;let e=t.p;te[e],N.includes(e),t.d,l(M[t.d]),f(l(M[t.d])),(t.r===void 0||ne&&ne.has(t))&&(e==null||!te[e]||m!==1&&N.includes(e))||se--}le=o.nextSibling()}n=le&&e===i?o:null}let a=i-ie,u=de(a),d=a-ae,h=null;{let e,t;for(;fe&&typeof(e=b.getKey())==`number`;){t=e-oe;let n=b.getComponent(),i=p(n);if(t>d)break;if(t===d){if(!i){h=b;break}{if(m===0&&r){h=b;break}let e=u&&f(u.getComponent());if(m===0&&e)break}}if(i){let e=n.d;k[e],N[e],n.i===void 0&&(k[e]||N[e]!=null&&m!==1)?(k[e]||N[e]!=null&&m===0)&&(oe++,ce--):oe++}fe=b.nextSibling()}}let g=d+oe+se+ce;s(g>=0,`trying to descend to a negative index`),D.descend(g),r&&(n=u=h=null,z++),t(n,c,u,h,D,O)&&ce++,D.ascend()}else{let n;for(;le&&(n=o.getKey(),typeof n!=`string`||!(n>e||n===e));)le=o.nextSibling();let r=le&&n===e?o:null,i=de(e),a;for(;fe&&(a=b.getKey(),typeof a!=`string`||!(a>e||a===e));)fe=b.nextSibling();let s=fe&&a===e?b:null;D.descend(e),t(r,c,i,s,D,O),D.ascend()}return de.end(),ue&&o.ascend(),pe&&b.ascend(),P}(I,I.clone(),L,L.clone(),R,null),h)return{ok:!1,conflict:h};R.reset();let ie=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(k.length||j.length)&&(ie(L,R,(e,t,n)=>{k[e]&&!A[e]&&n.write(`r`,!0),j[e]&&n.mergeTree(j[e].get())}),R.reset());let z=[],ae=[];if((M.length||k.length)&&!h){let e=i.readCursor(F(R.get()));if(ie(e,null,(e,t)=>{z[e]=t.clone()}),M.forEach(e=>{e&&ie(i.readCursor(e.get()),null,(e,t)=>{z[e]=t.clone()})}),function e(t,n,r,a,s,c){o.prefix++;let u=l(n);if(u&&f(u)){if(u.p!=null){s=u;let e=u.p;z[e].getPath(),r=z[e],a=ae[e]=i.writeCursor()}else u.r!==void 0&&(r=null,c=!0)}else p(l(r))&&(r=null);let d=t.getComponent();if(d){let e;if((e=d.d)!=null){let t=M[e];t&&(t.get(),a.mergeTree(t.get()),r=i.readCursor(t.get()))}}let m=0,h=0,g=i.advancer(n,void 0,(e,t)=>{f(t)&&m--}),_=i.advancer(r,(e,t)=>p(t)?-(e-h)-1:e-h,(e,t)=>{p(t)&&h++});for(let n of t)if(typeof n==`number`){let r=g(n),i=n+m,o=_(i),l=i+h;a.descend(l),e(t,r,o,a,s,c),a.ascend()}else a.descend(n),e(t,g(n),_(n),a,s,c),a.ascend();g.end(),_.end()}(L,e,e.clone(),R,null,!1),R.reset(),h)return{ok:!1,conflict:h};if(R.get(),ae.length){let e=ae.map(e=>e?e.get():null);if(ie(i.readCursor(F(R.get())),R,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=i.writeCursor(),n=i.writeCursor(),r=0,o=0;e.forEach(e=>{e!=null&&ie(i.readCursor(e),null,e=>{let i=re[e];t.writeMove(g[i].getPath(),_[i].getPath(),r++);let a=P[i];a&&a.forEach(e=>{k[e]||m!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),o++)})})}),h={type:a.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return h?{ok:!1,conflict:h}:{ok:!0,result:R.get()}}let L=e=>{let t=Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function R(e,t,n){let r=I(e,t,n);if(r.ok)return r.result;L(r.conflict)}let te=e=>{let t=i.writeCursor();return i.readCursor(e).traverse(t,(e,t)=>{(p(e)||S(e))&&t.write(`r`,!0)}),t.get()},ne=(e,t)=>{let{type:n,op1:r,op2:o}=e;switch(n){case a.ConflictType.DROP_COLLISION:return t===`left`?[null,te(o)]:[te(r),null];case a.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return i.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,te(o)]:[te(r),null];case a.ConflictType.BLACKHOLE:return[te(r),te(o)];default:throw Error(`Unrecognised conflict: `+n)}};function re(e,t,n,r){let i=null;for(;;){let a=I(t,n,r);if(a.ok)return j(i,a.result);{let{conflict:o}=a;e(o)||L(o);let[s,c]=ne(o,r);t=j(O(t),s),n=j(O(n),c),i=j(i,c)}}}})),ng=h(f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!n.hasOwnProperty(r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(tg(),e);var r=Yh();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var i=Xh();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return i.ConflictType}})}))());let rg=`__textXPreserveParagraphIds`,ig=function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});function ag(e){return{startOffset:e.startIndex,endOffset:e.endIndex+1}}function og(e){return{startOffset:e.startIndex,endOffset:e.endIndex}}function sg(e){return og(e)}function cg(e){return ag(e)}function lg(e){return ag(e)}function ug(e){return ag(e)}function dg(e){return{startOffset:e.startIndex,endOffset:e.startIndex+1}}function fg(e,t){return xg(e,t,`\x1B`,``)}function pg(e,t){return xg(e,t,``,``)}function mg(e,t){return e.startOffset<=t&&t<e.endOffset}function hg(e,t){return e.startOffset<t&&t<e.endOffset}function gg(e,t){return Math.max(e.startOffset,t.startOffset)<Math.min(e.endOffset,t.endOffset)}function _g(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>=t?{...e,endIndex:e.endIndex+n}:e}function vg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>t?{...e,endIndex:e.endIndex+n}:e}function yg(e,t,n){if(n<=0||e.endIndex<t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>=r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t-1;return s>=o?{...e,startIndex:o,endIndex:s}:null}function bg(e,t,n){if(n<=0||e.endIndex<=t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t;return s>o?{...e,startIndex:o,endIndex:s}:null}function xg(e,t,n,r){if(!Number.isInteger(t)||t<0||e[t]!==n)return null;let i=0;for(let a=t;a<e.length;a++){let o=e[a];if(o===n)i++;else if(o===r&&(i--,i===0))return{startOffset:t,endOffset:a+1}}return null}let Sg=`__textXRestoreParagraphIds`;function Cg(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&z.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();Ou(r,o)&&z.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function wg(e,t,n,r){let{textRuns:i}=e;if(i==null)return;let a=[],o=i.length,s=!1,c=t.textRuns??[];if(c.length)for(let e of c)e.st+=r,e.ed+=r;for(let e=0;e<o;e++){let t=i[e],{st:o,ed:l}=t;if(l<=r)a.push(t);else if(r>o&&r<l){s=!0;let e={...t,ed:r};a.push(e),c.length&&a.push(...c);let i={...t,st:r+n,ed:l+n};a.push(i)}else t.st+=n,t.ed+=n,s||(s=!0,a.push(...c)),a.push(t)}s||(s=!0,a.push(...c)),e.textRuns=Cg(a)}function Tg(e,t,n,r,i=!1,a=e.dataStream){var o;if(!e.paragraphs&&!((o=t.paragraphs)!=null&&o.length))return;e.paragraphs??=[];let{paragraphs:s}=e,{paragraphs:c}=t;i||Eg(s,c,r,{freshenSplitParagraph:!0,preserveExplicitSplitParagraphIds:!!t[Sg],preserveExplicitParagraphIds:!!t[rg],dataStream:a});let l=[],u=-1;for(let e=0,t=s.length;e<t;e++){let t=s[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n),u===-1&&i>=r&&(u=e),l.push(t.startIndex)}let d=-1;if(c){for(let e=0,t=c.length;e<t;e++){let t=c[e];t.startIndex+=r;let n=t.startIndex;d=l.indexOf(n)}d!==-1&&s.splice(d,1),s.push(...c),s.sort(df(`startIndex`))}}function Eg(e,t,n,r){if(!e||!(t!=null&&t.length))return;let i=Ag(e,n,r.dataStream),a=i?jg(t):-1,o=i==null?void 0:i.paragraphId,s=a===-1?void 0:t[a].paragraphId,c=(r.preserveExplicitSplitParagraphIds||r.preserveExplicitParagraphIds)&&s!=null&&s!==o,l=Dg(e),u=new Set;o&&l.delete(o);for(let e of r.reservedParagraphIds??[])l.add(e);let d;if(o&&a!==-1&&!c){let e=t[a];d=s!=null&&s!==o?Og(e,l,r.preserveMissingParagraphIds??!1):Hh(e,l,!1),r.freshenSplitParagraph&&d.paragraphId&&(i.paragraphId=d.paragraphId)}for(let e=0,n=t.length;e<n;e++){let n=t[e].paragraphId;if(r.preserveExplicitParagraphIds&&n&&!u.has(n)){t[e]={...t[e]},u.add(n);continue}if(e!==a||o==null||c){t[e]=Og(t[e],l,r.preserveMissingParagraphIds??!1);continue}t[e]=r.freshenSplitParagraph?Hh({...t[e],paragraphId:o},l):d}for(let e of t)if(e.paragraphId){var f;(f=r.reservedParagraphIds)==null||f.add(e.paragraphId)}}function Dg(e){let t=new Set;for(let n of e??[])n.paragraphId&&t.add(n.paragraphId);return t}function Og(e,t,n){return n&&e.paragraphId==null?z.deepClone(e):Hh(e,t)}let kg=new Set([`
5
+ `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function Ag(e,t,n){let r=[...e].sort((e,t)=>e.startIndex-t.startIndex);for(let e=0;e<r.length;e++){let i=r[e],a=e>0?r[e-1].startIndex+1:0;for(;a<i.startIndex;){let e=n==null?void 0:n[a];if(!e||!kg.has(e))break;a++}if(t>a&&t<i.startIndex)return i}}function jg(e){let t=0;for(let n=1;n<e.length;n++)e[n].startIndex<e[t].startIndex&&(t=n);return t}function Mg(e,t,n,r){var i;if(!e.sectionBreaks&&!((i=t.sectionBreaks)!=null&&i.length))return;e.sectionBreaks??=[];let{sectionBreaks:a}=e,o=t.sectionBreaks;Ng(a,o);for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(df(`startIndex`))}}function Ng(e,t,n=new Set){if(!(t!=null&&t.length))return;let r=new Set((e==null?void 0:e.map(e=>e.sectionId))??[]);for(let e of n)r.add(e);for(let e=0;e<t.length;e++)t[e]=vm(t[e],r),n.add(t[e].sectionId)}function Pg(e,t,n,r,i){if(e[i]==null&&t[i]==null)return;let a=e[i]??[];for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}let o=t[i];if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(df(`startIndex`))}a.length&&!e[i]&&(e[i]=a)}function Fg(e,t,n,r){Pg(e,t,n,r,`customBlocks`)}function Ig(e,t,n,r){Pg(e,t,n,r,`docxRawCustomBlocks`)}function Lg(e,t,n,r){if(e.docxRawBlocks==null&&t.docxRawBlocks==null)return;let i=e.docxRawBlocks??[];i.forEach(e=>{e.startIndex>=r&&(e.startIndex+=n)}),i.push(...(t.docxRawBlocks??[]).map(e=>({...e,startIndex:e.startIndex+r}))),i.sort(df(`startIndex`)),e.docxRawBlocks=i}function Rg(e){let t=[...e].sort((e,t)=>e.start-t.start||e.end-t.end),n=[];for(let e of t){let t=n[n.length-1];t&&e.start<=t.end?t.end=Math.max(t.end,e.end):e.end>e.start&&n.push({...e})}return n}function zg(e,t,n,r){if(e.docxExportExcludedRanges==null&&t.docxExportExcludedRanges==null)return;let i=(e.docxExportExcludedRanges??[]).map(e=>{let t=vg({startIndex:e.start,endIndex:e.end},r,n);return{start:t.startIndex,end:t.endIndex}}),a=(t.docxExportExcludedRanges??[]).map(e=>({start:e.start+r,end:e.end+r}));e.docxExportExcludedRanges=Rg([...i,...a])}function Bg(e,t,n,r){var i;if(!e.tables&&!((i=t.tables)!=null&&i.length))return;e.tables||=[];let{tables:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,vg(t,r,n))}let o=t.tables;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(df(`startIndex`))}}function Vg(e,t,n,r){var i;if(!e.columnGroups&&!((i=t.columnGroups)!=null&&i.length))return;e.columnGroups||=[];let{columnGroups:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,_g(t,r,n))}let o=t.columnGroups;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(df(`startIndex`))}}function Hg(e,t,n,r){var i;if(!e.blockRanges&&!((i=t.blockRanges)!=null&&i.length))return;e.blockRanges||=[];let{blockRanges:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,_g(t,r,n))}let o=t.blockRanges;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(df(`startIndex`))}}let Ug=e=>e.split(`$`)[0];function Wg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n=new Map;for(let r of e){let e={...r,rangeId:Ug(r.rangeId)},i=n.get(e.rangeId);i&&e.rangeType===i.rangeType&&Ip(i.properties,e.properties)&&i.endIndex+1>=e.startIndex?i.endIndex=Math.max(i.endIndex,e.endIndex):(t.push(e),n.set(e.rangeId,e))}let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}\$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function Gg(e,t){let n=e.filter(e=>e.rangeType!==1&&e.rangeType!==2&&e.rangeType!==3&&e.startIndex<t&&e.endIndex>=t);for(let r of n){let n=e.indexOf(r);e.splice(n,1,{...r,endIndex:t-1,properties:{...r.properties}},{...r,startIndex:t,properties:{...r.properties}})}}function Kg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function qg(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function Jg(e,t,n,r){e.customRanges||=[];let{customRanges:i}=e;Gg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;if((t.rangeType===1||t.rangeType===2||t.rangeType===3)&&a<r&&t.endIndex>=r){t.endIndex+=n;continue}a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e],o=n.rangeType===2?i.find(e=>e.rangeType===2&&e.rangeId===n.rangeId):void 0;if(o){o.startIndex=Math.min(o.startIndex,r+n.startIndex),o.endIndex=Math.max(o.endIndex,r+n.endIndex),o.properties=z.deepClone(n.properties),o.wholeEntity=n.wholeEntity,i.splice(i.indexOf(o),0,...a.splice(0));continue}n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customRanges=Wg(i)}function Yg(e,t,n,r){e.customDecorations||=[];let{customDecorations:i}=e;qg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customDecorations=Kg(i)}function Xg(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;if(i<=c&&a>=l){o.push({...s,st:c-i,ed:l-i});continue}c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t),n.push(s)}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function Zg(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;if(d>=i&&d<a){o.push({...u,startIndex:d-n}),c=!0;continue}d>=a&&(u.startIndex-=t),l.push(u),s==null&&c&&(s=u)}e.paragraphs=l}return o}function Qg(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;if(l>=i&&l<=a){o.push({...c,startIndex:l-n});continue}l>a&&(c.startIndex-=t),s.push(c)}e.sectionBreaks=s}return o}function $g(e,t,n,r){let i=e[r];if(i==null)return;let a=n,o=n+t-1,s=[],c=[];for(let e=0,r=i.length;e<r;e++){let r=i[e],{startIndex:l}=r;if(l>=a&&l<=o){s.push({...r,startIndex:l-n});continue}l>o&&(r.startIndex-=t),c.push(r)}return e[r]=c,i.length&&!e[r]&&(e[r]=i),s}function e_(e,t,n){return e.customBlocks??=[],$g(e,t,n,`customBlocks`)}function t_(e,t,n){return $g(e,t,n,`docxRawCustomBlocks`)}function n_(e,t,n){if(e.docxRawBlocks==null)return;let r=n+t,i=[],a=[];for(let o of e.docxRawBlocks)o.startIndex>=n&&o.startIndex<r?i.push({...o,startIndex:o.startIndex-n}):a.push(o.startIndex>=r?{...o,startIndex:o.startIndex-t}:o);return e.docxRawBlocks=a,i}function r_(e,t,n){if(e.docxExportExcludedRanges==null)return;let r=n+t,i=[],a=[];for(let o of e.docxExportExcludedRanges){let e=Math.max(o.start,n),s=Math.min(o.end,r);s>e&&i.push({start:e-n,end:s-n});let c=bg({startIndex:o.start,endIndex:o.end},n,t);c&&a.push({start:c.startIndex,end:c.endIndex})}return e.docxExportExcludedRanges=Rg(a),i}function i_(e,t,n){let{tables:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=bg(o,n,t);if(!s){i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n});continue}Object.assign(o,s),a.push(o)}e.tables=a}return i}function a_(e,t,n){let{columnGroups:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=yg(o,n,t);if(!s){i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n});continue}Object.assign(o,s),a.push(o)}e.columnGroups=a}return i}function o_(e,t,n){let{customRanges:r}=e,i=[];if(r){let a=new Map(r.filter(e=>e.rangeType===2).map(e=>[e,e.endIndex-e.startIndex])),o=new Map,s=[];for(let e=0,a=r.length;e<a;e++){let a=r[e],c=yg(a,n,t);if(!c){i.push(a);continue}if(Object.assign(a,c),a.rangeType===2){let e=`${a.startIndex}:${a.endIndex}`,t=o.get(e)??[];t.push(s.length),o.set(e,t)}s.push(a)}for(let e of o.values()){if(e.length<2)continue;let t=e.map(e=>s[e]).sort((e,t)=>a.get(e)-a.get(t));e.forEach((e,n)=>{s[e]=t[n]})}e.customRanges=Wg(s)}return i}function s_(e,t,n){let{blockRanges:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=yg(o,n,t);if(!s){i.push(o);continue}Object.assign(o,s),a.push(o)}e.blockRanges=a}return i}function c_(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o){s.push(c);continue}if(Math.max(a,l)<=Math.min(o,u)){let e=td(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}e.customDecorations=n}return s}let l_=function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),u_=function(e){return e.BULLET_LIST=`BULLET_LIST`,e.BULLET_LIST_1=`BULLET_LIST_1`,e.BULLET_LIST_2=`BULLET_LIST_2`,e.BULLET_LIST_3=`BULLET_LIST_3`,e.BULLET_LIST_4=`BULLET_LIST_4`,e.BULLET_LIST_5=`BULLET_LIST_5`,e.ORDER_LIST=`ORDER_LIST`,e.ORDER_LIST_1=`ORDER_LIST_1`,e.ORDER_LIST_2=`ORDER_LIST_2`,e.ORDER_LIST_3=`ORDER_LIST_3`,e.ORDER_LIST_4=`ORDER_LIST_4`,e.ORDER_LIST_5=`ORDER_LIST_5`,e.ORDER_LIST_QUICK_2=`ORDER_LIST_QUICK_2`,e.ORDER_LIST_QUICK_3=`ORDER_LIST_QUICK_3`,e.ORDER_LIST_QUICK_4=`ORDER_LIST_QUICK_4`,e.ORDER_LIST_QUICK_5=`ORDER_LIST_QUICK_5`,e.ORDER_LIST_QUICK_6=`ORDER_LIST_QUICK_6`,e.CHECK_LIST=`CHECK_LIST`,e.CHECK_LIST_CHECKED=`CHECK_LIST_CHECKED`,e}({}),d_={"a)":{glyphFormat:`%1)`,glyphType:2},"1.":{glyphFormat:`%1.`,glyphType:2},"a.":{glyphFormat:`%1.`,glyphType:5},"A.":{glyphFormat:`%1.`,glyphType:4},"i.":{glyphFormat:`%1.`,glyphType:7},"I.":{glyphFormat:`%1.`,glyphType:4}},f_=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),p_=e=>e.map((e,t)=>({...e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),m_=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(r+1)},textStyle:t}})),h_={BULLET_LIST:{listType:`BULLET_LIST`,nestingLevel:f_([`●`,`○`,`■`])},BULLET_LIST_1:{listType:`BULLET_LIST`,nestingLevel:f_([`❖`,`➢`,`■`])},BULLET_LIST_2:{listType:`BULLET_LIST`,nestingLevel:f_([`✔`,`●`,`◆`])},BULLET_LIST_3:{listType:`BULLET_LIST`,nestingLevel:f_([`■`,`◆`,`○`])},BULLET_LIST_4:{listType:`BULLET_LIST`,nestingLevel:f_([`✦`,`○`,`■`])},BULLET_LIST_5:{listType:`BULLET_LIST`,nestingLevel:f_([`➢`,`○`,`◆`])},ORDER_LIST:{listType:`ORDER_LIST`,nestingLevel:p_([{glyphFormat:`%1.`,glyphType:2},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:2},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:2},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_1:{listType:`ORDER_LIST`,nestingLevel:p_([{glyphFormat:`%1)`,glyphType:2},{glyphFormat:`%2)`,glyphType:5},{glyphFormat:`%3)`,glyphType:7},{glyphFormat:`%4)`,glyphType:2},{glyphFormat:`%5)`,glyphType:5},{glyphFormat:`%6)`,glyphType:7},{glyphFormat:`%7)`,glyphType:2},{glyphFormat:`%8)`,glyphType:5},{glyphFormat:`%9)`,glyphType:7}])},ORDER_LIST_2:{listType:`ORDER_LIST`,nestingLevel:p_([`%1.`,`%1.%2.`,`%1.%2.%3.`,`%1.%2.%3.%4.`,`%1.%2.%3.%4.%5.`,`%1.%2.%3.%4.%5.%6.`,`%1.%2.%3.%4.%5.%6.%7.`].map(e=>({glyphFormat:e,glyphType:2})))},ORDER_LIST_3:{listType:`ORDER_LIST`,nestingLevel:p_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_4:{listType:`ORDER_LIST`,nestingLevel:p_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:2},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:2},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:2},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_5:{listType:`ORDER_LIST`,nestingLevel:p_([{glyphFormat:`%1.`,glyphType:3},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:3},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:3},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},CHECK_LIST:{listType:`CHECK_LIST`,nestingLevel:m_(`☐`)},CHECK_LIST_CHECKED:{listType:`CHECK_LIST_CHECKED`,nestingLevel:m_(`☑`,{st:{s:1}})}},g_=e=>{let{glyphFormat:t,glyphType:n}=e,r=z.deepClone(h_.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},__={ORDER_LIST_QUICK_2:g_(d_[`a)`]),ORDER_LIST_QUICK_3:g_(d_[`a.`]),ORDER_LIST_QUICK_4:g_(d_[`i.`]),ORDER_LIST_QUICK_6:g_(d_[`I.`])};Object.assign(h_,__);let v_={"1.":`ORDER_LIST`,"a)":`ORDER_LIST_QUICK_2`,"a.":`ORDER_LIST_QUICK_3`,"i.":`ORDER_LIST_QUICK_4`,"A.":`ORDER_LIST_3`,"I.":`ORDER_LIST_QUICK_6`,"01.":`ORDER_LIST_5`,"*":`BULLET_LIST`};function y_(e,t,n,r,i){return{dataStream:``,textRuns:b_(e,t,n,r,i),paragraphs:S_(e,t,n,r,i),sectionBreaks:C_(e,t,n,r,i),customBlocks:w_(e,t,n,r,i),docxRawCustomBlocks:T_(e,t,n,r,i),tables:E_(e,t,n,r,i),columnGroups:D_(e,t,n,r,i),blockRanges:O_(e,t,n,r,i),customRanges:k_(e,t,n,r,i),customDecorations:A_(e,t,n,r,i)}}function b_(e,t,n,r,i){let{textRuns:a}=e,{textRuns:o}=t;if(a==null||o==null)return;let s=Xg(e,n,r);return i!==1&&(t.textRuns=x_(o,s,i)),wg(e,t,n,r),s}function x_(e,t,n){if(t.length===0)return e;e=z.deepClone(e),t=z.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===0?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Cg(r)}function S_(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=Zg(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,paragraphId:r,paragraphStyle:a,bullet:o}=t,c=[];for(let e of s){let{startIndex:t,paragraphId:s,paragraphStyle:l,bullet:u}=e,d,f;if(i===0?(d={...l,...a},f={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...u,...o}):(d={...a,...l},f={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...o,...u}),n===t){c.push({startIndex:n,paragraphId:r??s,paragraphStyle:d,bullet:f});break}}e.push(...c),c=[]}t.paragraphs=e}else for(let e of o){let t=s.find(t=>t.startIndex===e.startIndex);t&&e.paragraphId==null&&(e.paragraphId=t.paragraphId)}return Tg(e,t,n,r,!0),s}function C_(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=Qg(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e})}else t.sectionBreaks=o.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e});return Mg(e,t,n,r),s}function w_(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=e_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return Fg(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function T_(e,t,n,r,i){let a=e.docxRawCustomBlocks,o=t.docxRawCustomBlocks;if(a==null||o==null)return;let s=t_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let n=s.find(e=>e.startIndex===t.startIndex);n&&e.push(i===0?{...n,...t}:{...t,...n})}t.docxRawCustomBlocks=e}return Ig(e,t,n,r),a.length&&!e.docxRawCustomBlocks&&(e.docxRawCustomBlocks=a),s}function E_(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=i_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return Bg(e,t,n,r),s}function D_(e,t,n,r,i){let{columnGroups:a}=e,{columnGroups:o}=t;if(a==null||o==null)return;let s=a_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.columnGroups=e}return Vg(e,t,n,r),s}function O_(e,t,n,r,i){let{blockRanges:a}=e,{blockRanges:o}=t;if(a==null||o==null)return;let s=s_(e,n,r);return i!==1&&(t.blockRanges=o.map(e=>{let t=s.find(t=>t.blockId===e.blockId);return t?{...t,...e}:e})),Hg(e,t,n,r),s}function k_(e,t,n,r,i){e.customRanges||=[],Gg(e.customRanges,r),Gg(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=new Map;e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)});let u=[];if(!s)return[];s.forEach(e=>{let{startIndex:t,endIndex:i}=e,a=e.rangeType===2?c.find(t=>t.rangeType===2&&t.rangeId===e.rangeId):void 0;if(a){t>0&&(a.startIndex=t+r),i<n-1&&(a.endIndex=i+r),a.properties=z.deepClone(e.properties),a.wholeEntity=e.wholeEntity;return}c.push({...e,startIndex:t+r,endIndex:i+r})});let d=new Map(s.map((e,t)=>[e.rangeId,t])),f=new Map;c.forEach((e,t)=>{if(e.rangeType!==2||!d.has(e.rangeId))return;let n=`${e.startIndex}:${e.endIndex}`,r=f.get(n)??[];r.push(t),f.set(n,r)});for(let e of f.values()){let t=e.map(e=>c[e]).sort((e,t)=>d.get(e.rangeId)-d.get(t.rangeId));e.forEach((e,n)=>{c[e]=t[n]})}return e.customRanges=Wg(c),u}function A_(e,t,n,r,i){e.customDecorations||=[],qg(e.customDecorations,r),qg(e.customDecorations,r+n);let a=[],{customDecorations:o}=e,{customDecorations:s=[]}=t;if(i===1){for(let e=0;e<o.length;e++){let t=o[e],{startIndex:i,endIndex:s}=t;i>=r&&s<=r+n-1&&a.push(t)}s.forEach(e=>{let{startIndex:t,endIndex:n}=e;o.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of s){let{id:t}=e;if(e.type===9999){let e=o.filter(e=>e.id===t);e.length&&a.push(...e)}else o.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of a){let{id:t}=e,n=o.findIndex(e=>e.id===t);n!==-1&&o.splice(n,1)}return e.customDecorations=Kg(o),a}function j_(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function M_(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function N_(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function P_(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r??L_(t,n),s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function F_(e,t,n){let r=[],i=L_(t,n);for(let a of e){let e=P_(a,t,n,i);r.push(...e)}return r}let I_=[`\r`,``,``,`\x1B`,``,``];function L_(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!I_.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}let R_=e=>{var t;let{paragraphs:n,segmentId:r,document:i}=e,a=e.listType,o=((t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs)??[],s=n.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(a))===0}),c=J(6);if(n.length===1){let e=o.indexOf(n[0]),t=o[e-1],r=o[e+1];t&&t.bullet&&t.bullet.listType.indexOf(a)===0?(c=t.bullet.listId,a!==`CHECK_LIST`&&(a=t.bullet.listType)):r&&r.bullet&&r.bullet.listType.indexOf(a)===0&&(c=r.bullet.listId,a!==`CHECK_LIST`&&(a=r.bullet.listType))}let l=new sm;l.reset();let u=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:i}=e;u.push({t:`r`,len:t-l.cursor}),u.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[s?{paragraphId:n,paragraphStyle:r,startIndex:0}:{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{nestingLevel:(i==null?void 0:i.nestingLevel)??0,listType:a,listId:c}}]},coverType:1}),l.moveCursorTo(t+1)}return u},z_=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(`CHECK_LIST`)===-1)return!1;let s=new sm;s.reset();let c=new X,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===`CHECK_LIST`?`CHECK_LIST_CHECKED`:`CHECK_LIST`;return c.push({t:`r`,len:l-s.cursor}),c.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:1}),s.moveCursorTo(l+1),c},B_=e=>{var t;let{paragraphs:n,listType:r,listId:i,segmentId:a,document:o}=e;if(((t=o.getSelfOrHeaderFooterModel(a))==null||(t=t.getBody())==null?void 0:t.paragraphs)==null)return!1;let s=i??J(6),c=new sm;c.reset();let l=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:i={},bullet:a}=e;l.push({t:`r`,len:t-c.cursor}),l.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:i,bullet:{nestingLevel:(a==null?void 0:a.nestingLevel)??0,...(a==null?void 0:a.listType)===r&&a.textStyle?{textStyle:a.textStyle}:{},listType:r,listId:s}}]},coverType:1}),c.moveCursorTo(t+1)}return l};function V_(e,t){return t.some(t=>{let n=sg(t);return e.startIndex>n.startOffset&&mg(n,e.startIndex)})}let H_=new Set([`
6
+ `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function U_(e,t){let n;for(let r of e.paragraphs??[])r.startIndex<t.startIndex&&(!n||r.startIndex>n.startIndex)&&(n=r);let r=n?n.startIndex+1:0;for(;r<t.startIndex&&H_.has(e.dataStream[r]);)r++;return r}function W_(e){let t=new Map,n=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex);for(let r=0;r<n.length;r++){let i=n[r],a=r>0?n[r-1].startIndex+1:0;for(;a<i.startIndex&&H_.has(e.dataStream[a]);)a++;t.set(i.startIndex,a)}return t}function G_(e,t){let n=(e.blockRanges??[]).find(e=>{let n=cg(e);return t.startIndex>n.startOffset&&t.startIndex<n.endOffset-1});return n?cg(n).endOffset:t.startIndex+1}let K_=e=>{var t;let{paragraphs:n,document:r,type:i}=e,a=new sm;a.reset();let o=new X,s=r.getSnapshot().lists??{},c=((t=r.getBody())==null?void 0:t.tables)??[],l={...h_,...s};for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:s}=e,u=V_(e,c);if(o.push({t:`r`,len:t-a.cursor}),s){let e=l[s.listType].nestingLevel.length-1;u&&(e=Math.min(e,2)),o.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{...s,nestingLevel:Math.max(Math.min(s.nestingLevel+i,e),0)}}]},coverType:1})}else o.push({t:`r`,len:1});a.moveCursorTo(t+1)}return o},q_=e=>{var t,n;let{textRanges:r,segmentId:i,document:a,style:o,paragraphTextRun:s,cursor:c,deleteLen:l,textX:u}=e,d=a.getSelfOrHeaderFooterModel(i),f=F_(r,(d==null||(t=d.getBody())==null?void 0:t.paragraphs)??[],(d==null||(n=d.getBody())==null?void 0:n.dataStream)??``),p=new sm;c&&p.moveCursorTo(c);let m=u??new X;f.sort((e,t)=>e.startIndex-t.startIndex);let h=Math.max(0,f[0].paragraphStart-1);h>p.cursor&&(m.push({t:`r`,len:h-p.cursor}),p.moveCursorTo(h)),l&&m.push({t:`d`,len:l});for(let e of f){let{startIndex:t,paragraphId:n,paragraphStyle:r={}}=e,i=t-p.cursor;m.push({t:`r`,len:i,...s?{body:{dataStream:``,textRuns:[{ts:s,st:0,ed:i}]},coverType:1}:null}),m.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r,...o}}]},coverType:1}),p.moveCursorTo(t+1)}return m},J_=function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function Y_(e,t,n,r,i){return i===1?e>=n&&t<=r:i===2?e<r&&t>n&&t<=r:Math.max(e,n)<Math.min(t,r)}function X_(e,t,n,r,i){return i===0?{startIndex:Math.max(e,n)-n,endIndex:Math.min(t,r)-n}:{startIndex:e-n,endIndex:t-n}}function Z_(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let{st:i,ed:a}=r;if(z.hasIntersectionBetweenTwoRanges(i,a,t,n)){let o=z.deepClone(r);t>=i&&t<=a?e.push({...o,st:t,ed:Math.min(n,a)}):n>=i&&n<=a?e.push({...o,st:Math.max(t,i),ed:n}):e.push(o)}}return Cg(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}if(r)return[{st:0,ed:n-t,ts:{}}]}function Q_(e,t,n,r=0){let{tables:i=[]}=e,a=[];for(let e of i){let i=z.deepClone(e),{startIndex:o,endIndex:s}=i;Y_(o,s,t,n,r)&&a.push({...i,...X_(o,s,t,n,r)})}return a}function $_(e,t,n,r=0){let{blockRanges:i=[]}=e,a=[];for(let e of i){let i=z.deepClone(e),{startIndex:o,endIndex:s}=i;Y_(o,s,t,n,r)&&a.push({...i,...X_(o,s,t,n,r)})}return a}function ev(e,t,n,r=0){let{columnGroups:i=[]}=e,a=[];for(let o of i){let i=z.deepClone(o),{startIndex:s,endIndex:c}=i;e.dataStream[s]===``&&Y_(s,c,t,n,r)&&a.push({...i,...X_(s,c,t,n,r)})}return a}function tv(e,t,n,r=1){let{paragraphs:i=[]}=e,a=[];if(r===1){for(let e of i){let{startIndex:r}=e;r>=t&&r<n&&a.push(z.deepClone(e))}return a.length?a.map(e=>({...e,startIndex:e.startIndex-t})):void 0}let o=[...i].sort((e,t)=>e.startIndex-t.startIndex),s=W_(e);for(let e of o){let r=s.get(e.startIndex)??0,i=e.startIndex;if(i>=t&&i<n||Math.max(r,t)<Math.min(i,n)){let r=z.deepClone(e);r.startIndex=Math.min(Math.max(i,t),n),a.push(r)}}if(a.length)return a.map(e=>({...e,startIndex:e.startIndex-t}))}function nv(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(z.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function rv(e,t,n){return av(e.customBlocks??[],t,n)}function iv(e,t,n){return av(e.docxRawCustomBlocks??[],t,n)}function av(e,t,n){let r=[];for(let i of e){let{startIndex:e}=i;e>=t&&e<n&&r.push(z.deepClone(i))}if(r.length)return r.map(e=>({...e,startIndex:e.startIndex-t}))}function ov(e,t,n){return(e.docxRawBlocks??[]).filter(e=>e.startIndex>=t&&e.startIndex<n).map(e=>({...z.deepClone(e),startIndex:e.startIndex-t}))}function sv(e,t,n){return(e.docxExportExcludedRanges??[]).flatMap(e=>{let r=Math.max(e.start,t),i=Math.min(e.end,n);return i>r?[{start:r-t,end:i-t}]:[]})}function cv(e,t,n,r=!0,i=1,a=0){let{dataStream:o}=e,s={dataStream:o.slice(t,n)};e.renderedPageBreaks!=null&&(s.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e>=t&&e<n).map(e=>e-t)),e.__textXPreserveParagraphIds&&(s[rg]=!0),s.textRuns=Z_(e,t,n,r);let c=Q_(e,t,n,a);c.length&&(s.tables=c);let l=$_(e,t,n,a);l.length&&(s.blockRanges=l);let u=ev(e,t,n,a);u.length&&(s.columnGroups=u),s.paragraphs=tv(e,t,n,i);let d=nv(e,t,n-1);if(d?s.sectionBreaks=d:r&&(s.sectionBreaks=[]),i===1){let i=mv(e,t,n);i?s.customDecorations=i:r&&(s.customDecorations=[])}let{customRanges:f}=pv(e,t,n);return f?s.customRanges=i===0?f.filter(e=>e.rangeType!==1||s.dataStream[e.startIndex]===``&&s.dataStream[e.endIndex]===``):f:r&&(s.customRanges=[]),s.customBlocks=rv(e,t,n),e.docxRawCustomBlocks!=null&&(s.docxRawCustomBlocks=iv(e,t,n)??[]),e.docxRawBlocks!=null&&(s.docxRawBlocks=ov(e,t,n)),e.docxExportExcludedRanges!=null&&(s.docxExportExcludedRanges=sv(e,t,n)),s}function lv(e,t,n,r=!0,i=1){return cv(e,t,n,r,i,1)}function uv(e,t,n,r=!0,i=1){return cv(e,t,n,r,i,2)}function dv(e,t,n){var r,i,a,o,s,c,l,u,d,f;e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.map(e=>e+t)),(r=e.textRuns)==null||r.forEach(e=>{e.st+=t,e.ed+=t}),(i=e.paragraphs)==null||i.forEach(e=>{e.startIndex+=t}),(a=e.customBlocks)==null||a.forEach(e=>{e.startIndex+=t}),(o=e.docxRawCustomBlocks)==null||o.forEach(e=>{e.startIndex+=t}),(s=e.docxRawBlocks)==null||s.forEach(e=>{e.startIndex+=t}),(c=e.docxExportExcludedRanges)==null||c.forEach(e=>{e.start+=t,e.end+=t}),(l=e.customRanges)==null||l.forEach(e=>{e.startIndex+=t,e.endIndex+=t}),(u=e.customDecorations)==null||u.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(d=e.tables)==null||d.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(f=e.columnGroups)==null||f.forEach(e=>{e.startIndex+=t,e.endIndex+=n})}function fv(e){let{dataStream:t,textRuns:n,customRanges:r}=e,i=0,a=0;r==null||r.forEach(e=>{e.startIndex<0&&(i=Math.max(i,-e.startIndex)),e.endIndex>t.length-1&&(a=Math.max(a,e.endIndex-t.length+1))});let o=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-i),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+a)),dv(e,i,a),{...e,dataStream:o}}function pv(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function mv(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=z.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function hv(e,t,n){return e==null||t==null?e??t:x_(e,t,n)}function gv(e,t,n){if(e==null||t==null)return e??t;if(t.length===0||e.length===0)return e;if(n===1)return e.map(e=>({...e}));let r=new Map(e.map(e=>[e.rangeId,e]));return[...t.filter(t=>!e.some(e=>t.rangeType===0&&e.rangeType===0&&e.rangeId!==t.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)).map(e=>{let t=r.get(e.rangeId);return t==null?e:(r.delete(e.rangeId),{...e,...t})}),...r.values()]}function _v(e,t,n){return t.length===0||e.length===0||n===1?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function vv(e,t,n=0){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream};e.renderedPageBreaks!=null&&(r.renderedPageBreaks=[...e.renderedPageBreaks]),(e.__textXPreserveParagraphIds||t.__textXPreserveParagraphIds)&&(r[rg]=!0);let{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[],columnGroups:c=[],blockRanges:l=[]}=e,{textRuns:u,paragraphs:d=[],customRanges:f,customDecorations:p=[],columnGroups:m=[],blockRanges:h=[]}=t;r.textRuns=hv(u,i,n),r.customRanges=gv(f,o,n);let g=_v(p,s,n);g.length&&(r.customDecorations=g);let _=[],v=0,y=0;for(;v<a.length&&y<d.length;){let e=a[v],t=d[y],{startIndex:n}=e,{startIndex:r}=t;n===r?(_.push(na(e,t)),v++,y++):n<r?(_.push(z.deepClone(e)),v++):(_.push(z.deepClone(t)),y++)}v<a.length&&_.push(...a.slice(v)),y<d.length&&_.push(...d.slice(y)),_.length&&(r.paragraphs=_);let b=yv(l,h);b.length&&(r.blockRanges=b);let x=bv(c,m);return x.length&&(r.columnGroups=x),r}function yv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.blockId,z.deepClone(e)]));return t.forEach(e=>n.set(e.blockId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function bv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.columnGroupId,z.deepClone(e)]));return t.forEach(e=>n.set(e.columnGroupId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function xv(e){var t;if((t=e.rangeUpdates)!=null&&t.length)return!1;let{body:n}=e;if(n==null)return!0;let{textRuns:r,paragraphs:i,customRanges:a,customBlocks:o,docxRawCustomBlocks:s,docxRawBlocks:c,docxExportExcludedRanges:l,customDecorations:u,tables:d,columnGroups:f,blockRanges:p}=n;return r==null&&i==null&&a==null&&o==null&&s==null&&c==null&&l==null&&u==null&&d==null&&f==null&&p==null}function Sv(e,t=``){var n;if(!t)return[`body`];let{headers:r,footers:i}=e.getSnapshot();if(((n=e.getSnapshot().notes)==null?void 0:n[t])!=null)return[`notes`,t,`body`];if(r==null&&i==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((r==null?void 0:r[t])!=null)return[`headers`,t,`body`];if((i==null?void 0:i[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}var Cv=class{constructor(e){this._actions=e,T(this,`_index`,0),T(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e||=1/0;let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===`d`||t.t===`r`&&t.body==null?z.deepClone({...t,len:e}):z.deepClone({...t,len:e,body:uv(t.body,n,n+e,!1)})}return{t:`r`,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:`r`}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function wv(e,t,n){var r;let{dataStream:i}=e,a=n,o=n+t,s=(r=e.renderedPageBreaks)==null?void 0:r.filter(e=>e>=a&&e<o).map(e=>e-a);e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e<a||e>=o).map(e=>e>=o?e-t:e));let c=Xg(e,t,n),l=Zg(e,t,n),u=Qg(e,t,n),d=e_(e,t,n),f=t_(e,t,n),p=n_(e,t,n),m=r_(e,t,n),h=i_(e,t,n),g=a_(e,t,n),_=s_(e,t,n),v=o_(e,t,n),y=c_(e,t,n),b=``;return i&&(e.dataStream=od(i,a,o),b=i.slice(a,o)),{dataStream:b,renderedPageBreaks:s,textRuns:c,paragraphs:l,sectionBreaks:u,customBlocks:d,docxRawCustomBlocks:f,docxRawBlocks:p,docxExportExcludedRanges:m,tables:h,columnGroups:g,blockRanges:_,customRanges:v,customDecorations:y}}function Tv(e,t,n,r){let i=e.dataStream;e.dataStream=ad(e.dataStream,r,t.dataStream),(e.renderedPageBreaks!=null||t.renderedPageBreaks!=null)&&(e.renderedPageBreaks=[...(e.renderedPageBreaks??[]).map(e=>e>=r?e+n:e),...(t.renderedPageBreaks??[]).map(e=>e+r)].sort((e,t)=>e-t)),wg(e,t,n,r),Tg(e,t,n,r,!1,i),Mg(e,t,n,r),Fg(e,t,n,r),Ig(e,t,n,r),Lg(e,t,n,r),zg(e,t,n,r),Bg(e,t,n,r),Vg(e,t,n,r),Hg(e,t,n,r),Jg(e,t,n,r),Yg(e,t,n,r)}function Ev(e,t,n=[]){if(z.diffValue(e,t))return[];if(t&&typeof t==`object`&&!Array.isArray(t)&&(e==null||typeof e==`object`&&!Array.isArray(e))){let r=e??{},i=t,a=Array.from(new Set([...Object.keys(r),...Object.keys(i)]));return!a.length&&n.length?[n]:a.flatMap(e=>Ev(r[e],i[e],[...n,e]))}return[n]}function Dv(e){if(!Array.isArray(e)||e.some(e=>!Array.isArray(e)||!e.length||e.some(e=>typeof e!=`string`||[`__proto__`,`prototype`,`constructor`].includes(e))))throw Error(`Invalid custom range property paths.`)}function Ov(e,t,n){Dv(n);let r=z.deepClone(e);for(let e of n){let n=r.properties??={},i=t.properties,a=[];for(let t=0;t<e.length;t++){let r=e[t];i=i&&typeof i==`object`?i[r]:void 0,t===e.length-1?i===void 0?delete n[r]:n[r]=z.deepClone(i):((!n[r]||typeof n[r]!=`object`||Array.isArray(n[r]))&&(n[r]={}),a.push({object:n,key:r,value:i}),n=n[r])}for(let e of a.reverse())e.value===void 0&&Object.keys(e.object[e.key]).length===0&&delete e.object[e.key]}return t.properties===void 0&&!Object.keys(r.properties??{}).length&&delete r.properties,r}function kv(e,t){if(!e||!t.propertyPaths||!t.range)return t;if(!e.range)return e;let n=e.propertyPaths&&[...e.propertyPaths,...t.propertyPaths.filter(t=>!e.propertyPaths.some(e=>e.length<=t.length&&e.every((e,n)=>t[n]===e)))];return{...e,range:Ov(e.range,t.range,t.propertyPaths),propertyPaths:n}}function Av(e,t,n){if(!t||!e.range)return[e];if(!t.range)return[];if(!e.propertyPaths||!t.propertyPaths)return n===`left`?[{...e,propertyPaths:void 0}]:[];let r=e.propertyPaths.filter(e=>n===`left`||!t.propertyPaths.some(t=>e.slice(0,Math.min(e.length,t.length)).every((e,n)=>t[n]===e))).map(e=>t.propertyPaths.find(t=>t.length<e.length&&t.every((t,n)=>e[n]===t))??e);return r.length?[{...e,propertyPaths:r}]:[]}function jv(e){let t=new Map;for(let n of e)if(n.t===`r`)for(let e of n.rangeUpdates??[])t.set(e.rangeId,kv(t.get(e.rangeId),e));return t.size?z.deepClone(Array.from(t.values())):[]}function Mv(e){return e.flatMap(e=>{if(e.t===`i`&&e.len>1&&Array.from(e.body.dataStream).every(e=>e===``||e===``))return Array.from(e.body.dataStream,(t,n)=>({...e,len:1,body:uv(e.body,n,n+1,!1)}));if(e.t!==`r`||!e.rangeUpdates)return[e];let{rangeUpdates:t,oldRangeUpdates:n,...r}=e;return r.len===0&&!r.body?[]:[r]})}function Nv(e,t){return t!=null&&t.length?[...e,{t:`r`,len:0,rangeUpdates:t}]:e}function Pv(e,t){for(let{rangeId:n,range:r,nextRangeId:i,propertyPaths:a}of e??[]){if(a!==void 0&&(Dv(a),!r))throw Error(`Invalid custom range property paths.`);if(typeof n!=`string`||!n||i!=null&&typeof i!=`string`||r!==null&&(typeof r!=`object`||!r||Array.isArray(r)||r.rangeId!==n||!Number.isInteger(r.startIndex)||!Number.isInteger(r.endIndex)||r.startIndex<0||r.endIndex<r.startIndex||r.endIndex>=t))throw Error(`Invalid custom range identity or bounds.`)}}function Fv(e,t){if(!(t!=null&&t.length))return;let n=e.customRanges??[];for(let{rangeId:e,range:r,nextRangeId:i,propertyPaths:a}of[...t].reverse()){let t=n.findIndex(t=>t.rangeId===e);if(r&&a){t>=0&&(n[t]=Ov(n[t],r,a));continue}if(r){if(i!==void 0){t>=0&&n.splice(t,1);let e=n.findIndex(e=>e.rangeId===i);n.splice(e<0?n.length:e,0,z.deepClone(r))}else t>=0?n[t]=z.deepClone(r):n.push(z.deepClone(r))}else t>=0&&n.splice(t,1)}e.customRanges=n}function Iv(e,t,n=!1){return e.map(e=>{var r;let{rangeId:i,range:a}=e;if(!a&&n)return e;let o={dataStream:``,customRanges:a?[z.deepClone(a)]:[]},s=0;for(let e of t){var c;if(e.t===`i`){var l;Jg(o,{dataStream:``,customRanges:z.deepClone((l=e.body.customRanges)==null?void 0:l.filter(e=>e.rangeId===i))},e.len,s)}else if(e.t===`d`){o_(o,e.len,s);continue}else(c=e.body)!=null&&c.customRanges&&y_(o,{dataStream:``,customRanges:z.deepClone(e.body.customRanges.filter(e=>e.rangeId===i))},e.len,s,e.coverType??0);s+=e.len}let u=(r=o.customRanges)==null?void 0:r.find(e=>e.rangeId===i);return{...e,propertyPaths:u?e.propertyPaths:void 0,range:u&&a&&n?{...z.deepClone(a),startIndex:u.startIndex,endIndex:u.endIndex}:u??null}})}function Lv(e,t){let n=new Map(t==null?void 0:t.map(e=>[e.rangeId,e]));return n.size?e.map(e=>{var t;return(t=e.body)!=null&&t.customRanges?{...e,body:{...e.body,customRanges:e.body.customRanges.flatMap(e=>{if(!n.has(e.rangeId))return[e];let t=n.get(e.rangeId);return t.range?[{...t.propertyPaths?Ov(e,t.range,t.propertyPaths):z.deepClone(t.range),startIndex:e.startIndex,endIndex:e.endIndex}]:[]})}}:e}):e}function Rv(e,t,n){if(!t.length)return Nv(e,n);let r=[],i=[],a=0,o=0;for(let n of e){var s;let e=(s=n.body)==null?void 0:s.dataStream;n.t===`i`&&n.len===1&&t.some(t=>e===``&&a===t.startIndex||e===``&&a===t.endIndex)?(a>o&&i.push({t:`r`,len:a-o}),i.push({t:`d`,len:1}),o=a+1):r.push(n),n.t!==`d`&&(a+=n.len)}return Nv(r,Iv(n,i))}function zv(e,t,n,r,i=0){return y_(e,t,n,r,i)}function Bv(e,t,n){return t<=0?{dataStream:``}:wv(e,t,n)}function Vv(e,t,n,r){n!==0&&Tv(e,t,n,r)}function Hv(e,t){if(t.some(e=>e.t!==`r`&&e.valueRangeId!==void 0&&(typeof e.valueRangeId!=`string`||!e.valueRangeId)))throw Error(`Invalid scalar value range identity.`);let n=jv(t);n.length&&Pv(n,t.reduce((e,t)=>t.t===`i`?e+t.len:t.t===`d`?e-t.len:e,e.dataStream.length));let r=new sm;return r.reset(),t.forEach(t=>{switch(t.t){case`r`:{let{coverType:n,body:i,len:a}=t;i!=null&&zv(e,z.deepClone(i),a,r.cursor,n),r.moveCursor(a);break}case`i`:{let{body:n,len:i}=t;Vv(e,Uv(n)?n:z.deepClone(n),i,r.cursor),r.moveCursor(i);break}case`d`:{let{len:n}=t;Bv(e,n,r.cursor);break}default:throw Error(`Unknown action type for action: ${t}.`)}}),Fv(e,n),e}function Uv(e){return Object.keys(e).length===1&&typeof e.dataStream==`string`}function Wv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=z.deepClone(t),e=z.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===0)_={...f},n===0&&r===1&&h&&(_=Object.assign({},h,_));else if(_={...f},n===1){if(r===1)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===1){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Cg(a,!0)}function Gv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===1)return i===1?[z.deepClone(a)]:[z.deepClone(o)];if(r===1){let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}{let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}}function Kv(e,t,n,r,i){let a={startIndex:t.startIndex,paragraphId:t.paragraphId};if(t.paragraphStyle&&(a.paragraphStyle=z.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===1){if(r===1)i===1&&(a.paragraphStyle={...e.paragraphStyle});else if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(r===1){if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(i===1){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}return n===1&&r===1?a.bullet=i===1?z.deepClone(e.bullet):z.deepClone(t.bullet):e.bullet===void 0?a.bullet=z.deepClone(t.bullet):n===1||r===1?a.bullet=i===0&&t.bullet?z.deepClone(t.bullet):z.deepClone(e.bullet):i===0&&t.bullet!==void 0&&(a.bullet=z.deepClone(t.bullet)),a.bullet===void 0&&delete a.bullet,a}function qv(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return z.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===9999||i===9999)&&(a=!0,n.push({...r,type:9999}));break}a||n.push(r)}return n}function Jv(e,t,n=!1){let{body:r,coverType:i=0}=e,{body:a,coverType:o=0}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],blockRanges:d=[],customRanges:f,customDecorations:p}=r,{textRuns:m,paragraphs:h=[],blockRanges:g=[],customRanges:_,customDecorations:v}=a,y=Wv(l,m,i,o,+!!n);y&&(s.textRuns=y);let b=Gv(f,_,i,o,+!!n);b&&(s.customRanges=b);let x=qv(p,v);x&&(s.customDecorations=x);let S=[],C=0,w=0;for(;C<u.length&&w<h.length;){let e=u[C],t=h[w],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r,paragraphId:t.paragraphId};a=n?Kv(e,t,i,o,1):Kv(e,t,i,o,0),S.push(a),C++,w++}else r<a?C++:(S.push(z.deepClone(t)),w++)}w<h.length&&S.push(...h.slice(w)),S.length&&(s.paragraphs=S);let T=Yv(d,g,n);return T.length&&(s.blockRanges=T),{coverType:c,body:s}}function Yv(e,t,n){return e.length?t.length?t.map(t=>{let r=e.find(e=>e.blockId===t.blockId);return r&&n?na(t,r):t}):[]:t}function Xv(e){return Object.keys(e).length===1}function Zv(e){return new Set(e.flatMap(e=>e.t!==`r`&&e.valueRangeId?[e.valueRangeId]:[]))}function Qv(e,t){return e.map(e=>{var n,r;if(!((n=e.body)!=null&&(n=n.customRanges)!=null&&n.some(e=>t.has(e.rangeId))))return e;let i={...e.body,customRanges:e.body.customRanges.filter(e=>!t.has(e.rangeId))};return(r=i.customRanges)!=null&&r.length||delete i.customRanges,{...e,body:i}})}function $v(e,t,n){if((e==null?void 0:e.t)!==`i`||(t==null?void 0:t.t)!==`i`)return n===`left`;let r=e.body.dataStream,i=t.body.dataStream;return r===i?n===`left`:r===``||i===``?!0:r===``||i===``?!1:n===`left`}function ey(e,t,n,r){Eg(t.paragraphs,e.paragraphs,n,{freshenSplitParagraph:!1,preserveExplicitParagraphIds:!!e[rg],reservedParagraphIds:r,dataStream:t.dataStream})}var X=class e{constructor(){T(this,`_actions`,[])}static apply(e,t){return Hv(e,t)}static compose(t,n){let r=jv(t),i=jv(n);if(r.length||i.length){let a=Mv(t),o=Mv(n),s=new Map(Iv(r,o).map(e=>[e.rangeId,e]));for(let e of i)s.set(e.rangeId,kv(s.get(e.rangeId),e));return Nv(e.compose(a,o),Array.from(s.values()))}let a=new Cv(t),o=new Cv(n),s=new e;for(;a.hasNext()||o.hasNext();)if(o.peekType()===`i`)s.push(o.next());else if(a.peekType()===`d`)s.push(a.next());else{let e=Math.min(a.peekLength(),o.peekLength()),t=a.next(e),n=o.next(e);if(t.t===`i`&&n.t===`r`)n.body==null?s.push(t):s.push({...t,body:vv(t.body,n.body,n.coverType)});else if(t.t===`r`&&n.t===`r`){if(t.body==null&&n.body==null)s.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=+(t.coverType===1||n.coverType===1);s.push({...t,t:`r`,coverType:e,body:vv(t.body,n.body,n.coverType)})}else s.push(t.body?t:n)}else t.t===`r`&&n.t===`d`?s.push(n):t.t===`i`&&n.t}return s.trimEndUselessRetainAction(),s.serialize()}static transform(t,n,r=`right`){let i=jv(t),a=jv(n);if(i.length||a.length){let o=Mv(t),s=Mv(n),c=Iv(i,e._transform(o,s,r,!0),!0),l=c.flatMap(e=>Av(e,a.find(t=>t.rangeId===e.rangeId),r)),u=c.flatMap(e=>e.range&&a.some(t=>t.rangeId===e.rangeId&&!t.range)?[e.range]:[]);return Rv(Lv(e._transform(s,o,r===`left`?`right`:`left`,!0),a),u,l)}return this._transform(n,t,r===`left`?`right`:`left`)}static _transform(t,n,r=`right`,i=!1){let a=Zv(t),o=new Set(Array.from(Zv(n)).filter(e=>a.has(e))),s=new Cv(o.size&&r===`right`?Qv(t,o):t),c=new Cv(o.size&&r===`left`?Qv(n,o):n),l=new e;for(;s.hasNext()||c.hasNext();)if(s.peekType()===`i`&&((i?$v(s.peek(),c.peek(),r):r===`left`)||c.peekType()!==`i`)){let e=s.next();e.t===`i`&&e.valueRangeId&&o.has(e.valueRangeId)&&r===`right`?l.push({t:`d`,len:e.len,valueRangeId:e.valueRangeId}):l.retain(e.len)}else if(c.peekType()===`i`){let e=c.next();(e.t!==`i`||!e.valueRangeId||!o.has(e.valueRangeId)||r!==`left`)&&l.push(e)}else{let e=Math.min(s.peekLength(),c.peekLength()),t=s.next(e),n=c.next(e);if(t.t===`d`)continue;if(n.t===`d`){l.push(n);continue}if(t.body==null||n.body==null)l.push(n);else{let{coverType:e,body:i}=Jv(t,n,r===`left`);l.push({...n,t:`r`,coverType:e,body:i})}}return l.trimEndUselessRetainAction(),l.serialize()}static transformPosition(e,t,n=!1){let r=new Cv(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();if(r.next(),a===`d`){t-=Math.min(e,t-i);continue}a===`i`&&(i<t||!n)&&(t+=e),i+=e}return t}static isNoop(e){return e.length===0}static invert(t){if(jv(t).length){let n=t.flatMap(e=>{if(e.t!==`r`||!e.rangeUpdates)return[];if(!e.oldRangeUpdates)throw Error(`makeInvertible must capture custom ranges before inversion.`);return e.oldRangeUpdates});return Nv(e.invert(Mv(t)),z.deepClone(n))}let n=[];for(let e of t)if(e.t===`i`)n.push({t:`d`,len:e.len,body:e.body,valueRangeId:e.valueRangeId});else if(e.t===`d`){var r;if(e.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);(r=e.body.paragraphs)!=null&&r.length&&(e.body[Sg]=!0,Reflect.set(e.body,rg,!0)),n.push({t:`i`,body:e.body,len:e.len,valueRangeId:e.valueRangeId})}else if(e.body!=null){if(e.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);n.push({t:`r`,body:e.oldBody,oldBody:e.body,len:e.len,coverType:1})}else n.push(e);return n}static makeInvertible(e,t){let n=[],r=0,i=new Set,a=new Set;for(let s of e){if(s.t===`r`&&s.rangeUpdates&&(s.oldRangeUpdates=s.rangeUpdates.map(({rangeId:e,propertyPaths:n})=>{var r,i;let a=((r=t.customRanges)==null?void 0:r.findIndex(t=>t.rangeId===e))??-1;return{rangeId:e,range:a<0?null:z.deepClone(t.customRanges[a]),nextRangeId:a<0?void 0:((i=t.customRanges[a+1])==null?void 0:i.rangeId)??null,propertyPaths:a<0?void 0:n}})),s.t===`i`&&(ey(s.body,t,r,i),Ng(t.sectionBreaks,s.body.sectionBreaks,a)),s.t===`d`&&(s.body==null||s.body&&s.body.dataStream.length!==s.len)){let e=lv(t,r,r+s.len,!1);s.len=e.dataStream.length,s.body=e}if(s.t===`r`&&s.body!=null){let e=cv(t,r,r+s.len,!0);for(let t of[`tables`,`columnGroups`,`blockRanges`])s.body[t]??delete e[t];if(s.body.paragraphs==null)delete e.paragraphs;else{var o;let t=new Map((o=e.paragraphs)==null?void 0:o.map(e=>[e.startIndex,e]));s.body.paragraphs=s.body.paragraphs.map(e=>{let n=t.get(e.startIndex);if(!n||e.paragraphId!=null&&e.paragraphId!==n.paragraphId)return e;let r={...e};return Reflect.deleteProperty(r,`paragraphId`),Reflect.deleteProperty(n,`paragraphId`),r})}s.oldBody={...e,dataStream:``},s.len=e.dataStream.length}n.push(s),s.t!==`i`&&(r+=s.len)}return n}updateCustomRangeProperties(e,t){let n=Ev(e.properties??{},t);return n.length&&this.updateCustomRanges([{rangeId:e.rangeId,range:{...e,properties:t},propertyPaths:n}]),this}updateCustomRanges(e){return this.push({t:`r`,len:0,rangeUpdates:e}),this}insert(e,t){let n={t:`i`,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:`r`,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:`d`,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=z.deepClone(e[0]);if(r.t===`r`&&r.len===0&&r.body==null&&!r.rangeUpdates)return this;if(typeof n==`object`){if(n.t===`d`&&r.t===`d`&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,this;if(n.t===`d`&&r.t===`i`&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===`r`&&r.t===`r`&&n.body==null&&r.body==null&&!n.rangeUpdates&&!r.rangeUpdates)return n.len+=r.len,this;if(n.t===`i`&&Xv(n.body)&&r.t===`i`&&Xv(r.body)&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===`r`&&xv(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};T(X,`id`,`text-x`),T(X,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(X,"name",{value:`text-x`});var ty=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==X.id||(this._subTypes.set(e.name,e),ng.type.registerSubtype(e))}static apply(e,t){if(!ng.type.isNoop(t))return ng.type.apply(e,t)}static compose(e,t){return ng.type.compose(e,t)}static transform(e,t,n){return ng.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===X.name?X.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return ng.type.invertWithDoc(e,t)}static isNoop(e){return ng.type.isNoop(e)}static getInstance(){return this._instance??=new e,this._instance}removeOp(e,t){return ng.removeOp(e,t)}moveOp(e,t){return ng.moveOp(e,t)}insertOp(e,t){return ng.insertOp(e,t)}replaceOp(e,t,n){return ng.replaceOp(e,t,n)}editOp(e,t=[`body`]){return ng.editOp(t,X.name,e)}};T(ty,`uri`,`https://github.com/dream-num/univer#json-x`),T(ty,`_subTypes`,new Map),T(ty,`_instance`,null),ty.registerSubtype(X);let ny=[``,`\x1B`,``,``,``,``,``,``],ry=e=>{let t=ny.reduce((e,t)=>e.replaceAll(t,``),e);return t.endsWith(`\r
7
+ `)?t.slice(0,-2):t},iy=e=>!e||ry(e).replaceAll(`\r`,``)===``,ay=e=>{let t=e.replace(/\r\n?|\n/g,`\r`),n=[],r=new Set,i=[],a=0,o=``,s=(s,c=!0)=>{let l=t.slice(a,s);if(z.isLegalUrl(l)){let t=J(),u=`${l}`,d={startIndex:a,endIndex:a+u.length-1,rangeId:t,rangeType:0,properties:{url:e}};i.push(d),o+=u,a=s+1,c&&(o+=`\r`,n.push({startIndex:s,paragraphId:Bh(r)}))}else o+=t.slice(a,s+1),a=s+1,c&&n.push({startIndex:s,paragraphId:Bh(r)})},c=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(s(e),c=e);return(c!==t.length-1||t.length===1)&&s(t.length,!1),{dataStream:o,paragraphs:n,customRanges:i}},oy={id:`default_doc`,documentStyle:{}};function sy(e){if((e==null?void 0:e.dataStream)==null||e.sectionBreaks==null)return e;let t=e.sectionBreaks.filter(({startIndex:t})=>e.dataStream[t]===`
8
+ `||t<=0||e.dataStream[t-1]!==`\f`),n=new Set,r=t.length!==e.sectionBreaks.length,i=t.map(e=>e.sectionId&&!n.has(e.sectionId)?(n.add(e.sectionId),e):(r=!0,{...e,sectionId:_m(n)}));return r?{...e,sectionBreaks:i}:e}function cy(e){var t,n;if(e.id!=null&&Ap(e.id))return{...oy,...e};let r=Kh(e.id,e.locale,e.title,(t=e.documentStyle)==null?void 0:t.documentFlavor);if(z.isEmptyObject(e))return r;let i=ta({},r,e,(e,t,n)=>{if(Array.isArray(t)||n===`body`&&typeof t==`object`&&t)return t});return e.body!=null&&((n=e.documentStyle)==null?void 0:n.defaultParagraphStyle)===void 0&&delete i.documentStyle.defaultParagraphStyle,i.body=sy(i.body),i}var ly=class extends M{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){super(),T(this,`type`,n.UniverType.UNIVER_DOC),T(this,`_name$`,new t.BehaviorSubject(``)),T(this,`name$`,this._name$.asObservable()),T(this,`snapshot`,void 0),T(this,`_mutationRevision`,0),this.snapshot=cy(e),this._name$.next(this.snapshot.title??`No Title`)}getRev(){return this.snapshot.rev??1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._markMutation(),this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t,this._markMutation()}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){let e=this.snapshot.lists??{};return{...h_,...e}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig=t.renderConfig==null?e:{...t.renderConfig,...e},this._markMutation()}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e},this._markMutation()}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i),this._markMutation()}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;if(!n.pageSize){n.pageSize={width:e??1/0,height:t??1/0},this._markMutation();return}e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t),this._markMutation()}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o,this._markMutation()}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e},this._markMutation()}setDisabled(e){this.snapshot.disabled=e,this._markMutation()}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}getMutationRevision(){return this._mutationRevision}_markMutation(){this._mutationRevision++}},uy=class e extends ly{constructor(e){super(z.isEmptyObject(e)?Kh():e),T(this,`_unitId`,void 0),T(this,`headerModelMap`,new Map),T(this,`footerModelMap`,new Map),T(this,`noteModelMap`,new Map),T(this,`change$`,new t.BehaviorSubject(0)),this._unitId=this.snapshot.id??J(6),this._initializeHeaderFooterModel(),this._name$.next(this.snapshot.title??``)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this.noteModelMap.forEach(e=>e.dispose()),this.noteModelMap.clear(),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot=cy(e),this._initializeHeaderFooterModel(),this._markMutation(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){return e==null||e===``?this:this.headerModelMap.has(e)?this.headerModelMap.get(e):this.footerModelMap.has(e)?this.footerModelMap.get(e):this.noteModelMap.has(e)?this.noteModelMap.get(e):null}getUnitId(){return this._unitId}apply(e){if(ty.isNoop(e))return;let t=this.snapshot.notes,n=new Set,r=!1,i=ng.type.readCursor(e);return i.traverse(null,()=>{let e=i.getPath();e[0]===`notes`&&typeof e[1]==`string`&&n.add(e[1]),(e[0]===`styles`||e[0]===`documentStyle`)&&(r=!0)}),this.snapshot=ty.apply(this.snapshot,e),this._markMutation(),(r||t!==this.snapshot.notes||n.size>0)&&this._initializeNoteModels(r?void 0:t,n),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=0){let r=this.getBody();if(r!=null)return cv(r,e,t,!1,n)}_initializeHeaderFooterModel(){this._initializeNoteModels();let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}_initializeNoteModels(t,n){for(let[e,i]of this.noteModelMap){var r;(n!=null&&n.has(e)||(t==null?void 0:t[e])!==((r=this.snapshot.notes)==null?void 0:r[e])||!(t!=null&&t[e]))&&(i.dispose(),this.noteModelMap.delete(e))}for(let[t,n]of Object.entries(this.snapshot.notes??{})){if(this.noteModelMap.has(t))continue;let r=new e({...n,id:this.getUnitId(),documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles});this.noteModelMap.set(t,r)}}updateDocumentStyle(e){super.updateDocumentStyle(e),this._initializeNoteModels()}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e;return ry(((e=this.getBody())==null?void 0:e.dataStream)??``)}getStatistics(e={}){var t;return jm(((t=this.getBody())==null?void 0:t.dataStream)??``,e)}};function dy(e){if(e==null)return{};let t=z.deepClone(e);return z.removeNull(t),t}function fy(e,t){if(!e||!t)return{};let n=new Set,r=t=>{if(n.has(t))return{};let i=e[t];if(!i||i.type!==1)return{};n.add(t);let a=i.basedOn?r(i.basedOn):{};return n.delete(t),{...a,...dy(i.paragraphStyle)}};return r(t)}function py(e,t,n={}){let r=n.useLegacyModernDefaults??(e==null?void 0:e.documentFlavor)===2?{lineSpacing:Nh,spaceAbove:{v:0},spaceBelow:{v:12}}:{},i={...(e==null?void 0:e.documentFlavor)===1?{widowControl:1}:{},...r,...dy(e==null?void 0:e.defaultParagraphStyle)};n.excludeDocumentOuterSpacing&&(delete i.spaceAbove,delete i.spaceBelow);let a=dy(t),o=fy(n.styles,n.paragraphStyleId),s=a.namedStyleType??o.namedStyleType,c=s==null?null:Ph[s];return z.deepClone({...i,...c,...o,...a})}function my(e,t,n,r){if(t===``)return e;let i=new uy({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o;for(;(o=(r?i.getBody().dataStream:i.getBody().dataStream.toLowerCase()).indexOf(t))>=0;){let e=new X,t=ty.getInstance();if(o>0&&e.retain(o),n.length>0){var s;let t=i.sliceBody(o,o+a),r={dataStream:n};Array.isArray(t==null?void 0:t.textRuns)&&t.textRuns.length&&(r.textRuns=[{...t.textRuns[0],st:0,ed:n.length}]),t!=null&&(s=t.customRanges)!=null&&s.length&&(r.customRanges=[{...t.customRanges[0],startIndex:0,endIndex:n.length-1}]),e.insert(n.length,r)}e.delete(a),i.apply(t.editOp(e.serialize()))}let c=i.getBody();return i.dispose(),c}function hy(e){let{ranges:t,id:n,type:r}=e,i=new X,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:`r`,len:o-a}),i.push({t:`r`,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function gy(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new X,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:`r`,len:c}),s.push({t:`r`,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:9999}]}}),s}function _y(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function vy(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?hg(ug(i),e.startOffset)&&n.push(i):gg({startOffset:e.startOffset,endOffset:e.endOffset},ug(i))&&n.push(i)}return n}function yy(e){return{...z.deepClone(e),rangeId:J()}}function by(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function xy(e,t,n,r){let i=[],a=ag({startIndex:e,endIndex:t});for(let e=0,o=n.length;e<o;e++){let o=n[e];if((r===void 0||o.rangeType===r)&&gg(a,ug(o))&&i.push({...o}),o.startIndex>t)break}return i}function Sy(e,t){var n,r;let i=xy(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,t.customRanges??[]),a=Math.min(e.startOffset,((n=i[0])==null?void 0:n.startIndex)??1/0),o=Math.max(e.endOffset,(((r=i[i.length-1])==null?void 0:r.endIndex)??-1/0)+1);return{startOffset:a,endOffset:o,collapsed:a===o}}var Cy=h(f(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;){if(a<e.length-1&&!e[a][1]){e.splice(a,1);continue}switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``}}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O}))());function wy(e){var t;let{rangeId:n,segmentId:r,documentDataModel:i,insert:a}=e,o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===n);if(!o)return!1;let{startIndex:s,endIndex:c}=o,l=new X,u=c-s+1;l.push({t:`r`,len:s}),l.push({t:`r`,len:u,body:{dataStream:``,customRanges:[]}}),a&&l.push({t:`i`,body:a,len:a.dataStream.length});let d=c+1+((a==null?void 0:a.dataStream.length)??0);return l.selections=[{startOffset:d,endOffset:d,collapsed:!0}],l}function Ty(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new X,l=!1;return t.forEach(e=>{let t=Sy(e,o);if(!t||!o)return!1;let{startOffset:u,endOffset:d}=t,f=o.customRanges??[],p=(e,t,o)=>{var l,u;let d=xy(e,t,f,r),p=Math.min(((l=d[0])==null?void 0:l.startIndex)??1/0,e),m=Math.max(((u=d[d.length-1])==null?void 0:u.endIndex)??-1/0,t),h={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:m-p,wholeEntity:i,properties:{...a}};c.push({t:`r`,len:p-s}),c.push({t:`r`,len:m-p+1,body:{dataStream:``,customRanges:[h]},coverType:0}),s=m+1},m=(o.paragraphs??[]).filter(e=>e.startIndex<d&&e.startIndex>u),h=(o.customBlocks??[]).filter(e=>e.startIndex<d&&e.startIndex>u);by([u,d-1],[...m.map(e=>e.startIndex),...h.map(e=>e.startIndex)]).forEach(([e,t],n)=>p(e,t,n)),l=!0,c.selections=[{startOffset:t.endOffset,endOffset:t.endOffset,collapsed:!0}]}),l?c:!1}function Ey(e,t){return!!(e.atomicRange&&t.some(t=>t.startOffset<=e.atomicRange.startOffset&&t.endOffset>=e.atomicRange.endOffset))}let Dy=new Set([`\r`,`
9
+ `]),Oy=new Set([...Dy,``,``,``,``]);function ky(e){let t=e.filter(e=>e.endOffset>e.startOffset).map(e=>({...e,collapsed:!1})).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),n=[];for(let e of t){let t=n[n.length-1];if(t&&e.startOffset<=t.endOffset){t.endOffset=Math.max(t.endOffset,e.endOffset);continue}n.push(e)}return n}function Ay(e,t,n,r){let i=e.startOffset,a=!1;for(let o of t){if(o.endOffset<=i||o.startOffset>=e.endOffset)continue;a=!0;let t=Math.max(o.startOffset,e.startOffset),s=Math.min(o.endOffset,e.endOffset);for(let e=i;e<t;e++)if(!r.has(n.dataStream[e]))return!1;if(i=Math.max(i,s),i>=e.endOffset)return!0}for(let t=i;t<e.endOffset;t++)if(!r.has(n.dataStream[t]))return!1;return a}function jy(e,t,n,r){let i=[...e],a=e[0];for(let e of t)Ay(e,i,n,r)&&i.push({...a,...e,collapsed:!1});return ky(i)}function My(e,t){let n=ky(e);n=jy(n,(t.blockRanges??[]).map(cg),t,Dy),n=jy(n,(t.customRanges??[]).map(ug),t,Dy),n=jy(n,(t.columnGroups??[]).map(lg),t,Oy);let r=Math.max(0,t.dataStream.length-2);return r>0&&(n=jy(n,[{startOffset:0,endOffset:r}],t,Dy)),n}function Ny(e,t){return t.some(t=>e>=t.startOffset&&e<t.endOffset)}function Py(e,t){return e>=t.startOffset&&e<=t.endOffset}function Fy(e,t,n){e.length&&e.every(e=>Ny(e,t))&&n.add(e[e.length-1])}function Iy(e,t,n){let r=(e.columnGroups??[]).map(lg).filter(e=>t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset));for(let i=0;i<e.dataStream.length;i++){let a=e.dataStream[i];(a===``||a===``||a===``||a===``)&&Ny(i,t)&&!r.some(e=>i>=e.startOffset&&i<e.endOffset)&&n.add(i)}}function Ly(e,t,n){for(let r of e.blockRanges??[]){let e=cg(r);t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset)||(Ny(r.startIndex,t)&&n.add(r.startIndex),Ny(r.endIndex,t)&&n.add(r.endIndex))}}function Ry(e){let t=[...e.blockRanges??[]].sort((e,t)=>e.startIndex-t.startIndex),n=t.map(e=>{let t=cg(e);return{atomicRange:t,startOffset:t.startOffset+1,endOffset:t.endOffset-1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`}}),r=(e,r)=>{let i=0,a=t.length-1,o=-1;for(;i<=a;){let n=Math.floor((i+a)/2),r=t[n];if(e<=r.startIndex)a=n-1;else if(e>=r.endIndex)i=n+1;else{o=n;break}}o>=0&&n[o][r].push(e)};return(e.paragraphs??[]).forEach(e=>r(e.startIndex,`paragraphs`)),(e.sectionBreaks??[]).forEach(e=>r(e.startIndex,`sectionBreaks`)),n}function zy(e){let t=[{startOffset:0,endOffset:e.dataStream.length,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`}],n=[],r=[],i=()=>r.length?r[r.length-1]:n.length?n[n.length-1]:t[0];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)n.push({atomicRange:{startOffset:a,endOffset:a+1},startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`});else if(o===``){let e=n.pop();e&&(e.endOffset=a,e.atomicRange&&(e.atomicRange.endOffset=a+1),t.push(e))}else if(o===``)r.push({startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`});else if(o===``){let e=r.pop();e&&(e.endOffset=a,t.push(e))}else o===`\r`?i().paragraphs.push(a):o===`
10
+ `&&i().sectionBreaks.push(a)}return t.push(...Ry(e)),t}function By(e,t,n,r,i){if(Ey(e,t))return;let a=n&&Py(r,e),o=(n==null?void 0:n.dataStream)??``,s=o.includes(`\r`),c=o.includes(`
11
+ `);if(e.require===`paragraph-or-section`){let n=[...e.paragraphs,...e.sectionBreaks].sort((e,t)=>e-t);(!a||!s&&!c)&&Fy(n,t,i);return}(!a||!s)&&Fy(e.paragraphs,t,i),(!a||!c)&&Fy(e.sectionBreaks,t,i)}function Vy(e,t,n){if(!e.length)return e;let r=n==null?My(e,t):e;if(!r.length)return e;let i=r[0].startOffset,a=new Set;if(zy(t).forEach(e=>{By(e,r,n,i,a)}),Iy(t,r,a),Ly(t,r,a),!a.size)return r;let o=[];return r.forEach(e=>{let t=e.startOffset;for(let n=e.startOffset;n<e.endOffset;n++)a.has(n)&&(t<n&&o.push({...e,startOffset:t,endOffset:n,collapsed:!1}),t=n+1);t<e.endOffset&&o.push({...e,startOffset:t,endOffset:e.endOffset,collapsed:!1})}),o.length?o:[{...r[0],endOffset:r[0].startOffset,collapsed:!0}]}function Hy(e,t,n=0,r=null,i=!0,a){let o=Vy([...e].sort((e,t)=>e.startOffset-t.startOffset),t,r),s=[],{paragraphs:c=[]}=t,l=c==null?void 0:c.find(e=>e.startIndex>=o[0].startOffset&&e.startIndex<o[0].endOffset),u=n;if(o.forEach(e=>{var n;let{startOffset:i,endOffset:l}=e;i>u&&(s.push({t:`r`,len:i-u}),u=i),u<l&&(s.push({t:`d`,len:l-u}),u=l);let d=a===2&&o.length===1&&!r&&i<l?c.find(e=>e.startIndex===l&&U_(t,e)===i):void 0;if(d&&((n=d.paragraphStyle)==null?void 0:n.paragraphMarkTextStyle)==null){var f;let e=((f=t.textRuns)==null||(f=f.find(e=>e.st<=i&&e.ed>i))==null?void 0:f.ts)??{};s.push({t:`r`,len:1,body:{dataStream:``,textRuns:[{st:0,ed:1,ts:{...e}}]},coverType:1}),u++}}),r&&s.push({t:`i`,body:r,len:r.dataStream.length}),l!=null&&l.bullet&&i){let e=c.find(e=>e.startIndex-n>=o[o.length-1].endOffset-1);e&&(e.startIndex>u&&(s.push({t:`r`,len:e.startIndex-u}),u=e.startIndex),s.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...e,startIndex:0,bullet:l==null?void 0:l.bullet}]},coverType:0}))}return s}function Uy(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:`r`,len:n-i}),i=n),a>i&&(r.push({t:`r`,len:a-i,body:{...z.deepClone(t),dataStream:``}}),i=a)}),r}let Wy=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=Vy([n],o,r);if(s.length!==1||s[0].startOffset!==n.startOffset||s[0].endOffset!==n.endOffset){let e=new X;return e.push(...Hy([n],o,0,r)),e}let c=n.collapsed?null:cv(o,n.startOffset,n.endOffset),l=(0,Cy.default)(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e={t:`r`,body:{...lv(r,u,u+t.length,!1),dataStream:``},len:t.length};return u+=t.length,e}case 1:{let e={t:`i`,body:lv(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:`d`,len:t.length}}}),f=new X;return f.push({t:`r`,len:n.startOffset}),f.push(...d),f};function Gy(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}let Ky=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=Vy([n],s,r);if(c.length!==1||c[0].startOffset!==n.startOffset||c[0].endOffset!==n.endOffset){let e=new X;return e.push(...Hy([n],s,0,r)),e}let l=n.collapsed?null:cv(s,n.startOffset,n.endOffset),u=(0,Cy.default)(l?l.dataStream:``,r.dataStream),d=0,f=u.map(([e,t])=>{switch(e){case 0:{let e=Z_(r,d,d+t.length,!1),n={t:`r`,body:Gy(e,Z_(l,d,d+t.length,!1))?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r;return{...e,ts:{...e.ts,cl:(t=e.ts)!=null&&(t=t.cl)!=null&&(t=t.rgb)!=null&&t.includes(`.`)?{rgb:a.getColorFromTheme(((n=e.ts)==null||(n=n.cl)==null?void 0:n.rgb)??``)}:(r=e.ts)==null?void 0:r.cl}}}),dataStream:``},len:t.length};return d+=t.length,n}case 1:{let e={t:`i`,body:lv(r,d,d+t.length),len:t.length};return d+=t.length,e}default:return{t:`d`,len:t.length}}});if(f.every(e=>e.t===`r`&&!e.body))return!1;let p=new X;return p.push({t:`r`,len:n.startOffset}),p.push(...f),p};function qy(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(t!=null&&i!=null)for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function Jy(e,t,n=e.body,r=``){var i;if(!n)return[];let a=(i=e.notes)==null?void 0:i[r],o=a??e,s=a?[`notes`,r]:[],c=o.drawings??{},l=o.drawingsOrder??[],u=new Set(qy(n,t)),d=-1;for(;d!==u.size;){d=u.size;for(let e of Object.values(c))e.groupId&&u.has(e.groupId)&&u.add(e.drawingId)}let f=[...u].sort((e,t)=>l.indexOf(t)-l.indexOf(e)),p=ty.getInstance(),m=[];for(let e of f){let t=c[e];if(t!=null){let n=p.removeOp([...s,`drawings`,e],t);n&&m.push(n)}let n=l.indexOf(e);if(n>=0){let t=p.removeOp([...s,`drawingsOrder`,n],e);t&&m.push(t)}}return m}let Yy=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new X,u=ty.getInstance(),d=[],f=(t=i.getSelfOrHeaderFooterModel(c))==null?void 0:t.getBody();if(!f)return!1;let p=i.getSnapshot(),m=(n=p.notes)==null?void 0:n[c??``],h=m??p,g=m?[`notes`,c]:[],_=h.drawingsOrder??[],v=_.length;h.drawings??d.push(u.insertOp([...g,`drawings`],{})),h.drawingsOrder??d.push(u.insertOp([...g,`drawingsOrder`],[]));let y=o?Xy(f,s??0):s??0;if(o)y>0&&l.push({t:`r`,len:y});else{let e=Hy([r],f,0,null,!1);l.push(...e);let t=new Set(qy(f,[r]));v-=_.filter(e=>t.has(e)).length;for(let e of Jy(p,[r],f,c))e&&d.push(e)}let b=Qy(f,a,y);l.push({t:`i`,body:b,len:b.dataStream.length});let x=Sv(i,c),S=u.editOp(l.serialize(),x);d.push(S);for(let e of a){let{drawingId:t}=e,n=u.insertOp([...g,`drawings`,t],e),r=u.insertOp([...g,`drawingsOrder`,v++],t);d.push(n),d.push(r)}return d.reduce((e,t)=>ty.compose(e,t),null)};function Xy(e,t){let{dataStream:n}=e;return t===0&&n[0]===`\r`?1:n[t]===`
12
+ `&&n[t-1]===`\r`&&Zy(n,t)?t-1:t}function Zy(e,t){let n=0;for(let r=0;r<t;r++)e[r]===``?n++:e[r]===``&&(n=Math.max(0,n-1));return n>0}function Qy(e,t,n){var r;let i=`\b`.repeat(t.length),a=e.dataStream[n]===`
13
+ `||e.dataStream[n]===void 0;return{dataStream:a?`${i}\r`:i,customBlocks:t.map((e,t)=>({startIndex:t,blockId:e.drawingId})),...a?{paragraphs:[{startIndex:i.length,paragraphId:Bh(new Set((r=e.paragraphs)==null?void 0:r.map(e=>e.paragraphId)))}]}:{}}}function $y(e,t){if(e==null||t==null)return null;let n=e.dataStream,r=t.dataStream;if(n===r)return null;let i=r.length-n.length;if(i>0){let a=tb(e,t,n,r,i);if(a)return a}else if(i<0){let a=eb(e,t,n,r,-i);if(a)return a}let a=0;for(;a<n.length&&a<r.length&&n[a]===r[a];)a++;let o=n.length,s=r.length;for(;o>a&&s>a&&n[o-1]===r[s-1];)o--,s--;return{start:a,deleteLength:o-a,insertLength:s-a}}function eb(e,t,n,r,i){for(let a of nb(t,e))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a+i)===r.slice(a))return{start:a,deleteLength:i,insertLength:0};return null}function tb(e,t,n,r,i){for(let a of nb(e,t))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a)===r.slice(a+i))return{start:a,deleteLength:0,insertLength:i};return null}function nb(e,t){let n=[...rb(e.blockRanges,t.blockRanges,e=>e.blockId),...rb(e.tables,t.tables,e=>e.tableId),...rb(e.columnGroups,t.columnGroups,e=>e.columnGroupId),...rb(e.customBlocks,t.customBlocks,e=>e.blockId)];return Array.from(new Set(n)).sort((e,t)=>e-t)}function rb(e,t,n){let r=new Set((e??[]).map(n));return(t??[]).filter(e=>!r.has(n(e))).map(e=>e.startIndex)}var Z=class{};T(Z,`customRange`,{add:Ty,delete:wy,copyCustomRange:yy,getCustomRangesInterestsWithSelection:vy,isIntersecting:_y}),T(Z,`customDecoration`,{add:hy,delete:gy}),T(Z,`selection`,{replace:Wy,makeSelection:j_,normalizeSelection:M_,delete:Hy,replaceTextRuns:Ky,retain:Uy}),T(Z,`range`,{isIntersects:N_,getParagraphsInRange:P_,getParagraphsInRanges:F_}),T(Z,`transform`,{getPlainText:ry,fromPlainText:ay,isEmptyDocument:iy}),T(Z,`paragraph`,{bullet:{set:B_,switch:R_,toggleChecklist:z_,changeNestLevel:K_},style:{set:q_},util:{transform:L_,getParagraphsInRange:P_,getParagraphsInRanges:F_}}),T(Z,`drawing`,{add:Yy,remove:Jy});let ib=new Set(Object.values(xm).filter(e=>e!==``&&e!==` `));function ab(e){if(e.customRanges||=[],!e.paragraphs){e.paragraphs=[];let t=new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`\r`&&e.paragraphs.push({startIndex:n,paragraphId:Bh(t)})}if(e.customBlocks||=[],e.textRuns||=[],e.customDecorations||=[],!e.sectionBreaks){e.sectionBreaks=[];let t=new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`
14
+ `&&e.sectionBreaks.push({startIndex:n,sectionId:_m(t)})}return e.tables||=[],e}function ob(e){return e.body=ab(e.body??{dataStream:``}),e.drawingsOrder||=[],e.drawings||={},e.documentStyle||={},e}function sb(e){return typeof e==`string`?{rgb:e}:e}function cb(e){let{bold:t,italic:n,fontFamily:r,fontSize:i,color:a,background:o,...s}=e,c={...s};return t!==void 0&&(c.bl=+!!t),n!==void 0&&(c.it=+!!n),r!==void 0&&(c.ff=r),i!==void 0&&(c.fs=i),a!==void 0&&(c.cl=sb(a)),o!==void 0&&(c.bg=sb(o)),c}function lb(e){return typeof e==`number`?{v:e}:e}function ub(e){if(e)return e instanceof gb?e.build():{horizontalAlign:e.align,lineSpacing:e.lineHeight,spacingRule:e.lineHeightRule,indentFirstLine:lb(e.firstLineIndent),hanging:lb(e.hangingIndent),indentStart:lb(e.indentStart),indentEnd:lb(e.indentEnd),spaceAbove:lb(e.spaceBefore),spaceBelow:lb(e.spaceAfter),direction:e.direction,wordWrap:e.wordWrap===void 0?void 0:+!!e.wordWrap,keepLines:e.keepLines===void 0?void 0:+!!e.keepLines,keepNext:e.keepNext===void 0?void 0:+!!e.keepNext}}function db(e){var t;return(((t=e.body)==null?void 0:t.dataStream)??``).replace(/\r|\n/g,``).length>0}var fb=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===1}get bold(){return this._style.bl===1}get underline(){return this._style.ul&&mb.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&mb.create(this._style.bbl)}get strikethrough(){return this._style.st&&mb.create(this._style.st)}get overline(){return this._style.ol&&mb.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return pb.create(z.deepClone(this._style))}getValue(){return{...this._style}}},pb=class e extends fb{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=+!!e,this}setBold(e){return this._style.bl=+!!e,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(z.deepClone(this._style))}build(){return this.getValue()}},mb=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){T(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===1}get followFontColor(){return this._decoration.c===1}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=+!!e,this}setFollowFontColor(e){return this._decoration.c=+!!e,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(z.deepClone(this._decoration))}build(){return{...this._decoration}}},hb=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===1}get keepNext(){return this._style.keepNext===1}get wordWrap(){return this._style.wordWrap===1}get widowControl(){return this._style.widowControl===1}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===1}copy(){return gb.create(z.deepClone(this._style))}getValue(){return this._style}},gb=class e extends hb{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=+!!e,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=+!!e,this}setKeepNext(e){return this._style.keepNext=+!!e,this}setWordWrap(e){return this._style.wordWrap=+!!e,this}setWidowControl(e){return this._style.widowControl=+!!e,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=+!!e,this}copy(){return e.create(z.deepClone(this._style))}build(){return this.getValue()}},_b=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(T(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=ob(e)}copy(){return vb.create(z.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return vb.create({...z.deepClone(r),body:cv(n,e,t)})}toPlainText(){var e;return Z.transform.getPlainText(((e=this._data.body)==null?void 0:e.dataStream)??``).replaceAll(`\r`,`
15
+ `)}getParagraphStyle(){var e;return hb.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){let e=this._data.body;if(!e)return[];let t=W_(e);return(e.paragraphs??[]).map(e=>vb.create(xb(this._data,e.paragraphId,{startOffset:t.get(e.startIndex)??0,endOffset:e.startIndex})))}getTextRuns(){var e;return(((e=this._data.body)==null?void 0:e.textRuns)??[]).map(e=>({...e,ts:e.ts?fb.create(e.ts):null}))}getLinks(){var e;return((e=this._data.body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getData(){return this._data}},vb=class e extends _b{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`constructor`)return;let n=Object.getOwnPropertyDescriptor(e.prototype,t);n&&Object.defineProperty(this.prototype,t,n)})}static newEmptyData(){return ob({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
16
+ `,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0,paragraphId:Bh(new Set)}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t??e.newEmptyData())}constructor(e){super(e),T(this,`_doc`,void 0),T(this,`_trackedRanges`,new Set),T(this,`_childHandleRevision`,0),this._doc=new uy(e)}getParagraphs(){let e=this._data.body;if(!e)return[];let t=W_(e);return(e.paragraphs??[]).map(e=>this._createParagraphBuilder(e.paragraphId,t.get(e.startIndex)??0,e.startIndex))}getTextRuns(){return this.getParagraphs().flatMap(e=>e.getTextRuns())}_createTextRunBuilders(e){let t=this._data.body;if(!t||e.startOffset>=e.endOffset)return[];let n=new Set([e.startOffset,e.endOffset]),r=(t,r)=>{let i=Math.max(t,e.startOffset),a=Math.min(r,e.endOffset);i<a&&(n.add(i),n.add(a))};for(let e of t.textRuns??[])r(e.st,e.ed);for(let e of t.customRanges??[])r(e.startIndex,e.endIndex+1);for(let e of t.customDecorations??[])r(e.startIndex,e.endIndex+1);for(let r=e.startOffset;r<e.endOffset;r++)ib.has(t.dataStream[r])&&(n.add(r),n.add(r+1));let i=[...n].sort((e,t)=>e-t),a=[];for(let e=0;e<i.length-1;e++){let n=i[e],r=i[e+1];if(n>=r||r-n===1&&ib.has(t.dataStream[n]))continue;let o=(t.textRuns??[]).find(e=>e.st<=n&&e.ed>=r);a.push(new bb(this,this._trackRange(n,r),o==null?void 0:o.ts,o==null?void 0:o.sId,!!o,this._childHandleRevision))}return a}_replaceTextRun(e,t,n,r,i){var a,o;if(t.includes(`\r`)||t.includes(`
17
+ `))throw RangeError(`Rich text run replacement cannot contain paragraph or section breaks.`);let s=this._doc.getBody();if(!s)throw Error(`Rich text body is not available.`);let{startOffset:c,endOffset:l}=e;if(s.dataStream.slice(c,l)===t)return;let u=cv(s,c,l),d={dataStream:t};t&&i&&(d.textRuns=[{st:0,ed:t.length,sId:r,ts:z.deepClone(n)}]),t&&(a=u.customRanges)!=null&&a.length&&(d.customRanges=u.customRanges.map(e=>({...z.deepClone(e),startIndex:0,endIndex:t.length-1}))),t&&(o=u.customDecorations)!=null&&o.length&&(d.customDecorations=u.customDecorations.map(e=>({...z.deepClone(e),startIndex:0,endIndex:t.length-1})));let f=Z.selection.replace({doc:this._doc,selection:{startOffset:c,endOffset:l,collapsed:c===l},body:d});if(!f)throw Error(`Replace rich text run failed.`);X.apply(s,f.serialize()),this._rebaseTrackedRanges(c,l,t.length)}_createParagraphBuilder(e,t,n){return new yb(this,e,this._trackRange(t,n),this._childHandleRevision)}_assertChildHandleRevision(e){if(e!==this._childHandleRevision)throw Error(`Rich text child handle is no longer valid.`)}_trackRange(e,t){let n={startOffset:e,endOffset:t};return this._trackedRanges.add(n),n}_rebaseTrackedRanges(e,t,n){let r=n-(t-e),i=n=>n<=e?n:n>=t?n+r:e,a=i=>i<=e?i:i>=t?i+r:e+n;for(let e of this._trackedRanges)e.startOffset=i(e.startOffset),e.endOffset=a(e.endOffset)}_invalidateChildHandles(){this._childHandleRevision++,this._trackedRanges.clear()}text(e){return this.insertText(e)}align(e){let t=this._data.documentStyle??={},n=t.renderConfig??={};if(e.horizontal!==void 0){var r;n.horizontalAlign=e.horizontal;for(let t of((r=this._data.body)==null?void 0:r.paragraphs)??[])t.paragraphStyle={...t.paragraphStyle,horizontalAlign:e.horizontal}}return e.vertical!==void 0&&(n.verticalAlign=e.vertical),this}columns(e){if(!Number.isInteger(e.count)||e.count<1)throw RangeError(`Rich text column count must be a positive integer.`);let t=this._data.body??={dataStream:`\r
18
+ `},n=t.sectionBreaks??=[];if(!n.length){var r;n.push({sectionId:_m(new Set),startIndex:Math.max(0,(((r=t.dataStream)==null?void 0:r.length)??0)-1)})}let i=Math.max(0,e.spacing??0),a=e.count===1?void 0:Array.from({length:e.count},(t,n)=>({width:0,paddingEnd:n===e.count-1?0:i}));for(let e of n)a?e.columnProperties=a.map(e=>({...e})):delete e.columnProperties;return this}span(e,t){return e?t?this.insertText(e,cb(t)):this.insertText(e):this}bold(e){return this.span(e,{bold:!0})}italic(e){return this.span(e,{italic:!0})}code(e){return this.span(e,{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,background:`#f3f4f6`})}link(e,t){return e?this.insertLink(e,t):this}listItem(e,t={}){var n,r,i;let a=t.type??`BULLET_LIST`,o=(n=this._data.body)==null||(n=n.paragraphs)==null?void 0:n.slice(-1)[0],s=o==null?void 0:o.bullet,c=((r=t.listId)==null?void 0:r.trim())||((s==null?void 0:s.listType)===a?s.listId:J());(db(this._data)||t.paragraphStyle)&&this.paragraph(t.paragraphStyle);let l=(i=this._data.body)==null||(i=i.paragraphs)==null?void 0:i.slice(-1)[0];return l&&(l.bullet={listId:c,listType:a,nestingLevel:Math.max(0,Math.trunc(t.level??0))}),this.text(e)}paragraph(e){var t,n,r;let i=ub(e);if(!db(this._data)){if(i){var a;let e=(a=this._data.body)==null||(a=a.paragraphs)==null?void 0:a[0];e&&(e.paragraphStyle=i)}return this}let o=(t=this._data.body)==null||(t=t.paragraphs)==null?void 0:t.slice(-1)[0],s=z.deepClone(o==null?void 0:o.paragraphStyle),c=z.deepClone(o==null?void 0:o.bullet),l=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2);this.insertRichText(l,_b.create({id:`d`,documentStyle:{},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Bh(new Set),paragraphStyle:s,bullet:c}]}}));let u=(r=this._data.body)==null||(r=r.paragraphs)==null?void 0:r.slice(-1)[0];return i?u&&(u.paragraphStyle=i):u&&delete u.paragraphStyle,u&&delete u.bullet,this}insertText(e,t,n){var r;let i=(((r=this._data.body)==null?void 0:r.dataStream.length)??2)-2,a,o;if(typeof e==`string`?a=e:(i=Math.min(e,i),a=typeof t==`string`?t:``),o=typeof t==`object`?t instanceof pb?t.build():t:n instanceof pb?n.build():n,!a)return this;let s=Z.transform.fromPlainText(a),c={dataStream:s.dataStream,paragraphs:s.paragraphs,textRuns:o?[{ts:o,st:0,ed:s.dataStream.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),l.serialize()),this._invalidateChildHandles(),this}insertRichText(e,t){var n;let r=(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2,i;typeof e==`object`?i=e instanceof _b?e.getData():e:(r=Math.min(e,r),i=t instanceof _b?t.getData():t);let a=Z.selection.replace({doc:this._doc,selection:{startOffset:r,endOffset:r,collapsed:!0},body:i.body});if(!a)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),a.serialize()),this._invalidateChildHandles(),this}delete(e,t){var n;let r=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2),i,a;if(t===void 0){if(e<0)throw RangeError(`Delete count cannot be negative.`);a=Math.min(e,r),i=r-a}else{if(e<0||t<0)throw RangeError(`Delete range cannot be negative.`);i=Math.min(e,r),a=Math.min(t,r-i)}if(a>0){let e=Z.selection.delete([{startOffset:i,endOffset:i+a,collapsed:!0}],this._data.body);X.apply(this._doc.getBody(),e),this._invalidateChildHandles()}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof pb?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return X.apply(this._doc.getBody(),i),this._invalidateChildHandles(),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:0,rangeId:J(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),r.serialize()),this._invalidateChildHandles(),this}cancelLink(e,t){let n=!1;if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0});return n&&this._invalidateChildHandles(),this}removeLink(e){return this.cancelLink(e)}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Bh(new Set),paragraphStyle:e.build()}]},r=(((i=this._data.body)==null?void 0:i.dataStream.length)??2)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Bh(new Set),paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,_b.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:0,rangeId:J(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}},yb=class extends _b{constructor(e,t,n,r){super(xb(e.getData(),t,n)),this._owner=e,this._paragraphId=t,this._range=n,this._revision=r}getId(){return this._assertActive(),this._paragraphId}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}toPlainText(){return this.getText()}getTextRuns(){return this._assertActive(),this._owner._createTextRunBuilders(this._range)}getParagraphStyle(){return this._assertActive(),hb.create(this._getParagraph().paragraphStyle)}getParagraphBullet(){return this._assertActive(),this._getParagraph().bullet}getLinks(){var e;return this._assertActive(),((e=this.getData().body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getBullet(){return this.getParagraphBullet()}getData(){return this._assertActive(),xb(this._owner.getData(),this._paragraphId,this._range)}copy(){return vb.create(z.deepClone(this.getData()))}_getParagraph(){var e;let t=(e=this._owner.getData().body)==null||(e=e.paragraphs)==null?void 0:e.find(e=>e.paragraphId===this._paragraphId);if(!t)throw Error(`Rich text paragraph "${this._paragraphId}" was not found.`);return t}_assertActive(){this._owner._assertChildHandleRevision(this._revision)}},bb=class{constructor(e,t,n,r,i,a){this._owner=e,this._range=t,this._textStyle=n,this._styleId=r,this._hasExplicitTextStyle=i,this._revision=a,T(this,`_active`,!0)}get st(){return this._assertActive(),this._range.startOffset}get ed(){return this._assertActive(),this._range.endOffset}get sId(){return this._assertActive(),this._styleId}get ts(){return this._assertActive(),this._textStyle?fb.create(this._textStyle):null}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}getTextStyle(){return this.ts}hasTextStyle(){return this._assertActive(),this._hasExplicitTextStyle}setText(e){return this._assertActive(),this._owner._replaceTextRun(this._range,e,this._textStyle,this._styleId,this._hasExplicitTextStyle),e||(this._active=!1),this}_assertActive(){if(!this._active)throw Error(`Rich text run handle is no longer valid.`);this._owner._assertChildHandleRevision(this._revision)}};function xb(e,t,n){var r;let{body:i,...a}=e;if(!i)throw Error(`Rich text body is not available.`);let o=(r=i.paragraphs)==null?void 0:r.find(e=>e.paragraphId===t);if(!o)throw Error(`Rich text paragraph "${t}" was not found.`);let s=cv(i,n.startOffset,n.endOffset);return s.paragraphs=[{...z.deepClone(o),startIndex:n.endOffset-n.startOffset}],{...z.deepClone(a),body:s}}let Sb=`[${[`\r`,`
19
+ `,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\b`].join(``)}]`;function Q(e,t,n,r){return{...e,code:t,index:r,message:n}}function Cb(e,t,n){e.hasRootParagraph||t.push(Q(n,`missing-root-paragraph`,`Document body must contain at least one paragraph sentinel.`)),e.hasRootSectionBreak||t.push(Q(n,`missing-root-section-break`,`Document body must contain at least one section break sentinel.`))}function wb(e,t,n){let r=new Map;for(let i of e.paragraphs??[])e.dataStream[i.startIndex]===`\r`?r.set(i.startIndex,(r.get(i.startIndex)??0)+1):t.push(Q(n,`paragraph-token-mismatch`,`Paragraph metadata must point to a paragraph sentinel.`,i.startIndex));Eb(r,{context:n,duplicateCode:`duplicate-paragraph-metadata`,duplicateMessage:`Paragraph sentinel must have exactly one paragraph metadata entry.`},t)}function Tb(e,t,n){let r=new Map,i=new Map;for(let a of e.sectionBreaks??[])a.sectionId?i.set(a.sectionId,(i.get(a.sectionId)??0)+1):t.push(Q(n,`missing-section-id`,`Section break metadata must have a stable section id.`,a.startIndex)),e.dataStream[a.startIndex]===`
20
+ `?r.set(a.startIndex,(r.get(a.startIndex)??0)+1):t.push(Q(n,`section-break-token-mismatch`,`Section break metadata must point to a section break sentinel.`,a.startIndex));Eb(r,{context:n,duplicateCode:`duplicate-section-break-metadata`,duplicateMessage:`Section break sentinel must have exactly one section break metadata entry.`},t);for(let[e,r]of i)r>1&&t.push(Q(n,`duplicate-section-id`,`Section id "${e}" must be unique within a document segment.`))}function Eb(e,t,n){for(let[r,i]of e)i>1&&n.push(Q(t.context,t.duplicateCode,t.duplicateMessage,r))}function Db(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(r.startIndex<n.startIndex||r.startIndex===n.startIndex&&r.endIndex<n.endIndex)return[...e].sort((e,t)=>e.startIndex-t.startIndex||e.endIndex-t.endIndex)}return e}function Ob(){return{pairs:new Map,unmatchedEnds:[],unmatchedStarts:[]}}function kb(e,t,n){let r=e.unmatchedStarts.pop();if(r===void 0){e.unmatchedEnds.push(t);return}e.pairs.set(r,n?t+1:t)}function Ab(e){let t={hasRootParagraph:!1,hasRootSectionBreak:!1,tableRanges:Ob(),blockRanges:Ob(),columnGroupRanges:Ob(),customBlockIndexes:new Set},n=new RegExp(Sb,`g`);for(let r of e.matchAll(n)){let e=r.index,n=r[0];n===`\r`?t.hasRootParagraph=!0:n===`
21
+ `?t.hasRootSectionBreak=!0:n===``?t.tableRanges.unmatchedStarts.push(e):n===``?kb(t.tableRanges,e,!0):n===``?t.blockRanges.unmatchedStarts.push(e):n===``?kb(t.blockRanges,e,!1):n===``?t.columnGroupRanges.unmatchedStarts.push(e):n===``?kb(t.columnGroupRanges,e,!1):n===`\b`&&t.customBlockIndexes.add(e)}return t}function jb(e,t,n,r){let i=t.tableRanges.pairs,a=new Set,o=[],s=Db(e.tables??[]);for(let t of s){for(a.add(t.startIndex),(!Number.isInteger(t.startIndex)||e.dataStream[t.startIndex]!==``)&&n.push(Q(r,`table-start-token-mismatch`,`Table startIndex must point to a table start sentinel.`,t.startIndex)),(!Number.isInteger(t.endIndex)||t.endIndex<=t.startIndex||t.endIndex>e.dataStream.length||e.dataStream[t.endIndex-1]!==``||i.get(t.startIndex)!==t.endIndex)&&n.push(Q(r,`table-end-token-mismatch`,`Table endIndex must be the exclusive boundary immediately after a table end sentinel.`,t.endIndex));o.length>0&&o[o.length-1].endIndex<=t.startIndex;)o.pop();let s=o[o.length-1];s&&(t.startIndex===s.startIndex||t.endIndex>=s.endIndex)&&n.push(Q(r,`overlapping-table`,`Table ranges may nest but must not cross or duplicate.`,t.startIndex)),o.push(t)}for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-table-metadata`,`Table token range must have a table metadata entry.`,e))}function Mb(e,t,n,r){let i=t.blockRanges;for(let e of[...i.unmatchedStarts,...i.unmatchedEnds])n.push(Q(r,`unbalanced-block`,`Block sentinel has no matching boundary.`,e));let a=Db(e.blockRanges??[]),o=new Set,s;for(let e=0;e<a.length;e++){let t=a[e];o.add(t.startIndex),i.pairs.get(t.startIndex)!==t.endIndex&&n.push(Q(r,`block-range-token-mismatch`,`Block range must point to its matching block start and end sentinels.`,t.startIndex)),s&&gg(cg(s),cg(t))&&n.push(Q(r,`overlapping-block-range`,`Block ranges must not overlap or share structural sentinels.`,t.startIndex)),s=t}for(let e of i.pairs.keys())o.has(e)||n.push(Q(r,`missing-block-range-metadata`,`Block token range must have a block metadata entry.`,e))}function Nb(e,t,n,r){let i=t.columnGroupRanges.pairs,a=new Set,o=Db(e.columnGroups??[]),s;for(let t of o){a.add(t.startIndex);let o=i.get(t.startIndex);if(o!==t.endIndex&&n.push(Q(r,`column-group-range-token-mismatch`,`Column group range must point to its matching start and end sentinels.`,t.startIndex)),s&&gg(lg(s),lg(t))&&n.push(Q(r,`overlapping-column-group`,`Column group ranges must not overlap.`,t.startIndex)),s=t,Array.isArray(t.columns)){let i=0,a=o??t.endIndex;for(let n=t.startIndex+1;n<a;n++)e.dataStream[n]===``&&i++;i!==t.columns.length&&n.push(Q(r,`column-group-column-count-mismatch`,`Column group metadata column count must match the data stream.`,t.startIndex))}}for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-column-group-metadata`,`Column group token range must have a metadata entry.`,e))}function Pb(e,t,n,r){let i=new Map,a=[...e.customBlocks??[],...e.docxRawCustomBlocks??[]];for(let t of a){let{startIndex:a}=t;if(!Number.isInteger(a)||e.dataStream[a]!==`\b`){n.push(Q(r,`custom-block-token-mismatch`,`Custom block startIndex must point to a custom block sentinel.`,a));continue}i.set(a,(i.get(a)??0)+1)}Eb(i,{context:r,duplicateCode:`duplicate-custom-block-metadata`,duplicateMessage:`Custom block sentinel must have exactly one custom block metadata entry.`},n);for(let e of t.customBlockIndexes)i.has(e)||n.push(Q(r,`missing-custom-block-metadata`,`Custom block sentinel must have a custom block metadata entry.`,e))}function Fb(e,t,n){let r=[],i=[],a=[],o=new RegExp(Sb,`g`);for(let s of e.dataStream.matchAll(o)){let e=s.index,o=s[0],c=i[i.length-1],l=a[a.length-1],u=l==null?void 0:l.cell;if(o===`\r`)c&&(c.hasChild=!0),u&&(u.hasParagraph=!0);else if(o===`
22
+ `)c&&(c.hasChild=!0),u&&(u.hasSectionBreak=!0);else if(o===``)r.push(e);else if(o===``)i.push({startIndex:e,hasChild:!1});else if(o===``){let r=i.pop();r?r.hasChild||t.push(Q(n,`empty-column`,`Column must contain at least one paragraph or section child.`,r.startIndex)):t.push(Q(n,`unbalanced-column-group`,`Column end token has no matching column start.`,e))}else o===``?i.length>0||r.length===0?(t.push(Q(n,`unbalanced-column-group`,`Column group closes while a column is still open.`,e)),i.length=0):r.pop():o===``?(l&&!u&&t.push(Q(n,`unbalanced-table`,`Nested table must be inside a parent cell.`,e)),a.push({inRow:!1})):o===`\x1B`?((!l||l.inRow)&&t.push(Q(n,`unbalanced-table`,`Table row must start inside a table without an open row.`,e)),l&&(l.inRow=!0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table cell must start inside a row without an open cell.`,e)),l&&(l.cell={startIndex:e,hasParagraph:!1,hasSectionBreak:!1})):o===``?(u?(!u.hasParagraph||!u.hasSectionBreak)&&t.push(Q(n,`empty-table-cell`,`Table cell must contain a paragraph and section break child.`,u.startIndex)):t.push(Q(n,`unbalanced-table`,`Table cell end token has no matching start.`,e)),l&&(l.cell=void 0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table row closes while a cell is still open.`,e)),l&&(l.inRow=!1)):o===``&&((!l||l.inRow||u)&&t.push(Q(n,`unbalanced-table`,`Table closes while a row or cell is still open.`,e)),a.pop())}(r.length>0||i.length>0)&&t.push(Q(n,`unbalanced-column-group`,`Column group or column token is not closed.`,e.dataStream.length)),a.length>0&&t.push(Q(n,`unbalanced-table`,`Table, row, or cell token is not closed.`,e.dataStream.length))}function Ib(e,t,n){let r=new Map,i=[];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)i.push(a);else if(o===``){let e=i.pop();e==null?t.push(Q(n,`unbalanced-custom-range`,`Custom range end token has no matching start.`,a)):r.set(e,a)}}for(let e of i)t.push(Q(n,`unbalanced-custom-range`,`Custom range start token has no matching end.`,e));let a=e.customRanges??[],o=new Set;for(let i of a)o.has(i.rangeId)&&t.push(Q(n,`duplicate-custom-range-id`,`Custom range ids must be unique.`,i.startIndex)),o.add(i.rangeId),i.rangeType===1&&(e.dataStream[i.startIndex]!==``||e.dataStream[i.endIndex]!==``||r.get(i.startIndex)!==i.endIndex)&&t.push(Q(n,`custom-range-token-mismatch`,`Field metadata must point to a matching custom range token pair.`,i.startIndex));for(let[e,i]of r)a.some(t=>t.startIndex===e&&t.endIndex===i)||t.push(Q(n,`missing-custom-range-metadata`,`Custom range token pair has no metadata.`,e));let s=a.filter(e=>e.rangeType===1).slice().sort((e,t)=>e.startIndex-t.startIndex||t.endIndex-e.endIndex),c=[];for(let e of s){for(;c.length>0&&c[c.length-1].endIndex<e.startIndex;)c.pop();let r=c[c.length-1];r&&e.endIndex>r.endIndex&&t.push(Q(n,`crossing-custom-range`,`Field ranges may nest but must not cross.`,e.startIndex)),c.push(e)}}function Lb(e,t={segmentType:`body`}){let n=[],r=Ab(e.dataStream);if(Cb(r,n,t),wb(e,n,t),Tb(e,n,t),jb(e,r,n,t),Mb(e,r,n,t),Nb(e,r,n,t),Pb(e,r,n,t),Fb(e,n,t),Ib(e,n,t),t.segmentType===`header`||t.segmentType===`footer`)for(let r of e.customRanges??[])(r.rangeType===8||r.rangeType===9)&&n.push(Q(t,`invalid-note-reference`,`Note references are only supported in the document body.`,r.startIndex));return n}function Rb(e,t){var n,r,i;let a={segmentType:`note`,segmentId:e},o=Lb(t.body,a);(t.noteId!==e||e.length===0||![`footnote`,`endnote`].includes(t.type))&&o.push({...a,code:`invalid-note-id`,message:`Note identity must match its segment key.`}),(n=t.body.customRanges)!=null&&n.some(e=>e.rangeType===8||e.rangeType===9)&&o.push({...a,code:`nested-note`,message:`A note cannot contain another note reference.`});let s=((r=t.body.sectionBreaks)==null?void 0:r.filter(e=>{var n;return!((n=t.body.tables)!=null&&n.some(t=>e.startIndex>=t.startIndex&&e.startIndex<t.endIndex))}))??[],c=s.some(e=>Object.keys(e).some(e=>e!==`sectionId`&&e!==`startIndex`)),l=Object.values(t.drawings??{}).some(e=>e.layoutType!==0),u=Object.values(t.tableSource??{}).some(e=>e.textWrap===1);return(s.length>1||c||(i=t.body.columnGroups)!=null&&i.length||l||u)&&o.push({...a,code:`invalid-note-body`,message:`Notes support paragraphs, inline drawings and flow tables without independent sections or columns.`}),o}function zb(e){let t=[];if(e.body){t.push(...Lb(e.body,{segmentType:`body`}));let i=new Set;for(let a of e.body.customRanges??[]){var n,r;if(a.rangeType!==8&&a.rangeType!==9)continue;let o=(n=a.properties)==null?void 0:n.noteId;typeof o!=`string`||((r=e.notes)==null?void 0:r[o])==null?t.push({code:`missing-note`,segmentType:`body`,index:a.startIndex,message:`Note reference must resolve to a note segment.`}):e.notes[o].type===(a.rangeType===9?`endnote`:`footnote`)?i.has(o)?t.push({code:`duplicate-note-reference`,segmentType:`body`,index:a.startIndex,message:`Each note must have its own reference identity.`}):i.add(o):t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference kind must match its target.`}),(a.startIndex!==a.endIndex||e.body.dataStream[a.startIndex]!==``||!a.wholeEntity)&&t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference must cover one whole-entity reference character.`})}}for(let[n,r]of Object.entries(e.headers??{}))t.push(...Lb(r.body,{segmentType:`header`,segmentId:n}));for(let[n,r]of Object.entries(e.footers??{}))t.push(...Lb(r.body,{segmentType:`footer`,segmentId:n}));for(let[n,r]of Object.entries(e.notes??{})){var i,a;t.push(...Rb(n,r)),((i=e.headers)!=null&&i[n]||(a=e.footers)!=null&&a[n])&&t.push({code:`invalid-note-id`,segmentType:`note`,segmentId:n,message:`Notes must not share a segment identity with a header or footer.`})}return t}function Bb(e,t){return`${t==="default"?`default`:t===`first`?`firstPage`:`evenPage`}${e===`header`?`Header`:`Footer`}Id`}function Vb(e,t,n,r){if(n<0||n>=t.length)return{linkedToPrevious:!1};let i=t[n],a=i[r];if(typeof a==`string`&&a)return{segmentId:a,linkedToPrevious:!1,sourceSectionId:i.sectionId};if(n===0){let t=e[r];return{...typeof t==`string`&&t?{segmentId:t}:{},linkedToPrevious:!1}}let o=Vb(e,t,n-1,r);return{...o.segmentId?{segmentId:o.segmentId}:{},linkedToPrevious:!0,sourceSectionId:o.sourceSectionId}}function Hb(e,t,n){let r={};for(let i of[`defaultHeaderId`,`defaultFooterId`,`firstPageHeaderId`,`firstPageFooterId`,`evenPageHeaderId`,`evenPageFooterId`]){let{segmentId:a}=Vb(e,t,n,i);a&&(r[i]=a)}return r}function Ub(e){var t;let n=(t=e.properties)==null?void 0:t.dataBinding;if(n!=null&&n.storeItemID&&n.xpath)return JSON.stringify([n.storeItemID.toLowerCase(),n.xpath,n.prefixMappings??``])}function Wb(e,t){if(t.properties.showingPlaceholder)return``;if(t.properties.kind===`checkbox`){var n;return(n=t.properties.checkbox)!=null&&n.checked?`true`:`false`}let r=e.dataStream.slice(t.startIndex,t.endIndex+1).replace(/^[\x00-\x08\x0A-\x1F]+|[\x00-\x08\x0A-\x1F]+$/g,``);if(t.properties.kind===`date`){var i;return((i=t.properties.date)==null?void 0:i.fullDate)??r}if(t.properties.kind===`dropDownList`||t.properties.kind===`comboBox`){var a;return((a=t.properties.listItems)==null||(a=a.find(e=>e.displayText===r))==null?void 0:a.value)??r}return[`text`,`richText`].includes(t.properties.kind)?r:void 0}var Gb=class{constructor(){T(this,`skipNextObservers`,!1),T(this,`lastReturnValue`,void 0),T(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},Kb=class extends t.Subject{constructor(...e){super(...e),T(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>(e.priority??0)-(t.priority??0)),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Gb;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function qb(e){return new t.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let Jb=(0,i.createIdentifier)(`core.resource-manager.service`),Yb={[n.UnitRole.Editor]:`Editor`,[n.UnitRole.Owner]:`Owner`,[n.UnitRole.Reader]:`Reader`,[n.UnitRole.UNRECOGNIZED]:`UNRECOGNIZED`},Xb=e=>e?{userID:`${Yb[e]}_${J(8)}`,name:Yb[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},Zb=(e,t)=>e.startsWith(Yb[t]);var Qb=class extends k{constructor(...e){super(...e),T(this,`_model`,new Map),T(this,`_userChange$`,new t.Subject),T(this,`userChange$`,this._userChange$.asObservable()),T(this,`_currentUser$`,new t.BehaviorSubject(Xb())),T(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let $b=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,T(this,`_permissionMap`,new Map([])),T(this,`_permissionOverrides`,new Map),T(this,`_cfgEnableObjInherit`,!1),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(Xb(n.UnitRole.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?Zb(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[n.UniverType.UNIVER_SHEET,n.UniverType.UNIVER_DOC,n.UniverType.UNIVER_SLIDE,n.UniverType.UNIVER_BOARD],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=J(8),{objectType:r,selectRangeObject:i,worksheetObject:a}=e,o=i||a,s={objectType:r,unitID:(o==null?void 0:o.unitID)||``,name:(o==null?void 0:o.name)||``,strategies:[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}],selectRangeObject:i};return this._permissionMap.set(t,s),t}async allowed(e){let{objectID:t,actions:r}=e,i=this._permissionMap.get(t);return i?r.map(e=>{let r=`${t}:${e}`;if(this._permissionOverrides.has(r))return{action:e,allowed:this._permissionOverrides.get(r)};let a=i.strategies.find(t=>t.action===e);return a?{action:e,allowed:this._getRole(a.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}}):r.map(e=>({action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],r=[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}];return e.objectIDs.forEach(i=>{let a=this._permissionMap.get(i),o=(a==null?void 0:a.strategies)||r,s={objectID:i,unitID:e.unitID,objectType:(a==null?void 0:a.objectType)||3,name:(a==null?void 0:a.name)||``,shareOn:!1,shareRole:n.UnitRole.Owner,shareScope:-1,scope:{read:n.ObjectScope.AllCollaborator,edit:n.ObjectScope.AllCollaborator},creator:Xb(n.UnitRole.Owner),strategies:o.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${i}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let r=o.find(t=>t.action===e);return r?{action:e,allowed:this._getRole(r.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}})};t.push(s)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:r}=e,i=this._permissionMap.get(t);i&&r&&(i.strategies=r.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,i),r.forEach(e=>{e.role===n.UnitRole.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===n.UnitRole.Owner||e.role===n.UnitRole.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}setCfgEnableObjInherit(e){this._cfgEnableObjInherit=e}getCfgEnableObjInherit(){return this._cfgEnableObjInherit}};$b=ma([V(0,Jb),V(1,(0,i.Inject)(Qb))],$b);let ex=(0,i.createIdentifier)(`IAuthzIoIoService`),tx=(0,i.createIdentifier)(`univer.confirm-service`);var nx=class{constructor(){T(this,`confirmOptions$`,new t.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let rx=`FOCUSING_UNIT`,ix=`FOCUSING_SHEET`,ax=`FOCUSING_DOC`,ox=`FOCUSING_SLIDE`,sx=`FOCUSING_BOARD`,cx=`EDITOR_ACTIVATED`,lx=`FOCUSING_FX_BAR_EDITOR`;var ux=class extends k{constructor(...e){super(...e),T(this,`_error$`,new t.Subject),T(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emitPermissionDenied(e,t=[]){this._error$.next({errorKey:`Permission denied.`,code:`PERMISSION_DENIED`,permissionTarget:JSON.stringify([e,[...new Set(t)].sort()])})}emit(e){this._error$.next({errorKey:e})}};let dx=function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),fx=function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),px=(0,i.createIdentifier)(`core.image-io.service`),mx=(0,i.createIdentifier)(`core.url-image.service`);function hx(e=``,t=`zhCN`,n=``){return{id:e,sheetOrder:[],name:n,appVersion:ze,locale:t,dateSystem:`date1900`,styles:{},sheets:{},resources:[]}}var gx=class{constructor(e={}){T(this,`_styles`,void 0),T(this,`_cacheMap`,new bd(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=J(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&z.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(z.diffValue(t[n],e))return n;return null}};let _x=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Gd.equals(t,e))),vx=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Gd.equals(e.range,r.range)}),yx={t:0,b:2,l:2,r:2},bx=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function xx(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=0,verticalAlign:s=0,wrapStrategy:c=0,cellValueType:l}=n,u=(a==null?void 0:a.t)??yx.t,d=(a==null?void 0:a.r)??yx.r,f=(a==null?void 0:a.b)??yx.b,p=(a==null?void 0:a.l)??yx.l,{vertexAngle:m,centerAngle:h}=Ax(i);return new uy({id:`d`,body:{dataStream:`${e}\r
23
+ `,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphId:Bh(new Set),paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{sectionId:_m(new Set),startIndex:r+1}]},documentStyle:{textStyle:z.deepClone(t),defaultParagraphStyle:{horizontalAlign:o},pageSize:{width:1/0,height:1/0},documentFlavor:0,marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Sx(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function Cx(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function wx(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===0))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:0,body:i,properties:{url:t,refId:n}});a&&X.apply(i,a.serialize())}function Tx(e){return e!=null}function Ex(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function Dx(e){let t=Y.ff,n=Y.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=`italic`;(e.it===0||e.it===void 0)&&(r=`normal`);let i=`bold`;(e.bl===0||e.bl===void 0)&&(i=`normal`);let a=n;e.fs&&(a=e.fs);let o=Ox(e.ff,t),{va:s}=e,c=a;if(s===2||s===3){let{sbr:e,spr:t}=kx(o,c);c*=s===2?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function Ox(e,t){return e!=null&&e.trim()?e.split(`,`).map(e=>{let t=e.trim().replace(/^['"]|['"]$/g,``);return t.includes(` `)?`"${t}"`:t}).filter(Boolean).join(`, `):t}function kx(e,t){return bx(t)}function Ax(e){let{a:t=0,v:n=0}=e||{a:0,v:0},r=0,i=t;return n===1&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}var jx=class{constructor(e,t){this._config=e,T(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return!n||n.hd!==1}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e??{w:this._config.defaultColumnWidth,hd:0},r++}return n}getSize(){return nu(this._columnData)}getColumnWidth(e){var t;return((t=this._columnData[e])==null?void 0:t.w)??this._config.defaultColumnWidth}setColumnWidth(e,t){let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t})}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}};function Mx(e,t){let{textRuns:n=[]}=t,r=0;for(let t of n){let{ts:n={},st:i,ed:a}=t;if(n[e]==null)return 0;switch(e){case`bl`:case`it`:if(n[e]===0)return 0;break;case`ul`:case`st`:if(n[e].s===0)return 0;break;default:throw Error(`unknown style key: ${e} in IStyleBase`)}r+=a-i}return+(t.dataStream.indexOf(`\r
24
+ `)===r)}var Nx=class e{constructor(e,t,n){this._deps=n,T(this,`_range`,void 0),T(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=z.numToWord(n+1)+(e+1),a=z.numToWord(r+1)+(t+1)):(i=z.numToWord(r+1)+(t+1),a=z.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||Y.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).clone();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||Y.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?Mx(`ul`,t.body)===1?{s:1}:{s:0}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?Mx(`st`,t.body)===1?{s:1}:{s:0}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(Mx(`it`,t.body)===1):this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(Mx(`bl`,t.body)===1):this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(e=>(e==null?void 0:e.p)||``))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles(`td`)}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles(`tr`)}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return+(this.getWrapStrategy()===3)}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||Y[e]}))}};T(Nx,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===3?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===2?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===1?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});var Px=class{constructor(e,t,n){this._config=e,this._viewModel=t,T(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e??{h:this._config.defaultRowHeight,hd:0},r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=0;for(let a=0;a<t;a++){let{ia:t,ah:o,h:s=r.defaultRowHeight}=n[a+e]||{hd:0,h:r.defaultRowHeight};i+=(t==null||t===1)&&typeof o==`number`?o:s}return i}setRowHeight(e,t){let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._rowData[r]={...t})}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getRowRawVisible(e){let t=this.getRow(e);return!t||t.hd!==1}getSize(){return nu(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}};let Fx=1e3;function Ix(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:0,rowCount:Fx,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:1,rowHeader:{width:46,hidden:0},columnHeader:{height:20,hidden:0},rightToLeft:0};Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])});let n=e.freeze;return n.xSplit=n.xSplit??t.freeze.xSplit,n.ySplit=n.ySplit??t.freeze.ySplit,n.startRow=n.ySplit===0?t.freeze.startRow:n.startRow??t.freeze.startRow,n.startColumn=n.xSplit===0?t.freeze.startColumn:n.startColumn??t.freeze.startColumn,e}var Lx=class extends k{constructor(e){super(),T(this,`_cellCache`,new Map),T(this,`_rowCache`,new Map),T(this,`_columnCache`,new Map),T(this,`_hasRow`,!1),T(this,`_hasColumn`,!1),T(this,`_hasAll`,!1),T(this,`_allIndex`,-1),T(this,`_mergeData`,void 0),T(this,`_rangeMap`,new bd(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===1?this._createRowCache(n,t):e===2?this._createColumnCache(n,t):e===3?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r??(r=new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Gd.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},Rx=class extends k{constructor(e){super(),this.getRawCell=e,T(this,`_cellContentInterceptor`,null),T(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,3,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,2):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,1):this.getRawCell(e,t)}getRowFiltered(e){var t;return((t=this._rowFilteredInterceptor)==null?void 0:t.getRowFiltered(e))??!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,D(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,D(()=>this._rowFilteredInterceptor=null)}};let zx={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Bx=class{constructor(e,t,n){this.unitId=e,this._styles=n,T(this,`_sheetId`,void 0),T(this,`_snapshot`,void 0),T(this,`_cellData`,void 0),T(this,`_rowManager`,void 0),T(this,`_columnManager`,void 0),T(this,`_viewModel`,void 0),T(this,`_spanModel`,void 0),T(this,`_isRowStylePrecedeColumnStyle`,!0),T(this,`_getCellHeight`,void 0),this._snapshot=Ix(t);let{columnData:r,rowData:i,cellData:a}=this._snapshot;this._sheetId=this._snapshot.id??J(6),this._cellData=new du(a),this._viewModel=new Rx((e,t)=>this.getCellRaw(e,t)),this._rowManager=new Px(this._snapshot,this._viewModel,i),this._columnManager=new jx(this._snapshot,r),this._spanModel=new Lx(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,D(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this.getRowHeight(e)}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return n??this._isRowStylePrecedeColumnStyle?ae(r,a,i,o==null?void 0:o.themeStyle,s):ae(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return r??this._isRowStylePrecedeColumnStyle?ae(i,o,a,n==null?void 0:n.themeStyle,s):ae(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=`raw`){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new du;return rf(e,n,t,r).forEach((e,t)=>{let n;if(i===`raw`)n=this.getCellRaw(e,t);else if(i===`intercepted`)n=this.getCell(e,t);else if(i===`both`){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Tx(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;rf(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Nx(this,e,{getStyles:()=>this._styles}):new Nx(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden===0?0:1}getHiddenState(){return this._snapshot.hidden}setHiddenState(e){this._snapshot.hidden=e}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn){s=l.endColumn+1;continue}if(c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=zx){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...zx,...n},s,c=`document`,l=Sx(t),u=o?Y.tr:l.textRotation||Y.tr,d=l.horizontalAlign||Y.ht,f=l.verticalAlign||Y.vt,p=l.wrapStrategy||Y.tb,m=l.paddingData||yx;if(e.f&&a)s=xx(e.f.toString(),{},{verticalAlign:f}),d=Y.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=Ax(u);s=this._updateConfigAndGetDocumentModel(i?z.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=Cx(t);c=Dx(n).fontCache;let r=Vx(e);e.t===4&&a&&(r=`'${r}`),s=xx(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&wx(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new uy(e)}getBlankCellDocumentModel(e,t,n){var r;let i=this.getComposedCellStyleByCellData(t,n,e),a=Cx(i),o=this.getCellDocumentModel(e,i,{ignoreTextRotation:!0});if(o!=null)return o.documentModel??=xx(``,a),o;let s=Sx(i),c=Y.tr,l=s.horizontalAlign??Y.ht,u=s.verticalAlign??Y.vt,d=s.wrapStrategy??Y.tb,f=s.paddingData??yx,p=Dx(a).fontCache;return{documentModel:xx(``,a),fontString:p,textRotation:c,wrapStrategy:d,verticalAlign:u,horizontalAlign:l,paddingData:f,fill:i==null||(r=i.bg)==null?void 0:r.rgb}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function Vx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===3?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===3?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Hx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;if(r==null)return``;if(e.t===3){if(typeof r==`string`)return r.toUpperCase();if(typeof r==`number`)return r?`TRUE`:`FALSE`}return typeof r==`boolean`?r?`TRUE`:`FALSE`:String(r)}function Ux(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function Wx(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let Gx=class extends M{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},r){super(),this._logService=r,T(this,`type`,n.UniverType.UNIVER_SHEET),T(this,`_sheetCreated$`,new t.Subject),T(this,`sheetCreated$`,this._sheetCreated$.asObservable()),T(this,`_sheetDisposed$`,new t.Subject),T(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),T(this,`_activeSheet$`,new t.BehaviorSubject(null)),T(this,`activeSheet$`,this._activeSheet$.asObservable()),T(this,`_worksheets`,void 0),T(this,`_styles`,void 0),T(this,`_snapshot`,void 0),T(this,`_unitId`,void 0),T(this,`_count`,void 0),T(this,`_name$`,void 0),T(this,`name$`,void 0);let i=hx();z.isEmptyObject(e)?this._snapshot=i:(this._snapshot=z.commonExtend(i,e),e.dateSystem==null?delete this._snapshot.dateSystem:e.dateSystem!==`date1900`&&e.dateSystem!==`date1904`&&(this._logService.warn(`[Workbook]`,`Unknown date system "${String(e.dateSystem)}"; falling back to Excel 1900.`),this._snapshot.dateSystem=`date1900`));let{styles:a}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=J(6)),this._unitId=this._snapshot.id,this._styles=new gx(a),this._count=1,this._worksheets=new Map,this._name$=new t.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getDateSystem(){return this._snapshot.dateSystem===`date1904`?`date1904`:`date1900`}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Bx(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==1)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(e=!0){return this.getSheets().filter(e=>e.isSheetHidden()===1).filter(t=>e||t.getHiddenState()!==2).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.isSheetHidden()!==1).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(z.isEmptyObject(n)){let e=J();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Bx(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};Gx=ma([V(1,da)],Gx);let Kx=(0,i.createIdentifier)(`univer.current`),qx=class extends k{constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._logService=r,T(this,`_unitsByType`,new Map),T(this,`_unitCreateOptions`,new Map),T(this,`_createHandler`,void 0),T(this,`_ctorByType`,new Map),T(this,`_currentUnits`,new Map),T(this,`_currentUnits$`,new t.BehaviorSubject(this._currentUnits)),T(this,`currentUnits$`,this._currentUnits$.asObservable()),T(this,`_unitAdded$`,new t.Subject),T(this,`unitAdded$`,this._unitAdded$.asObservable()),T(this,`_unitDisposed$`,new t.Subject),T(this,`unitDisposed$`,this._unitDisposed$.asObservable()),T(this,`_focused$`,new t.BehaviorSubject(null)),T(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear(),this._unitCreateOptions.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}__getCtorByType(e){return this._ctorByType.get(e)}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,t.map)(t=>t.get(e)??null),(0,t.distinctUntilChanged)())}getCurrentUnitOfType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.get(t[1])!==t[0]&&(this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits))}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,t.filter)(t=>t.unit.type===e))}__addUnit(e,t){this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let n=e.type;this._unitsByType.has(n)||this._unitsByType.set(n,[]);let r=this._unitsByType.get(n),i=e.getUnitId();if(r.findIndex(e=>e.getUnitId()===i)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${i}.`);r.push(e),t&&this._unitCreateOptions.set(i,{...t}),this._unitAdded$.next({unit:e,options:t}),((t==null?void 0:t.makeCurrent)??!0)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,t.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getUnitCreateOptions(e){return this._unitCreateOptions.get(e)??null}getAllUnitsForType(e){return this._unitsByType.get(e)??[]}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){var t,r;this._focused$.getValue()!==e&&(this._focused$.next(e),this.focused instanceof Gx?(this._contextService.setContextValue(rx,!0),this._contextService.setContextValue(ax,!1),this._contextService.setContextValue(ix,!0),this._contextService.setContextValue(ox,!1),this._contextService.setContextValue(sx,!1),this.setCurrentUnitForType(e)):this.focused instanceof uy?(this._contextService.setContextValue(rx,!0),this._contextService.setContextValue(ax,!0),this._contextService.setContextValue(ix,!1),this._contextService.setContextValue(ox,!1),this._contextService.setContextValue(sx,!1),this.setCurrentUnitForType(e)):((t=this.focused)==null?void 0:t.type)===n.UniverType.UNIVER_SLIDE?(this._contextService.setContextValue(rx,!0),this._contextService.setContextValue(ax,!1),this._contextService.setContextValue(ix,!1),this._contextService.setContextValue(ox,!0),this._contextService.setContextValue(sx,!1),this.setCurrentUnitForType(e)):((r=this.focused)==null?void 0:r.type)===n.UniverType.UNIVER_BOARD?(this._contextService.setContextValue(rx,!0),this._contextService.setContextValue(ax,!1),this._contextService.setContextValue(ix,!1),this._contextService.setContextValue(ox,!1),this._contextService.setContextValue(sx,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(rx,!1),this._contextService.setContextValue(ax,!1),this._contextService.setContextValue(ix,!1),this._contextService.setContextValue(ox,!1),this._contextService.setContextValue(sx,!1)))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:n.UniverType.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),this._unitCreateOptions.delete(e),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitOfType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){var t;((t=this.focused)==null?void 0:t.getUnitId())===e&&this._focused$.next(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};qx=ma([V(0,(0,i.Inject)(i.Injector)),V(1,ca),V(2,(0,i.Inject)(da))],qx);let Jx=function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),Yx={0:`Starting`,1:`Ready`,2:`Rendered`,3:`Steady`};var Xx=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${Yx[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let Zx=class extends k{constructor(e){super(),this._logService=e,T(this,`_lifecycle$`,new t.BehaviorSubject(0)),T(this,`lifecycle$`,this._lifecycle$.asObservable()),T(this,`_lock`,!1),this._reportProgress(0)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,t.firstValueFrom)(this.lifecycle$.pipe((0,t.filter)(t=>t>=e),Ta(t=>t===e),(0,t.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new Xx(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,t.merge)(Qx(this.stage),this._lifecycle$.pipe((0,t.skip)(1))).pipe(Ta(e=>e===3))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${Yx[e]}".`)}};Zx=ma([V(0,da)],Zx);function Qx(e){switch(e){case 0:return(0,t.of)(0);case 1:return(0,t.of)(0,1);case 2:return(0,t.of)(0,1,2);default:return(0,t.of)(0,1,2,3)}}let $x=(0,i.createIdentifier)(`ILocalStorageService`);var eS=class extends k{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),T(this,`_currentLocale$`,new t.BehaviorSubject(`zhCN`)),T(this,`currentLocale$`,this._currentLocale$.asObservable()),T(this,`_direction$`,new t.BehaviorSubject(`ltr`)),T(this,`direction$`,this._direction$.asObservable()),T(this,`_locales`,null),T(this,`localeChanged$`,new t.Subject),T(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}return e}),this.disposeWithMe(D(()=>{this._locales=null,this._currentLocale$.complete(),this._direction$.complete(),this.localeChanged$.complete()}))}load(e){this._locales=na(this._locales??{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}setDirection(e){this._direction$.next(e)}getDirection(){return this._direction$.value}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let tS=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:0,mentions:[{objectType:0,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};tS=ma([V(0,(0,i.Inject)(Qb))],tS);let nS=(0,i.createIdentifier)(`univer.service.mention-io`);var rS=class extends k{constructor(e,n,r,i){super(),this._objectTypes=i,T(this,`_rules`,new Map),T(this,`_changes`,new t.Subject),T(this,`changed$`,this._changes.asObservable()),this.disposeWithMe(e.registerPluginResource({pluginName:n,businesses:[r],toJson:e=>JSON.stringify(this.getRules(e)),parseJson:e=>{let t=JSON.parse(e);if(!Array.isArray(t)||t.some(e=>!e||typeof e.objectId!=`string`||typeof e.permissionId!=`string`||!e.permissionId||!this._objectTypes.includes(e.objectType)))throw Error(`Invalid object permission resource.`);return t},onLoad:(e,t)=>{this._rules.set(e,new Map(t.map(e=>[this._key(e.objectType,e.objectId),z.deepClone(e)]))),this._changes.next(e)},onUnLoad:e=>{this._rules.delete(e),this._changes.next(e)}})),this.disposeWithMe(()=>{this._rules.clear(),this._changes.complete()})}getRules(e){var t;return[...((t=this._rules.get(e))==null?void 0:t.values())??[]].map(e=>z.deepClone(e))}getRule(e,t,n){var r;let i=(r=this._rules.get(e))==null?void 0:r.get(this._key(t,n));return i&&z.deepClone(i)}setRule(e,t,n,r){return this.setRules(e,[{objectId:n,objectType:t,rule:r}])}setRules(e,t){if(typeof e!=`string`||!e||!Array.isArray(t)||t.length===0)return!1;let n=new Set;for(let e of t){if(!e)return!1;let{objectId:t,objectType:r,rule:i}=e,a=this._key(r,t);if(typeof t!=`string`||!t||!this._objectTypes.includes(r)||n.has(a)||i!==null&&(!i||i.objectId!==t||i.objectType!==r||typeof i.permissionId!=`string`||!i.permissionId))return!1;n.add(a)}let r=z.deepClone(t),i=this._rules.get(e)??new Map;for(let{objectId:e,objectType:t,rule:n}of r)n?i.set(this._key(t,e),n):i.delete(this._key(t,e));return this._rules.set(e,i),this._changes.next(e),!0}_key(e,t){return`${e}/${t}`}};let iS=(0,i.createIdentifier)(`univer.undo-redo.service`);var aS=class{dispose(){}async dispatchToHandlers(){return!1}};let oS=`univer.command.redo`,sS=`univer.command.undo`,cS=new class extends aS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,sS)}handler(e){let t=e.get(iS),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.undoMutations,r).result?(t.popUndoToRedo(),!0):!1}},lS=new class extends aS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,oS)}handler(e){let t=e.get(iS),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.redoMutations,r).result?(t.popRedoToUndo(),!0):!1}},uS=class extends k{constructor(e,n,r,i){super(),this._univerInstanceService=e,this._commandService=n,this._contextService=r,T(this,`undoRedoStatus$`,void 0),T(this,`_undoRedoStatus$`,new t.BehaviorSubject({undos:0,redos:0})),T(this,`_undoStacks`,new Map),T(this,`_redoStacks`,new Map),T(this,`_batchingStatus`,new Map),T(this,`_activeGroups`,new Map),T(this,`_itemGroups`,new WeakMap),T(this,`_historyLimit`,void 0),this._historyLimit=i.getConfig(`undoRedo.historyLimit`)??50,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(cS)),this.disposeWithMe(this._commandService.registerCommand(lS)),this.disposeWithMe(D(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(D(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}getUndoRedoStatus(e){var t,n;return{undos:((t=this._undoStacks.get(e))==null?void 0:t.length)??0,redos:((n=this._redoStacks.get(e))==null?void 0:n.length)??0}}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0),i=this._historyLimit;n.length=0;let a=this._activeGroups.get(t),o=this._pitchUndoElement(t);a?o&&this._itemGroups.get(o)===a.id?a.mode===`replace`?o.redoMutations=e.redoMutations:(o.redoMutations.push(...e.redoMutations),o.undoMutations.unshift(...e.undoMutations)):(s(e),this._itemGroups.set(e,a.id)):this._batchingStatus.has(e.unitID)?this._batchingStatus.get(e.unitID)===0||!o?(s(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(o,e):s(e);function s(e){r.push(e),r.length>i&&r.splice(0,1)}this._updateStatus()}beginUndoRedoGroup(e,t,n=`replace`){if(this._activeGroups.has(e)||this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot group undo redo twice at the same time!`);let r={id:t,mode:n};return this._activeGroups.set(e,r),D(()=>{this._activeGroups.get(e)===r&&this._activeGroups.delete(e)})}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(this._itemGroups.delete(e),e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._itemGroups.delete(e),this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),this._itemGroups.delete(i),Sa(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e)||this._activeGroups.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,0),D(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(ix),n=this._contextService.getContextValue(lx),r=this._contextService.getContextValue(cx);if(t){if(n&&r)e=Ep;else if(r)e=Tp;else{var i;e=((i=this._univerInstanceService.getFocusedUnit())==null?void 0:i.getUnitId())??``}}else{var a;e=((a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())??``}return e}};uS=ma([V(0,Kx),V(1,_a),V(2,ca),V(3,oa)],uS);let dS=function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),fS=(0,i.createIdentifier)(`univer.permission-service`),pS={[n.UnitObject.Document]:n.UnitObject.Document,[n.UnitObject.DocumentSection]:n.UnitObject.Document,[n.UnitObject.DocumentParagraph]:n.UnitObject.Document,[n.UnitObject.DocumentEntity]:n.UnitObject.Document,[n.UnitObject.Slide]:n.UnitObject.Slide,[n.UnitObject.SlidePage]:n.UnitObject.Slide,[n.UnitObject.SlideElement]:n.UnitObject.Slide,[n.UnitObject.SlideMaster]:n.UnitObject.Slide,[n.UnitObject.Base]:n.UnitObject.Base,[n.UnitObject.BaseTable]:n.UnitObject.Base,[n.UnitObject.BaseField]:n.UnitObject.Base,[n.UnitObject.BaseRecord]:n.UnitObject.Base,[n.UnitObject.BaseView]:n.UnitObject.Base,[n.UnitObject.BaseDashboard]:n.UnitObject.Base,[n.UnitObject.Board]:n.UnitObject.Board,[n.UnitObject.BoardElement]:n.UnitObject.Board},mS=class extends k{constructor(e,r,i,a,o,s){super(),this._injector=e,this._permissions=r,this._logService=i,this._users=a,this._config=o,this._commands=s,T(this,`_models`,new Map),T(this,`_initialized`,new Set),T(this,`_policies`,new Map),T(this,`_generations`,new Map),T(this,`_nextGeneration`,0),T(this,`_revision`,new t.BehaviorSubject(0)),T(this,`changed$`,this._revision.asObservable()),T(this,`_unitChanges`,new t.Subject),T(this,`unitChanges$`,this._unitChanges.asObservable()),this.disposeWithMe(this._permissions.permissionPointUpdate$.subscribe(e=>{e.subType===n.UnitAction.Edit&&pS[e.type]===e.type&&this._revision.next(this._revision.value+1)})),this.disposeWithMe(()=>{this._initialized.clear(),this._policies.clear(),this._generations.clear(),this._revision.complete(),this._unitChanges.complete()})}get _authz(){return this._injector.get(ex)}registerRuleModel(e,t,r,i){if(this._models.has(e))throw Error(`Object permission rule model already registered.`);this._models.set(e,{model:t,mutationId:r,batchMutationId:i});let a=t.changed$.subscribe(e=>{this._generations.delete(e),this._policies.delete(e),t.getRules(e).forEach(t=>{if(!this.supports({unitId:e,objectId:t.objectId,objectType:t.objectType}))return;let r=`${t.objectType}.${n.UnitAction.Edit}_${e}_${t.objectId}`;this._permissions.getPermissionPoint(r)?this._permissions.updatePermissionPoint(r,!1):this._permissions.addPermissionPoint({id:r,type:t.objectType,subType:n.UnitAction.Edit,value:!1,status:`init`,unitId:e,objectId:t.objectId})}),this._revision.next(this._revision.value+1),this._initialized.has(e)&&this.refreshUnit(e).catch(e=>this._logService.error(e))});return this.disposeWithMe(D(()=>{a.unsubscribe(),this._models.delete(e)}))}_getRule(e){var t;return(t=this._models.get(pS[e.objectType]))==null?void 0:t.model.getRule(e.unitId,e.objectType,e.objectId)}_getAuthzId(e){var t;return e.objectId===e.unitId?e.unitId:(t=this._getRule(e))==null?void 0:t.permissionId}initializeUnit(e){if(!this.supports(e)||this._initialized.has(e.unitId))return;this._initialized.add(e.unitId);let t=[];this._permissions.getAllPermissionPoint().forEach(n=>{n.subscribe(n=>{`unitId`in n&&n.unitId===e.unitId&&t.push(n.id)}).unsubscribe()}),t.forEach(e=>this._permissions.updatePermissionPoint(e,!1)),this.refreshUnit(e.unitId).catch(e=>{this._logService.error(e)})}supports(e){var t;return((t=this._config.getConfig(`objectPermissionTypes`))==null?void 0:t.includes(e.objectType))===!0&&this._models.has(pS[e.objectType])}getPolicies(e){return this._policies.get(e)??[]}hasPolicy(e){var t,r;let i=this.getPolicies(e.unitId).find(t=>t.objectID===e.objectId&&t.objectType===e.objectType);return!!i&&(((t=i.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf||((r=i.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator||i.strategies.some(e=>e.role===n.UnitRole.Owner))}canView(e){var t;let r=pS[e.objectType];return this.supports(e)&&r!==void 0&&((t=this._permissions.getPermissionPoint(`${r}.${n.UnitAction.Edit}_${e.unitId}`))==null?void 0:t.value)===!0}async canManage(e){if(!this.supports(e))return!1;let t=await this._getPolicy(e);if(!this._getRule(e)&&e.objectId!==e.unitId){let t=pS[e.objectType];return t!==void 0&&this._allowed({...e,objectId:e.unitId,objectType:t},n.UnitAction.CreatePermissionObject)}return(e.objectId===e.unitId||!!t)&&this._canChangeRule(e,t,n.UnitAction.ManageCollaborator)}async canDelete(e){if(!this.supports(e)||e.objectId===e.unitId)return!1;let t=await this._getPolicy(e);return!!t&&this._canChangeRule(e,t,n.UnitAction.Delete)}async remove(e){var t;let n=(t=this._getRule(e))==null?void 0:t.permissionId;if(!await this.canDelete(e))throw Error(`Object permission deletion denied.`);await this._commitRule(e,null,n),await this.refreshUnit(e.unitId)}async _commitRule(e,t,n){let r=this._models.get(pS[e.objectType]);if(!r)throw Error(`Object permission rule model is not registered.`);let i=this._getRule(e)??null;if((i==null?void 0:i.permissionId)!==n)throw Error(`Object permission binding changed during the request.`);let a={id:r.mutationId,params:{...e,rule:t}},o={id:r.mutationId,params:{...e,rule:i}};if(!await this._commands.executeCommand(a.id,a.params))throw Error(`Could not update the object permission binding.`);this._injector.get(iS).pushUndoRedo({unitID:e.unitId,redoMutations:[a],undoMutations:[o]})}async _getPolicy(e){let t=this._getAuthzId(e);if(t)return(await this._authz.list({unitID:e.unitId,objectIDs:[t],actions:[]})).find(n=>n.unitID===e.unitId&&n.objectID===t&&n.objectType===e.objectType)}async _allowed(e,t){let n=this._getAuthzId(e);return n?(await this._authz.allowed({unitID:e.unitId,objectID:n,objectType:e.objectType,actions:[t]})).some(e=>e.action===t&&e.allowed===!0):!1}async _canChangeRule(e,t,n){var r;if(await this._allowed(e,n))return!0;let i=t==null||(r=t.creator)==null?void 0:r.userID;return!!i&&i===this._users.getCurrentUser().userID}async read(e){var t,r;let i=this._getAuthzId(e);if(!i)return{edit:`all`,collaborators:[],strategies:[]};let[a,o]=await Promise.all([this._getPolicy(e),e.objectId===e.unitId?[]:this._authz.listCollaborators({unitID:e.unitId,objectID:i})]),s=`all`;return(a==null||(t=a.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf?s=`owner`:(a==null||(r=a.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator?s=`members`:a!=null&&a.strategies.some(e=>e.action===n.UnitAction.Edit&&e.role===n.UnitRole.Owner)&&(s=`owner`),{edit:s,collaborators:o,strategies:(a==null?void 0:a.strategies)??[]}}async setPoint(e,t,r){if(!this.supports(e)){this._permissions.getPermissionPoint(t.id)||this._permissions.addPermissionPoint(t),this._permissions.updatePermissionPoint(t.id,r);return}this._assertSupported(e);let i=await this.read(e);i.strategies=i.strategies.filter(e=>e.action!==t.subType),i.strategies.push({action:t.subType,role:r?n.UnitRole.Editor:n.UnitRole.Owner}),t.subType===n.UnitAction.Edit&&(i.edit=r?`all`:`owner`),await this.save(e,i)}async save(e,t){var n;let r=(n=this._getRule(e))==null?void 0:n.permissionId,i=await this._writePolicy(e,t,r);i&&await this._commitRule(e,i,r),await this.refreshUnit(e.unitId)}async _writePolicy(e,t,r){var i,a;if(this._assertSupported(e),!await this.canManage(e))throw Error(`Object permission management denied.`);if(e.objectId===e.unitId&&t.edit===`members`)throw Error(`File membership must be managed through the sharing service.`);if(t.edit===`members`&&!t.collaborators.length)throw Error(`Select at least one collaborator.`);let o=await this._getPolicy(e),s=t.strategies.filter(e=>e.action!==n.UnitAction.Edit);s.push({action:n.UnitAction.Edit,role:t.edit===`owner`?n.UnitRole.Owner:n.UnitRole.Editor});let c=n.ObjectScope.AllCollaborator;t.edit===`members`?c=n.ObjectScope.SomeCollaborator:t.edit===`owner`&&(c=n.ObjectScope.OneSelf);let l={read:(o==null||(i=o.scope)==null?void 0:i.read)??n.ObjectScope.AllCollaborator,edit:c};if(((a=this._getRule(e))==null?void 0:a.permissionId)!==r)throw Error(`Object permission binding changed during the request.`);let u=this._getAuthzId(e);if(u)await this._authz.update({unitID:e.unitId,objectID:u,objectType:e.objectType,name:(o==null?void 0:o.name)??e.objectId,share:void 0,strategies:s,scope:l,collaborators:e.objectId===e.unitId?void 0:{collaborators:t.edit===`members`?t.collaborators:[]}});else{let r={unitID:e.unitId,name:e.objectId,strategies:s,scope:l,collaborators:t.edit===`members`?t.collaborators:[]},i={objectType:e.objectType};switch(pS[e.objectType]){case n.UnitObject.Document:i.documentObject=r;break;case n.UnitObject.Slide:i.slideObject=r;break;case n.UnitObject.Base:i.baseObject=r;break;case n.UnitObject.Board:i.boardObject=r;break;default:throw Error(`Unsupported object permission type.`)}if(u=await this._authz.create(i),!u)throw Error(`Authz did not return a permission ID.`);return{objectId:e.objectId,objectType:e.objectType,permissionId:u}}}async saveMany(e){let t=e[0],n=t&&this._models.get(pS[t.objectType]);if(!t||!(n!=null&&n.batchMutationId)||e.some(e=>e.unitId!==t.unitId||e.objectId===t.unitId||pS[e.objectType]!==pS[t.objectType]||!this.supports(e))||new Set(e.map(e=>`${e.objectType}/${e.objectId}`)).size!==e.length)throw Error(`Invalid object permission batch.`);let r={succeeded:[],failed:[]},i=[];for(let t of e){let e=this._getRule(t)??null;try{let n;if(t.policy===null){if(!await this.canDelete(t))throw Error(`Object permission deletion denied.`);n=null}else n=await this._writePolicy(t,t.policy,e==null?void 0:e.permissionId);if(n===void 0){var a;if(((a=this._getRule(t))==null?void 0:a.permissionId)!==(e==null?void 0:e.permissionId))throw Error(`Object permission binding changed during the request.`);r.succeeded.push(t.objectId)}else i.push({target:t,rule:n,previous:e})}catch(e){r.failed.push({objectId:t.objectId,error:e})}}let o=i.filter(({target:e,previous:t})=>{var n;return((n=this._getRule(e))==null?void 0:n.permissionId)===(t==null?void 0:t.permissionId)||(r.failed.push({objectId:e.objectId,error:Error(`Object permission binding changed during the request.`)}),!1)});if(o.length){let e={unitId:t.unitId,rules:o.map(({target:e,rule:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))},i={unitId:t.unitId,rules:o.map(({target:e,previous:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))};try{if(!await this._commands.executeCommand(n.batchMutationId,e))throw Error(`Could not update the object permission bindings.`);this._injector.get(iS).pushUndoRedo({unitID:t.unitId,redoMutations:[{id:n.batchMutationId,params:e}],undoMutations:[{id:n.batchMutationId,params:i}]}),r.succeeded.push(...o.map(({target:e})=>e.objectId))}catch(e){r.failed.push(...o.map(({target:t})=>({objectId:t.objectId,error:e})))}}try{await this.refreshUnit(t.unitId)}catch(e){r.refreshError=e}return r}async refreshUnit(e){if(this._disposed)return;let t=[...this._models.values()].flatMap(({model:t})=>t.getRules(e)),r=new Map(t.map(e=>[`${e.objectType}/${e.objectId}`,e])),i=new Map,a=(t,n,r,a)=>{if(!this.supports({unitId:e,objectId:r,objectType:n}))return;let o=`${n}/${t}`,s=i.get(o);i.set(o,{unitID:e,objectID:t,objectType:n,targetId:r,actions:[...new Set([...(s==null?void 0:s.actions)??[],...a])]})},o=[];t.forEach(e=>a(e.permissionId,e.objectType,e.objectId,[n.UnitAction.Edit])),this._permissions.getAllPermissionPoint().forEach(t=>{t.subscribe(t=>{if(!(`unitId`in t)||t.unitId!==e)return;let n=`objectId`in t&&typeof t.objectId==`string`?t.objectId:e,i=r.get(`${t.type}/${n}`);n===e?a(e,t.type,e,[t.subType]):i?a(i.permissionId,t.type,n,[t.subType]):this.supports({unitId:e,objectId:n,objectType:t.type})&&o.push(t.id)}).unsubscribe()}),o.forEach(e=>this._permissions.updatePermissionPoint(e,!0));let s=++this._nextGeneration;this._generations.set(e,s);let c=[...i.values()];c.length&&this._initialized.add(e);let l=[],u=[];for(let t=0;t<c.length;t+=100){let n=c.slice(t,t+100),r=await this._authz.list({unitID:e,objectIDs:n.map(e=>e.objectID),actions:[]});l.push(...r),n.forEach(e=>{let t=r.find(t=>t.objectID===e.objectID&&t.objectType===e.objectType);e.actions=[...new Set([...e.actions,...(t==null?void 0:t.strategies.map(e=>e.action))??[]])]}),u.push(...await this._authz.batchAllowed(n.map(({targetId:e,...t})=>t)))}if(this._disposed||this._generations.get(e)!==s)return;let d=new Map(u.filter(t=>t.unitID===e).map(e=>[e.objectID,e])),f=new Map(l.filter(t=>t.unitID===e).map(e=>[`${e.objectType}/${e.objectID}`,e]));c.forEach(t=>{let n=d.get(t.objectID),r=f.get(`${t.objectType}/${t.objectID}`);[...new Set([...t.actions,...(r==null?void 0:r.strategies.map(e=>e.action))??[]])].forEach(r=>{let i=`${t.objectType}.${r}_${e}${t.targetId===e?``:`_${t.targetId}`}`;this._permissions.getPermissionPoint(i)||this._permissions.addPermissionPoint({id:i,type:t.objectType,subType:r,status:`done`,value:!1,unitId:e,objectId:t.targetId}),this._permissions.updatePermissionPoint(i,(n==null?void 0:n.actions.some(e=>e.action===r&&e.allowed===!0))??!1)})}),this._policies.set(e,l.filter(t=>t.unitID===e).map(e=>{var t;return{...e,objectID:((t=i.get(`${e.objectType}/${e.objectID}`))==null?void 0:t.targetId)??e.objectID}})),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}clearUnit(e){this._initialized.delete(e),this._generations.delete(e),this._policies.delete(e),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}_assertSupported(e){if(!this.supports(e))throw Error(`Object permission management is not supported by this Authz provider.`)}};mS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,fS),V(2,da),V(3,(0,i.Inject)(Qb)),V(4,oa),V(5,_a)],mS);var hS=class extends k{constructor(...e){super(...e),T(this,`_permissionPointMap`,new Map),T(this,`_permissionPointUpdate$`,new t.Subject),T(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),T(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let n=e instanceof t.BehaviorSubject,r=n?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,n?e:new t.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=`done`,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){let n=e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()});return(0,t.combineLatest)(n).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function gS(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let _S=Symbol(`DependentOn`);var vS=class extends k{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};T(vS,`pluginName`,void 0),T(vS,`packageName`,Re),T(vS,`version`,ze),T(vS,`type`,n.UniverType.UNIVER_UNKNOWN);var yS=class{constructor(){T(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function bS(...e){return function(t){t[_S]=e}}let xS=class{constructor(e,t,r){this._injector=e,this._lifecycleService=t,this._logService=r,T(this,`_pluginRegistry`,new Map),T(this,`_pluginStore`,new yS),T(this,`_seenPlugins`,new Set),T(this,`_loadedPlugins`,new Set),T(this,`_loadedPluginTypes`,new Set([n.UniverType.UNIVER_UNKNOWN])),T(this,`_flushTimerByType`,new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let r={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,r),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:i}=e;this._loadedPluginTypes.has(i)&&(i===n.UniverType.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(i))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:r,packageName:i,version:a}=e;if(t===n.UniverType.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!r)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(a&&a!==vS.version&&this._logService.error(`[PluginService]`,[`Plugin version mismatch.`,` plugin: "${r||e.name}"`,` package: "${i}"`,` plugin version: "${a}"`,` core version: "${vS.version}"`,` registration will continue, but please make sure all @univerjs packages use the same version.`].join(`
25
+ `)),this._seenPlugins.has(r))throw Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],r=new Set,i=e=>{let{plugin:a}=e,{pluginName:o}=a;if(this._loadedPlugins.has(o)||r.has(o))return;r.add(o),this._pluginRegistry.delete(o);let s=a[_S];s&&s.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)i(t);else if(!this._seenPlugins.has(e.pluginName)&&!r.has(e.pluginName)){if(a.type===n.UniverType.UNIVER_UNKNOWN&&e.type!==n.UniverType.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${e.pluginName}.`);a.type!==e.type&&e.type!==n.UniverType.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),i({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>i(e));let a=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(a)}_pluginsRunLifecycle(e){let n=this._lifecycleService.stage;if(Qx(n).subscribe(t=>this._runStage(e,t)),n!==3){let n=this._lifecycleService.lifecycle$.pipe((0,t.skip)(1)).subscribe(t=>{this._runStage(e,t),t===3&&n.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case 0:e.onStarting();break;case 1:e.onReady();break;case 2:e.onRendered();break;case 3:e.onSteady()}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};xS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,(0,i.Inject)(Zx)),V(2,da)],xS);let SS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_currentRegion$`,void 0),T(this,`currentRegion$`,void 0),T(this,`_hasExplicitRegion`,!1),this._currentRegion$=new t.BehaviorSubject(this._localeService.getCurrentLocale()),this.currentRegion$=this._currentRegion$.asObservable(),this.disposeWithMe(this._localeService.currentLocale$.subscribe(e=>{!this._hasExplicitRegion&&e!==this._currentRegion$.value&&this._currentRegion$.next(e)})),this.disposeWithMe(D(()=>this._currentRegion$.complete()))}setRegion(e){this._hasExplicitRegion=!0,this._currentRegion$.next(e)}getCurrentRegion(){return this._currentRegion$.value}};SS=ma([V(0,(0,i.Inject)(eS))],SS);let CS=(0,i.createIdentifier)(`resource-loader-service`),wS=class extends k{constructor(e){super(),this._logService=e,T(this,`_resourceMap`,new Map),T(this,`_register$`,new t.Subject),T(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){let n=this.getAllResourceHooks(),r=[];for(let i=0;i<n.length;i++){let a=n[i];if(!a.businesses.includes(t))continue;let o=a.toJson(e);r.push({name:a.pluginName,data:o})}return r}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),D(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){let n=this.getAllResourceHooks();for(let i=0;i<n.length;i++){var r;let a=n[i],o=t==null||(r=t.find(e=>e.name===a.pluginName))==null?void 0:r.data;if(o)try{let t=a.parseJson(o);a.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}}}unloadResources(e,t){let n=this.getAllResourceHooks();for(let r=0;r<n.length;r++){let i=n[r];i.businesses.includes(t)&&i.onUnLoad(e)}}dispose(){this._register$.complete(),this._resourceMap.clear()}};wS=ma([V(0,da)],wS);var TS=class extends k{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),T(this,`_darkMode$`,new t.BehaviorSubject(!1)),T(this,`darkMode$`,this._darkMode$.asObservable()),T(this,`_validColorCache`,new Map),T(this,`_currentTheme`,a.defaultTheme),T(this,`_currentTheme$`,new t.BehaviorSubject(this._currentTheme)),T(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(D(()=>{this._currentTheme=a.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in a.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in a.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return _i(this._currentTheme,e)}},ES=class{constructor(e,t=1e3){this._injector=e,T(this,`_imageCacheMap`,void 0),this._imageCacheMap=new bd(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(px)?this._injector.get(px):null,s=this._injector.has(mx)?this._injector.get(mx):null;if(e===`UUID`)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===`URL`)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function DS(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function OS(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}let kS=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],$=new Uint32Array(96);var AS=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=kS[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=kS.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return jS(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=[];for(;s>0;){let l=$[--s],u=$[--s],d=$[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&($[s++]=d,$[s++]=f-1,$[s++]=1-l),(l===0?n>=p:r>=m)&&($[s++]=f+1,$[s++]=u,$[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=$[--s],d=$[--s],f=$[--s];if(d-f<=o){for(let n=f;n<=d;n++)FS(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];FS(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&($[s++]=f,$[s++]=p-1,$[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&($[s++]=p+1,$[s++]=d,$[s++]=1-u)}return c}};function jS(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;MS(e,t,o,r,i,a),jS(e,t,n,r,o-1,1-a),jS(e,t,n,o+1,i,1-a)}function MS(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);MS(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(NS(e,t,r,n),t[2*i+a]>o&&NS(e,t,r,i);s<c;){for(NS(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?NS(e,t,r,c):(c++,NS(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function NS(e,t,n,r){PS(e,n,r),PS(t,2*n,2*r),PS(t,2*n+1,2*r+1)}function PS(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function FS(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var IS=class{constructor(e=!1){this._enableOneCellCache=e,T(this,`_tree`,new Map),T(this,`_oneCellCache`,new Map),T(this,`_kdTree`,new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Ad),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new AS(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this.getTree(t,n),o=a.search({minX:r.startColumn,minY:r.startRow,maxX:r.endColumn,maxY:r.endRow});for(let e=0;e<o.length;e++)o[e].id===i&&a.remove(o[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){for(let t of e)this.remove(t)}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,new Map);for(let n in e[t]){let r=new Ad;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};function LS(e){return new Promise(t=>setTimeout(t,e))}function RS(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}function zS(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=zS(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=zS(e[i])}return t}function BS(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:zS(e.p)),e.s!==void 0&&(t.s=e.s===null||typeof e.s==`string`?e.s:zS(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ft!==void 0&&(t.ft=e.ft),e.fd!==void 0&&(t.fd=e.fd),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:zS(e.custom)),t}function VS(e){if(e==null)return e;let t=BS(e);return e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function HS(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=BS(r))}t[a]=s}return t}function US(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(s.s=o.s===null||typeof o.s==`string`?o.s:zS(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:zS(o.custom)),t[a]=s}return t}function WS(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function GS(e){let t={id:e.id,name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,backgroundImage:e.backgroundImage?{source:e.backgroundImage.source,imageSourceType:e.backgroundImage.imageSourceType,scaleX:e.backgroundImage.scaleX,scaleY:e.backgroundImage.scaleY}:void 0,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:WS(e.mergeData),cellData:HS(e.cellData),rowData:US(e.rowData),columnData:US(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(t.defaultStyle=e.defaultStyle===null||typeof e.defaultStyle==`string`?e.defaultStyle:zS(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:zS(e.custom)),t}let KS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_fontLocale`,void 0),T(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};KS=ma([V(0,(0,i.Inject)(eS))],KS);function qS(e={}){let t={defaultBackgroundColor:`rgba(24, 119, 242, 0.08)`,defaultStripeColor:`rgba(24, 119, 242, 0.25)`,rowGaps:{1:{size:6},3:{size:10,color:`rgba(245, 158, 11, 0.14)`},6:{size:14,color:`rgba(16, 185, 129, 0.12)`,stripeColor:`rgba(5, 150, 105, 0.35)`}},colGaps:{1:{size:5},2:{size:8,stripeColor:`rgba(59, 130, 246, 0.35)`},4:{size:12,color:`rgba(244, 63, 94, 0.12)`,stripeColor:`rgba(225, 29, 72, 0.30)`}}};return{...t,...e,rowGaps:{...t.rowGaps,...e.rowGaps},colGaps:{...t.colGaps,...e.colGaps}}}let JS=class extends KS{constructor(e,t,n,r,i,a){super(n),this.worksheet=e,this._styles=t,this._contextService=r,this._configService=i,this._injector=a,T(this,`_worksheetData`,void 0),T(this,`_renderRawFormula`,!1),T(this,`_cellData`,void 0),T(this,`_imageCacheMap`,void 0),T(this,`_skipAutoHeightForMergedCells`,!0),T(this,`_rowTotalHeight`,0),T(this,`_columnTotalWidth`,0),T(this,`_rowHeaderWidth`,0),T(this,`_columnHeaderHeight`,0),T(this,`_rowHeightAccumulation`,[]),T(this,`_columnWidthAccumulation`,[]),T(this,`_marginTop`,0),T(this,`_marginLeft`,0),T(this,`_gapConfig`,{}),T(this,`_scaleX`,1),T(this,`_scaleY`,1),T(this,`_scrollX`,0),T(this,`_scrollY`,0),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new ES(this._injector),this.initConfig()}initConfig(){this._skipAutoHeightForMergedCells=!(this._configService.getConfig(Op)??!1),this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig(`isRowStylePrecedeColumnStyle`)??!1)}resetCache(){}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){z.isDefine(e)&&(this._scrollX=e),z.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}get gapConfig(){return this._gapConfig}setGapConfig(e){this._gapConfig=this._fillDefaultGapThemeColors(e),this.makeDirty(!0),this._updateLayout()}_fillDefaultGapThemeColors(e){if(e.defaultBackgroundColor&&e.defaultStripeColor)return e;let{r:t,g:n,b:r}=new La(this._injector.get(TS).getColorFromTheme(`primary.500`)).toRgb();return{...e,defaultBackgroundColor:e.defaultBackgroundColor??`rgba(${t}, ${n}, ${r}, 0.025)`,defaultStripeColor:e.defaultStripeColor??`rgba(${t}, ${n}, ${r}, 0.08)`}}getRowGapSize(e){var t;return((t=this._gapConfig.rowGaps)==null||(t=t[e])==null?void 0:t.size)??0}getColGapSize(e){var t;return((t=this._gapConfig.colGaps)==null||(t=t[e])==null?void 0:t.size)??0}getGapSizeGetter(){if(this._gapConfig.rowGaps||this._gapConfig.colGaps)return{row:e=>this.getRowGapSize(e),col:e=>this.getColGapSize(e)}}getRowGapAtPosition(e){let{rowGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._rowHeightAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}getColGapAtPosition(e){let{colGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._columnWidthAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){var o;let e=n;if(this.worksheet.getRowFiltered(t))e=0;else if(a[t]!=null){let r=a[t];if(!r)continue;let{h:i=n,ah:o,ia:s}=r;e=(s==null||s===1)&&typeof o==`number`&&o>0?o:i,r.hd===1&&(e=0)}let s=((o=this._gapConfig.rowGaps)==null||(o=o[t])==null?void 0:o.size)??0;r+=s,r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=t;for(let t=0;t<e;t++){var o;let e=n;if(a[t]!=null){let n=a[t];if(!n)continue;n.w!=null&&(e=n.w),n.hd===1&&(e=0)}let s=((o=this._gapConfig.colGaps)==null||(o=o[t])==null?void 0:o.size)??0;r+=s,r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=1){let a=0;if(t>n){let o=this._columnWidthAccumulation.length-1;for(let s=t;s>=n;s--){let n=s;if(!hu(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n+1>o?o:n+1;let{startX:c,endX:l}=XS(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(a+=i===2&&n===t?(l-c)/2:l-c,r<a)return n}return t}for(let o=t;o<=n;o++){let n=o;if(!hu(this.worksheet.getCell(e,n))&&n!==t||this.intersectMergeRange(e,n))return n===t?n:n-1<0?0:n-1;let{startX:s,endX:c}=XS(e,n,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(a+=i===2&&n===t?(c-s)/2:c-s,r<a)return n}return n}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===1?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===1?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new du,l=0,u=null;for(;s;){s=!1;for(let e=0;e<o.length;e++){let{startRow:t,startColumn:d,endRow:f,endColumn:p}=o[e];if(c.getValue(t,d))continue;let m={startColumn:r,startRow:n,endColumn:a,endRow:i},h={startColumn:d,startRow:t,endColumn:p,endRow:f};Qd(m,h)&&(n=Math.min(n,t),r=Math.min(r,d),i=Math.max(i,f),a=Math.max(a,p),c.setValue(t,d,!0),s=!0,l++,u=h)}}return t&&l===1&&Gd.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=XS(e,t,r,i,void 0,this.getGapSizeGetter());return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this;e=QS(e,t,n,this.columnHeaderHeightAndMarginTop);let a=Na(i,e,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(i[a]-e)<Math.abs(e-(i[a-1]??0))&&(a+=1),a}getColumnIndexByOffsetX(e,t,n,r){let i=ZS(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=Na(a,i,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(a[o]-i)<Math.abs(i-(a[o-1]??0))&&(o+=1),o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=XS(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t),this.getGapSizeGetter()),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=Na(this.columnWidthAccumulation,e),r=e-((this._columnWidthAccumulation[n-1]||0)+this.getColGapSize(n)),i=Na(this.rowHeightAccumulation,t);return{row:i,column:n,columnOffset:r,rowOffset:t-((this._rowHeightAccumulation[i-1]||0)+this.getRowGapSize(i))}}getCellIndexAndOffsetByPosition(e,t){let{actualRow:n,actualColumn:r,startX:i,startY:a}=this.getCellWithCoordByOffset(e,t,this._scaleX,this._scaleY,{x:this._scrollX,y:this._scrollY});return{row:n,rowOffset:t-a,column:r,columnOffset:e-i}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new uy(e)}dispose(){super.dispose(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};JS=ma([V(2,(0,i.Inject)(eS)),V(3,ca),V(4,oa),V(5,(0,i.Inject)(i.Injector))],JS);function YS(e,t,n,r,i=0,a=0){let o=e-1,s=t-1,c=(n[o]||0)+i,l=n[e];l??=n[n.length-1];let u=(r[s]||0)+a,d=r[t];return d??=r[r.length-1],{startY:c,endY:l,startX:u,endX:d}}function XS(e,t,n,r,i,a){e=z.clamp(e,0,n.length-1),t=z.clamp(t,0,r.length-1);let{startY:o,endY:s,startX:c,endX:l}=YS(e,t,n,r,(a==null?void 0:a.row(e))??0,(a==null?void 0:a.col(t))??0);if(!i)return{startY:o,endY:s,startX:c,endX:l,isMerged:!1,isMergedMainCell:!1,actualRow:e,actualColumn:t,mergeInfo:{startY:o,endY:s,startX:c,endX:l,startRow:e,startColumn:t,endRow:e,endColumn:t}};let{isMerged:u,isMergedMainCell:d,startRow:f,startColumn:p,endRow:m,endColumn:h}=i,g={startRow:f,startColumn:p,endRow:m,endColumn:h,startY:o,endY:s,startX:c,endX:l},_=n.length-1,v=r.length-1;if(u&&f!==-1&&p!==-1){let e=(a==null?void 0:a.row(f))??0,t=(a==null?void 0:a.col(p))??0,i=(n[f-1]||0)+e,o=n[m]||n[_],s=(r[p-1]||0)+t,c=r[h]||r[v];g={...g,startY:i,endY:o,startX:s,endX:c}}else if(!u&&m!==-1&&h!==-1){let e=n[m]||n[_],t=r[h]||r[v];g={...g,startY:o,endY:e,startX:c,endX:t}}return{isMerged:u,isMergedMainCell:d,actualRow:e,actualColumn:t,startY:o,endY:s,startX:c,endX:l,mergeInfo:g}}function ZS(e,t,n,r){let{x:i}=n;return e/t+i-r}function QS(e,t,n,r){let{y:i}=n;return e=e/t+i-r,e}let $S=[`script`,`style`,`meta`,`comment`,`link`],eC=function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),tC=function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),nC=function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),rC=function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),iC=function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),aC=function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),oC=function(e){return e.Blank=`blank`,e.String=`string`,e.Number=`number`,e.Date=`date`,e.Boolean=`boolean`,e.Error=`error`,e}({}),sC=function(e){return e.All=`all`,e.Include=`include`,e.Exclude=`exclude`,e}({}),cC=class extends k{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=(e,t,n=[],r)=>{let i=n.find(t=>t.name===e.pluginName);if(i)try{let n=e.parseJson(i.data);e.onLoad(t,n)}catch{console.error(`Load ${r}{${t}} Resources{${e.pluginName}} Data Error.`)}},t=t=>{t.businesses.forEach(r=>{switch(r){case n.UniverType.UNRECOGNIZED:case n.UniverType.UNIVER_UNKNOWN:case n.UniverType.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_DOC).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Document`)});break;case n.UniverType.UNIVER_SLIDE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SLIDE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Slide`)});break;case n.UniverType.UNIVER_BOARD:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BOARD).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Board`)});break;case n.UniverType.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SHEET).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Workbook`)});break;case n.UniverType.UNIVER_BASE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BASE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Base`)})}})};this._resourceManagerService.getAllResourceHooks().forEach(e=>t(e)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(e=>t(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SHEET).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_DOC).subscribe(e=>{let{unit:t}=e;Ap(t.getUnitId())||this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BOARD).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BASE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_DOC)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BASE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BASE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SLIDE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BOARD).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BOARD)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=z.deepClone(t.getSnapshot());return r.resources=n,r}};cC=ma([V(0,(0,i.Inject)(Jb)),V(1,(0,i.Inject)(Kx))],cC);var lC=class extends M{constructor(...e){super(...e),T(this,`type`,void 0),T(this,`name$`,void 0)}getUnitId(){throw Error(`Method not implemented.`)}setName(e){throw Error(`Method not implemented.`)}getSnapshot(){throw Error(`Method not implemented.`)}getRev(){throw Error(`Method not implemented.`)}incrementRev(){throw Error(`Method not implemented.`)}setRev(e){throw Error(`Method not implemented.`)}},uC=class{get _univerInstanceService(){return this._injector.get(Kx)}get _pluginService(){return this._injector.get(xS)}constructor(e={},t){T(this,`_startedTypes`,new Set),T(this,`_injector`,void 0),T(this,`_disposingCallbacks`,new O);let n=this._injector=dC(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,region:o,locales:s,direction:c,logLevel:l,logCommandExecution:u,undoRedoHistoryLimit:d}=e,f=this._injector.get(oa);r&&this._injector.get(TS).setTheme(r),i&&this._injector.get(TS).setDarkMode(i),s&&this._injector.get(eS).load(s),a&&this._injector.get(eS).setLocale(a),o&&this._injector.get(SS).setRegion(o),c&&this._injector.get(eS).setDirection(c),l&&this._injector.get(da).setLogLevel(l),u!==void 0&&f.setConfig(ha,u),f.setConfig(`undoRedo.historyLimit`,d??50),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(D(e));return D(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(eS).setLocale(e)}setRegion(e){this._injector.get(SS).setRegion(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}_init(e){this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SHEET,Gx),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_DOC,uy),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SLIDE,lC);let t=e.get(Kx);t.__setCreateHandler((n,r,i,a)=>{let o=!this._startedTypes.has(n);o&&(this._pluginService.startPluginsForType(n),this._startedTypes.add(n));let s=t.__getCtorByType(n)??i;if(!s)throw Error(`[Univer]: No constructor registered for unit type ${n}.`);let c=e.createInstance(s,r);return t.__addUnit(c,a),o&&this._tryProgressToReady(),c})}_tryProgressToReady(){this._injector.get(Zx).stage<1&&(this._injector.get(Zx).stage=1)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function dC(e,t){let n=gS([[ux],[eS],[SS],[TS],[Zx],[xS],[Qb],[Kx,{useClass:qx}],[fS,{useClass:hS}],[mS],[da,{useClass:fa,lazy:!0}],[_a,{useClass:ba}],[iS,{useClass:uS,lazy:!0}],[oa,{useClass:sa}],[ca,{useClass:la}],[Jb,{useClass:wS,lazy:!0}],[CS,{useClass:cC,lazy:!0}],[ex,{useClass:$b}],[nS,{useClass:tS,lazy:!0}]],t),r=e?e.createChild(n):new i.Injector(n);return Je(r,[[Qb],[CS]]),r}x(),e.ABCToNumber=af,e.AUTO_HEIGHT_FOR_MERGED_CELLS=Op,e.AbsoluteRefType=lo,e.ActionIterator=Cv,e.AlignTypeH=ph,e.AlignTypeV=mh,e.ArrangeTypeEnum=Mp,e.AsyncInterceptorManager=Gp,e.AsyncLock=xp.default,Object.defineProperty(e,"AuthzIoLocalService",{enumerable:!0,get:function(){return $b}}),e.AutoFillSeries=se,e.BASE_RECORD_ID_FIELD_ID=Sf,e.BASE_RECORD_ID_FIELD_NAME=Cf,e.BORDER_KEYS=Ch,e.BORDER_STYLE_KEYS=Sh,e.BaseConditionalColorOperator=gf,e.BaseConditionalColorTarget=hf,e.BaseConditionalDateMode=_f,e.BaseDataModel=jf,e.BaseFieldType=ff,e.BaseFilterConjunction=yf,e.BaseFilterOperator=vf,e.BaseHierarchyInvalidReason=xf,e.BaseRecordLinkRole=pf,e.BaseSortDirection=bf,e.BaseViewType=mf,e.BaselineOffset=Ne,e.BlockType=Vm,e.BooleanNumber=Pe,e.BorderStyleTypes=ce,e.BorderType=le,e.BuildTextUtils=Z,e.BulletAlignment=Im,e.COLORS=Ia,e.COLOR_STYLE_KEYS=xh,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=ha,e.CanceledError=Xe,e.CellModeEnum=mo,e.CellValueType=Fe,e.ColorKit=La,e.ColorType=ue,e.ColumnLayoutType=ah,e.ColumnResponsiveType=oh,e.ColumnSeparatorType=Gm,Object.defineProperty(e,"CommandService",{enumerable:!0,get:function(){return ba}}),e.CommandType=ga,e.CommonHideTypes=de,e.ConfigService=sa,e.ContextService=la,e.CopyPasteType=fe,e.CustomCommandExecutionError=Ye,e.CustomDecorationType=Bm,e.CustomRangeType=Rm,e.DEFAULT_CELL=Ah,e.DEFAULT_DOC=oy,e.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING=Nh,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE=0,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW=12,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
26
+ `,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=Oh,e.DEFAULT_RANGE_ARRAY=Dh,e.DEFAULT_SELECTION=kh,e.DEFAULT_STYLES=Y,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=Fx,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Dp,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Ep,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Tp,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=po,e.DashStyleType=Qm,e.DataStreamTreeNodeType=bm,e.DataStreamTreeTokenType=xm,e.DataValidationErrorStyle=eC,e.DataValidationImeMode=tC,e.DataValidationOperator=nC,e.DataValidationRenderMode=rC,e.DataValidationStatus=iC,e.DataValidationType=aC,e.DateSystem=pe,e.DeleteDirection=me,e.DependentOn=bS,e.DesktopLogService=fa,e.DeveloperMetadataVisibility=he,e.Dimension=ge,e.Direction=_e,e.Disposable=k,e.DisposableCollection=O,e.DocStyleType=Nm,e.DocumentBlockRangeType=Lm,e.DocumentBlockType=Mm,e.DocumentDataModel=uy,e.DocumentFlavor=Hm,e.DocxBreakType=zm,e.DrawingTypeEnum=Np,e.EDITOR_ACTIVATED=cx,e.EXCEL_1904_OFFSET=Qs,e.EXTENSION_NAMES=Fh,e.ErrorService=ux,e.EventState=Gb,e.EventSubject=Kb,e.FOCUSING_BOARD=sx,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=ax,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=lx,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=`FOCUSING_SHAPE_TEXT_EDITOR`,e.FOCUSING_SHEET=ix,e.FOCUSING_SLIDE=ox,e.FOCUSING_UNIT=rx,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FilterSelectionMode=sC,e.FollowNumberWithType=Pm,e.FontItalic=je,e.FontStyleType=lh,e.FontWeight=Me,e.FormulaType=ro,e.GridType=Um,e.HorizontalAlign=Oe,e.IAuthzIoService=ex,e.ICommandService=_a,e.IConfigService=oa,e.IConfirmService=tx,e.IContextService=ca,e.IImageIoService=px,e.ILocalStorageService=$x,e.ILogService=da,e.IMentionIOService=nS,e.IPermissionService=fS,e.IResourceLoaderService=CS,e.IResourceManagerService=Jb,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=mx,e.IUndoRedoService=iS,e.IUniverInstanceService=Kx,e.ImageCacheMap=ES,e.ImageSourceType=dx,e.ImageUploadStatusType=fx,Object.defineProperty(e,"Inject",{enumerable:!0,get:function(){return i.Inject}}),Object.defineProperty(e,"InjectSelf",{enumerable:!0,get:function(){return i.InjectSelf}}),Object.defineProperty(e,"Injector",{enumerable:!0,get:function(){return i.Injector}}),e.InterceptorEffectEnum=zp,e.InterceptorManager=Hp,e.InterpolationPointType=ye,Object.defineProperty(e,"JSON1",{enumerable:!0,get:function(){return ng}}),e.JSONX=ty,e.LOCALE_META=xe,e.LRUHelper=xd,e.LRUMap=bd,Object.defineProperty(e,"LifecycleService",{enumerable:!0,get:function(){return Zx}}),e.LifecycleStages=Jx,e.LifecycleUnreachableError=Xx,e.ListGlyphType=Fm,Object.defineProperty(e,"LocalUndoRedoService",{enumerable:!0,get:function(){return uS}}),e.LocaleService=eS,e.LocaleType=be,e.LogLevel=ua,Object.defineProperty(e,"LookUp",{enumerable:!0,get:function(){return i.LookUp}}),e.MAX_COLUMN_COUNT=16384,e.MAX_ROW_COUNT=1048576,e.MODERN_DOCUMENT_DEFAULT_MARGIN=66.66666666666667,e.MODERN_DOCUMENT_WIDTH=Rh,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,"Many",{enumerable:!0,get:function(){return i.Many}}),e.MemoryCursor=sm,Object.defineProperty(e,"MentionIOLocalService",{enumerable:!0,get:function(){return tS}}),e.MentionType=Se,e.ModernDocumentWidthMode=Lh,e.NAMED_STYLE_MAP=Mh,e.NAMED_STYLE_SPACE_MAP=Ph,e.NamedStyleType=Xm,e.NilCommand=ya,e.NumberUnitType=fh,e.OBJECT_PERMISSION_CONFIG_KEY=`objectPermissionTypes`,e.ObjectMatrix=du,e.ObjectPermissionRuleModel=rS,Object.defineProperty(e,"ObjectPermissionService",{enumerable:!0,get:function(){return mS}}),e.ObjectRelativeFromH=uh,e.ObjectRelativeFromV=dh,Object.defineProperty(e,"Optional",{enumerable:!0,get:function(){return i.Optional}}),e.PADDING_KEYS=Th,e.PAGE_SIZE=Ih,e.PAPER_TYPES=vh,e.PARAGRAPH_ID_PREFIX=zh,e.PRESERVE_INSERTED_PARAGRAPH_IDS=rg,e.PRESET_LIST_TYPE=h_,e.PageOrientType=gh,e.PaperType=_h,e.ParagraphElementType=qm,e.ParagraphStyleBuilder=gb,e.ParagraphStyleValue=hb,e.PermissionService=hS,e.PermissionStatus=dS,e.Plugin=vS,Object.defineProperty(e,"PluginService",{enumerable:!0,get:function(){return xS}}),e.PositionedObjectLayoutType=Ym,e.PresetListType=u_,e.ProtectionType=Ce,Object.defineProperty(e,"Quantity",{enumerable:!0,get:function(){return i.Quantity}}),e.QuickListType=l_,e.QuickListTypeMap=v_,e.RANGE_DIRECTION=fo,e.RANGE_TYPE=co,e.RBush=Ad,e.RCDisposable=j,e.RESTORE_INSERTED_PARAGRAPH_IDS=Sg,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=IS,e.Range=Nx,e.RecordValueType=oC,e.Rectangle=Gd,Object.defineProperty(e,"RediError",{enumerable:!0,get:function(){return i.RediError}}),e.RedoCommand=lS,e.RedoCommandId=oS,e.RefAlias=nf,Object.defineProperty(e,"RegionService",{enumerable:!0,get:function(){return SS}}),e.Registry=fm,e.RegistryAsMap=pm,e.RelativeDate=we,Object.defineProperty(e,"ResourceManagerService",{enumerable:!0,get:function(){return wS}}),e.RichTextBuilder=vb,e.RichTextParagraphBuilder=yb,e.RichTextRunBuilder=bb,e.RichTextValue=_b,e.RxDisposable=A,e.SECTION_ID_PREFIX=gm,e.SHEET_EDITOR_UNITS=jh,e.STYLE_KEYS=Eh,e.SectionType=Wm,Object.defineProperty(e,"Self",{enumerable:!0,get:function(){return i.Self}}),Object.defineProperty(e,"SheetSkeleton",{enumerable:!0,get:function(){return JS}}),e.SheetTypes=Te,e.SheetViewModel=Rx,Object.defineProperty(e,"Skeleton",{enumerable:!0,get:function(){return KS}}),Object.defineProperty(e,"SkipSelf",{enumerable:!0,get:function(){return i.SkipSelf}}),e.SliceBodyType=J_,e.SpacingRule=Zm,e.Styles=gx,e.TEXT_DECORATION_KEYS=bh,e.TEXT_ROTATION_KEYS=wh,e.THEME_COLORS=ho,e.TRADITIONAL_DOCUMENT_DEFAULT_MARGIN=72,e.TabStopAlignment=$m,e.TabStopLeader=eh,e.TableAlignmentType=nh,e.TableLayoutType=rh,e.TableRowHeightRule=sh,e.TableSizeType=th,e.TableTextWrapType=ih,e.TestConfirmService=nx,e.TextDecoration=De,e.TextDecorationBuilder=mb,e.TextDirection=Ee,e.TextDirectionType=Km,e.TextStyleBuilder=pb,e.TextStyleValue=fb,e.TextX=X,e.TextXActionType=ig,e.ThemeColorType=Ie,e.ThemeColors=Le,e.ThemeService=TS,e.Tools=z,e.UndoCommand=cS,e.UndoCommandId=sS,e.UnitModel=M,e.Univer=uC,Object.defineProperty(e,"UniverInstanceService",{enumerable:!0,get:function(){return qx}}),e.UniverInstanceType=n.UniverType,e.UpdateDocsAttributeType=to,e.UserManagerService=Qb,e.VerticalAlign=ke,e.VerticalAlignmentType=ch,Object.defineProperty(e,"WithNew",{enumerable:!0,get:function(){return i.WithNew}}),Object.defineProperty(e,"Workbook",{enumerable:!0,get:function(){return Gx}}),e.Worksheet=Bx,e.WorksheetHiddenState=no,e.WrapStrategy=Ae,e.WrapTextType=Jm,e.addLinkToDocumentModel=wx,e.afterInitApply=ka,e.afterTime=Da,e.allocateBaseFormulaTableName=ip,e.assertBaseTableRecordIdentity=Of,e.awaitTime=LS,e.binSearchFirstGreaterThanTarget=Ma,e.binarySearchArray=ja,e.bufferDebounceTime=Ea,e.cellToRange=wu,e.characterSpacingControlType=hh,e.checkForSubstrings=ku,e.checkIfMove=Fa,e.checkParagraphHasBullet=nd,e.checkParagraphHasIndent=rd,e.checkParagraphHasIndentByStyle=id,e.cloneBodyWithFreshParagraphIds=Vh,e.cloneCellData=BS,e.cloneCellDataMatrix=HS,e.cloneCellDataWithSpanAndDisplay=VS,e.cloneParagraphWithId=Hh,e.cloneSectionBreakWithId=vm,e.cloneValue=zS,e.cloneWorksheetData=GS,e.codeToBlob=Pa,e.columnLabelToNumber=Sd,e.composeBody=vv,e.composeInterceptors=Vp,e.composeStyles=ae,e.concatMatrixArray=ou,e.containsInteriorInsertionOffset=hg,e.containsStreamIndex=mg,e.convertCellToRange=fu,e.convertObservableToBehaviorSubject=Oa,e.covertCellValue=Tu,e.covertCellValues=Eu,e.createAsyncInterceptorKey=Up,e.createBaseFormulaTableNameMap=rp,e.createBaseFormulaTableReferenceNormalizer=cp,e.createBaseRecordIdField=Tf,e.createDefaultBaseTableSnapshot=kf,e.createDefaultUser=Xb,e.createDocumentModelWithStyle=xx,Object.defineProperty(e,"createIdentifier",{enumerable:!0,get:function(){return i.createIdentifier}}),e.createInterceptorKey=Bp,e.createInternalEditorID=kp,e.createParagraphId=Bh,e.createRandomId=Ed,e.createRowColIter=rf,e.createSectionId=_m,e.createSheetGapTestConfig=qS,e.currencySymbols=Ql,e.customNameCharacterCheck=OS,e.dateKit=ed,e.debounce=Ji,e.dedupe=Ve,e.dedupeBy=He,e.deepCompare=Du,e.delayAnimationFrame=RS,e.deleteContent=od,e.excelDateSerial=dc,e.excelDateTimePartsToSerial=lc,e.excelDateTimeSerial=fc,e.excelSerialToDate=sc,e.excelSerialToDateTime=cc,e.excelSerialToDateTimeParts=ac,e.extractPureTextFromCell=Vx,Object.defineProperty(e,"forwardRef",{enumerable:!0,get:function(){return i.forwardRef}}),e.fromCallback=wa,e.fromEventSubject=qb,e.generateIntervalsByPoints=ld,e.generateRandomId=J,e.get=_i,e.getArrayLength=nu,e.getBaseFormulaTableName=op,e.getBasesEmptySnapshot=Af,e.getBlockRangeInterval=cg,e.getBodySlice=cv,e.getBodySliceForSplitTextXAction=uv,e.getBodySliceForTextXAction=lv,e.getBorderStyleType=xu,e.getCellCoordByIndexSimple=YS,e.getCellValueType=ao,e.getCellWithCoordByIndexCore=XS,e.getColorStyle=gu,e.getColumnGroupRangeInterval=lg,e.getCustomBlockIdsInSelections=qy,e.getCustomBlockInterval=dg,e.getCustomBlockSlice=rv,e.getCustomDecorationSlice=mv,e.getCustomRangeInterval=ug,e.getCustomRangeSlice=pv,e.getDateSystemMaxSerial=ec,e.getDisplayValueFromCell=Hx,e.getDocsEmptySnapshot=Kh,e.getDocsUpdateBody=Su,e.getDrawingOrderIndex=Fp,e.getEmptyCell=Ex,e.getExclusiveRangeInterval=og,e.getInclusiveRangeInterval=ag,e.getIntersectRange=Qd,e.getNumfmtLocaleTag=Jl,e.getNumfmtParseValueFilter=eu,e.getOriginCellValue=Ux,e.getParagraphContentStartOffset=U_,e.getParagraphContentStartOffsets=W_,e.getParagraphFollowingBlockOffset=G_,e.getParagraphsSlice=tv,e.getPlainText=ry,e.getReverseDirection=ve,e.getRichTextEditPath=Sv,e.getSdtBindingKey=Ub,e.getSdtBindingValue=Wb,e.getSectionBreakSlice=nv,e.getSectionHeaderFooterReferenceKey=Bb,e.getSheetsEmptySnapshot=hx,e.getSingleDataStreamChange=$y,e.getTableCellTokenInterval=pg,e.getTableRangeInterval=sg,e.getTableRowTokenInterval=fg,e.getTableSlice=Q_,e.getTextRunSlice=Z_,e.getTransformOffsetX=ZS,e.getTransformOffsetY=QS,e.getWorksheetUID=Wx,e.groupBy=Ge,e.handleStyleToString=yu,e.hashAlgorithm=cd,e.horizontalLineSegmentsSubtraction=td,e.insertMatrixArray=iu,e.insertTextToContent=ad,e.intersectsOperationalIntervals=gg,e.invertColorByHSL=rm,e.invertColorByMatrix=om,Object.defineProperty(e,"isAsyncDependencyItem",{enumerable:!0,get:function(){return i.isAsyncDependencyItem}}),Object.defineProperty(e,"isAsyncHook",{enumerable:!0,get:function(){return i.isAsyncHook}}),e.isBaseRecordIdFieldName=Df,e.isBlackColor=$a,e.isBooleanString=Cp,e.isCellCoverable=hu,e.isCellV=so,Object.defineProperty(e,"isClassDependencyItem",{enumerable:!0,get:function(){return i.isClassDependencyItem}}),e.isCommentEditorID=jp,Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i.isCtor}}),e.isDefaultFormat=ql,Object.defineProperty(e,"isDisposable",{enumerable:!0,get:function(){return i.isDisposable}}),e.isEmptyCell=mu,Object.defineProperty(e,"isFactoryDependencyItem",{enumerable:!0,get:function(){return i.isFactoryDependencyItem}}),e.isFormulaId=vu,e.isFormulaString=_u,e.isICellData=io,e.isInternalEditorID=Ap,e.isNodeEnv=oe,e.isNotNullOrUndefined=Tx,e.isNullCell=oo,e.isNumeric=lm,e.isPatternEqualWithoutDecimal=Yl,e.isRangesEqual=_x,e.isRealNum=sd,e.isSafeNumeric=um,e.isSafeUrl=R,e.isSameStyleTextRun=Ou,e.isTextFormat=Kl,e.isUnitRangesEqual=vx,e.isValidBaseRecordId=Ef,e.isValidRange=Cu,Object.defineProperty(e,"isValueDependencyItem",{enumerable:!0,get:function(){return i.isValueDependencyItem}}),e.isWhiteColor=eo,e.makeArray=Ke,e.makeCellRangeToRangeData=pu,e.mapObjectMatrix=tu,e.merge=na,e.mergeIntervals=ud,e.mergeLocales=dd,e.mergeOverrideWithDependencies=gS,e.mergeSets=hm,e.mergeWith=ta,e.mergeWorksheetSnapshotWithDefault=Ix,e.migrateBaseFormulaTableNames=lp,e.mixinClass=cm,e.moveMatrixArray=cu,e.moveRangeByOffset=Kd,e.nameCharacterCheck=DS,e.noop=Lp,e.normalizeBaseFormulaTableName=np,e.normalizeBaseFormulaTableReferences=sp,e.normalizeBody=fv,e.normalizeDrawingOrderIndex=Pp,e.normalizeInsertedSectionIdsForDocument=Ng,e.normalizeTextRuns=Cg,e.normalizeUrl=L,e.numberToABC=of,e.numberToListABC=cf,Object.defineProperty(e,"numfmt",{enumerable:!0,get:function(){return vl}}),e.regexp=Gl,e.registerDependencies=qe,e.remove=Be,e.repeatStringNumTimes=sf,e.replaceInDocumentBody=my,e.requestImmediateMacroTask=mm,e.resolveDocumentParagraphStyle=py,e.resolveSectionHeaderFooterReference=Vb,e.resolveSectionHeaderFooterReferences=Hb,e.resolveWithBasePath=te,e.rotate=We,e.searchArray=Na,e.searchInOrderedArray=Aa,e.selectionToArray=uo,e.sequence=Qe,e.sequenceAsync=Ze,e.sequenceExecute=Sa,e.sequenceExecuteAsync=Ca,e.set=ia,Object.defineProperty(e,"setDependencies",{enumerable:!0,get:function(){return i.setDependencies}}),e.setWith=aa,e.shallowEqual=Ip,e.shiftExclusiveRangeOnDelete=bg,e.shiftExclusiveRangeOnInsert=vg,e.shiftInclusiveRangeOnDelete=yg,e.shiftInclusiveRangeOnInsert=_g,e.skipParseTagNames=$S,e.sliceMatrixArray=su,e.sortRules=lf,e.sortRulesByDesc=uf,e.sortRulesFactory=df,e.spliceArray=au,e.splitIntoGrid=Jd,e.takeAfter=Ta,e.throttle=Rp,e.toDisposable=D,e.touchDependencies=Je,e.updateAttributeByDelete=wv,e.updateAttributeByInsert=Tv,e.validateDocBodyStructure=Lb,e.validateDocumentStructure=zb,e.willLoseNumericPrecision=dm});