@univerjs/core 0.2.4 → 0.2.5

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/index.js +11 -9
  2. package/lib/es/index.js +5239 -3956
  3. package/lib/types/common/const.d.ts +1 -0
  4. package/lib/types/common/di.d.ts +17 -0
  5. package/lib/types/common/json.d.ts +18 -0
  6. package/lib/types/index.d.ts +4 -2
  7. package/lib/types/observer/observable.d.ts +2 -1
  8. package/lib/types/services/__tests__/index.d.ts +7 -7
  9. package/lib/types/services/authz-io/type.d.ts +1 -1
  10. package/lib/types/services/command/command.service.d.ts +2 -2
  11. package/lib/types/services/config/config.service.d.ts +1 -1
  12. package/lib/types/services/context/context.service.d.ts +1 -1
  13. package/lib/types/services/instance/instance.service.d.ts +2 -2
  14. package/lib/types/services/lifecycle/lifecycle.d.ts +1 -1
  15. package/lib/types/services/lifecycle/lifecycle.service.d.ts +1 -1
  16. package/lib/types/services/local-storage/local-storage.service.d.ts +1 -1
  17. package/lib/types/services/log/log.service.d.ts +1 -1
  18. package/lib/types/services/permission/type.d.ts +1 -1
  19. package/lib/types/services/plugin/plugin-override.d.ts +1 -1
  20. package/lib/types/services/plugin/plugin.d.ts +1 -1
  21. package/lib/types/services/plugin/plugin.service.d.ts +1 -1
  22. package/lib/types/services/resource-loader/type.d.ts +1 -1
  23. package/lib/types/services/resource-manager/type.d.ts +2 -2
  24. package/lib/types/services/snapshot/snapshot-server.service.d.ts +1 -1
  25. package/lib/types/services/undoredo/undoredo.service.d.ts +2 -2
  26. package/lib/types/shared/lifecycle.d.ts +1 -1
  27. package/lib/types/shared/lru/lru-map.d.ts +1 -1
  28. package/lib/types/shared/rxjs.d.ts +1 -1
  29. package/lib/types/sheets/view-model.d.ts +1 -1
  30. package/lib/types/univer.d.ts +1 -1
  31. package/lib/umd/index.js +11 -9
  32. package/package.json +4 -4
package/lib/umd/index.js CHANGED
@@ -1,9 +1,11 @@
1
- (function(u,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("rxjs"),require("rxjs/operators"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","@wendellhu/redi"],B):(u=typeof globalThis<"u"?globalThis:u||self,B(u.UniverCore={},u.rxjs,u.rxjs.operators,u["@wendellhu/redi"]))})(this,function(u,B,oe,ct){"use strict";var Rc=Object.defineProperty;var Cc=(u,B,oe)=>B in u?Rc(u,B,{enumerable:!0,configurable:!0,writable:!0,value:oe}):u[B]=oe;var g=(u,B,oe)=>Cc(u,typeof B!="symbol"?B+"":B,oe);var Ao,bo;function Mo(t,n){for(var e=0;e<n.length;e++){const s=n[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function Uo(){Lo()}const on=typeof global<"u"?global:typeof self<"u"?self:window;function Lo(){typeof on.requestIdleCallback!="function"&&(on.requestIdleCallback=function(e){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof on.cancelIdleCallback!="function"&&(on.cancelIdleCallback=function(e){clearTimeout(e)})}const Do="__default_document_sub_component_id20231101__",Ge=2,Ms=1;function yo(t,n){if(n==null||t==null)return!0;const{left:e=0,top:s=0,height:r=0,width:i=0,angle:o=0}=n,{left:a=0,top:l=0,height:d=0,width:h=0,angle:c=0}=t,f=h,_=d,E=i,R=r;return Math.abs(a-e)>Ge||Math.abs(l-s)>Ge||Math.abs(f-E)>Ge||Math.abs(_-R)>Ge||Math.abs(c-o)>Ms}function Us(t,n){let e=0,s=t.length-1;for(;e<=s;){const r=Math.floor((s+e)/2);if(n<t[r]&&(r===0||n>=t[r-1]))return r;if(n>=t[r])e=r+1;else if(n<t[r])s=r-1;else return-1}return-1}function Ls(t,n){let e=0,s=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(s=t[o],o===0?r=0:r=t[o-1],n>=r&&n<=s){i=o;break}if(s=t[e],e===0?r=0:r=t[e-1],n>=r&&n<s){i=e;break}e++,o--}return i}function Po(t,n){let e=t.length-1;return n<0?-1:n<t[0]?0:n>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||n<=t[20]||n>=t[e-20]?e=Ls(t,n):e=Us(t,n),e)}function ko(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Ds=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Ds||{}),dt=(t=>(t[t.NONE=0]="NONE",t[t.THIN=1]="THIN",t[t.HAIR=2]="HAIR",t[t.DOTTED=3]="DOTTED",t[t.DASHED=4]="DASHED",t[t.DASH_DOT=5]="DASH_DOT",t[t.DASH_DOT_DOT=6]="DASH_DOT_DOT",t[t.DOUBLE=7]="DOUBLE",t[t.MEDIUM=8]="MEDIUM",t[t.MEDIUM_DASHED=9]="MEDIUM_DASHED",t[t.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",t[t.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",t[t.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",t[t.THICK=13]="THICK",t))(dt||{}),ys=(t=>(t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.NONE="none",t.ALL="all",t.OUTSIDE="outside",t.INSIDE="inside",t.HORIZONTAL="horizontal",t.VERTICAL="vertical",t.TLBR="tlbr",t.TLBC_TLMR="tlbc_tlmr",t.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",t.BLTR="bl_tr",t.MLTR_BCTR="mltr_bctr",t))(ys||{}),xt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(xt||{}),Ps=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(Ps||{}),ks=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(ks||{}),Hs=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(Hs||{}),Fs=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Fs||{}),$s=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))($s||{});function Ho(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var Ws=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(Ws||{}),Bs=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))(Bs||{}),Ie=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t.ZH_TW="zhTW",t.VI_VN="viVN",t))(Ie||{}),Gs=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(Gs||{}),Vs=(t=>(t[t.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",t[t.PAST_YEAR=1]="PAST_YEAR",t[t.PAST_MONTH=2]="PAST_MONTH",t[t.PAST_WEEK=3]="PAST_WEEK",t[t.YESTERDAY=4]="YESTERDAY",t[t.TODAY=5]="TODAY",t[t.TOMORROW=6]="TOMORROW",t))(Vs||{}),an=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(an||{}),Ve=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t))(Ve||{}),xs=(t=>(t[t.DASH=0]="DASH",t[t.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",t[t.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",t[t.DASHED_HEAVY=3]="DASHED_HEAVY",t[t.DASH_LONG=4]="DASH_LONG",t[t.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",t[t.DOT_DASH=6]="DOT_DASH",t[t.DOT_DOT_DASH=7]="DOT_DOT_DASH",t[t.DOTTED=8]="DOTTED",t[t.DOTTED_HEAVY=9]="DOTTED_HEAVY",t[t.DOUBLE=10]="DOUBLE",t[t.NONE=11]="NONE",t[t.SINGLE=12]="SINGLE",t[t.THICK=13]="THICK",t[t.WAVE=14]="WAVE",t[t.WAVY_DOUBLE=15]="WAVY_DOUBLE",t[t.WAVY_HEAVY=16]="WAVY_HEAVY",t[t.WORDS=17]="WORDS",t))(xs||{}),Se=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(Se||{}),De=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(De||{}),ye=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ye||{}),ln=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(ln||{}),un=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(un||{}),Pe=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Pe||{}),Y=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(Y||{}),Oe=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Oe||{}),$t=(t=>(t[t.DARK1=0]="DARK1",t[t.LIGHT1=1]="LIGHT1",t[t.DARK2=2]="DARK2",t[t.LIGHT2=3]="LIGHT2",t[t.ACCENT1=4]="ACCENT1",t[t.ACCENT2=5]="ACCENT2",t[t.ACCENT3=6]="ACCENT3",t[t.ACCENT4=7]="ACCENT4",t[t.ACCENT5=8]="ACCENT5",t[t.ACCENT6=9]="ACCENT6",t[t.HYPERLINK=10]="HYPERLINK",t[t.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",t))($t||{}),cn=(t=>(t.OFFICE="Office",t.OFFICE_2007_2010="Office 2007-2010",t.GRAYSCALE="Grayscale",t.BLUE_WARM="Blue Warm",t.BLUE="Blue",t.BLUE_II="Blue II",t.BLUE_GREEN="Blue Green",t.GREEN="Green",t.GREEN_YELLOW="Green Yellow",t.YELLOW="Yellow",t.YELLOW_ORANGE="Yellow Orange",t.ORANGE="Orange",t.ORANGE_RED="Orange Red",t.RED_ORANGE="Red Orange",t.RED="Red",t.RED_VIOLET="Red Violet",t.VIOLET="Violet",t.VIOLET_II="Violet II",t.MEDIAN="Median",t.PAPER="Paper",t.MARQUEE="Marquee",t.SLIPSTREAM="Slipstream",t.Aspect="Aspect",t))(cn||{}),js=(t=>(t.Line="line",t.LineInv="lineInv",t.Triangle="triangle",t.RtTriangle="rtTriangle",t.Rect="rect",t.Diamond="diamond",t.Parallelogram="parallelogram",t.Trapezoid="trapezoid",t.NonIsocelesTrapezoid="nonIsocelesTrapezoid",t.Pentagon="pentagon",t.Hexagon="hexagon",t.Heptagon="heptagon",t.Octagon="octagon",t.Decagon="decagon",t.Dodecagon="dodecagon",t.Star4="star4",t.Star5="star5",t.Star6="star6",t.Star7="star7",t.Star8="star8",t.Star10="star10",t.Star12="star12",t.Star16="star16",t.Star24="star24",t.Star32="star32",t.RoundRect="roundRect",t.Round1Rect="round1Rect",t.Round2SameRect="round2SameRect",t.Round2DiagRect="round2DiagRect",t.Ellipse="ellipse",t))(js||{}),Ks=(t=>(t.RightArrow="rightArrow",t.LeftArrow="leftArrow",t.UpArrow="upArrow",t.DownArrow="downArrow",t.LeftRightArrow="leftRightArrow",t.UpDownArrow="upDownArrow",t.QuadArrow="quadArrow",t.LeftRightUpArrow="leftRightUpArrow",t.BentArrow="bentArrow",t.UturnArrow="uturnArrow",t.CircularArrow="circularArrow",t.NotchedRightArrow="notchedRightArrow",t.HomePlate="homePlate",t.Chevron="chevron",t.LeftCircularArrow="leftCircularArrow",t.LeftRightCircularArrow="leftRightCircularArrow",t))(Ks||{}),Ys=(t=>(t.Plaque="plaque",t.Can="can",t.Cube="cube",t.Bevel="bevel",t.Donut="donut",t.NoSmoking="noSmoking",t.BlockArc="blockArc",t.FoldedCorner="foldedCorner",t))(Ys||{}),zs=(t=>(t.SmileyFace="smileyFace",t.Heart="heart",t.LightningBolt="lightningBolt",t.Sun="sun",t.Moon="moon",t.Cloud="cloud",t.Arc="arc",t.Backpack="backpack",t.Frame="frame",t.HalfFrame="halfFrame",t.Corner="corner",t.Chord="chord",t.Pie="pie",t.Teardrop="teardrop",t.WedgeRectCallout="wedgeRectCallout",t.WedgeRRectCallout="wedgeRRectCallout",t.WedgeEllipseCallout="wedgeEllipseCallout",t.CloudCallout="cloudCallout",t.BorderCallout1="borderCallout1",t.BorderCallout2="borderCallout2",t.BorderCallout3="borderCallout3",t.AccentCallout1="accentCallout1",t.AccentCallout2="accentCallout2",t.AccentCallout3="accentCallout3",t.Callout1="callout1",t.Callout2="callout2",t.Callout3="callout3",t.ActionButtonBackPrevious="actionButtonBackPrevious",t.ActionButtonEnd="actionButtonEnd",t.ActionButtonForwardNext="actionButtonForwardNext",t.ActionButtonHelp="actionButtonHelp",t.ActionButtonHome="actionButtonHome",t.ActionButtonInformation="actionButtonInformation",t.ActionButtonMovie="actionButtonMovie",t.ActionButtonReturn="actionButtonReturn",t.ActionButtonSound="actionButtonSound",t))(zs||{});const Xs={[cn.OFFICE]:{[$t.ACCENT1]:"#4472C4",[$t.ACCENT2]:"#ED7D31",[$t.ACCENT3]:"#A5A5A5",[$t.ACCENT4]:"#70AD47",[$t.ACCENT5]:"#5B9BD5",[$t.ACCENT6]:"#70AD47",[$t.DARK1]:"#000000",[$t.DARK2]:"#44546A",[$t.LIGHT1]:"#FFFFFF",[$t.LIGHT2]:"#E7E6E6",[$t.HYPERLINK]:"#0563C1",[$t.FOLLOWED_HYPERLINK]:"#954F72"}};class hn{constructor(){g(this,"_themeValue",$t.LIGHT1);g(this,"_themeColors");g(this,"_themeTint");g(this,"_rgbValue","");g(this,"_colorType");this._colorType=xt.UNSUPPORTED,this._themeColors=cn.OFFICE,this._themeTint=0}asRgbColor(){return new dn(this._rgbValue,this)}asThemeColor(){return new fn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case xt.THEME:return this.asThemeColor();case xt.RGB:return this.asRgbColor();case xt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=xt.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=xt.THEME,this._themeColors=n}setThemeTint(n){this._colorType=xt.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=xt.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class Ne{constructor(n){g(this,"_builder");this._builder=n}static rgbColorToHexValue(n){return`#${((1<<24)+(n.getRed()<<16)+(n.getGreen()<<8)+n.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(n){n?n.indexOf("#")>-1&&(n=n.substring(1)):n="#000000";const e=+`0x${n[0]}${n[1]}`,s=+`0x${n[2]}${n[3]}`,r=+`0x${n[4]}${n[5]}`;return new hn().setRgbColor(`rgb(${e},${s},${r})`).asRgbColor()}static hexToRgbString(n){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,(i,o,a,l)=>o+o+a+a+l+l);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),a=Number.parseInt(s[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Ne(this._builder)}equals(n){return!1}}class qs{constructor(n){g(this,"_saturation",0);g(this,"_hue",0);g(this,"_lightness",0);g(this,"_alpha",0);const e=n.getRed()/255,s=n.getGreen()/255,r=n.getBlue()/255,i=n.getAlpha()/255,o=Math.min(e,Math.min(s,r)),a=Math.max(e,Math.max(s,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),e===a&&(this._hue=(s-r)/l),s===a&&(this._hue=2+(r-e)/l),r===a&&(this._hue=4+(e-s)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const n=new hn;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,s,i),a=this.setColor(e,s,r),l=r-1/3,d=this.setColor(e,s,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(d*255)},${this._alpha*255})`),n.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(n,e,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=e+(n-e)*6*s:2*s<1?r=n:3*s<2?r=e+(n-e)*(2/3-s)*6:r=e,r}setLightness(n){this._lightness=n}}const Kt=class Kt extends Ne{constructor(e,s){super(s);g(this,"_cssString");g(this,"_red");g(this,"_green");g(this,"_blue");g(this,"_alpha");let r=e.match(Kt.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=e.match(Kt.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Ne.rgbColorToHexValue(this)}getRed(){let e=this._red+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+Kt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return xt.RGB}clone(){return new Kt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof Kt?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};g(Kt,"RGB_COLOR_AMT",0),g(Kt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),g(Kt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let dn=Kt;const Ce=class Ce extends Ne{constructor(e,s,r,i){super(i);g(this,"_themeColorType");g(this,"_themeTint");g(this,"_themeColors");this._themeColorType=e,this._themeTint=s,this._themeColors=r}lumValue(e,s){if(e==null)return s;let r;return e<0?r=s*(1+e):r=s*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=Xs[this._themeColors];if(e==null)throw new Error("not find themeColors type");const s=e[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(Ce._cacheThemeColor.has(this._themeColors)){if(r=Ce._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,Ce._cacheThemeColor.set(this._themeColors,r);const i=new qs(Ne.hexValueToRgbColor(s));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new Ce(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof Ce?e._themeColorType===this._themeColorType:!1}getColorType(){return xt.THEME}getThemeColorType(){return this._themeColorType}};g(Ce,"_cacheThemeColor",new Map);let fn=Ce;const Fo="rgb(",$o="rgba(",Hn={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class Zt{constructor(n){g(this,"_color");g(this,"_rgbColor");g(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof Zt){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=Zs(n);if(e==null){this._setNullColor();return}this._color=e;const s=xo(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var d,h;s=Math.min(1,Math.max(0,s));const r=new Zt(n).toRgb(),i=new Zt(e).toRgb(),o=(d=r.a)!=null?d:1,a=(h=i.a)!=null?h:1,l={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(a-o)*s+o};return new Zt(l)}static getContrastRatio(n,e){const s=new Zt(n).getLuminance(),r=new Zt(e).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:e,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${n},${e},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:e,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,a=[_n(Math.round(e).toString(16)),_n(Math.round(s).toString(16)),_n(Math.round(r).toString(16)),_n(Math.round(i*255).toString(16))];return n&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return zo(this.toRgb())}toHsl(){return Yo(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new Zt(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new Zt(e)}setAlpha(n){return new Zt({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:e,b:s}=this.toRgb();return n=Fn(n),e=Fn(e),s=Fn(s),Number((.2126*n+.7152*e+.0722*s).toFixed(3))}getBrightness(){const{r:n,g:e,b:s}=this.toRgb();return(n*299+e*587+s*114)/1e3}getAlpha(){var n;return(n=this._color.a)!=null?n:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const _n=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),Zs=t=>{if(qo(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const n=t.trim();if(Hn[n]){const e=Hn[n],s={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return s.a=e[3]||1,s}if(n.startsWith("#"))return Wo(n);if(n.startsWith("rgb"))return Bo(n);if(n.startsWith("hsl"))return Go(n);if(n.startsWith("hsv"))return Vo(n)},Wo=t=>{const n=t.substring(1),e=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let s=n.match(e);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},Bo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Go=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Vo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},xo=t=>{const n=Zs(t);if(n!=null)return"r"in n?n:"l"in n?jo(n):Ko(n)},$n=(t,n,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t),jo=t=>{let{h:n,s:e,l:s}=t;n/=360,e/=100,s/=100;let r=0,i=0,o=0;if(e===0)r=i=o=s;else{const l=s<.5?s*(1+e):s+e-s*e,d=2*s-l;r=$n(d,l,n+1/3),i=$n(d,l,n),o=$n(d,l,n-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},Ko=t=>{let{h:n,s:e,v:s}=t;n=n/360*6,e/=100,s/=100;const r=Math.floor(n),i=n-r,o=s*(1-e),a=s*(1-i*e),l=s*(1-(1-i)*e),d=r%6,h=[s,a,o,o,l,s][d],c=[l,s,s,a,o,o][d],f=[o,o,l,s,s,a][d],_={r:h*255,g:c*255,b:f*255};return t.a!==void 0&&(_.a=t.a),_},Yo=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const h=r-i;switch(l=o>.5?h/(2-r-i):h/(r+i),r){case n:a=(e-s)/h+(e<s?6:0);break;case e:a=(s-n)/h+2;break;default:a=(n-e)/h+4;break}a/=6}const d={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(d.a=t.a),d},zo=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s);let o;const a=r,l=r-i,d=r===0?0:l/r;if(r===i)o=0;else{switch(r){case n:o=(e-s)/l+(e<s?6:0);break;case e:o=(s-n)/l+2;break;default:o=(n-e)/l+4;break}o/=6}const h={h:Math.round(o*360),s:Math.round(d*100),v:Math.round(a*100)};return t.a!==void 0&&(h.a=t.a),h},Xo=t=>t==null,qo=t=>!Xo(t)&&typeof t=="object";function Zo(t){const n=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}function Jo(t){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}var kt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(kt||{});function Qo(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function ta(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Oe.STRING;if(typeof t.v=="number")return Oe.NUMBER;if(typeof t.v=="boolean")return Oe.BOOLEAN}function ea(t){if(t==null)return!0;const{v:n,f:e,si:s,p:r,s:i,custom:o}=t;return!(!(n==null||typeof n=="string"&&n.length===0)||e!=null&&e.length>0||s!=null&&s.length>0||r!=null||o!=null)}function na(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Js=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Js||{}),Qs=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Qs||{}),xe=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(xe||{}),fe=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(fe||{}),tr=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t[t.MENTION=6]="MENTION",t[t.UNI_FORMULA=7]="UNI_FORMULA",t))(tr||{}),er=(t=>(t[t.COMMENT=0]="COMMENT",t))(er||{}),nr=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(nr||{}),sr=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(sr||{}),rr=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))(rr||{}),ir=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(ir||{}),or=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(or||{}),ar=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(ar||{}),lr=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(lr||{}),ur=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(ur||{}),cr=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(cr||{}),hr=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(hr||{}),dr=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(dr||{}),fr=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(fr||{}),_r=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(_r||{}),gr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(gr||{}),mr=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(mr||{}),Er=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Er||{}),Rr=(t=>(t[t.PAGE=0]="PAGE",t[t.COLUMN=1]="COLUMN",t[t.CHARACTER=2]="CHARACTER",t[t.MARGIN=3]="MARGIN",t[t.INSIDE_MARGIN=4]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.LEFT_MARGIN=6]="LEFT_MARGIN",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(Rr||{}),Cr=(t=>(t[t.PAGE=0]="PAGE",t[t.PARAGRAPH=1]="PARAGRAPH",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.TOP_MARGIN=4]="TOP_MARGIN",t[t.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=6]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",t))(Cr||{}),pr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t[t.PIXEL=3]="PIXEL",t))(pr||{}),Ir=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t[t.BOTH=5]="BOTH",t[t.DISTRIBUTE=6]="DISTRIBUTE",t))(Ir||{}),Sr=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(Sr||{}),Or=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Or||{}),Nr=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Nr||{}),Ar=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(Ar||{}),br=(t=>(t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t[t.DRAWING_IMAGE=0]="DRAWING_IMAGE",t[t.DRAWING_SHAPE=1]="DRAWING_SHAPE",t[t.DRAWING_CHART=2]="DRAWING_CHART",t[t.DRAWING_TABLE=3]="DRAWING_TABLE",t[t.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",t[t.DRAWING_VIDEO=5]="DRAWING_VIDEO",t[t.DRAWING_GROUP=6]="DRAWING_GROUP",t[t.DRAWING_UNIT=7]="DRAWING_UNIT",t[t.DRAWING_DOM=8]="DRAWING_DOM",t))(br||{}),ot=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(ot||{}),Nt=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(Nt||{});function sa(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function ra(t,n,e){let s=!1,r=!1,i=t,o=n,a=t,l=n;if(e==null)return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l};for(let d=0;d<e.length;d++){const{startRow:h,endRow:c,startColumn:f,endColumn:_}=e[d];if(t===h&&n===f){i=c,o=_,a=h,l=f,r=!0;break}if(t>=h&&t<=c&&n>=f&&n<=_){i=c,o=_,a=h,l=f,s=!0;break}}return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l}}var Wn=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(Wn||{}),vr=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(vr||{}),wr=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(wr||{});const ia="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let oa=t=>crypto.getRandomValues(new Uint8Array(t)),aa=(t,n,e)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*n/t.length);return(i=n)=>{let o="";for(;;){let a=e(r),l=r;for(;l--;)if(o+=t[a[l]&s]||"",o.length===i)return o}}},la=(t,n=21)=>aa(t,n,oa),ua=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=ia[e[t]&63];return n};const ca=new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[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 ha(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:ca.test(t):!1}function da(t){return/^[a-zA-Z]+:\/\//.test(t)}function fa(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function _a(t){return da(t)?t:fa(t)?`mailto://${t}`:`https://${t}`}const ga=/^-ms-/,ma=/-([a-z])/g,_e=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class k{static stringAt(n){let e="",s=n;for(;s>=_e.length;)s/=_e.length,s-=1,e+=_e[s%_e.length];const r=n%_e.length;return e+=_e[r],e}static indexAt(n){let e=0;for(let s=0;s<n.length-1;s+=1){const r=n.charCodeAt(s)-65,i=n.length-1-s;e+=_e.length**i+_e.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return k.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!e&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(n.indexOf("Windows NT 5.0")>-1||n.indexOf("Windows 2000")>-1)return"Windows 2000";if(n.indexOf("Windows NT 5.1")>-1||n.indexOf("Windows XP")>-1)return"Windows XP";if(n.indexOf("Windows NT 5.2")>-1||n.indexOf("Windows 2003")>-1)return"Windows 2003";if(n.indexOf("Windows NT 6.0")>-1||n.indexOf("Windows Vista")>-1)return"Windows Vista";if(n.indexOf("Windows NT 6.1")>-1||n.indexOf("Windows 7")>-1)return"Windows 7";if(n.indexOf("Windows NT 10")>-1||n.indexOf("Windows 10")>-1)return"Windows 10";if(n.indexOf("Windows NT 11")>-1||n.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const n=navigator.userAgent,e=n.indexOf("Opera")>-1,s=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!e,r=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,i=n.indexOf("Edge")>-1,o=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(n);const h=Number.parseFloat(RegExp.$1);return h===7?"IE7":h===8?"IE8":h===9?"IE9":h===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(n=21,e){return Tr(n,e)}static getClassName(n){return n.constructor.name}static deepMerge(n,...e){e.forEach(o=>o&&i(o));function s(o,a){o.forEach((l,d)=>{var h,c;if(k.isArray(l)){const f=(h=a[d])!=null?h:[];a[d]=f,s(l,f);return}if(k.isObject(l)){const f=(c=a[d])!=null?c:{};a[d]=f,r(l,f);return}a[d]=l})}function r(o,a){Object.keys(o).forEach(l=>{var h,c;const d=o[l];if(k.isObject(d)){const f=(h=a[l])!=null?h:{};a[l]=f,r(d,f);return}if(k.isArray(d)){const f=(c=a[l])!=null?c:[];a[l]=f,s(d,f);return}a[l]=d})}function i(o){Object.keys(o).forEach(a=>{var d,h;const l=o[a];if(k.isArray(l)){const c=(d=n[a])!=null?d:[];n[a]=c,s(l,c);return}if(k.isObject(l)){const c=(h=n[a])!=null?h:{};n[a]=c,r(l,c);return}n[a]=l})}return n}static numberFixed(n,e){return Number(Number(n).toFixed(e))}static diffValue(n,e){function s(o,a){const l=k.getValueType(o),d=k.getValueType(a);return l!==d?!1:k.isArray(o)?r(o,a):k.isObject(o)?i(o,a):k.isDate(o)?o.getTime()===a.getTime():k.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(n.length!==e.length)return!1;for(let l=0,d=o.length;l<d;l++){const h=o[l],c=a[l];if(!s(h,c))return!1}return!0}function i(o,a){const l=Object.keys(o),d=Object.keys(a);if(l.length!==d.length)return!1;for(const h of l){if(!d.includes(h))return!1;const c=o[h],f=a[h];if(!s(c,f))return!1}return!0}return s(n,e)}static deepClone(n){if(!this.isDefine(n))return n;if(this.isRegExp(n))return new RegExp(n);if(this.isDate(n))return new Date(n);if(this.isArray(n)){const e=[];return n.forEach((s,r)=>{e[r]=k.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=k.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}return n}static getLanguage(){const n="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||n}static getValueType(n){return Object.prototype.toString.apply(n)}static isDefine(n){return n!=null}static isBlank(n){return this.isDefine(n)?this.isString(n)?n.trim()==="":!1:!0}static isAssignableFrom(n,e){return n instanceof e}static isBoolean(n){return this.getValueType(n)==="[object Boolean]"}static isPlainObject(n){return this.isDefine(n)?Object.getPrototypeOf(n)===Object.getPrototypeOf({}):!1}static isFunction(n){return this.getValueType(n)==="[object Function]"}static isDate(n){return this.getValueType(n)==="[object Date]"}static isRegExp(n){return this.getValueType(n)==="[object RegExp]"}static isArray(n){return this.getValueType(n)==="[object Array]"}static isString(n){return this.getValueType(n)==="[object String]"}static isNumber(n){return this.getValueType(n)==="[object Number]"}static isStringNumber(n){return!isNaN(Number.parseFloat(n))&&isFinite(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isEmptyObject(n){for(const e in n)return!1;return!0}static isMobile(){let n=0,e=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&e<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const n=navigator.userAgent.toLowerCase();return String(n.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const n=navigator.userAgent;return n.indexOf("Android")>-1||n.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(n){return ha(n)}static normalizeUrl(n){return _a(n)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return k.isDefine(n)?k.isDefine(e)?n.length===e:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,e){return e.toUpperCase()}static camelCase(n){return n.replace(ga,"ms-").replace(ma,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:k.removeNull(s)}),n}static fillTwoDimensionalArray(n,e,s){return new Array(n).fill(s).map(r=>new Array(e).fill(s))}static numToWord(n){let e="";for(;n>0;){let s=n%26;s=s===0?s=26:s,e=String.fromCharCode(96+s)+e,n=(n-s)/26}return e.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const e=n.toLowerCase().split(""),s=e.length;let r=0,i=0;for(let o=0;o<s;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(n){let i="";for(;n>=0;)i=String.fromCharCode(n%26+97)+i,n=Math.floor(n/26)-1;return i.toUpperCase()}static randSort(n){for(let e=0,s=n.length;e<s;e++){const r=Number.parseInt((Math.random()*s).toString()),i=n[r];n[r]=n[e],n[e]=i}return n}static commonExtend(n,e){const s={};for(const r in n)s[r]=n[r];for(const r in e)e[r]!=null&&(s[r]=e[r]);return s}static commonExtend1(n,e){for(const s in n)e[s]==null&&(e[s]=n[s]);return e}static arrayToObject(n){const e={};return n.forEach((s,r)=>{e[r]={},s.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(n,e,s,r){return e>=s&&r>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const e=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),s=n.length<=255;return!e&&s}static set(n,e,s){const r=e.split("."),i=r.pop();r.forEach(o=>{n[o]||(n[o]={}),n=n[o]}),i&&(n[i]=s)}static clamp(n,e,s){return Math.max(e,Math.min(s,n))}}function Tr(t=21,n){return n?la(n,t)():ua(t)}function Ea(t){const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:d}=t,h=n,c=e,f=n,_=e;if(s&&i){const{startRow:E,startColumn:R,endRow:U,endColumn:D,startY:et,endY:Et,startX:_t,endX:C}=i;h=E,c=R,f=U,_=D,o=et,a=Et,l=_t,d=C}return r&&(o=i.startY,a=i.endY,l=i.startX,d=i.endX,f=i.endRow,_=i.endColumn),{startRow:h,startColumn:c,endRow:f,endColumn:_,startY:o,endY:a,startX:l,endX:d}}function Ra(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let d=n,h=e,c=n,f=e;return(s||r)&&(d=i,h=o,c=a,f=l),{startRow:d,startColumn:h,endRow:c,endColumn:f}}function Mr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function Ca(t){return Mr(t)&&(t==null?void 0:t.coverable)!==!1}function se(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new hn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function pa(t){return k.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Ia(t){return k.isString(t)&&t.length>0}function Sa(t,n=!1){var i;let e="";const s=new Map([["ff",()=>{t.ff&&(e+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),e+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(e+="font-style: italic; ")}],["bl",()=>{t.bl&&(e+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):e+="text-decoration: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.ul.cl)}; `),t.ul.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):e+="text-decoration-line: line-through; ",t.st.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.st.cl)}; `),t.st.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):e+="text-decoration-line: overline; ",t.ol.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${se(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${se(t.bg)}; `)}],["bd",()=>{var o,a,l,d,h,c,f,_,E,R,U,D;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${gn((a=t.bd)==null?void 0:a.b.s)} ${(l=se(t.bd.b.cl))!=null?l:""}; `),(d=t.bd)!=null&&d.t&&(e+=`border-top: ${gn((h=t.bd)==null?void 0:h.t.s)} ${(c=se(t.bd.t.cl))!=null?c:""}; `),(f=t.bd)!=null&&f.r&&(e+=`border-right: ${gn((_=t.bd)==null?void 0:_.r.s)} ${(E=se(t.bd.r.cl))!=null?E:""}; `),(R=t.bd)!=null&&R.l&&(e+=`border-left: ${gn((U=t.bd)==null?void 0:U.l.s)} ${(D=se(t.bd.l.cl))!=null?D:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${se(t.cl)}; `)}],["va",()=>{t.va===Pe.SUBSCRIPT?e+="vertical-align: sub; ":t.va===Pe.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===Ve.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===Ve.RIGHT_TO_LEFT&&(e+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(e+=`--data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(a=t.tr)!=null&&a.v?` ,${(l=t.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{t.ht===Se.LEFT?e+="text-align: left; ":t.ht===Se.RIGHT?e+="text-align: right; ":t.ht===Se.CENTER?e+="text-align: center; ":t.ht===Se.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===De.BOTTOM?e+="vertical-align: bottom; ":t.vt===De.TOP?e+="vertical-align: top; ":t.vt===De.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===ye.CLIP?e+="white-space: nowrap; overflow-x: hidden; ":t.tb===ye.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var h,c,f,_,E,R,U,D;const o=`${(h=t.pd)==null?void 0:h.b}pt`,a=`${(c=t.pd)==null?void 0:c.t}pt`,l=`${(f=t.pd)==null?void 0:f.l}pt`,d=`${(_=t.pd)==null?void 0:_.r}pt`;(E=t.pd)!=null&&E.b&&(e+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(e+=`padding-top: ${a}; `),(U=t.pd)!=null&&U.l&&(e+=`padding-left: ${l}; `),(D=t.pd)!=null&&D.r&&(e+=`padding-right: ${d}; `)}]]),r=["bd","tr","tb"];for(const o in t)n&&r.includes(o)||(i=s.get(o))==null||i();return e}function gn(t){let n="";return t===dt.NONE?n="none":t===dt.THIN?n="0.5pt solid":t===dt.HAIR?n="0.5pt double":t===dt.DOTTED?n="0.5pt dotted":t===dt.DASHED||t===dt.DASH_DOT?n="0.5pt dashed":t===dt.DASH_DOT_DOT?n="0.5pt dotted":t===dt.DOUBLE?n="0.5pt double":t===dt.MEDIUM?n="1pt solid":t===dt.MEDIUM_DASHED||t===dt.MEDIUM_DASH_DOT?n="1pt dashed":t===dt.MEDIUM_DASH_DOT_DOT?n="1pt dotted":t===dt.SLANT_DASH_DOT?n="0.5pt dashed":t===dt.THICK&&(n="1.5pt solid"),n}function Oa(t){let n=0;if(t=t.trim(),t==="none")n=dt.NONE;else if(t==="0.5pt solid")n=dt.THIN;else if(t==="0.5pt double")n=dt.HAIR;else if(t==="0.5pt dotted")n=dt.DOTTED;else if(t==="0.5pt dashed")n=dt.DASHED;else if(t==="1pt solid")n=dt.MEDIUM;else if(t==="1pt dashed")n=dt.MEDIUM_DASHED;else if(t==="1pt dotted")n=dt.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")n=dt.THICK;else if(!t.includes("none"))n=dt.THIN;else return dt.NONE;return n}function Na(t,n){let e=t.body;if(n){const{headers:s,footers:r}=t;s!=null&&s[n]?e=s[n].body:r!=null&&r[n]&&(e=r[n].body)}return e}function Aa(t){const{startRow:n,endRow:e,startColumn:s,endColumn:r,rangeType:i}=t;return!(n<0||s<0||e<0||r<0||!(Number.isNaN(n)&&Number.isNaN(e))&&i===ot.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===ot.ROW||i!==ot.ROW&&i!==ot.COLUMN&&(Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(e)))}function ba(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function Bn(t,n){return Object.prototype.toString.call(t)===Object.prototype.toString.call(n)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(n).length?!1:Object.keys(t).every(e=>Bn(t[e],n[e])):t===n:!1}function Ur(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:Bn(e,s)}function va(t,n){return n.some(e=>t.indexOf(e)>-1)}function mn(t,n,e,s){if(t>n&&([t,n]=[n,t]),e>s&&([e,s]=[s,e]),n<e||s<t)return[t,n];e<t&&(e=t),s>n&&(s=n);const r=s-e+1;let i=[];return t===e?i=[s+1-r,n-r]:n===s?i=[t,e-1]:i=[t,n-r],i}function wa(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Ta(t){if(t==null)return!1;const n=t.paragraphStyle;return Lr(n)}function Lr(t){var n;return!(t==null||(t.indentStart==null||t.indentStart.v===0)&&t.hanging==null||((n=t.hanging)==null?void 0:n.v)===0)}function Dr(t,n,e){return t.slice(0,n)+e+t.slice(n)}function yr(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function Ma(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Ua(t){let n=0;for(let e=0;e<t.length;e++)n=t.charCodeAt(e)+(n<<6)+(n<<16)-n;return n>>>0}function Pr(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],s=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function kr(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var s=e.call(t),r,i=[],o;try{for(;(n===void 0||n-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return i}function Hr(t,n,e){if(e||arguments.length===2)for(var s=0,r=n.length,i;s<r;s++)(i||!(s in n))&&(i||(i=Array.prototype.slice.call(n,0,s)),i[s]=n[s]);return t.concat(i||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;function je(t){return typeof t=="function"}function La(t){var n=function(s){Error.call(s),s.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Gn=La(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
- `+e.map(function(s,r){return r+1+") "+s.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function Fr(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var $r=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Pr(o),l=a.next();!l.done;l=a.next()){var d=l.value;d.remove(this)}}catch(R){n={error:R}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var h=this.initialTeardown;if(je(h))try{h()}catch(R){i=R instanceof Gn?R.errors:[R]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var f=Pr(c),_=f.next();!_.done;_=f.next()){var E=_.value;try{Wr(E)}catch(R){i=i!=null?i:[],R instanceof Gn?i=Hr(Hr([],kr(i)),kr(R.errors)):i.push(R)}}}catch(R){s={error:R}}finally{try{_&&!_.done&&(r=f.return)&&r.call(f)}finally{if(s)throw s.error}}}if(i)throw new Gn(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)Wr(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&Fr(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&Fr(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();$r.EMPTY;function Da(t){return t instanceof $r||t&&"closed"in t&&je(t.remove)&&je(t.add)&&je(t.unsubscribe)}function Wr(t){je(t)?t():t.unsubscribe()}function At(t){let n=!1;return t?Da(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:At(()=>{})}function ya(t){return At(()=>{t.unsubscribe()})}class Vn{constructor(){g(this,"_disposables",new Set)}add(n){const e=At(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Mt{constructor(){g(this,"_disposed",!1);g(this,"_collection",new Vn)}disposeWithMe(n){return this._collection.add(n)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class Pa extends Mt{constructor(){super(...arguments);g(this,"dispose$",new B.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class ka extends Mt{constructor(e){super();g(this,"_ref",0);this._rootDisposable=e}inc(){if(this._disposed)throw new Error("[RCDisposable]: should not ref to a disposed.");this._ref+=1}dec(){this._ref-=1,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}}class Ke{static hasLength(n,e){return n.length===e}static getValueType(n){return Object.prototype.toString.apply(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isIterable(n){return n[Symbol.iterator]!=null}static isNumber(n){return this.getValueType(n)==="[object Number]"}}function En(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function Ha(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function Fa(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function $a(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function Wa(t,n){const e=new Map;return t.forEach(s=>{const r=n(s);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(s)}),e}function Ba(t){return Array.isArray(t)?t:[t]}const ht=Symbol("newer"),Ut=Symbol("older");class Br{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:n.key}):{done:!0,value:void 0}}}class Gr{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:n.value}):{done:!0,value:void 0}}}class Vr{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ht],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}bo=ht,Ao=Ut;class xn{constructor(n,e){g(this,"key");g(this,"value");g(this,bo);g(this,Ao);this.key=n,this.value=e,this[ht]=void 0,this[Ut]=void 0}toJSON(){return{key:this.key,value:this.value}}}class xr{constructor(...n){g(this,"_keymap");g(this,"size",0);g(this,"limit");g(this,"oldest");g(this,"newest");g(this,"_onShiftListeners",[]);if(Ke.hasLength(n,1)){if(Ke.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(Ke.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(Ke.hasLength(n,2)){const e=n[0],s=n[1];this._initialize(e,s)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),At(()=>En(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,e&&(this.assign(e),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ht]&&(n===this.oldest&&(this.oldest=n[ht]),n[ht][Ut]=n[Ut]),n[Ut]&&(n[Ut][ht]=n[ht]),n[ht]=void 0,n[Ut]=this.newest,this.newest&&(this.newest[ht]=n),this.newest=n)}assign(n){let e,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=n[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new xn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[ht]=o,o[Ut]=e):this.oldest=o,e=o,s--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(n,e){let s=this._keymap.get(n);return s?(s.value=e,this._markEntryAsUsed(s),this):(this._keymap.set(n,s=new xn(n,e)),this.newest?(this.newest[ht]=s,s[Ut]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ht]?(this.oldest=this.oldest[ht],this.oldest[Ut]=void 0):(this.oldest=void 0,this.newest=void 0),n[ht]=n[Ut]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(e=>e(n)),[n.key,n.value]}get(n){const e=this._keymap.get(n);if(e)return this._markEntryAsUsed(e),e.value}has(n){return this._keymap.has(n)}find(n){const e=this._keymap.get(n);return e?e.value:void 0}delete(n){const e=this._keymap.get(n);if(e)return this._keymap.delete(e.key),e[ht]&&e[Ut]?(e[Ut][ht]=e[ht],e[ht][Ut]=e[Ut]):e[ht]?(e[ht][Ut]=void 0,this.oldest=e[ht]):e[Ut]?(e[Ut][ht]=void 0,this.newest=e[Ut]):this.oldest=this.newest=void 0,this.size--,e.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Br(this.oldest)}values(){return new Gr(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Vr(this.oldest)}forEach(n,e){typeof e!="object"&&(e=this);let s=this.oldest;for(;s;)n.call(e,s.value,s.key,this),s=s[ht]}toJSON(){const n=new Array(this.size);let e=0,s=this.oldest;for(;s;)n[e++]={key:s.key,value:s.value},s=s[ht];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[ht],e&&(n+=" < ");return n}}function ge(t){let n=0;const e=Object.keys(t);for(const s of e){const r=Number(s);n=Math.max(n,r)}return n+1}function jn(t,n,e){const s=ge(e),r=e;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=n}function Kn(t,n,e){const s=Object.keys(e).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+n?delete e[r]:e[r]!==void 0&&(e[r-n]=e[r],delete e[r])}function Ga(t,n){const e=t,s=Object.keys(e),r=s.length,i=n,o=Object.keys(i),a=o.length,l={};let d=0;for(let h=0;h<r;h++,d++){const c=s[h];l[d]=e[c]}for(let h=0;h<a;h++,d++){const c=o[h];l[d]=i[c]}return l}function Va(t,n,e){const s=e;if(ge(e)>0){const i={};let o=0;for(let a=t;a<=n;a++)s[a]&&(i[o]=s[a],o++);return i}return{}}function Yn(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?xa(t,n,e,s):ja(t,n,e,s)}function xa(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+n]=a,a===void 0&&delete r[o+n]}i.forEach((o,a)=>{r[e+a]=o,o===void 0&&delete r[e+a]})}function ja(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t+n;o<e;o++){const a=r[o];r[o-n]=a,a===void 0&&delete r[o-n]}i.forEach((o,a)=>{r[e+a-n]=o,o===void 0&&delete r[e+a-n]})}class Jt{constructor(n={}){g(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new Jt({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,o)===!1)return this}return this}forRow(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const d=Number(l),h=o[Number(l)];if(n(i,d,h)===!1)return this}}return this}swapRow(n,e){const s=this._matrix[n],r=this._matrix[e];this._matrix[n]=r,this._matrix[e]=s}getRow(n){return this._matrix[n]}getRowOrCreate(n){let e=this.getRow(n);return e==null&&(e={},this._matrix[n]=e),e}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,e=Object.keys(n);if(e.length===0)return!1;for(const s of e){const r=Number(s),i=n[r];if(Object.keys(i).length>0)return!0}return!1}getValue(n,e){var s,r;return(r=(s=this._matrix)==null?void 0:s[n])==null?void 0:r[e]}setValue(n,e,s){const r=this.getRowOrCreate(n);r[e]=s}deleteValue(n,e){var s,r;(r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e]}realDeleteValue(n,e){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e],this.getRow(n)){const o=this.getRow(n);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[n])}}setRow(n,e){this._matrix[n]=e}moveRows(n,e,s){Yn(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{Yn(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)jn(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{i&&jn(s,void 0,i)})}removeRows(n,e){Kn(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{r&&Kn(n,e,r)})}getFragment(n,e,s,r){const i=new Jt;let o=0;for(let a=n;a<=e;a++){const l={};let d=0;for(let h=s;h<=r;h++){const c=this.getValue(a,h);l[d]=c,d++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new Jt;for(let o=n;o<=e;o++)for(let a=s;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,k.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return ge(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=ge(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const n=new Array;return this.forValue((e,s,r)=>{n.push(r)}),n}toArray(){const n=[];return this.forRow((e,s)=>{n[e]==null&&(n[e]=[]),s.forEach(r=>{n[e][r]=this.getValue(e,r)})}),n}toFullArray(){const n=this.getRange(),{endColumn:e,endRow:s}=n,r=[];for(let i=0;i<=s;i++){const o=Array(e+1).fill(void 0);r.push(o)}return this.forValue((i,o,a)=>{r[i][o]=a}),r}toJSON(){return this._matrix}clone(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getData(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getArrayData(){let n=0,e=0,s=!1,r=!1;const i=new Jt;return this.forEach((o,a)=>{s||(s=!0,n=o),Object.keys(a).forEach(l=>{const d=Number(l);r?d<e&&(e=d):(r=!0,e=d);const h=this.getValue(o,d);i.setValue(o-n,d-e,h)})}),i.getData()}getDataRange(){let n=0,e=0,s=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,n=a),l==null)return;const d=ge(l)-1;d>s&&(s=d),Object.keys(l).forEach(h=>{const c=Number(h);o?c<e&&(e=c):(o=!0,e=c)}),a>r&&(r=a)}),{startRow:n,startColumn:e,endRow:r,endColumn:s}}getDiscreteRanges(){const n=[];return this.forEach((e,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const a of n)if(e>=a.startRow&&e<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(e,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||n.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),n}merge(n){this.forValue((e,s)=>{const r=n.getValue(e,s);r!=null&&this.setValue(e,s,r)})}_setOriginValue(n={}){this._matrix=n}}const le=class le{static clone(n){return n.rangeType!==void 0?{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:n.rangeType}:{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn}}static equals(n,e){return n==null||e==null?!1:n.endRow===e.endRow&&n.endColumn===e.endColumn&&n.startRow===e.startRow&&n.startColumn===e.startColumn&&(n.rangeType===e.rangeType||n.rangeType===void 0&&e.rangeType===ot.NORMAL||e.rangeType===void 0&&n.rangeType===ot.NORMAL)}static intersects(n,e){if(n.rangeType===ot.ROW&&e.rangeType===ot.COLUMN||n.rangeType===ot.COLUMN&&e.rangeType===ot.ROW)return!0;if(n.rangeType===ot.ROW&&e.rangeType===ot.ROW)return n.startRow<=e.endRow&&n.endRow>=e.startRow;if(n.rangeType===ot.COLUMN&&e.rangeType===ot.COLUMN)return n.startColumn<=e.endColumn&&n.endColumn>=e.startColumn;const s=Math.floor(Number.MAX_SAFE_INTEGER/10),r=Number.isNaN(n.startRow)?0:n.startRow,i=Number.isNaN(n.endRow)?s:n.endRow,o=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?s:n.endColumn,l=Number.isNaN(e.startRow)?0:e.startRow,d=Number.isNaN(e.endRow)?s:e.endRow,h=Number.isNaN(e.startColumn)?0:e.startColumn,c=Number.isNaN(e.endColumn)?s:e.endColumn,f=Math.abs(o+a-h-c),_=Math.abs(o-a)+Math.abs(h-c),E=Math.abs(r+i-l-d),R=Math.abs(r-i)+Math.abs(l-d);return f<=_&&E<=R}static getIntersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,d=e.startColumn,h=e.endColumn;let c,f,_,E;if(a<=r)a>=s?f=a:f=s;else return null;if(l>=s)l>=r?E=r:E=l;else return null;if(d<=o)d>i?c=d:c=i;else return null;if(h>=i)h>=o?_=o:_=h;else return null;return{startRow:f,endRow:E,startColumn:c,endColumn:_,rangeType:ot.NORMAL}}static contains(n,e){return n.startRow<=e.startRow&&n.endRow>=e.endRow&&n.startColumn<=e.startColumn&&n.endColumn>=e.endColumn}static realContain(n,e){return le.contains(n,e)&&(n.startRow<e.startRow||n.endRow>e.endRow||n.startColumn<e.startColumn||n.endColumn>e.endColumn)}static union(...n){return n.reduce((e,s)=>({startRow:Math.min(e.startRow,s.startRow),startColumn:Math.min(e.startColumn,s.startColumn),endRow:Math.max(e.endRow,s.endRow),endColumn:Math.max(e.endColumn,s.endColumn),rangeType:ot.NORMAL}),n[0])}static realUnion(...n){const e=n.some(i=>i.rangeType===ot.COLUMN),s=n.some(i=>i.rangeType===ot.ROW),r=le.union(...n);return{startColumn:s?Number.NaN:r.startColumn,endColumn:s?Number.NaN:r.endColumn,startRow:e?Number.NaN:r.startRow,endRow:e?Number.NaN:r.endRow,rangeType:s?ot.ROW:e?ot.COLUMN:ot.NORMAL}}static subtract(n,e){if(e.startRow>n.endRow||e.endRow<n.startRow||e.startColumn>n.endColumn||e.endColumn<n.startColumn)return[n];const s=[];e.startRow>=n.startRow&&s.push({startRow:n.startRow,startColumn:n.startColumn,endRow:e.startRow-1,endColumn:n.endColumn}),e.endRow<=n.endRow&&s.push({startRow:e.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const r=Math.max(n.startRow,e.startRow),i=Math.min(n.endRow,e.endRow);return e.startColumn>=n.startColumn&&s.push({startRow:r,startColumn:n.startColumn,endRow:i,endColumn:e.startColumn-1}),e.endColumn<=n.endColumn&&s.push({startRow:r,startColumn:e.endColumn+1,endRow:i,endColumn:n.endColumn}),s.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,e){return!(n.left>e.right||n.right<e.left||n.top>e.bottom||n.bottom<e.top)}static getIntersectionBetweenTwoRect(n,e){const s=Math.max(n.left,e.left),r=Math.min(n.right,e.right),i=Math.max(n.top,e.top),o=Math.min(n.bottom,e.bottom);return r<=s||o<=i?null:{left:s,right:r,top:i,bottom:o,width:r-s,height:o-i}}};g(le,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),g(le,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[Nt.ROW,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[Nt.ROW,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[Nt.COLUMN,Nt.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),g(le,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),g(le,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),g(le,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let me=le;class Ka{constructor(n,e){g(this,"_values",[]);g(this,"_keys",[]);g(this,"_keyMaps",new Map);this._values=n,this._keys=e,n.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(n){this._keys.forEach(e=>{const s=n[e],r=this._keyMaps.get(e)||new Map;r.set(s,n),this._keyMaps.set(e,r)})}getValue(n,e){const s=e||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(n))return i.get(n)}return null}hasValue(n){for(let e=0;e<this._keys.length;e++){const s=this._keyMaps.get(this._keys[e]);if(s!=null&&s.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,e,s){const r=this.getValue(n);r&&Object.keys(r).includes(e)&&(r[e]=s)}deleteValue(n){const e=this.getValue(n);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===e);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(n){var e;return[...((e=this._keyMaps.get(n))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function zn(t,n,e,s){return{forEach(r){for(let i=t;i<=n;i++)for(let o=e;o<=s;o++)r(i,o)}}}function Ya(t){if(t==null||t.length===0)return Number.NaN;const n=t.toLowerCase().split(""),e=n.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=s(n[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const Rn=65,jr=90,za=97;function Xa(t){const n=jr-Rn+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+Rn)+e,t=Math.floor(t/n)-1;return e}function Kr(t,n){let e="";for(;n>0;)e+=t,n--;return e}function qa(t,n=!1){const e=jr-Rn+1;let s=za;n&&(s=Rn);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return Kr(r,i)}function Za(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function Ja(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function Ae(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function Qa(t,n){let e;function s(...r){const i=this,o=function(){e=null,t.apply(i,r)};clearTimeout(e),e=setTimeout(o,n)}return Object.defineProperty(s,"cancel",{value:()=>{clearTimeout(e)},enumerable:!1,writable:!1}),s}function Cn(t,n,e){const{dataStream:s,textRuns:r=[]}=t;let i=n;const o=[];for(const a of r){const{st:l,ed:d}=a;k.hasIntersectionBetweenTwoRanges(n,e,l,d)&&(l>i?(o.push(s.slice(i,l)),o.push(Xn(s,{...a,ed:Math.min(d,e)}))):o.push(Xn(s,{...a,st:i,ed:Math.min(d,e)}))),i=Math.max(n,Math.min(d,e))}return i!==e&&o.push(s.slice(i,e)),o.join("")}function tl(t,n=!0){var e;if(n&&((e=t.paragraphs)!=null&&e.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const a of r){const{startIndex:l,paragraphStyle:d={}}=a,{spaceAbove:h,spaceBelow:c,lineSpacing:f}=d,_=[];h!=null&&(typeof h=="number"?_.push(`margin-top: ${h}px`):_.push(`margin-top: ${h.v}px`)),c!=null&&(typeof c=="number"?_.push(`margin-bottom: ${c}px`):_.push(`margin-bottom: ${c.v}px`)),f!=null&&_.push(`line-height: ${f}`),l>o+1?i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}>${Cn(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=Cn(t,o,s.length)),i}else return Cn(t,0,t.dataStream.length)}function Xn(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:d,st:h,ol:c,bg:f,cl:_,va:E}=r;let R=t.slice(e,s);const U=[];return a===Y.TRUE&&(R=`<i>${R}</i>`),E===Pe.SUPERSCRIPT?R=`<sup>${R}</sup>`:E===Pe.SUBSCRIPT&&(R=`<sub>${R}</sub>`),(d==null?void 0:d.s)===Y.TRUE&&(R=`<u>${R}</u>`),(h==null?void 0:h.s)===Y.TRUE&&(R=`<s>${R}</s>`),l===Y.TRUE&&(R=`<strong>${R}</strong>`),i&&U.push(`font-family: ${i}`),_&&U.push(`color: ${_.rgb}`),o&&U.push(`font-size: ${o}pt`),c&&U.push("text-decoration: overline"),f&&U.push(`background: ${f.rgb}`),U.length?`<span style="${U.join("; ")};">${R}</span>`:R}const el={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},nl={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},sl={startRow:0,startColumn:0,endRow:0,endColumn:0},rl={row:0,column:0},pn={ff:"Arial",fs:11,it:Y.FALSE,bl:Y.FALSE,ul:{s:Y.FALSE},st:{s:Y.FALSE},ol:{s:Y.FALSE},tr:{a:0,v:Y.FALSE},td:Ve.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Se.UNSPECIFIED,vt:De.UNSPECIFIED,tb:ye.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Yr={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var zr=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(zr||{});function In(t,n){const{textRuns:e=[]}=n;let s=0;for(const i of e){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return Y.FALSE;switch(t){case"bl":case"it":{if(o[t]===Y.FALSE)return Y.FALSE;break}case"ul":case"st":{if(o[t].s===Y.FALSE)return Y.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
4
- `)===s?Y.TRUE:Y.FALSE}const nn=class nn{constructor(n,e,s){g(this,"_range");g(this,"_worksheet");this._deps=s,this._range=e,this._worksheet=n}static foreach(n,e){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n;for(let a=s;a<=i;a++)for(let l=r;l<=o;l++)e(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=[];for(let o=n;o<=e;o++){const a=[];for(let l=s;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Jt;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new Jt;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a-n,l-s,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=k.numToWord(s+1)+(n+1),o=k.numToWord(r+1)+(e+1)):(i=k.numToWord(r+1)+(e+1),o=k.numToWord(s+1)+(n+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||pn.bg.rgb}))}getCell(n,e){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:s+n,endRow:s+n,startColumn:i+e,endColumn:i+e};return new nn(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:e,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,s,r,i).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let d=0;d<=s-e;d++)for(let h=0;h<=i-r;h++){if(o==null||((a=o==null?void 0:o[d])==null?void 0:a[h])==null)continue;const c=o[d][h].s;c&&(o[d][h].s=l.get(c))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||pn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("ul",n.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("st",n.body)===Y.TRUE?{s:Y.TRUE}:{s:Y.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,s;const n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...n.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("it",n.body)===Y.TRUE?ln.ITALIC:ln.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?In("bl",n.body)===Y.TRUE?un.BOLD:un.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:e}=this,{startRow:s,endRow:r}=n;let i=0;for(let o=0;o<=r-s;o++){const a=e.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:n,endColumn:e}=this._range;return e-n+1}getNumRows(){const{startRow:n,endRow:e}=this._range;return e-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.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(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>n.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:e}=this,{startColumn:s,endColumn:r}=n;let i=0;for(let o=0;o<=r-s;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===ye.WRAP?Y.TRUE:Y.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){nn.foreach(this._range,n)}_getStyles(n){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[n]||pn[n]}))}};g(nn,"transformRange",(n,e)=>n.rangeType===ot.ALL?{startColumn:0,startRow:0,endColumn:e.getMaxColumns()-1,endRow:e.getMaxRows()-1}:n.rangeType===ot.COLUMN?{startRow:0,endRow:e.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===ot.ROW?{startColumn:0,endColumn:e.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let ke=nn;function il(t,n){if(t.length===0||t[0].length===0)return null;const e=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let a=0;a<t[0].length;a++)e[a]=n(t[i][a])?e[a]+1:0;const o=ol(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function ol(t){const n=[];let e=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(n.length===0||t[r]>=t[n[n.length-1]])n.push(r++);else{const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}for(;n.length>0;){const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}return s}function al(t,n){ke.foreach(n,(e,s)=>{t[e][s]=void 0})}function ll(t,n){const e=t.toFullArray(),s=[];for(;;){const r=il(e,n);if(!r)break;s.push(r),al(e,r)}return s}function ul(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||Nt.NONE,o=r.endAbsoluteRefType||Nt.NONE;return!s&&i===Nt.ALL&&o===Nt.ALL?r:s||i===Nt.NONE&&o===Nt.NONE?me.moveOffset(r,n,e):(i===Nt.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===Nt.COLUMN?r={...r,startRow:r.startRow+e}:i===Nt.ROW&&(r={...r,startColumn:r.startColumn+n}),o===Nt.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===Nt.COLUMN?r={...r,endRow:r.endRow+e}:o===Nt.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function Xr(t){for(const[n,e]of t.entries())try{if(!await e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}function qr(t){for(const[n,e]of t.entries())try{if(!e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}const Ye=ct.createIdentifier("univer.context-service");class Zr extends Mt{constructor(){super(...arguments);g(this,"_contextChanged$",new B.Subject);g(this,"contextChanged$",this._contextChanged$.asObservable());g(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var s;return(s=this._contextMap.get(e))!=null?s:!1}setContextValue(e,s){this._contextMap.set(e,s),this._contextChanged$.next({[e]:s})}subscribeContextValue$(e){return new B.Observable(s=>{const r=this._contextChanged$.pipe(B.filter(i=>typeof i[e]<"u")).subscribe(i=>s.next(i[e]));return this._contextMap.has(e)&&s.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var Jr=(t=>(t[t.SILENT=0]="SILENT",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.VERBOSE=4]="VERBOSE",t))(Jr||{});const Ee=ct.createIdentifier("univer.log");class Qr extends Mt{constructor(){super(...arguments);g(this,"_logLevel",3)}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)}setLogLevel(e){this._logLevel=e}_log(e,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):e(...s)}}var cl=Object.defineProperty,hl=Object.getOwnPropertyDescriptor,dl=(t,n,e,s)=>{for(var r=s>1?void 0:s?hl(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&cl(n,e,r),r},ti=(t,n)=>(e,s)=>n(e,s,t),ze=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(ze||{});const Xe=ct.createIdentifier("anywhere.command-service");class fl{constructor(){g(this,"_commands",new Map);g(this,"_commandTypes",new Map)}registerCommand(n){if(this._commands.has(n.id))throw new Error(`[CommandRegistry]: command "${n.id}" has been registered before.`);return this._commands.set(n.id,n),this._commandTypes.set(n.id,n.type),At(()=>{var e;this._commands.delete(n.id),this._commandTypes.delete(n.id),(e=n.onDispose)==null||e.call(n)})}hasCommand(n){return this._commands.has(n)}getCommand(n){return this._commands.has(n)?[this._commands.get(n)]:null}getCommandType(n){return this._commandTypes.get(n)}}const ei={id:"nil",type:0,handler:()=>!0};u.CommandService=class extends Mt{constructor(e,s){super();g(this,"_commandRegistry");g(this,"_beforeCommandExecutionListeners",[]);g(this,"_commandExecutedListeners",[]);g(this,"_multiCommandDisposables",new Map);g(this,"_commandExecutingLevel",0);g(this,"_commandExecutionStack",[]);this._injector=e,this._logService=s,this._commandRegistry=new fl,this._registerCommand(ei)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._registerCommand(e)}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),At(()=>{const s=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),At(()=>{const s=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,s,r){try{const i=this._commandRegistry.getCommand(e);if(i){const[o]=i,a={id:o.id,type:o.type,params:s},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(h=>h(a,r));const d=await this._execute(o,s,r);return this._commandExecutedListeners.forEach(h=>h(a,r)),l.dispose(),d}throw new Error(`[CommandService]: command "${e}" is not registered.`)}catch(i){throw this._logService.error(i),i}}syncExecuteCommand(e,s,r){var o;const i=this._commandRegistry.getCommand(e);if(i){const[a]=i,l={id:a.id,type:a.type,params:s};if(a.type===2){const c=Fa(this._commandExecutionStack,f=>f.type===0);c&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=c.id)}const d=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(c=>c(l,r));const h=this._syncExecute(a,s,r);return this._commandExecutedListeners.forEach(c=>c(l,r)),d.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),At(()=>En(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const s=this._commandRegistry.getCommand(e.id);let r;if(s){if(s[0].multi!==!0)throw new Error("Command has registered as a single command.");r=s[0]}else{const o=new Vn;r=new _l(e.id),o.add(this._commandRegistry.registerCommand(r)),o.add(At(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,o)}const i=r.registerImplementation(e);return At(()=>{var o;i.dispose(),r.hasImplementations()||(o=this._multiCommandDisposables.get(e.id))==null||o.dispose()})}async _execute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let i;try{i=await this._injector.invoke(e.handler,s,r),this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}_syncExecute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let i;try{if(i=this._injector.invoke(e.handler,s,r),i instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}},u.CommandService=dl([ti(0,ct.Inject(ct.Injector)),ti(1,Ee)],u.CommandService);class _l{constructor(n){g(this,"name");g(this,"multi",!0);g(this,"type",0);g(this,"priority",0);g(this,"_implementations",[]);g(this,"handler",async(n,e)=>{if(!this._implementations.length)return!1;const s=n.get(Ee),r=n.get(Ye),i=n.get(ct.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const e={command:n};return this._implementations.push(e),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),At(()=>{var r;const s=this._implementations.indexOf(e);this._implementations.splice(s,1),(r=n.onDispose)==null||r.call(n)})}hasImplementations(){return this._implementations.length>0}}function qn(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return qr(s)}function gl(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return Xr(s)}function ni(t){return new B.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}function si(t){return function(e){return new B.Observable(s=>(e.subscribe({next:r=>{s.next(r),t(r)&&s.complete()},complete:()=>s.complete(),error:r=>s.error(r)}),()=>s.unsubscribe()))}}const ml=t=>new Promise(n=>{B.merge(ni(t.onCommandExecuted.bind(t)).pipe(oe.filter(([e])=>e.type===ze.MUTATION)),B.timer(300)).pipe(oe.debounceTime(16),oe.first()).subscribe(()=>{n()})});var jt=(t=>(t[t.UNDEFINED=0]="UNDEFINED",t[t.OK=1]="OK",t[t.INTERNAL_ERROR=2]="INTERNAL_ERROR",t[t.PERMISSION_DENIED=3]="PERMISSION_DENIED",t[t.NOT_FOUND=4]="NOT_FOUND",t[t.UNAUTHENTICATED=5]="UNAUTHENTICATED",t[t.ALREADY_EXISTS=6]="ALREADY_EXISTS",t[t.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",t[t.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",t[t.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",t[t.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",t[t.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",t[t.APPLY_REJECT=7001]="APPLY_REJECT",t[t.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",t[t.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",t[t.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",t[t.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",t[t.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",t[t.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",t[t.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",t[t.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",t[t.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",t[t.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",t[t.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(jt||{});function ri(t){return!!(t&&t.code&&t.code!==jt.OK&&t.code!=="OK")}var Q=(t=>(t[t.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",t[t.UNIVER_DOC=1]="UNIVER_DOC",t[t.UNIVER_SHEET=2]="UNIVER_SHEET",t[t.UNIVER_SLIDE=3]="UNIVER_SLIDE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Q||{}),ii=(t=>(t[t.SomeCollaborator=0]="SomeCollaborator",t[t.AllCollaborator=1]="AllCollaborator",t[t.OneSelf=2]="OneSelf",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(ii||{}),Wt=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Wt||{}),Sn=(t=>(t[t.Unkonwn=0]="Unkonwn",t[t.Workbook=1]="Workbook",t[t.Worksheet=2]="Worksheet",t[t.SelectRange=3]="SelectRange",t[t.Document=4]="Document",t[t.Slide=5]="Slide",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Sn||{});class On extends Mt{}class Zn{constructor(){g(this,"_data",[])}static create(){return new Zn}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const e=this._data.indexOf(n);this._data.splice(e,1)}getData(){return this._data}}class Jn{constructor(){g(this,"_data",new Map)}static create(){return new Jn}add(n,e){this._data.has(n)||this._data.set(n,e)}delete(n){this._data.delete(n)}getData(){return this._data}}var oi=(t=>(t[t.PARAGRAPH=0]="PARAGRAPH",t[t.SECTION_BREAK=1]="SECTION_BREAK",t[t.TABLE=2]="TABLE",t[t.TABLE_ROW=3]="TABLE_ROW",t[t.TABLE_CELL=4]="TABLE_CELL",t[t.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",t))(oi||{}),ae=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
5
- `,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="",t.TABLE_END="",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(ae||{}),Nn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Nn||{});const El={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:xe.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:xe.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:xe.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function Qn(t){const n=[];for(const e of t){const{ed:s,ts:r}=e;if(e.sId===void 0&&delete e.sId,k.isEmptyObject(r)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const i=n.pop();Ur(e,i)&&k.hasIntersectionBetweenTwoRanges(i.st,i.ed,e.st,e.ed)?n.push({...e,st:i.st,ed:s}):n.push(i,e)}return n}function ai(t,n,e,s){var d;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(d=n.textRuns)!=null?d:[];if(l.length)for(const h of l)h.st+=s,h.ed+=s;for(let h=0;h<o;h++){const c=r[h],f=r[h+1],{st:_,ed:E}=c;if(E<s)i.push(c);else if(s>=_&&s<=E){if(f&&f.st===f.ed&&s===f.st){i.push(c);continue}if(a)c.st+=e,c.ed+=e,i.push(c);else{a=!0,c.ed+=e;const R=[];if(l.length){const U={...c,st:_,ed:l[0].st};U.ed>U.st&&R.push(U),R.push(...l);const D=l[l.length-1],et={...c,st:D.ed,ed:E+e};et.ed>et.st&&R.push(et)}else R.push(c);i.push(...R)}}else c.st+=e,c.ed+=e,a||(a=!0,i.push(...l)),i.push(c)}a||(a=!0,i.push(...l)),t.textRuns=Qn(i)}function ts(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let h=0,c=r.length;h<c;h++){const f=r[h],{startIndex:_}=f;_>=s&&(f.startIndex+=e),l===-1&&_>=s&&(l=h),a.push(f.startIndex)}let d=-1;if(i){for(let h=0,c=i.length;h<c;h++){const f=i[h];f.startIndex+=s;const _=f.startIndex;d=a.indexOf(_)}if(o===ae.PARAGRAPH&&i.length===1){const h=r[l],c=i[0],f=h.paragraphStyle,_=h.bullet;h.paragraphStyle=c.paragraphStyle,h.bullet=c.bullet,c.paragraphStyle=f,c.bullet=_}d!==-1&&r.splice(d,1),r.push(...i),r.sort(Ae("startIndex"))}}function Rl(t,n,e,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:d}=l;d>=s&&(l.startIndex+=e)}const i=n.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function li(t,n,e,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:d}=l;d>=s&&(l.startIndex+=e)}const i=n.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function ui(t,n,e,s){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:d,endIndex:h}=l;d>s?(l.startIndex+=e,l.endIndex+=e):h>=s-1&&(l.endIndex+=e)}const i=n.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(Ae("startIndex"))}}function ci(t,n,e,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let l=0,d=r.length;l<d;l++){const h=r[l];i[h.rangeId]=h;const{startIndex:c,endIndex:f}=h;c>=s?(h.startIndex+=e,h.endIndex+=e):f>s-1&&(h.endIndex+=e)}if(r.find(l=>l.startIndex>s&&l.endIndex<s))return;const a=[];if(n.customRanges){for(let l=0,d=n.customRanges.length;l<d;l++){const h=n.customRanges[l],c=i[h.rangeId];if(h.startIndex+=s,h.endIndex+=s,c){if(c.startIndex<=h.startIndex&&c.endIndex>=h.endIndex||t.dataStream[c.startIndex]===ae.CUSTOM_RANGE_START&&t.dataStream[c.endIndex]===ae.CUSTOM_RANGE_END)continue;if(t.dataStream[c.startIndex]===ae.CUSTOM_RANGE_START){c.endIndex=h.endIndex;continue}if(t.dataStream[c.endIndex]===ae.CUSTOM_RANGE_END){c.startIndex=h.startIndex;continue}}a.push(h)}r.push(...a),r.sort(Ae("startIndex"))}}function Cl(t){t.sort((s,r)=>s.startIndex-r.startIndex);const n=[];let e=t[0];for(let s=1;s<t.length;s++)e.endIndex+1>=t[s].startIndex?e.endIndex=Math.max(e.endIndex,t[s].endIndex):(n.push(e),e=t[s]);return n.push(e),n}function pl(t){const n={};for(let e=0,s=t.length;e<s;e++){const r=t[e],i=n[r.id];n[r.id]=[...i!=null?i:[],r]}return Object.keys(n).forEach(e=>{const s=n[e],r=Cl(s);n[e]=r}),Object.values(n).flat()}function hi(t,n,e,s){t.customDecorations||(t.customDecorations=[]);const{customDecorations:r}=t;if(e>0)for(let i=0,o=r.length;i<o;i++){const a=r[i],{startIndex:l,endIndex:d}=a;l>=s?(a.startIndex+=e,a.endIndex+=e):d>s-1&&(a.endIndex+=e)}if(n.customDecorations){const i=[];for(let o=0,a=n.customDecorations.length;o<a;o++){const l=n.customDecorations[o];i.push(l),l.startIndex+=s,l.endIndex+=s}r.push(...i),t.customDecorations=pl(r),t.customDecorations.sort(Ae("startIndex"))}}function di(t,n,e){var a;const{textRuns:s}=t,r=e,i=e+n,o=[];if(r===i&&(s!=null&&s.find(l=>l.st===e&&l.ed===e))){const l=s.find(d=>d.st===e&&d.ed===e);return o.push({...l,st:l.st-e,ed:l.ed-e}),t.textRuns=(a=t.textRuns)==null?void 0:a.filter(d=>d!==l),o}if(s){const l=[];for(let d=0,h=s.length;d<h;d++){const c=s[d],{st:f,ed:_}=c;if(r<=f&&i>=_){o.push({...c,st:f-r,ed:_-r});continue}else f<=r&&_>=i?(o.push({...c,st:r-r,ed:i-r}),c.ed-=n):r>=f&&r<_?(o.push({...c,st:r-r,ed:_-r}),c.ed=r):i>f&&i<=_?(o.push({...c,st:f-r,ed:i-r}),c.st=i-n,c.ed-=n):f>=i&&(c.st-=n,c.ed-=n);l.push(c)}t.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function fi(t,n,e){const{paragraphs:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,d=s.length;l<d;l++){const h=s[l],{startIndex:c}=h;if(c>=r&&c<i){o.push({...h,startIndex:c-e});continue}else c>=i&&(h.startIndex-=n);a.push(h)}t.paragraphs=a}return o}function _i(t,n,e){const{sectionBreaks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,d=s.length;l<d;l++){const h=s[l],{startIndex:c}=h;if(c>=r&&c<=i){o.push({...h,startIndex:c-e});continue}else c>i&&(h.startIndex-=n);a.push(h)}t.sectionBreaks=a}return o}function gi(t,n,e){const{customBlocks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,d=s.length;l<d;l++){const h=s[l],{startIndex:c}=h;if(c>=r&&c<=i){o.push({...h,startIndex:c-e});continue}else c>i&&(h.startIndex-=n);a.push(h)}t.customBlocks=a}return o}function mi(t,n,e){const{tables:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,d=s.length;l<d;l++){const h=s[l],{startIndex:c,endIndex:f}=h;if(r<=c&&i>=f){o.push({...h,startIndex:c-e,endIndex:f-e});continue}else if(c<=r&&f>=i){const _=mn(c,f,r,i);h.startIndex=_[0],h.endIndex=_[1]}else i<c&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.tables=a}return o}function Ei(t,n,e){const{customRanges:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,d=s.length;l<d;l++){const h=s[l],{startIndex:c,endIndex:f}=h;if(r<=c&&i>=c){o.push({...h,startIndex:c-e,endIndex:f-e});continue}else if(c<=r&&f>=i){const _=mn(c,f,r,i);h.startIndex=_[0],h.endIndex=_[1]}else i<c&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.customRanges=a}return o}function Ri(t,n,e,s=!0){const{customDecorations:r}=t,i=e,o=e+n-1,a=[];if(r){const l=[];for(let d=0,h=r.length;d<h;d++){const c=r[d],{startIndex:f,endIndex:_}=c;if(f>=i&&_<=o){a.push(c);continue}else if(Math.max(i,f)<=Math.min(o,_)){const E=mn(f,_,i,o);c.startIndex=E[0],c.endIndex=E[1]}else o<f&&s&&(c.startIndex-=n,c.endIndex-=n);l.push(c)}t.customDecorations=l}return a}function Il(t,n,e,s,r){const i=Sl(t,n,e,s,r),o=Ol(t,n,e,s,r),a=Nl(t,n,e,s,r),l=Al(t,n,e,s,r),d=bl(t,n,e,s,r),h=vl(t,n,e,s,r),c=wl(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:d,customRanges:h,customDecorations:c}}function Sl(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=di(t,e,s);if(r!==kt.REPLACE){const l=Ci(o,a,r);n.textRuns=l}return ai(t,n,e,s),a}function Ci(t,n,e){if(n.length===0)return t;t=k.deepClone(t),n=k.deepClone(n);const s=[],r=t.length,i=n.length;let o=0,a=0,l=null;function d(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:_,ed:E,ts:R}=t[o],{st:U,ed:D,ts:et,sId:Et}=n[a];let _t;if(e===kt.COVER?_t={...et,...R}:_t={...R,...et},E<U)d()||s.push(t[o]),o++;else if(D<_)d()||s.push(n[a]),a++;else{const C={st:Math.min(_,U),ed:Math.max(_,U),ts:_<U?{...R}:{...et},sId:_<U?void 0:Et};C.ed>C.st&&s.push(C),s.push({st:Math.max(_,U),ed:Math.min(E,D),ts:_t,sId:Et}),E<D?(o++,n[a].st=E,n[a].st===n[a].ed&&a++):(a++,t[o].st=D,t[o].st===t[o].ed&&o++);const O={st:Math.min(E,D),ed:Math.max(E,D),ts:E<D?{...et}:{...R},sId:E<D?Et:void 0};l=O.ed>O.st?O:null}}d();const h=s[s.length-1],c=t[r-1],f=n[i-1];return h.ed!==Math.max(c.ed,f.ed)&&(c.ed>f.ed?s.push(c):s.push(f)),Qn(s)}function Ol(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=fi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const d of o){const{startIndex:h,paragraphStyle:c,bullet:f}=d;let _=[];for(const E of a){const{startIndex:R,paragraphStyle:U,bullet:D}=E;let et,Et;if(r===kt.COVER?(et={...U,...c},Et={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...D,...f}):(et={...c,...U},Et={listId:"",listType:Nn.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...D}),h===R){_.push({startIndex:h,paragraphStyle:et,bullet:Et});break}}l.push(..._),_=[]}n.paragraphs=l}return ts(t,n,e,s),a}function Nl(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=_i(t,e,s);if(r!==kt.REPLACE){const l=[];for(const d of o){const{startIndex:h}=d;let c=[];for(const f of a){const{startIndex:_}=f;if(h===_){r===kt.COVER?c.push({...f,...d}):c.push({...d,...f});break}}l.push(...c),c=[]}n.sectionBreaks=l}return ts(t,n,e,s),a}function Al(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=gi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const d of o){const{startIndex:h}=d;let c=[];for(const f of a){const{startIndex:_}=f;if(h===_){r===kt.COVER?c.push({...f,...d}):c.push({...d,...f});break}}l.push(...c),c=[]}n.customBlocks=l}return li(t,n,e,s),a}function bl(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=mi(t,e,s);if(r!==kt.REPLACE){const l=[];for(const d of o){const{startIndex:h,endIndex:c}=d;let f=[];for(const _ of a){const{startIndex:E,endIndex:R}=_;if(E>=h&&R<=c){r===kt.COVER?f.push({..._,...d}):f.push({...d,..._});break}}l.push(...f),f=[]}n.tables=l}return ui(t,n,e,s),a}function vl(t,n,e,s,r){t.customRanges||(t.customRanges=[]);const{customRanges:i}=t,{customRanges:o}=n;if(i==null||o==null)return;let a=[];return r===kt.REPLACE&&(a=Ei(t,e,s)),ci(t,n,0,s),a}function wl(t,n,e,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===kt.REPLACE&&(i=Ri(t,e,s,!1)),hi(t,n,0,s),i}var es=(t=>(t[t.copy=0]="copy",t[t.cut=1]="cut",t))(es||{});function qe(t,n,e,s=!1,r=1){const{dataStream:i,textRuns:o=[],paragraphs:a=[],customBlocks:l=[]}=t,d={dataStream:i.slice(n,e)},h=[];for(const E of o){const R=k.deepClone(E),{st:U,ed:D}=R;k.hasIntersectionBetweenTwoRanges(U,D,n,e)&&(n>=U&&n<=D?h.push({...R,st:n,ed:Math.min(e,D)}):e>=U&&e<=D?h.push({...R,st:Math.max(n,U),ed:e}):h.push(R))}h.length?d.textRuns=h.map(E=>{const{st:R,ed:U}=E;return{...E,st:R-n,ed:U-n}}):s&&(d.textRuns=[{st:0,ed:e-n,ts:{}}]);const c=[];for(const E of a){const{startIndex:R}=E;R>=n&&R<=e&&c.push(k.deepClone(E))}c.length&&(d.paragraphs=c.map(E=>({...E,startIndex:E.startIndex-n}))),r===1&&(d.customDecorations=Ii(t,n,e));const{customRanges:f}=pi(t,n,e);d.customRanges=f;const _=[];for(const E of l){const{startIndex:R}=E;R>=n&&R<=e&&_.push(k.deepClone(E))}return _.length&&(d.customBlocks=_.map(E=>({...E,startIndex:E.startIndex-n}))),d}function Tl(t){const{dataStream:n,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}=t;let o=0,a=0;r==null||r.forEach(d=>{d.startIndex<0&&(o=Math.max(o,-d.startIndex)),d.endIndex>n.length-1&&(a=Math.max(a,d.endIndex-n.length+1))});const l=`${ae.CUSTOM_RANGE_START.repeat(o)}${n}${ae.CUSTOM_RANGE_END.repeat(a)}`;return e&&(e[0]&&(e[0].st=e[0].st-o),e[e.length-1]&&(e[e.length-1].ed=e[e.length-1].ed+a)),e==null||e.forEach(d=>{d.st+=o,d.ed+=o}),s==null||s.forEach(d=>{d.startIndex+=o}),r==null||r.forEach(d=>{d.startIndex+=o,d.endIndex+=o}),i==null||i.forEach(d=>{d.startIndex+=o,d.endIndex+=a}),{...t,dataStream:l,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}}function pi(t,n,e){const{customRanges:s=[]}=t;let r=0,i=0;const o=s.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,e-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(o.length){o.forEach(a=>{a.startIndex<n&&(r+=1),a.endIndex>e-1&&(i+=1)});for(let a=0;a<r;a++){const l=o[a];l.startIndex=n-r+a}if(i){const a=[...o].sort((l,d)=>d.endIndex-l.endIndex);for(let l=0;l<i;l++){const d=a[l];d.endIndex=e+i-l-1}}}return{customRanges:o.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:r,rightOffset:i}}function Ii(t,n,e){const{customDecorations:s=[]}=t,r=[];return s.forEach(i=>{if(Math.max(i.startIndex,n)<=Math.min(i.endIndex,e-1)){const o=k.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,e)-n})}}),r}function ns(t,n,e=kt.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=n,l=Ci(o,r,e);l.length&&(s.textRuns=l);const d=[];let h=0,c=0;for(;h<i.length&&c<a.length;){const f=i[h],_=a[c],{startIndex:E}=f,{startIndex:R}=_;E===R?(d.push(k.deepMerge(f,_)),h++,c++):E<R?(d.push(k.deepClone(f)),h++):(d.push(k.deepClone(_)),c++)}return h<i.length&&d.push(...i.slice(h)),c<a.length&&d.push(...a.slice(c)),d.length&&(s.paragraphs=d),s}function Ml(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function Ul(t=k.generateRandomId(6),n=Ie.EN_US,e=""){return{id:t,locale:n,title:e,body:{dataStream:`\r
6
- `,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ll(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Gt={},Si={},ss={};Object.defineProperty(ss,"__esModule",{value:!0});function Dl(t,n){if(Array.isArray(n))return!1;for(let e in t)if(!rs(t[e],n[e]))return!1;for(let e in n)if(t[e]===void 0)return!1;return!0}function yl(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!rs(t[e],n[e]))return!1;return!0}function rs(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?yl(t,n):Dl(t,n)}ss.default=rs;var is={};Object.defineProperty(is,"__esModule",{value:!0});function os(t){if(t===null)return null;if(Array.isArray(t))return t.map(os);if(typeof t=="object"){const n={};for(let e in t)n[e]=os(t[e]);return n}else return t}is.default=os;var as={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.eachChildOf=t.advancer=t.readCursor=t.writeCursor=t.WriteCursor=t.ReadCursor=t.isValidPathItem=void 0;function n(h,c){if(!h)throw new Error(c)}const e=h=>h!=null&&typeof h=="object"&&!Array.isArray(h),s=(h,c)=>typeof h==typeof c?h>c:typeof h=="string"&&typeof c=="number";function r(h,c){for(let f in h){const _=f;c.write(_,h[_])}}t.isValidPathItem=h=>typeof h=="number"||typeof h=="string"&&h!=="__proto__";class i{constructor(c=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=c}ascend(){n(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):(n(this.idx>0),this.idx--,e(this.container[this.idx])&&this.idx--)}getPath(){const c=[];let f=this.container,_=this.parents.length-1,E=this.idx;for(;E>=0;)c.unshift(f[E]),E===0?(E=this.indexes[_*2],f=this.parents[_--]):E-=e(f[E-1])?2:1;return c}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return n(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let c;return this.container&&this.container.length>this.idx+1&&e(c=this.container[this.idx+1])?c:null}descendFirst(){let c=this.idx+1;if(!this.container||c>=this.container.length||e(this.container[c])&&c+1>=this.container.length)return!1;e(this.container[c])&&c++;const f=this.container[c];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(c),this.idx=0,this.container=f):this.idx=c,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const c=this.indexes[this.indexes.length-1]+1,f=this.parents[this.parents.length-1];return c>=f.length?!1:(n(!isNaN(c)),this.indexes[this.indexes.length-1]=c,this.container=f[c],!0)}_init(c,f,_,E){this.container=c,this.idx=f,this.parents=_.slice(),this.indexes=E.slice()}clone(){const c=new o;return c._init(this.container,this.idx,this.parents,this.indexes),c}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(c,f){const _=this.getComponent();_&&f(_,c);for(const E of this)c&&c.descend(E),this.traverse(c,f),c&&c.ascend()}eachPick(c,f){this.traverse(c,(_,E)=>{_.p!=null&&f(_.p,E)})}eachDrop(c,f){this.traverse(c,(_,E)=>{_.d!=null&&f(_.d,E)})}}t.ReadCursor=o;class a extends i{constructor(c=null){super(c),this.pendingDescent=[],this._op=c}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let c=0;c<this.pendingDescent.length;c++){const f=this.pendingDescent[c];let _=this.idx+1;if(_<this.container.length&&e(this.container[_])&&_++,n(_===this.container.length||!e(this.container[_])),_===this.container.length)this.container.push(f),this.idx=_;else if(this.container[_]===f)this.idx=_;else{if(!Array.isArray(this.container[_])){const E=this.container.splice(_,this.container.length-_);this.container.push(E),this.lcIdx>-1&&(this.lcIdx=_)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(s(f,this.container[this.lcIdx][0])),_=this.lcIdx+1,this.lcIdx=-1);_<this.container.length&&s(f,this.container[_][0]);)_++;if(this.indexes.push(_),this.idx=0,_<this.container.length&&this.container[_][0]===f)this.container=this.container[_];else{const E=[f];this.container.splice(_,0,E),this.container=E}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const c=this.idx+1;if(c<this.container.length&&e(this.container[c]))return this.container[c];{const f={};return this.container.splice(c,0,f),f}}write(c,f){const _=this.getComponent();n(_[c]==null||_[c]===f,"Internal consistency error: Overwritten component. File a bug"),_[c]=f}get(){return this._op}descend(c){if(!t.isValidPathItem(c))throw Error("Invalid JSON key");this.pendingDescent.push(c)}descendPath(c){return this.pendingDescent.push(...c),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(c,f=r){if(c===null)return;if(n(Array.isArray(c)),c===this._op)throw Error("Cannot merge into my own tree");const _=this.lcIdx,E=this.parents.length;let R=0;for(let U=0;U<c.length;U++){const D=c[U];typeof D=="string"||typeof D=="number"?(R++,this.descend(D)):Array.isArray(D)?this.mergeTree(D,f):typeof D=="object"&&f(D,this)}for(;R--;)this.ascend();this.lcIdx=this.parents.length===E?_:-1}at(c,f){this.descendPath(c),f(this);for(let _=0;_<c.length;_++)this.ascend();return this}writeAtPath(c,f,_){return this.at(c,()=>this.write(f,_)),this.reset(),this}writeMove(c,f,_=0){return this.writeAtPath(c,"p",_).writeAtPath(f,"d",_)}getPath(){const c=super.getPath();return c.push(...this.pendingDescent),c}}t.WriteCursor=a,t.writeCursor=()=>new a,t.readCursor=h=>new o(h);function l(h,c,f){let _,E;E=_=h?h.descendFirst():!1;function R(U){let D;for(;E;){const et=D=h.getKey();if(U!=null){let Et=!1;if(c&&typeof et=="number"&&(D=c(et,h.getComponent()),D<0&&(D=~D,Et=!0)),s(D,U))return null;if(D===U&&!Et)return h}f&&typeof D=="number"&&f(D,h.getComponent()),E=h.nextSibling()}return null}return R.end=()=>{_&&h.ascend()},R}t.advancer=l;function d(h,c,f){let _,E,R,U;for(_=E=h&&h.descendFirst(),R=U=c&&c.descendFirst();_||R;){let D=_?h.getKey():null,et=R?c.getKey():null;D!==null&&et!==null&&(s(et,D)?et=null:D!==et&&(D=null)),f(D==null?et:D,D!=null?h:null,et!=null?c:null),D!=null&&_&&(_=h.nextSibling()),et!=null&&R&&(R=c.nextSibling())}E&&h.ascend(),U&&c.ascend()}t.eachChildOf=d})(as);var ls={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConflictType=void 0,function(n){n[n.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",n[n.DROP_COLLISION=2]="DROP_COLLISION",n[n.BLACKHOLE=3]="BLACKHOLE"}(t.ConflictType||(t.ConflictType={}))})(ls);var us={},be={},Oi;function cs(){return Oi||(Oi=1,Object.defineProperty(be,"__esModule",{value:!0}),be.uniToStrPos=be.strPosToUni=void 0,be.strPosToUni=(t,n=t.length)=>{let e=0,s=0;for(;s<n;s++){const r=t.charCodeAt(s);r>=55296&&r<=57343&&(e++,s++)}if(s!==n)throw Error("Invalid offset - splits unicode bytes");return s-e},be.uniToStrPos=(t,n)=>{let e=0;for(;n>0;n--){const s=t.charCodeAt(e);e+=s>=55296&&s<=57343?2:1}return e}),be}var hs={},Ni;function ds(){return Ni||(Ni=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const n=cs(),e=C=>{if(!Array.isArray(C))throw Error("Op must be an array of components");let O=null;for(let w=0;w<C.length;w++){const q=C[w];switch(typeof q){case"object":if(typeof q.d!="number"&&typeof q.d!="string")throw Error("Delete must be number or string");if(t.dlen(q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(q>0))throw Error("Skip components must be >0");if(typeof O=="number")throw Error("Adjacent skip components should be combined");break}O=q}if(typeof O=="number")throw Error("Op has a trailing skip")};function s(C,O){let w=0,q=0;for(let st=0;st<C.length;st++){const Z=C[st];switch(O(Z,w,q),typeof Z){case"object":w+=t.dlen(Z.d);break;case"string":q+=n.strPosToUni(Z);break;case"number":w+=Z,q+=Z;break}}}t.eachOp=s;function r(C,O){const w=[],q=a(w);return s(C,(st,Z,Yt)=>{q(O(st,Z,Yt))}),c(w)}const i=C=>C,o=C=>r(C,i);t.dlen=C=>typeof C=="number"?C:n.strPosToUni(C);const a=C=>O=>{if(!(!O||O.d===0||O.d===""))if(C.length===0)C.push(O);else if(typeof O==typeof C[C.length-1])if(typeof O=="object"){const w=C[C.length-1];w.d=typeof w.d=="string"&&typeof O.d=="string"?w.d+O.d:t.dlen(w.d)+t.dlen(O.d)}else C[C.length-1]+=O;else C.push(O)},l=C=>typeof C=="number"?C:typeof C=="string"?n.strPosToUni(C):typeof C.d=="number"?C.d:n.strPosToUni(C.d);t.uniSlice=(C,O,w)=>{const q=n.uniToStrPos(C,O),st=w==null?1/0:n.uniToStrPos(C,w);return C.slice(q,st)};const d=(C,O,w)=>typeof C=="number"?w==null?C-O:Math.min(C,w)-O:t.uniSlice(C,O,w),h=C=>{let O=0,w=0;return{take:(Z,Yt)=>{if(O===C.length)return Z===-1?null:Z;const bt=C[O];let gt;if(typeof bt=="number")return Z===-1||bt-w<=Z?(gt=bt-w,++O,w=0,gt):(w+=Z,Z);if(typeof bt=="string"){if(Z===-1||Yt==="i"||n.strPosToUni(bt.slice(w))<=Z)return gt=bt.slice(w),++O,w=0,gt;{const St=w+n.uniToStrPos(bt.slice(w),Z);return gt=bt.slice(w,St),w=St,gt}}else{if(Z===-1||Yt==="d"||t.dlen(bt.d)-w<=Z)return gt={d:d(bt.d,w)},++O,w=0,gt;{let St=d(bt.d,w,w+Z);return w+=Z,{d:St}}}},peek:()=>C[O]}},c=C=>(C.length>0&&typeof C[C.length-1]=="number"&&C.pop(),C);function f(C,O,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");e(C),e(O);const q=[],st=a(q),{take:Z,peek:Yt}=h(C);for(let gt=0;gt<O.length;gt++){const St=O[gt];let Lt,zt;switch(typeof St){case"number":for(Lt=St;Lt>0;)zt=Z(Lt,"i"),st(zt),typeof zt!="string"&&(Lt-=l(zt));break;case"string":w==="left"&&typeof Yt()=="string"&&st(Z(-1)),st(n.strPosToUni(St));break;case"object":for(Lt=t.dlen(St.d);Lt>0;)switch(zt=Z(Lt,"i"),typeof zt){case"number":Lt-=zt;break;case"string":st(zt);break;case"object":Lt-=t.dlen(zt.d)}break}}let bt;for(;bt=Z(-1);)st(bt);return c(q)}function _(C,O){e(C),e(O);const w=[],q=a(w),{take:st}=h(C);for(let Yt=0;Yt<O.length;Yt++){const bt=O[Yt];let gt,St;switch(typeof bt){case"number":for(gt=bt;gt>0;)St=st(gt,"d"),q(St),typeof St!="object"&&(gt-=l(St));break;case"string":q(bt);break;case"object":gt=t.dlen(bt.d);let Lt=0;for(;Lt<gt;)switch(St=st(gt-Lt,"d"),typeof St){case"number":q({d:d(bt.d,Lt,Lt+St)}),Lt+=St;break;case"string":Lt+=n.strPosToUni(St);break;case"object":q(St)}break}}let Z;for(;Z=st(-1);)q(Z);return c(w)}const E=(C,O)=>{let w=0;for(let q=0;q<O.length&&C>w;q++){const st=O[q];switch(typeof st){case"number":{w+=st;break}case"string":const Z=n.strPosToUni(st);w+=Z,C+=Z;break;case"object":C-=Math.min(t.dlen(st.d),C-w);break}}return C},R=(C,O)=>typeof C=="number"?E(C,O):C.map(w=>E(w,O));function U(C,O,w){return r(C,(q,st)=>typeof q=="object"&&typeof q.d=="number"?{d:w.slice(O,st,st+q.d)}:q)}function D(C){return r(C,O=>{switch(typeof O){case"object":if(typeof O.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return O.d;case"string":return{d:O};case"number":return O}})}function et(C){return r(C,O=>typeof O=="object"&&typeof O.d=="string"?{d:n.strPosToUni(O.d)}:O)}function Et(C){let O=!0;return s(C,w=>{typeof w=="object"&&typeof w.d=="number"&&(O=!1)}),O}function _t(C){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:c,normalize:o,checkOp:e,create(O=""){if(typeof O!="string")throw Error("Initial data must be a string");return C.create(O)},apply(O,w){e(w);const q=C.builder(O);for(let st=0;st<w.length;st++){const Z=w[st];switch(typeof Z){case"number":q.skip(Z);break;case"string":q.append(Z);break;case"object":q.del(t.dlen(Z.d));break}}return q.build()},transform:f,compose:_,transformPosition:E,transformSelection:R,isInvertible:Et,makeInvertible(O,w){return U(O,w,C)},stripInvertible:et,invert:D,invertWithDoc(O,w){return D(U(O,w,C))},isNoop:O=>O.length===0}}t.default=_t}(hs)),hs}var An={},Ai;function Pl(){if(Ai)return An;Ai=1,Object.defineProperty(An,"__esModule",{value:!0});const t=ds(),n=cs();function e(s,r){return{get:s,getLength(){return s().length},insert(i,o,a){const l=n.strPosToUni(s(),i);return r([l,o],a)},remove(i,o,a){const l=n.strPosToUni(s(),i);return r([l,{d:o}],a)},_onOp(i){t.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const d=t.dlen(o.d);this.onRemove&&this.onRemove(l,d)}})},onInsert:null,onRemove:null}}return An.default=e,e.provides={text:!0},An}var bi;function kl(){return bi||(bi=1,function(t){var n=Bt&&Bt.__createBinding||(Object.create?function(f,_,E,R){R===void 0&&(R=E),Object.defineProperty(f,R,{enumerable:!0,get:function(){return _[E]}})}:function(f,_,E,R){R===void 0&&(R=E),f[R]=_[E]}),e=Bt&&Bt.__setModuleDefault||(Object.create?function(f,_){Object.defineProperty(f,"default",{enumerable:!0,value:_})}:function(f,_){f.default=_}),s=Bt&&Bt.__importStar||function(f){if(f&&f.__esModule)return f;var _={};if(f!=null)for(var E in f)Object.hasOwnProperty.call(f,E)&&n(_,f,E);return e(_,f),_},r=Bt&&Bt.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=cs(),o=s(ds()),a=r(Pl()),l={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const _=[];return{skip(E){let R=i.uniToStrPos(f,E);if(R>f.length)throw Error("The op is too long for this document");_.push(f.slice(0,R)),f=f.slice(R)},append(E){_.push(E)},del(E){f=f.slice(i.uniToStrPos(f,E))},build(){return _.join("")+f}}},slice:o.uniSlice},d=o.default(l),h=Object.assign(Object.assign({},d),{api:a.default});t.type=h,t.insert=(f,_)=>_.length===0?[]:f===0?[_]:[f,_],t.remove=(f,_)=>o.dlen(_)===0?[]:f===0?[{d:_}]:[f,{d:_}];var c=ds();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return c.default}})}(us)),us}(function(t){var n=Bt&&Bt.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const e=n(ss),s=n(is),r=as,i=ls;function o(m,p){if(!m)throw new Error(p)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:m=>m,isNoop:m=>m==null,setDebug(m){},registerSubtype:D,checkValidOp:st,normalize:Z,apply:Yt,transformPosition:bt,compose:gt,tryTransform:ws,transform:mc,makeInvertible:zt,invert:St,invertWithDoc:gc,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(m,p,A)=>wo(()=>!0,m,p,A),typeAllowingConflictsPred:m=>Object.assign(Object.assign({},t.type),{transform:(p,A,L)=>wo(m,p,A,L)})};const a=m=>m?m.getComponent():null;function l(m){return m&&typeof m=="object"&&!Array.isArray(m)}const d=m=>Array.isArray(m)?m.slice():m!==null&&typeof m=="object"?Object.assign({},m):m,h=m=>m&&(m.p!=null||m.r!==void 0),c=m=>m&&(m.d!=null||m.i!==void 0);function f(m,p){return o(m!=null),typeof p=="number"?(o(Array.isArray(m),"Invalid key - child is not an array"),(m=m.slice()).splice(p,1)):(o(l(m),"Invalid key - child is not an object"),delete(m=Object.assign({},m))[p]),m}function _(m,p,A){return typeof p=="number"?(o(m!=null,"Container is missing for key"),o(Array.isArray(m),"Cannot use numerical key for object container"),o(m.length>=p,"Cannot insert into out of bounds index"),m.splice(p,0,A)):(o(l(m),"Cannot insert into missing item"),o(m[p]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),m[p]=A),A}t.removeOp=(m,p=!0)=>r.writeCursor().writeAtPath(m,"r",p).get(),t.moveOp=(m,p)=>r.writeCursor().writeMove(m,p).get(),t.insertOp=(m,p)=>r.writeCursor().writeAtPath(m,"i",p).get(),t.replaceOp=(m,p,A)=>r.writeCursor().at(m,L=>{L.write("r",p),L.write("i",A)}).get(),t.editOp=(m,p,A,L=!1)=>r.writeCursor().at(m,b=>O(b,p,A,L)).get();const E=(m,p)=>m!=null&&(typeof p=="number"?Array.isArray(m):typeof m=="object"),R=(m,p)=>E(m,p)?m[p]:void 0,U={};function D(m){let p=m.type?m.type:m;p.name&&(U[p.name]=p),p.uri&&(U[p.uri]=p)}const et=m=>{const p=U[m];if(p)return p;throw Error("Missing type: "+m)};D(kl());const Et=(m,p)=>m+p;D({name:"number",apply:Et,compose:Et,invert:m=>-m,transform:m=>m});const _t=m=>m==null?null:m.et?et(m.et):m.es?U["text-unicode"]:m.ena!=null?U.number:null,C=m=>m.es?m.es:m.ena!=null?m.ena:m.e,O=(m,p,A,L=!1)=>{const[b,M]=typeof p=="string"?[et(p),p]:[p,p.name];!L&&b.isNoop&&b.isNoop(A)||(M==="number"?m.write("ena",A):M==="text-unicode"?m.write("es",A):(m.write("et",M),m.write("e",A)))};function w(m){o(typeof m=="number"),o(m>=0),o(m===(0|m))}function q(m){typeof m=="number"?w(m):o(typeof m=="string")}function st(m){if(m===null)return;const p=new Set,A=new Set,L=M=>{let j=!0,V=!1;for(let I in M){const N=M[I];if(j=!1,o(I==="p"||I==="r"||I==="d"||I==="i"||I==="e"||I==="es"||I==="ena"||I==="et","Invalid component item '"+I+"'"),I==="p")w(N),o(!p.has(N)),p.add(N),o(M.r===void 0);else if(I==="d")w(N),o(!A.has(N)),A.add(N),o(M.i===void 0);else if(I==="e"||I==="es"||I==="ena"){o(!V),V=!0;const v=_t(M);o(v,"Missing type in edit"),v.checkValidOp&&v.checkValidOp(C(M))}}o(!j)},b=(M,j,V)=>{if(!Array.isArray(M))throw Error("Op must be null or a list");if(M.length===0)throw Error("Empty descent");j||q(M[0]);let I=1,N=0,v=0;for(let T=0;T<M.length;T++){const x=M[T];if(o(x!=null),Array.isArray(x)){const K=b(x,!1);if(N){const S=typeof v,$=typeof K;S===$?o(v<K,"descent keys are not in order"):o(S==="number"&&$==="string")}v=K,N++,I=3}else typeof x=="object"?(o(I===1,`Prev not scalar - instead ${I}`),L(x),I=2):(o(I!==3),q(x),o(r.isValidPathItem(x),"Invalid path key"),I=1)}return o(N!==1,"Operation makes multiple descents. Remove some []"),o(I===2||I===3),M[0]};b(m,!0),o(p.size===A.size,"Mismatched picks and drops in op");for(let M=0;M<p.size;M++)o(p.has(M)),o(A.has(M))}function Z(m){let p=0,A=[];const L=r.writeCursor();return L.mergeTree(m,(b,M)=>{const j=_t(b);if(j){const I=C(b);O(M,j,j.normalize?j.normalize(I):I)}for(const I of["r","p","i","d"])if(b[I]!==void 0){const N=I==="p"||I==="d"?(V=b[I],A[V]==null&&(A[V]=p++),A[V]):b[I];M.write(I,N)}var V}),L.get()}function Yt(m,p){if(st(p),p===null)return m;const A=[];return function L(b,M){let j=b,V=0,I={root:b},N=0,v=I,T="root";function x(){for(;N<V;N++){let K=M[N];typeof K!="object"&&(o(E(v,T)),v=v[T]=d(v[T]),T=K)}}for(;V<M.length;V++){const K=M[V];if(Array.isArray(K)){const S=L(j,K);S!==j&&S!==void 0&&(x(),j=v[T]=S)}else if(typeof K=="object"){K.d!=null?(x(),j=_(v,T,A[K.d])):K.i!==void 0&&(x(),j=_(v,T,K.i));const S=_t(K);if(S)x(),j=v[T]=S.apply(j,C(K));else if(K.e!==void 0)throw Error("Subtype "+K.et+" undefined")}else j=R(j,K)}return I.root}(m=function L(b,M){const j=[];let V=0;for(;V<M.length;V++){const T=M[V];if(Array.isArray(T))break;typeof T!="object"&&(j.push(b),b=R(b,T))}for(let T=M.length-1;T>=V;T--)b=L(b,M[T]);for(--V;V>=0;V--){const T=M[V];if(typeof T!="object"){const x=j.pop();b=b===R(x,T)?x:b===void 0?f(x,T):(N=T,v=b,(I=d(I=x))[N]=v,I)}else h(T)&&(o(b!==void 0,"Cannot pick up or remove undefined"),T.p!=null&&(A[T.p]=b),b=void 0)}var I,N,v;return b}(m,p),p)}function bt(m,p){m=m.slice(),st(p);const A=r.readCursor(p);let L,b,M=!1;const j=[];for(let I=0;;I++){const N=m[I],v=A.getComponent();if(v&&(v.r!==void 0?M=!0:v.p!=null&&(M=!1,L=v.p,b=I)),I>=m.length)break;let T=0;const x=r.advancer(A,void 0,(S,$)=>{h($)&&T++});j.unshift(x);const K=x(N);if(typeof N=="number"&&(m[I]-=T),!K)break}if(j.forEach(I=>I.end()),M)return null;const V=()=>{let I=0;if(L!=null){const N=A.getPath();I=N.length,m=N.concat(m.slice(b))}for(;I<m.length;I++){const N=m[I],v=a(A),T=_t(v);if(T){const S=C(v);T.transformPosition&&(m[I]=T.transformPosition(m[I],S));break}let x=0;const K=r.advancer(A,(S,$)=>c($)?~(S-x):S-x,(S,$)=>{c($)&&x++})(N);if(typeof N=="number"&&(m[I]+=x),!K)break}};return L!=null?A.eachDrop(null,I=>{I===L&&V()}):V(),m}function gt(m,p){if(st(m),st(p),m==null)return p;if(p==null)return m;let A=0;const L=r.readCursor(m),b=r.readCursor(p),M=r.writeCursor(),j=[],V=[],I=[],N=[],v=[],T=[],x=new Set;L.traverse(null,S=>{S.p!=null&&(I[S.p]=L.clone())}),b.traverse(null,S=>{S.d!=null&&(N[S.d]=b.clone())});const K=r.writeCursor();return function S($,mt,ut,J,Ct,ue,Ht,Dt){o(mt||ut);const pt=a(mt),Xt=a(ut),Qt=!!Xt&&Xt.r!==void 0,Te=!!pt&&pt.i!==void 0,qt=pt?pt.d:null,Vt=Xt?Xt.p:null,ce=(ue||Qt)&&Vt==null;if(Vt!=null)J=N[Vt],Ht=V[Vt]=new r.WriteCursor;else if(Xt&&Xt.r!==void 0)J=null;else{const P=a(J);P&&P.d!=null&&(J=null)}const at=a(J);if(qt!=null)if($=I[qt],Dt=j[qt]=new r.WriteCursor,ce)ue&&!Qt&&Dt.write("r",!0);else{const P=v[qt]=A++;Ht.write("d",P)}else if(pt&&pt.i!==void 0)$=null;else{const P=a($);P&&P.p!=null&&($=null)}let H;Te?(o(Ct===void 0),H=pt.i):H=Ct;const z=(Vt==null?!Te||ue||Qt:H===void 0)?null:Ht.getComponent();if(Vt!=null){if(!(Ct!==void 0||Te)){const P=qt!=null?v[qt]:A++;T[Vt]=P,Dt.write("p",P)}}else Qt&&(Te||Ct!==void 0||(Xt.r,Dt.write("r",Xt.r)));const F=ce?null:_t(pt),y=_t(at);if((F||y)&&(F&&F.name,y&&y.name),F&&y){o(F===y);const P=C(pt),X=C(at),Tt=F.compose(P,X);O(Ht,F,Tt),x.add(at)}else F?O(Ht,F,C(pt)):y&&(O(Ht,y,C(at)),x.add(at));const W=typeof H=="object"&&H!=null;let rt=!1,it=0,lt=0,wt=0,vt=0,It=0;const Pt=r.advancer(J,(P,X)=>c(X)?vt-P-1:P-vt,(P,X)=>{c(X)&&vt++}),nt=r.advancer($,(P,X)=>h(X)?it-P-1:P-it,(P,X)=>{h(X)&&it++});if(r.eachChildOf(mt,ut,(P,X,Tt)=>{let Ft,he,Me=P,te=P,rn=P;if(typeof P=="number"){let yt=P+wt;he=Pt(yt),te=yt+vt;let Ot=P+lt;Ft=nt(Ot),c(a(he))&&(Ft=null),Me=Ot+it,rn=P+It,o(Me>=0,"p1PickKey is negative"),o(te>=0,"p2DropKey is negative");const ee=c(a(X)),de=h(a(Tt));(ee||de&&!ce)&&It--,ee&&lt--,de&&wt--}else Ft=nt(P),he=Pt(P);Dt.descend(Me),Ht.descend(te);const We=W&&!c(a(X))?H[rn]:void 0,re=S(Ft,X,Tt,he,We,ce,Ht,Dt);var ie,G,Rt;W&&!ce?We!==re&&(rt||(H=Array.isArray(H)?H.slice():Object.assign({},H),rt=!0),ie=H,Rt=re,typeof(G=rn)=="number"?(o(Array.isArray(ie)),o(G<ie.length)):(o(!Array.isArray(ie)),o(ie[G]!==void 0)),Rt===void 0?typeof G=="number"?ie.splice(G,1):delete ie[G]:ie[G]=Rt):o(re===void 0),Ht.ascend(),Dt.ascend()}),nt.end(),Pt.end(),z!=null)z.i=H;else if(!ue&&!Qt&&Vt==null)return H}(L,L.clone(),b,b.clone(),void 0,!1,M,K),M.reset(),M.mergeTree(K.get()),M.reset(),M.get(),j.map(S=>S.get()),V.map(S=>S.get()),L.traverse(M,(S,$)=>{const mt=S.p;if(mt!=null){const ut=v[mt];ut!=null&&$.write("p",ut);const J=j[mt];J&&J.get(),J&&$.mergeTree(J.get())}else S.r!==void 0&&$.write("r",S.r)}),M.reset(),M.get(),b.traverse(M,(S,$)=>{const mt=S.d;if(mt!=null){const J=T[mt];J!=null&&$.write("d",J);const Ct=V[mt];Ct&&$.mergeTree(Ct.get())}else S.i!==void 0&&$.write("i",S.i);const ut=_t(S);ut&&!x.has(S)&&O($,ut,C(S))}),M.get()}function St(m){if(m==null)return null;const p=new r.ReadCursor(m),A=new r.WriteCursor;let L;const b=[],M=[];return function j(V,I,N){const v=V.getComponent();let T,x=!1;if(v){v.p!=null&&(I.write("d",v.p),b[v.p]=V.clone()),v.r!==void 0&&I.write("i",v.r),v.d!=null&&(I.write("p",v.d),N=void 0),v.i!==void 0&&(N=T=v.i);const S=_t(v);S&&(N===void 0?(L||(L=new Set),L.add(v)):(C(v),N=S.apply(N,C(v)),x=!0))}let K=0;for(const S of V){I.descend(S);const $=typeof S=="number"?S-K:S,mt=R(N,$);c(V.getComponent())&&K++;const ut=j(V,I,mt);if(N!==void 0&&ut!==void 0){if(x||(x=!0,N=d(N)),!E(N,$))throw Error("Cannot modify child - invalid operation");N[$]=ut}I.ascend()}if(T===void 0)return x?N:void 0;I.write("r",N)}(p,A,void 0),L&&(A.reset(),function j(V,I,N){const v=I.getComponent();if(v){const S=v.d;if(S!=null&&(V=b[S],N=M[S]=r.writeCursor()),L.has(v)){const $=_t(v);if(!$.invert)throw Error(`Cannot invert subtype ${$.name}`);O(N,$,$.invert(C(v)))}}let T=0,x=0;const K=r.advancer(V,(S,$)=>h($)?T-S-1:S-T,(S,$)=>{h($)&&T++});for(const S of I)if(typeof S=="number"){const $=S-x,mt=K($),ut=$+T;N.descend(ut),j(mt,I,N),c(I.getComponent())&&x++,N.ascend()}else N.descend(S),j(K(S),I,N),N.ascend();K.end()}(p.clone(),p,A),M.length&&(A.reset(),p.traverse(A,(j,V)=>{const I=j.p;if(I!=null){const N=M[I];N&&N.get(),N&&V.mergeTree(N.get())}}))),A.get()}const Lt=(m,p)=>m.some(A=>typeof A=="object"&&(Array.isArray(A)?Lt(A,p):p(A)));function zt(m,p){if(m==null||!Lt(m,I=>{var N;return I.r!==void 0||((N=_t(I))===null||N===void 0?void 0:N.makeInvertible)!=null}))return m;const A=new r.ReadCursor(m),L=new r.WriteCursor;let b=!1;const M=[],j=[],V=(I,N,v)=>{const T=I.getComponent();let x=!1;if(T){T.d!=null&&N.write("d",T.d),T.i!==void 0&&N.write("i",T.i);const S=T.p;if(S!=null&&(M[S]=I.clone(),o(v!==void 0,"Operation picks up at an invalid key"),j[S]=v,N.write("p",T.p)),T.r!==void 0&&v===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const $=_t(T);$&&($.makeInvertible?b=!0:O(N,$,C(T),!0))}let K=0;for(const S of I){N.descend(S);const $=typeof S=="number"?S-K:S,mt=R(v,$),ut=V(I,N,mt);mt!==ut&&(x||(x=!0,v=d(v)),ut===void 0?(v=f(v,$),typeof S=="number"&&K++):v[$]=ut),N.ascend()}return T&&(T.r!==void 0?(N.write("r",s.default(v)),v=void 0):T.p!=null&&(v=void 0)),v};return V(A,L,p),L.get(),b&&(L.reset(),function I(N,v,T,x,K){const S=v.getComponent();if(S){S.i!==void 0?(x=S.i,K=!0):S.d!=null&&(x=j[S.d],N=M[S.d],K=!1,S.d);let J=_t(S);if(J&&J.makeInvertible){const Ct=C(S);O(T,J,J.makeInvertible(Ct,x),!0)}}let $=0,mt=0;const ut=r.advancer(N,(J,Ct)=>h(Ct)?$-J-1:J-$,(J,Ct)=>{h(Ct)&&$++});for(const J of v)if(typeof J=="number"){const Ct=J-mt,ue=ut(Ct),Ht=Ct+$,Dt=R(x,K?Ct:Ht);T.descend(J),I(ue,v,T,Dt,K),c(v.getComponent())&&mt++,T.ascend()}else{const Ct=R(x,J);T.descend(J),I(ut(J),v,T,Ct,K),T.ascend()}ut.end()}(A.clone(),A,L,p,!1)),L.get()}function gc(m,p){return St(zt(m,p))}const vs=m=>{if(m==null)return null;const p=m.slice();for(let A=0;A<m.length;A++){const L=p[A];Array.isArray(L)&&(p[A]=vs(L))}return p};function ws(m,p,A){o(A==="left"||A==="right","Direction must be left or right");const L=A==="left"?0:1;if(p==null)return{ok:!0,result:m};st(m),st(p);let b=null;const M=[],j=[],V=[],I=[],N=[],v=[],T=[],x=[],K=[],S=[],$=[],mt=[],ut=[],J=[],Ct=[];let ue=0;const Ht=r.readCursor(m),Dt=r.readCursor(p),pt=r.writeCursor();if(function at(H,z=null,F){const y=a(z);y&&(y.r!==void 0?F=z.clone():y.p!=null&&(F=null,v[y.p]=H.clone()));const W=H.getComponent();let rt;W&&(rt=W.p)!=null&&(N[rt]=z?z.clone():null,V[rt]=H.clone(),F&&(S[rt]=!0,K[rt]=F),y&&y.p!=null&&(J[rt]=y.p));const it=r.advancer(z);for(const lt of H)at(H,it(lt),F);it.end()}(Dt,Ht,null),function at(H,z,F,y,W){const rt=F.getComponent();let it,lt=!1;rt&&((it=rt.d)!=null?(I[it]=F.clone(),y!=null&&(Ct[y]==null&&(Ct[y]=[]),Ct[y].push(it)),H=N[it]||null,z=V[it]||null,S[it]?(W&&($[it]=!0),W=K[it]||null):!W||L!==1&&J[it]!=null||b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.moveOp(z.getPath(),F.getPath())}),lt=!0):rt.i!==void 0&&(H=z=null,lt=!0,W&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.insertOp(F.getPath(),rt.i)})));const wt=a(H);wt&&(wt.r!==void 0?W=H.clone():wt.p!=null&&(wt.p,y=wt.p,W=null));const vt=_t(rt);vt&&W&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(W.getPath()),op2:t.editOp(F.getPath(),vt,C(rt),!0)});let It=0,Pt=0;const nt=r.advancer(z,(X,Tt)=>h(Tt)?It-X-1:X-It,(X,Tt)=>{h(Tt)&&It++}),P=r.advancer(H);for(const X of F)if(typeof X=="number"){const Tt=X-Pt,Ft=nt(Tt);Pt+=+at(P(Tt+It),Ft,F,y,W)}else{const Tt=nt(X);at(P(X),Tt,F,y,W)}return nt.end(),P.end(),lt}(Ht,Dt,Dt.clone(),null,null),I.map(at=>at&&at.get()),b)return{ok:!1,conflict:b};$.map(at=>!!at);const Xt=[];let Qt=null;(function at(H,z,F,y,W){let rt=!1;const it=a(z);if(h(it)){const nt=it.p;nt!=null?(F=I[nt],y=mt[nt]=r.writeCursor(),rt=!0,W=null):(F=null,W=z.clone())}else c(a(F))&&(F=null);const lt=H.getComponent();if(lt){const nt=lt.p;nt!=null?(W&&(x[nt]=W),Xt[nt]=W||L===1&&rt?null:y.getComponent(),M[nt]=H.clone(),F&&(T[nt]=F.clone())):lt.r!==void 0&&(W||y.write("r",!0),(W||rt)&&(Qt==null&&(Qt=new Set),Qt.add(lt)))}let wt=0,vt=0;const It=r.advancer(z,void 0,(nt,P)=>{h(P)&&wt++}),Pt=r.advancer(F,(nt,P)=>c(P)?~(nt-vt):nt-vt,(nt,P)=>{c(P)&&vt++});if(H)for(const nt of H)if(typeof nt=="string"){const P=It(nt),X=Pt(nt);y.descend(nt),at(H,P,X,y,W),y.ascend()}else{const P=It(nt),X=nt-wt,Tt=h(a(P))?null:Pt(X),Ft=X+vt;o(Ft>=0),y.descend(Ft),at(H,P,Tt,y,W),y.ascend()}It.end(),Pt.end()})(Ht,Dt,Dt.clone(),pt,null),pt.reset();let Te=[];if(function at(H,z,F,y,W,rt){o(z);const it=z.getComponent();let lt=a(y),wt=!1;const vt=(G,Rt,yt)=>G?t.moveOp(G.getPath(),Rt.getPath()):t.insertOp(Rt.getPath(),yt.i);if(c(it)){const G=it.d;G!=null&&(j[G]=z.clone());const Rt=G!=null?Xt[G]:null;let yt=!1;if(it.i!==void 0||G!=null&&Rt){let Ot;lt&&(lt.i!==void 0||(Ot=lt.d)!=null&&!S[Ot])&&(yt=Ot!=null?G!=null&&G===J[Ot]:e.default(lt.i,it.i),yt||Ot!=null&&L!==1&&J[Ot]!=null||b==null&&(b={type:i.ConflictType.DROP_COLLISION,op1:vt(G!=null?M[G]:null,z,it),op2:vt(Ot!=null?V[Ot]:null,y,lt)})),yt||(rt?b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:vt(G!=null?M[G]:null,z,it),op2:t.removeOp(rt.getPath())}):(G!=null?(Te[ue]=G,W.write("d",Rt.p=ue++)):W.write("i",s.default(it.i)),wt=!0))}else if(G!=null&&!Rt){const Ot=x[G];Ot&&(rt=Ot.clone())}G!=null?(H=M[G],F=v[G],y=T[G]):it.i!==void 0&&(H=F=null,yt||(y=null))}else h(a(H))&&(H=F=y=null);const It=a(H),Pt=a(F);if(h(Pt)){const G=Pt.p;Pt.r!==void 0&&(!It||It.r===void 0)||S[G]?(y=null,rt=F.clone()):G!=null&&(y=I[G],L!==1&&J[G]!=null||((W=ut[G])||(W=ut[G]=r.writeCursor()),W.reset(),rt=null))}else!c(it)&&c(lt)&&(y=null);lt=y!=null?y.getComponent():null;const nt=_t(it);if(nt){const G=C(it);if(rt)b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(z.getPath(),nt,G,!0),op2:t.removeOp(rt.getPath())});else{const Rt=_t(lt);let yt;if(Rt){if(nt!==Rt)throw Error("Transforming incompatible types");const Ot=C(lt);yt=nt.transform(G,Ot,A)}else yt=s.default(G);O(W,nt,yt)}}let P=0,X=0,Tt=0,Ft=0,he=0,Me=0,te=H!=null&&H.descendFirst(),rn=te;const We=r.advancer(F,void 0,(G,Rt)=>{h(Rt)&&Tt++});let re=y!=null&&y.descendFirst(),ie=re;for(const G of z)if(typeof G=="number"){let Rt;const yt=c(z.getComponent()),Ot=G-X;{let pe;for(;te&&typeof(pe=H.getKey())=="number";){pe+=P;const ne=H.getComponent(),Be=h(ne);if(pe>Ot||pe===Ot&&(!Be||L===0&&yt))break;if(Be){P--;const Ue=ne.p;J.includes(Ue),ne.d,a(ut[ne.d]),h(a(ut[ne.d])),(ne.r===void 0||Qt&&Qt.has(ne))&&(Ue==null||!Xt[Ue]||L!==1&&J.includes(Ue))||he--}te=H.nextSibling()}Rt=te&&pe===Ot?H:null}const ee=Ot-P;let de=We(ee);const Ts=ee-Tt;let kn=null;{let pe,ne;for(;re&&typeof(pe=y.getKey())=="number";){ne=pe-Ft;const Be=y.getComponent(),Ue=c(Be);if(ne>Ts)break;if(ne===Ts){if(!Ue){kn=y;break}{if(L===0&&yt){kn=y;break}const Le=de&&h(de.getComponent());if(L===0&&Le)break}}if(Ue){const Le=Be.d;J[Le],Be.i===void 0&&(S[Le]||J[Le]!=null&&L!==1)?(S[Le]||J[Le]!=null&&L===0)&&(Ft++,Me--):Ft++}re=y.nextSibling()}}const To=Ts+Ft+he+Me;o(To>=0,"trying to descend to a negative index"),W.descend(To),yt&&(Rt=de=kn=null,X++),at(Rt,z,de,kn,W,rt)&&Me++,W.ascend()}else{let Rt;for(;te&&(Rt=H.getKey(),typeof Rt!="string"||!(Rt>G||Rt===G));)te=H.nextSibling();const yt=te&&Rt===G?H:null,Ot=We(G);let ee;for(;re&&(ee=y.getKey(),typeof ee!="string"||!(ee>G||ee===G));)re=y.nextSibling();const de=re&&ee===G?y:null;W.descend(G),at(yt,z,Ot,de,W,rt),W.ascend()}return We.end(),rn&&H.ascend(),ie&&y.ascend(),wt}(Ht,Ht.clone(),Dt,Dt.clone(),pt,null),b)return{ok:!1,conflict:b};pt.reset();const qt=(at,H,z)=>at.traverse(H,(F,y)=>{F.d!=null&&z(F.d,at,y)});(S.length||mt.length)&&(qt(Dt,pt,(at,H,z)=>{S[at]&&!$[at]&&z.write("r",!0),mt[at]&&z.mergeTree(mt[at].get())}),pt.reset());const Vt=[],ce=[];if((ut.length||S.length)&&!b){const at=r.readCursor(vs(pt.get()));if(qt(at,null,(H,z)=>{Vt[H]=z.clone()}),ut.forEach(H=>{H&&qt(r.readCursor(H.get()),null,(z,F)=>{Vt[z]=F.clone()})}),function H(z,F,y,W,rt,it){const lt=a(F);if(lt&&h(lt))if(lt.p!=null){const P=lt.p;Vt[P].getPath(),y=Vt[P],W=ce[P]=r.writeCursor()}else lt.r!==void 0&&(y=null);else c(a(y))&&(y=null);const wt=z.getComponent();if(wt){let P;if((P=wt.d)!=null){const X=ut[P];X&&(X.get(),W.mergeTree(X.get()),y=r.readCursor(X.get()))}}let vt=0,It=0;const Pt=r.advancer(F,void 0,(P,X)=>{h(X)&&vt--}),nt=r.advancer(y,(P,X)=>c(X)?-(P-It)-1:P-It,(P,X)=>{c(X)&&It++});for(const P of z)if(typeof P=="number"){const X=Pt(P),Tt=P+vt,Ft=nt(Tt),he=Tt+It;W.descend(he),H(z,X,Ft,W),W.ascend()}else W.descend(P),H(z,Pt(P),nt(P),W),W.ascend();Pt.end(),nt.end()}(Dt,at,at.clone(),pt),pt.reset(),b)return{ok:!1,conflict:b};if(pt.get(),ce.length){const H=ce.map(F=>F?F.get():null),z=r.readCursor(vs(pt.get()));if(qt(z,pt,(F,y,W)=>{const rt=H[F];rt&&(W.mergeTree(rt),H[F]=null)}),H.find(F=>F)){const F=r.writeCursor(),y=r.writeCursor();let W=0,rt=0;H.forEach(it=>{it!=null&&qt(r.readCursor(it),null,lt=>{const wt=Te[lt];F.writeMove(M[wt].getPath(),j[wt].getPath(),W++);const vt=Ct[wt];vt&&vt.forEach(It=>{S[It]||L!==1&&J[It]!=null||y.writeMove(V[It].getPath(),I[It].getPath(),rt++)})})}),b={type:i.ConflictType.BLACKHOLE,op1:F.get(),op2:y.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:pt.get()}}const vo=m=>{const p=new Error("Transform detected write conflict");throw p.conflict=m,p.type=p.name="writeConflict",p};function mc(m,p,A){const L=ws(m,p,A);if(L.ok)return L.result;vo(L.conflict)}const $e=m=>{const p=r.writeCursor();return r.readCursor(m).traverse(p,(A,L)=>{(c(A)||_t(A))&&L.write("r",!0)}),p.get()},Ec=(m,p)=>{const{type:A,op1:L,op2:b}=m;switch(A){case i.ConflictType.DROP_COLLISION:return p==="left"?[null,$e(b)]:[$e(L),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let M=!1;return r.readCursor(L).traverse(null,j=>{j.r!==void 0&&(M=!0)}),M?[null,$e(b)]:[$e(L),null];case i.ConflictType.BLACKHOLE:return[$e(L),$e(b)];default:throw Error("Unrecognised conflict: "+A)}};function wo(m,p,A,L){let b=null;for(;;){const M=ws(p,A,L);if(M.ok)return gt(b,M.result);{const{conflict:j}=M;m(j)||vo(j);const[V,I]=Ec(j,L);p=gt(Z(p),V),A=gt(Z(A),I),b=gt(b,I)}}}})(Si),function(t){var n=Bt&&Bt.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),e=Bt&&Bt.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&n(o,i,a)};Object.defineProperty(t,"__esModule",{value:!0}),e(Si,t);var s=as;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=ls;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})}(Gt);const Hl=Mo({__proto__:null,default:Ll(Gt)},[Gt]);var tt=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(tt||{});class fs{constructor(n){g(this,"_index",0);g(this,"_offset",0);this._actions=n}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(n){n||(n=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const s=this._offset,r=e.len;return n>=r-s?(n=r-s,this._index+=1,this._offset=0):this._offset+=n,e.t===tt.DELETE||e.t===tt.RETAIN&&e.body==null?k.deepClone({...e,len:n}):k.deepClone({...e,len:n,body:qe(e.body,s,s+n)})}else return{t:tt.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:tt.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,e=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=n,this._index=e,[s].concat(r)}}else return[]}}class vi{constructor(){g(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function wi(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=di(t,n,e),a=fi(t,n,e),l=_i(t,n,e),d=gi(t,n,e),h=mi(t,n,e),c=Ei(t,n,e),f=Ri(t,n,e);let _="";return s&&(t.dataStream=yr(s,r,i),_=s.slice(r,i)),{dataStream:_,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:d,tables:h,customRanges:c,customDecorations:f}}function Ti(t,n,e,s){t.dataStream=Dr(t.dataStream,s,n.dataStream),ai(t,n,e,s),ts(t,n,e,s),Rl(t,n,e,s),li(t,n,e,s),ui(t,n,e,s),ci(t,n,e,s),hi(t,n,e,s)}function Fl(t,n,e,s,r=kt.COVER){return Il(t,n,e,s,r)}function $l(t,n,e){return n<=0?{dataStream:""}:wi(t,n,e)}function Wl(t,n,e,s){e!==0&&Ti(t,n,e,s)}function Bl(t,n){const e=new vi;return e.reset(),n.forEach(s=>{switch(s=k.deepClone(s),s.t){case tt.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Fl(t,i,o,e.cursor,r),e.moveCursor(o);break}case tt.INSERT:{const{body:r,len:i}=s;Wl(t,r,i,e.cursor),e.moveCursor(i);break}case tt.DELETE:{const{len:r}=s;$l(t,r,e.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function Mi(t){return Object.keys(t).length===1}const sn=class sn{constructor(){g(this,"_actions",[])}static apply(n,e){return Bl(n,e)}static compose(n,e){const s=new fs(n),r=new fs(e),i=new sn;for(;s.hasNext()||r.hasNext();)if(r.peekType()===tt.INSERT)i.push(r.next());else if(s.peekType()===tt.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===tt.INSERT&&l.t===tt.RETAIN?l.body==null?i.push(a):i.push({...a,body:ns(a.body,l.body,l.coverType)}):a.t===tt.RETAIN&&l.t===tt.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:ns(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===tt.RETAIN&&l.t===tt.DELETE?i.push(l):a.t===tt.INSERT&&(l.t,tt.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(n,e,s){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const e=[];for(const s of n)if(s.t===tt.INSERT)e.push({t:tt.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===tt.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");e.push({t:tt.INSERT,body:s.body,len:s.len,line:0,segmentId:s.segmentId})}else if(s.body!=null){if(s.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");e.push({t:tt.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:kt.REPLACE,segmentId:s.segmentId})}else e.push(s);return e}static makeInvertible(n,e){const s=[];let r=0;for(const i of n){if(i.t===tt.DELETE&&i.body==null){const o=qe(e,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===tt.RETAIN&&i.body!=null){const o=qe(e,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==tt.INSERT&&(r+=i.len)}return s}insert(n,e,s=""){const r={t:tt.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:tt.RETAIN,len:n,segmentId:e};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(n,e=""){const s={t:tt.DELETE,len:n,line:0,segmentId:e};return this.push(s),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...n){if(n.length>1){for(const i of n)this.push(i);return this}let e=this._actions.length,s=this._actions[e-1];const r=k.deepClone(n[0]);if(r.t===tt.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===tt.DELETE&&r.t===tt.DELETE)return s.len+=r.len,this;if(s.t===tt.DELETE&&r.t===tt.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===tt.RETAIN&&r.t===tt.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===tt.INSERT&&Mi(s.body)&&r.t===tt.INSERT&&Mi(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===tt.RETAIN&&Ml(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};g(sn,"id","text-x"),g(sn,"uri","https://github.com/dream-num/univer#text-x");let Re=sn;Object.defineProperty(Re,"name",{value:"text-x"});const Fe=class Fe{static registerSubtype(n){var e;this._subTypes.has(n.name)&&((e=this._subTypes.get(n.name))==null?void 0:e.id)!==Re.id||(this._subTypes.set(n.name,n),Gt.type.registerSubtype(n))}static apply(n,e){if(!Gt.type.isNoop(e))return Gt.type.apply(n,e)}static compose(n,e){return Gt.type.compose(n,e)}static transform(n,e,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,e){return Gt.type.invertWithDoc(n,e)}static isNoop(n){return Gt.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new Fe),this._instance}removeOp(n,e){return Gt.removeOp(n,e)}moveOp(n,e){return Gt.moveOp(n,e)}insertOp(n,e){return Gt.insertOp(n,e)}replaceOp(n,e,s){return Gt.replaceOp(n,e,s)}editOp(n,e=["body"]){return Gt.editOp(e,Re.name,n)}};g(Fe,"uri","https://github.com/dream-num/univer#json-x"),g(Fe,"_subTypes",new Map),g(Fe,"_instance",null);let ve=Fe;ve.registerSubtype(Re);const _s={id:"default_doc",documentStyle:{}};class Gl extends On{constructor(e){super();g(this,"type",Q.UNIVER_DOC);g(this,"snapshot");this.snapshot={..._s,...e}}getUnitId(){throw new Error("Method not implemented.")}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,s){this.snapshot.drawings=e,this.snapshot.drawingsOrder=s}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:s,l:r,b:i,r:o}=e,{documentStyle:a}=this.snapshot;s!=null&&(a.marginTop=s),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(e,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:e,height:s};return}e!==void 0&&(r.pageSize.width=e),s!==void 0&&(r.pageSize.height=s)}updateDrawing(e,s){const{drawings:r}=this,{width:i,height:o,left:a,top:l}=s,d=r==null?void 0:r[e];if(!d)return;const h=d.docTransform;h.size.width=i,h.size.height=o,h.positionH.posOffset=a,h.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class we extends Gl{constructor(e){var r;super(k.isEmptyObject(e)?Ul():e);g(this,"_unitId");g(this,"headerModelMap",new Map);g(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:k.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()})}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}getRev(){var e;return(e=this.snapshot.rev)!=null?e:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={..._s,...e},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!ve.isNoop(e))return this.snapshot=ve.apply(this.snapshot,e),e!=null&&e.some(s=>Array.isArray(s)&&((s==null?void 0:s[0])==="headers"||(s==null?void 0:s[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(e,s,r=es.copy){const i=this.getBody();if(i!=null)return qe(i,e,s,!1,r)}_initializeHeaderFooterModel(){const{headers:e,footers:s}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new we(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new we(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const Ui=ct.createIdentifier("univer.config-service");class Li{constructor(){g(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,e){this._config.set(n,e)}deleteConfig(n){this._config.delete(n)}}class Di extends Mt{constructor(){super(...arguments);g(this,"_error$",new B.Subject);g(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}class yi{constructor(n={}){g(this,"_styles");g(this,"_cacheMap",new xr(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const s=this._getExistingStyleId(n);return s||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,e){const s=k.generateRandomId(6);return this._styles[s]=n,this._cacheMap.set(e,s),s}setValue(n){if(n==null)return;const e=JSON.stringify(n),s=this.search(n,e);return s!=="-1"?s:this.add(n,e)}toJSON(){return this._styles}getStyleByCell(n){let e;n&&k.isObject(n.s)?e=n.s:e=(n==null?void 0:n.s)&&this.get(n.s);const s=n==null?void 0:n.interceptorStyle;return s?{...e,...s}:e}_generateCacheMap(){const{_styles:n,_cacheMap:e}=this;for(const s in n){const r=JSON.stringify(n[s]);e.set(r,s)}}_getExistingStyleId(n){const{_styles:e}=this;for(const s in e)if(k.diffValue(e[s],n))return s;return null}}class Vl{constructor(n,e){g(this,"_columnData",{});this._config=n,this._columnData=e}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:e}=this,s=e[n];return s?s.hd!==Y.TRUE:!0}getHiddenCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:ot.COLUMN}),s}getVisibleCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,s.push({rangeType:ot.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:ot.COLUMN}),s}getColumnDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return ge(this._columnData)}getColumnWidth(n){const{_columnData:e}=this,s=this._config;let r=0;return r=(e[n]||{hd:Y.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(n){const e=this._columnData[n];if(e)return e}getColumnOrCreate(n){const{_columnData:e}=this,s=this._config,r=e[n];if(r)return r;const i={w:s.defaultColumnWidth,hd:Y.FALSE};return this._columnData[n]=i,i}}class xl{constructor(n,e,s){g(this,"_rowData");this._config=n,this._viewModel=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(n,e=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=s[o+n]||{hd:Y.FALSE,h:r.defaultRowHeight},{ia:l,ah:d,h=r.defaultRowHeight}=a;i+=(l==null||l===Y.TRUE)&&typeof d=="number"?d:h}return i}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:e}=this,s=e[n];if(s)return s;const r=this._config,i={hd:Y.FALSE,h:r.defaultRowHeight};return e[n]=i,i}getHiddenRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getVisibleRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ot.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:ot.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==Y.TRUE:!0}getSize(){return ge(this._rowData)}}const jl="DEFAULT_WORKSHEET_ROW_COUNT",Pi=1e3,Kl="DEFAULT_WORKSHEET_COLUMN_COUNT",ki=20,Yl="DEFAULT_WORKSHEET_ROW_HEIGHT",Hi=24,zl="DEFAULT_WORKSHEET_COLUMN_WIDTH",Fi=88,Xl="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",$i=46,ql="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Wi=20;function Bi(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:Y.FALSE,rowCount:Pi,columnCount:ki,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Fi,defaultRowHeight:Hi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:Y.TRUE,rowHeader:{width:$i,hidden:Y.FALSE},columnHeader:{height:Wi,hidden:Y.FALSE},selections:["A1"],rightToLeft:Y.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class Gi extends Mt{constructor(e){super();g(this,"_cellContentInterceptor",null);g(this,"_rowFilteredInterceptor",null);this.getRawCell=e}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,s):this.getRawCell(e,s)}getRowFiltered(e){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(e))!=null?r:!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=e,At(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,At(()=>this._rowFilteredInterceptor=null)}}class Ze{constructor(n,e,s){g(this,"_sheetId");g(this,"_snapshot");g(this,"_cellData");g(this,"_rowManager");g(this,"_columnManager");g(this,"_viewModel");var a;this.unitId=n,this._styles=s,this._snapshot=Bi(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:k.generateRandomId(6),this._cellData=new Jt(o),this._viewModel=new Gi((l,d)=>this.getCellRaw(l,d)),this._rowManager=new xl(this._snapshot,this._viewModel,i),this._columnManager=new Vl(this._snapshot,r)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),e=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return n.forEach((d,h)=>{Object.keys(h).forEach(c=>{const f=+c,_=n.getValue(d,f),E=_!=null&&_.s?this._styles.get(_.s):null,R=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(_&&(_.v||_.p)||E!=null&&E.bg||R)&&(a?s=Math.min(s,d):(s=d,a=!0),r=Math.max(r,d),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),e.forEach(d=>{a?s=Math.min(s,d.startRow):(s=d.startRow,a=!0),r=Math.max(r,d.endRow),l?i=Math.min(i,d.startColumn):(i=d.startColumn,a=!0),o=Math.max(o,d.endColumn)}),!a||!l?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,e=k.deepClone(n);return new Ze(this.unitId,e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,e){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(me.intersects({startRow:n,startColumn:e,endRow:n,endColumn:e},i))return i}return null}getCell(n,e){return n<0||e<0?null:this._viewModel.getCell(n,e)}getCellRaw(n,e){return this.getCellMatrix().getValue(n,e)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,e,s,r,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(d=>me.intersects({startRow:n,startColumn:e,endRow:s,endColumn:r},d)),l=new Jt;return zn(n,s,e,r).forEach((d,h)=>{const c=i?this.getCellRaw(d,h):this.getCell(d,h);c&&l.setValue(d,h,c)}),a.forEach(d=>{const{startColumn:h,startRow:c,endColumn:f,endRow:_}=d;zn(c,_,h,f).forEach((E,R)=>{E===c&&R===h&&l.setValue(E,R,{...o.getValue(E,R),rowSpan:_-c+1,colSpan:f-h+1}),(E!==c||R!==h)&&l.realDeleteValue(E,R)})}),l}getRange(n,e,s,r){return typeof n=="object"?new ke(this,n,{getStyles:()=>this._styles}):new ke(this,{startRow:n,startColumn:e,endColumn:r||e,endRow:s||n},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:n}=this,{columnCount:e}=n;return e}getMaxRows(){const{_snapshot:n}=this,{rowCount:e}=n;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(n){this._snapshot.rowCount=n}getColumnCount(){return this._snapshot.columnCount}setColumnCount(n){this._snapshot.columnCount=n}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:n}=this,{showGridlines:e}=n;return e===0}getTabColor(){const{_snapshot:n}=this,{tabColor:e}=n;return e}getColumnWidth(n){return this.getColumnManager().getColumnWidth(n)}getRowHeight(n){return this._viewModel.getRowFiltered(n)?0:this.getRowManager().getRowHeight(n)}getRowVisible(n){return this._viewModel.getRowFiltered(n)?!1:this.getRowRawVisible(n)}getRowRawVisible(n){return this.getRowManager().getRowRawVisible(n)}getHiddenRows(n,e){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(n,e);return r.forEach(i=>i.endColumn=s),r}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,e){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(n,e);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const n=this.getRowCount();return this._rowManager.getVisibleRows(0,n-1)}getVisibleCols(){const n=this.getColumnCount();return this._columnManager.getVisibleCols(0,n-1)}isRightToLeft(){const{_snapshot:n}=this,{rightToLeft:e}=n;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(n){return n&&(n.v!==void 0||n.f!==void 0||n.p!==void 0)}iterateByRow(n,e=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n,a=this;return{[Symbol.iterator]:()=>{let l=s,d=r;return{next(){for(;;){if(d>o&&(l+=1,d=r),l>i)return{done:!0,value:void 0};const h=a.getCell(l,d),c=!h,f=a.getMergedCell(l,d);if(f){if(l!==f.startRow||d!==f.startColumn){d=f.endColumn+1;continue}if(c&&e){d=f.endColumn+1;continue}const E={row:l,col:d,value:h};return E.colSpan=f.endColumn-f.startColumn+1,E.rowSpan=f.endRow-f.startRow+1,d=f.endColumn+1,{done:!1,value:E}}if(c&&e)d+=1;else{const _={row:l,col:d,value:h};return d+=1,{done:!1,value:_}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let d=r,h=i;return{next(){for(;;){if(d>o&&(h+=1,d=r),h>a)return{done:!0,value:void 0};const c=l.getMergedCell(d,h);if(c){const E=d!==c.startRow,R=E||h!==c.startColumn;if(s&&R||!s&&E){d=c.endRow+1;continue}const U=l.getCell(c.startRow,c.startColumn);if(!U&&e){d=c.endRow+1;continue}const et={row:d,col:c.startColumn,value:U};return et.colSpan=c.endColumn-c.startColumn+1,et.rowSpan=c.endRow-c.startRow+1,d=c.endRow+1,{done:!1,value:et}}const f=l.getCell(d,h);if(!f&&e)d+=1;else{const E={row:d,col:h,value:f};return d+=1,{done:!1,value:E}}}}}}}}}function Zl(t){var s,r;if(!t)return"";const n=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(n)return n;const e=t.v;return typeof e=="string"?t.t===Oe.BOOLEAN?e.toUpperCase():e.replace(/[\r\n]/g,""):typeof e=="number"?t.t===Oe.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const Jl="0.2.4";function Ql(t="",n=Ie.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:Jl,locale:n,styles:{},sheets:{},resources:[]}}var tu=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,nu=(t,n,e,s)=>{for(var r=s>1?void 0:s?eu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&tu(n,e,r),r},su=(t,n)=>(e,s)=>n(e,s,t);function ru(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}u.Workbook=class extends On{constructor(e={},s){super();g(this,"type",Q.UNIVER_SHEET);g(this,"_sheetCreated$",new B.Subject);g(this,"sheetCreated$",this._sheetCreated$.asObservable());g(this,"_sheetDisposed$",new B.Subject);g(this,"sheetDisposed$",this._sheetDisposed$.asObservable());g(this,"_activeSheet$",new B.BehaviorSubject(null));g(this,"activeSheet$",this._activeSheet$.asObservable());g(this,"_worksheets");g(this,"_styles");g(this,"_snapshot");g(this,"_unitId");g(this,"_count");g(this,"_name$");g(this,"name$");this._logService=s;const r=Ql();k.isEmptyObject(e)?this._snapshot=r:this._snapshot=k.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=k.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new yi(i),this._count=1,this._worksheets=new Map,this._name$=new B.BehaviorSubject(e.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return k.deepClone(this._snapshot)}static isIRangeType(e){return typeof e=="string"||"startRow"in e||"row"in e}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)!=null?e:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(e,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(s,0,e);const a=new Ze(this._unitId,r,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>r===e)}getActiveSheet(e){if(!this._activeSheet&&typeof e>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const e=this._activeSheet;if(e)return e;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const a=this._worksheets.get(s[i]);if(a&&a.isSheetHidden()!==Y.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){const s=this._worksheets.get(e);return s?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),delete this._snapshot.sheets[e],this._sheetDisposed$.next(s),!0):!1}getActiveSheetIndex(){const{sheetOrder:e}=this._snapshot;return e.findIndex(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:e}=this._snapshot,s=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===Y.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==Y.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let s=e;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}generateNewSheetName(e){let s=e+this._count;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}_parseWorksheetSnapshots(){const{_snapshot:e,_worksheets:s}=this,{sheets:r,sheetOrder:i}=e;if(k.isEmptyObject(r)){const o=k.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const d=new Ze(this._unitId,a,this._styles);s.set(o,d),i.includes(o)||i.push(o)}this.ensureActiveSheet()}},u.Workbook=nu([su(1,Ee)],u.Workbook);class gs extends On{constructor(e){var s;super();g(this,"type",Q.UNIVER_SLIDE);g(this,"_snapshot");g(this,"_unitId");this._snapshot={...Yr,...e},this._unitId=(s=this._snapshot.id)!=null?s:k.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var r;return(r=this.getElementsByPage(e))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:Wn.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Je="FOCUSING_SHEET",bn="FOCUSING_DOC",vn="FOCUSING_SLIDE",iu="FOCUSING_EDITOR_BUT_HIDDEN",Vi="EDITOR_ACTIVATED",ou="FOCUSING_EDITOR_INPUT_FORMULA",xi="FOCUSING_FORMULA_EDITOR",au="FOCUSING_UNIVER_EDITOR",lu="FOCUSING_EDITOR_INPUT_FORMULA",uu="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",cu="FOCUSING_COMMON_DRAWINGS";var hu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,fu=(t,n,e,s)=>{for(var r=s>1?void 0:s?du(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&hu(n,e,r),r},ji=(t,n)=>(e,s)=>n(e,s,t);const He=ct.createIdentifier("univer.current");u.UniverInstanceService=class extends Mt{constructor(e,s){super();g(this,"_unitsByType",new Map);g(this,"_createHandler");g(this,"_ctorByType",new Map);g(this,"_currentUnits",new Map);g(this,"_currentUnits$",new B.BehaviorSubject(this._currentUnits));g(this,"currentUnits$",this._currentUnits$.asObservable());g(this,"_unitAdded$",new B.Subject);g(this,"unitAdded$",this._unitAdded$.asObservable());g(this,"_unitDisposed$",new B.Subject);g(this,"unitDisposed$",this._unitDisposed$.asObservable());g(this,"_focused$",new B.BehaviorSubject(null));g(this,"focused$",this._focused$.asObservable());this._injector=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(e){this._createHandler=e}createUnit(e,s){return this._createHandler(e,s,this._ctorByType.get(e))}registerCtorForType(e,s){return this._ctorByType.set(e,s),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(B.map(s=>{var r;return(r=s.get(e))!=null?r:null}),B.distinctUntilChanged())}getCurrentUnitForType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(s[1],s[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(e){this._currentUnits.set(e,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(B.filter(s=>s.type===e))}__addUnit(e){const s=e.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(e),this._unitAdded$.next(e),this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(B.filter(s=>s.type===e))}getUnit(e,s){var i;const r=(i=this._getUnitById(e))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Q.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,Q.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,Q.UNIVER_SHEET)}getAllUnitsForType(e){var s;return(s=this._unitsByType.get(e))!=null?s:[]}changeDoc(e,s){const r=this.getAllUnitsForType(Q.UNIVER_DOC),i=r.find(o=>o.getUnitId()===e);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const e=this._focused$.getValue();return e?(s=this._getUnitById(e))==null?void 0:s[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof u.Workbook?(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Je,!0),this._contextService.setContextValue(vn,!1)):this.focused instanceof we?(this._contextService.setContextValue(bn,!0),this._contextService.setContextValue(Je,!1),this._contextService.setContextValue(vn,!1)):this.focused instanceof gs&&(this._contextService.setContextValue(bn,!1),this._contextService.setContextValue(Je,!1),this._contextService.setContextValue(vn,!0))}getFocusedUnit(){return this.focused}getUnitType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${e}`);return s[1]}disposeUnit(e){const s=this._getUnitById(e);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),a=o.indexOf(r);return o.splice(a,1),this._removeCurrentUnitForType(i),this._focused$.next(null),this._unitDisposed$.next(r),!0}_getUnitById(e){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===e);if(i)return[i,s]}}},u.UniverInstanceService=fu([ji(0,ct.Inject(ct.Injector)),ji(1,Ye)],u.UniverInstanceService);var ft=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(ft||{});const _u={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},wn=new Map;function Ki(t,n){return function(r){Tn(t,n)}}function Tn(t,n){wn.has(t)||wn.set(t,[]),wn.get(t).push(n)}var gu=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,Yi=(t,n,e,s)=>{for(var r=s>1?void 0:s?mu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&gu(n,e,r),r},zi=(t,n)=>(e,s)=>n(e,s,t);u.LifecycleService=class extends Mt{constructor(e){super();g(this,"_lifecycle$",new B.BehaviorSubject(ft.Starting));g(this,"lifecycle$",this._lifecycle$.asObservable());g(this,"_lock",!1);this._logService=e,this._reportProgress(ft.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(e<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(e!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return B.merge(Xi(this.stage),this._lifecycle$.pipe(B.skip(1))).pipe(si(e=>e===ft.Steady))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${_u[e]}".`)}},u.LifecycleService=Yi([zi(0,Ee)],u.LifecycleService),u.LifecycleInitializerService=class extends Mt{constructor(e){super();g(this,"_seenTokens",new Set);this._injector=e}initModulesOnStage(e){var s;(s=wn.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}},u.LifecycleInitializerService=Yi([zi(0,ct.Inject(ct.Injector))],u.LifecycleInitializerService);function Xi(t){switch(t){case ft.Starting:return B.of(ft.Starting);case ft.Ready:return B.of(ft.Starting,ft.Ready);case ft.Rendered:return B.of(ft.Starting,ft.Ready,ft.Rendered);default:return B.of(ft.Starting,ft.Ready,ft.Rendered,ft.Steady)}}class Qe extends Mt{constructor(){super();g(this,"_currentLocale$",new B.BehaviorSubject(Ie.ZH_CN));g(this,"currentLocale$",this._currentLocale$.asObservable());g(this,"_locales",null);g(this,"localeChanged$",new B.Subject);g(this,"t",(e,...s)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const r=e.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return s.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return e});this.disposeWithMe(At(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(e){var s;this._locales=k.deepMerge((s=this._locales)!=null?s:{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,s){const r=s.shift();if(r&&e&&r in e){const i=e[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}var ms=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(ms||{});const Es=ct.createIdentifier("univer.permission-service");Tn(ft.Starting,Es);class qi extends Mt{constructor(){super(...arguments);g(this,"_permissionPointMap",new Map);g(this,"_permissionPointUpdate$",new B.Subject);g(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(e){const s=this._permissionPointMap.get(e);s&&(s.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){const s=e instanceof B.BehaviorSubject,r=s?e.getValue():e;if(!r.id)return!1;if(this._permissionPointMap.get(r.id))throw new Error(`${r.id} PermissionPoint already exists`);return this._permissionPointMap.set(r.id,s?e:new B.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0}updatePermissionPoint(e,s){const r=this._permissionPointMap.get(e);if(!r)return;const i=r.getValue();i.value=s,i.status=ms.DONE,r.next({...i}),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){const s=this._permissionPointMap.get(e);if(s)return s.getValue()}getPermissionPoint$(e){const s=this._permissionPointMap.get(e);if(s)return s}composePermission$(e){const s=e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.asObservable()});return B.combineLatest(s).pipe(oe.map(r=>r))}composePermission(e){return e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const e=new Map;return this._permissionPointMap.forEach((s,r)=>{e.set(r,s)}),e}}class Zi extends Mt{constructor(){super(...arguments);g(this,"_resourceMap",new Map);g(this,"_register$",new B.Subject);g(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e){return this.getAllResourceHooks().map(i=>{const o=i.toJson(e);return{name:i.pluginName,data:o}})}getResourcesByType(e,s){return this.getAllResourceHooks().filter(o=>o.businesses.includes(s)).map(o=>{const a=o.toJson(e);return{name:o.pluginName,data:a}})}registerPluginResource(e){const s=e.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,e),this._register$.next(e),At(()=>this._resourceMap.delete(s))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(a=>a.name===r.pluginName))==null?void 0:o.data;if(i)try{const a=r.parseJson(i);r.onLoad(e,a)}catch{console.error("LoadResources Error!")}})}unloadResources(e){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Mn=ct.createIdentifier("resource-manager-service");var Eu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Cu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Ru(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Eu(n,e,r),r},Ji=(t,n)=>(e,s)=>n(e,s,t);let Rs=class extends Mt{constructor(n,e){super();g(this,"saveWorkbook",n=>{const e=n.getUnitId(),s=this._resourceManagerService.getResources(e)||[],r=n.getSnapshot();return r.resources=s,r});this._resourceManagerService=n,this._univerInstanceService=e,this._init()}_init(){const n=s=>{s.businesses.forEach(r=>{switch(r){case Q.UNRECOGNIZED:case Q.UNIVER_UNKNOWN:case Q.UNIVER_SLIDE:case Q.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Q.UNIVER_DOC).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Document{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}});break}case Q.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Q.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{n(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{n(s)})),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(At(this._univerInstanceService.getTypeOfUnitDisposed$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}saveDoc(n){const e=n.getUnitId(),s=this._resourceManagerService.getResourcesByType(e,Q.UNIVER_DOC)||[],r=n.getSnapshot();return r.resources=s,r}};Rs=Cu([Ji(0,ct.Inject(Mn)),Ji(1,ct.Inject(He))],Rs);const Cs=ct.createIdentifier("resource-loader-service");Tn(ft.Ready,Cs);class ps extends Mt{constructor(){super();g(this,"_currentTheme");g(this,"_currentTheme$",new B.BehaviorSubject({}));g(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(At(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}}const Un="__INTERNAL_EDITOR__",Qi=`${Un}DOCS_NORMAL`,to=`${Un}DOCS_FORMULA_BAR`,pu=`\r
7
- `;function Iu(t){return`${Un}${t}`}function Su(t){return t.startsWith(Un)}var Ou=Object.defineProperty,Nu=Object.getOwnPropertyDescriptor,Au=(t,n,e,s)=>{for(var r=s>1?void 0:s?Nu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Ou(n,e,r),r},Is=(t,n)=>(e,s)=>n(e,s,t);const Ln=ct.createIdentifier("univer.undo-redo.service"),bu=20;class eo{dispose(){}async dispatchToHandlers(){return!1}}const no="univer.command.redo",so="univer.command.undo",ro=new class extends eo{constructor(){super(...arguments);g(this,"type",ze.COMMAND);g(this,"id",so)}async handler(n){const e=n.get(Ln),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(Xe);return qn(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},io=new class extends eo{constructor(){super(...arguments);g(this,"type",ze.COMMAND);g(this,"id",no)}async handler(n){const e=n.get(Ln),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(Xe);return qn(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends Mt{constructor(e,s,r){super();g(this,"undoRedoStatus$");g(this,"_undoRedoStatus$",new B.BehaviorSubject({undos:0,redos:0}));g(this,"_undoStacks",new Map);g(this,"_redoStacks",new Map);g(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ro)),this.disposeWithMe(this._commandService.registerCommand(io)),this.disposeWithMe(At(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(At(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:s}=e,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(e.unitID)){const a=this._batchingStatus.get(e.unitID),l=this._pitchUndoElement(e.unitID);a===0||!l?(o(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(l,e)}else o(e);function o(a){i.push(a),i.length>bu&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const s=this._getRedoStack(e);s&&(s.length=0);const r=this._getUndoStack(e);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){const e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){const s=this._getUndoStack(e);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(e){const s=this._getRedoStack(e);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(e,0),At(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUnitId(),s=e&&((i=this._undoStacks.get(e))==null?void 0:i.length)||0,r=e&&((o=this._redoStacks.get(e))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(e,s=!1){let r=this._undoStacks.get(e);return!r&&s&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,s=!1){let r=this._redoStacks.get(e);return!r&&s&&(r=[],this._redoStacks.set(e,r)),r||null}_getUndoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getUndoStack(e,!0)}_getRedoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getRedoStack(e,!0)}_tryBatchingElements(e,s){e.redoMutations.push(...s.redoMutations),e.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,a,l,d;let e="";const s=this._contextService.getContextValue(Je),r=this._contextService.getContextValue(xi),i=this._contextService.getContextValue(Vi);return s?r?e=to:i?e=Qi:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(d=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?d:"",e}},u.LocalUndoRedoService=Au([Is(0,He),Is(1,Xe),Is(2,Ye)],u.LocalUndoRedoService);const oo=Symbol("DependentOn");class Ss extends Mt{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}g(Ss,"pluginName"),g(Ss,"type",Q.UNIVER_UNKNOWN);class vu{constructor(){g(this,"_plugins",[])}addPlugin(n){this._plugins.push(n)}removePlugins(){const n=this._plugins.slice();return this._plugins.length=0,n}forEachPlugin(n){this._plugins.forEach(n)}}class wu{constructor(){g(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Tu=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,ao=(t,n,e,s)=>{for(var r=s>1?void 0:s?Mu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Tu(n,e,r),r},tn=(t,n)=>(e,s)=>n(e,s,t);const Uu=4;function Lu(...t){return function(n){n[oo]=t}}u.PluginService=class{constructor(n){g(this,"_pluginHolderForUniver");g(this,"_pluginHoldersForTypes",new Map);g(this,"_seenPlugins",new Set);g(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const n of this._pluginHoldersForTypes.values())n.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(n,e){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:s}=n;s===Q.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,e),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).register(n,e)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const e=this._injector.createInstance(Dn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,e),e}return this._pluginHoldersForTypes.get(n)}_immediateInitPlugin(n){this._seenPlugins.add(n.pluginName),this._ensurePluginHolderForType(n.type).immediateInitPlugin(n)}_checkPluginSeen(n){return this._seenPlugins.has(n.pluginName)}_assertPluginValid(n){const{type:e,pluginName:s}=n;if(e===Q.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(s))throw new Error(`[PluginService]: duplicated plugin name for "${s}". Maybe a plugin that dependents on "${s} has already registered it. In that case please register "${s}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Uu))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,e]of this._pluginHoldersForTypes)e.started&&e.flush()}},u.PluginService=ao([tn(0,ct.Inject(ct.Injector))],u.PluginService);let Dn=class extends Mt{constructor(n,e,s,r,i,o){super();g(this,"_started",!1);g(this,"_pluginRegistry",new wu);g(this,"_pluginStore",new vu);g(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=e,this._logService=s,this._injector=r,this._lifecycleService=i,this._lifecycleInitializerService=o,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(B.skip(1)).subscribe(a=>{this._awaitingPlugins.forEach(l=>this._runStage(l,a))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(n=>n.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._awaitingPlugins.length=0}register(n,e){this._pluginRegistry.registerPlugin(n,e)}immediateInitPlugin(n){const e=this._initPlugin(n,void 0);this._pluginsRunLifecycle([e])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:e,options:s})=>this._initPlugin(e,s));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,e){const s=n[oo];if(s){const i=()=>{const o=s.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const r=this._injector.createInstance(n,e);return this._pluginStore.addPlugin(r),r}_pluginsRunLifecycle(n){Xi(this._lifecycleService.stage).subscribe(e=>this._runStage(n,e)),this._awaitingPlugins.push(n)}_runStage(n,e){n.forEach(s=>{switch(e){case ft.Starting:s.onStarting(this._injector);break;case ft.Ready:s.onReady();break;case ft.Rendered:s.onRendered();break;case ft.Steady:s.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(e)}};Dn=ao([tn(2,Ee),tn(3,ct.Inject(ct.Injector)),tn(4,ct.Inject(u.LifecycleService)),tn(5,ct.Inject(u.LifecycleInitializerService))],Dn);function lo(t,n){if(!n)return t;const e=[];for(const s of t){const r=n.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;e.push([s[0],r[1]])}else e.push(s)}return e}const Os={[Wt.Editor]:"Editor",[Wt.Owner]:"Owner",[Wt.Reader]:"Reader",[Wt.UNRECOGNIZED]:"UNRECOGNIZED"},yn=t=>t?{userID:`${Os[t]}_${k.generateRandomId(8)}`,name:Os[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Ns=(t,n)=>t.startsWith(Os[n]);var Du=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,Pu=(t,n,e,s)=>{for(var r=s>1?void 0:s?yu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Du(n,e,r),r};u.UserManagerService=class{constructor(){g(this,"_model",new Map);g(this,"_userChange$",new B.Subject);g(this,"userChange$",this._userChange$.asObservable());g(this,"_currentUser$",new B.BehaviorSubject(yn()));g(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,e){const s=this._model.get(n);if(s)return s;e&&e()}delete(n){const e=this.getUser(n);this._model.delete(n),e&&this._userChange$.next({type:"delete",user:e})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}},u.UserManagerService=Pu([Ki(ft.Starting,u.UserManagerService)],u.UserManagerService);var ku=Object.defineProperty,Hu=Object.getOwnPropertyDescriptor,Fu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Hu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&ku(n,e,r),r},uo=(t,n)=>(e,s)=>n(e,s,t);u.AuthzIoLocalService=class{constructor(n,e){g(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=e,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(yn(Wt.Owner))}_getRole(n){const e=this._userManagerService.getCurrentUser();return e?Ns(e.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const e=[...this._permissionMap.keys()].reduce((s,r)=>{const i=this._permissionMap.get(r);return s[r]=i,s},{});return JSON.stringify(e)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Q.UNIVER_SHEET,Q.UNIVER_DOC,Q.UNIVER_SLIDE],onLoad:(n,e)=>{for(const s in e)this._permissionMap.set(s,e[s])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const e=k.generateRandomId(8);switch(n.objectType){case Sn.SelectRange:{const s=n.selectRangeObject;this._permissionMap.set(e,{...s,objectType:n.objectType});break}case Sn.Worksheet:{const s=n.worksheetObject;this._permissionMap.set(e,{...s,objectType:n.objectType,readScope:ii.SomeCollaborator})}}return e}async allowed(n){var e;if(this._permissionMap.has(n.objectID)){const s=this._permissionMap.get(n.objectID);if(s&&s.objectType===Sn.Worksheet)return(e=s==null?void 0:s.strategies)==null?void 0:e.map(r=>({action:r.action,allowed:r.role===Wt.Editor}))}return n.actions.map(s=>({action:s,allowed:this._getRole(Wt.Owner)||this._getRole(Wt.Editor)}))}async batchAllowed(n){const e=this._userManagerService.getCurrentUser(),s=n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!1}))}));return e&&(Ns(e.userID,Wt.Owner)||Ns(e.userID,Wt.Editor))?n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!0}))})):s}async list(n){const e=[];return n.objectIDs.forEach(s=>{const r=this._permissionMap.get(s);if(r){const i={objectID:s,unitID:n.unitID,objectType:r.objectType,name:r.name,shareOn:!1,shareRole:Wt.Owner,shareScope:-1,creator:yn(Wt.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole(Wt.Owner)||this._getRole(Wt.Editor)}))};e.push(i)}}),e}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}},u.AuthzIoLocalService=Fu([uo(0,Mn),uo(1,ct.Inject(u.UserManagerService))],u.AuthzIoLocalService);const co=ct.createIdentifier("IAuthzIoIoService");class $u{constructor(n={},e){g(this,"_startedTypes",new Set);g(this,"_injector");const s=this._injector=Wu(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(ps).setTheme(r),o&&this._injector.get(Qe).load(o),i&&this._injector.get(Qe).setLocale(i),a&&this._injector.get(Ee).setLogLevel(a),this._init(s)}get _univerInstanceService(){return this._injector.get(He)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Qe).setLocale(n)}createUnit(n,e){return this._univerInstanceService.createUnit(n,e)}createUniverSheet(n){return this._univerInstanceService.createUnit(Q.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(Q.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(Q.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(Q.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,gs);const e=n.get(He);e.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const a=n.createInstance(i,r);return e.__addUnit(a),this._tryProgressToReady(),a}const o=n.createInstance(i,r);return e.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<ft.Ready&&(this._injector.get(u.LifecycleService).stage=ft.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Wu(t,n){const e=lo([[Di],[Qe],[ps],[u.LifecycleService],[u.LifecycleInitializerService],[u.PluginService],[u.UserManagerService],[He,{useClass:u.UniverInstanceService}],[Es,{useClass:qi}],[Ee,{useClass:Qr,lazy:!0}],[Xe,{useClass:u.CommandService}],[Ln,{useClass:u.LocalUndoRedoService,lazy:!0}],[Ui,{useClass:Li}],[Ye,{useClass:Zr}],[Mn,{useClass:Zi,lazy:!0}],[Cs,{useClass:Rs,lazy:!0}],[co,{useClass:u.AuthzIoLocalService,lazy:!0}]],n);return t?t.createChild(e):new ct.Injector(e)}const Bu=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!me.equals(s,e))),Gu=(t,n)=>n.length===t.length&&t.every((e,s)=>{const r=n[s];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&me.equals(e.range,r.range)});function Vu(t,n){if(Object.is(t,n))return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;const e=Object.keys(t),s=Object.keys(n);if(e.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(n);for(let i=0;i<e.length;i++){const o=e[i];if(!r(o))return!1;const a=t[o],l=n[o];if(a!==l)return!1}return!0}function ho(t){return/^-?\d+(\.\d+)?$/.test(t)}function xu(t){return ho(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function ju(t){return["true","false"].includes(t.toLowerCase())}function Ku(t,n){return n.forEach(e=>t.add(e)),t}function Yu(t,n=16){let e=0,s=null;return function(...i){const o=Date.now();o-e<n?(s&&clearTimeout(s),s=setTimeout(()=>{e=o,t.apply(this,i)},n)):(e=o,t.apply(this,i))}}function zu(t){const n=new MessageChannel;let e=!1;const s=()=>{e||t()};return n.port1.onmessage=s,n.port2.postMessage(null),()=>{e=!0,n.port1.close(),n.port2.close()}}var fo=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(fo||{});function Xu(t,n,e){if(n==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new we(s),i=n.length;let o;for(;(o=r.getBody().dataStream.indexOf(n))>=0;){const l=new Re,d=ve.getInstance();if(o>0&&l.retain(o),e.length>0){const h=r.sliceBody(o,o+i),c={dataStream:e};Array.isArray(h==null?void 0:h.textRuns)&&h.textRuns.length&&(c.textRuns=[{...h.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,c)}l.delete(i),r.apply(d.editOp(l.serialize()))}const a=r.getBody();return r.dispose(),a}class _o{constructor(){g(this,"skipNextObservers",!1);g(this,"lastReturnValue");g(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class qu extends B.Subject{constructor(){super(...arguments);g(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let s;typeof e=="function"?s={next:([i,o])=>e(i,o)}:s=e;const r=super.subscribe(s);return this._sortedObservers.push(s),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),r.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==s)),r}clearObservers(){this._sortedObservers.forEach(e=>{var s;return(s=e.complete)==null?void 0:s.call(e)}),this._sortedObservers.length=0}emitEvent(e){var s;if(!this.closed){const r=new _o;r.lastReturnValue=e;for(const i of this._sortedObservers){const o=(s=i.next)==null?void 0:s.call(i,[e,r]);if(r.lastReturnValue=o,r.skipNextObservers)return{handled:!0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}const Zu=ct.createIdentifier("ILocalStorageService");function Ju(t){return`sheet_interceptor_${t}`}const go=t=>function(n,e){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,n)};class Qu{constructor(n){g(this,"_interceptorsByName",new Map);g(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return go(s||[])}intercept(n,e){const s=n;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(e),this._interceptorsByName.set(s,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>En(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const tc=ct.createIdentifier("univer.snapshot-server-service");class ec{constructor(){g(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,e){return Promise.resolve({snapshot:{unitID:"",type:Q.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:jt.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:jt.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:jt.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:jt.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:jt.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:jt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:jt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:jt.OK,message:""},concurrent:[]})}}function nc(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function As(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const en=new TextEncoder,Pn=new TextDecoder;function mo(t){const n=k.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,en.encode(JSON.stringify(n))}function Eo(t){const n=k.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,en.encode(JSON.stringify(n))}function sc(t){const n=k.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,en.encode(JSON.stringify(n))}function Ro(t){return JSON.parse(Pn.decode(t))}function rc(t){return JSON.parse(typeof t=="string"?As(t):Pn.decode(t))}function ic(t){return JSON.parse(typeof t=="string"?As(t):Pn.decode(t))}const bs=256*20;function Co(t,n){const e=new Jt(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+bs,s-1),a=e.getSlice(i,Math.min(i+bs,s-1),0,n),l=oc(a);r.push({id:k.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=bs}return r}function oc(t){const n=t.getData();return en.encode(JSON.stringify(n))}async function ac(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([c,f])=>{const _={id:f.id,type:an.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:mo(f)};if(o[c]=_,f.cellData){const E=Co(f.cellData,f.rowCount),R=await Promise.all(E.map(U=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:U})));if(R.some(U=>{var D;return((D=U.error)==null?void 0:D.code)!==jt.OK}))return!1;i[c]={sheetID:c,blocks:R.map(U=>U.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Eo(n),d={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:e,rev:d.rev,type:Q.UNIVER_SHEET,workbook:d,doc:void 0}}}async function lc(t,n,e,s,r){var f,_;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([E,R])=>{const U={id:R.id,type:an.GRID,name:R.name,rowCount:R.rowCount,columnCount:R.columnCount,originalMeta:mo(R)};if(o[E]=U,R.cellData){const D=Co(R.cellData,R.rowCount),et=await Promise.all(D.map(Et=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:Et})));if(et.some(Et=>{var _t;return((_t=Et.error)==null?void 0:_t.code)!==jt.OK}))return!1;i[E]={sheetID:E,blocks:et.map(Et=>Et.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Eo(n),d={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},h={unitID:e,rev:d.rev,type:Q.UNIVER_SHEET,workbook:d,doc:void 0},c=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_SHEET,snapshot:h});if(ri(c.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
- ErrorCode: ${(f=c.error)==null?void 0:f.code}:${(_=c.error)==null?void 0:_.message}`);return{snapshot:h}}function uc(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,d])=>{const h=Ro(d.originalMeta);r[l]={id:d.id,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,...h}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,d])=>{var f;const h=r[l];h.cellData={};const c=[];(f=d.blocks)==null||f.forEach(_=>{const E=i.get(_);if(E)c.push(E);else throw new Error("")}),c.forEach(_=>{const E=rc(_.data);Object.entries(E).forEach(([R,U])=>{const D=h.cellData[+R]={};Object.entries(U).forEach(([et,Et])=>{D[+et]=Et})})})});const o=Ro(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:Ie.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function cc(t){const n=t.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:e,rev:s,name:r,originalMeta:i,resources:o=[]}=n,{body:a,documentStyle:l={},settings:d={},drawings:h={},drawingsOrder:c=[]}=ic(i);return{id:e,rev:s,locale:Ie.EN_US,title:r,body:a,documentStyle:l,settings:d,drawings:h,drawingsOrder:c,resources:o}}async function hc(t,n,e,s,r){var l,d,h;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:sc(n)},o={unitID:e,rev:i.rev,type:Q.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_DOC,snapshot:o});if(ri(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
- ErrorCode: ${(d=a.error)==null?void 0:d.code}:${(h=a.error)==null?void 0:h.message}`);return{snapshot:o}}async function dc(t,n){const e=t.workbook;if(!e)throw new Error("Workbook metadata is not available");const s=[],r=[];return Object.entries(e.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async l=>{const d={unitID:e.unitID,type:Q.UNIVER_SHEET,blockID:l},{block:h}=await n.getSheetBlock({},d);if(h)s.push(h);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var po=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(po||{}),Io=(t=>(t[t.DISABLED=0]="DISABLED",t[t.FULL_ALPHA=1]="FULL_ALPHA",t[t.FULL_HANGUL=2]="FULL_HANGUL",t[t.FULL_KATAKANA=3]="FULL_KATAKANA",t[t.HALF_ALPHA=4]="HALF_ALPHA",t[t.HALF_HANGUL=5]="HALF_HANGUL",t[t.HALF_KATAKANA=6]="HALF_KATAKANA",t[t.HIRAGANA=7]="HIRAGANA",t[t.NO_CONTROL=8]="NO_CONTROL",t[t.OFF=9]="OFF",t[t.ON=10]="ON",t))(Io||{}),So=(t=>(t.BETWEEN="between",t.EQUAL="equal",t.GREATER_THAN="greaterThan",t.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",t.LESS_THAN="lessThan",t.LESS_THAN_OR_EQUAL="lessThanOrEqual",t.NOT_BETWEEN="notBetween",t.NOT_EQUAL="notEqual",t))(So||{}),Oo=(t=>(t.CUSTOM="custom",t.LIST="list",t.LIST_MULTIPLE="listMultiple",t.NONE="none",t.TEXT_LENGTH="textLength",t.DATE="date",t.TIME="time",t.WHOLE="whole",t.DECIMAL="decimal",t.CHECKBOX="checkbox",t))(Oo||{}),No=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(No||{});const fc=["script","style","meta","comment","link"];function _c(t){return!(t.length===0||t.length>31||t.startsWith("'")||t.endsWith("'")||/[:\\\/\?\*\[\]]/.test(t))}Uo(),u.ABCToNumber=Ya,u.AbsoluteRefType=Nt,u.ActionIterator=fs,u.AlignTypeH=Ir,u.AlignTypeV=Sr,u.ArrangeTypeEnum=Ar,u.ArrowsAndMarkersShapes=Ks,u.AutoFillSeries=Ds,u.BaselineOffset=Pe,u.BasicShapes=js,u.BlockType=nr,u.BooleanNumber=Y,u.BorderStyleTypes=dt,u.BorderType=ys,u.BulletAlignment=fe,u.COLORS=Hn,u.CellValueType=Oe,u.ClientSnapshotServerService=ec,u.Color=Ne,u.ColorBuilder=hn,u.ColorKit=Zt,u.ColorType=xt,u.ColumnSeparatorType=or,u.CommandType=ze,u.CommonHideTypes=Ps,u.ConfigService=Li,u.ContentAlignment=mr,u.ContextService=Zr,u.CopyPasteType=ks,u.CustomDecorationType=er,u.CustomRangeType=tr,u.DEFAULT_CELL=rl,u.DEFAULT_DOC=_s,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Do,u.DEFAULT_EMPTY_DOCUMENT_VALUE=pu,u.DEFAULT_RANGE=nl,u.DEFAULT_RANGE_ARRAY=el,u.DEFAULT_SELECTION=sl,u.DEFAULT_SLIDE=Yr,u.DEFAULT_STYLES=pn,u.DEFAULT_WORKSHEET_COLUMN_COUNT=ki,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Kl,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Wi,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=ql,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=Fi,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=zl,u.DEFAULT_WORKSHEET_ROW_COUNT=Pi,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=jl,u.DEFAULT_WORKSHEET_ROW_HEIGHT=Hi,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Yl,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=$i,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Xl,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=to,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Qi,u.DashStyleType=fr,u.DataStreamTreeNodeType=oi,u.DataStreamTreeTokenType=ae,u.DataValidationErrorStyle=po,u.DataValidationImeMode=Io,u.DataValidationOperator=So,u.DataValidationRenderMode=fo,u.DataValidationStatus=No,u.DataValidationType=Oo,u.DependentOn=Lu,u.DesktopLogService=Qr,u.DeveloperMetadataVisibility=Hs,u.Dimension=Fs,u.Direction=$s,u.Disposable=Mt,u.DisposableCollection=Vn,u.DocStyleType=Js,u.DocumentDataModel=we,u.DocumentFlavor=sr,u.DrawingTypeEnum=br,u.EDITOR_ACTIVATED=Vi,u.EXTENSION_NAMES=zr,u.Entry=xn,u.EntryIterator=Vr,u.ErrorService=Di,u.EventState=_o,u.EventSubject=qu,u.FOCUSING_COMMON_DRAWINGS=cu,u.FOCUSING_DOC=bn,u.FOCUSING_EDITOR_BUT_HIDDEN=iu,u.FOCUSING_EDITOR_INPUT_FORMULA=ou,u.FOCUSING_EDITOR_STANDALONE=lu,u.FOCUSING_FORMULA_EDITOR=xi,u.FOCUSING_SHEET=Je,u.FOCUSING_SLIDE=vn,u.FOCUSING_UNIVER_EDITOR=au,u.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=uu,u.FollowNumberWithType=Qs,u.FontItalic=ln,u.FontStyleType=Er,u.FontWeight=un,u.FormatType=Ws,u.GlyphType=xe,u.GridType=rr,u.HLSColor=qs,u.HorizontalAlign=Se,u.IAuthzIoService=co,u.ICommandService=Xe,u.IConfigService=Ui,u.IContextService=Ye,u.ILocalStorageService=Zu,u.ILogService=Ee,u.IPermissionService=Es,u.IResourceLoaderService=Cs,u.IResourceManagerService=Mn,u.ISnapshotServerService=tc,u.IUndoRedoService=Ln,u.IUniverInstanceService=He,u.InterceptorManager=Qu,u.InterpolationPointType=Bs,u.JSON1=Hl,u.JSONX=ve,u.KeyIterator=Br,u.LRUHelper=Ke,u.LRUMap=xr,u.LifecycleStages=ft,u.LocaleService=Qe,u.LocaleType=Ie,u.LogLevel=Jr,u.MOVE_BUFFER_VALUE=Ge,u.MemoryCursor=vi,u.NamedStyleType=hr,u.NilCommand=ei,u.NumberUnitType=pr,u.ObjectMatrix=Jt,u.ObjectRelativeFromH=Rr,u.ObjectRelativeFromV=Cr,u.OnLifecycle=Ki,u.OtherShapes=Ys,u.PRESET_LIST_TYPE=El,u.PageElementType=vr,u.PageOrientType=Nr,u.PageType=Wn,u.ParagraphElementType=lr,u.PermissionService=qi,u.PermissionStatus=ms,u.Plugin=Ss,u.PositionedObjectLayoutType=cr,u.PresetListType=Nn,u.ProtectionType=Gs,u.RANGE_TYPE=ot,u.RCDisposable=ka,u.RGBA_PAREN=$o,u.RGB_PAREN=Fo,u.ROTATE_BUFFER_VALUE=Ms,u.Range=ke,u.Rectangle=me,u.RedoCommand=io,u.RedoCommandId=no,u.RefAlias=Ka,u.Registry=Zn,u.RegistryAsMap=Jn,u.RelativeDate=Vs,u.RelativeSlideLink=wr,u.ResourceManagerService=Zi,u.RgbColor=dn,u.RxDisposable=Pa,u.SectionType=ir,u.SheetTypes=an,u.SheetViewModel=Gi,u.SliceBodyType=es,u.SlideDataModel=gs,u.SpacingRule=dr,u.SpecialShapes=zs,u.Styles=yi,u.THEME_COLORS=Xs,u.TabStopAlignment=_r,u.TextDecoration=xs,u.TextDirection=Ve,u.TextDirectionType=ar,u.TextX=Re,u.TextXActionType=tt,u.ThemeColor=fn,u.ThemeColorType=$t,u.ThemeColors=cn,u.ThemeService=ps,u.Tools=k,u.UndoCommand=ro,u.UndoCommandId=so,u.UnitModel=On,u.Univer=$u,u.UniverInstanceType=Q,u.UpdateDocsAttributeType=kt,u.ValueIterator=Gr,u.VerticalAlign=De,u.WidthType=gr,u.Worksheet=Ze,u.WrapStrategy=ye,u.WrapTextType=ur,u.afterInitApply=ml,u.b64DecodeUnicode=As,u.b64EncodeUnicode=nc,u.binarySearchArray=Us,u.cellToRange=ba,u.characterSpacingControlType=Or,u.checkForSubstrings=va,u.checkIfMove=yo,u.checkParagraphHasBullet=wa,u.checkParagraphHasIndent=Ta,u.checkParagraphHasIndentByStyle=Lr,u.codeToBlob=ko,u.composeBody=ns,u.composeInterceptors=go,u.concatMatrixArray=Ga,u.convertBodyToHtml=tl,u.covertTextRunToHtml=Xn,u.createDefaultUser=yn,u.createInterceptorKey=Ju,u.createInternalEditorID=Iu,u.createRowColIter=zn,u.debounce=Qa,u.dedupe=Ha,u.deepCompare=Bn,u.deleteContent=yr,u.extractPureTextFromCell=Zl,u.fromCallback=ni,u.fromObservable=ya,u.generateRandomId=Tr,u.generateTemporarySnap=ac,u.getArrayLength=ge,u.getBodySlice=qe,u.getBodySliceHtml=Cn,u.getBorderStyleType=Oa,u.getCellInfoInMergeData=ra,u.getCellValueType=ta,u.getColorStyle=se,u.getCustomDecorationSlice=Ii,u.getCustomRangeSlice=pi,u.getDocsUpdateBody=Na,u.getReverseDirection=Ho,u.getSheetBlocksFromSnapshot=dc,u.getWorksheetUID=ru,u.groupBy=Wa,u.handleStyleToString=Sa,u.hashAlgorithm=Ua,u.horizontalLineSegmentsSubtraction=mn,u.insertMatrixArray=jn,u.insertTextToContent=Dr,u.isBlackColor=Zo,u.isBooleanString=ju,u.isCellCoverable=Ca,u.isCellV=na,u.isEmptyCell=Mr,u.isFormulaId=Ia,u.isFormulaString=pa,u.isICellData=Qo,u.isInternalEditorID=Su,u.isNullCell=ea,u.isNumeric=ho,u.isRangesEqual=Bu,u.isRealNum=Ma,u.isSafeNumeric=xu,u.isSameStyleTextRun=Ur,u.isUnitRangesEqual=Gu,u.isValidRange=Aa,u.isWhiteColor=Jo,u.makeArray=Ba,u.makeCellRangeToRangeData=Ra,u.makeCellToSelection=Ea,u.mergeOverrideWithDependencies=lo,u.mergeSets=Ku,u.mergeWorksheetSnapshotWithDefault=Bi,u.moveMatrixArray=Yn,u.moveRangeByOffset=ul,u.nameCharacterCheck=_c,u.normalizeBody=Tl,u.normalizeTextRuns=Qn,u.numberToABC=Xa,u.numberToListABC=qa,u.orderSearchArray=Ls,u.queryObjectMatrix=ll,u.remove=En,u.repeatStringNumTimes=Kr,u.replaceInDocumentBody=Xu,u.requestImmediateMacroTask=zu,u.rotate=$a,u.runOnLifecycle=Tn,u.searchArray=Po,u.selectionToArray=sa,u.sequence=qr,u.sequenceAsync=Xr,u.sequenceExecute=qn,u.sequenceExecuteAsync=gl,u.shallowEqual=Vu,u.skipParseTagNames=fc,u.sliceMatrixArray=Va,u.sortRules=Za,u.sortRulesByDesc=Ja,u.sortRulesFactory=Ae,u.spliceArray=Kn,u.takeAfter=si,u.textDecoder=Pn,u.textEncoder=en,u.throttle=Yu,u.toDisposable=At,u.transformDocumentDataToSnapshot=hc,u.transformSnapshotToDocumentData=cc,u.transformSnapshotToWorkbookData=uc,u.transformWorkbookDataToSnapshot=lc,u.updateAttributeByDelete=wi,u.updateAttributeByInsert=Ti,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,W){typeof exports=="object"&&typeof module<"u"?W(exports,require("rxjs"),require("rxjs/operators"),require("react")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","react"],W):(u=typeof globalThis<"u"?globalThis:u||self,W(u.UniverCore={},u.rxjs,u.rxjs.operators,u.React))})(this,function(u,W,ht,ke){"use strict";var dd=Object.defineProperty;var fd=(u,W,ht)=>W in u?dd(u,W,{enumerable:!0,configurable:!0,writable:!0,value:ht}):u[W]=ht;var g=(u,W,ht)=>fd(u,typeof W!="symbol"?W+"":W,ht);var Ta,ya;function La(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}function Pa(e,n){for(var t=0;t<n.length;t++){const r=n[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const et=La(ke);function ka(){Fa()}const mn=typeof global<"u"?global:typeof self<"u"?self:window;function Fa(){typeof mn.requestIdleCallback!="function"&&(mn.requestIdleCallback=function(t){const r=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-r));t({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof mn.cancelIdleCallback!="function"&&(mn.cancelIdleCallback=function(t){clearTimeout(t)})}const Ha="__default_document_sub_component_id20231101__",Qt=2,is=1;function $a(e,n){if(n==null||e==null)return!0;const{left:t=0,top:r=0,height:s=0,width:i=0,angle:o=0}=n,{left:a=0,top:l=0,height:d=0,width:h=0,angle:c=0}=e,f=h,_=d,E=i,p=s;return Math.abs(a-t)>Qt||Math.abs(l-r)>Qt||Math.abs(f-E)>Qt||Math.abs(_-p)>Qt||Math.abs(c-o)>is}function os(e,n){let t=0,r=e.length-1;for(;t<=r;){const s=Math.floor((r+t)/2);if(n<e[s]&&(s===0||n>=e[s-1]))return s;if(n>=e[s])t=s+1;else if(n<e[s])r=s-1;else return-1}return-1}function as(e,n){let t=0,r=0,s=0,i=-1,o=e.length-1;for(;t<e.length&&o>=0&&o>=t;){if(r=e[o],o===0?s=0:s=e[o-1],n>=s&&n<=r){i=o;break}if(r=e[t],t===0?s=0:s=e[t-1],n>=s&&n<r){i=t;break}t++,o--}return i}function Wa(e,n){let t=e.length-1;return n<0?-1:n<e[0]?0:n>e[e.length-1]?Number.POSITIVE_INFINITY:(e.length<40||n<=e[20]||n>=e[t-20]?t=as(e,n):t=os(e,n),t)}function Ba(e){const n=new Blob([e],{type:"text/javascript"});return window.URL.createObjectURL(n)}var ls=(e=>(e[e.DEFAULT_SERIES=0]="DEFAULT_SERIES",e[e.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",e))(ls||{}),he=(e=>(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))(he||{}),us=(e=>(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))(us||{}),ze=(e=>(e[e.UNSUPPORTED=0]="UNSUPPORTED",e[e.RGB=1]="RGB",e[e.HEX=2]="HEX",e[e.THEME=3]="THEME",e))(ze||{}),cs=(e=>(e[e.ON=0]="ON",e[e.OFF=1]="OFF",e))(cs||{}),hs=(e=>(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))(hs||{}),ds=(e=>(e[e.DOCUMENT=0]="DOCUMENT",e[e.PROJECT=1]="PROJECT",e))(ds||{}),fs=(e=>(e[e.COLUMNS=0]="COLUMNS",e[e.ROWS=1]="ROWS",e))(fs||{}),_s=(e=>(e[e.UP=0]="UP",e[e.RIGHT=1]="RIGHT",e[e.DOWN=2]="DOWN",e[e.LEFT=3]="LEFT",e))(_s||{});function ja(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var gs=(e=>(e[e.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",e[e.TEXT=1]="TEXT",e[e.NUMBER=2]="NUMBER",e[e.PERCENT=3]="PERCENT",e[e.CURRENCY=4]="CURRENCY",e[e.DATE=5]="DATE",e[e.TIME=6]="TIME",e[e.DATE_TIME=7]="DATE_TIME",e[e.SCIENTIFIC=8]="SCIENTIFIC",e))(gs||{}),ms=(e=>(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))(ms||{}),bt=(e=>(e.EN_US="enUS",e.ZH_CN="zhCN",e.RU_RU="ruRU",e.ZH_TW="zhTW",e.VI_VN="viVN",e))(bt||{}),Es=(e=>(e[e.RANGE=0]="RANGE",e[e.SHEET=1]="SHEET",e))(Es||{}),ps=(e=>(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))(ps||{}),En=(e=>(e[e.GRID=0]="GRID",e[e.KANBAN=1]="KANBAN",e[e.GANTT=2]="GANTT",e))(En||{}),qt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",e[e.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",e))(qt||{}),Rs=(e=>(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))(Rs||{}),At=(e=>(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))(At||{}),Wt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TOP=1]="TOP",e[e.MIDDLE=2]="MIDDLE",e[e.BOTTOM=3]="BOTTOM",e))(Wt||{}),Bt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.OVERFLOW=1]="OVERFLOW",e[e.CLIP=2]="CLIP",e[e.WRAP=3]="WRAP",e))(Bt||{}),pn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ITALIC=1]="ITALIC",e))(pn||{}),Rn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.BOLD=1]="BOLD",e))(Rn||{}),jt=(e=>(e[e.NORMAL=1]="NORMAL",e[e.SUBSCRIPT=2]="SUBSCRIPT",e[e.SUPERSCRIPT=3]="SUPERSCRIPT",e))(jt||{}),z=(e=>(e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e))(z||{}),Tt=(e=>(e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.FORCE_STRING=4]="FORCE_STRING",e))(Tt||{}),We=(e=>(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))(We||{}),Cn=(e=>(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))(Cn||{}),Cs=(e=>(e.Line="line",e.LineInv="lineInv",e.Triangle="triangle",e.RtTriangle="rtTriangle",e.Rect="rect",e.Diamond="diamond",e.Parallelogram="parallelogram",e.Trapezoid="trapezoid",e.NonIsocelesTrapezoid="nonIsocelesTrapezoid",e.Pentagon="pentagon",e.Hexagon="hexagon",e.Heptagon="heptagon",e.Octagon="octagon",e.Decagon="decagon",e.Dodecagon="dodecagon",e.Star4="star4",e.Star5="star5",e.Star6="star6",e.Star7="star7",e.Star8="star8",e.Star10="star10",e.Star12="star12",e.Star16="star16",e.Star24="star24",e.Star32="star32",e.RoundRect="roundRect",e.Round1Rect="round1Rect",e.Round2SameRect="round2SameRect",e.Round2DiagRect="round2DiagRect",e.Ellipse="ellipse",e))(Cs||{}),Is=(e=>(e.RightArrow="rightArrow",e.LeftArrow="leftArrow",e.UpArrow="upArrow",e.DownArrow="downArrow",e.LeftRightArrow="leftRightArrow",e.UpDownArrow="upDownArrow",e.QuadArrow="quadArrow",e.LeftRightUpArrow="leftRightUpArrow",e.BentArrow="bentArrow",e.UturnArrow="uturnArrow",e.CircularArrow="circularArrow",e.NotchedRightArrow="notchedRightArrow",e.HomePlate="homePlate",e.Chevron="chevron",e.LeftCircularArrow="leftCircularArrow",e.LeftRightCircularArrow="leftRightCircularArrow",e))(Is||{}),vs=(e=>(e.Plaque="plaque",e.Can="can",e.Cube="cube",e.Bevel="bevel",e.Donut="donut",e.NoSmoking="noSmoking",e.BlockArc="blockArc",e.FoldedCorner="foldedCorner",e))(vs||{}),Os=(e=>(e.SmileyFace="smileyFace",e.Heart="heart",e.LightningBolt="lightningBolt",e.Sun="sun",e.Moon="moon",e.Cloud="cloud",e.Arc="arc",e.Backpack="backpack",e.Frame="frame",e.HalfFrame="halfFrame",e.Corner="corner",e.Chord="chord",e.Pie="pie",e.Teardrop="teardrop",e.WedgeRectCallout="wedgeRectCallout",e.WedgeRRectCallout="wedgeRRectCallout",e.WedgeEllipseCallout="wedgeEllipseCallout",e.CloudCallout="cloudCallout",e.BorderCallout1="borderCallout1",e.BorderCallout2="borderCallout2",e.BorderCallout3="borderCallout3",e.AccentCallout1="accentCallout1",e.AccentCallout2="accentCallout2",e.AccentCallout3="accentCallout3",e.Callout1="callout1",e.Callout2="callout2",e.Callout3="callout3",e.ActionButtonBackPrevious="actionButtonBackPrevious",e.ActionButtonEnd="actionButtonEnd",e.ActionButtonForwardNext="actionButtonForwardNext",e.ActionButtonHelp="actionButtonHelp",e.ActionButtonHome="actionButtonHome",e.ActionButtonInformation="actionButtonInformation",e.ActionButtonMovie="actionButtonMovie",e.ActionButtonReturn="actionButtonReturn",e.ActionButtonSound="actionButtonSound",e))(Os||{});const Ss={[Cn.OFFICE]:{[We.ACCENT1]:"#4472C4",[We.ACCENT2]:"#ED7D31",[We.ACCENT3]:"#A5A5A5",[We.ACCENT4]:"#70AD47",[We.ACCENT5]:"#5B9BD5",[We.ACCENT6]:"#70AD47",[We.DARK1]:"#000000",[We.DARK2]:"#44546A",[We.LIGHT1]:"#FFFFFF",[We.LIGHT2]:"#E7E6E6",[We.HYPERLINK]:"#0563C1",[We.FOLLOWED_HYPERLINK]:"#954F72"}};class In{constructor(){g(this,"_themeValue",We.LIGHT1);g(this,"_themeColors");g(this,"_themeTint");g(this,"_rgbValue","");g(this,"_colorType");this._colorType=ze.UNSUPPORTED,this._themeColors=Cn.OFFICE,this._themeTint=0}asRgbColor(){return new vn(this._rgbValue,this)}asThemeColor(){return new On(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case ze.THEME:return this.asThemeColor();case ze.RGB:return this.asRgbColor();case ze.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=ze.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=ze.THEME,this._themeColors=n}setThemeTint(n){this._colorType=ze.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=ze.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class yt{constructor(n){g(this,"_builder");this._builder=n}static rgbColorToHexValue(n){return`#${((1<<24)+(n.getRed()<<16)+(n.getGreen()<<8)+n.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(n){n?n.indexOf("#")>-1&&(n=n.substring(1)):n="#000000";const t=+`0x${n[0]}${n[1]}`,r=+`0x${n[2]}${n[3]}`,s=+`0x${n[4]}${n[5]}`;return new In().setRgbColor(`rgb(${t},${r},${s})`).asRgbColor()}static hexToRgbString(n){const t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(i,o,a,l)=>o+o+a+a+l+l);const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let s=null;if(r){const i=Number.parseInt(r[1],16),o=Number.parseInt(r[2],16),a=Number.parseInt(r[3],16);s=`rgba(${i},${o},${a})`}return s}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new yt(this._builder)}equals(n){return!1}}class Ns{constructor(n){g(this,"_saturation",0);g(this,"_hue",0);g(this,"_lightness",0);g(this,"_alpha",0);const t=n.getRed()/255,r=n.getGreen()/255,s=n.getBlue()/255,i=n.getAlpha()/255,o=Math.min(t,Math.min(r,s)),a=Math.max(t,Math.max(r,s)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),t===a&&(this._hue=(r-s)/l),r===a&&(this._hue=2+(s-t)/l),s===a&&(this._hue=4+(t-r)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const n=new In;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let t;this._lightness<.5?t=this._lightness*(1+this._saturation):t=this._lightness+this._saturation-this._lightness*this._saturation;const r=2*this._lightness-t,s=this._hue/360,i=s+1/3,o=this.setColor(t,r,i),a=this.setColor(t,r,s),l=s-1/3,d=this.setColor(t,r,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(d*255)},${this._alpha*255})`),n.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(n,t,r){r<0&&(r+=1),r>1&&(r-=1);let s;return 6*r<1?s=t+(n-t)*6*r:2*r<1?s=n:3*r<2?s=t+(n-t)*(2/3-r)*6:s=t,s}setLightness(n){this._lightness=n}}const Xe=class Xe extends yt{constructor(t,r){super(r);g(this,"_cssString");g(this,"_red");g(this,"_green");g(this,"_blue");g(this,"_alpha");let s=t.match(Xe.RGBA_EXTRACT);if(s){const i=+s[1],o=+s[2],a=+s[3],l=+s[4];this._cssString=t,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(s=t.match(Xe.RGB_EXTRACT),s){const i=+s[1],o=+s[2],a=+s[3];this._cssString=t,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return yt.rgbColorToHexValue(this)}getRed(){let t=this._red+Xe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getGreen(){let t=this._green+Xe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getBlue(){let t=this._blue+Xe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getAlpha(){return this._alpha}getColorType(){return ze.RGB}clone(){return new Xe(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(t){return t instanceof Xe?t._red===this._red&&t._blue===this._blue&&t._green===this._green&&t._alpha===this._alpha:!1}getCssString(){return this._cssString}};g(Xe,"RGB_COLOR_AMT",0),g(Xe,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),g(Xe,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let vn=Xe;const Nt=class Nt extends yt{constructor(t,r,s,i){super(i);g(this,"_themeColorType");g(this,"_themeTint");g(this,"_themeColors");this._themeColorType=t,this._themeTint=r,this._themeColors=s}lumValue(t,r){if(t==null)return r;let s;return t<0?s=r*(1+t):s=r*(1-t)+(255-255*(1-t)),s}asRgbColor(){const t=Ss[this._themeColors];if(t==null)throw new Error("not find themeColors type");const r=t[this._themeColorType];if(r==null)throw new Error("not find themeColors value");let s;if(Nt._cacheThemeColor.has(this._themeColors)){if(s=Nt._cacheThemeColor.get(this._themeColors),s.has(this._themeColorType))return s.get(this._themeColorType)}else s=new Map,Nt._cacheThemeColor.set(this._themeColors,s);const i=new Ns(yt.hexValueToRgbColor(r));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return s.set(this._themeColorType,o),o}clone(){return new Nt(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(t){return t instanceof Nt?t._themeColorType===this._themeColorType:!1}getColorType(){return ze.THEME}getThemeColorType(){return this._themeColorType}};g(Nt,"_cacheThemeColor",new Map);let On=Nt;const Ga="rgb(",Va="rgba(",Zn={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class tt{constructor(n){g(this,"_color");g(this,"_rgbColor");g(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof tt){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const t=ws(n);if(t==null){this._setNullColor();return}this._color=t;const r=Xa(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}static mix(n,t,r){var d,h;r=Math.min(1,Math.max(0,r));const s=new tt(n).toRgb(),i=new tt(t).toRgb(),o=(d=s.a)!=null?d:1,a=(h=i.a)!=null?h:1,l={r:(i.r-s.r)*r+s.r,g:(i.g-s.g)*r+s.g,b:(i.b-s.b)*r+s.b,a:(a-o)*r+o};return new tt(l)}static getContrastRatio(n,t){const r=new tt(n).getLuminance(),s=new tt(t).getLuminance();return(Math.max(r,s)+.05)/(Math.min(r,s)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:t,b:r,a:s=1}=this.toRgb(),i=s<1;return`rgb${i?"a":""}(${n},${t},${r}${i?`,${s}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:t,g:r,b:s,a:i=1}=this.toRgb(),o=i<1,a=[Sn(Math.round(t).toString(16)),Sn(Math.round(r).toString(16)),Sn(Math.round(s).toString(16)),Sn(Math.round(i*255).toString(16))];return n&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Ja(this.toRgb())}toHsl(){return Za(this.toRgb())}lighten(n=10){const t=this.toHsl();return t.l+=n,t.l=Math.min(Math.max(t.l,0),100),new tt(t)}darken(n=10){const t=this.toHsl();return t.l-=n,t.l=Math.min(Math.max(t.l,0),100),new tt(t)}setAlpha(n){return new tt({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:t,b:r}=this.toRgb();return n=Jn(n),t=Jn(t),r=Jn(r),Number((.2126*n+.7152*t+.0722*r).toFixed(3))}getBrightness(){const{r:n,g:t,b:r}=this.toRgb();return(n*299+t*587+r*114)/1e3}getAlpha(){var n;return(n=this._color.a)!=null?n:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const Sn=e=>e.length===1?`0${e}`:e,Jn=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),ws=e=>{if(tl(e)){if("r"in e){const r={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(r.a=e.a),r}if("l"in e){const r={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(r.a=e.a),r}const t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}const n=e.trim();if(Zn[n]){const t=Zn[n],r={r:Math.round(t[0]),g:Math.round(t[1]),b:Math.round(t[2])};return r.a=t[3]||1,r}if(n.startsWith("#"))return xa(n);if(n.startsWith("rgb"))return Ka(n);if(n.startsWith("hsl"))return za(n);if(n.startsWith("hsv"))return Ya(n)},xa=e=>{const n=e.substring(1),t=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let r=n.match(t);if(!r||r.length<3)throw new Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(i=>i+i));const s={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(s.a=Number.parseInt(r[3],16)/255),s},Ka=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal rgb color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal rgb color`);const r={r:Number.parseInt(t[0],10),g:Number.parseInt(t[1],10),b:Number.parseInt(t[2],10)};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},za=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsl color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsl color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),l:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Ya=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsv color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsv color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),v:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Xa=e=>{const n=ws(e);if(n!=null)return"r"in n?n:"l"in n?Qa(n):qa(n)},er=(e,n,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+(n-e)*6*t:t<1/2?n:t<2/3?e+(n-e)*(2/3-t)*6:e),Qa=e=>{let{h:n,s:t,l:r}=e;n/=360,t/=100,r/=100;let s=0,i=0,o=0;if(t===0)s=i=o=r;else{const l=r<.5?r*(1+t):r+t-r*t,d=2*r-l;s=er(d,l,n+1/3),i=er(d,l,n),o=er(d,l,n-1/3)}const a={r:Math.round(s*255),g:Math.round(i*255),b:Math.round(o*255)};return e.a!==void 0&&(a.a=e.a),a},qa=e=>{let{h:n,s:t,v:r}=e;n=n/360*6,t/=100,r/=100;const s=Math.floor(n),i=n-s,o=r*(1-t),a=r*(1-i*t),l=r*(1-(1-i)*t),d=s%6,h=[r,a,o,o,l,r][d],c=[l,r,r,a,o,o][d],f=[o,o,l,r,r,a][d],_={r:h*255,g:c*255,b:f*255};return e.a!==void 0&&(_.a=e.a),_},Za=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),i=Math.min(n,t,r),o=(s+i)/2;let a,l;if(s===i)a=l=0;else{const h=s-i;switch(l=o>.5?h/(2-s-i):h/(s+i),s){case n:a=(t-r)/h+(t<r?6:0);break;case t:a=(r-n)/h+2;break;default:a=(n-t)/h+4;break}a/=6}const d={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return e.a!==void 0&&(d.a=e.a),d},Ja=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),i=Math.min(n,t,r);let o;const a=s,l=s-i,d=s===0?0:l/s;if(s===i)o=0;else{switch(s){case n:o=(t-r)/l+(t<r?6:0);break;case t:o=(r-n)/l+2;break;default:o=(n-t)/l+4;break}o/=6}const h={h:Math.round(o*360),s:Math.round(d*100),v:Math.round(a*100)};return e.a!==void 0&&(h.a=e.a),h},el=e=>e==null,tl=e=>!el(e)&&typeof e=="object";function nl(e){const n=/^#(?:[0]{3}|[0]{6})\b/,t=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,r=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||i.test(e))}function rl(e){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,t=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,r=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||i.test(e))}var Fe=(e=>(e[e.COVER=0]="COVER",e[e.REPLACE=1]="REPLACE",e[e.INTERSECTION=2]="INTERSECTION",e))(Fe||{});function sl(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)}function il(e){if(e.t!==void 0)return e.t;if(typeof e.v=="string")return Tt.STRING;if(typeof e.v=="number")return Tt.NUMBER;if(typeof e.v=="boolean")return Tt.BOOLEAN}function ol(e){if(e==null)return!0;const{v:n,f:t,si:r,p:s,s:i,custom:o}=e;return!(!(n==null||typeof n=="string"&&n.length===0)||t!=null&&t.length>0||r!=null&&r.length>0||s!=null||o!=null)}function al(e){return e!=null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}var bs=(e=>(e[e.character=0]="character",e[e.paragraph=1]="paragraph",e[e.table=2]="table",e[e.numbering=3]="numbering",e))(bs||{}),As=(e=>(e[e.TAB=0]="TAB",e[e.SPACE=1]="SPACE",e[e.NOTHING=2]="NOTHING",e))(As||{}),Zt=(e=>(e[e.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.DECIMAL=2]="DECIMAL",e[e.ZERO_DECIMAL=3]="ZERO_DECIMAL",e[e.UPPER_ALPHA=4]="UPPER_ALPHA",e[e.ALPHA=5]="ALPHA",e[e.UPPER_ROMAN=6]="UPPER_ROMAN",e[e.ROMAN=7]="ROMAN",e))(Zt||{}),Rt=(e=>(e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Rt||{}),Ts=(e=>(e[e.HYPERLINK=0]="HYPERLINK",e[e.FIELD=1]="FIELD",e[e.SDT=2]="SDT",e[e.BOOKMARK=3]="BOOKMARK",e[e.COMMENT=4]="COMMENT",e[e.CUSTOM=5]="CUSTOM",e[e.MENTION=6]="MENTION",e[e.UNI_FORMULA=7]="UNI_FORMULA",e))(Ts||{}),ys=(e=>(e[e.COMMENT=0]="COMMENT",e))(ys||{}),Ds=(e=>(e[e.DRAWING=0]="DRAWING",e[e.CUSTOM=1]="CUSTOM",e))(Ds||{}),Ms=(e=>(e[e.TRADITIONAL=0]="TRADITIONAL",e[e.MODERN=1]="MODERN",e))(Ms||{}),Us=(e=>(e[e.DEFAULT=0]="DEFAULT",e[e.LINES=1]="LINES",e[e.LINES_AND_CHARS=2]="LINES_AND_CHARS",e[e.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",e))(Us||{}),Ls=(e=>(e[e.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",e[e.CONTINUOUS=1]="CONTINUOUS",e[e.NEXT_PAGE=2]="NEXT_PAGE",e[e.EVEN_PAGE=3]="EVEN_PAGE",e[e.ODD_PAGE=4]="ODD_PAGE",e))(Ls||{}),Ps=(e=>(e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",e))(Ps||{}),ks=(e=>(e[e.NORMAL=0]="NORMAL",e[e.TBRL=1]="TBRL",e[e.LRTBV=2]="LRTBV",e))(ks||{}),Fs=(e=>(e[e.TEXT_RUN=0]="TEXT_RUN",e[e.AUTO_TEXT=1]="AUTO_TEXT",e[e.PAGE_BREAK=2]="PAGE_BREAK",e[e.COLUMN_BREAK=3]="COLUMN_BREAK",e[e.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",e[e.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",e[e.EQUATION=6]="EQUATION",e[e.DRAWING=7]="DRAWING",e[e.PERSON=8]="PERSON",e[e.RICH_LINK=9]="RICH_LINK",e))(Fs||{}),Hs=(e=>(e[e.BOTH_SIDES=0]="BOTH_SIDES",e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.LARGEST=3]="LARGEST",e))(Hs||{}),$s=(e=>(e[e.INLINE=0]="INLINE",e[e.WRAP_NONE=1]="WRAP_NONE",e[e.WRAP_POLYGON=2]="WRAP_POLYGON",e[e.WRAP_SQUARE=3]="WRAP_SQUARE",e[e.WRAP_THROUGH=4]="WRAP_THROUGH",e[e.WRAP_TIGHT=5]="WRAP_TIGHT",e[e.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",e))($s||{}),Ws=(e=>(e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",e[e.NORMAL_TEXT=1]="NORMAL_TEXT",e[e.TITLE=2]="TITLE",e[e.SUBTITLE=3]="SUBTITLE",e[e.HEADING_1=4]="HEADING_1",e[e.HEADING_2=5]="HEADING_2",e[e.HEADING_3=6]="HEADING_3",e[e.HEADING_4=7]="HEADING_4",e[e.HEADING_5=8]="HEADING_5",e[e.HEADING_6=9]="HEADING_6",e))(Ws||{}),Bs=(e=>(e[e.AUTO=0]="AUTO",e[e.AT_LEAST=1]="AT_LEAST",e[e.EXACT=2]="EXACT",e))(Bs||{}),js=(e=>(e[e.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",e[e.SOLID=1]="SOLID",e[e.DOT=2]="DOT",e[e.DASH=3]="DASH",e))(js||{}),Gs=(e=>(e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Gs||{}),Vs=(e=>(e.EVENLY_DISTRIBUTED="0",e.FIXED_WIDTH="1",e))(Vs||{}),xs=(e=>(e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",e[e.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",e[e.TOP=2]="TOP",e[e.MIDDLE=3]="MIDDLE",e[e.BOTTOM=4]="BOTTOM",e))(xs||{}),Ks=(e=>(e.NORMAL="normal",e.BOLD="bold",e.ITALIC="italic",e))(Ks||{}),zs=(e=>(e[e.PAGE=0]="PAGE",e[e.COLUMN=1]="COLUMN",e[e.CHARACTER=2]="CHARACTER",e[e.MARGIN=3]="MARGIN",e[e.INSIDE_MARGIN=4]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",e[e.LEFT_MARGIN=6]="LEFT_MARGIN",e[e.RIGHT_MARGIN=7]="RIGHT_MARGIN",e))(zs||{}),Ys=(e=>(e[e.PAGE=0]="PAGE",e[e.PARAGRAPH=1]="PARAGRAPH",e[e.LINE=2]="LINE",e[e.MARGIN=3]="MARGIN",e[e.TOP_MARGIN=4]="TOP_MARGIN",e[e.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",e[e.INSIDE_MARGIN=6]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",e))(Ys||{}),Xs=(e=>(e[e.POINT=0]="POINT",e[e.LINE=1]="LINE",e[e.CHARACTER=2]="CHARACTER",e[e.PIXEL=3]="PIXEL",e))(Xs||{}),Qs=(e=>(e[e.CENTER=0]="CENTER",e[e.INSIDE=1]="INSIDE",e[e.LEFT=2]="LEFT",e[e.OUTSIDE=3]="OUTSIDE",e[e.RIGHT=4]="RIGHT",e[e.BOTH=5]="BOTH",e[e.DISTRIBUTE=6]="DISTRIBUTE",e))(Qs||{}),qs=(e=>(e[e.BOTTOM=0]="BOTTOM",e[e.CENTER=1]="CENTER",e[e.INSIDE=2]="INSIDE",e[e.OUTSIDE=3]="OUTSIDE",e[e.TOP=4]="TOP",e))(qs||{}),Zs=(e=>(e[e.compressPunctuation=0]="compressPunctuation",e[e.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",e[e.doNotCompress=2]="doNotCompress",e))(Zs||{}),Js=(e=>(e[e.PORTRAIT=0]="PORTRAIT",e[e.LANDSCAPE=1]="LANDSCAPE",e))(Js||{}),ei=(e=>(e[e.forward=0]="forward",e[e.backward=1]="backward",e[e.front=2]="front",e[e.back=3]="back",e))(ei||{}),ti=(e=>(e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e[e.DRAWING_IMAGE=0]="DRAWING_IMAGE",e[e.DRAWING_SHAPE=1]="DRAWING_SHAPE",e[e.DRAWING_CHART=2]="DRAWING_CHART",e[e.DRAWING_TABLE=3]="DRAWING_TABLE",e[e.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",e[e.DRAWING_VIDEO=5]="DRAWING_VIDEO",e[e.DRAWING_GROUP=6]="DRAWING_GROUP",e[e.DRAWING_UNIT=7]="DRAWING_UNIT",e[e.DRAWING_DOM=8]="DRAWING_DOM",e))(ti||{}),oe=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(oe||{}),Oe=(e=>(e[e.NONE=0]="NONE",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(Oe||{});function ll(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}function ul(e,n,t){let r=!1,s=!1,i=e,o=n,a=e,l=n;if(t==null)return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:i,endColumn:o,startRow:a,startColumn:l};for(let d=0;d<t.length;d++){const{startRow:h,endRow:c,startColumn:f,endColumn:_}=t[d];if(e===h&&n===f){i=c,o=_,a=h,l=f,s=!0;break}if(e>=h&&e<=c&&n>=f&&n<=_){i=c,o=_,a=h,l=f,r=!0;break}}return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:i,endColumn:o,startRow:a,startColumn:l}}var tr=(e=>(e[e.SLIDE=0]="SLIDE",e[e.MASTER=1]="MASTER",e[e.LAYOUT=2]="LAYOUT",e[e.HANDOUT_MASTER=3]="HANDOUT_MASTER",e[e.NOTES_MASTER=4]="NOTES_MASTER",e))(tr||{}),ni=(e=>(e[e.SHAPE=0]="SHAPE",e[e.IMAGE=1]="IMAGE",e[e.TEXT=2]="TEXT",e[e.SPREADSHEET=3]="SPREADSHEET",e[e.DOCUMENT=4]="DOCUMENT",e[e.SLIDE=5]="SLIDE",e))(ni||{}),ri=(e=>(e[e.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",e[e.NEXT_SLIDE=1]="NEXT_SLIDE",e[e.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",e[e.FIRST_SLIDE=3]="FIRST_SLIDE",e[e.LAST_SLIDE=4]="LAST_SLIDE",e))(ri||{});const cl="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let hl=e=>crypto.getRandomValues(new Uint8Array(e)),dl=(e,n,t)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,s=-~(1.6*r*n/e.length);return(i=n)=>{let o="";for(;;){let a=t(s),l=s;for(;l--;)if(o+=e[a[l]&r]||"",o.length===i)return o}}},fl=(e,n=21)=>dl(e,n,hl),_l=(e=21)=>{let n="",t=crypto.getRandomValues(new Uint8Array(e));for(;e--;)n+=cl[t[e]&63];return n};const gl=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"]),ml=new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[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 El(e){if(!Number.isNaN(+e))return!1;if(e.startsWith("http://localhost:3002")||e.startsWith("localhost:3002"))return!0;if(ml.test(e)){if(si(e))return!0;try{const r=new URL(ii(e)).hostname.split(".").pop();if(r&&gl.has(r))return!0}catch{return!1}}return!1}function si(e){return/^[a-zA-Z]+:\/\//.test(e)}function pl(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function ii(e){return si(e)?e:pl(e)?`mailto://${e}`:`https://${e}`}const Rl=/^-ms-/,Cl=/-([a-z])/g,Ct=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class k{static stringAt(n){let t="",r=n;for(;r>=Ct.length;)r/=Ct.length,r-=1,t+=Ct[r%Ct.length];const s=n%Ct.length;return t+=Ct[s],t}static indexAt(n){let t=0;for(let r=0;r<n.length-1;r+=1){const s=n.charCodeAt(r)-65,i=n.length-1-r;t+=Ct.length**i+Ct.length*s}return t+=n.charCodeAt(n.length-1)-65,t}static deleteBlank(n){return k.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,t=navigator.platform==="Win32"||navigator.platform==="Windows",r=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(r)return"Mac";if(navigator.platform==="X11"&&!t&&!r)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(t){if(n.indexOf("Windows NT 5.0")>-1||n.indexOf("Windows 2000")>-1)return"Windows 2000";if(n.indexOf("Windows NT 5.1")>-1||n.indexOf("Windows XP")>-1)return"Windows XP";if(n.indexOf("Windows NT 5.2")>-1||n.indexOf("Windows 2003")>-1)return"Windows 2003";if(n.indexOf("Windows NT 6.0")>-1||n.indexOf("Windows Vista")>-1)return"Windows Vista";if(n.indexOf("Windows NT 6.1")>-1||n.indexOf("Windows 7")>-1)return"Windows 7";if(n.indexOf("Windows NT 10")>-1||n.indexOf("Windows 10")>-1)return"Windows 10";if(n.indexOf("Windows NT 11")>-1||n.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const n=navigator.userAgent,t=n.indexOf("Opera")>-1,r=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!t,s=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,i=n.indexOf("Edge")>-1,o=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(r){new RegExp("MSIE (\\d+\\.\\d+);").test(n);const h=Number.parseFloat(RegExp.$1);return h===7?"IE7":h===8?"IE8":h===9?"IE9":h===10?"IE10":"0"}return o?"FF":t?"Opera":a?"Safari":l?"Chrome":i?"Edge":s?"IE11":"Unknown browser"}static generateRandomId(n=21,t){return oi(n,t)}static getClassName(n){return n.constructor.name}static deepMerge(n,...t){t.forEach(o=>o&&i(o));function r(o,a){o.forEach((l,d)=>{var h,c;if(k.isArray(l)){const f=(h=a[d])!=null?h:[];a[d]=f,r(l,f);return}if(k.isObject(l)){const f=(c=a[d])!=null?c:{};a[d]=f,s(l,f);return}a[d]=l})}function s(o,a){Object.keys(o).forEach(l=>{var h,c;const d=o[l];if(k.isObject(d)){const f=(h=a[l])!=null?h:{};a[l]=f,s(d,f);return}if(k.isArray(d)){const f=(c=a[l])!=null?c:[];a[l]=f,r(d,f);return}a[l]=d})}function i(o){Object.keys(o).forEach(a=>{var d,h;const l=o[a];if(k.isArray(l)){const c=(d=n[a])!=null?d:[];n[a]=c,r(l,c);return}if(k.isObject(l)){const c=(h=n[a])!=null?h:{};n[a]=c,s(l,c);return}n[a]=l})}return n}static numberFixed(n,t){return Number(Number(n).toFixed(t))}static diffValue(n,t){function r(o,a){const l=k.getValueType(o),d=k.getValueType(a);return l!==d?!1:k.isArray(o)?s(o,a):k.isObject(o)?i(o,a):k.isDate(o)?o.getTime()===a.getTime():k.isRegExp(o)?o.toString()===a.toString():o===a}function s(o,a){if(n.length!==t.length)return!1;for(let l=0,d=o.length;l<d;l++){const h=o[l],c=a[l];if(!r(h,c))return!1}return!0}function i(o,a){const l=Object.keys(o),d=Object.keys(a);if(l.length!==d.length)return!1;for(const h of l){if(!d.includes(h))return!1;const c=o[h],f=a[h];if(!r(c,f))return!1}return!0}return r(n,t)}static deepClone(n){if(!this.isDefine(n))return n;if(this.isRegExp(n))return new RegExp(n);if(this.isDate(n))return new Date(n);if(this.isArray(n)){const t=[];return n.forEach((r,s)=>{t[s]=k.deepClone(r)}),t}if(this.isObject(n)){const t={};return Object.keys(n).forEach(r=>{const s=n[r];t[r]=k.deepClone(s)}),Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}return n}static getLanguage(){const n="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||n}static getValueType(n){return Object.prototype.toString.apply(n)}static isDefine(n){return n!=null}static isBlank(n){return this.isDefine(n)?this.isString(n)?n.trim()==="":!1:!0}static isAssignableFrom(n,t){return n instanceof t}static isBoolean(n){return this.getValueType(n)==="[object Boolean]"}static isPlainObject(n){return this.isDefine(n)?Object.getPrototypeOf(n)===Object.getPrototypeOf({}):!1}static isFunction(n){return this.getValueType(n)==="[object Function]"}static isDate(n){return this.getValueType(n)==="[object Date]"}static isRegExp(n){return this.getValueType(n)==="[object RegExp]"}static isArray(n){return this.getValueType(n)==="[object Array]"}static isString(n){return this.getValueType(n)==="[object String]"}static isNumber(n){return this.getValueType(n)==="[object Number]"}static isStringNumber(n){return!isNaN(Number.parseFloat(n))&&isFinite(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isEmptyObject(n){for(const t in n)return!1;return!0}static isMobile(){let n=0,t=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(t=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&t<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const n=navigator.userAgent.toLowerCase();return String(n.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const n=navigator.userAgent;return n.indexOf("Android")>-1||n.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(n){return El(n)}static normalizeUrl(n){return ii(n)}static itCount(n){return t=>{for(let r=0;r<n;r++)t&&t()}}static hasLength(n,t){return k.isDefine(n)?k.isDefine(t)?n.length===t:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,t){return t.toUpperCase()}static camelCase(n){return n.replace(Rl,"ms-").replace(Cl,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(t=>{const r=n[t];r==null?delete n[t]:k.removeNull(r)}),n}static fillTwoDimensionalArray(n,t,r){return new Array(n).fill(r).map(s=>new Array(t).fill(r))}static numToWord(n){let t="";for(;n>0;){let r=n%26;r=r===0?r=26:r,t=String.fromCharCode(96+r)+t,n=(n-r)/26}return t.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const t=n.toLowerCase().split(""),r=t.length;let s=0,i=0;for(let o=0;o<r;o++)i=t[o].charCodeAt(0)-96,s+=i*26**(r-o-1);return s===0?Number.NaN:s-1}static chatAtABC(n){let i="";for(;n>=0;)i=String.fromCharCode(n%26+97)+i,n=Math.floor(n/26)-1;return i.toUpperCase()}static randSort(n){for(let t=0,r=n.length;t<r;t++){const s=Number.parseInt((Math.random()*r).toString()),i=n[s];n[s]=n[t],n[t]=i}return n}static commonExtend(n,t){const r={};for(const s in n)r[s]=n[s];for(const s in t)t[s]!=null&&(r[s]=t[s]);return r}static commonExtend1(n,t){for(const r in n)t[r]==null&&(t[r]=n[r]);return t}static arrayToObject(n){const t={};return n.forEach((r,s)=>{t[s]={},r.forEach((i,o)=>{t[s][o]=i})}),t}static hasIntersectionBetweenTwoRanges(n,t,r,s){return t>=r&&s>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),r=n.length<=255;return!t&&r}static set(n,t,r){const s=t.split("."),i=s.pop();s.forEach(o=>{n[o]||(n[o]={}),n=n[o]}),i&&(n[i]=r)}static clamp(n,t,r){return Math.max(t,Math.min(r,n))}}function oi(e=21,n){return n?fl(n,e)():_l(e)}function Il(e){const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,mergeInfo:i}=e;let{startY:o,endY:a,startX:l,endX:d}=e,h=n,c=t,f=n,_=t;if(r&&i){const{startRow:E,startColumn:p,endRow:N,endColumn:D,startY:te,endY:me,startX:fe,endX:R}=i;h=E,c=p,f=N,_=D,o=te,a=me,l=fe,d=R}return s&&(o=i.startY,a=i.endY,l=i.startX,d=i.endX,f=i.endRow,_=i.endColumn),{startRow:h,startColumn:c,endRow:f,endColumn:_,startY:o,endY:a,startX:l,endX:d}}function vl(e){if(!e)return;const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,startRow:i,startColumn:o,endRow:a,endColumn:l}=e;let d=n,h=t,c=n,f=t;return(r||s)&&(d=i,h=o,c=a,f=l),{startRow:d,startColumn:h,endRow:c,endColumn:f}}function ai(e){var t;return!e||(((t=e==null?void 0:e.v)==null?void 0:t.toString())||"").length===0&&!e.p}function Ol(e){return ai(e)&&(e==null?void 0:e.coverable)!==!1}function lt(e){if(e){if(e.rgb)return e.rgb;if(e.th)return new In().setThemeColor(e.th).asThemeColor().asRgbColor().getCssString()}return null}function Sl(e){return k.isString(e)&&e.substring(0,1)==="="&&e.length>1}function Nl(e){return k.isString(e)&&e.length>0}function wl(e,n=!1){var i;let t="";const r=new Map([["ff",()=>{e.ff&&(t+=`font-family: ${e.ff}; `)}],["fs",()=>{if(e.fs){let o=e.fs;e.va&&(o/=2),t+=`font-size: ${o}pt; `}}],["it",()=>{e.it&&(t+="font-style: italic; ")}],["bl",()=>{e.bl&&(t+="font-weight: bold; ")}],["ul",()=>{var o;(o=e.ul)!=null&&o.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):t+="text-decoration: underline; ",e.ul.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${lt(e.ul.cl)}; `),e.ul.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ul.t} `))}],["st",()=>{var o;(o=e.st)!=null&&o.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):t+="text-decoration-line: line-through; ",e.st.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${lt(e.st.cl)}; `),e.st.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.st.t} `))}],["ol",()=>{var o;(o=e.ol)!=null&&o.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):t+="text-decoration-line: overline; ",e.ol.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${lt(e.ol.cl)}; `),e.ol.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ol.t} `))}],["bg",()=>{e.bg&&(t+=`background: ${lt(e.bg)}; `)}],["bd",()=>{var o,a,l,d,h,c,f,_,E,p,N,D;(o=e.bd)!=null&&o.b&&(t+=`border-bottom: ${Nn((a=e.bd)==null?void 0:a.b.s)} ${(l=lt(e.bd.b.cl))!=null?l:""}; `),(d=e.bd)!=null&&d.t&&(t+=`border-top: ${Nn((h=e.bd)==null?void 0:h.t.s)} ${(c=lt(e.bd.t.cl))!=null?c:""}; `),(f=e.bd)!=null&&f.r&&(t+=`border-right: ${Nn((_=e.bd)==null?void 0:_.r.s)} ${(E=lt(e.bd.r.cl))!=null?E:""}; `),(p=e.bd)!=null&&p.l&&(t+=`border-left: ${Nn((N=e.bd)==null?void 0:N.l.s)} ${(D=lt(e.bd.l.cl))!=null?D:""}; `)}],["cl",()=>{e.cl&&(t+=`color: ${lt(e.cl)}; `)}],["va",()=>{e.va===jt.SUBSCRIPT?t+="vertical-align: sub; ":e.va===jt.SUPERSCRIPT&&(t+="vertical-align: super; ")}],["td",()=>{e.td===qt.LEFT_TO_RIGHT?t+="direction: ltr; ":e.td===qt.RIGHT_TO_LEFT&&(t+="direction: rtl; ")}],["tr",()=>{var o,a,l;e.tr&&(t+=`--data-rotate: (${(o=e.tr)==null?void 0:o.a}deg${(a=e.tr)!=null&&a.v?` ,${(l=e.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{e.ht===At.LEFT?t+="text-align: left; ":e.ht===At.RIGHT?t+="text-align: right; ":e.ht===At.CENTER?t+="text-align: center; ":e.ht===At.JUSTIFIED&&(t+="text-align: justify; ")}],["vt",()=>{e.vt===Wt.BOTTOM?t+="vertical-align: bottom; ":e.vt===Wt.TOP?t+="vertical-align: top; ":e.vt===Wt.MIDDLE&&(t+="vertical-align: middle; ")}],["tb",()=>{e.tb===Bt.CLIP?t+="white-space: nowrap; overflow-x: hidden; ":e.tb===Bt.WRAP&&(t+="white-space: normal;")}],["pd",()=>{var h,c,f,_,E,p,N,D;const o=`${(h=e.pd)==null?void 0:h.b}pt`,a=`${(c=e.pd)==null?void 0:c.t}pt`,l=`${(f=e.pd)==null?void 0:f.l}pt`,d=`${(_=e.pd)==null?void 0:_.r}pt`;(E=e.pd)!=null&&E.b&&(t+=`padding-bottom: ${o}; `),(p=e.pd)!=null&&p.t&&(t+=`padding-top: ${a}; `),(N=e.pd)!=null&&N.l&&(t+=`padding-left: ${l}; `),(D=e.pd)!=null&&D.r&&(t+=`padding-right: ${d}; `)}]]),s=["bd","tr","tb"];for(const o in e)n&&s.includes(o)||(i=r.get(o))==null||i();return t}function Nn(e){let n="";return e===he.NONE?n="none":e===he.THIN?n="0.5pt solid":e===he.HAIR?n="0.5pt double":e===he.DOTTED?n="0.5pt dotted":e===he.DASHED||e===he.DASH_DOT?n="0.5pt dashed":e===he.DASH_DOT_DOT?n="0.5pt dotted":e===he.DOUBLE?n="0.5pt double":e===he.MEDIUM?n="1pt solid":e===he.MEDIUM_DASHED||e===he.MEDIUM_DASH_DOT?n="1pt dashed":e===he.MEDIUM_DASH_DOT_DOT?n="1pt dotted":e===he.SLANT_DASH_DOT?n="0.5pt dashed":e===he.THICK&&(n="1.5pt solid"),n}function bl(e){let n=0;if(e=e.trim(),e==="none")n=he.NONE;else if(e==="0.5pt solid")n=he.THIN;else if(e==="0.5pt double")n=he.HAIR;else if(e==="0.5pt dotted")n=he.DOTTED;else if(e==="0.5pt dashed")n=he.DASHED;else if(e==="1pt solid")n=he.MEDIUM;else if(e==="1pt dashed")n=he.MEDIUM_DASHED;else if(e==="1pt dotted")n=he.MEDIUM_DASH_DOT_DOT;else if(e==="1.5pt solid")n=he.THICK;else if(!e.includes("none"))n=he.THIN;else return he.NONE;return n}function Al(e,n){let t=e.body;if(n){const{headers:r,footers:s}=e;r!=null&&r[n]?t=r[n].body:s!=null&&s[n]&&(t=s[n].body)}return t}function Tl(e){const{startRow:n,endRow:t,startColumn:r,endColumn:s,rangeType:i}=e;return!(n<0||r<0||t<0||s<0||!(Number.isNaN(n)&&Number.isNaN(t))&&i===oe.COLUMN||!(Number.isNaN(r)&&Number.isNaN(s))&&i===oe.ROW||i!==oe.ROW&&i!==oe.COLUMN&&(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(s)||Number.isNaN(t)))}function yl(e,n){return{startRow:e,endRow:e,startColumn:n,endColumn:n}}function nr(e,n){return Object.prototype.toString.call(e)===Object.prototype.toString.call(n)?Object.prototype.toString.call(e)==="[object Object]"||Object.prototype.toString.call(e)==="[object Array]"?Object.keys(e).length!==Object.keys(n).length?!1:Object.keys(e).every(t=>nr(e[t],n[t])):e===n:!1}function li(e,n){const t=e.ts||{},r=n.ts||{};return e.sId!==n.sId?!1:nr(t,r)}function Dl(e,n){return n.some(t=>e.indexOf(t)>-1)}function wn(e,n,t,r){if(e>n&&([e,n]=[n,e]),t>r&&([t,r]=[r,t]),n<t||r<e)return[e,n];t<e&&(t=e),r>n&&(r=n);const s=r-t+1;let i=[];return e===t?i=[r+1-s,n-s]:n===r?i=[e,t-1]:i=[e,n-s],i}function Ml(e){if(e==null)return!1;const n=e.bullet;return(n==null?void 0:n.listId)!=null}function Ul(e){if(e==null)return!1;const n=e.paragraphStyle;return ui(n)}function ui(e){var n;return!(e==null||(e.indentStart==null||e.indentStart.v===0)&&e.hanging==null||((n=e.hanging)==null?void 0:n.v)===0)}function ci(e,n,t){return e.slice(0,n)+t+e.slice(n)}function hi(e,n,t){return n>t?e:e.slice(0,n)+e.slice(t)}function Ll(e){return e===null||e.toString().replace(/\s/g,"")===""||typeof e=="boolean"?!1:!isNaN(e)}function Pl(e){let n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+(n<<6)+(n<<16)-n;return n>>>0}function di(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function fi(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var r=t.call(e),s,i=[],o;try{for(;(n===void 0||n-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i}function _i(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,i;r<s;r++)(i||!(r in n))&&(i||(i=Array.prototype.slice.call(n,0,r)),i[r]=n[r]);return e.concat(i||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;function Jt(e){return typeof e=="function"}function kl(e){var n=function(r){Error.call(r),r.stack=new Error().stack},t=e(n);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var rr=kl(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
+ `+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function gi(e,n){if(e){var t=e.indexOf(n);0<=t&&e.splice(t,1)}}var mi=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,t,r,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=di(o),l=a.next();!l.done;l=a.next()){var d=l.value;d.remove(this)}}catch(p){n={error:p}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}else o.remove(this);var h=this.initialTeardown;if(Jt(h))try{h()}catch(p){i=p instanceof rr?p.errors:[p]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var f=di(c),_=f.next();!_.done;_=f.next()){var E=_.value;try{Ei(E)}catch(p){i=i!=null?i:[],p instanceof rr?i=_i(_i([],fi(i)),fi(p.errors)):i.push(p)}}}catch(p){r={error:p}}finally{try{_&&!_.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(i)throw new rr(i)}},e.prototype.add=function(n){var t;if(n&&n!==this)if(this.closed)Ei(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(n)}},e.prototype._hasParent=function(n){var t=this._parentage;return t===n||Array.isArray(t)&&t.includes(n)},e.prototype._addParent=function(n){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(n),t):t?[t,n]:n},e.prototype._removeParent=function(n){var t=this._parentage;t===n?this._parentage=null:Array.isArray(t)&&gi(t,n)},e.prototype.remove=function(n){var t=this._finalizers;t&&gi(t,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}();mi.EMPTY;function Fl(e){return e instanceof mi||e&&"closed"in e&&Jt(e.remove)&&Jt(e.add)&&Jt(e.unsubscribe)}function Ei(e){Jt(e)?e():e.unsubscribe()}function Se(e){let n=!1;return e?Fl(e)?{dispose:()=>e.unsubscribe()}:typeof e=="function"?{dispose:()=>{n||(n=!0,e())}}:e:Se(()=>{})}function Hl(e){return Se(()=>{e.unsubscribe()})}class sr{constructor(){g(this,"_disposables",new Set)}add(n){const t=Se(n);return this._disposables.add(t),{dispose:()=>{t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Te{constructor(){g(this,"_disposed",!1);g(this,"_collection",new sr)}disposeWithMe(n){return this._collection.add(n)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class $l extends Te{constructor(){super(...arguments);g(this,"dispose$",new W.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Wl extends Te{constructor(t){super();g(this,"_ref",0);this._rootDisposable=t}inc(){if(this._disposed)throw new Error("[RCDisposable]: should not ref to a disposed.");this._ref+=1}dec(){this._ref-=1,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}}class en{static hasLength(n,t){return n.length===t}static getValueType(n){return Object.prototype.toString.apply(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isIterable(n){return n[Symbol.iterator]!=null}static isNumber(n){return this.getValueType(n)==="[object Number]"}}function bn(e,n){const t=e.indexOf(n);return t>-1?(e.splice(t,1),!0):!1}function Bl(e){const n=new Set,t=[];for(const r of e)n.has(r)||(n.add(r),t.push(r));return t}function jl(e,n){for(let t=e.length-1;t>-1;t--){const r=e[t];if(n(r,t))return r}return null}function Gl(e,n){if(e.length===0)return e;const t=n%e.length;return e.slice(t).concat(e.slice(0,t))}function Vl(e,n){const t=new Map;return e.forEach(r=>{const s=n(r);let i=t.get(s);t.has(s)||(i=[],t.set(s,i)),i.push(r)}),t}function xl(e){return Array.isArray(e)?e:[e]}const ce=Symbol("newer"),ye=Symbol("older");class pi{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ce],{done:!1,value:n.key}):{done:!0,value:void 0}}}class Ri{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ce],{done:!1,value:n.value}):{done:!0,value:void 0}}}class Ci{constructor(n){g(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ce],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}ya=ce,Ta=ye;class ir{constructor(n,t){g(this,"key");g(this,"value");g(this,ya);g(this,Ta);this.key=n,this.value=t,this[ce]=void 0,this[ye]=void 0}toJSON(){return{key:this.key,value:this.value}}}class Ii{constructor(...n){g(this,"_keymap");g(this,"size",0);g(this,"limit");g(this,"oldest");g(this,"newest");g(this,"_onShiftListeners",[]);if(en.hasLength(n,1)){if(en.isNumber(n[0])){const t=n[0];this._initialize(t,void 0);return}if(en.isIterable(n[0])){const t=n[0];this._initialize(0,t);return}return}if(en.hasLength(n,2)){const t=n[0],r=n[1];this._initialize(t,r)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),Se(()=>bn(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,t&&(this.assign(t),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ce]&&(n===this.oldest&&(this.oldest=n[ce]),n[ce][ye]=n[ye]),n[ye]&&(n[ye][ce]=n[ce]),n[ce]=void 0,n[ye]=this.newest,this.newest&&(this.newest[ce]=n),this.newest=n)}assign(n){let t,r=this.limit||Number.MAX_VALUE;this._keymap.clear();const s=n[Symbol.iterator]();for(let i=s.next();!i.done;i=s.next()){const o=new ir(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),t?(t[ce]=o,o[ye]=t):this.oldest=o,t=o,r--===0)throw new Error("overflow")}this.newest=t,this.size=this._keymap.size}set(n,t){let r=this._keymap.get(n);return r?(r.value=t,this._markEntryAsUsed(r),this):(this._keymap.set(n,r=new ir(n,t)),this.newest?(this.newest[ce]=r,r[ye]=this.newest):this.oldest=r,this.newest=r,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ce]?(this.oldest=this.oldest[ce],this.oldest[ye]=void 0):(this.oldest=void 0,this.newest=void 0),n[ce]=n[ye]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(t=>t(n)),[n.key,n.value]}get(n){const t=this._keymap.get(n);if(t)return this._markEntryAsUsed(t),t.value}has(n){return this._keymap.has(n)}find(n){const t=this._keymap.get(n);return t?t.value:void 0}delete(n){const t=this._keymap.get(n);if(t)return this._keymap.delete(t.key),t[ce]&&t[ye]?(t[ye][ce]=t[ce],t[ce][ye]=t[ye]):t[ce]?(t[ce][ye]=void 0,this.oldest=t[ce]):t[ye]?(t[ye][ce]=void 0,this.newest=t[ye]):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 pi(this.oldest)}values(){return new Ri(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ci(this.oldest)}forEach(n,t){typeof t!="object"&&(t=this);let r=this.oldest;for(;r;)n.call(t,r.value,r.key,this),r=r[ce]}toJSON(){const n=new Array(this.size);let t=0,r=this.oldest;for(;r;)n[t++]={key:r.key,value:r.value},r=r[ce];return n}toString(){let n="",t=this.oldest;for(;t;)n+=`${String(t.key)}:${t.value}`,t=t[ce],t&&(n+=" < ");return n}}function It(e){let n=0;const t=Object.keys(e);for(const r of t){const s=Number(r);n=Math.max(n,s)}return n+1}function or(e,n,t){const r=It(t),s=t;for(let i=r-1;i>=e;i--)s[i+1]=s[i];s[e]=n}function ar(e,n,t){const r=Object.keys(t).reduce((s,i)=>Math.max(s,Number.parseInt(i)),0)+1;for(let s=e;s<r;s++)s<e+n?delete t[s]:t[s]!==void 0&&(t[s-n]=t[s],delete t[s])}function Kl(e,n){const t=e,r=Object.keys(t),s=r.length,i=n,o=Object.keys(i),a=o.length,l={};let d=0;for(let h=0;h<s;h++,d++){const c=r[h];l[d]=t[c]}for(let h=0;h<a;h++,d++){const c=o[h];l[d]=i[c]}return l}function zl(e,n,t){const r=t;if(It(t)>0){const i={};let o=0;for(let a=e;a<=n;a++)r[a]&&(i[o]=r[a],o++);return i}return{}}function lr(e,n,t,r){const s=e>t;if(!s&&e+n>t)throw new Error("Invalid move operation");s?Yl(e,n,t,r):Xl(e,n,t,r)}function Yl(e,n,t,r){const s=r,i=[];for(let o=e;o<e+n;o++)i.push(s[o]);for(let o=e-1;o>=t;o--){const a=s[o];s[o+n]=a,a===void 0&&delete s[o+n]}i.forEach((o,a)=>{s[t+a]=o,o===void 0&&delete s[t+a]})}function Xl(e,n,t,r){const s=r,i=[];for(let o=e;o<e+n;o++)i.push(s[o]);for(let o=e+n;o<t;o++){const a=s[o];s[o-n]=a,a===void 0&&delete s[o-n]}i.forEach((o,a)=>{s[t+a-n]=o,o===void 0&&delete s[t+a-n]})}class nt{constructor(n={}){g(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new nt({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const i=Number(s),o=t[i];if(n(i,o)===!1)return this}return this}forRow(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const i=Number(s),o=t[i];if(n(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const i=Number(s),o=t[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const d=Number(l),h=o[Number(l)];if(n(i,d,h)===!1)return this}}return this}swapRow(n,t){const r=this._matrix[n],s=this._matrix[t];this._matrix[n]=s,this._matrix[t]=r}getRow(n){return this._matrix[n]}getRowOrCreate(n){let t=this.getRow(n);return t==null&&(t={},this._matrix[n]=t),t}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,t=Object.keys(n);if(t.length===0)return!1;for(const r of t){const s=Number(r),i=n[s];if(Object.keys(i).length>0)return!0}return!1}getValue(n,t){var r,s;return(s=(r=this._matrix)==null?void 0:r[n])==null?void 0:s[t]}setValue(n,t,r){const s=this.getRowOrCreate(n);s[t]=r}deleteValue(n,t){var r,s;(s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t]}realDeleteValue(n,t){var r,s,i;if((s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t],this.getRow(n)){const o=this.getRow(n);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[n])}}setRow(n,t){this._matrix[n]=t}moveRows(n,t,r){lr(n,t,r,this._matrix)}moveColumns(n,t,r){this.forEach((s,i)=>{lr(n,t,r,i)})}insertRows(n,t){for(let r=n;r<n+t;r++)or(r,{},this._matrix)}insertColumns(n,t){for(let r=n;r<n+t;r++)this.forEach((s,i)=>{i&&or(r,void 0,i)})}removeRows(n,t){ar(n,t,this._matrix)}removeColumns(n,t){this.forEach((r,s)=>{s&&ar(n,t,s)})}getFragment(n,t,r,s){const i=new nt;let o=0;for(let a=n;a<=t;a++){const l={};let d=0;for(let h=r;h<=s;h++){const c=this.getValue(a,h);l[d]=c,d++}i.setRow(o,l),o++}return i}getSlice(n,t,r,s){const i=new nt;for(let o=n;o<=t;o++)for(let a=r;a<=s;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,k.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return It(this._matrix)}getRange(){const r=this.getLength()-1;let s=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=It(a)-1;s=l>s?l:s}}return{startRow:0,startColumn:0,endRow:r,endColumn:s}}toNativeArray(){const n=new Array;return this.forValue((t,r,s)=>{n.push(s)}),n}toArray(){const n=[];return this.forRow((t,r)=>{n[t]==null&&(n[t]=[]),r.forEach(s=>{n[t][s]=this.getValue(t,s)})}),n}toFullArray(){const n=this.getRange(),{endColumn:t,endRow:r}=n,s=[];for(let i=0;i<=r;i++){const o=Array(t+1).fill(void 0);s.push(o)}return this.forValue((i,o,a)=>{s[i][o]=a}),s}toJSON(){return this._matrix}clone(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getData(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getArrayData(){let n=0,t=0,r=!1,s=!1;const i=new nt;return this.forEach((o,a)=>{r||(r=!0,n=o),Object.keys(a).forEach(l=>{const d=Number(l);s?d<t&&(t=d):(s=!0,t=d);const h=this.getValue(o,d);i.setValue(o-n,d-t,h)})}),i.getData()}getDataRange(){let n=0,t=0,r=0,s=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,n=a),l==null)return;const d=It(l)-1;d>r&&(r=d),Object.keys(l).forEach(h=>{const c=Number(h);o?c<t&&(t=c):(o=!0,t=c)}),a>s&&(s=a)}),{startRow:n,startColumn:t,endRow:s,endColumn:r}}getDiscreteRanges(){const n=[];return this.forEach((t,r)=>{Object.keys(r).forEach(s=>{const i=Number(s);let o=!1;for(const a of n)if(t>=a.startRow&&t<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(t,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||n.push({startRow:t,endRow:t,startColumn:i,endColumn:i})})}),n}merge(n){this.forValue((t,r)=>{const s=n.getValue(t,r);s!=null&&this.setValue(t,r,s)})}_setOriginValue(n={}){this._matrix=n}}const _t=class _t{static clone(n){return n.rangeType!==void 0?{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:n.rangeType}:{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn}}static equals(n,t){return n==null||t==null?!1:n.endRow===t.endRow&&n.endColumn===t.endColumn&&n.startRow===t.startRow&&n.startColumn===t.startColumn&&(n.rangeType===t.rangeType||n.rangeType===void 0&&t.rangeType===oe.NORMAL||t.rangeType===void 0&&n.rangeType===oe.NORMAL)}static intersects(n,t){if(n.rangeType===oe.ROW&&t.rangeType===oe.COLUMN||n.rangeType===oe.COLUMN&&t.rangeType===oe.ROW)return!0;if(n.rangeType===oe.ROW&&t.rangeType===oe.ROW)return n.startRow<=t.endRow&&n.endRow>=t.startRow;if(n.rangeType===oe.COLUMN&&t.rangeType===oe.COLUMN)return n.startColumn<=t.endColumn&&n.endColumn>=t.startColumn;const r=Math.floor(Number.MAX_SAFE_INTEGER/10),s=Number.isNaN(n.startRow)?0:n.startRow,i=Number.isNaN(n.endRow)?r:n.endRow,o=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?r:n.endColumn,l=Number.isNaN(t.startRow)?0:t.startRow,d=Number.isNaN(t.endRow)?r:t.endRow,h=Number.isNaN(t.startColumn)?0:t.startColumn,c=Number.isNaN(t.endColumn)?r:t.endColumn,f=Math.abs(o+a-h-c),_=Math.abs(o-a)+Math.abs(h-c),E=Math.abs(s+i-l-d),p=Math.abs(s-i)+Math.abs(l-d);return f<=_&&E<=p}static getIntersects(n,t){const r=n.startRow,s=n.endRow,i=n.startColumn,o=n.endColumn,a=t.startRow,l=t.endRow,d=t.startColumn,h=t.endColumn;let c,f,_,E;if(a<=s)a>=r?f=a:f=r;else return null;if(l>=r)l>=s?E=s:E=l;else return null;if(d<=o)d>i?c=d:c=i;else return null;if(h>=i)h>=o?_=o:_=h;else return null;return{startRow:f,endRow:E,startColumn:c,endColumn:_,rangeType:oe.NORMAL}}static contains(n,t){return n.startRow<=t.startRow&&n.endRow>=t.endRow&&n.startColumn<=t.startColumn&&n.endColumn>=t.endColumn}static realContain(n,t){return _t.contains(n,t)&&(n.startRow<t.startRow||n.endRow>t.endRow||n.startColumn<t.startColumn||n.endColumn>t.endColumn)}static union(...n){return n.reduce((t,r)=>({startRow:Math.min(t.startRow,r.startRow),startColumn:Math.min(t.startColumn,r.startColumn),endRow:Math.max(t.endRow,r.endRow),endColumn:Math.max(t.endColumn,r.endColumn),rangeType:oe.NORMAL}),n[0])}static realUnion(...n){const t=n.some(i=>i.rangeType===oe.COLUMN),r=n.some(i=>i.rangeType===oe.ROW),s=_t.union(...n);return{startColumn:r?Number.NaN:s.startColumn,endColumn:r?Number.NaN:s.endColumn,startRow:t?Number.NaN:s.startRow,endRow:t?Number.NaN:s.endRow,rangeType:r?oe.ROW:t?oe.COLUMN:oe.NORMAL}}static subtract(n,t){if(t.startRow>n.endRow||t.endRow<n.startRow||t.startColumn>n.endColumn||t.endColumn<n.startColumn)return[n];const r=[];t.startRow>=n.startRow&&r.push({startRow:n.startRow,startColumn:n.startColumn,endRow:t.startRow-1,endColumn:n.endColumn}),t.endRow<=n.endRow&&r.push({startRow:t.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const s=Math.max(n.startRow,t.startRow),i=Math.min(n.endRow,t.endRow);return t.startColumn>=n.startColumn&&r.push({startRow:s,startColumn:n.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=n.endColumn&&r.push({startRow:s,startColumn:t.endColumn+1,endRow:i,endColumn:n.endColumn}),r.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,t){return!(n.left>t.right||n.right<t.left||n.top>t.bottom||n.bottom<t.top)}static getIntersectionBetweenTwoRect(n,t){const r=Math.max(n.left,t.left),s=Math.min(n.right,t.right),i=Math.max(n.top,t.top),o=Math.min(n.bottom,t.bottom);return s<=r||o<=i?null:{left:r,right:s,top:i,bottom:o,width:s-r,height:o-i}}};g(_t,"getRelativeRange",(n,t)=>({startRow:n.startRow-t.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-t.startColumn,endColumn:n.endColumn-n.startColumn})),g(_t,"getPositionRange",(n,t,r)=>({...r||{},startRow:r&&[Oe.ROW,Oe.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:n.startRow+t.startRow,endRow:r&&[Oe.ROW,Oe.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:n.endRow+n.startRow+t.startRow,startColumn:r&&[Oe.COLUMN,Oe.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:n.startColumn+t.startColumn,endColumn:r&&[Oe.COLUMN,Oe.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:n.endColumn+n.startColumn+t.startColumn})),g(_t,"moveHorizontal",(n,t=0,r=0)=>({...n,startColumn:n.startColumn+t,endColumn:n.endColumn+t+r})),g(_t,"moveVertical",(n,t=0,r=0)=>({...n,startRow:n.startRow+t,endRow:n.endRow+t+r})),g(_t,"moveOffset",(n,t,r)=>({...n,startRow:n.startRow+r,endRow:n.endRow+r,startColumn:n.startColumn+t,endColumn:n.endColumn+t}));let vt=_t;class Ql{constructor(n,t){g(this,"_values",[]);g(this,"_keys",[]);g(this,"_keyMaps",new Map);this._values=n,this._keys=t,n.forEach(r=>{this._initKeyMap(r)})}_initKeyMap(n){this._keys.forEach(t=>{const r=n[t],s=this._keyMaps.get(t)||new Map;s.set(r,n),this._keyMaps.set(t,s)})}getValue(n,t){const r=t||this._keys;for(let s=0;s<r.length;s++){const i=this._keyMaps.get(r[s]);if(i!=null&&i.has(n))return i.get(n)}return null}hasValue(n){for(let t=0;t<this._keys.length;t++){const r=this._keyMaps.get(this._keys[t]);if(r!=null&&r.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,t,r){const s=this.getValue(n);s&&Object.keys(s).includes(t)&&(s[t]=r)}deleteValue(n){const t=this.getValue(n);if(t){this._keys.forEach(s=>{const i=this._keyMaps.get(s),o=t[s];i==null||i.delete(o)});const r=this._values.findIndex(s=>s===t);this._values.splice(r,1)}}getValues(){return this._values}getKeyMap(n){var t;return[...((t=this._keyMaps.get(n))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function ur(e,n,t,r){return{forEach(s){for(let i=e;i<=n;i++)for(let o=t;o<=r;o++)s(i,o)}}}function ql(e){if(e==null||e.length===0)return Number.NaN;const n=e.toLowerCase().split(""),t=n.length,r=o=>o.charCodeAt(0)-96;let s=0,i=0;for(let o=0;o<t;o++)i=r(n[o]),s+=i*26**(t-o-1);return s===0?Number.NaN:s-1}const An=65,vi=90,Zl=97;function Jl(e){const n=vi-An+1;let t="";for(;e>=0;)t=String.fromCharCode(e%n+An)+t,e=Math.floor(e/n)-1;return t}function Oi(e,n){let t="";for(;n>0;)t+=e,n--;return t}function eu(e,n=!1){const t=vi-An+1;let r=Zl;n&&(r=An);const s=String.fromCharCode(e%t+r),i=Math.floor(e/t)+1;return Oi(s,i)}function tu(e,n){return e.zIndex>n.zIndex?1:e.zIndex===n.zIndex?0:-1}function nu(e,n){return e.zIndex>n.zIndex?-1:e.zIndex===n.zIndex?0:1}function Dt(e="index",n=1){return(t,r)=>t[e]>r[e]?n:t[e]===r[e]?0:-n}function ru(e,n){let t;function r(...s){const i=this,o=function(){t=null,e.apply(i,s)};clearTimeout(t),t=setTimeout(o,n)}return Object.defineProperty(r,"cancel",{value:()=>{clearTimeout(t)},enumerable:!1,writable:!1}),r}function Tn(e,n,t){const{dataStream:r,textRuns:s=[]}=e;let i=n;const o=[];for(const a of s){const{st:l,ed:d}=a;k.hasIntersectionBetweenTwoRanges(n,t,l,d)&&(l>i?(o.push(r.slice(i,l)),o.push(cr(r,{...a,ed:Math.min(d,t)}))):o.push(cr(r,{...a,st:i,ed:Math.min(d,t)}))),i=Math.max(n,Math.min(d,t))}return i!==t&&o.push(r.slice(i,t)),o.join("")}function su(e,n=!0){var t;if(n&&((t=e.paragraphs)!=null&&t.length)){const{dataStream:r,paragraphs:s=[]}=e;let i="",o=-1;for(const a of s){const{startIndex:l,paragraphStyle:d={}}=a,{spaceAbove:h,spaceBelow:c,lineSpacing:f}=d,_=[];h!=null&&(typeof h=="number"?_.push(`margin-top: ${h}px`):_.push(`margin-top: ${h.v}px`)),c!=null&&(typeof c=="number"?_.push(`margin-bottom: ${c}px`):_.push(`margin-bottom: ${c.v}px`)),f!=null&&_.push(`line-height: ${f}`),l>o+1?i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}>${Tn(e,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${_.length?`style="${_.join("; ")};"`:""}></p>`,o=l}return o!==r.length&&(i+=Tn(e,o,r.length)),i}else return Tn(e,0,e.dataStream.length)}function cr(e,n){const{st:t,ed:r,ts:s={}}=n,{ff:i,fs:o,it:a,bl:l,ul:d,st:h,ol:c,bg:f,cl:_,va:E}=s;let p=e.slice(t,r);const N=[];return a===z.TRUE&&(p=`<i>${p}</i>`),E===jt.SUPERSCRIPT?p=`<sup>${p}</sup>`:E===jt.SUBSCRIPT&&(p=`<sub>${p}</sub>`),(d==null?void 0:d.s)===z.TRUE&&(p=`<u>${p}</u>`),(h==null?void 0:h.s)===z.TRUE&&(p=`<s>${p}</s>`),l===z.TRUE&&(p=`<strong>${p}</strong>`),i&&N.push(`font-family: ${i}`),_&&N.push(`color: ${_.rgb}`),o&&N.push(`font-size: ${o}pt`),c&&N.push("text-decoration: overline"),f&&N.push(`background: ${f.rgb}`),N.length?`<span style="${N.join("; ")};">${p}</span>`:p}const iu={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},ou={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},au={startRow:0,startColumn:0,endRow:0,endColumn:0},lu={row:0,column:0},yn={ff:"Arial",fs:11,it:z.FALSE,bl:z.FALSE,ul:{s:z.FALSE},st:{s:z.FALSE},ol:{s:z.FALSE},tr:{a:0,v:z.FALSE},td:qt.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:At.UNSPECIFIED,vt:Wt.UNSPECIFIED,tb:Bt.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Si={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var Ni=(e=>(e.ARRAY_CONVERTOR="ARRAY_CONVERTOR",e.MATRIX_CONVERTOR="MATRIX_CONVERTOR",e))(Ni||{});function Dn(e,n){const{textRuns:t=[]}=n;let r=0;for(const i of t){const{ts:o={},st:a,ed:l}=i;if(o[e]==null)return z.FALSE;switch(e){case"bl":case"it":{if(o[e]===z.FALSE)return z.FALSE;break}case"ul":case"st":{if(o[e].s===z.FALSE)return z.FALSE;break}default:throw new Error(`unknown style key: ${e} in IStyleBase`)}r+=l-a}return n.dataStream.indexOf(`\r
4
+ `)===r?z.TRUE:z.FALSE}const fn=class fn{constructor(n,t,r){g(this,"_range");g(this,"_worksheet");this._deps=r,this._range=t,this._worksheet=n}static foreach(n,t){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=n;for(let a=r;a<=i;a++)for(let l=s;l<=o;l++)t(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,i=[];for(let o=n;o<=t;o++){const a=[];for(let l=r;l<=s;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new nt;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,i=this._worksheet.getCellMatrix(),o=new nt;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)o.setValue(a-n,l-r,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range;let i,o;return r<s?(i=k.numToWord(r+1)+(n+1),o=k.numToWord(s+1)+(t+1)):(i=k.numToWord(s+1)+(t+1),o=k.numToWord(r+1)+(n+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var i;const s=n.getStyleByCell(r);return((i=s==null?void 0:s.bg)==null?void 0:i.rgb)||yn.bg.rgb}))}getCell(n,t){const{startRow:r,endRow:s,startColumn:i,endColumn:o}=this._range,a={startRow:r+n,endRow:r+n,startColumn:i+t,endColumn:i+t};return new fn(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:t,endRow:r,startColumn:s,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(t,r,s,i).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let d=0;d<=r-t;d++)for(let h=0;h<=i-s;h++){if(o==null||((a=o==null?void 0:o[d])==null?void 0:a[h])==null)continue;const c=o[d][h].s;c&&(o[d][h].s=l.get(c))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var i;const s=n.getStyleByCell(r);return((i=s==null?void 0:s.cl)==null?void 0:i.rgb)||yn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?Dn("ul",n.body)===z.TRUE?{s:z.TRUE}:{s:z.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?Dn("st",n.body)===z.TRUE?{s:z.TRUE}:{s:z.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var t,r;const n=((t=this.getValue())==null?void 0:t.p)||{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)!=null})?Math.max(...n.body.textRuns.map(s=>{var i;return((i=s==null?void 0:s.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?Dn("it",n.body)===z.TRUE?pn.ITALIC:pn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?Dn("bl",n.body)===z.TRUE?Rn.BOLD:Rn.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:t}=this,{startRow:r,endRow:s}=n;let i=0;for(let o=0;o<=s-r;o++){const a=t.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:n,endColumn:t}=this._range;return t-n+1}getNumRows(){const{startRow:n,endRow:t}=this._range;return t-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(t=>(t==null?void 0:t.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>n.getStyleByCell(r)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:t}=this,{startColumn:r,endColumn:s}=n;let i=0;for(let o=0;o<=s-r;o++)i+=t.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===Bt.WRAP?z.TRUE:z.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){fn.foreach(this._range,n)}_getStyles(n){const t=this._deps.getStyles();return this.getValues().map(r=>r.map(s=>{const i=t&&t.getStyleByCell(s);return i&&i[n]||yn[n]}))}};g(fn,"transformRange",(n,t)=>n.rangeType===oe.ALL?{startColumn:0,startRow:0,endColumn:t.getMaxColumns()-1,endRow:t.getMaxRows()-1}:n.rangeType===oe.COLUMN?{startRow:0,endRow:t.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===oe.ROW?{startColumn:0,endColumn:t.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let Gt=fn;function uu(e,n){if(e.length===0||e[0].length===0)return null;const t=new Array(e[0].length).fill(0);let r=0,s=null;for(let i=0;i<e.length;i++){for(let a=0;a<e[0].length;a++)t[a]=n(e[i][a])?t[a]+1:0;const o=cu(t);o.area>r&&(r=o.area,s={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return s}function cu(e){const n=[];let t=0,r={area:0,height:0,start:0,end:0},s=0;for(;s<e.length;)if(n.length===0||e[s]>=e[n[n.length-1]])n.push(s++);else{const i=e[n.pop()],o=n.length===0?s:s-n[n.length-1]-1;i*o>t&&(t=i*o,r={area:t,height:i,start:n.length===0?0:n[n.length-1]+1,end:s-1})}for(;n.length>0;){const i=e[n.pop()],o=n.length===0?s:s-n[n.length-1]-1;i*o>t&&(t=i*o,r={area:t,height:i,start:n.length===0?0:n[n.length-1]+1,end:s-1})}return r}function hu(e,n){Gt.foreach(n,(t,r)=>{e[t][r]=void 0})}function du(e,n){const t=e.toFullArray(),r=[];for(;;){const s=uu(t,n);if(!s)break;r.push(s),hu(t,s)}return r}function fu(e,n,t,r=!1){let s={...e};const i=s.startAbsoluteRefType||Oe.NONE,o=s.endAbsoluteRefType||Oe.NONE;return!r&&i===Oe.ALL&&o===Oe.ALL?s:r||i===Oe.NONE&&o===Oe.NONE?vt.moveOffset(s,n,t):(i===Oe.NONE?s={...s,startRow:s.startRow+t,startColumn:s.startColumn+n}:i===Oe.COLUMN?s={...s,startRow:s.startRow+t}:i===Oe.ROW&&(s={...s,startColumn:s.startColumn+n}),o===Oe.NONE?s={...s,endRow:s.endRow+t,endColumn:s.endColumn+n}:o===Oe.COLUMN?s={...s,endRow:s.endRow+t}:o===Oe.ROW&&(s={...s,endColumn:s.endColumn+n}),s)}var hr=Symbol("$$IDENTIFIER_DECORATOR");function _u(e){return e&&e[hr]===!0}function dr(e){return typeof e=="function"}function fr(e){return!!(e&&typeof e.useClass<"u")}function _r(e){return!!(e&&typeof e.useFactory<"u")}function gr(e){return!!(e&&typeof e.useValue<"u")}function gu(e){return!!(e&&typeof e.useExisting<"u")}function mr(e){return!!(e&&typeof e.useAsync<"u")}var wi=Symbol("AsyncHook");function Mn(e){return!!(e&&e.__symbol===wi)}function Ve(e){return typeof e>"u"?"undefined":dr(e)&&!e[hr]?e.name:e.toString()}u.Quantity=void 0,function(e){e.MANY="many",e.OPTIONAL="optional",e.REQUIRED="required"}(u.Quantity||(u.Quantity={})),u.LookUp=void 0,function(e){e.SELF="self",e.SKIP_SELF="skipSelf"}(u.LookUp||(u.LookUp={}));var mu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Le=function(e){mu(n,e);function n(t){return e.call(this,"[redi]: ".concat(t))||this}return n}(Error),bi=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ai=Symbol("$$TARGET"),Er=Symbol("$$DEPENDENCIES"),Eu=function(e){bi(n,e);function n(t,r){var s="Could not find dependency registered on the ".concat(t,' (indexed) parameter of the constructor of "').concat(Ve(r),'".');return e.call(this,s)||this}return n}(Le),Ti=function(e){bi(n,e);function n(t,r){var s='It seems that you register "undefined" as dependency on the '.concat(r+1,' parameter of "').concat(Ve(t),'". Please make sure that there is not cyclic dependency among your TypeScript files, or consider using "forwardRef". For more info please visit our website https://redi.wendell.fun/docs/debug#could-not-find-dependency-registered-on');return e.call(this,s)||this}return n}(Le);function yi(e){var n=e;return n[Er]||[]}function pr(e,n){var t=yi(e),r=t.find(function(s){return s.paramIndex===n});if(!r)throw new Eu(n,e);return r}function Rr(e,n,t,r,s){r===void 0&&(r=u.Quantity.REQUIRED);var i={paramIndex:t,identifier:n,quantity:r,lookUp:s,withNew:!1};if(typeof n>"u")throw new Ti(e,t);var o=e;o[Ai]===o?o[Er].push(i):(o[Er]=[i],o[Ai]=o)}var Di=new Set;function xe(e){if(Di.has(e))throw new Le('Identifier "'.concat(e,'" already exists.'));Di.add(e);var n=function(t,r,s){Rr(t,n,s)};return n.toString=function(){return e},n[hr]=!0,n}var pu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ru=function(e){pu(n,e);function n(t,r,s){var i='Expect "'.concat(r,'" dependency items for id "').concat(Ve(t),'" but get ').concat(s,".");return e.call(this,i)||this}return n}(Le);function Mi(e,n,t){if(n===u.Quantity.OPTIONAL&&t>1||n===u.Quantity.REQUIRED&&t!==1)throw new Ru(e,n,t)}function Cu(e,n){return e===u.Quantity.MANY?n:n[0]}function Iu(e,n,t){var r=pr(e,n);r.quantity=t}function Cr(e){return function n(t){return this instanceof n?this:function(r,s,i){if(t)Rr(r,t,i,e);else{if(e===u.Quantity.REQUIRED)throw new Ti(r,i);Iu(r,i,e)}}}}var Ui=Cr(u.Quantity.MANY),Li=Cr(u.Quantity.OPTIONAL),rt=Cr(u.Quantity.REQUIRED);function vu(e){return{unwrap:e}}function Ou(e){return!!e&&typeof e.unwrap=="function"}function Su(e){return Ou(e)?e.unwrap():e}function Ir(e){return!!e&&typeof e.dispose=="function"}var Pi=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}();function Nu(e){return e.length===1}var Un=[];function ki(e){Un.push(e)}function Fi(){Un.pop()}function wu(){Un.length=0}var Hi=function(e){Pi(n,e);function n(t,r,s){var i='Cannot find "'.concat(Ve(r),'" registered by any injector. It is the ').concat(s,'th param of "').concat(_u(t)?Ve(t):t.name,'".');return e.call(this,i)||this}return n}(Le),Ln=function(e){Pi(n,e);function n(t){var r=this,s='Cannot find "'.concat(Ve(t),'" registered by any injector. The stack of dependencies is: "').concat(Un.map(function(i){return Ve(i)}).join(" -> "),'".');return r=e.call(this,s)||this,wu(),r}return n}(Le),bu=function(){function e(n){var t=this;this.dependencyMap=new Map,this.normalizeDependencies(n).map(function(r){return t.add(r[0],r[1])})}return e.prototype.add=function(n,t){typeof t>"u"&&(t={useClass:n,lazy:!1});var r=this.dependencyMap.get(n);typeof r>"u"&&(r=[],this.dependencyMap.set(n,r)),r.push(t)},e.prototype.delete=function(n){this.dependencyMap.delete(n)},e.prototype.get=function(n,t){t===void 0&&(t=u.Quantity.REQUIRED);var r=this.dependencyMap.get(n);return Mi(n,t,r.length),Cu(t,r)},e.prototype.has=function(n){return this.dependencyMap.has(n)},e.prototype.append=function(n){var t=this;this.normalizeDependencies(n).forEach(function(r){return t.add(r[0],r[1])})},e.prototype.dispose=function(){this.dependencyMap.clear()},e.prototype.normalizeDependencies=function(n){return n.map(function(t){var r=t[0],s;return Nu(t)?s={useClass:t[0],lazy:!1}:s=t[1],[r,s]})},e}(),Au=function(){function e(){this.resolvedDependencies=new Map}return e.prototype.add=function(n,t){var r=this.resolvedDependencies.get(n);typeof r>"u"&&(r=[],this.resolvedDependencies.set(n,r)),r.push(t)},e.prototype.has=function(n){return this.resolvedDependencies.has(n)},e.prototype.delete=function(n){if(this.resolvedDependencies.has(n)){var t=this.resolvedDependencies.get(n);t.forEach(function(r){return Ir(r)?r.dispose():void 0}),this.resolvedDependencies.delete(n)}},e.prototype.get=function(n,t){t===void 0&&(t=u.Quantity.REQUIRED);var r=this.resolvedDependencies.get(n);if(!r)throw new Ln(n);return Mi(n,t,r.length),t===u.Quantity.MANY?r:r[0]},e.prototype.dispose=function(){Array.from(this.resolvedDependencies.values()).forEach(function(n){n.forEach(function(t){return Ir(t)?t.dispose():void 0})}),this.resolvedDependencies.clear()},e}();function Tu(e,n,t){var r=pr(e,n);r.lookUp=t}function $i(e){return function n(){return this instanceof n?this:function(t,r,s){Tu(t,s,e)}}}var Wi=$i(u.LookUp.SKIP_SELF),Bi=$i(u.LookUp.SELF);function yu(e,n,t){var r=pr(e,n);r.withNew=t}function Du(e){return function n(){return this instanceof n?this:function(t,r,s){yu(t,s,e)}}}var ji=Du(!0);function Gi(e,n){return n===void 0&&(n=0),e?e.map(function(t,r){if(r+=n,!Array.isArray(t))return{paramIndex:r,identifier:t,quantity:u.Quantity.REQUIRED,withNew:!1};var s=t.slice(0,t.length-1),i=t[t.length-1],o=void 0,a=u.Quantity.REQUIRED,l=!1;return s.forEach(function(d){if(d instanceof Bi)o=u.LookUp.SELF;else if(d instanceof Wi)o=u.LookUp.SKIP_SELF;else if(d instanceof Li)a=u.Quantity.OPTIONAL;else if(d instanceof Ui)a=u.Quantity.MANY;else if(d instanceof ji)l=!0;else throw new Le("unknown dep modifier ".concat(d,"."))}),{paramIndex:r,identifier:i,quantity:a,lookUp:o,withNew:l}}):[]}var vr;(function(){if(typeof requestIdleCallback<"u"&&typeof cancelIdleCallback<"u")vr=function(n,t){var r=requestIdleCallback(n,typeof t=="number"?{timeout:t}:void 0),s=!1;return function(){s||(s=!0,cancelIdleCallback(r))}};else{var e=Object.freeze({didTimeout:!0,timeRemaining:function(){return 15}});vr=function(n){var t=setTimeout(function(){return n(e)}),r=!1;return function(){r||(r=!0,clearTimeout(t))}}}})();var Mu=function(){function e(n){var t=this;this.didRun=!1,this.selfExecutor=function(){try{t.value=n()}catch(r){t.error=r}finally{t.didRun=!0}},this.disposeCallback=vr(function(){return t.selfExecutor()})}return e.prototype.hasRun=function(){return this.didRun},e.prototype.dispose=function(){this.disposeCallback()},e.prototype.getValue=function(){if(this.didRun||(this.dispose(),this.selfExecutor()),this.error)throw this.error;return this.value},e}(),Vt=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Pn=function(){return Pn=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Pn.apply(this,arguments)},Mt=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,i;r<s;r++)(i||!(r in n))&&(i||(i=Array.prototype.slice.call(n,0,r)),i[r]=n[r]);return e.concat(i||Array.prototype.slice.call(n))},Uu=300,tn=Symbol("$$NOT_INSTANTIATED_SYMBOL"),Lu=function(e){Vt(n,e);function n(t){return e.call(this,'Detecting cyclic dependency. The last identifier is "'.concat(Ve(t),'".'))||this}return n}(Le),Pu=function(e){Vt(n,e);function n(){return e.call(this,"Injector cannot be accessed after it was disposed.")||this}return n}(Le),ku=function(e){Vt(n,e);function n(t){return e.call(this,'Async item "'.concat(Ve(t),'" returns another async item.'))||this}return n}(Le),Fu=function(e){Vt(n,e);function n(t){return e.call(this,'Cannot get async item "'.concat(Ve(t),'" from sync api.'))||this}return n}(Le),Vi=function(e){Vt(n,e);function n(t){return e.call(this,'Cannot add dependency "'.concat(Ve(t),'" after it is already resolved.'))||this}return n}(Le),Hu=function(e){Vt(n,e);function n(t){return e.call(this,'Cannot dependency dependency "'.concat(Ve(t),'" after it is already resolved.'))||this}return n}(Le),dt=function(){function e(n,t){t===void 0&&(t=null),this.parent=t,this.children=[],this.resolutionOngoing=0,this.disposed=!1,this.dependencyCollection=new bu(n||[]),this.resolvedDependencyCollection=new Au,t&&t.children.push(this)}return e.prototype.createChild=function(n){return this._ensureInjectorNotDisposed(),new e(n,this)},e.prototype.dispose=function(){this.children.forEach(function(n){return n.dispose()}),this.children.length=0,this.dependencyCollection.dispose(),this.resolvedDependencyCollection.dispose(),this.deleteSelfFromParent(),this.disposed=!0},e.prototype.deleteSelfFromParent=function(){if(this.parent){var n=this.parent.children.indexOf(this);n>-1&&this.parent.children.splice(n,1)}},e.prototype.add=function(n){this._ensureInjectorNotDisposed();var t=n[0],r=n[1];if(this.resolvedDependencyCollection.has(t))throw new Vi(t);typeof r>"u"?this.dependencyCollection.add(t):mr(r)||fr(r)||gr(r)||_r(r)?this.dependencyCollection.add(t,r):this.resolvedDependencyCollection.add(t,r)},e.prototype.replace=function(n){this._ensureInjectorNotDisposed();var t=n[0];if(this.resolvedDependencyCollection.has(t))throw new Vi(t);this.dependencyCollection.delete(t),n.length===1?this.dependencyCollection.add(t):this.dependencyCollection.add(t,n[1])},e.prototype.delete=function(n){if(this._ensureInjectorNotDisposed(),this.resolvedDependencyCollection.has(n))throw new Hu(n);this.dependencyCollection.delete(n)},e.prototype.invoke=function(n){for(var t=this,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];this._ensureInjectorNotDisposed();var i={get:function(o,a,l){return t._get(o,a,l)}};return n.apply(void 0,Mt([i],r,!1))},e.prototype.has=function(n){var t;return this.dependencyCollection.has(n)||((t=this.parent)===null||t===void 0?void 0:t.has(n))||!1},e.prototype.get=function(n,t,r){this._ensureInjectorNotDisposed();var s=this._get(n,t,r);if(Array.isArray(s)&&s.some(function(i){return Mn(i)})||Mn(s))throw new Fu(n);return s},e.prototype._get=function(n,t,r,s){var i=u.Quantity.REQUIRED;if(t===u.Quantity.REQUIRED||t===u.Quantity.OPTIONAL||t===u.Quantity.MANY?i=t:r=t,!s){var o=this.getValue(n,i,r);if(o!==tn)return o}return this.createDependency(n,i,r,!s)},e.prototype.getAsync=function(n){this._ensureInjectorNotDisposed();var t=this.getValue(n,u.Quantity.REQUIRED);if(t!==tn)return Promise.resolve(t);var r=this.createDependency(n,u.Quantity.REQUIRED);return Mn(r)?r.whenReady():Promise.resolve(r)},e.prototype.createInstance=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this._ensureInjectorNotDisposed(),this._resolveClassImpl.apply(this,Mt([{useClass:n}],t,!1))},e.prototype._resolveDependency=function(n,t,r){r===void 0&&(r=!0);var s;ki(n);try{gr(t)?s=this._resolveValueDependency(n,t):_r(t)?s=this._resolveFactory(n,t,r):fr(t)?s=this._resolveClass(n,t,r):gu(t)?s=this._resolveExisting(n,t):s=this._resolveAsync(n,t),Fi()}catch(i){throw Fi(),i}return s},e.prototype._resolveExisting=function(n,t){var r=this.get(t.useExisting);return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveValueDependency=function(n,t){var r=t.useValue;return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveClass=function(n,t,r){var s=this;r===void 0&&(r=!0),t.useClass;var i;if(t.lazy){var o=new Mu(function(){return s._ensureInjectorNotDisposed(),s._resolveClassImpl(t)});i=new Proxy(Object.create(null),{get:function(a,l){if(l in a)return a[l];if(l!=="whenReady"){var d=o.getValue(),h=d[l];return typeof h!="function"||(h=h.bind(d),a[l]=h),h}},set:function(a,l,d){return o.getValue()[l]=d,!0}})}else i=this._resolveClassImpl(t);return n&&r&&this.resolvedDependencyCollection.add(n,i),i},e.prototype._resolveClassImpl=function(n){for(var t,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];var i=n.useClass;this.markNewResolution(i);for(var o=yi(i).sort(function(N,D){return N.paramIndex-D.paramIndex}).map(function(N){return Pn(Pn({},N),{identifier:Su(N.identifier)})}),a=[],l=0,d=o;l<d.length;l++){var h=d[l];try{var c=this._get(h.identifier,h.quantity,h.lookUp,h.withNew);a.push(c)}catch(N){throw N instanceof Ln?new Hi(i,h.identifier,h.paramIndex):N}}var f=Mt([],r,!0),_=o.length>0?o[0].paramIndex:f.length;if(f.length!==_){console.warn("[redi]: Expect ".concat(_," custom parameter(s) of ").concat(Ve(i)," but get ").concat(f.length,"."));var E=_-f.length;E>0?f=Mt(Mt([],f,!0),new Array(E).fill(void 0),!0):f=f.slice(0,_)}var p=new(i.bind.apply(i,Mt(Mt([void 0],f,!1),a,!1)));return(t=n==null?void 0:n.onInstantiation)===null||t===void 0||t.call(n,p),this.markResolutionCompleted(),p},e.prototype._resolveFactory=function(n,t,r){var s;this.markNewResolution(n);for(var i=Gi(t.deps),o=[],a=0,l=i;a<l.length;a++){var d=l[a];try{var h=this._get(d.identifier,d.quantity,d.lookUp,d.withNew);o.push(h)}catch(f){throw f instanceof Ln?new Hi(n,d.identifier,d.paramIndex):f}}var c=t.useFactory.apply(null,o);return r&&this.resolvedDependencyCollection.add(n,c),this.markResolutionCompleted(),(s=t==null?void 0:t.onInstantiation)===null||s===void 0||s.call(t,c),c},e.prototype._resolveAsync=function(n,t){var r=this,s={__symbol:wi,whenReady:function(){return r._resolveAsyncImpl(n,t)}};return s},e.prototype._resolveAsyncImpl=function(n,t){var r=this;return t.useAsync().then(function(s){var i=r.getValue(n);if(i!==tn)return i;var o;if(Array.isArray(s)){var a=s[1];if(mr(a))throw new ku(n);o=r._resolveDependency(n,a)}else dr(s)?o=r._resolveClassImpl({useClass:s,onInstantiation:t.onInstantiation}):o=s;return r.resolvedDependencyCollection.add(n,o),o})},e.prototype.getValue=function(n,t,r){var s=this;t===void 0&&(t=u.Quantity.REQUIRED);var i=function(){return s.dependencyCollection.has(n)&&!s.resolvedDependencyCollection.has(n)?tn:s.resolvedDependencyCollection.get(n,t)},o=function(){return s.parent?s.parent.getValue(n,t):tn};return r===u.LookUp.SKIP_SELF?o():r===u.LookUp.SELF||this.resolvedDependencyCollection.has(n)||this.dependencyCollection.has(n)?i():o()},e.prototype.createDependency=function(n,t,r,s){var i=this;t===void 0&&(t=u.Quantity.REQUIRED),s===void 0&&(s=!0);var o=function(){var l=i.dependencyCollection.get(n,t),d=null;return Array.isArray(l)?d=l.map(function(h){return i._resolveDependency(n,h,s)}):l&&(d=i._resolveDependency(n,l,s)),d},a=function(){if(i.parent)return i.parent.createDependency(n,t,void 0,s);if(t===u.Quantity.OPTIONAL)return null;throw ki(n),new Ln(n)};return r===u.LookUp.SKIP_SELF?a():n===e?this:this.dependencyCollection.has(n)?o():a()},e.prototype.markNewResolution=function(n){if(this.resolutionOngoing+=1,this.resolutionOngoing>=Uu)throw new Lu(n)},e.prototype.markResolutionCompleted=function(){this.resolutionOngoing-=1},e.prototype._ensureInjectorNotDisposed=function(){if(this.disposed)throw new Pu},e}();function $u(e,n,t){t===void 0&&(t=0);var r=Gi(n,t);r.forEach(function(s){Rr(e,s.identifier,s.paramIndex,s.quantity,s.lookUp)})}var xi=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global,Ki="REDI_GLOBAL_LOCK",Wu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;xi[Ki]?Wu||console.error(`[redi]: You are loading scripts of redi more than once! This may cause undesired behavior in your application.
5
+ Maybe your dependencies added redi as its dependency and bundled redi to its dist files. Or you import different versions of redi.
6
+ For more info please visit our website: https://redi.wendell.fun/en-US/docs/debug#import-scripts-of-redi-more-than-once`):xi[Ki]=!0;var zi="REDI_CONTEXT_LOCK",Bu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Yi=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global;Yi[zi]?Bu||console.error(`[redi]: "RediContext" is already created. You may import "RediContext" from different paths. Use "import { RediContext } from '@wendellhu/redi/react-bindings'; instead."`):Yi[zi]=!0;var nn=et.createContext({injector:null});nn.displayName="RediContext";var Or=nn.Provider,Xi=nn.Consumer,ju=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Gu=function(e){ju(n,e);function n(){return e.call(this,"Using dependency injection outside of a RediContext.")||this}return n}(Le);function Qi(){var e=et.useContext(nn);if(!e.injector)throw new Gu;return e.injector}function Vu(e,n,t){var r=Qi();return et.useMemo(function(){return r.get(e,n,t)},[e,n,t])}var kn=function(){return kn=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},kn.apply(this,arguments)};function xu(e){var n=e.children,t=e.dependencies,r=et.useRef(null);return et.useEffect(function(){return function(){var s;return(s=r.current)===null||s===void 0?void 0:s.dispose()}},[]),et.createElement(Xi,null,function(s){var i;return r.current?i=r.current:(i=s.injector?s.injector.createChild(t):new dt(t),r.current=i),et.createElement(Or,{value:{injector:i}},n)})}function Ku(e,n){return function(r){return et.createElement(Or,{value:{injector:n}},et.createElement(e,kn({},r)))}}function zu(e,n){return function(r){return et.createElement(xu,{dependencies:n},et.createElement(e,kn({},r)))}}var Yu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Xu=function(e){Yu(n,e);function n(t){return e.call(this,'You should make "RediContext" as '.concat(t.constructor.name,"'s default context type. ")+"If you want to use multiple context, please check this on React doc site. https://reactjs.org/docs/context.html#classcontexttype")||this}return n}(Le);function Qu(e,n,t){return function(){return{get:function(){var r=this,s=r.context;if(!s||!s.injector)throw new Xu(r);var i=s.injector,o=i.get(e,n||u.Quantity.REQUIRED,t);return o}}}}var qu=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,i;r<s;r++)(i||!(r in n))&&(i||(i=Array.prototype.slice.call(n,0,r)),i[r]=n[r]);return e.concat(i||Array.prototype.slice.call(n))};function qi(e,n){var t=e instanceof W.BehaviorSubject&&typeof n>"u"?e.getValue():n,r=ke.useState(t),s=r[0],i=r[1];return ke.useEffect(function(){var o=e.subscribe(function(a){return i(a)});return function(){return o.unsubscribe()}},[e]),s}function Zi(e){return typeof e=="function"?e():e}function Zu(e,n,t,r){if(typeof e=="function"&&!r)throw new Le("Expected deps to be provided when observable is a function!");var s=ke.useRef(null),i=ke.useRef(!1),o=ke.useMemo(function(){return e},qu([],typeof r<"u"?r:[e],!0)),a=ke.useState(0);a[0];var l=a[1],d=ke.useRef(function(){var h;if(o){var c=Zi(o).subscribe(function(f){i.current=!0,h=f});c.unsubscribe()}return h!=null?h:n}());if(ke.useEffect(function(){var h=null;return o&&(s.current=Zi(o),h=s.current.subscribe(function(c){d.current=c,l(function(f){return f+1})})),function(){return h==null?void 0:h.unsubscribe()}},[o]),t&&!i.current)throw new Error("Expect `shouldHaveSyncValue` but not getting a sync value!");return d.current}function Ju(e){var n=ke.useState(0),t=n[1];ke.useEffect(function(){var r=e.subscribe(function(){return t(function(s){return s+1})});return function(){return r.unsubscribe()}},[])}var Sr=new WeakMap;function ec(e,n){var t=ke.useRef(void 0),r=qi(e,n),s=ke.useMemo(function(){return ke.createContext(r)},[e]),i=ke.useCallback(function(o){return ke.createElement(s.Provider,{value:r},o.children)},[e,r]);return t.current!==e&&(t.current&&Sr.delete(t.current),t.current=e,Sr.set(e,s)),{Provider:i,value:r}}function tc(e){var n=Sr.get(e);if(!n)throw new Le("try to read context value but no ancestor component subscribed it.");return ke.useContext(n)}async function Ji(e){for(const[n,t]of e.entries())try{if(!await t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}function eo(e){for(const[n,t]of e.entries())try{if(!t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}const rn=xe("univer.context-service");class to extends Te{constructor(){super(...arguments);g(this,"_contextChanged$",new W.Subject);g(this,"contextChanged$",this._contextChanged$.asObservable());g(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(t){var r;return(r=this._contextMap.get(t))!=null?r:!1}setContextValue(t,r){this._contextMap.set(t,r),this._contextChanged$.next({[t]:r})}subscribeContextValue$(t){return new W.Observable(r=>{const s=this._contextChanged$.pipe(W.filter(i=>typeof i[t]<"u")).subscribe(i=>r.next(i[t]));return this._contextMap.has(t)&&r.next(this._contextMap.get(t)),()=>s.unsubscribe()})}}var no=(e=>(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))(no||{});const Ot=xe("univer.log");class ro extends Te{constructor(){super(...arguments);g(this,"_logLevel",3)}debug(...t){this._logLevel>=4&&this._log(console.debug,...t)}log(...t){this._logLevel>=3&&this._log(console.log,...t)}warn(...t){this._logLevel>=2&&this._log(console.warn,...t)}error(...t){this._logLevel>=1&&this._log(console.error,...t)}setLogLevel(t){this._logLevel=t}_log(t,...r){const s=r[0];/^\[(.*?)\]/g.test(s)?t(`\x1B[97;104m${s}\x1B[0m`,...r.slice(1)):t(...r)}}var nc=Object.defineProperty,rc=Object.getOwnPropertyDescriptor,sc=(e,n,t,r)=>{for(var s=r>1?void 0:r?rc(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&nc(n,t,s),s},so=(e,n)=>(t,r)=>n(t,r,e),sn=(e=>(e[e.COMMAND=0]="COMMAND",e[e.OPERATION=1]="OPERATION",e[e.MUTATION=2]="MUTATION",e))(sn||{});const on=xe("anywhere.command-service");class ic{constructor(){g(this,"_commands",new Map);g(this,"_commandTypes",new Map)}registerCommand(n){if(this._commands.has(n.id))throw new Error(`[CommandRegistry]: command "${n.id}" has been registered before.`);return this._commands.set(n.id,n),this._commandTypes.set(n.id,n.type),Se(()=>{var t;this._commands.delete(n.id),this._commandTypes.delete(n.id),(t=n.onDispose)==null||t.call(n)})}hasCommand(n){return this._commands.has(n)}getCommand(n){return this._commands.has(n)?[this._commands.get(n)]:null}getCommandType(n){return this._commandTypes.get(n)}}const io={id:"nil",type:0,handler:()=>!0};u.CommandService=class extends Te{constructor(t,r){super();g(this,"_commandRegistry");g(this,"_beforeCommandExecutionListeners",[]);g(this,"_commandExecutedListeners",[]);g(this,"_multiCommandDisposables",new Map);g(this,"_commandExecutingLevel",0);g(this,"_commandExecutionStack",[]);this._injector=t,this._logService=r,this._commandRegistry=new ic,this._registerCommand(io)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(t){return this._commandRegistry.hasCommand(t)}registerCommand(t){return this._registerCommand(t)}registerMultipleCommand(t){return this._registerMultiCommand(t)}beforeCommandExecuted(t){if(this._beforeCommandExecutionListeners.indexOf(t)===-1)return this._beforeCommandExecutionListeners.push(t),Se(()=>{const r=this._beforeCommandExecutionListeners.indexOf(t);this._beforeCommandExecutionListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(t){if(this._commandExecutedListeners.indexOf(t)===-1)return this._commandExecutedListeners.push(t),Se(()=>{const r=this._commandExecutedListeners.indexOf(t);this._commandExecutedListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(t,r,s){try{const i=this._commandRegistry.getCommand(t);if(i){const[o]=i,a={id:o.id,type:o.type,params:r},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(h=>h(a,s));const d=await this._execute(o,r,s);return this._commandExecutedListeners.forEach(h=>h(a,s)),l.dispose(),d}throw new Error(`[CommandService]: command "${t}" is not registered.`)}catch(i){throw this._logService.error(i),i}}syncExecuteCommand(t,r,s){var o;const i=this._commandRegistry.getCommand(t);if(i){const[a]=i,l={id:a.id,type:a.type,params:r};if(a.type===2){const c=jl(this._commandExecutionStack,f=>f.type===0);c&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=c.id)}const d=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(c=>c(l,s));const h=this._syncExecute(a,r,s);return this._commandExecutedListeners.forEach(c=>c(l,s)),d.dispose(),h}throw new Error(`[CommandService]: command "${t}" is not registered.`)}_pushCommandExecutionStack(t){return this._commandExecutionStack.push(t),Se(()=>bn(this._commandExecutionStack,t))}_registerCommand(t){return this._commandRegistry.registerCommand(t)}_registerMultiCommand(t){const r=this._commandRegistry.getCommand(t.id);let s;if(r){if(r[0].multi!==!0)throw new Error("Command has registered as a single command.");s=r[0]}else{const o=new sr;s=new oc(t.id),o.add(this._commandRegistry.registerCommand(s)),o.add(Se(()=>{this._multiCommandDisposables.delete(t.id)})),this._multiCommandDisposables.set(t.id,o)}const i=s.registerImplementation(t);return Se(()=>{var o;i.dispose(),s.hasImplementations()||(o=this._multiCommandDisposables.get(t.id))==null||o.dispose()})}async _execute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${t.id}"`),this._commandExecutingLevel++;let i;try{i=await this._injector.invoke(t.handler,r,s),this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}_syncExecute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${t.id}".`),this._commandExecutingLevel++;let i;try{if(i=this._injector.invoke(t.handler,r,s),i instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}},u.CommandService=sc([so(0,rt(dt)),so(1,Ot)],u.CommandService);class oc{constructor(n){g(this,"name");g(this,"multi",!0);g(this,"type",0);g(this,"priority",0);g(this,"_implementations",[]);g(this,"handler",async(n,t)=>{if(!this._implementations.length)return!1;const r=n.get(Ot),s=n.get(rn),i=n.get(dt);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(s))&&(r.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,t)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const t={command:n};return this._implementations.push(t),this._implementations.sort((r,s)=>s.command.priority-r.command.priority),Se(()=>{var s;const r=this._implementations.indexOf(t);this._implementations.splice(r,1),(s=n.onDispose)==null||s.call(n)})}hasImplementations(){return this._implementations.length>0}}function Nr(e,n,t){const r=e.map(s=>()=>n.syncExecuteCommand(s.id,s.params,t));return eo(r)}function ac(e,n,t){const r=e.map(s=>()=>n.executeCommand(s.id,s.params,t));return Ji(r)}function oo(e){return new W.Observable(n=>{const t=e((...r)=>n.next(r));return()=>t==null?void 0:t.dispose()})}function ao(e){return function(t){return new W.Observable(r=>(t.subscribe({next:s=>{r.next(s),e(s)&&r.complete()},complete:()=>r.complete(),error:s=>r.error(s)}),()=>r.unsubscribe()))}}const lc=e=>new Promise(n=>{W.merge(oo(e.onCommandExecuted.bind(e)).pipe(ht.filter(([t])=>t.type===sn.MUTATION)),W.timer(300)).pipe(ht.debounceTime(16),ht.first()).subscribe(()=>{n()})});var Ye=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.OK=1]="OK",e[e.INTERNAL_ERROR=2]="INTERNAL_ERROR",e[e.PERMISSION_DENIED=3]="PERMISSION_DENIED",e[e.NOT_FOUND=4]="NOT_FOUND",e[e.UNAUTHENTICATED=5]="UNAUTHENTICATED",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",e[e.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",e[e.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",e[e.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",e[e.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",e[e.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",e[e.APPLY_REJECT=7001]="APPLY_REJECT",e[e.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",e[e.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",e[e.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",e[e.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",e[e.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",e[e.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",e[e.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",e[e.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",e[e.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",e[e.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",e[e.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ye||{});function lo(e){return!!(e&&e.code&&e.code!==Ye.OK&&e.code!=="OK")}var J=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(J||{}),uo=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(uo||{}),Be=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Be||{}),Fn=(e=>(e[e.Unkonwn=0]="Unkonwn",e[e.Workbook=1]="Workbook",e[e.Worksheet=2]="Worksheet",e[e.SelectRange=3]="SelectRange",e[e.Document=4]="Document",e[e.Slide=5]="Slide",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Fn||{});class Hn extends Te{}class wr{constructor(){g(this,"_data",[])}static create(){return new wr}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const t=this._data.indexOf(n);this._data.splice(t,1)}getData(){return this._data}}class br{constructor(){g(this,"_data",new Map)}static create(){return new br}add(n,t){this._data.has(n)||this._data.set(n,t)}delete(n){this._data.delete(n)}getData(){return this._data}}var co=(e=>(e[e.PARAGRAPH=0]="PARAGRAPH",e[e.SECTION_BREAK=1]="SECTION_BREAK",e[e.TABLE=2]="TABLE",e[e.TABLE_ROW=3]="TABLE_ROW",e[e.TABLE_CELL=4]="TABLE_CELL",e[e.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",e))(co||{}),ft=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
7
+ `,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(ft||{}),$n=(e=>(e.BULLET_LIST="BULLET_LIST",e.ORDER_LIST="ORDER_LIST",e))($n||{});const uc={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:Zt.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:Zt.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:Zt.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function Ar(e){const n=[];for(const t of e){const{ed:r,ts:s}=t;if(t.sId===void 0&&delete t.sId,k.isEmptyObject(s)&&t.sId==null)continue;if(n.length===0){n.push(t);continue}const i=n.pop();li(t,i)&&k.hasIntersectionBetweenTwoRanges(i.st,i.ed,t.st,t.ed)?n.push({...t,st:i.st,ed:r}):n.push(i,t)}return n}function ho(e,n,t,r){var d;const{textRuns:s}=e;if(s==null)return;const i=[],o=s.length;let a=!1;const l=(d=n.textRuns)!=null?d:[];if(l.length)for(const h of l)h.st+=r,h.ed+=r;for(let h=0;h<o;h++){const c=s[h],f=s[h+1],{st:_,ed:E}=c;if(E<r)i.push(c);else if(r>=_&&r<=E){if(f&&f.st===f.ed&&r===f.st){i.push(c);continue}if(a)c.st+=t,c.ed+=t,i.push(c);else{a=!0,c.ed+=t;const p=[];if(l.length){const N={...c,st:_,ed:l[0].st};N.ed>N.st&&p.push(N),p.push(...l);const D=l[l.length-1],te={...c,st:D.ed,ed:E+t};te.ed>te.st&&p.push(te)}else p.push(c);i.push(...p)}}else c.st+=t,c.ed+=t,a||(a=!0,i.push(...l)),i.push(c)}a||(a=!0,i.push(...l)),e.textRuns=Ar(i)}function Tr(e,n,t,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let h=0,c=s.length;h<c;h++){const f=s[h],{startIndex:_}=f;_>=r&&(f.startIndex+=t),l===-1&&_>=r&&(l=h),a.push(f.startIndex)}let d=-1;if(i){for(let h=0,c=i.length;h<c;h++){const f=i[h];f.startIndex+=r;const _=f.startIndex;d=a.indexOf(_)}if(o===ft.PARAGRAPH&&i.length===1){const h=s[l],c=i[0],f=h.paragraphStyle,_=h.bullet;h.paragraphStyle=c.paragraphStyle,h.bullet=c.bullet,c.paragraphStyle=f,c.bullet=_}d!==-1&&s.splice(d,1),s.push(...i),s.sort(Dt("startIndex"))}}function cc(e,n,t,r){const{sectionBreaks:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:d}=l;d>=r&&(l.startIndex+=t)}const i=n.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Dt("startIndex"))}}function fo(e,n,t,r){const{customBlocks:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:d}=l;d>=r&&(l.startIndex+=t)}const i=n.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r}s.push(...i),s.sort(Dt("startIndex"))}}function _o(e,n,t,r){const{tables:s}=e;if(s==null)return;for(let o=0,a=s.length;o<a;o++){const l=s[o],{startIndex:d,endIndex:h}=l;d>r?(l.startIndex+=t,l.endIndex+=t):h>=r-1&&(l.endIndex+=t)}const i=n.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=r,l.endIndex+=r}s.push(...i),s.sort(Dt("startIndex"))}}function go(e,n,t,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e,i={};for(let l=0,d=s.length;l<d;l++){const h=s[l];i[h.rangeId]=h;const{startIndex:c,endIndex:f}=h;c>=r?(h.startIndex+=t,h.endIndex+=t):f>r-1&&(h.endIndex+=t)}if(s.find(l=>l.startIndex>r&&l.endIndex<r))return;const a=[];if(n.customRanges){for(let l=0,d=n.customRanges.length;l<d;l++){const h=n.customRanges[l],c=i[h.rangeId];if(h.startIndex+=r,h.endIndex+=r,c){if(c.startIndex<=h.startIndex&&c.endIndex>=h.endIndex||e.dataStream[c.startIndex]===ft.CUSTOM_RANGE_START&&e.dataStream[c.endIndex]===ft.CUSTOM_RANGE_END)continue;if(e.dataStream[c.startIndex]===ft.CUSTOM_RANGE_START){c.endIndex=h.endIndex;continue}if(e.dataStream[c.endIndex]===ft.CUSTOM_RANGE_END){c.startIndex=h.startIndex;continue}}a.push(h)}s.push(...a),s.sort(Dt("startIndex"))}}function hc(e){e.sort((r,s)=>r.startIndex-s.startIndex);const n=[];let t=e[0];for(let r=1;r<e.length;r++)t.endIndex+1>=e[r].startIndex?t.endIndex=Math.max(t.endIndex,e[r].endIndex):(n.push(t),t=e[r]);return n.push(t),n}function dc(e){const n={};for(let t=0,r=e.length;t<r;t++){const s=e[t],i=n[s.id];n[s.id]=[...i!=null?i:[],s]}return Object.keys(n).forEach(t=>{const r=n[t],s=hc(r);n[t]=s}),Object.values(n).flat()}function mo(e,n,t,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;if(t>0)for(let i=0,o=s.length;i<o;i++){const a=s[i],{startIndex:l,endIndex:d}=a;l>=r?(a.startIndex+=t,a.endIndex+=t):d>r-1&&(a.endIndex+=t)}if(n.customDecorations){const i=[];for(let o=0,a=n.customDecorations.length;o<a;o++){const l=n.customDecorations[o];i.push(l),l.startIndex+=r,l.endIndex+=r}s.push(...i),e.customDecorations=dc(s),e.customDecorations.sort(Dt("startIndex"))}}function Eo(e,n,t){var a;const{textRuns:r}=e,s=t,i=t+n,o=[];if(s===i&&(r!=null&&r.find(l=>l.st===t&&l.ed===t))){const l=r.find(d=>d.st===t&&d.ed===t);return o.push({...l,st:l.st-t,ed:l.ed-t}),e.textRuns=(a=e.textRuns)==null?void 0:a.filter(d=>d!==l),o}if(r){const l=[];for(let d=0,h=r.length;d<h;d++){const c=r[d],{st:f,ed:_}=c;if(s<=f&&i>=_){o.push({...c,st:f-s,ed:_-s});continue}else f<=s&&_>=i?(o.push({...c,st:s-s,ed:i-s}),c.ed-=n):s>=f&&s<_?(o.push({...c,st:s-s,ed:_-s}),c.ed=s):i>f&&i<=_?(o.push({...c,st:f-s,ed:i-s}),c.st=i-n,c.ed-=n):f>=i&&(c.st-=n,c.ed-=n);l.push(c)}e.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function po(e,n,t){const{paragraphs:r}=e,s=t,i=t+n,o=[];if(r){const a=[];for(let l=0,d=r.length;l<d;l++){const h=r[l],{startIndex:c}=h;if(c>=s&&c<i){o.push({...h,startIndex:c-t});continue}else c>=i&&(h.startIndex-=n);a.push(h)}e.paragraphs=a}return o}function Ro(e,n,t){const{sectionBreaks:r}=e,s=t,i=t+n-1,o=[];if(r){const a=[];for(let l=0,d=r.length;l<d;l++){const h=r[l],{startIndex:c}=h;if(c>=s&&c<=i){o.push({...h,startIndex:c-t});continue}else c>i&&(h.startIndex-=n);a.push(h)}e.sectionBreaks=a}return o}function Co(e,n,t){const{customBlocks:r}=e,s=t,i=t+n-1,o=[];if(r){const a=[];for(let l=0,d=r.length;l<d;l++){const h=r[l],{startIndex:c}=h;if(c>=s&&c<=i){o.push({...h,startIndex:c-t});continue}else c>i&&(h.startIndex-=n);a.push(h)}e.customBlocks=a}return o}function Io(e,n,t){const{tables:r}=e,s=t,i=t+n-1,o=[];if(r){const a=[];for(let l=0,d=r.length;l<d;l++){const h=r[l],{startIndex:c,endIndex:f}=h;if(s<=c&&i>=f){o.push({...h,startIndex:c-t,endIndex:f-t});continue}else if(c<=s&&f>=i){const _=wn(c,f,s,i);h.startIndex=_[0],h.endIndex=_[1]}else i<c&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}e.tables=a}return o}function vo(e,n,t){const{customRanges:r}=e,s=t,i=t+n-1,o=[];if(r){const a=[];for(let l=0,d=r.length;l<d;l++){const h=r[l],{startIndex:c,endIndex:f}=h;if(s<=c&&i>=c){o.push({...h,startIndex:c-t,endIndex:f-t});continue}else if(c<=s&&f>=i){const _=wn(c,f,s,i);h.startIndex=_[0],h.endIndex=_[1]}else i<c&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}e.customRanges=a}return o}function Oo(e,n,t,r=!0){const{customDecorations:s}=e,i=t,o=t+n-1,a=[];if(s){const l=[];for(let d=0,h=s.length;d<h;d++){const c=s[d],{startIndex:f,endIndex:_}=c;if(f>=i&&_<=o){a.push(c);continue}else if(Math.max(i,f)<=Math.min(o,_)){const E=wn(f,_,i,o);c.startIndex=E[0],c.endIndex=E[1]}else o<f&&r&&(c.startIndex-=n,c.endIndex-=n);l.push(c)}e.customDecorations=l}return a}function fc(e,n,t,r,s){const i=_c(e,n,t,r,s),o=gc(e,n,t,r,s),a=mc(e,n,t,r,s),l=Ec(e,n,t,r,s),d=pc(e,n,t,r,s),h=Rc(e,n,t,r,s),c=Cc(e,n,t,r,s);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:d,customRanges:h,customDecorations:c}}function _c(e,n,t,r,s){const{textRuns:i}=e,{textRuns:o}=n;if(i==null||o==null)return;const a=Eo(e,t,r);if(s!==Fe.REPLACE){const l=So(o,a,s);n.textRuns=l}return ho(e,n,t,r),a}function So(e,n,t){if(n.length===0)return e;e=k.deepClone(e),n=k.deepClone(n);const r=[],s=e.length,i=n.length;let o=0,a=0,l=null;function d(){return l?(r.push(l),l=null,!0):!1}for(;o<s&&a<i;){const{st:_,ed:E,ts:p}=e[o],{st:N,ed:D,ts:te,sId:me}=n[a];let fe;if(t===Fe.COVER?fe={...te,...p}:fe={...p,...te},E<N)d()||r.push(e[o]),o++;else if(D<_)d()||r.push(n[a]),a++;else{const R={st:Math.min(_,N),ed:Math.max(_,N),ts:_<N?{...p}:{...te},sId:_<N?void 0:me};R.ed>R.st&&r.push(R),r.push({st:Math.max(_,N),ed:Math.min(E,D),ts:fe,sId:me}),E<D?(o++,n[a].st=E,n[a].st===n[a].ed&&a++):(a++,e[o].st=D,e[o].st===e[o].ed&&o++);const O={st:Math.min(E,D),ed:Math.max(E,D),ts:E<D?{...te}:{...p},sId:E<D?me:void 0};l=O.ed>O.st?O:null}}d();const h=r[r.length-1],c=e[s-1],f=n[i-1];return h.ed!==Math.max(c.ed,f.ed)&&(c.ed>f.ed?r.push(c):r.push(f)),Ar(r)}function gc(e,n,t,r,s){const{paragraphs:i}=e,{paragraphs:o}=n;if(i==null||o==null)return;const a=po(e,t,r);if(s!==Fe.REPLACE){const l=[];for(const d of o){const{startIndex:h,paragraphStyle:c,bullet:f}=d;let _=[];for(const E of a){const{startIndex:p,paragraphStyle:N,bullet:D}=E;let te,me;if(s===Fe.COVER?(te={...N,...c},me={listId:"",listType:$n.BULLET_LIST,nestingLevel:0,textStyle:{},...D,...f}):(te={...c,...N},me={listId:"",listType:$n.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...D}),h===p){_.push({startIndex:h,paragraphStyle:te,bullet:me});break}}l.push(..._),_=[]}n.paragraphs=l}return Tr(e,n,t,r),a}function mc(e,n,t,r,s){const{sectionBreaks:i}=e,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=Ro(e,t,r);if(s!==Fe.REPLACE){const l=[];for(const d of o){const{startIndex:h}=d;let c=[];for(const f of a){const{startIndex:_}=f;if(h===_){s===Fe.COVER?c.push({...f,...d}):c.push({...d,...f});break}}l.push(...c),c=[]}n.sectionBreaks=l}return Tr(e,n,t,r),a}function Ec(e,n,t,r,s){const{customBlocks:i}=e,{customBlocks:o}=n;if(i==null||o==null)return;const a=Co(e,t,r);if(s!==Fe.REPLACE){const l=[];for(const d of o){const{startIndex:h}=d;let c=[];for(const f of a){const{startIndex:_}=f;if(h===_){s===Fe.COVER?c.push({...f,...d}):c.push({...d,...f});break}}l.push(...c),c=[]}n.customBlocks=l}return fo(e,n,t,r),a}function pc(e,n,t,r,s){const{tables:i}=e,{tables:o}=n;if(i==null||o==null)return;const a=Io(e,t,r);if(s!==Fe.REPLACE){const l=[];for(const d of o){const{startIndex:h,endIndex:c}=d;let f=[];for(const _ of a){const{startIndex:E,endIndex:p}=_;if(E>=h&&p<=c){s===Fe.COVER?f.push({..._,...d}):f.push({...d,..._});break}}l.push(...f),f=[]}n.tables=l}return _o(e,n,t,r),a}function Rc(e,n,t,r,s){e.customRanges||(e.customRanges=[]);const{customRanges:i}=e,{customRanges:o}=n;if(i==null||o==null)return;let a=[];return s===Fe.REPLACE&&(a=vo(e,t,r)),go(e,n,0,r),a}function Cc(e,n,t,r,s){e.customDecorations||(e.customDecorations=[]);let i=[];return s===Fe.REPLACE&&(i=Oo(e,t,r,!1)),mo(e,n,0,r),i}var yr=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(yr||{});function an(e,n,t,r=!1,s=1){const{dataStream:i,textRuns:o=[],paragraphs:a=[],customBlocks:l=[]}=e,d={dataStream:i.slice(n,t)},h=[];for(const E of o){const p=k.deepClone(E),{st:N,ed:D}=p;k.hasIntersectionBetweenTwoRanges(N,D,n,t)&&(n>=N&&n<=D?h.push({...p,st:n,ed:Math.min(t,D)}):t>=N&&t<=D?h.push({...p,st:Math.max(n,N),ed:t}):h.push(p))}h.length?d.textRuns=h.map(E=>{const{st:p,ed:N}=E;return{...E,st:p-n,ed:N-n}}):r&&(d.textRuns=[{st:0,ed:t-n,ts:{}}]);const c=[];for(const E of a){const{startIndex:p}=E;p>=n&&p<=t&&c.push(k.deepClone(E))}c.length&&(d.paragraphs=c.map(E=>({...E,startIndex:E.startIndex-n}))),s===1&&(d.customDecorations=wo(e,n,t));const{customRanges:f}=No(e,n,t);d.customRanges=f;const _=[];for(const E of l){const{startIndex:p}=E;p>=n&&p<=t&&_.push(k.deepClone(E))}return _.length&&(d.customBlocks=_.map(E=>({...E,startIndex:E.startIndex-n}))),d}function Ic(e){const{dataStream:n,textRuns:t,paragraphs:r,customRanges:s,customDecorations:i}=e;let o=0,a=0;s==null||s.forEach(d=>{d.startIndex<0&&(o=Math.max(o,-d.startIndex)),d.endIndex>n.length-1&&(a=Math.max(a,d.endIndex-n.length+1))});const l=`${ft.CUSTOM_RANGE_START.repeat(o)}${n}${ft.CUSTOM_RANGE_END.repeat(a)}`;return t&&(t[0]&&(t[0].st=t[0].st-o),t[t.length-1]&&(t[t.length-1].ed=t[t.length-1].ed+a)),t==null||t.forEach(d=>{d.st+=o,d.ed+=o}),r==null||r.forEach(d=>{d.startIndex+=o}),s==null||s.forEach(d=>{d.startIndex+=o,d.endIndex+=o}),i==null||i.forEach(d=>{d.startIndex+=o,d.endIndex+=a}),{...e,dataStream:l,textRuns:t,paragraphs:r,customRanges:s,customDecorations:i}}function No(e,n,t){const{customRanges:r=[]}=e;let s=0,i=0;const o=r.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,t-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(o.length){o.forEach(a=>{a.startIndex<n&&(s+=1),a.endIndex>t-1&&(i+=1)});for(let a=0;a<s;a++){const l=o[a];l.startIndex=n-s+a}if(i){const a=[...o].sort((l,d)=>d.endIndex-l.endIndex);for(let l=0;l<i;l++){const d=a[l];d.endIndex=t+i-l-1}}}return{customRanges:o.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:s,rightOffset:i}}function wo(e,n,t){const{customDecorations:r=[]}=e,s=[];return r.forEach(i=>{if(Math.max(i.startIndex,n)<=Math.min(i.endIndex,t-1)){const o=k.deepClone(i);s.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,t)-n})}}),s}function Dr(e,n,t=Fe.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s=[],paragraphs:i=[]}=e,{textRuns:o=[],paragraphs:a=[]}=n,l=So(o,s,t);l.length&&(r.textRuns=l);const d=[];let h=0,c=0;for(;h<i.length&&c<a.length;){const f=i[h],_=a[c],{startIndex:E}=f,{startIndex:p}=_;E===p?(d.push(k.deepMerge(f,_)),h++,c++):E<p?(d.push(k.deepClone(f)),h++):(d.push(k.deepClone(_)),c++)}return h<i.length&&d.push(...i.slice(h)),c<a.length&&d.push(...a.slice(c)),d.length&&(r.paragraphs=d),r}function vc(e){const{body:n}=e;if(n==null)return!0;const{textRuns:t=[],paragraphs:r=[]}=n;return t.length===0&&r.length===0}function Oc(e=k.generateRandomId(6),n=bt.EN_US,t=""){return{id:e,locale:n,title:t,body:{dataStream:`\r
8
+ `,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var je=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ge={},bo={},Mr={};Object.defineProperty(Mr,"__esModule",{value:!0});function Nc(e,n){if(Array.isArray(n))return!1;for(let t in e)if(!Ur(e[t],n[t]))return!1;for(let t in n)if(e[t]===void 0)return!1;return!0}function wc(e,n){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Ur(e[t],n[t]))return!1;return!0}function Ur(e,n){return e===n?!0:e===null||n===null||typeof e!="object"||typeof n!="object"?!1:Array.isArray(e)?wc(e,n):Nc(e,n)}Mr.default=Ur;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});function Pr(e){if(e===null)return null;if(Array.isArray(e))return e.map(Pr);if(typeof e=="object"){const n={};for(let t in e)n[t]=Pr(e[t]);return n}else return e}Lr.default=Pr;var kr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function n(h,c){if(!h)throw new Error(c)}const t=h=>h!=null&&typeof h=="object"&&!Array.isArray(h),r=(h,c)=>typeof h==typeof c?h>c:typeof h=="string"&&typeof c=="number";function s(h,c){for(let f in h){const _=f;c.write(_,h[_])}}e.isValidPathItem=h=>typeof h=="number"||typeof h=="string"&&h!=="__proto__";class i{constructor(c=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=c}ascend(){n(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):(n(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const c=[];let f=this.container,_=this.parents.length-1,E=this.idx;for(;E>=0;)c.unshift(f[E]),E===0?(E=this.indexes[_*2],f=this.parents[_--]):E-=t(f[E-1])?2:1;return c}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return n(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let c;return this.container&&this.container.length>this.idx+1&&t(c=this.container[this.idx+1])?c:null}descendFirst(){let c=this.idx+1;if(!this.container||c>=this.container.length||t(this.container[c])&&c+1>=this.container.length)return!1;t(this.container[c])&&c++;const f=this.container[c];return Array.isArray(f)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(c),this.idx=0,this.container=f):this.idx=c,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const c=this.indexes[this.indexes.length-1]+1,f=this.parents[this.parents.length-1];return c>=f.length?!1:(n(!isNaN(c)),this.indexes[this.indexes.length-1]=c,this.container=f[c],!0)}_init(c,f,_,E){this.container=c,this.idx=f,this.parents=_.slice(),this.indexes=E.slice()}clone(){const c=new o;return c._init(this.container,this.idx,this.parents,this.indexes),c}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(c,f){const _=this.getComponent();_&&f(_,c);for(const E of this)c&&c.descend(E),this.traverse(c,f),c&&c.ascend()}eachPick(c,f){this.traverse(c,(_,E)=>{_.p!=null&&f(_.p,E)})}eachDrop(c,f){this.traverse(c,(_,E)=>{_.d!=null&&f(_.d,E)})}}e.ReadCursor=o;class a extends i{constructor(c=null){super(c),this.pendingDescent=[],this._op=c}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let c=0;c<this.pendingDescent.length;c++){const f=this.pendingDescent[c];let _=this.idx+1;if(_<this.container.length&&t(this.container[_])&&_++,n(_===this.container.length||!t(this.container[_])),_===this.container.length)this.container.push(f),this.idx=_;else if(this.container[_]===f)this.idx=_;else{if(!Array.isArray(this.container[_])){const E=this.container.splice(_,this.container.length-_);this.container.push(E),this.lcIdx>-1&&(this.lcIdx=_)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(r(f,this.container[this.lcIdx][0])),_=this.lcIdx+1,this.lcIdx=-1);_<this.container.length&&r(f,this.container[_][0]);)_++;if(this.indexes.push(_),this.idx=0,_<this.container.length&&this.container[_][0]===f)this.container=this.container[_];else{const E=[f];this.container.splice(_,0,E),this.container=E}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const c=this.idx+1;if(c<this.container.length&&t(this.container[c]))return this.container[c];{const f={};return this.container.splice(c,0,f),f}}write(c,f){const _=this.getComponent();n(_[c]==null||_[c]===f,"Internal consistency error: Overwritten component. File a bug"),_[c]=f}get(){return this._op}descend(c){if(!e.isValidPathItem(c))throw Error("Invalid JSON key");this.pendingDescent.push(c)}descendPath(c){return this.pendingDescent.push(...c),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(c,f=s){if(c===null)return;if(n(Array.isArray(c)),c===this._op)throw Error("Cannot merge into my own tree");const _=this.lcIdx,E=this.parents.length;let p=0;for(let N=0;N<c.length;N++){const D=c[N];typeof D=="string"||typeof D=="number"?(p++,this.descend(D)):Array.isArray(D)?this.mergeTree(D,f):typeof D=="object"&&f(D,this)}for(;p--;)this.ascend();this.lcIdx=this.parents.length===E?_:-1}at(c,f){this.descendPath(c),f(this);for(let _=0;_<c.length;_++)this.ascend();return this}writeAtPath(c,f,_){return this.at(c,()=>this.write(f,_)),this.reset(),this}writeMove(c,f,_=0){return this.writeAtPath(c,"p",_).writeAtPath(f,"d",_)}getPath(){const c=super.getPath();return c.push(...this.pendingDescent),c}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=h=>new o(h);function l(h,c,f){let _,E;E=_=h?h.descendFirst():!1;function p(N){let D;for(;E;){const te=D=h.getKey();if(N!=null){let me=!1;if(c&&typeof te=="number"&&(D=c(te,h.getComponent()),D<0&&(D=~D,me=!0)),r(D,N))return null;if(D===N&&!me)return h}f&&typeof D=="number"&&f(D,h.getComponent()),E=h.nextSibling()}return null}return p.end=()=>{_&&h.ascend()},p}e.advancer=l;function d(h,c,f){let _,E,p,N;for(_=E=h&&h.descendFirst(),p=N=c&&c.descendFirst();_||p;){let D=_?h.getKey():null,te=p?c.getKey():null;D!==null&&te!==null&&(r(te,D)?te=null:D!==te&&(D=null)),f(D==null?te:D,D!=null?h:null,te!=null?c:null),D!=null&&_&&(_=h.nextSibling()),te!=null&&p&&(p=c.nextSibling())}E&&h.ascend(),N&&c.ascend()}e.eachChildOf=d})(kr);var Fr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,function(n){n[n.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",n[n.DROP_COLLISION=2]="DROP_COLLISION",n[n.BLACKHOLE=3]="BLACKHOLE"}(e.ConflictType||(e.ConflictType={}))})(Fr);var Hr={},Ut={},Ao;function $r(){return Ao||(Ao=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.uniToStrPos=Ut.strPosToUni=void 0,Ut.strPosToUni=(e,n=e.length)=>{let t=0,r=0;for(;r<n;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(t++,r++)}if(r!==n)throw Error("Invalid offset - splits unicode bytes");return r-t},Ut.uniToStrPos=(e,n)=>{let t=0;for(;n>0;n--){const r=e.charCodeAt(t);t+=r>=55296&&r<=57343?2:1}return t}),Ut}var Wr={},To;function Br(){return To||(To=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const n=$r(),t=R=>{if(!Array.isArray(R))throw Error("Op must be an array of components");let O=null;for(let T=0;T<R.length;T++){const Q=R[T];switch(typeof Q){case"object":if(typeof Q.d!="number"&&typeof Q.d!="string")throw Error("Delete must be number or string");if(e.dlen(Q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(Q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(Q>0))throw Error("Skip components must be >0");if(typeof O=="number")throw Error("Adjacent skip components should be combined");break}O=Q}if(typeof O=="number")throw Error("Op has a trailing skip")};function r(R,O){let T=0,Q=0;for(let re=0;re<R.length;re++){const q=R[re];switch(O(q,T,Q),typeof q){case"object":T+=e.dlen(q.d);break;case"string":Q+=n.strPosToUni(q);break;case"number":T+=q,Q+=q;break}}}e.eachOp=r;function s(R,O){const T=[],Q=a(T);return r(R,(re,q,Qe)=>{Q(O(re,q,Qe))}),c(T)}const i=R=>R,o=R=>s(R,i);e.dlen=R=>typeof R=="number"?R:n.strPosToUni(R);const a=R=>O=>{if(!(!O||O.d===0||O.d===""))if(R.length===0)R.push(O);else if(typeof O==typeof R[R.length-1])if(typeof O=="object"){const T=R[R.length-1];T.d=typeof T.d=="string"&&typeof O.d=="string"?T.d+O.d:e.dlen(T.d)+e.dlen(O.d)}else R[R.length-1]+=O;else R.push(O)},l=R=>typeof R=="number"?R:typeof R=="string"?n.strPosToUni(R):typeof R.d=="number"?R.d:n.strPosToUni(R.d);e.uniSlice=(R,O,T)=>{const Q=n.uniToStrPos(R,O),re=T==null?1/0:n.uniToStrPos(R,T);return R.slice(Q,re)};const d=(R,O,T)=>typeof R=="number"?T==null?R-O:Math.min(R,T)-O:e.uniSlice(R,O,T),h=R=>{let O=0,T=0;return{take:(q,Qe)=>{if(O===R.length)return q===-1?null:q;const Ne=R[O];let _e;if(typeof Ne=="number")return q===-1||Ne-T<=q?(_e=Ne-T,++O,T=0,_e):(T+=q,q);if(typeof Ne=="string"){if(q===-1||Qe==="i"||n.strPosToUni(Ne.slice(T))<=q)return _e=Ne.slice(T),++O,T=0,_e;{const Ie=T+n.uniToStrPos(Ne.slice(T),q);return _e=Ne.slice(T,Ie),T=Ie,_e}}else{if(q===-1||Qe==="d"||e.dlen(Ne.d)-T<=q)return _e={d:d(Ne.d,T)},++O,T=0,_e;{let Ie=d(Ne.d,T,T+q);return T+=q,{d:Ie}}}},peek:()=>R[O]}},c=R=>(R.length>0&&typeof R[R.length-1]=="number"&&R.pop(),R);function f(R,O,T){if(T!=="left"&&T!=="right")throw Error("side ("+T+") must be 'left' or 'right'");t(R),t(O);const Q=[],re=a(Q),{take:q,peek:Qe}=h(R);for(let _e=0;_e<O.length;_e++){const Ie=O[_e];let De,qe;switch(typeof Ie){case"number":for(De=Ie;De>0;)qe=q(De,"i"),re(qe),typeof qe!="string"&&(De-=l(qe));break;case"string":T==="left"&&typeof Qe()=="string"&&re(q(-1)),re(n.strPosToUni(Ie));break;case"object":for(De=e.dlen(Ie.d);De>0;)switch(qe=q(De,"i"),typeof qe){case"number":De-=qe;break;case"string":re(qe);break;case"object":De-=e.dlen(qe.d)}break}}let Ne;for(;Ne=q(-1);)re(Ne);return c(Q)}function _(R,O){t(R),t(O);const T=[],Q=a(T),{take:re}=h(R);for(let Qe=0;Qe<O.length;Qe++){const Ne=O[Qe];let _e,Ie;switch(typeof Ne){case"number":for(_e=Ne;_e>0;)Ie=re(_e,"d"),Q(Ie),typeof Ie!="object"&&(_e-=l(Ie));break;case"string":Q(Ne);break;case"object":_e=e.dlen(Ne.d);let De=0;for(;De<_e;)switch(Ie=re(_e-De,"d"),typeof Ie){case"number":Q({d:d(Ne.d,De,De+Ie)}),De+=Ie;break;case"string":De+=n.strPosToUni(Ie);break;case"object":Q(Ie)}break}}let q;for(;q=re(-1);)Q(q);return c(T)}const E=(R,O)=>{let T=0;for(let Q=0;Q<O.length&&R>T;Q++){const re=O[Q];switch(typeof re){case"number":{T+=re;break}case"string":const q=n.strPosToUni(re);T+=q,R+=q;break;case"object":R-=Math.min(e.dlen(re.d),R-T);break}}return R},p=(R,O)=>typeof R=="number"?E(R,O):R.map(T=>E(T,O));function N(R,O,T){return s(R,(Q,re)=>typeof Q=="object"&&typeof Q.d=="number"?{d:T.slice(O,re,re+Q.d)}:Q)}function D(R){return s(R,O=>{switch(typeof O){case"object":if(typeof O.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return O.d;case"string":return{d:O};case"number":return O}})}function te(R){return s(R,O=>typeof O=="object"&&typeof O.d=="string"?{d:n.strPosToUni(O.d)}:O)}function me(R){let O=!0;return r(R,T=>{typeof T=="object"&&typeof T.d=="number"&&(O=!1)}),O}function fe(R){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:c,normalize:o,checkOp:t,create(O=""){if(typeof O!="string")throw Error("Initial data must be a string");return R.create(O)},apply(O,T){t(T);const Q=R.builder(O);for(let re=0;re<T.length;re++){const q=T[re];switch(typeof q){case"number":Q.skip(q);break;case"string":Q.append(q);break;case"object":Q.del(e.dlen(q.d));break}}return Q.build()},transform:f,compose:_,transformPosition:E,transformSelection:p,isInvertible:me,makeInvertible(O,T){return N(O,T,R)},stripInvertible:te,invert:D,invertWithDoc(O,T){return D(N(O,T,R))},isNoop:O=>O.length===0}}e.default=fe}(Wr)),Wr}var Wn={},yo;function bc(){if(yo)return Wn;yo=1,Object.defineProperty(Wn,"__esModule",{value:!0});const e=Br(),n=$r();function t(r,s){return{get:r,getLength(){return r().length},insert(i,o,a){const l=n.strPosToUni(r(),i);return s([l,o],a)},remove(i,o,a){const l=n.strPosToUni(r(),i);return s([l,{d:o}],a)},_onOp(i){e.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const d=e.dlen(o.d);this.onRemove&&this.onRemove(l,d)}})},onInsert:null,onRemove:null}}return Wn.default=t,t.provides={text:!0},Wn}var Do;function Ac(){return Do||(Do=1,function(e){var n=je&&je.__createBinding||(Object.create?function(f,_,E,p){p===void 0&&(p=E),Object.defineProperty(f,p,{enumerable:!0,get:function(){return _[E]}})}:function(f,_,E,p){p===void 0&&(p=E),f[p]=_[E]}),t=je&&je.__setModuleDefault||(Object.create?function(f,_){Object.defineProperty(f,"default",{enumerable:!0,value:_})}:function(f,_){f.default=_}),r=je&&je.__importStar||function(f){if(f&&f.__esModule)return f;var _={};if(f!=null)for(var E in f)Object.hasOwnProperty.call(f,E)&&n(_,f,E);return t(_,f),_},s=je&&je.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const i=$r(),o=r(Br()),a=s(bc()),l={create(f){return f},toString(f){return f},builder(f){if(typeof f!="string")throw Error("Invalid document snapshot: "+f);const _=[];return{skip(E){let p=i.uniToStrPos(f,E);if(p>f.length)throw Error("The op is too long for this document");_.push(f.slice(0,p)),f=f.slice(p)},append(E){_.push(E)},del(E){f=f.slice(i.uniToStrPos(f,E))},build(){return _.join("")+f}}},slice:o.uniSlice},d=o.default(l),h=Object.assign(Object.assign({},d),{api:a.default});e.type=h,e.insert=(f,_)=>_.length===0?[]:f===0?[_]:[f,_],e.remove=(f,_)=>o.dlen(_)===0?[]:f===0?[{d:_}]:[f,{d:_}];var c=Br();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return c.default}})}(Hr)),Hr}(function(e){var n=je&&je.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const t=n(Mr),r=n(Lr),s=kr,i=Fr;function o(m,C){if(!m)throw new Error(C)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:m=>m,isNoop:m=>m==null,setDebug(m){},registerSubtype:D,checkValidOp:re,normalize:q,apply:Qe,transformPosition:Ne,compose:_e,tryTransform:rs,transform:cd,makeInvertible:qe,invert:Ie,invertWithDoc:ud,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(m,C,w)=>Ma(()=>!0,m,C,w),typeAllowingConflictsPred:m=>Object.assign(Object.assign({},e.type),{transform:(C,w,U)=>Ma(m,C,w,U)})};const a=m=>m?m.getComponent():null;function l(m){return m&&typeof m=="object"&&!Array.isArray(m)}const d=m=>Array.isArray(m)?m.slice():m!==null&&typeof m=="object"?Object.assign({},m):m,h=m=>m&&(m.p!=null||m.r!==void 0),c=m=>m&&(m.d!=null||m.i!==void 0);function f(m,C){return o(m!=null),typeof C=="number"?(o(Array.isArray(m),"Invalid key - child is not an array"),(m=m.slice()).splice(C,1)):(o(l(m),"Invalid key - child is not an object"),delete(m=Object.assign({},m))[C]),m}function _(m,C,w){return typeof C=="number"?(o(m!=null,"Container is missing for key"),o(Array.isArray(m),"Cannot use numerical key for object container"),o(m.length>=C,"Cannot insert into out of bounds index"),m.splice(C,0,w)):(o(l(m),"Cannot insert into missing item"),o(m[C]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),m[C]=w),w}e.removeOp=(m,C=!0)=>s.writeCursor().writeAtPath(m,"r",C).get(),e.moveOp=(m,C)=>s.writeCursor().writeMove(m,C).get(),e.insertOp=(m,C)=>s.writeCursor().writeAtPath(m,"i",C).get(),e.replaceOp=(m,C,w)=>s.writeCursor().at(m,U=>{U.write("r",C),U.write("i",w)}).get(),e.editOp=(m,C,w,U=!1)=>s.writeCursor().at(m,b=>O(b,C,w,U)).get();const E=(m,C)=>m!=null&&(typeof C=="number"?Array.isArray(m):typeof m=="object"),p=(m,C)=>E(m,C)?m[C]:void 0,N={};function D(m){let C=m.type?m.type:m;C.name&&(N[C.name]=C),C.uri&&(N[C.uri]=C)}const te=m=>{const C=N[m];if(C)return C;throw Error("Missing type: "+m)};D(Ac());const me=(m,C)=>m+C;D({name:"number",apply:me,compose:me,invert:m=>-m,transform:m=>m});const fe=m=>m==null?null:m.et?te(m.et):m.es?N["text-unicode"]:m.ena!=null?N.number:null,R=m=>m.es?m.es:m.ena!=null?m.ena:m.e,O=(m,C,w,U=!1)=>{const[b,M]=typeof C=="string"?[te(C),C]:[C,C.name];!U&&b.isNoop&&b.isNoop(w)||(M==="number"?m.write("ena",w):M==="text-unicode"?m.write("es",w):(m.write("et",M),m.write("e",w)))};function T(m){o(typeof m=="number"),o(m>=0),o(m===(0|m))}function Q(m){typeof m=="number"?T(m):o(typeof m=="string")}function re(m){if(m===null)return;const C=new Set,w=new Set,U=M=>{let x=!0,G=!1;for(let I in M){const S=M[I];if(x=!1,o(I==="p"||I==="r"||I==="d"||I==="i"||I==="e"||I==="es"||I==="ena"||I==="et","Invalid component item '"+I+"'"),I==="p")T(S),o(!C.has(S)),C.add(S),o(M.r===void 0);else if(I==="d")T(S),o(!w.has(S)),w.add(S),o(M.i===void 0);else if(I==="e"||I==="es"||I==="ena"){o(!G),G=!0;const A=fe(M);o(A,"Missing type in edit"),A.checkValidOp&&A.checkValidOp(R(M))}}o(!x)},b=(M,x,G)=>{if(!Array.isArray(M))throw Error("Op must be null or a list");if(M.length===0)throw Error("Empty descent");x||Q(M[0]);let I=1,S=0,A=0;for(let y=0;y<M.length;y++){const V=M[y];if(o(V!=null),Array.isArray(V)){const K=b(V,!1);if(S){const v=typeof A,$=typeof K;v===$?o(A<K,"descent keys are not in order"):o(v==="number"&&$==="string")}A=K,S++,I=3}else typeof V=="object"?(o(I===1,`Prev not scalar - instead ${I}`),U(V),I=2):(o(I!==3),Q(V),o(s.isValidPathItem(V),"Invalid path key"),I=1)}return o(S!==1,"Operation makes multiple descents. Remove some []"),o(I===2||I===3),M[0]};b(m,!0),o(C.size===w.size,"Mismatched picks and drops in op");for(let M=0;M<C.size;M++)o(C.has(M)),o(w.has(M))}function q(m){let C=0,w=[];const U=s.writeCursor();return U.mergeTree(m,(b,M)=>{const x=fe(b);if(x){const I=R(b);O(M,x,x.normalize?x.normalize(I):I)}for(const I of["r","p","i","d"])if(b[I]!==void 0){const S=I==="p"||I==="d"?(G=b[I],w[G]==null&&(w[G]=C++),w[G]):b[I];M.write(I,S)}var G}),U.get()}function Qe(m,C){if(re(C),C===null)return m;const w=[];return function U(b,M){let x=b,G=0,I={root:b},S=0,A=I,y="root";function V(){for(;S<G;S++){let K=M[S];typeof K!="object"&&(o(E(A,y)),A=A[y]=d(A[y]),y=K)}}for(;G<M.length;G++){const K=M[G];if(Array.isArray(K)){const v=U(x,K);v!==x&&v!==void 0&&(V(),x=A[y]=v)}else if(typeof K=="object"){K.d!=null?(V(),x=_(A,y,w[K.d])):K.i!==void 0&&(V(),x=_(A,y,K.i));const v=fe(K);if(v)V(),x=A[y]=v.apply(x,R(K));else if(K.e!==void 0)throw Error("Subtype "+K.et+" undefined")}else x=p(x,K)}return I.root}(m=function U(b,M){const x=[];let G=0;for(;G<M.length;G++){const y=M[G];if(Array.isArray(y))break;typeof y!="object"&&(x.push(b),b=p(b,y))}for(let y=M.length-1;y>=G;y--)b=U(b,M[y]);for(--G;G>=0;G--){const y=M[G];if(typeof y!="object"){const V=x.pop();b=b===p(V,y)?V:b===void 0?f(V,y):(S=y,A=b,(I=d(I=V))[S]=A,I)}else h(y)&&(o(b!==void 0,"Cannot pick up or remove undefined"),y.p!=null&&(w[y.p]=b),b=void 0)}var I,S,A;return b}(m,C),C)}function Ne(m,C){m=m.slice(),re(C);const w=s.readCursor(C);let U,b,M=!1;const x=[];for(let I=0;;I++){const S=m[I],A=w.getComponent();if(A&&(A.r!==void 0?M=!0:A.p!=null&&(M=!1,U=A.p,b=I)),I>=m.length)break;let y=0;const V=s.advancer(w,void 0,(v,$)=>{h($)&&y++});x.unshift(V);const K=V(S);if(typeof S=="number"&&(m[I]-=y),!K)break}if(x.forEach(I=>I.end()),M)return null;const G=()=>{let I=0;if(U!=null){const S=w.getPath();I=S.length,m=S.concat(m.slice(b))}for(;I<m.length;I++){const S=m[I],A=a(w),y=fe(A);if(y){const v=R(A);y.transformPosition&&(m[I]=y.transformPosition(m[I],v));break}let V=0;const K=s.advancer(w,(v,$)=>c($)?~(v-V):v-V,(v,$)=>{c($)&&V++})(S);if(typeof S=="number"&&(m[I]+=V),!K)break}};return U!=null?w.eachDrop(null,I=>{I===U&&G()}):G(),m}function _e(m,C){if(re(m),re(C),m==null)return C;if(C==null)return m;let w=0;const U=s.readCursor(m),b=s.readCursor(C),M=s.writeCursor(),x=[],G=[],I=[],S=[],A=[],y=[],V=new Set;U.traverse(null,v=>{v.p!=null&&(I[v.p]=U.clone())}),b.traverse(null,v=>{v.d!=null&&(S[v.d]=b.clone())});const K=s.writeCursor();return function v($,ge,ue,Z,pe,gt,He,Me){o(ge||ue);const Re=a(ge),Ze=a(ue),st=!!Ze&&Ze.r!==void 0,kt=!!Re&&Re.i!==void 0,Je=Re?Re.d:null,Ke=Ze?Ze.p:null,mt=(gt||st)&&Ke==null;if(Ke!=null)Z=S[Ke],He=G[Ke]=new s.WriteCursor;else if(Ze&&Ze.r!==void 0)Z=null;else{const P=a(Z);P&&P.d!=null&&(Z=null)}const ae=a(Z);if(Je!=null)if($=I[Je],Me=x[Je]=new s.WriteCursor,mt)gt&&!st&&Me.write("r",!0);else{const P=A[Je]=w++;He.write("d",P)}else if(Re&&Re.i!==void 0)$=null;else{const P=a($);P&&P.p!=null&&($=null)}let F;kt?(o(pe===void 0),F=Re.i):F=pe;const Y=(Ke==null?!kt||gt||st:F===void 0)?null:He.getComponent();if(Ke!=null){if(!(pe!==void 0||kt)){const P=Je!=null?A[Je]:w++;y[Ke]=P,Me.write("p",P)}}else st&&(kt||pe!==void 0||(Ze.r,Me.write("r",Ze.r)));const H=mt?null:fe(Re),L=fe(ae);if((H||L)&&(H&&H.name,L&&L.name),H&&L){o(H===L);const P=R(Re),X=R(ae),Ae=H.compose(P,X);O(He,H,Ae),V.add(ae)}else H?O(He,H,R(Re)):L&&(O(He,L,R(ae)),V.add(ae));const B=typeof F=="object"&&F!=null;let se=!1,ie=0,le=0,be=0,we=0,Ce=0;const Pe=s.advancer(Z,(P,X)=>c(X)?we-P-1:P-we,(P,X)=>{c(X)&&we++}),ne=s.advancer($,(P,X)=>h(X)?ie-P-1:P-ie,(P,X)=>{h(X)&&ie++});if(s.eachChildOf(ge,ue,(P,X,Ae)=>{let $e,Et,Ft=P,it=P,gn=P;if(typeof P=="number"){let Ue=P+be;Et=Pe(Ue),it=Ue+we;let ve=P+le;$e=ne(ve),c(a(Et))&&($e=null),Ft=ve+ie,gn=P+Ce,o(Ft>=0,"p1PickKey is negative"),o(it>=0,"p2DropKey is negative");const ot=c(a(X)),pt=h(a(Ae));(ot||pt&&!mt)&&Ce--,ot&&le--,pt&&be--}else $e=ne(P),Et=Pe(P);Me.descend(Ft),He.descend(it);const Yt=B&&!c(a(X))?F[gn]:void 0,ut=v($e,X,Ae,Et,Yt,mt,He,Me);var ct,j,Ee;B&&!mt?Yt!==ut&&(se||(F=Array.isArray(F)?F.slice():Object.assign({},F),se=!0),ct=F,Ee=ut,typeof(j=gn)=="number"?(o(Array.isArray(ct)),o(j<ct.length)):(o(!Array.isArray(ct)),o(ct[j]!==void 0)),Ee===void 0?typeof j=="number"?ct.splice(j,1):delete ct[j]:ct[j]=Ee):o(ut===void 0),He.ascend(),Me.ascend()}),ne.end(),Pe.end(),Y!=null)Y.i=F;else if(!gt&&!st&&Ke==null)return F}(U,U.clone(),b,b.clone(),void 0,!1,M,K),M.reset(),M.mergeTree(K.get()),M.reset(),M.get(),x.map(v=>v.get()),G.map(v=>v.get()),U.traverse(M,(v,$)=>{const ge=v.p;if(ge!=null){const ue=A[ge];ue!=null&&$.write("p",ue);const Z=x[ge];Z&&Z.get(),Z&&$.mergeTree(Z.get())}else v.r!==void 0&&$.write("r",v.r)}),M.reset(),M.get(),b.traverse(M,(v,$)=>{const ge=v.d;if(ge!=null){const Z=y[ge];Z!=null&&$.write("d",Z);const pe=G[ge];pe&&$.mergeTree(pe.get())}else v.i!==void 0&&$.write("i",v.i);const ue=fe(v);ue&&!V.has(v)&&O($,ue,R(v))}),M.get()}function Ie(m){if(m==null)return null;const C=new s.ReadCursor(m),w=new s.WriteCursor;let U;const b=[],M=[];return function x(G,I,S){const A=G.getComponent();let y,V=!1;if(A){A.p!=null&&(I.write("d",A.p),b[A.p]=G.clone()),A.r!==void 0&&I.write("i",A.r),A.d!=null&&(I.write("p",A.d),S=void 0),A.i!==void 0&&(S=y=A.i);const v=fe(A);v&&(S===void 0?(U||(U=new Set),U.add(A)):(R(A),S=v.apply(S,R(A)),V=!0))}let K=0;for(const v of G){I.descend(v);const $=typeof v=="number"?v-K:v,ge=p(S,$);c(G.getComponent())&&K++;const ue=x(G,I,ge);if(S!==void 0&&ue!==void 0){if(V||(V=!0,S=d(S)),!E(S,$))throw Error("Cannot modify child - invalid operation");S[$]=ue}I.ascend()}if(y===void 0)return V?S:void 0;I.write("r",S)}(C,w,void 0),U&&(w.reset(),function x(G,I,S){const A=I.getComponent();if(A){const v=A.d;if(v!=null&&(G=b[v],S=M[v]=s.writeCursor()),U.has(A)){const $=fe(A);if(!$.invert)throw Error(`Cannot invert subtype ${$.name}`);O(S,$,$.invert(R(A)))}}let y=0,V=0;const K=s.advancer(G,(v,$)=>h($)?y-v-1:v-y,(v,$)=>{h($)&&y++});for(const v of I)if(typeof v=="number"){const $=v-V,ge=K($),ue=$+y;S.descend(ue),x(ge,I,S),c(I.getComponent())&&V++,S.ascend()}else S.descend(v),x(K(v),I,S),S.ascend();K.end()}(C.clone(),C,w),M.length&&(w.reset(),C.traverse(w,(x,G)=>{const I=x.p;if(I!=null){const S=M[I];S&&S.get(),S&&G.mergeTree(S.get())}}))),w.get()}const De=(m,C)=>m.some(w=>typeof w=="object"&&(Array.isArray(w)?De(w,C):C(w)));function qe(m,C){if(m==null||!De(m,I=>{var S;return I.r!==void 0||((S=fe(I))===null||S===void 0?void 0:S.makeInvertible)!=null}))return m;const w=new s.ReadCursor(m),U=new s.WriteCursor;let b=!1;const M=[],x=[],G=(I,S,A)=>{const y=I.getComponent();let V=!1;if(y){y.d!=null&&S.write("d",y.d),y.i!==void 0&&S.write("i",y.i);const v=y.p;if(v!=null&&(M[v]=I.clone(),o(A!==void 0,"Operation picks up at an invalid key"),x[v]=A,S.write("p",y.p)),y.r!==void 0&&A===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const $=fe(y);$&&($.makeInvertible?b=!0:O(S,$,R(y),!0))}let K=0;for(const v of I){S.descend(v);const $=typeof v=="number"?v-K:v,ge=p(A,$),ue=G(I,S,ge);ge!==ue&&(V||(V=!0,A=d(A)),ue===void 0?(A=f(A,$),typeof v=="number"&&K++):A[$]=ue),S.ascend()}return y&&(y.r!==void 0?(S.write("r",r.default(A)),A=void 0):y.p!=null&&(A=void 0)),A};return G(w,U,C),U.get(),b&&(U.reset(),function I(S,A,y,V,K){const v=A.getComponent();if(v){v.i!==void 0?(V=v.i,K=!0):v.d!=null&&(V=x[v.d],S=M[v.d],K=!1,v.d);let Z=fe(v);if(Z&&Z.makeInvertible){const pe=R(v);O(y,Z,Z.makeInvertible(pe,V),!0)}}let $=0,ge=0;const ue=s.advancer(S,(Z,pe)=>h(pe)?$-Z-1:Z-$,(Z,pe)=>{h(pe)&&$++});for(const Z of A)if(typeof Z=="number"){const pe=Z-ge,gt=ue(pe),He=pe+$,Me=p(V,K?pe:He);y.descend(Z),I(gt,A,y,Me,K),c(A.getComponent())&&ge++,y.ascend()}else{const pe=p(V,Z);y.descend(Z),I(ue(Z),A,y,pe,K),y.ascend()}ue.end()}(w.clone(),w,U,C,!1)),U.get()}function ud(m,C){return Ie(qe(m,C))}const ns=m=>{if(m==null)return null;const C=m.slice();for(let w=0;w<m.length;w++){const U=C[w];Array.isArray(U)&&(C[w]=ns(U))}return C};function rs(m,C,w){o(w==="left"||w==="right","Direction must be left or right");const U=w==="left"?0:1;if(C==null)return{ok:!0,result:m};re(m),re(C);let b=null;const M=[],x=[],G=[],I=[],S=[],A=[],y=[],V=[],K=[],v=[],$=[],ge=[],ue=[],Z=[],pe=[];let gt=0;const He=s.readCursor(m),Me=s.readCursor(C),Re=s.writeCursor();if(function ae(F,Y=null,H){const L=a(Y);L&&(L.r!==void 0?H=Y.clone():L.p!=null&&(H=null,A[L.p]=F.clone()));const B=F.getComponent();let se;B&&(se=B.p)!=null&&(S[se]=Y?Y.clone():null,G[se]=F.clone(),H&&(v[se]=!0,K[se]=H),L&&L.p!=null&&(Z[se]=L.p));const ie=s.advancer(Y);for(const le of F)ae(F,ie(le),H);ie.end()}(Me,He,null),function ae(F,Y,H,L,B){const se=H.getComponent();let ie,le=!1;se&&((ie=se.d)!=null?(I[ie]=H.clone(),L!=null&&(pe[L]==null&&(pe[L]=[]),pe[L].push(ie)),F=S[ie]||null,Y=G[ie]||null,v[ie]?(B&&($[ie]=!0),B=K[ie]||null):!B||U!==1&&Z[ie]!=null||b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(B.getPath()),op2:e.moveOp(Y.getPath(),H.getPath())}),le=!0):se.i!==void 0&&(F=Y=null,le=!0,B&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(B.getPath()),op2:e.insertOp(H.getPath(),se.i)})));const be=a(F);be&&(be.r!==void 0?B=F.clone():be.p!=null&&(be.p,L=be.p,B=null));const we=fe(se);we&&B&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(B.getPath()),op2:e.editOp(H.getPath(),we,R(se),!0)});let Ce=0,Pe=0;const ne=s.advancer(Y,(X,Ae)=>h(Ae)?Ce-X-1:X-Ce,(X,Ae)=>{h(Ae)&&Ce++}),P=s.advancer(F);for(const X of H)if(typeof X=="number"){const Ae=X-Pe,$e=ne(Ae);Pe+=+ae(P(Ae+Ce),$e,H,L,B)}else{const Ae=ne(X);ae(P(X),Ae,H,L,B)}return ne.end(),P.end(),le}(He,Me,Me.clone(),null,null),I.map(ae=>ae&&ae.get()),b)return{ok:!1,conflict:b};$.map(ae=>!!ae);const Ze=[];let st=null;(function ae(F,Y,H,L,B){let se=!1;const ie=a(Y);if(h(ie)){const ne=ie.p;ne!=null?(H=I[ne],L=ge[ne]=s.writeCursor(),se=!0,B=null):(H=null,B=Y.clone())}else c(a(H))&&(H=null);const le=F.getComponent();if(le){const ne=le.p;ne!=null?(B&&(V[ne]=B),Ze[ne]=B||U===1&&se?null:L.getComponent(),M[ne]=F.clone(),H&&(y[ne]=H.clone())):le.r!==void 0&&(B||L.write("r",!0),(B||se)&&(st==null&&(st=new Set),st.add(le)))}let be=0,we=0;const Ce=s.advancer(Y,void 0,(ne,P)=>{h(P)&&be++}),Pe=s.advancer(H,(ne,P)=>c(P)?~(ne-we):ne-we,(ne,P)=>{c(P)&&we++});if(F)for(const ne of F)if(typeof ne=="string"){const P=Ce(ne),X=Pe(ne);L.descend(ne),ae(F,P,X,L,B),L.ascend()}else{const P=Ce(ne),X=ne-be,Ae=h(a(P))?null:Pe(X),$e=X+we;o($e>=0),L.descend($e),ae(F,P,Ae,L,B),L.ascend()}Ce.end(),Pe.end()})(He,Me,Me.clone(),Re,null),Re.reset();let kt=[];if(function ae(F,Y,H,L,B,se){o(Y);const ie=Y.getComponent();let le=a(L),be=!1;const we=(j,Ee,Ue)=>j?e.moveOp(j.getPath(),Ee.getPath()):e.insertOp(Ee.getPath(),Ue.i);if(c(ie)){const j=ie.d;j!=null&&(x[j]=Y.clone());const Ee=j!=null?Ze[j]:null;let Ue=!1;if(ie.i!==void 0||j!=null&&Ee){let ve;le&&(le.i!==void 0||(ve=le.d)!=null&&!v[ve])&&(Ue=ve!=null?j!=null&&j===Z[ve]:t.default(le.i,ie.i),Ue||ve!=null&&U!==1&&Z[ve]!=null||b==null&&(b={type:i.ConflictType.DROP_COLLISION,op1:we(j!=null?M[j]:null,Y,ie),op2:we(ve!=null?G[ve]:null,L,le)})),Ue||(se?b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:we(j!=null?M[j]:null,Y,ie),op2:e.removeOp(se.getPath())}):(j!=null?(kt[gt]=j,B.write("d",Ee.p=gt++)):B.write("i",r.default(ie.i)),be=!0))}else if(j!=null&&!Ee){const ve=V[j];ve&&(se=ve.clone())}j!=null?(F=M[j],H=A[j],L=y[j]):ie.i!==void 0&&(F=H=null,Ue||(L=null))}else h(a(F))&&(F=H=L=null);const Ce=a(F),Pe=a(H);if(h(Pe)){const j=Pe.p;Pe.r!==void 0&&(!Ce||Ce.r===void 0)||v[j]?(L=null,se=H.clone()):j!=null&&(L=I[j],U!==1&&Z[j]!=null||((B=ue[j])||(B=ue[j]=s.writeCursor()),B.reset(),se=null))}else!c(ie)&&c(le)&&(L=null);le=L!=null?L.getComponent():null;const ne=fe(ie);if(ne){const j=R(ie);if(se)b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(Y.getPath(),ne,j,!0),op2:e.removeOp(se.getPath())});else{const Ee=fe(le);let Ue;if(Ee){if(ne!==Ee)throw Error("Transforming incompatible types");const ve=R(le);Ue=ne.transform(j,ve,w)}else Ue=r.default(j);O(B,ne,Ue)}}let P=0,X=0,Ae=0,$e=0,Et=0,Ft=0,it=F!=null&&F.descendFirst(),gn=it;const Yt=s.advancer(H,void 0,(j,Ee)=>{h(Ee)&&Ae++});let ut=L!=null&&L.descendFirst(),ct=ut;for(const j of Y)if(typeof j=="number"){let Ee;const Ue=c(Y.getComponent()),ve=j-X;{let wt;for(;it&&typeof(wt=F.getKey())=="number";){wt+=P;const at=F.getComponent(),Xt=h(at);if(wt>ve||wt===ve&&(!Xt||U===0&&Ue))break;if(Xt){P--;const Ht=at.p;Z.includes(Ht),at.d,a(ue[at.d]),h(a(ue[at.d])),(at.r===void 0||st&&st.has(at))&&(Ht==null||!Ze[Ht]||U!==1&&Z.includes(Ht))||Et--}it=F.nextSibling()}Ee=it&&wt===ve?F:null}const ot=ve-P;let pt=Yt(ot);const ss=ot-Ae;let qn=null;{let wt,at;for(;ut&&typeof(wt=L.getKey())=="number";){at=wt-$e;const Xt=L.getComponent(),Ht=c(Xt);if(at>ss)break;if(at===ss){if(!Ht){qn=L;break}{if(U===0&&Ue){qn=L;break}const $t=pt&&h(pt.getComponent());if(U===0&&$t)break}}if(Ht){const $t=Xt.d;Z[$t],Xt.i===void 0&&(v[$t]||Z[$t]!=null&&U!==1)?(v[$t]||Z[$t]!=null&&U===0)&&($e++,Ft--):$e++}ut=L.nextSibling()}}const Ua=ss+$e+Et+Ft;o(Ua>=0,"trying to descend to a negative index"),B.descend(Ua),Ue&&(Ee=pt=qn=null,X++),ae(Ee,Y,pt,qn,B,se)&&Ft++,B.ascend()}else{let Ee;for(;it&&(Ee=F.getKey(),typeof Ee!="string"||!(Ee>j||Ee===j));)it=F.nextSibling();const Ue=it&&Ee===j?F:null,ve=Yt(j);let ot;for(;ut&&(ot=L.getKey(),typeof ot!="string"||!(ot>j||ot===j));)ut=L.nextSibling();const pt=ut&&ot===j?L:null;B.descend(j),ae(Ue,Y,ve,pt,B,se),B.ascend()}return Yt.end(),gn&&F.ascend(),ct&&L.ascend(),be}(He,He.clone(),Me,Me.clone(),Re,null),b)return{ok:!1,conflict:b};Re.reset();const Je=(ae,F,Y)=>ae.traverse(F,(H,L)=>{H.d!=null&&Y(H.d,ae,L)});(v.length||ge.length)&&(Je(Me,Re,(ae,F,Y)=>{v[ae]&&!$[ae]&&Y.write("r",!0),ge[ae]&&Y.mergeTree(ge[ae].get())}),Re.reset());const Ke=[],mt=[];if((ue.length||v.length)&&!b){const ae=s.readCursor(ns(Re.get()));if(Je(ae,null,(F,Y)=>{Ke[F]=Y.clone()}),ue.forEach(F=>{F&&Je(s.readCursor(F.get()),null,(Y,H)=>{Ke[Y]=H.clone()})}),function F(Y,H,L,B,se,ie){const le=a(H);if(le&&h(le))if(le.p!=null){const P=le.p;Ke[P].getPath(),L=Ke[P],B=mt[P]=s.writeCursor()}else le.r!==void 0&&(L=null);else c(a(L))&&(L=null);const be=Y.getComponent();if(be){let P;if((P=be.d)!=null){const X=ue[P];X&&(X.get(),B.mergeTree(X.get()),L=s.readCursor(X.get()))}}let we=0,Ce=0;const Pe=s.advancer(H,void 0,(P,X)=>{h(X)&&we--}),ne=s.advancer(L,(P,X)=>c(X)?-(P-Ce)-1:P-Ce,(P,X)=>{c(X)&&Ce++});for(const P of Y)if(typeof P=="number"){const X=Pe(P),Ae=P+we,$e=ne(Ae),Et=Ae+Ce;B.descend(Et),F(Y,X,$e,B),B.ascend()}else B.descend(P),F(Y,Pe(P),ne(P),B),B.ascend();Pe.end(),ne.end()}(Me,ae,ae.clone(),Re),Re.reset(),b)return{ok:!1,conflict:b};if(Re.get(),mt.length){const F=mt.map(H=>H?H.get():null),Y=s.readCursor(ns(Re.get()));if(Je(Y,Re,(H,L,B)=>{const se=F[H];se&&(B.mergeTree(se),F[H]=null)}),F.find(H=>H)){const H=s.writeCursor(),L=s.writeCursor();let B=0,se=0;F.forEach(ie=>{ie!=null&&Je(s.readCursor(ie),null,le=>{const be=kt[le];H.writeMove(M[be].getPath(),x[be].getPath(),B++);const we=pe[be];we&&we.forEach(Ce=>{v[Ce]||U!==1&&Z[Ce]!=null||L.writeMove(G[Ce].getPath(),I[Ce].getPath(),se++)})})}),b={type:i.ConflictType.BLACKHOLE,op1:H.get(),op2:L.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:Re.get()}}const Da=m=>{const C=new Error("Transform detected write conflict");throw C.conflict=m,C.type=C.name="writeConflict",C};function cd(m,C,w){const U=rs(m,C,w);if(U.ok)return U.result;Da(U.conflict)}const zt=m=>{const C=s.writeCursor();return s.readCursor(m).traverse(C,(w,U)=>{(c(w)||fe(w))&&U.write("r",!0)}),C.get()},hd=(m,C)=>{const{type:w,op1:U,op2:b}=m;switch(w){case i.ConflictType.DROP_COLLISION:return C==="left"?[null,zt(b)]:[zt(U),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let M=!1;return s.readCursor(U).traverse(null,x=>{x.r!==void 0&&(M=!0)}),M?[null,zt(b)]:[zt(U),null];case i.ConflictType.BLACKHOLE:return[zt(U),zt(b)];default:throw Error("Unrecognised conflict: "+w)}};function Ma(m,C,w,U){let b=null;for(;;){const M=rs(C,w,U);if(M.ok)return _e(b,M.result);{const{conflict:x}=M;m(x)||Da(x);const[G,I]=hd(x,U);C=_e(q(C),G),w=_e(q(w),I),b=_e(b,I)}}}})(bo),function(e){var n=je&&je.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),t=je&&je.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&n(o,i,a)};Object.defineProperty(e,"__esModule",{value:!0}),t(bo,e);var r=kr;Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=Fr;Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(Ge);const Tc=Pa({__proto__:null,default:Sc(Ge)},[Ge]);var ee=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(ee||{});class jr{constructor(n){g(this,"_index",0);g(this,"_offset",0);this._actions=n}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(n){n||(n=Number.POSITIVE_INFINITY);const t=this._actions[this._index];if(t){const r=this._offset,s=t.len;return n>=s-r?(n=s-r,this._index+=1,this._offset=0):this._offset+=n,t.t===ee.DELETE||t.t===ee.RETAIN&&t.body==null?k.deepClone({...t,len:n}):k.deepClone({...t,len:n,body:an(t.body,r,r+n)})}else return{t:ee.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:ee.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,t=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=n,this._index=t,[r].concat(s)}}else return[]}}class Mo{constructor(){g(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function Uo(e,n,t){const{dataStream:r}=e,s=t,i=t+n,o=Eo(e,n,t),a=po(e,n,t),l=Ro(e,n,t),d=Co(e,n,t),h=Io(e,n,t),c=vo(e,n,t),f=Oo(e,n,t);let _="";return r&&(e.dataStream=hi(r,s,i),_=r.slice(s,i)),{dataStream:_,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:d,tables:h,customRanges:c,customDecorations:f}}function Lo(e,n,t,r){e.dataStream=ci(e.dataStream,r,n.dataStream),ho(e,n,t,r),Tr(e,n,t,r),cc(e,n,t,r),fo(e,n,t,r),_o(e,n,t,r),go(e,n,t,r),mo(e,n,t,r)}function yc(e,n,t,r,s=Fe.COVER){return fc(e,n,t,r,s)}function Dc(e,n,t){return n<=0?{dataStream:""}:Uo(e,n,t)}function Mc(e,n,t,r){t!==0&&Lo(e,n,t,r)}function Uc(e,n){const t=new Mo;return t.reset(),n.forEach(r=>{switch(r=k.deepClone(r),r.t){case ee.RETAIN:{const{coverType:s,body:i,len:o}=r;i!=null&&yc(e,i,o,t.cursor,s),t.moveCursor(o);break}case ee.INSERT:{const{body:s,len:i}=r;Mc(e,s,i,t.cursor),t.moveCursor(i);break}case ee.DELETE:{const{len:s}=r;Dc(e,s,t.cursor);break}default:throw new Error(`Unknown action type for action: ${r}.`)}}),e}function Po(e){return Object.keys(e).length===1}const _n=class _n{constructor(){g(this,"_actions",[])}static apply(n,t){return Uc(n,t)}static compose(n,t){const r=new jr(n),s=new jr(t),i=new _n;for(;r.hasNext()||s.hasNext();)if(s.peekType()===ee.INSERT)i.push(s.next());else if(r.peekType()===ee.DELETE)i.push(r.next());else{const o=Math.min(r.peekLength(),s.peekLength()),a=r.next(o),l=s.next(o);a.t===ee.INSERT&&l.t===ee.RETAIN?l.body==null?i.push(a):i.push({...a,body:Dr(a.body,l.body,l.coverType)}):a.t===ee.RETAIN&&l.t===ee.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:Dr(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===ee.RETAIN&&l.t===ee.DELETE?i.push(l):a.t===ee.INSERT&&(l.t,ee.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(n,t,r){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const t=[];for(const r of n)if(r.t===ee.INSERT)t.push({t:ee.DELETE,len:r.len,line:0,body:r.body,segmentId:r.segmentId});else if(r.t===ee.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");t.push({t:ee.INSERT,body:r.body,len:r.len,line:0,segmentId:r.segmentId})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");t.push({t:ee.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:Fe.REPLACE,segmentId:r.segmentId})}else t.push(r);return t}static makeInvertible(n,t){const r=[];let s=0;for(const i of n){if(i.t===ee.DELETE&&i.body==null){const o=an(t,s,s+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===ee.RETAIN&&i.body!=null){const o=an(t,s,s+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}r.push(i),i.t!==ee.INSERT&&(s+=i.len)}return r}insert(n,t,r=""){const s={t:ee.INSERT,body:t,len:n,line:0,segmentId:r};return this.push(s),this}retain(n,t="",r,s){const i={t:ee.RETAIN,len:n,segmentId:t};return r!=null&&(i.body=r),s!=null&&(i.coverType=s),this.push(i),this}delete(n,t=""){const r={t:ee.DELETE,len:n,line:0,segmentId:t};return this.push(r),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...n){if(n.length>1){for(const i of n)this.push(i);return this}let t=this._actions.length,r=this._actions[t-1];const s=k.deepClone(n[0]);if(s.t===ee.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===ee.DELETE&&s.t===ee.DELETE)return r.len+=s.len,this;if(r.t===ee.DELETE&&s.t===ee.INSERT&&(t-=1,r=this._actions[t-1],r==null))return this._actions.unshift(s),this;if(r.t===ee.RETAIN&&s.t===ee.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===ee.INSERT&&Po(r.body)&&s.t===ee.INSERT&&Po(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return t===this._actions.length?this._actions.push(s):this._actions.splice(t,0,s),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===ee.RETAIN&&vc(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};g(_n,"id","text-x"),g(_n,"uri","https://github.com/dream-num/univer#text-x");let St=_n;Object.defineProperty(St,"name",{value:"text-x"});const Kt=class Kt{static registerSubtype(n){var t;this._subTypes.has(n.name)&&((t=this._subTypes.get(n.name))==null?void 0:t.id)!==St.id||(this._subTypes.set(n.name,n),Ge.type.registerSubtype(n))}static apply(n,t){if(!Ge.type.isNoop(t))return Ge.type.apply(n,t)}static compose(n,t){return Ge.type.compose(n,t)}static transform(n,t,r){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,t){return Ge.type.invertWithDoc(n,t)}static isNoop(n){return Ge.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new Kt),this._instance}removeOp(n,t){return Ge.removeOp(n,t)}moveOp(n,t){return Ge.moveOp(n,t)}insertOp(n,t){return Ge.insertOp(n,t)}replaceOp(n,t,r){return Ge.replaceOp(n,t,r)}editOp(n,t=["body"]){return Ge.editOp(t,St.name,n)}};g(Kt,"uri","https://github.com/dream-num/univer#json-x"),g(Kt,"_subTypes",new Map),g(Kt,"_instance",null);let Lt=Kt;Lt.registerSubtype(St);const Gr={id:"default_doc",documentStyle:{}};class Lc extends Hn{constructor(t){super();g(this,"type",J.UNIVER_DOC);g(this,"snapshot");this.snapshot={...Gr,...t}}getUnitId(){throw new Error("Method not implemented.")}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var t;return((t=this.snapshot.settings)==null?void 0:t.zoomRatio)||1}resetDrawing(t,r){this.snapshot.drawings=t,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(t){this.snapshot.id=t}updateDocumentRenderConfig(t){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=t:r.renderConfig={...r.renderConfig,...t}}updateDocumentStyle(t){this.snapshot.documentStyle==null?this.snapshot.documentStyle=t:this.snapshot.documentStyle={...this.snapshot.documentStyle,...t}}updateDocumentDataMargin(t){const{t:r,l:s,b:i,r:o}=t,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(t,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){t=t!=null?t:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:t,height:r};return}t!==void 0&&(s.pageSize.width=t),r!==void 0&&(s.pageSize.height=r)}updateDrawing(t,r){const{drawings:s}=this,{width:i,height:o,left:a,top:l}=r,d=s==null?void 0:s[t];if(!d)return;const h=d.docTransform;h.size.width=i,h.size.height=o,h.positionH.posOffset=a,h.positionV.posOffset=l}setZoomRatio(t=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:t}:this.snapshot.settings.zoomRatio=1}}class Pt extends Lc{constructor(t){var s;super(k.isEmptyObject(t)?Oc():t);g(this,"_unitId");g(this,"headerModelMap",new Map);g(this,"footerModelMap",new Map);const r=6;this._unitId=(s=this.snapshot.id)!=null?s:k.generateRandomId(r),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(t=>{t.dispose()}),this.footerModelMap.forEach(t=>{t.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var t;return(t=this.snapshot.body)==null?void 0:t.customRanges}getCustomDecorations(){var t;return(t=this.snapshot.body)==null?void 0:t.customDecorations}getRev(){var t;return(t=this.snapshot.rev)!=null?t:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(t){if(t.id&&t.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Gr,...t},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(t){if(t!=null){if(this.headerModelMap.has(t))return this.headerModelMap.get(t);if(this.footerModelMap.has(t))return this.footerModelMap.get(t)}return this}getUnitId(){return this._unitId}apply(t){if(!Lt.isNoop(t))return this.snapshot=Lt.apply(this.snapshot,t),t!=null&&t.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(t,r,s=yr.copy){const i=this.getBody();if(i!=null)return an(i,t,r,!1,s)}_initializeHeaderFooterModel(){const{headers:t,footers:r}=this.getSnapshot();if(t)for(const s in t){const i=t[s];this.headerModelMap.set(s,new Pt(i))}if(r)for(const s in r){const i=r[s];this.footerModelMap.set(s,new Pt(i))}}updateDocumentId(t){super.updateDocumentId(t),this._unitId=t}}const ko=xe("univer.config-service");class Fo{constructor(){g(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,t){this._config.set(n,t)}deleteConfig(n){this._config.delete(n)}}class Ho extends Te{constructor(){super(...arguments);g(this,"_error$",new W.Subject);g(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(t){this._error$.next({errorKey:t})}}class $o{constructor(n={}){g(this,"_styles");g(this,"_cacheMap",new Ii(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,t){if(this._cacheMap.has(t))return this._cacheMap.get(t);const r=this._getExistingStyleId(n);return r||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,t){const r=k.generateRandomId(6);return this._styles[r]=n,this._cacheMap.set(t,r),r}setValue(n){if(n==null)return;const t=JSON.stringify(n),r=this.search(n,t);return r!=="-1"?r:this.add(n,t)}toJSON(){return this._styles}getStyleByCell(n){let t;n&&k.isObject(n.s)?t=n.s:t=(n==null?void 0:n.s)&&this.get(n.s);const r=n==null?void 0:n.interceptorStyle;return r?{...t,...r}:t}_generateCacheMap(){const{_styles:n,_cacheMap:t}=this;for(const r in n){const s=JSON.stringify(n[r]);t.set(s,r)}}_getExistingStyleId(n){const{_styles:t}=this;for(const r in t)if(k.diffValue(t[r],n))return r;return null}}class Pc{constructor(n,t){g(this,"_columnData",{});this._config=n,this._columnData=t}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:t}=this,r=t[n];return r?r.hd!==z.TRUE:!0}getHiddenCols(n=0,t=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=n;o<=t;o++){const a=this.getColVisible(o);s&&a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:oe.COLUMN}),r}getVisibleCols(n=0,t=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=n;o<=t;o++){const a=this.getColVisible(o);s&&!a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:oe.COLUMN}),r}getColumnDatas(n,t){const r={};let s=0;for(let i=n;i<n+t;i++){const o=this.getColumnOrCreate(i);r[s]=o,s++}return r}getSize(){return It(this._columnData)}getColumnWidth(n){const{_columnData:t}=this,r=this._config;let s=0;return s=(t[n]||{hd:z.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(n){const t=this._columnData[n];if(t)return t}getColumnOrCreate(n){const{_columnData:t}=this,r=this._config,s=t[n];if(s)return s;const i={w:r.defaultColumnWidth,hd:z.FALSE};return this._columnData[n]=i,i}}class kc{constructor(n,t,r){g(this,"_rowData");this._config=n,this._viewModel=t,this._rowData=r}getRowData(){return this._rowData}getRowDatas(n,t){const r={};let s=0;for(let i=n;i<n+t;i++){const o=this.getRowOrCreate(i);r[s]=o,s++}return r}getRowHeight(n,t=1){const{_rowData:r}=this,s=this._config;let i=0;for(let o=0;o<t;o++){const a=r[o+n]||{hd:z.FALSE,h:s.defaultRowHeight},{ia:l,ah:d,h=s.defaultRowHeight}=a;i+=(l==null||l===z.TRUE)&&typeof d=="number"?d:h}return i}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:t}=this,r=t[n];if(r)return r;const s=this._config,i={hd:z.FALSE,h:s.defaultRowHeight};return t[n]=i,i}getHiddenRows(n=0,t=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=n;o<=t;o++){const a=this.getRowRawVisible(o);s&&a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&!a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getVisibleRows(n=0,t=this.getSize()-1){const r=[];let s=!1,i=-1;for(let o=n;o<=t;o++){const a=this.getRowRawVisible(o);s&&!a?(s=!1,r.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&a&&(s=!0,i=o)}return s&&r.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getRowRawVisible(n){const t=this.getRow(n);return t?t.hd!==z.TRUE:!0}getSize(){return It(this._rowData)}}const Fc="DEFAULT_WORKSHEET_ROW_COUNT",Wo=1e3,Hc="DEFAULT_WORKSHEET_COLUMN_COUNT",Bo=20,$c="DEFAULT_WORKSHEET_ROW_HEIGHT",jo=24,Wc="DEFAULT_WORKSHEET_COLUMN_WIDTH",Go=88,Bc="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Vo=46,jc="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",xo=20;function Ko(e){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:z.FALSE,rowCount:Wo,columnCount:Bo,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Go,defaultRowHeight:jo,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:z.TRUE,rowHeader:{width:Vo,hidden:z.FALSE},columnHeader:{height:xo,hidden:z.FALSE},selections:["A1"],rightToLeft:z.FALSE};return Object.keys(n).forEach(t=>{const r=t;typeof e[r]>"u"&&(e[r]=n[r])}),e}class zo extends Te{constructor(t){super();g(this,"_cellContentInterceptor",null);g(this,"_rowFilteredInterceptor",null);this.getRawCell=t}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(t,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(t,r):this.getRawCell(t,r)}getRowFiltered(t){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(t))!=null?s:!1}registerCellContentInterceptor(t){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=t,Se(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(t){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=t,Se(()=>this._rowFilteredInterceptor=null)}}class ln{constructor(n,t,r){g(this,"_sheetId");g(this,"_snapshot");g(this,"_cellData");g(this,"_rowManager");g(this,"_columnManager");g(this,"_viewModel");var a;this.unitId=n,this._styles=r,this._snapshot=Ko(t);const{columnData:s,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:k.generateRandomId(6),this._cellData=new nt(o),this._viewModel=new zo((l,d)=>this.getCellRaw(l,d)),this._rowManager=new kc(this._snapshot,this._viewModel,i),this._columnManager=new Pc(this._snapshot,s)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),t=this.getMergeData();let r=-1,s=-1,i=-1,o=-1,a=!1,l=!1;return n.forEach((d,h)=>{Object.keys(h).forEach(c=>{const f=+c,_=n.getValue(d,f),E=_!=null&&_.s?this._styles.get(_.s):null,p=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(_&&(_.v||_.p)||E!=null&&E.bg||p)&&(a?r=Math.min(r,d):(r=d,a=!0),s=Math.max(s,d),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),t.forEach(d=>{a?r=Math.min(r,d.startRow):(r=d.startRow,a=!0),s=Math.max(s,d.endRow),l?i=Math.min(i,d.startColumn):(i=d.startColumn,a=!0),o=Math.max(o,d.endColumn)}),!a||!l?null:{startColumn:i,startRow:r,endColumn:o,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,t=k.deepClone(n);return new ln(this.unitId,t,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,t){const r=this._snapshot.mergeData;for(let s=0;s<r.length;s++){const i=r[s];if(vt.intersects({startRow:n,startColumn:t,endRow:n,endColumn:t},i))return i}return null}getCell(n,t){return n<0||t<0?null:this._viewModel.getCell(n,t)}getCellRaw(n,t){return this.getCellMatrix().getValue(n,t)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,t,r,s,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(d=>vt.intersects({startRow:n,startColumn:t,endRow:r,endColumn:s},d)),l=new nt;return ur(n,r,t,s).forEach((d,h)=>{const c=i?this.getCellRaw(d,h):this.getCell(d,h);c&&l.setValue(d,h,c)}),a.forEach(d=>{const{startColumn:h,startRow:c,endColumn:f,endRow:_}=d;ur(c,_,h,f).forEach((E,p)=>{E===c&&p===h&&l.setValue(E,p,{...o.getValue(E,p),rowSpan:_-c+1,colSpan:f-h+1}),(E!==c||p!==h)&&l.realDeleteValue(E,p)})}),l}getRange(n,t,r,s){return typeof n=="object"?new Gt(this,n,{getStyles:()=>this._styles}):new Gt(this,{startRow:n,startColumn:t,endColumn:s||t,endRow:r||n},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:n}=this,{columnCount:t}=n;return t}getMaxRows(){const{_snapshot:n}=this,{rowCount:t}=n;return t}getRowCount(){return this._snapshot.rowCount}setRowCount(n){this._snapshot.rowCount=n}getColumnCount(){return this._snapshot.columnCount}setColumnCount(n){this._snapshot.columnCount=n}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:n}=this,{showGridlines:t}=n;return t===0}getTabColor(){const{_snapshot:n}=this,{tabColor:t}=n;return t}getColumnWidth(n){return this.getColumnManager().getColumnWidth(n)}getRowHeight(n){return this._viewModel.getRowFiltered(n)?0:this.getRowManager().getRowHeight(n)}getRowVisible(n){return this._viewModel.getRowFiltered(n)?!1:this.getRowRawVisible(n)}getRowRawVisible(n){return this.getRowManager().getRowRawVisible(n)}getHiddenRows(n,t){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(n,t);return s.forEach(i=>i.endColumn=r),s}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,t){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(n,t);return s.forEach(i=>i.endRow=r),s}getVisibleRows(){const n=this.getRowCount();return this._rowManager.getVisibleRows(0,n-1)}getVisibleCols(){const n=this.getColumnCount();return this._columnManager.getVisibleCols(0,n-1)}isRightToLeft(){const{_snapshot:n}=this,{rightToLeft:t}=n;return t}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(n){return n&&(n.v!==void 0||n.f!==void 0||n.p!==void 0)}iterateByRow(n,t=!0){const{startRow:r,startColumn:s,endRow:i,endColumn:o}=n,a=this;return{[Symbol.iterator]:()=>{let l=r,d=s;return{next(){for(;;){if(d>o&&(l+=1,d=s),l>i)return{done:!0,value:void 0};const h=a.getCell(l,d),c=!h,f=a.getMergedCell(l,d);if(f){if(l!==f.startRow||d!==f.startColumn){d=f.endColumn+1;continue}if(c&&t){d=f.endColumn+1;continue}const E={row:l,col:d,value:h};return E.colSpan=f.endColumn-f.startColumn+1,E.rowSpan=f.endRow-f.startRow+1,d=f.endColumn+1,{done:!1,value:E}}if(c&&t)d+=1;else{const _={row:l,col:d,value:h};return d+=1,{done:!1,value:_}}}}}}}}iterateByColumn(n,t=!0,r=!0){const{startRow:s,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let d=s,h=i;return{next(){for(;;){if(d>o&&(h+=1,d=s),h>a)return{done:!0,value:void 0};const c=l.getMergedCell(d,h);if(c){const E=d!==c.startRow,p=E||h!==c.startColumn;if(r&&p||!r&&E){d=c.endRow+1;continue}const N=l.getCell(c.startRow,c.startColumn);if(!N&&t){d=c.endRow+1;continue}const te={row:d,col:c.startColumn,value:N};return te.colSpan=c.endColumn-c.startColumn+1,te.rowSpan=c.endRow-c.startRow+1,d=c.endRow+1,{done:!1,value:te}}const f=l.getCell(d,h);if(!f&&t)d+=1;else{const E={row:d,col:h,value:f};return d+=1,{done:!1,value:E}}}}}}}}}function Gc(e){var r,s;if(!e)return"";const n=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(n)return n;const t=e.v;return typeof t=="string"?e.t===Tt.BOOLEAN?t.toUpperCase():t.replace(/[\r\n]/g,""):typeof t=="number"?e.t===Tt.BOOLEAN?t?"TRUE":"FALSE":t.toString():typeof t=="boolean"?t?"TRUE":"FALSE":""}const Vc="0.2.5";function xc(e="",n=bt.ZH_CN,t=""){return{id:e,sheetOrder:[],name:t,appVersion:Vc,locale:n,styles:{},sheets:{},resources:[]}}var Kc=Object.defineProperty,zc=Object.getOwnPropertyDescriptor,Yc=(e,n,t,r)=>{for(var s=r>1?void 0:r?zc(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&Kc(n,t,s),s},Xc=(e,n)=>(t,r)=>n(t,r,e);function Qc(e,n){return`${e.getUnitId()}|${n.getSheetId()}`}u.Workbook=class extends Hn{constructor(t={},r){super();g(this,"type",J.UNIVER_SHEET);g(this,"_sheetCreated$",new W.Subject);g(this,"sheetCreated$",this._sheetCreated$.asObservable());g(this,"_sheetDisposed$",new W.Subject);g(this,"sheetDisposed$",this._sheetDisposed$.asObservable());g(this,"_activeSheet$",new W.BehaviorSubject(null));g(this,"activeSheet$",this._activeSheet$.asObservable());g(this,"_worksheets");g(this,"_styles");g(this,"_snapshot");g(this,"_unitId");g(this,"_count");g(this,"_name$");g(this,"name$");this._logService=r;const s=xc();k.isEmptyObject(t)?this._snapshot=s:this._snapshot=k.commonExtend(s,t);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=k.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new $o(i),this._count=1,this._worksheets=new Map,this._name$=new W.BehaviorSubject(t.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return k.deepClone(this._snapshot)}static isIRangeType(t){return typeof t=="string"||"startRow"in t||"row"in t}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(t){this._name$.next(t),this._snapshot.name=t}getUnitId(){return this._unitId}getRev(){var t;return(t=this._snapshot.rev)!=null?t:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(t,r,s){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[t])return!1;i[t]=s,o.splice(r,0,t);const a=new ln(this._unitId,s,this._styles);return this._worksheets.set(t,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===t)}getActiveSheet(t){if(!this._activeSheet&&typeof t>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const t=this._activeSheet;if(t)return t;const r=this._snapshot.sheetOrder;for(let i=0,o=r.length;i<o;i++){const a=this._worksheets.get(r[i]);if(a&&a.isSheetHidden()!==z.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(t){this._activeSheet$.next(t)}removeSheet(t){const r=this._worksheets.get(t);return r?(this._worksheets.delete(t),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(t),1),delete this._snapshot.sheets[t],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:t}=this._snapshot;return t.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:t}=this._snapshot;return t.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:t}=this._snapshot,r=[];return t.forEach(s=>{const i=this._worksheets.get(s);i&&r.push(i.getName())}),r}getSheetIndex(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>t.getSheetId()===s)}getSheetBySheetName(t){const{sheetOrder:r}=this._snapshot,s=r.find(i=>this._worksheets.get(i).getName()===t);return this._worksheets.get(s)}getSheetBySheetId(t){return this._worksheets.get(t)}getSheetByIndex(t){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[t])}getHiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden===z.TRUE).map(t=>t.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden!==z.TRUE).map(t=>t.getConfig().id)}load(t){this._snapshot=t}checkSheetName(t){return this.getSheetsName().includes(t)}uniqueSheetName(t="Sheet1"){let r=t;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}generateNewSheetName(t){let r=t+this._count;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:t,_worksheets:r}=this,{sheets:s,sheetOrder:i}=t;if(k.isEmptyObject(s)){const o=k.generateRandomId();s[o]={id:o}}for(const o in s){const a=s[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const d=new ln(this._unitId,a,this._styles);r.set(o,d),i.includes(o)||i.push(o)}this.ensureActiveSheet()}},u.Workbook=Yc([Xc(1,Ot)],u.Workbook);class Vr extends Hn{constructor(t){var r;super();g(this,"type",J.UNIVER_SLIDE);g(this,"_snapshot");g(this,"_unitId");this._snapshot={...Si,...t},this._unitId=(r=this._snapshot.id)!=null?r:k.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var t;return(t=this._snapshot.body)==null?void 0:t.pages}getPageOrder(){var t;return(t=this._snapshot.body)==null?void 0:t.pageOrder}getPage(t){const r=this.getPages();return r==null?void 0:r[t]}getElementsByPage(t){var r;return(r=this.getPage(t))==null?void 0:r.pageElements}getElement(t,r){var s;return(s=this.getElementsByPage(t))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:tr.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const un="FOCUSING_SHEET",Bn="FOCUSING_DOC",jn="FOCUSING_SLIDE",qc="FOCUSING_EDITOR_BUT_HIDDEN",Yo="EDITOR_ACTIVATED",Zc="FOCUSING_EDITOR_INPUT_FORMULA",Xo="FOCUSING_FORMULA_EDITOR",Jc="FOCUSING_UNIVER_EDITOR",eh="FOCUSING_EDITOR_INPUT_FORMULA",th="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",nh="FOCUSING_COMMON_DRAWINGS";var rh=Object.defineProperty,sh=Object.getOwnPropertyDescriptor,ih=(e,n,t,r)=>{for(var s=r>1?void 0:r?sh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&rh(n,t,s),s},Qo=(e,n)=>(t,r)=>n(t,r,e);const xt=xe("univer.current");u.UniverInstanceService=class extends Te{constructor(t,r){super();g(this,"_unitsByType",new Map);g(this,"_createHandler");g(this,"_ctorByType",new Map);g(this,"_currentUnits",new Map);g(this,"_currentUnits$",new W.BehaviorSubject(this._currentUnits));g(this,"currentUnits$",this._currentUnits$.asObservable());g(this,"_unitAdded$",new W.Subject);g(this,"unitAdded$",this._unitAdded$.asObservable());g(this,"_unitDisposed$",new W.Subject);g(this,"unitDisposed$",this._unitDisposed$.asObservable());g(this,"_focused$",new W.BehaviorSubject(null));g(this,"focused$",this._focused$.asObservable());this._injector=t,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(t){this._createHandler=t}createUnit(t,r){return this._createHandler(t,r,this._ctorByType.get(t))}registerCtorForType(t,r){return this._ctorByType.set(t,r),{dispose:()=>{this._ctorByType.delete(t)}}}getCurrentTypeOfUnit$(t){return this.currentUnits$.pipe(W.map(r=>{var s;return(s=r.get(t))!=null?s:null}),W.distinctUntilChanged())}getCurrentUnitForType(t){return this._currentUnits.get(t)}setCurrentUnitForType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${t}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(t){this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(t){return this._unitAdded$.pipe(W.filter(r=>r.type===t))}__addUnit(t){const r=t.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]),this._unitsByType.get(r).push(t),this._unitAdded$.next(t),this.setCurrentUnitForType(t.getUnitId())}getTypeOfUnitDisposed$(t){return this.unitDisposed$.pipe(W.filter(r=>r.type===t))}getUnit(t,r){var i;const s=(i=this._getUnitById(t))==null?void 0:i[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(J.UNIVER_DOC)}getUniverDocInstance(t){return this.getUnit(t,J.UNIVER_DOC)}getUniverSheetInstance(t){return this.getUnit(t,J.UNIVER_SHEET)}getAllUnitsForType(t){var r;return(r=this._unitsByType.get(t))!=null?r:[]}changeDoc(t,r){const s=this.getAllUnitsForType(J.UNIVER_DOC),i=s.find(o=>o.getUnitId()===t);if(i!=null){const o=s.indexOf(i);s.splice(o,1)}this.__addUnit(r)}get focused(){var r;const t=this._focused$.getValue();return t?(r=this._getUnitById(t))==null?void 0:r[0]:null}focusUnit(t){this._focused$.next(t),this.focused instanceof u.Workbook?(this._contextService.setContextValue(Bn,!1),this._contextService.setContextValue(un,!0),this._contextService.setContextValue(jn,!1)):this.focused instanceof Pt?(this._contextService.setContextValue(Bn,!0),this._contextService.setContextValue(un,!1),this._contextService.setContextValue(jn,!1)):this.focused instanceof Vr&&(this._contextService.setContextValue(Bn,!1),this._contextService.setContextValue(un,!1),this._contextService.setContextValue(jn,!0))}getFocusedUnit(){return this.focused}getUnitType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: No document with unitId ${t}`);return r[1]}disposeUnit(t){const r=this._getUnitById(t);if(!r)return!1;const[s,i]=r,o=this._unitsByType.get(i),a=o.indexOf(s);return o.splice(a,1),this._removeCurrentUnitForType(i),this._focused$.next(null),this._unitDisposed$.next(s),!0}_getUnitById(t){for(const[r,s]of this._unitsByType){const i=s.find(o=>o.getUnitId()===t);if(i)return[i,r]}}},u.UniverInstanceService=ih([Qo(0,rt(dt)),Qo(1,rn)],u.UniverInstanceService);var de=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(de||{});const oh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},Gn=new Map;function qo(e,n){return function(s){Vn(e,n)}}function Vn(e,n){Gn.has(e)||Gn.set(e,[]),Gn.get(e).push(n)}var ah=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,Zo=(e,n,t,r)=>{for(var s=r>1?void 0:r?lh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&ah(n,t,s),s},Jo=(e,n)=>(t,r)=>n(t,r,e);u.LifecycleService=class extends Te{constructor(t){super();g(this,"_lifecycle$",new W.BehaviorSubject(de.Starting));g(this,"lifecycle$",this._lifecycle$.asObservable());g(this,"_lock",!1);this._logService=t,this._reportProgress(de.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(t){if(t<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(t!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(t),this._lifecycle$.next(t),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return W.merge(ea(this.stage),this._lifecycle$.pipe(W.skip(1))).pipe(ao(t=>t===de.Steady))}_reportProgress(t){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${oh[t]}".`)}},u.LifecycleService=Zo([Jo(0,Ot)],u.LifecycleService),u.LifecycleInitializerService=class extends Te{constructor(t){super();g(this,"_seenTokens",new Set);this._injector=t}initModulesOnStage(t){var r;(r=Gn.get(t))==null||r.forEach(s=>{this._injector.has(s)&&!this._seenTokens.has(s)&&(this._injector.get(s),this._seenTokens.add(s))})}},u.LifecycleInitializerService=Zo([Jo(0,rt(dt))],u.LifecycleInitializerService);function ea(e){switch(e){case de.Starting:return W.of(de.Starting);case de.Ready:return W.of(de.Starting,de.Ready);case de.Rendered:return W.of(de.Starting,de.Ready,de.Rendered);default:return W.of(de.Starting,de.Ready,de.Rendered,de.Steady)}}class cn extends Te{constructor(){super();g(this,"_currentLocale$",new W.BehaviorSubject(bt.ZH_CN));g(this,"currentLocale$",this._currentLocale$.asObservable());g(this,"_locales",null);g(this,"localeChanged$",new W.Subject);g(this,"t",(t,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=t.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof i=="string"){let o=i;return r.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return t});this.disposeWithMe(Se(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(t){var r;this._locales=k.deepMerge((r=this._locales)!=null?r:{},t)}setLocale(t){this._currentLocale$.next(t),this.localeChanged$.next()}getLocales(){var t;return(t=this._locales)==null?void 0:t[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(t,r){const s=r.shift();if(s&&t&&s in t){const i=t[s];return r.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,r):i}return null}}var xr=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(xr||{});const Kr=xe("univer.permission-service");Vn(de.Starting,Kr);class ta extends Te{constructor(){super(...arguments);g(this,"_permissionPointMap",new Map);g(this,"_permissionPointUpdate$",new W.Subject);g(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(t){const r=this._permissionPointMap.get(t);r&&(r.complete(),this._permissionPointMap.delete(t))}addPermissionPoint(t){const r=t instanceof W.BehaviorSubject,s=r?t.getValue():t;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?t:new W.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(t,r){const s=this._permissionPointMap.get(t);if(!s)return;const i=s.getValue();i.value=r,i.status=xr.DONE,s.next({...i}),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(t){const r=this._permissionPointMap.get(t);if(r)return r.getValue()}getPermissionPoint$(t){const r=this._permissionPointMap.get(t);if(r)return r}composePermission$(t){const r=t.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.asObservable()});return W.combineLatest(r).pipe(ht.map(s=>s))}composePermission(t){return t.map(s=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(s);if(!i)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const t=new Map;return this._permissionPointMap.forEach((r,s)=>{t.set(s,r)}),t}}class na extends Te{constructor(){super(...arguments);g(this,"_resourceMap",new Map);g(this,"_register$",new W.Subject);g(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(t){return this.getAllResourceHooks().map(i=>{const o=i.toJson(t);return{name:i.pluginName,data:o}})}getResourcesByType(t,r){return this.getAllResourceHooks().filter(o=>o.businesses.includes(r)).map(o=>{const a=o.toJson(t);return{name:o.pluginName,data:a}})}registerPluginResource(t){const r=t.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,t),this._register$.next(t),Se(()=>this._resourceMap.delete(r))}disposePluginResource(t){this._resourceMap.delete(t)}loadResources(t,r){this.getAllResourceHooks().forEach(s=>{var o;const i=(o=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:o.data;if(i)try{const a=s.parseJson(i);s.onLoad(t,a)}catch{console.error("LoadResources Error!")}})}unloadResources(t){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(t)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const xn=xe("resource-manager-service");var uh=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,hh=(e,n,t,r)=>{for(var s=r>1?void 0:r?ch(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&uh(n,t,s),s},ra=(e,n)=>(t,r)=>n(t,r,e);let zr=class extends Te{constructor(n,t){super();g(this,"saveWorkbook",n=>{const t=n.getUnitId(),r=this._resourceManagerService.getResources(t)||[],s=n.getSnapshot();return s.resources=r,s});this._resourceManagerService=n,this._univerInstanceService=t,this._init()}_init(){const n=r=>{r.businesses.forEach(s=>{switch(s){case J.UNRECOGNIZED:case J.UNIVER_UNKNOWN:case J.UNIVER_SLIDE:case J.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(J.UNIVER_DOC).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(i.getUnitId(),l)}catch{console.error(`Load Document{${i.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}});break}case J.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(J.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(r=>{n(r)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(r=>{n(r)})),this.disposeWithMe(Se(this._univerInstanceService.getTypeOfUnitAdded$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.loadResources(r.getUnitId(),r.getSnapshot().resources)}))),this.disposeWithMe(Se(this._univerInstanceService.getTypeOfUnitDisposed$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.unloadResources(r.getUnitId())})))}saveDoc(n){const t=n.getUnitId(),r=this._resourceManagerService.getResourcesByType(t,J.UNIVER_DOC)||[],s=n.getSnapshot();return s.resources=r,s}};zr=hh([ra(0,rt(xn)),ra(1,rt(xt))],zr);const Yr=xe("resource-loader-service");Vn(de.Ready,Yr);class Xr extends Te{constructor(){super();g(this,"_currentTheme");g(this,"_currentTheme$",new W.BehaviorSubject({}));g(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Se(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(t){this._currentTheme=t,this._currentTheme$.next(t)}}const Kn="__INTERNAL_EDITOR__",sa=`${Kn}DOCS_NORMAL`,ia=`${Kn}DOCS_FORMULA_BAR`,dh="__defaultDocumentZenEditorSpecialUnitId_20231218__",fh=`\r
9
+ `;function _h(e){return`${Kn}${e}`}function gh(e){return e.startsWith(Kn)}var mh=Object.defineProperty,Eh=Object.getOwnPropertyDescriptor,ph=(e,n,t,r)=>{for(var s=r>1?void 0:r?Eh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&mh(n,t,s),s},Qr=(e,n)=>(t,r)=>n(t,r,e);const zn=xe("univer.undo-redo.service"),Rh=20;class oa{dispose(){}async dispatchToHandlers(){return!1}}const aa="univer.command.redo",la="univer.command.undo",ua=new class extends oa{constructor(){super(...arguments);g(this,"type",sn.COMMAND);g(this,"id",la)}async handler(n){const t=n.get(zn),r=t.pitchTopUndoElement();if(!r)return!1;const s=n.get(on);return Nr(r.undoMutations,s)?(t.popUndoToRedo(),!0):!1}},ca=new class extends oa{constructor(){super(...arguments);g(this,"type",sn.COMMAND);g(this,"id",aa)}async handler(n){const t=n.get(zn),r=t.pitchTopRedoElement();if(!r)return!1;const s=n.get(on);return Nr(r.redoMutations,s)?(t.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends Te{constructor(t,r,s){super();g(this,"undoRedoStatus$");g(this,"_undoRedoStatus$",new W.BehaviorSubject({undos:0,redos:0}));g(this,"_undoStacks",new Map);g(this,"_redoStacks",new Map);g(this,"_batchingStatus",new Map);this._univerInstanceService=t,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ua)),this.disposeWithMe(this._commandService.registerCommand(ca)),this.disposeWithMe(Se(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Se(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(t){const{unitID:r}=t,s=this._getRedoStack(r,!0),i=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(t.unitID)){const a=this._batchingStatus.get(t.unitID),l=this._pitchUndoElement(t.unitID);a===0||!l?(o(t),this._batchingStatus.set(t.unitID,1)):this._tryBatchingElements(l,t)}else o(t);function o(a){i.push(a),i.length>Rh&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(t){const r=this._getRedoStack(t);r&&(r.length=0);const s=this._getUndoStack(t);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const t=this._getFocusedUnitId();return this._pitchUndoElement(t)}pitchTopRedoElement(){const t=this._getFocusedUnitId();return this._pitchRedoElement(t)}_pitchUndoElement(t){const r=this._getUndoStack(t);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(t){const r=this._getRedoStack(t);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}__tempBatchingUndoRedo(t){if(this._batchingStatus.has(t))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(t,0),Se(()=>this._batchingStatus.delete(t))}_updateStatus(){var i,o;const t=this._getFocusedUnitId(),r=t&&((i=this._undoStacks.get(t))==null?void 0:i.length)||0,s=t&&((o=this._redoStacks.get(t))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(t,r=!1){let s=this._undoStacks.get(t);return!s&&r&&(s=[],this._undoStacks.set(t,s)),s||null}_getRedoStack(t,r=!1){let s=this._redoStacks.get(t);return!s&&r&&(s=[],this._redoStacks.set(t,s)),s||null}_getUndoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getUndoStack(t,!0)}_getRedoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getRedoStack(t,!0)}_tryBatchingElements(t,r){t.redoMutations.push(...r.redoMutations),t.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var o,a,l,d;let t="";const r=this._contextService.getContextValue(un),s=this._contextService.getContextValue(Xo),i=this._contextService.getContextValue(Yo);return r?s?t=ia:i?t=sa:t=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":t=(d=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?d:"",t}},u.LocalUndoRedoService=ph([Qr(0,xt),Qr(1,on),Qr(2,rn)],u.LocalUndoRedoService);const ha=Symbol("DependentOn");class qr extends Te{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}g(qr,"pluginName"),g(qr,"type",J.UNIVER_UNKNOWN);class Ch{constructor(){g(this,"_plugins",[])}addPlugin(n){this._plugins.push(n)}removePlugins(){const n=this._plugins.slice();return this._plugins.length=0,n}forEachPlugin(n){this._plugins.forEach(n)}}class Ih{constructor(){g(this,"_pluginsRegistered",[])}registerPlugin(n,t){this._pluginsRegistered.push({plugin:n,options:t})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var vh=Object.defineProperty,Oh=Object.getOwnPropertyDescriptor,da=(e,n,t,r)=>{for(var s=r>1?void 0:r?Oh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&vh(n,t,s),s},hn=(e,n)=>(t,r)=>n(t,r,e);const Sh=4;function Nh(...e){return function(n){n[ha]=e}}u.PluginService=class{constructor(n){g(this,"_pluginHolderForUniver");g(this,"_pluginHoldersForTypes",new Map);g(this,"_seenPlugins",new Set);g(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(Yn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const n of this._pluginHoldersForTypes.values())n.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(n,t){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:r}=n;r===J.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,t),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(r).register(n,t)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const t=this._injector.createInstance(Yn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,t),t}return this._pluginHoldersForTypes.get(n)}_immediateInitPlugin(n){this._seenPlugins.add(n.pluginName),this._ensurePluginHolderForType(n.type).immediateInitPlugin(n)}_checkPluginSeen(n){return this._seenPlugins.has(n.pluginName)}_assertPluginValid(n){const{type:t,pluginName:r}=n;if(t===J.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(r==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Sh))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,t]of this._pluginHoldersForTypes)t.started&&t.flush()}},u.PluginService=da([hn(0,rt(dt))],u.PluginService);let Yn=class extends Te{constructor(n,t,r,s,i,o){super();g(this,"_started",!1);g(this,"_pluginRegistry",new Ih);g(this,"_pluginStore",new Ch);g(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=t,this._logService=r,this._injector=s,this._lifecycleService=i,this._lifecycleInitializerService=o,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(W.skip(1)).subscribe(a=>{this._awaitingPlugins.forEach(l=>this._runStage(l,a))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(n=>n.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._awaitingPlugins.length=0}register(n,t){this._pluginRegistry.registerPlugin(n,t)}immediateInitPlugin(n){const t=this._initPlugin(n,void 0);this._pluginsRunLifecycle([t])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:t,options:r})=>this._initPlugin(t,r));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,t){const r=n[ha];if(r){const i=()=>{const o=r.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const s=this._injector.createInstance(n,t);return this._pluginStore.addPlugin(s),s}_pluginsRunLifecycle(n){ea(this._lifecycleService.stage).subscribe(t=>this._runStage(n,t)),this._awaitingPlugins.push(n)}_runStage(n,t){n.forEach(r=>{switch(t){case de.Starting:r.onStarting(this._injector);break;case de.Ready:r.onReady();break;case de.Rendered:r.onRendered();break;case de.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(t)}};Yn=da([hn(2,Ot),hn(3,rt(dt)),hn(4,rt(u.LifecycleService)),hn(5,rt(u.LifecycleInitializerService))],Yn);function fa(e,n){if(!n)return e;const t=[];for(const r of e){const s=n.find(([i])=>i===r[0]);if(s){if(s[1]===null)continue;t.push([r[0],s[1]])}else t.push(r)}return t}const Zr={[Be.Editor]:"Editor",[Be.Owner]:"Owner",[Be.Reader]:"Reader",[Be.UNRECOGNIZED]:"UNRECOGNIZED"},Xn=e=>e?{userID:`${Zr[e]}_${k.generateRandomId(8)}`,name:Zr[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Jr=(e,n)=>e.startsWith(Zr[n]);var wh=Object.defineProperty,bh=Object.getOwnPropertyDescriptor,Ah=(e,n,t,r)=>{for(var s=r>1?void 0:r?bh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&wh(n,t,s),s};u.UserManagerService=class{constructor(){g(this,"_model",new Map);g(this,"_userChange$",new W.Subject);g(this,"userChange$",this._userChange$.asObservable());g(this,"_currentUser$",new W.BehaviorSubject(Xn()));g(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,t){const r=this._model.get(n);if(r)return r;t&&t()}delete(n){const t=this.getUser(n);this._model.delete(n),t&&this._userChange$.next({type:"delete",user:t})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}},u.UserManagerService=Ah([qo(de.Starting,u.UserManagerService)],u.UserManagerService);var Th=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,Dh=(e,n,t,r)=>{for(var s=r>1?void 0:r?yh(n,t):n,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(n,t,s):o(s))||s);return r&&s&&Th(n,t,s),s},_a=(e,n)=>(t,r)=>n(t,r,e);u.AuthzIoLocalService=class{constructor(n,t){g(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=t,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(Xn(Be.Owner))}_getRole(n){const t=this._userManagerService.getCurrentUser();return t?Jr(t.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const t=[...this._permissionMap.keys()].reduce((r,s)=>{const i=this._permissionMap.get(s);return r[s]=i,r},{});return JSON.stringify(t)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[J.UNIVER_SHEET,J.UNIVER_DOC,J.UNIVER_SLIDE],onLoad:(n,t)=>{for(const r in t)this._permissionMap.set(r,t[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const t=k.generateRandomId(8);switch(n.objectType){case Fn.SelectRange:{const r=n.selectRangeObject;this._permissionMap.set(t,{...r,objectType:n.objectType});break}case Fn.Worksheet:{const r=n.worksheetObject;this._permissionMap.set(t,{...r,objectType:n.objectType,readScope:uo.SomeCollaborator})}}return t}async allowed(n){var t;if(this._permissionMap.has(n.objectID)){const r=this._permissionMap.get(n.objectID);if(r&&r.objectType===Fn.Worksheet)return(t=r==null?void 0:r.strategies)==null?void 0:t.map(s=>({action:s.action,allowed:s.role===Be.Editor}))}return n.actions.map(r=>({action:r,allowed:this._getRole(Be.Owner)||this._getRole(Be.Editor)}))}async batchAllowed(n){const t=this._userManagerService.getCurrentUser(),r=n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(i=>({action:i,allowed:!1}))}));return t&&(Jr(t.userID,Be.Owner)||Jr(t.userID,Be.Editor))?n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(i=>({action:i,allowed:!0}))})):r}async list(n){const t=[];return n.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const i={objectID:r,unitID:n.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:Be.Owner,shareScope:-1,creator:Xn(Be.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole(Be.Owner)||this._getRole(Be.Editor)}))};t.push(i)}}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}},u.AuthzIoLocalService=Dh([_a(0,xn),_a(1,rt(u.UserManagerService))],u.AuthzIoLocalService);const ga=xe("IAuthzIoIoService");class Mh{constructor(n={},t){g(this,"_startedTypes",new Set);g(this,"_injector");const r=this._injector=Uh(t,n==null?void 0:n.override),{theme:s,locale:i,locales:o,logLevel:a}=n;s&&this._injector.get(Xr).setTheme(s),o&&this._injector.get(cn).load(o),i&&this._injector.get(cn).setLocale(i),a&&this._injector.get(Ot).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(xt)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(cn).setLocale(n)}createUnit(n,t){return this._univerInstanceService.createUnit(n,t)}createUniverSheet(n){return this._univerInstanceService.createUnit(J.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(J.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(J.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(J.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(J.UNIVER_DOC,Pt),this._univerInstanceService.registerCtorForType(J.UNIVER_SLIDE,Vr);const t=n.get(xt);t.__setCreateHandler((r,s,i)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginForType(r),this._startedTypes.add(r);const a=n.createInstance(i,s);return t.__addUnit(a),this._tryProgressToReady(),a}const o=n.createInstance(i,s);return t.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<de.Ready&&(this._injector.get(u.LifecycleService).stage=de.Ready)}registerPlugin(n,t){this._pluginService.registerPlugin(n,t)}}function Uh(e,n){const t=fa([[Ho],[cn],[Xr],[u.LifecycleService],[u.LifecycleInitializerService],[u.PluginService],[u.UserManagerService],[xt,{useClass:u.UniverInstanceService}],[Kr,{useClass:ta}],[Ot,{useClass:ro,lazy:!0}],[on,{useClass:u.CommandService}],[zn,{useClass:u.LocalUndoRedoService,lazy:!0}],[ko,{useClass:Fo}],[rn,{useClass:to}],[xn,{useClass:na,lazy:!0}],[Yr,{useClass:zr,lazy:!0}],[ga,{useClass:u.AuthzIoLocalService,lazy:!0}]],n);return e?e.createChild(t):new dt(t)}const Lh=(e,n)=>n.length===e.length&&!e.some(t=>n.some(r=>!vt.equals(r,t))),Ph=(e,n)=>n.length===e.length&&e.every((t,r)=>{const s=n[r];return s.unitId===t.unitId&&s.sheetId===t.sheetId&&vt.equals(t.range,s.range)});function kh(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||!e||typeof n!="object"||!n)return!1;const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;const s=Object.prototype.hasOwnProperty.bind(n);for(let i=0;i<t.length;i++){const o=t[i];if(!s(o))return!1;const a=e[o],l=n[o];if(a!==l)return!1}return!0}function ma(e){return/^-?\d+(\.\d+)?$/.test(e)}function Fh(e){return ma(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function Hh(e){return["true","false"].includes(e.toLowerCase())}function $h(e,n){return n.forEach(t=>e.add(t)),e}function Wh(e,n=16){let t=0,r=null;return function(...i){const o=Date.now();o-t<n?(r&&clearTimeout(r),r=setTimeout(()=>{t=o,e.apply(this,i)},n)):(t=o,e.apply(this,i))}}function Bh(e){const n=new MessageChannel;let t=!1;const r=()=>{t||e()};return n.port1.onmessage=r,n.port2.postMessage(null),()=>{t=!0,n.port1.close(),n.port2.close()}}var Ea=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ea||{});function jh(e,n,t){if(n==="")return e;const r={id:"mock-id",body:e,documentStyle:{}},s=new Pt(r),i=n.length;let o;for(;(o=s.getBody().dataStream.indexOf(n))>=0;){const l=new St,d=Lt.getInstance();if(o>0&&l.retain(o),t.length>0){const h=s.sliceBody(o,o+i),c={dataStream:t};Array.isArray(h==null?void 0:h.textRuns)&&h.textRuns.length&&(c.textRuns=[{...h.textRuns[0],st:0,ed:t.length}]),l.insert(t.length,c)}l.delete(i),s.apply(d.editOp(l.serialize()))}const a=s.getBody();return s.dispose(),a}class pa{constructor(){g(this,"skipNextObservers",!1);g(this,"lastReturnValue");g(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Gh extends W.Subject{constructor(){super(...arguments);g(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(t){let r;typeof t=="function"?r={next:([i,o])=>t(i,o)}:r=t;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==r)),s}clearObservers(){this._sortedObservers.forEach(t=>{var r;return(r=t.complete)==null?void 0:r.call(t)}),this._sortedObservers.length=0}emitEvent(t){var r;if(!this.closed){const s=new pa;s.lastReturnValue=t;for(const i of this._sortedObservers){const o=(r=i.next)==null?void 0:r.call(i,[t,s]);if(s.lastReturnValue=o,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function Vh(e){return new W.Observable(n=>{const t=e.subscribeEvent(r=>{n.next(r)});return()=>t.unsubscribe()})}const xh=xe("ILocalStorageService");function Kh(e){return`sheet_interceptor_${e}`}const Ra=e=>function(n,t){let r=-1;function s(i,o){if(i<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");return r=i,i===e.length?o:e[i].handler(o,t,s.bind(null,i+1))}return s(0,n)};class zh{constructor(n){g(this,"_interceptorsByName",new Map);g(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const t=n,r=this._interceptorsByName.get(t);return Ra(r||[])}intercept(n,t){const r=n;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(t),this._interceptorsByName.set(r,s.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>bn(this._interceptorsByName.get(r),t)}getInterceptPoints(){return this._interceptorPoints}}const Yh=xe("univer.snapshot-server-service");class Xh{constructor(){g(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,t){return Promise.resolve({snapshot:{unitID:"",type:J.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Ye.OK,message:""}})}getSheetBlock(n,t){const r=this._sheetBlockCache.get(t.blockID);return Promise.resolve({block:r,error:{code:Ye.OK,message:""}})}fetchMissingChangesets(n,t){return Promise.resolve({changesets:[],error:{code:Ye.OK,message:""}})}getResourcesRequest(n,t){return Promise.resolve({resources:{},error:{code:Ye.OK,message:""}})}saveSnapshot(n,t){return Promise.resolve({error:{code:Ye.OK,message:""}})}saveSheetBlock(n,t){const{block:r}=t;return r?(this._sheetBlockCache.set(r.id,r),Promise.resolve({error:{code:Ye.OK,message:""},blockID:r.id})):Promise.resolve({error:{code:Ye.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,t){return Promise.resolve({error:{code:Ye.OK,message:""},concurrent:[]})}}function Qh(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(n,t)=>String.fromCharCode(Number.parseInt(t,16))))}function es(e){return decodeURIComponent(Array.prototype.map.call(atob(e),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const dn=new TextEncoder,Qn=new TextDecoder;function Ca(e){const n=k.deepClone(e);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,dn.encode(JSON.stringify(n))}function Ia(e){const n=k.deepClone(e);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,dn.encode(JSON.stringify(n))}function qh(e){const n=k.deepClone(e);return delete n.id,delete n.rev,delete n.title,delete n.resources,dn.encode(JSON.stringify(n))}function va(e){return JSON.parse(Qn.decode(e))}function Zh(e){return JSON.parse(typeof e=="string"?es(e):Qn.decode(e))}function Jh(e){return JSON.parse(typeof e=="string"?es(e):Qn.decode(e))}const ts=256*20;function Oa(e,n){const t=new nt(e),r=t.getLength(),s=[];let i=0;for(;i<r;){const o=Math.min(i+ts,r-1),a=t.getSlice(i,Math.min(i+ts,r-1),0,n),l=ed(a);s.push({id:k.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=ts}return s}function ed(e){const n=e.getData();return dn.encode(JSON.stringify(n))}async function td(e,n,t,r,s){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([c,f])=>{const _={id:f.id,type:En.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:Ca(f)};if(o[c]=_,f.cellData){const E=Oa(f.cellData,f.rowCount),p=await Promise.all(E.map(N=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:N})));if(p.some(N=>{var D;return((D=N.error)==null?void 0:D.code)!==Ye.OK}))return!1;i[c]={sheetID:c,blocks:p.map(N=>N.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Ia(n),d={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:t,rev:d.rev,type:J.UNIVER_SHEET,workbook:d,doc:void 0}}}async function nd(e,n,t,r,s){var f,_;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([E,p])=>{const N={id:p.id,type:En.GRID,name:p.name,rowCount:p.rowCount,columnCount:p.columnCount,originalMeta:Ca(p)};if(o[E]=N,p.cellData){const D=Oa(p.cellData,p.rowCount),te=await Promise.all(D.map(me=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:me})));if(te.some(me=>{var fe;return((fe=me.error)==null?void 0:fe.code)!==Ye.OK}))return!1;i[E]={sheetID:E,blocks:te.map(me=>me.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Ia(n),d={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},h={unitID:t,rev:d.rev,type:J.UNIVER_SHEET,workbook:d,doc:void 0},c=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_SHEET,snapshot:h});if(lo(c.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
10
+ ErrorCode: ${(f=c.error)==null?void 0:f.code}:${(_=c.error)==null?void 0:_.message}`);return{snapshot:h}}function rd(e,n,t){const r=e.workbook;if(!r)throw new Error("");const s={};Object.entries(r.sheets).forEach(([l,d])=>{const h=va(d.originalMeta);s[l]={id:d.id,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,...h}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),r.blockMeta&&Object.entries(r.blockMeta).forEach(([l,d])=>{var f;const h=s[l];h.cellData={};const c=[];(f=d.blocks)==null||f.forEach(_=>{const E=i.get(_);if(E)c.push(E);else throw new Error("")}),c.forEach(_=>{const E=Zh(_.data);Object.entries(E).forEach(([p,N])=>{const D=h.cellData[+p]={};Object.entries(N).forEach(([te,me])=>{D[+te]=me})})})});const o=va(r.originalMeta);return{id:e.unitID,rev:r.rev,name:r.name,sheetOrder:r.sheetOrder,appVersion:"",locale:bt.EN_US,sheets:s,styles:{},resources:r.resources||[],...o}}function sd(e){const n=e.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:t,rev:r,name:s,originalMeta:i,resources:o=[]}=n,{body:a,documentStyle:l={},settings:d={},drawings:h={},drawingsOrder:c=[]}=Jh(i);return{id:t,rev:r,locale:bt.EN_US,title:s,body:a,documentStyle:l,settings:d,drawings:h,drawingsOrder:c,resources:o}}async function id(e,n,t,r,s){var l,d,h;const i={unitID:n.id,rev:r,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:qh(n)},o={unitID:t,rev:i.rev,type:J.UNIVER_DOC,workbook:void 0,doc:i},a=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_DOC,snapshot:o});if(lo(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
11
+ ErrorCode: ${(d=a.error)==null?void 0:d.code}:${(h=a.error)==null?void 0:h.message}`);return{snapshot:o}}async function od(e,n){const t=e.workbook;if(!t)throw new Error("Workbook metadata is not available");const r=[],s=[];return Object.entries(t.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async l=>{const d={unitID:t.unitID,type:J.UNIVER_SHEET,blockID:l},{block:h}=await n.getSheetBlock({},d);if(h)r.push(h);else throw new Error("Block not found")});s.push(...a)}),await Promise.all(s),r}var Sa=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Sa||{}),Na=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Na||{}),wa=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(wa||{}),ba=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e))(ba||{}),Aa=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Aa||{});const ad=["script","style","meta","comment","link"];function ld(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}ka(),u.ABCToNumber=ql,u.AbsoluteRefType=Oe,u.ActionIterator=jr,u.AlignTypeH=Qs,u.AlignTypeV=qs,u.ArrangeTypeEnum=ei,u.ArrowsAndMarkersShapes=Is,u.AutoFillSeries=ls,u.BaselineOffset=jt,u.BasicShapes=Cs,u.BlockType=Ds,u.BooleanNumber=z,u.BorderStyleTypes=he,u.BorderType=us,u.BulletAlignment=Rt,u.COLORS=Zn,u.CellValueType=Tt,u.ClientSnapshotServerService=Xh,u.Color=yt,u.ColorBuilder=In,u.ColorKit=tt,u.ColorType=ze,u.ColumnSeparatorType=Ps,u.CommandType=sn,u.CommonHideTypes=cs,u.ConfigService=Fo,u.ContentAlignment=xs,u.ContextService=to,u.CopyPasteType=hs,u.CustomDecorationType=ys,u.CustomRangeType=Ts,u.DEFAULT_CELL=lu,u.DEFAULT_DOC=Gr,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Ha,u.DEFAULT_EMPTY_DOCUMENT_VALUE=fh,u.DEFAULT_RANGE=ou,u.DEFAULT_RANGE_ARRAY=iu,u.DEFAULT_SELECTION=au,u.DEFAULT_SLIDE=Si,u.DEFAULT_STYLES=yn,u.DEFAULT_WORKSHEET_COLUMN_COUNT=Bo,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Hc,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=xo,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=jc,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=Go,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Wc,u.DEFAULT_WORKSHEET_ROW_COUNT=Wo,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Fc,u.DEFAULT_WORKSHEET_ROW_HEIGHT=jo,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=$c,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Vo,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Bc,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ia,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=sa,u.DOCS_ZEN_EDITOR_UNIT_ID_KEY=dh,u.DashStyleType=js,u.DataStreamTreeNodeType=co,u.DataStreamTreeTokenType=ft,u.DataValidationErrorStyle=Sa,u.DataValidationImeMode=Na,u.DataValidationOperator=wa,u.DataValidationRenderMode=Ea,u.DataValidationStatus=Aa,u.DataValidationType=ba,u.DependentOn=Nh,u.DesktopLogService=ro,u.DeveloperMetadataVisibility=ds,u.Dimension=fs,u.Direction=_s,u.Disposable=Te,u.DisposableCollection=sr,u.DocStyleType=bs,u.DocumentDataModel=Pt,u.DocumentFlavor=Ms,u.DrawingTypeEnum=ti,u.EDITOR_ACTIVATED=Yo,u.EXTENSION_NAMES=Ni,u.Entry=ir,u.EntryIterator=Ci,u.ErrorService=Ho,u.EventState=pa,u.EventSubject=Gh,u.FOCUSING_COMMON_DRAWINGS=nh,u.FOCUSING_DOC=Bn,u.FOCUSING_EDITOR_BUT_HIDDEN=qc,u.FOCUSING_EDITOR_INPUT_FORMULA=Zc,u.FOCUSING_EDITOR_STANDALONE=eh,u.FOCUSING_FORMULA_EDITOR=Xo,u.FOCUSING_SHEET=un,u.FOCUSING_SLIDE=jn,u.FOCUSING_UNIVER_EDITOR=Jc,u.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=th,u.FollowNumberWithType=As,u.FontItalic=pn,u.FontStyleType=Ks,u.FontWeight=Rn,u.FormatType=gs,u.GlyphType=Zt,u.GridType=Us,u.HLSColor=Ns,u.HorizontalAlign=At,u.IAuthzIoService=ga,u.ICommandService=on,u.IConfigService=ko,u.IContextService=rn,u.ILocalStorageService=xh,u.ILogService=Ot,u.IPermissionService=Kr,u.IResourceLoaderService=Yr,u.IResourceManagerService=xn,u.ISnapshotServerService=Yh,u.IUndoRedoService=zn,u.IUniverInstanceService=xt,u.Inject=rt,u.Injector=dt,u.InterceptorManager=zh,u.InterpolationPointType=ms,u.JSON1=Tc,u.JSONX=Lt,u.KeyIterator=pi,u.LRUHelper=en,u.LRUMap=Ii,u.LifecycleStages=de,u.LocaleService=cn,u.LocaleType=bt,u.LogLevel=no,u.MOVE_BUFFER_VALUE=Qt,u.Many=Ui,u.MemoryCursor=Mo,u.NamedStyleType=Ws,u.NilCommand=io,u.NumberUnitType=Xs,u.ObjectMatrix=nt,u.ObjectRelativeFromH=zs,u.ObjectRelativeFromV=Ys,u.OnLifecycle=qo,u.Optional=Li,u.OtherShapes=vs,u.PRESET_LIST_TYPE=uc,u.PageElementType=ni,u.PageOrientType=Js,u.PageType=tr,u.ParagraphElementType=Fs,u.PermissionService=ta,u.PermissionStatus=xr,u.Plugin=qr,u.PositionedObjectLayoutType=$s,u.PresetListType=$n,u.ProtectionType=Es,u.RANGE_TYPE=oe,u.RCDisposable=Wl,u.RGBA_PAREN=Va,u.RGB_PAREN=Ga,u.ROTATE_BUFFER_VALUE=is,u.Range=Gt,u.Rectangle=vt,u.RediConsumer=Xi,u.RediContext=nn,u.RediError=Le,u.RediProvider=Or,u.RedoCommand=ca,u.RedoCommandId=aa,u.RefAlias=Ql,u.Registry=wr,u.RegistryAsMap=br,u.RelativeDate=ps,u.RelativeSlideLink=ri,u.ResourceManagerService=na,u.RgbColor=vn,u.RxDisposable=$l,u.SectionType=Ls,u.Self=Bi,u.SheetTypes=En,u.SheetViewModel=zo,u.SkipSelf=Wi,u.SliceBodyType=yr,u.SlideDataModel=Vr,u.SpacingRule=Bs,u.SpecialShapes=Os,u.Styles=$o,u.THEME_COLORS=Ss,u.TabStopAlignment=Gs,u.TextDecoration=Rs,u.TextDirection=qt,u.TextDirectionType=ks,u.TextX=St,u.TextXActionType=ee,u.ThemeColor=On,u.ThemeColorType=We,u.ThemeColors=Cn,u.ThemeService=Xr,u.Tools=k,u.UndoCommand=ua,u.UndoCommandId=la,u.UnitModel=Hn,u.Univer=Mh,u.UniverInstanceType=J,u.UpdateDocsAttributeType=Fe,u.ValueIterator=Ri,u.VerticalAlign=Wt,u.WidthType=Vs,u.WithDependency=Qu,u.WithNew=ji,u.Worksheet=ln,u.WrapStrategy=Bt,u.WrapTextType=Hs,u.afterInitApply=lc,u.b64DecodeUnicode=es,u.b64EncodeUnicode=Qh,u.binarySearchArray=os,u.cellToRange=yl,u.characterSpacingControlType=Zs,u.checkForSubstrings=Dl,u.checkIfMove=$a,u.checkParagraphHasBullet=Ml,u.checkParagraphHasIndent=Ul,u.checkParagraphHasIndentByStyle=ui,u.codeToBlob=Ba,u.composeBody=Dr,u.composeInterceptors=Ra,u.concatMatrixArray=Kl,u.connectDependencies=zu,u.connectInjector=Ku,u.convertBodyToHtml=su,u.covertTextRunToHtml=cr,u.createDefaultUser=Xn,u.createIdentifier=xe,u.createInterceptorKey=Kh,u.createInternalEditorID=_h,u.createRowColIter=ur,u.debounce=ru,u.dedupe=Bl,u.deepCompare=nr,u.deleteContent=hi,u.extractPureTextFromCell=Gc,u.forwardRef=vu,u.fromCallback=oo,u.fromEventSubject=Vh,u.fromObservable=Hl,u.generateRandomId=oi,u.generateTemporarySnap=td,u.getArrayLength=It,u.getBodySlice=an,u.getBodySliceHtml=Tn,u.getBorderStyleType=bl,u.getCellInfoInMergeData=ul,u.getCellValueType=il,u.getColorStyle=lt,u.getCustomDecorationSlice=wo,u.getCustomRangeSlice=No,u.getDocsUpdateBody=Al,u.getReverseDirection=ja,u.getSheetBlocksFromSnapshot=od,u.getWorksheetUID=Qc,u.groupBy=Vl,u.handleStyleToString=wl,u.hashAlgorithm=Pl,u.horizontalLineSegmentsSubtraction=wn,u.insertMatrixArray=or,u.insertTextToContent=ci,u.isAsyncDependencyItem=mr,u.isAsyncHook=Mn,u.isBlackColor=nl,u.isBooleanString=Hh,u.isCellCoverable=Ol,u.isCellV=al,u.isClassDependencyItem=fr,u.isCtor=dr,u.isDisposable=Ir,u.isEmptyCell=ai,u.isFactoryDependencyItem=_r,u.isFormulaId=Nl,u.isFormulaString=Sl,u.isICellData=sl,u.isInternalEditorID=gh,u.isNullCell=ol,u.isNumeric=ma,u.isRangesEqual=Lh,u.isRealNum=Ll,u.isSafeNumeric=Fh,u.isSameStyleTextRun=li,u.isUnitRangesEqual=Ph,u.isValidRange=Tl,u.isValueDependencyItem=gr,u.isWhiteColor=rl,u.makeArray=xl,u.makeCellRangeToRangeData=vl,u.makeCellToSelection=Il,u.mergeOverrideWithDependencies=fa,u.mergeSets=$h,u.mergeWorksheetSnapshotWithDefault=Ko,u.moveMatrixArray=lr,u.moveRangeByOffset=fu,u.nameCharacterCheck=ld,u.normalizeBody=Ic,u.normalizeTextRuns=Ar,u.numberToABC=Jl,u.numberToListABC=eu,u.orderSearchArray=as,u.queryObjectMatrix=du,u.remove=bn,u.repeatStringNumTimes=Oi,u.replaceInDocumentBody=jh,u.requestImmediateMacroTask=Bh,u.rotate=Gl,u.runOnLifecycle=Vn,u.searchArray=Wa,u.selectionToArray=ll,u.sequence=eo,u.sequenceAsync=Ji,u.sequenceExecute=Nr,u.sequenceExecuteAsync=ac,u.setDependencies=$u,u.shallowEqual=kh,u.skipParseTagNames=ad,u.sliceMatrixArray=zl,u.sortRules=tu,u.sortRulesByDesc=nu,u.sortRulesFactory=Dt,u.spliceArray=ar,u.takeAfter=ao,u.textDecoder=Qn,u.textEncoder=dn,u.throttle=Wh,u.toDisposable=Se,u.transformDocumentDataToSnapshot=id,u.transformSnapshotToDocumentData=sd,u.transformSnapshotToWorkbookData=rd,u.transformWorkbookDataToSnapshot=nd,u.updateAttributeByDelete=Uo,u.updateAttributeByInsert=Lo,u.useDependency=Vu,u.useDependencyContext=ec,u.useDependencyContextValue=tc,u.useDependencyValue=qi,u.useInjector=Qi,u.useObservable=Zu,u.useUpdateBinder=Ju,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});