@sheetxl/sdk 0.4.17 → 0.4.19

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 (103) hide show
  1. package/browser/cjs/{CDLqFwncOhC1wDZC.cjs → -XdpUGDwGmHHx1Rt.cjs} +1 -1
  2. package/browser/cjs/{BqcfsDsZ9f7JdzKO.cjs → B9v3u3hwmPue1Crf.cjs} +1 -1
  3. package/browser/cjs/{jewNbTdUsdZn85qJ.cjs → BPzvAcSjBOPCLRae.cjs} +1 -1
  4. package/browser/cjs/{DXz16Win9zW3-DCK.cjs → BSWe1zW77SdisEXi.cjs} +4 -4
  5. package/browser/cjs/{OeT2rhl1meBDmjQo.cjs → BWO4PWgRzvVsWDJA.cjs} +1 -1
  6. package/browser/cjs/{B9N4-bYInZllG2Vi.cjs → Bg5cGAcyMKhc1LVR.cjs} +1 -1
  7. package/browser/cjs/{OsU5EupiWMQ3fPIh.cjs → BmLK2Q7ZKH-MpZf2.cjs} +1 -1
  8. package/browser/cjs/{DGFY8kWoCEj4ZXED.cjs → BnloHxo3XPFlt9gf.cjs} +1 -1
  9. package/browser/cjs/{DiWEKYfmqir7C8N1.cjs → C0dfikqxNZtNj-22.cjs} +1 -1
  10. package/browser/cjs/{DA9m7pLOxxQPsBdB.cjs → C501EF7RGelm6o3R.cjs} +3 -3
  11. package/browser/cjs/{S-HINUWuUdC-KS9g.cjs → C9nSUDDtDNZklTgo.cjs} +1 -1
  12. package/browser/cjs/{ID1QB7CJqggIX5cn.cjs → CAyn-VHwt044Jaid.cjs} +1 -1
  13. package/browser/cjs/{V9VOu_k4Rtug4RcS.cjs → CBHpVFiJCCNa32Qd.cjs} +2 -2
  14. package/browser/cjs/{BylwboCc_4j5UMET.cjs → CJx8P3pZaRnS6Kny.cjs} +2 -2
  15. package/browser/cjs/{Bs1-GjGU7pxiy_M5.cjs → CrfDFjK9RNj481-9.cjs} +1 -1
  16. package/browser/cjs/CxV1-OXj1ZO7MZQF.cjs +60 -0
  17. package/browser/cjs/{GQHYwlbvacmirBNZ.cjs → D6QgMx0WUlWgYoae.cjs} +1 -1
  18. package/browser/cjs/{DcjSbOA9M7ZOS6Az.cjs → D8kiw7ChCC7ethCe.cjs} +1 -1
  19. package/browser/cjs/{3VDZDkTm5fMIQI6N.cjs → DPc0gEusAoUYAI0O.cjs} +1 -1
  20. package/browser/cjs/{CPnt5XIB2Fgd9bWL.cjs → DWPbAMkxOt6Cb9cp.cjs} +2 -2
  21. package/browser/cjs/{CnfgV9Wd1T6-Pv2G.cjs → DWRcbn9JzkP-rey4.cjs} +4 -4
  22. package/browser/cjs/{BILhe2td-4SMvvUj.cjs → DaEr2QpQ5d613oTn.cjs} +1 -1
  23. package/browser/cjs/{BgDpp2NvFj2vzAVw.cjs → DaYyPfJx_pc2iDDm.cjs} +1 -1
  24. package/browser/cjs/{BAb0ERWXvfy2WmDV.cjs → DoPx_0PJzz8WOjE-.cjs} +1 -1
  25. package/browser/cjs/{D2UW-mksnVpC9tEC.cjs → DoXjUhbXYEMYEj6w.cjs} +1 -1
  26. package/browser/cjs/{CpqBjkr0v-wwSc7T.cjs → Doku1UVzxfUkKjsU.cjs} +1 -1
  27. package/browser/cjs/{BKcwfHmM1wquAD7A.cjs → V_uwtlknwPnP2Un_.cjs} +1 -1
  28. package/browser/cjs/{B4GH_CVeD57P-hlT.cjs → eL4wAPO18NOtxRmW.cjs} +1 -1
  29. package/browser/cjs/{BXud78wUhzgFT2S8.cjs → hReZyLibRX_QhdqA.cjs} +1 -1
  30. package/browser/cjs/{B3kTGDDfOqlqnEGJ.cjs → hW1yREos32gpIHsR.cjs} +1 -1
  31. package/browser/cjs/index.cjs +2 -2
  32. package/browser/cjs/{DHVgvKzhF0OYfEZC.cjs → mN18HSNpekubzWOx.cjs} +1 -1
  33. package/browser/cjs/{D8wdzj5CM24hJ1aE.cjs → oROZhcugo511lwYD.cjs} +2 -2
  34. package/browser/cjs/{HDXrC4LJYhbrQApr.cjs → qjfxOoVcFF4_7fg8.cjs} +1 -1
  35. package/browser/esm/{DGJTN-b9ouYX803M.mjs → 1v0wWt1fqPRDORx-.mjs} +1 -1
  36. package/browser/esm/{DBXwQ0f8Ati5WRuU.mjs → 5v6eKDgISAObg5Sk.mjs} +4159 -4167
  37. package/{node/esm/DW5Iij5qx_-zRyh_.mjs → browser/esm/B6zlCMitM169AEV5.mjs} +1 -1
  38. package/browser/esm/{CQORIQhGia8o5m8o.mjs → BYu-X1qYzm9tZ3jy.mjs} +1 -1
  39. package/browser/esm/{CanQ4-mYL62IJeuF.mjs → BaqE8hRXzTNVxA7s.mjs} +2 -2
  40. package/{node/esm/BXxbXrxSh-BuAodI.mjs → browser/esm/BefBv4Sji_c90mMN.mjs} +1 -1
  41. package/browser/esm/{D7wfl5eCDWfixHec.mjs → Bf7DBXkGk1UG9hJQ.mjs} +1 -1
  42. package/{node/esm/Dp1vOHGwKnbhMDwt.mjs → browser/esm/BgePMvIc6yA6_ebp.mjs} +1 -1
  43. package/browser/esm/{DNHdhhNdg0TXxZJc.mjs → Br2kerMrZq0pplwK.mjs} +1 -1
  44. package/browser/esm/{SY5tg3hWzx5Sa4E4.mjs → BrAfC_Hz1HZiZjNh.mjs} +1 -1
  45. package/browser/esm/{CYORNeYlDN4jqrMU.mjs → BwotCxIgIVf7Syhx.mjs} +4 -4
  46. package/browser/esm/{F8djmSVikTezJzXf.mjs → C0HNcnUg1sYe6vKJ.mjs} +1 -1
  47. package/browser/esm/{DRP8IbcRnWmU10a_.mjs → C94a-TJowUoPL9Fp.mjs} +2 -2
  48. package/{node/esm/D9wllJd2NQsKjN0q.mjs → browser/esm/CV8kpqwdAKIIEJia.mjs} +1 -1
  49. package/browser/esm/{C753NBsw15_scxlE.mjs → CZ6VZ3NtZyMBJLvF.mjs} +1 -1
  50. package/browser/esm/{D-o0wp3zJOfayahp.mjs → C_hMM356eOyIGEgy.mjs} +1 -1
  51. package/{node/esm/CyhvX5MYakGJnjBB.mjs → browser/esm/CrBwUqwLJqFG3U4m.mjs} +1 -1
  52. package/{node/esm/YVh_FQDZy_7TDW13.mjs → browser/esm/CxdfUZ_whNEdCrBM.mjs} +1 -1
  53. package/{node/esm/gxsdzHxAUv9mdGRm.mjs → browser/esm/Cy781c813953r7bq.mjs} +1 -1
  54. package/{node/esm/DxxtEY6Lx0tI5nCI.mjs → browser/esm/CyZcmz9fV3_Zu57s.mjs} +1 -1
  55. package/browser/esm/{CK_d9zrthjJmxjZs.mjs → D36yXHRPCJFPE2Cn.mjs} +1 -1
  56. package/browser/esm/{lcTNH2TGk9jzzBYP.mjs → D9GMsV9S5kpEpaQ3.mjs} +2 -2
  57. package/{node/esm/BtgPzodeOq2vx7wu.mjs → browser/esm/DIiCZ8EuWYWD1G4X.mjs} +1 -1
  58. package/{node/esm/CpTrD47P1a9cw4hD.mjs → browser/esm/DLn3G10hRwsZCSWB.mjs} +1 -1
  59. package/browser/esm/{GK86KtgRHGM6WEPS.mjs → DW6X_ih_Ttv8w6c2.mjs} +1 -1
  60. package/browser/esm/{BYhijLO1qau0IPzK.mjs → DnRa0ZQVLa2Fqzju.mjs} +2 -2
  61. package/browser/esm/{2WyiYBEJzMQjlAq3.mjs → Dnypbs7l46y-W1pE.mjs} +3 -3
  62. package/{node/esm/CQh-wICFva-n-1VH.mjs → browser/esm/JP2SydGPgN2PrEam.mjs} +1 -1
  63. package/browser/esm/{fjinWOi8jboT8nsw.mjs → N5WXqNpZDnhetIYG.mjs} +1 -1
  64. package/browser/esm/{BD2QWG24Ai8XS1sH.mjs → OBWvICzxYhna2IxF.mjs} +1 -1
  65. package/browser/esm/{Cb7NocgusuSJxDyb.mjs → XrA8fo2R4AS3HzFz.mjs} +1 -1
  66. package/browser/esm/{DApmL5HvHL8dQjJu.mjs → aR99Cx5S9piceH0j.mjs} +1 -1
  67. package/browser/esm/{q7typc_bMggMtaUm.mjs → dRf_0yDP86DLaRrp.mjs} +4 -4
  68. package/browser/esm/index.mjs +2 -2
  69. package/licenses/dependencies.txt +3 -3
  70. package/node/esm/{jAfpqn4QloqfzCef.mjs → 07j0n4N6h6oBOk_2.mjs} +2 -2
  71. package/{browser/esm/DW5Iij5qx_-zRyh_.mjs → node/esm/B6zlCMitM169AEV5.mjs} +1 -1
  72. package/node/esm/{CU1iAiFndQXlG0c4.mjs → BNu3V1ap_WR3jqdX.mjs} +1 -1
  73. package/node/esm/{DRxVd-LklLTR0Avh.mjs → BSLIxDVCng1Ep_kU.mjs} +1 -1
  74. package/node/esm/{WClUDCTnhiH2nwzN.mjs → BSbOEM-6aEtAEUn2.mjs} +1 -1
  75. package/{browser/esm/BXxbXrxSh-BuAodI.mjs → node/esm/BefBv4Sji_c90mMN.mjs} +1 -1
  76. package/{browser/esm/Dp1vOHGwKnbhMDwt.mjs → node/esm/BgePMvIc6yA6_ebp.mjs} +1 -1
  77. package/node/esm/{PRCrUy2cTQp7hzRs.mjs → BhJMGJ-z8AHuc4PL.mjs} +1 -1
  78. package/node/esm/{SY5tg3hWzx5Sa4E4.mjs → BrAfC_Hz1HZiZjNh.mjs} +1 -1
  79. package/node/esm/{C1LotnhrtdmYBfLD.mjs → BvdYpC2TrqFNZ1dz.mjs} +1 -1
  80. package/node/esm/{CWNngv8lEonC71Qk.mjs → Bx9qRsBq80w6DZmQ.mjs} +4 -4
  81. package/node/esm/{COtz2-D0iXpaDzf3.mjs → BxOnww5rEBN0LYwd.mjs} +3 -3
  82. package/node/esm/{F8djmSVikTezJzXf.mjs → C0HNcnUg1sYe6vKJ.mjs} +1 -1
  83. package/node/esm/{CtsrVzglO2nU_Uxz.mjs → CHeQiTLK58a6NVsG.mjs} +1 -1
  84. package/{browser/esm/D9wllJd2NQsKjN0q.mjs → node/esm/CV8kpqwdAKIIEJia.mjs} +1 -1
  85. package/node/esm/{BPaqCLpmmt3F8Y67.mjs → CjPySw20pNmqGeem.mjs} +1 -1
  86. package/{browser/esm/CyhvX5MYakGJnjBB.mjs → node/esm/CrBwUqwLJqFG3U4m.mjs} +1 -1
  87. package/node/esm/{m-xRNSE6rMaeHTas.mjs → CteSWuaSiS_quyBE.mjs} +1 -1
  88. package/{browser/esm/YVh_FQDZy_7TDW13.mjs → node/esm/CxdfUZ_whNEdCrBM.mjs} +1 -1
  89. package/{browser/esm/gxsdzHxAUv9mdGRm.mjs → node/esm/Cy781c813953r7bq.mjs} +1 -1
  90. package/{browser/esm/DxxtEY6Lx0tI5nCI.mjs → node/esm/CyZcmz9fV3_Zu57s.mjs} +1 -1
  91. package/node/esm/{CK_d9zrthjJmxjZs.mjs → D36yXHRPCJFPE2Cn.mjs} +1 -1
  92. package/{browser/esm/BtgPzodeOq2vx7wu.mjs → node/esm/DIiCZ8EuWYWD1G4X.mjs} +1 -1
  93. package/node/esm/{Dd8svp0SZupg0qId.mjs → DK54CIvklXVGAymn.mjs} +2 -2
  94. package/{browser/esm/CpTrD47P1a9cw4hD.mjs → node/esm/DLn3G10hRwsZCSWB.mjs} +1 -1
  95. package/node/esm/{DtjguzvyogR9GHRR.mjs → DbXESzawTrm7E2Do.mjs} +1 -1
  96. package/node/esm/{sYt1hGSPpstn9ljA.mjs → DjenIXryJ8ccxNad.mjs} +1 -1
  97. package/{browser/esm/CQh-wICFva-n-1VH.mjs → node/esm/JP2SydGPgN2PrEam.mjs} +1 -1
  98. package/node/esm/{fjinWOi8jboT8nsw.mjs → N5WXqNpZDnhetIYG.mjs} +1 -1
  99. package/node/esm/{BD2QWG24Ai8XS1sH.mjs → OBWvICzxYhna2IxF.mjs} +1 -1
  100. package/node/esm/index.mjs +445 -445
  101. package/node/esm/{BF5XLlWweZJpoxFw.mjs → kQVOc3F7_ib5L98K.mjs} +2 -2
  102. package/package.json +4 -4
  103. package/browser/cjs/CyWg0eUf6QBgutTE.cjs +0 -60
@@ -0,0 +1,60 @@
1
+ "use strict";/**
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.19
3
+ *
4
+ * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
+ * License: The license can be found at https://www.sheetxl.com/license.
6
+ */const U={Number:"n",String:"s",Boolean:"b",Error:"e",RichData:"r",Null:"z"};var cs;exports.w=void 0,exports.n=void 0,(cs=exports.w||(exports.w={})).Orientation={Column:"column",Row:"row"},cs.Orientations={...cs.Orientation,Both:"both"},cs.Direction={Up:"up",Down:"down",Left:"left",Right:"right"},(s=>{s.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},s.Label={Parse:"#PARSE!",Null:"#NULL!",Div0:"#DIV/0!",Value:"#VALUE!",Ref:"#REF!",Name:"#NAME?",Num:"#NUM!",NA:"#N/A",GettingData:"#GETTING_DATA",Spill:"#SPILL!",Connect:"#CONNECT!",Blocked:"#BLOCKED!",Unknown:"#UNKNOWN!",Field:"#FIELD!",Calc:"#CALC!",Busy:"#BUSY!",Python:"#PYTHON!",Timeout:"#TIMEOUT!"};class e extends Error{constructor(b,w,E,x){super(E,x),this._label=w,this._code=b,this.details=x}static{this.code=s.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(b){return!!b&&(this._code===b._code||this._code===b.code)}get[Symbol.toStringTag](){return"[FormulaError]"}toString(){return this.message||this._label}}s.Known=e;class t extends e{constructor(b,w){super(s.Code.Parse,s.Label.Parse,b,w)}static{this.code=s.Code.Parse}getDetails(){const b=this.details;return{line:b?.line??1,column:b?.column??1,offset:b?.offset??0,length:b?.length??0}}}s.Parse=t;class n extends e{constructor(b,w){super(s.Code.Null,s.Label.Null,b,w)}static{this.code=s.Code.Null}}s.Null=n;class r extends e{constructor(b,w){super(s.Code.Div0,s.Label.Div0,b,w)}static{this.code=s.Code.Div0}}s.Div0=r;class o extends e{constructor(b,w){super(s.Code.Value,s.Label.Value,b,w)}static{this.code=s.Code.Value}}s.Value=o;class i extends e{constructor(b,w){super(s.Code.Ref,s.Label.Ref,b,w)}static{this.code=s.Code.Ref}}s.Ref=i;class a extends e{constructor(b,w){super(s.Code.Name,s.Label.Name,b,w)}static{this.code=s.Code.Name}}s.Name=a;class l extends e{constructor(b,w){super(s.Code.Num,s.Label.Num,b,w)}static{this.code=s.Code.Num}}s.Num=l;class c extends e{constructor(b,w){super(s.Code.NA,s.Label.NA,b,w)}static{this.code=s.Code.NA}}s.NA=c;class h extends e{constructor(b,w){super(s.Code.GettingData,s.Label.GettingData,b,w)}static{this.code=s.Code.GettingData}}s.GettingData=h;class u extends e{constructor(b,w){super(s.Code.Spill,s.Label.Spill,b,w)}static{this.code=s.Code.Spill}}s.Spill=u;class d extends e{constructor(b,w){super(s.Code.Connect,s.Label.Connect,b,w)}static{this.code=s.Code.Connect}}s.Connect=d;class g extends e{constructor(b,w){super(s.Code.Blocked,s.Label.Blocked,b,w)}static{this.code=s.Code.Blocked}}s.Blocked=g;class m extends e{constructor(b,w){super(s.Code.Unknown,s.Label.Unknown,b,w)}static{this.code=s.Code.Unknown}}s.Unknown=m;class f extends e{constructor(b,w){super(s.Code.Field,s.Label.Field,b,w)}static{this.code=s.Code.Field}}s.Field=f;class _ extends e{constructor(b,w){super(s.Code.Calc,s.Label.Calc,b,w)}static{this.code=s.Code.Calc}}s.Calc=_;class p extends e{constructor(b,w){super(s.Code.Busy,s.Label.Busy,b,w)}static{this.code=s.Code.Busy}}s.Busy=p;class S extends e{constructor(b,w){super(s.Code.Python,s.Label.Python,b,w)}static{this.code=s.Code.Python}}s.Python=S;class C extends e{constructor(b,w){super(s.Code.Timeout,s.Label.Timeout,b,w)}static{this.code=s.Code.Timeout}}s.Timeout=C})(exports.n||(exports.n={}));const Je={};Je[exports.n.Code.Parse]=exports.n.Parse,Je[exports.n.Code.Null]=exports.n.Null,Je[exports.n.Code.Div0]=exports.n.Div0,Je[exports.n.Code.Value]=exports.n.Value,Je[exports.n.Code.Ref]=exports.n.Ref,Je[exports.n.Code.Name]=exports.n.Name,Je[exports.n.Code.Num]=exports.n.Num,Je[exports.n.Code.NA]=exports.n.NA,Je[exports.n.Code.GettingData]=exports.n.GettingData,Je[exports.n.Code.Spill]=exports.n.Spill,Je[exports.n.Code.Connect]=exports.n.Connect,Je[exports.n.Code.Blocked]=exports.n.Blocked,Je[exports.n.Code.Unknown]=exports.n.Unknown,Je[exports.n.Code.Field]=exports.n.Field,Je[exports.n.Code.Calc]=exports.n.Calc,Je[exports.n.Code.Busy]=exports.n.Busy,Je[exports.n.Code.Python]=exports.n.Python,Je[exports.n.Code.Timeout]=exports.n.Timeout;const rg=new Map,ec=new Map,og=new Map,sg=new Map,Rc=Object.keys(Je);for(let s=0;s<Rc.length;s++){const e=Rc[s],t=Je[e];og.set(exports.n.Label[e],t),sg.set(exports.n.Code[e],t);const n=new t;rg.set(n.getLabel(),n),ec.set(n.getCode(),n)}const Mf=ec.get(exports.n.Code.Unknown);var ze;(ze=exports.n||(exports.n={})).BuiltIn={Parse:new ze.Parse,Null:new ze.Null,Div0:new ze.Div0,Value:new ze.Value,Ref:new ze.Ref,Name:new ze.Name,Num:new ze.Num,NA:new ze.NA,GettingData:new ze.GettingData,Spill:new ze.Spill,Connect:new ze.Connect,Blocked:new ze.Blocked,Unknown:new ze.Unknown,Field:new ze.Field,Calc:new ze.Calc,Busy:new ze.Busy,Python:new ze.Python,Timeout:new ze.Timeout},ze.getBuiltInByLabel=s=>rg.get(s),ze.newTypedError=(s,e,t)=>{let n;return n=typeof s=="string"?og.get(s):sg.get(s),n||(n=ze.Unknown),new n(e,t)},ze.getBuiltInById=s=>ec.get(s)||Mf;let ig=class{constructor(s){this._subscribeFn=s}subscribe(s,e,t){const n=typeof s=="object"?{next:s.next||(()=>{}),error:s.error||(()=>{}),complete:s.complete||(()=>{}),unsubscribe:()=>{}}:{next:s||(()=>{}),error:e||(()=>{}),complete:t||(()=>{}),unsubscribe:()=>{}},r=this._subscribeFn(n);return n.unsubscribe=()=>{typeof r=="function"&&r()},n}},ag=class{getRange(s){throw new hs}getReference(s,e){throw new hs}getNumberFormat(s,e){return e?.toString()??""}fromOADate(s){return new Date(s)}toOADate(s){return s.getTime()}getValueAt(s,e){return null}getEntireCoords(){return Ff}isValidDate(s){return(s instanceof Date||Object.prototype.toString.call(s)==="[object Date]")&&!isNaN(s.getTime())}getPosition(){return Tf}getFormulaAt(s,e){return null}getSpillAt(s,e){return null}getSheetIndex(s){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(s){}getFunction(s){return null}getAddress(s,e){throw new hs}parseAsDateTime(s,e){throw new hs}getRuntime(){return Nf}};class hs extends Error{constructor(e="Not implemented in StubbedFormulaContext"){super(e),this.name="NotImplementedError"}}const Tf=Object.freeze({colIndex:0,rowIndex:0}),Ff=Object.freeze({colStart:0,rowStart:0,colEnd:Math.pow(2,14)-1,rowEnd:Math.pow(2,20)-1}),Nf={getCurrencySymbol:()=>"$",getNumberDecimalSeparator:()=>".",getNumberGroupSeparator:()=>",",isDate1904:()=>!1,getLocation:()=>"unknown",getVersion:()=>"1.0.0",getOS:()=>"unknown",getUser:()=>"unidentified",getDescription:()=>"Stubbed Formula Context"},kf=new ag,Be={Up:"up",Down:"down",Left:"left",Right:"right"},cn={TopLeft:"tl",Top:"t",TopRight:"tr",Left:"l",Center:"c",Right:"r",BottomLeft:"bl",Bottom:"b",BottomRight:"br"},Te={html:"text/html",plain:"text/plain",png:"image/png"},Of=Object.freeze({left:0,top:0}),Bf=Object.freeze({left:0,top:0,bottom:0,right:0}),Df=Object.freeze({x:0,y:0,width:0,height:0}),Yo=Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:Df,EmptyRect:Bf,EmptyTopLeft:Of},Symbol.toStringTag,{value:"Module"})),se={Column:"column",Row:"row"},Yn={...se,Both:"both"},Lf=Object.freeze({colIndex:0,rowIndex:0}),Pf=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),lg=(s,e)=>s.colStart===e.colStart?s.rowStart-e.rowStart:s.colStart-e.colStart,cg=(s,e)=>s.rowStart===e.rowStart?s.colStart-e.colStart:s.rowStart-e.rowStart,zf=(s,e)=>s.rowEnd===e.rowEnd?e.colEnd-s.colEnd:e.rowEnd-s.rowEnd,jf=(s,e)=>s.colEnd===e.colEnd?e.rowEnd-s.rowEnd:e.colEnd-s.colEnd,Ac=(s,e)=>s.colIndex===e.colIndex?s.rowIndex-e.rowIndex:s.colIndex-e.colIndex,Mc=(s,e)=>s.rowIndex===e.rowIndex?s.colIndex-e.colIndex:s.rowIndex-e.rowIndex,hg=(s=se.Row,e=!1)=>e?s!==se.Column?zf:jf:s!==se.Column?cg:lg,Tc=(s,e)=>s===e||!(!s||!e)&&s.rowIndex===e.rowIndex&&s.colIndex===e.colIndex,Sl=(s,e)=>s===e||!(!s||!e)&&s.rowStart===e.rowStart&&s.rowEnd===e.rowEnd&&s.colStart===e.colStart&&s.colEnd===e.colEnd,wl=(s,e)=>!(!s||!e||s.colStart>e.colEnd||e.colStart>s.colEnd||s.rowStart>e.rowEnd||e.rowStart>s.rowEnd),Fc=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Sl(s[t],e[t]))return!1;return!0},ta=(s,e,t)=>{if(!s&&!e)return null;if(!s)return t?e:{...e};if(!e)return t?s:{...s};const n=Math.min(s.colStart,e.colStart),r=Math.min(s.rowStart,e.rowStart),o=Math.max(s.colEnd,e.colEnd),i=Math.max(s.rowEnd,e.rowEnd);let a=t;return a?(a.colStart=n,a.rowStart=r,a.colEnd=o,a.rowEnd=i):a={colStart:n,rowStart:r,colEnd:o,rowEnd:i},a},Nc=(s,e)=>{if(!e||e.length===0)return s;const t={...s};for(let n=0;n<e.length;n++){const r=e[n];wl(t,r)&&(t.rowStart=Math.min(t.rowStart,r.rowStart),t.colStart=Math.min(t.colStart,r.colStart),t.rowEnd=Math.max(t.rowEnd,r.rowEnd),t.colEnd=Math.max(t.colEnd,r.colEnd))}return t},Wf=[null,null],Hf=(s,e,t)=>{if(s[0].value===s[1].value)return e};function kc(s,e=2,t,n=se.Row,r){let o=[...s];if(e<=0||s.length<=1)return o;let i=n===se.Column,a=0,l=!1;do{const c=o.sort(hg(i?se.Row:se.Column));o=[],o.push(c[0]);const h=c.length;let u=0,d=c[0],g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd;for(let p=1;p<h;p++){const S=c[p];let C=!1;if(C=i?d&&m===S.rowStart&&_===S.rowEnd&&f+1===S.colStart:d&&g===S.colStart&&f===S.colEnd&&_+1===S.rowStart,C){let y={colStart:g,rowStart:m,colEnd:i?S.colEnd:f,rowEnd:i?_:S.rowEnd};if(d.value!==void 0&&(y.value=d.value),t){const b=r??[null,null];b[0]=d,b[1]=S,y=t(b,y,n)}if(y){o[u]=y,l=!0,d=y,g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd;continue}}o[++u]=S,d=S,g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd}a++,i=!i,a===1&&(l=!0)}while(a<e&&l&&o.length>1);return o}const k=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:Lf,EmptyRange:Pf,cellToRange:(s,e)=>{if(!s)return null;let t=e;return t||(t={...s},delete t.colIndex,delete t.rowIndex),t.colStart=s.colIndex??0,t.rowStart=s.rowIndex??0,t.colEnd=s.colIndex??0,t.rowEnd=s.rowIndex??0,t},columnFirstCellComparator:Ac,columnFirstRangeComparator:lg,createCellComparator:(s=se.Row,e=!1)=>e?s!==se.Column?(t,n)=>t.rowIndex===n.rowIndex?n.colIndex-t.colIndex:n.rowIndex-t.rowIndex:(t,n)=>t.colIndex===n.colIndex?n.rowIndex-t.rowIndex:n.colIndex-t.colIndex:s!==se.Column?Mc:Ac,createConflatingRanges:(s,e=!1)=>{const t=[];let n,r,o=Number.MIN_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER;return{append:(a,l,c)=>{let h=!0;const u=c!==void 0;if(u){const m=s?s(r,c,e):r===c?c:void 0;m===void 0?h=!1:c=m}if(h&&l===i+1&&a===o)return e?n.rowEnd=l:n.colEnd=l,i=l,void(r=c);n&&t.push(n);const d=e?a:l,g=e?l:a;n={colStart:d,rowStart:g,colEnd:d,rowEnd:g},u&&(n.value=c),o=a,i=l,r=c},done:a=>(n&&(t.push(n),n=null),a?kc(t,3,a===!0?Hf:a,e?se.Column:se.Row,Wf):t)}},createRangeComparator:hg,defaultRange:(s,e,t)=>s?t?(t.colStart=s.colStart??e.colStart,t.rowStart=s.rowStart??e.rowStart,t.colEnd=s.colEnd??e.colEnd,t.rowEnd=s.rowEnd??e.rowEnd,t):{colStart:s.colStart??e.colStart,rowStart:s.rowStart??e.rowStart,colEnd:s.colEnd??e.colEnd,rowEnd:s.rowEnd??e.rowEnd}:e,extendRangeToIntersectingRanges:Nc,extendRangeToUnionRanges:(s,e)=>{if(!e||e.length===0)return s;let t=s,n=null;for(;!Sl(t,n);)n=t,t=Nc(n,e);return t},indexOfCoords:(s,e)=>{const t={colStart:s.colIndex,rowStart:s.rowIndex,colEnd:s.colIndex,rowEnd:s.rowIndex};for(let n=e.length-1;n>=0;n--)if(wl(t,e[n]))return n;return-1},intersectRanges:(s,e,t)=>{if(!s)return t?e:{...e};if(!e)return t?s:{...s};if(!s&&!e||s.rowStart>e.rowEnd||s.rowEnd<e.rowStart||s.colStart>e.colEnd||s.colEnd<e.colStart)return null;const n=Math.max(s.colStart,e.colStart),r=Math.max(s.rowStart,e.rowStart),o=Math.min(s.colEnd,e.colEnd),i=Math.min(s.rowEnd,e.rowEnd);let a=t;return a?(a.colStart=n,a.rowStart=r,a.colEnd=o,a.rowEnd=i):a={colStart:n,rowStart:r,colEnd:o,rowEnd:i},a},isCellWithinRange:(s,e)=>!(!s||!e||s.rowIndex<e.rowStart||s.rowIndex>e.rowEnd||s.colIndex<e.colStart||s.colIndex>e.colEnd),isEqualCells:Tc,isEqualRanges:Sl,isEqualRangesArrays:Fc,isEqualSelectionCoords:(s,e)=>s===e||!(!s||!e)&&s.rangeIndex===e.rangeIndex&&!!Tc(s.cell,e.cell)&&Fc(s.ranges,e.ranges),isRangeWithinRange:(s,e)=>!(s.rowStart<e.rowStart||s.rowEnd>e.rowEnd||s.colStart<e.colStart||s.colEnd>e.colEnd),isRangesIntersect:wl,isSingleCell:s=>!!s&&s.rowEnd===s.rowStart&&s.colStart===s.colEnd,isValidRange:s=>!(!s||typeof s.colStart!="number"||s.colStart<0||typeof s.colEnd!="number"||s.colEnd<s.colStart||typeof s.rowStart!="number"||s.rowStart<0||typeof s.rowEnd!="number"||s.rowEnd<s.rowStart),mergeRangedValues:kc,rowFirstCellComparator:Mc,rowFirstRangeComparator:cg,sanitizeRange:s=>s?{colStart:s.colIndex??s.colStart??0,rowStart:s.rowIndex??s.rowStart??0,colEnd:s.colIndex??s.colEnd??0,rowEnd:s.rowIndex??s.rowEnd??0}:null,translateRange:(s,e=-s.rowStart,t=-s.colStart,n)=>n?(n.colStart=s.colStart+t,n.rowStart=s.rowStart+e,n.colEnd=s.colEnd+t,n.rowEnd=s.rowEnd+e,n):{colStart:s.colStart+t,rowStart:s.rowStart+e,colEnd:s.colEnd+t,rowEnd:s.rowEnd+e},unionRanges:ta,unionRangesArrays:(s,e,t)=>{if(!s||s.length===0)return null;if(s.length===1&&!e)return s[0];let n=s[0];for(let r=1;r<s.length;r++)n=ta(n,s[r],t);return e&&(n=ta(n,e,t)),n}},Symbol.toStringTag,{value:"Module"})),Vf=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function $f(s){return function(e){return!!e&&typeof e=="object"}(s)&&!function(e){const t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||function(n){return n.$$typeof===Vf}(e)}(s)}function bo(s,e){return e.clone!==!1&&e.isMergeableObject(s)?tr((t=s,Array.isArray(t)?[]:{}),s,e):s;var t}function Gf(s,e,t){return s.concat(e).map(function(n){return bo(n,t)})}function Oc(s){return Object.keys(s).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(s))}function Bc(s,e){try{return e in s}catch{return!1}}function tr(s,e,t){(t=t||{}).arrayMerge=t.arrayMerge||Gf,t.isMergeableObject=t.isMergeableObject||$f,t.cloneUnlessOtherwiseSpecified=bo;const n=Array.isArray(e);return n===Array.isArray(s)?n?t.arrayMerge(s,e,t):function(r,o,i){const a={};return i.isMergeableObject(r)&&Oc(r).forEach(function(l){a[l]=bo(r[l],i)}),Oc(o).forEach(function(l){(function(c,h){return Bc(c,h)&&!(Object.hasOwnProperty.call(c,h)&&Object.propertyIsEnumerable.call(c,h))})(r,l)||(Bc(r,l)&&i.isMergeableObject(o[l])?a[l]=function(c,h){if(!h.customMerge)return tr;const u=h.customMerge(c);return typeof u=="function"?u:tr}(l,i)(r[l],o[l],i):a[l]=bo(o[l],i))}),a}(s,e,t):bo(e,t)}tr.all=function(s,e){if(!Array.isArray(s))throw new Error("first argument should be an array");return s.reduce(function(t,n){return tr(t,n,e)},{})};const Uf=Object.freeze([]),qf=Object.freeze({}),Dc=s=>s,js=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){let e=16*Math.random()|0;return(s==="x"?e:3&e|8).toString(16)}),ug=(s,e)=>s===e||!(!Array.isArray(s)||!Array.isArray(e)||s.length!==e.length)&&s.every((t,n)=>t===e[n]),Qr=s=>typeof s=="object"&&!Array.isArray(s)&&s!==null,dg=s=>typeof s!="object"||Array.isArray(s)||s===null?s:(Object.keys(s).forEach(function(e){s[e]&&typeof s[e]=="object"?dg(s[e]):s[e]!==null&&s[e]!==void 0||delete s[e],typeof s[e]=="object"&&Object.keys(s[e]).length===0&&delete s[e]}),Object.keys(s).length===0?null:s),Jf=(s,e)=>!(s!==e&&!ug(s,e)&&!s.isEqual?.(e)),gg=(s,e,t=Jf)=>{if(s==null||s===e)return null;if(!s||typeof s!="object"||Array.isArray(s)||s.isImmutable?.())return t(s,e)?null:s;const n=Object.keys(s);if(n.length===0)return null;let r=!1;for(let o=0;o<n.length;o++){const i=n[o];gg(s[i],e?.[i],t)===null&&(r=!0,delete s[i])}return r&&Object.keys(s).length===0?null:void 0},Lc=typeof performance=="object"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),Pc=s=>s==null,zc=(s,e)=>!(e.left>s.right||e.right<s.left||e.top>s.bottom||e.bottom<s.top),jc=!(typeof window>"u"||!window.document||!window.document.createElement),mt={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},jo=()=>{if(mg())return mt.Node;const s=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return s?/(win32|win64|windows|wince)/i.test(s)?mt.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(s)?mt.MacOS:/(iphone|ipad|ipod)/i.test(s)?mt.IOS:/android/.test(s)?mt.Android:/linux/.test(s)?mt.Linux:/^((?!chrome|android|).)*safari/i.test(s)?mt.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(s)?mt.Firefox:mt.Unknown:mt.Unknown};function mg(){return typeof process<"u"&&process.release?.name==="node"||(typeof process<"u"&&process.browser,!1)}const Wc=(s,e=!1)=>(document.hasFocus()||e)&&(s===document.activeElement||s?.contains(document.activeElement)),F=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:Uf,EmptyObject:qf,OSType:mt,arrayMove:function(s,e,t){const n=s.slice();return n.splice(t<0?n.length+t:t,0,n.splice(e,1)[0]),n},asNumber:s=>{const e=(t=>1*t)(s);return Number.isFinite(e)?e:0},camelToPrettyCase:s=>s.length===1?s.toUpperCase():s.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).trim(),canUseDOM:jc,cancelTimeout:s=>{cancelAnimationFrame(s.id)},castToString:s=>s==null||s===void 0?"":typeof s!="string"?""+s:s,cloneObject:s=>Pc(s)?s:JSON.parse(JSON.stringify(s)),consoleWithNoSource:(...s)=>new Promise(e=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,s),e()})}),debounce:function(s,e=300,t=!1){let n,r,o,i,a=0;function l(){let h=Date.now()-a;h<e&&h>=0?n=setTimeout(l,e-h):(n=null,t||(i=s.apply(o,r),o=r=null))}e==null&&(e=100);const c=function(){o=globalThis,r=arguments,a=Date.now();var h=t&&!n;return n||(n=setTimeout(l,e)),h&&(i=s.apply(o,r),o=r=null),i};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(i=s.apply(o,r),o=r=null,clearTimeout(n),n=null)},c},deepEqual:function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;let n,r,o;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!s(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!s(r[1],t.get(r[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let i=o[r];if(!(i==="_owner"&&e.$$typeof||s(e[i],t[i])))return!1}return!0}return e!=e&&t!=t},deepFreeze:function s(e){return Object.freeze(e),Object.keys(e).forEach(t=>{typeof e[t]!="object"||e[t]===null||Object.isFrozen(e[t])||s(e[t])}),e},deepMerge:tr,diffValues:(s,e)=>{const t={},n=Object.keys(e),r=n.length;for(let o=0;o<r;o++){const i=n[o];s[i]!==e[i]&&(s[i]===void 0?t[i]=e[i]:t[i]=s[i])}return Object.keys(t).length===0?null:t},findEqualOrGreater:function(s,e,t=Dc){let n=0,r=s.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t(s[o]);if(i===e)return o;i<e?n=o+1:r=o-1}return n},findEqualOrLesser:function(s,e,t=Dc){let n=s.length-1,r=0;for(;n>=r;){let o=Math.floor((n+r)/2),i=t(s[o]);if(i===e)return o;i>e?n=o-1:r=o+1}return n},findNextStep:(s,e=!0,t=15,n=10,r=400)=>{const o=Math.max(s-n,0)+(e?1:-1);return Math.min(r,Math[e?"ceil":"floor"](o/t)*t+n)},getDPI:()=>{let s=1;return typeof window=="object"&&(s=window.devicePixelRatio||1),s},getFromPath:(s,e)=>{const t=e.split(".");let n=s;for(let r=0;r<t.length;r++){const o=t[r];if(!n)return null;let i=n[o];if(typeof i=="function"&&(i=i.bind(n)()),!i||!Qr(i))return i;n=i}return n??null},getOS:jo,hasFocus:Wc,isDefined:s=>s!=null,isEmpty:s=>s==null||s==="",isEqualArrays:ug,isEqualBounds:(s,e)=>s===e||!(s&&!e||e&&!s)&&s.x===e.x&&s.y===e.y&&s.width===e.width&&s.height===e.height,isEqualObjectKeys:(s,e)=>{if(s===e)return!0;if(s&&!e||e&&!s)return!1;const t=Object.keys(s);if(t.length!==Object.keys(e).length)return!1;for(let n=0;n<t.length;n++)if(s[t[n]]!==e[t[n]])return!1;return!0},isNode:mg,isNullOrUndefined:Pc,isNumeric:s=>{const e=1*s;return Number.isFinite(e)&&typeof e=="number"},isObject:Qr,isPromiseLike:s=>!!s&&typeof s.then=="function",isRectInsideRect:(s,e)=>s.top>=e.top&&s.bottom<=e.bottom&&s.left>=e.left&&s.right<=e.right,isRectIntersect:zc,mergeContentful:(...s)=>{const e=s.length;if(e>0&&s[e-1]!==void 0&&!Qr(s[e-1]))return s[e-1];let t=s[0]||{};for(let n=1;n<e;n++)t=tr(t,s[n]||{},{arrayMerge:(r,o)=>[...o]});return t},nextTick:s=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>{s()}):(typeof setImmediate=="function"?setImmediate:setTimeout)(()=>{s()})},openFileDialog:(s="*.*")=>new Promise((e,t)=>{if(!jc)return void t("Unable to open dialog with no dom.");const n=document.createElement("input");n.type="file",n.accept=s;let r=null,o=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||o||(o=!0,e(null))},1e3)},{once:!0,passive:!0}),n.onchange=()=>{if(r=n.files[0],r){if(o)return void console.warn("File open detected after faux cancel.",r);e(r)}},n.autofocus=!0,n.click()}),rafThrottle:s=>{let e,t=!1,n=function(){t=!1,s(e)};return function(r){e=r,e&&e.persist&&e.persist(),t||(t=!0,requestAnimationFrame(n))}},removeEmptyProperties:dg,removeEqualValues:gg,removeListenerAll:s=>{if(!s)return[];for(let e=0;e<s.length;e++)s[e]&&s[e]();return[]},requestTimeout:(s,e)=>{const t=Lc(),n={id:requestAnimationFrame(function r(){Lc()-t>=e?s.call(null):n.id=requestAnimationFrame(r)})};return n},roundAccurately:(s,e=0)=>{if(s==null||!isFinite(s))return null;const t=10**e;return Number(Math.round(s*t)/t)},setToPath:(s,e,t)=>{const n=e.split(".");let r=s;if(!r)throw new Error("Can not set path to a null path.");for(let o=0;r&&o<n.length-1;o++){const i=n[o];let a=r[i];if(a==null&&(a={},r[i]=a),!Qr(a))throw new Error("Can not set path to a non object path.");r=a}if(typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"&&!Qr(t))throw new Error(`Can not set path to ${t} that is not a a supported primitive.`);return r[n[n.length-1]]=t,s},splitNumber:s=>{let e=Math.abs(s);if(isNaN(e)||!isFinite(s))return null;let t=0|e,n=e-t,r=0,o=0,i=1;if(n>5e-8)for(;o<8&&Math.abs(r/i-n)>5e-8;)o++,i*=10,r=Math.round(n*i);return{ip:Math.trunc(s),fp:r,ipLength:Math.ceil(Math.log10(t+1)),fpLength:o}},subtractRect:(s,e,t=!1)=>{if(!e)return[s];if(!zc(s,e))return[];const n=[];let r=s;const o=()=>{e.top>r.top&&e.top<r.bottom&&(n.push({...r,bottom:e.top}),r={...r,top:e.top})},i=()=>{e.bottom>r.top&&e.bottom<r.bottom&&(n.push({...r,top:e.bottom}),r={...r,bottom:e.bottom})},a=()=>{e.right>r.left&&e.right<r.right&&(n.push({...r,left:e.right}),r={...r,right:e.right})},l=()=>{e.left>r.left&&e.left<r.right&&(n.push({...r,right:e.left}),r={...r,left:e.left})};return t?(l(),a(),o(),i()):(o(),i(),a(),l()),n},textToKey:s=>s.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(s,e){let t=null;return(...n)=>{const r=Date.now();(!t||r-t>=e)&&(t=r,s(...n))}},toSafeJSON:function s(e){if(e===null||typeof e!="object")return e;if(typeof e.toJSON=="function")return e.toJSON();if(Array.isArray(e))return e.map(n=>s(n));if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]=s(e[n]));return t},transpose:s=>{if(!s)return s;const e=s.length,t=s[0].length,n=[];for(let r=0;r<t;r++)n[r]=Array(e);for(let r=0;r<e;r++)for(let o=0;o<t;o++)n[o][r]=s[r][o];return n},uuidV4:js,validEnumValue:(s,e)=>{if(!Object.values(s).includes(e))throw new Error(`Invalid type: ${e??"null"}. Must be one of: ${Object.values(e).join(", ")}.`)},whenFocus:async(s,e=!1)=>new Promise(t=>{Wc(s,e)?t(!0):s.addEventListener("focusin",()=>{t(!0)},{once:!0}),s.focus()})},Symbol.toStringTag,{value:"Module"})),fg=Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:s=>`Invalid argument: '${s}'.`},Symbol.toStringTag,{value:"Module"})),pg=s=>{const e=new Uint8Array(s),t=e.byteLength;let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);if(typeof window<"u"&&typeof globalThis.btoa=="function")return globalThis.btoa(n);if(typeof Buffer<"u")return Buffer.from(n,"binary").toString("base64");throw new Error("Unsupported environment")},yl=s=>new Promise((e,t)=>{if(s)if(typeof FileReader<"u"){const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=()=>{t(n.error)},n.readAsText(s)}else if(typeof Buffer<"u"){const n=r=>Buffer.from(r).toString("utf-8");s.arrayBuffer().then(r=>{e(n(r))}).catch(r=>{t(r)})}else t(new Error("Unsupported environment"));else e("")}),Mr=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:pg,base64ToArrayBuffer:s=>{const e=typeof window<"u"&&typeof globalThis.atob=="function"?globalThis.atob(s):Buffer.from(s,"base64").toString("binary"),t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer},blobToString:yl},Symbol.toStringTag,{value:"Module"})),_g="data:image/png;base64,",Sg="Unable to resolve image.",Hc=s=>new Promise(async(e,t)=>{let n=null;try{n=new Image,n.src=s,n.addEventListener("load",function(){e({width:n.naturalWidth,height:n.naturalHeight})},{once:!0}),n.addEventListener("error",function(){URL.revokeObjectURL(s),t("Invalid Image")},{once:!0}),await n.decode("sync")}catch{n?.src&&URL.revokeObjectURL(n.src)}n||t(Sg)}),na="image/svg+xml",Bo=Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:_g,getImageDataUrl:(s,e=1)=>new Promise(async(t,n)=>{let r=null;try{r=new Image,r.src=s,r.addEventListener("load",function(){try{const o=document.createElement("canvas");o.width=r.naturalWidth,o.height=r.naturalHeight,o.getContext("2d").drawImage(r,0,0);const i=o.toDataURL("image/png",e);t({elemImg:r,dataUrl:i})}catch(o){URL.revokeObjectURL(s),n(o)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(s),n("Invalid Image")},{once:!0}),await r.decode("sync")}catch{r?.src&&URL.revokeObjectURL(r.src)}r||n(Sg)}),loadImageDetails:async(s,e=null)=>{let t=null;const n=async()=>{try{const o=e??"image/*",i=URL.createObjectURL(new Blob([s],{type:o})),a=await Hc(i);t={mimeType:o,naturalDimensions:a,asUrl:i}}catch{}},r=async()=>{try{const o=new TextDecoder().decode(s),i=URL.createObjectURL(new Blob([o],{type:na})),a=await Hc(i);t={mimeType:e??na,naturalDimensions:a,asUrl:i,asSVGText:o}}catch{}};if(e===na?await r():e.startsWith("image/")?await n():(await n(),t||await r()),!t)throw new Error("Failed to load image");return t}},Symbol.toStringTag,{value:"Module"}));function Ws(s,e){e||(e={}),typeof e=="function"&&(e={cmp:e});let t=typeof e.cycles=="boolean"&&e.cycles;const n=e.cmp&&function(o){return function(i){return function(a,l){const c={key:a,value:i[a]},h={key:l,value:i[l]};return o(c,h)}}}(e.cmp);let r=[];return function o(i){if(i&&i.toJSON&&typeof i.toJSON=="function"&&(i=i.toJSON()),i===void 0)return;if(typeof i=="number")return isFinite(i)?""+i:"null";if(typeof i!="object")return JSON.stringify(i);let a;if(Array.isArray(i)){a="[";for(let h=0;h<i.length;h++)h&&(a+=","),a+=o(i[h])||"null";return a+"]"}if(i===null)return"null";if(r.indexOf(i)!==-1){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const l=r.push(i)-1,c=Object.keys(i).sort(n&&n(i));a="";for(let h=0;h<c.length;h++){const u=c[h],d=o(i[u]);d&&(a&&(a+=","),a+=JSON.stringify(u)+":"+d)}return r.splice(l,1),"{"+a+"}"}(s)}var Vc;exports.it=void 0,(Vc=exports.it||(exports.it={})).resolveTypedUpdates=(s,e,t,n)=>{if(s===null)return s;if(s===void 0)return n;let r=s;if(e?.shorthand){const l=e?.shorthand(s,t);l!==void 0&&(r=l)}if(r!==null&&e?.getSubType){const l=e.getSubType(r);l&&(e=l)}const o=e?.properties,i=e?.arrayType??!1;let a=r;if(e&&e.merge&&a&&n)a=e.merge(a,n,t);else if(!i&&o){const l=Object.keys({...r,...n});a=null;for(let c=0;c<l.length;c++){const h=l[c];let u,d=r[h];if(d!==void 0){const g=o[h];u=g?(0,Vc.resolveTypedUpdates)(d,g,t,n?.[h]):d}else u=n?.[h];u!=null&&(a=a??{},a[h]=u)}}return a};class Ur extends Error{constructor(e,t=null){super(e,t),this.name="ChainedError",this._cause=t}get cause(){return this._cause}}class wg extends Ur{constructor(e="Partial Error",t=null){super(e,t)}}class ke extends wg{constructor(e="Out of bounds",t=null){super(e,t),this.name="OutOfBoundsError"}}class yg extends Ur{constructor(e="Partial Error",t=null){super(e,t)}}class Dt extends Ur{constructor(e="Null not supported",t=null){super(e,t)}}class Cl extends Error{constructor(e="Null not supported",t){super(e),this._type=t}get type(){return this._type}}class tc extends Ur{constructor(e="Not implemented",t=null){super(e,t)}}const $c=`The Safari browser does not support advanced copy and paste.
7
+ Copy and paste will be limited to within the browser tab.
8
+
9
+ Please use Chrome or Edge if external copy and paste is required.`,ra=`You do not have permissions to access the clipboard.
10
+ All copy and paste operations will be limited to the browser tab.`,Cg={Safari:`The Safari browser does not support advanced copy and paste.
11
+ Copy and paste will be limited to within the browser tab.
12
+
13
+ Please use Chrome or Edge if external copy and paste is required.`,Perms:ra,PermsWrite:jo()===mt.Safari?$c:ra,PermsRead:jo()===mt.Safari?$c:ra},oa=async()=>new Promise(s=>{document.hasFocus()?s():globalThis.addEventListener?.("focus",()=>{s()},{once:!0}),document.activeElement.focus?.()}),sa=async(s,e,t)=>{if(jo()===mt.Safari)return await t(new Error(Cg.Safari));try{const n=async i=>{try{return await i()}catch(a){if(a.message?.includes("Document is not focused"))return!1;throw a}},r=await globalThis?.navigator?.permissions?.query({name:s,allowWithoutGesture:!0,allowWithoutSanitization:!0});let o=!1;if(r.state==="prompt"&&(o=await n(e)),o||r.state!=="granted"||(o=await e()),!o)return await t(new Error(r.state))}catch(n){return n.message==="No valid data on clipboard"||n.name==="DataError"?void 0:await t(n)}},bg=async s=>{try{return await s.read({unsanitized:[Te.html]})}catch{}return await s.read()},Eg=async(s,e)=>{if(!s)return null;const t=await bg(s);let n=!1;for(let r=0;!n&&t&&r<t.length;r++)if(n=t[r].types.includes(e),n)return await t[r].getType(e);return n?void 0:null};if(!globalThis.ClipboardItem){const s=(t,n)=>new Blob([n],{type:t});class e{constructor(n,r){this._items={},this._types=Object.keys(n);const o={},i=Object.keys(n);for(let a=0;a<i.length;a++){const l=i[a];let c=n[l];o[l]=typeof c=="string"?s(l,c):c}this._items=o,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(n){return Promise.resolve(this._items[n])}supports(n){return!0}}globalThis.ClipboardItem=e}const Si=async(s,e=Te.html)=>new Promise(async(t,n)=>{try{const r=await Eg(s,e);if(r){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{t("")},o.readAsText(r)}else t("")}catch(r){n(r)}}),bl=async(s,e=Te.html)=>{const t=await Si(s,e);if(!t)return null;let n=null;try{n=new DOMParser().parseFromString(t,Te.html)}catch{console.warn("Can't parse html from clipboard.")}return n},vg=async s=>{s&&await s.writeText("")},Xf={readBlobFromClipboard:Eg,readStringFromClipboard:Si,readHTMLFromClipboard:bl,clearClipboard:vg},Wo="clipboard-uuid",dr="web text/uuid",Gc=s=>`<div style="display:none" ${Wo}="${s}"/>`,Kf=(s,e)=>{let t=null;try{const n=new DOMParser().parseFromString(e,Te.html);n.body.firstElementChild.setAttribute(Wo,s),t=n.getElementsByTagName("body")[0].innerHTML}catch(n){console.warn("Can't embed uuid.",n)}return t},Uc=(s,e)=>{if(!e||!s)return!1;try{const t=e.querySelectorAll(`[${Wo}="${s}"]`);if(t&&t.length===1)return!0;if(e.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};class El{constructor(e){if(e?.nativeClipboard===void 0||e?.nativeClipboard===!0)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{e?.nativeClipboard===!0&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=e?.nativeClipboard===!1?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await sa("clipboard-read",async()=>{await oa();const e=await Si(this._nativeClipboard,dr);if(!this._state||e&&e===this._state.uuid)return!0;const t=await bl(this._nativeClipboard,Te.html);return!this._state||(Uc(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||jo()===mt.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await sa("clipboard-read",async()=>{if(await oa(),this._state?.uuid){const t=await Si(this._nativeClipboard,dr);if(t&&t===e._state.uuid)return!0;const n=await bl(this._nativeClipboard,Te.html);if(Uc(e._state?.uuid,n))return!0}return e._state={items:await bg(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:js(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],r=e.uuid;let o=e.items??[];const i=()=>{t._state={uuid:r,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await sa("clipboard-write",async()=>{await oa(),r&&o.length===0&&(o.push(new ClipboardItem({[dr]:new Blob([r],{type:dr})})),o.push(new ClipboardItem({[Te.html]:new Blob([Gc(r)],{type:Te.html})})));for(let a=0;a<Math.min(1,o.length);a++){const l=o[a];let c=l.types.indexOf(Te.html),h=null;if(c!==-1){const g=await l.getType(Te.html);h=await yl(g),h&&(h=Kf(r,h))}if(!h&&l.types.includes(Te.plain)){const g=await l.getType(Te.plain);if(g){let m=null;typeof g=="string"?(console.warn("text as string",g),m=g):m=await yl(g),m&&(h=`<div ${Wo}="${r}">${m}</div>`)}}if(!h&&l.types.includes(Te.png)){const g=await l.getType(Te.png),m=pg(await g.arrayBuffer());h=`<div ${Wo}="${r}"><img src="${_g+m}"/></div>`}!h&&r&&(h=Gc(r));const u=new Blob([h??""],{type:Te.html}),d={};for(let g=0;g<l.types.length;g++){const m=l.types[g];d[m]=g===c?u:l.getType(m)}h&&c===-1&&(d[Te.html]=u),r&&(d[dr]=new Blob([r],{type:dr})),n.push(new ClipboardItem(d))}try{n&&n.length!==0?await this._nativeClipboard.write(n):await vg(this._nativeClipboard)}catch(a){a.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",a)}return i(),!0},async a=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const o=await e.toText?.()??null;o&&(n[Te.plain]=new Blob([o??""],{type:Te.plain}))}catch(o){t=o}try{const o=await e.toHtml?.()??null;o&&(n[Te.html]=new Blob([o],{type:Te.html}))}catch(o){t=o,console.warn("export to html",o)}try{const o=await e.toImage?.()??null;o&&(n[Te.png]=o)}catch(o){t=o,console.warn("export to png",o)}const r=this._write({uuid:js(),ref:e,items:Object.keys(n).length>0?[new ClipboardItem(n)]:null});if(t)throw t;return r}clear(e=!1){this._state&&(this._state=null,e&&this._write({uuid:null,ref:null,items:null}),this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")))}async readReference(){return await this.read(),this._state?.ref??null}readText(){return new Promise(async(e,t)=>{const n=await this.read();let r=null;for(let i=0;!r&&n&&i<n.length;i++)n[i].types.includes(Te.plain)&&(r=await n[i].getType(Te.plain));if(!r)return void e("");const o=new FileReader;o.onload=()=>{e(o.result)},o.readAsText(r),o.onerror=i=>{t(i)}})}async writeText(e){const t=[new ClipboardItem({[Te.plain]:new Blob([e],{type:Te.plain})})];return this._write({uuid:js(),items:t,ref:null})}addEventListener(e,t,n={}){const r=n?.capture?this._listenersCapture:this._listeners;let o=r.get(e);o||(o=new Map,r.set(e,o)),o.set(t,typeof n=="boolean"?{}:n)}dispatchEvent(e){if(!e)return;const t=n=>{const r=n.get(e.type);r&&r.forEach((o,i)=>{try{typeof i=="function"?i(e):i.handleEvent&&i.handleEvent(e),o.once&&r.delete(i)}catch(a){console.warn(a)}})};return t(this._listenersCapture),t(this._listeners),!0}removeEventListener(e,t,n){const r=n?.capture?this._listenersCapture:this._listeners,o=r.get(e);o&&(o.delete(t),o.size===0&&r.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}}var ia;(ia=El||(El={})).ErrorMessages=Cg,ia.Global=new ia;class qc{constructor(e=100){this._maxStack=e,this._undoStack=[],this._redoStack=[],this._repeatOperation=null,this._listeners=new Set}get maxStack(){return this._maxStack}undo(e=1){if(this._undoStack.length===0)return;let t=!1;try{for(let n=0;n<e&&this._undoStack.length>0;n++){const r=this._undoStack[this._undoStack.length-1];r.redo=r.undo(),this._undoStack.pop(),typeof r.redo=="function"?this._redoStack.push(r):this._redoStack=[],t=!0}}catch(n){throw n}finally{t&&this._notifyOnStackChange()}}redo(e=1){if(this._redoStack.length===0)return void(this._repeatOperation!==null&&this._repeatOperation.repeat());let t=!1;try{for(let n=0;n<e&&this._redoStack.length>0;n++){const r=this._redoStack[this._redoStack.length-1];r.redo(),this._redoStack.pop(),this._undoStack.push(r),t=!0}}catch(n){throw n}finally{t&&this._notifyOnStackChange()}}hasUndo(){return this._undoStack.length>0}getTopUndoDescription(){return this._undoStack.length===0?null:this._undoStack[this._undoStack.length-1].description}hasRedo(){return this._redoStack.length>0||this._repeatOperation!==null}getTopRedoDescription(){return this._repeatOperation!==null?this._repeatOperation.description:this._redoStack.length===0?null:this._redoStack[this._redoStack.length-1].description}getUndoDescriptions(){if(this._undoDescriptions)return this._undoDescriptions;const e=[];for(let t=this._undoStack.length-1;t>=0;t--)e.push(this._undoStack[t].description);return this._undoDescriptions=e,this._undoDescriptions}getRedoDescriptions(){if(this._redoDescriptions)return this._redoDescriptions;const e=[];for(let t=this._redoStack.length-1;t>=0;t--)e.push(this._redoStack[t].description);return e.length===0&&this._repeatOperation!==null&&e.push(this._repeatOperation.description),this._redoDescriptions=Object.freeze(e),this._redoDescriptions}addUndoOperation(e){const t={description:e.description,undo:e.undo,redo:null};this._undoStack.push(t),this._redoStack=[],this._undoStack.length>this._maxStack&&this._undoStack.shift(),this._notifyOnStackChange()}setRepeatableOperation(e){this._repeatOperation=e??null,this._redoStack=[],this._notifyOnStackChange()}clear(e=!0){this._undoStack=[],this._redoStack=[],this._repeatOperation=null,this._undoDescriptions=null,this._redoDescriptions=null,e&&this._notifyOnStackChange()}addListener(e){const t=this._listeners;return t.add(e),()=>{t.delete(e)}}_notifyOnStackChange(){this._undoDescriptions=null,this._redoDescriptions=null,this._listeners.forEach(e=>{e.onStackChange?.()})}}const Jc=(s,e)=>{const t=new Map;return s.forEach((n,r)=>{e.get(r)!==n&&t.set(r,n)}),t};let Xc=!1;class Kc{constructor(e){this._record=e}getId(){return this._record.id}getDescription(){return this._record.description}getMeta(){return Object.freeze(this._record.meta)}getAuthor(){return this._record.author}getTimestamp(){return this._record.timestamp}getOperation(){return this._record.operation}}class Lt{constructor(e){this._listeners=new Set,this._listenersState=new Map,this._commits=new Map,this._locked=!1,this._current=null,this._pending=null,this._isSync=e?.sync??Xc,this._isTransient=e?.transient??!1,this._author=e?.author;const t={id:"0",description:"initial",meta:{},author:this._author,timestamp:Date.now(),states:new Map,version:0,previousId:null},n={record:t,commit:new Kc(t)};this._current=n,this._cacheModel=null,this._cacheState=null,this._states=t.states,this._transactionStack=[],this._transactionOpen=!1;const r=new Map;r.set(t.id,n),this._commits=r}static{this.setDefaultSync=e=>{Xc=e}}getLog(e,t=100){const n=[];let r=e;do{const o=this._commits.get(r);if(!o)throw new Error(`Invalid commit id: '${r}'`);if(n.push(o.commit),r=o.record.previousId,!r)return n}while(n.length<t)}getCommitCount(){return this._commits.size}isOpenTransaction(){return this._transactionStack.length>0||this._transactionOpen}getPendingView(){const e=this._transactionStack;return e.length>0?e[0].getView():null}getState(e){const t=this._transactionStack;if(t.length===0){if(this._cacheModel===e)return this._cacheState;const n=this._states.get(e);return this._cacheModel=e,this._cacheState=n,n}return t[t.length-1].getState(e)}getCurrentCommit(){return this._pending?.commit??this._current.commit}restore(e,t){const n=this._getCommitContainer(e,t);if(this._current.commit.getId()===n.commit.getId())return n.commit;let r;t?.viewId&&t?.viewId!=="custom"||(r=n.record.viewAfter);const o=Jc(n.record.states,this._current.record.states);this._notifyStates("onBeforeCommitStart",this._current,o,r,!0,!1),this._current=n,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,this._notifyStates("onAfterStateChange",n,o,r,!1,!0,!0),this._notify("onCommitChange",n.commit,!0),this._transactionOpen=!0;try{this._notifyStates("onRestoreOrRevert",n,n.record.states,r,!1,!0)}finally{this._transactionOpen=!1}return n.commit}revert(e,t){const n=this._getCommitContainer(e,t),r=this._commits.get(n.record.previousId);if(!r)throw new Error(`Invalid commit id: '${n.record.previousId}'`);let o;t?.viewId&&t?.viewId!==" custom"||(o=n.record.viewBefore??n.record.viewAfter);const i=Jc(r.record.states,this._current.record.states);this._notifyStates("onBeforeCommitStart",this._current,i,o,!0,!1),this._current=r,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,this._notifyStates("onAfterStateChange",r,i,o,!0,!1,!0),this._notify("onCommitChange",r.commit,!0),this._transactionOpen=!0;try{this._notifyStates("onRestoreOrRevert",r,r.record.states,o,!0,!0)}finally{this._transactionOpen=!1}return r.commit}_getCommitContainer(e,t){const n=this._commits.get(e);if(!n)throw new Error(`Invalid commit id: '${e}'`);if(this._isTransient)throw new Error("Cannot revert transient store");if(t?.force&&this._transactionStack.length>0&&this._transactionStack[0].rollback(),this._transactionStack.length!==0)throw new Error("Open transactions.");return n}_pruneForwards(e){}beginCommit(e,t){const n=this._transactionStack,r=n.length;if(this._locked)throw console.warn("TransactionStore locked",n),new Error(`TransactionStore is locked by '${n[r-1].getDescription()}`);const o=e?.preventFurtherTransactions,i=this,a=(c,h,u)=>{const d=i._transactionStack;r!==d.length-1&&console.warn("Transaction stack out of sync",r,d.length,d),o&&(this._locked=!1),d.pop(),t?.(c,h,u),d.length===0&&(i._pending=null)};let l;if(n.length===0){const c=this._current.record,h={states:new Map,id:F.uuidV4(),description:typeof e=="string"?e:e?.description??null,meta:{},timestamp:Date.now(),author:null,version:c.version+1,previousId:c.id,viewBefore:null,viewAfter:{},operation:e?.operation},u={record:h,commit:new Kc(h)};this._pending=u,this._notify("onCommitStart",u.commit),l=new Yf(this,u,c?.states,e,a)}else l=n[n.length-1].beginTransaction(e,a);return o&&(this._locked=!0),this._transactionStack.push(l),l}doBatch(e,t,n){let r;const o=this.beginCommit(t,n),i=this.getCurrentCommit();try{r=e?.(i);const a=()=>{o.commit(t)};if(r&&typeof r.then=="function")return new Promise((l,c)=>{r.then(h=>{try{a(),l(h)}catch(u){c(u)}}).catch(h=>{o.rollback(),c(h)})});a()}catch(a){throw o.rollback(),a}return r}remove(e){return!!e}addListener(e){const t=this._listeners;return t.add(e),()=>{t.delete(e)}}addStateListener(e,t){if(!e)throw new Error("Model is required");if(!t)throw new Error("Listener is required");let n=this._listenersState.get(e);return n||(n=new Set,this._listenersState.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this._listenersState.delete(e)}}dispatchEvents(e,t=!1){!t||this._isSync?e():setTimeout(e,0)}_commitRecord(e,t,n){let r=e.record,o=e.commit;if(!this._isTransient){if(n){const i=this._commits.get(r.previousId);if(i){r.previousId=i.record.id;const a=i.record,l=a.states;l&&r.states.forEach((c,h)=>{l.set(h,c)}),a.viewAfter={...a.viewAfter,...r.viewAfter},a.meta={...a.meta,...r.meta},a.timestamp=r.timestamp,r=a,o=i.commit,e={record:r,commit:o}}}this._commits.set(r.id,e)}this._current=e,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,n||this._notify("onCommitChange",o),this._notifyStates("onAfterStateChange",e,t,e.record.viewAfter,!1,!1,!0),n||this._notify("onCommitEnd",o,!0)}_notifyStates(e,t,n,r,o=!1,i=!1,a=!1){const l=t.commit,c=this._listenersState;n.forEach((h,u)=>{const d=c.get(u);d&&this.dispatchEvents(()=>{d.forEach(g=>{g[e]?.(h,r,l,o,i)})},a)})}_notify(e,t,n=!1){this.dispatchEvents(()=>{this._listeners.forEach(r=>{r[e]?.(t)})},n)}}class xg{constructor(e,t){this._children=new Set,this._depth=0,this._container=null,this._closed=!1,this._container=e,t=typeof t=="string"?{description:t}:t,this._description=t?.description??"",t?.viewBefore!==void 0&&(e.record.viewBefore=e.record.viewBefore&&t.viewBefore?{...e.record.viewBefore,...t.viewBefore}:t.viewBefore),t?.viewAfter!==void 0&&(e.record.viewAfter=e.record.viewAfter&&t.viewAfter?{...e.record.viewAfter,...t.viewAfter}:t.viewAfter)}getView(){return this._container.record.viewAfter??this._container.record.viewBefore}getDepth(){return this._depth}getDescription(){return this._description}getStates(){return this._states}beginTransaction(e,t){this._ensureOpen();const n=new Qf(this,this._container,typeof e=="string"?{description:e}:e,t);return this._children||this._children,this._children.add(n),n}updateState(e,t){this._ensureOpen();const n=this.getState(e),r=typeof t=="function"?t(n):t===void 0?n:{...n,...t};if(r){let o=this._states;o||(o=new Map,this._states=o),o.set(e,r)}return r}commit(e){if(this._ensureOpen(),typeof e=="string"&&(e={description:e}),e){if(e.description&&(this._description=e.description),e.meta&&(this._meta=F.mergeContentful(e.meta,this._meta)),e.viewAfter!==void 0){const t=this._container.record;let n=e.viewAfter;if(n===null)t.viewAfter=null;else{const r=t.viewAfter;typeof n=="function"&&(n=n(r)),t.viewAfter={...r,...n}}}if(e.viewBefore!==void 0){const t=this._container.record;let n=e.viewBefore;if(n===null)t.viewAfter=null;else{const r=t.viewBefore;typeof n=="function"&&(n=n(r)),t.viewBefore={...r,...n}}}}return this._children&&this._children.forEach(t=>{t.commit(e)}),this}isClose(){return this._closed}_ensureOpen(){if(this._closed)throw this._descriptions&&console.warn(`stack: [${this._descriptions.join(",")}]`),new Error("Transaction already closed")}_removeChild(e){this._children.delete(e),this._mergeStates(e._states)}_mergeStates(e){if(!e||e.size===0)return;let t=this._states;return t?(e.forEach((n,r)=>{const o=this.updateState(r,n);t.set(r,o)}),t):(this._states=e,e)}}class Yf extends xg{constructor(e,t,n,r,o){super(t,r),this._store=e,this._prevStates=n,this._onClose=o,this._states=new Map,this._meta=t.record.meta}getId(){return this._container.commit.getId()}getParent(){return this}commit(e){const t=this._states,n=this._container,r=n.record.viewAfter;this._store._notifyStates("onBeforeCommitStart",n,t,r,!1,!1),super.commit(e),this._store._notifyStates("onBeforeCommitEnd",n,t,r,!1,!1);const o=new Map(this._prevStates);return this._states.forEach((i,a)=>{i===null?o.delete(a):o.set(a,i)}),this._states=o,this._description&&(n.record.description=this._description),this._meta&&(n.record.meta=this._meta),n.record.states=o,this._closed=!0,this._onClose?.(this,!1,e),this._store._commitRecord(n,t,e?.forceAmend??!1),this}rollback(){return this._ensureOpen(),this._children&&this._children.forEach(e=>{e.rollback()}),this._closed=!0,this._onClose?.(this,!0,null),this}updateState(e,t){const n=super.updateState(e,t);return this._states.set(e,n),n}getState(e){let t=this._states.get(e);return t||(t=this._prevStates.get(e)),t}_mergeStates(e){return!e||e.size===0?new Map:super._mergeStates(e)}}class Qf extends xg{constructor(e,t,n,r){if(super(t,n),!e)throw new Error("Parent transaction required");this._parent=e,this._depth=this._parent.getDepth()+1,this._onClose=r}getId(){return this._parent.getId()}getParent(){return this._parent}getState(e){const t=this._states?this._states.get(e):void 0;return t!==void 0?t:this._parent.getState(e)}commit(e){return super.commit(e),this._parent._removeChild(this),this._closed=!0,this._onClose?.(this,!1,e),this._parent??this}rollback(){return this._ensureOpen(),this._children&&this._children.forEach(e=>{e.rollback()}),this._parent._removeChild(this),this._closed=!0,this._onClose?.(this,!0,null),this._parent??this}}const Ig=()=>{try{return"0.4.19"}catch{return""}},mn=Object.freeze(Object.defineProperty({__proto__:null,getBuildDate:()=>{try{return"Tue Aug 12 2025"}catch{return""}},getBuildVersion:Ig},Symbol.toStringTag,{value:"Module"})),Zf=`
14
+ https://www.sheetxl.com ${Ig()}`,aa="#1976d2",ep=()=>typeof window=="object"?window.location.hostname:F.getOS(),gr=Object.freeze(Object.defineProperty({__proto__:null,generateNodeId:async()=>"0",getKey:async()=>{throw new Error("getKey is not implemented in browser environment")},printBanner:async s=>{const e=s?console.log:F.consoleWithNoSource,t=`%c
15
+ ███████╗██╗ ██╗███████╗███████╗████████╗ ██╗ ██╗██╗
16
+ ██╔════╝██║ ██║██╔════╝██╔════╝╚══██╔══╝ ╚██╗██╔╝██║
17
+ ███████╗███████║█████╗ █████╗ ██║ ╚███╔╝ ██║
18
+ ╚════██║██╔══██║██╔══╝ ██╔══╝ ██║ ██╔██╗ ██║
19
+ ███████║██║ ██║███████╗███████╗ ██║ ██╔╝ ██╗███████╗
20
+ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝${Zf}
21
+ `;return await e(`${t}`,`font-family:monospace;color:${aa};font-size:12px;`),Promise.resolve()},printDetails:async(s,e=!1,t=!1,n=!1)=>{let r;const o=console.log,i=[`color:${aa};font-size:12px`];if(s.isEval()?(i.push(`font-family:monospace;color:${aa};font-size:12px;`),r="%cEvaluation Only",i[0]="color:#E12929;font-size:12px",r+=`%c
22
+ Please visit https://my.sheetxl.com to register.`):(r=`%cLicensee: ${s.licensee()??"Invalid License"}
23
+ `,r+=`Expires: ${s.expiration()?.toLocaleDateString()??"Never"}`,s.domains()&&s.domains().length>0&&(r+=`
24
+ Domains: ${s.domains().join(", ")}`),s.cpuCount()>0&&(r+=`
25
+ Cpus: ${s.cpuCount()}`)),!n&&s.exceptions().length>0){i.push("color:red;font-size:12px"),r+=`
26
+ Exceptions:
27
+ %c`;for(let a=0;a<s.exceptions().length;a++)r+=` ${s.exceptions()[a]}`}return t&&(i.push("color:#FFA726;font-size:12px"),r+="%c",r+=`
28
+ Location: '${ep()}'`,r+=`
29
+ KeyFrom: '${s.keyFrom()}'`),await o(`${r}`,...i),Promise.resolve()},setKey:async(s,e=!1)=>{throw new Error("setKey is not implemented in browser environment")}},Symbol.toStringTag,{value:"Module"})),tp=(s,e,t=126)=>((n,r,o=126)=>{let i=n.split("");for(let a=0;a<i.length;a++)i[a].charCodeAt(0)<=o&&(i[a]=String.fromCharCode((i[a].charCodeAt(0)+r)%o));return i.join("")})(s,t-e),np=s=>typeof window=="object"?window.atob(s):Buffer.from(s,"base64").toString("ascii");function Ht(s,e,t,n,r){return we(n- -372,t)}function en(s,e,t,n,r){return we(e-653,s)}(function(){const r="v(5$",o="I[4M",a="xo]S",l="Vc1c",c="O!Lv",u="PXJ@",m=nc();function f(y,b,w,E,x){return we(E-212,b)}function _(y,b,w,E,x){return we(x- -883,w)}function p(y,b,w,E,x){return we(E-256,b)}function S(y,b,w,E,x){return we(b- -197,y)}function C(y,b,w,E,x){return we(y-774,x)}for(;;)try{if(parseInt(f(0,"ltf6",0,793))/1*(-parseInt(f(0,"FVnZ",0,849))/2)+-parseInt(C(1280,0,0,0,"!jhC"))/3*(parseInt(C(1344,0,0,0,r))/4)+parseInt(p(0,o,0,725))/5+-parseInt(S(a,346))/6+-parseInt(S("2t8s",416))/7*(parseInt(p(0,l,0,895))/8)+parseInt(p(0,c,0,810))/9*(-parseInt(_(0,0,"O!Lv",0,-282))/10)+parseInt(C(1416,0,0,0,u))/11===729925)break;m.push(m.shift())}catch{m.push(m.shift())}})();const wi=()=>{const t="iJs!";if(typeof window===c(1218,1236,1320,1288,"O!Lv"))return window[c(1103,1029,1071,1077,"AGJ0")][o=1252,i=t,we(o-766,i)];var o,i,a,l;function c(h,u,d,g,m){return we(h-608,m)}return F[a="AGJ0",l=1429,we(l-865,a)]()},vl=()=>{return wi()[r=1202,o="pY50",we(r-606,o)](we(566,"CjxI"))||wi()===we(600,"AGJ0");var r,o};function we(s,e){const t=nc();return we=function(n,r){let o=t[n-=445];if(we.vgkpaN===void 0){const l=function(c,h){let u,d,g=[],m=0,f="";for(c=function(_){let p="",S="";for(let C,y,b=0,w=0;y=_.charAt(w++);~y&&(C=b%4?64*C+y:y,b++%4)?p+=String.fromCharCode(255&C>>(-2*b&6)):0)y="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(y);for(let C=0,y=p.length;C<y;C++)S+="%"+("00"+p.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(S)}(c),d=0;d<256;d++)g[d]=d;for(d=0;d<256;d++)m=(m+g[d]+h.charCodeAt(d%h.length))%256,u=g[d],g[d]=g[m],g[m]=u;d=0,m=0;for(let _=0;_<c.length;_++)d=(d+1)%256,m=(m+g[d])%256,u=g[d],g[d]=g[m],g[m]=u,f+=String.fromCharCode(c.charCodeAt(_)^g[(g[d]+g[m])%256]);return f};we.fZskqK=l,s=arguments,we.vgkpaN=!0}const i=n+t[0],a=s[i];return a?o=a:(we.KNqAmP===void 0&&(we.KNqAmP=!0),o=we.fZskqK(o,r),s[i]=o),o},we(s,e)}function Mt(s,e,t,n,r){return we(n- -500,t)}function tn(s,e,t,n,r){return we(s-718,n)}const rp=(s,e,t,n)=>{const r="YHjd";function c(g,m,f,_,p){return we(f-391,p)}function h(g,m,f,_,p){return we(f-454,m)}return{licensee:()=>s[c(0,0,947,0,"M8nP")],expiration:()=>{return new Date(s[g=1041,m="PXJ@",we(g-563,m)]);var g,m},domains:()=>s[c(0,0,971,0,"MNbA")]??[],developerCount:()=>s[c(0,0,844,0,"TJO$")]??1,cpuCount:()=>s[c(0,0,1036,0,"pY50")]??0,type:()=>s[c(0,0,1025,0,"2t8s")]??h(0,"dVC#",1009),exceptions:()=>e,isValidFor:g=>{if(e?.[m="I[4M",f=1366,c(0,0,f-418,0,m)]>0)return!1;var m,f;return!0},isValid:()=>!0,isEval:()=>!1,features:()=>{return Object[c(0,0,880,0,"ltf6")](s[g=-97,m="Y3wQ",we(g- -606,m)]??{});var g,m},keyFrom:()=>t,getBuildVersion:mn[h(0,"8z[X",1080)],getBuildDate:mn[u=r,d=589,we(d- -9,u)]};var u,d},Yc=s=>{const e="Vc1c",n="60SN",r="Vc1c",i="Drr5",a="dVC#",c="M8nP";function g(C,y,b,w,E){return we(w-183,y)}function m(C,y,b,w,E){return we(b-363,y)}function f(C,y,b,w,E){return we(w-512,y)}let _=F[g(0,"x[e(",0,671)];if(vl()||F[g(0,e,0,664)]()){const C=mn[g(0,"iBYB",0,792)](),y=new Date(C),b=new Date;Math[S(n,-142,-124)]((b[f(0,r,0,978)]()-y[p("UqGm",703,696,739)]())/864e5)>=120&&(_=[S(i,-128,-121)])}else _=[m(0,a,848)];function p(C,y,b,w,E){return we(w-289,C)}function S(C,y,b,w,E){return we(b- -746,C)}return{licensee:()=>p("ma!H",0,0,897),expiration:()=>null,domains:()=>[wi()],developerCount:()=>1,cpuCount:()=>0,type:()=>p("HeCB",0,0,819),isEval:()=>!0,exceptions:()=>_,isValidFor:()=>_[f(0,"KT8I",0,960)]===0,isValid:()=>!1,features:()=>Object[m(0,"dVC#",870)]({}),keyFrom:()=>s,getBuildVersion:mn[S("luX[",0,-119)],getBuildDate:mn[S(c,0,-244)]}},Ne={promise:null,details:null,bannerPrinted:!1,detailsPrinted:!1,licenseKey:null,keyFrom:null};let la=!1,Qc=!1;function Zr(s,e,t,n,r){return we(e- -164,s)}function nc(){const s=["W6FcIJ1c","WR04W7pcJSk0","W6RdIaqTWP8XobFdJxL0W5q","FcBcSxzaWRJdRmkwW4a","umkPWO0BW7ddLCk/","t8kWW5VdH3yRW5S","W4qZnCkhWOjewa","WQFdPmoIqmkNov7dG8oNW40TA2e","WRXYgMm/jq","W6BcPmkXc8oREd3dQmo2W6W","W4RcPSkXfCo2BWVdTCoN","WPFcNCoMWQBdItisoJ5S","W4pdImoABSknuLRdSCk5W7G","W69ti1Dyffq","WQfKlhG","sCkmi2NcSeyHCSkvWOvtomk6pG","W7uvrNCvW7KjtSoY","WRfUow0YlSog","WPNcL8kppCotffBdVCkgW6FdH2i","mgiRcwL3W54","BHpdHstdGHldSbi","ySk7W5NdH3mUW4ZcQWG+kYBdRgPWWRJcRSoVwrm","zCoTpSkfn8oIW6/cNmkJwuD1dxW+xt9LW5q","WPLOn2K1m8oqvSoAoCoqBd3cVgFcVmofW5bpW6KDfq8lpX/cMmoZW5i","W7ddKColySknvq","D2BcLu8Qoq","W57cKtHlaSk3cCoVehG4rcFdNINcVmopWOm","W6TQWQ/dOwfkW4a3W6BdJa","FSkHeK3cJxiE","ve7cHcXNccFdJCowzW","ASkeWQCZEGzPW77cNeRdL8kCtmk7d381pf1rhd8TWRFcUmoKAq","W4q0kCkc","WP/dGK0qmMq/WR51WQK1WP4zWQCwnv1dW4C","W5eVpSkzWRXEsvm","WOGCW7eUWQGk","W40VqKCpW6qkDCoPaLOG","W7lcTCkKo8oQyGBdPCouW6euCe/cRSkR","W6TVWRddR8oxWO5PfrS","W5BcRGq3WRPjWORdIHS","mSk3WOX6W6ldI8k/hSoIgCk1nHyVW5FdRIpcPW4t","W6NdNdu6W4tcKmoxWRSUumoY","WQ4VW67cRa","WQewWQuhWRGAoKHpixPZ","x8kPWOa8W6VdLSkHW5pcOSk7W557hCoq","uSk/WReRW6pdLG","WOrMfsBdJY7cK0FcGbTcvWy0DHLoWQm","rmkpWQuqyWzHWRRcLeldGmkC","WOVdTv4RWP1T","WOJcGHFdNCk4CbVcPxTIDseh","n8kqbh7dU8khnW","AKpdSSkZW5lcNSovDgu","W5n5WRRdIw1AW4aQW68","WQVdR3Wra0GsWOHvWPm","jmoxFCosWPKcW4VcS8oXnmoaWRal","WQJcHXpcO8ooWRdcJConv8o3","kmkcpMRdSSkOjq","W6tcIY9Eg8kT","sCkmi2NcSeyH","W7pcKcnlb8kWhG","WQVcKX/cQCom","ifC9W54Nnmoby8o/WPVdVJ/dUG","aCohoNu","W7ZdM8otWPlcMSkud8o1W5iZWPX6W4PHmZipD8oUhL0jWQZdKvK","W5ddRcXgwComW6FcL0JcQSkvWQJdLSkPW7C","oCkgjL3dOSkhpXvoW5GzamkFsSkB","FSk6WPuXWQldTSk7W6dcTCk8W4nQwmo/brO","w8kio33cVgWK","W7lcHZ5dhmkN","W4JcIs9gb8k6dmk7ea","W7lcKtG","ocjXW5mcFW","lWJcTmkG","WPFcNGtdImkKzG3cNu5P","x8kNW4BdH3m","g8olgmkclSowW58","ivK9W5yRiCoczCo5WOFdRW","oSkxWQpdT8oiW4VdUqxdLsbH","WPHZbNW+W50PqSoK","rYpcQSo+oG","arldHvGWs37cLCo5zSoAW63dHcW","hxCQd2T1W7Kdi8k4omkm","DmkLW53dJ3eZ","W5CXl8kPWOrcu08","BfVcGGfScatdHCouESoWW5O","WQv0j2q","W6BdJ8opASkpsfVcMSk4W67dVwiIWOO","W5nqWQVdL2TkW44bW5u","awfED0LomLpdUmo+BbJdNbiDh04vCq","zmoCW4H6WPDAW5G","rchcQCo6j8kMFa","wdBcQmoWoSk9","W5ZdRcfcxSokW6y","tmkWW5VdSNyQW40","WRldHmkTW4tcIZlcQcmLB3pcRmoiw8kdxI/cLgq","hmk8WO5zW7VdI8k3wSokeCkInG","BbpdKJxdMW/dPqruW6NcP8oFt8kt","WQtcQ8o1WRhdIduylGq","WRj1aahdNZy","BCkfW7e3BH9KWQZcSvFdNCkwta","ndXEW5ukoG","W5ldNqipWPq8","t8kWW5VdH3yRW5VdMXy+jJFdP30","W4RdMCotWOZcM8kglmo1W4K1","vWBdLJNdMrtdKqrsW4VcOCoguG","WO/dJSo5W6tcIZlcQcmLBXJcUCod","W7zsaLvvaG","WQtcHmo3WQRdItuZfc90WP/cKZK","WOVcHqJdGmkJzG0","B8ofW6dcKmkxW6xdSG","ESk/W6RcLfVcGq","qfVcNaf2","rdakkWqaBM/dSmoWDW/dPG","WOJdSLOPWOPX","A3KMWOXEASotW5rcWR7cJGS","imoJWRxdIHBdN1b9W5xdTr/cRWW","WOz4B8oAW5KabqRcSmkNW6HpW51D","sNFcIuGHp8oFW7hdO8ozBCkUWRG","W5ddLGasWPa3","WQHJiIVdLIBcGW","dmogFmoRWOuFW6hcOSoGmq","vLpcGafWbq","kbNcOCkGW4xcTSoC","WP/dGSoHWOBcJINcUsGZyIa","yCotW5RcQ8kAW60","yCotW5hcSSkFW6q","WOtcJer9W4L2aXddR3rbW6q","W4bxlvzya1a2sW","DgFdTgZdPgHTqg3dHgBcVXVdNmoi","W53dLWuWWP8KfXm","wCkTWPOZW6FdImkcW7hcUCk8W4rQha","WRNdHSo9W5ZcMXdcVZ83CW","W4NdK8oCBSkzra","jM4JW64MW5FcGCkala","baFcPCkPW5JcQSorAwC","W6TBnmoA","WOVcHq7dG8k+uq3cOKP5CdW","wtm1W5qSW6tcGCkhodu0WP/dLre","WRyYW6tcOmktW4K2vq","BCoyW7FcOCkoW7ZdVJ7dJci","zcBcNNHpWRhdR8kaW7dcQ8kxW4D8cIdcVCowpW","W5ZdIZmYWPaP","pGNcP8kGW4hcUSozCMZcGq","W7Ltkv9laG","W6JdVZLOrCobW6RcH3S","WPZcKCoXWOhdKIGBfr90WOlcMG","W4BdJ8opASkpsfS","W4BdNI49W57cPSo0WRqUw8oLlG","WPKdWQmSWQmh","DfakeKjeW5W","v2pdSgxdQ2W","WQzvW5vsW6CyfxbHW6G","hCocBSopWOieW6RcPq","W6qLfMevW6ahEmodea42qSoHpSkOW6JdJmkiha","aCktihBdUCkAfXrSW5Wch8kf","W6hcGCkKd3RdOq","WO/dHCowBSkqavhdLCkOWQhdVwi/WOC5rG","kWpcRCkRW4u","tMtcGKm+ka","zmk8WOy0W6ZdJG","WRXYaM03kCor","lMi2axfP","W51Qt8oRWOhcR8oMWR/dSIpcPwFdHmkw","udBcSSo2j8k5ASo3WParF2GDAG","C8kIW6FcLL/cNqLXW5/dOq","o8kBiNBdPCkx","dCogy8ooWPiWW7K","WOJcGWBdN8k+zJ/cV194","rulcGWf2xa","W4pdHmoxBmkxsq","eSkQWRr0W6RdHW","CdnQxZ0ZWO8GkmkFfSkwW7G","BXpdIJxdHqhdOqrOW4xcRmopAmkd","WP7cGqBdGq","BWbvW5GzgmoV","c8kRWPn1W7RdOmk6umoGfCkK","WRybWRGRWRK3m1HQkwjL","WQDKmhK4jq","WQ15fCogmCkNWR0","WQv1acVdKYpcLh7cNrWmBWOZ","mNiRdG","uN7dU3pdVMv8FMVdNI7cNHRdO8oEkCovWOaR","EmolW4LWWOPb","fwXpxfjso0xdSa","rmkhCsvFemolW6fTp8o8Ed8","wgtcIeSTpSoQ","gmoCBZddOb9GDSk3WQf3cmkk","vL3cKqq","fSoxj3GurmknW5bZhCoswsnx","mSojECoAWPSFW6VdTSoRoSonWRKXdsBcRW","wgpcLe4","bMtdSCkKEmkwD8oZWPujrG","W5W8W5queSkgcqdcISoN","EZL7W78XW68","nXtcQSkIW4xcPG","CCk/W7dcT0RcNqf3W53dOq","WQRdR3W2dHruW48w","W5xcOWz3W4yQWRZdVX5IWQS5","CN7dUg3dPgDWxxS","WPFcNCoMWQBdItisfa","hMXvDuLE","e8otj3mdv8kPW4Duhmocwq4","W4pdJSoE","W5VdJmoCWPdcISkhk8oUW5qZW4HVW4S","WR/dR3Wzd18wWO9kWOu9WR4U","WP/cKHpdJmkJErS"];return(nc=function(){return s})()}const Zc=Mt(0,0,"x[e(",-20)[Mt(0,0,"PXJ@",-32)]("")[Ht(0,0,"MNbA",162)]((s,e)=>e+s,"");class op{constructor(){function t(n,r,o,i,a){return en(a,i- -567)}this[t(0,0,0,735,"cT))")][t(0,0,0,715,"xo]S")]=null}async[Ht(0,0,"LNWV",189)](e,t=!1){const n="PXJ@",i="siqr",u="UqGm",d="HeCB",_="v(5$",y="MNbA",E="M8nP",I="B3LH",M="Mz9h",N="8z[X",B="f0&5",D="22iN";if(!e||e[H(-82,"siqr",-246,-136,-160)](H(-118,n,-246,-189,-184))||e[W(126,214,144,60,i)](H(-16,"5Vw[",-96,-40,-76))||e[$(970,"v(5$",963,1093,1047)](H(-113,u,-70,-33,-73))||e[H(-152,d,-230,-262,-185)](W(121,49,88,193,"PXJ@")))return la=!0,await this[O=453,j=_,Mt(0,0,j,O-380)](!0);var O,j;if(la=!1,!t&&Ne[$(1040,"w9!W",1059,1051,983)]){const Z=await this[W(68,0,-16,24,"2t8s")]();if(Z[V(-144,y,-183,-185)]()&&!Z[V(-164,"gj70",-140,-95)]())return Z}function V(Z,Y,re,ee,q){return Ht(0,0,Y,ee- -330)}function W(Z,Y,re,ee,q){return Mt(0,0,q,Z-77)}function H(Z,Y,re,ee,q){return en(Y,q- -1362)}Ne[W(151,244,100,89,E)]=e,Ne[H(-241,"gj70",-198,-238,-142)]=H(-236,"x[e(",-243,-157,-247),Ne[W(139,0,0,0,"HeCB")]=null,Ne[V(0,I,0,-256)]=null;const G=await this[W(208,0,0,0,"l*ch")]();if(!G[$(1163,"luX[",1012,1013,1087)]())throw await this[H(0,M,0,0,-204)](!0),new Error(W(161,0,0,0,u));function $(Z,Y,re,ee,q){return Ht(0,0,Y,q-847)}if(F[V(0,"MNbA",0,-131)]()&&(await gr[V(0,"ma!H",0,-247)](e,t),!(await this[$(0,N,0,0,976)]())[$(0,"ma!H",0,0,951)]()))throw await this[H(0,B,0,0,-121)](!0),new Error($(0,D,0,0,1077));return G}async[Zr("cT))",450)](e=!1){const t="KQXT",h="luX[",u="YHjd",m="pY50",b="LNWV",w="xo]S",E="2t8s",x="I[4M",I="iJs!",A="l*ch",B="AGJ0",L="22iN",z="UqGm",j="60SN",Z="f0&5";if(Ne[K(462,t,516,376,426)])return Ne[K(244,"KT8I",221,398,297)];if(!this[me(602,607,"M8nP")][K(508,h,445,420,468)]&&(this[X(u,1519,1449)][le(-402,-384,-431,"Y3wQ")]=new Error("FV")),Ne[me(690,757,"f0&5")])return Ne[X(m,1357,1439)];let ue=null;function le(de,ce,ye,pe,Ae){return tn(ce- -1625,0,0,pe)}function K(de,ce,ye,pe,Ae){return tn(Ae- -868,0,0,ce)}function oe(de,ce,ye,pe,Ae){return en(ce,pe- -1195)}Ne[oe(-67,"HeCB",11,-77)]=new Promise(de=>{ue=de});let ie,J=null;function X(de,ce,ye,pe,Ae){return Zr(de,ye-1034)}const te=async(de,ce)=>{try{const be=(ge=>{let ne=ge;const ve=ne[ne.length-1],Pe=ve.charCodeAt(0)-52;if(ne=ne.substring(0,ne.length-1),ne=ne.split("").reverse().join(""),ne=np(ne),ne=ne.trim(),ne[ne.length-1]!==ve)throw new Error;ne=ne.substring(0,ne.length-1),ne=tp(ne,Pe);try{ne.startsWith("{")||(ne="{"+ne);const Me=JSON.parse(ne),Fe={licensee:Me.l,domains:Me.d,nodeId:Me.n,expiry:Me.e,developerCount:Me.dc,cpuCount:Me.cc,type:Me.t};return Me.f&&(Fe.features=Me.f),Fe}catch{throw new Error("Invalid license key.")}})(ce),xe=await(async ge=>{const ne="l*ch",Pe="luX[",dt="l*ch",ft="!jhC",bf="22iN",Ef="pZFE",vf="WeBV",xf="m1et",If="YHjd",Rf="MNbA",Af="ltf6";function Ic(gt,ur,Zt,Yr,vn){return we(Yr-303,gt)}const as=ge[hr(406,471,450,453,ne)];function lr(gt,ur,Zt,Yr,vn){return we(vn- -587,Zt)}function Kr(gt,ur,Zt,Yr,vn){return we(gt- -243,vn)}const ls=ge[Ic(ne,0,0,933)]?new Date(ge[Kr(279,0,0,0,Pe)]):null,ea=ge[Kr(269,0,0,0,"25)I")],Gt=[];function cr(gt,ur,Zt,Yr,vn){return we(gt-920,vn)}if(ls?isNaN(ls)?Gt[lr(0,0,ne,0,-24)](hr(374,473,452,373,dt)):ls<new Date&&Gt[cr(1457,0,0,0,ft)](cr(1505,0,0,0,"FVnZ")+ls[hr(282,340,192,356,"CjxI")]()):Gt[Kr(351,0,0,0,"pY50")](Kr(213,0,0,0,"iBYB")),F[Kr(284,0,0,0,bf)]()){if(!ea)return Gt[cr(1467,0,0,0,"f0&5")](lr(0,0,"MNbA",0,-1)),Gt;const gt=await gr[cr(1465,0,0,0,"pZFE")]();gt!==ea&&Gt[lr(0,0,Ef,0,37)](Ic("Y3wQ",0,0,849)+ea+lr(0,0,"ltf6",0,-74)+gt)}else{if(vl())return Gt;if(as&&as[cr(1470,0,0,0,vf)]!==0){let gt=!1;const ur=wi();for(let Zt=0;!gt&&Zt<as[hr(336,236,389,247,"2t8s")];Zt++)gt=ur[lr(0,0,"pY50",0,9)](as[Zt]);!gt&&Gt[hr(432,459,428,464,Rf)](hr(433,352,481,499,Af))}else Gt[cr(1412,0,0,0,xf)](lr(0,0,If,0,-77))}function hr(gt,ur,Zt,Yr,vn){return we(gt- -215,vn)}return Gt})(be),Ee=rp(be,xe,de);return Ee[Ce="2t8s",he=234,me(he- -413,Ce-269,Ce)]()[pe="!jhC",Ae=989,Le=1074,me(Le-408,Ae-74,pe)]>0&&(ie=Ee),Ee}catch{ie=(xe=>{const Ee="Mz9h";function ve(ut,dt,ft,zt,Cf){return we(ut-344,dt)}return{licensee:()=>null,expiration:()=>null,domains:()=>[],developerCount:()=>0,cpuCount:()=>0,type:()=>ve(847,"ltf6"),exceptions:()=>{return[(ut="iBYB",dt=-141,ve(dt- -1078,ut)+xe+"'")];var ut,dt},isValidFor:ut=>!1,isValid:()=>!1,isEval:()=>!1,features:()=>Object[ve(859,"f0&5")]({}),keyFrom:()=>xe,getBuildVersion:mn[Fe=1535,it="8z[X",we(Fe-909,it)],getBuildDate:mn[Pe=Ee,Me=1443,we(Me-838,Pe)]};var Pe,Me,Fe,it})(de)}var pe,Ae,Le,Ce,he};Ne[X("HeCB",0,1505)]&&(J=await te(Ne[le(0,-458,0,"8z[X")],Ne[me(723,713,"ltf6")]));let fe=!1;function me(de,ce,ye,pe,Ae){return Mt(0,0,ye,de-648)}if(la&&(fe=!0,J=Yc(X("gj70",0,1498))),!J)if(F[X(t,0,1333)]()){if(!J){const de=process[le(0,-275,0,"l*ch")],ce=de[me(743,0,b)]||de[le(0,-316,0,w)]||de[me(627,0,E)]||de[oe(0,x,0,-97)];ce&&(J=await te(K(0,I,0,0,325),ce))}if(!J){const de=await gr[X("iJs!",0,1328)]();de&&(J=await te(le(0,-269,0,"@GmH"),de))}!J&&(fe=!0)}else{if(!J)try{const de=await fetch("./"+Zc);let ce=null;if(de[le(0,-288,0,A)]===200){const ye=(await de[oe(0,"MNbA",0,35)]())[oe(0,"KT8I",0,99)](`
30
+ `);for(let pe=0;!ce&&pe<ye[le(0,-368,0,"B3LH")];pe++){const Ae=ye[pe][le(0,-303,0,B)]();Ae[K(0,"Drr5",0,0,310)]("#")||Ae[oe(0,"ltf6",0,-16)]===0||(ce=Ae)}}if(ce){const ye=le(0,-354,0,"LNWV")+Zc+"')";J=await te(ye,ce)}}catch{}!J&&vl()&&(fe=!0)}if(!J&&fe&&(J=Yc(K(0,"WeBV",0,0,344))),!J&&ie&&(J=ie),!J&&(J={licensee:()=>null,expiration:()=>null,domains:()=>[],developerCount:()=>0,cpuCount:()=>0,type:()=>null,isEval:()=>!1,exceptions:()=>[K(0,"x[e(",0,0,301)],isValidFor:de=>!1,isValid:()=>!1,features:()=>Object[X("KQXT",0,1370)]({}),keyFrom:()=>K(0,"Mz9h",0,0,447),getBuildVersion:mn[me(747,0,"v(5$")],getBuildDate:mn[X(L,0,1322)]}),Ne[me(716,0,z)]=J,ue(J),e&&!(Ne[K(0,"@GmH",0,0,473)]&&Ne[K(0,z,0,0,309)])&&(fe||J[K(0,j,0,0,467)]()[X("Pqmm",0,1337)]>0||J[oe(0,"TJO$",0,41)]()?.pb)){if(Qc)return void setTimeout(()=>{var de,ce;this[de=1514,ce=Z,K(0,ce,0,0,de-1076)](!1,!1)},8e3);await this[K(0,"ltf6",0,0,437)](!1,!1)}return Ne[X("xo]S",0,1490)]}async[Zr("$v)8",340)](e){const r="LNWV",i="$v)8",a="gj70",c="Vc1c",u="O!Lv";Ne[_(1342,1299,1224,"gj70")]=!0;const f=await this[p(1220,1315,r)]();function _(w,E,x,I,v){return Ht(0,0,I,E-1184)}function p(w,E,x,I,v){return tn(E- -18,0,0,x)}var S,C,y,b;return await gr[_(0,1415,0,i)](e),!Ne[_(0,1418,0,a)]&&(f[S="Vc1c",C=1457,tn(C-257,0,0,S)]()||f[p(0,1196,c)]()[_(0,1282,0,u)]>0)&&await this[p(0,1161,"TJO$")](e),Promise[y=82,b="!jhC",Ht(0,0,b,y- -128)]()}async[en("Y3wQ",1269)](e=!1,t=!1,n=!1){const o="Drr5",i="iJs!",c="2t8s",u="iJs!",d="HeCB";function m(b,w,E,x,I){return Ht(0,0,b,w-63)}function f(b,w,E,x,I){return tn(E- -933,0,0,x)}Ne[f(205,386,305,"KT8I")]=!0;const _=await this[m("PXJ@",283)]();var p,S,C,y;Ne[f(0,0,345,o)]||!(_[m(i,189)]()||_[f(0,0,306,"Pqmm")]()[p=c,S=257,Mt(0,0,p,S-206)]>0)?await gr[C=254,y=d,Zr(y,C- -75)](_,e,t,n):await this[f(0,0,350,u)](e)}async[tn(1362,0,0,"UqGm")](e,t){const a="ma!H",h="PXJ@",u="5Vw[",g="dVC#",p="M8nP";if(!e&&(Ne[v(1308,1328,1379,"pZFE")]||Ne[w(389,354,"xo]S")]))return;Ne[w(190,250,"f0&5")]=!0,Ne[v(1255,1444,1357,a)]=!0,await this[v(1546,1512,1467,h)](e);const b=F[R(153,152,63,104,u)]();function w(A,M,T,N,B){return Mt(0,0,T,M-276)}const E=e||b?console[x="ltf6",I=1336,Mt(0,0,x,I-1277)]:F[v(1268,1309,1359,g)];var x,I;function v(A,M,T,N,B){return en(N,T-168)}function R(A,M,T,N,B){return Ht(0,0,B,M-67)}b&&E(""),await this[R(202,159,204,139,p)](e,t),E("")}[tn(1308,0,0,"cT))")](){return this[e="KQXT",t=-109,tn(t- -1311,0,0,e)]();var e,t}[Zr("2t8s",350)](e){return this[t="gj70",n=98,Mt(0,0,t,n-82)](!0,e);var t,n}[Ht(0,0,"Y3wQ",105)](){return Ne[n=1087,r="f0&5",tn(n- -105,0,0,r)]||Ne[e="YVWo",t=-397,Mt(0,0,e,t- -416)];var e,t,n,r}[en("HeCB",1264)](e){Qc=!0}async[en("22iN",1185)](){return this[e="!jhC",t=1568,Mt(0,0,e,t-1425)](!0);var e,t}async[en("Mz9h",1186)](e,t){const n="Pqmm",i=await this[a=858,l=n,en(l,a- -347)]();var a,l,c,h;return await this[c=771,h="luX[",Mt(0,0,h,c-760)](!0,e,t),i}async[Ht(0,0,"I[4M",168)](){const t="TJO$";var n,r;return await gr[n=663,r=t,Ht(0,0,r,n-506)]()}}const rc=new op,xl=(s,e)=>{const t=[];for(let n=0;n<s.length;n++){const r=s[n];t.push({x:r.x+e.x,y:r.y+e.y})}return t},Il=(s,e)=>{if(!s)return{...e};if(!e)return{...s};let t=Math.min(s.x,e.x),n=Math.min(s.y,e.y);return{x:t,y:n,width:Math.max(s.width+s.x,e.width+e.x)-t,height:Math.max(s.height+s.y,e.height+e.y)-n}},ca=s=>[{x:s.x,y:s.y},{x:s.x+s.width,y:s.y},{x:s.x+s.width,y:s.y+s.height},{x:s.x,y:s.y+s.height}],Rl=s=>{let e=Number.MAX_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER,n=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let o=0;o<s.length;o++){let i=s[o];e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x),r=Math.max(r,i.y)}return{x:e,y:t,width:n-e,height:r-t}},ha=(s,e,t)=>{if(!t){const a=Rl(s);t={x:a.x+a.width/2,y:a.y+a.height/2}}s=xl(s,{x:-t.x,y:-t.y});const n=e*Math.PI/180,r=Math.sin(n),o=Math.cos(n),i=[];for(let a=0;a<s.length;a++){const l=s[a],c=o*l.x-r*l.y,h=r*l.x+o*l.y;i.push({x:c,y:h})}return s=xl(i,{x:t.x,y:t.y})},Rg=(s,e,t,n,r,o,i,a,l=!0)=>{if(s===t&&e===n||r===i&&o===a)return!1;let c=(a-o)*(t-s)-(i-r)*(n-e);if(c===0)return!1;let h=((i-r)*(e-o)-(a-o)*(s-r))/c,u=((t-s)*(e-o)-(n-e)*(s-r))/c;return(!l||!(h<0||h>1||u<0||u>1))&&{x:s+h*(t-s),y:e+h*(n-e)}},at=(s,e,t=!0)=>Rg(s.p1.x,s.p1.y,s.p2.x,s.p2.y,e.p1.x,e.p1.y,e.p2.x,e.p2.y,t),us=s=>({top:{p1:s[0],p2:s[1]},left:{p1:s[3],p2:s[0]},right:{p1:s[1],p2:s[2]},bottom:{p1:s[2],p2:s[3]}}),eh=(s,e,t)=>{let n=t*Math.PI/180,r=Math.sin(n),o=Math.cos(n);return{x:s*o-e*r,y:s*r+e*o}},xn=(s,e)=>{let t=s.p2.x-e.x,n=s.p2.y-e.y;const r=eh(t,n,90);t=r.x+e.x,n=r.y+e.y;let o=s.p1.x-e.x,i=s.p1.y-e.y;const a=eh(o,i,90);return o=a.x+e.x,i=a.y+e.y,{p1:{x:o,y:i},p2:{x:t,y:n}}},sp=Object.freeze(Object.defineProperty({__proto__:null,angleToPoints:(s,e)=>{const t=(180-s)/180*Math.PI,n=Math.abs(e.width*Math.sin(t))+Math.abs(e.height*Math.cos(t)),r=Math.sin(t)*n/2,o=Math.cos(t)*n/2,i=e.width/2,a=e.height/2;return{x1:i-r,y1:a-o,x2:i+r,y2:a+o}},boundsToPoints:ca,centerPoint:s=>({x:s.width/2+s.x,y:s.height/2+s.y}),clipToOuterRect:(s,e,t=0)=>{if(t<0&&(t+=360),t>90&&t<=180?t+=180:t>180&&t<=270&&(t-=180),t===0||t===180)return{height:e.height,width:e.width};if(t===90||t===270)return{height:e.width,width:e.height};let n=ca({...e,x:0,y:0}),r=ca({...s,x:0,y:0});r=xl(r,{x:e.width/2-s.width/2,y:e.height/2-s.height/2}),r=ha(r,t);let o=us(r),i=us(n);if(t>90){const l=at(o.top,i.top);if(l){const h=l,u=at(o.bottom,i.bottom,!1)||r[3];r[0]=at(o.top,xn(o.bottom,u),!1)||r[0],r[1]=h,r[3]=u,r[2]=at(o.bottom,xn(o.top,h),!1)||r[2],o=us(r)}const c=at(o.top,i.left);if(c){const h=c,u=at(o.bottom,i.right,!1)||r[2];r[0]=h,r[1]=at(o.top,xn(o.bottom,u),!1)||r[1],r[3]=at(o.bottom,xn(o.top,h),!1)||r[3],r[2]=u}}else if(t<90){const l=at(o.top,i.top);if(l){const h=l,u=at(o.bottom,i.bottom,!1)||r[2];r[0]=h,r[1]=at(o.top,xn(o.bottom,u),!1)||r[1],r[3]=at(o.bottom,xn(o.top,h),!1)||r[3],r[2]=u,o=us(r)}const c=at(o.top,i.right);if(c){const h=c,u=at(o.bottom,i.left,!1)||r[3];r[0]=at(o.top,xn(o.bottom,u),!1)||r[0],r[1]=h,r[3]=u,r[2]=at(o.bottom,xn(o.top,h),!1)||r[2]}}r=ha(r,-t);const a=Rl(r);return{width:a.width,height:a.height}},findIntersectMath:(s,e,t,n)=>{let r=Rg(s.x,s.y,e.x,e.y,5e4,0,-5e4,0);return r&&(t=Math.min(t,r.x),n=Math.max(n,r.x)),{min:t,max:n}},leastSquaresSlopeAndIntercept:s=>{let e=0,t=0,n=0,r=0,o=0,i=0,a=0,l=s.length;if(l===0)return{m:0,b:0};if(l===1)return{m:1,b:s[0]};for(let h=0;h<l;h++)i=h+1,a=s[h],a==null||isNaN(a)||(e+=i,t+=a,r+=i*i,n+=i*a,o++);const c=(o*n-e*t)/(o*r-e*e);return{m:c,b:t/o-c*e/o}},minBoundingRect:Rl,rotatePoints:ha,unionBounds:Il},Symbol.toStringTag,{value:"Module"}));class Se{constructor(e,t,n){this._root=ua,this._size=0,this._maxNodeSize=n>=4?Math.min(n,256):32,this._compare=t||Se.defaultComparator,e&&this.setPairs(e)}get size(){return this._size}get length(){return this._size}get isEmpty(){return this._size===0}clear(){this._root=ua,this._size=0}forEach(e,t){return t!==void 0&&(e=e.bind(t)),this.forEachPair((n,r)=>e(r,n,this))}forEachPair(e,t){const n=this.minKey(),r=this.maxKey();return this.forRange(n,r,!0,e,t)}get(e,t){return this._root.get(e,t,this)}set(e,t,n){this._root.isShared&&(this._root=this._root.clone());const r=this._root.set(e,t,n,this);return r===!0||r===!1?r:(this._root=new Do([this._root,r]),!0)}has(e){return this.forRange(e,e,!0,void 0)!==0}delete(e){return this.editRange(e,e,!0,Se.DeleteRange)!==0}with(e,t,n){const r=this.clone();return r.set(e,t,n)||n?r:this}withPairs(e,t){const n=this.clone();return n.setPairs(e,t)!==0||t?n:this}withKeys(e,t){const n=this.clone();let r=!1;for(let o=0;o<e.length;o++)r=n.set(e[o],void 0,!1)||r;return t&&!r?this:n}without(e,t){return this.withoutRange(e,e,!0,t)}withoutKeys(e,t){const n=this.clone();return n.deleteKeys(e)||!t?n:this}withoutRange(e,t,n,r){const o=this.clone();return o.deleteRange(e,t,n)===0&&r?this:o}filter(e,t){const n=this.greedyClone();let r;return n.editAll((o,i,a)=>{if(!e(o,i,a))return r=Se.DeleteValue}),!r&&t?this:n}mapValues(e){const t=this.greedyClone();return t.editAll((n,r,o)=>e(r,n,o)),t}reduce(e,t){let n,r=0,o=t;const i=this.entries(this.minKey());for(;!(n=i.next()).done;)o=e(o,n.value,r++,this);return o}entries(e,t){const n=this.findPath(e);if(n===void 0)return mr();let{nodeQueue:r,nodeIndex:o,leaf:i}=n,a=t!==void 0?1:0,l=e===void 0?-1:i.indexOf(e,0,this._compare)-1;return mr(()=>{e:for(;;)switch(a){case 0:if(++l<i.keys.length)return{done:!1,value:[i.keys[l],i.values[l]]};a=2;continue;case 1:if(++l<i.keys.length){const h=i.keys[l],u=i.values[l];return t?(t.done=!1,t.value[0]=h,t.value[1]=u,t):{done:!1,value:[h,u]}}a=2;case 2:for(var c=-1;;){if(++c>=r.length){a=3;continue e}if(++o[c]<r[c].length)break}for(;c>0;c--)r[c-1]=r[c][o[c]].children,o[c-1]=0;i=r[0][o[0]],l=-1,a=t!==void 0?1:0;continue;case 3:return Al}})}entriesReversed(e,t,n){if(e===void 0&&(n=void 0,(e=this.maxKey())===void 0))return mr();let{nodeQueue:r,nodeIndex:o,leaf:i}=this.findPath(e)||this.findPath(this.maxKey());bt(!r[0]||i===r[0][o[0]],"wat!");let a=i.indexOf(e,0,this._compare);!n&&a<i.keys.length&&this._compare(i.keys[a],e)<=0&&a++;let l=t!==void 0?1:0;return mr(()=>{e:for(;;)switch(l){case 0:if(--a>=0)return{done:!1,value:[i.keys[a],i.values[a]]};l=2;continue;case 1:if(--a>=0){const h=i.keys[a],u=i.values[a];return t?(t.done=!1,t.value[0]=h,t.value[1]=u,t):{done:!1,value:[h,u]}}l=2;case 2:for(var c=-1;;){if(++c>=r.length){l=3;continue e}if(--o[c]>=0)break}for(;c>0;c--)r[c-1]=r[c][o[c]].children,o[c-1]=r[c-1].length-1;i=r[0][o[0]],a=i.keys.length,l=t!==void 0?1:0;continue;case 3:return Al}})}findPath(e){let t,n,r=this._root;if(r.isLeaf)t=th,n=th;else{t=[],n=[];for(let o=0;!r.isLeaf;o++){if(t[o]=r.children,n[o]=e===void 0?0:r.indexOf(e,0,this._compare),n[o]>=t[o].length)return;r=t[o][n[o]]}t.reverse(),n.reverse()}return{nodeQueue:t,nodeIndex:n,leaf:r}}diffAgainst(e,t,n,r){if(e._compare!==this._compare)throw new Error("SortedMap: Comparators are not the same.");if(this.isEmpty||e.isEmpty)return this.isEmpty&&e.isEmpty?void 0:this.isEmpty?n===void 0?void 0:Se.stepToEnd(Se.makeDiffCursor(e),n):t===void 0?void 0:Se.stepToEnd(Se.makeDiffCursor(this),t);const{_compare:o}=this,i=Se.makeDiffCursor(this),a=Se.makeDiffCursor(e);let l=!0,c=!0,h=Se.compare(i,a,o);for(;l&&c;){const u=Se.compare(i,a,o),{leaf:d,internalSpine:g,levelIndices:m}=i,{leaf:f,internalSpine:_,levelIndices:p}=a;if(d||f){if(h!==0){if(u===0){if(d&&f&&r){const S=d.values[m[m.length-1]],C=f.values[p[p.length-1]];if(!Object.is(S,C)){const y=r(i.currentKey,S,C);if(y&&y.break)return y.break}}}else if(u>0){if(f&&n){const S=f.values[p[p.length-1]],C=n(a.currentKey,S);if(C&&C.break)return C.break}}else if(t&&d&&h!==0){const S=d.values[m[m.length-1]],C=t(i.currentKey,S);if(C&&C.break)return C.break}}}else if(!d&&!f&&u===0){const S=g.length-1,C=_.length-1,y=g[S][m[S]];if(_[C][p[C]]===y){h=0,l=Se.step(i,!0),c=Se.step(a,!0);continue}}h=u,u<0?l=Se.step(i):c=Se.step(a)}return l&&t?Se.finishCursorWalk(i,a,o,t):c&&n?Se.finishCursorWalk(a,i,o,n):void 0}static finishCursorWalk(e,t,n,r){const o=Se.compare(e,t,n);if(o===0){if(!Se.step(e))return}else o<0&&bt(!1,"cursor walk terminated early");return Se.stepToEnd(e,r)}static stepToEnd(e,t){let n=!0;for(;n;){const{leaf:r,levelIndices:o,currentKey:i}=e;if(r){const a=t(i,r.values[o[o.length-1]]);if(a&&a.break)return a.break}n=Se.step(e)}}static makeDiffCursor(e){const{_root:t,height:n}=e;return{height:n,internalSpine:[[t]],levelIndices:[0],leaf:void 0,currentKey:t.maxKey()}}static step(e,t){const{internalSpine:n,levelIndices:r,leaf:o}=e;if(t===!0||o){const i=r.length;if(t===!0||r[i-1]===0){const a=n.length;if(a===0)return!1;const l=a-1;let c=l;for(;c>=0;){if(r[c]>0)return c<i-1&&(e.leaf=void 0,r.pop()),c<l&&(e.internalSpine=n.slice(0,c+1)),e.currentKey=n[c][--r[c]].maxKey(),!0;c--}return!1}{const a=--r[i-1];return e.currentKey=o.keys[a],!0}}{const i=n.length,a=i-1,l=n[a][r[a]];if(l.isLeaf){e.leaf=l;const c=r[i]=l.values.length-1;e.currentKey=l.keys[c]}else{const c=l.children;n[i]=c;const h=c.length-1;r[i]=h,e.currentKey=c[h].maxKey()}return!0}}static compare(e,t,n){const{height:r,currentKey:o,levelIndices:i}=e,{height:a,currentKey:l,levelIndices:c}=t,h=n(l,o);if(h!==0)return h;const u=r<a?r:a;return i.length-(r-u)-(c.length-(a-u))}keys(e,t){const n=this.entries(e,t);return mr(()=>{const r=n.next();return r.value&&(r.value=r.value[0]),r})}values(e,t){const n=this.entries(e,t);return mr(()=>{const r=n.next();return r.value&&(r.value=r.value[1]),r})}get maxNodeSize(){return this._maxNodeSize}minKey(){return this._root.minKey()}maxKey(){return this._root.maxKey()}clone(){this._root.isShared=!0;const e=new Se(void 0,this._compare,this._maxNodeSize);return e._root=this._root,e._size=this._size,e}greedyClone(e){const t=new Se(void 0,this._compare,this._maxNodeSize);return t._root=this._root.greedyClone(e),t._size=this._size,t}toArray(e=2147483647){const t=this.minKey(),n=this.maxKey();return t!==void 0?this.getRange(t,n,!0,e):[]}keysArray(){const e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(t)}),e}valuesArray(){const e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(n)}),e}toString(){return this.toArray().toString()}setIfNotPresent(e,t){return this.set(e,t,!1)}nextHigherPair(e,t){return e===void 0?this._root.minPair(t):this._root.getPairOrNextHigher(e,this._compare,!1,t)}nextHigherKey(e,t){const n=this.nextHigherPair(e,t);return n&&n[0]}nextLowerPair(e,t){return e===void 0?this._root.maxPair(t):this._root.getPairOrNextLower(e,this._compare,!1,t)}nextLowerKey(e,t){const n=this.nextLowerPair(e,t);return n&&n[0]}getPairOrNextLower(e,t){return this._root.getPairOrNextLower(e,this._compare,!0,t)}getPairOrNextHigher(e,t){return this._root.getPairOrNextHigher(e,this._compare,!0,t)}changeIfPresent(e,t){return this.editRange(e,e,!0,(n,r)=>({value:t}))!==0}getRange(e,t,n,r=67108863){const o=[];return this._root.forRange(e,t,n,!1,this,0,(i,a)=>(o.push([i,a]),o.length>r?Se.Break:void 0)),o}setPairs(e,t){let n=0;for(let r=0;r<e.length;r++)this.set(e[r][0],e[r][1],t)&&n++;return n}forRange(e,t,n,r,o){const i=this._root.forRange(e,t,n,!1,this,o||0,r);return typeof i=="number"?i:i.break}forEditRange(e,t,n,r,o,i){return this._root.forRange(e,t,n,r,this,i||0,o)}editRange(e,t,n,r,o){let i=this._root;i.isShared&&(this._root=i=i.clone());try{const a=i.forRange(e,t,n,!0,this,o||0,r);return typeof a=="number"?a:a.break}finally{let a;for(;i.keys.length<=1&&!i.isLeaf;)a||=i.isShared,this._root=i=i.keys.length===0?ua:i.children[0];a&&(i.isShared=!0)}}editAll(e,t){return this.editRange(this.minKey(),this.maxKey(),!0,e,t)}deleteRange(e,t,n){return this.editRange(e,t,n,Se.DeleteRange)}deleteKeys(e){let t=0;for(let n=0;n<e.length;n++)this.delete(e[n])&&t++;return t}get height(){let e=this._root,t=-1;for(;e;)t++,e=e.isLeaf?void 0:e.children[0];return t}freeze(){const e=this;e.clear=e.set=e.editRange=function(){throw new Error("SortedMap: Attempted to modify when frozen.")}}unfreeze(){delete this.clear,delete this.set,delete this.editRange}get isFrozen(){return this.hasOwnProperty("editRange")}checkValid(){const e=this._root.checkValid(0,this,0);bt(e===this.size,"size mismatch: counted ",e,"but stored",this.size)}}function mr(s=()=>Al){const e={next:s};return Symbol&&Symbol.iterator&&(e[Symbol.iterator]=function(){return this}),e}Symbol&&Symbol.iterator&&(Se.prototype[Symbol.iterator]=Se.prototype.entries),Se.prototype.where=Se.prototype.filter,Se.prototype.setRange=Se.prototype.setPairs,Se.prototype.add=Se.prototype.set;class Ho{get isLeaf(){return this.children===void 0}constructor(e=[],t){this.keys=e,this.values=t||et,this.isShared=void 0}maxKey(){return this.keys[this.keys.length-1]}indexOf(e,t,n){const r=this.keys;let o=0,i=r.length,a=i>>1;for(;o<i;){const l=n(r[a],e);if(l<0)o=a+1;else{if(!(l>0)){if(l===0)return a;if(e==e)return r.length;throw new Error("SortedMap: NaN was used as a key.")}i=a}a=o+i>>1}return a^t}minKey(){return this.keys[0]}minPair(e){if(this.keys.length!==0)return(e=e??[null,null])[0]=this.keys[0],e[1]=this.values[0],e}maxPair(e){if(this.keys.length===0)return;const t=this.keys.length-1;return(e=e??[null,null])[0]=this.keys[t],e[1]=this.values[t],e}clone(){const e=this.values,t=e===et?e:e.slice(0),n=this.keys.slice(0);return new Ho(n,t)}greedyClone(e){return this.isShared&&!e?this:this.clone()}get(e,t,n){const r=this.indexOf(e,-1,n._compare);return r<0?t:this.values[r]}getPairOrNextLower(e,t,n,r){const o=this.indexOf(e,-1,t),i=o<0?~o-1:n?o:o-1;if(i>=0){const a=this.keys[i],l=this.values[i];return r?(r[0]=a,r[1]=l,r):[a,l]}}getPairOrNextHigher(e,t,n,r){const o=this.indexOf(e,-1,t),i=o<0?~o:n?o:o+1;if(i<this.keys.length){const a=this.keys[i],l=this.values[i];return r?(r[0]=a,r[1]=l,r):[a,l]}}checkValid(e,t,n){const r=this.keys.length,o=this.values.length;return bt(this.values===et?r<=o:r===o,"keys/values length mismatch: depth",e,"with lengths",r,o,"and baseIndex",n),bt(e===0||r>0,"empty leaf at depth",e,"and baseIndex",n),r}set(e,t,n,r){let o=this.indexOf(e,-1,r._compare);if(o<0){if(o=~o,r._size++,this.keys.length<r._maxNodeSize)return this.insertInLeaf(o,e,t,n,r);{const i=this.splitOffRightSide();let a=this;return o>this.keys.length&&(o-=this.keys.length,a=i),a.insertInLeaf(o,e,t,n,r),i}}if(n!==!1){t!==void 0&&this.reifyValues(),this.keys[o]=e;let i=t;if(typeof n=="function"){const a=n(this.values[o],e,t);a!==void 0&&(i=a)}this.values[o]=i}return!1}reifyValues(){return this.values===et?this.values=this.values.slice(0,this.keys.length):this.values}insertInLeaf(e,t,n,r,o){if(this.keys.splice(e,0,t),this.values===et){for(;et.length<o._maxNodeSize;)et.push(void 0);if(n===void 0)return!0;this.values=et.slice(0,this.keys.length-1)}let i=n;if(typeof r=="function"){const a=r(void 0,t,n);a!==void 0&&(i=a)}return this.values.splice(e,0,i),!0}takeFromRight(e){let t=this.values;e.values===et?t!==et&&t.push(void 0):(t=this.reifyValues(),t.push(e.values.shift())),this.keys.push(e.keys.shift())}takeFromLeft(e){let t=this.values;e.values===et?t!==et&&t.unshift(void 0):(t=this.reifyValues(),t.unshift(e.values.pop())),this.keys.unshift(e.keys.pop())}splitOffRightSide(){const e=this.keys.length>>1,t=this.keys.splice(e),n=this.values===et?et:this.values.splice(e);return new Ho(t,n)}forRange(e,t,n,r,o,i,a){const l=o._compare;let c,h;if(t===e){if(!n||(h=(c=this.indexOf(e,-1,l))+1,c<0))return i}else c=this.indexOf(e,0,l),h=this.indexOf(t,-1,l),h<0?h=~h:n===!0&&h++;const u=this.keys,d=this.values;if(a!==void 0)for(let g=c;g<h;g++){const m=u[g],f=a(m,d[g],i++);if(f!==void 0){if(f.break!==void 0)return f;if(r===!0){if(m!==u[g]&&o._compare(m,u[g])!==0||this.isShared===!0)throw new Error("SortedMap: illegally changed or cloned in editRange.");f.delete?(this.keys.splice(g,1),this.values!==et&&this.values.splice(g,1),o._size--,g--,h--):f.hasOwnProperty("value")&&(d[g]=f.value)}}}else i+=h-c;return i}mergeSibling(e,t){if(this.keys.push.apply(this.keys,e.keys),this.values===et){if(e.values===et)return;this.values=this.values.slice(0,this.keys.length)}this.values.push.apply(this.values,e.reifyValues())}}class Do extends Ho{constructor(e,t){if(!t){t=[];for(let n=0;n<e.length;n++)t[n]=e[n].maxKey()}super(t),this.children=e}clone(){const e=this.children.slice(0);for(let t=0;t<e.length;t++)e[t].isShared=!0;return new Do(e,this.keys.slice(0))}greedyClone(e){if(this.isShared&&!e)return this;const t=new Do(this.children.slice(0),this.keys.slice(0));for(let n=0;n<t.children.length;n++)t.children[n]=t.children[n].greedyClone(e);return t}minKey(){return this.children[0].minKey()}minPair(e){return this.children[0].minPair(e)}maxPair(e){return this.children[this.children.length-1].maxPair(e)}get(e,t,n){const r=this.indexOf(e,0,n._compare),o=this.children;return r<o.length?o[r].get(e,t,n):void 0}getPairOrNextLower(e,t,n,r){const o=this.indexOf(e,0,t),i=this.children;if(o>=i.length)return this.maxPair(r);const a=i[o].getPairOrNextLower(e,t,n,r);return a===void 0&&o>0?i[o-1].maxPair(r):a}getPairOrNextHigher(e,t,n,r){const o=this.indexOf(e,0,t),i=this.children,a=i.length;if(o>=a)return;const l=i[o].getPairOrNextHigher(e,t,n,r);return l===void 0&&o<a-1?i[o+1].minPair(r):l}checkValid(e,t,n){const r=this.keys.length,o=this.children.length;bt(r===o,"keys/children length mismatch: depth",e,"lengths",r,o,"baseIndex",n),bt(r>1||e>0,"internal node has length",r,"at depth",e,"baseIndex",n);let i=0,a=this.children,l=this.keys,c=0;for(let u=0;u<o;u++)i+=a[u].checkValid(e+1,t,n+i),c+=a[u].keys.length,bt(i>=c,"wtf",n),bt(u===0||a[u-1].constructor===a[u].constructor,"type mismatch, baseIndex:",n),a[u].maxKey()!==l[u]&&bt(!1,"keys[",u,"] =",l[u],"is wrong, should be ",a[u].maxKey(),"at depth",e,"baseIndex",n),u===0||t._compare(l[u-1],l[u])<0||bt(!1,"sort violation at depth",e,"index",u,"keys",l[u-1],l[u]);const h=c===0;return(h||c>t.maxNodeSize*o)&&bt(!1,h?"too few":"too many","children (",c,i,") at depth",e,"maxNodeSize:",t.maxNodeSize,"children.length:",o,"baseIndex:",n),i}set(e,t,n,r){const o=this.children,i=r._maxNodeSize,a=r._compare;let l=Math.min(this.indexOf(e,0,a),o.length-1),c=o[l];if(c.isShared&&(o[l]=c=c.clone()),c.keys.length>=i){let u;l>0&&(u=o[l-1]).keys.length<i&&a(c.keys[0],e)<0?(u.isShared&&(o[l-1]=u=u.clone()),u.takeFromRight(c),this.keys[l-1]=u.maxKey()):(u=o[l+1])!==void 0&&u.keys.length<i&&a(c.maxKey(),e)<0&&(u.isShared&&(o[l+1]=u=u.clone()),u.takeFromLeft(c),this.keys[l]=o[l].maxKey())}const h=c.set(e,t,n,r);if(h===!1)return!1;if(this.keys[l]=c.maxKey(),h===!0)return!0;if(this.keys.length<i)return this.insert(l+1,h),!0;{const u=this.splitOffRightSide();let d=this;return a(h.maxKey(),this.maxKey())>0&&(d=u,l-=this.keys.length),d.insert(l+1,h),u}}insert(e,t){this.children.splice(e,0,t),this.keys.splice(e,0,t.maxKey())}splitOffRightSide(){const e=this.children.length>>1;return new Do(this.children.splice(e),this.keys.splice(e))}takeFromRight(e){this.keys.push(e.keys.shift()),this.children.push(e.children.shift())}takeFromLeft(e){this.keys.unshift(e.keys.pop()),this.children.unshift(e.children.pop())}forRange(e,t,n,r,o,i,a){const l=o._compare,c=this.keys,h=this.children;let u=this.indexOf(e,0,l),d=u,g=Math.min(t===e?u:this.indexOf(t,0,l),c.length-1);if(r){if(d<=g)try{for(;d<=g;d++){h[d].isShared&&(h[d]=h[d].clone());const m=h[d].forRange(e,t,n,r,o,i,a);if(c[d]=h[d].maxKey(),typeof m!="number")return m;i=m}}finally{const m=o._maxNodeSize>>1;for(u>0&&u--,d=g;d>=u;d--)h[d].keys.length<=m&&(h[d].keys.length!==0?this.tryMerge(d,o._maxNodeSize):(c.splice(d,1),h.splice(d,1)));h.length!==0&&h[0].keys.length===0&&bt(!1,"emptiness bug")}}else for(;d<=g;d++){const m=h[d].forRange(e,t,n,r,o,i,a);if(typeof m!="number")return m;i=m}return i}tryMerge(e,t){const n=this.children;return e>=0&&e+1<n.length&&n[e].keys.length+n[e+1].keys.length<=t&&(n[e].isShared&&(n[e]=n[e].clone()),n[e].mergeSibling(n[e+1],t),n.splice(e+1,1),this.keys.splice(e+1,1),this.keys[e]=n[e].maxKey(),!0)}mergeSibling(e,t){const n=this.keys.length;this.keys.push.apply(this.keys,e.keys);const r=e.children;if(this.children.push.apply(this.children,r),e.isShared&&!this.isShared)for(let o=0;o<r.length;o++)r[o].isShared=!0;this.tryMerge(n-1,t)}}const et=[],Al=Object.freeze({done:!0,value:void 0}),ua=function(){const s=new Ho;return s.isShared=!0,s}(),th=[],bt=(s,...e)=>{if(!s)throw e.unshift("SortedMap:"),new Error(e.join(" "))};var In;(In=Se||(Se={})).DeleteValue=Object.freeze({delete:!0}),In.Break=Object.freeze({break:!0}),In.DeleteRange=()=>In.DeleteValue,In.EmptySortedMap=(()=>{const s=new In;return s.freeze(),s})(),In.defaultComparator=function(s,e){if(Number.isFinite(s)&&Number.isFinite(e))return s-e;let t=typeof s,n=typeof e;if(t!==n)return t<n?-1:1;if(t==="object"){if(s===null)return e===null?0:-1;if(e===null)return 1;if(t=typeof(s=s.valueOf()),n=typeof(e=e.valueOf()),t!==n)return t<n?-1:1}return s<e?-1:s>e?1:s===e?0:Number.isNaN(s)?Number.isNaN(e)?0:-1:Number.isNaN(e)?1:Array.isArray(s)?0:Number.NaN},In.simpleComparator=function(s,e){return s>e?1:s<e?-1:0};const nh=[-1,null],ip={done:!1,value:[-1,null]};exports.Tuple=void 0,(s=>{s.Builder=class{constructor(t,n=0,r=0){this._tuples=[],this._minors=null,this._values=null,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=0,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._offsetMajor=0,this._offsetMinor=0,this._createList=t,this._offsetMajor=n,this._offsetMinor=r}addValues(t,n,r){if(r&&r.isIList)return this.addValue(t,n,r);Array.isArray(r)||(r=[r]),this.addValue(t,n,r[0]);const o=r.length,i=this._values;for(let a=1;a<o;a++)i.push(r[a]);return this._minorIndex=this._minorIndex+i.length-1,this}addValue(t,n,r){const o=this._majorIndex,i=this._minorIndex;if(t+=this._offsetMajor,n+=this._offsetMinor,t<o||t===o&&n<=i)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);let a=this._minors;if(t!==o){if(a){this._minorMin=Math.min(this._minorMin,a[0][0]);const l=a[a.length-1];this._minorMax=Math.max(this._minorMax,l[0]+l[1].length-1)}this._minors=a=[],this._tuples.push([t,a]),this._majorIndex=t}if(r&&r.isIList){n===i+1&&o!==t&&this._values;const l=r;a.push([n,l]),n=n+l.length-1}else{let l=null;n!==i+1||o!==t?(this._values=l=[],a.push([n,l])):l=this._values,l.push(r)}return this._minorIndex=n,this}build(){const t=this._tuples;if(t.length===0)return null;const n=this._minors;this._minorMin=Math.min(this._minorMin,n[0][0]);const r=n[n.length-1];this._minorMax=Math.max(this._minorMax,r[0]+r[1].length-1);const o=this._createList;if(o){const i=n.length;for(let a=0;a<i;a++)n[a][1]=o(n[a][1])}return{tuples:t,bounds:{majorStart:t[0][0],minorStart:this._minorMin,majorEnd:t[t.length-1][0],minorEnd:this._minorMax}}}},s.TransposedBuilder=class{constructor(t,n=0,r=0){this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=0,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._offsetMajor=0,this._offsetMinor=0,this._createList=t,this._offsetMajor=n,this._offsetMinor=r,this._minors=new Se}addValues(t,n,r){Array.isArray(r)||(r=[r]);const o=r.length;for(let i=0;i<o;i++){const a=n+i;this.addValue(t,a,r[i])}return this}addValue(t,n,r){let o,i;const a=this._majorIndex;let l=this._minorIndex;if(t+=this._offsetMajor,n+=this._offsetMinor,i=this._current,t!==a){if(this._majorIndex=t,t<a)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);l=Number.MIN_SAFE_INTEGER}else if(i=this._current,n<=l)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);if(i&&i.minor===n&&(o=i.span),o)i.minor>=n&&i.next&&(this._current=i.next);else{const g=this._minors,m=i?i.next??i.prev:null;if(m){let f;const _=m.minor;m&&m.minor===n?(i=m,o=i.span):f=_>n?g.getPairOrNextHigher(n,nh):g.getPairOrNextLower(n,nh),f&&(i=f[1],f[0]===n&&(o=i.span))}if(!o){this._majorMin=Math.min(this._majorMin,t),o=[n,[[t,[]]]];const f={minor:n,span:o,prev:null,next:null};i&&(i.minor<n?(f.prev=i,f.next=i.next,i.next&&(i.next.prev=f),i.next=f):(f.prev=i.prev,f.next=i,i.prev&&(i.prev.next=f),i.prev=f)),g.set(n,f),this._current=f;const _=this._first;(!_||n<_.minor)&&(this._first=f),f.next&&(this._current=f.next)}}let c=o[1];const h=c[c.length-1];let u=h[0],d=h[1];return u+d.length!==t&&(d=[],u=t,c.push([u,d])),d.push(r),this._majorMax=Math.max(this._majorMax,t),this._minorIndex=n,this}build(){const t=[],n=this._createList,r=this._minors.entries(void 0,ip);let o=r.next();for(;!o.done;){const i=o.value[1].span;if(n)for(let a=0;a<i.length;a++)i[a][1]=this._createList(i[a][1]);t.push(i),o=r.next()}return t.length===0?null:{tuples:t,bounds:{majorStart:t[0][0],minorStart:this._majorMin,majorEnd:t[t.length-1][0],minorEnd:this._majorMax}}}};class e extends Ur{constructor(n="Out of order",r=null){super(n,r),this.name="OutOfOrderError"}}s.OutOfOrderError=e})(exports.Tuple||(exports.Tuple={}));const ap={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function da(s){return(e={})=>{const t=e.width?String(e.width):s.defaultWidth;return s.formats[t]||s.formats[s.defaultWidth]}}const lp={date:da({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:da({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:da({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},cp={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function eo(s){return(e,t)=>{let n;if((t?.context?String(t.context):"standalone")==="formatting"&&s.formattingValues){const r=s.defaultFormattingWidth||s.defaultWidth,o=t?.width?String(t.width):r;n=s.formattingValues[o]||s.formattingValues[r]}else{const r=s.defaultWidth,o=t?.width?String(t.width):s.defaultWidth;n=s.values[o]||s.values[r]}return n[s.argumentCallback?s.argumentCallback(e):e]}}function to(s){return(e,t={})=>{const n=t.width,r=n&&s.matchPatterns[n]||s.matchPatterns[s.defaultMatchWidth],o=e.match(r);if(!o)return null;const i=o[0],a=n&&s.parsePatterns[n]||s.parsePatterns[s.defaultParseWidth],l=Array.isArray(a)?function(h,u){for(let d=0;d<h.length;d++)if(u(h[d]))return d}(a,h=>h.test(i)):function(h,u){for(const d in h)if(Object.prototype.hasOwnProperty.call(h,d)&&u(h[d]))return d}(a,h=>h.test(i));let c;return c=s.valueCallback?s.valueCallback(l):l,c=t.valueCallback?t.valueCallback(c):c,{value:c,rest:e.slice(i.length)}}}var no;const hp={code:"en-US",formatDistance:(s,e,t)=>{let n;const r=ap[s];return n=typeof r=="string"?r:e===1?r.one:r.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n},formatLong:lp,formatRelative:(s,e,t,n)=>cp[s],localize:{ordinalNumber:(s,e)=>{const t=Number(s),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:eo({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:eo({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:s=>s-1}),month:eo({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:eo({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:eo({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(no={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:s=>parseInt(s,10)},(s,e={})=>{const t=s.match(no.matchPattern);if(!t)return null;const n=t[0],r=s.match(no.parsePattern);if(!r)return null;let o=no.valueCallback?no.valueCallback(r[0]):r[0];return o=e.valueCallback?e.valueCallback(o):o,{value:o,rest:s.slice(n.length)}}),era:to({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:to({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:s=>s+1}),month:to({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:to({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:to({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},rh=(s,e)=>{switch(s){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},oh=(s,e)=>{switch(s){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},sh={p:oh,P:(s,e)=>{const t=s.match(/(P+)(p+)?/)||[],n=t[1],r=t[2];if(!r)return rh(s,e);let o;switch(n){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"})}return o.replace("{{date}}",rh(n,e)).replace("{{time}}",oh(r,e))}},up=/^D+$/,dp=/^Y+$/,gp=["D","DD","YY","YYYY"];function mp(s){return up.test(s)}function fp(s){return dp.test(s)}function ih(s,e,t){const n=function(r,o,i){const a=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${o}\`) for formatting ${a} to the input \`${i}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(s,e,t);if(console.warn(n),gp.includes(s))throw new RangeError(n)}const ah=Symbol.for("constructDateFrom");function kr(s,e){return typeof s=="function"?s(e):s&&typeof s=="object"&&ah in s?s[ah](e):s instanceof Date?new s.constructor(e):new Date(e)}let pp={};function Ag(){return pp}function yi(s,e){return kr(e||s,s)}class Mg{constructor(){this.subPriority=0}validate(e,t){return!0}}class _p extends Mg{constructor(e,t,n,r,o){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=r,o&&(this.subPriority=o)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}}class Sp extends Mg{constructor(e,t){super(),this.priority=10,this.subPriority=-1,this.context=e||(n=>kr(t,n))}set(e,t){return t.timestampIsSet?e:kr(e,function(n,r){const o=function(i){return typeof i=="function"&&i.prototype?.constructor===i}(r)?new r(0):kr(r,0);return o.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),o.setHours(n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),o}(e,this.context))}}let Hs=class{run(s,e,t,n){const r=this.parse(s,e,t,n);return r?{setter:new _p(r.value,this.validate,this.set,this.priority,this.subPriority),rest:r.rest}:null}validate(s,e,t){return!0}};const Tg=/^(1[0-2]|0?\d)/,wp=/^(3[0-1]|[0-2]?\d)/,yp=/^\d/,Cp=/^\d{1,2}/,bp=/^\d{1,3}/,Ep=/^\d{1,4}/;function wn(s,e){return s&&{value:e(s.value),rest:s.rest}}function Bn(s,e){const t=e.match(s);return t?{value:parseInt(t[0],10),rest:e.slice(t[0].length)}:null}function Lo(s,e){switch(s){case 1:return Bn(yp,e);case 2:return Bn(Cp,e);case 3:return Bn(bp,e);case 4:return Bn(Ep,e);default:return Bn(new RegExp("^\\d{1,"+s+"}"),e)}}class Fg extends Hs{constructor(){super(...arguments),this.incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"],this.priority=110}parse(e,t,n){const r=o=>o-1;switch(t){case"M":return wn(Bn(Tg,e),r);case"MM":return wn(Lo(2,e),r);case"Mo":return wn(n.ordinalNumber(e,{unit:"month"}),r);case"MMM":return n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(e,{width:"narrow",context:"formatting"});default:return n.month(e,{width:"wide",context:"formatting"})||n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}}const vp=[31,28,31,30,31,30,31,31,30,31,30,31],xp=[31,29,31,30,31,30,31,31,30,31,30,31];function Ip(s,e,t){const n=Ag(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=yi(s,t?.in),i=o.getDay(),a=7-r;return function(l,c,h){const u=yi(l,h?.in);return isNaN(c)?kr(h?.in||l,NaN):(c&&u.setDate(u.getDate()+c),u)}(o,e<0||e>6?e-(i+a)%7:((e%7+7)%7+a)%7-(i+a)%7,t)}const Eo={y:new class extends Hs{constructor(){super(...arguments),this.priority=130,this.incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"]}parse(s,e,t){const n=r=>({year:r,isTwoDigitYear:e==="yy"});switch(e){case"y":return wn(Lo(4,s),n);case"yo":return wn(t.ordinalNumber(s,{unit:"year"}),n);default:return wn(Lo(e.length,s),n)}}validate(s,e){return e.isTwoDigitYear||e.year>0}set(s,e,t){const n=s.getFullYear();if(t.isTwoDigitYear){const o=function(i,a){const l=a>0,c=l?a:1-a;let h;if(c<=50)h=i||100;else{const u=c+50;h=i+100*Math.trunc(u/100)-(i>=u%100?100:0)}return l?h:1-h}(t.year,n);return s.setFullYear(o,0,1),s.setHours(0,0,0,0),s}const r="era"in e&&e.era!==1?1-t.year:t.year;return s.setFullYear(r,0,1),s.setHours(0,0,0,0),s}},M:new Fg,d:new class extends Hs{constructor(){super(...arguments),this.priority=90,this.subPriority=1,this.incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]}parse(s,e,t){switch(e){case"d":return Bn(wp,s);case"do":return t.ordinalNumber(s,{unit:"date"});default:return Lo(e.length,s)}}validate(s,e){const t=function(r){return r%400==0||r%4==0&&r%100!=0}(s.getFullYear()),n=s.getMonth();return t?e>=1&&e<=xp[n]:e>=1&&e<=vp[n]}set(s,e,t){return s.setDate(t),s.setHours(0,0,0,0),s}},E:new class extends Hs{constructor(){super(...arguments),this.priority=90,this.incompatibleTokens=["D","i","e","c","t","T"]}parse(s,e,t){switch(e){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"})||t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})||t.day(s,{width:"abbreviated",context:"formatting"})||t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"})}}validate(s,e){return e>=0&&e<=6}set(s,e,t,n){return(s=Ip(s,t,n)).setHours(0,0,0,0),s}}},Rp=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ap=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Mp=/^'([^]*?)'?$/,Tp=/''/g,Fp=/\S/,Np=/[a-zA-Z]/;function kp(s,e,t,n){const r=()=>kr(n?.in||t,NaN),o=Object.assign({},Ag()),i=n?.locale??o.locale??hp,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0;if(!e)return s?r():yi(t,n?.in);const c={firstWeekContainsDate:a,weekStartsOn:l,locale:i},h=[new Sp(n?.in,t)],u=e.match(Ap).map(_=>{const p=_[0];return p in sh?(0,sh[p])(_,i.formatLong):_}).join("").match(Rp),d=[];for(let _ of u){!n?.useAdditionalWeekYearTokens&&fp(_)&&ih(_,e,s),!n?.useAdditionalDayOfYearTokens&&mp(_)&&ih(_,e,s);const p=_[0],S=Eo[p];if(S){const{incompatibleTokens:C}=S;if(Array.isArray(C)){const b=d.find(w=>C.includes(w.token)||w.token===p);if(b)throw new RangeError(`The format string mustn't contain \`${b.fullToken}\` and \`${_}\` at the same time`)}else if(S.incompatibleTokens==="*"&&d.length>0)throw new RangeError(`The format string mustn't contain \`${_}\` and any other token at the same time`);d.push({token:p,fullToken:_});const y=S.run(s,_,i.match,c);if(!y)return r();h.push(y.setter),s=y.rest}else{if(p.match(Np))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");if(_==="''"?_="'":p==="'"&&(_=Op(_)),s.indexOf(_)!==0)return r();s=s.slice(_.length)}}if(s.length>0&&Fp.test(s))return r();const g=h.map(_=>_.priority).sort((_,p)=>p-_).filter((_,p,S)=>S.indexOf(_)===p).map(_=>h.filter(p=>p.priority===_).sort((p,S)=>S.subPriority-p.subPriority)).map(_=>_[0]);let m=yi(t,n?.in);if(isNaN(+m))return r();const f={};for(const _ of g){if(!_.validate(m,c))return r();const p=_.set(m,f,c);Array.isArray(p)?(m=p[0],Object.assign(f,p[1])):m=p}return m}function Op(s){return s.match(Mp)[1].replace(Tp,"'")}const Ng=s=>!isNaN(s)&&(Object.prototype.toString.call(s)==="[object Date]"||s instanceof Date);function lh(s,e,t){let n=s,r=s.length,o=e.length;for(var i=r;i<o;++i){const a=e[i];if(a==="#")return n;n=t?n+a:a+n}return n}function vt(s,e){for(var t="";t.length<e;)t+=s;return t}function Or(s){for(var e="",t=s.length-1;t>=0;)e+=s.charAt(t--);return e}function kt(s,e){var t=""+s;return t.length>=e?t:vt("0",e-t.length)+t}function Ml(s,e){var t=""+s;return t.length>=e?t:vt(" ",e-t.length)+t}function Ci(s,e){var t=""+s;return t.length>=e?t:t+vt(" ",e-t.length)}var ch=Math.pow(2,32);function fr(s,e){return s>ch||s<-ch?function(t,n){var r=""+Math.round(t);return r.length>=n?r:vt("0",n-r.length)+r}(s,e):function(t,n){var r=""+t;return r.length>=n?r:vt("0",n-r.length)+r}(Math.round(s),e)}function Vs(s,e){return e=e||0,s.length>=7+e&&(32|s.charCodeAt(e))==103&&(32|s.charCodeAt(e+1))==101&&(32|s.charCodeAt(e+2))==110&&(32|s.charCodeAt(e+3))==101&&(32|s.charCodeAt(e+4))==114&&(32|s.charCodeAt(e+5))==97&&(32|s.charCodeAt(e+6))==108}var hh=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],ga=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]],Zn={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",5:"$#,##0_);($#,##0)",6:"$#,##0_);[Red]($#,##0)",7:"$#,##0.00_);($#,##0.00)",8:"$#,##0.00_);[Red]($#,##0.00)",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",23:"General",24:"General",25:"General",26:"General",27:"m/d/yyyy",28:"m/d/yyyy",29:"m/d/yyyy",30:"m/d/yyyy",32:"h:mm:ss",31:"m/d/yyyy",33:"h:mm:ss",34:"h:mm:ss",35:"h:mm:ss",36:"m/d/yyyy",37:"#,##0_);(#,##0)",38:"#,##0_);[Red](#,##0)",39:"#,##0.00_);(#,##0.00)",40:"#,##0.00_);[Red](#,##0.00)",41:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',42:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)',43:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',44:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@",50:"m/d/yyyy",51:"m/d/yyyy",52:"m/d/yyyy",53:"m/d/yyyy",54:"m/d/yyyy",55:"m/d/yyyy",56:'"上午/下午 "hh"時"mm"分"ss"秒 "'},uh={5:37,6:38,7:39,8:40,23:0,24:0,25:0,26:0,27:14,28:14,29:14,30:14,31:14,50:14,51:14,52:14,53:14,54:14,55:14,56:14,57:14,58:14,59:1,60:2,61:3,62:4,67:9,68:10,69:12,70:13,71:14,72:14,73:15,74:16,75:17,76:20,77:21,78:22,79:45,80:46,81:47,82:0},Bp={5:'"$"#,##0_);\\("$"#,##0\\)',63:'"$"#,##0_);\\("$"#,##0\\)',6:'"$"#,##0_);[Red]\\("$"#,##0\\)',64:'"$"#,##0_);[Red]\\("$"#,##0\\)',7:'"$"#,##0.00_);\\("$"#,##0.00\\)',65:'"$"#,##0.00_);\\("$"#,##0.00\\)',8:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',66:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',41:'_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',42:'_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',43:'_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',44:'_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'};function bi(s,e,t){for(var n=s<0?-1:1,r=s*n,o=0,i=1,a=0,l=1,c=0,h=0,u=Math.floor(r);c<e&&(a=(u=Math.floor(r))*i+o,h=u*c+l,!(r-u<5e-8));)r=1/(r-u),o=i,i=a,l=c,c=h;if(h>e&&(c>e?(h=l,a=o):(h=c,a=i)),!t)return[0,n*a,h];var d=Math.floor(n*a/h);return[d,n*a-d*h,h]}function vo(s,e,t){if(s>2958465||s<0)return null;var n=0|s,r=Math.floor(86400*(s-n)),o=0,i=[],a={D:n,T:r,u:86400*(s-n)-r,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(a.u)<1e-6&&(a.u=0),e&&e.date1904&&(n+=1462),a.u>.9999&&(a.u=0,++r===86400&&(a.T=r=0,++n,++a.D)),n===60)i=t?[1317,10,29]:[1900,2,29],o=3;else if(n===0)i=t?[1317,8,29]:[1900,1,0],o=6;else{n>60&&--n;var l=new Date(1900,0,1);l.setDate(l.getDate()+n-1),i=[l.getFullYear(),l.getMonth()+1,l.getDate()],o=l.getDay(),n<60&&(o=(o+6)%7),t&&(o=function(c,h){h[0]-=581;var u=c.getDay();return c<60&&(u=(u+6)%7),u}(l,i))}return a.y=i[0],a.m=i[1],a.d=i[2],a.S=r%60,r=Math.floor(r/60),a.M=r%60,r=Math.floor(r/60),a.H=r,a.q=o,a}var kg=new Date(1899,11,31,0,0,0),Dp=kg.getTime(),Lp=new Date(1900,2,1,0,0,0);function oc(s,e=!1){var t=s.getTime();return e?t-=1262304e5:s>=Lp&&(t+=864e5),(t-(Dp+6e4*(s.getTimezoneOffset()-kg.getTimezoneOffset())))/864e5}function ma(s){return s.indexOf(".")===-1?s:s.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function Pp(s){var e,t=Math.floor(Math.log(Math.abs(s))*Math.LOG10E);return e=t>=-4&&t<=-1?s.toPrecision(10+t):Math.abs(t)<=9?function(n){var r=n<0?12:11,o=ma(n.toFixed(12));return o.length<=r||(o=n.toPrecision(10)).length<=r?o:n.toExponential(5)}(s):t===10?s.toFixed(10).substr(0,12):function(n){var r=ma(n.toFixed(11));return r.length>(n<0?12:11)||r==="0"||r==="-0"?n.toPrecision(6):r}(s),ma(function(n){return n.indexOf("E")===-1?n:n.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}(e.toUpperCase()))}function fa(s,e){switch(typeof s){case"string":return s;case"boolean":return s?"TRUE":"FALSE";case"number":return(0|s)===s?s.toString(10):Pp(s);case"undefined":return"";case"object":if(s==null)return"";if(Ng(s))return $g(14,oc(s,e&&e.date1904),e)}throw new Error("unsupported value in General format: "+s)}function zp(s,e,t,n){var r,o="",i=0,a=0,l=t.y,c=0;switch(s){case 98:l=t.y+543;case 121:switch(e.length){case 1:case 2:r=l%100,c=2;break;default:r=l%1e4,c=4}break;case 109:switch(e.length){case 1:case 2:r=t.m,c=e.length;break;case 3:return ga[t.m-1][1];case 5:return ga[t.m-1][0];default:return ga[t.m-1][2]}break;case 100:switch(e.length){case 1:case 2:r=t.d,c=e.length;break;case 3:return hh[t.q][0];default:return hh[t.q][1]}break;case 104:switch(e.length){case 1:case 2:r=1+(t.H+11)%12,c=e.length;break;default:throw new Error("bad hour format: "+e)}break;case 72:switch(e.length){case 1:case 2:r=t.H,c=e.length;break;default:throw new Error("bad hour format: "+e)}break;case 77:switch(e.length){case 1:case 2:r=t.M,c=e.length;break;default:throw new Error("bad minute format: "+e)}break;case 115:if(e!=="s"&&e!=="ss"&&e!==".0"&&e!==".00"&&e!==".000")throw new Error("bad second format: "+e);return t.u!==0||e!=="s"&&e!=="ss"?(a=n>=2?n===3?1e3:100:n===1?10:1,(i=Math.round(a*(t.S+t.u)))>=60*a&&(i=0),e==="s"?i===0?"0":""+i/a:(o=kt(i,2+n),e==="ss"?o.substr(0,2):"."+o.substr(2,e.length-1))):kt(t.S,e.length);case 90:switch(e){case"[h]":case"[hh]":r=24*t.D+t.H;break;case"[m]":case"[mm]":r=60*(24*t.D+t.H)+t.M;break;case"[s]":case"[ss]":r=60*(60*(24*t.D+t.H)+t.M)+Math.round(t.S+t.u);break;default:throw new Error("bad absolute time format: "+e)}c=e.length===3?1:2;break;case 101:r=l,c=1}return c>0?kt(r,c):""}function Dn(s){if(s.length<=3)return s;for(var e=s.length%3,t=s.substr(0,e);e!==s.length;e+=3)t+=(t.length>0?",":"")+s.substr(e,3);return t}var Og=/%/g;function Bg(s,e){var t,n=s.indexOf("E")-s.indexOf(".")-1;if(s.match(/^#+0.0E\+0$/)){if(e===0)return"0.0E+0";if(e<0)return"-"+Bg(s,-e);var r=s.indexOf(".");r===-1&&(r=s.indexOf("E"));var o=Math.floor(Math.log(e)*Math.LOG10E)%r;if(o<0&&(o+=r),(t=(e/Math.pow(10,o)).toPrecision(n+1+(r+o)%r)).indexOf("e")===-1){var i=Math.floor(Math.log(e)*Math.LOG10E);for(t.indexOf(".")===-1?t=t.charAt(0)+"."+t.substr(1)+"E+"+(i-t.length+o):t+="E+"+(i-o);t.substr(0,2)==="0.";)t=(t=t.charAt(0)+t.substr(2,r)+"."+t.substr(2+r)).replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");t=t.replace(/\+-/,"-")}t=t.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(a,l,c,h){return l+c+h.substr(0,(r+o)%r)+"."+h.substr(o)+"E"})}else t=e.toExponential(n);return s.match(/E\+00$/)&&t.match(/e[+-]\d$/)&&(t=t.substr(0,t.length-1)+"0"+t.charAt(t.length-1)),s.match(/E-/)&&t.match(/e\+/)&&(t=t.replace(/e\+/,"e")),t.replace("e","E")}var Dg=/[0#?] (\?+)( ?)\/( ?)(\d+)/,Lg=/^([0#?]+)\.([0#?]+)/,Pg=/\).*[0#]/,zg=/\(###\) ###\\?-####/;function Tt(s){var e="";let t,n=s.length;for(var r=0;r!==n;++r)switch(t=s.charAt(r),t){case"#":break;case" ":e+=" ";break;case"0":e+="0";break;case"?":e+="?";break;default:e+=String.fromCharCode(cc)}return e}function dh(s,e){var t=Math.pow(10,e);return""+Math.round(s*t)/t}function gh(s,e){var t=Math.pow(10,e);return Math.round(s*t)/t}function mh(s,e){var t=s-Math.floor(s),n=Math.pow(10,e);return e<(""+Math.round(t*n)).length?0:Math.round(t*n)}function yt(s,e,t){if(s.charCodeAt(0)===40&&!e.match(Pg)){var n=e.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return t>=0?yt("n",n,t):"("+yt("n",n,-t)+")"}if(e.charCodeAt(e.length-1)===44)return function(f,_,p){let S=_.length-1;for(;_.charCodeAt(S-1)===44;)--S;return yn(f,_.substr(0,S),p/Math.pow(10,3*(_.length-S)))}(s,e,t);if(e.indexOf("%")!==-1)return function(f,_,p){let S=_.replace(Og,""),C=_.length-S.length;return yn(f,S,p*Math.pow(10,2*C))+vt("%",C)}(s,e,t);if(e.indexOf("E")!==-1)return Bg(e,t);if(e.charCodeAt(0)===36)return"$"+yt(s,e.substr(e.charAt(1)===" "?2:1),t);var r,o,i,a,l=Math.abs(t),c=t<0?"-":"";if(e.match(/^00+$/))return c+fr(l,e.length);if(e.match(/^[#?]+$/))return(r=fr(t,0))==="0"&&(r=""),r.length>e.length?r:Tt(e.substr(0,e.length-r.length))+r;if(o=e.match(Dg))return function(f,_,p){var S=parseInt(f[4],10),C=Math.round(_*S),y=Math.floor(C/S),b=C-y*S,w=S;return p+(y===0?"":""+y)+" "+(b===0?vt(" ",f[1].length+1+f[4].length):Ml(b,f[1].length)+f[2]+"/"+f[3]+kt(w,f[4].length))}(o,l,c);if(e.match(/^#+0+$/))return c+fr(l,e.length-e.indexOf("0"));if(o=e.match(Lg)){i=Math.trunc(dh(t,o[2].length));var h=function(f){if(!isFinite(f))return 0;for(var _=1,p=0;Math.round(f*_)/_!==f;)_*=10,p++;return p}(a=gh(Math.abs(i-t),o[2].length));return a=(a=""+gh(a,h)).replace(/^0\./,""),r=lh(""+Math.abs(i),o[1])+"."+lh(""+a,o[2],!0),r=e.indexOf("0.")!==-1?r:r.replace(/^0\./,"."),t<0?"-"+r:r}if(o=(e=e.replace(/^#+([0.])/,"$1")).match(/^(0*)\.(#*)$/))return c+dh(l,o[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,o[1].length?"0.":".");if(o=e.match(/^#{1,3},##0(\.?)$/))return c+Dn(fr(l,0));if(o=e.match(/^#,##0\.([#0]*0)$/))return t<0?"-"+yt(s,e,-t):Dn(""+(Math.floor(t)+function(f,_){return _<(""+Math.round((f-Math.floor(f))*Math.pow(10,_))).length?1:0}(t,o[1].length)))+"."+kt(mh(t,o[1].length),o[1].length);if(o=e.match(/^#,#*,#0/))return yt(s,e.replace(/^#,#*,/,""),t);if(o=e.match(/^([0#]+)(\\?-([0#]+))+$/))return r=Or(yt(s,e.replace(/[\\-]/g,""),t)),i=0,Or(Or(e.replace(/\\/g,"")).replace(/[0#]/g,function(f){return i<r.length?r.charAt(i++):f==="0"?"0":""}));if(e.match(zg))return"("+(r=yt(s,"##########",t)).substr(0,3)+") "+r.substr(3,3)+"-"+r.substr(6);var u="";if(o=e.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(o[4].length,7),a=bi(l,Math.pow(10,i)-1,!1),r=""+c,(u=yn("n",o[1],a[1])).charAt(u.length-1)===" "&&(u=u.substr(0,u.length-1)+"0"),r+=u+o[2]+"/"+o[3],(u=Ci(a[2],i)).length<o[4].length&&(u=Tt(o[4].substr(o[4].length-u.length))+u),r+=u;if(o=e.match(/[#0?] ([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(Math.max(o[1].length,o[4].length),7),a=bi(l,Math.pow(10,i)-1,!0),c+yt(s,e.substring(0,o.index+1),a[0])+" "+(a[1]?Ml(a[1],i)+o[2]+"/"+o[3]+Ci(a[2],i):vt(" ",2*i+1+o[2].length+o[3].length));if(o=e.match(/^[#0?]+$/))return r=fr(t,0),e.length<=r.length?r:Tt(e.substr(0,e.length-r.length))+r;if(o=e.match(/^([#0?]+)\.([#0]+)$/)){r=""+t.toFixed(Math.min(o[2].length,10)).replace(/([^0])0+$/,"$1"),i=r.indexOf(".");var d=e.indexOf(".")-i,g=e.length-r.length-d;return Tt(e.substr(0,d)+r+e.substr(e.length-g))}if(o=e.match(/^00,000\.([#0]*0)$/))return i=mh(t,o[1].length),t<0?"-"+yt(s,e,-t):Dn(function(f){return f<2147483647&&f>-2147483648?""+(f>=0?0|f:f-1|0):""+Math.floor(f)}(t)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(f){return"00,"+(f.length<3?kt(0,3-f.length):"")+f})+"."+kt(i,o[1].length);switch(e){case"###,##0.00":return yt(s,"#,##0.00",t);case"###,###":case"##,###":case"#,###":var m=Dn(fr(l,0));return m!=="0"?c+m:"";case"###,###.00":return yt(s,"###,##0.00",t).replace(/^0\./,".");case"#,###.00":return yt(s,"#,##0.00",t).replace(/^0\./,".")}throw new Error("unsupported format |"+e+"|")}function jg(s,e){var t,n=s.indexOf("E")-s.indexOf(".")-1;if(s.match(/^#+0.0E\+0$/)){if(e===0)return"0.0E+0";if(e<0)return"-"+jg(s,-e);var r=s.indexOf(".");r===-1&&(r=s.indexOf("E"));var o=Math.floor(Math.log(e)*Math.LOG10E)%r;if(o<0&&(o+=r),!(t=(e/Math.pow(10,o)).toPrecision(n+1+(r+o)%r)).match(/[Ee]/)){var i=Math.floor(Math.log(e)*Math.LOG10E);t.indexOf(".")===-1?t=t.charAt(0)+"."+t.substr(1)+"E+"+(i-t.length+o):t+="E+"+(i-o),t=t.replace(/\+-/,"-")}t=t.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(a,l,c,h){return l+c+h.substr(0,(r+o)%r)+"."+h.substr(o)+"E"})}else t=e.toExponential(n);return s.match(/E\+00$/)&&t.match(/e[+-]\d$/)&&(t=t.substr(0,t.length-1)+"0"+t.charAt(t.length-1)),s.match(/E-/)&&t.match(/e\+/)&&(t=t.replace(/e\+/,"e")),t.replace("e","E")}function Jt(s,e,t){if(s.charCodeAt(0)===40&&!e.match(Pg)){var n=e.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return t>=0?Jt("n",n,t):"("+Jt("n",n,-t)+")"}if(e.charCodeAt(e.length-1)===44)return function(m,f,_){for(var p=f.length-1;f.charCodeAt(p-1)===44;)--p;return yn(m,f.substr(0,p),_/Math.pow(10,3*(f.length-p)))}(s,e,t);if(e.indexOf("%")!==-1)return function(m,f,_){var p=f.replace(Og,""),S=f.length-p.length;return yn(m,p,_*Math.pow(10,2*S))+vt("%",S)}(s,e,t);if(e.indexOf("E")!==-1)return jg(e,t);if(e.charCodeAt(0)===36)return"$"+Jt(s,e.substr(e.charAt(1)===" "?2:1),t);var r,o,i,a,l=Math.abs(t),c=t<0?"-":"";if(e.match(/^00+$/))return c+kt(l,e.length);if(e.match(/^[#?]+$/))return r=""+t,t===0&&(r=""),r.length>e.length?r:Tt(e.substr(0,e.length-r.length))+r;if(o=e.match(Dg))return function(m,f,_){return _+(f===0?"":""+f)+vt(" ",m[1].length+2+m[4].length)}(o,l,c);if(e.match(/^#+0+$/))return c+kt(l,e.length-e.indexOf("0"));if(o=e.match(Lg))return r=(""+t).replace(/^([^.]+)$/,"."+Tt(o[2])).replace(/\.$/,"."+Tt(o[2])),r=kt(Math.abs(t),o[1].length)+r.replace(/\.(\d*)$/,function(m,f){return"."+f+vt("0",Tt(o[2]).length-f.length)}),r=e.indexOf("0.")!==-1?r:r.replace(/^0\./,"."),t<0?"-"+r:r;if(e=e.replace(/^#+([0.])/,"$1"),o=e.match(/^(0*)\.(#*)$/))return c+(""+l).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,o[1].length?"0.":".");if(o=e.match(/^#{1,3},##0(\.?)$/))return c+Dn(""+l);if(o=e.match(/^#,##0\.([#0]*0)$/))return t<0?"-"+Jt(s,e,-t):Dn(""+t)+"."+vt("0",o[1].length);if(o=e.match(/^#,#*,#0/))return Jt(s,e.replace(/^#,#*,/,""),t);if(o=e.match(/^([0#]+)(\\?-([0#]+))+$/))return r=Or(Jt(s,e.replace(/[\\-]/g,""),t)),i=0,Or(Or(e.replace(/\\/g,"")).replace(/[0#]/g,function(m){return i<r.length?r.charAt(i++):m==="0"?"0":""}));if(e.match(zg))return"("+(r=Jt(s,"##########",t)).substr(0,3)+") "+r.substr(3,3)+"-"+r.substr(6);var h="";if(o=e.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(o[4].length,7),a=bi(l,Math.pow(10,i)-1,!1),r=""+c,(h=yn("n",o[1],a[1])).charAt(h.length-1)===" "&&(h=h.substr(0,h.length-1)+"0"),r+=h+o[2]+"/"+o[3],(h=Ci(a[2],i)).length<o[4].length&&(h=Tt(o[4].substr(o[4].length-h.length))+h),r+=h;if(o=e.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(Math.max(o[1].length,o[4].length),7),c+((a=bi(l,Math.pow(10,i)-1,!0))[0]||(a[1]?"":"0"))+" "+(a[1]?Ml(a[1],i)+o[2]+"/"+o[3]+Ci(a[2],i):vt(" ",2*i+1+o[2].length+o[3].length));if(o=e.match(/^[#0?]+$/))return r=""+t,e.length<=r.length?r:Tt(e.substr(0,e.length-r.length))+r;if(o=e.match(/^([#0]+)\.([#0]+)$/)){r=""+t.toFixed(Math.min(o[2].length,10)).replace(/([^0])0+$/,"$1"),i=r.indexOf(".");var u=e.indexOf(".")-i,d=e.length-r.length-u;return Tt(e.substr(0,u)+r+e.substr(e.length-d))}if(o=e.match(/^00,000\.([#0]*0)$/))return t<0?"-"+Jt(s,e,-t):Dn(""+t).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(m){return"00,"+(m.length<3?kt(0,3-m.length):"")+m})+"."+kt(0,o[1].length);switch(e){case"###,###":case"##,###":case"#,###":var g=Dn(""+l);return g!=="0"?c+g:"";default:if(e.match(/\.[0#?]*$/))return Jt(s,e.slice(0,e.lastIndexOf(".")),t)+Tt(e.slice(e.lastIndexOf(".")))}throw new Error("unsupported format |"+e+"|")}function yn(s,e,t){return(0|t)===t?Jt(s,e,t):yt(s,e,t)}function Wg(s){var e=[],t=!1;const n=s.length;for(var r=0,o=0;r<n;++r)switch(s.charCodeAt(r)){case 34:t=!t;break;case 95:case 42:case 92:++r;break;case 59:e[e.length]=s.substr(o,r-o),o=r+1}if(e[e.length]=s.substr(o),t===!0)throw new Error("Format |"+s+"| unterminated string ");return e}var Hg=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function Vg(s){for(var e=0,t="",n="",r=s.length;e<r;)switch(t=s.charAt(e)){case"G":Vs(s,e)&&(e+=6),e++;break;case'"':for(;s.charCodeAt(++e)!==34&&e<s.length;);++e;break;case"\\":case"_":e+=2;break;case"@":++e;break;case"B":case"b":if(s.charAt(e+1)==="1"||s.charAt(e+1)==="2")return!0;case"M":case"D":case"Y":case"H":case"S":case"E":case"m":case"d":case"y":case"h":case"s":case"e":case"g":return!0;case"A":case"a":case"上":if(s.substr(e,3).toUpperCase()==="A/P"||s.substr(e,5).toUpperCase()==="AM/PM"||s.substr(e,5).toUpperCase()==="上午/下午")return!0;++e;break;case"[":for(n=t;s.charAt(e++)!=="]"&&e<s.length;)n+=s.charAt(e);if(n.match(Hg))return!0;break;case".":case"0":case"#":for(;e<s.length&&("0#?.,E+-%".indexOf(t=s.charAt(++e))>-1||t==="\\"&&s.charAt(e+1)==="-"&&"0#".indexOf(s.charAt(e+2))>-1););break;case"?":for(;s.charAt(++e)===t;);break;case"*":++e,s.charAt(e)!==" "&&s.charAt(e)!=="*"||++e;break;case"(":case")":++e;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;e<s.length&&"0123456789".indexOf(s.charAt(++e))>-1;);break;default:++e}return!1}var fh=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function ph(s,e){if(e==null)return!1;var t=parseFloat(e[2]);switch(e[1]){case"=":if(s===t)return!0;break;case">":if(s>t)return!0;break;case"<":if(s<t)return!0;break;case"<>":if(s!==t)return!0;break;case">=":if(s>=t)return!0;break;case"<=":if(s<=t)return!0}return!1}function $g(s,e,t){t==null&&(t=F.EmptyObject);var n="";switch(typeof s){case"string":n=s==="m/d/yy"&&t.dateNF?t.dateNF:s;break;case"number":(n=s===14&&t.dateNF?t.dateNF:(t.table!=null?t.table:Zn)[s])==null&&(n=t.table&&t.table[uh[s]]||Zn[uh[s]]),n==null&&(n=Bp[s]||"General")}if(Vs(n,0))return fa(e,t);Ng(e)&&(e=oc(e,t.date1904));var r=function(o,i){var a=Wg(o),l=a.length,c=a[l-1].indexOf("@");if(c!==-1&&a[l-1][c-1]==="\\"&&(c=-1),l<4&&c>-1&&--l,a.length>4)throw new Error("We can't find right format for |"+a.join("|")+"|");if(typeof i!="number")return[4,a.length===4||c>-1?a[a.length-1]:"@"];switch(a.length){case 1:a=c>-1?["General","General","General",a[0]]:[a[0],a[0],a[0],"@"];break;case 2:a=c>-1?[a[0],a[0],a[0],a[1]]:[a[0],a[1],a[0],"@"];break;case 3:a=c>-1?[a[0],a[1],a[0],a[2]]:[a[0],a[1],a[2],"@"]}var h=i>0?a[0]:i<0?a[1]:a[2];if(a[0].indexOf("[")===-1&&a[1].indexOf("[")===-1)return[l,h];if(a[0].match(/\[[=<>]/)!=null||a[1].match(/\[[=<>]/)!=null){var u=a[0].match(fh),d=a[1].match(fh);return ph(i,u)?[l,a[0]]:ph(i,d)?[l,a[1]]:[l,a[u!=null&&d!=null?2:1]]}return[l,h]}(n,e);if(Vs(r[1]))return fa(e,t);if(e===!0)e="TRUE";else if(e===!1)e="FALSE";else if(e===""||e==null)return"";return function(o,i,a,l){var c,h,u,d=[],g="",m=0,f="",_="t",p="H";let S=o.length;for(;m<S;)switch(f=o.charAt(m)){case"G":if(!Vs(o,m))throw new Error("unrecognized character "+f+" in "+o);d[d.length]={t:"G",v:"General"},m+=7;break;case'"':for(g="";(u=o.charCodeAt(++m))!==34&&m<o.length;)g+=String.fromCharCode(u);d[d.length]={t:"t",v:g},++m;break;case"\\":var C=o.charAt(++m),y=C==="("||C===")"?C:"t";d[d.length]={t:y,v:C},++m;break;case"@":d[d.length]={t:"T",v:i},++m;break;case"B":case"b":if(o.charAt(m+1)==="1"||o.charAt(m+1)==="2"){if(c==null&&(c=vo(i,a,o.charAt(m+1)==="2"))==null)return"";d[d.length]={t:"X",v:o.substr(m,2)},_=f,m+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":f=f.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(i<0||c==null&&(c=vo(i,a))==null)return"";for(g=f;++m<o.length&&o.charAt(m).toLowerCase()===f;)g+=f;f==="m"&&_.toLowerCase()==="h"&&(f="M"),f==="h"&&(f=p),d[d.length]={t:f,v:g},_=f;break;case"A":case"a":case"上":var b={t:f,v:f};if(c==null&&(c=vo(i,a)),o.substr(m,3).toUpperCase()==="A/P"?(c!=null&&(b.v=c.H>=12?"P":"A"),b.t="T",p="h",m+=3):o.substr(m,5).toUpperCase()==="AM/PM"?(c!=null&&(b.v=c.H>=12?"PM":"AM"),b.t="T",m+=5,p="h"):o.substr(m,5).toUpperCase()==="上午/下午"?(c!=null&&(b.v=c.H>=12?"下午":"上午"),b.t="T",m+=5,p="h"):(b.t="t",++m),c==null&&b.t==="T")return"";d[d.length]=b,_=f;break;case"[":for(g=f;o.charAt(m++)!=="]"&&m<o.length;)g+=o.charAt(m);if(g.slice(-1)!=="]")throw new Error('unterminated "[" block: |'+g+"|");if(g.match(Hg)){if(c==null&&(c=vo(i,a))==null)return"";d[d.length]={t:"Z",v:g.toLowerCase()},_=g.charAt(1)}else g.indexOf("$")>-1&&(g=(g.match(/\$([^-[\]]*)/)||[])[1]||"$",Vg(o)||(d[d.length]={t:"t",v:g}));break;case".":if(c!=null){for(g=f;++m<o.length&&(f=o.charAt(m))==="0";)g+=f;d[d.length]={t:"s",v:g};break}case"0":case"#":for(g=f;++m<o.length&&"0#?.,E+-%".indexOf(f=o.charAt(m))>-1;)g+=f;d[d.length]={t:"n",v:g};break;case"?":for(g=f;o.charAt(++m)===f;)g+=f;d[d.length]={t:f,v:g},_=f;break;case"*":if(++m,!(g=o.charAt(m)))throw new Error("no character specified for repeat function: "+o);d[d.length]={t:"R",v:g},++m;break;case"_":if(++m,!(g=o.charAt(m)))throw new Error("no character specified for spacing function: "+o);d[d.length]={t:"S",v:g},++m;break;case"(":case")":d[d.length]={t:l===1?"t":f,v:f},++m;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(g=f;m<o.length&&"0123456789".indexOf(o.charAt(++m))>-1;)g+=o.charAt(m);d[d.length]={t:"D",v:g};break;case" ":d[d.length]={t:f,v:f},++m;break;case"$":d[d.length]={t:"t",v:"$"},++m;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(f)===-1)throw new Error("unrecognized character "+f+" in "+o);d[d.length]={t:"t",v:f},++m}var w,E=0,x=0;for(m=d.length-1,_="t";m>=0;--m)switch(d[m].t){case"h":case"H":d[m].t=p,_="h",E<1&&(E=1);break;case"s":(w=d[m].v.match(/\.0+$/))&&(x=Math.max(x,w[0].length-1)),E<3&&(E=3);case"d":case"y":case"M":case"e":_=d[m].t;break;case"m":_==="s"&&(d[m].t="M",E<2&&(E=2));break;case"X":break;case"Z":E<1&&d[m].v.match(/[Hh]/)&&(E=1),E<2&&d[m].v.match(/[Mm]/)&&(E=2),E<3&&d[m].v.match(/[Ss]/)&&(E=3)}switch(E){case 0:break;case 1:c.u>=.5&&(c.u=0,++c.S),c.S>=60&&(c.S=0,++c.M),c.M>=60&&(c.M=0,++c.H);break;case 2:c.u>=.5&&(c.u=0,++c.S),c.S>=60&&(c.S=0,++c.M)}var I,v="";for(S=d.length,m=0;m<S;++m)switch(d[m].t){case"t":case"T":case" ":case"D":break;case"X":d[m].v="",d[m].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":d[m].v=zp(d[m].t.charCodeAt(0),d[m].v,c,x),d[m].t="t";break;case"n":case"?":for(I=m+1;d[I]!=null&&((f=d[I].t)==="?"||f==="D"||(f===" "||f==="t")&&d[I+1]!=null&&(d[I+1].t==="?"||d[I+1].t==="t"&&d[I+1].v==="/")||d[m].t==="("&&(f===" "||f==="n"||f===")")||f==="t"&&(d[I].v==="/"||d[I].v===" "&&d[I+1]!=null&&d[I+1].t==="?"));)d[m].v+=d[I].v,d[I]={v:"",t:";"},++I;v+=d[m].v,m=I-1;break;case"G":d[m].t="t",d[m].v=fa(i,a)}var R,A,M="";if(v.length>0){v.charCodeAt(0)===40?(R=i<0&&v.charCodeAt(0)===45?-i:i,A=yn("n",v,R)):(A=yn("n",v,R=i<0&&l>1?-i:i),R<0&&d[0]&&d[0].t==="t"&&(A=A.substr(1),d[0].v="-"+d[0].v)),I=A.length-1;var T=d.length;for(S=d.length,m=0;m<S;++m)if(d[m]!=null&&d[m].t!=="t"&&d[m].v.indexOf(".")>-1){T=m;break}var N=S;if(T===S&&A.indexOf("E")===-1){for(m=d.length-1;m>=0;--m)d[m]!=null&&"n?".indexOf(d[m].t)!==-1&&(I>=d[m].v.length-1?(I-=d[m].v.length,d[m].v=A.substr(I+1,d[m].v.length)):I<0?d[m].v="":(d[m].v=A.substr(0,I+1),I=-1),d[m].t=d[m].v.indexOf("?")>=0?"N":"t",N=m);I>=0&&N<d.length&&(d[N].v=A.substr(0,I+1)+d[N].v)}else if(T!==d.length&&A.indexOf("E")===-1){for(I=A.indexOf(".")-1,m=T;m>=0;--m)if(d[m]!=null&&"n?".indexOf(d[m].t)!==-1){for(h=d[m].v.indexOf(".")>-1&&m===T?d[m].v.indexOf(".")-1:d[m].v.length-1,M=d[m].v.substr(h+1);h>=0;--h)I>=0&&(d[m].v.charAt(h)==="0"||d[m].v.charAt(h)==="#"||d[m].v.charAt(h)==="?")&&(M=A.charAt(I--)+M);d[m].v=M,d[m].t=M.indexOf("?")>=0?"N":"t",N=m}for(I>=0&&N<d.length&&(d[N].v=A.substr(0,I+1)+d[N].v),I=A.indexOf(".")+1,m=T;m<d.length;++m)if(d[m]!=null&&("n?(".indexOf(d[m].t)!==-1||m===T)){for(h=d[m].v.indexOf(".")>-1&&m===T?d[m].v.indexOf(".")+1:0,M=d[m].v.substr(0,h);h<d[m].v.length;++h)I<A.length&&(M+=A.charAt(I++));d[m].v=M,d[m].t=M.indexOf("?")>=0?"N":"t",N=m}}}for(m=0;m<S;++m)d[m]!=null&&"n?".indexOf(d[m].t)>-1&&(R=l>1&&i<0&&m>0&&d[m-1].v==="-"?-i:i,d[m].v=yn(d[m].t,d[m].v,R),d[m].t=d[m].v.indexOf("?")>=0?"N":"t");var B="";for(S=d.length,m=0;m<S;m++)if(d[m].t==="R")a?.onRepeatChar?.(B.length,d[m].v);else if(d[m].t==="S")a?.onSpacingChar?.(B.length,d[m].v),B+=a?.spacingCharacter??" ";else if(d[m].t==="N"){M=d[m].v;for(var D=0;D<M.length;D++)(f=M[D])==="?"&&(a?.onDigitChar?.(B.length,f),f=a?.digitCharacter??" "),B+=f}else d[m]!=null&&(B+=d[m].v);return B}(r[1],e,t,r[0])}function _h(s,e){if(typeof e!="number"){e=+e||-1;for(var t=0;t<392;++t)if(Zn[t]!==void 0){if(Zn[t]===s){e=t;break}}else e<0&&(e=t);e<0&&(e=391)}return Zn[e]=s,e}const Ge={format:$g,dateNumLocal:oc,load:_h,split_fmt:Wg,_table:Zn,load_table:function(s){for(var e=0;e!==392;++e)s[e]!==void 0&&_h(s[e],e)},parse_date_code:vo,is_date:Vg,get_table:function(){return Ge._table=Zn}},qe="\\s*([-]?[0-9e]*[.]?[0-9]+)",jp=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),Wp=new RegExp(`^rgba\\(${qe},${qe},${qe},${qe}\\)$`),Hp=new RegExp(`^lrgb\\(${qe},${qe},${qe}\\)$`),Vp=new RegExp(`^lrgba\\(${qe},${qe},${qe},${qe}\\)$`),$p=new RegExp(`^hsl\\(${qe},${qe},${qe}\\)$`),Gp=new RegExp(`^hsla\\(${qe},${qe},${qe},${qe}\\)$`),Up=new RegExp(/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/),qp=new RegExp(/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/),Jp=new RegExp("^index(\\d+)$","i"),pa=(s,e,t)=>[parseFloat(s),parseFloat(e),parseFloat(t)],_a=(s,e=255)=>{const t=[...s];for(var n=0;n<s.length;n++)t[n]=s[n]/e;return t},Sh=(s,e=0)=>{const t=[...s];for(var n=0;n<s.length;n++)F.roundAccurately(s[n],e+8)%1==.5?t[n]=Math.floor(s[n]):t[n]=F.roundAccurately(s[n],e);return t},ot=(s,e=!0)=>{const t=[...s],n=e?1:255;for(var r=0;r<s.length;r++)t[r]=Math.max(0,Math.min(n,s[r]));return t},Tr=s=>Math.max(0,Math.min(1,s)),Gg=s=>((s%=360)<0&&(s-=360),s),nr=s=>{const e=[...s];for(var t=0;t<s.length;t++)e[t]=$s(s[t]);return e},or=s=>{const e=[...s];for(var t=0;t<s.length;t++)e[t]=Gs(s[t]);return e},$s=s=>s<.04045?s/12.92:Math.pow((s+.055)/1.055,2.4),Gs=s=>s<.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,sr=s=>{let e=s[0],t=s[1],n=s[2];e%=360,e/=360,t/=100,n/=100;let r=n<.5?n*(1+t):n+t-t*n,o=2*n-r;return[Math.max(0,Sa(o,r,e+1/3)),Math.max(0,Sa(o,r,e)),Math.max(0,Sa(o,r,e-1/3))]},Sa=(s,e,t)=>(t<0&&(t+=1),t>1&&(t-=1),6*t<1?s+6*(e-s)*t:2*t<1?e:3*t<2?s+6*(e-s)*(2/3-t):s),zn=s=>{let e=s[0],t=s[1],n=s[2],r=Math.min(e,Math.min(t,n)),o=Math.max(e,Math.max(t,n)),i=0;o===r?i=0:o===e?i=(60*(t-n)/(o-r)+360)%360:o===t?i=60*(n-e)/(o-r)+120:o===n&&(i=60*(e-t)/(o-r)+240);const a=(o+r)/2;let l=0;return l=o===r?0:a<=.5?(o-r)/(o+r):(o-r)/(2-o-r),[i,100*l,100*a]},rt=0,wa=1,ro=2,Us=0,qs=1,Js=2,Xs=0,Ks=1,Ys=2,Xp=(s,e)=>{let t=e/100;return((n,r)=>{let o=nr(n);o[0]=r(o[0],o),o[1]=r(o[1],o),o[2]=r(o[2],o);let i=or(o);return i=ot(i),i})(s,(n,r)=>n*t)},ds=2.55,Kp=(s,e)=>{const t=zn(s),n=t[2],r=F.roundAccurately((o=n,(i=e)>0?(o*ds*(1-i)+(255-255*(1-i)))/ds:i<0?o*ds*(1+i)/ds:o),3);var o,i;t[2]=r;let a=sr(t);return a=ot(a),a},Yp=(s,e)=>{let t=nr(s),n=e/100;for(var r=0;r<3;r++)t[r]=t[r]*n+(1-n);let o=or(t);return o=ot(o),o},ya=(s,e,t)=>{let n=zn(e),r=t/1;s===rt&&(r=Gg(t)),n[s]=r;let o=sr(n);return o=ot(o),o},Ca=(s,e,t)=>{let n=zn(e);if(s===rt){let o=t/360;n[rt]=360*(n[rt]/360+o),n[rt]%=360,n[rt]<0&&(n[rt]-=360)}else{let o=t/.1;n[s]=.1*(n[s]/.1+o)}let r=sr(n);return r=ot(r),r},ba=(s,e,t)=>{let n=zn(e),r=t/100;n[s]=n[s]*r,s===rt&&(n[rt]=Gg(n[rt]));let o=sr(n);return o=ot(o),o},nn=(s,e,t,n)=>{let r=nr(e),o=t/100;n===Xs?r[s]=o:n===Ks?r[s]+=o:n===Ys&&(r[s]*=o);let i=or(r);return i=ot(i),i},Qp=s=>{let e=nr(s),t=.213*e[Us]+.715*e[qs]+.072*e[Js];e[0]=t,e[1]=t,e[2]=t;let n=or(e);return n=ot(n),n},Zp=s=>{let e=zn(s);e[rt]+=180,e[rt]%=360,e[rt]<0&&(e[rt]-=360);let t=sr(e);return t=ot(t),t},wh=(s,e=!0)=>{let t=e?nr(s):[...s];const n=e?1:255;return t[0]=n-t[0],t[1]=n-t[1],t[2]=n-t[2],e&&(t=or(t)),t=ot(t,e),t},e0=s=>{const e=[0,0,0];return e[0]=Gs(s[0]),e[1]=Gs(s[1]),e[2]=Gs(s[2]),ot(e)},t0=s=>{const e=[0,0,0];return e[0]=$s(s[0]),e[1]=$s(s[1]),e[2]=$s(s[2]),ot(e)},yh=(s,e,t,n=null)=>{const r=o=>{let i=o.toString(16);return i.length===1?"0"+i:i};return(n===null?"":r(Math.round(255*n)))+r(Number(s)).toUpperCase()+r(Number(e)).toUpperCase()+r(Number(t)).toUpperCase()},pr=.2126,Rn=.7152,_r=.0722;var gn;(s=>{s.RGBA=class{constructor(t,n,r,o=1){this._private={red:t,green:n,blue:r,alpha:o}}get red(){return this._private.red}get green(){return this._private.green}get blue(){return this._private.blue}get alpha(){return this._private.alpha??1}toString(t=!0){return t&&this._private.alpha!==null?`rgba(${this.red},${this.green},${this.blue},${this.alpha})`:`rgb(${this.red},${this.green},${this.blue})`}isEqual(t){return!!t&&t.red===this.red&&t.green===this.green&&t.blue===this.blue&&t.alpha===this.alpha}isAlmostEqual(t){if(!t)return!1;const n=1.5;return!(Math.abs(t.red-this.red)>n)&&!(Math.abs(t.green-this.green)>n)&&!(Math.abs(t.blue-this.blue)>n)&&!(Math.abs(t.alpha-this.alpha)>n)}},s.HSLA=class{constructor(t,n,r,o){this._private={hue:t,sat:n,lum:r,alpha:o}}get hue(){return this._private.hue}get sat(){return this._private.sat}get lum(){return this._private.lum}get alpha(){return this._private.alpha??1}toString(t=!0){return t&&this._private.alpha!==null?`hsla(${this.hue},${this.sat},${this.lum},${this.alpha})`:`hsl(${this.hue},${this.sat},${this.lum})`}isEqual(t){return!!t&&t.hue===this.hue&&t.sat===this.sat&&t.lum===this.lum&&t.alpha===this.alpha}isAlmostEqual(t){if(!t)return!1;const n=1.5;return!(Math.abs(t.hue-this.hue)>n)&&!(Math.abs(t.sat-this.sat)>n)&&!(Math.abs(t.lum-this.lum)>n)&&!(Math.abs(t.alpha-this.alpha)>n)}};class e extends s.RGBA{toString(n=!0){return n&&this._private.alpha!==null?"#"+yh(this.red,this.green,this.blue,this.alpha??1).toUpperCase():"#"+yh(this.red,this.green,this.blue).toUpperCase()}}s.HEX=e})(gn||(gn={}));const n0=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,r0=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Qs=function(s){if(!s)return null;s=s.replace(n0,function(t,n,r,o){return n+n+r+r+o+o});let e=r0.exec(s);return e?new gn.RGBA(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)):null},Ch=["000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","800000","008000","000080","808000","800080","008080","C0C0C0","808080","9999FF","993366","FFFFCC","CCFFFF","660066","FF8080","0066CC","CCCCFF","000080","FF00FF","FFFF00","00FFFF","800080","800000","008080","0000FF","00CCFF","CCFFFF","CCFFCC","FFFF99","99CCFF","FF99CC","CC99FF","FFCC99","3366FF","33CCCC","99CC00","FFCC00","FF9900","FF6600","666699","969696","003366","339966","003300","333300","993300","993366","333399","333333"],Kn=new Map;for(let s=0;s<Ch.length;s++)Kn.set(s,Qs(Ch[s]));Kn.set(-4105,null),Kn.set(-4142,null),Kn.set(64,Qs("000000")),Kn.set(65,Qs("FFFFFF")),Kn.set(81,Qs("FFFFFF"));const Ei=s=>Kn.get(s),ae={General:"General",Number:"Number",Currency:"Currency",Accounting:"Accounting",ShortDate:"Short Date",LongDate:"Long Date",MediumDate:"Medium Date",ShortTime:"Short Time",MediumTime:"Medium Time",LongTime:"Long Time",Comma:"Comma",Percentage:"Percentage",Fraction:"Fraction",Scientific:"Scientific",Text:"Text",Special:"Special",Custom:"Custom"};let Ea=null;const Ug=()=>Ea||(Ea=Intl.DateTimeFormat().resolvedOptions().locale??"en-US",Ea),o0=/^\[\$-(.*?)\]/i,s0=/^[0-9a-fA-F]+$/,i0=Ge.split_fmt,sc=(s,e,t)=>{const n=o0.exec(s);let r=Ug();if(n&&n[1]){let o=n[1];s0.test(o)||o.includes("-")}if(bh[s]&&(s=bh[s]),typeof e=="number"){const o=xo(s,e,{locale:r,...t});if(o!==null)return o.fmt}return Ge.format(s,e,t)},xo=(s,e,t)=>{if(typeof e!="number")return null;const n=Jr(e,t?.date1904??!1),r=t?.locale??Ug();let o=!1,i=s,a=-1;if((a=i.indexOf("Short Date"))!==-1){const l=new Intl.DateTimeFormat(r).format(n);i=i.substring(0,a)+l+i.substring(a+10),o=!0}if((a=i.indexOf("Medium Date"))!==-1){const l=Ge.format(Ge.get_table()[15],e,t);i=i.substring(0,a)+l+i.substring(a+11),o=!0}if((a=i.indexOf("Long Date"))!==-1){const l=new Intl.DateTimeFormat(r,{dateStyle:"full"}).format(n);i=i.substring(0,a)+l+i.substring(a+9),o=!0}if((a=i.indexOf("Short Time"))!==-1){const l=Ge.format(Ge.get_table()[20],e,t);i=i.substring(0,a)+l+i.substring(a+10),o=!0}if((a=i.indexOf("Medium Time"))!==-1){const l=Ge.format(Ge.get_table()[18],e,t);i=i.substring(0,a)+l+i.substring(a+11),o=!0}if((a=i.indexOf("Long Time"))!==-1){const l=new Intl.DateTimeFormat(r,{timeStyle:"medium"}).format(n);i=i.substring(0,a)+l+i.substring(a+9),o=!0}return o?{fmt:i,date:n}:null},bh=Object.freeze({"General Number":"General","General Date":"m/d/yyyy h:mm","Medium Date":Ge.get_table()[15],"Medium Time":Ge.get_table()[18],"Short Time":Ge.get_table()[20],Currency:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',Fixed:Ge.get_table()[2],Standard:Ge.get_table()[4],Percent:Ge.get_table()[10],Scientific:Ge.get_table()[11],"Yes/No":'"Yes";"Yes";"No";@',"True/False":'"True";"True";"False";@',"On/Off":'"Yes";"Yes";"No";@'}),a0=Object.freeze({black:0,white:1,red:2,green:3,blue:4,yellow:5,magenta:6,cyan:7}),l0=s=>{let e=null;if((s=s.toLowerCase()).startsWith("color")){const t=parseInt(s.substring(5));t>=0&&t<=56&&(e=`Index${t+7}`)}if(!e){const t=a0[s];t!==void 0&&(e=Ei(t).toString())}return e},qg="=",c0="<>",Jg=">",Tl="<",Xg=">=",h0="<=",Un=new Map;Un.set(qg,(s,e)=>s===e),Un.set(c0,(s,e)=>s!==e),Un.set(Jg,(s,e)=>s>e),Un.set(Tl,(s,e)=>s<e),Un.set(Xg,(s,e)=>s>=e),Un.set(h0,(s,e)=>s<=e);const u0=/(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow|Color[0-9]+)/i,d0=/(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)/i,g0=/\[(.*?)\]/g,m0=(s,e)=>{const t={color:null,condition:null};let n=null,r=new RegExp(g0);for(;(n=r.exec(s))!==null;){let o=!1,i=u0.exec(n[1]);if(i){if(o=!0,t.color)throw new Error(`format error, two colors specified: '${s}' and '${t.color}'.`);t.color=l0(i[1]),t.color||console.warn("Unable to parse LegacyColor",i[1])}let a=d0.exec(n[1]);if(a){if(o=!0,t.condition)throw new Error(`Format error, two conditions specified: ' ${s}'`);t.condition={op:a[1],comp:parseFloat(a[2])}}if(!o)return t}return t.condition||(t.condition=e),t},f0=(s,e)=>{let t=(r=>{const o=[];if(!r)return o;const i=r.split(";");for(let a=0;a<i.length;a++){let l=null;i.length===2?a===0?l={op:Xg,comp:0}:a===1&&(l={op:Tl,comp:0}):i.length!==3&&i.length!==4||(l=a===0?{op:Jg,comp:0}:a===1?{op:Tl,comp:0}:a===2?{op:qg,comp:0}:null);const c=i[a],h=m0(c,l);o.push({format:c,colorAndCondition:h})}return o})(s),n=t[0].colorAndCondition;if(t.length===1&&n&&!n.condition&&n.color)return n.color;for(let r=0;r<t.length;r++){n=t[r].colorAndCondition;let o=n?.condition??void 0;if(r===3)return typeof e=="string"&&n?.color?n.color:null;if(o&&typeof e=="number"&&Un.get(o.op)(e,o.comp))return n?.color??null}},Eh=s=>{if(s===ae.MediumDate||s===ae.LongDate||s===ae.ShortDate||s===ae.MediumTime||s===ae.LongTime||s===ae.ShortTime)return!0},p0=(s,e)=>s===e?0:Eh(s)?1:Eh(e)?-1:s===ae.Percentage?1:e===ae.Percentage?-1:s===ae.Currency||s===ae.Accounting?1:e===ae.Currency||e===ae.Accounting?-1:0,qr=s=>(s instanceof Date||Object.prototype.toString.call(s)==="[object Date]")&&!isNaN(s.getTime()),_0=(s,e,t)=>{return t==="month"||t==="months"||t==="m"?(n=s,12*((r=e).getUTCFullYear()-n.getUTCFullYear())+(r.getUTCMonth()-n.getUTCMonth())+(r.getUTCDate()-n.getUTCDate()<0?-1:0)):t==="year"||t==="years"||t==="y"?((o,i)=>Math.abs(i.getFullYear()-o.getFullYear()))(s,e):t==="day"||t==="days"||t==="d"?((o,i)=>Math.floor((Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())-Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()))/864e5))(s,e):void console.warn("invalid unit"+t);var n,r},gs="d",vh="m",xh="y",Ih=(s,e,t)=>{if(t==="month"||t==="months"||t==="m"){const n=new Date(s.getTime());return new Date(n.setMonth(n.getMonth()+e))}if(t==="year"||t==="years"||t==="y"){const n=new Date(s.getTime());return n.setFullYear(n.getFullYear()+e),n}if(t==="day"||t==="days"||t==="d"){const n=new Date(s.getTime());return n.setDate(n.getDate()+e),n}if(t==="hour"||t==="hours"||t==="h"){const n=new Date(s.getTime());return n.setHours(n.getHours()+e),n}return console.warn("invalid unit"+t),null},Jr=(s,e=!1)=>{let t=Ge.parse_date_code(s,{date1904:e});return t?new Date(t.y,t.m-1,t.d,t.H,t.M,t.S,Math.round(1e3*t.u)):null},Qo=(s,e=!1)=>isNaN(s)?null:Ge.dateNumLocal(s,e),S0=new class extends Fg{parse(s,e,t){const n=r=>r-1;switch(e){case"M":return wn(Bn(Tg,s),n);case"MM":return wn(Lo(2,s),n);case"Mo":return wn(t.ordinalNumber(s,{unit:"month"}),n);case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}}},rn=(s=>{let e=s,t=[];for(let n=0;n<e.length;n++){let r=e[n][0].indexOf("yyy")>-1,o=e[n][0].indexOf(".")>-1,i=e[n][0].indexOf("-")>-1;t.push({parseFormat:e[n][0],numberFormat:e[n][1],todaysYear:!r,windowYear:!0,containsDot:o,containsDash:i}),r&&t.push({parseFormat:e[n][0].replace(/yyy/g,"yyyy"),numberFormat:e[n][1],todaysYear:!1,windowYear:!1,containsDot:o,containsDash:i})}return t})([["MM-d","d-mmm"],["MM-yyy","mmm-yy"],["M-yyy","mmm-yy"],["M-d-yyy","m/d/yyyy"],["yyy-M-d","m/d/yyyy"],["yyy-d-M","m/d/yyyy"],["d.MMM","d-mmm"],["d.MMMM","d-mmm"],["d.MMM.yyy","d-mmm-yy"],["d.MMMM.yyy","d-mmm-yy"],["MMM.d","d-mmm"],["MMMM.d","d-mmm"],["MMM.yyy","mmm-yy"],["MMMM.yyy","mmm-yy"],["MMM dd, yyy","d-mmm-yy"],["MMMM dd, yyy","d-mmm-yy"],["EEE, MMMM dd, yyy","[$-x-sysdate]ddd, mmmm dd, yyyy"],["EEEE, MMMM dd, yyy","[$-x-sysdate]dddd, mmmm dd, yyyy"]]),w0={year:0,month:1,day:0,hour:0,minute:0,second:0,millis:0},y0=(s,e=!1)=>{const t={...w0,...s};return t.year=e?1904:1900,t.dow=-1,t.oaDateTime=((n,r=!1)=>{if(!n)return null;let o=n.day,i=n.hour;i>24&&(o+=Math.floor(i/24),i%=24),o>60&&--o;const a=new Date(n.year,n.month-1,o,i,n.minute,n.second,n.millis);return Qo(a,r)})(t,e),t},C0=new RegExp("([0-9]{1,2})\\s*(P[M]?|A[M]?)\\s*$","i"),b0=new RegExp("([0-9]+)\\s*\\:$","i"),va=new RegExp("(\\s*[0-9]{1,2})\\s+(P[M]?|A[M]?)\\s*$","i"),Rh=new RegExp("(\\s*[0-9]{1,4})\\s*([\\.]{1}\\s*[0-9]+)?\\s*\\:","i"),E0=new RegExp("(\\s*[0-9]{1,4})\\s*([\\.]{1}\\s*[0-9]*)?\\s*$","i"),Kg=(s,e=!1,t=!1)=>{if(!s||s.trim().length<2||s.indexOf(":")===-1&&s.match(va)===null)return null;let n=null,r=null,o=null,i=!1,a=!1,l="h:mm AM/PM",c=[],h=s,u=null;do{let _=h.indexOf(":");_===-1?(c.push(h),h=null):(c.push(h.substring(0,_+1)),h=h.substring(_+1,h.length))}while(c.length<3&&h&&h.length>0);if(h?.length>0)return null;const d=(_,p,S)=>{let C=_.match(p);if(!C)return null;u===null&&(u=_.substring(0,C.index));let y=parseInt(C[1]);if(C[2]&&o===null){if(S){let w=parseFloat(C[2].substring(1,C[2].length));isNaN(w)||(r=w)}let b=parseFloat(C[2]);isNaN(b)||(n=b),o=S}return y},g=(_,p)=>{let S=_.match(p);if(!S||S.length!==3)return null;u===null&&(u=_.substring(0,S.index)),i=!0;let C=parseInt(S[1]);return a=S[2].charAt(0)==="p"||S[2].charAt(0)==="P",C};c[c.length-1].trim().length===0&&c.pop();const m=[];if(c.length>0){let _=d(c[0],b0,!1);if(_===null&&(_=g(c[0],C0)),_===null)return null;m.push(_)}if(c.length>2){let _=d(c[1],Rh,!0);if(_===null&&(_=g(c[0],va)),_===null)return null;m.push(_)}if(c.length>1){const _=c[c.length-1];let p=d(_,Rh,!1);if(p===null&&(p=d(_,E0,!1)),p===null&&(p=g(_,va)),p===null)return null;m.push(p)}if(u!==null&&u.length>0&&!t)return null;if(o===!0&&(m.length===2&&m.splice(1,0,0),m[2]=r||0),i){if(m[0]>12||m[1]>=60||m[2]>=60)return null;m[0]===12?m[0]=a?12:0:a&&(m[0]+=12)}else l=c.length>2?"h:mm:ss":"h:mm",m[0]>23&&(l="[h]:mm:ss"),n!==null&&(l="mm:ss.0"),m[1]>=60&&(l="General"),m[2]>=60&&(l="General");l!=="General"&&(m.length===1&&m.push(0),m.length===2&&(n===null?m.push(0):m.unshift(0)));let f={hour:m[0]??0,minute:m[1]??0,second:m[2]??0,millis:1e3*(n??0)};return{numberFormat:l,parsed:y0(f,e),leadingText:u}},v0={},ic=(s,e=!1,t=null)=>{const n=t??Date.now(),r=new Date(n).getFullYear();let o=s.trim().replaceAll(/\s+/g," ");o=o.replaceAll(/\s*([-/])\s*/g,"$1");let i=o.replaceAll(/[-/ ]/g,"."),a=o.replaceAll(/[/]/g,"-");const l=Eo.M;Eo.M=S0;for(let c=0;c<rn.length;c++){let h=o;rn[c].containsDot?h=i:rn[c].containsDash&&(h=a);let u=kp(h,rn[c].parseFormat,n,v0),d=Ge.dateNumLocal(u,e);if(qr(u)&&(rn[c].windowYear||d>0)){if(rn[c].windowYear){let m=u.getFullYear()<=29?2e3+u.getFullYear():1900+u.getFullYear();u.setFullYear(m)}if(rn[c].todaysYear&&u.setFullYear(r),d=Ge.dateNumLocal(u,e),rn[c].parseFormat.indexOf("EEE")>-1){const m=sc("ddd",d,{date1904:e});if(!h.toLowerCase().includes(m.toLowerCase()))return null}let g=rn[c].numberFormat;return Eo.M=l,{asOADate:d,asJSDate:u,numberFormat:g}}}return Eo.M=l,null};function Zo(s){if(!s)return!1;let e=s.replaceAll(/\[([^)]+)\]/g,"").toLowerCase();return e=e.replaceAll(/".*"/g,""),e=e.replaceAll(/\\./g,""),e=e.replace(/[_*]./g,""),!e.includes("time")&&!!(e.includes("d")||e.includes("m")&&!e.includes("h")&&!e.includes("s")||e.includes("y")||e==="short date"||e==="medium date"||e==="long date")}function Wi(s){if(!s)return!1;let e=s.replaceAll(/\[([^)]+)\]/g,"").toLowerCase();return e=e.replaceAll(/".*"/g,""),e=e.replaceAll(/\\./g,""),e=e.replace(/[_*]./g,""),!e.includes("date")&&!(!e.includes("h")&&!e.includes("s")&&e!=="short time"&&e!=="medium time"&&e!=="long time")}var Ah,on;exports.IText=void 0,(Ah=exports.IText||(exports.IText={})).SmallCaps={None:"none",Small:"small",All:"all"},Ah.StrikeStyle={None:"none",Single:"single",Double:"double"},exports.ITextFrame=void 0,(on=exports.ITextFrame||(exports.ITextFrame={})).TabStop=class{},on.HorizontalAlignment={General:"general",Left:"left",Center:"center",Right:"right",Justify:"justify",Distributed:"distributed",CenterContinuous:"centerContinuous",Fill:"fill"},on.VerticalAlignment={Top:"top",Center:"center",Bottom:"bottom",Justify:"justify",Distributed:"distributed"},on.Orientation={Horizontal:"horizontal",Vertical:"90",Vertical270:"270",Stacked:"stacked"},on.ReadingDirection={Auto:"auto",LeftToRight:"ltr",RightToLeft:"rtl"},on.Overflow={Visible:"visible",Wrap:"wrap",Clip:"clip",Shrink:"shrink",Ellipsis:"ellipsis"},on.Autofit={None:"none",Normal:"normal",Shape:"shape"},on.TabStopAlignment={Default:"default",Left:"left",Right:"right",Center:"center"},on.toCSSHorizontalTextAlign=s=>s?s.toLowerCase():null;const Yg=(s,e,t=1e3)=>{if(!s)throw new Error("A template string must be specified.");if(e(s))return s;let n=new RegExp(/\d+/,"g").exec(s),r=null,o=0;n!==null?(r=s,o=parseFloat(n[0]),isNaN(o)&&(o=0)):(o=1,r=`${s}_${o}`);let i=isNaN(o)?0:o;for(;o<i+t;)try{const a=r.replace(/\d+/g,()=>""+o++);if(e(a))return a}catch{}throw new Error(`Unable to find valid name for '${s}'.`)},jr=(s,e=!1)=>{if(!s||s.length===0)return s;const t=s.charAt(0);if(t>="a"&&t<="z"){const n=String.fromCharCode(t.charCodeAt(0)-32);return e?n+s.slice(1).toLowerCase():n+s.slice(1)}return s},Mh=s=>{if(!s||typeof s!="string")return"";const e=s.split(/[\\/]/).pop()||"",t=e.lastIndexOf(".");return e===""||t<1?"":e.slice(t+1)},Qg=s=>s.toLowerCase().replace(/([-_][a-z])/g,e=>e.toUpperCase().replace("-","").replace("_","")),Zg=(s,e=36)=>s.substring(0,36)+(s.length>e?"…":""),Zs=s=>{if(s===void 0)return 0;let e=s.toString().split(".");return e.length<=1?0:e[1].length||0},em=new RegExp(/^["|'|`](.*)["|'|`]$/),x0=new RegExp("^([a-zA-Z]+:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i"),tm=(s=",",e="'")=>new RegExp(`\\s*${s}\\s*(?=(?:[^${e}]*${e}[^${e}]*${e})*[^${e}]*$)`,"g"),nm=tm(),ac=s=>s.replace(em,"$1"),rm=(s,e="'")=>`${e}${s}${e}`,om=(s,e=void 0,t=void 0)=>{let n=nm;return e===void 0&&t===void 0||(n=tm(e,t)),s.split(n)},sm=s=>{let e;try{e=new URL(s)}catch{return!1}return(e.protocol==="http:"||e.protocol==="https:")&&x0.test(s)},I0=new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/i),im=s=>!!s.toLowerCase().startsWith("mailto:")||I0.test(s),am=s=>((s>=26?am((s/26|0)-1):"")+"abcdefghijklmnopqrstuvwxyz"[s%26|0]).toUpperCase(),R0=Object.freeze(Object.defineProperty({__proto__:null,DefaultUnQuoteRegEx:nm,camelToSnake:s=>s&&s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`),capitalize:jr,clampString:Zg,countDecimals:Zs,findValidTextValue:Yg,getBaseName:(s,e=!1)=>{if(!s||typeof s!="string")return"";const t=s.split(/[\\/]/).pop()||"";if(t==="")return"";const n=Mh(t),r=n.length===0?t:t.slice(0,t.length-n.length-1);return e?jr(r,!0):r},getFileNameExtension:Mh,isQuoted:s=>s&&s.length>1&&em.test(s)&&s[0]===s[s.length-1],isValidEmail:im,isValidHttpUrl:sm,numberToAlphabet:am,quote:rm,snakeToCamel:Qg,splitUnquoted:om,unquote:ac},Symbol.toStringTag,{value:"Module"})),A0=(s,e,t,n=null)=>{const r=(e||11*exports.IFont.getDeviceScale())/exports.IFont.getDeviceScale(),o=n?.letterSpacing||0,i=s.length,a=i*(.55*r)-(s.match(/[il.,;!|]/g)||[]).length*r*.15+(s.match(/[mwMW]/g)||[]).length*r*.1+(i>0?(i-1)*o:0),l=Math.ceil(1.2*r),c=Math.ceil(.8*r),h=Math.ceil(.2*r),u=Math.ceil(.45*r),d=Math.ceil(1.1*r),g=Math.max(1,Math.ceil(.08*r));return{width:a,lineHeight:l,baseline:c,lineGap:h,strikePosition:u,underlinePosition:d,strikeThickness:g,underlineThickness:g,actualBoundingBoxLeft:0,actualBoundingBoxRight:a,actualBoundingBoxAscent:c,actualBoundingBoxDescent:l-c,fontBoundingBoxAscent:c,fontBoundingBoxDescent:l-c,emHeightAscent:c,emHeightDescent:l-c,hangingBaseline:.8*c,alphabeticBaseline:c,ideographicBaseline:l}},tt={},Th=(s,e)=>{let t="normal";return s&&e?t="bold italic":s?t="bold":e&&(t="italic"),t},Fh=s=>s.split(",").map(e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e}).join(", "),Nh=new Map,xa=new Map;let sn=null;const M0=(s,e,t,n=null)=>{const r=n?.letterSpacing||0;typeof window>"u"||tt.contextMeasure||(tt.canvasMeasure=document?document.createElement("canvas"):null,tt.contextMeasure=tt.canvasMeasure.getContext("2d"),tt.contextMeasure.letterSpacing=`${r}px`,tt.contextMeasure.textRendering="geometricPrecision",tt.contextMeasure.textBaseline="alphabetic",tt.contextMeasure.textAlign="left");const o=t||"calibri",i=e||11*exports.IFont.getDeviceScale(),a=n?.isBold||!1,l=n?.isItalic||!1;let c=null;if(s==="#"||s==="0"||s==="M"||s===""||s==="_"||s==="-"){c=((f,_,p,S,C,y)=>f+Math.round(100*_)/100+p+S+C+y)(s,i,o,a,l,r);const m=Nh.get(c);if(m)return m}if(sn&&sn.text===s&&sn.size===e&&sn.family===t&&sn.options?.isBold===n?.isBold&&sn.options?.isItalic===n?.isItalic&&sn.options?.letterSpacing===n?.letterSpacing)return sn.metrics;let h={};const u=Th(a,l)+" "+F.roundAccurately(i,2)+"px "+Fh(o);tt.contextMeasure?(tt.contextMeasure.font=u,tt.contextMeasure.letterSpacing=`${n?.letterSpacing??0}px`,h=tt.contextMeasure.measureText(s)):h.width=s.length*F.roundAccurately(i/exports.IFont.getDeviceScale()*.6,2);let d=xa.get(u);if(!d&&typeof window<"u"){const m=document.createElement("div");m.style.visibility="hidden",m.style.position="absolute";const f=document.createElement("span");f.textContent="Mj",f.style.fontSize="100px",f.style.fontWeight=n?.isBold?"bold":"normal",f.style.fontStyle=n?.isItalic?"italic":"normal",f.style.fontFamily=`'${o}'`,f.style.lineHeight="1.2",m.appendChild(f),document.body.appendChild(m);const _=m.getBoundingClientRect(),p=f.getBoundingClientRect();document.body.removeChild(m),tt.contextMeasure.font=Th(a,l)+" "+F.roundAccurately(100,2)+"px "+Fh(o);const S=tt.contextMeasure.measureText("M"),C=_.bottom-_.top,y=C-(S.fontBoundingBoxAscent+S.fontBoundingBoxDescent),b=S.fontBoundingBoxAscent+p.top,w=tt.contextMeasure.measureText("_"),E=b-w.actualBoundingBoxAscent,x=Math.max(1,Math.abs(w.actualBoundingBoxAscent+w.actualBoundingBoxDescent)),I=tt.contextMeasure.measureText("-"),v=F.roundAccurately(b-I.actualBoundingBoxAscent+Math.max(1,.05*C,0)),R=x,A=i/100;d={lineHeight:Math.ceil(C*A),baseline:Math.ceil(b*A),lineGap:Math.ceil(y*A),strikePosition:Math.ceil(v*A),underlinePosition:Math.ceil(E*A),strikeThickness:Math.ceil(R*A),underlineThickness:Math.ceil(x*A)},tt.contextMeasure.font=u,xa.set(u,d)}d||(d={lineHeight:Math.ceil(1.2*i),baseline:Math.ceil(i)+Math.floor(.1*i),lineGap:Math.ceil(.1*i),strikePosition:Math.ceil(.55*i)+Math.floor(.1*i),strikeThickness:1,underlinePosition:Math.ceil(1.1*i),underlineThickness:1},xa.set(u,d));const g={...h,width:h.width,...d};return c!==null&&Nh.set(c,g),sn={text:s,size:e,family:t,options:n,metrics:g},g};let Sr=null;const T0=()=>{if(Sr)return Sr;try{const s=document.createElement("canvas"),e=s.getContext&&s.getContext("2d");e&&typeof e.fillText=="function"&&(Sr=M0)}catch{}return Sr||(console.warn("⚠️ CanvasFontMeasurer not available, falling back to SimpleFontMeasurer"),Sr=A0),Sr};let ms=null;var an;exports.IFont=void 0,(an=exports.IFont||(exports.IFont={})).Style={Normal:"normal",Italic:"italic"},an.Scheme={Major:"major",Minor:"minor",None:"none"},an.UnderlineStyle={None:"none",Double:"double",DoubleAccounting:"doubleAccounting",Single:"single",SingleAccounting:"singleAccounting"},an.VerticalAlignment={Baseline:"baseline",Sub:"sub",Super:"super"},an.setSharedMeasurer=s=>{ms=s},an.getSharedMeasurer=()=>ms||(ms=T0(),ms),an.getDeviceScale=()=>96/72*1,an.getPanoseFallback=s=>{const e=[],t=s.length;for(let i=0;i<t;i+=2)e.push(parseInt(s.substring(i,i+2),16));const n=e[0],r=e[1],o=e[3];switch(n){case 2:return o===9?"monospace":r>=2&&r<=8?"serif":"sans-serif";case 3:return"cursive";case 4:return"fantasy";case 5:return"monospace";default:return"sans-serif"}},an.GenericName={Serif:"serif",SanSerif:"sans-serif",MonoSpace:"monospace",Cursive:"cursive",Fantasy:"fantasy",SystemUI:"system-ui",UISystem:"ui-system",UISerif:"ui-serif",UISanSerif:"ui-sans-serif",UIMonoSpace:"ui-monospace",UIRounded:"ui-rounded",Math:"math",Emoji:"emoji",Fangsong:"fangsong"};class lm{constructor(e){this._private={input:e},typeof e=="string"?this._private.name=e:Object.assign(this._private,e)}toJSON(){return this._private.input}getFamily(){return this._private.name}getPitch(){return this._private.pitch}getPanose(){return this._private.panose}toString(){return typeof this._private.input=="string"?this._private.input:JSON.stringify(this._private.input)}get isIFont(){return!0}}const cm=["Arial","Arial Black","Brush Script MT","Calibri","Comic Sans MS","Courier New","Garamond","Georgia","Impact","Luminari","Palatino Linotype","Tahoma","Times New Roman","Trebuchet MS","Verdana"],_t=new Map;_t.set(exports.IFont.GenericName.Serif,["Tahoma"]),_t.set(exports.IFont.GenericName.SanSerif,["Calibri"]),_t.set(exports.IFont.GenericName.MonoSpace,["Courier New"]),_t.set(exports.IFont.GenericName.Cursive,["Comic Sans MS"]),_t.set(exports.IFont.GenericName.Fantasy,["Luminari"]),_t.set(exports.IFont.GenericName.UISystem,["Arial"]),_t.set(exports.IFont.GenericName.UISerif,["Tahoma"]),_t.set(exports.IFont.GenericName.UISanSerif,["Arial"]),_t.set(exports.IFont.GenericName.UIMonoSpace,["Courier New"]),_t.set(exports.IFont.GenericName.UIRounded,["Arial"]),_t.set(exports.IFont.GenericName.Math,[]),_t.set(exports.IFont.GenericName.Emoji,[]),_t.set(exports.IFont.GenericName.Fangsong,[]);const Fl=new Map;let hm=[];lc(cm);const F0=eval;function lc(s){s||lc(cm);let e=[];for(let t=0;t<s.length;t++){let n=s[t];typeof n=="string"&&(n=new lm(n));let r=!0;const o="document";try{r=F0(`${o}.fonts.check('12px ${n.getFamily()}')`)}catch{}const i={fontRef:n,loaded:r};e.push(i),Fl.set(n.getFamily(),i)}hm=Object.freeze(e)}const Ia=new Map,N0=Object.freeze(Object.defineProperty({__proto__:null,findBestMatch:(s,e)=>{const t=Ia.get(s);if(t)return t.fontRef===null?null:t;let n=[s];e.fallbacks&&(n=n.concat(e.fallbacks));let r=null;for(let o=0;!r&&o<n.length;o++){let i=n[o];if(r=Fl.get(i),!r){const a=_t.get(i);if(a)for(let l=0;!r&&l<a.length;l++)r=Fl.get(a[l])}}return r?Ia.set(s,r):Ia.set(s,{fontRef:null,loaded:!1}),r},getFontList:function(){return hm},setFontList:lc},Symbol.toStringTag,{value:"Module"}));class Hi{constructor(e,t,n,r=null,o=null,i=null){this._private={wrapped:!0,insets:Yo.EmptyRect,orientation:exports.ITextFrame.Orientation.Horizontal,autoFit:exports.ITextFrame.Autofit.None,fontScale:1,vertical:!1,columnCount:1,columnSpacing:0,verticalAlignment:exports.ITextFrame.VerticalAlignment.Center,horizontalCentered:!1,lineReduction:0,isSpaceFirstLastPara:!1,presetTextWarp:null,paragraphs:F.EmptyArray},this._bounds=null,this._textBounds=null,this._lines=null,this._lastLayoutDims=void 0,this._lastLayout=void 0,this._private=Object.assign(this._private,e||{}),this._defaultFont=t,this._alignment=n,this._lines=r,this._bounds=Object.freeze(o),this._textBounds=Object.freeze(i)}visitParas(e){e?.visitTextFrame?.(this);const t=this.paragraphs,n=t.length;for(let r=0;r<n;r++){const o=t[r];e?.visitTextParagraph?.(o,r,n);const i=o.runs,a=i.length;for(let l=0;l<a;l++)e?.visitTextRun?.(i[l],l,a)}}visitLines(e){e?.visitTextFrame?.(this);const t=this.lines,n=t.length;for(let r=0;r<n;r++){const o=t[r];e?.visitTextLine?.(o,r,n);const i=o.runs,a=i.length;for(let l=0;l<a;l++)e?.visitTextRun?.(i[l],l,a)}}layout(e=null){return this._lastLayout&&this._lastLayoutDims?.width===e?.width&&this._lastLayoutDims?.height===e?.height||(this._lastLayout=j0(this,this._defaultFont,this._alignment,e),this._lastLayoutDims=e),this._lastLayout}clone(e){const t=e?.visitTextFrame?.(this),n=Object.assign(this._private,t||{});return delete n.bounds,new Hi(n,this._defaultFont,this._alignment)}equals(e){return F.deepEqual(this._private,e._private)}createTemporaryTextFrame(e,t){return Gi(e,this._defaultFont,this._alignment,t??this._private.wrapped)}get bounds(){if(this._bounds===null)throw new Error(kh);return this._bounds}get textBounds(){if(this._textBounds===null)throw new Error(kh);return this._textBounds}get lines(){return this._lines}get wrapped(){return this._private.wrapped}get insets(){return this._private.insets}get orientation(){return this._private.orientation}get autoFit(){return this._private.autoFit}get fontScale(){return this._private.fontScale}get vertical(){return this._private.vertical}get columnCount(){return this._private.columnCount}get columnSpacing(){return this._private.columnSpacing}get verticalAlignment(){return this._private.verticalAlignment}get horizontalCentered(){return this._private.horizontalCentered}get lineReduction(){return this._private.lineReduction}get isSpaceFirstLastPara(){return this._private.isSpaceFirstLastPara}get presetTextWarp(){return this._private.presetTextWarp}get paragraphs(){return this._private.paragraphs}}const kh="bounds can not be used until layout";class Oh{static{this.NL=`
31
+ `}static{this.DefaultLineSpacing=100}static{this.DefaultTabWidth=72}}class Vi{constructor(e){this._private={defaultFontSize:11,defaultTabSize:Oh.DefaultTabWidth,tabOverrides:F.EmptyArray,spacingBefore:0,spacingAfter:0,lineSpacing:Oh.DefaultLineSpacing,align:exports.ITextFrame.HorizontalAlignment.Left,endParagraphSize:0,indentLevel:0,leadingIndent:0,hangingIndent:0,rightMargin:0,bullet:null},this._private=Object.assign(this._private,e||{})}clone(e){const t=e?.visitTextParagraph?.(this,0,1),n=Object.assign(this._private,t||{});return delete n.bounds,new Vi(n)}equals(e){return F.deepEqual(this._private,e._private)}get bounds(){return this._bounds}get defaultFontSize(){return this._private.defaultFontSize}get defaultTabSize(){return this._private.defaultTabSize}get tabOverrides(){return this._private.tabOverrides}get spacingBefore(){return this._private.spacingBefore}get spacingAfter(){return this._private.spacingAfter}get lineSpacing(){return this._private.lineSpacing}get align(){return this._private.align}get endParagraphSize(){return this._private.endParagraphSize}get indentLevel(){return this._private.indentLevel}get leadingIndent(){return this._private.leadingIndent}get hangingIndent(){return this._private.hangingIndent}get rightMargin(){return this._private.rightMargin}get bullet(){return this._private.bullet}get runs(){return this._private.runs}}class $i{constructor(e,t=null){this._private={text:null,fontName:"Arial",bold:!1,italic:!1,superSub:!1,fontSize:11,letterSpacing:0,kerningMin:10,smallCaps:exports.IText.SmallCaps.None,offset:0,strikeStyle:exports.IText.StrikeStyle.None},this._private={...this._private,...e},this._bounds=t}clone(e){const t=e?.visitTextRun?.(this,0,1),n=Object.assign(this._private,t||{});return delete n.bounds,new $i(n)}equals(e){return F.deepEqual(this._private,e._private)}get bounds(){return this._bounds}get text(){return this._private.text}get fontName(){return this._private.fontName}get bold(){return this._private.bold}get italic(){return this._private.italic}get fontSize(){return this._private.fontSize}get superSub(){return this._private.superSub}get letterSpacing(){return this._private.letterSpacing}get kerningMin(){return this._private.kerningMin}get smallCaps(){return this._private.smallCaps}get offset(){return this._private.offset}get strikeStyle(){return this._private.strikeStyle}}class um{constructor(e,t,n){this._private={},this._private={bounds:e,baseline:t,runs:n}}get bounds(){return this._private.bounds}get baseline(){return this._private.baseline}get runs(){return this._private.runs}get bullet(){return null}}function hc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Bh,Dh,Lh,Ph,zh,jh;function k0(){if(Ph)return Lh;Ph=1;const s=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,e=(t,n,r)=>{let o=t[n];t[n]=t[r],t[r]=o};return Lh={swap32LE:t=>{s&&(n=>{const r=n.length;for(let o=0;o<r;o+=4)e(n,o,o+3),e(n,o+1,o+2)})(t)}}}var O0=function(){if(jh)return zh;jh=1;const s=function(){if(Dh)return Bh;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function n(w,E){this.source=w,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=E,this.destLen=0,this.ltree=new t,this.dtree=new t}Dh=1;var r=new t,o=new t,i=new Uint8Array(30),a=new Uint16Array(30),l=new Uint8Array(30),c=new Uint16Array(30),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new t,d=new Uint8Array(320);function g(w,E,x,I){var v,R;for(v=0;v<x;++v)w[v]=0;for(v=0;v<30-x;++v)w[v+x]=v/x|0;for(R=I,v=0;v<30;++v)E[v]=R,R+=1<<w[v]}var m=new Uint16Array(16);function f(w,E,x,I){var v,R;for(v=0;v<16;++v)w.table[v]=0;for(v=0;v<I;++v)w.table[E[x+v]]++;for(w.table[0]=0,R=0,v=0;v<16;++v)m[v]=R,R+=w.table[v];for(v=0;v<I;++v)E[x+v]&&(w.trans[m[E[x+v]]++]=v)}function _(w){w.bitcount--||(w.tag=w.source[w.sourceIndex++],w.bitcount=7);var E=1&w.tag;return w.tag>>>=1,E}function p(w,E,x){if(!E)return x;for(;w.bitcount<24;)w.tag|=w.source[w.sourceIndex++]<<w.bitcount,w.bitcount+=8;var I=w.tag&65535>>>16-E;return w.tag>>>=E,w.bitcount-=E,I+x}function S(w,E){for(;w.bitcount<24;)w.tag|=w.source[w.sourceIndex++]<<w.bitcount,w.bitcount+=8;var x=0,I=0,v=0,R=w.tag;do I=2*I+(1&R),R>>>=1,++v,x+=E.table[v],I-=E.table[v];while(I>=0);return w.tag=R,w.bitcount-=v,E.trans[x+I]}function C(w,E,x){var I,v,R,A,M,T;for(I=p(w,5,257),v=p(w,5,1),R=p(w,4,4),A=0;A<19;++A)d[A]=0;for(A=0;A<R;++A){var N=p(w,3,0);d[h[A]]=N}for(f(u,d,0,19),M=0;M<I+v;){var B=S(w,u);switch(B){case 16:var D=d[M-1];for(T=p(w,2,3);T;--T)d[M++]=D;break;case 17:for(T=p(w,3,3);T;--T)d[M++]=0;break;case 18:for(T=p(w,7,11);T;--T)d[M++]=0;break;default:d[M++]=B}}f(E,d,0,I),f(x,d,I,v)}function y(w,E,x){for(;;){var I,v,R,A,M=S(w,E);if(M===256)return 0;if(M<256)w.dest[w.destLen++]=M;else for(I=p(w,i[M-=257],a[M]),v=S(w,x),A=R=w.destLen-p(w,l[v],c[v]);A<R+I;++A)w.dest[w.destLen++]=w.dest[A]}}function b(w){for(var E,x;w.bitcount>8;)w.sourceIndex--,w.bitcount-=8;if((E=256*(E=w.source[w.sourceIndex+1])+w.source[w.sourceIndex])!==(65535&~(256*w.source[w.sourceIndex+3]+w.source[w.sourceIndex+2])))return-3;for(w.sourceIndex+=4,x=E;x;--x)w.dest[w.destLen++]=w.source[w.sourceIndex++];return w.bitcount=0,0}return function(w,E){var x;for(x=0;x<7;++x)w.table[x]=0;for(w.table[7]=24,w.table[8]=152,w.table[9]=112,x=0;x<24;++x)w.trans[x]=256+x;for(x=0;x<144;++x)w.trans[24+x]=x;for(x=0;x<8;++x)w.trans[168+x]=280+x;for(x=0;x<112;++x)w.trans[176+x]=144+x;for(x=0;x<5;++x)E.table[x]=0;for(E.table[5]=32,x=0;x<32;++x)E.trans[x]=x}(r,o),g(i,a,4,3),g(l,c,2,1),i[28]=0,a[28]=258,Bh=function(w,E){var x,I,v=new n(w,E);do{switch(x=_(v),p(v,2,0)){case 0:I=b(v);break;case 1:I=y(v,r,o);break;case 2:C(v,v.ltree,v.dtree),I=y(v,v.ltree,v.dtree);break;default:I=-3}if(I!==0)throw new Error("Data error")}while(!x);return v.destLen<v.dest.length?typeof v.dest.slice=="function"?v.dest.slice(0,v.destLen):v.dest.subarray(0,v.destLen):v.dest}}(),{swap32LE:e}=k0();return zh=class{constructor(t){const n=typeof t.readUInt32BE=="function"&&typeof t.slice=="function";if(n||t instanceof Uint8Array){let r;if(n)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),r=t.readUInt32LE(8),t=t.slice(12);else{const o=new DataView(t.buffer);this.highStart=o.getUint32(0,!0),this.errorValue=o.getUint32(4,!0),r=o.getUint32(8,!0),t=t.subarray(12)}t=s(t,new Uint8Array(r)),t=s(t,new Uint8Array(r)),e(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let n;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(n=(this.data[t>>5]<<2)+(31&t),this.data[n]):t<=65535?(n=(this.data[2048+(t-55296>>5)]<<2)+(31&t),this.data[n]):t<this.highStart?(n=this.data[2080+(t>>11)],n=this.data[n+(t>>5&63)],n=(n<<2)+(31&t),this.data[n]):this.data[this.data.length-4]}}}();const B0=hc(O0);var Wh,Hh={},D0=(Wh||(Wh=1,function(s){var e=typeof Uint8Array<"u"?Uint8Array:Array,t=43,n=47,r=48,o=97,i=65,a=45,l=95;function c(h){var u=h.charCodeAt(0);return u===t||u===a?62:u===n||u===l?63:u<r?-1:u<r+10?u-r+26+26:u<i+26?u-i:u<o+26?u-o+26:void 0}s.toByteArray=function(h){var u,d,g,m,f,_;if(h.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=h.length;f=h.charAt(p-2)==="="?2:h.charAt(p-1)==="="?1:0,_=new e(3*h.length/4-f),g=f>0?h.length-4:h.length;var S=0;function C(y){_[S++]=y}for(u=0,d=0;u<g;u+=4,d+=3)C((16711680&(m=c(h.charAt(u))<<18|c(h.charAt(u+1))<<12|c(h.charAt(u+2))<<6|c(h.charAt(u+3))))>>16),C((65280&m)>>8),C(255&m);return f===2?C(255&(m=c(h.charAt(u))<<2|c(h.charAt(u+1))>>4)):f===1&&(C((m=c(h.charAt(u))<<10|c(h.charAt(u+1))<<4|c(h.charAt(u+2))>>2)>>8&255),C(255&m)),_},s.fromByteArray=function(h){var u,d,g,m=h.length%3,f="";function _(S){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(S)}function p(S){return _(S>>18&63)+_(S>>12&63)+_(S>>6&63)+_(63&S)}for(u=0,g=h.length-m;u<g;u+=3)f+=p(d=(h[u]<<16)+(h[u+1]<<8)+h[u+2]);switch(m){case 1:f+=_((d=h[h.length-1])>>2),f+=_(d<<4&63),f+="==";break;case 2:f+=_((d=(h[h.length-2]<<8)+h[h.length-1])>>10),f+=_(d>>4&63),f+=_(d<<2&63),f+="="}return f}}(Hh)),Hh),Nl={};const L0=[[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,4,4,4,4,4,4,4],[0,4,4,1,1,4,4,4,4,1,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,4,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[4,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,1,0,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,0,0,1,1,1,1,1,1,1,0,0,4,2,4,1,1,1,1,1,0,1,1,1,0],[1,4,4,1,1,1,4,4,4,0,0,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,0,1,4,4,4,0,0,1,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,0,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,4,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,1,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,1,1,1,1,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,1,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,1,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,1,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,0,4,4,4,0,0,0,0,0,0,0,0,0,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0]],P0=new B0(hc(D0).toByteArray("AAgOAAAAAAAQ4QAAAQ0P8vDtnQuMXUUZx+eyu7d7797d9m5bHoWltKVUlsjLWE0VJNigQoMVqkStEoNQQUl5GIo1KKmogEgqkKbBRki72lYabZMGKoGAjQRtJJDaCCIRiiigREBQS3z+xzOTnZ3O+3HOhd5NfpkzZx7fN9988zivu2M9hGwB28F94DnwEngd/Asc1EtIs9c/bIPDwCxwLDgezHcodyo4w5C+CCwBS8FnwSXgCnA1uFbI93XwbXAbWAfWgx+CzWAb+An4KfgFeAzsYWWfYuFz4CXwGvgb+Dfo6yNkEEwGh4CZYB44FpwI3g1OY+kfBItZOo2fB84Hy8DF4HJwNbiWpV8PVoO1LH4n2NRXyN+KcAd4kNVP9XsY4aPgcfAbsBfs6SniL4K/sPjfEf6HlanXCRkCw2BGvUh/keWfXS/CY+pFXs7x9XHmM94LTmWIeU2cgbxnS/k/B3kf86jDhU8L9V2E40vAFWAlWFUfb++NOL4F3C7JX4/4GiE+hvgWsF0oS7mXldspnN+F493gyXrh9xTav0cg3EvzgVfBG6wsmVSEkxBOBgdPGpd7JI6PnqRvJ68/xlbHof53gPeA94OzwLngk+ACsAwsByvASrAK3MB0Ws3CtQjvBJvAVrADPMDSHkb4CNijaccTwvnf4fiPEs8Lxy+D18A/QU8/xjgYBjPAbDAKTgYLwOngTHAO+EQ/8wuEF4EvsPiVCFf2+9tsFStzA8LVHuXXBsi6QyqzUYiPMR/7Mc7dAx7oL8bzw/3u/Bw8Bp4Az4AXwCtgHzsmDXP5fiF9iiVvly5d0sHngar16NKlS5cuXbp06fLmYlqHXrcd3ph4P0THUY3iXh49novju4S0tzfs5d+JPKewfAsRntZb3K9ZhOMlrO6lCC8An28U9+OuovcPcPxlVu5rCL/VmHh/iHIrzn3fIPu7SN8Axmg+8AOwEWwCm7tp3bRuWjetm5Y8bSu4B9zbKO6ZVsnORrVU3f4uXTqZ2H3sLoyx3eDXjfDndE9qyj6L838CfwVvgFpzYnof4oNgOhgBc8Fos9DrZIQLmtXPP1MmF6wGj4H+KXoWguvADkXaPil+YpuQy8Am8Ey7ODdtmJDF4HowBp4De6HDTNjhfHAHeBr0DBBy0kDxfPbcgSIusgrcWhtnJ8vL+TPix7UIOQtcBq4C28Cr4KRBnANbwSuDE+s50JgyNNFuXbp06XIgsXjIvPafjvXozKY+fVFz/z0LT1uCtKVSWbrOLWPnztG8e0Xfy7ol8XtZJi7WtG+5od2UFXQ/A12vUeS7jp27yVKHjdsU9lXB869TyNvAzt0lpP2oWbwLdjiO78bx/Sz+EMJHwK9Y/LcIfw+eZ3F67/Hl5vh9xX80J+rwX8SvRDhpgL17iPAQMHNArfPrqHPewLheI+AERV6efwV418B4nOZ/H+IfYHV8GOF5LJ3eAz0fx8sM9S0fUNud39O9CulfGZhY5huI3wzWgNvBelbHZoTbNPVpfYjKQpkHwUNgl0LWblbnk0LbbDxr0OMFpL3iqWdu9nWYPlVAWkXY39LnGdCkDbeqv1YNbfcMQ3t9oe8lzm6NH9N1ZB6Ln4BwfkJZJk7RyFnYKt6b/JDQXx9p5X+eFdqOjzM9P9MB/lUlFzr20aXIdzlY4dmn9F3YqtvoO76/2hp/D/xA5Zue88nNyL8GbFbs075X0tyUig3Qd2MCnf//HjnzpbsR3g9+1kHzzVjdnE71/qVBX9rGPUh/ysNWe1neFzvIDi5zAufV1sT0N0poR22wkFUfTOPfA4N2mbZ5fSrqOHSw+IbkSBbOGSzSRgf91/GTUWYBOB2cIZQ/G8cfBZ8CFwrnL8XxF8FKcA24jqXdiPA7Qr61OF7H4mMItwzuv2/YLth1ISt3Hzu3k4W7EH5JqPdRHD/O4k+z8A8IX5Lq3y7Z4nXE9xn6kX6vQ4bKfy+ok+hH+xf3hq9dnTTHhjKd2GmDuWA242iHMq4cC7A8kJ7i8o1+skSa7Jieo38HCWnoNjKFhdSFBxzpZ7QE6lI8N4S14aASZcryaV/WWHw66f6NHuCoxuQxmvM56GX9QMd8Q4D65ywGP+ZzRJuM+zQvx/MOS2VFeqQ4IXnH26zM9Xe6/E6D+4foAzzuajPZp8Qyw5ayZVDWuH0z0BtYRkeIDqH9KO9VbH1btd/lhNqCzvl8zeLnG0S/hnU6baHfpiuO6yy0rd+DHURo/zYF5H26j03rQsip2ndzz82u1z9N4VjWKWeb68Tedpt95HRVXp7H1R6p+/Wt4FPy/PpWwscOLRJ+PVWF/+W0iVyGzs18TIvXkOJ1Wxm66vSXz+vylenrZcj1ub439W+K8RNCGTJi2p/TJ1K23VaXr35tRpnzmjxequgfcfyk6B/TGBVlyedsNgpdd/h+W1U3P99QyFPNo1X3TwpM/WLTIWYfoBqXrv6iskHZ/RFr79R6hIyHBrH3f1nrUVnjP8SnZZ+rYtzr9Exld5MNbPNErusAPg+77u/eDOPftU9yj39TH7rezxd1LvsZQJlzkWlOirG/79zjMj/mtHUKu7vKy+3/LnXr9okyKedjX5/0He9iP/j63LwOQdarEVlfy8OO/Lqw023j6xcqmwxLiOd6heM2i9cV9LJy8jMJ23yQ+rpbfu7EQ/pXE8KYvUSqvVnb4XzZa6LrHMXHR+zcLvqWbm/Bn0/HzIs6fWPHoat8XfnDKmZGxRxeMbn2UqZ5Q94nmcZRbqqUXbZ8+lcjE+cPX11t814orvvAXNcG8vqj2vvk1MGn3anlj0bIT72v47bvE+Lc98T9b6r7AKn6j+8Duf7D0nnZx/j7Zjn0j9nbpSTndaLr9WNLivP+iN23xF7L+fqv6ZouFyb78jxVXvv5jJ9YUs9/sddO8h7KNg5jrhfaJGztT6G7KF+1d6yCmD5Kdb2fan60rSc552fZr3zeQ9DpnPp+Si5cx5Ktv2QfSzF/mMbWdOm46rFI4XstnU9xeqX4NKb7TKEdcr6pZOK3ID1k/LvFHkVczEuZLEDr499YqvqBym1aEHWgcvoYOtv0M91qQl5TfpO/in6rWx8OVpT1Wedkv3f5xom3T/xeR/6Gx6V86PWAOB4bBpqWdN+yTcVxjIyGRz/FrDGu6w/3d7kPm8StX8RyPu+uuvpNju/vTLJV37GpvoM0oZPnW87VLnL/5pDno1NoW1R6yedU6TyUv3u19a3KFnIbTLYz+ZCLP4T0tU1uivFgso0pnsJ/UtXvarNY28Xq5cvkBDrQP/E5ZaiuQwwfmTlsOiQRU1fMuqrDd/3ISSuwjOwXOfTyGUMpZIXq4GpLn3pUcdfzch2x7XO1u2uZHOPb1G6b3Xg9PH1IIWeEpJlPQtqos2EKW8b0u8rnuP1UeVLoXJb9be0uG9nnbchjU+XTszT5VeNBThPHnc5OKj1U9aj0GTHIVaGy1YhEWT4ixns00DT+XEzWn/7VAsIc63Cov3OdyhwjrnaqQqZvWKXdypRdlq+k8msZ031U+Rm4fA+3TtyeR9hwfW9G9yxDN0fZMN33F+9TE6md4hwoxumfaUzI9fN3PFT3xVV2msrQ3UsnChm6Nulk8TndpS28D3zX9tTIPsF/z7Am5OkTjm1tI1JZW74+4VgsZ0N3L1yXV3WeP5uR7TGHHdvC3JQlxybfpd22tDlk/2eofRK8TzrN/qnar/K/OUTth6I/+jAnEptNbPvFHP2gs40N3+dfMWtwqvVct7/wfd8gtQ7imifial9ZJ9/3IHLYU6eDj3+4PhsNhX+vwvcWLnu6kGfEMe8DuciPfUfGZB8X/7HJy/Gefe5n+VRGFd/wyP2ta7/LO4yh/sbLV/k9lev6kfO9Dt/5U67b1/6u/epqB1U9Me23jfHY9sscAg4tkbLl+e4/U36rJ9ddxfd6sg5vq5ice42Wpk/pb9FOJ36/W9tpv4kbC79nUbZceX8Zu6/qJ+P3WvhvA8v3reh7Jbn2d6rrNC7XNZTLma4Ba0JI9efX2uLzF5scG/w9UNU1ZxW+ymUfzELeTllXlQ1rUuhzjS5fp9c964iFBOqeSz63bU065nZKdU+mDEz3qHIjjifquw0pnb/raRtvrnsYcb46ihT3taoYz6brdNW9l6rWRnE/navdPn1XlR1km7hcz1WlH/elKuSOSvLLuE8U6m8uzwRdfcGl73VyTHuyMvzJ1Sa2cWDTP/Z63Kc94n2B1PYr24dz1JlyHLlcP+S4B6vD1c9EW4q2LWstCvUjeVy63k/LMYdUNd5D1xQfvVTzX1VjkMsUv88N8VH5fReVn/Fjn++/h6X6Q8a6b1/q3g/i/ewi0/Scs8zxXeV6mWIOUPlPzBgdFerW+bZrm2P18dnjuK6HunEp+rHvPMXbr+sHVb/lnL+pTP57jPw9Cvk3PW178JD9qChfzuvTf7Htl38L1QUf/VKu9SFjwWbTWPvFEvu7Uq76y7+31g6QlYPc669pbsm9Xur2LWI9Pu8ypfDXqm3A2z8s1FWGn4ntL9NfQu2oSlftX9uetvTtv7J8Ql4zxfXGZ3zk8PeQ9w59x2uMfqI8/q5eKh/l9cb2rwsu9rSNl06ZP2Pmxtz+rNMx93yno0n2/82rVH7rQ+y9P15H6FyRun9ViH81ATmffI7nJ5r8uXXW6enbP6b/B8/l5OifVHYLnb9S39s2zcc+Ph+rh8+eQgVPS72elzGWY/tUtbbabBpDiI7yN1q6/4th2y+ErAc5+9BVvu/7KamJbWNZeuqI/R4tRf+YyD1HmOZM1bMV3/14Sn10c0Xu+Sj1nOXb5jL73ncdy02uvlXZNde65dOHYl7Vs4KYuS6FzWLn2zJlpZqPXPVPOa5yzKOyn1VhT9lmMfdbfH7D11Wf2PXN5h9y+dD287+qxgSnaYmnIrRtIb8pJe6/Uv9OVer6Whn0zfGO/BEloZI9ojmfAlUflClDd178bTmVHVTpZXOkAlk/lb42UujmI89HH5V+cl7XtowY6vTxLVWok6UrGzoGTHN+bB+6ri05687VNpvfuvRfaP2uMlNQth1D5JjGelm/8yn+9p3p/7qk9gnfeddXZmq/Sm333PJT659Kv1zjNbZ9uv2Oi//67CV8/N1nj1DmviyXDNVeJkaeaX8UsyesYg8cu2+NvdaPfb+lLDu5tvt/")),Vh=function(s){switch(s){case 33:case 39:case 40:case 42:return 12;case 35:return 5;default:return s}},$h=function(s){switch(s){case 37:case 38:return 34;case 41:return 22;default:return s}};class Ra{constructor(e,t=!1){this.position=e,this.required=t}}Nl=class{nextCodePoint(){const s=this.string.charCodeAt(this.pos++),e=this.string.charCodeAt(this.pos);return 55296<=s&&s<=56319&&56320<=e&&e<=57343?(this.pos++,1024*(s-55296)+(e-56320)+65536):s}nextCharClass(){return Vh(P0.get(this.nextCodePoint()))}getSimpleBreak(){switch(this.nextClass){case 41:return!1;case 34:case 37:case 38:return this.curClass=34,!1;case 36:return this.curClass=36,!1}return null}getPairTableBreak(s){let e=!1;switch(L0[this.curClass][this.nextClass]){case 0:e=!0;break;case 1:e=s===41;break;case 2:if(e=s===41,!e)return e=!1,e;break;case 3:if(s!==41)return e}return this.LB8a&&(e=!1),!this.LB21a||this.curClass!==16&&this.curClass!==17?this.LB21a=this.curClass===13:(e=!1,this.LB21a=!1),this.curClass===28?(this.LB30a++,this.LB30a==2&&this.nextClass===28&&(e=!0,this.LB30a=0)):this.LB30a=0,this.curClass=this.nextClass,e}nextBreak(){if(this.curClass==null){let s=this.nextCharClass();this.curClass=$h(s),this.nextClass=s,this.LB8a=s===31,this.LB30a=0}for(;this.pos<this.string.length;){this.lastPos=this.pos;const s=this.nextClass;if(this.nextClass=this.nextCharClass(),this.curClass===34||this.curClass===36&&this.nextClass!==37)return this.curClass=$h(Vh(this.nextClass)),new Ra(this.lastPos,!0);let e=this.getSimpleBreak();if(e===null&&(e=this.getPairTableBreak(s)),this.LB8a=this.nextClass===31,e)return new Ra(this.lastPos)}return this.lastPos<this.string.length?(this.lastPos=this.string.length,new Ra(this.string.length)):null}constructor(s){this.string=s,this.pos=0,this.lastPos=0,this.curClass=null,this.nextClass=null,this.LB8a=!1,this.LB21a=!1,this.LB30a=0}};class z0{constructor(e){this._textMeasurer=e}_measureText(e){const t=this._fontSize,n=this._fontName,r=this._metricOptions;if(this._isSuperSub){const o=this._textMeasurer(e,.6*t,n,r);return{...this._textMeasurer("M",t,n,r),width:o.width}}return this._textMeasurer(e,t,n,r)}_breakWord(e,t,n){let r=0;for(;r<e.length;){let o={startPosition:this._charactersRead+r,text:"",x:0,y:0,width:0,widthWhitespace:0,height:0,baseline:0},i=!1,a=0;const l=this._maxWidth;do{i=!1;const c=e.substring(r,r+a+1),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),(o.x+u.width<=l||c.length<=1)&&(o.text=c,o.width=u.width,o.widthWhitespace=d.width,o.height=Math.max(o.height,u.lineHeight),o.baseline=Math.max(o.baseline,u.baseline),i=!0,a++)}while(i&&r+a<e.length);if(i){const c=e.substring(r,e.length),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),t.startPosition=this._charactersRead+r,t.width=u.width,o.widthWhitespace=d.width,t.height=Math.max(t.height,u.lineHeight),t.baseline=Math.max(t.baseline,u.baseline),t.text=c}else if(n?.(o)===!1)return!1;r+=a}}_breakWhiteSpace(e,t=null){for(;e&&this._charactersRead<e.length;){let n={startPosition:this._charactersRead,text:"",x:0,y:0,width:0,widthWhitespace:0,height:0,baseline:0},r=!1;const o=this._maxWidth,i=this._indent,a=this._breaker;do if(r=!1,n.startPosition===0&&n.text.length===0&&(n.x=i,this._lastBreak=a.nextBreak()),this._lastBreak){const c=e.substring(n.startPosition,this._lastBreak.position),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),n.x+u.width<=o?(n.text=c,n.width=u.width,n.widthWhitespace=d.width,n.height=Math.max(n.height,u.lineHeight),n.baseline=Math.max(n.baseline,u.baseline),r=!0,this._charactersRead=this._lastBreak.position):n.text.length===0&&this._breakWord(c,n,t)!==!1&&(r=!0,this._charactersRead=this._lastBreak.position),(r||c.indexOf(`
32
+ `)===-1)&&this._lastBreak.required&&(this._lastBreak=a.nextBreak(),r=!1)}while(r&&(this._lastBreak=a.nextBreak()));if(t?.(n)===!1)return!1}}wrap(e,t=null){this._breaker=new Nl(e),this._linesRead=[],this._charactersRead=0,this._maxXRead=0,this._maxXWhitespaceRead=0,this._maxYRead=0,this._fontName=t?.fontName??"Arial",this._fontSize=t?.fontSize??12,this._metricOptions={isBold:t?.bold??!1,isItalic:t?.italic??!1,letterSpacing:t?.letterSpacing??0},this._isSuperSub=t?.superSub??!1,this._indent=t?.indent??0,this._maxWidth=t?.maxWidth??Number.MAX_SAFE_INTEGER,this._maxWidth<=0&&(this._maxWidth=Number.MAX_SAFE_INTEGER),this._maxHeight=t?.maxHeight??Number.MAX_SAFE_INTEGER,this._maxHeight<=0&&(this._maxHeight=Number.MAX_SAFE_INTEGER);const n=o=>{if(this._linesRead.length>0){let i=this._linesRead[this._linesRead.length-1];o.y=i.y+i.height}if(o.y+o.height>this._maxHeight)return!1;this._maxXRead=Math.max(this._maxXRead,o.x+o.width),this._maxXWhitespaceRead=Math.max(this._maxXWhitespaceRead,o.x+o.widthWhitespace),this._maxYRead=Math.max(this._maxYRead,o.y+o.height),this._linesRead.push(o)};if(e===""){const o=this._measureText(e);n({startPosition:0,text:"",x:0,y:0,width:0,widthWhitespace:0,height:o.lineHeight,baseline:o.baseline})}else if(this._breakWhiteSpace(e,n),new Nl(e.charAt(e.length-1).repeat(2)).nextBreak().required){const o=this._measureText(e);n({startPosition:e.length,text:"",x:0,y:0,width:0,widthWhitespace:0,height:o.lineHeight,baseline:o.baseline})}const r={bounds:{x:0,y:0,width:this._maxXRead,widthWhitespace:this._maxXWhitespaceRead,height:this._maxYRead},lines:this._linesRead};return this._breaker=null,this._linesRead=[],r}}const j0=(s,e,t,n=null,r=exports.IFont.getSharedMeasurer())=>{let o="",i=null,a=null;const l=s.paragraphs,c=l.length;for(let y=0;y<c;y++){const b=l[y].runs,w=b.length;for(let E=0;E<w;E++)o+=b[E].text,E===0&&(i=b[E]);y===0&&(a=l[y])}const h=s.insets??Yo.EmptyRect,u=new z0(r),d=n?.width?n.width-h.right-h.left:n?.width,g=n?.height?n.height-h.bottom-h.top:null,m=u.wrap(o,{fontName:i.fontName,fontSize:i.fontSize*exports.IFont.getDeviceScale(),bold:i.bold,italic:i.italic,superSub:i.superSub,letterSpacing:i.letterSpacing,maxWidth:s.wrapped&&d?d:null,maxHeight:g});let f=[];const _=m.lines,p=_.length,S=new Array(p);for(let y=0;y<p;y++){const b=_[y],w={x:b.x,y:b.y,width:b.width,height:b.height},E=new $i({text:b.text,fontName:i.fontFamily,fontSize:i.fontSize,bold:i.bold,italic:i.italic,superSub:i.superSub,letterSpacing:i.letterSpacing},w);f.push(E),S[y]=new um(w,b.baseline,[E])}const C=new Vi({runs:f,align:a.align});return new Hi({paragraphs:[C],wrapped:s.wrapped,verticalAlignment:s.verticalAlignment},e,t,S,{x:m.bounds.x,y:m.bounds.y,width:m.bounds.widthWhitespace,height:m.bounds.height},{x:m.bounds.x,y:m.bounds.y,width:m.bounds.width,height:m.bounds.height})},Gh=s=>{let e=!1,t=!1;for(let n=0;n<s.length;n++){const r=s.charCodeAt(n);if(r>=65&&r<=90?e=!0:r>=97&&r<=122&&(t=!0),e&&t)return 0}return e?1:t?-1:0},Gi=(s,e,t,n,r=!1)=>{if(s==null)return null;const o=new $i({text:s,fontName:e.toCSS().fontFamily,fontSize:e.getSize(),bold:e.getWeight()>400,italic:e.getStyle()===exports.IFont.Style.Italic,superSub:!r&&(e.getVerticalAlignment()===exports.IFont.VerticalAlignment.Sub||e.getVerticalAlignment()===exports.IFont.VerticalAlignment.Super),letterSpacing:e.getLetterSpacing()}),i=r?exports.ITextFrame.HorizontalAlignment.Left:t.getHorizontal(),a=t.getVertical(),l=new Vi({runs:[o],align:i});let c=[];return c.push(new um(null,e.getSize(),[o])),new Hi({paragraphs:[l],wrapped:n&&(t.getOverflow()===exports.ITextFrame.Overflow.Wrap||i===exports.ITextFrame.HorizontalAlignment.Justify||i===exports.ITextFrame.HorizontalAlignment.Distributed||a===exports.ITextFrame.VerticalAlignment.Justify||a===exports.ITextFrame.VerticalAlignment.Distributed),verticalAlignment:a},e,t,c)},fs=(s,e,t,n)=>({x:s*n-e*t,y:s*t+e*n}),Uh=s=>{let e=0,t=0,n=0,r=0,o=0,i=0,a=0,l=s.length;if(l===0)return{m:0,b:0};if(l===1)return{m:1,b:s[0]};for(let h=0;h<l;h++)i=h+1,a=s[h],a==null||isNaN(a)||(e+=i,t+=a,r+=i*i,n+=i*a,o++);const c=(o*n-e*t)/(o*r-e*e);return{m:c,b:t/o-c*e/o}},kl=(s,e)=>{if(e===null)return null;const t=F.isObject(e);return s!=null&&t?F.mergeContentful(s,e):t?F.cloneObject(e):e},W0=(s,e,t)=>s==null||typeof s=="object"&&Object.keys(s).length===0;function uc(s,e,t,n){if(s===e)return s??null}function H0(s){return s==null}function V0(s,e,t=1,n){if(t===0)return{preceding:s?[...s]:[],modified:[],trailing:[]};const r=function(l,c,h=1){let u=F.findEqualOrGreater(l,c,f=>f.max);const d=l.slice(0,u),g=[],m=[];if(!l[u])return{preceding:d,modified:g,trailing:m};for(let f=u;f<l.length;f++)c+h<l[f].min?m.push({...l[f],min:l[f].min-h,max:l[f].max-h}):c>=l[f].min?Math.max(c,l[f].max+1-h)>l[f].min&&g.push({...l[f],max:Math.max(c-1,l[f].max-h)}):c<l[f].min&&c+h<=l[f].max&&g.push({...l[f],min:Math.max(c,l[f].min-h),max:l[f].max-h});return{preceding:d,modified:g,trailing:m}}(s,e,t),o=r.preceding,i=r.trailing;let a=[];return o.length>0&&a.push(o.pop()),a=a.concat(r.modified),i.length>0&&a.push(i.shift()),{preceding:o,modified:rr(a,{onMerge:uc}).modified,trailing:i}}function Ol(s,e,t){if(!s)throw new Error("runs can not be null");if(!e)return{preceding:[],modified:s?[...s]:[],trailing:[]};const n=function(i,a,l,c,h=!1){if(!a)return{preceding:[],modified:i?[...i]:[],trailing:[]};let u,d=F.findEqualOrGreater(i,a.min,S=>S.max),g=i.slice(0,d),m=i.slice(d),f=[],_={...a},p=m[0]||{min:a.min,max:a.max,value:void 0};for(u=h?(S,C,y)=>{const b=(c||kl)(C,y,S);b!==void 0?S.value=b:delete S.value,f.push(S)}:(S,C,y)=>{const b=(c||kl)(C??null,y,S);b!==void 0?S.value=b:delete S.value,f.push(S)};m.length>=0&&_.max-_.min>=0;){if(_.min<p.min)u({min:_.min,max:Math.min(_.max,p.min-1)},void 0,_.value),_={min:p.min,max:_.max,value:_.value},p={min:_.min,max:p.max,value:p.value};else if(_.min>p.min){const S=p.value!==void 0&&l?l(p,_.min):[p.value,p.value];f.push({min:p.min,max:Math.min(_.min,p.max)-1,value:S[0]}),_={min:Math.min(_.min,p.max),max:_.max,value:_.value},p={min:_.min,max:p.max,value:S[1]}}else{const S=p.value!==void 0&&l?l(p,_.min):[p.value,p.value];u({min:p.min,max:Math.min(_.max,p.max)},S[0],_.value),_={min:Math.min(_.max,p.max)+1,max:_.max,value:_.value},p={min:Math.min(_.max,p.max)+1,max:p.max,value:S[1]}}p.min<=p.max?m[0]=p:(m=m.slice(1),p=m[0]||{min:p.min,max:_.max})}return{preceding:g,modified:f,trailing:m}}(s,e,t?.onSplit,t?.onUpdate,t?.inPlace);let r=[];n.preceding.length>0&&r.push(n.preceding.pop()),r=r.concat(n.modified),n.trailing.length>0&&r.push(n.trailing.shift());const o=function(i,a){if(!i||i.length===0)return{preceding:[],modified:i?[...i]:[],trailing:[]};const l=Math.min(i.length-1,a?.startOffset??0),c=Math.min(i.length,a?.endOffset??i.length),h=a?.cull??H0;let u=i.slice(0,l),d=i.slice(c);const g=[];for(let m=l;m<c;m++)h(i[m].value,i[m].min,i[m].max)!==!0&&g.push(i[m]);return{preceding:u,modified:g,trailing:d}}(rr(r,{onMerge:t?.onMerge??uc}).modified,{cull:t?.isCull||W0});return{preceding:n.preceding,modified:o.modified,trailing:n.trailing}}function Xt(s){return[...s.preceding,...s.modified,...s.trailing]}function rr(s,e){if(!s||s.length===0)return{preceding:[],modified:s?[...s]:[],trailing:[]};const t=Math.min(s.length-1,e?.startOffset??0),n=Math.min(s.length,e?.endOffset??s.length),r=e?.onMerge??uc;let o=s.slice(0,t),i=s.slice(n);const a=[];let l={...s[t]},c=s[t]?.max||0;for(let h=t+1;h<=n;h++){const u=s[h];let d=!1;if(u&&u.min<=s[h-1].max+1)if(l.value===void 0&&u.value===void 0)d=!0;else{const g=r(l.value,u.value,l.max-l.min+1,u.max-u.min+1);g!==void 0&&(d=!0,l.value=g)}d?l.max=Math.max(c,u.max):(a.push(l),l={...s[h]},u&&(l.max=Math.max(c,u.max))),l&&(c=l.max)}return{preceding:o,modified:a,trailing:i}}function qh(s){return s&&s.sort((e,t)=>{let n=e.min-t.min;return n===0&&(n=e.max-t.max),n})}const Jh=(s,e=!1)=>{if(!s||s.length===0)return F.EmptyArray;const t=e?s:s.sort(),n=[];let r=null;for(let o=0;o<t.length;o++){const i=t[o];r?r.max===i-1?r.max=i:(n.push(r),r={min:i,max:i}):r={min:i,max:i}}return r&&n.push(r),n},Xh=(s,e)=>s?e?s||e?s.min>e.max||s.max<e.min?null:{min:Math.max(s.min,e.min),max:Math.min(s.max,e.max)}:null:{...s}:{...e},dm=s=>{const e=s.length===0;return{runs:s,run:{min:e?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,max:e?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,value:null},index:Number.MAX_SAFE_INTEGER}},gm=(s,e)=>{const t=e.run,n=t.min,r=t.max;if(s>=n&&s<=r)return t.value;let o=e.index;const i=e.runs;if(o<i.length-1&&s>r){o++;const h=i[o],u=h.min,d=h.max;if(s>=u&&s<=d)return e.index=o,t.min=u,t.max=d,t.value=h.value,t.value}if(o!==Number.MAX_SAFE_INTEGER&&o>0&&s<n){o--;const h=i[o],u=h.min,d=h.max;if(s>=u&&s<=d)return e.index=o,t.min=u,t.max=d,t.value=h.value,t.value}if(o=F.findEqualOrGreater(i,s,h=>h.max),o===i.length)return o=i.length,e.index=o,t.min=i[o-1].max+1,t.max=Number.MAX_SAFE_INTEGER,t.value=null,null;const a=i[o],l=a.min,c=a.max;if(s>=l&&s<=c){e.index=o,t.min=l,t.max=c;const h=a.value;return t.value=h,h}return o--,e.index=o,t.min=o>=0?i[o].max+1:Number.MIN_SAFE_INTEGER,t.max=l-1,t.value=null,null},Kh=function(s,e,t,n){if(s.length===0){if(t!=null||n!=null){const c=e({min:t??n,max:n??t});if(c&&c.break)return c}return}const r=t??s[0].min,o=n??s[s.length-1].max;let i=r-1,a=F.findEqualOrGreater(s,r,c=>c.max),l=s[a];for(;l&&l.min<=o;){if(i<l.min-1){const h=e({min:Math.max(i+1,r),max:Math.min(l.min-1,o)});if(h&&h.break)return h}const c=e({...l,min:Math.max(l.min,r),max:Math.min(l.max,o)});if(c&&c.break)return c;i=l.max,l=s[++a]}if(i<o){const c=e({min:Math.min(i+1,o),max:o});if(c&&c.break)return c}},Yh=new RegExp("([0-9]+)$");var ps,_s;exports.AutoFill=void 0,(s=>{s.Date=class{constructor(a){this._options=a}canFill(a,l){return qr(a)}createFillAt(a,l){l={...this._options,...l};let c=0,h=this._options?.unit;h||(h=a.length===1?gs:((g,m=!1)=>{if(!g||g.length<1)return gs;let f=g;m||(f=g.slice(),f=f.sort((C,y)=>C.getTime()-y.getTime()));let _=!1,p=-1,S=-1;for(let C=0;C<f.length;C++){let y=f[C];if(C>f.length-1&&y.getTime()<f[C+1].getTime())throw new Error("Dates are expected to be sorted.");let b=12*y.getFullYear()+y.getMonth();if(b===S)return gs;S=b;let w=y.getFullYear();w>p?p=w:_=!0}return _?vh:xh})(a));const u=Ih(a[0],0,h);u.setHours(0,0,0,0);let d=1;l?.reverse&&(d*=-1,c*=-1);for(let g=1;g<a.length;g++){let m=_0(a[g-1],a[g],h);if(g===1)d=m;else if(m!==d)return null}return a.length===1&&l.multiFill,g=>{const m=Ih(u,d*g,h);if(c!==0){const f=0+c*g,_=f%1440,p=Math.floor(_/60),S=_%60;m.setHours(p,S,0,0);const C=Math.floor(f/1440),y=Math.floor(C/365),b=C%365,w=Math.floor(b/30),E=b%30;y>0&&m.setFullYear(m.getFullYear()+y),w>0&&m.setMonth(m.getMonth()+w),E>0&&m.setDate(m.getDate()+E)}return m}}},s.Linear=class{constructor(a){this._options=a}canFill(a,l){return typeof a=="number"||a===null}createFillAt(a,l){l={...this._options,...l};const c=Uh(a),h=c.b;let u=c.m;return a.length===1?(l.reverse&&(u=-u),l.multiFill?d=>d*u+h:null):d=>u*(d+1)+h}};const e={value:null,template:null},t={sensitivity:"accent"};s.Ordinal=class{_template(a){const l=a.match(Yh);if(!l)return null;const c=l[1],h=a.lastIndexOf(c);return h===-1?null:a.substring(0,h)}canFill(a,l){if(a===null)return!0;if(typeof a!="string")return e.value=null,!1;const c=this._template(a);return c&&(l===void 0||l===e.value&&c.localeCompare(e.template,void 0,t)===0)?(e.value=a,e.template=c,!0):(e.value=null,!1)}createFillAt(a,l){const c=[],h=a[0];let u=null,d=null,g=0;if(h){const S=h.match(Yh);if(S){u=S[1],u.startsWith("0")&&(g=u.length);const C=h.lastIndexOf(u);d=h.substring(0,C)}}const m=a.length;for(let S=0;S<m;S++){const C=a[S];let y=null;if(C){const b=C.substring(d.length,C.length);b.startsWith("0")&&(g=Math.max(g,b.length));const w=parseFloat(b);isNaN(w)||(y=w)}c.push(y)}const f=Uh(c),_=f.b;let p=f.m;return p!==0&&Number.isInteger(p)?S=>{if(a[S%m]===null)return null;const C=(m===1?l.reverse?-S:S:p*(S+1))+_,y=""+Math.abs(C),b="0".repeat(Math.max(0,g-y.length))+y;return d+b}:null}},s.Copy=class{canFill(a,l){return!0}createFillAt(a,l){const c=a.length;return h=>a[h%c]??null}};const n=Object.freeze(["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),r=Object.freeze(["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]),o=Object.freeze(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),i=Object.freeze(["January","February","March","April","May","June","July","August","September","October","November","December"]);s.List=class{constructor(a){this._lists=[],this._map=new Map;const l=[];if(a?.customLists){const u=a.customLists;for(let d=u.length-1;d>0;d--)l.push(u[d])}l.push(i),l.push(o),l.push(r),l.push(n);const c=this._map,h=[];for(let u=0;u<l.length;u++){const d=l[u],g=[];h.push(g);for(let m=0;m<d.length;m++){const f=d[m],_=jr(f,!0),p=_.toLowerCase().trim();let S=c.get(p);S||(S=[],c.set(p,S));const C={value:_,asKey:p,major:u,minor:m};S.push(C),g.push(C)}}this._lists=Object.freeze(h)}canFill(a,l){return a===null?!0:typeof a!="string"?!1:!!this._map.get(a.toLowerCase().trim())}createFillAt(a,l){const c=[],h=a[0];c.push(h.toLowerCase().trim());const u=this._map.get(c[0]);let d;const g=new Map,m=new Set;for(let v=0;v<u.length;v++){const R=u[v];g.set(R.major,R)}if(a.length>1){for(let v=1;v<a.length;v++){const R=a[v].toLowerCase().trim(),A=this._map.get(R);if(!A)return null;v===1&&(d=A),c.push(R);for(let M=0;M<A.length;M++){const T=A[M].major;g.has(T)&&m.add(T)}}if(m.size===0)return null}let f=null;const _=this._lists;for(let v=0;!f&&v<_.length;v++)(a.length===1||m.has(v))&&(f=g.get(v));if(!f)return null;let p=null;for(let v=0;!p&&d&&v<d.length;v++)d[v].asKey===c[1]&&(p=d[v]);let S=!1,C=!1;const y=Gh(h);y===1?S=!0:(y===-1||Gh(h[0])===-1)&&(C=!0);const b=_[f.major];let w=f.minor,E=1;if(c.length>1){E=p.minor-f.minor;for(let v=2;v<c.length;v++)if(b[v+w].minor-b[v-1+w].minor!==E)return null}a.length===1&&l?.reverse&&(E=-E);const x=a.length,I=b.length;return v=>{if(a[v%x]===null)return null;let R=(v*E+w)%I;R<0&&(R=I+R);const A=b[R].value??null;return S?A.toUpperCase():C?A.toLowerCase():A}}},s.Composite=class{constructor(a){a=Array.isArray(a)?[...a]:[a],this._fillers=a}canFill(a,l){return!0}createFillAt(a,l){const c=this._fillers;l={multiFill:a.length>1,...l};const h=a.length;let u=0,d=!1;for(let E=0;!d&&E<=h;E++)a[E]===null?u++:d=!0;let g=0;d=!1;for(let E=h-1;!d&&E>=u;E--)a[E]===null?g++:d=!0;const m=[];let f=null,_=null,p=[],S=u,C=0;const y=E=>{if(f&&f.max+1===S){const x=f.value;x.fillAt.push(E),f.max=S,x.length++,x.valuesLength++}else f={min:S,max:S,value:{fillAt:[E],start:S,length:1,valuesLength:h,blankInterval:0}};m.push(f)},b=h-g;for(S=u;S<b;){let E=a[S];if(E===null){S++;continue}_=null;let x,I=1,v=!1;for(let T=0;!v&&T<c.length+1;T++){const N=c[T];N&&(v=N.canFill(E,x),v&&(_=N))}if(!_){E!==null&&y(E),S++;continue}let R=0;C=0,x=E;do E=a[S+I],v=_.canFill(E,x),v&&(E!==null?(x=E,R>0&&(I-R===1?C=R:R!==C&&(C=0)),R=0):R++,I++);while(v&&S+I<b);p=[a[S]];const A=1+C,M=I-R;for(let T=A;T<M;T+=A)p.push(a[S+T]);if(p.length>0){const T=p.length,N=T+(T-1)*C,B=_.createFillAt?.(p,l)??p;m.push({min:S,max:S+N-1,value:{fillAt:B,start:S,length:N,valuesLength:T,blankInterval:C}})}S+=I}const w=dm(m);return E=>{const x=E>=0,I=Math.abs(E),v=gm(I%h,w);if(!v)return null;const R=Math.floor(I/h),A=v.length,M=v.start,T=(R+(x?1:0))*M+(R+(x?0:1))*(h-(M+A));let N=E+(x?-T:T);const B=v.blankInterval;if(B!==0){let P=N%A;if(P%(1+B)!==0)return null;N=Math.floor(P/(1+B))+v.valuesLength*R}const D=v.fillAt;return typeof D=="function"?D(N):D[N%D.length]}}},s.Types={Series:new s.Composite([new s.Date,new s.Linear,new s.Ordinal,new s.List]),DateDays:new s.Date({unit:gs}),DateMonths:new s.Date({unit:vh}),DateYears:new s.Date({unit:xh}),Copy:new s.Copy},s.fillTo=(a,l,c,h)=>{const u=[],d=l.length,g=a.createFillAt(l,h);for(let m=d;m<c;m++)u.push(g(m));return u}})(exports.AutoFill||(exports.AutoFill={})),exports.IPrint=void 0,exports.IPrint||(exports.IPrint={}),exports.IFill=void 0,(ps=exports.IFill||(exports.IFill={})).Type={None:"none",Solid:"solid",Gradient:"gradient",Pattern:"pattern",Image:"pattern",Background:"background",Group:"group",Custom:"custom"},ps.GradientType={Linear:"linear",Path:"path",Circular:"circular",Rect:"rect"},ps.TileMirror={None:"none",Vertical:"v",Horizontal:"h",Both:"b"},ps.BuiltInSheetPattern={None:"none",Solid:"solid",DarkGray:"darkGray",MediumGray:"mediumGray",LightGray:"lightGray",Gray0625:"gray0625",Gray125:"gray125",DarkHorizontal:"darkHorizontal",DarkVertical:"darkVertical",DarkDown:"darkDown",DarkUp:"darkUp",DarkGrid:"darkGrid",DarkTrellis:"darkTrellis",LightHorizontal:"lightHorizontal",LightVertical:"lightVertical",LightDown:"lightDown",LightUp:"lightUp",LightGrid:"lightGrid",LightTrellis:"lightTrellis",Custom:"custom"},exports.IColor=void 0,(_s=exports.IColor||(exports.IColor={})).AdjustmentType={Alpha:"alpha",AlphaOff:"alphaOff",AlphaMod:"alphaMod",Hue:"hue",Sat:"sat",Lum:"lum",HueOff:"hueOff",SatOff:"satOff",LumOff:"lumOff",HueMod:"hueMod",SatMod:"satMod",LumMod:"lumMod",Red:"red",Green:"green",Blue:"blue",RedOff:"redOff",GreenOff:"greenOff",BlueOff:"blueOff",RedMod:"redMod",GreenMod:"greenMod",BlueMod:"blueMod",Shade:"shade",Tint:"tint",ETint:"eTint",Gray:"gray",Comp:"comp",Inv:"inv",Gamma:"gamma",InvGamma:"invGamma"},_s.Named={ActiveBorder:"activeBorder",ActiveCaption:"activeCaption",CaptionText:"captionText",AppWorkspace:"appWorkspace",BtnFace:"btnFace",BtnShadow:"btnShadow",DkShadow3d:"3dDkShadow",BtnHighlight:"btnHighlight",Light3d:"3dLight",BtnText:"btnText",Background:"background",GrayText:"grayText",Highlight:"highlight",HighlightText:"highlightText",HotLight:"hotLight",InactiveBorder:"inactiveBorder",InactiveCaption:"inactiveCaption",InactiveCaptionText:"inactiveCaptionText",InfoBk:"infoBk",InfoText:"infoText",Menu:"menu",MenuText:"menuText",ScrollBar:"scrollBar",Window:"window",WindowFrame:"windowFrame",WindowText:"windowText",Transparent:"transparent",AliceBlue:"aliceBlue",AntiqueWhite:"antiqueWhite",Aqua:"aqua",Aquamarine:"aquamarine",Azure:"azure",Beige:"beige",Bisque:"bisque",Black:"black",BlanchedAlmond:"blanchedAlmond",Blue:"blue",BlueViolet:"blueViolet",Brown:"brown",BurlyWood:"burlyWood",CadetBlue:"cadetBlue",Chartreuse:"chartreuse",Chocolate:"chocolate",Coral:"coral",CornflowerBlue:"cornflowerBlue",Cornsilk:"cornsilk",Crimson:"crimson",Cyan:"cyan",DkBlue:"dkBlue",DkCyan:"dkCyan",DkGoldenrod:"dkGoldenrod",DkGray:"dkGray",DkGreen:"dkGreen",DkKhaki:"dkKhaki",DkMagenta:"dkMagenta",DkOliveGreen:"dkOliveGreen",DkOrange:"dkOrange",DkOrchid:"dkOrchid",DkRed:"dkRed",DkSalmon:"dkSalmon",DkSeaGreen:"dkSeaGreen",DkSlateBlue:"dkSlateBlue",DkSlateGray:"dkSlateGray",DkTurquoise:"dkTurquoise",DkViolet:"dkViolet",DeepPink:"deepPink",DeepSkyBlue:"deepSkyBlue",DimGray:"dimGray",DodgerBlue:"dodgerBlue",Firebrick:"firebrick",FloralWhite:"floralWhite",ForestGreen:"forestGreen",Fuchsia:"fuchsia",Gainsboro:"gainsboro",GhostWhite:"ghostWhite",Gold:"gold",Goldenrod:"goldenrod",Gray:"gray",Green:"green",GreenYellow:"greenYellow",Honeydew:"honeydew",HotPink:"hotPink",IndianRed:"indianRed",Indigo:"indigo",Ivory:"ivory",Khaki:"khaki",Lavender:"lavender",LavenderBlush:"lavenderBlush",LawnGreen:"lawnGreen",LemonChiffon:"lemonChiffon",LtBlue:"ltBlue",LtCoral:"ltCoral",LtCyan:"ltCyan",LtGoldenrodYellow:"ltGoldenrodYellow",LtGray:"ltGray",LtGreen:"ltGreen",LtPink:"ltPink",LtSalmon:"ltSalmon",LtSeaGreen:"ltSeaGreen",LtSkyBlue:"ltSkyBlue",LtSlateGray:"ltSlateGray",LtSteelBlue:"ltSteelBlue",LtYellow:"ltYellow",Lime:"lime",LimeGreen:"limeGreen",Linen:"linen",Magenta:"magenta",Maroon:"maroon",MedAquamarine:"medAquamarine",MedBlue:"medBlue",MedOrchid:"medOrchid",MedPurple:"medPurple",MedSeaGreen:"medSeaGreen",MedSlateBlue:"medSlateBlue",MedSpringGreen:"medSpringGreen",MedTurquoise:"medTurquoise",MedVioletRed:"medVioletRed",MidnightBlue:"midnightBlue",MintCream:"mintCream",MistyRose:"mistyRose",Moccasin:"moccasin",NavajoWhite:"navajoWhite",Navy:"navy",OldLace:"oldLace",Olive:"olive",OliveDrab:"oliveDrab",Orange:"orange",OrangeRed:"orangeRed",Orchid:"orchid",PaleGoldenrod:"paleGoldenrod",PaleGreen:"paleGreen",PaleTurquoise:"paleTurquoise",PaleVioletRed:"paleVioletRed",PapayaWhip:"papayaWhip",PeachPuff:"peachPuff",Peru:"peru",Pink:"pink",Plum:"plum",PowderBlue:"powderBlue",Purple:"purple",Red:"red",RosyBrown:"rosyBrown",RoyalBlue:"royalBlue",SaddleBrown:"saddleBrown",Salmon:"salmon",SandyBrown:"sandyBrown",SeaGreen:"seaGreen",SeaShell:"seaShell",Sienna:"sienna",Silver:"silver",SkyBlue:"skyBlue",SlateBlue:"slateBlue",SlateGray:"slateGray",Snow:"snow",SpringGreen:"springGreen",SteelBlue:"steelBlue",Tan:"tan",Teal:"teal",Thistle:"thistle",Tomato:"tomato",Turquoise:"turquoise",Violet:"violet",Wheat:"wheat",White:"white",WhiteSmoke:"whiteSmoke",Yellow:"yellow",YellowGreen:"yellowGreen",ButtonFace:"buttonFace",ButtonHighlight:"buttonHighlight",ButtonShadow:"buttonShadow",GradientActiveCaption:"gradientActiveCaption",GradientInactiveCaption:"gradientInactiveCaption",MenuBar:"menuBar",MenuHighlight:"menuHighlight"},_s.Scheme={Bg1:"bg1",Bg2:"bg2",Tx1:"tx1",Tx2:"tx2",Accent1:"accent1",Accent2:"accent2",Accent3:"accent3",Accent4:"accent4",Accent5:"accent5",Accent6:"accent6",Hlink:"hlink",FolHlink:"folHlink"},_s.Type={Scheme:"scheme",Named:"named",Index:"index",HSL:"hsl",RGB:"rgb",LRGB:"lrgb",Hex:"hex"};const Qh=[[4290032820,1,exports.IColor.Named.ActiveBorder,!0],[4288263377,2,exports.IColor.Named.ActiveCaption,!0],[4278190080,3,exports.IColor.Named.CaptionText,!0],[4289440683,4,exports.IColor.Named.AppWorkspace,!0],[4293980400,5,exports.IColor.Named.BtnFace,!0],[4285098345,6,exports.IColor.Named.BtnShadow,!0],[4278190080,7,exports.IColor.Named.DkShadow3d,!0],[4293125091,8,exports.IColor.Named.BtnHighlight,!0],[4293125091,9,exports.IColor.Named.Light3d,!0],[4278190080,10,exports.IColor.Named.BtnText,!0],[4278190080,11,exports.IColor.Named.Background,!0],[4285361517,12,exports.IColor.Named.GrayText,!0],[4281571839,13,exports.IColor.Named.Highlight,!0],[4294967295,14,exports.IColor.Named.HighlightText,!0],[4278216396,15,exports.IColor.Named.HotLight,!0],[4294244348,16,exports.IColor.Named.InactiveBorder,!0],[4290760155,17,exports.IColor.Named.InactiveCaption,!0],[4278190080,18,exports.IColor.Named.InactiveCaptionText,!0],[4294967265,19,exports.IColor.Named.InfoBk,!0],[4278190080,20,exports.IColor.Named.InfoText,!0],[4293980400,21,exports.IColor.Named.Menu,!0],[4278190080,22,exports.IColor.Named.MenuText,!0],[4291348680,23,exports.IColor.Named.ScrollBar,!0],[4294967295,24,exports.IColor.Named.Window,!0],[4284769380,25,exports.IColor.Named.WindowFrame,!0],[4278190080,26,exports.IColor.Named.WindowText,!0],[16777215,27,exports.IColor.Named.Transparent],[4293982463,28,exports.IColor.Named.AliceBlue],[4294634455,29,exports.IColor.Named.AntiqueWhite],[4278255615,30,exports.IColor.Named.Aqua],[4286578644,31,exports.IColor.Named.Aquamarine],[4293984255,32,exports.IColor.Named.Azure],[4294309340,33,exports.IColor.Named.Beige],[4294960324,34,exports.IColor.Named.Bisque],[4278190080,35,exports.IColor.Named.Black],[4294962125,36,exports.IColor.Named.BlanchedAlmond],[4278190335,37,exports.IColor.Named.Blue],[4287245282,38,exports.IColor.Named.BlueViolet],[4289014314,39,exports.IColor.Named.Brown],[4292786311,40,exports.IColor.Named.BurlyWood],[4284456608,41,exports.IColor.Named.CadetBlue],[4286578432,42,exports.IColor.Named.Chartreuse],[4291979550,43,exports.IColor.Named.Chocolate],[4294934352,44,exports.IColor.Named.Coral],[4284782061,45,exports.IColor.Named.CornflowerBlue],[4294965468,46,exports.IColor.Named.Cornsilk],[4292613180,47,exports.IColor.Named.Crimson],[4278255615,48,exports.IColor.Named.Cyan],[4278190219,49,exports.IColor.Named.DkBlue],[4278225803,50,exports.IColor.Named.DkCyan],[4290283019,51,exports.IColor.Named.DkGoldenrod],[4289309097,52,exports.IColor.Named.DkGray],[4278215680,53,exports.IColor.Named.DkGreen],[4290623339,54,exports.IColor.Named.DkKhaki],[4287299723,55,exports.IColor.Named.DkMagenta],[4283788079,56,exports.IColor.Named.DkOliveGreen],[4294937600,57,exports.IColor.Named.DkOrange],[4288230092,58,exports.IColor.Named.DkOrchid],[4287299584,59,exports.IColor.Named.DkRed],[4293498490,60,exports.IColor.Named.DkSalmon],[4287609995,61,exports.IColor.Named.DkSeaGreen],[4282924427,62,exports.IColor.Named.DkSlateBlue],[4281290575,63,exports.IColor.Named.DkSlateGray],[4278243025,64,exports.IColor.Named.DkTurquoise],[4287889619,65,exports.IColor.Named.DkViolet],[4294907027,66,exports.IColor.Named.DeepPink],[4278239231,67,exports.IColor.Named.DeepSkyBlue],[4285098345,68,exports.IColor.Named.DimGray],[4280193279,69,exports.IColor.Named.DodgerBlue],[4289864226,70,exports.IColor.Named.Firebrick],[4294966e3,71,exports.IColor.Named.FloralWhite],[4280453922,72,exports.IColor.Named.ForestGreen],[4294902015,73,exports.IColor.Named.Fuchsia],[4292664540,74,exports.IColor.Named.Gainsboro],[4294506751,75,exports.IColor.Named.GhostWhite],[4294956800,76,exports.IColor.Named.Gold],[4292519200,77,exports.IColor.Named.Goldenrod],[4286611584,78,exports.IColor.Named.Gray],[4278222848,79,exports.IColor.Named.Green],[4289593135,80,exports.IColor.Named.GreenYellow],[4293984240,81,exports.IColor.Named.Honeydew],[4294928820,82,exports.IColor.Named.HotPink],[4291648604,83,exports.IColor.Named.IndianRed],[4283105410,84,exports.IColor.Named.Indigo],[4294967280,85,exports.IColor.Named.Ivory],[4293977740,86,exports.IColor.Named.Khaki],[4293322490,87,exports.IColor.Named.Lavender],[4294963445,88,exports.IColor.Named.LavenderBlush],[4286381056,89,exports.IColor.Named.LawnGreen],[4294965965,90,exports.IColor.Named.LemonChiffon],[4289583334,91,exports.IColor.Named.LtBlue],[4293951616,92,exports.IColor.Named.LtCoral],[4292935679,93,exports.IColor.Named.LtCyan],[4294638200,94,exports.IColor.Named.LtGoldenrodYellow],[4292072403,95,exports.IColor.Named.LtGray],[4287688336,96,exports.IColor.Named.LtGreen],[4294948545,97,exports.IColor.Named.LtPink],[4294942842,98,exports.IColor.Named.LtSalmon],[4280332970,99,exports.IColor.Named.LtSeaGreen],[4287090426,100,exports.IColor.Named.LtSkyBlue],[4286023833,101,exports.IColor.Named.LtSlateGray],[4289774814,102,exports.IColor.Named.LtSteelBlue],[4294967264,103,exports.IColor.Named.LtYellow],[4278255360,104,exports.IColor.Named.Lime],[4281519410,105,exports.IColor.Named.LimeGreen],[4294635750,106,exports.IColor.Named.Linen],[4294902015,107,exports.IColor.Named.Magenta],[4286578688,108,exports.IColor.Named.Maroon],[4284927402,109,exports.IColor.Named.MedAquamarine],[4278190285,110,exports.IColor.Named.MedBlue],[4290401747,111,exports.IColor.Named.MedOrchid],[4287852763,112,exports.IColor.Named.MedPurple],[4282168177,113,exports.IColor.Named.MedSeaGreen],[4286277870,114,exports.IColor.Named.MedSlateBlue],[4278254234,115,exports.IColor.Named.MedSpringGreen],[4282962380,116,exports.IColor.Named.MedTurquoise],[4291237253,117,exports.IColor.Named.MedVioletRed],[4279834992,118,exports.IColor.Named.MidnightBlue],[4294311930,119,exports.IColor.Named.MintCream],[4294960353,120,exports.IColor.Named.MistyRose],[4294960309,121,exports.IColor.Named.Moccasin],[4294958765,122,exports.IColor.Named.NavajoWhite],[4278190208,123,exports.IColor.Named.Navy],[4294833638,124,exports.IColor.Named.OldLace],[4286611456,125,exports.IColor.Named.Olive],[4285238819,126,exports.IColor.Named.OliveDrab],[4294944e3,127,exports.IColor.Named.Orange],[4294919424,128,exports.IColor.Named.OrangeRed],[4292505814,129,exports.IColor.Named.Orchid],[4293847210,130,exports.IColor.Named.PaleGoldenrod],[4288215960,131,exports.IColor.Named.PaleGreen],[4289720046,132,exports.IColor.Named.PaleTurquoise],[4292571283,133,exports.IColor.Named.PaleVioletRed],[4294963157,134,exports.IColor.Named.PapayaWhip],[4294957753,135,exports.IColor.Named.PeachPuff],[4291659071,136,exports.IColor.Named.Peru],[4294951115,137,exports.IColor.Named.Pink],[4292714717,138,exports.IColor.Named.Plum],[4289781990,139,exports.IColor.Named.PowderBlue],[4286578816,140,exports.IColor.Named.Purple],[4294901760,141,exports.IColor.Named.Red],[4290547599,142,exports.IColor.Named.RosyBrown],[4282477025,143,exports.IColor.Named.RoyalBlue],[4287317267,144,exports.IColor.Named.SaddleBrown],[4294606962,145,exports.IColor.Named.Salmon],[4294222944,146,exports.IColor.Named.SandyBrown],[4281240407,147,exports.IColor.Named.SeaGreen],[4294964718,148,exports.IColor.Named.SeaShell],[4288696877,149,exports.IColor.Named.Sienna],[4290822336,150,exports.IColor.Named.Silver],[4287090411,151,exports.IColor.Named.SkyBlue],[4285160141,152,exports.IColor.Named.SlateBlue],[4285563024,153,exports.IColor.Named.SlateGray],[4294966010,154,exports.IColor.Named.Snow],[4278255487,155,exports.IColor.Named.SpringGreen],[4282811060,156,exports.IColor.Named.SteelBlue],[4291998860,157,exports.IColor.Named.Tan],[4278222976,158,exports.IColor.Named.Teal],[4292394968,159,exports.IColor.Named.Thistle],[4294927175,160,exports.IColor.Named.Tomato],[4282441936,161,exports.IColor.Named.Turquoise],[4293821166,162,exports.IColor.Named.Violet],[4294303411,163,exports.IColor.Named.Wheat],[4294967295,164,exports.IColor.Named.White],[4294309365,165,exports.IColor.Named.WhiteSmoke],[4294967040,166,exports.IColor.Named.Yellow],[4288335154,167,exports.IColor.Named.YellowGreen],[4293980400,168,exports.IColor.Named.ButtonFace],[4294967295,169,exports.IColor.Named.ButtonHighlight],[4288716960,170,exports.IColor.Named.ButtonShadow],[4290367978,171,exports.IColor.Named.GradientActiveCaption],[4292338930,172,exports.IColor.Named.GradientInactiveCaption],[4293980400,173,exports.IColor.Named.MenuBar],[4281571839,174,exports.IColor.Named.MenuHighlight]],$0=new class{constructor(){this._lookupByName=new Map;for(let s=0;s<Qh.length;s++){const e=Qh[s],t=e[0],n=(t>>24&255)/255,r=t>>16&255,o=t>>8&255,i=255&t,a={id:e[1],name:e[2],rgbaColor:{r,g:o,b:i,a:n},system:e.length>3};this._lookupByName.set(a.name.toLowerCase(),a)}}valueOfName(s){return this._lookupByName.get(s?s.toLowerCase():"transparent")}},Aa=[{scheme:exports.IColor.Scheme.Tx1,description:"First Text Color"},{scheme:exports.IColor.Scheme.Tx2,description:"Second Text Color"},{scheme:exports.IColor.Scheme.Bg1,description:"First Background Color"},{scheme:exports.IColor.Scheme.Bg2,description:"Second Background Color"},{scheme:exports.IColor.Scheme.Accent1,description:"Accent 1"},{scheme:exports.IColor.Scheme.Accent2,description:"Accent 2"},{scheme:exports.IColor.Scheme.Accent3,description:"Accent 3"},{scheme:exports.IColor.Scheme.Accent4,description:"Accent 4"},{scheme:exports.IColor.Scheme.Accent5,description:"Accent 5"},{scheme:exports.IColor.Scheme.Accent6,description:"Accent 6"},{scheme:exports.IColor.Scheme.Hlink,description:"Hyperlink"},{scheme:exports.IColor.Scheme.FolHlink,description:"Followed Hyperlink"},{scheme:"dk1",description:"Text/Background - Dark 1"},{scheme:"lt1",description:"Text/Background - Light 1"},{scheme:"dk2",description:"Text/Background - Dark 2"},{scheme:"lt2",description:"Text/Background - Light 2"}],mm=new Map;for(let s=0;s<Aa.length;s++)mm.set(Aa[s].scheme.toLowerCase(),Aa[s]);const Zh=s=>s?{srgb:[s.red/255,s.green/255,s.blue/255],alpha:s.alpha!==void 0?s.alpha:1}:null,eu=function(s,e,t,n){let r=Zh((c=>{let h=$0.valueOfName(c);return h?new gn.RGBA(h.rgbaColor.r,h.rgbaColor.g,h.rgbaColor.b,h.rgbaColor.a):null})(s)),o=null,i=null,a=null;if(r===null&&(l=s,mm.get(l.toLowerCase()))){if(!e)throw new Error("a scheme val was used but a schemeLookup was not provided");o=s,i=e(o),r=Zh(i),a=exports.IColor.Type.Scheme}var l;if(r===null){let c=s.match(Up)||s.match(qp);if(c){let h,u=1;c.length===4?h=[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(h=[parseInt(c[2],16),parseInt(c[3],16),parseInt(c[4],16)],u=Tr(parseInt(c[1],16)/255)),h=_a(h),h=ot(h),r={srgb:h,alpha:u},a=exports.IColor.Type.Hex}}if(r===null){let c=s.match(jp)||s.match(Wp);if(c){let h=pa(c[1],c[2],c[3]);h=_a(h),h=ot(h),r={srgb:h,alpha:c[4]?Tr(parseFloat(c[4])):1},a=exports.IColor.Type.RGB}}if(r===null){let c=s.match(Hp)||s.match(Vp);if(c){let h=pa(c[1],c[2],c[3]);h=_a(h,100),h=or(h),h=ot(h),r={srgb:h,alpha:c[4]?Tr(parseFloat(c[4])):1},a=exports.IColor.Type.LRGB}}if(r===null){let c=s.match($p)||s.match(Gp);if(c){let h=pa(c[1],c[2],c[3]);h=sr(h),h=ot(h),r={srgb:h,alpha:c[4]?Tr(parseFloat(c[4])):1},a=exports.IColor.Type.HSL}}if(r===null){let c=s.match(Jp);if(c){const h=parseInt(c[1]);let u=t?.(h)??Ei(h);u&&(r={srgb:[u.red/255,u.green/255,u.blue/255],alpha:u.alpha},a=exports.IColor.Type.Index)}}if(r===null)throw new Error("Not a valid color format: "+s);return{srgbAlpha:r,key:o,color:i,type:a}},Bl=new Map,Ma=Object.keys(exports.IColor.AdjustmentType);for(let s=0;s<Ma.length;s++)Bl.set(exports.IColor.AdjustmentType[Ma[s]].toLowerCase(),exports.IColor.AdjustmentType[Ma[s]]);const tu=new RegExp("\\s+\\s*(?![^()]*\\))|,\\s*(?![^()]*\\))"),nu=new RegExp("\\s*[,]\\s*|\\s+");let Ta=null;const ru={[exports.IColor.Scheme.Bg1]:"window",[exports.IColor.Scheme.Bg2]:"E7E6E6",[exports.IColor.Scheme.Tx1]:"windowText",[exports.IColor.Scheme.Tx2]:"44546A",[exports.IColor.Scheme.Accent1]:"4472C4",[exports.IColor.Scheme.Accent2]:"ED7D31",[exports.IColor.Scheme.Accent3]:"A5A5A5",[exports.IColor.Scheme.Accent4]:"FFC000",[exports.IColor.Scheme.Accent5]:"5B9BD5",[exports.IColor.Scheme.Accent6]:"70AD47",[exports.IColor.Scheme.Hlink]:"0563C1",[exports.IColor.Scheme.FolHlink]:"954F72"};class Ue{constructor(e,t,n,r=null){let o=null,i=null;if(e instanceof Ue)o=e.getVal(),e.getAdjustments()&&(i=[...e.getAdjustments()]);else if(typeof e=="string"){const a=this._parse(e);o=a.val,i=a.adjs}else e?.val&&(o=e.val,i=e.adjs);if(!o)throw new Error("Unable to determine color value");this._private={val:o,adjs:i,schemeLookup:t,indexedLookup:n,parsedVal:eu(o,t,n),adjusted:null,resolved:null}}_parse(e){let t=null,n=e.toLowerCase().trim();const r=n.split(tu);if(r&&(t=r[0],n=n.substring(t.length,n.length).trim()),!t)throw new Error("no color key found");const o=[],i=n.split(nu);for(let a=0;a<i.length;a++){const l=i[a];if(!l)continue;const c=Bl.get(l.toLowerCase());if(!c)throw new Error("Invalid adjustment type:"+l);let h=null;if(!(c===exports.IColor.AdjustmentType.Gray||c===exports.IColor.AdjustmentType.Comp||c===exports.IColor.AdjustmentType.Inv||c===exports.IColor.AdjustmentType.Gamma||c===exports.IColor.AdjustmentType.InvGamma)){a++;const u=i[a];if(h=parseFloat(u),h==null)throw new Error(`Invalid adjustment value: missing value for'${l}'`);if(isNaN(h))throw new Error("Invalid adjustment value:"+u)}o.push({[c]:h})}return{val:t,adjs:o}}_forceDark(e=!0){this._resolve();const t=this._private.resolved;let n=[t.red,t.green,t.blue];n=((a,l)=>{l=(l%360+360)%360;const c=[1,0,0,0,1,0,0,0,1],h=Math.cos(l*Math.PI/180),u=Math.sin(l*Math.PI/180);c[0]=pr+.7874*h-pr*u,c[1]=Rn-Rn*h-Rn*u,c[2]=_r-_r*h+.9278*u,c[3]=pr-pr*h+.143*u,c[4]=Rn+(1-Rn)*h+.14*u,c[5]=_r-_r*h-.283*u,c[6]=pr-pr*h-.7874*u,c[7]=Rn-Rn*h+Rn*u,c[8]=_r+.9278*h+_r*u;const d=_=>Math.round(Math.max(0,Math.min(255,_))),g=a[0],m=a[1],f=a[2];return[d(c[0]*g+c[1]*m+c[2]*f),d(c[3]*g+c[4]*m+c[5]*f),d(c[6]*g+c[7]*m+c[8]*f)]})(n,180),n=wh(n,!1);let r=nr(n);const o=zn(r);if(o[ro]=.95*o[ro],r=sr(o),n=or(r),n=Sh(n),n=ot(n,!1),e)return new gn.RGBA(n[0],n[1],n[2],t.alpha);const i=zn(nr(n));return new gn.HSLA(i[0],i[1],i[2],t.alpha)}_resolve(){if(this._private.resolved){if(!this._private.parsedVal.key)return;let o=this._private.schemeLookup(this._private.parsedVal.key);if(o===this._private.parsedVal.color||o?.isEqual(this._private.parsedVal.color))return}const e=eu(this._private.val,this._private.schemeLookup,this._private.indexedLookup,this._private.last);let t=((o,i)=>{let a=[...o.srgb],l=o.alpha!==void 0?o.alpha:1;for(var c=0;i&&c<i.length;c++){const h=i[c],u=Object.keys(h)[0],d=h[u];u===exports.IColor.AdjustmentType.Alpha?(l=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.AlphaOff?(l+=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.AlphaMod?(l*=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.Hue?a=ya(rt,a,d):u===exports.IColor.AdjustmentType.Sat?a=ya(wa,a,d):u===exports.IColor.AdjustmentType.Lum?a=ya(ro,a,d):u===exports.IColor.AdjustmentType.HueOff?a=Ca(rt,a,d):u===exports.IColor.AdjustmentType.SatOff?a=Ca(wa,a,d):u===exports.IColor.AdjustmentType.LumOff?a=Ca(ro,a,d):u===exports.IColor.AdjustmentType.HueMod?a=ba(rt,a,d):u===exports.IColor.AdjustmentType.SatMod?a=ba(wa,a,d):u===exports.IColor.AdjustmentType.LumMod?a=ba(ro,a,d):u===exports.IColor.AdjustmentType.Red?a=nn(Us,a,d,Xs):u===exports.IColor.AdjustmentType.Green?a=nn(qs,a,d,Xs):u===exports.IColor.AdjustmentType.Blue?a=nn(Js,a,d,Xs):u===exports.IColor.AdjustmentType.RedOff?a=nn(Us,a,d,Ks):u===exports.IColor.AdjustmentType.GreenOff?a=nn(qs,a,d,Ks):u===exports.IColor.AdjustmentType.BlueOff?a=nn(Js,a,d,Ks):u===exports.IColor.AdjustmentType.RedMod?a=nn(Us,a,d,Ys):u===exports.IColor.AdjustmentType.GreenMod?a=nn(qs,a,d,Ys):u===exports.IColor.AdjustmentType.BlueMod?a=nn(Js,a,d,Ys):u===exports.IColor.AdjustmentType.Shade?a=Xp(a,d):u===exports.IColor.AdjustmentType.Tint?a=Yp(a,d):u===exports.IColor.AdjustmentType.ETint?a=Kp(a,d):u===exports.IColor.AdjustmentType.Gray?a=Qp(a):u===exports.IColor.AdjustmentType.Comp?a=Zp(a):u===exports.IColor.AdjustmentType.Inv?a=wh(a,d):u===exports.IColor.AdjustmentType.Gamma?a=e0(a):u===exports.IColor.AdjustmentType.InvGamma?a=t0(a):console.warn("unknown adjustmentType: "+u)}return{srgb:a,alpha:l}})(e.srgbAlpha,this._private.adjs),n=((o,i=255)=>{const a=[...o];for(var l=0;l<o.length;l++)a[l]=o[l]*i;return a})(t.srgb);n=Sh(n);let r=Tr(t.alpha);this._private.adjusted=t,this._private.parsedVal=e,this._private.resolved=new gn.RGBA(n[0],n[1],n[2],r)}static parse(e,t,n,r=null){if(e instanceof Ue)return e;const o=e;let i=null,a=o?.trim(),l=null;try{if(!i){const u=a?.split(tu);u&&(i=u[0],a=a.substring(i.length,a.length).trim())}if(!i)throw new Error("no color found");const c=[],h=a.split(nu);for(let u=0;u<h.length;u++){const d=h[u];if(!d)continue;const g=Bl.get(d.toLowerCase());if(!g)throw new Error("Invalid adjustment type:"+d);let m=null;if(!(g===exports.IColor.AdjustmentType.Gray||g===exports.IColor.AdjustmentType.Comp||g===exports.IColor.AdjustmentType.Inv||g===exports.IColor.AdjustmentType.Gamma||g===exports.IColor.AdjustmentType.InvGamma)){u++;const f=h[u];if(m=parseFloat(f),m==null)throw new Error(`Invalid adjustment value: missing value for'${d}'`);if(isNaN(m))throw new Error("Invalid adjustment value:"+f)}c.push({[g]:m})}l=new Ue({val:i,adjs:c},t,n,r)}catch(c){throw c}return l}static getDefaultSchemeLookup(){if(!Ta){const e=new Map,t=Object.keys(ru);for(let n=0;n<t.length;n++){const r=t[n];e.set(r.toLowerCase(),Ue.parse(ru[r],null))}Ta=n=>e.get(n.toLowerCase())?.toRGBA()}return Ta}isEqual(e){return e instanceof Ue&&this.toString().toLowerCase()===e.toString().toLowerCase()}getVal(){return this._private.val}getAdjustments(){return this._private.adjs}adjust(e){return new Ue({val:this._private.val,adjs:this._private.adjs?this._private.adjs.concat(e):e},this._private.schemeLookup,this._private.indexedLookup,this._private.last)}getType(){return this._resolve(),this._private.parsedVal.type??null}toCSS(e=!1,t=!0){const n=e?this._forceDark():this.toRGBA();return n.alpha===0?"none":n.toString(t)}toRGBA(e=!1){return this._resolve(),e?this._forceDark():this._private.resolved}toHSLA(e=!1){if(this._resolve(),e)return this._forceDark(!1);let t=zn(this._private.adjusted.srgb);return new gn.HSLA(t[0],t[1],t[2],Tr(this._private.adjusted.alpha??1))}toHex(e=!1){this._resolve();const t=e?this._forceDark():this._private.resolved;return new gn.HEX(t.red,t.green,t.blue,t.alpha??1)}toBlackOrWhite(e=!1,t=157){const n=this.toRGBA(e),r=.299*n.red+.587*n.green+.114*n.blue>t;return new Ue(r?"#000000":"#FFFFFF",this._private.schemeLookup,this._private.indexedLookup,this._private.last)}get[Symbol.toStringTag](){return this.toString()}toString(){let e=this._private.val;const t=this._private.adjs;for(let n=0;t&&n<t.length;n++){const r=t[n];if(!r)continue;const o=Object.keys(r)[0];e+=" "+o;const i=r[o];typeof i=="number"&&(e+=" "+i),n<t.length-1&&(e+=",")}return e}get isIColor(){return!0}}var ou;exports.IBorder=void 0,(ou=exports.IBorder||(exports.IBorder={})).StrokeStyle={None:"none",DashDot:"dashDot",MediumDashDot:"mediumDashDot",Dotted:"dotted",Hair:"hair",Thin:"thin",Medium:"medium",Thick:"thick",MediumDashDotDot:"mediumDashDotDot",DashDotDot:"dashDotDot",Dashed:"dashed",MediumDashed:"mediumDashed",SlantDashDot:"slantDashDot",Double:"double"},ou.Edge={Left:"left",Top:"top",Right:"right",Bottom:"bottom",Horizontal:"horizontal",Vertical:"vertical",DiagonalUp:"diagonalUp",DiagonalDown:"diagonalDown"};const fm=[],pm=new Map,su=Object.freeze([[exports.IBorder.StrokeStyle.Thin,"Thin",1,null],[exports.IBorder.StrokeStyle.Hair,"Hair",1,[1,1]],[exports.IBorder.StrokeStyle.Dotted,"Dotted",1,[2,2]],[exports.IBorder.StrokeStyle.Dashed,"Dashed",1,[3,1]],[exports.IBorder.StrokeStyle.DashDot,"Dash Dot",1,[3,3,9,3]],[exports.IBorder.StrokeStyle.DashDotDot,"Dash Dot Dot",1,[3,3,3,3,9,3]],[exports.IBorder.StrokeStyle.Double,"Double",3,null],[exports.IBorder.StrokeStyle.Medium,"Medium",2,null],[exports.IBorder.StrokeStyle.MediumDashed,"Medium Dashed",2,[9,3]],[exports.IBorder.StrokeStyle.MediumDashDot,"Medium Dash Dot",2,[3,3,9,3]],[exports.IBorder.StrokeStyle.MediumDashDotDot,"Medium Dash Dot Dot",2,[3,3,3,3,9,3]],[exports.IBorder.StrokeStyle.SlantDashDot,"Slant Dash Dot",2,[5,1,11,1]],[exports.IBorder.StrokeStyle.Thick,"Thick",3,null],[exports.IBorder.StrokeStyle.None,"None",0,null]]);for(let s=0;s<su.length;s++){const e=su[s],t=e[0],n=Object.freeze({style:t,description:e[1],width:e[2],pattern:e[3]});fm.push(n),pm.set(t,n)}(s=>{s.isEqualStrokes=(e,t)=>!(e&&!t||t&&!e)&&(e===t||e.getStyle()===t.getStyle()&&e.getColor().isEqual(t.getColor())),s.oppositeEdge=e=>e===s.Edge.Left?s.Edge.Right:e===s.Edge.Right?s.Edge.Left:e===s.Edge.Top?s.Edge.Bottom:e===s.Edge.Bottom?s.Edge.Top:e,s.BuiltInDefinitionsArray=fm,s.BuiltInDefinitions=pm})(exports.IBorder||(exports.IBorder={}));const G0={Text:"text",Repeat:"repeat",Spacing:"spacing"},iu=s=>!(!s.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)&&!s.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)),U0=Object.freeze({formatValue:sc,isFractionFormat:iu,adjustDecimalPlaces:(s,e)=>{if(!s)return"";const t=(i,a)=>{let l=i||"";const c=l.length===0||l.endsWith(".")?"0":l.charAt(l.length-1);return a<0?(l=l.substring(0,Math.max(0,l.length+a)),l==="."&&(l="")):(l.startsWith(".")||(l+="."),l+=c.repeat(a)),l},n=(i,a)=>{if(i==="General")return a>0?"0"+t("",a):i;if(iu(i))return i;let l=i,c=-1,h=-1,u=l.indexOf("E");if(u>=0&&(l=l.substring(0,u)),c=l.indexOf("."),c>=0){l=l.substring(c,l.length);let d=l&&l.match(/([.]{1}[0,#]+)/);if(!d)return i;l=d[1],h=c+l.length}else{if(a<=0)return i;c=l.lastIndexOf("0"),c<0&&(c=l.lastIndexOf("#")),c>=0&&(c+=1),h=c,l=""}return c===-1?i:(l=t(l,a),i.substring(0,c)+l+i.substring(h,i.length))},r=[];let o=i0(s);for(let i=0;i<o.length;i++)r.push(n(o[i].trim(),e));return r.join(";")}}),q0=Ge._table,dc=s=>s===14?"Short Date":q0[s]??null,oo=[{numberFormat:"General",formatType:ae.General,primary:1},{numberFormat:"0",formatType:ae.Number,regMatch:/^0[.]{0,1}[0]*$/,args:{decimalPlaces:0,separator:!1}},{numberFormat:"#,##0.00",formatType:ae.Number,regMatch:/^#,##0[.]{0,1}[0]*$/,primary:2,args:{decimalPlaces:2,separator:!0}},{numberFormat:"#,##0_);(#,##0)",formatType:ae.Number,args:{decimalPlaces:0,separator:!0}},{numberFormat:"#,##0_);[Red](#,##0)",formatType:ae.Number,args:{decimalPlaces:0,separator:!0}},{numberFormat:"#,##0.00_);(#,##0.00)",formatType:ae.Number,args:{decimalPlaces:2,separator:!0}},{numberFormat:"#,##0.00_);[Red](#,##0.00)",formatType:ae.Number,args:{decimalPlaces:2,separator:!0}},{numberFormat:"$#,##0.00",formatType:ae.Currency,primary:3,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:"$#,##0_);($#,##0)",formatType:ae.Currency,args:{decimalPlaces:0,currencySymbol:"$"}},{numberFormat:"$#,##0_);[Red]($#,##0)",formatType:ae.Currency,args:{decimalPlaces:0,currencySymbol:"$"}},{numberFormat:"$#,##0.00_);($#,##0.00)",formatType:ae.Currency,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:"$#,##0.00_);[Red]($#,##0.00)",formatType:ae.Currency,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',primary:4,formatType:ae.Accounting},{numberFormat:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)',formatType:ae.Accounting},{numberFormat:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',formatType:ae.Accounting},{numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',formatType:ae.Accounting},{numberFormat:"Short Date",formatType:ae.ShortDate,primary:5},{numberFormat:"d-mmm-yy",formatType:ae.MediumDate,primary:5.5},{numberFormat:"Long Date",formatType:ae.LongDate,primary:6},{numberFormat:"h:mm",formatType:ae.ShortTime,primary:7},{numberFormat:"h:mm AM/PM",formatType:ae.MediumTime,primary:7.5},{numberFormat:"Long Time",formatType:ae.LongTime,primary:8},{numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',formatType:ae.Comma,primary:9},{numberFormat:"0.00%",formatType:ae.Percentage,primary:10,args:{decimalPlaces:2},regMatch:/^^[0#?]*[.]{0,1}[0#?]*%*$/},{numberFormat:"0%",formatType:ae.Percentage,args:{decimalPlaces:0}},{numberFormat:"# ?/?",formatType:ae.Fraction,primary:11},{numberFormat:"# ??/??",formatType:ae.Fraction},{numberFormat:"0.00E+00",formatType:ae.Scientific,primary:12,args:{decimalPlaces:2},regMatch:/^[0#?]*[.]{0,1}[0#?]*E\+[0#?]*$/},{numberFormat:"##0.0E+0",formatType:ae.Custom,args:{decimalPlaces:0}},{numberFormat:"@",formatType:ae.Text,primary:13},{numberFormat:"d-mmm",formatType:ae.Custom},{numberFormat:"mmm-yy",formatType:ae.Custom},{numberFormat:"h:mm:ss",formatType:ae.Custom},{numberFormat:"m/d/yyyy h:mm",formatType:ae.Custom},{numberFormat:"mm:ss",formatType:ae.Custom},{numberFormat:"mm:ss.0",formatType:ae.Custom},{numberFormat:"[h]:mm:ss",formatType:ae.Custom}],Fa=[{numberFormat:"00000",formatType:ae.Special,primary:11},{numberFormat:"00000-0000",formatType:ae.Special},{numberFormat:"[<=9999999]###-####;(###) ###-####",formatType:ae.Special},{numberFormat:"000-00-0000",formatType:ae.Special}],es=new Map,Io=[];for(let s=0;s<oo.length;s++){let e=oo[s].numberFormat.toLowerCase();es.set(e,oo[s]),oo[s].regMatch&&Io.unshift(oo[s])}for(let s=0;s<Fa.length;s++){let e=Fa[s].numberFormat.toLowerCase();es.set(e,Fa[s])}const Dl=[],_m=new Map;es.forEach(function(s,e,t){s.primary&&(Dl.push(s),_m.set(F.textToKey(s.formatType),s.numberFormat))}),Dl.sort(function(s,e){return s.primary-e.primary});const au=es.get(ae.General.toLowerCase());class J0{lookupStyle(e){if(!e)return au;if(typeof e=="number"&&(e=dc(e)),!e.toLowerCase)return console.warn("Invalid numberFormat",e),au;e=e.toLowerCase();let t=es.get(e);if(t)return t;for(let n=0;!t&&n<Io.length;n++)Io[n].regMatch&&e.match(Io[n].regMatch)&&(t=Io[n]);return t||{numberFormat:e,formatType:ae.Custom}}lookupPrimary(){return Dl}lookupDefault(e){return _m.get(F.textToKey(e))}}var Ss,lu;exports.NumberFormat=void 0,(Ss=exports.NumberFormat||(exports.NumberFormat={})).Type=ae,Ss.Parser=U0,Ss.Styles=new J0,Ss.ParseRunType=G0,exports.IStyle=void 0,(lu=exports.IStyle||(exports.IStyle={})).BuiltInName={Normal:"Normal",RowLevel:"RowLevel_#",ColLevel:"ColLevel_#",Comma:"Comma",Currency:"Currency",Percent:"Percent",Comma0:"Comma [0]",Currency0:"Currency [0]",Hyperlink:"Hyperlink",FollowedHyperlink:"Followed Hyperlink",Note:"Note",WarningText:"Warning Text",Unknown12:"??-12",Unknown13:"??-13",Unknown14:"??-14",Title:"Title",Heading1:"Heading 1",Heading2:"Heading 2",Heading3:"Heading 3",Heading4:"Heading 4",Input:"Input",Output:"Output",Calculation:"Calculation",CheckCell:"Check Cell",LinkedCell:"Linked Cell",Total:"Total",Good:"Good",Bad:"Bad",Neutral:"Neutral",Accent1:"Accent1",Accent1_20:"20% - Accent1",Accent1_40:"40% - Accent1",Accent1_60:"60% - Accent1",Accent2:"Accent2",Accent2_20:"20% - Accent2",Accent2_40:"40% - Accent2",Accent2_60:"60% - Accent2",Accent3:"Accent3",Accent3_20:"20% - Accent3",Accent3_40:"40% - Accent3",Accent3_60:"60% - Accent3",Accent4:"Accent4",Accent4_20:"20% - Accent4",Accent4_40:"40% - Accent4",Accent4_60:"60% - Accent4",Accent5:"Accent5",Accent5_20:"20% - Accent5",Accent5_40:"40% - Accent5",Accent5_60:"60% - Accent5",Accent6:"Accent6",Accent6_20:"20% - Accent6",Accent6_40:"40% - Accent6",Accent6_60:"60% - Accent6",ExplanatoryText:"Explanatory Text"},lu.IconSet={Arrows3:"3Arrows",ArrowsGray3:"3ArrowsGray",Flags3:"3Flags",Signs3:"3Signs",Symbols3:"3Symbols",Symbols3_2:"3Symbols2",TrafficLights3:"3TrafficLights1",TrafficLights3_2:"3TrafficLights2",Arrows4:"4Arrows",ArrowsGray4:"4ArrowsGray",Rating4:"4Rating",RedToBlack4:"4RedToBlack",TrafficLights4:"4TrafficLights",Arrows5:"5Arrows",ArrowsGray5:"5ArrowsGray",Quarters5:"5Quarters",Rating5:"5Rating"};const X0=(s,e,t,n,r)=>{const o=JSON.parse(JSON.stringify(s.definition));o.adjs||(o.adjs=[]);let i="",a=0,l=0;e>0?(l=e,a=100-e,i=`Lighter ${e}%`):e<0&&(a=100+e,i=`Darker ${-e}%`),a&&o.adjs.push({[exports.IColor.AdjustmentType.LumMod]:a}),l&&o.adjs.push({[exports.IColor.AdjustmentType.LumOff]:l});const c=new Ue({val:o.val,adjs:o.adjs},t),h=c.toString();n?.set(h,c);const u=c.toRGBA().toString();return r?.set(u,c),{description:s.description+", "+i,definition:o}},K0=(s,e,t,n)=>{let r=[];for(let o=0;o<s.length;o++){let i=[];r.push(i);const a=c=>{for(let h=0;h<c.length;h++)i.push(X0(s[o],c[h],e,t,n))};let l=new Ue({val:s[o].definition.val,adjs:s[o].definition.adjs},e).toHSLA().lum;a(l===0?[50,35,25,15,5]:l===100?[-5,-15,-25,-35,-50]:l<=20?[90,75,50,25,10]:l>=80?[-10,-25,-50,-75,-90]:[80,60,40,-25,-50])}return r};exports.ITheme=void 0,(exports.ITheme||(exports.ITheme={})).buildPalette=K0,exports.IThemeCollection=void 0,(exports.IThemeCollection||(exports.IThemeCollection={})).BuiltInSearchType={BuiltIn:"builtIn",All:"all",Custom:"custom"};const Y0=[["Office","windowText","window","0E2841","E8E8E8","156082","E97132","196B24","0F9ED5","A02B93","4EA72E","467886","96607D"],["Office 2013-2022","windowText","window","44546A","E7E6E6","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],["Office 2007-2010","windowText","window","1F497D","EEECE1","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646","0000FF","800080"],["Grayscale","windowText","window","000000","F8F8F8","DDDDDD","B2B2B2","969696","808080","5F5F5F","4D4D4D","5F5F5F","919191"],["Atlas","windowText","window","454545","E0E0E0","F81B02","FC7715","AFBF41","50C49F","3B95C4","B560D4","FC5A1A","B49E74"],["Banded","2C2C2C","FFFFFF","099BDD","F2F2F2","FFC000","A5D028","08CC78","F24099","828288","F56617","005DBA","6C606A"],["Basis","000000","FFFFFF","565349","DDDDDD","A6B727","DF5327","FE9E00","418AB3","D7D447","818183","F59E00","B2B2B2"],["Berlin","windowText","window","9D360E","E7E6E6","F09415","C1B56B","4BAF73","5AA6C0","D17DF9","FA7E5C","FFAE3E","FCC77E"],["Celestial","windowText","window","18276C","EBEBEB","AC3EC1","477BD1","46B298","90BA4C","DD9D31","E25247","C573D2","CCAEE8"],["Circuit","windowText","window","134770","82FFFF","9ACD4C","FAA93A","D35940","B258D3","63A0CC","8AC4A7","B8FA56","7AF8CC"],["Damask","windowText","window","2A5B7F","ABDAFC","9EC544","50BEA3","4A9CCC","9A66CA","C54F71","DE9C3C","6BA9DA","A0BCD3"],["Depth","windowText","window","455F51","94D7E4","41AEBD","97E9D5","A2CF49","608F3D","F4DE3A","FCB11C","FBCA98","D3B86D"],["Dividend","windowText","window","3D3D3D","EBEBEB","4D1434","903163","B2324B","969FA7","66B1CE","40619D","828282","A5A5A5"],["Droplet","windowText","window","355071","AABED7","2FA3EE","4BCAAD","86C157","D99C3F","CE6633","A35DD1","56BCFE","97C5E3"],["Facet","windowText","window","2C3C43","EBEBEB","90C226","54A021","E6B91E","E76618","C42F1A","918655","99CA3C","B9D181"],["Frame","000000","FFFFFF","545454","BFBFBF","40BAD2","FAB900","90BB23","EE7008","1AB39F","D5393D","90BB23","EE7008"],["Gallery","windowText","window","454545","DFDBD5","B71E42","DE478E","BC72F0","795FAF","586EA6","6892A0","FA2B5C","BC658E"],["Integral","windowText","window","335B74","DFE3E5","1CADE4","2683C6","27CED7","42BA97","3E8853","62A39F","6B9F25","B26B02"],["Ion Boardroom","windowText","window","3B3059","EBEBEB","B31166","E33D6F","E45F3C","E9943A","9B6BF2","D53DD0","8F8F8F","A5A5A5"],["Ion","windowText","window","1E5155","EBEBEB","B01513","EA6312","E6B729","6AAC90","54849A","9E5E9B","58C1BA","9DFFCB"],["Madison","windowText","window","1F2D29","C5FAEB","A1D68B","5EC795","4DADCF","CDB756","E29C36","8EC0C1","6D9D9B","6D8583"],["Main Event","windowText","window","424242","C8C8C8","B80E0F","A6987D","7F9A71","64969F","9B75B2","80737A","F21213","B6A394"],["Mesh","windowText","window","363D46","EBEBEB","6F6F6F","BFBFA5","DCD084","E7BF5F","E9A039","CF7133","F28943","F1B76C"],["Metropolitan","windowText","window","162F33","EAF0E0","50B4C8","A8B97F","9B9256","657689","7A855D","84AC9D","2370CD","877589"],["Organic","windowText","window","212121","DADADA","83992A","3C9770","44709D","A23C33","D97828","DEB340","A8BF4D","B4CA80"],["Parallax","windowText","window","212121","CDD0D1","30ACEC","80C34F","E29D3E","D64A3B","D64787","A666E1","3085ED","82B6F4"],["Parcel","000000","FFFFFF","4A5356","E8E3CE","F6A21D","9BAFB5","C96731","9CA383","87795D","A0988C","00B0F0","738F97"],["Quotable","windowText","window","212121","636363","00C6BB","6FEBA0","B6DF5E","EFB251","EF755F","ED515C","8F8F8F","A5A5A5"],["Retrospect","000000","window","637052","CCDDEA","E48312","BD582C","865640","9B8357","C2BC80","94A088","2998E3","8C8C8C"],["Savon","windowText","window","1485A4","E3DED1","1CADE4","2683C6","27CED7","42BA97","3E8853","62A39F","F49100","739D9B"],["Slate","windowText","window","212123","DADADA","BC451B","D3BA68","BB8640","AD9277","A55A43","AD9D7B","E98052","F4B69B"],["Slice","windowText","window","146194","76DBF4","052F61","A50E82","14967C","6A9E1F","E87D37","C62324","0D2E46","356A95"],["Vapor Trail","windowText","window","454545","DADADA","DF2E28","FE801A","E9BF35","81BB42","32C7A9","4A9BDC","F0532B","F38B53"],["View","000000","FFFFFF","46464A","D6D3CC","6F6F74","92A9B9","A7B789","B9A489","8D6374","9B7362","67AABF","ABAFA5"],["Wisp","windowText","window","766F54","E3EACF","A53010","DE7E18","9F8351","728653","92AA4C","6AAC91","FB4A18","FB9318"],["Wood Type","windowText","window","696464","E9E5DC","D34817","9B2D1F","A28E6A","956251","918485","855D5D","CC9900","96A9A9"]],Q0=[["Office","Calibri Light","Calibri"],["Office 2013-2022","Calibri Light","Calibri"],["Office 2007-2010","Calibri Light","Calibri"],["Grayscale","Calibri Light","Calibri"],["Atlas","Calibri Light","Rockwell"],["Banded","Corbel","Corbel"],["Basis","Corbel","Corbel"],["Berlin","Trebuchet MS","Trebuchet MS"],["Celestial","Calibri Light","Calibri"],["Circuit","Tw Cen MT","Tw Cen MT"],["Damask","Bookman Old Style","Rockwell"],["Depth","Corbel","Corbel"],["Madison","Arial","Arial"],["Main Event","Impact","Impact"],["Mesh","Century Gothic","Century Gothic"],["Metropolitan","Calibri Light","Calibri Light"],["Organic","Garamond","Garamond"],["Parallax","Corbel","Corbel"],["Parcel","Gill Sans MT","Gill Sans MT"],["Quotable","Century Gothic","Century Gothic"],["Retrospect","Calibri Light","Calibri"],["Savon","Century Gothic","Century Gothic"],["Slate","Calisto MT","Calisto MT"],["Slice","Century Gothic","Century Gothic"],["Vapor Trail","Century Gothic","Century Gothic"],["View","Century Schoolbook","Century Schoolbook"],["Wisp","Century Gothic","Century Gothic"],["Wood Type","Rockwell Condensed","Rockwell"]],Z0=[["Office","Office","Office"],["2013-2022","Office 2013-2022","Office 2013-2022"],["Atlas","Atlas","Atlas"],["Banded","Banded","Banded"],["Basis","Basis","Basis"],["Berlin","Berlin","Berlin"],["Celestial","Celestial","Celestial"],["Circuit","Circuit","Circuit"],["Damask","Damask","Damask"],["Depth","Depth","Depth"],["Dividend","Dividend","Dividend"],["Droplet","Droplet","Droplet"],["Facet","Facet","Facet"],["Frame","Frame","Frame"],["Gallery","Gallery","Gallery"],["Grayscale","Grayscale","Grayscale"],["Integral","Integral","Integral"],["Ion Boardroom","Ion Boardroom","Ion Boardroom"],["Ion","Ion","Ion"],["Madison","Madison","Madison"],["Main Event","Main Event","Main Event"],["Mesh","Mesh","Mesh"],["Metropolitan","Metropolitan","Metropolitan"],["Organic","Organic","Organic"],["Parallax","Parallax","Parallax"],["Parcel","Parcel","Parcel"],["Quotable","Quotable","Quotable"],["Retrospect","Retrospect","Retrospect"],["Savon","Savon","Savon"],["Slate","Slate","Slate"],["Slice","Slice","Slice"],["Vapor Trail","Vapor Trail","Vapor Trail"],["View","View","View"],["Wisp","Wisp","Wisp"],["Wood Type","Wood Type","Wood Type"],["Office 2007-2010","Office 2007-2010","Office 2007-2010"]],Na="Themes is readonly. To make modifications create a new DocsThemes instance.",cu={[exports.IColor.Scheme.Bg1]:"lt1",[exports.IColor.Scheme.Bg2]:"lt2",[exports.IColor.Scheme.Tx1]:"dk1",[exports.IColor.Scheme.Tx2]:"dk2",[exports.IColor.Scheme.Accent1]:"accent1",[exports.IColor.Scheme.Accent2]:"accent2",[exports.IColor.Scheme.Accent3]:"accent3",[exports.IColor.Scheme.Accent4]:"accent4",[exports.IColor.Scheme.Accent5]:"accent5",[exports.IColor.Scheme.Accent6]:"accent6",[exports.IColor.Scheme.Hlink]:"hlink",[exports.IColor.Scheme.FolHlink]:"folHlink"},Wr="Office",Ll=[Wr,"Calibri Light","Calibri"],Hr=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],Sm=s=>{const e={};for(let t=0;t<s.length;t++){const n=s[t],r=n[0],o={name:r};e[r]=o;for(let i=0;i<Hr.length;i++){const a=Hr[i],l=n[i+1];if(!l)continue;const c=Ue.parse(l);l&&(o[a]=c.toString())}}return e},wm=s=>{const e={};for(let t=0;t<s.length;t++){const n=s[t],r=n[0],o={name:r};e[r]=o,o.majorFont=n[1]??Ll[1],o.minorFont=n[2]??Ll[2]}return e},e_=Sm([[Wr,"windowText","window","44546A","E7E6E6","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"]]),t_=wm([Ll]),Vo=e_[Wr],Ir=t_[Wr];let Kt=null;const n_=new class{constructor(){this._colors={};for(let s=0;s<Hr.length;s++){const e=Hr[s],t=Ue.parse(Vo[e]);this._colors[e]=t}}getName(){return Vo.name}getDk1(){return this._colors.dk1}getLt1(){return this._colors.lt1}getDk2(){return this._colors.dk2}getLt2(){return this._colors.lt2}getAccent1(){return this._colors.accent1}getAccent2(){return this._colors.accent2}getAccent3(){return this._colors.accent3}getAccent4(){return this._colors.accent4}getAccent5(){return this._colors.accent5}getAccent6(){return this._colors.accent6}getHlink(){return this._colors.hlink}getFolHlink(){return this._colors.folHlink}toJSON(){return null}};class r_{constructor(e,t=n_){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;const t=Object.keys(e);if(t.length!==0)for(let n=0;n<t.length;n++){const r=t[n];this._overrides[r]=r==="name"?e[r]:Ue.parse(e[r])}}_value(e,t){return this._overrides&&this._overrides[e]!==null&&this._overrides[e]!==void 0?this._overrides[e]:this._delegate?.[t]?.()}getName(){return this._value("name","getName")}getDk1(){return this._value("dk1","getDk1")}getLt1(){return this._value("lt1","getLt1")}getDk2(){return this._value("dk2","getDk2")}getLt2(){return this._value("lt2","getLt2")}getAccent1(){return this._value("accent1","getAccent1")}getAccent2(){return this._value("accent2","getAccent2")}getAccent3(){return this._value("accent3","getAccent3")}getAccent4(){return this._value("accent4","getAccent4")}getAccent5(){return this._value("accent5","getAccent5")}getAccent6(){return this._value("accent6","getAccent6")}getHlink(){return this._value("hlink","getHlink")}getFolHlink(){return this._value("folHlink","getFolHlink")}toJSON(){const e=F.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}}const o_=new class{constructor(){this._colors={};for(let s=0;s<Hr.length;s++){const e=Hr[s],t=Ue.parse(Vo[e]);this._colors[e]=t}}getName(){return Ir.name}getMajorFont(){return Ir.majorFont}getMinorFont(){return Ir.minorFont}getMajorFallbacks(){return Ir.majorFallbacks}getMinorFallbacks(){return Ir.minorFallbacks}};class s_{constructor(e,t=o_){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;const t=Object.keys(e);if(t.length!==0)for(let n=0;n<t.length;n++){const r=t[n];this._overrides[r]=e[r]}}_value(e,t){return this._overrides&&this._overrides[e]!==null&&this._overrides[e]!==void 0?this._overrides[e]:this._delegate?.[t]?.()}getName(){return this._value("name","getName")}getMajorFont(){return this._value("majorFont","getMajorFont")}getMinorFont(){return this._value("minorFont","getMinorFont")}getMajorFallbacks(){return this._value("majorFallbacks","getMajorFallbacks")}getMinorFallbacks(){return this._value("minorFallbacks","getMinorFallbacks")}toJSON(){const e=F.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}}class vi{constructor(e,t=null,n=null){if(this._cacheColors=new Map,!t&&e?.name){const l=Kt?Kt.get(e.name.toLowerCase()):null;l&&(t=l)}if(!t&&Kt&&(t=Kt.get(Wr.toLowerCase())),this._name=e?.name??t?.getName(),!this._name)throw new Error("Theme must have a name.");this._builtInID=n,this._delegate=t,this._colors=new r_(e?.colors,this._delegate?.getColorScheme()),this._fonts=new s_(e?.fonts,this._delegate?.getFontScheme());const r=cu,o={},i=Object.keys(r);for(let l=0;l<i.length;l++){const c=i[l];o[c]=`get${jr(r[c])}`}o.dk1="getDk1",o.dk2="getDk2",o.lt1="getLt1",o.lt2="getLt2",o.folhlink="getFolHlink",this._colorMap=o;const a=this;this._schemeLookup=l=>{let c=a._cacheColors[l];if(c)return c;const h=a._colorMap[l];if(!h)throw new Error(`Invalid color scheme key: ${l}`);const u=a.getColorScheme();let d=u[h].bind(u)();return d||(d=Vo[cu[l]??l]),c=new Ue(d).toRGBA(),a._cacheColors[l]=c,c}}get builtInID(){return this._builtInID??null}getName(){return this._name??this._delegate?.getName()??null}isCustom(){return this._builtInID!==null&&this._builtInID!==void 0}getColorScheme(){return this._colors}getFontScheme(){return this._fonts}schemeLookup(){return this._schemeLookup}parseColor(e){return Ue.parse(e,this._schemeLookup)}toJSON(){const e={name:this.getName()},t=this._colors.toJSON();t&&(Object.keys(t).length>1||t.name&&t.name!==e.name)&&(e.colors=t);const n=this._fonts.toJSON();return n&&(Object.keys(n).length>1||n.name&&n.name!==e.name)&&(e.fonts=n),Object.keys(e).length===1&&e.name===Wr?null:e}}const i_=()=>{if(Kt)return Kt;const s=((t,n,r)=>{const o=[];for(let i=0;i<t.length;i++){const a=t[i],l=a[0],c=n[a[1]]??Vo,h=r[a[2]]??Ir;o.push({name:l,colors:c,fonts:h})}return o})(Z0,Sm(Y0),wm(Q0)),e=new Map;for(let t=0;t<s.length;t++){const n=new vi(s[t]),r=new vi(null,n,t+1);e.set(r.getName().toLowerCase(),r)}return Kt=e,e};class gc{constructor(e=null,t=!1){i_(),this._isReadOnly=t,this._customMap=new Map,this._defaultTheme=this.getByName("Office")}getDefaultTheme(){return this._defaultTheme}setDefaultTheme(e){if(this._isReadOnly)throw new Error(Na);if(!e)throw new Error("Theme cannot be null.");const t=this.getDefaultTheme();return this.getByName(e.getName())||this.setCustomTheme(e),this._defaultTheme=e,t}getByName(e){return e=e.toLowerCase(),this._customMap.get(e)||(Kt.get(e)??null)}search(e){const t=e?.type??exports.IThemeCollection.BuiltInSearchType.All,n=new Map;return t!==exports.IThemeCollection.BuiltInSearchType.BuiltIn&&t!==exports.IThemeCollection.BuiltInSearchType.All||Kt.forEach((o,i)=>n.set(i,o)),t!==exports.IThemeCollection.BuiltInSearchType.Custom&&t!==exports.IThemeCollection.BuiltInSearchType.All||this._customMap.forEach((o,i)=>n.set(i,o)),e?.selected&&n.set(e.selected.getName().toLowerCase(),e.selected),(o=>{const i=[...o];return i.sort((a,l)=>F.isDefined(a.builtInID)&&!F.isDefined(l.builtInID)?1:!F.isDefined(a.builtInID)&&F.isDefined(l.builtInID)?-1:F.isDefined(a.builtInID)&&F.isDefined(l.builtInID)?a.builtInID-l.builtInID:a.getName().localeCompare(l.getName())),i})(Array.from(n.values()))}getCount(){return this._customMap.size+Kt.size}setCustomTheme(e){if(this._isReadOnly)throw new Error(Na);const t=e.getName().toLowerCase(),n=this._customMap.get(t);return this._customMap.set(t,e),n??null}deleteCustomTheme(e){if(this._isReadOnly)throw new Error(Na);let t=null;t=typeof e=="string"?e.toLowerCase():e.getName().toLowerCase();const n=this._customMap.get(t);return this._customMap.delete(t),n??null}}exports.ITableStyle=void 0,(exports.ITableStyle||(exports.ITableStyle={})).ElementType={WholeTable:"wholeTable",FirstColumnStripe:"firstColumnStripe",SecondColumnStripe:"secondColumnStripe",FirstRowStripe:"firstRowStripe",SecondRowStripe:"secondRowStripe",LastColumn:"lastColumn",FirstColumn:"firstColumn",HeaderRow:"headerRow",TotalRow:"totalRow",FirstHeaderCell:"firstHeaderCell",LastHeaderCell:"lastHeaderCell",FirstTotalCell:"firstTotalCell",LastTotalCell:"lastTotalCell"},(exports.ITableStyle||(exports.ITableStyle={})).Empty=class{constructor(s){this._normalStyle=s}getName(){return"None"}isShownInTableStyles(){return!1}isShownInPivotStyles(){return!1}getRanged(s){return null}getProperties(){return F.EmptyObject}isBuiltIn(){return!0}delete(){}toJSON(){return null}get isITableStyle(){return!0}},exports.IAnchored=void 0,(exports.IAnchored||(exports.IAnchored={})).Type={Absolute:"absolute",OneCell:"oneCell",TwoCell:"twoCell"};const Nt="Model has been closed. No further operations are allowed.",hu="Name is required";class st{constructor(e,t){this._listeners=new Set,this._pending=null,this._listeners=new Set,this._transactions=t??new Lt({transient:!0}),this._src=e;const n=this;this._transactionsRemoveListener=this._transactions?.addListener({onCommitEnd(r){const o=n._pending;if(!o)return;n._pending=null;const i=r.getId(),a=new Set;for(let l=0;l<o.length;l++){const c=o[l];c.commitId===i&&n._doNotify(c.listeners,c.removes,c.options,a)}}})}addListeners(e,t){const n=t?.transactional??this._transactions.isOpenTransaction(),r={listeners:e},o=this,i=()=>{if(!n)return void o._listeners.delete(r);const a=o._transactions.getState(o)?.listeners,l=new Set(a);l.delete(r);const c=o._transactions.beginCommit();try{c.updateState(o,{listeners:l}),c.commit({forceAmend:!0})}catch(h){throw c.rollback(),h}};if(r.remove=t?.once?i:null,n){const a=o._transactions.getState(o)?.listeners,l=new Set(a);l.add(r);const c=this._transactions.beginCommit();try{c.updateState(o,{listeners:l}),c.commit({forceAmend:!0})}catch(h){throw c.rollback(),h}}else o._listeners.add(r);return i}async _doNotify(e,t=null,n,r){const o=n?.source??this._src,i=[],a=n?.params;for(let c=0;c<e.length;c++){const h=e[c];r&&r.has(h)||(r?.add(h),i.push(h(o,a)))}let l=null;if(t&&(l=()=>{for(let c=0;c<t.length;c++)t[c]()}),n?.async)return new Promise(async(c,h)=>{try{const u=await Promise.all(i);l?.(),c(u)}catch(u){l?.(),h(u)}});l?.()}notify(e,t){let n=null,r=null;const o=u=>{u.forEach(d=>{const g=d.listeners[e];g&&(n||(n=[]),n.push(g),d.remove&&(r||(r=[]),r.push(d.remove)))})},i=t?.transactional??this._transactions.isOpenTransaction();if(i){const u=this._transactions.getState(this)?.listeners;u&&o(u)}const a=n,l=r;n=null,r=null,o(this._listeners);const c=n,h=r;if(n=null,r=null,i){if(a&&this._doNotify(a,l,t),c){let u=this._pending;return u||(this._pending=u=[]),u.push({commitId:this._transactions.getCurrentCommit().getId(),listeners:c,removes:h,options:t}),this._doNotify(c,l,t)}}else if(c)return this._doNotify(c,h,t)}close(){this._transactions.remove(this),this._transactionsRemoveListener()}}class ir{constructor(e){this._emitter=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options?.transactions??new Lt({transient:!0}),this._emitter=new st(this,this._transactions),this._updateState({isDeleted:!1}),e?.json&&this._fromJSON(e.json),this._options?.setContainerReadOnlyCallback?.(()=>{t._processOnContainerReadOnly()}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._processStateChange(n,r,o)},onRestoreOrRevert(n,r,o){t._processRestoreOrRevert(n,r,o)}}),this._processInit()}_fromJSON(e){}isReadOnly(){return this._options.isReadOnly?.()??!1}isDeleted(){return this._getState().isDeleted??!1}getType(){return this._options.type}get isIModel(){return!0}_processTransactionDone(e){}_getDescription(){return null}_getState(){if(this._closed)throw new Error(Nt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_getTransactions(){return this._transactions}_updateState(e,t,n){if(this._closed)throw new Error(Nt);if(!e)return;const r=this._beginCommit(t?.description);try{r.updateState(this,e);let o=!1;if(n)for(let i=0;i<n.length;i++){const a=n[i];o=o||a==="onAnyChange",this._emitter.notify(a)}!o&&n&&n.length>0&&this._emitter.notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_getEmitter(){return this._emitter}_processInit(){}_processStateChange(e,t,n){}_processRestoreOrRevert(e,t,n){this._emitter.notify("onInvalidated")}delete(e){if(this._getState().isDeleted)throw new Error("Model has been deleted.");this._options.deleteFromContainer&&this._options.deleteFromContainer?.(e),this._delete()}_delete(){const e=this._getDescription(),t="Delete",n=e?`${t} ${e}`:t,r=this._beginCommit(n);try{this._processDelete(),r.commit()}catch(o){throw r.rollback(),o}}_processOnContainerDeleted(){this._processDelete()}_processDelete(){this._updateState({isDeleted:!0},null,["onDelete"])}_processOnContainerReadOnly(){this._emitter.notify("onReadOnlyChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}beginCommit(e){return this._beginCommit(e)}doBatch(e,t){const n=this;return this._transactions.doBatch(e,typeof t=="string"?{description:t}:t,r=>{n._processTransactionDone(r)})}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}}class ym extends ir{_fromJSON(e){const t={};if(t.name=e?.name??null,!t.name)throw new Error(hu);t.comment=e?.comment??null,t.hidden=e?.hidden??!1,t.scope=e?.scope??null,this._updateState(t,{description:this._options.createDescription??"Create Item"+(t.name?` '${t.name}'`:"")})}_toJSON(){const e=this._getState(),t={name:e.name};return e.comment&&(t.comment=e.comment),e.hidden&&(t.hidden=e.hidden),e.hidden&&(t.hidden=e.hidden),t}getName(){return this._getState().name}setName(e,t){if(!e)throw new Error(hu);return this._updateState({name:e},{description:`Update Named '${e}'`,...t})}getComment(){return this._getState().comment}setComment(e,t){return this._updateState({comment:e},{description:"Set Comment",...t})}isHidden(){return this._getState().hidden}getScope(){return this._getState().scope}get isINamed(){return!0}}var pt;exports.ISort=void 0,(exports.ISort||(exports.ISort={})).SortOn={Value:"value",FillColor:"fillColor",FontColor:"fontColor",Icon:"icon"},exports.Sort=void 0,(pt=exports.Sort||(exports.Sort={})).CaseInsensitiveOptions={sensitivity:"base",numeric:!1},pt.CaseSensitiveOptions={sensitivity:"case",numeric:!1},pt.BooleanCollator=Object.freeze({type:U.Boolean,compare:(s,e,t)=>s===!0?1:-1}),pt.StringCollator=Object.freeze({type:U.String,compare:(s,e,t)=>s.localeCompare(e,"en",t),defaultOptions:pt.CaseInsensitiveOptions}),pt.NumberCollator=Object.freeze({type:U.Number,compare:(s,e,t)=>s<e?-1:1}),pt.RichDataCollator=Object.freeze({type:U.RichData,compare:(s,e,t)=>s.type.localeCompare(e.type,"en")}),pt.DefaultRangeOptions=Object.freeze({hasHeader:!1,reverse:!1,includeHidden:!1,collatorOptions:pt.CaseInsensitiveOptions,orientation:exports.w.Orientation.Row,offset:0}),pt.DefaultCollators=Object.freeze([pt.BooleanCollator,pt.StringCollator,pt.NumberCollator,pt.RichDataCollator]);const a_=(s,e,t,n)=>{let r;for(;!(r=s.next()).done;)try{e(r.value[1],r.value[0],t)}catch(o){if(typeof s.throw!="function")throw o;s.throw(o)}typeof s.return=="function"&&s.return()},Cm=s=>{const e=s.next.bind(s),t={next:n=>{const r=e(n);return r.done?Re:{done:r.done,value:r.value[1]}},[Symbol.iterator]:()=>t,...s.return&&{return:s.return.bind(s)},...s.throw&&{throw:s.throw.bind(s)}};return t},so=s=>{if(!s||s.length===0)return null;let e=Number.MAX_SAFE_INTEGER,t=-1,n=null;return(r,o=!1)=>{if(r===e)return r;o!==!1&&(e=Number.MAX_SAFE_INTEGER),r!==e+(o?-1:1)&&(t=((a,l,c=!0)=>{if(!a||a.length===0)return null;let h,u=-1;return c?(u=F.findEqualOrGreater(a,l,d=>d.max),h=a[u]):(u=F.findEqualOrLesser(a,l,d=>d.min),h=a[u]),h?(c?l>h.max&&(u+=1,h=a[u]):l<h.min&&(u-=1,h=a[u]),h?u:-1):-1})(s,r,!o),n=s[t]);let i=r;if(o)for(;n&&i<=n.max;)i=n.min-1,n=s[--t];else for(;n&&i>=n.min;)i=n.max+1,n=s[++t];return e=i,i}},Re=Object.freeze({done:!0,value:void 0}),Xe=Object.freeze({next:()=>Re,[Symbol.iterator]:()=>Xe});var Br;Object.seal({done:!1,value:void 0}),(s=>{s.isList=t=>!!t&&!!t.isIList,s.isListLike=t=>!!t&&typeof t.length=="number"&&typeof t.at=="function",s.fromArray=(t,n,r,o)=>new e(t,n,r,o);class e{constructor(n,r,o,i){this.g=r,this.s=o;let a=n??i;if(o&&n&&!i){i=new Array(n.length);for(let l=0;l<n.length;l++){let c=n[l];i[l]=o(c,l)}a=i}this.a=a??F.EmptyArray,r&&(this.at=l=>{l<0&&(l=a.length+l);const c=a[l];if(c!==void 0)return r(c,l)})}at(n){const r=this.a;return n<0&&(n=r.length+n),r[n]}fromArray(n){return new e(n,this.g,this.s)}get length(){return this.a.length}get isIList(){return!0}}s.ArrayList=e})(Br||(Br={}));class Bt{constructor(e){if(this._s=null,this._r=null,this._l=0,e&&e.length>0){const t=Br.isList(e)&&!Array.isArray(e)?e:new Br.ArrayList(e);this._s=t,this._l=e.length}}at(e){const t=this._s;if(t)return t.at(e);const n=this._c;if(n&&n.min<=e&&n.max>=e){const l=n.value;return l.v.at(e-n.min+l.s)}const r=this._r,o=F.findEqualOrGreater(r,e,l=>l.max),i=r[o];if(!i)return;const a=i.value;return this._c=i,a.v.at(e-i.min+a.s)}toArray(e=Number.MAX_SAFE_INTEGER){const t=[],n=this.entries(l_);let r=n.next();for(;!r.done&&t.length<e;)t.push(r.value[1]),r=n.next();return t}entries(e){const t=this.length;if(t===0)return Xe;let n,r,o,i=!0,a=0,l=t-1;if(e){i=!e.reverse;const g=e.bounds;g&&(a=Math.max(g.min??a,a),l=Math.min(g.max??l,l)),n=e.reuseResult??null,r=e.processSkip}const c=i?1:-1;let h=(i?a:l)-c;const u=this._s;if(u)o=g=>{if(!(g<a||g>l))return u.at(g)};else{const g=this._r;let m=i?0:g.length-1,f=g[m];const _=(p,S)=>{const C=p===m?f:g[p];if(C&&S>=C.min&&S<=C.max)return m=p,f=C,C};o=p=>{if(p<a||p>l)return;let S=_(m,p);if(S||(S=_(m+c,p)),!S){const y=F.findEqualOrGreater(g,p,b=>b.max);S=_(y,p)}if(!S)return;const C=S.value;return C.v.at(p-S.min+C.s)}}const d={next:g=>{let m,f=h+c;return g!==void 0&&(g<0&&(g=t+g),f=g),f<a||f>l||r&&(f=r(f,!i),f<a||f>l)?Re:(m=o(f),h=f,n?(Ro.done=!1,Ro.value[0]=f,Ro.value[1]=m,Ro):{done:!1,value:[h,m]})},[Symbol.iterator]:()=>d};return d}slice(e,t=void 0){const n=this._r??uu(this._s);if(!n)return ka;const r=this.length;if(e=Math.min(Math.max(0,e),r),(t=Math.min(Math.max(0,t??r),r))-e<=0)return ka;if(e<=0&&t>=r)return this;const o=e,i=t-1;let a=[],l=0;for(let h=0;h<n.length;h++){let u=n[h];const d=u.max;if(o===0&&d<=i){a.push(u);continue}const g=u.min;if(g>i){h=n.length;continue}if(d<o){l=d+1;continue}const m=Math.max(0,o-g),f=Math.max(0,d-i),_=f+m,p=u.value;a.push({min:g-l,max:d-_-l,value:{s:p.s+m,e:p.e-f,v:p.v}}),l+=_}const c=new Bt;return c._r=a,c._l=i-o+1,c}concat(e){if(!e)return this;if(!Br.isListLike(e))throw new Error("Value must be IListLike");const t=this._l;if(t===0)return e.isIReadableList?e:e.length===0?ka:new Bt(e);const n=e,r=e.length;if(r===0)return this;const o=this._r??uu(this._s),i=o.slice(0,o.length-1);let a=o[o.length-1],l=a?a.min:0,c=a?a.max:0,h=a?a.value:null,u=h?h.v:null,d=h?h.e-h.s:0;const g=_=>{const p=_.s,S=_.e,C=S-p;if(C+d<c_&&u&&u.fromArray){let w=_.v;const E=[],x=h.s,I=h.e;for(let R=x;R<=I;R++)E.push(u.at(R));for(let R=p;R<=S;R++)E.push(w.at(R));const v=u.fromArray(E);if(v)return w=v,d=w.length-1,h={s:0,e:d,v:w},a={min:l,max:l+d,value:h},c=l+d,void(u=w)}i.push(a);const y=c+1,b=y+C;a={min:y,max:b,value:_},l=y,c=b,h=a?a.value:null,u=h?h.v:null,d=h?h.e-h.s:0};if(e instanceof Bt){const _=e._s;if(_)g({s:0,e:_.length-1,v:_});else{const p=e._r;for(let S=0;S<p.length;S++)g(p[S].value)}}else g({s:0,e:r-1,v:n});i.push(a);const m=new Bt,f=t+r;return i.length===1&&i[0].min===0&&i[0].max===f-1?m._s=i[0].value.v:m._r=i,m._l=f,m}get length(){return this._l}[Symbol.iterator](){return Cm(this.entries())}get isIReadableList(){return!0}get isIList(){return!0}get[Symbol.toStringTag](){return"[ImmutableList]"}toString(){const e=this.length;if(e===0)return"";let t="";for(let n=0;n<e;n++){n>0&&(t+=",");const r=this.at(n);t+=r==null?"":String(r)}return t}}const uu=s=>[{min:0,max:s.length-1,value:{s:0,e:s.length-1,v:s}}],ka=new Bt,Ro=Object.seal({done:!1,value:[-1,null]}),l_=Object.freeze({reverse:!1,bounds:{min:0,max:Number.MAX_SAFE_INTEGER},skipRuns:null,reuseResult:Ro}),c_=4;var xi;(s=>{const e=(n,r)=>{const o=n!==se.Row;return r?(i,a)=>{if(i===a)return 0;const l=i[0],c=i[1],h=a[1];if(c===h)return l?-1:1;const u=a[0];let d=0,g=0;if(o?(d=l?c.colEnd:c.colStart,g=u?h.colEnd:h.colStart):(d=l?c.rowEnd:c.rowStart,g=u?h.rowEnd:h.rowStart),d===g&&l!==u)return l?-1:1;if(d!==g)return g-d;let m=0,f=0;if(o?(m=l?c.colStart:c.colEnd,f=u?h.colStart:h.colEnd):(m=l?c.rowStart:c.rowEnd,f=u?h.rowStart:h.rowEnd),m===f&&l!==u)return l?-1:1;if(m!==f)return f-m;const _=i[2]??0;return(a[2]??0)-_}:(i,a)=>{if(i===a)return 0;const l=i[0],c=i[1],h=a[1];if(c===h)return l?-1:1;const u=a[0];let d=0,g=0;if(o?(d=l?c.colStart:c.colEnd,g=u?h.colStart:h.colEnd):(d=l?c.rowStart:c.rowEnd,g=u?h.rowStart:h.rowEnd),d===g&&l!==u)return l?-1:1;if(d!==g)return d-g;let m=0,f=0;return o?(m=l?c.colEnd:c.colStart,f=u?h.colEnd:h.colStart):(m=l?c.rowEnd:c.rowStart,f=u?h.rowEnd:h.rowStart),m===f&&l!==u?l?-1:1:m!==f?m-f:(i[2]??0)-(a[2]??0)}};class t{constructor(r,o){if(this._isColumn=!0,this._isByCell=!1,this._isReverse=!1,this._cursor=null,this._reuse=null,this._localReuse={done:!1,value:[null,null]},this._eventsMajor=null,this._eventMajorIndex=0,this._majorStart=0,this._majorEnd=0,this._eventMinorPeek=null,this._minorStart=0,this._minorEnd=0,!r||r.length===0)return;let i=se.Column,a=!1,l=!0,c=!1;o&&(i=o.orientation??se.Column,this._isColumn=l=i!==se.Row,this._isReverse=a=o.reverse??!1,this._isByCell=c=o.byCell??!1);const h=r.length,u=new Array(2*h);for(let f=0;f<h;f++){const _=r[f],p=[null,null];u[2*f]=[!0,_,f,p],u[2*f+1]=[!1,_,f,p]}u.sort(e(i,a)),this._eventsMajor=u;const d=u[0][1];this._majorStart=a?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,this._majorEnd=l?a?d.colEnd+1:d.colStart-1:a?d.rowEnd+1:d.rowStart-1,this._eventsMinor=new Se(null,e(l?se.Row:se.Column,a));const g=new Array(16);g.length=0,this._cursor={cell:null,range:{colStart:d.colStart,rowStart:d.rowStart,colEnd:d.colEnd,rowEnd:d.rowEnd},overlaps:g},c&&(this._cursor.cell={colIndex:a?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,rowIndex:a?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER});const m=o?.reuseIterator;m&&(this._reuse=m,m.value=this._cursor)}next(r){const o=this._isColumn,i=this._isReverse;if(r){if(!this._isByCell)throw new Error("nextCell is only supported when byCell is true");const I=k.createCellComparator(o?se.Column:se.Row,i);let v;do{const R=this._cursor,A=R.cell;if(A.colIndex!==Number.MAX_SAFE_INTEGER&&I(A,r)>=0)throw new Error("nextCell must be after the current iteration cell");if(v=this.next(),v.done)return v;const M=v.value.cell;if(I(M,r)>=0)return v;const T=R.range;if(o){const N=r.colIndex===A.colIndex;A.rowIndex=i?N?Math.max(r.rowIndex,T.rowStart):T.rowStart:N?Math.min(r.rowIndex,T.rowEnd):T.rowEnd}else{const N=r.rowIndex===A.rowIndex;A.colIndex=i?N?Math.max(r.colIndex,T.colStart):T.colStart:N?Math.min(r.colIndex,T.colEnd):T.colEnd}if(I(A,r)>=0)return M.rowIndex=A.rowIndex,M.colIndex=A.colIndex,v}while(!v.done);return v}let a=this._cursor;if(!a)return Re;let l=this._reuse;if(!l){const I=a.cell,v=a.range,R={cell:null,range:{colStart:v.colStart,rowStart:v.rowStart,colEnd:v.colEnd,rowEnd:v.rowEnd},overlaps:[...a.overlaps]};I&&(R.cell={colIndex:I.colIndex,rowIndex:I.rowIndex}),this._cursor=R,l={done:!1,value:R}}const c=l.value,h=c.range,u=c.cell,d=this._isByCell,g=i?-1:1;let m=!1;if(d){const I=u.rowIndex,v=u.colIndex,R=o?I:v,A=o?i?h.rowStart:h.rowEnd:i?h.colStart:h.colEnd;if((i?R>=A:R<=A)&&(o?u.rowIndex=I+g:u.colIndex=v+g,i?R>A:R<A))return l;const M=o?u.colIndex:u.rowIndex,T=o?i?h.colStart:h.colEnd:i?h.rowStart:h.rowEnd;(i?M>T:M<T)&&(m=!0)}const f=c.overlaps;let _=this._majorStart,p=this._majorEnd,S=this._eventsMinor,C=this._minorStart,y=this._minorEnd,b=this._eventsMinorIterator,w=this._eventMinorPeek,E=w;for(;E&&!E.done;){const I=E.value[0];if(I[0])E=null;else{if(w=b.next(),w.done)f.length=0;else{const v=I[1];let R=f.length;if(R>1){const A=f.indexOf(v);A!==-1&&(f[A]=f[R-1])}if(f.length=R-1,R=f.length,R>0){const A=w.value[0],M=A[1],T=o?i?M.colStart:M.colEnd:i?M.rowStart:M.rowEnd;if(i?_>=T:_<=T){let N=!1;if(A[0]){const B=o?i?M.rowEnd:M.rowStart:i?M.colEnd:M.colStart;(i?B<y+g:B>y+g)&&(C=y+g,y=B-g,N=!0)}else{const B=o?i?M.rowStart:M.rowEnd:i?M.colStart:M.colEnd;(i?B<y:B>y)&&(C=y+g,y=B,N=!0)}if(N)return o?(h.rowStart=i?y:C,h.rowEnd=i?C:y):(h.colStart=i?y:C,h.colEnd=i?C:y),this._minorStart=C,this._minorEnd=y,this._eventMinorPeek=w,l}}}w.done&&(w=null),E=w}}if(!w)if(m){b=S.entries(void 0,this._localReuse),w=b.next(),this._eventsMinorIterator=b;const I=w.value[0][1],v=o?i?I.rowEnd:I.rowStart:i?I.colEnd:I.colStart;o?(u.colIndex=u.colIndex+g,u.rowIndex=v):(u.colIndex=v,u.rowIndex=u.rowIndex+g)}else{let I=this._eventMajorIndex;const v=this._eventsMajor,R=v.length;if(I>=R)return this._cursor=null,Re;let A=v[I],M=A[0],T=!1;for(;!M&&!T&&A;){const B=A[1],D=o?i?B.colStart:B.colEnd:i?B.rowStart:B.rowEnd;if(i?D<p:D>p){T=!0;continue}const P=A[3];S.delete(P[0]),S.delete(P[1]),I++,A=v[I],A&&(M=A[0])}let N=S.size>0?p+g:-1;for(T=!1;M&&!T&&A;){const B=A[1];if(N!==-1&&(o?i?B.colEnd:B.colStart:i?B.rowEnd:B.rowStart)!==N){T=!0;continue}const D=A[2],P=[!0,B,D],L=[!1,B,D],z=A[3];if(z[0]=P,z[1]=L,S.set(P,0),S.set(L,0),N===-1&&(N=o?i?B.colEnd:B.colStart:i?B.rowEnd:B.rowStart),I++,A=v[I],!A||(M=A[0],!M))continue;const O=A[1];(o?i?O.colEnd:O.colStart:i?O.rowEnd:O.rowStart)!==N&&(T=!0)}if(N!==-1&&(_=N),d&&(o?u.colIndex=_:u.rowIndex=_),this._eventMajorIndex=I,I>=R)return this._eventsMinorIterator=b,this._cursor=null,Re;if(A){const B=A[0],D=A[1],P=o?i?D.colEnd:D.colStart:i?D.rowEnd:D.rowStart,L=o?i?D.colStart:D.colEnd:i?D.rowStart:D.rowEnd;p=B?P-g:L}f.length=0,b=S.entries(void 0,this._localReuse),w=b.next(),this._eventsMinorIterator=b}let x=w;do{const I=x.value;x=null;const v=I[0],R=v[1];if(!v[0])continue;const A=o?i?R.rowEnd:R.rowStart:i?R.colEnd:R.colStart;C!==A&&(C=A),w=b.next();const M=w.value[0],T=M[0],N=M[1],B=o?i?N.rowEnd:N.rowStart:i?N.colEnd:N.colStart;if(T&&B===C)x=w;else{const D=o?i?R.rowStart:R.rowEnd:i?R.colStart:R.colEnd,P=o?i?N.rowStart:N.rowEnd:i?N.colStart:N.colEnd;y=(i?Math.max:Math.min)(D,T?B-g:P),d&&(o?u.rowIndex=C:u.colIndex=C)}f[f.length]=Object.freeze(R)}while(x);return o?(h.colStart=i?p:_,h.colEnd=i?_:p,h.rowStart=i?y:C,h.rowEnd=i?C:y):(h.rowStart=i?p:_,h.rowEnd=i?_:p,h.colStart=i?y:C,h.colEnd=i?C:y),this._eventMinorPeek=w,this._minorStart=C,this._minorEnd=y,this._majorStart=_,this._majorEnd=p,l}return(r){return null}throw(r){return null}[Symbol.iterator](){return this}}s.IteratorInstance=t})(xi||(xi={}));const Fn=(s,e=Be.Right,t=null)=>{if(!s)return s;if(s.length===0)return[];const n=e===Be.Right,r=e===Be.Left,o=e===Be.Up,i=e===Be.Down;return s.sort((a,l)=>{if(!a&&!l)return 0;if(a&&!l)return-1;if(l&&!a)return 1;const c=t?.(a,l)??0;return c!==0?c:n?a.rowStart===l.rowStart?a.colStart-l.colStart:a.rowStart-l.rowStart:i?a.colStart===l.colStart?a.rowStart-l.rowStart:a.colStart-l.colStart:r?a.rowStart===l.rowStart?l.colStart-a.colStart:l.rowStart-a.rowStart:o?a.colStart===l.colStart?l.rowStart-a.rowStart:l.colStart-a.colStart:0})},h_=(s,e)=>{const t=e.min,n=s.min;if(e.max===Number.MAX_SAFE_INTEGER){const r=t,o=s.max;return n<=r&&r<=o?0:o<r?-1:n>r?1:(console.warn("coords are not inserted correctly",s,e),0)}return n-t};class jn{constructor(e){this._runs=null,this._dataCoords=null,this._count=0,this._length=0,this._maxCoords=null,this._options=e,e?.maxCoords&&(this._maxCoords=Object.freeze({...e.maxCoords})),this._runs=new Se(void 0,h_,e?.nodeSize),this._reuseRunsIterator={done:!1,value:[null,null]},this._reuseRunsEntry=[null,null]}_validateBounds(e=Number.MIN_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER){const n=this._maxCoords,r=n?.min??Number.MIN_SAFE_INTEGER,o=n?.max??Number.MAX_SAFE_INTEGER;if(e<r||t>o)throw new ke}entries(e){let t,n,r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER,i=!0;e&&(e?.bounds&&(r=e.bounds?.min??Number.MIN_SAFE_INTEGER,o=e.bounds?.max??Number.MAX_SAFE_INTEGER,this._validateBounds(r,o)),i=!e.reverse,t=u_(e.reuseResult),n=e.processSkip);const a=this._dataCoords;if(!a)return Xe;r=Math.max(a.min,r),o=Math.min(a.max,o);let l=null,c=null,h=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER;if(n){const _=n;n=(p,S)=>_(p+h,S)-h}const d=_=>{let p;_!==Number.MIN_SAFE_INTEGER&&_!==Number.MAX_SAFE_INTEGER&&(xt.min=_,p=xt),l=i?this._runs.entries(p,this._reuseRunsIterator):this._runs.entriesReversed(p,this._reuseRunsIterator),h=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,c=null},g=_=>{if(_!==void 0){if(_<h||_>u)return void(c=void 0);_-=h}if(!c)return;let p=c.next(_);if(!c)return;let S=p.value,C=S?.[1];return p.done?void(c=void 0):d_(S[0]+h,C,t)},m=_=>{let p;return p=g(_),p||(p=(S=>{let C;do{if(S!==void 0&&d(S),!l)return;if(C=l.next(),C.done)return void(l=void 0);const y=C.value,b=y[0],w=y[1],E=b.min,x=b.max,I=Math.max(E,r)-E,v=Math.max(I,Math.min(x,o))-E;wr.bounds.min=I,wr.bounds.max=v,wr.reverse=!i,wr.processSkip=n,wr.reuseResult=t,h=E,u=x,c=w.entries(wr);const R=g(S);if(R)return R;S=void 0}while(!C.done);l=void 0})(_),p||Re)},f={next(_){if(_!==void 0&&(_<0||_>o))throw new ke;return m(_)},return:_=>null,throw:_=>null};return d(i?r:o),f}runs(e){let t,n=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,o=!0,i=!1;e&&(e.bounds&&(n=e.bounds?.min??Number.MIN_SAFE_INTEGER,r=e.bounds?.max??Number.MAX_SAFE_INTEGER,this._validateBounds(n,r),e.overflowRun&&(i=!0)),o=!e.reverse,t=g_(e.reuseResult));const a=this._dataCoords;if(!a)return Xe;n=Math.max(a.min,n),r=Math.min(a.max,r);let l=null;const c=u=>{let d;u!==Number.MIN_SAFE_INTEGER&&u!==Number.MAX_SAFE_INTEGER&&(xt.min=u,d=xt),l=o?this._runs.entries(d,this._reuseRunsIterator):this._runs.entriesReversed(d,this._reuseRunsIterator)},h={next(u){if(u!==void 0){if(u<n||u>r)throw new ke;c(u)}if(!l)return Re;const d=l.next();if(d.done)return l=void 0,Re;const g=d.value,m=g[0];let f=m;const _=f.min,p=f.max;if(o&&_>r||!o&&p<n)return Re;let S=g[1];return i||(p>r&&(S=S.slice(0,S.length-(p-r)),f={...f},f.max=r),_<n&&(S=S.slice(n-_),f===m&&(f={...f}),f.min=n)),m_(f,S,t)},return:u=>null,throw:u=>null};return c(o?n:r),h}slice(e,t){const n=this._runs,r=n.minKey().min,o=n.maxKey().max;if(t===void 0&&(t=o+1),this._count===0||e<=r&&t-1>=o)return this.clone();const i=Math.max(r,e),a=Math.min(o,t-1),l=a-i,c=[];let h=0;Ba.bounds.min=i,Ba.bounds.max=a;const u=this.runs(Ba);let d=u.next();for(;!d.done;){const m=d.value;let f=m[0],_=m[1];f={min:f.min-i,max:f.max-i},f.min<0&&(_=_.slice(-f.min),f.min=0),f.max>=l&&(_=_.slice(0,_.length-(f.max-l)),f.max=l),h+=_.length,c.push([f,_]),d=u.next()}const g=new jn(this._options);return g._runs.setPairs(c),g._updateCount(h),g}concat(e){const t=this.clone();if(!e||e.length===0)return t;const n=this._runs.nextLowerPair(void 0,this._reuseRunsEntry),r=n[0],o=n[1],i=r.max+1;let a=!1,l=0;const c=[];if(e.isISparseList){const h=e.runs();let u=h.next();for(;!u.done;){const d=u.value;let g=d[0];const m={min:g.min+i,max:g.max+i};let f=d[1];if(g.min===0){a=!0,l-=o.length,f=o.concat(f);const _=r.min;m.min=_,m.max=f.length-1+_}l+=f.length,c.push([m,f]),u=h.next()}}else{const h=e.length,u={min:r.min,max:h-1+i};e=o.concat(e),a=!0,l+=h,c.push([u,e])}return a&&t._runs.delete(r),t._runs.setPairs(c),t._updateCount(l),t}toArray(e=Number.MAX_SAFE_INTEGER,t=!0){if(this.length===0)return F.EmptyArray;const n=t?0:Number.MIN_SAFE_INTEGER,r=Math.min(this._runs.maxKey().max,e);return Oa.bounds.min=Number.MIN_SAFE_INTEGER,Oa.bounds.max=r,f_(this.entries(Oa),t,r,n)}get isIReadableList(){return!0}get length(){return this._length}getCoords(){return this._dataCoords}clear(){this._runs.clear(),this._dataCoords=null,this._count=0,this._length=0}get isISparseList(){return!0}get isIList(){return!0}_updateCount(e){if(this._count+=e,this._lastRunsRead=void 0,this._lastListRead=void 0,this._count>0){const t=this._runs,n=Object.freeze({min:t.minKey().min,max:t.maxKey().max});this._dataCoords=n,this._length=n.max+1}else this._dataCoords=null,this._length=0}_update(e,t,n=null,r=void 0){const o=e,i=o+t-1;let a=0,l=i,c=i,h=null,u=null;xt.min=o,yr.min=i,(n||r)&&(xt.min-=1,yr.min+=1);const d=this._runs;let g=!1;if(d.editRange(xt,yr,!0,(m,f,_)=>{const p=m.min,S=m.max;return p<o&&S+1>=o&&(l=p,h=f),p-1<=i&&S>i&&(c=p,u=f),a-=S-p+1,g=!0,Se.DeleteValue}),n||r===void 0||(n=new Bt([r])),n){let m=n;g=!0;let f=o;h&&(h=h.slice(0,o-l),m=h.concat(m),f=l),u&&(u=u.slice(i+1-c),m=m.concat(u)),a+=m.length,d.set({min:f,max:f+m.length-1},m)}else h&&(h=h.slice(0,o-l),a+=h.length,d.set({min:l,max:l+h.length-1},h)),u&&(u=u.slice(i+1-c),a+=u.length,d.set({min:i+1,max:i+u.length},u));return this._updateCount(a),g}setAt(e,t){if(e===void 0)throw new Dt;return this._validateBounds(e,e),this._update(e,1,null,t)}setRunAt(e,t){if(!t||t.length===0)return!1;if(e===void 0||!t.length)throw new Dt;const n=t.length;return this._validateBounds(e,e+n-1),this._update(e,n,t)}delete(e,t){return t===void 0&&(t=Math.max(this.getCoords().max-e+1,0)),!(t<=0)&&(this._validateBounds(e,e),this._update(e,t,null))}shift(e,t){if(t===0)return!1;let n=e,r=e;t<0&&(r=e-t-1),this._validateBounds(n,r);const o=this._runs,i=o.maxKey();if(t<0&&r>=i.max&&n<=o.minKey().min)return this._runs.clear(),this._dataCoords=null,this._count=0,this._length=0,!0;let a=0,l=n,c=r,h=null,u=null;xt.min=l,yr.min=i.min,t<0&&(xt.min-=1,yr.min+=1);let d=!1;const g=[];if(o.editRange(xt,yr,!0,(m,f,_)=>{const p=m.min,S=m.max;return p<n&&S+1>=n&&(l=p,h=f),(p<n||t<0)&&p-1<=r&&m.max>r&&(c=p,u=f),t>0&&p>=n||t<0&&p-1>r?g.push([{min:p+t,max:S+t},f]):a-=S-p+1,d=!0,Se.DeleteValue}),t>0){const m=h||u;m&&(h=m.slice(0,n-l),c=e+t,u=m.slice(n-l))}else h&&(h=h.slice(0,n-l)),u&&(u=u.slice(r+1-c),c=e),h&&u&&l+h.length===c&&(h=h.concat(u),u=null);return h&&h.length>0&&(a+=h.length,o.set({min:l,max:l+h.length-1},h)),u&&(a+=u.length,o.set({min:c,max:c+u.length-1},u)),g.length>0&&o.setPairs(g),this._updateCount(a),d}at(e){xt.min=e;const t=this._lastRunsRead;if(t){const i=t.min;if(i<=e&&t.max>=e)return this._lastListRead.at(e-i)}let n,r;const o=this._runs.getPairOrNextHigher(xt,__);if(o&&(n=o[0],r=o[1]),this._lastRunsRead=n,this._lastListRead=r,!(!n||e<n.min||e>n.max))return r.at(e-n.min)}[Symbol.iterator](){return Cm(this.entries())}clone(){const e=new jn(this._options);return e._runs=this._runs.clone(),e._count=this._count,e._dataCoords=this._dataCoords,e._length=this._length,e}getMaxCoords(){return this._maxCoords||null}getCount(){return this._count}getRunsCount(){return this._runs.size}get[Symbol.toStringTag](){return"[SparseList]"}}jn||(jn={});const u_=s=>typeof s!="boolean"?(s&&!s.value&&(s.value=[-1,null]),s):s===!0?mc:void 0,d_=(s,e,t)=>{const n=t??{done:!1,value:[-1,null]},r=n.value;return r[0]=s,r[1]=e,n},g_=s=>typeof s!="boolean"?(s&&!s.value&&(s.value=[null,null]),s):s===!0?p_:void 0,m_=(s,e,t)=>{const n=t??{done:!1,value:[null,null]},r=n.value;return r[0]=s,r[1]=e,n},f_=(s,e=!1,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER)=>{const r=[];let o=s.next(),i=Math.max(n,0)-1;for(;!o.done;){if(e){const a=o.value[0];for(let l=i;l<a-1;l++)r.push(void 0);i=a}r.push(o.value[1]),o=s.next()}if(e)for(let a=i;a<t;a++)r.push(void 0);return r},p_=Object.seal({done:!1,value:[{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},null]}),mc=Object.seal({done:!1,value:[-1,null]}),wr={reverse:!1,bounds:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},processSkip:null,reuseResult:mc},Oa=Object.freeze({reverse:!1,bounds:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},processSkip:null,reuseResult:mc}),xt={min:0,max:Number.MAX_SAFE_INTEGER},yr={min:0,max:Number.MAX_SAFE_INTEGER},__=[null,null],Ba={bounds:{min:0,max:0},overflowRun:!0};class S_{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(e){return this.data.children.length===0?[]:this._all(this.data,e??[])}isEmpty(){return this.data.children.length===0}search(e,t){let n=this.data;if(n.children.length===0||!ys(e,n))return F.EmptyArray;const r=t??[],o=this.toBBox,i=[];for(;n;){const a=n.children,l=a.length,c=n.leaf;for(let h=0;h<l;h++){const u=a[h],d=c?o(u):u;ys(e,d)&&(c?r.push(u):La(e,d)?this._all(u,r):i.push(u))}n=i.pop()}return r}collides(e){let t=this.data;if(!ys(e,t))return!1;const n=[];for(;t;){for(let r=0;r<t.children.length;r++){const o=t.children[r],i=t.leaf?this.toBBox(o):o;if(ys(e,i)){if(t.leaf||La(e,i))return!0;n.push(o)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;const t=this._minEntries;if(e.length<t){for(let r=0;r<e.length;r++)this.insert(e[r]);return this}let n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Rr([]),this}remove(e,t){if(!e)return this;let n=this.data;const r=this.toBBox(e),o=[],i=[];let a,l,c;for(;n||o.length;){if(n||(n=o.pop(),l=o[o.length-1],a=i.pop(),c=!0),n.leaf){const h=w_(e,n.children,t);if(h!==-1)return n.children.splice(h,1),o.push(n),this._condense(o),this}c||n.leaf||!La(n,r)?l?(a++,n=l.children[a],c=!1):n=null:(o.push(n),i.push(a),a=0,l=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){const o=n-t+1;let i,a=this._maxEntries;if(o<=a)return i=Rr(e.slice(t,n+1)),Cr(i,this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(a)),a=Math.ceil(o/Math.pow(a,r-1))),i=Rr([]),i.leaf=!1,i.height=r;const l=Math.ceil(o/a),c=l*Math.ceil(Math.sqrt(a));du(e,t,n,c,this.compareMinX);for(let h=t;h<=n;h+=c){const u=Math.min(h+c-1,n);du(e,h,u,l,this.compareMinY);for(let d=h;d<=u;d+=l){const g=Math.min(d+l-1,u);i.children.push(this._build(e,d,g,r-1))}}return Cr(i,this.toBBox),i}_chooseSubtree(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){let o,i=1/0,a=1/0;for(let l=0;l<t.children.length;l++){const c=t.children[l],h=Da(c),u=b_(e,c)-h;u<a?(a=u,i=h<i?h:i,o=c):u===a&&h<i&&(i=h,o=c)}t=o||t.children[0]}return t}_insert(e,t,n=!1){const r=n?e:this.toBBox(e),o=[],i=this._chooseSubtree(r,this.data,t,o);for(i.children.push(e),Mo(i,r);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(r,o,t)}_split(e,t){const n=e[t],r=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,r);const i=this._chooseSplitIndex(n,o,r),a=Rr(n.children.splice(i,n.children.length-i));a.height=n.height,a.leaf=n.leaf,Cr(n,this.toBBox),Cr(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Rr([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Cr(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r=-1,o=1/0,i=1/0;for(let a=t;a<=n-t;a++){const l=Ao(e,0,a,this.toBBox),c=Ao(e,a,n,this.toBBox),h=E_(l,c),u=Da(l)+Da(c);h<o?(o=h,r=a,i=u<i?u:i):h===o&&u<i&&(i=u,r=a)}return r||n-t}_chooseSplitAxis(e,t,n){const r=e.leaf?this.compareMinX:y_,o=e.leaf?this.compareMinY:C_;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,o)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);const o=this.toBBox,i=Ao(e,0,t,o),a=Ao(e,n-t,n,o);let l=ws(i)+ws(a);for(let c=t;c<n-t;c++){const h=e.children[c];Mo(i,e.leaf?o(h):h),l+=ws(i)}for(let c=n-t-1;c>=t;c--){const h=e.children[c];Mo(a,e.leaf?o(h):h),l+=ws(a)}return l}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Mo(t[r],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)e[n].children.length===0?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():Cr(e[n],this.toBBox)}}function w_(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n<e.length;n++)if(t(s,e[n]))return n;return-1}function Cr(s,e){Ao(s,0,s.children.length,e,s)}function Ao(s,e,t,n,r=null){r||(r=Rr(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<t;o++){const i=s.children[o];Mo(r,s.leaf?n(i):i)}return r}function Mo(s,e){return s.minX=Math.min(s.minX,e.minX),s.minY=Math.min(s.minY,e.minY),s.maxX=Math.max(s.maxX,e.maxX),s.maxY=Math.max(s.maxY,e.maxY),s}function y_(s,e){return s.minX-e.minX}function C_(s,e){return s.minY-e.minY}function Da(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function ws(s){return s.maxX-s.minX+(s.maxY-s.minY)}function b_(s,e){return(Math.max(e.maxX,s.maxX)-Math.min(e.minX,s.minX))*(Math.max(e.maxY,s.maxY)-Math.min(e.minY,s.minY))}function E_(s,e){const t=Math.max(s.minX,e.minX),n=Math.max(s.minY,e.minY),r=Math.min(s.maxX,e.maxX),o=Math.min(s.maxY,e.maxY);return Math.max(0,r-t)*Math.max(0,o-n)}function La(s,e){return s.minX<=e.minX&&s.minY<=e.minY&&e.maxX<=s.maxX&&e.maxY<=s.maxY}function ys(s,e){return e.minX<=s.maxX&&e.minY<=s.maxY&&e.maxX>=s.minX&&e.maxY>=s.minY}function Rr(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function du(s,e,t,n,r){const o=[e,t];for(;o.length;){if((t=o.pop())-(e=o.pop())<=n)continue;const i=e+Math.ceil((t-e)/n/2)*n;bm(s,i,e,t,r),o.push(e,i,i,t)}}function bm(s,e,t,n,r){for(;n>t;){if(n-t>600){const l=n-t+1,c=e-t+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);bm(s,e,Math.max(t,Math.floor(e-c*u/l+d)),Math.min(n,Math.floor(e+(l-c)*u/l+d)),r)}const o=s[e];let i=t,a=n;for(io(s,t,e),r(s[n],o)>0&&io(s,t,n);i<a;){for(io(s,i,a),i++,a--;r(s[i],o)<0;)i++;for(;r(s[a],o)>0;)a--}r(s[t],o)===0?io(s,t,a):(a++,io(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function io(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}class gu extends S_{toBBox(e){return{minX:10*e.colStart,minY:10*e.rowStart,maxX:10*e.colEnd+5,maxY:10*e.rowEnd+5}}compareMinX(e,t){return e.colStart-t.colStart}compareMinY(e,t){return e.rowStart-t.rowStart}isEmpty(){return this.data.children.length===0}searchRange(e,t=!1,n){if(this.isEmpty())return F.EmptyArray;const r=this.search(this.toBBox(e),n);return t?r.filter(o=>o.colStart>=e.colStart&&o.rowStart>=e.rowStart&&o.colEnd<=e.colEnd&&o.rowEnd<=e.rowEnd):r}}class Ie{constructor(e){this._shared=null,this._rTree=null,this._cloneKey=null,this._lastMiss={colStart:Number.MAX_SAFE_INTEGER,rowStart:0,colEnd:0,rowEnd:0},this._lastSingle=null,this._lastSingleResult=null,this._options=e,this._rTree=new gu(e?.maxNodeEntries??16)}visitRanges(e,t,n=null){let r=this.search(e);n&&(r=Fn(r,n));const o=[],i=[];let a=null;const l=r.length;for(let c=0;!a&&c<l;c++){const h=r[c],u=t?.(h);u&&(u.delete===!0?i.push(h):u.update!==void 0&&(i.push(h),o.push(u.update)),u&&u.break===!0&&(a=u))}for(let c=0;c<i.length;c++)this.remove(i[c]);return this.load(o),a}getBoundingCoords(){const e=this._getReadTree().toJSON();return e&&e.children&&e.children.length!==0?{colStart:e.minX/10,rowStart:e.minY/10,colEnd:(e.maxX-5)/10,rowEnd:(e.maxY-5)/10}:null}size(){return this._getReadTree().all().length}isEmpty(){return this._getReadTree().isEmpty()}search(e,t=!1,n){const r=this._getReadTree();if(r.isEmpty())return F.EmptyArray;let o;if(!t){if(o=this._lastMiss,o.colStart!==Number.MAX_SAFE_INTEGER&&k.isRangeWithinRange(e,o))return F.EmptyArray;if(this._lastSingle&&k.isRangeWithinRange(e,o))return this._lastSingleResult}const i=r.searchRange(e,t,n);return t||(i.length===0?(o.colStart=e.colStart,o.rowStart=e.rowStart,o.colEnd=e.colEnd,o.rowEnd=e.rowEnd):i.length===1?(this._lastSingle=i[0],this._lastSingleResult=i):(this._lastMiss.colStart=Number.MAX_SAFE_INTEGER,this._lastSingle=null,this._lastSingleResult=null)),i}has(e){const t=this._getReadTree();return t.collides(t.toBBox(e))}all(e){return this._getReadTree().all(e)}shift(e){const t=e.range,n=e.direction,r=e.cloneIfUpdate??!1,o=e.coordValidator??null,i=e.onShift??null,a=n===Be.Left||n===Be.Right,l=a?se.Column:se.Row,c=n===Be.Up||n===Be.Left?-1:1,h=(a?t.colEnd-t.colStart+1:t.rowEnd-t.rowStart+1)*c,u=[],d=[];let g=null;const m=this.getBoundingCoords();if(!m)return this;const f=n===Be.Up||n===Be.Left?Be.Right:Be.Left,_=new Map,p=new Map,S=this._options?.updateEntryOptions,C=S?.isMergeOnShift??!1,y=S?.isSplitOnExpand??!1,b=S?.isTrailingEdge??!1,w=n===Be.Left||n===Be.Up,E=S?.getSplit??ei,x=S?.getShifted,I=S?.onShifted,v=S?.onRemoved,R=S?.onMerged,A=S?.onUpdated,M=I?[]:null,T=v?[]:null,N=A?[]:null;this.visitRanges({colStart:t.colStart-(a?1:0),rowStart:t.rowStart-(a?0:1),colEnd:a?m.colEnd:t.colEnd,rowEnd:a?t.rowEnd:m.rowEnd},P=>{if((a?P.colEnd<t.colStart:P.rowEnd<t.rowStart)&&!b)return;const L=R_(t,P,a?Yn.Column:Yn.Row),z=P.group;if(w&&!z&&t.colStart<=P.colStart&&t.rowStart<=P.rowStart&&t.colEnd>=P.colEnd&&t.rowEnd>=P.rowEnd){const H=pu(P,null,{after:null,before:P,intersect:t,isSplit:L,orientation:l,amount:h},x,E,i,!1);if(H===void 0)return;if(H===null)return g=k.unionRanges(g,P),T&&T.push(P),void u.push(P)}let O={...P};n===Be.Right?(t.colStart<=O.colStart&&(O.colStart+=h),O.colEnd+=h):n===Be.Left?t.colStart<O.colStart?(O.colStart=Math.max(O.colStart+h,t.colStart),O.colEnd=Math.max(O.colEnd+h,O.colStart-1)):O.colEnd+=Math.max(h,t.colStart-O.colEnd-1):n===Be.Down?(t.rowStart<=O.rowStart&&(O.rowStart+=h),O.rowEnd+=h):n===Be.Up&&(t.rowStart<O.rowStart?(O.rowStart=Math.max(O.rowStart+h,t.rowStart),O.rowEnd=Math.max(O.rowEnd+h,t.rowStart-1)):O.rowEnd+=Math.max(h,t.rowStart-O.rowEnd-1)),(O.colEnd<O.colStart||O.rowEnd<O.rowStart)&&(O=null);const j=pu(P,O,{after:O,before:P,intersect:t,isSplit:L,orientation:l,amount:h},x,E,i,y&&h>0);if(j===void 0)return;const V=j===null?[O]:j,W=V.length;if(V[0]!==P||W!==1){if(o)for(let G=0;G<W;G++){const $=V[G];$&&o($)}let H;z?(_.set(z.uuid,z),H=[],p.set(P.uuid,H)):u.push(P);for(let G=0;G<W;G++){const $=V[G];g=k.unionRanges(g,$),z?H.push($):(d.push($),M&&M.push($),N&&N.push(P))}}},f);let B=null;B=r&&(u.length>0||d.length>0||p.size>0)?this.clone():this,B._updateNodes(d,u),p.size>0&&B._updateGroupedEntries(_,p);let D=F.EmptyArray;if(C&&m&&g){let P=!0;if(h>0&&(P=a?t.rowStart>m.rowStart||t.rowEnd<m.rowEnd:t.colStart>m.colStart||t.colEnd<m.colEnd),P){const L=mu(g,k.unionRanges(m,g),a?0:1,a?1:0);R&&(D=B._mergeNodes(L,!1))}}return A&&N.length>0&&A(N),I&&M.length>0&&I(M),R&&D.length>0&&R(D),v&&T.length>0&&v(T),B}insertNonOverlapping(e,t){const n=t?.onIntersect??((C,y)=>({...C,value:y.value})),r=this.search(e),o=new Map,i=new Map,a=this._options?.updateEntryOptions,l=a?.onUpdated,c=a?.onRemoved,h=a?.onMerged,u=a?.getSplit,d=a?.getIntersect,g=a?.getUpdate;let m=null,f=null,_=null,p=function(C,y,b){const w=b?.getIntersect??x_,E=b?.getUpdate??I_;if(C.length===0){if(w){const L=w({...y,value:null},y);y=L&&L.value!==null?{...L}:null}if(E){const L=E(y);L!==void 0&&(y=L)}return y?[y]:F.EmptyArray}const x=b?.getSplit??v_,I=(L,z,O=!0)=>{const j=z.search(L),V=j.length;for(let W=0;W<V;W++){const H=j[W];if(k.isEqualRanges(H,L))continue;z?.remove(H);const G=Vr(H,L,x,O);for(let $=0;$<G.length;$++){const Z=G[$];z.insert(Z),I(Z,z,!1)}}},v=new Ie;v.load(C),I(y,v);const R=new Ie;R.load([y]);const A=v.search(y);for(let L=0;L<A.length;L++)I(A[L],R);const M=(L,z,O)=>{let j=z.search(L);console.assert(j.length<=1,"intersecting incorrect ranges");const V=j[0]??{...L,value:null};if(k.isEqualRanges(V,L)){let W=w(V,L);z.remove(V),O.insert(W)}else{z.remove(V);const W=Vr(V,L,x),H=W.length;for(let G=0;G<H;G++){const $=W[G];if(k.isEqualRanges($,L)){const Z=w($,L);O.insert(Z)}else z.insert($)}}},T=new Ie,N=R.all(),B=N.length;for(let L=0;L<B;L++)M(N[L],v,T);const D=(L,z)=>{const O=L.all(),j=O.length;for(let V=0;V<j;V++){let W=O[V];if(E){const H=E(W);H!==void 0&&(W=H)}W!==null&&W.value!==null&&z.push(W)}},P=v.all();return D(T,P),P}(r,e,{getSplit:(C,y,b,w)=>{let E;return u?(E=u(C,y,b,w),E):(E=ei(C,y,b,w),E)},getIntersect:(C,y)=>{d&&(y=d(C,y));const b=n(C,y);return b===void 0||(b===null||b.value===null)&&C.value?.onRemove?.(C),b},getUpdate:C=>{const y=C?.group;if(y){o.set(y.uuid,y);let w=i.get(C.lastId??C.uuid);w||(w=[],i.set(C.lastId??C.uuid,w)),w.push(C.value===null?null:C)}let b=C;if(g&&(b=g(C)),b&&b.value!==null)l&&(m||(m=[]),m.push(b));else if(c&&!_){_=[];let w=b&&b.value===null?b:{...C,value:null};_.push(w)}return b}});const S=this.getBoundingCoords();if(o.size>0){const C=[],y=p.length;for(let b=0;b<y;b++){let w=p[b];w.group||C.push(w)}p=C}if(this._updateNodes(p,r,t?.onUpdates),o.size>0&&this._updateGroupedEntries(o,i),S&&!t?.noMerge){const C=mu(e,k.unionRanges(S,e)),y=this.search(C);if(y.length>1){const b=a?.getMerged??fu;let w=y;w=fn(w,se.Column,1,b),w=fn(w,se.Row,1,b),y.length!==w.length&&(h&&w.length>0&&(f=w),this._updateNodes(w,y,t?.onUpdates))}}return m&&l(m),f&&h(f),_&&c(_),this}insertGroup(e,t){t=t??F.uuidV4();const n=[],r=e.length;for(let o=0;o<r;o++){const i={...e[o],group:{entries:n,uuid:t,offset:o},uuid:F.uuidV4()};n.push(i),e[o]=i}return this.load(e),this._options?.updateEntryOptions?.onGroupUpdate?.(e,t),this}createCopiedEntries(e,t,n,r,o){return A_(this,e,t,n,r,o,this._options?.updateEntryOptions?.getSplit??ei)}_updateGroupedEntries(e,t){const n=[],r=[],o=new Map,i=e.values();let a=i.next();for(;!a.done;){const l=a.value,c=l.entries,h=l.uuid,u=[];for(let d=0;d<c.length;d++){let g=c[d];n.push(g);let m=t.get(g.uuid);m===void 0&&(m=[{...g}]);for(let f=0;f<m.length;f++){let _=m[f];_!==null&&(_={..._,group:{offset:u.length,entries:u,uuid:h}},u.push(_),r.push(_))}}u.sort((d,g)=>d.group.offset-g.group.offset),o.set(h,u),a=i.next()}if(this._updateNodes(r,n),o){const l=this._options?.updateEntryOptions?.onGroupUpdate;if(l){const c=o.entries();let h=c.next();for(;!h.done;){const u=h.value[0];l(h.value[1],u),h=c.next()}}}}_copy(e,t){let n=e.rTree.all();const r=new gu(this._options?.maxNodeEntries);return t&&(n=n.concat(t)),n.length>0&&r.load(n),{refCount:1,rTree:r}}_updateNodes(e,t,n){if(!(e&&e.length!==0||t&&t.length!==0))return;const r=this._getWritableTree();if(t){const o=t.length;for(let i=0;i<o;i++)r.remove(t[i])}e.length>0&&r.load(e),n?.(e,t,this),this._options?.updateEntryOptions?.onUpdates?.(e,t,this)}_mergeNodes(e,t){const n=this.search(e,t);let r=F.EmptyArray;if(n.length>1){const o=this._options?.updateEntryOptions.getMerged??fu;let i=n;i.length>1&&(i=fn(i,se.Column,1,o)),i.length>1&&(i=fn(i,se.Row,1,o)),n.length!==i.length&&(r=i,this._updateNodes(i,n))}return r}_getReadTree(){return this._shared?.rTree??this._rTree}_ensureWritable(e){const t=this._shared;if(!t)return;if(t.refCount--,t.refCount===0)return this._shared=null,void(e&&this._rTree.load(e));const n=this._copy(t,e);this._shared=null,this._rTree=n.rTree}_getWritableTree(e){return this._lastMiss.colStart=Number.MAX_SAFE_INTEGER,this._lastSingle=null,this._lastSingleResult=null,this._shared?(this._ensureWritable(e),this._rTree):(e&&this._rTree.load(e),this._rTree)}remove(e,t){return e&&this._getWritableTree().remove(e,t??k.isEqualRanges),this}insert(e){return e&&this._getWritableTree().insert(e),this}load(e){return e&&e.length>0&&this._getWritableTree(e),this}clear(){return this.isEmpty()||this._getWritableTree().clear(),this}clone(e=null){if(e!==null&&this._cloneKey===e)return this;let t=this._shared;t||(t={rTree:this._rTree,refCount:1},this._shared=t),t.refCount++;const n=new Ie(this._options);return n._shared=t,n._cloneKey=e,n}fromJSON(e){return this._getWritableTree().fromJSON(e),this}}const mu=(s,e=s,t=1,n=1)=>({...s,colStart:Math.max(s.colStart-t,e.colStart),rowStart:Math.max(s.rowStart-n,e.rowStart),colEnd:Math.min(s.colEnd+t,e.colEnd),rowEnd:Math.min(s.rowEnd+n,e.rowEnd)});function v_(s,e,t,n){return[{...e[0],value:s.value},{...e[0],value:s.value}]}function x_(s,e){return{...s}}function Vr(s,e,t=null,n=!0){if(k.isEqualRanges(s,e))return[{...s}];const r=k.intersectRanges(s,e,M_);if(!r)return null;const o=[],i=s.uuid;let a=s;if(a.rowStart<r.rowStart){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:r.rowStart-1};i&&(n&&(l.lastId=i),l.uuid=F.uuidV4());const c={...a,colStart:a.colStart,rowStart:r.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=F.uuidV4());const h=c.rowStart-l.rowStart;It[0]=l,It[1]=c;const u=t(a,It,se.Row,h);u!==void 0&&(o.push(u[0]),a=u[1])}if(a.rowEnd>r.rowEnd){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:r.rowEnd};i&&(n&&(l.lastId=i),l.uuid=F.uuidV4());const c={...a,colStart:a.colStart,rowStart:r.rowEnd+1,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=F.uuidV4());const h=c.rowStart-l.rowStart;It[0]=l,It[1]=c;const u=t(a,It,se.Row,h);u!==void 0&&(o.push(u[1]),a=u[0])}if(a.colStart<r.colStart){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:r.colStart-1,rowEnd:a.rowEnd};i&&(n&&(l.lastId=i),l.uuid=F.uuidV4());const c={...a,colStart:r.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=F.uuidV4());const h=c.colStart-l.colStart;It[0]=l,It[1]=c;const u=t(a,It,se.Column,h);u!==void 0&&(o.push(u[0]),a=u[1])}if(a.colEnd>r.colEnd){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:r.colEnd,rowEnd:a.rowEnd};i&&(n&&(l.lastId=i),l.uuid=F.uuidV4());const c={...a,colStart:r.colEnd+1,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=F.uuidV4());const h=c.colStart-l.colStart;It[0]=l,It[1]=c;const u=t(a,It,se.Column,h);u!==void 0&&(o.push(u[1]),a=u[0])}return a===s&&(a={...s}),o.push(a),o}function I_(s){return s.value===null?null:s}function fn(s,e=se.Column,t=2,n,r){let o=[...s];if(t<=0||s.length<=1)return o;let i=e===se.Column,a=0,l=!1;do{const c=o.sort(k.createRangeComparator(i?se.Row:se.Column));o=[],l=!1,o.push(c[0]);for(let h=1;h<c.length;h++){const u=c[h],d=o[o.length-1];let g=!1;if(g=i?d&&d.rowStart===u.rowStart&&d.rowEnd===u.rowEnd&&d.colEnd+1===u.colStart:d&&d.colStart===u.colStart&&d.colEnd===u.colEnd&&d.rowEnd+1===u.rowStart,g){let m={...d,colEnd:i?u.colEnd:d.colEnd,rowEnd:i?d.rowEnd:u.rowEnd};if(n){const f=r??[null,null];f[0]=d,f[1]=u,m=n(f,m,e)}if(m){o[o.length-1]=m,l=!0;continue}}o.push(u)}a++,i=!i}while(a<t&&l&&o.length>1);return o}const Pl=(s,e=2,t=se.Row,n,r,o)=>{if(s.length<=1)return[...s];let i=[];const a=t===se.Column,l=new xi.IteratorInstance(s,{orientation:a?se.Row:se.Column});let c=l.next();for(;!c.done;){const h=c.value;c=l.next();const u=h.range;if(e>0){const d=i[i.length-1];let g=!1;if(g=a?d&&d.rowStart===u.rowStart&&d.rowEnd===u.rowEnd&&d.colEnd+1===u.colStart:d&&d.colStart===u.colStart&&d.colEnd===u.colEnd&&d.rowEnd+1===u.rowStart,g){let m={...d,colEnd:a?u.colEnd:d.colEnd,rowEnd:a?d.rowEnd:u.rowEnd};if(m){i[i.length-1]=m;continue}}}i.push(u)}return e>1&&(i=fn(i,a?se.Row:se.Column,e,n,o)),i};function ei(s,e,t,n){const r=s.value;if(r?.getSplit){const o=r.getSplit(e,t,n);if(o===void 0)return;e[0].value=o[0],e[1].value=o[1]}return e}function fu(s,e,t){const n=s[0].value,r=s[1].value;if(n?.getMerged&&r){const o=n.getMerged(s[1].value,k.sanitizeRange(e),t);if(o===void 0)return;e.value=o}return e}const R_=(s,e,t=Yn.Both)=>{const n=i=>i?s.rowStart>e.rowStart&&s.rowStart<=e.rowEnd||s.rowEnd<e.rowEnd&&s.rowEnd>=e.rowStart:s.colStart>e.colStart&&s.colStart<=e.colEnd||s.colEnd<e.colEnd&&s.colEnd>=e.colStart;let r=t===Yn.Column,o=t===Yn.Row;return t===Yn.Both&&(r=o=!0),!(!r||!n(!0))||!(!o||!n(!1))};function pu(s,e,t,n,r,o,i){const a=t.orientation===se.Column,l=t.intersect,c=(h,u)=>{let d=h.value,g=null,m=u.after;if(i){let f=null,_=0,p=0;if(a&&l.colStart>h.colStart?(f={...h,colEnd:l.colStart-1},p=u.amount):!a&&l.rowStart>h.rowStart&&(f={...h,rowEnd:l.rowStart-1},_=u.amount),f){const S=Vr(s,f,r);if(S.length>1)for(let C=0;C<S.length;C++){let y=S[C];k.isEqualRanges(y,f)?(g=g??[],g.push(y)):(m=y,d=y.value,u={...u,after:{...y,colStart:y.colStart+p,rowStart:y.rowStart+_,colEnd:y.colEnd+p,rowEnd:y.rowEnd+_,uuid:F.uuidV4()},before:y,intersect:f,isSplit:!0})}}}if(n?m=n(u.before,u.after,u):d&&d.getShifted?m=d.getShifted(u):u.after&&(m={...u.after,value:h.value}),m!==void 0)return o&&(m!==u.after&&(u={...u,after:m}),o(u)),m=(f=>{if(!f){const _=s.value;return _.onRemove&&_.onRemove(k.sanitizeRange(t.before)),null}return f})(m),m&&(g=g??[],g.push(m)),g};if(t.isSplit){let h;h=a?{...s,rowStart:Math.max(l.rowStart,t.before.rowStart),rowEnd:Math.min(l.rowEnd,t.before.rowEnd)}:{...s,colStart:Math.max(l.colStart,t.before.colStart),colEnd:Math.min(l.colEnd,t.before.colEnd)};const u=Vr(s,h,r),d=[];for(let g=0;g<u.length;g++){const m=u[g];if(k.isEqualRanges(m,h)){let f=null;e&&(f=a?{colStart:e.colStart,rowStart:h.rowStart,colEnd:e.colEnd,rowEnd:h.rowEnd,value:m.value}:{colStart:h.colStart,rowStart:e.rowStart,colEnd:h.colEnd,rowEnd:e.rowEnd,value:m.value});const _=c(m,{...t,before:m,after:f});if(_)for(let p=0;p<_.length;p++)d.push(_[p])}else d.push(m)}return d}return c(s,t)}const A_=(s,e,t,n,r,o,i)=>{const a=t.colEnd-t.colStart+1,l=t.rowEnd-t.rowStart+1,c=t.colStart-e.colStart,h=t.rowStart-e.rowStart,u=n?.transpose??!1;let d=1,g=1;u?(d=e.rowEnd-e.rowStart+1,g=e.colEnd-e.colStart+1):(d=e.colEnd-e.colStart+1,g=e.rowEnd-e.rowStart+1);const m=Math.ceil(a/d),f=Math.ceil(l/g),_=r??[],p=o??F.EmptyArray,S=t.colEnd,C=t.rowEnd;return s.visitRanges(e,y=>{let b=y.value;if(!b.copyTo)return;let w=y;if(!k.isRangeWithinRange(w,e)){const N=Vr(w,e,i);w=N[N.length-1]}b=w.value;let E=w.colEnd-w.colStart+1,x=w.rowEnd-w.rowStart+1,I=c+w.colStart,v=h+w.rowStart;if(u){I=w.rowStart-e.rowStart+t.colStart,v=w.colStart-e.colStart+t.rowStart;const N=E;E=x,x=N}let R=m,A=f;const M=a<=R*E,T=l<=A*x;if(M||T){const N=b?.canTile?.({colStart:I,rowStart:v,colEnd:Math.min(I+(M?a:E)-1,S),rowEnd:Math.min(v+(T?l:x)-1,C)},n);!M||N!==!0&&N!==se.Column||(E=a,R=1),!T||N!==!0&&N!==se.Row||(x=l,A=1)}for(let N=0;N<R;N++){const B=I+N*d;for(let D=0;D<A;D++){const P=v+D*g,L=Math.min(B+E-1,S),z=Math.min(P+x-1,C),O={colStart:B,rowStart:P,colEnd:L,rowEnd:z};if(B>L||P>z)continue;const j=b.copyTo(O,n);j&&_.push({...O,value:j})}}},Be.Right),{inserts:_,removes:p}},It=[null,null],M_={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Et=(s=Number.MIN_SAFE_INTEGER,e=Number.MIN_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,r,o,i)=>{if(o&&(s!==Number.MIN_SAFE_INTEGER&&s<o.colStart||e!==Number.MIN_SAFE_INTEGER&&e<o.rowStart||t!==Number.MAX_SAFE_INTEGER&&t>o.colEnd||n!==Number.MAX_SAFE_INTEGER&&n>o.rowEnd))throw new ke;return i&&(s=Math.max(i.colStart,s),e=Math.max(i.rowStart,e),t=Math.min(i.colEnd,t),n=Math.min(i.rowEnd,n),t<s||n<e)?null:(ao.majorStart=r?s:e,ao.majorEnd=r?t:n,ao.minorStart=r?e:s,ao.minorEnd=r?n:t,ao)},$o=(s,e,t)=>{const n={colStart:0,rowStart:0,colEnd:0,rowEnd:0};return n.colStart=e?s.majorStart:s.minorStart,n.rowStart=e?s.minorStart:s.majorStart,n.colEnd=e?s.majorEnd:s.minorEnd,n.rowEnd=e?s.minorEnd:s.majorEnd,n},ao={majorStart:0,majorEnd:0,minorStart:0,minorEnd:0},_u=(s,e)=>s[0]-e[0];class Em{constructor(e,t){this._isColumn=!0,this._isReverse=!1,this._skipMajors=!1,this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=Number.MIN_SAFE_INTEGER,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=Number.MIN_SAFE_INTEGER,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._delegateMajorIndex=Number.MIN_SAFE_INTEGER,this._delegateMinorIndex=Number.MIN_SAFE_INTEGER,this._delegate=e;const n=(t.orientation??se.Column)===se.Column;this._isColumn=n,this._isReverse=t.reverse??!1,this._skipMajors=t.skipMajors??!1;const r=t.bounds,o=r.colStart,i=r.rowStart,a=r.colEnd,l=r.rowEnd;this._majorMin=n?o:i,this._majorMax=n?a:l,this._minorMin=n?i:o,this._minorMax=n?l:a,this._processMajorSkip=n?t.processColumnSkip:t.processRowSkip,this._processMinorSkip=n?t.processRowSkip:t.processColumnSkip;const c=e.next();this._delegateResult=c,this._initialize()}_initialize(){const e=this._isColumn,t=this._isReverse,n=t?-1:1;let r=t?this._majorMax:this._majorMin,o=(t?this._minorMax:this._minorMin)-n;const i=this._processMinorSkip;i&&(o=i(o,t));const a=this._processMajorSkip;a&&(r=a(r,t)),this._majorIndex=r,this._minorIndex=o;const l=this._delegateResult;if(l.done)this._delegateMajorIndex=this._majorMax,this._delegateMinorIndex=this._minorMax+n;else{const c=l.value[0];this._delegateMajorIndex=e?c.colIndex:c.rowIndex,this._delegateMinorIndex=e?c.rowIndex:c.colIndex}}next(e){e!==void 0&&(this._delegateResult=this._delegate.next(e),this._initialize());const t=this._isReverse,n=this._isColumn,r=this._majorMin,o=this._majorMax;let i=this._majorIndex,a=this._minorIndex;if(i>o||i<r)return Re;let l=this._delegateMajorIndex,c=this._delegateMinorIndex,h=this._delegateResult.done;if(i===l&&a===c){const g=this._delegate.next();if(this._delegateResult=g,h=g.done,h)l=t?r:o,l=t?this._minorMin:this._minorMax;else{const m=g.value[0];l=n?m.colIndex:m.rowIndex,c=n?m.rowIndex:m.colIndex}this._delegateMajorIndex=l,this._delegateMinorIndex=c}const u=t?-1:1;if(this._minorIndex=a+=u,i===l&&a===c&&!h)return this._delegateResult;const d=this._processMinorSkip;if(d&&(a=d(a,t)),a>this._minorMax||a<this._minorMin){i+=u;const g=this._processMajorSkip;g&&(i=g(i,t)),this._skipMajors&&(!t&&i<l||t&&i>l)&&(i=l),this._majorIndex=i,a=t?this._minorMax:this._minorMin}return this._minorIndex=a,i===l&&a===c&&!h?this._delegateResult:i>o||i<r?Re:{done:!1,value:[{colIndex:n?i:a,rowIndex:n?a:i}]}}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}class zl{constructor(e){this._isColumn=!0,this._majorSize=Number.MAX_SAFE_INTEGER,this._minorSize=Number.MAX_SAFE_INTEGER,this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=Number.MIN_SAFE_INTEGER,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=Number.MIN_SAFE_INTEGER,this._majorIndex=Number.MAX_SAFE_INTEGER,this._minorIndex=Number.MAX_SAFE_INTEGER,this._minorOffset=0,this._minorRepeat=0,this._majorOffset=-1,this._majorRepeat=1,this._pattern=[];const t=e.delegate;this._delegate=t;const n=(e.orientation??se.Column)===se.Column;this._isColumn=n;const r=e.dims,o=e.bounds,i=o.colStart,a=o.rowStart,l=o.colEnd,c=o.rowEnd;if(this._majorSize=1+(n?l-i:c-a),this._minorSize=1+(n?c-a:l-i),this._majorMin=n?i:a,this._minorMin=n?a:i,this._majorMax=(n?i+r.major:a+r.major)-1,this._minorMax=(n?a+r.minor:i+r.minor)-1,this._majorSize>this._majorMax+1||this._minorSize>this._minorMax+1)throw new Error("The dimensions must be larger than the bounds.");const h=t.next();this._nextDelegateResult=h,this._initialize()}_initialize(){const e=this._isColumn,t=this._nextDelegateResult;if(t.done)this._nextResult=Re;else{const n=t.value[0],r=e?n.colIndex:n.rowIndex,o=e?n.rowIndex:n.colIndex,i=[[o,t.value[1]]];this._minorSpan=i,this._majorIndex=r,this._minorIndex=o,this._pattern.push([r,i]),this._nextResult=t}}next(e){if(e!==void 0)throw new tc;const t=this._nextResult,n=this._isColumn;let r=this._majorIndex,o=this._nextDelegateResult;if(!o.done){const c=o.value[0];if((n?c.colIndex:c.rowIndex)===r&&(o=this._delegate.next(),this._nextDelegateResult=o,!o.done)){const h=o.value,u=h[0],d=n?u.colIndex:u.rowIndex,g=n?u.rowIndex:u.colIndex;if(d===r)return this._minorSpan.push([g,h[1]]),this._minorOffset=this._minorSpan.length-1,this._minorIndex=g,this._nextResult=o,t}}const i=this._minorMax;let a=this._minorIndex;if(a<i){let c=this._minorOffset;c++;const h=this._minorSpan;c>=h.length&&(c=0,this._minorRepeat++);const u=h[c],d=this._minorMin;if(a=d+(u[0]-d+this._minorSize*this._minorRepeat),this._minorIndex=a,this._minorOffset=c,a<=i){const g=[{colIndex:n?r:a,rowIndex:n?a:r},u[1]];return this._nextResult={done:!1,value:g},t}}if(!o.done){const c=o.value,h=c[0],u=n?h.colIndex:h.rowIndex,d=n?h.rowIndex:h.colIndex,g=[[d,c[1]]];return this._pattern.push([u,g]),this._majorIndex=u,this._minorSpan=g,this._minorOffset=0,this._minorIndex=d,this._minorRepeat=0,this._nextResult=o,t}const l=this._majorMax;if(r<l){let c=this._majorOffset;c++;const h=this._pattern;c>=h.length&&(c=0,this._majorRepeat++);const u=h[c],d=u[1],g=d[0],m=this._majorMin;if(r=m+(u[0]-m+this._majorSize*this._majorRepeat),this._majorIndex=r,this._majorOffset=c,r<=l){this._minorSpan=d,this._minorOffset=0,a=g[0],this._minorIndex=a,this._minorRepeat=0;const f=[{colIndex:n?r:a,rowIndex:n?a:r},g[1]];return this._nextResult={done:!1,value:f},t}}return t.done||(this._nextResult=Re),t}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}class Su{constructor(e,t,n){this._comparator=e?.comparator??k.createCellComparator(e.orientation??se.Column,e.reverse??!1),this._iterator1=t,this._iterator2=n;const r=t.next();this._nextResult1=r;const o=n.next();this._nextResult2=o,e?.reuseResult&&(e.reuseResult===!0?this._reuseResult={done:!1,value:[void 0,void 0,void 0,void 0]}:this._reuseResult=e.reuseResult)}next(e){let t=this._nextResult1,n=this._nextResult2;if(t.done&&n.done)return t;if(t.done){const a=n;this._nextResult2=this._iterator2.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[2]=h[0],c[3]=h[1],c[0]=void 0,c[1]=void 0,l}if(n.done){const a=t;this._nextResult1=this._iterator1.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[0]=h[0],c[1]=h[1],c[2]=void 0,c[3]=void 0,l}let r=(0,this._comparator)(t.value[0],n.value[0]);if(r<0){const a=t;this._nextResult1=this._iterator1.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[0]=h[0],c[1]=h[1],c[2]=void 0,c[3]=void 0,l}if(r>0){const a=n;this._nextResult2=this._iterator2.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[2]=h[0],c[3]=h[1],c[0]=void 0,c[1]=void 0,l}this._nextResult1=this._iterator1.next(),this._nextResult2=this._iterator2.next();const o=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};o.done=!1;const i=o.value;return i[0]=t.value[0],i[1]=t.value[1],i[2]=n.value[0],i[3]=n.value[1],o}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}const wu="Must be an array of arrays.",ti=(s,e,t)=>{const n=e.majorStart,r=e.minorStart,o=e.majorEnd,i=[],a=e.minorEnd-r+1,l=typeof s=="function";for(let c=n;c<=o;c++){const h=new Array(a);if(l)if(t){let d=r;for(let g=0;g<a;g++)h[g]=s(d++,c)}else{let d=r;for(let g=0;g<a;g++)h[g]=s(c,d++)}else h.fill(s,0,a);const u=[[r,h]];i.push([c,u])}return{tuples:i,bounds:e}},Ii=(s,e=!1,t=null,n=!1)=>{let r=0,o=0,i=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER;if(t&&(r=t.majorStart??0,o=t.minorStart??0,i=(t.majorEnd??Number.MAX_SAFE_INTEGER)-r+1,a=(t.minorEnd??Number.MAX_SAFE_INTEGER)-o+1),e){const c=r;r=o,o=c;const h=i;i=a,a=h}if(!Array.isArray(s))throw new Error(wu);if(s.length>i)throw new ke;const l=e?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder;for(let c=0;c<s.length;c++){let h=s[c];if(h!=null&&h.length!==0){if(!Array.isArray(h))throw new Error(wu);if(h.length>a)throw new ke;if(n){let u=-1;for(let d=0;d<h.length;d++)h[d]==null?u!==-1&&(l.addValues(c+r,o+u,h.slice(u,d)),u=-1):u===-1&&(u=d);u!==-1&&l.addValues(c+r,o+u,h.slice(u))}else l.addValues(c+r,o,h)}}return l.build()},T_=(s,e,t)=>{if(s===e)return e},F_=(s,e,t)=>{if(s[0].value===s[1].value)return e},N_=[null,null],Ln=(s=!0,e=T_)=>{const t=[];let n,r,o=Number.MIN_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER;return{append:(a,l,c)=>{let h=!0;if(c!==void 0){const g=r===void 0?c:e(r,c,s);g===void 0?h=!1:c=g}if(h&&l===i+1&&a===o)return s?n.rowEnd=l:n.colEnd=l,i=l,void(r=c);n&&t.push(n);const u=s?a:l,d=s?l:a;n={colStart:u,rowStart:d,colEnd:u,rowEnd:d,value:c},o=a,i=l,r=c},done:(a=!1)=>(n&&(t.push(n),n=null),a?fn(t,s?se.Column:se.Row,2,F_,N_):t)}};class Qt{constructor(e){this._major=null,this._dataCoords=null,this._count=0,this._isColumn=!0,this._lastMajor=Number.MIN_SAFE_INTEGER,this._lastMinorSpan=null,this._maxCoords=null,this._isShared=!1,this._options={orientation:se.Row,...e},this._isColumn=(e?.orientation??se.Column)===se.Column,e?.maxCoords&&(this._maxCoords=Object.freeze({colStart:Math.max(0,e.maxCoords.colStart??0),rowStart:Math.max(0,e.maxCoords.rowStart??0),colEnd:Math.min(Number.MAX_SAFE_INTEGER,e.maxCoords.colEnd??Number.MAX_SAFE_INTEGER),rowEnd:Math.min(Number.MAX_SAFE_INTEGER,e.maxCoords.rowEnd??Number.MAX_SAFE_INTEGER)})),this._createRun=e?.createRun??(t=>new Bt(t)),this._optionsMinor={},this._major=new jn({nodeSize:k_})}getRuns(e){const t=this._isColumn,n=this._maxCoords,r=this.getCoords();if(!r)return Xe;const o=e?.bounds;let i,a;if(o){const _=Et(o?.colStart??Number.MIN_SAFE_INTEGER,o?.rowStart??Number.MIN_SAFE_INTEGER,o?.colEnd??Number.MAX_SAFE_INTEGER,o?.rowEnd??Number.MAX_SAFE_INTEGER,t,n,r);if(!_)return Xe;i={bounds:{min:_.majorStart,max:_.majorEnd}},a={bounds:{min:_.minorStart,max:_.minorEnd}}}const l=this._major.entries(i);let c=l.next();if(c.done)return Xe;let h=c.value[0],u=c.value[1],d=u.runs(a),g=d.next();if(g.done)return Xe;let m=g.value[0].min,f=g.value[1];return{[Symbol.iterator](){return this},next(){if(c.done)return Re;const _={done:!1,value:[h,m,f]};for(g=d.next();g.done&&!c.done;)c=l.next(),c.done||(h=c.value[0],u=c.value[1],d=u.runs(a),g=d.next());return g.done||(m=g.value[0].min,f=g.value[1]),_}}}getOrientation(){return this._isColumn?se.Column:se.Row}entries(e){const t=this._isColumn;let n=t,r=!0;const o=this._maxCoords,i=this.getCoords(),a=Et(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,t,o,i);if(!a)return Xe;let l,c,h,u=a.majorStart,d=a.majorEnd,g=a.minorStart,m=a.minorEnd,f=!1;if(e){e?.orientation&&(n=e?.orientation===se.Column,r=t===n);const w=e?.bounds;if(w){const E=Et(w.colStart,w.rowStart,w.colEnd,w.rowEnd,t,o,i);if(!E)return Xe;u=E.majorStart,d=E.majorEnd,g=E.minorStart,m=E.minorEnd}f=e.reverse??!1,h=(E=>typeof E!="boolean"?E:E===!0?{done:!1,value:[{colIndex:-1,rowIndex:-1},null]}:void 0)(e.reuseResult),l=t?e.processColumnSkip:e.processRowSkip,l&&(f?d=l(d,f):u=l(u,f)),c=t?e.processRowSkip:e.processColumnSkip,c&&(f?m=c(d,f):g=c(g,f))}if(!i)return Xe;r||u!==d||(r=!0),je.bounds.min=u,je.bounds.max=d,je.reverse=f,je.processSkip=l,je.reuseResult=To;let _=this._major.entries(je),p=yu();const S=w=>{if(!w.nextActive)return;const E=v=>{const R=w.nextMinorIndex,A=w.nextMinorValue,M=w.nextActive;return v?(w.nextMinorIndex=v[0],w.nextMinorValue=v[1],w.nextActive=!0):(w.nextActive=!1,w.nextMinorIndex=f?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,w.nextMinorValue=null),w.value=A,w.minorIndex=R,w.active=M,An[0]=w.majorIndex,An[1]=R,An[2]=A,An},x=w.minorIterator;if(!x)return E();const I=x.next();return I.done&&(w.minorIterator=null),E(I.value)},C=w=>{if(_)for(;;){const E=_.next();if(E.done)return void(_=void 0);const x=E.value,I=x[1];I||console.warn("issue",I),w.majorIndex=x[0],w.active=!0,w.nextActive=!1,Rt.bounds.min=g,Rt.bounds.max=m,Rt.reverse=f,Rt.processSkip=c,Rt.reuseResult=vm;const v=I.entries(Rt),R=v.next();if(!R.done){const A=R.value;return w.nextMinorIndex=A[0],w.nextMinorValue=A[1],w.minorIterator=v,w.nextActive=!0,S(w)}}};let y=null;if(r)y=()=>{let w;return w=S(p),w||(w=C(p),w||void 0)};else{const w=f?m:g,E=f?g:m;let x,I=w,v=E,R=!0;const A=()=>{if(p.nextMajorCursor)return p=p.nextMajorCursor,p;p=x,(I<g||I>m||I===v)&&(p=null),I=v,v=E};y=()=>{for(;p;){let M=null;if(R){let T=x?yu():p;if(M=C(T),M){x?(T.prevMajorCursor=p,p.nextMajorCursor=T,p=T):x=p,v=f?Math.max(v,p.nextMinorIndex):Math.min(v,p.nextMinorIndex);const N=p.minorIndex;N!==w&&(v=f?Math.max(v,N):Math.min(v,N),M=null)}else R=!1,A()}else{const T=p.minorIndex,N=p.nextMinorIndex;T===I?(An[0]=p.majorIndex,An[1]=T,An[2]=p.value,M=An):!f&&T>I||f&&T<I?v=f?Math.max(v,T):Math.min(v,T):!f&&N>I||f&&N<I?v=f?Math.max(v,N):Math.min(v,N):M=S(p),p.active&&(v=f?Math.max(v,p.nextMinorIndex):Math.min(v,p.nextMinorIndex)),E===I||p.active||(p.prevMajorCursor?p.prevMajorCursor.nextMajorCursor=p.nextMajorCursor:x=p.nextMajorCursor,p.nextMajorCursor&&(p.nextMajorCursor.prevMajorCursor=p.prevMajorCursor)),A()}if(M)return M}}}return{next(w){if(w)throw new tc("Iterator with next argument is not supported.");const E=y();return E?((I,v,R,A,M)=>{const T=M??{done:!1,value:[{colIndex:-1,rowIndex:-1},null]},N=T.value,B=N[0];return B.colIndex=A?I:v,B.rowIndex=A?v:I,N[1]=R,T})(E[0],E[1],E[2],t,h):Re},[Symbol.iterator](){return this},return:w=>null,throw:w=>null}}values(e){const t=this.entries(e);let n;return e?.reuseResult&&(n=e.reuseResult===!0?{done:!1,value:null}:e.reuseResult),{next(r){const o=t.next(r);return o.done?Re:n?(n.value=o.value[1],n):{done:!1,value:o.value[1]}},[Symbol.iterator](){return this},return:r=>null,throw:r=>null}}keys(e){const t=this.entries(e);let n;return e?.reuseResult&&(n=e.reuseResult===!0?{done:!1,value:null}:e.reuseResult),{next(r){const o=t.next(r);return o.done?Re:n?(n.value=o.value[0],n):{done:!1,value:o.value[0]}},[Symbol.iterator](){return this},return:r=>null,throw:r=>null}}_updateMajorSpan(e,t=!1){if(!e||e.length===0)return;t&&e.sort((l,c)=>l[0]-c[0]);const n=this._major,r=e[0];let o=r[0],i=o,a=[r[1]];for(let l=1;l<e.length;l++){const c=e[l],h=c[0],u=c[1];h===i+1?a.push(u):(n.setRunAt(o,new Bt(a)),o=h,a=[u]),i=h}a.length>0&&n.setRunAt(o,new Bt(a))}setValues(e){if(!e)throw new Dt;if(e.length===0)return this;const t=(e=e.sort(_u))[0][0],n=e[e.length-1][0];let r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;const i=this._isColumn,a=this._maxCoords;if(a){const b=i?a.colStart:a.rowStart,w=i?a.colEnd:a.rowEnd;if(t<b||n>w)throw new ke;r=i?a.rowStart:a.colStart,o=i?a.rowEnd:a.colEnd}if(!e||e.length===0)return this;let l=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER,h=0,u=t-1;const d=[],g=(b,w,E)=>{if(u===E)throw new exports.Tuple.OutOfOrderError(`Duplicate major Indices: {${E}}.`);u=E,w=w.sort(_u),b=b.clone();let x=Number.MIN_SAFE_INTEGER;const I=w.length;for(let v=0;v<I;v++){const R=w[v],A=R[0],M=R[1],T=A+M.length-1;if(x>=A)throw new exports.Tuple.OutOfOrderError(`Overlapping minor Indices: {${E}, ${A}}.`);if(A<r||T>o)throw new ke;if(M&&M.length>0){const N=b.getCount();b.setRunAt(A,m(M));const B=b.getCount();h+=B-N,l=Math.min(l,b.getCoords().min),c=Math.max(c,b.getCoords().max)}x=T}_++,d.push([E,b])},m=this._createRun,f=this._optionsMinor;let _=0;const p=()=>{const b=e[_],w=b[0],E=b[1],x=new jn(f);g(x,E,w)},S=this._major;je.bounds.min=t,je.bounds.max=n,je.reverse=!1,je.processSkip=null,je.reuseResult=To;const C=S.entries(je);let y=C.next();for(;!y.done;){const b=y.value,w=b[0];let E=e[_],x=E[0];if(x>w)y=C.next();else{for(;x<w;)p(),E=e[_],x=E[0];if(x===w){const I=E[1],v=b[1];g(v,I,w)}y=C.next()}}for(;e[_];)p();return this._updateMajorSpan(d),this._updateCountAndCoords(h,t,l,n,c),this}_updateCountAndCoords(e,t,n,r,o,i=!1){const a=this._count+e;if(this._count=a,this._lastMajor=Number.MIN_SAFE_INTEGER,!this._dataCoords)return;const l=this._isColumn;let c=l?t:n,h=l?n:t,u=l?r:o,d=l?o:r;if(a===0)this._dataCoords=null;else{const g=this._dataCoords;g&&(c=(i?Math.max:Math.min)(c,g.colStart),h=(i?Math.max:Math.min)(h,g.rowStart),u=(i?Math.min:Math.max)(u,g.colEnd),d=(i?Math.min:Math.max)(d,g.rowEnd));const m={colStart:c,rowStart:h,colEnd:u,rowEnd:d};this._dataCoords=m}}clear(){this._major.clear(),this._dataCoords=null,this._count=0}delete(e){const t=this._count;if(!e)return this.clear(),t>0;const n=this._isColumn,r=this._maxCoords,o=this.getCoords(),i=Et(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,o);if(!i||t===0)return!1;if(k.isRangeWithinRange(o,e))return this.clear(),t>0;const a=i.majorStart,l=i.majorEnd,c=i.minorStart,h=i.minorEnd;let u=n?o.colStart:o.rowStart,d=n?o.colEnd:o.rowEnd;const g=n?o.rowStart:o.colStart,m=n?o.rowEnd:o.colEnd;let f=!1,_=0;const p=this._major;if(c<=g&&h>=m){je.bounds.min=a,je.bounds.max=l;const x=p.entries(je);let I=x.next();for(;!I.done;)_-=I.value[1].getCount(),I=x.next();return p.delete(a,l-a+1),this._count+=_,this._dataCoords=null,_!==0}const S=[],C=this._isShared,y=[];je.bounds.min=a,je.bounds.max=l,Rt.reverse=!1,Rt.processSkip=null,Rt.reuseResult=To;const b=p.entries(je);let w=b.next();for(;!w.done;){const x=w.value,I=x[0];let v=x[1];const R=v.getCoords(),A=R.min,M=R.max;if(c<=A&&h>=A||c<=M&&c<=M)if((A===g&&c<=g||M===m&&h>=m)&&(f=!0),A>=c&&M<=h)S.push(I),_-=v.getCount();else{const T=v.getCount();C&&(v=v.clone(),y.push([I,v])),v.delete(c,h-c+1),_+=v.getCount()-T}w=b.next()}this._updateMajorSpan(y);const E=S.length;if(E>0){const x=Jh(S,!0);for(let v=0;v<x.length;v++){const R=x[v];p.delete(R.min,R.max-R.min+1)}const I=p.getCoords();if(!I)return this.clear(),!0;u=I.min,d=I.max}return f?(this._count+=_,this._dataCoords=null,!0):E===0?(this._count+=_,_!==0):(this._updateCountAndCoords(_,u,g,d,m,!0),_!==0)}shift(e,t){if(!e||!t)throw new Dt;const n=this._isColumn,r=this._maxCoords,o=t===Be.Right||t===Be.Down,i=t===Be.Left||t===Be.Right,a=Et(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,e);if(!a)return!1;const l=a.majorStart,c=a.majorEnd,h=a.minorStart,u=a.minorEnd,d=this.getCoords();if(!d)return!1;const g=n?d.colStart:d.rowStart,m=n?d.colEnd:d.rowEnd,f=n?d.rowStart:d.colStart,_=n?d.rowEnd:d.colEnd,p=h<=f&&u>=_,S=n===i;if((S&&p||!S&&l<=g&&c>=m)&&!Et(d.colStart,d.rowStart,d.colEnd+(o&&i?e.colEnd-e.colStart+1:0),d.rowEnd+(o&&!i?e.rowEnd-e.rowStart+1:0),n,r)||S&&l>m||!S&&h>_)return!1;let C=S?c-l+1:u-h+1;if(!o&&(C*=-1,k.isRangeWithinRange(d,e)))return this.clear(),!0;let y=0;const b=this._major,w=[];if(je.bounds.min=l,je.bounds.max=S?Number.MAX_SAFE_INTEGER:c,Rt.reverse=!o,Rt.processSkip=null,Rt.reuseResult=To,S&&p){if(!o){je.bounds.max=c;const O=b.entries(je);let j=O.next();for(;!j.done;)y-=j.value[1].getCount(),j=O.next()}b.shift(l,C);const z=b.getCoords();return this._dataCoords=null,this._updateCountAndCoords(y,z.min,f,z.max,_),!0}let E=n?d.colStart:d.rowStart,x=n?d.colEnd:d.rowEnd,I=n?d.rowStart:d.colStart,v=n?d.rowEnd:d.colEnd;o||(I=Number.MAX_SAFE_INTEGER,v=Number.MIN_SAFE_INTEGER);let R=Number.MAX_SAFE_INTEGER;r&&(R=i?r.colEnd:r.rowEnd);const A=new Set,M=S?new Map:null,T=[],N=b.entries(je),B={bounds:{min:h,max:u}};let D=N.next();for(;!D.done;){const z=D.value,O=z[0],j=z[1].clone(),V=j.getCoords(),W=V.min,H=V.max;if(S&&M.set(O,j),h<=H){const G=j.getCount();S?(O>=l-C&&a_(j.runs(B),(Z,Y)=>{const re=Y.min,ee=Y.max;let q=Z;re-1<=u&&ee>u&&(q=q.slice(0,u+1-re)),re<h&&ee+1>=h&&(q=q.slice(h-re)),T.push({majorIndex:O+C,minorIndex:Math.max(re,h),run:q})}),j.delete(h,u-h+1)):j.shift(h,C);const $=j.getCount();if($===0)A.add(O),I=Math.min(I,H),v=Math.max(v,W);else{const Z=j.getCoords();if(I=Math.min(I,Z.min),v=Math.max(v,Z.max),v>R)throw new ke}y+=$-G,w.push([O,j])}D=N.next()}const P=this._optionsMinor;let L=!1;for(let z=0;z<T.length;z++){const O=T[z],j=O.majorIndex,V=O.run;let W=M.get(j);W||(W=new jn(P),M.set(j,W),w.push([j,W]),L=!0),W.setRunAt(O.minorIndex,V),y+=V.length,E=Math.min(E,j),x=Math.max(x,j),A&&A.delete(j)}if(this._updateMajorSpan(w,L),A&&A.size>0){const z=Array.from(A.values()),O=Jh(z);for(let V=0;V<O.length;V++){const W=O[V];b.delete(W.min,W.max-W.min+1)}const j=b.getCoords();if(!j)return this.clear(),!0;E=j.min,x=j.max}if(v!==_||I!==f)return this._count+=y,this._dataCoords=null,!0;{const z=this._count+y;this._count=z,this._dataCoords=z===0?null:Object.freeze({colStart:n?E:I,rowStart:n?I:E,colEnd:n?x:v,rowEnd:n?v:x})}return y!==0||!k.isEqualRanges(d,this.getCoords())}getCount(){return this._count}getValueAt(e,t){const n=this._isColumn,r=n?t:e,o=n?e:t,i=this._lastMajor;let a;if(i===r&&i!==Number.MIN_SAFE_INTEGER?a=this._lastMinorSpan:(a=this._major.at(r),this._lastMajor=r,this._lastMinorSpan=a),!!a)return a.at(o)}setValueAt(e,t,n){const r=this._isColumn,o=[r?t:e,[[r?e:t,[n]]]];this.setValues([o])}copyTo(e,t,n){if(this.getCount()===0)return;const r=this.getOrientation(),o=e.getOrientation(),i=this.getRuns({bounds:n});let a=i.next();const l=k.cellToRange(t);l.colEnd=n.colEnd-n.colStart+t.colIndex,l.rowEnd=n.rowEnd-n.rowStart+t.rowIndex;const c=this._isColumn,h=this._maxCoords,u=this.getCoords();let d,g=Et(n.colStart??Number.MIN_SAFE_INTEGER,n.rowStart??Number.MIN_SAFE_INTEGER,n.colEnd??Number.MAX_SAFE_INTEGER,n.rowEnd??Number.MAX_SAFE_INTEGER,c,h,u);g={...g};const m=o!==se.Row,f=e.getMaxCoords();d=Et(l?.colStart??Number.MIN_SAFE_INTEGER,l?.rowStart??Number.MIN_SAFE_INTEGER,l?.colEnd??Number.MAX_SAFE_INTEGER,l?.rowEnd??Number.MAX_SAFE_INTEGER,m,f),d={...d};const _=d.majorStart-g.majorStart,p=d.minorStart-g.minorStart,S=r===o?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder;for(;!a.done;){const y=a.value[0];let b=a.value[1],w=a.value[2];b+w.length>g.minorEnd&&(w=w.slice(0,g.minorEnd-b+1)),b<g.minorStart&&(w=w.slice(g.minorStart-b),b=g.minorStart),S.addValues(y+_,b+p,w),a=i.next()}const C=S.build();e.delete(l),C&&e.setValues(C.tuples)}getCoords(){if(this._dataCoords)return this._dataCoords;if(this._major.getCount()===0)return null;let e=Number.MAX_SAFE_INTEGER,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;const o=this._major.entries();let i=o.next();for(;!i.done;){const c=i.value,h=c[0];e=Math.min(h,e),t=Math.max(h,t);const u=c[1].getCoords();n=Math.min(u.min,n),r=Math.max(u.max,r),i=o.next()}const a=this._isColumn,l=Object.freeze({colStart:a?e:n,rowStart:a?n:e,colEnd:a?t:r,rowEnd:a?r:t});return this._dataCoords=l,l}clone(e){this._isShared=!0;const t=new Qt(this._options);return t._isShared=!0,t._major=this._major.clone(),t._dataCoords=this._dataCoords,t._count=this._count,t}cloneEmpty(e){return new Qt(this._options)}getMaxCoords(){return this._maxCoords||null}get[Symbol.toStringTag](){let e="";const t=this.getCoords();if(t){const n=t.colEnd-t.colStart+1,r=t.rowEnd-t.rowStart+1;e=`${this.getCount()}-${this._isColumn?n:r}x${this._isColumn?r:n}`}return`[SparseGrid:${e}]`}}Qt||(Qt={});const k_=12;Object.seal({done:!1,value:null});const An=[-1,-1,null],vm=Object.seal({done:!1,value:[-1,null]}),To=Object.seal({done:!1,value:[-1,null]}),Rt={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:vm},je={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:To},yu=()=>({majorIndex:-1,minorIndex:-1,value:null,active:!1,nextMinorIndex:-1,nextActive:!1,nextMinorValue:null,minorIterator:null,nextMajorCursor:null,prevMajorCursor:null});class Ri{constructor(e){if(this._l=0,this._at=null,this._dt=Cu.Undefined,this._a32=null,this._a64=null,this._cv=null,this._vt=null,this._vi32=null,this._vi64=null,this._vf32=null,this._vf64=null,!e)throw new Error("options is required");const t=e.length;if(this._l=t,this._dt=e.type,this._cv=e.getCoercedValue??null,t>0){e.types&&(this._at=e.types,this._vt=new Uint8Array(this._at));const n=e.values32??null;n&&(this._a32=n,this._vi32=new Int32Array(n),this._vf32=new Float32Array(n));const r=e.values64??null;if(r&&(this._a64=r,this._vf64=new Float64Array(r),this._vi64=new BigInt64Array(r)),!n&&!r)throw new Error("values32 or values64 is required")}}getConstructorOptions(){return{length:this._l,type:this._dt,types:this._at,values32:this._a32,values64:this._a64,getCoercedValue:this._cv}}at(e){if(e>>>0>=this._l)return;const t=this._vt,n=t&&t[e]||this._dt;let r,o=!1;switch(this._vi32?r=this._vi32[e]:(o=!0,r=Number(this._vi64[e])),n){case ni:return o?Number(r):r;case Po:return o?this._vf64[e]:this._vf32[e];case ri:return!!r;case oi:case si:return this._cv(n,o?Number(r):r);case Fo:return this._vi64[o?e:r];case No:return this._vf64[o?e:r];case Rm:return Number.NaN;case Am:return Number.MAX_SAFE_INTEGER;case Mm:return Number.MIN_SAFE_INTEGER;case xm:return 1/0;case Im:return-1/0;case Tm:return null;case fc:case ii:return}return this._cv(n,o?Number(r):r)}toArray(e){const t=[],n=Math.max(e,this._l);for(let r=0;r<n;r++)t.push(this.at(r));return t}get length(){return this._l}get[Symbol.toStringTag](){return"[MixTypedArrayList]"}toString(){const e=this._a32,t=this._a64;let n="";return e&&!t?n="32":t&&!e&&(n="64"),`{${n}${this._at?"":":SINGLE_TYPE"}}:${this._l}}`}static _createArrayBuffer(e){try{return new SharedArrayBuffer(e)}catch{}return new ArrayBuffer(e)}static fromArray(e,t,n,r,o=O_){const i=e.length;if(i===0)return new Ri({type:Cu.Undefined,length:i,getCoercedValue:n});let a=this._createArrayBuffer(i*Int8Array.BYTES_PER_ELEMENT),l=new Uint8Array(a),c=0,h=!1,u=bu(e[0],r);for(let w=0;w<i;w++){const E=e[w],x=bu(E,r);x!==No&&x!==Fo||c++,u!==x&&(l[w]=x,h=!0)}h||(l=null,a=null);let d,g,m,f,_,p,S,C,y=!1;c/i>o&&(y=!0,c=i),c!==0&&(m=this._createArrayBuffer(c*BigInt64Array.BYTES_PER_ELEMENT),f=new BigInt64Array(m),_=new Float64Array(m)),y?(d=f,g=_):(p=this._createArrayBuffer(i*Int32Array.BYTES_PER_ELEMENT),S=new Int32Array(p),C=new Float32Array(p),d=S,g=C);let b=u;if(y)for(let w=0;w<i;w++){const E=e[w];switch(l&&(b=l[w]||u),b){case ni:d[w]=BigInt(E);break;case ri:d[w]=BigInt(E?1:0);break;case Po:g[w]=E;break;case Fo:d[w]=E;break;case No:g[w]=E;break;case oi:case si:d[w]=BigInt(t?.(b,E)??0);break;default:b>127&&b<255&&(d[w]=BigInt(t?.(b,E)??0))}}else{let w=0;for(let E=0;E<i;E++){const x=e[E];switch(l&&(b=l[E]||u),b){case ni:d[E]=x;break;case ri:d[E]=x?1:0;break;case Po:g[E]=x;break;case Fo:S[E]=w,f[w]=x,w++;break;case No:S[E]=w,_[w]=x,w++;break;case oi:case si:d[E]=t?.(b,x)??0;break;default:b>127&&b<255&&(d[E]=t?.(b,x)??0)}}}return new Ri({length:i,types:h?a:null,type:u,values32:p,values64:m,getCoercedValue:n})}}const O_=.1,ni=1,Po=2,ri=3,Fo=4,No=5,oi=6,si=7,xm=8,Im=9,Rm=10,Am=11,Mm=12,Tm=13,fc=14,ii=127,Cu={Undefined:fc},bu=(s,e)=>{switch(typeof s){case"number":const t=s;return Number.isNaN(t)?Rm:t===1/0?xm:t===-1/0?Im:Object.is(t,-0)?Po:t===Number.MAX_SAFE_INTEGER?Am:t===Number.MIN_SAFE_INTEGER?Mm:Number.isInteger(t)&&t<=2147483647&&t>=-2147483648?ni:Math.fround(t)===t?Po:No;case"string":return oi;case"boolean":return ri;case"object":if(s===null)return Tm;if(s instanceof Error)return si;if(!e)return ii;const n=e(s);if(n<128||n>255)throw new Error("Custom type must be between 128 and 255");return n;case"bigint":return Fo;case"undefined":return fc;case"symbol":case"function":return ii}return ii},ko=s=>{if(!s||s.length<=1)return!1;if(s.length===2)return k.isRangesIntersect(s[0],s[1]);const e=new Ie;e.load(s);for(let t=0;t<s.length;t++)if(e.search(s[t]).length>1)return!0;return!1},jl=(s,e,t)=>{const n=[];if(k.isRangesIntersect(s,e)){const r=F.subtractRect({top:s.rowStart,left:s.colStart,bottom:s.rowEnd+1,right:s.colEnd+1},{top:e.rowStart,left:e.colStart,bottom:e.rowEnd+1,right:e.colEnd+1},t===se.Column);for(let o=0;o<r.length;o++){const i={colStart:r[o].left,rowStart:r[o].top,colEnd:r[o].right-1,rowEnd:r[o].bottom-1};n.push(i)}}else n.push(s);return n},Eu=(s,e,t)=>{if(e&&s?.[0])for(let n=0;n<s.length;n++){const r=s[n];k.intersectRanges(r,e)&&t(r,!k.isRangeWithinRange(r,e),n)}},vu=(s,e)=>{const t=s.colStart,n=s.rowStart,r=e.colStart,o=e.rowStart;return(i,a)=>{const l=i.colIndex-t,c=a.colIndex-r;return l===c?i.rowIndex-n-(a.rowIndex-o):l-c}},xu=(s,e)=>{const t=s.colStart,n=s.rowStart,r=e.colStart,o=e.rowStart;return(i,a)=>{const l=i.rowIndex-n,c=a.rowIndex-o;return l===c?i.colIndex-t-(a.colIndex-r):l-c}},ai=(s,e,t=!1,n=!1)=>{let r=e.colEnd-e.colStart+1,o=e.rowEnd-e.rowStart+1;if(n){const c=r;r=o,o=c}const i={colStart:s.colStart,rowStart:s.rowStart,colEnd:s.colStart+r-1,rowEnd:s.rowStart+o-1};if(t){let c=s.colStart,h=s.rowStart;return k.isSingleCell(s)?(c+=r-1,h+=o-1):(c+=s.colEnd-s.colStart,h+=s.rowEnd-s.rowStart),i.colEnd=n?h:c,i.rowEnd=n?c:h,i}const a=s.colEnd-s.colStart+1;if(a%r!==0)return i;const l=s.rowEnd-s.rowStart+1;return l%o!==0||(i.colEnd=s.colStart+a-1,i.rowEnd=s.rowStart+l-1),i};class Pa{constructor(e,t){this._l=0,e&&t>0&&(this._u=e,this._l=t)}at(e){if(e>this._l||e<0||!this._u)return;const t=Math.floor(e%this._u.length);return this._u.at(t)}toArray(e){const t=[],n=this._u,r=n.length;for(let o=0;o<e;o++){const i=Math.floor(o%r);t.push(n.at(i))}return t}get length(){return this._l}get[Symbol.toStringTag](){return"[RepeatingList]"}get isIList(){return!0}}class nt{constructor(e,t,n=null,r=!1){this._isLiteral=!1,this._values=e,this._coords=t,this._type=n,this._isLiteral=r}getValueAt(e,t,n){const r=this._coords;if(!r)return;let o=this._values.getValueAt(e+r.rowStart,t+r.colStart)??null;o===void 0&&(o=null);const i=n?.type,a=i!==void 0?i:this._type;return a&&(o=Ot(o,Ze(o,!0),a)),o}_applyBuilder(e,t,n=!1){if(!t)return e;const r=t.build();return r&&(n&&(e=e.clone()),e.setValues(r.tuples)),e}_cloneFromBuilder(e,t,n,r){if(!e)return this;const o=e.build();if(!o)return this;let i=this._values;const a=i.getOrientation(),l=(t?.orientation??a)===exports.w.Orientation.Column,c=$o(o.bounds,l),h=this._coords??k.EmptyRange,u=Math.max(c.colEnd-c.colStart+1,n??h.colEnd-h.colStart+1),d=Math.max(c.rowEnd-c.rowStart+1,r??h.rowEnd-h.rowStart+1),g=h.colStart,m=h.rowStart,f=g+u-1,_=m+d-1;return i=i.clone(),i.setValues(o.tuples),new nt(i,{colStart:g,rowStart:m,colEnd:f,rowEnd:_},this._type,this._isLiteral)}forEach(e,t){if(!e)return;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value,i=e(o.value,o.coords,this);if(i)return i.break;r=n.next()}}reduce(e,t,n){if(!e)return t;const r=this.entries(n);let o=r.next(),i=t;for(;!o.done;){const a=o.value;i=e(i,a.value,a.coords,this),o=r.next()}return i}some(e,t){if(!e)return!1;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value;if(e(o.value,o.coords,this))return!0;r=n.next()}return!1}every(e,t){if(!e)return!0;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value;if(!e(o.value,o.coords,this))return!1;r=n.next()}return!0}replace(e,t){let n;if(n=e?.isIRange?e:Nm(e,this._values,this._coords,this._type),this.size===0)return n;if(n.size===0)return this;const r=this._values.clone(),o=n._values,i=n._coords??k.EmptyRange,a=this._coords??k.EmptyRange,l=a.colStart,c=a.rowStart,h=l+(t.colIndex??0),u=c+(t.rowIndex??0);o.copyTo(r,{colIndex:h,rowIndex:u},i);const d=Math.max(this.getWidth(),n.getWidth()+(t?.colIndex??0)),g=Math.max(this.getHeight(),n.getHeight()+(t?.rowIndex??0));return new nt(r,{colStart:l,rowStart:c,colEnd:l+d-1,rowEnd:c+ +g-1},this._type)}slice(e){if(!e)return this;const t=this._coords??k.EmptyRange,n=(e.colStart??0)+t.colStart,r=(e.rowStart??0)+t.rowStart,o={colStart:n,rowStart:r,colEnd:(e.colEnd??t.colEnd-n)+t.colStart,rowEnd:(e.rowEnd??t.rowEnd-r)+t.rowStart},i=k.intersectRanges(t,o);return new nt(this._values,i,this._type)}resize(e,t,n=null){if(e<0||t<0)throw new Error(`Invalid resize dimensions: ${e} x ${t}`);const r=this._coords??k.EmptyRange,o=r.colEnd-r.colStart+1,i=r.rowEnd-r.rowStart+1;if(e===o&&t===i)return this;const a={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colStart+e-1,rowEnd:r.rowStart+t-1};let l=this._values;return(e>o||t>i)&&(l=l.clone(),e>o&&(Qe.colStart=r.colEnd+1,Qe.rowStart=r.rowStart,Qe.colEnd=r.colEnd,Qe.rowEnd=r.rowEnd,this._fill(l,r,n)),t>i&&(Qe.colStart=r.colStart,Qe.rowStart=r.rowEnd+1,Qe.colEnd=r.colEnd,Qe.rowEnd=r.rowEnd,this._fill(l,r,n))),new nt(l,a,this._type)}_mergeIterators(e,t,n){const r=this._coords??k.EmptyRange,o=e._coords??k.EmptyRange,i=this._values.getOrientation(),a=n?.orientation??i,l=a!==exports.w.Orientation.Row,c=this._entries(n),h=this._entries(n),u=r.colStart,d=r.rowStart,g=u-o.colStart,m=d-o.rowStart,f=a===i?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,_=new Su({...n,bounds:r,comparator:(l?vu:xu)(r,o)},c,h);let p=_.next();for(;!p.done;){const S=p.value;let C=S[1],y=S[3];const b=S[0],w=S[2],E=b?b.colIndex:w.colIndex+g,x=b?b.rowIndex:w.rowIndex+m,I=t(C,y,{colIndex:E-u,rowIndex:x-d},this),v=l?E:x,R=l?x:E;f.addValue(v,R,I),p=_.next()}return f}intersect(e,t,n){if(!e)throw new Error("Invalid range to intersect");const r=e,o=this._coords??null,i=r._coords??null;if(!k.intersectRanges(o,i))return new nt(this._values,null,this._type);const a=this._mergeIterators(r,t,n);return this._cloneFromBuilder(a,n)}startIncrementalUpdates(e){const t=e?.orientation??exports.w.Orientation.Column,n=this._values.getOrientation(),r=(e?.orientation??n)!==exports.w.Orientation.Row,o=t===n?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,i=this,a=this._coords??k.EmptyRange,l=a.colStart,c=a.rowStart,h=r?l:c,u=r?c:l,d={pushAt(g,m,f){const _=r?m:g,p=r?g:m;return o.addValue(_+h,p+u,f),d},pushMultipleAt(g,m,f){const _=r?m:g,p=r?g:m;return o.addValues(_+h,p+u,f),d},apply(){const g=o.build();return g?(g.bounds.majorStart=h,g.bounds.minorStart=u,i._cloneFromBuilder(o,e)):null}};return d}map(e,t){const n=this._values;if(!this._coords||n.getCount()===0)return this;const r=n.getOrientation(),o=t?.orientation??r;let i;const a=this.entries(t);let l=a.next();l.done||(i=this._createTupleBuilder(o));const c=o===exports.w.Orientation.Column;for(;!l.done;){const h=l.value,u=h.coords,d=e(h.value,u,this),g=c?u.colIndex:u.rowIndex,m=c?u.rowIndex:u.colIndex;i.addValue(g,m,d),l=a.next()}return this._cloneFromBuilder(i,t)}filter(e,t){const n=this._values;if(!this._coords||n.getCount()===0)return this;const r=n.getOrientation(),o=t?.orientation??r,i=this._createTupleBuilder(o),a=this.entries(t);let l=a.next();const c=o===exports.w.Orientation.Column;for(;!l.done;){const h=l.value,u=h.coords,d=h.value;if(e(d,u,this)){const g=c?u.colIndex:u.rowIndex,m=c?u.rowIndex:u.colIndex;i.addValue(g,m,d)}l=a.next()}return this._cloneFromBuilder(i,t)}broadcast(e,t,n){let r=this._coords;if(e==null)return this;let o=n?.type,i=n?.otherType??o;const a=o?Ot(null,U.Null,o):null,l=i?Ot(null,U.Null,i):null;let c;if(e.isIRange)c=e;else{const L=this._values.clone();L.setValueAt(0,0,e),c=new nt(L,k.EmptyRange,Ze(e,!0))}const h=c,u=this.getWidth(),d=this.getHeight(),g=h.getWidth(),m=h.getHeight();let f=Math.min(u,g),_=Math.min(d,m),p=Math.max(u,g),S=Math.max(d,m);const C=n?.mismatchFill;let y=!1;if(u!==g)if(u===1)f=g;else if(g===1)f=u;else{if(!C)throw new Error(`Incompatible shapes for broadcast: width dimensions ${u} and ${g} must be equal or one must be 1`);y=!0}if(d!==m)if(d===1)_=m;else if(m===1)_=d;else{if(!C)throw new Error(`Incompatible shapes for broadcast: height dimensions ${d} and ${m} must be equal or one must be 1`);y=!0}const b=this._values.getOrientation(),w=b,E=w===exports.w.Orientation.Column;r=r??k.EmptyRange;let x,I,v=h._coords??k.EmptyRange;if(y&&(r={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colStart+f-1,rowEnd:r.rowStart+f-1},v={colStart:v.colStart,rowStart:v.rowStart,colEnd:v.colStart+f-1,rowEnd:v.rowStart+f-1}),u===1&&u<g||d===1&&d<m){const L={...r};u===1&&(L.colEnd=L.colStart),d===1&&(L.rowEnd=L.rowStart),x=new zl({delegate:this._entries({...n,orientation:w,bounds:L,reuseResult:!1}),bounds:L,orientation:w,dims:{major:E?f:_,minor:E?_:f}})}else x=this._entries({...n,orientation:w,bounds:r,reuseResult:!1});if(g===1&&g<u||m===1&&m<d){const L={...v};g===1&&(L.colEnd=L.colStart),m===1&&(L.rowEnd=L.rowStart),I=new zl({delegate:h._entries({...n,type:i??null,orientation:w,bounds:L,reuseResult:!1}),bounds:L,orientation:w,dims:{major:E?f:_,minor:E?_:f}})}else I=h._entries({...n,type:i??null,orientation:w,bounds:v,reuseResult:!1});const R=r.colStart,A=r.rowStart,M=R-v.colStart,T=A-v.rowStart,N=w===b?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,B=new Su({...n,bounds:r,comparator:(E?vu:xu)(r,v)},x,I);let D,P=B.next();for(;!P.done;){const L=P.value;let z=L[1],O=L[3];const j=L[0],V=L[2],W=j?j.colIndex:V.colIndex+M,H=j?j.rowIndex:V.rowIndex+T;let G,$;z instanceof exports.n.Value?G=z:O instanceof exports.n.Value&&(G=O),$=G||t(z??a,O??l,{colIndex:W-R,rowIndex:H-A},this);const Z=E?W:H,Y=E?H:W;N.addValue(Z,Y,$),P=B.next()}if(C&&p>f||S>_){const L=this._values.clone();if(this._applyBuilder(L,N),p>f){const z=Et(R+f,A,R+p-1,A+S-1,E),O=ti(C,z,E);L.setValues(O.tuples)}if(S>_){const z=Et(R,A+_,R+p-1,A+S-1,E),O=ti(C,z,E);L.setValues(O.tuples)}D=new nt(L,{colStart:R,rowStart:A,colEnd:R+p-1,rowEnd:A+S-1},this._type)}else D=this._cloneFromBuilder(N,n,p,S);return D}_fill(e,t,n){if(n===null)return void e.delete(t);const r=e.getOrientation()===exports.w.Orientation.Column,o=Et(t.colStart,t.rowStart,t.colEnd,t.rowEnd,r),i=ti(n,o,r);e.setValues(i.tuples)}_validateCoords(e){}fill(e,t){let n=this._coords;if(!n&&!t)return this;n=n??k.EmptyRange,t&&(Qe.colStart=(t.colStart??0)+n.colStart,Qe.rowStart=(t.rowStart??0)+n.rowStart,Qe.colEnd=(t.colEnd??n.colEnd-n.colStart)+n.colStart,Qe.rowEnd=(t.rowEnd??n.rowEnd-n.rowStart)+n.rowStart),this._validateCoords(Qe);const r=this._values.clone();return this._fill(r,Qe,e),(Qe.rowEnd>n.rowEnd||Qe.colEnd>n.colEnd)&&(n={colStart:n.colStart,rowStart:n.rowStart,colEnd:Math.max(n.colEnd,Qe.colEnd),rowEnd:Math.max(n.rowEnd,Qe.rowEnd)}),new nt(r,n,this._type)}empty(){const e=this._values.cloneEmpty();return new nt(e,null,this._type)}flatten(e){const t=[],n=this.values(e);let r=n.next();for(;!r.done;)t.push(r.value),r=n.next();return t}fillEmpty(e,t=1,n=1){const r=this._coords;if(!r)return this;const o=this._values;if(t<1&&n<1)throw new Error("Must be at least size of 1");const i=o.getOrientation(),a=i,l=a===exports.w.Orientation.Column,c=Math.max(this.getWidth(),t),h=Math.max(this.getHeight(),n),u=l?r.colStart:r.rowStart,d=l?r.rowStart:r.colStart,g=l?r.colStart+c-1:r.rowStart+h-1,m=l?r.rowStart+h-1:r.colStart+c-1,f=o.getRuns({bounds:{colStart:r.colStart,rowStart:r.rowStart,colEnd:l?g:m,rowEnd:l?m:g},overflowRun:!0});let _=f.next(),p=u,S=d;const C=a===i?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder;for(;!_.done;){const y=_.value,b=y[0];for(;p<b;){const v=new Pa([e],m+1-S);C.addValues(p,S,v),p++,S=d}const w=y[1],E=Math.max(w,d),x=y[2],I=Math.min(w+x.length-1,m);if(S<E){const v=new Pa([e],w-S);C.addValues(p,S,v)}S=I+1,I>=m?(p=b+1,S=d):p=b,_=f.next()}for(;p<=g;){const y=new Pa([e],m+1-S);C.addValues(p,S,y),p++,S=d}return this._cloneFromBuilder(C,void 0,c,h)}transpose(){if(this.size<=1)return this;const e=this._values.getOrientation(),t=this._coords,n=this.getWidth(),r=this.getHeight(),o=this._entries({orientation:e===exports.w.Orientation.Column?exports.w.Orientation.Row:exports.w.Orientation.Column,bounds:t,reuseResult:!0}),i=e===exports.w.Orientation.Column,a=new exports.Tuple.Builder,l=i?t.colStart:t.rowStart,c=i?t.rowStart:t.colStart;let h=o.next();for(;!h.done;){const u=h.value,d=u[0],g=i?d.colIndex:d.rowIndex-l,m=(i?d.rowIndex:d.colIndex-c)+l,f=g+c,_=u[1];a.addValue(m,f,_),h=o.next()}return this._cloneFromBuilder(a,void 0,r,n)}values(e){const t=this.entries(e);return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?Re:{done:!1,value:n.value.value}}}}_createTupleBuilder(e){const t=this._coords,n=this._values.getOrientation(),r=e??n,o=r!==exports.w.Orientation.Row,i=o?t.colStart:t.rowStart,a=o?t.rowStart:t.colStart;return r===n?new exports.Tuple.Builder(null,i,a):new exports.Tuple.TransposedBuilder(null,i,a)}entries(e){const t=this._coords;if(!t)return Xe;const n=e?.bounds;if(e={...e,bounds:t},n){const i=(n.colStart??0)-t.colStart,a=(n.rowStart??0)-t.rowStart,l=Math.max(i+t.colStart,t.colStart),c=Math.max(a+t.rowStart,t.rowStart),h=Math.min((n.colEnd??Number.MAX_SAFE_INTEGER)-i,t.colEnd-t.colStart)+1,u=Math.min((n.rowEnd??Number.MAX_SAFE_INTEGER)-a,t.rowEnd-t.rowStart)+1;e.bounds={colStart:l,rowStart:c,colEnd:l+h-1,rowEnd:c+u-1}}const r=this._entries(e),o={[Symbol.iterator]:()=>o,next(){for(;;){let i=r.next();if(i.done)return Re;const a=i.value,l=a[0];return{done:!1,value:{coords:{colIndex:l.colIndex-t.colStart,rowIndex:l.rowIndex-t.rowStart},value:a[1]}}}}};return o}_entries(e){if(!this._coords)return Xe;let t=this._values.entries(e);const n=e?.type??this._type;let r=null;if(e?.includeEmpty&&(t=new Em(t,e),n&&(r=Ot(null,U.Null,n))),n){const o=t,i=e.coerce??!1,a=e.includeBoolean??!1,l=e.includeMistyped??!1;t={[Symbol.iterator]:()=>t,next(){for(;;){let c=o.next();if(c.done)return Re;const h=c.value,u=h[1];let d=u;if(d==null)d=r;else if(n&&(i||!l)){let g=Ze(d,!0),m=g!==n;if(m&&(i&&(d=Ot(d,g,n,a),m=d?.isFormulaError),m&&!l))continue}return d===u?c:{done:!1,value:[h[0],d]}}}}}return t}getValues(e){if(!this._coords)return[[]];const t={...e,includeEmpty:!0,reverse:!1,bounds:{colStart:0,rowStart:0,colEnd:this.getWidth()-1,rowEnd:this.getHeight()-1}};let n=!1;t.orientation=e?.orientation??exports.w.Orientation.Row,e&&(e.maxHeight&&(t.bounds.rowEnd=0+e.maxHeight-1),e.maxWidth&&(t.bounds.colEnd=0+e.maxWidth-1),e.trailingEmpties&&(n=e.trailingEmpties),t.orientation=e?.orientation??exports.w.Orientation.Row);const r=[];if(!n){t.includeEmpty=!1,t.reverse=!0;const u=this.entries(t).next();if(u.done)return B_;const d=u.value.coords;t.bounds.colEnd=d.colIndex,t.bounds.rowEnd=d.rowIndex,t.includeEmpty=!0,t.reverse=!1}const o=this.entries(t),i=t.orientation!==exports.w.Orientation.Row,a=e?.onValue;let l,c=-1,h=[];for(l=o.next();!l.done;){const u=l.value,d=u.coords,g=i?d.colIndex:d.rowIndex;g!==c&&(h=[],r.push(h),c=g);let m=u.value;if(a){const f=a(m,d.rowIndex,d.colIndex,this);f!==void 0&&(m=f)}h.push(m),l=o.next()}return r}toType(e){return new nt(this._values,this._coords,e,this._isLiteral)}getWidth(){const e=this._coords;return e?e.colEnd-e.colStart+1:0}getHeight(){const e=this._coords;return e?e.rowEnd-e.rowStart+1:0}get size(){const e=this._coords;return e?(e.colEnd-e.colStart+1)*(e.rowEnd-e.rowStart+1):0}isLiteral(){return this._isLiteral}getScalarType(){return this._type}[Symbol.iterator](){const e=this.entries();return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}get[Symbol.toStringTag](){return"[Range]"}toString(){const e=this._coords,t=e?`${e.colEnd-e.colStart+1}x${e.rowEnd-e.rowStart+1}`:exports.n.Ref.toString();let n="{";const r=this.entries({includeEmpty:!0,orientation:exports.w.Orientation.Row});let o=r.next(),i=0,a=o.value?.coords.rowIndex??0;for(;!o.done&&i<10;){const l=o.value;l.coords.rowIndex>a?(n+=";",a=l.coords.rowIndex):i>0&&(n+=","),i++;let c=l.value;typeof c=="string"?c=`"${c}"`:typeof c=="boolean"&&(c=c?"TRUE":"FALSE"),n+=c,o=r.next()}return o.done?n+="}":n+="...",`[${t}:${n}]`}get isIRange(){return!0}}const Qe={colStart:Number.MIN_SAFE_INTEGER,rowStart:Number.MIN_SAFE_INTEGER,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER},B_=Object.freeze([Object.freeze([null])]),ts=Object.freeze({colStart:0,rowStart:0,colEnd:Math.pow(2,14)-1,rowEnd:Math.pow(2,20)-1}),D_=Object.freeze({colIndex:0,rowIndex:0}),Ai=()=>ts,Ze=(s,e=!1)=>typeof s=="number"?isNaN(s)||s===1/0||s===-1/0?U.Error:U.Number:typeof s=="string"?U.String:typeof s=="boolean"?U.Boolean:s?.isFormulaError?U.Error:s===null?U.Null:F.isObject(s)&&s.hasOwnProperty("type")&&typeof s.type=="string"?U.RichData:e&&qr(s)?"Date":s===void 0?(console.warn("undefined"),U.Null):null,Iu=new Map([[U.Null,"any"],[U.Number,"number"],[U.String,"string"],[U.Boolean,"boolean"],[U.Error,"FormulaError"],[U.RichData,"richData"],["*","Scalar"]]),L_=new Map([["p","IReferenceRange"],["r","IRange"]]),P_={orientation:exports.w.Orientation.Row},Ot=(s,e,t=U.Number,n=!1,r=!1)=>{if(e===t||!t)return e===U.Number&&(s=ns(s,null,"number")),s;if(t===U.Number){switch(e){case U.Null:return 0;case U.String:let o=0;try{const i=rf(s);o=i&&typeof i.value=="number"?i.value:Number.NaN}catch{}return!Number.isFinite(o)||Math.abs(o)>999e305?exports.n.BuiltIn.Value:o;case U.Boolean:return n?s?1:0:exports.n.BuiltIn.Value;case"Date":return Qo(s,r)??exports.n.BuiltIn.Value;case U.Error:return s}return s.toString()}if(t===U.String){switch(e){case U.Null:return"";case U.Number:return s.toString();case U.Boolean:return s?"TRUE":"FALSE";case U.Error:return s}return s}if(t===U.Boolean){switch(e){case U.Null:return 0;case U.Number:return!!s;case U.String:let o=s.trim().toUpperCase();return o==="TRUE"||o!=="FALSE"&&exports.n.BuiltIn.Value;case U.Error:return s}return exports.n.BuiltIn.Value}if(t==="Date"){switch(e){case U.Number:return Jr(s,r)??exports.n.BuiltIn.Value;case U.String:try{const o=ic(s,r);if(o)return o.asJSDate??exports.n.BuiltIn.Value}catch{}return s;case U.Error:return s}return exports.n.BuiltIn.Value}return exports.n.BuiltIn.Value},Ru=s=>{let e=s;for(;Array.isArray(e);){if(e.length>1)return!1;e=e[0]}return!e||!e.isIRange||e.size===1},Fm=(s,e,t,n,r,o=!1)=>{if(Array.isArray(t)){const i=t.length;for(let a=0;a<i;a++){let l=t[a];if(Array.isArray(l)){const c=Fm(s,e,l,n,r,o);if(o)continue;if(c instanceof exports.n.Value)return c}else{if(n){if(l=Ot(l,Ze(l,!0),n,o),o)continue;if(l instanceof exports.n.Value)return l}e.push(l)}}return}if(t&&t.colStart!==void 0){let i=s.getReference?.(t);n&&(i=i.toType(n)),t=i}if(t?.isIRange)return((i,a)=>{let l=i.next();for(;!l.done;){let c=l.value;if(c instanceof exports.n.Value)return c;a.push(c),l=i.next()}})(t.values({type:n,coerce:!0,includeMistyped:!o,...P_}),e);if(n){if(t=Ot(t,Ze(t,!0),n,r!==null),o)return;if(t instanceof exports.n.Value)return t}e.push(t)},lo=(s,e,t,n,r,o)=>{if(r==="r"){let a=t;return a&&a.isIReferenceRange?(n&&(a=a.toType(n)),void e.push(t)):new exports.n.Value("Cannot convert a literal to a reference.")}let i=t?.isIRange?t:null;if(r!=="l"){if(i){const a=i.getValues({type:n});return void e.push(a)}{Array.isArray(t)||(t=[t]);const a=t.length,l=new Array(a);for(let c=0;c<a;c++){let h=t[c];Array.isArray(h)||(h=[h]);const u=h.length,d=new Array(u);for(let g=0;g<u;g++){let m=h[g];if(n&&(m=Ot(m,Ze(m,!0),n)),m instanceof exports.n.Value)return m;d[g]=m}l[c]=d}e.push(l)}}else{if(i)n&&i.getScalarType()!==n&&(i=i.toType(n));else try{if(!o&&(t=ns(t),n&&(t=Ot(t,Ze(t,!0),n,!0),t?.isFormulaError&&n!==U.Error)))return e.push(t),t;i=s.getRange(t),n&&(i=i.toType(n))}catch(a){return a}e.push(i)}},ns=(s,e,t=typeof s)=>{if(t==="number")return isNaN(s)?exports.n.BuiltIn.Num:isFinite(s)?s+=0:exports.n.BuiltIn.Div0;if(s==null)return null;if(!e)return s;if(Array.isArray(s))try{s=e.getRange(s)}catch{return exports.n.BuiltIn.Value}return e.isValidDate(s)?(e.formatResults("Short Date"),e.toOADate(s)):s},Nm=(s,e,t,n)=>{let r;r=Array.isArray(s)?Array.isArray(s[0])?s:[s]:[[s]],e||(e=new Qt({orientation:exports.w.Orientation.Column}));const o=e.getOrientation()===exports.w.Orientation.Column,i=Ii(r,o,Et(t?.colStart??0,t?.rowStart??0,void 0,void 0,o),!0),a=$o(i.bounds,o);return e.setValues(i.tuples),new nt(e,a,n,!t)},z_=new RegExp(/^([$]?[a-zA-Z]*[$]?[0-9]*)[:]?([$]?[a-zA-Z]*[$]?[0-9]*)?$/),j_=new RegExp(/^(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?)(:(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?))?$/,"i"),W_=new RegExp(/^(R?)(\[?[-+]?\d+\]?|\d+)?(C?)(\[?[-+]?\d+\]?|\d+)?$/,"i"),H_=new RegExp("(?:'[^']+'|[A-Za-z0-9_\\-.]+?!)?(\\$?[A-Za-z]+\\$?\\d+(?::\\$?[A-Za-z]+\\$?\\d+)?|\\$?[A-Za-z]+:\\$?[A-Za-z]+|\\$?\\d+:\\$?\\d+)","g"),V_=/\s+/g,$_=/"(?:[^"]|"")*"|\[[^[\]]+\]/g,za=/[\uE000-\uF8FF]/g,Ye="#REF!",km=Math.pow(2,14),G_=Math.pow(2,20);let Au,Mu;const $t=s=>(Au===s||(Mu=""+(s+1),Au=s),Mu);let Tu,ja;const Pt=s=>{if(Tu===s)return ja;if(Tu=s,s<0)throw new Error("invalid column "+s);let e="";for(++s;s;s=Math.floor((s-1)/26))e=String.fromCharCode((s-1)%26+65)+e;return ja=e,ja},U_=/[^a-zA-Z0-9]/,rs=s=>s?Pt(s.colIndex)+$t(s.rowIndex):null,Hn=s=>{if(!s)return Ye;const e=Pt(s.colIndex),t=$t(s.rowIndex);return(s.$colIndex?"$"+e:e)+(s.$rowIndex?"$"+t:t)},pc=(s,e)=>{let t=s??e;var n;return t&&(t=ac(t),t=t.replace(/'/g,"''"),n=t,U_.test(n)&&(t=rm(t))),t},Om=(s,e)=>s?s+(s.endsWith("!")?"":"!")+e:Ye,bn=(s,e,t=rs)=>{if(!s)return null;const n=s.colStart,r=s.rowStart,o=s.colEnd,i=s.rowEnd;if(n===o&&r===i)return t({colIndex:n,rowIndex:r});s={...e,...s};const a=n===Number.MIN_SAFE_INTEGER||e&&n<=e.colStart&&o>=e.colEnd,l=r===Number.MIN_SAFE_INTEGER||e&&r<=e.rowStart&&i>=e.rowEnd;let c=null;c=l?Pt(n):a?$t(r):t({colIndex:n,rowIndex:r});let h=null;return h=l?Pt(o):a?$t(i):t({colIndex:o,rowIndex:i}),c+":"+h},Wa=(s,e,t=Hn)=>{if(!s)return Ye;const n=s.colIndex,r=s.rowIndex,o=n===Number.MIN_SAFE_INTEGER;let i=null;if(r===Number.MIN_SAFE_INTEGER?(i=Pt(n),s.$colIndex&&(i="$"+i)):o?(i=$t(r),s.$rowIndex&&(i="$"+i)):i=t(s),s.sheetName||e){const a=pc(s.sheetName,e);i=Om(a,i)}return i},pn=(s,e,t=Hn)=>{if(!s)return Ye;const n=s.rowStart!==void 0&&s.rowStart===s.rowEnd;if(s.colStart!==void 0&&s.colStart===s.colEnd&&n)return t({colIndex:s.colStart,rowIndex:s.rowStart,$colIndex:s.$colStart,$rowIndex:s.$rowStart});s={...e,...s};const r=e&&s.rowStart<=e.rowStart&&s.rowEnd>=e.rowEnd,o=e&&s.colStart<=e.colStart&&s.colEnd>=e.colEnd;let i=null;r?(i=Pt(s.colStart),i=s.$colStart?"$"+i:i):o?(i=$t(s.rowStart),i=s.$rowStart?"$"+i:i):i=t({colIndex:s.colStart,rowIndex:s.rowStart,$colIndex:s.$colStart,$rowIndex:s.$rowStart});let a=null;return r?(a=Pt(s.colEnd),a=s.$colEnd?"$"+a:a):o?(a=$t(s.rowEnd),a=s.$rowEnd?"$"+a:a):a=t({colIndex:s.colEnd,rowIndex:s.rowEnd,$colIndex:s.$colEnd,$rowIndex:s.$rowEnd}),i+":"+a},Ui=(s,e,t=Hn)=>{const n=pn(s,e,t),r=pc(s?.sheetName,e?.sheetName);return Om(r,n)},Bm=(s,e=!1)=>{if(!s)return null;let t=0,n=0,r=!1,o=!1;const i=s.length;for(let l=0;l<i;++l){const c=s.charCodeAt(l);if(c>=48&&c<=57){if(n=10*n+(c-48),t===0&&!e)return}else if(c>=65&&c<=90){if(t=26*t+(c-64),n!==0)return}else if(c>=97&&c<=122){if(t=26*t+(c-96),n!==0)return}else{if(c!==36)return;if(t!==0||r){if(n!==0||o)return;o=!0}else r=!0}}const a={};return e||n!==0&&t!==0?(t>0&&(a.colIndex=t-1,r&&(a.$colIndex=r)),n>0&&(a.rowIndex=n-1,(o||e&&r)&&(a.$rowIndex=o||e&&r)),a):null},Ft=(s,e=ts,t=!1)=>{if(!s)return null;let n=s.toUpperCase();const r=Pm(n,t);let o=null,i=null;if(r?.[1]){const l=!!r[2],c=t?li:Bm;o=c(r[1],l),i=c(r[2]??r[1],l)}if(!o&&!i||o&&i&&(o.rowIndex===void 0&&i.rowIndex!==void 0||o.rowIndex!==void 0&&i.rowIndex===void 0||o.colIndex===void 0&&i.colIndex!==void 0||o.colIndex!==void 0&&i.colIndex===void 0))return null;const a={};return o&&(o.colIndex!==void 0&&(a.colStart=o.colIndex),o.rowIndex!==void 0&&(a.rowStart=o.rowIndex),o.$colIndex!==void 0&&(a.$colStart=o.$colIndex),o.$rowIndex!==void 0&&(a.$rowStart=o.$rowIndex),a?.colStart!==void 0&&a?.colStart>e?.colEnd)?null:(i&&(i.colIndex!==void 0&&(a.colEnd=i.colIndex),i.rowIndex!==void 0&&(a.rowEnd=i.rowIndex),i.$colIndex!==void 0&&(a.$colEnd=i.$colIndex),i.$rowIndex!==void 0&&(a.$rowEnd=i.$rowIndex)),{...e,...a})},os=(s,e,t=!1)=>{const n=(o=>{const i=o.lastIndexOf("!");if(i===-1)return null;let a=o.slice(0,i);return a=ac(a),a=a.replace(/''/g,"'"),[a,o.slice(i+1)]})(s);let r;if(n){if(r=Ft(n[1],e,t),!r)return null;r.sheetName=n[0]}else r=Ft(s,e,t);return r||null},_c=(s,e,t=pn,n=Hn)=>{if(!s||s.length===0)return null;const r=[],o=s.length;for(let i=0;i<o;i++){const a=s[i];let l=null;a?a.rowIndex!==void 0||a.colIndex!==void 0?l=n(a):a.rowStart!==void 0||a.colStart!==void 0?l=t(a,e,n):typeof a=="string"&&(l=a):l=Ye,l&&r.push(l)}return r},Dm=(s,e,t=Ui,n=Hn)=>{const r=_c(s,e,t,n);return r?r.join(","):Ye},Lm=(s,e,t,n=os,r,o=!1)=>{if(e!==null){if(typeof e=="string"){const i=n(e,t,o);if(!i){const a=r?.(e);if(a){const l=a.length;for(let c=0;c<l;c++){const h=a[c];Lm(s,h,t,n,r,o)}}return}e=i}else e.isICellRange?e=e.getCoords():e.isICell&&(e=k.cellToRange(e.getCoords()));if(e!==null){if(e.rowStart!==void 0||e.colStart!==void 0||e.colEnd!==void 0||e.rowEnd!==void 0){const i=e;s.push({...t,...i})}else if(e.rowIndex!==void 0||e.colIndex!==void 0){const i=e,a={...t,...i,colStart:i.colIndex,rowStart:i.rowIndex,colEnd:i.colIndex,rowEnd:i.rowIndex};a.sheetName===null&&t.sheetName&&(a.sheetName=t.sheetName),delete a.colIndex,delete a.rowIndex,s.push(a)}}else s.push(null)}else s.push(null)},Sc=(s,e,t=os,n,r=!1)=>{if(!s)return[e];let o;o=typeof s=="string"?om(s):s.isICellRanges?s.getCoords():Array.isArray(s)?s:[s];const i=[],a=o.length;for(let l=0;l<a;l++){const c=o[l];Lm(i,c,e,t,n,r)}return i},Fr=(s,e)=>{let t=0,n=0;const r=s.length;for(let o=0;o<r;++o){const i=s.charCodeAt(o);if(i>=48&&i<=57){if(t=10*t+(i-48),n===0)return}else if(i>=65&&i<=90){if(n=26*n+(i-64),t!==0)return}else if(!(i>=97&&i<=122)||(n=26*n+(i-96),t!==0))return}return e?(e.colIndex=n-1,e.rowIndex=t-1,e):{colIndex:n-1,rowIndex:t-1}},li=(s,e=!1,t)=>{t?(t.colIndex=Number.MIN_SAFE_INTEGER,t.rowIndex=Number.MIN_SAFE_INTEGER,t.$colIndex=!1,t.$rowIndex=!1):t={colIndex:Number.MIN_SAFE_INTEGER,rowIndex:Number.MIN_SAFE_INTEGER,$colIndex:!1,$rowIndex:!1};const n=W_.exec(s);if(!n)return null;const r=n[1],o=n[3];if(!(e||r&&o))return null;if(r){const i=n[2];i?i&&(i.startsWith("[")?(t.rowIndex=parseInt(i.slice(1,-1)),t.$rowIndex=!1):(t.rowIndex=parseInt(i)-1,t.$rowIndex=!0)):(t.rowIndex=0,t.$rowIndex=!1)}if(o){const i=n[4];i?i.startsWith("[")?(t.colIndex=parseInt(i.slice(1,-1)),t.$colIndex=!1):(t.colIndex=parseInt(i)-1,t.$colIndex=!0):(t.colIndex=0,t.$colIndex=!1)}return t},Wl=(s,e)=>{let t=0,n=0,r=!1,o=!1;const i=s.length;for(let a=0;a<i;++a){const l=s.charCodeAt(a);l>=48&&l<=57?t=10*t+(l-48):l>=65&&l<=90?n=26*n+(l-64):l>=97&&l<=122?n=26*n+(l-96):l===36&&(a===0?r=!0:o=!0)}return n--,t--,e.colIndex=n,e.rowIndex=t,t===-1?(e.$colIndex=r,e.$rowIndex=!1,e):n===-1?(e.$colIndex=!1,e.$rowIndex=r,e):(e.$colIndex=r,e.$rowIndex=o,e)},q_=s=>{let e=0;const t=s.length;for(let n=0;n<t;++n){const r=s.charCodeAt(n);if(r>=65&&r<=90)e=26*e+(r-64);else{if(!(r>=97&&r<=122))return e-1;e=26*e+(r-96)}}return e-1},Ct=(s,e)=>{let t=e;t?(t.rowStart=0,t.colStart=0,t.rowEnd=0,t.colEnd=0):t={rowStart:0,colStart:0,rowEnd:0,colEnd:0};let n=0,r=0,o=0,i=s.length;for(n=0;r<i&&(o=s.charCodeAt(r),o>96&&o<123&&(o-=32),!(o<65||o>91));++r)n=26*n+(o-64);for(t.colStart=--n,n=0;r<i;++r){let a=s.charCodeAt(r)-48;if(a<0||a>9)break;n=10*n+a}if(t.rowStart=--n,r===i||s.charCodeAt(++r)===58)return t.colEnd=t.colStart,t.rowEnd=t.rowStart,t;for(n=0;r!==i&&(o=s.charCodeAt(r),o>96&&o<123&&(o-=32),!(o<65||o>91));++r)n=26*n+(o-64);for(t.colEnd=--n,n=0;r!==i;++r){let a=s.charCodeAt(r)-48;if(a<0||a>9)break;n=10*n+a}return t.rowEnd=--n,t},Pm=(s,e=!1)=>{const t=s.match(e?j_:z_);return s.endsWith(":")?null:t},Hl={rowIndex:-1,colIndex:-1,$colIndex:!1,$rowIndex:!1},Ha=(s,e,t,n=km)=>{let r=s.lastIndexOf("!"),o="";r!==-1&&(o=s.slice(0,r)+"!",s=s.slice(r+1));let i=null;const a=()=>{let c="";const h=i.rowIndex;if(h!==-1)if(i.$rowIndex)c+=`R${h+1}`;else{const g=h-e;c+=g===0?"R":`R[${g}]`}let u="";const d=i.colIndex;if(d!==-1)if(i.$colIndex)u+=`C${d+1}`;else{const g=d-t;u+=g===0?"C":`C[${g}]`}o+=c+u};r=s.lastIndexOf(":");const l=r!==-1;if(l){const c=s.slice(0,r);s=s.slice(r+1),i=Wl(c,Hl),i.colIndex!==-1&&i.rowIndex!==-1&&(a(),o+=":")}return i=Wl(s,Hl),!l&&i.colIndex>n?s:(a(),o)},Dr=[],J_=s=>(Dr.push(s),String.fromCharCode(57344+Dr.length-1)),X_=s=>{const e=s.charCodeAt(0)-57344;return Dr[e]},K_=(s,e,t)=>{let n="";const r=s.length;for(let o=0;o<r;o++){const i=s[o];n+=typeof i=="string"?i:zm(i,e,t)}return n},ci=(s,e)=>{let t="";const n=s.rowIndex;n!==Number.MIN_SAFE_INTEGER&&(s.$rowIndex?t+=`R${n+1}`:t+=n===0?"R":`R[${n+1}]`);let r="";const o=s.colIndex;return o!==Number.MIN_SAFE_INTEGER&&(s.$colIndex?r+=`C${o+1}`:r+=o===0?"C":`C[${o+1}]`),s.sheetName&&(t=pc(s.sheetName,e)+"!"+t),t+r},zm=(s,e,t)=>{let n="";const r=s.colIndex;r!==Number.MIN_SAFE_INTEGER&&(s.$colIndex?n+="$"+Pt(r):n+=Pt(r+t));const o=s.rowIndex;return o!==Number.MIN_SAFE_INTEGER&&(s.$rowIndex?n+="$"+$t(o):n+=$t(o+e)),n},Y_=(s,e,t,n)=>{Dr.length=0;let r=0,o=s.replace($_,J_),i=0,a=o.replace(H_,(l,c,h)=>{const u=Ha(l,e,t);if(n){if(h>i){const g=o.slice(i,h).replace(za,(m,f)=>Dr[r++]);n.push(g)}const d=l.lastIndexOf(":");if(d!==-1){const g=l.slice(0,d),m=l.slice(d+1),f=Ha(g,e,t),_=Ha(m,e,t);n.push(li(f,!0)??f),n.push(":"),n.push(li(_,!0)??_)}else n.push(li(u,!0)??u)}return i=h+l.length,u});if(n&&i<o.length){const l=o.slice(i);n.push(l.replace(za,(c,h)=>Dr[r++]))}return a=a.toUpperCase().replace(V_,""),a.replace(za,X_)},Lr="Must specify an address.",jm="Only a single range is allowed for this operation. Use 'getRanges' instead.",Wm="Invalid range. The Range must be specified as '{ TOP_LEFT:BOTTOM_RIGHT }'.",Go=s=>`Invalid address. Can not parse ${typeof s=="string"?`'${s}' `:""}as an address or named item.`,_e=()=>{throw new Error("Invalid range.")};class er{constructor(e,t,n=!1){this._c=e,this._cycleId=t,this._e=n}getCycleId(){return this._cycleId}getError(){return this._e}getCoords(){return this._c}setError(e,t){const n=this._c;return{...n,value:new er(n,t,e)}}getShifted(e){const t=e.after;if(!t)return null;const n=k.sanitizeRange(t);return{...n,value:new er(n,this._cycleId,this._e)}}getMerged(e,t,n){}getSplit(e,t){}}class Vt{constructor(e,t){this._c=e,this._o=t}getCoords(){return this._c}getOrientation(){return this._o}getShifted(e){return e.after?{...e.after,value:new Vt(e.after,this._o)}:null}getMerged(e,t,n){const r=this._o;return new Vt(t,r)}getSplit(e,t){const n=this._o;return[new Vt(e[0],n),new Vt(e[1],n)]}getState(){return this._c}}const Fu=(s,e)=>{if(!s||s.length===0)return F.EmptyArray;const t=[],n=e?exports.w.Orientation.Column:exports.w.Orientation.Row;for(let r=0;r<s.length;r++){const o=s[r],i=o[0],a=o[1];for(let l=0;l<a.length;l++){const c=a[l],h=c[0],u=c[1].length-1,d={colStart:e?i:h,rowStart:e?h:i,colEnd:e?i:h+u,rowEnd:e?h+u:i,value:new Vt({colStart:e?i:h,rowStart:e?h:i,colEnd:e?i:h+u,rowEnd:e?h+u:i},n)};t.push(d)}}return t},Vl=0,Nu=1;class un{constructor(e,t,n){this.ref=e,this.formula=t;const r=e.colStart,o=e.rowStart;if(n){const i=n,a=i.length;for(let l=0;l<a;l++){const c=[...i[l]];i[l]=c;const h=c.length;for(let u=0;u<h;u++){const d={...c[u]};c[u]=d,d.colIndex=u+r,d.rowIndex=l+o,d.block=this}}this.calcs=i}else{const i=t.getDirectPrecedentsAt(o,r),a=i?.length??0,l=new Array(e.rowEnd-o+1),c=e.colEnd-r+1,h=l.length;for(let u=0;u<h;u++){const d=new Array(c),g=d.length;for(let m=0;m<g;m++)d[m]={block:this,colIndex:m+r,rowIndex:u+o,cycleId:0,markId:0,inDegree:0,dependents:F.EmptyArray,inputs:a===0?F.EmptyArray:new Array(a),precedents:a===0?F.EmptyArray:new Array(a),dynamic:null,cachedValue:void 0,removed:!1,pending:!1,pendingPrecedents:!1,pendingPromise:null,pendingResolved:!1,state:Vl,error:void 0};l[u]=d}this.calcs=l}}toJSON(){const e=this.ref;return[bn(e),this.formula.getTextAt(e.rowStart,e.colStart)]}getCoords(){return this.ref}getShifted(e){if(!e.after)return null;const t=k.sanitizeRange(e.after),n=[...this.calcs],r=new un(t,this.formula,n);return{...e.after,value:r}}setReferenceAt(e,t){const n=this.formula.setReferenceAt(e,t),r=[...this.calcs];return new un(this.ref,n,r)}getMerged(e,t,n){const r=this.formula,o=e.formula;if(!r.isEquals(o))return;const i=this.calcs,a=e.calcs;let l;if(n===exports.w.Orientation.Row)l=[...i,...a];else{const c=i.length;l=new Array(c);for(let h=0;h<c;h++)l[h]=[...i[h],...a[h]]}return new un(t,r,l)}getSplit(e,t,n){const r=this.formula,o=t===exports.w.Orientation.Column;let i,a;const l=this.calcs;if(o){const c=l.length;i=new Array(c),a=new Array(c);for(let h=0;h<c;h++){const u=l[h];i[h]=u.slice(0,n),a[h]=u.slice(n)}}else i=l.slice(0,n),a=l.slice(n);return[new un(e[0],r,i),new un(e[1],r,a)]}copyTo(e,t){const n=this.formula;return new un(e,n)}canTile(e,t){return!0}onRemove(e){const t=e.value.calcs,n=t.length;for(let r=0;r<n;r++){const o=t[r],i=o.length;for(let a=0;a<i;a++){const l=o[a];l.pendingPromise&&(l.pendingPromise.cancelled=!0),l.removed=!0}}}}const ku=Object.freeze({break:!0});var Q;(Q||(Q={})).Type={Style:"style",Table:"table",Merge:"merge",Hyperlink:"hyperlink",Comments:"comments",Unlock:"unlock",Contentful:"contentful",Conditional:"conditional",Formula:"formula",Spill:"spill",Continuous:"continuous",Pending:"pending",CalcError:"calcError"};const Q_=Object.freeze({[Q.Type.Style]:!1,[Q.Type.Table]:!1,[Q.Type.Merge]:!1,[Q.Type.Hyperlink]:!1,[Q.Type.Comments]:!1,[Q.Type.Unlock]:!1,[Q.Type.Formula]:!1,[Q.Type.Spill]:!1,[Q.Type.Pending]:!1,[Q.Type.CalcError]:!1,[Q.Type.Contentful]:!1,[Q.Type.Conditional]:!1,[Q.Type.Continuous]:!1}),Hm=Object.freeze({[Q.Type.Style]:!1,[Q.Type.Table]:!1,[Q.Type.Merge]:!1,[Q.Type.Hyperlink]:!1,[Q.Type.Comments]:!1,[Q.Type.Unlock]:!1,[Q.Type.Formula]:!1,[Q.Type.Spill]:!1,[Q.Type.Pending]:!1,[Q.Type.CalcError]:!1,[Q.Type.Conditional]:!1,[Q.Type.Continuous]:!1}),Z_=Object.freeze({[Q.Type.Style]:!1,[Q.Type.Table]:!0,[Q.Type.Merge]:!1,[Q.Type.Hyperlink]:!1,[Q.Type.Comments]:!1,[Q.Type.Unlock]:!1,[Q.Type.Formula]:!1}),eS=Object.freeze({[Q.Type.Style]:!1,[Q.Type.Table]:!1,[Q.Type.Hyperlink]:!1,[Q.Type.Comments]:!1,[Q.Type.Unlock]:!1,[Q.Type.Contentful]:!1,[Q.Type.Formula]:!1}),Cs="This sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.",tS=(s="update")=>`Unable to ${s}, this sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,Mi="The range is outside of the bounds of the sheet.",Ou="Listener can not be null",Bu="We can't insert items. The sheet is protected.",Du=s=>`We can't create a ${s} that overlaps with another table or merge.`,Lu="Overlapping ranges can not be merged.",Va="We can't insert cells because this would push values off the end of the worksheet. These cells may appear empty but they have some formatting or formulas. Delete enough rows or columns and try again.",Pu="Unable to partially fill over merged cells.",zu="Unable to sort merged cells unless they are all the same size.",St="Sheet has been closed. No further operations are allowed.",Pr="IteratorContext can only be used during visit.",ju="When using addresses directly from the sheet do not include the sheet name.",Vm=s=>`Unable to return more than ${s} values. To access values in a more scalable solution use 'ICellRange.forEach' or an iterator.`,Wu="Multiple selection ranges can not be copied.",Hu="Unable to determine source.",Vu="When pasting before or after the cut area both areas must align.",br=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$u=new Set,$l=typeof process=="object"&&process?process:{},$m=(s,e,t,n)=>{typeof $l.emitWarning=="function"?$l.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`)};let Ti=globalThis.AbortController,Gu=globalThis.AbortSignal;if(Ti===void 0){Gu=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,n){this._onabort.push(n)}},Ti=class{constructor(){e()}signal=new Gu;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const n of this.signal._onabort)n(t);this.signal.onabort?.(t)}}};let s=$l.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1";const e=()=>{s&&(s=!1,$m("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const Nn=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Gm=s=>Nn(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?hi:null:null;class hi extends Array{constructor(e){super(e),this.fill(0)}}class Nr{heap;length;static#l=!1;static create(e){const t=Gm(e);if(!t)return[];Nr.#l=!0;const n=new Nr(e,t);return Nr.#l=!1,n}constructor(e,t){if(!Nr.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class wc{#l;#u;#f;#R;#p;#F;#N;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#_;#r;#n;#e;#c;#d;#a;#s;#S;#i;#w;#y;#g;#C;#I;#h;#k;static unsafeExposeInternals(e){return{starts:e.#y,ttls:e.#g,sizes:e.#w,keyMap:e.#r,keyList:e.#n,valList:e.#e,next:e.#c,prev:e.#d,get head(){return e.#a},get tail(){return e.#s},free:e.#S,isBackgroundFetch:t=>e.#t(t),backgroundFetch:(t,n,r,o)=>e.#D(t,n,r,o),moveToTail:t=>e.#T(t),indexes:t=>e.#b(t),rindexes:t=>e.#E(t),isStale:t=>e.#m(t)}}get max(){return this.#l}get maxSize(){return this.#u}get calculatedSize(){return this.#_}get size(){return this.#o}get fetchMethod(){return this.#F}get memoMethod(){return this.#N}get dispose(){return this.#f}get onInsert(){return this.#R}get disposeAfter(){return this.#p}constructor(e){const{max:t=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:l,dispose:c,onInsert:h,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:g,maxSize:m=0,maxEntrySize:f=0,sizeCalculation:_,fetchMethod:p,memoMethod:S,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:w,ignoreFetchAbort:E}=e;if(t!==0&&!Nn(t))throw new TypeError("max option must be a nonnegative integer");const x=t?Gm(t):Array;if(!x)throw new Error("invalid max value: "+t);if(this.#l=t,this.#u=m,this.maxEntrySize=f||this.#u,this.sizeCalculation=_,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#N=S,p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#F=p,this.#I=!!p,this.#r=new Map,this.#n=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#c=new x(t),this.#d=new x(t),this.#a=0,this.#s=0,this.#S=Nr.create(t),this.#o=0,this.#_=0,typeof c=="function"&&(this.#f=c),typeof h=="function"&&(this.#R=h),typeof u=="function"?(this.#p=u,this.#i=[]):(this.#p=void 0,this.#i=void 0),this.#C=!!this.#f,this.#k=!!this.#R,this.#h=!!this.#p,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(this.#u!==0&&!Nn(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!Nn(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#V()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=Nn(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!Nn(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L()}if(this.#l===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#u){const I="LRU_CACHE_UNBOUNDED";(v=>!$u.has(v))(I)&&($u.add(I),$m("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",I,wc))}}getRemainingTTL(e){return this.#r.has(e)?1/0:0}#L(){const e=new hi(this.#l),t=new hi(this.#l);this.#g=e,this.#y=t,this.#P=(o,i,a=br.now())=>{if(t[o]=i!==0?a:0,e[o]=i,i!==0&&this.ttlAutopurge){const l=setTimeout(()=>{this.#m(o)&&this.#v(this.#n[o],"expire")},i+1);l.unref&&l.unref()}},this.#A=o=>{t[o]=e[o]!==0?br.now():0},this.#x=(o,i)=>{if(e[i]){const a=e[i],l=t[i];if(!a||!l)return;o.ttl=a,o.start=l,o.now=n||r();const c=o.now-l;o.remainingTTL=a-c}};let n=0;const r=()=>{const o=br.now();if(this.ttlResolution>0){n=o;const i=setTimeout(()=>n=0,this.ttlResolution);i.unref&&i.unref()}return o};this.getRemainingTTL=o=>{const i=this.#r.get(o);if(i===void 0)return 0;const a=e[i],l=t[i];return!a||!l?1/0:a-((n||r())-l)},this.#m=o=>{const i=t[o],a=e[o];return!!a&&!!i&&(n||r())-i>a}}#A=()=>{};#x=()=>{};#P=()=>{};#m=()=>!1;#V(){const e=new hi(this.#l);this.#_=0,this.#w=e,this.#M=t=>{this.#_-=e[t],e[t]=0},this.#z=(t,n,r,o)=>{if(this.#t(n))return 0;if(!Nn(r)){if(!o)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(n,t),!Nn(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#O=(t,n,r)=>{if(e[t]=n,this.#u){const o=this.#u-e[t];for(;this.#_>o;)this.#B(!0)}this.#_+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#_)}}#M=e=>{};#O=(e,t,n)=>{};#z=(e,t,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#b({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#s;this.#j(t)&&(!e&&this.#m(t)||(yield t),t!==this.#a);)t=this.#d[t]}*#E({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#a;this.#j(t)&&(!e&&this.#m(t)||(yield t),t!==this.#s);)t=this.#c[t]}#j(e){return e!==void 0&&this.#r.get(this.#n[e])===e}*entries(){for(const e of this.#b())this.#e[e]===void 0||this.#n[e]===void 0||this.#t(this.#e[e])||(yield[this.#n[e],this.#e[e]])}*rentries(){for(const e of this.#E())this.#e[e]===void 0||this.#n[e]===void 0||this.#t(this.#e[e])||(yield[this.#n[e],this.#e[e]])}*keys(){for(const e of this.#b()){const t=this.#n[e];t===void 0||this.#t(this.#e[e])||(yield t)}}*rkeys(){for(const e of this.#E()){const t=this.#n[e];t===void 0||this.#t(this.#e[e])||(yield t)}}*values(){for(const e of this.#b())this.#e[e]===void 0||this.#t(this.#e[e])||(yield this.#e[e])}*rvalues(){for(const e of this.#E())this.#e[e]===void 0||this.#t(this.#e[e])||(yield this.#e[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#b()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,this.#n[n],this))return this.get(this.#n[n],t)}}forEach(e,t=this){for(const n of this.#b()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,this.#n[n],this)}}rforEach(e,t=this){for(const n of this.#E()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,this.#n[n],this)}}purgeStale(){let e=!1;for(const t of this.#E({allowStale:!0}))this.#m(t)&&(this.#v(this.#n[t],"expire"),e=!0);return e}info(e){const t=this.#r.get(e);if(t===void 0)return;const n=this.#e[t],r=this.#t(n)?n.__staleWhileFetching:n;if(r===void 0)return;const o={value:r};if(this.#g&&this.#y){const i=this.#g[t],a=this.#y[t];if(i&&a){const l=i-(br.now()-a);o.ttl=l,o.start=Date.now()}}return this.#w&&(o.size=this.#w[t]),o}dump(){const e=[];for(const t of this.#b({allowStale:!0})){const n=this.#n[t],r=this.#e[t],o=this.#t(r)?r.__staleWhileFetching:r;if(o===void 0||n===void 0)continue;const i={value:o};if(this.#g&&this.#y){i.ttl=this.#g[t];const a=br.now()-this.#y[t];i.start=Math.floor(Date.now()-a)}this.#w&&(i.size=this.#w[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const r=Date.now()-n.start;n.start=br.now()-r}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const h=this.#z(e,t,n.size||0,a);if(this.maxEntrySize&&h>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#v(e,"set"),this;let u=this.#o===0?void 0:this.#r.get(e);if(u===void 0)u=this.#o===0?this.#s:this.#S.length!==0?this.#S.pop():this.#o===this.#l?this.#B(!1):this.#o,this.#n[u]=e,this.#e[u]=t,this.#r.set(e,u),this.#c[this.#s]=u,this.#d[u]=this.#s,this.#s=u,this.#o++,this.#O(u,h,l),l&&(l.set="add"),c=!1,this.#k&&this.#R?.(t,e,"add");else{this.#T(u);const d=this.#e[u];if(t!==d){if(this.#I&&this.#t(d)){d.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:g}=d;g===void 0||i||(this.#C&&this.#f?.(g,e,"set"),this.#h&&this.#i?.push([g,e,"set"]))}else i||(this.#C&&this.#f?.(d,e,"set"),this.#h&&this.#i?.push([d,e,"set"]));if(this.#M(u),this.#O(u,h,l),this.#e[u]=t,l){l.set="replace";const g=d&&this.#t(d)?d.__staleWhileFetching:d;g!==void 0&&(l.oldValue=g)}}else l&&(l.set="update");this.#k&&this.onInsert?.(t,e,t===d?"update":"replace")}if(r===0||this.#g||this.#L(),this.#g&&(c||this.#P(u,r,o),l&&this.#x(l,u)),!i&&this.#h&&this.#i){const d=this.#i;let g;for(;g=d?.shift();)this.#p?.(...g)}return this}pop(){try{for(;this.#o;){const e=this.#e[this.#a];if(this.#B(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#h&&this.#i){const e=this.#i;let t;for(;t=e?.shift();)this.#p?.(...t)}}}#B(e){const t=this.#a,n=this.#n[t],r=this.#e[t];return this.#I&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#C||this.#h)&&(this.#C&&this.#f?.(r,n,"evict"),this.#h&&this.#i?.push([r,n,"evict"])),this.#M(t),e&&(this.#n[t]=void 0,this.#e[t]=void 0,this.#S.push(t)),this.#o===1?(this.#a=this.#s=0,this.#S.length=0):this.#a=this.#c[t],this.#r.delete(n),this.#o--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,o=this.#r.get(e);if(o!==void 0){const i=this.#e[o];if(this.#t(i)&&i.__staleWhileFetching===void 0)return!1;if(!this.#m(o))return n&&this.#A(o),r&&(r.has="hit",this.#x(r,o)),!0;r&&(r.has="stale",this.#x(r,o))}else r&&(r.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,r=this.#r.get(e);if(r===void 0||!n&&this.#m(r))return;const o=this.#e[r];return this.#t(o)?o.__staleWhileFetching:o}#D(e,t,n,r){const o=t===void 0?void 0:this.#e[t];if(this.#t(o))return o;const i=new Ti,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});const l={signal:i.signal,options:n,context:r},c=(g,m=!1)=>{const{aborted:f}=i.signal,_=n.ignoreFetchAbort&&g!==void 0;if(n.status&&(f&&!m?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),f&&!_&&!m)return h(i.signal.reason);const p=u;return this.#e[t]===u&&(g===void 0?p.__staleWhileFetching?this.#e[t]=p.__staleWhileFetching:this.#v(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,g,l.options))),g},h=g=>{const{aborted:m}=i.signal,f=m&&n.allowStaleOnFetchAbort,_=f||n.allowStaleOnFetchRejection,p=_||n.noDeleteOnFetchRejection,S=u;if(this.#e[t]===u&&(!p||S.__staleWhileFetching===void 0?this.#v(e,"fetch"):f||(this.#e[t]=S.__staleWhileFetching)),_)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw g};n.status&&(n.status.fetchDispatched=!0);const u=new Promise((g,m)=>{const f=this.#F?.(e,o,l);f&&f instanceof Promise&&f.then(_=>g(_===void 0?void 0:_),m),i.signal.addEventListener("abort",()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(g(void 0),n.allowStaleOnFetchAbort&&(g=_=>c(_,!0)))})}).then(c,g=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=g),h(g))),d=Object.assign(u,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,d,{...l.options,status:void 0}),t=this.#r.get(e)):this.#e[t]=d,d}#t(e){if(!this.#I)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ti}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:f,forceRefresh:_=!1,status:p,signal:S}=t;if(!this.#I)return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});const C={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:g,status:p,signal:S};let y=this.#r.get(e);if(y===void 0){p&&(p.fetch="miss");const b=this.#D(e,y,C,f);return b.__returned=b}{const b=this.#e[y];if(this.#t(b)){const I=n&&b.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",I&&(p.returnedStale=!0)),I?b.__staleWhileFetching:b.__returned=b}const w=this.#m(y);if(!_&&!w)return p&&(p.fetch="hit"),this.#T(y),r&&this.#A(y),p&&this.#x(p,y),b;const E=this.#D(e,y,C,f),x=E.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=w?"stale":"refresh",x&&w&&(p.returnedStale=!0)),x?E.__staleWhileFetching:E.__returned=E}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#N;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...i}=t,a=this.get(e,i);if(!o&&a!==void 0)return a;const l=n(e,a,{options:i,context:r});return this.set(e,l,i),l}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=t,a=this.#r.get(e);if(a!==void 0){const l=this.#e[a],c=this.#t(l);return i&&this.#x(i,a),this.#m(a)?(i&&(i.get="stale"),c?(i&&n&&l.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?l.__staleWhileFetching:void 0):(o||this.#v(e,"expire"),i&&n&&(i.returnedStale=!0),n?l:void 0)):(i&&(i.get="hit"),c?l.__staleWhileFetching:(this.#T(a),r&&this.#A(a),l))}i&&(i.get="miss")}#W(e,t){this.#d[t]=e,this.#c[e]=t}#T(e){e!==this.#s&&(e===this.#a?this.#a=this.#c[e]:this.#W(this.#d[e],this.#c[e]),this.#W(this.#s,e),this.#s=e)}delete(e){return this.#v(e,"delete")}#v(e,t){let n=!1;if(this.#o!==0){const r=this.#r.get(e);if(r!==void 0)if(n=!0,this.#o===1)this.#H(t);else{this.#M(r);const o=this.#e[r];if(this.#t(o)?o.__abortController.abort(new Error("deleted")):(this.#C||this.#h)&&(this.#C&&this.#f?.(o,e,t),this.#h&&this.#i?.push([o,e,t])),this.#r.delete(e),this.#n[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#d[r];else if(r===this.#a)this.#a=this.#c[r];else{const i=this.#d[r];this.#c[i]=this.#c[r];const a=this.#c[r];this.#d[a]=this.#d[r]}this.#o--,this.#S.push(r)}}if(this.#h&&this.#i?.length){const r=this.#i;let o;for(;o=r?.shift();)this.#p?.(...o)}return n}clear(){return this.#H("delete")}#H(e){for(const t of this.#E({allowStale:!0})){const n=this.#e[t];if(this.#t(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#n[t];this.#C&&this.#f?.(n,r,e),this.#h&&this.#i?.push([n,r,e])}}if(this.#r.clear(),this.#e.fill(void 0),this.#n.fill(void 0),this.#g&&this.#y&&(this.#g.fill(0),this.#y.fill(0)),this.#w&&this.#w.fill(0),this.#a=0,this.#s=0,this.#S.length=0,this.#_=0,this.#o=0,this.#h&&this.#i){const t=this.#i;let n;for(;n=t?.shift();)this.#p?.(...n)}}}var Uu;exports.ICell=void 0,(Uu=exports.ICell||(exports.ICell={})).CalcStatus={Ready:"ready",Stale:"stale",Pending:"pending",Streaming:"streaming"},Uu.Content={Values:"values",Formats:"formats",Formulas:"formula",Hyperlinks:"hyperlinks",Tables:"tables",Notes:"notes",Comments:"comments",Warnings:"warnings",Errors:"errors",Merges:"merges"};class nS{constructor(e,t,n){if(!n)throw new Dt;if(typeof n=="string"&&(n={address:n}),typeof n.address!="string")throw new Error("Invalid hyperlink");this._t=e,this._r=t,this._p=n}open(e,t){return this._r(this.getAddress(),null,e??this.getTarget(),t)}getTarget(){let e=this._p.target;return e||(this._p.address.startsWith("#")?"_self":"_blank")}getDisplayText(){return this._t()??this.getAddress()}getAddress(){return this._p.address??""}getTooltip(){return this._p.tooltip??null}get isIHyperlink(){return!0}}function qu(s){return!/^(-?\d|--)/.test(s)}function Ju(s){const e=[];let t="",n="",r=7;for(let o,i=0;o=s.charAt(i);i++)if(/[a-zA-Z\d\xa0-\uffff_-]/.test(o)&&r===7)t+=o;else if(o==="\\"&&r===7)r=6;else if(o===" "&&r===7){if(t!==""){if(!qu(t))return null;e.push(t),t=""}}else if(r===6)/[0-9a-f]/i.test(o)?(n+=o,r=8):(t+=o,r=7);else{if(r!==8)return null;/[0-9a-f]/i.test(o)&&n.length<6?n+=o:(t+=String.fromCodePoint(parseInt(n,16)),t+=o,n="",r=7)}if(t!==""){if(!qu(t))return null;e.push(t)}return e.join(" ")}function Xu(s,e){let t=e,n="";const r={"font-family":[]};for(let o,i=0;o=s.charAt(i);i+=1)if(t!==4||o!=='"'&&o!=="'")if(t===3&&o===",")t=4,n="";else if(t===4&&o===","){const a=Ju(n);a&&r["font-family"].push(a),n=""}else if(t===5&&o===" ")/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:deg|grad|rad|turn)$/.test(n)?(r["font-style"]+=" "+n,n=""):i-=1,t=1;else if(t!==1||o!==" "&&o!=="/")t===2&&o===" "?(/^(?:\+|-)?([0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)?$/.test(n)&&(r["line-height"]=n),t=4,n=""):n+=o;else{if(/^(?:(?:xx|x)-large|(?:xx|s)-small|small|large|medium)$/.test(n)||/^(?:larg|small)er$/.test(n)||/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)$/.test(n))t=o==="/"?2:4,r["font-size"]=n;else if(/^italic$/.test(n))r["font-style"]=n;else if(/^oblique$/.test(n))r["font-style"]=n,t=5;else if(/^small-caps$/.test(n))r["font-variant"]=n;else if(/^(?:bold(?:er)?|lighter|normal)$/.test(n))r["font-weight"]=n;else if(/^[+-]?(?:[0-9]*\.)?[0-9]+(?:e[+-]?(?:0|[1-9][0-9]*))?$/.test(n)){const a=parseFloat(n);a>=1&&a<=1e3&&(r["font-weight"]=n)}else/^(?:(?:ultra|extra|semi)-)?(?:condensed|expanded)$/.test(n)&&(r["font-stretch"]=n);n=""}else{let a=i+1;do if(a=s.indexOf(o,a)+1,!a)return null;while(s.charAt(a-2)==="\\");r["font-family"].push(s.slice(i+1,a-1).replace(/\\('|")/g,"$1")),i=a-1,t=3,n=""}if(t===3&&!/^\s*$/.test(n))return null;if(t===4){const o=Ju(n);o&&r["font-family"].push(o)}return r}const ui=s=>{if(typeof s!="string")return null;let e=function(o){const i=Xu(o,4);return i!==null?i["font-family"]:null}(s);Array.isArray(e)&&e.length===0&&(e=null),e=e?{"font-family":e}:function(o){const i=Xu(o,1);return i!==null&&i["font-size"]&&i["font-family"].length?i:null}(s);let t=null,n=null,r=null;if(e){let o=e["font-family"];const i=o.shift();i&&(t=i),o.length>0&&(n=o),e["font-size"]!==void 0&&(r=e["font-size"])}return{family:t,fallbacks:n,size:r}},Yt=(s,e=!1)=>s?.toHex(e)?.toString(!1).toLowerCase()??null,Ku=s=>s==null?null:F.roundAccurately(s,2)+"pt",Um=(s,e)=>{let t="";const n=s&&s!==exports.IFont.UnderlineStyle.None;return e&&(t+="line-through"),n&&e&&(t+=" "),n&&(t+="underline",s!==!0&&s!==exports.IFont.UnderlineStyle.Single&&s!==exports.IFont.UnderlineStyle.SingleAccounting||(t+=" solid"),s!==exports.IFont.UnderlineStyle.Double&&s!==exports.IFont.UnderlineStyle.DoubleAccounting||(t+=" double")),t},rS=Object.freeze({underline:exports.IFont.UnderlineStyle.None,strike:!1}),qm=s=>s?(s=s.toLowerCase())==="single"?exports.IFont.UnderlineStyle.Single:s==="double"?exports.IFont.UnderlineStyle.Double:s==="single-accounting"||s==="singleaccounting"?exports.IFont.UnderlineStyle.SingleAccounting:s==="double-accounting"||s==="doubleaccounting"?exports.IFont.UnderlineStyle.DoubleAccounting:exports.IFont.UnderlineStyle.None:exports.IFont.UnderlineStyle.None,Yu=s=>s?s.toLowerCase():null,Qu=s=>s?s===exports.ITextFrame.Overflow.Visible||s===exports.ITextFrame.Overflow.Clip||s===exports.ITextFrame.Overflow.Shrink?"nowrap":s===exports.ITextFrame.Overflow.Wrap?"normal":void 0:null,Fi=(s,e)=>{let t="";if(s&&(s.includes(" ")&&(s='"'+s+'"'),t=s),e)for(let n=0;n<e.length;n++)t.length>0&&(t+=", "),t+=e[n];return t},Zu=s=>{let e="",t=!1,n="";for(let r=0;r<s.length;r++){const o=s.charAt(r);t&&o!=="]"&&o!=='"'?e+=o:o==='"'?(e+="\\0022",t=!t):["[","]",",","#",".","@","/",":",";","-"," "].includes(o)?(e+="\\"+o,o==="["?t=!0:o==="]"&&(t=!1)):["(",")"].includes(o)?e+=n==="_"?"\\"+o:"\\\\\\"+o:["$"].includes(o)?e+="\\0022"+o+"\\0022":e+=o,n=o}return'"'+e+'"'},oS="Thin",sS="Hairline",iS="Extra Light",aS="Ultra Light",lS="Light",ed="Normal",cS="Regular",hS="Medium",uS="Semi Bold",dS="Demi Bold",gS="Bold",mS="Extra Bold",fS="Ultra Bold",pS="Black",_S="Heavy",SS="Extra Black",wS="Ultra Black",yS="lighter",CS="normal",bS="bold",ES="bolder",We=new Map;We.set(F.textToKey(oS),100),We.set(F.textToKey(sS),100),We.set(F.textToKey(iS),200),We.set(F.textToKey(aS),200),We.set(F.textToKey(lS),300),We.set(F.textToKey(ed),400),We.set(F.textToKey(cS),400),We.set(F.textToKey(hS),500),We.set(F.textToKey(uS),600),We.set(F.textToKey(dS),600),We.set(F.textToKey(ed),400),We.set(F.textToKey(gS),700),We.set(F.textToKey(mS),800),We.set(F.textToKey(fS),800),We.set(F.textToKey(pS),900),We.set(F.textToKey(_S),900),We.set(F.textToKey(SS),950),We.set(F.textToKey(wS),950),We.set(F.textToKey(yS),100),We.set(F.textToKey(CS),400),We.set(F.textToKey(bS),700),We.set(F.textToKey(ES),700);const vS="xx-small",xS="x-small",IS="small",RS="medium",AS="large",MS="x-large",TS="xx-large",FS="xxx-large",NS="smaller",kS="larger",OS="math",BS=new RegExp("^[0-9]*[.]?[0-9]+$","g"),At=new Map;At.set(F.textToKey(vS),s=>.4*s),At.set(F.textToKey(xS),s=>.5*s),At.set(F.textToKey(IS),s=>.6*s),At.set(F.textToKey(RS),s=>s),At.set(F.textToKey(AS),s=>1.1*s),At.set(F.textToKey(MS),s=>1.25*s),At.set(F.textToKey(TS),s=>1.5*s),At.set(F.textToKey(FS),s=>2*s),At.set(F.textToKey(NS),s=>.9*s),At.set(F.textToKey(kS),s=>1.1*s),At.set(F.textToKey(OS),s=>s);const zr=(s,e=11,t="pt")=>{if(!s)return null;let n=e;s=s.trim().toLowerCase();const r=t==="pt"?exports.IFont.getDeviceScale():1,o=t==="pt"?1:exports.IFont.getDeviceScale();if(BS.test(s)){const i=parseFloat(s);isNaN(i)||(s=i+t)}if(s.endsWith("pt"))n=parseFloat(s.substring(0,s.length-2).trim())*o;else if(s.endsWith("px"))n=parseFloat(s.substring(0,s.length-2).trim())/r;else if(s.endsWith("em"))n=parseFloat(s.substring(0,s.length-2).trim())*e;else if(s.endsWith("rem"))n=parseFloat(s.substring(0,s.length-3).trim())*e;else if(s.endsWith("%"))n=parseFloat(s.substring(0,s.length-1).trim())/100*e;else if(typeof s=="string"){const i=F.textToKey(s),a=At.get(i);if(a)return a(e)}return isNaN(n)?null:n},$e=new Map;$e.set(exports.IFill.BuiltInSheetPattern.None,{description:"None",cssKey:"none"}),$e.set(exports.IFill.BuiltInSheetPattern.Solid,{description:"Solid",cssKey:"solid"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkGray,{description:"75% gray",cssKey:"gray-75"}),$e.set(exports.IFill.BuiltInSheetPattern.MediumGray,{description:"50% gray",cssKey:"gray-50"}),$e.set(exports.IFill.BuiltInSheetPattern.LightGray,{description:"25% gray",cssKey:"gray-25"}),$e.set(exports.IFill.BuiltInSheetPattern.Gray125,{description:"12.5% Gray",cssKey:"gray-125"}),$e.set(exports.IFill.BuiltInSheetPattern.Gray0625,{description:"6.25% Gray",cssKey:"gray-0625"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkHorizontal,{description:"Horizontal Strip",cssKey:"horz-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkVertical,{description:"Vertical Strip",cssKey:"vert-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkDown,{description:"Reverse Diagonal Stripe",cssKey:"reverse-diag-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkUp,{description:"Diagonal Strip",cssKey:"diag-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkGrid,{description:"Diagonal Crosshatch",cssKey:"diag-cross"}),$e.set(exports.IFill.BuiltInSheetPattern.DarkTrellis,{description:"Thick Diagonal Crosshatch",cssKey:"thick-diag-cross"}),$e.set(exports.IFill.BuiltInSheetPattern.LightHorizontal,{description:"Thin Horizontal Stripe",cssKey:"thin-horz-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.LightVertical,{description:"Thin Vertical Stripe",cssKey:"thin-vert-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.LightDown,{description:"Thin Reverse Diagonal Stripe",cssKey:"thin-reverse-diag-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.LightUp,{description:"Thin Diagonal Stripe",cssKey:"thin-diag-stripe"}),$e.set(exports.IFill.BuiltInSheetPattern.LightGrid,{description:"Thin Horizontal Cross",cssKey:"thin-horz-cross"}),$e.set(exports.IFill.BuiltInSheetPattern.LightTrellis,{description:"Thin Diagonal Cross",cssKey:"thin-diag-cross"});let di="";const Jm=new Map;$e.forEach((s,e)=>{di.length>0&&(di+="|"),di+="\\b"+s.cssKey+"\\b",Jm.set(s.cssKey,e)});const DS=new RegExp(`(\\s*(?:${di}))`,"g"),LS=s=>{if(!s)return null;let e=s.toLowerCase();e=e.replace(/;/,"");let t=e.match(DS);if(!t)return null;let n=null;t&&t.length>0&&(n=(o=>{if(!o)return null;let i=e.indexOf(o);return e=e.substring(0,i)+e.substring(i+o.length,e.length),o.trim()})(t[0])),e=e.trim();const r=e?e.trim():null;return!n&&!r?null:{patternType:Jm.get(n??"solid"),foreground:r??null}},Xm=(s,e=!1,t=null)=>{if(!s||!s.getStops()||s.getStops().length<1)return null;if(s.getStops().length===1)return Yt(s.getStops()[0].getColor(),e);let n="";for(let o=0;o<s.getStops().length;o++){const i=s.getStops()[o];n+=Yt(i.getColor(),e)+" "+100*(i.getOffset()??o*(s.getStops().length-1))+"%",o<s.getStops().length-1&&(n+=", ")}let r=s.getAngle()??0;if(s.getGradientType()===exports.IFill.GradientType.Path){const o=Yt(s.getStops()[0]?.getColor(),e),i=Yt((s.getStops()[1]??s.getStops()[0])?.getColor(),e),a=s.getFillTo()??{left:0,top:0,right:0,bottom:0},l=-1;let c=`${100-l}% ${100-l}%`;if(r=315,a.left===1&&a.right===1&&a.right===1&&a.bottom===1)r=135,c=`${l}% ${l}%`;else if(a.top!==0&&a.bottom!==0&&a.left===0&&a.right===0)r=225,c=`${100-l}% ${l}%`;else if(a.left===1&&a.right!==0&&a.top===0&&a.bottom===0)r=45,c=`${l}% ${100-l}%`;else if(a.left!==0&&a.right!==0&&a.top!==0&&a.bottom!==0)return`radial-gradient(${n})`;const h=70;return`conic-gradient(from ${r}deg at ${c}, ${o} 0deg, ${i} ${h/2}deg,${i} ${360-h/2}deg, ${o} 360deg)`}return`linear-gradient(${r}deg, ${n})`},ct=new Map;ct.set(exports.IBorder.StrokeStyle.None,{size:null,cssKey:"none"}),ct.set(exports.IBorder.StrokeStyle.DashDot,{size:.5,cssKey:"dot-dash"}),ct.set(exports.IBorder.StrokeStyle.DashDotDot,{size:.5,cssKey:"dot-dot-dash"}),ct.set(exports.IBorder.StrokeStyle.Dashed,{size:.5,cssKey:"dashed"}),ct.set(exports.IBorder.StrokeStyle.MediumDashed,{size:1,cssKey:"dashed"}),ct.set(exports.IBorder.StrokeStyle.Dotted,{size:.5,cssKey:"dotted"}),ct.set(exports.IBorder.StrokeStyle.MediumDashDot,{size:1,cssKey:"dot-dash"}),ct.set(exports.IBorder.StrokeStyle.MediumDashDotDot,{size:1,cssKey:"dot-dot-dash"}),ct.set(exports.IBorder.StrokeStyle.Hair,{size:.5,cssKey:"hairline"}),ct.set(exports.IBorder.StrokeStyle.Thin,{size:.5,cssKey:"solid"}),ct.set(exports.IBorder.StrokeStyle.Thick,{size:1.5,cssKey:"solid"}),ct.set(exports.IBorder.StrokeStyle.Medium,{size:1,cssKey:"solid"}),ct.set(exports.IBorder.StrokeStyle.Double,{size:2,cssKey:"double"}),ct.set(exports.IBorder.StrokeStyle.SlantDashDot,{size:1,cssKey:"dot-dash-slanted"});const qn=s=>{if(!s)return"none";const e=ct.get(s.getStyle());if(!e)return null;if(e.cssKey==="none")return e.cssKey;let t=((n,r=!1)=>n?.toRGBA(r).toString(!1)??null)(s?.getColor());return t=t?" "+t:"",`${e.size!==null?`${e.size}pt `:""}${e.cssKey}${t}`};let Ni=[];const td=new Set,Gl=new Map,zo=(s,e)=>{let t=s.size!==null?`${s.size.toString()} ${s.cssKey}`:s.cssKey;Gl.set(t,e),td.has(s.cssKey)||(Ni.push(s.cssKey),td.add(s.cssKey))};ct.forEach(zo);const $a=Object.keys(exports.IBorder.StrokeStyle);for(let s=0;s<$a.length;s++)zo({size:null,cssKey:$a[s].toLowerCase()},exports.IBorder.StrokeStyle[$a[s]]);zo({size:null,cssKey:"double"},exports.IBorder.StrokeStyle.Double),zo({size:null,cssKey:"solid"},exports.IBorder.StrokeStyle.Medium),zo({size:null,cssKey:"hidden"},exports.IBorder.StrokeStyle.None),Ni.sort((s,e)=>e.length-s.length);let gi="";for(let s=0;s<Ni.length;s++)gi.length>0&&(gi+="|"),gi+="\\b"+Ni[s]+"\\b";const PS=new RegExp(`(\\s*(?:${gi}))`,"g"),zS=new RegExp("(\\s*[0-9]*[.]?[0-9]+(?:pt|px){0,1})","g"),Km=s=>{if(!s)return null;let e=s.toLowerCase(),t=e.match(PS);if(!t)return null;const n=c=>{if(!c)return null;let h=e.indexOf(c);return e=e.substring(0,h)+e.substring(h+c.length,e.length).trim(),c.trim()};let r=null;if(t&&t.length>0&&(r=n(t[0])),!r)return null;let o=null;if(t=e.match(zS),t&&t.length>0){let c=n(t[0]);o=parseFloat(c.substring(0,c.length-2))}e=e.trim();const i=e?e.trim():null;let a=o===null?r:`${o.toString()} ${r}`,l=Gl.get(a);return l||(l=Gl.get(r)),l?{color:i,style:l}:null},jS="start",WS="end",HS="left",VS="right",$S="center",GS="justify",US="justify-all",qS="baseline",JS="top",XS="middle",KS="bottom",YS="sub",QS="text-top",ZS="justify",ew="distributed",kn=new Map;kn.set(F.textToKey(jS),exports.ITextFrame.HorizontalAlignment.Left),kn.set(F.textToKey(HS),exports.ITextFrame.HorizontalAlignment.Left),kn.set(F.textToKey(WS),exports.ITextFrame.HorizontalAlignment.Right),kn.set(F.textToKey(VS),exports.ITextFrame.HorizontalAlignment.Right),kn.set(F.textToKey($S),exports.ITextFrame.HorizontalAlignment.Center),kn.set(F.textToKey(GS),exports.ITextFrame.HorizontalAlignment.Justify),kn.set(F.textToKey(US),exports.ITextFrame.HorizontalAlignment.Justify);const hn=new Map;hn.set(F.textToKey(qS),exports.ITextFrame.VerticalAlignment.Bottom),hn.set(F.textToKey(JS),exports.ITextFrame.VerticalAlignment.Top),hn.set(F.textToKey(XS),exports.ITextFrame.VerticalAlignment.Center),hn.set(F.textToKey(KS),exports.ITextFrame.VerticalAlignment.Bottom),hn.set(F.textToKey(YS),exports.ITextFrame.VerticalAlignment.Bottom),hn.set(F.textToKey(QS),exports.ITextFrame.VerticalAlignment.Top),hn.set(F.textToKey(ZS),exports.ITextFrame.VerticalAlignment.Justify),hn.set(F.textToKey(ew),exports.ITextFrame.VerticalAlignment.Distributed);const Ym=(s,e)=>{if(s instanceof Ue)return{color:s};if(typeof s=="string")try{return{color:s==="none"||s==="transparent"?null:e(s)}}catch(t){throw t}return s},Uo={shorthand:(s,e)=>{if(!s||s==="none"||s==="transparent")return null;try{return e.parseColor(s).toString()}catch(t){console.warn("error",t)}return s},merge:(s,e,t)=>s},Mn={shorthand:(s,e)=>{if(typeof s=="string"&&(s=Km(s)),!s)return null;const t={};return s.style&&(t.style=s.style),s.color&&(t.color=s.color),s.isIStroke?s.getProperties():t},properties:{color:Uo}},nd={shorthand:(s,e)=>s==="none"||s==="transparent"||typeof s=="object"&&Object.keys(s).length===0?{type:exports.IFill.Type.None}:(s.getType?.(),exports.IFill.Type.None,s)},rd={shorthand:(s,e)=>(typeof(s=Ym(s,e.parseColor.bind(e)))=="object"&&s.color&&(s.type=exports.IFill.Type.Solid),s),merge:(s,e,t)=>s.color?s:(e?.toJSON&&(e=e.toJSON()),e?.type===exports.IFill.Type.Solid?{...e}:e?.type===exports.IFill.Type.Gradient?{type:exports.IFill.Type.Solid,color:e?.stops?.[0]?.color??t.parseColor(exports.IColor.Scheme.Bg1)}:e?.type===exports.IFill.Type.Pattern?{type:exports.IFill.Type.Solid,color:e?.foreground??t.parseColor(exports.IColor.Scheme.Bg1)}:s?{...s}:null),properties:{color:Uo}},od={shorthand:(s,e)=>(typeof s=="object"&&s.stops&&(s.type=exports.IFill.Type.Gradient),s),merge:(s,e,t)=>s.stops?s:(e?.toJSON&&(e=e.toJSON()),e?.type===exports.IFill.Type.Gradient?{...e}:e?.type===exports.IFill.Type.Solid?{type:exports.IFill.Type.Gradient,stops:[{offset:0,color:e?.color??exports.IColor.Scheme.Accent1},{offset:1,color:exports.IColor.Scheme.Bg1}]}:e?.type===exports.IFill.Type.Pattern?{type:exports.IFill.Type.Gradient,stops:[{offset:0,color:e?.foreground??exports.IColor.Scheme.Bg1},{offset:1,color:e?.background??exports.IColor.Scheme.Accent1}]}:s?{...s}:null),properties:{stops:{shorthand:(s,e)=>s,arrayType:{shorthand:(s,e)=>s=Ym(s,e.parseColor.bind(e)),properties:{color:Uo}}}}},sd={shorthand:(s,e)=>{if(typeof s=="object"){const t=s;(t.foreground||t.background||t.patternType)&&(t.type=exports.IFill.Type.Pattern,t.patternType=t.patternType??exports.IFill.BuiltInSheetPattern.Solid)}return s},merge:(s,e,t)=>{if(s.background&&s.foreground)return s;e?.toJSON&&(e=e.toJSON());const n=exports.IFill.BuiltInSheetPattern.MediumGray;return e?.type===exports.IFill.Type.Pattern?{...e,...s}:e?.type===exports.IFill.Type.Solid?{patternType:n,...s,foreground:e?.color??exports.IColor.Named.WindowText,background:exports.IColor.Scheme.Bg1}:e?.type===exports.IFill.Type.Gradient?{patternType:n,...s,foreground:e?.stops?.[0]?.color??exports.IColor.Named.WindowText,background:e?.stops?.[1]?.color??exports.IColor.Scheme.Bg1}:s?{type:exports.IFill.Type.Pattern,patternType:exports.IFill.BuiltInSheetPattern.Solid,foreground:exports.IColor.Named.WindowText,background:exports.IColor.Scheme.Bg1,...s}:null},properties:{foreground:Uo,background:Uo}},He={properties:{font:{shorthand:(s,e)=>{if(typeof s=="string"){const t=ui(s);if(t){const n={};if(t.family&&(n.family=t.family),t.fallbacks&&(n.fallbacks=t.fallbacks),t.size&&(n.size=zr(t.size)),Object.keys(t).length>0)return n}}return s},properties:{family:{shorthand:(s,e)=>ui(s)?.family??null},fallbacks:{shorthand:(s,e)=>{if(typeof s!="string")return s;let t=ui(s);if(!t)return null;let n=[t.family];return t.fallbacks&&(n=n.concat(t.fallbacks)),n}},size:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=zr(s,e.getNormal().getFont().getSize())),isNaN(t)||typeof t!="number"?null:(t=Math.max(1,Math.min(F.roundAccurately(t,1),409)),t)}},weight:{shorthand:(s,e)=>{if(typeof s!="string")return s;const t=(n=>{let r=400;if(r=typeof n=="number"?n:parseFloat(n),!isNaN(r))return r;if(typeof n=="string"){const o=F.textToKey(n),i=We.get(o);if(i)return i}return r})(s);return isNaN(t)||typeof t!="number"?null:t}},underline:{shorthand:(s,e)=>s?s===!0?exports.IFont.UnderlineStyle.Single:qm(s):exports.IFont.UnderlineStyle.None}}},fill:{shorthand:(s,e)=>{const t=[nd,rd,od,sd];for(let n=0;n<t.length;n++){let r=t[n]?.shorthand?.(s,e);if(r?.type)return r}return s},getSubType:s=>s.type===exports.IFill.Type.None?nd:s.type===exports.IFill.Type.Solid?rd:s.type===exports.IFill.Type.Gradient?od:s.type===exports.IFill.Type.Pattern?sd:null},alignment:{properties:{indent:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=parseFloat(s)),isNaN(t)||typeof t!="number"?null:t}},rotation:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=parseFloat(s)),isNaN(t)||typeof t!="number"?null:(t%=360,t<0&&(t+=360),t)}}}},border:{shorthand:(s,e)=>{if(typeof s=="string"){const t=Km(s);return{left:t,right:t,top:t,bottom:t,horizontal:null,vertical:null,diagonalUp:null,diagonalDown:null}}return s.isIBorder?s.getProperties():s},properties:{top:Mn,left:Mn,right:Mn,bottom:Mn,horizontal:Mn,vertical:Mn,diagonalUp:Mn,diagonalDown:Mn}},numberFormat:{shorthand:(s,e)=>{if(typeof s=="string"){let t=exports.NumberFormat.Styles.lookupDefault(s);return t!==void 0?t:s}return typeof s=="number"?dc(s):null}}}},tw={properties:{style:He}},nw=Object.freeze({displayText:"",conditionalColor:null,repeatChars:F.EmptyArray,spacingChars:F.EmptyArray,repeatPlaceholder:null,formattedRuns:Object.freeze({runs:F.EmptyArray,length:0,width:0,lastRepeatIndex:-1}),canWrap:!1,asDate:null,isDateFormat:!1,isTimeFormat:!1,isDate1904:!1}),Qm=(s,e,t,n,r,o=!1)=>{if(s==null)return nw;let i="",a=null,l=null,c=null;if(t===U.Error)i=s.getLabel();else if(t===U.RichData)i="(Rich Object)";else if(t===U.Boolean)i=s?"TRUE":"FALSE";else if(n)try{i=sc(n,s,{date1904:o,spacingCharacter:"",digitCharacter:"",onRepeatChar:(E,x)=>{l||(l=[]),l.push({offset:E,char:x})},onSpacingChar:(E,x)=>{c||(c=[]),c.push({offset:E,char:x})},onDigitChar:E=>{c||(c=[]),c.push({offset:E,char:"0"})}})}catch{}const h=Zo(n),u=Wi(n),d=h||u?Jr(s,o):null;(h||u)&&parseFloat(s)<0&&(a="#",i=a.repeat(5));let g=null;const m=e.getAlignment(),f=m.getHorizontal(),_=m.getVertical(),p=m.getOverflow(),S=!(t!==U.String||f===exports.ITextFrame.HorizontalAlignment.Fill||l!==null&&l.length!==0||p!==exports.ITextFrame.Overflow.Wrap&&f!==exports.ITextFrame.HorizontalAlignment.Justify&&f!==exports.ITextFrame.HorizontalAlignment.Distributed&&_!==exports.ITextFrame.VerticalAlignment.Justify&&_!==exports.ITextFrame.VerticalAlignment.Distributed);let C=i;S||t!==U.String||(C=C.replaceAll(/\n/g,""));const y=c?.length>0||l?.length>0;if(p!==exports.ITextFrame.Overflow.Wrap||y){const E=e.getFont();let x=E.getSize();E.isSuperSub()&&(x*=E.getSuperSubScale());let I=[];for(let B=0;B<c?.length;B++){const D=c[B],P=e.measureText(D.char,x).width;I.push({...D,type:"spacing",width:P})}if(l?.length>0){const B=l[l.length-1],D=e.measureText(B.char,x).width;I.push({...B,type:"repeat",width:D})}I=I.sort((B,D)=>B.offset-D.offset);let v=[],R=0,A=0,M=-1,T=-1;const N=B=>{const D={type:"text",width:e.measureText(B,x).width,text:B};v.push(D),A+=D.width,R+=B.length};for(let B=0;B<I.length;B++){const D=I[B];if(T!==D.offset){const L=C.substring(R,D.offset);L&&N(L)}const P={type:D.type,width:D.width,text:D.char};D.type!=="repeat"?A+=P.width:M=v.length,v.push(P),T=D.offset}if(R<C.length){let B=C.substring(R,C.length);B&&N(B)}g={runs:Object.freeze(v),length:R,width:A,lastRepeatIndex:M}}const b=f0(n,s),w={displayText:i??"",conditionalColor:b?r(b):null,repeatChars:l??F.EmptyArray,spacingChars:c??F.EmptyArray,repeatPlaceholder:a,formattedRuns:g,canWrap:S,asDate:d,isDateFormat:h,isTimeFormat:u,isDate1904:o};return Object.freeze(w)},Ve=Object.freeze({fallbacks:F.EmptyArray,weight:400,style:exports.IFont.Style.Normal,fill:exports.IColor.Scheme.Tx1,letterSpacing:null,underline:exports.IFont.UnderlineStyle.None,strike:!1,scheme:exports.IFont.Scheme.Minor,verticalAlign:exports.IFont.VerticalAlignment.Baseline,shadow:!1,outline:!1,extend:!1}),Tn=Object.freeze({style:exports.IBorder.StrokeStyle.None,color:exports.IColor.Scheme.Tx1}),rw=Object.freeze({[exports.IBorder.Edge.Top]:Tn,[exports.IBorder.Edge.Left]:Tn,[exports.IBorder.Edge.Bottom]:Tn,[exports.IBorder.Edge.Right]:Tn,[exports.IBorder.Edge.Horizontal]:Tn,[exports.IBorder.Edge.Vertical]:Tn,[exports.IBorder.Edge.DiagonalUp]:Tn,[exports.IBorder.Edge.DiagonalDown]:Tn}),ow=Object.freeze({horizontal:exports.ITextFrame.HorizontalAlignment.General,vertical:exports.ITextFrame.VerticalAlignment.Bottom,indent:0,relativeIndent:0,overflow:exports.ITextFrame.Overflow.Visible,rotation:0,stacked:!1,quotePrefix:!1,justifyLastLine:!1,readingOrder:exports.ITextFrame.ReadingDirection.Auto,readingDirection:exports.ITextFrame.ReadingDirection.Auto}),sw=Object.freeze({locked:!1,formulaHidden:!1}),Zm=Object.freeze({fill:{type:exports.IFill.Type.None},numberFormat:"General",alignment:ow,font:Ve,border:rw,protection:sw,quotePrefix:!1,namedStyle:null}),iw=(()=>{const s=[{named:exports.IStyle.BuiltInName.Normal},{named:exports.IStyle.BuiltInName.RowLevel},{named:exports.IStyle.BuiltInName.ColLevel},{named:exports.IStyle.BuiltInName.Comma,numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)'},{named:exports.IStyle.BuiltInName.Currency,numberFormat:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'},{named:exports.IStyle.BuiltInName.Percent,numberFormat:"0%"},{named:exports.IStyle.BuiltInName.Comma0,numberFormat:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)'},{named:exports.IStyle.BuiltInName.Currency0,numberFormat:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)'},{named:exports.IStyle.BuiltInName.Hyperlink,font:{...Ve,fill:exports.IColor.Scheme.Hlink,underline:exports.IFont.UnderlineStyle.Single}},{named:exports.IStyle.BuiltInName.FollowedHyperlink,font:{...Ve,fill:exports.IColor.Scheme.FolHlink,underline:exports.IFont.UnderlineStyle.Single}},{named:exports.IStyle.BuiltInName.Note,fill:"FFFFFFCC",font:{...Ve,style:exports.IFont.Style.Normal,fill:exports.IColor.Scheme.Tx1},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"}}},{named:exports.IStyle.BuiltInName.WarningText,font:{...Ve,fill:"FFFF0000"}},{named:exports.IStyle.BuiltInName.Unknown12},{named:exports.IStyle.BuiltInName.Unknown13},{named:exports.IStyle.BuiltInName.Unknown14},{named:exports.IStyle.BuiltInName.Title,font:{...Ve,size:18,fill:exports.IColor.Scheme.Tx2}},{named:exports.IStyle.BuiltInName.Heading1,font:{...Ve,size:15,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Thick,color:exports.IColor.Scheme.Accent1}}},{named:exports.IStyle.BuiltInName.Heading2,font:{...Ve,size:13,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Thick,color:"accent1 lumMod 40, lumOff 60"}}},{named:exports.IStyle.BuiltInName.Heading3,font:{...Ve,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Medium,color:"accent1 lumMod 40, lumOff 60"}}},{named:exports.IStyle.BuiltInName.Heading4,font:{weight:"bold",fill:exports.IColor.Scheme.Tx2,...Ve}},{named:exports.IStyle.BuiltInName.Input,fill:"FFFFCC99",font:{...Ve,fill:"FF3F3F76"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"}}},{named:exports.IStyle.BuiltInName.Output,fill:"FFF2F2F2",font:{...Ve,fill:"FF3F3F3F"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"}}},{named:exports.IStyle.BuiltInName.Calculation,fill:"FFF2F2F2",font:{...Ve,fill:"FFFA7D00"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"}}},{named:exports.IStyle.BuiltInName.CheckCell,fill:"FFA5A5A5",font:{...Ve,fill:exports.IColor.Scheme.Bg1},border:{left:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},top:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},right:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},bottom:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"}}},{named:exports.IStyle.BuiltInName.LinkedCell,font:{...Ve,fill:"FFFA7D00"},border:{bottom:{style:exports.IBorder.StrokeStyle.Double,color:"FFFF8001"}}},{named:exports.IStyle.BuiltInName.Total,font:{...Ve,weight:"bold",fill:exports.IColor.Scheme.Tx1},border:{top:{style:exports.IBorder.StrokeStyle.Thin,color:exports.IColor.Scheme.Accent1},bottom:{style:exports.IBorder.StrokeStyle.Double,color:exports.IColor.Scheme.Accent1}}},{named:exports.IStyle.BuiltInName.Good,fill:"FFC6EFCE",font:{...Ve,fill:"FF006100"}},{named:exports.IStyle.BuiltInName.Bad,fill:"FFFFC7CE",font:{...Ve,fill:"FF9C0006"}},{named:exports.IStyle.BuiltInName.Neutral,fill:"FFFFEB9C",font:{...Ve,fill:"FF9C5700"}},{named:exports.IStyle.BuiltInName.Accent1},{named:exports.IStyle.BuiltInName.Accent1_20},{named:exports.IStyle.BuiltInName.Accent1_40},{named:exports.IStyle.BuiltInName.Accent1_60},{named:exports.IStyle.BuiltInName.Accent2},{named:exports.IStyle.BuiltInName.Accent2_20},{named:exports.IStyle.BuiltInName.Accent2_40},{named:exports.IStyle.BuiltInName.Accent2_60},{named:exports.IStyle.BuiltInName.Accent3},{named:exports.IStyle.BuiltInName.Accent3_20},{named:exports.IStyle.BuiltInName.Accent3_40},{named:exports.IStyle.BuiltInName.Accent3_60},{named:exports.IStyle.BuiltInName.Accent4},{named:exports.IStyle.BuiltInName.Accent4_20},{named:exports.IStyle.BuiltInName.Accent4_40},{named:exports.IStyle.BuiltInName.Accent4_60},{named:exports.IStyle.BuiltInName.Accent5},{named:exports.IStyle.BuiltInName.Accent5_20},{named:exports.IStyle.BuiltInName.Accent5_40},{named:exports.IStyle.BuiltInName.Accent5_60},{named:exports.IStyle.BuiltInName.Accent6},{named:exports.IStyle.BuiltInName.Accent6_20},{named:exports.IStyle.BuiltInName.Accent6_40},{named:exports.IStyle.BuiltInName.Accent6_60},{named:exports.IStyle.BuiltInName.ExplanatoryText,font:{...Ve,style:exports.IFont.Style.Italic,fill:"FF7F7F7F"}}];for(let e=29;e<=52;e++){const t=(e-29)%4,n=Math.floor((e-29)/4);let r="";t===1?r=" lumMod 20, lumOff 80":t===2?r=" lumMod 40, lumOff 60":t===3&&(r=" lumMod 60, lumOff 40"),s[e].fill=`accent${n+1}${r}`,s[e].font={fill:t===0?exports.IColor.Scheme.Bg1:exports.IColor.Scheme.Tx1,...Ve}}return F.deepFreeze(s)})(),aw=new class{_svgImage(s,e,t,n=8){return{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${n}' height='${n}' viewBox='0 0 ${n} ${n}' shape-rendering='crispEdges' %3E%3Cpath d='${t}' stroke='${s}' %3E%3C/path%3E%3C/svg%3E")`,backgroundRepeat:"repeat",backgroundSize:`${n}px ${n}px`,backgroundPositionX:"0px",backgroundPositionY:"0px",backgroundPosition:""+-n,backgroundColor:e}}toCSS(s,e,t){return s&&s!==exports.IFill.BuiltInSheetPattern.None?s===exports.IFill.BuiltInSheetPattern.Solid?{background:t}:s===exports.IFill.BuiltInSheetPattern.Gray0625?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 4.5 L 0.5 5.5 M 4.5 2.5 L 4.5 3.5 M 4.5 6.5 L 4.5 7.5",8):s===exports.IFill.BuiltInSheetPattern.LightGray?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 2.5 L 0.5 3.5 M 2.5 -0.5 L 2.5 0.5 M 2.5 1.5 L 2.5 2.5 M 2.5 3.5 L 2.5 4.5",4):s===exports.IFill.BuiltInSheetPattern.MediumGray?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 1.5 L 1.5 2.5 M 1.5 -0.5 L 1.5 0.5 M -0.5 -0.5 L -0.5 0.5",2):s===exports.IFill.BuiltInSheetPattern.DarkGray?this._svgImage(e,t,"M 0 0 L 0 4 M 1 1 L 1 2 M 1 3 L 1 4 M 2 0 L 2 4 M 3 0.5 L 3 1.5 M 3 2.5 L 3 3.5 M 4 0 L 4 4",4):s===exports.IFill.BuiltInSheetPattern.LightHorizontal?this._svgImage(e,t,"M 0 2 L 4 2",4):s===exports.IFill.BuiltInSheetPattern.DarkHorizontal?this._svgImage(e,t,"M 0 2 L 4 2 M 0 3 L 4 3",4):s===exports.IFill.BuiltInSheetPattern.LightVertical?this._svgImage(e,t,"M 2 0 L 2 4",4):s===exports.IFill.BuiltInSheetPattern.DarkVertical?this._svgImage(e,t,"M 2 0 L 2 4 M 3 0 L 3 4",4):s===exports.IFill.BuiltInSheetPattern.LightUp?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 3.5 L 1.5 4.5 M 1.5 -0.5 L 1.5 0.5 M 2.5 2.5 L 2.5 3.5 M 3.5 1.5 L 3.5 2.5",4):s===exports.IFill.BuiltInSheetPattern.DarkUp?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 1.5 M 0.5 3.5 L 0.5 4.5 M 1.5 2.5 L 1.5 4.5 M 2.5 1.5 L 2.5 3.5 M 3.5 0.5 L 3.5 2.5 M 1.5 -0.5 L 1.5 0.5",4):s===exports.IFill.BuiltInSheetPattern.LightDown?this._svgImage(e,t,"M 0.5 0 L 0.5 1 M 1.5 1 L 1.5 2 M 2.5 2 L 2.5 3 M 3.5 3 L 3.5 4",4):s===exports.IFill.BuiltInSheetPattern.DarkDown?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 2 M 1.5 1 L 1.5 3 M 2.5 2 L 2.5 4 M 3.5 3 L 3.5 5 M 3.5 -0.5 L 3.5 1.0",4):s===exports.IFill.BuiltInSheetPattern.LightGrid?this._svgImage(e,t,"M 1.5 -0.5 L 1.5 4.5 M -0.5 1.5 L 4.5 1.5",4):s===exports.IFill.BuiltInSheetPattern.DarkGrid?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 1.5 M 1.5 -0.5 L 1.5 1.5 M 2.5 1.5 L 2.5 3.5 M 3.5 1.5 L 3.5 3.5 M 0.5 3.5 L 0.5 4.5 M 1.5 3.5 L 1.5 4.5",4):s===exports.IFill.BuiltInSheetPattern.LightTrellis?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 3.5 L 1.5 4.5 M 1.5 -0.5 L 1.5 0.5 M 2.5 2.5 L 2.5 3.5 M 3.5 1.5 L 3.5 2.5 M 1.5 1.5 L 1.5 2.5 M 3.5 3.5 L 3.5 4.5 M 3.5 -0.5 L 3.5 0.5",4):s===exports.IFill.BuiltInSheetPattern.DarkTrellis?this._svgImage(e,t,"M 0 0 L 4 0 M 0 1 L 2 1 M 0 2 L 4 2 M 2 3 L 4 3 M 0 4 L 4 4",4):(exports.IFill.BuiltInSheetPattern.Custom,this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 4.5 L 0.5 5.5 M 2.5 2.5 L 2.5 3.5 M 2.5 6.5 L 2.5 7.5 M 4.5 0.5 L 4.5 1.5 M 4.5 4.5 L 4.5 5.5 M 6.5 2.5 L 6.5 3.5 M 6.5 6.5 L 6.5 7.5",8)):{background:"none"}}},qi=(s,e,t)=>{if(e===void 0)return;if(e===null)return null;if(e.isIStyle)return e._p.getProperties();let n=null;return typeof e=="function"?n=e(typeof t=="function"?t():t):n=e,n};class lw{constructor(e,t){this._c=e,this._p=Object.freeze(Array.isArray(t)?t:[t??null])}value(e){const t=this._p;for(let n=t.length-1;n>=0;n--){const r=t[n];if(!r)continue;const o=r[e];if(o!==void 0)return o}}values(e){const t=this._p,n=t.length;let r;for(let o=0;o<n;o++){const i=t[o];if(!i)continue;const a=i[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){const e=this._p;return e?e[e.length-1]:null}toJSON(){return null}}class En{constructor(e,t){this._c=e,this._p=Object.freeze(t)}_value(e){const t=this._p;for(let n=t.length-1;n>=0;n--){const r=t[n];if(!r)continue;const o=r[e];if(o!==void 0)return o}}_values(e){const t=this._p,n=t.length;let r;for(let o=0;o<n;o++){const i=t[o];if(!i)continue;const a=i[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){const e=this._p;return e?e[e.length-1]:null}toJSON(){return null}}class Er extends En{constructor(e,t,n){super(t,n),this._edge=e}getStyle(){return this._value("style")}getColor(){const e=this._value("color");return e?this._c.parseColor(e):null}isNone(){return this.getStyle()===exports.IBorder.StrokeStyle.None}toCSS(){const e=qn(this);switch(this._edge){case exports.IBorder.Edge.Left:return{borderLeft:e};case exports.IBorder.Edge.Right:return{borderRight:e};case exports.IBorder.Edge.Top:return{borderTop:e};case exports.IBorder.Edge.Bottom:return{borderBottom:e};case exports.IBorder.Edge.DiagonalUp:case exports.IBorder.Edge.DiagonalDown:return{borderDiagonalUp:e}}}get isIStroke(){return!0}}class cw extends En{getLeft(){return new Er(exports.IBorder.Edge.Left,this._c,this._values(exports.IBorder.Edge.Left))}getRight(){return new Er(exports.IBorder.Edge.Right,this._c,this._values(exports.IBorder.Edge.Right))}getTop(){return new Er(exports.IBorder.Edge.Top,this._c,this._values(exports.IBorder.Edge.Top))}getBottom(){return new Er(exports.IBorder.Edge.Bottom,this._c,this._values(exports.IBorder.Edge.Bottom))}getDiagonalUp(){return new Er(exports.IBorder.Edge.DiagonalUp,this._c,this._values(exports.IBorder.Edge.DiagonalUp))}getDiagonalDown(){return new Er(exports.IBorder.Edge.DiagonalDown,this._c,this._values(exports.IBorder.Edge.DiagonalDown))}isEmpty(){return!1}get isIBorder(){return!0}}class hw extends En{get isITextBoxAlignment(){return!0}getHorizontal(){return this._value("horizontal")}getVertical(){return this._value("vertical")}getIndent(){return this._value("indent")}getRelativeIndent(){return this._value("relativeIndent")}getOverflow(){return this._value("overflow")}getRotation(){return this._value("rotation")}getStacked(){return this._value("stacked")}getJustifyLastLine(){return this._value("justifyLastLine")}getReadingDirection(){return this._value("readingDirection")}}class uw extends En{isEqualMeasure(e){return!!e&&this.getFamily()===e.getFamily()&&!!F.isEqualArrays(this.getFallbacks(),e.getFallbacks())&&this.getSize()===e.getSize()&&this.getWeight()===e.getWeight()&&this.getStyle()===e.getStyle()&&this.getStrike()===e.getStrike()&&this.getScheme()===e.getScheme()&&this.getShadow()===e.getShadow()&&this.getOutline()===e.getOutline()&&this.getLetterSpacing()===e.getLetterSpacing()&&this.getVerticalAlignment()===e.getVerticalAlignment()}isSuperSub(){const e=this.getVerticalAlignment();return e===exports.IFont.VerticalAlignment.Sub||e===exports.IFont.VerticalAlignment.Super}isSuperScript(){const e=this.getVerticalAlignment();return e===exports.IFont.VerticalAlignment.Sub||e===exports.IFont.VerticalAlignment.Super}getSuperSubScale(){return this.getFamily(),this.getSize(),this.getVerticalAlignment(),.6}getSuperSubShift(){return this.getFamily(),e=this.getSize(),(t=this.getVerticalAlignment())===exports.IFont.VerticalAlignment.Super?-e/3:t===exports.IFont.VerticalAlignment.Sub?e/5:0;var e,t}toCSS(e,t=1,n=!1){const r={fontFamily:Fi(this.getFamily(),this.getFallbacks()),letterSpacing:`${this.getLetterSpacing()}px`,fontWeight:this.getWeight(),fontStyle:this.getStyle(),textDecoration:Um(this.getUnderline(),this.getStrike()),color:this.getFill().toCSS(e),fontSize:`${F.roundAccurately(this.getSize()*exports.IFont.getDeviceScale()*t,2)}px`,textRendering:"geometricPrecision"};if(n){const o=this._c.getNormal().getFont().toCSS(e,t,!1),i=r.textDecoration,a=r.fontWeight;F.removeEqualValues(r,o),i&&(r.textDecoration=i),a&&(r.fontWeight=a)}return r}getFamily(){return this._value("family")??this._c.getTheme().getFontScheme().getMinorFont()}getFallbacks(){let e=this._value("fallbacks")??this._c.getTheme().getFontScheme().getMinorFallbacks()??F.EmptyArray;return this.getFamily()==="Aptos Narrow"&&(e=["Calibri",...e]),e}getSize(){return this._value("size")??this._c.getDefaultFontSize()??11}getWeight(){return this._value("weight")}getStyle(){return this._value("style")}getFill(){const e=this._value("fill");return this._c.parseColor(e??exports.IColor.Scheme.Bg1)}getLetterSpacing(){return this._value("letterSpacing")??this.getSize()/-25}getUnderline(){return this._value("underline")}getStrike(){return this._value("strike")}getScheme(){return this._value("scheme")}getVerticalAlignment(){return this._value("verticalAlign")}getShadow(){return this._value("shadow")}getOutline(){return this._value("outline")}getExtend(){return this._value("extend")}get isIStyledFont(){return!0}}const dw=Object.freeze({background:"none"});class id extends En{getType(){return exports.IFill.Type.None}toCSS(e){return dw}toJSON(){return{type:exports.IFill.Type.None}}}class gw extends En{getType(){return exports.IFill.Type.Solid}getColor(){return this._c.parseColor(this._value("color")??exports.IColor.Scheme.Bg1)}toCSS(e){return{background:this.getColor().toCSS(e)}}toJSON(){return{type:exports.IFill.Type.Solid,color:this.getColor()?.toString()??null}}}class mw extends En{getOffset(){return this._value("offset")??0}getColor(){return this._c.parseColor(this._value("color")??exports.IColor.Scheme.Bg1)}}class fw extends En{getType(){return exports.IFill.Type.Gradient}getStops(){const e=this._value("stops")??[],t=[],n=this._c;for(let r=0;r<e.length;r++){const o=e[r];t.push(new mw(n,[o]))}return t}getGradientType(){return this._value("gradientType")??exports.IFill.GradientType.Linear}getAngle(){return this._value("angle")??0}getFillTo(){return this._value("fillTo")??null}toCSS(e,t){const n=Xm(this,e,t);return n?{background:n}:null}toJSON(){const e={type:exports.IFill.Type.Gradient};if(this.getStops().length>0){let t=[];for(let n=0;n<t.length;n++)t.push({offset:t[n].offset,color:t[n].color.toString()});e.stops=t}return this.getAngle()!==0&&(e.angle=this.getAngle()),this.getGradientType()!==exports.IFill.GradientType.Linear&&(e.gradientType=this.getGradientType()),this.getFillTo()&&(e.fillTo=this.getFillTo()),e}}class pw extends En{getType(){return exports.IFill.Type.Pattern}getBackground(){const e=this._value("background")??exports.IColor.Named.Window;return this._c.parseColor(e)}getForeground(){return this._c.parseColor(this._value("foreground")??exports.IColor.Scheme.Tx1)}getPatternType(){return this._value("patternType")??exports.IFill.BuiltInSheetPattern.None}toCSS(e){const t=this.getBackground().toCSS(e),n=this.getForeground().toCSS(e);return this.getPatternType()===exports.IFill.BuiltInSheetPattern.None?{background:"none"}:this.getPatternType()===exports.IFill.BuiltInSheetPattern.Solid?{background:this.getForeground().toCSS(e)}:aw.toCSS(this.getPatternType(),n,t)}toJSON(){const e={type:exports.IFill.Type.Pattern};this.getPatternType()!==exports.IFill.BuiltInSheetPattern.None&&(e.patternType=this.getPatternType());const t=this.getForeground();t&&(e.foreground=t.toString());const n=this.getBackground();return n&&(e.background=n.toString()),e}}class ef{constructor(e){this._options=e,this._c=e.styles,this._p=new lw(e.styles,e.properties),this._hasVisibleStyling=!this.getFill()||this.getFill().getType()!==exports.IFill.Type.None||!this.getBorder().isEmpty()}hasVisibleStyling(){return this._hasVisibleStyling}isNormal(){return!1}getNamed(){const e=this._p.value("named")??exports.IStyle.BuiltInName.Normal;return this._c.getNamed(e)}createTemporaryStyle(e){const t=this._c,n=qi(0,e,this),r=this._options,o=r.range,i=r.direct.cloneWithUpdate(n);return $r(t,i,o)}measureText(e,t=this.getFont().getSize(),n,r){const o=this.getFont();n||(n=o.getFamily());let i=o.getFallbacks();n==="Aptos Narrow"&&(i=["Calibri",...i]);const a=Fi(n,i);return exports.IFont.getSharedMeasurer()(e,t*exports.IFont.getDeviceScale(),a,{isBold:o.getWeight()>400,isItalic:o.getStyle().includes("italic"),letterSpacing:o.getLetterSpacing(),...r})}createTemporaryTextFrame(e,t=!1){return Gi(e,this.getFont(),this.getAlignment(),t)}getBestFit(){if(this._bestFit!==void 0)return this._bestFit;const e=this.getInsets(),t=this.measureText("My");return this._bestFit={width:null,height:t.lineHeight+e.top+e.bottom},this._bestFit}getInsets(){if(this._insets!==void 0)return this._insets;const e=(this.getFont().getSize(),1),t=(n=this.getFont().getSize(),Math.max(2,Math.round(n<225?n/5:n/3.5)));var n;const r={top:e,left:t,bottom:e,right:t},o=this._p,i=o?.value("insets");return i&&(i.top!==void 0&&(r.top+=i.top),i.left!==void 0&&(r.left+=i.left),i.bottom!==void 0&&(r.bottom+=i.bottom),i.right!==void 0&&(r.right+=i.right)),this._insets=Object.freeze(r),this._insets}getBorder(){return new cw(this._c,this._p.values("border"))}getFont(){return new uw(this._c,this._p.values("font"))}getFill(){const e=this._p;let t=e.values("fill"),n=e.value("fill");return n.type===exports.IFill.Type.None?new id(this._c,t):n.type===exports.IFill.Type.Solid||!n.type&&n.color?new gw(this._c,t):n.type===exports.IFill.Type.Gradient?new fw(this._c,t):n.type===exports.IFill.Type.Pattern?new pw(this._c,t):new id(this._c,t)}getAlignment(){return new hw(this._c,this._p.values("alignment"))}getNumberFormat(){const e=this._p.value("numberFormat");return typeof e=="number"?dc(e):e}getQuotePrefix(){return this._p.value("quotePrefix")}get isIStyle(){return!0}}const $r=(s,e,t)=>{const n=t?.rowStart??k.EmptyCell.rowIndex,r=t?.colStart??k.EmptyCell.colIndex,o=[Zm],i=s.getNormalRanged(),a=i.getPropertiesAt(n,r,null);if(a&&o.push(a),!e)return new _w({styles:s,range:t,properties:o,layerTypes:null,direct:i});const l=e.getPropertiesAt(n,r,null);return l&&o.push(l),new ef({styles:s,range:t,properties:o,direct:e})};class _w extends ef{isNormal(){return!0}}const Vn=(s,e)=>{if(s&&!e||e&&!s)return!1;if(s===e)return!0;if(s.style!==e.style)return!1;if(s.color===e.color)return!0;let t=s.color;(s&&s.color).isIColor&&(t=s.color.toString());let n=e.color;return(e&&e.color).isIColor&&(n=e.color.toString()),t===n};class Ke{constructor(e,t,n,r){this._c=e,this._r=t,this._p=n??null,this._t=r??null,this._e=this._p===null||Object.keys(this._p).length===1&&this._p.named===exports.IStyle.BuiltInName.Normal}isEmpty(){return this._e}getProperties(){return this._p}getCoords(){return this._r}cloneWithUpdate(e){if(e===void 0)return this;const t=this._c,n=this._r,r=this._p,o=exports.it.resolveTypedUpdates(e,He,t,r);return new Ke(t,n,o)}copyTo(e,t){const n=this._c,r=this._r,o=e.rowStart-r.rowStart,i=e.colStart-r.colStart;let a=null;return k.isEqualRanges(r,this._t)||(a=k.translateRange(r,o,i)),new Ke(n,e,this._p,a)}canTile(e,t){return!this._p.border}_createShifted(e){return new Ke(this._c,e,this._p)}getShifted(e){return e.after?{...e.after,value:this._createShifted(k.sanitizeRange(e.after))}:null}getSplit(e,t){const n=this._c,r=this._p,o=this._r;let i=r;const a=e[0];let l=r;const c=e[1],h=r?r.border:null;if(h){const d=t===exports.w.Orientation.Column;if(d?h.left!==void 0||h.right!==void 0||h.vertical!==void 0:h.top!==void 0||h.bottom!==void 0||h.horizontal!==void 0){i={...i};const g=this._splitBorderRange(h,o,a,d);g?i.border=g:g===null&&delete i.border,l={...l};const m=this._splitBorderRange(h,o,c,d);m?l.border=m:m===null&&delete l.border}}const u=this._t;return[new Ke(n,e[0],i,u),new Ke(n,e[1],l,u)]}getMerged(e,t,n){const r=n===exports.w.Orientation.Column,o=this._p,i=e._p;if(o&&!i||i&&!o||!o&&!i)return;let a=Object.keys(o),l=Object.keys(i);if(a.length!==l.length)return;for(let d=0;d<a.length;d++){const g=a[d];if(g==="border")continue;const m=o[g],f=i[g];if(!F.deepEqual(m,f))return}const c=o.border,h=i.border;if(c&&!h||h&&!c)return;const u=this._c;if(c||h){const d=r?exports.IBorder.Edge.Top:exports.IBorder.Edge.Left,g=r?exports.IBorder.Edge.Bottom:exports.IBorder.Edge.Right;if(!Vn(c[d],h[d])||!Vn(c[g],h[g]))return;const m=this._r,f=e._r,_=1+(r?m.rowEnd-m.rowStart:m.colEnd-m.colStart),p=1+(r?m.colEnd-m.colStart:m.rowEnd-m.rowStart),S=1+(r?f.colEnd-f.colStart:f.rowEnd-f.rowStart),C=r?exports.IBorder.Edge.Horizontal:exports.IBorder.Edge.Vertical;if(_>1&&!Vn(c[C],h[C]))return;const y=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom,b=r?exports.IBorder.Edge.Left:exports.IBorder.Edge.Top;if(!Vn(c[y],h[b]))return;const w=r?exports.IBorder.Edge.Vertical:exports.IBorder.Edge.Horizontal,E=c[y];if(p>1&&!Vn(E,c[w]))return;const x=S===1?h[b]:h[w];if(S>1&&!Vn(x,h[w])||!Vn(E,x))return;const I={border:{[d]:c[d],[g]:c[g],[C]:c[C],[w]:E,[b]:c[b],[y]:h[y]}},v=exports.it.resolveTypedUpdates(I,He,u,o);return new Ke(u,t,v)}return new Ke(u,t,this._p)}hasTrailingEdge(){return!0}isMergeOnShift(){return!0}_splitBorderRange(e,t,n,r){const o=r?exports.IBorder.Edge.Left:exports.IBorder.Edge.Top,i=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom,a=r?exports.IBorder.Edge.Vertical:exports.IBorder.Edge.Horizontal,l=r?t.colStart:t.rowStart,c=r?t.colEnd:t.rowEnd,h=r?n.colStart:n.rowStart,u=r?n.colEnd:n.rowEnd;let d={...e};return delete d[o],delete d[i],delete d[a],l===h?e[o]&&(d[o]=e[o]):e[a]&&(d[o]=e[a]),c===u?e[i]&&(d[i]=e[i]):e[a]&&(d[i]=e[a]),u-h>0&&e[a]&&(d[a]=e[a]),Object.keys(d).length===0?null:d}_localizeBorderRange(e,t,n){if(!e)return;let r=null;const o=t.rowStart,i=t.rowEnd,a=n.rowStart,l=n.rowEnd;e.top&&a===o&&(r=r??{},r.top=e.top),e.bottom&&l===i&&(r=r??{},r.bottom=e.bottom),e.horizontal&&(l-a>0&&(r=r??{},r.horizontal=e.horizontal),a>o&&(r=r??{},r.top=e.horizontal),l<i&&(r=r??{},r.bottom=e.horizontal));const c=t.colStart,h=t.colEnd,u=n.colStart,d=n.colEnd;return e.left&&u===c&&(r=r??{},r.left=e.left),e.right&&d===h&&(r=r??{},r.right=e.right),e.vertical&&(d-u>0&&(r=r??{},r.vertical=e.vertical),u>c&&(r=r??{},r.left=e.vertical),d<h&&(r=r??{},r.right=e.vertical)),r}_localizeBorder(e,t,n,r){if(!e)return;let o=null;const i=t.rowStart,a=t.rowEnd;e.top&&n===i&&(o=o??{},o.top=e.top),e.bottom&&n===a&&(o=o??{},o.bottom=e.bottom),e.horizontal&&(n>i&&(o=o??{},o.top=e.horizontal),n<a&&(o=o??{},o.bottom=e.horizontal));const l=t.colStart,c=t.colEnd;return e.left&&r===l&&(o=o??{},o.left=e.left),e.right&&r===c&&(o=o??{},o.right=e.right),e.vertical&&(r>l&&(o=o??{},o.left=e.vertical),r<c&&(o=o??{},o.right=e.vertical)),o}getPropertiesAt(e,t,n){const r=this._p;let o=r,i=null;const a=this._t;if(a){const u=this._r,d=a.colEnd-a.colStart+1,g=a.rowEnd-a.rowStart+1;t=u.colStart+(t-u.colStart+(a.colStart-u.colStart))%d,e=u.rowStart+(e-u.rowStart+(a.rowStart-u.rowStart))%g}const l=r?.font;l&&l.fill&&(i=i??this._c.getNormalRanged().getPropertiesAt(e,t,n),i&&i.font&&l.fill===i.font.fill&&(o===r&&(o={...o}),o.font={...l},delete o.font.fill));const c=r?.fill;c&&(i=i??this._c.getNormalRanged().getPropertiesAt(e,t,n),i&&F.deepEqual(c,i.fill)&&(o===r&&(o={...o}),delete o.fill));const h=o?.border;if(h){const u=a??this._r,d=this._localizeBorder(h,u,e,t);d!==void 0&&(o===r&&(o={...o}),d===null?delete o.border:o.border=d)}return o}toJSON(){return F.toSafeJSON(this._p)}}const Sw=Object.freeze({value:null,style:null,hyperlink:null,formula:null,type:U.Null,stringToParse:null}),ad=Object.seal({value:void 0,style:void 0,hyperlink:void 0,formula:void 0,type:void 0,stringToParse:void 0}),ww=Object.seal({value:void 0,style:void 0,hyperlink:void 0,formula:void 0}),yw=Object.freeze({width:1,height:1}),Cw=new wc({max:1e3}),bw=new class{isEditAllowed(){return!0}isFormulaHidden(){return!1}get isICellProtection(){return!0}},Ul=(s,e,t=null,n=null,r=!1)=>{if(s===void 0)return;if(s===null)return Sw;if(s&&s.isICell){const p=s,S=ad;return S.value=p.getValue(),p.getStyle().isNormal()||(S.style=p.getStyle()._p.getProperties()),S.formula=p.getFormulaText(),S.hyperlink=p.getHyperlink(),S.type=p.getType(),S}let o;s.value!==void 0||s.style!==void 0||s.hyperlink!==void 0?o=s:(o=ww,o.value=s,o.style=void 0,o.hyperlink=void 0);const i=ad;i.type=void 0,i.value=void 0,i.style=void 0,i.formula=void 0,i.hyperlink=void 0,i.stringToParse=void 0;let a,l=o.value,c=!1;if(o.value!==void 0&&(a=Ze(l),a||(c=qr(l),c&&(a=U.Number)),!a))throw new Error("Invalid cell type. See documentation for information on valid built in cell types and creating custom cell types.");let h,u,d=null,g=null,m;if(a===U.String){if(m=o.value,t){let p=n?.get(m);if(!p){const S=m.length,C=m.charAt(0);C==="="&&S>1?(u=m.substring(1),l=null):(p=rf(m,t),!p||typeof p.value!="string"||C!=="+"&&C!=="-"||(u="="+m,l=null),p!==void 0&&n&&n.set(m,p))}p&&(p.value!==void 0&&(l=p.value,a=Ze(l)),p.style!==void 0&&(d=p.style),p.hyperlink!==void 0&&(h=p.hyperlink)),!r&&t.parse&&(g=m)}}else if(c){const p=t?.date1904??e.date1904;l=Qo(o.value,p),d=S=>{if(!Zo(S.getNumberFormat()))return{numberFormat:"Short Date"}}}else l=o.value;let f=o.style;if(f&&f.isIStyle&&(f=f._p.getProperties()),h=o.hyperlink??h,d)if(f){const p=f;f=S=>{let C=S.createTemporaryStyle(d);return C=C.createTemporaryStyle(p),C=C._p.getProperties(),C}}else f=d;let _=!1;return l!==void 0&&(l===null?(i.value=null,i.type=U.Null):(i.value=l,i.type=a),_=!0),f!==void 0&&(i.style=f,_=!0),h!==void 0&&(i.hyperlink=h,_=!0),u!==void 0&&(i.formula=u,_=!0),r||(i.stringToParse=g,_=!0),_?(i.type=a,i):void 0},tf=(s,e,t,n)=>Qm(t,e,s,e.getNumberFormat(),r=>n.styles.parseColor(r),n.date1904),nf=(s,e,t,n,r=!1)=>{if(s===U.Null)return null;let o="";if(r)o=""+t;else{const i=tf(s,e,t,n);if(i.formattedRuns){const a=i.formattedRuns.runs;for(let l=0;l<a.length;l++)o+=a[l].text}else o=i.displayText}return Gi(o,e.getFont(),e.getAlignment(),s===U.String,r)},yc=(s,e)=>{const t=e.getInsets();if(s===U.Null)return t;let n=t;const r=Ji(s,e),o=e.getAlignment().getIndent();if(o&&(r===exports.ITextFrame.HorizontalAlignment.Left||r===exports.ITextFrame.HorizontalAlignment.Right)){n={...t};const i=e.measureText(" ".repeat(1*o)),a=Math.min(3,Math.max(1,(26-e.getFont().getSize())/2));let l=i.width*a;r===exports.ITextFrame.HorizontalAlignment.Left?n.left+=l:r===exports.ITextFrame.HorizontalAlignment.Right&&(n.right+=l)}return Object.freeze(n)},Ji=(s,e)=>{const t=e.getAlignment(),n=t.getRotation(),r=t.getHorizontal();return n!==0&&r===exports.ITextFrame.HorizontalAlignment.General?n>0&&n<90||n>180&&n<=270?exports.ITextFrame.HorizontalAlignment.Right:exports.ITextFrame.HorizontalAlignment.Left:r===exports.ITextFrame.HorizontalAlignment.General?s===U.Null?exports.ITextFrame.HorizontalAlignment.Left:s===U.Boolean||s===U.Error?exports.ITextFrame.HorizontalAlignment.Center:e.getNumberFormat()==="@"?exports.ITextFrame.HorizontalAlignment.Left:s===U.Number?exports.ITextFrame.HorizontalAlignment.Right:exports.ITextFrame.HorizontalAlignment.Left:r},Ew=(s,e,t,n,r,o,i,a)=>{if(e===U.Null||n==="")return null;const l=s.colIndex;if(!((D,P,L=!1,z=!1)=>{if(D===U.Null)return!1;const O=P.getAlignment(),j=O.getHorizontal();if(j===exports.ITextFrame.HorizontalAlignment.CenterContinuous)return!0;if(j===exports.ITextFrame.HorizontalAlignment.Fill||j===exports.ITextFrame.HorizontalAlignment.Distributed||D!==U.String||O.getOverflow()!==exports.ITextFrame.Overflow.Visible||j===exports.ITextFrame.HorizontalAlignment.Right&&L||j===exports.ITextFrame.HorizontalAlignment.Center&&L&&z||z&&(j===exports.ITextFrame.HorizontalAlignment.General||j===exports.ITextFrame.HorizontalAlignment.Left))return!1;const V=O.getVertical();return V!==exports.ITextFrame.VerticalAlignment.Justify&&V!==exports.ITextFrame.VerticalAlignment.Distributed})(e,t,r!==null&&r.colIndex+1===l,o!==null&&o.colIndex-1===l))return null;const c=xw(e,t,n,a),h=t.getAlignment().getHorizontal(),u=h===exports.ITextFrame.HorizontalAlignment.Fill,d=h===exports.ITextFrame.HorizontalAlignment.CenterContinuous||u;if(!c&&!d)return null;const g=(m=Ji(e,t))===exports.ITextFrame.HorizontalAlignment.Center||m===exports.ITextFrame.HorizontalAlignment.CenterContinuous?cn.Center:m===exports.ITextFrame.HorizontalAlignment.Right?cn.Right:cn.Left;var m;let f=0,_=0,p=0,S=0,C=1;if(d&&n!==null&&i.directStyle){const D=i.directStyle.getCoords();C=Math.min(a.nextContentful(s,D.colEnd),D.colEnd)-s.colIndex+1}const y=a.colHeaders,b=y.findOffset.bind(y),w=y.findIndex.bind(y);let E=b(l);const x=E;let I=b(l+C),v=I-E,R=l,A=l;const M={x:0,y:0,width:v,height:c?.height??0},T=l-l+C;let N=c?c.width-v:0,B=M;return u&&(N=0),v>0&&N>0&&(g===cn.Center&&(N/=2),g!==cn.Left&&g!==cn.Center||(A=w(I+N),o!==null&&(A=Math.min(A,o.colIndex-1)),I=b(A),S=N,_=A-l),g!==cn.Right&&g!==cn.Center||(R=w(E-N),r!==null&&(R=Math.max(R,r.colIndex+1)),E=b(R),p=N,f=l-R),M.x=x-E,B.x=M.x),{anchorBounds:M,leftIndex:f,rightIndex:_,leftOffset:p,rightOffset:S,colSpan:T,colBounds:B}};class vw{constructor(e,t){if(this._styles=e,this._rs=t,t?.table){const n=t?.table;this._table=n.getStyle().getRanged(n)}if(t?.conditionals){this._conditionals=[];for(let n=0;n<t.conditionals.length;n++){const r=t.conditionals[n];this._conditionals.push(r)}}}getCoords(){return k.EmptyRange}getPropertiesAt(e,t,n){let r=null,o=this._rs.directStyle?.getPropertiesAt(e,t,n)??null;const i=this._styles;if(o&&o.named){const h=o.named;if(h!==exports.IStyle.BuiltInName.Normal){const u=this._styles.getNamed(h);u?r=u.getRanged().getPropertiesAt(e,t,n):console.warn(`A named styled was referenced but not found: '${h}'.`)}}let a=null;const l=this._table?.getPropertiesAt(e,t,n);l&&(a=a?exports.it.resolveTypedUpdates(l,He,i,a):l),r&&(a=a?exports.it.resolveTypedUpdates(r,He,i,a):r);const c=this._conditionals;if(c)for(let h=0;h<c.length;h++){const u=c[h].getPropertiesAt(e,t,n);u&&(a=a?exports.it.resolveTypedUpdates(u,He,i,a):u)}return o&&(a=a?exports.it.resolveTypedUpdates(o,He,i,a):o),a}cloneWithUpdate(e){return(this._rs.directStyle??this._styles.getNormalRanged()).cloneWithUpdate(e)}}const ki=(s,e,t,n)=>{if(!t)return n.styles.getNormal();const r=n.styles;return $r(r,t?new vw(r,t):null,e)},On=(s,e,t,n,r,o,i,a=null,l=Cw)=>{if(t===null)return e?e.getBestFit():null;const c=s===U.String,h=e.getFont(),u=h.getWeight(),d=h.getSize(),g=h.getFamily(),m=e.getAlignment(),f=m.getOverflow(),_=m.getRotation(),p=m.getVertical(),S=e.getNumberFormat(),C=c&&f===exports.ITextFrame.Overflow.Visible,y=c&&(f===exports.ITextFrame.Overflow.Wrap||p===exports.ITextFrame.VerticalAlignment.Justify||p===exports.ITextFrame.VerticalAlignment.Distributed),b=(a??"")+"\0"+d+g+u+S+_+C+y+o+i+(a?"":t),w=l.get(b);if(w)return w;let E=null,x=null;const I=yc(s,e),v=I.top+I.bottom+ +Tw(e);let R=!1,A=!1;i&&(A=!0,(_!==0||y)&&(A=!1));const M=A?void 0:nf(s,e,t,n),T=I.left+I.right+2;if(M){if(s===U.Number&&S==="General"&&o){let D=t,P=F.splitNumber(D),L="";L=Math.abs(D)>=Math.pow(10,12)||Math.abs(D)<=Math.pow(10,-12)?`0.${"0".repeat(Math.max(2,Math.min(P.ipLength,5)))}E+00`:Math.abs(P.ipLength)===0?"0.0":Math.abs(P.fpLength)>0?"0".repeat(P.ipLength)+".0":"0".repeat(P.ipLength),D<0&&(L="-"+L),L="0".repeat(L.length);const z=e.measureText(L);E=z.width,x=z.lineHeight}else{let D=null;y&&(D={width:Math.max(1,r-T)});const P=M.layout(D);E=P.bounds.width,x=P.bounds.height}if(E!==null&&(E+=T),x!==null&&(x+=v),R=s===U.String,_){R&&f===exports.ITextFrame.Overflow.Wrap&&(R=!1);const D=((P,L)=>{const{x:z,y:O,width:j,height:V}=P,W=L*Math.PI/180,H=Math.sin(W),G=Math.cos(W),$=j/2,Z=V/2,Y=fs(-$,-Z,H,G),re=fs($,-Z,H,G),ee=fs(-$,Z,H,G),q=fs($,Z,H,G);let ue=Math.min(Y.x,re.x,ee.x,q.x)+$,le=Math.max(Y.x,re.x,ee.x,q.x)+$,K=Math.min(Y.y,re.y,ee.y,q.y)+Z;return{x:z+ue,y:O+K,width:le-ue,height:Math.max(Y.y,re.y,ee.y,q.y)+Z-K}})({x:0,y:0,width:E,height:x},_);E=D.width,x=D.height}}else x=e.getBestFit().height;o&&R&&(E=0);const N={width:E,height:x},B=Object.freeze(N);return l.set(b,B),B},xw=(s,e,t,n)=>{const r=yc(s,e),o=Ji(s,e);let i=r.left+r.right;o===exports.ITextFrame.HorizontalAlignment.Left?i=r.right:o===exports.ITextFrame.HorizontalAlignment.Right?i=r.left:o===exports.ITextFrame.HorizontalAlignment.Center&&(i=r.left+r.right);const a=On(s,e,t,n,Number.MAX_SAFE_INTEGER,!1,!1);return{width:Math.ceil(a.width-i),height:Math.ceil(a.height)}};class Wn{constructor(e,t,n=U.Null,r=null,o=null,i=null,a=null){this._options=e,this._coords=t??null,this._t=n,this._rs=o,this._v=r,this._p=i,this._n=a}isEqual(e){if(!e)return!1;if(this===e)return!0;const t=e;return!!t.isICell&&this._v===t._v&&!!k.isEqualCells(this._coords,e.getCoords())&&this._options.sheet===t._options?.sheet}getCoords(){return this._coords}getA1(){const e=this._coords;return e?pn(this._options.resolveRange(e).getCoords()):Ye}getSource(){return this._options.sheet}select(e){return this._options.opener("#"+rs(this._coords),e)}getColumnFilter(){if(!this._rs)return null;let e=null;if(this._rs.table){const t=this._rs.table.getHeaderRange().getCoords();if(t&&k.isCellWithinRange(this._coords,t)){const n=this._coords.colIndex-t.colStart;e=this._rs.table.getColumnFilter(n)??null}}return e}getProtection(){return bw}getTextOverflow(){const e=this._to;if(e!==void 0)return e;if(this._rs&&this._rs.merge)return this._to=null,null;const t=this.getStyle(),n=Ew(this._coords,this._t,t,this._v,this._p,this._n,this._rs,this._options);return n===null||n.leftIndex===0&&n.rightIndex===0&&n.colSpan<=1?(this._to=null,null):(this._to=n,this._to)}getRenderHorizontalAlignment(){return Ji(this._t,this.getStyle())}isEmpty(){return this._v===null&&!this._rs}getExtrusions(){const e=this._rs;if(!e&&this._to===null)return null;if(e){const r=e.merge;if(r!==void 0)return r.getCoords()}const t=this.getTextOverflow();if(!t)return null;const n=this._coords;return{colStart:n.colIndex-t.leftIndex,rowStart:n.rowIndex,colEnd:n.colIndex+t.rightIndex+t.colSpan-1,rowEnd:n.rowIndex}}isEditAllowed(){const e=this._options;return e?!e.getProtection().isLocked()||!!this._rs&&this.getProtection().isEditAllowed():!0}isFormulaHidden(){return!!this._options.getProtection().isLocked()&&!!this._rs&&this.getProtection().isFormulaHidden()}isContentful(){return this._v!==null}getBestFit(e,t=!1){return e===void 0&&(e=this._options.sheet.getColumnHeaders().getSpanSize(this._coords.colIndex)??64),On(this._t,this.getStyle(),this._v,this._options,e,t,!1)}getInsets(){return this._v===null?this.getStyle().getInsets():yc(this._t,this.getStyle())}getTextFrame(e){let t,n;if(e&&(n=this.getFormulaText()),t=n??this._v,t===null)return null;const r=this.getStyle();return n?((o,i)=>i===U.Null?null:Gi(i,o.getFont(),o.getAlignment(),!1,!0))(r,t,this._options):nf(this._t,r,t,this._options,e)}getValue(){return this._v}getFormula(){let e=this._rs?.formula;if(!e)return null;const t=this._coords;return t?(Array.isArray(e)&&(e=e[0]),new Rw(this._options,e,t)):null}getFormulaText(){let e=this._rs?.formula;if(!e)return null;const t=this._coords;return t?(Array.isArray(e)&&(e=e[0]),"="+e.getFormulaTextAt(t.rowIndex,t.colIndex)):null}getCalcStatus(){const e=this._rs;return e&&e.pending?exports.ICell.CalcStatus.Pending:exports.ICell.CalcStatus.Ready}getType(){return this._t}getStyle(e=!1){if(!e&&this._styleConditional)return this._styleConditional;if(e&&this._styleSpecific)return this._styleSpecific;const t=ki(0,k.cellToRange(this._coords),this._rs,this._options);return e?this._styleSpecific=t:this._styleConditional=t,t}createTemporaryCell(e){const t=this._options;if(e===null)return new Wn(t,this._coords,null);const n=Ul(e,this._options);let r=this._rs;if(n.style!==void 0){const a=this._coords??k.EmptyCell,l=k.cellToRange(a),c=()=>ki(0,l,this._rs,this._options),h=qi(this._options.styles,n.style,c),u=(this._rs?.directStyle??new Ke(t.styles,l)).cloneWithUpdate(h);r={...r,directStyle:u}}let o=this._t,i=this._v;return n&&n.value!==void 0&&(i=n.value,o=n.type),i===this._v&&o===this._t&&r===this._rs?this:i!==null||r?new Wn(this._options,this._coords,o,i,r):new Wn(this._options,this._coords)}_isDate1904(){return this._options.date1904}getNumberFormat(e){if(e!==void 0){const t=this._v;return Qm(t,this.getStyle(),this._t,e,n=>this._options.styles.parseColor(n),this._isDate1904())}return tf(this._t,this.getStyle(),this._v,this._options)}toDate(){return this._t!==U.Number?null:this._rs?this.getNumberFormat().asDate:null}toText(e){return this.getNumberFormat(e).displayText}toTextUnformatted(e){if(e){const n=this.getFormulaText();if(n)return n}let t=this._v;return this.isSpillOverflow()&&(t=null),((n,r,o,i)=>{if(r===U.Null||n==null)return"";if(r===U.Number){const a=n,l=Zo(o),c=Wi(o);if(l||c){const h=parseFloat(n),u=h%1!=0,d=h>=1;if(h<0)return F.castToString(n);if(!l||c||u)if(!c||l||d){const g=xo("Short Date",a,i),m=xo("Long Time",a,i);if(g&&m)return g.fmt+" "+m.fmt}else{const g=xo("Long Time",a,i);if(g)return g.fmt}else{const g=xo("Short Date",a,i);if(g)return g.fmt}}}if(r===U.Number&&o.endsWith("%")){let a=F.roundAccurately(100*parseFloat(n));if(!isNaN(a))return a+"%"}return r===U.Boolean?n?"TRUE":"FALSE":r===U.Error?n?.getLabel?.()??exports.n.Label.Unknown:r===U.RichData?"(Rich Object)":F.castToString(n)})(t,this._t,this.getStyle().getNumberFormat(),{date1904:this._isDate1904()})}getComments(){const e=this._rs?.comments;return e?Object.freeze(e):null}getHyperlink(){const e=this._rs?.hyperlink;return e?new nS(this.toText.bind(this),this._options.opener,e):null}getErrors(){const e=this._rs;return e&&e.calcError?[e.calcError]:F.EmptyArray}getWarnings(){return F.EmptyArray}getSpans(){const e=this._rs?.merge;if(!e)return yw;const t=e.getCoords();return Object.freeze({width:t.colEnd-t.colStart+1,height:t.rowEnd-t.rowStart+1})}isTopLeft(){const e=this._rs?.merge;if(!e)return!0;const t=e.getCoords();return this._coords&&this._coords.colIndex===t.colStart&&this._coords.rowIndex===t.rowStart}getSpill(){let e=this._rs?.spills;if(!e||!this._coords)return null;Array.isArray(e)||(bs[0]=e,e=bs);let t=null;for(let n=0;!t&&n<e.length;n++){const r=e[n];r.getError()||(t=r)}return t||(t=e[0]),this._options.getRange(t.getCoords())}isSpillOverflow(){let e=this._rs?.spills;if(!e)return!1;if(!this._coords)return null;Array.isArray(e)||(bs[0]=e,e=bs);for(let t=0;t<e.length;t++){const n=e[t].getCoords();if(this._coords.colIndex===n.colStart&&this._coords.rowIndex===n.rowStart)return!1}return!0}get[Symbol.toStringTag](){return"[Cell]"}toString(){let e="{blank}";return this._v!==null&&(e=this.toTextUnformatted(),this.getType()===U.String&&(e=`'${e}'`)),`${this.getA1()} => ${e}`}get isICell(){return!0}}let Iw=class extends Wn{constructor(s){super(s,null,null,null)}isEmpty(){return!0}isContentful(){return!1}toString(){return"{EMPTY CELL}"}};class Rw{constructor(e,t,n){this._options=e,this._entry=t,this._coords=n}getTokens(e){const t=this._coords;return t?this._entry.getTokensAt(t.rowIndex,t.colIndex,e):F.EmptyArray}evaluate(e){const t=this._coords;return t?this._options.calcGraph().evaluateAt(t.rowIndex,t.colIndex,e):F.EmptyArray}toText(e){const t=this._coords;return t?"="+this._entry.getFormulaTextAt(t.rowIndex,t.colIndex,e):null}getDirectPrecedents(){const e=this._coords;return e?this._options.calcGraph().getDirectPrecedentsAt(e.rowIndex,e.colIndex):F.EmptyArray}getReferences(){const e=this._coords;return e?this._entry.getReferencesAt(e.rowIndex,e.colIndex):F.EmptyArray}setReferenceAt(e,t){const n=this._coords;return n?(this._options.calcGraph().setReferenceAt(n.rowIndex,n.colIndex,e,t),this):F.EmptyArray}get[Symbol.toStringTag](){return"[Formula]"}toString(){return this.toText()}}const bs=[null];let Ga;const Oi=(s,e,t,n=!1)=>{const r=t===exports.w.Orientation.Row,o=s.length,i=new Array(o);for(let a=0;a<o;a++){const l=s[a];if(r){const c=l.colEnd-l.colStart+1;i[a]={...l,colStart:n?l.colEnd+1:l.colStart,rowStart:e.rowStart,colEnd:n?l.colEnd+c:l.colEnd,rowEnd:e.rowEnd}}else{const c=l.rowEnd-l.rowStart+1;i[a]={...l,colStart:e.colStart,rowStart:n?l.rowEnd+1:l.rowStart,colEnd:e.colEnd,rowEnd:n?l.rowEnd+c:l.rowEnd}}}return i},qo=(s,e,t)=>{const n=e,r=s.length;for(let o=0;o<r;o++){const i=s[o];if((i.rowStart<=n.rowStart&&i.rowEnd>=n.rowEnd)!==t)return!t}return t},Jo=(s,e,t)=>{const n=e,r=s.length;for(let o=0;o<r;o++){const i=s[o];if((i.colStart<=n.colStart&&i.colEnd>=n.colEnd)!==t)return!t}return t},ld=(s,e)=>{let t=0;const n=s.length;for(let r=0;r<n;r++){const o=s[r];e===exports.w.Orientation.Column?t+=o.colEnd-o.colStart+1:t+=o.rowEnd-o.rowStart+1}return t},Aw=(s,e)=>{if(e){if(s.colStart<=e.colStart&&s.colEnd>=e.colEnd)return exports.w.Orientation.Row;if(s.rowStart<=e.rowStart&&s.rowEnd>=e.rowEnd)return exports.w.Orientation.Column}return s?(t=>t.rowEnd-t.rowStart>t.colEnd-t.colStart?exports.w.Orientation.Column:exports.w.Orientation.Row)(s):exports.w.Orientation.Row},Es=()=>!1,Ua=()=>!0,vs=()=>null,cd=()=>Xe,ln=()=>0,hd=new class extends Wn{constructor(){super(null,null)}createTemporaryCell(){return this}getType(){return U.Error}getWarnings(){return[Ye]}getStyle(s=!1){return Ga||(Ga=new Xr().getNormal(),Ga)}toString(){return`${this._coords?rs(this._coords):Ye} => ${this._v??"{blank}"}`}},Ut=()=>Pn,Pn={forEach:()=>{},[Symbol.iterator]:cd,entries:cd,select:_e,find:_e,calculate:_e,getCell:()=>hd,getValue:vs,setValue:_e,setValues:_e,updateCells:_e,updateStyle:_e,getCells:()=>[[hd]],getStyleUpdater:_e,getValues:()=>[[null]],getBounds:vs,getIntersect:Ut,getUnion:Ut,getDifferences:_e,getResizeBy:Ut,getResizeTo:Ut,getOffsetBy:Ut,getOffsetTo:Ut,getFixed:Ut,getUsedRange:Ut,getEntireRows:Ut,getEntireColumns:Ut,getSurrounding:_e,getExtended:_e,isEntireRows:Es,isEntireColumns:Es,isEntireRange:Es,getWidth:ln,getHeight:ln,size:0,sort:_e,clear:_e,setHyperlink:_e,setComments:_e,merge:_e,unmerge:_e,getMerges:_e,insert:_e,insertFrom:_e,delete:_e,getDefaultShiftOrientation:_e,getDefaultSortCriteria:_e,autoFill:_e,autoFit:_e,getSnapshot:_e,copyFrom:_e,doBatch:_e,startIncrementalUpdates:_e,getRowHeaders:_e,getColumnHeaders:_e,getCounts:_e,getCount:ln,isContentful:Es,addListener:_e,getColumnStart:ln,getRowStart:ln,getColumnEnd:ln,getRowEnd:ln,getRowCount:ln,getColumnCount:ln,getVisible:_e,getCoords:vs,isEmpty:Ua,toString:()=>Ye,getA1:()=>Ye,isInvalid:Ua,getSource:vs,isReadOnly:Ua,isICellRange:!0};function _n(s,e=null,t=null,n=Ye){return s||t?Object.freeze({...Pn,getSheet:()=>s,bounds:()=>t,getA1:()=>n,toString:()=>t?bn(t,e):n}):Pn}const Mw=/^[\\+-]?[0-9]*\.?[0-9]*$/,rf=(s,e,t)=>{if(s===void 0)throw new Error("A value is required to create a cell from a text.");const n=t??{value:null};if((s=F.castToString(s)).trim()==="")return n;if(s.toUpperCase()==="TRUE"||s.toUpperCase()==="FALSE")return n.value=s.toUpperCase()==="TRUE",n;if(s.startsWith("'")&&!e?.ignoreQuotePrefix)return n.style={quotePrefix:!0},n.value=s.substring(1,s.length),n;n.value=s;const r=",",o="$",i=".";let a=s.trim(),l=1,c=!1;a=(_=>{const p=new RegExp("([(]{1}([^(|^)]+)[)]{1})").exec(_);if(p?.[2]){const S=_.substring(0,p.index)+p[2].trim()+_.substring(p.index+("("+p[2]+")").length-1,_.length-1);return S.indexOf("(")>-1||S.indexOf(")")>-1?_:(c=!0,l=-1,S)}return _})(a);let h=0;a=(_=>{const p=new RegExp("[0-9]+([eE][-+]?[0-9]+)?$").exec(_);if(p?.[1]){const S=_.substring(0,_.length-p[1].length);let C=1,y=p[1].substring(1,p[1].length);if(y.startsWith("-")?(y=y.substring(1,y.length),C=-1):y.startsWith("+")&&(y=y.substring(1,y.length)),!isNaN(y))return h=y*C,S}return _})(a);let u=!1;if(a=(_=>{const p=new RegExp(`^(\\${o}[\\ ]*\\-|\\${o}[\\ ]*\\+|\\-[\\ ]*\\${o}|\\+[\\ ]*\\${o}|\\-|\\+)?`).exec(_);if(p?.[1]){const S=p?.[1].indexOf(o)>-1,C=p?.[1].indexOf("-")>-1,y=p?.[1].indexOf("+")>-1,b=(S?o:"")+_.substring(p.index+p[1].length,_.length).trim(),w=b.indexOf("-")>-1,E=b.indexOf("+")>-1;return w||E?_:(u=C||y,C&&(l=-1),b)}return _})(a),u&&(c||a.length===0))return n;let d=!1;if(a=(_=>{if(new RegExp(`^(?:\\${o}[\\ ]*)?((\\d{1,3}(${r}\\d{3})*)|(\\d*))(\\${i}|\\${i}\\d*)?(?:[\\ ]*\\%)?$`).test(a)){const p=_.replace(new RegExp(`${r}`,"g"),"");return d=p.length<_.length,p}return _})(a),a.match(Mw)&&!isNaN(a)){if(n.value=a*l,h!==0)n.value=n.value*Math.pow(10,h),n.style={numberFormat:`0${i+"0".repeat(2)}E+00`};else if(d){let _=Zs(a);n.style=_>0?{numberFormat:`#${r}##0${i+"0".repeat(2)}`}:{numberFormat:`#${r}##0`}}return n}if(a.trimEnd().endsWith("%")&&a.trimEnd().length>1){let _=a.substring(0,a.length-1);if(!isNaN(_)){n.value=_*l/100;const p=Zs(_);n.style=S=>{if(!S.getNumberFormat().includes("%"))return{numberFormat:p>0?`0${i+"0".repeat(2)}%`:"0%"}}}return n}if(a.startsWith(o)&&s.trim().length>1){let _=a.replace(o,"");if(!isNaN(_)){let p=Zs(_);n.value=_*l,n.style=S=>{if(S.getNumberFormat().includes(o))return;let C;return C=p>0?`${o}#${r}##0${i+"0".repeat(2)}_);[Red](${o}#${r}##0${i+"0".repeat(2)})`:`${o}#${r}##0_);[Red](${o}#${r}##0)`,{numberFormat:C}}}return n}let g=null,m=null;try{m=Kg(s,e?.date1904,!0);let _=s;m&&(_=m.leadingText),_.trim().length>0&&(g=ic(_,e?.date1904)),!g&&m?.leadingText.trim().length>0&&(m=null)}catch{}if(g||m){n.style=p=>{let S=p.getNumberFormat();const C=Zo(S);if(g&&C)return;const y=Wi(S);if(!m||!y){if(g&&m&&!C&&!y?S="m/d/yyyy h:mm":g&&!C?S=g.numberFormat:m&&!y&&(S=m.numberFormat),m&&m.parsed.oaDateTime>1&&(S="General"),g&&!C&&!m){const b=exports.NumberFormat.Parser.formatValue(g.numberFormat,g.asOADate,{date1904:e?.date1904}),w=Intl.DateTimeFormat().resolvedOptions().locale??"en-US";b===new Intl.DateTimeFormat(w).format(g.asJSDate)?S="Short Date":b===new Intl.DateTimeFormat(w,{dateStyle:"full"}).format(g.asJSDate)?S="Long Date":b===new Intl.DateTimeFormat(w,{timeStyle:"medium"}).format(g.asJSDate)&&(S="Long Time")}return{numberFormat:S}}};let _=0;return g&&(_+=g.asOADate),m&&(_+=m.parsed.oaDateTime),n.value=_,n}const f=exports.n.getBuiltInByLabel(s);return f?(n.value=f,n):(n.value=s,sm(s)?n.hyperlink=s:im(s)&&(n.hyperlink=s,n.hyperlink.toLowerCase().startsWith("mailto:")||(n.hyperlink=`mailto:${n.hyperlink}`)),n)},Tw=s=>{const e=s.getFont().getUnderline()===exports.IFont.UnderlineStyle.SingleAccounting,t=s.getFont().getUnderline()===exports.IFont.UnderlineStyle.DoubleAccounting;let n=0;return(e||t)&&(n=s.measureText("").underlineThickness+1,t?n*=2:n+=1),n},qa=s=>{const e=[];return s.getUsedRange().forEachSpan((t,n)=>{const r=n.getCoords();t===0&&e.push(r)},{includeStyles:!1}),Xt(rr(e))},Ja=(s,e,t,n)=>{const r=n?.asJSDate;let o;t?o=Hm:(r||n?.includeMergeOverflow)&&(o={},r&&(o[Q.Type.Style]=!1,o[Q.Type.Table]=!1),n.includeMergeOverflow&&(o[Q.Type.Merge]=!1));const i=n?.orientation??exports.w.Orientation.Row,a=n?.maxSize??1e4,l=s({includeEmpty:!0,orientation:i,reverse:n?.reverse,excludeHidden:n?.excludeHidden,includeMergeOverflow:n?.includeMergeOverflow,includeRangeTypes:o,bounds:e,excludeCellDetails:!r}),c=i!==exports.w.Orientation.Row,h=[];let u,d=-1,g=null,m=0;for(u=l.next();!u.done;){if(m>a)throw new Error(Vm(a));const f=u.value,_=f.context.getCoords(),p=c?_.colIndex:_.rowIndex;p!==d&&(g=[],h.push(g),d=p);let S=f.value;if(t)S=f.context.getCell();else if(r&&S!==null&&typeof S=="number"){const C=f.context.getCell().toDate();C&&(S=C)}g.push(S),u=l.next(),m++}return h},Oo=(s,e)=>s===e||!(!s||!e)&&s.rowStart===e.rowStart&&s.rowEnd===e.rowEnd&&s.colStart===e.colStart&&s.colEnd===e.colEnd&&s.$rowStart===e.$rowStart&&s.$rowEnd===e.$rowEnd&&s.$colStart===e.$colStart&&s.$colEnd===e.$colEnd,of=(s,e)=>{if(!s)return;const t={...s};return e?typeof e=="boolean"?(t.$colStart=e,t.$rowStart=e,t.$colEnd=e,t.$rowEnd=e,t):(typeof e.colStart=="boolean"&&(t.$colStart=e.colStart),typeof e.rowStart=="boolean"&&(t.$rowStart=e.rowStart),typeof e.colEnd=="boolean"&&(t.$colEnd=e.colEnd),typeof e.rowEnd=="boolean"&&(t.$rowEnd=e.rowEnd),t):t};class Xa{constructor(e,t,n){const r=this;this.setState=o=>{const i=o[0];let a=o[1],l=o[2];if(t&&t.includeMergeOverflow&&l&&l.merge){const h=t.bounds,u=l.merge.getCoords();let d=!1;const g=u.colStart,m=u.rowStart,f=h.colStart,_=h.rowStart,p=i.colIndex,S=i.rowIndex;!d&&g<f&&m>=_&&p===f&&S===m&&(d=!0),!d&&m<_&&g>=f&&S===_&&p===g&&(d=!0),!d&&m<_&&g<f&&S===_&&p===f&&(d=!0),d&&(a=l.merge.tvTl(),l=l.merge.rsTl())}l&&Object.keys(l).length===0&&(l=null);let c=a;return a===void 0?(this._t=null,this._v=null,c=null):(this._t=Ze(c),this._v=c),this._r=l,this._p=o[3],this._n=o[4],this._c=i,c},this.clear=()=>{r._c=null},this.context={getCoords(){const o=r._c;if(!o)throw new Error(Pr);return o},getCell(){const o=r._c;if(!o)throw new Error(Pr);if(this.excludeCellDetails)throw new Error("IteratorContext can only return a cell if the forEach excludeCellDetails has not been set to false.");const i=r._r,a=r._t,l=r._v;return l!==null||i?new Wn(n,o,a,l,i,r._p,r._n):new Wn(n,o)},getType:()=>r._t,getA1(o){if(!r.context)throw new Error(Pr);let i=r._c;return o&&(i={...r._c,...o}),n.resolveRange(i).toString()},toJSDate(o){if(r._t!==U.Number)return null;let i=o;if(i===void 0)i=r._v;else if(typeof i!="number")throw new Error("The arguments are not valid.");return Jr(i,n.date1904)}}}}const Cn=(s,e)=>{if(s||e)return s&&e?{...s,...e}:s||e},ud=(s,e,t,n=exports.w.Orientation.Row)=>{const r=s.getRange(e,{excludeHidden:n}),o=r.forEach((p,S)=>({break:S.getCoords()}),{excludeCellDetails:!0,orientation:n});if(!o)return;const i=n===exports.w.Orientation.Row,a=new Map,l=new Map,c=new Map;let h=null;const u=s.getRange(o).getMerges();let d=u.length>0?1+(i?u[0].rowEnd-u[0].rowStart:u[0].colEnd-u[0].colStart):1;const g=i?o.rowIndex:o.colIndex;if(r.forEach((p,S)=>{const C=S.getCoords(),y=i?C.colIndex:C.rowIndex,b=i?C.rowIndex:C.colIndex;if(b===g)a.set(y,p);else{if(b!==g+d)return ku;typeof p=="string"?h=!1:p!==null&&l.set(y,p)}if(h!=null)return ku},{orientation:n,excludeCellDetails:!0,address:e}),h===null){const p=l.entries();let S=p.next();for(;h===null&&!S.done;){const[C,y]=S.value,b=a.get(C);b&&(typeof b=="string"?c.set(C,b):h=!1),S=p.next()}h=h??c.size>0}const m={colStart:o.colIndex,rowStart:o.rowIndex,colEnd:e.colEnd,rowEnd:e.rowEnd};if(m.colStart>m.colEnd||m.rowStart>m.rowEnd||k.isSingleCell(m))return null;const f=Math.min(Math.max(t?.colIndex??0,m.colStart),m.colEnd),_=Math.min(Math.max(t?.rowIndex??0,m.rowStart),m.rowEnd);return{coords:m,options:{...exports.Sort.DefaultRangeOptions,hasHeader:h,orientation:n,offset:n===exports.w.Orientation.Row?f-m.colStart:_-m.rowStart},headers:c}},dd=(s,e,t=null)=>Br.fromArray(s,(n,r)=>{const o=n?.[1];if(o==null)return null;let i=n[0]??null;switch(o){case U.String:i=e.getById(i);break;case U.Error:i=exports.n.getBuiltInById(i)}return i},(n,r)=>{const o=Ze(n);let i=n;switch(o){case U.String:i=e.add(i);break;case U.Error:i=i.getCode()}return[i,o]},t),gd=(s,e)=>{const t=[],n=e?exports.w.Orientation.Column:exports.w.Orientation.Row,r=s.length;for(let o=0;o<r;o++){const i=s[o],a=i[0],l=i[1],c=l.length;for(let h=0;h<c;h++){const u=l[h],d=u[0],g=u[1].length-1,m={colStart:e?a:d,rowStart:e?d:a,colEnd:e?a:d+g,rowEnd:e?d+g:a,value:new Vt({colStart:e?a:d,rowStart:e?d:a,colEnd:e?a:d+g,rowEnd:e?d+g:a},n)};t.push(m)}}return t},co=(s,e,t=-1)=>{if(!s||s.length===0)return null;const n=s.length===1&&s[0].rowStart===s[0].rowEnd&&s[0].colStart===s[0].colEnd,r=t===-1?s.length-1:Math.min(Math.max(0,t),s.length-1);return{cell:e??{rowIndex:s[r].rowStart,colIndex:s[r].colStart},ranges:n?[]:[...s],rangeIndex:n?-1:r}},Ar=s=>{if(!s)return null;const e=[];if(s.ranges&&s.ranges.length>0){const t=Math.max(0,Math.min(s.rangeIndex??0,s.ranges.length));for(let n=t;n<s.ranges.length;n++)e.push(s.ranges[n]);for(let n=0;n<t;n++)e.push(s.ranges[n])}else s.cell&&e.push(k.cellToRange(s.cell));return e},De=(s,e)=>{if(!s||s.length===0)return null;let t=s.length-1;const n=s[t],r=s[0];if(!r||!r)return null;const o=s.length===1&&r.rowStart===r.rowEnd&&r.colStart===r.colEnd;return n?{cell:{rowIndex:n.rowStart,colIndex:n.colStart},ranges:o?[]:[...s],rangeIndex:o?-1:t}:null},md="Item has been closed. No further operations are allowed.";class Xi{constructor(e){if(this._emitter=null,this._closed=!1,!e)throw new Error("Anchored.ConstructorOptions is required");if(this._options={...e},!this._options.initialAnchor)throw new Error("Initial anchor is required");const t=this;this._transactions=this._options.transactions??new Lt({transient:!0}),this._emitter=new st(this,this._transactions),this._updateState({anchor:this._options.initialAnchor},{description:e?.createDescription??"Create Anchored Item"}),this._options.setContainerShiftCallback?.(n=>t._processContainerShift(n)),this._options.setContainerLayoutCallback?.(()=>{t._processContainerLayout()}),this._options.setContainerDeleteCallback?.(()=>{t._processContainerDelete()}),this._options.setContainerProtectionCallback?.(()=>{t._processContainerProtection()}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onBeforeCommitStart(n,r,o){t._processBeforeCommitStart(n,r,o)},onAfterStateChange(n,r,o){t._processStateChange(n,r,o),t._processAnchorCoords(),t._emitter.notify("onAnchorCoordsChange")},onRestoreOrRevert(n,r,o){t._processRestoreOrRevert(n,r,o)}})}_getEmitter(){return this._emitter}delete(e){this._options.deleteFromContainer?.(e)}getAnchorCoords(){return this._getState()?.anchor??null}getAnchorType(){return this._getState()?.anchorType??exports.IAnchored.Type.TwoCell}isProtected(){return this._options.isProtected?.()??!1}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(md);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_getTransactions(){return this._transactions}_updateState(e,t,n){if(this._closed)throw new Error(md);if(!e)return;const r=this._beginCommit(t?.description);try{r.updateState(this,e);let o=!1;if(n)for(let i=0;i<n.length;i++){const a=n[i];o=o||a==="onAnyChange",this._emitter.notify(a)}!o&&n&&n.length>0&&this._emitter.notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_processContainerShift(e){let t=null;const n={anchor:e.after};return e.after||(n.isDeleted=!0,t=["onDelete"]),this._updateState(n,{description:"Update Anchor"},t),e.after}_processBeforeCommitStart(e,t,n){}_processStateChange(e,t,n){}_processRestoreOrRevert(e,t,n){this._emitter.notify("onInvalidated")}_processAnchorCoords(){}_processContainerLayout(){}_getDescription(){return null}_delete(){const e=this._getDescription(),t="Delete",n=e?`${t} ${e}`:t,r=this._beginCommit(n);try{this._processDelete(),r.commit()}catch(o){throw r.rollback(),o}}_processContainerDelete(){this._processDelete()}_processDelete(){}_processContainerProtection(){this._emitter.notify("onProtectedChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}_processClose(){this._closed=!0,this._emitter.notify("onClose"),this._transactionsRemoveListener?.()}close(){this._closed||this._processClose()}get isIAnchored(){return!0}}var $n;exports.AddressUtils=void 0,($n=exports.AddressUtils||(exports.AddressUtils={})).fastStringToCol=q_,$n.fastStringToCell=Fr,$n.fastStringToRange=Ct,$n.rangeToString=bn,$n.cellToString=Hn,$n.normalizeA1ToR1C1=Y_,$n.resolveRelativeToA1=K_;const Fw=(s,e)=>s.offset-e.offset,fd=s=>{if(!s||s.size===0)return[];let e=[];return s.forEach((t,n)=>{t&&Object.keys(t).length!==0&&e.push({...t,offset:n})}),e.sort(Fw)};class Nw extends Xi{constructor(e){super({...e,createDescription:"Insert AutoSort"}),this._apply=e.apply,this._processUpdate=e.processUpdate,this._fromJSON(e.json)}getRange(){return this._getState().anchor}getFieldAt(e){const t=this._getState().byOffset.get(e)??null;return t?Object.keys(t).length===0||Object.keys(t).length===1&&t.hasOwnProperty("offset")?null:{collatorOptions:null,...t}:null}insertSort(){return null}getSort(){return null}apply(e){const t=this._getState().byOffset,n=new Map(t);for(let r=0;r<e.length;r++){const o={...e[r]},i=o.offset;delete o.offset,n.set(i,o)}return this._updateState({byOffset:n},{description:"Set Sort Criteria"}),this.reapply()}setFieldAt(e,t){const n=this._getState().byOffset,r=new Map(n);return t&&Object.keys(t).length>0?r.set(e,t):r.delete(e),this._updateState({byOffset:r},{description:"Sort"}),this.reapply()}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._processUpdate?.()}reapply(){const e=this._getState(),t=fd(e.byOffset);return this._apply?.(t),this}clear(){return this._updateState({byOffset:new Map},{description:"Clear Sort"}),this.reapply()}_fromJSON(e){const t=e??{},n={byOffset:new Map};if(t.fields)for(let r=0;r<t.fields.length;r++){let o=t.fields[r];const i=o.offset;o={...t.fields[r]},delete o.offset,n.byOffset.set(i,o)}this._updateState(n,{description:"Load"})}toJSON(){const e={},t=this._getState();t.anchor&&(e.ref=exports.AddressUtils.rangeToString(t.anchor,this._options.maxRangeCoords));const n=fd(t.byOffset);return n.length>0&&(e.fields=n),Object.keys(e).length===0?null:e}}const kw=(s,e)=>s.offset-e.offset,Ka=s=>{if(!s||s.size===0)return[];let e=[];return s.forEach((t,n)=>{t&&Object.keys(t).length!==0&&e.push({...t,offset:n})}),e.sort(kw)},pd=(s,e=new Map)=>{if(!s||s.length===0)return e;for(let t=0;t<s.length;t++){const n={...s[t]},r=n.offset;delete n.offset,e.set(r,n)}return e},Ya=s=>{let e=0;const t=s.entries();let n=null;do n=t.next(),n.value?.[1]&&n.value[1].hiddenButton&&e++;while(!n.done);return e};class sf extends Xi{constructor(e){super({...e,createDescription:"Insert AutoFilter"}),this._apply=e.apply,this._processUpdate=e.processUpdate,e.setFilterCoordsCallback?.(t=>{this._getState().anchor}),this._fromJSON(e.json)}getCoords(){return this._getState().anchor}getFieldAt(e){const t=this._getState().byOffset.get(e)??null;return t?Object.keys(t).length===0||Object.keys(t).length===1&&t.hasOwnProperty("offset")?null:{hiddenButton:!1,criteria:F.EmptyArray,...t}:null}insertSort(){return null}getSort(){return null}apply(e){const t=this._getState().byOffset,n=new Map(t);return pd(e,n),this._updateState({byOffset:n,hiddenCount:Ya(n)},{description:"Set Filter Criteria"}),this.reapply()}setFieldAt(e,t){const n=this._getState(),r=n.anchor.colEnd-n.anchor.colStart+1;if(e<0||e>r-1)throw new Error(`Invalid range: '${e}'`);const o=n.byOffset,i=new Map(o);t&&Object.keys(t).length>0?i.set(e,t):i.delete(e);const a=o.get(e)?.hiddenButton===!0?1:0,l=t?.hiddenButton===!0?1:0;return this._updateState({byOffset:i,hiddenCount:Math.min(r,Math.max(0,n.hiddenCount+l-a))},{description:"Set Filter Criteria"}),this.reapply()}getShowFilterButton(){const e=this._getState(),t=e.anchor,n=t.colEnd-t.colStart+1;return e.hiddenCount<n}setShowFilterButton(e){const t=this.getAnchorCoords(),n=t.colEnd-t.colStart+1;let r=Array(n);const o=this._getState().byOffset,i=Ka(o);for(let l=0;i&&l<i.length;l++){const c={...i[l]};r[c.offset]=c,e?delete c.hiddenButton:c.hiddenButton=!0}if(!e)for(let l=0;l<r.length;l++)r[l]||(r[l]={hiddenButton:!0});const a=new Map;for(let l=0;l<r.length;l++){const c=r[l];a.set(l,c)}return this._updateState({byOffset:a,hiddenCount:e?a.size:0},{description:(e?"Hide":"Show")+" Filter Buttons"}),this._processUpdate?.(),this}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._processUpdate?.()}_processContainerShift(e){if(e.after&&e.orientation===exports.w.Orientation.Column){let t=e.intersect.colStart-e.before.colStart,n=e.amount;t<=0&&(n-=t,t=0);const r=this._getState().byOffset,o=new Map(r);if(r.forEach((i,a)=>{i&&Object.keys(i).length!==0&&(a>=t&&o.delete(a),a>t&&o.set(a+n,i))}),n>0&&this._getState().hiddenCount>0)for(let i=t;i<t+n;i++)o.set(i,{hiddenButton:!0});this._updateState({byOffset:o,hiddenCount:Ya(o),sort:null},{description:"Update Fields"})}return super._processContainerShift(e)}reapply(){const e=this._getState(),t=Ka(e.byOffset);return this._apply?.(t),this}clear(){return this._updateState({byOffset:new Map,hiddenCount:0,sort:null},{description:"Set Filter Criteria"}),this.reapply()}_fromJSON(e){const t=e??{},n={byOffset:new Map,hiddenCount:0};t.fields&&(pd(t.fields,n.byOffset),n.hiddenCount=Ya(n.byOffset)),t.sort,this._updateState(n,{description:"Load"})}toJSON(){const e={},t=this._getState();t.anchor&&(e.ref=bn(t.anchor,this._options.maxRangeCoords));const n=Ka(t.byOffset);return n.length>0&&(e.fields=n),t.sort,Object.keys(e).length===0?null:e}}const ql="A table must have a least one row for the data.",_d="Table1",xs=Object.freeze({showRowStripes:!0,showColumnStripes:!1,showFirstColumn:!1,showLastColumn:!1}),Sd=(s,e,t)=>{if(s.length!==e.length)return console.warn("make columns the same length"),!1;const n=new Set;for(let l=0;l<e.length;l++){const c=e[l]?.name;c&&n.add(c.toLocaleLowerCase())}for(let l=0;t&&l<t.length;l++){const c=t[l]?.name;c&&n.add(c.toLocaleLowerCase())}const r=(l,c="")=>{if(!l)return!1;const h=l.toLocaleLowerCase();return h===c||!n.has(h)};let o=1;const i=(l,c,h,u,d=1e3)=>{if(u(l,h=(h??"").trim().toLocaleLowerCase()))return l;for(;o<d;)try{const g=c+ ++o;if(u(g,h))return g}catch{}throw new Error(`Unable to find valid name for '${c}'.`)};let a=0;for(let l=0;l<s.length;l++){const c=s[l]?.name;if(c&&c===e[l]?.name)continue;const h=i(c,s[l]?.name||"Column",e[l]?.name,r);n.add(h.toLocaleLowerCase()),e[l]?.name!==h&&(s[l].name=h,a++)}return a>0};class Ow{constructor(e,t,n,r){this._name=e,this._filter=t,this._sort=n,this._offset=r}getName(){return this._name}getField(){return this._filter?this._filter.getFieldAt(this._offset)??null:null}setField(e){return this._filter?(this._filter.setFieldAt(this._offset,e),this):this}getSortField(){return this._sort?this._sort.getFieldAt(this._offset):null}setSortField(e){return this._sort?(this._sort.setFieldAt(this._offset,e),this):this}reapply(){return this._filter?.reapply(),this}clear(){return this._filter?.setFieldAt(this._offset,null),this._sort?.setFieldAt(this._offset,null),this}hasHiddenButton(){return this._filter?.getFieldAt(this._offset)?.hiddenButton??!1}}class Bw extends ym{constructor(e,t,n,r){super({...r,type:"namedTable"}),this._names=e,this._sheet=t,this._table=n;const o=this;this._table.addListeners({onDelete:()=>{o._options.deleteFromContainer?o._options.deleteFromContainer?.():o._delete()},onAnyChange:()=>{o._emitter.notify("onAnyChange")},onAnchorCoordsChange:()=>{o._emitter.notify("onAnyChange")}},{transactional:!0})}async select(e){return await this._table.select(e),this}getRanges(){return this._names.getRanges(this._table.getUsedRange())}getScope(){return null}getType(){return"table"}getName(){return this._table.getName()}getValue(){return this._table}}class af extends Xi{constructor(e){if(super({...e,createDescription:"Insert Table"}),this._isUpdatingHeader=!1,this._colHeadersSizeUnlistener=null,this._rowHeadersSizeUnlistener=null,this._visibleRange=null,this._isHeaderVisible=!0,this._isTotalVisible=!0,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0,this._range=null,!e.json)throw new Error("json is required");if(!e.json.ref)throw new Error("json.ref is required");const t=this;this._styles=e.styles??e.sheet?.getStyles()??new Xr,this._names=e.names,this._sheet=e.sheet,this._processTableUpdate=e.processTableUpdate,this._setNameOnContainer=e.setNameOnContainer,this._options={...e},this._styleCache=null,this._stylePropsCache=null,this._stylesRemoveListener=this._styles.addListeners({onTableStylesChange(){t._styleCache=null,t._stylePropsCache=null,t._getEmitter().notify("onStyleChange"),t._getEmitter().notify("onAnyChange")}});const n={...e?.json};if(e.sheet){const r=e.sheet;if(this._autoExpandRemoveListener=r.getEntireRange().addListener(a=>{if(a.trigger!=="setCells"||a.isUndo)return;const l=t.getAnchorCoords();if(!l)return;let c=a.getSource().getCoords();Array.isArray(c)&&(c=c[0]);let h=null;if(c.rowStart>=l.rowStart&&c.rowEnd<=l.rowEnd&&c.colStart>=l.colStart&&c.colStart<=l.colEnd+1&&c.colEnd>l.colEnd){const u={...c,colStart:l.colEnd+1};if(r.getRange(u).isContentful()){const d={...u,rowStart:l.rowStart,rowEnd:u.rowStart-1};if(d.rowEnd-d.rowStart<0||!r.getRange(d).isContentful()){const g={...u,rowStart:u.rowEnd+1,rowEnd:l.rowEnd};(g.rowEnd-g.rowStart<0||!r.getRange(g).isContentful())&&(h={...l,colEnd:c.colEnd})}}}else if(!t.getShowTotals()&&c.colStart>=l.colStart&&c.colEnd<=l.colEnd&&c.rowStart>=l.rowStart&&c.rowStart<=l.rowEnd+1&&c.rowEnd>l.rowEnd){const u={...c,rowStart:l.rowEnd+1};if(r.getRange(u).isContentful()){const d={...u,colStart:l.colStart,colEnd:u.colStart-1};if(d.colEnd-d.colStart<0||!r.getRange(d).isContentful()){const g={...u,colStart:u.colEnd+1,colEnd:l.colEnd};(g.colEnd-g.colStart<0||!r.getRange(g).isContentful())&&(h={...l,rowEnd:c.rowEnd})}}}if(h&&r.getRange(h).getMerges().length>0&&(h=null),h&&r.getTables().search({address:h}).length!==1&&(h=null),h){const u=t._beginCommit("Table Auto Expansion");try{t.resize(h),u.commit({viewAfter:null})}catch(d){u.rollback(),console.warn("Unable to AutoExpand"),console.warn(d)}}},{transactional:!1,ignoreShifts:!0}),this._headerValueListener=()=>{if(this._isUpdatingHeader)return;const a=this._columnsFromSheet();a&&this._updateColumns(a.columns,!1,a.forceUpdate,null)},e.readSheetHeader){const a=this._columnsFromSheet();n.columns=a.columns}const o=()=>{const a=this.getAnchorCoords();let l=0,c=0;if(a&&(l=r.getColumnHeaders().findVisibleIndex(a.colEnd).min,c=r.getRowHeaders().findVisibleIndex(a.rowEnd).min),a&&(l<a.colEnd||c<a.rowEnd)){const h=r.getColumnHeaders(),u=r.getRowHeaders(),d=h.findVisibleIndex(a.colStart).max,g=u.findVisibleIndex(a.rowStart).max;this._visibleRange={colStart:d,colEnd:l,rowStart:g,rowEnd:c},this._isHeaderVisible=!u.at(a.rowStart).isHidden(),this._isTotalVisible=!u.at(a.rowEnd).isHidden(),this._isFirstColumnVisible=!h.at(a.colStart).isHidden(),this._isLastColumnVisible=!h.at(a.colEnd).isHidden()}else this._visibleRange=null,this._isHeaderVisible=!0,this._isTotalVisible=!0,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0},i={onSizesChange:()=>{o()}};this._colHeadersSizeUnlistener=r.getColumnHeaders().addListeners(i),this._rowHeadersSizeUnlistener=r.getRowHeaders().addListeners(i),o()}this._fromJSON(n),this._names&&(this._namedItem=this._createNamed(),this._namedItem&&this._names.add(this._namedItem))}getSnapshot(e){const t=this.toJSON(),n=this.getAnchorCoords(),r=this.getName(),o={...t};delete o.ref;const i=this,a=Object.freeze({...e});let l=!1;return{async copyTo(c,h){const u=c.tables,d=c.range;({...a,...h}).isCut&&!l&&(i.delete(),l=!0);const g={colStart:d.colStart,rowStart:d.rowStart,colEnd:n.colEnd-n.colStart+d.colStart,rowEnd:n.rowEnd-n.rowStart+d.rowStart};return u.add(g,{json:o,isLoad:!0,hasHeader:!0,styleName:o.styleOptions?.name??null}),g},getCoords:()=>n,getSource:()=>i,getName:()=>r,getMarkOptions:()=>a,isISnapshot:!0}}getAnchorType(){return exports.IAnchored.Type.TwoCell}getStyle(){if(this._styleCache)return this._styleCache;const e=this._getState();return e?(this._styleCache=this._styles.getTableStyle(e.styleOptions.name)??this._styles.getDefaultTableStyle(),this._styleCache):this._styles.getTableStyle(null)}addRows(e,t=1){const n={...this._getState().anchor};return n.rowEnd+=t,this._modifyTable({anchor:n},"Add Table Row"+(t>1?"s":"")),this}deleteRowsAt(e,t=1){let n={...this._getState().anchor};return n.rowEnd-=t,n.rowEnd<n.rowStart&&(n=null),this._modifyTable({anchor:n},"Delete Table Row"+(t>1?"s":"")),this}addColumn(e,t){const n=this._getState(),r={...n.anchor};r.colEnd+=1;const o=[],i={name:`${t??n.columns[e-1]?.name??`Column${e+1}`}3`};o.push(i);const a=[...n.columns.slice(0,e),...o,...n.columns.slice(e)];return this._modifyTable({anchor:r,columns:a},"Add Table Column"),i}getColumns(){return this._getState()?.columns}convertToRange(e=Number.MAX_SAFE_INTEGER){let t=this._beginCommit("Convert to Range");try{if(this._sheet){const n=this.getAnchorCoords(),r=(n.colEnd-n.colStart+1)*(n.rowEnd-n.rowStart+1);if(r>e)throw new Error(`There are ${r} and there is a limit of ${e}.`);const o=this._sheet.getRange(n),i=o.startIncrementalUpdates({orientation:exports.w.Orientation.Column});o.forEach((a,l)=>{const c=l.getCoords(),h=l.getCell();i.pushAt(c.rowIndex,c.colIndex,{style:h.getStyle(!1)})},{includeEmpty:!0,orientation:exports.w.Orientation.Column}),i.apply()}this.delete()}catch{t.rollback(),t=null}return t&&t.commit(),this._sheet.getRange(this._getState()?.anchor)}resize(e,t="Resize Table"){let n=this._sheet.getRange(e).getCoords();const r=this._getState().anchor;if(r.rowStart!==n.rowStart||n.colEnd<r.colStart||n.colStart>r.colEnd)throw new Error("The top of the table must not change and the new table location must overlap with the original table.");const o=this._beginCommit(t);try{n=this._options.setContainerCoords(e),k.isEqualRanges(n,r)||this._modifyTable({anchor:n}),o.commit()}catch(i){throw console.warn(i),o.rollback(),i}return this._sheet.getRange(n)}getName(){return this._getState()?.name}setName(e){const t=this._beginCommit(`Set Table Name '${e}'`);try{this._modifyTable({name:e}),t.commit()}catch(n){throw t.rollback(),n}return this}getDescription(){return this._getState()?.description}setDescription(e){return this._modifyTable({description:e})}select(e){return this.getUsedRange().select(e)}getRange(){return this._range?this._range:this._getState()?this._range=this._sheet.getRange(this._getState().anchor):Pn}_processRestoreOrRevert(e,t,n){this._styleCache=null,super._processRestoreOrRevert(e,t,n)}_processAnchorCoords(){this._range=null,super._processAnchorCoords()}getUsedRange(){const e=this._getUsedCoords();return e?this._sheet.getRange(e):Pn}_getUsedCoords(){const e=this._getState(),t=e.headerRowCount,n=e.totalsRowCount,r=e.anchor;if(!r)return null;const o={...r,rowStart:r.rowStart+t,rowEnd:r.rowEnd-n};return o.rowEnd<o.rowStart||o.colEnd<o.colStart?null:o}getHeaderRange(){const e=this._getHeaderCoords();return e?this._sheet.getRange(e):Pn}_getHeaderCoords(){const e=this._getState(),t=e.headerRowCount;if(t<1)return null;const n=e.anchor;return n?{...n,rowEnd:n.rowStart+t-1}:null}getTotalRange(){const e=this._getTotalCoords();return e?this._sheet.getRange(e):Pn}_getTotalCoords(){const e=this._getState(),t=e.totalsRowCount;if(t<1)return null;const n=e.anchor;return n?{...n,rowStart:n.rowEnd-t+1}:null}getStyleOptions(){return this.isClosed()?xs:this._getState()?.styleOptions}updateStyleOptions(e,t="Update Style Info"){const n=this.getStyleOptions(),r=e?{...n,...e}:xs;return this._modifyTable({styleOptions:r},t),this._styleCache=null,this._getEmitter().notify("onStyleChange"),this}getStyleAt(e){let t=this._stylePropsCache;return t||(t=this.getStyle().getRanged(this),this._stylePropsCache=t),$r(this._styles,t,k.cellToRange(e))}getShowTotals(){return this._getState()?.totalsRowCount>0}setShowTotals(e){return this._modifyTable({totalsRowCount:e?1:0},"Toggle Show Totals")}getShowHeaders(){return this._getState()?.headerRowCount>0}setShowHeaders(e){return this._modifyTable({headerRowCount:e?1:0},"Toggle Show Headers")}getShowFilterButton(){const e=this.getFilter();return!!e&&e.getShowFilterButton()}setShowFilterButton(e){const t=this.getFilter();return t?(t.setShowFilterButton(e),this):this}_applyFilterAndSort(){console.log("apply Filter",this.getFilter(),this.getSort()),this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_processUpdate(){this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_createFilter(e){const t=this;return new sf({initialAnchor:this._getUsedCoords(),maxRangeCoords:this._options.maxRangeCoords,json:e,transactions:this._getTransactions(),setContainerShiftCallback(n){t._filterShiftCallback=n},setFilterCoordsCallback(n){t._filterCoordsCallback=n},deleteFromContainer:n=>{this._updateState({filter:null},{description:n?.description??"Delete Filter"}),t._processUpdate?.()},apply:n=>{t._applyFilterAndSort()},processUpdate:()=>{t._processUpdate?.()},isProtected:()=>t.isProtected()})}insertFilter(){let e=this.getFilter();return e||(e=this._createFilter(),this._updateState({filter:e},{description:"Insert Filter"}),e)}getFilter(){return this._getState()?.filter??null}_createSort(e){const t=this;return new Nw({initialAnchor:this._getUsedCoords(),maxRangeCoords:this._options.maxRangeCoords,json:e,transactions:this._getTransactions(),deleteFromContainer:n=>{this._updateState({sort:null},{description:n?.description??"Delete Sort"}),t._processUpdate?.()},apply:n=>{t._applyFilterAndSort()},processUpdate:()=>{t._processUpdate?.()},isProtected:()=>t.isProtected()})}insertSort(){let e=this.getSort();return e||(e=this._createSort(),this._updateState({sort:e},{description:"Insert Sort"}),e)}getSort(){return this._getState()?.sort??null}getColumnFilter(e){const t=this.getFilter();if(!t)return null;const n=this.getSort();let r=null;return r=this._getState()?.columns[e],r===null?null:new Ow(r.name,t,n,e)}getVisibleRefRangeCoords(){return this._visibleRange?this._visibleRange:this.getAnchorCoords()}getVisibleCellCoords(e){return e&&this._visibleRange?{colIndex:Math.min(this._visibleRange.colEnd,Math.max(this._visibleRange.colStart,this._sheet.getColumnHeaders().findVisibleIndex(e.colIndex).min)),rowIndex:Math.min(this._visibleRange.rowEnd,Math.max(this._visibleRange.rowStart,this._sheet.getRowHeaders().findVisibleIndex(e.rowIndex).min))}:e}isHeaderVisible(){return this._isHeaderVisible}isTotalVisible(){return this._isTotalVisible}isFirstColumnVisible(){return this._isFirstColumnVisible}isLastColumnVisible(){return this._isLastColumnVisible}_columnsFromSheet(){const e=this._getHeaderCoords();if(!e||!this._sheet){const n=this.getAnchorCoords();return{columns:n?Array(n.colEnd-n.colStart+1).fill(null):[],forceUpdate:!0}}const t={columns:[],forceUpdate:!1};return this._sheet.getRange({...e,rowEnd:e.rowStart}).forEach((n,r)=>{const o=r.getCell();t.columns.push({name:o.toText()}),t.forceUpdate=t.forceUpdate||o.getType()!==U.String},{includeEmpty:!0}),t}_updateColumns(e,t,n=!1,r){if(this._isUpdatingHeader)return;const o=this._getHeaderCoords(),i=this._getUsedCoords(),a=[];if(i){const d=i.colEnd-i.colStart+1;for(let g=0;g<d;g++){const m=e[g];a.push({...m})}}let l=!1;const c=this._getState().columns;if(l=t?((d,g)=>{const m=new Set,f=S=>!!S&&!m.has(S.toLocaleLowerCase()),_=(S,C,y,b)=>b(S)?S:C+(y+1);let p=0;for(let S=0;S<d.length;S++){const C=_(d[S]?.name||g[S]?.name,d[S]?.name||"Column",p,f);m.add(C.toLocaleLowerCase()),d[S]?.name!==C&&(d[S].name=C,p++)}return p>0})(a,c):Sd(a,c,r),!(n||c.length!==a.length||l))return;const h="Update Columns";this._isUpdatingHeader=!0;let u=this._beginCommit(h);try{if(this._updateState({columns:a},{description:h}),this._sheet&&o){const d=this._sheet.getEntireRange().startIncrementalUpdates({orientation:exports.w.Orientation.Row});for(let g=0;g<a.length;g++){const m=a[g].name;d.pushAt(o.rowStart,o.colStart+g,m)}d.apply({textParser:!1})}}catch{u.rollback()}return u&&u.commit(),this._isUpdatingHeader=!1,a}_processDelete(){this._getState().headerRemoveListener?.(),this._updateState({headerRemoveListener:null}),super._processDelete()}_processFilterUpdate(){const e=this._getUsedCoords();console.log("process on Filter and Sort dataRange",e)}_processContainerShift(e){if(e.isSplit)throw new Error("We can not partially insert or remove cells as this would split a table.");const t=this._getState();if(e.after&&e.after.rowStart+t.headerRowCount>=e.after.rowEnd+1)throw new Error(ql);const n=e.orientation===exports.w.Orientation.Column;if(e.amount<0&&e.after&&!n){const o=this._getHeaderCoords();if(o&&e.intersect.rowStart<=o.rowEnd&&e.intersect.rowEnd>=o.rowStart)throw new Error("We can not remove rows that contain table headers. Remove the table header.")}const r=super._processContainerShift(e);if(n){let o=e.amount,i=e.intersect.colStart-e.before.colStart;if(i<=0&&o>0)return;i<0&&(o-=i,i=0);const a=this._getState()?.columns;let l=[...a],c=[],h=[];if(o>0){l.splice(i,0,...Array(o).fill(null)),c=[...l];const u=new Set;for(let _=0;_<a.length;_++)u.add(a[_]?.name?.toLowerCase().trim());const d=a[i-1],g=d?.name?.match(/\d+$/);let m=null,f=0;g&&(m=g.input.substring(0,g.index),f=parseInt(g[0]));for(let _=0;_<o;_++){let p={...d};c[i+_]=p;const S=m+(f+_+1);S&&!u.has(S.toLowerCase().trim())&&(p.name=S)}Sd(c,l,null)}else c=l,h=c.splice(i,-o);this._updateState({columns:c},{description:"Process Columns"}),this._updateColumns(c,!1,!0,h)}else e.after||this._updateState({columns:[]},{description:"Process Columns"});return e.after||this._delete(),this._filterShiftCallback&&this._filterShiftCallback({...e,after:this._getUsedCoords()}),r}_modifyTable(e,t="Modify Table"){if(this.isClosed())throw new Error("Table has been closed. No further operations are allowed.");const n=this._getState(),r=n.anchor,o=n.headerRowCount,i=this._getHeaderCoords();let a=this._beginCommit(t);try{if(this._updateState(e),e.name!==void 0){if(!e.name)throw new Error("Table must have a name.");this._setNameOnContainer?.(e.name)}let l=e.anchor??null;if((e.anchor!==void 0||e.headerRowCount!==void 0||e.totalsRowCount!==void 0)&&e.headerRowCount!==void 0&&o!==e.headerRowCount)if(e.headerRowCount>o){const c=r.rowStart-(e.headerRowCount-o);this._sheet&&(c<this._options.maxRangeCoords.rowStart||this._sheet.getRange({...r,rowStart:c,rowEnd:r.rowStart-1}).isContentful())?(this._sheet.getRange({...r,rowStart:r.rowStart+e.headerRowCount,rowEnd:r.rowStart+e.headerRowCount}).insert(exports.w.Orientation.Row),l={...r,rowEnd:r.rowEnd+(e.headerRowCount-o)}):l={...r,rowStart:r.rowStart+(o-e.headerRowCount)}}else i&&this._sheet&&this._sheet.doBatch(()=>{this._sheet.getRange(i).clear()},{}),l={...r,rowStart:r.rowStart+(o-(e.headerRowCount??o))};if(l){let c=n.columns;const h=e.headerRowCount!==void 0&&e.headerRowCount!==n.headerRowCount||e.totalsRowCount!==void 0&&e.totalsRowCount!==n.totalsRowCount,u=l.colStart!==r.colStart||l.colEnd!==r.colEnd;let d=[];if(u){const g=[...n.columns];l.colEnd>r.colEnd?g.splice(r.colEnd+1,0,...Array(l.colEnd-r.colEnd).fill(null)):l.colEnd<r.colEnd&&(d=g.splice(l.colEnd-1,r.colEnd-l.colEnd)),l.colStart<r.colStart?g.splice(0,0,...Array(r.colStart-l.colStart).fill(null)):l.colStart>r.colStart&&(d=d.concat(g.splice(0,l.colStart-r.colStart))),c=g}if(this._options.setContainerCoords?.(l),this._updateState({anchor:l,columns:c},{description:t}),!this._getUsedCoords())throw new Error(ql);if(u||h){const g=h?{columns:c,forceUpdate:!0}:this._columnsFromSheet();g&&(this._updateColumns(g.columns,!1,g.forceUpdate,d),this._processHeaderListener())}this._filterCoordsCallback?.(l)}e.styleOptions!==void 0&&(this._styleCache=null),this._getEmitter().notify("onAnyChange"),a.commit()}catch(l){throw a.rollback(),l}return this}addListeners(e,t){return this._emitter.addListeners(e,t)}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._styleCache=null,this._stylePropsCache=null,this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_processHeaderListener(){if(this._getState().headerRemoveListener?.(),this._sheet){let t=this._getHeaderCoords();if(!t){const r=this._getUsedCoords();t={...r,rowEnd:r.rowStart}}const n=this._sheet.getRange(t).addListener(this._headerValueListener,{transactional:!0});this._updateState({headerRemoveListener:n})}}toJSON(){const e={},t=this._getState();if(!t)return null;if(t.name&&(e.name=t.name),t.anchor&&(e.ref=bn(t.anchor,this._options.maxRangeCoords)),t.description&&(e.description=t.description),t.headerRowCount!==1&&(e.headerRowCount=t.headerRowCount),t.totalsRowCount!==0&&(e.totalsRowCount=t.totalsRowCount),t.columns&&(e.columns=[...t.columns]),t.styleOptions){const n=F.diffValues(t.styleOptions,{...xs,name:null});n&&(e.styleOptions=n)}if(t.filter){const n=t.filter.toJSON();n&&(e.filter=n,delete e.filter.ref)}return e}_createNamed(){return this._sheet?.getName()&&this._names?new Bw(this._names,this._sheet,this,{transactions:this._getTransactions(),json:{name:this.getName()}}):null}_fromJSON(e){const t=e??{},n={headerRowCount:1,totalsRowCount:0};var r;if(t.name&&(n.name=t.name),t.ref&&(t.ref=(r=t.ref)&&typeof r=="string"?Ft(r):r),this._names){const a=this._names.findValidName(n.name??_d);n.name!==a&&(n.name=a)}n.name||(n.name=_d),t.description&&(n.description=t.description),t.headerRowCount!==void 0&&(n.headerRowCount=t.headerRowCount),t.totalsRowCount!==void 0&&(n.totalsRowCount=t.totalsRowCount),n.columns=t.columns??F.EmptyArray,n.styleOptions={...xs,...t.styleOptions};const o="Insert Table";this._updateState(n,{description:o});const i=this._columnsFromSheet();i&&(n.columns=this._updateColumns(i.columns,!0,i.forceUpdate,null),delete n.columns),t.sort&&(n.sort=this._createSort(t.sort)),t.filter&&(n.filter=this._createFilter(t.filter)),this._modifyTable(n,o),this._processHeaderListener()}close(){super.close(),this.isClosed()||(this._autoExpandRemoveListener?.(),this._getState()?.headerRemoveListener?.(),this._updateState({headerRemoveListener:null},{description:"Close Table"}),this._stylesRemoveListener?.(),this._colHeadersSizeUnlistener?.(),this._rowHeadersSizeUnlistener?.())}get isITable(){return!0}}let wt=null;const ho="TableStyleMedium2",jt=(s,e,t)=>{if(!s.border)return s;let n=((o,i,a)=>{if(!o)return o;let l=null;return(o.top||o.horizontal)&&(i.rowIndex!==a.rowStart||i.colIndex<a.colStart||i.colIndex>a.colEnd)&&(l=l??{...o},delete l.top,o.horizontal&&(l.top=o.horizontal)),(o.bottom||o.horizontal)&&(i.rowIndex!==a.rowEnd||i.colIndex<a.colStart||i.colIndex>a.colEnd)&&(l=l??{...o},delete l.bottom,o.horizontal&&(l.bottom=o.horizontal)),(o.left||o.vertical)&&(i.colIndex!==a.colStart||i.rowIndex<a.rowStart||i.rowIndex>a.rowEnd)&&(l=l??{...o},delete l.left,o.vertical&&(l.left=o.vertical)),(o.right||o.vertical)&&(i.colIndex!==a.colEnd||i.rowIndex<a.rowStart||i.rowIndex>a.rowEnd)&&(l=l??{...o},delete l.right,o.vertical&&(l.right=o.vertical)),o.horizontal&&(l=l??{...o},delete l.horizontal),o.vertical&&(l=l??{...o},delete l.vertical),l??o})(s.border,e,t),r=s;return n!==s.border&&(r={...s},Object.keys(n).length>0?r.border=n:delete r.border),r};class Dw{constructor(e,t,n){this._table=e,this._styles=t,this._properties=n}_resolveProperties(e){const t={name:e.name},n=this._styles,r=Object.values(exports.ITableStyle.ElementType),o=r.length;for(let i=0;i<o;i++){const a=r[i],l=e[a];if(!l||!F.isObject(l))continue;const c=exports.it.resolveTypedUpdates(Object.freeze(l),He,n);t[a]=c}return Object.freeze(t)}getCoords(){return this._table.getAnchorCoords()}getPropertiesAt(e,t){const n=this._table,r=this._styles,o=this._properties;Qa.rowIndex=e,Qa.colIndex=t;const i=n.getVisibleCellCoords(Qa),a=n.getVisibleRefRangeCoords();if(!a)return null;const l=Math.max(0,a.colEnd-a.colStart)+1,c=Math.max(0,a.rowEnd-a.rowStart)+1,h=Math.max(0,i.rowIndex-a.rowStart),u=Math.max(0,i.colIndex-a.colStart),d={rowIndex:h,colIndex:u},g=n.getStyleOptions();let m={},f=!1,_=0;n.isHeaderVisible()&&(_=n.getShowHeaders()?1:0,f=_>h);let p=!1,S=0;n.isTotalVisible()&&(S=n.getShowTotals()?1:0,p=c-S<=h);let C=u===l-1&&g.showLastColumn;n.isLastColumnVisible()||(C=!1);let y=u===0&&g.showFirstColumn;n.isFirstColumnVisible()||(y=!1);const b=!f&&!p;if(o.wholeTable&&(m=o.wholeTable,m.border&&(m=jt(m,d,{rowStart:0,rowEnd:c-1,colStart:0,colEnd:l-1}))),b&&g.showColumnStripes){const w=o.firstColumnStripe?.size??1,E=o.secondColumnStripe?.size??1;let x=u%(w+E);const I=x<w;I||(x-=w);let v=I?o.firstColumnStripe:o.secondColumnStripe;if(v){const R={rowIndex:h,colIndex:x},A={rowStart:_,rowEnd:c-S-1,colStart:0,colEnd:Math.min(l-u,I?w:E)};I&&x===0&&u>0&&v.border?.left&&o.secondColumnStripe?.border.right&&(v={...v},v.border={...v.border},delete v.border.left),I&&x===w-1&&u<l-1&&v.border?.right&&o.secondColumnStripe?.border.left&&(v={...v},v.border={...v.border},delete v.border.right);const M=v.border?jt(v,R,A):v;m=exports.it.resolveTypedUpdates(M,He,r,m)}}if(b&&g.showRowStripes){const w=_,E=o.firstRowStripe?.size??1,x=o.secondRowStripe?.size??1;let I=(h-w)%(E+x);const v=I<E;v||(I-=E);let R=v?o.firstRowStripe:o.secondRowStripe;if(R){const A={colIndex:u,rowIndex:I},M={colStart:0,colEnd:l-1,rowStart:0,rowEnd:Math.min(c-h,v?E:x)};v&&I===0&&h>w&&R.border?.top&&o.secondRowStripe?.border.bottom&&(R={...R},R.border={...R.border},delete R.border.top),v&&I===E-1&&h<c-1&&R.border?.bottom&&o.secondRowStripe?.border.top&&(R={...R},R.border={...R.border},delete R.border.bottom);const T=R.border?jt(R,A,M):R;m=exports.it.resolveTypedUpdates(T,He,r,m)}}if(C&&o.lastColumn){let w=o.lastColumn;w.border&&(w=jt(w,d,{rowStart:0,rowEnd:c-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(y&&o.firstColumn){let w=o.firstColumn;w.border&&(w=jt(w,d,{rowStart:0,rowEnd:c-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(f&&o.headerRow){let w=o.headerRow;w.border&&(w=jt(w,d,{rowStart:0,rowEnd:_-1,colStart:0,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(p&&o.totalRow){let w=o.totalRow;w.border&&(w=jt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:0,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(f&&y&&o.firstHeaderCell){let w=o.firstHeaderCell;w.border&&(w=jt(w,d,{rowStart:0,rowEnd:_-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(f&&C&&o.lastHeaderCell){let w=o.lastHeaderCell;w.border&&(w=jt(w,d,{rowStart:0,rowEnd:_-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(p&&y&&o.firstTotalCell){let w=o.firstTotalCell;w.border&&(w=jt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,He,r,m)}if(p&&C&&o.lastTotalCell){let w=o.lastTotalCell;w.border&&(w=jt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,He,r,m)}return f&&o.headerRow&&n.getColumnFilter(u)&&!n.getColumnFilter(u).hasHiddenButton()&&(m.insets={right:15}),m}}class wd{constructor(e,t,n,r){this._styles=e,this._isBuiltIn=n,this._doDelete=r,this._properties=F.deepFreeze(this._resolveProperties(t)),this.isShownInTableStyles()}_resolveProperties(e){const t={name:e.name};e.table!==void 0&&(t.table=e.table),e.pivot!==void 0&&(t.pivot=e.pivot);const n=this._styles,r=Object.values(exports.ITableStyle.ElementType),o=r.length;for(let i=0;i<o;i++){const a=r[i],l=e[a];if(!l||!F.isObject(l))continue;const c=exports.it.resolveTypedUpdates(Object.freeze(l),He,n);t[a]=c}return Object.freeze(t)}delete(){if(!this._doDelete)throw new Error("Not able to delete builtin style.");this._doDelete(this._properties.name)}getRanged(e){return new Dw(e,this._styles,this._properties)}getProperties(){return this._properties}getName(){return this._properties.name}isShownInTableStyles(){return this._properties.table!==!1}isShownInPivotStyles(){return this._properties.pivot??!1}isBuiltIn(){return this._isBuiltIn}toJSON(){const e=F.cloneObject(this._properties);return e.name=this._properties.name,e}get isITableStyle(){return!0}}const Qa={rowIndex:0,colIndex:0};class Lw extends Ke{constructor(e,t){super(e,k.EmptyRange,t)}isEmpty(){return this._p===null}getCoords(){return this._r}cloneWithUpdate(e){if(e===void 0)return this;const t=this._c,n=this._r,r=exports.it.resolveTypedUpdates(e,He,t,this._p);return new Ke(t,n,r)}_createShifted(e){return new Ke(this._c,e,this._p)}getShifted(e){return e.after?{...e.after,value:this._createShifted(k.sanitizeRange(e.after))}:null}getSplit(e,t){const n=this._c,r=this._p;return[new Ke(n,e[0],r),new Ke(n,e[1],r)]}getMerged(e,t,n){const r=this._p,o=e._p;if(r&&!o||o&&!r||!r&&!o)return;let i=Object.keys(r),a=Object.keys(o);if(r.named===exports.IStyle.BuiltInName.Normal&&(i=i.filter(c=>c.toLowerCase()!==exports.IStyle.BuiltInName.Normal)),o.named===exports.IStyle.BuiltInName.Normal&&(a=a.filter(c=>c.toLowerCase()!==exports.IStyle.BuiltInName.Normal)),i.length!==a.length)return;for(let c=0;c<i.length;c++){const h=i[c],u=r[h],d=o[h];if(!F.deepEqual(u,d))return}const l=this._c;return new Ke(l,t,this._p)}getPropertiesAt(e,t){return this._p}toJSON(){return F.toSafeJSON(this._p)}}class yd{constructor(e,t,n,r=null){this._name=t.name,this._properties=t,this._rangeStyle=new Lw(e,t.style),this._doDelete=n,this._builtInID=r}getRanged(){return this._rangeStyle}getName(){return this._name}isHidden(){return this._properties.hidden??!1}getILevel(){return this._properties.iLevel??null}getBuiltInID(){return this._builtInID}delete(){this._doDelete?.(this)}toJSON(){return this._properties?F.toSafeJSON(this._properties):null}get isINamed(){return!0}}let Pw=class{constructor(s,e,t,n,r){this._state=s,this._normalJSON=e??{},this._toJSONInternal=t,this._fromJSONInternal=n,this._onLastEnd=r,this._state.openScopes.add(this),this._isClosed=!1,this._state.byJSONs.set(Ws(this._normalJSON),0),this._state.byIds.set(0,this._normalJSON)}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}getElementID(s){if(this._isClosed)throw new Error("PersistScope is closed.");const e=Ws(s=s??{});let t=this._state.byJSONs.get(e);return t!==void 0||(t=this._state.byJSONs.size,this._state.byJSONs.set(e,t),this._state.byIds.set(t,s)),t}getElementJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");return this._state.byIds.get(s)??null}fromJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");const e=JSON.parse(JSON.stringify(s||{}));this._fromJSONInternal(e);const t=e.direct;if(t)for(let n=0;n<t.length;n++){const r=n,o=t[n],i=Ws(o);this._state.byIds.set(r,o),this._state.byJSONs.set(i,r)}}toJSON(){if(this._isClosed)throw new Error("PersistScope is closed.");const s=[];return this._state.byIds.forEach((e,t)=>{s[t]=e}),s.length===1&&s.splice(0,1),this._toJSONInternal(s)}};class Xr{constructor(e=null,t=null,n=11){this._emitter=null,this._normalRanged=null,this._theme=e??new gc().getDefaultTheme(),this._defaultFontSize=n;const r=this;this._emitter=new st(this),this._schemeLookup=o=>r._theme.schemeLookup()(o),this._indexedColors=this._fromJSONIndexedColors(t),this._indexedLookup=o=>{const i=this._indexedColors[o];return i?i.toRGBA():Ei(o)},this._initializeBuiltIns(),this._customCellStyles=new Map,this._customTableStyles=new Map,this._indexedColors=[],this._mruColors=[],this._persistCache=null}_initializeNamedStyles(e,t){for(let n=0;n<e.length;n++){const r=e[n],o={...r},i=r.named;delete o.named;const a=exports.it.resolveTypedUpdates(o,He,this),l=new yd(this,{name:i,style:a},this._hideOrRemoveNamed.bind(this),n);i===exports.IStyle.BuiltInName.Normal&&(this._normalRanged=l.getRanged(),this._normalStyle=$r(this,null)),t.set(i.toLowerCase(),l)}}_initializeTableStyles(){const e=(()=>{if(wt)return wt;wt=new Map;const n=(u,d)=>{if(d===0)return"TableStyleNone";let g="Custom";return u==="l"?g="Light":u==="m"?g="Medium":u==="d"&&(g="Dark"),`TableStyle${g}${d}`},r=(u,d=0)=>d===0?u:d>0?`${u} lumMod ${100-d}, lumOff ${d}`:d<0?`${u} lumMod ${100+d}`:void 0,o=u=>({type:exports.IFill.Type.Pattern,patternType:exports.IFill.BuiltInSheetPattern.Solid,foreground:u,background:u}),i=(u,d=!1)=>{const g={fill:u};return d&&(g.weight=700),g},a=(u,d=exports.IBorder.StrokeStyle.Thin)=>({style:d,color:u}),l=(u,d)=>{for(let g=0;g<7;g++)u.push(d(`accent${g+1}`))};let c=0,h=[];h.push(["dk1",r("bg1",-15),"dk1"]),l(h,u=>[r(u,-25),r(u,80),u]),c=1;for(let u=0;u<7;u++){const d=n("l",u+c),g=h[u][0],m=h[u][1]??g,f=h[u][2]??g;wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{top:a(f),bottom:a(f)}},headerRow:{font:i(g,!0),border:{bottom:a(f)}},totalRow:{font:i(g,!0),border:{top:a(f)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(m)},firstColumnStripe:{fill:o(m)}}))}c+=7,h=[],h.push(["dk1","dk1","lt1"]),l(h,u=>["dk1",u,"lt1"]);for(let u=0;u<7;u++){const d=n("l",u+c),g=h[u][0],m=h[u][1],f=h[u][2];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(m),right:a(m),top:a(m),bottom:a(m)}},headerRow:{font:i(f,!0),fill:o(m)},totalRow:{font:i(g,!0),border:{top:a(m,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{border:{top:a(m)}},secondRowStripe:{border:{top:a(m)}},firstColumnStripe:{border:{left:a(m)}},secondColumnStripe:{border:{left:a(m)}}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15)]),l(h,u=>[u,r(u,80)]);for(let u=0;u<7;u++){const d=n("l",u+c),g="dk1",m=h[u][0],f=h[u][1];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(m),right:a(m),top:a(m),bottom:a(m),horizontal:a(m),vertical:a(m)}},headerRow:{font:i(g,!0)},totalRow:{font:i(g,!0),border:{top:a(m,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(f)},firstColumnStripe:{fill:o(f)}}))}c=1,h=[],h.push(["dk1","dk1",r("bg1",-15)]),l(h,u=>[u,r(u,40),r(u,80)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(_),right:a(_),top:a(_),bottom:a(_),horizontal:a(_)}},headerRow:{font:i(m,!0),fill:o(f)},totalRow:{font:i(g,!0),border:{top:a(f,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35)]),l(h,u=>[u,r(u,80),r(u,60)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(_),border:{horizontal:a(m),vertical:a(m)}},headerRow:{font:i(m,!0),fill:o(f),border:{bottom:a(m,exports.IBorder.StrokeStyle.Thick)}},totalRow:{font:i(m,!0),fill:o(f),border:{top:a(m,exports.IBorder.StrokeStyle.Thick)}},firstColumn:{font:i(m,!0),fill:o(f)},lastColumn:{font:i(m,!0),fill:o(f)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35)]),l(h,u=>[u,r(u,80),r(u,60)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=r("bg1",-15);wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{top:a(g,exports.IBorder.StrokeStyle.Medium),bottom:a(g,exports.IBorder.StrokeStyle.Medium),left:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,right:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,horizontal:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,vertical:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0}},headerRow:{font:i(m,!0),fill:o(f),border:{bottom:a(g,exports.IBorder.StrokeStyle.Medium)}},totalRow:{border:{top:a(g,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(m,!0),fill:o(f)},lastColumn:{font:i(m,!0),fill:o(f)},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35),"dk1"]),l(h,u=>[u,r(u,80),r(u,60),r(u,40)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m=h[u][0],f=h[u][1],_=h[u][2],p=h[u][3];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(f),border:{top:a(p),right:a(p),left:a(p),bottom:a(p),vertical:a(p),horizontal:a(p)}},headerRow:{font:i(g),fill:o(f)},totalRow:{font:i(g),border:{top:a(m,exports.IBorder.StrokeStyle.Medium)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c=1,h=[],h.push(["dk1",r("dk1",15),r("dk1",25),r("dk1",50)]),l(h,u=>["dk1",r(u,-50),r(u,-25),u]);for(let u=0;u<7;u++){const d=n("d",u+c),g="lt1",m=h[u][0],f=h[u][1],_=h[u][2],p=h[u][3];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(p)},headerRow:{font:i(g,!0),fill:o(m),border:{bottom:a(g,exports.IBorder.StrokeStyle.Medium)}},totalRow:{font:i(g,!0),fill:o(f),border:{top:a(g,exports.IBorder.StrokeStyle.Medium)}},firstColumn:{font:i(g,!0),fill:o(_),border:{right:a(g,exports.IBorder.StrokeStyle.Medium)}},lastColumn:{font:i(g,!0),fill:o(_),border:{left:a(g,exports.IBorder.StrokeStyle.Medium)}},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c+=7,h=[],h.push([r("bg1",-15),"dk1",r("bg1",-35)]),h.push([r("accent1",80),"accent2",r("accent1",60)]),h.push([r("accent3",80),"accent4",r("accent3",60)]),h.push([r("accent5",80),"accent6",r("accent5",60)]);for(let u=0;u<4;u++){const d=n("d",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];wt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(f)},headerRow:{font:i(m,!0),fill:o(_)},totalRow:{font:i(g,!0),border:{top:a(g,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}return wt})(),t=new Map;return e.forEach((n,r)=>{const o=n.name.toLowerCase(),i=new wd(this,n,!0);t.set(o,i)}),t}_initializeBuiltIns(){const e=new Map;this._builtInsCellStyles=e,this._initializeNamedStyles(iw,e),this._builtInsTableStyles=this._initializeTableStyles(),this._emptyTableStyle=new exports.ITableStyle.Empty(this._normalStyle)}getNormal(){return this._normalStyle}getNormalRanged(){return this._normalRanged}setTheme(e){this._theme=e,this._emitter.notify("onThemeChange"),this._emitter.notify("onAnyChange")}getTheme(){return this._theme}setDefaultFontSize(e){this._defaultFontSize=e,this._emitter.notify("onDefaultFontChange"),this._emitter.notify("onAnyChange")}getDefaultFontSize(){return this._defaultFontSize}beginPersist(){return this._persistCache||(this._persistCache={byIds:new Map,byJSONs:new Map,openScopes:new Set}),new Pw(this._persistCache,{},this._toJSONInternal.bind(this),this._fromJSONInternal.bind(this),()=>{this._persistCache=null})}getNamed(e){if(!e)return null;e=e.toLowerCase();let t=null;return this._customCellStyles&&(t=this._customCellStyles.get(e)),t||(t=this._builtInsCellStyles.get(e)),t??null}getCustomNamed(){const e=Array.from(this._customCellStyles.values());return e.sort((t,n)=>t.getName().localeCompare(n.getName())),e}setNamed(e,t=!1){if(!e||!e.name||!e.style)throw new Dt;this.validateStyleName(e.name,!1);const n=this._setCustomCellStyleInternal(e,t);return this._emitter.notify("onNamedStylesChange"),this._emitter.notify("onAnyChange"),n}_setCustomCellStyleInternal(e,t=!1,n=0){const r=e.name.toLowerCase(),o=this._builtInsCellStyles.get(r),i=o?.getBuiltInID()??null;let a=null;t&&(a=(this._customCellStyles.get(r)??o)?._properties??null);const l=qi(0,e.style,this.getNormal());e={...e,style:l};const c=exports.it.resolveTypedUpdates(e,tw,this,a),h=new yd(this,c,this._hideOrRemoveNamed.bind(this),i);return c.name===exports.IStyle.BuiltInName.Normal&&(this._normalRanged=h.getRanged(),this._normalStyle=$r(this,null)),this._customCellStyles.set(r,h),h}_setCustomTableStyleInternal(e,t){const n=e.toLowerCase();let r=this._customTableStyles.get(n)??this._builtInsTableStyles.get(n);r&&(e=r.getName());const o=new wd(this,{...t,name:e},!1,this._deleteCustomTableStyle.bind(this));return this._customTableStyles.set(n,o),o}_hideOrRemoveNamed(e){let t=null;if(t=typeof e=="string"?e:e?.getName?.(),!t||(t=t.toLowerCase(),t===exports.IStyle.BuiltInName.Normal.toLowerCase()))return!1;const n=this._builtInsCellStyles.get(t);let r=!1;if(n&&!n.isHidden()){const o=n.toJSON();this.setNamed({...o,hidden:!0}),r=!0}else t=t.toLowerCase(),r=this._customCellStyles.delete(t);return r&&(this._emitter.notify("onNamedStylesChange"),this._emitter.notify("onAnyChange")),r}getTableStyle(e){if(!e)return this._emptyTableStyle;let t=this._customTableStyles.get(e.toLowerCase());return t||(t=this._builtInsTableStyles.get(e.toLowerCase())),t??null}getCustomTableStyles(){const e=Array.from(this._customTableStyles.values());return e.sort((t,n)=>t.getName().localeCompare(n.getName())),e}setDefaultTableStyle(e){const t=e?.toLowerCase();return this._defaultTableStyle=this._customTableStyles.get(t)??this._builtInsTableStyles.get(t)??this._builtInsTableStyles.get(ho.toLowerCase()),this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),e===this._defaultTableStyle.getName()}getDefaultTableStyle(){return this._defaultTableStyle||(this._defaultTableStyle=this._builtInsTableStyles.get(ho.toLowerCase())),this._defaultTableStyle}_deleteCustomTableStyle(e){const t=this._customTableStyles.get(e?.toLowerCase());return!!t&&(this._customTableStyles.delete(e.toLowerCase()),this._defaultTableStyle?.getName()===t.getName()&&(this._defaultTableStyle=this._builtInsTableStyles.get(ho.toLowerCase())),this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),!0)}setCustomTableStyle(e,t){const n=this._setCustomTableStyleInternal(e,t);return this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),n}validateStyleName(e,t=!1){if(!e||e.trim().length===0)throw new Error("Style name cannot be empty.");if(t&&this.getNamed(e)!==null)throw new Error("Style name is already taken.")}normalize(e){if(!e)return null;const t=exports.it.resolveTypedUpdates(e,He,this),n=Zm;let r=null;if(r=t.named?this.getNamed(t.named)?.getRanged().getPropertiesAt(0,0,null):this._normalRanged.getPropertiesAt(0,0,null),r){const i={...r};F.removeEqualValues(t,i)}const o=this.getTheme().getFontScheme();return F.removeEqualValues(t,{font:{size:this.getDefaultFontSize(),family:o.getMinorFont(),fallbacks:o.getMinorFallbacks()}}),F.removeEqualValues(t,n),t}schemeLookup(){return this._schemeLookup}indexedLookup(){return this._indexedLookup}parseColor(e){return Ue.parse(e,this._schemeLookup,this._indexedLookup)}recentColors(){return this._mruColors}addRecentColor(e){if(!e)return;const t=this._mruColors,n=[],r=e.toString();for(let o=0;o<t.length&&o<10;o++)t[o].toString()!==r&&n.push(t[o]);return n.unshift(e),this._mruColors=Object.freeze(n),this._mruColors}clearRecentColors(){this._mruColors=Object.freeze([])}getIndexedColors(){return this._indexedColors}setCustomIndexedColors(e){this._indexedColors=e?.length>0?[...e]:null}getCustomIndexedColors(){const e=Math.max(this._indexedColors?.length,66),t=[];for(let n=0;n<e;n++)this._indexedColors[n]!==null&&t.push(this._indexedColors[n]??new Ue(Ei(n)?.toString()));return t}addListeners(e,t){return this._emitter.addListeners(e,t)}_toJSONInternal(e){const t={};e.length>0&&(t.direct=e);const n=this.getCustomNamed();let r=[];for(let l=0;l<n.length;l++){let c=n[l].toJSON();r.push(c)}r.length>0&&(t.named=r);const o={};this._defaultTableStyle&&this._defaultTableStyle.getName()!==ho&&(o.defaultTableStyle=this._defaultTableStyle.getName());const i={},a=this.getCustomTableStyles();for(let l=0;l<a.length;l++){let c=a[l].toJSON();delete c.name,c&&Object.keys(c).length>0&&(i[a[l].getName()]=c)}if(Object.keys(i).length>0&&(o.styles=i),Object.keys(o).length>0&&(t.tables=o),this._indexedColors.length>0){t.indexedColors=[];for(let l=0;l<this._indexedColors.length;l++)t.indexedColors.push(this._indexedColors[l].toString())}if(this._mruColors.length>0){t.mruColors=[];for(let l=0;l<this._mruColors.length;l++)t.mruColors.push(this._mruColors[l].toString())}return Object.keys(t).length===0?null:t}_fromJSONIndexedColors(e){if(!e||e.length===0)return F.EmptyArray;const t=[];if(e?.length>0)for(let n=0;n<e.length;n++)try{t.push(this.parseColor(e[n]))}catch{console.warn("Unable to parse color: "+e[n])}return t}_fromJSONInternal(e){this._indexedColors=this._fromJSONIndexedColors(e.indexedColors);const t=e.named;for(let o=0;t&&o<t.length;o++)this._setCustomCellStyleInternal(e.named[o]);let n=ho;if(this._defaultTableStyle=null,e.tables){e.tables.defaultTableStyle&&(n=e.tables.defaultTableStyle);const o=e.tables.styles?Object.keys(e.tables.styles):null;for(let i=0;o&&i<o.length;i++){const a=o[i],l=e.tables.styles[a];this._setCustomTableStyleInternal(a,l)}}this._defaultTableStyle=this.getTableStyle(n);let r=[];if(e.mruColors?.length>0)for(let o=0;o<e.mruColors.length;o++)try{r.push(this.parseColor(e.mruColors[o]))}catch{console.warn("Unable to parse color: "+e.mruColors[o])}this._mruColors=r}}const Za="BinaryResource must have only one initial data value.",el="Resource is closed.";class mi{constructor(e){if(this._listeners=new Set,this._type=e.type,this._name=e?.name,e.base64){const t=e.base64;this._asArrayBufferResolve=async()=>{const n=await Promise.resolve(t);return Promise.resolve(Mr.base64ToArrayBuffer(n))}}if(e.fetch){if(this._asArrayBufferResolve)throw new Error(Za);const t=e.fetch;this._asArrayBufferResolve=async()=>{let n,r=null;r=typeof t=="string"?t:e.input;const o=await fetch(r,n),i=o.headers.get("Content-Type");return!this._type&&i&&(this._type=i),o.arrayBuffer()}}if(e.buffer){if(this._asArrayBufferResolve)throw new Error(Za);this._asArrayBufferResolve=async()=>{let t=null;return t=typeof e.buffer=="function"?await e.buffer():e.buffer,Promise.resolve(t)}}if(e.file){if(this._asArrayBufferResolve)throw new Error(Za);this._asArrayBufferResolve=async()=>await(await Promise.resolve(e.file)).arrayBuffer()}if(!this._asArrayBufferResolve)throw new Error("BinaryResource must have an initial data value.");this._refs=new Set,this._isClosed=!1}getName(){return this._name}async toJSONAsync(){const e=await this.toBuffer(),t={base64:Mr.arrayBufferToBase64(e)};return this._type!==Mr.DEFAULT_MIME_TYPE&&(t.type=this._type),this._name&&(t.name=this._name),t}async toBuffer(){if(this._asArrayBuffer)return this._asArrayBuffer;try{this._asArrayBuffer=this._asArrayBufferResolve()}catch(e){throw e}return this._asArrayBuffer}async getType(){return this._type?this._type:(await this.toBuffer(),this._type??Mr.DEFAULT_MIME_TYPE)}addReference(e){if(this._isClosed)throw new Error(el);this._refs.add(e)}deleteReference(e){if(this._isClosed)throw new Error(el);if(this._refs.size===0||!this._refs.has(e))return;this._refs.delete(e);const t=this;if(this._refs.size===0){const n=this._listeners;n.forEach(r=>{r.onUnload?.(t),n.delete(r)}),this._asArrayBuffer=null,this._isClosed=!0}}addUnloadListener(e){if(this._isClosed)throw new Error(el);this._listeners.add(e)}get isIResource(){return!0}isClosed(){return this._isClosed}}let zw=class{constructor(s,e,t){this._state=s,this._fromJSON=e,this._onLastEnd=t,this._state.openScopes.add(this),this._isClosed=!1}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}toResourceId(s){if(this._isClosed)throw new Error("PersistScope is closed.");let e=this._state.byRefs.get(s);return e!==void 0||(e=this._state.byRefs.size,this._state.byRefs.set(s,e),this._state.byIds.set(e,s)),e}fromResourceId(s){return this._state.byIds.get(s)??null}fromJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");if(!s||s.length===0)return;const e=this._state.byRefs.size;for(let t=0;t<s.length;t++){const n=s[t],r=this._fromJSON(n);this._state.byRefs.set(r,e+t),this._state.byIds.set(e+t,r)}}toJSONAsync(){if(this._isClosed)throw new Error("PersistScope is closed.");const s=[];return this._state.byRefs.forEach((e,t)=>{s[e]=Promise.resolve(t.toJSONAsync())}),Promise.all(s)}};class Cc{constructor(){this._resources=new Set}add(e){if(typeof e=="string"){let r=!1;this._resources.forEach(o=>{o.getName()===e&&(r=!0,e=o)}),r||(e=new mi({name:e,fetch:e,type:null}))}let t=null;t=e instanceof mi?e:new mi({...e});const n=this;return this._resources.has(t)||(t.addUnloadListener({onUnload:r=>{n._resources.delete(t)}}),this._resources.add(t)),t}getCount(){return this._resources.size}beginPersist(){this._persistOpen||(this._persistOpen={byRefs:new Map,byIds:new Map,openScopes:new Set});const e={},t=new Set,n=this;return new zw(this._persistOpen,r=>{const o=n.add({base64:r.base64,name:r.name,type:r.type});return o.addReference(e),t.add(o),o},()=>{t.forEach(r=>{r.deleteReference(e)}),n._persistOpen=null})}}class jw{constructor(e,t,n){this._state=e,this._fromJSON=t,this._onLastEnd=n,this._state.openScopes.add(this),this._isClosed=!1}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}add(e){if(this._isClosed)throw new Error("PersistScope is closed.");let t=this._state.byRefs.get(e);return t!==void 0||(t=this._state.byRefs.size,this._state.byRefs.set(e,t),this._state.byIds.set(t,e)),t}at(e){return this._state.byIds.get(e)??null}fromJSON(e){if(this._isClosed)throw new Error("PersistScope is closed.");e&&e.length!==0&&this._fromJSON(e)}toJSONAsync(){if(this._isClosed)throw new Error("PersistScope is closed.");const e=[];return this._state.byRefs.forEach((t,n)=>{e[t]=Promise.resolve(n.toJSONAsync?n.toJSONAsync():n)}),Promise.all(e)}}class Ki{constructor(){this._nextId=0,this._lastReadId=-1,this._lastReadValue=null,this._stringsByText=new Map,this._stringsById=new Map}addMultiple(e,t=!1){const n=this._stringsByText,r=this._stringsById,o=e.length;let i=this._nextId;for(let a=0;a<o;a++){const l=e[a];n.get(l)!==void 0&&t||(n.set(l,i),r.set(i,l),i++)}this._lastReadId=-1,this._nextId=i}add(e){const t=this._stringsByText,n=t.get(e);if(n!==void 0)return n;const r=this._nextId++;return t.set(e,r),this._stringsById.set(r,e),this._lastReadId=-1,r}getById(e){if(this._lastReadId===e)return this._lastReadValue;const t=this._stringsById.get(e)??null;return this._lastReadId=e,this._lastReadValue=t,t}getCount(){return this._stringsById.size}beginPersist(){this._persistOpen||(this._persistOpen={byRefs:new Map,byIds:new Map,openScopes:new Set});const e=this;return new jw(this._persistOpen,t=>(Array.isArray(t)?e.addMultiple(t):e.add(t),t),()=>{e._persistOpen=null})}}exports.IPicture=void 0,exports.IPicture||(exports.IPicture={});class lf extends ir{constructor(e){super(e),e.json&&(this._resource=e.fromResourceId(e.json.resId))}getType(){return"picture"}toJSON(e){const t={},n=e?.(this._resource);n!==null&&(t.resId=n);const r=this._getState();return r&&r.effects&&(t.effects=r.effects),t}getTypeDescription(){return"Picture"}async _asDataUrl(){if(this._dataUrl)return this._dataUrl;const e=await this.getDetails(),t=await Bo.getImageDataUrl(e.asUrl());return this._dataUrl=t.dataUrl,this._dataUrl}toHtml(){return null}async toImage(){const e=(await this._asDataUrl()).substring(Bo.DATA_URL_PNG_PREFIX.length),t=Mr.base64ToArrayBuffer(e);return new Blob([t],{type:Te.png})}async getDetails(){return this._details||(this._details=new Promise(async(e,t)=>{try{const n=await this._resource.toBuffer(),r=await this._resource.getType(),o=await Bo.loadImageDetails(n,r);e({getNaturalDimensions:()=>o.naturalDimensions,asUrl:()=>o.asUrl,asSVGText:()=>o.asSVGText})}catch(n){t(n)}})),this._details}_fromDrawingJSON(e,t){this._resource?.deleteReference(this),this._resource=t?.(e.resId),this._resource.addReference(this)}_toDrawingJSON(e){const t={},n=e?.(this._resource);return n!==null&&(t.resId=n),t}_processDelete(){super._processDelete()}}exports.ICalculation=void 0,(exports.ICalculation||(exports.ICalculation={})).Status={Ready:"ready",Error:"error",Starting:"starting",Stopping:"stopping",Off:"off"};class Xo extends nt{constructor(e,t=null,n,r,o){if(super(e,n,t),this._sheetName=r||null,this._getEntireCoords=o??Ai,this._coords=Ww(n,this._getEntireCoords()),!n)throw new Error("ReferenceRange requires a coords");this._validateCoords(n)}toType(e){return new Xo(this._values,e,this._coords,this._sheetName,this._getEntireCoords)}getCoords(){return this._coords}get isIReferenceRange(){return!0}isLiteral(){return!1}_validateCoords(e){const t=this._getEntireCoords?.();if(t&&(e.rowStart<t.rowStart&&e.rowStart!==Number.MIN_SAFE_INTEGER||e.rowEnd>t.rowEnd&&e.rowEnd!==Number.MAX_SAFE_INTEGER||e.colStart<t.colStart&&e.colStart!==Number.MIN_SAFE_INTEGER||e.colEnd>t.colEnd&&e.colEnd!==Number.MAX_SAFE_INTEGER))throw new ke}get[Symbol.toStringTag](){return"[ReferenceRange]"}toString(){return`${bn(this._coords,this._getEntireCoords?.())}`}}const Ww=(s,e)=>{let t=s.rowStart,n=s.rowEnd,r=s.colStart,o=s.colEnd,i=!1;return r===Number.MIN_SAFE_INTEGER&&(r=e.colStart,i=!0),t===Number.MIN_SAFE_INTEGER&&(t=e.rowStart,i=!0),n===Number.MAX_SAFE_INTEGER&&(n=e.rowEnd,i=!0),o===Number.MAX_SAFE_INTEGER&&(o=e.colEnd,i=!0),i?{rowStart:t,rowEnd:n,colStart:r,colEnd:o}:s},Cd=(s,e)=>s.value?.once===e.value?.once,Hw=(s,e)=>s.colStart===e.colStart&&s.rowStart===e.rowStart,cf=(s,e,t)=>!!t&&s===t.rowStart&&e===t.colStart,Vw=(s,e=0,t=0)=>{const n=s._values,r=s._coords,o=n.getRuns({bounds:r}),i=n.getOrientation()!==exports.w.Orientation.Row,a=i?r.colStart:r.rowStart,l=i?r.rowStart:r.colStart,c=new exports.Tuple.Builder(null,e,t);let h=o.next();for(;!h.done;){const u=h.value;c.addValues(u[0]-a,u[1]-l,u[2]),h=o.next()}return c.build()},fi=(s,e,t,n,r,o,i,a,l,c,h,u,d=!1)=>{let g,m,f=null,_=r.size();u===void 0&&(u=o.getOrientation()===exports.w.Orientation.Column);const p=e?e.length:0,S=t?t.length:0;let C;const y=p+S;for(let w=0;w<y&&_>0;w++){const E=w<p?e[w]:t[w-p],x=r.search(E),I=x.length;for(let v=0;v<I;v++){const R=x[v];if(!cf(R.rowStart,R.colStart,E)){if(R.value.getError())continue;C||(C=[]),C.push(R)}r.remove(R,Hw);const A=R.value;A.getCycleId()!==s&&l?.insert(R),A.getError()||(o.delete(R),n.insertNonOverlapping({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:null},{onIntersect:(M,T)=>{if(M.value!==null)return i?.push(M),f=k.unionRanges(f,M),a?.insertNonOverlapping(M),f=k.unionRanges(f,M),T}})),_--}}for(let w=0;w<p;w++){const E=e[w],x={colStart:E.colStart,rowStart:E.rowStart,colEnd:E.colEnd,rowEnd:E.rowEnd,value:null};n.insertNonOverlapping(x,{onIntersect:(I,v)=>{if(I.value===null)return;const R=k.sanitizeRange(v);return d&&a?.insertNonOverlapping(R),c?.insertNonOverlapping({...v,value:!1}),i?.push(R),f=k.unionRanges(f,R),v}}),h?.insertNonOverlapping(x,{onIntersect:(I,v)=>{if(I.value!==null)return i?.push(v),f=k.unionRanges(f,v),v},onUpdates:(I,v,R)=>{m||(m=[]);const A=I.length;for(let T=0;T<A;T++){const N=I[T];m.push(N)}g||(g=[]);const M=v.length;for(let T=0;T<M;T++){const N=v[T],B=k.sanitizeRange(N);g.push(B)}}})}const b=u?exports.w.Orientation.Column:exports.w.Orientation.Row;if(C){const w=C.length,E=new Array(w);for(let x=0;x<w;x++){const I=C[x],v=I.value.setError(!0,s);l?.insert(v),E[x]=v,f=k.unionRanges(f,I);const R={colStart:I.colStart,rowStart:I.rowStart,colEnd:I.colStart,rowEnd:I.rowStart};n.insertNonOverlapping({colStart:I.colStart,rowStart:I.rowStart,colEnd:I.colStart,rowEnd:I.rowStart,value:new Vt(I,b)}),i?.push(R)}r.load(E)}for(let w=0;w<S;w++){const E=k.sanitizeRange(t[w]);n.insertNonOverlapping({colStart:E.colStart,rowStart:E.rowStart,colEnd:E.colEnd,rowEnd:E.rowEnd,value:new Vt(E,b)}),d&&a?.insertNonOverlapping(E),i?.push(E),f=k.unionRanges(f,E)}return f},Jl=(s,e,t)=>{if(!e)return s;const n=e.block;if(!n)return s;const r=s??[],o=e.colIndex,i=e.rowIndex;let a,l,c,h;t?(a=t.colStart,l=t.rowStart,c=t.colEnd,h=t.rowEnd):(a=o,l=i,c=o,h=i);const u={colStart:a,rowStart:l,colEnd:c,rowEnd:h,value:{blockEntry:{colStart:a,rowStart:l,colEnd:c,rowEnd:h,value:n},width:1,height:1,index:-1,$absWidth:!1,$absHeight:!1,once:e}};let d=e.dynamic;return d||(d=[],e.dynamic=d),d.push(u),r.push(u),r};class bc{constructor(e){this._fullCalcRequired=!1,this._iterationId=0,this._cycleId=1,this._pendingInvalidations=new Set,this._emitter=null,this._isProcessingJSON=!1,this._collectDirties=(o,i=!1,a,l)=>{const c=this._formulaSpatial,h=this._precedentSpatial;let u=qw,d=0;if(i){const g=c.all();for(let m=0;m<g.length;m++){const f=g[m].value.calcs,_=f.length;for(let p=0;p<_;p++){const S=f[p],C=S.length;for(let y=0;y<C;y++){const b=S[y];b.markId!==o&&(u[d++]=b,b.markId=o,b.pending=!1,b.pendingResolved=!1,b.pendingPromise&&(b.pendingPromise.cancelled=!0))}}}}else{const g=a.length;for(let m=0;m<g;m++){const f=a[m];xd.length=0;const _=xd;h.search(f,!1,_),c.search(f,!1,_);const p=_.length;if(p===0)continue;const S=f.colStart,C=f.rowStart,y=f.colEnd-S,b=f.rowEnd-C;for(let w=0;w<p;w++){const E=_[w],x=E.value,I=x.blockEntry?.value??x,v=I.ref,R=v.colEnd-v.colStart,A=v.rowEnd-v.rowStart,M=E.colEnd-E.colStart-R,T=E.rowEnd-E.rowStart-A,N=x.once;if(N)N.markId<=o&&(N.removed?(h.remove(E,Cd),N.removed=!1):u[d++]=N,N.markId=o);else{let B=0,D=0,P=R,L=A;if(!x.$absHeight){const O=C-E.rowStart;D=Math.min(Math.max(O-T,0),A),L=Math.min(b+C,A)}if(!x.$absWidth){const O=S-E.colStart;B=Math.min(Math.max(O-M,0),R),P=Math.min(y+O,R)}const z=I.calcs;for(let O=D;O<=L;O++){const j=z[O];for(let V=B;V<=P;V++){const W=j[V];W.markId!==o&&(u[d++]=W,W.markId=o,W.pendingPromise&&(W.pendingPromise.cancelled=!0))}}}}}l&&l.forEach(m=>{if(Array.isArray(m)){const f=m.length;for(let _=0;_<f;_++){const p=m[_],S=p.length;for(let C=0;C<S;C++){const y=p[C];y.markId===o||y.removed||(u[d++]=y,y.markId=o,y.pendingPromise&&(y.pendingPromise.cancelled=!0))}}}else m.markId===o||m.removed||(u[d++]=m,m.markId=o,m.pendingPromise&&(m.pendingPromise.cancelled=!0))})}return u.length=d,u};const t=(e={strings:new Ki,...e}).getEntireCoords??Ai;if(this._getEntireCoords=t,this._options=e,this._strings=e.strings,this._onCalculated=e?.onCalculated??(()=>{}),this._cycleId=1,this._values=new Qt({orientation:exports.w.Orientation.Column}),this._getFormulaParser=e.getFormulaParser,!this._getFormulaParser)throw new Error("Formula parser is not defined");this._latest={graph:this},this._iterationId=0;const n=this;this._formulaSpatial=new Ie({updateEntryOptions:{isMergeOnShift:!0,isSplitOnExpand:!0,onUpdates:(o,i,a)=>{const l=a._cloneKey??n;if(l._isProcessingJSON)return;let c=l._notifyFormulaInsertEntries,h=l._notifyFormulaRemoveEntries;const u=l._precedentSpatial,d=i?i.length:0;if(d>0){let m=h?h.length:0;h?h.length=m+d:(h=new Array(d),l._notifyFormulaRemoveEntries=h);for(let f=0;f<d;f++){const _=i[f],p=_.value,S=p.ref;h[m+f]=S;const C=S.rowStart,y=S.colStart,b=p.formula.getDirectPrecedentsAt(C,y);if(!b)continue;const w=b.length;for(let E=0;E<w;E++){const x=b[E];if(x===null||x instanceof exports.n.Known)continue;const I=u.search(x),v=I.length;for(let R=0;R<v;R++){const A=I[R];A.value.blockEntry.value===_.value&&u.remove(A)}}}}const g=o?o.length:0;if(g>0){const m=[];for(let f=0;f<g;f++){const _=o[f],p=_.colEnd-_.colStart,S=_.rowEnd-_.rowStart,C=_.value,y=C.formula,b=C.ref,w=b.rowStart,E=b.colStart,x=[],I=y.getDirectPrecedentsAt(w,E,!0,Is,Rs),v=I.length;for(let R=0;R<v;R++){const A=I[R];if(A instanceof exports.n.Known)continue;const M=Is[R],T=Rs[R],N={colStart:A.colStart,rowStart:A.rowStart,colEnd:A.colEnd+(T?0:p),rowEnd:A.rowEnd+(M?0:S),value:{blockEntry:_,width:p+1,height:S+1,index:R,$absWidth:T,$absHeight:M,once:null}};x.push(A),m.push(N)}c||(c=[],l._notifyFormulaInsertEntries=c),c.push({colStart:_.colStart,rowStart:_.rowStart,colEnd:_.colEnd,rowEnd:_.rowEnd,value:{tokens:y.getTokens(),references:y.getReferences(),precedents:x}})}u.load(m)}}}}),this._contentfulSpatial=new Ie({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}});const r={updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!1}};this._precedentSpatial=new Ie(r),this._volatile=new Set,this._spillSpatial=new Ie(r),this._errorSpatial=new Ie(r),this._pendingSpatial=new Ie(r),this._invalidations=new Ie,this._notifyValues=new Ie,this._notifySpills=new Ie,this._notifyFormats=new Ie,this._notifyPending=new Ie,this._calculation=e.calculation,this._clearScope()}addListeners(e,t){return this._emitter||(this._emitter=new st(this)),this._emitter.addListeners(e,t)}shift(e){const t=e.cloneIfUpdate??!0?this.clone(this):this,n={...e};delete n.cloneIfUpdate,delete n.onShift,t._values.shift(n.range,n.direction);const r=t._contentfulSpatial;t._contentfulSpatial=r.shift(n);const o=t._spillSpatial;t._spillSpatial=o.shift(n);const i=t._formulaSpatial;if(i.isEmpty())return t;const a=e.range,l=e.direction,c=l===exports.w.Direction.Left||l===exports.w.Direction.Right;l!==exports.w.Direction.Up&&exports.w.Direction.Left,c?(a.colEnd,a.colStart):(a.rowEnd,a.rowStart),t._notifyFormulaInsertEntries,t._notifyFormulaRemoveEntries;const h=t._getEntireCoords(),u=new Map;this._precedentSpatial.visitRanges({...a,colEnd:c?h.colEnd:a.colEnd,rowEnd:c?a.rowEnd:h.rowEnd},p=>{let S=p.value;if(p.value.once)return;let C=S.blockEntry,y=u.get(C);y||(y={rows:[],cols:[],index:[]},u.set(C,y)),y.index.push(S.index)});const d=[],g=[],m=u.entries();let f=m.next();const _=(p,S,C,y)=>{let b=p.value;const w=b.formula.getReferences(),E=S.length;for(let x=0;x<E;x++){const I=w[x];I!==null&&(I instanceof exports.n.Known||typeof I!="string"&&I[x])}return p.value=b,p};for(;!f.done;){const[p,S]=f.value,C=p.value,y=S.rows.sort(),b=y.length,w=S.cols.sort().length,E=S.index.sort();if(g.push(p),b===0&&w===0){const I={...p};_(I,E),d.push(I),f=m.next();continue}let x=0;for(let I=0;I<b;I++){const v=y[I];if(v===x)continue;il[0]={colStart:C.ref.colStart,rowStart:x,colEnd:C.ref.colEnd,rowEnd:v-1,value:C},il[1]={colStart:C.ref.colStart,rowStart:v,colEnd:C.ref.colStart,rowEnd:C.ref.rowEnd,value:C};const R=Kw(C,il,exports.w.Orientation.Row,v);let A=R[0];_(A,E),d.push(A),A=R[1],_(A,E),d.push(A),x=v}f=m.next()}return i._updateNodes(d,g),t._fullCalcRequired=!0,this._invalidate(d),t}clone(e){if(e!==void 0&&this._cloneKey===e)return this;const t=new bc(this._options);t._cloneKey=e,t._values=this._values.clone(t),t._contentfulSpatial=this._contentfulSpatial.clone(t),t._formulaSpatial=this._formulaSpatial.clone(t),t._precedentSpatial=this._precedentSpatial.clone(t),t._volatile=new Set(this._volatile),t._spillSpatial=this._spillSpatial.clone(t),t._errorSpatial=this._errorSpatial.clone(t),t._pendingSpatial=this._pendingSpatial.clone(t),t._invalidations=this._invalidations.clone(t),t._notifyValues=this._notifyValues.clone(t),t._notifySpills=this._notifySpills.clone(t),t._notifyFormats=this._notifyFormats.clone(t),t._notifyPending=this._notifyPending.clone(t);const n=this._notifyFormulaInsertEntries;n&&(t._notifyFormulaInsertEntries=[...n]);const r=this._notifyFormulaRemoveEntries;r&&(t._notifyFormulaRemoveEntries=[...r]);const o=this._pendingActions;return o&&(t._pendingActions=[...o]),t._cycleId=this._cycleId,t._emitter=this._emitter,t._fullCalcRequired=this._fullCalcRequired,this._latest.graph=t,t._iterationId=this._iterationId+1,t}invalidate(e){const t=this._invalidations;if(Array.isArray(e)){const n=e.length;for(let r=0;r<n;r++){let o=e[r];typeof o=="string"&&(o=Ct(o)),t.insertNonOverlapping(o)}}else{let n=e;typeof n=="string"&&(n=Ct(n)),t.insertNonOverlapping(n)}}setFormulaAt(e,t){let n,r=null;return typeof e=="string"?n=Ct(e,Oe):(Oe.colStart=e.colIndex,Oe.rowStart=e.rowIndex,Oe.colEnd=e.colIndex,Oe.rowEnd=e.rowIndex,n=Oe),t?r=this._setInputs(null,[{colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,value:t}]):this.delete(n),r}getFormulaAt(e,t){let n;typeof e=="string"&&(n=Ct(e,Oe));const r=this._formulaSpatial.search(n);if(r.length===0)return null;const o=r[0].value;return o.formula?o.formula.getTextAt(n.rowStart,n.colStart,t):void 0}_formulaAt(e,t){_o.colStart=t,_o.rowStart=e,_o.colEnd=t,_o.rowEnd=e;const n=this._formulaSpatial.search(_o);if(n.length===0)throw new Error(`No formula found at ${rs({rowIndex:e,colIndex:t})}`);return n[0]}getDirectPrecedentsAt(e,t,n){return this._formulaAt(e,t).value.formula.getDirectPrecedentsAt(e,t,n)}getReferencesAt(e,t){return this._formulaAt(e,t).value.formula.getReferences()}setReferenceAt(e,t,n,r){const o=this._formulaAt(e,t).value.formula.setReferenceAt(n,r).getTextAt(e,t);return this.setFormulaAt({rowIndex:e,colIndex:t},o),this}evaluateAt(e,t,n){const r=this._formulaAt(e,t),o=r.value,i=o.ref,a=i.colStart-t,l=i.rowStart-e,c=this._calculation._getContext(),h=this._calculation._getScope();return h.sheetName=this._options.getSheetName?.(),h.rowIndex=e,h.colIndex=t,h.node=o.calcs[l][a],r.value.formula.evaluate(c,n)}setInputAt(e,t){let n=null;const r=typeof e=="string"?Fr(e,Gw):e;if(t!==null){const o=new exports.Tuple.Builder,i=this._values.getOrientation()===exports.w.Orientation.Column,a=i?r.colIndex:r.rowIndex,l=i?r.rowIndex:r.colIndex;o.addValue(a,l,t),n=this.setInputs(o.build(),null)}else this.delete(k.cellToRange(r,Oe));return n}setInputs(e,t){return this._setInputs(e,t)}delete(e){typeof e=="string"&&(e=Ft(e));const t=this._setInputs(null,[{...e,value:null}],e);return this._emitter?.notify("onInvalidate"),t.removes}_createCopySpillEntries(e,t,n,r,o){const i=r??[],a=o??[],l=t.colStart,c=t.rowStart,h=t.colEnd,u=t.rowEnd,d=n.colStart,g=n.rowStart,m=e.search(t),f=m.length;for(let _=0;_<f;_++){const p=m[_];a&&a.push(p);const S=p.rowStart,C=p.colStart;if(S<c||S>u||C<l||C>h||p.value.getError())continue;const y=d+(p.colEnd-C),b=g+(p.rowEnd-S),w={colStart:d,rowStart:g,colEnd:y,rowEnd:b};i.push({colStart:d,rowStart:g,colEnd:y,rowEnd:b,value:new er(w,0,!1)})}return{removes:a,inserts:i}}_copyCalcs(e,t,n){const r=e._formulaSpatial;if(r.isEmpty())return;const o=this._getEntireCoords(),i=o.colStart,a=o.rowStart,l=o.colEnd,c=o.rowEnd,h=r.createCopiedEntries(t,n),u=h.inserts;let d=u.length,g=0;const m=e._spillSpatial;let f=[];for(;g<d;){let _=u[g],p=_.value,S=p.ref,C=S.colStart,y=S.rowStart,b=S.colEnd,w=S.rowEnd;this._createCopySpillEntries(m,t,S,f,null);let E=p.formula.getReferences();const x=E.length;for(let I=0;I<x;I++){const v=E[I];if(!v||v.isFormulaError||typeof v=="string")continue;const R=v,A=R.colStart,M=R.rowStart,T=R.colEnd,N=R.rowEnd;let B=R.$colStart?A:A+C,D=R.$rowStart?M:M+y,P=R.$colEnd?T:T+b,L=R.$rowEnd?N:N+w;if(A===Number.MIN_SAFE_INTEGER&&(B=i,P=l),M===Number.MIN_SAFE_INTEGER&&(D=a,L=c),B<i||P>l||D<a||L>c){const z=i-B,O=a-D,j=l-P,V=c-L;po.colStart=Math.max(C,C+z),po.rowStart=Math.max(y,y+O),po.colEnd=Math.min(b,b+j),po.rowEnd=Math.min(w,w+V);const W=Vr(_,po,ei);if(W){const H=W.length;_=W[H-1],p=_.value,S=p.ref,C=S.colStart,y=S.rowStart,b=S.colEnd,w=S.rowEnd;for(let G=0;G<H-1;G++){const $=W[G];u.push($),d++}}else p=p.setReferenceAt(I,null),_.value=p,E=p.formula.getReferences()}}u[g++]=_}this._formulaSpatial._updateNodes(u,h.removes),r._mergeNodes({colStart:n.colStart-1,rowStart:n.rowStart-1,colEnd:n.colEnd+1,rowEnd:n.rowEnd+1}),f&&this._spillSpatial._updateNodes(f,[]),this._fullCalcRequired=!0,this._invalidate(u),this._invalidate(h.removes)}_moveCalcs(e,t,n){const r=e._formulaSpatial.createCopiedEntries(t,n);console.log("_moveCalcs",r,"from:",t,"to:",n);const o=this._formulaSpatial,i=(g,m,f,_)=>{let p=g.value;const S=p.formula.getReferences(),C=S.length,y=m.colStart-f.colStart,b=m.rowStart-f.rowStart,w=p.ref,E=f.colStart-w.colStart,x=f.colEnd-w.colEnd,I=f.rowStart-w.rowStart,v=f.rowEnd-w.rowEnd;for(let R=0;R<C;R++){const A=S[R];if(!A||A.isFormulaError||typeof A=="string")continue;const M=A,T=M.colStart,N=M.rowStart,B=M.colEnd,D=M.rowEnd;let P=y,L=b;const z=E<=T&&x>=B||T==Number.MIN_SAFE_INTEGER,O=I<=N&&v>=D||N==Number.MIN_SAFE_INTEGER;let j=!O;M.$colStart||P===0||T===Number.MIN_SAFE_INTEGER?j=!1:j||(j=T<E||T>x,j||!M.$colEnd||M.$colStart||(j=!0));let V=!z;M.$rowStart||L===0||N===Number.MIN_SAFE_INTEGER?V=!1:V||(V=N<I||N>v,j||!M.$rowEnd||M.$rowStart||(V=!0));let W=!O;M.$colEnd||P===0||N===Number.MIN_SAFE_INTEGER?W=!1:W||(W=B<E||B>x,j||!M.$colStart||M.$colEnd||(W=!0));let H=!z;if(M.$rowEnd||L===0||N===Number.MIN_SAFE_INTEGER?H=!1:H||(H=D<I||D>v,H||!M.$rowEnd||M.$rowStart||(H=!0)),!(j||W||V||H))continue;const G={...M};j&&(G.colStart+=P),V&&(G.rowStart+=L),W&&(G.colEnd+=P),H&&(G.rowEnd+=L),p=p.setReferenceAt(R,G)}return g.value=p,g},a=e._spillSpatial;let l=[],c=[];const h=r.inserts,u=h.length;for(let g=0;g<u;g++){const m=h[g];this._createCopySpillEntries(a,t,m,l,c),h[g]=i(m,t,n)}o._updateNodes(r.inserts,[]),e._formulaSpatial._updateNodes([],r.removes);const d=[];l.length>0&&(this._spillSpatial._updateNodes(l,[]),e._spillSpatial._updateNodes([],c),fi(this._cycleId,c,F.EmptyArray,e._contentfulSpatial,a,e._values,d,e._notifyValues,e._notifySpills,e._notifyPending,e._errorSpatial,e._values.getOrientation()!==exports.w.Orientation.Row,!1)),this._fullCalcRequired=!0,this._invalidate(r.inserts),e._invalidate(d),e._invalidate(r.removes)}getSnapshot(e){const t=this,n=Object.freeze({...e});let r=n.range;return typeof r=="string"&&(r=Ct(r)),{async copyTo(o,i){const a=o.calcGraph;let l=o.range;typeof l=="string"&&(l=Ct(l));const c=ai(l,r,i?.fitDestination,i?.transpose);return{...n,...i}.isCut?a._moveCalcs(t,r,c):a._copyCalcs(t,r,c),l},getCoords:()=>r,getSource:()=>t,getName:()=>"Calculation",getMarkOptions:()=>n,isISnapshot:!0}}autoFill(e,t){return typeof e=="string"&&(e=Ct(e)),typeof t=="string"&&(t=Ct(t)),this._copyCalcs(this,e,t),this}_scheduleRecalculation(e){const t=this._pendingInvalidations;if(e)if(Array.isArray(e)){const r=e.length;for(let o=0;o<r;o++)t.add(e[o])}else t.add(e);const n=this;F.debounce(()=>{const r=n._latest.graph,o=r._volatile,i=r._cycleId;t.forEach(a=>{a.cycleId>i||o.add(a)}),t.clear(),r.calculate()},100)()}_notifyCalculated(e){const t=this,n=t._notifyValues,r=n.all();return new Promise(o=>{F.nextTick(()=>{const i=t._cycleId;let a,l=t._fullCalcRequired;l||(typeof e=="boolean"?l=e:e&&(a=e,l=a.full??!1));const c={};let h=null;const u=r.length;if(u>0){n.clear();let C=r,y=null;for(let R=0;R<u;R++){const A=r[R],M=A.colStart,T=A.colEnd;if(M!==T){y||(y=[]);for(let N=M+1;N<=T;N++)y.push({colStart:N,rowStart:A.rowStart,colEnd:N,rowEnd:A.rowEnd});A.colEnd=M}}y&&(C=r.concat(y)),C.sort(k.columnFirstRangeComparator);const b=new exports.Tuple.Builder(R=>new Bt(R));let w;const E=t._values,x=E.getOrientation()===exports.w.Orientation.Column,I=C.length;for(let R=0;R<I;R++){const A=C[R];h=k.unionRanges(h,A,Oe);const M=E.getRuns({bounds:A});let T=M.next();const N=A.colStart,B=A.rowStart,D=A.colEnd,P=A.rowEnd,L=x?B:N,z=x?D:P,O=x?P:D;let j=x?N:B,V=L;for(;!T.done;){const W=T.value,H=W[0];for(;j<H;)w||(w=[]),w.push({colStart:x?j:V,rowStart:x?V:j,colEnd:x?j:O,rowEnd:x?O:j}),j++,V=L;const G=W[1],$=W[2],Z=Math.max(G,L),Y=Math.min(G+$.length-1,O);b.addValues(H,Z,$),V<Z&&(w||(w=[]),w.push({colStart:x?H:V,rowStart:x?V:H,colEnd:x?H:Z-1,rowEnd:x?Z-1:H})),V=Y+1,Y>=O?(j=H+1,V=L):j=H,T=M.next()}for(;j<=z;)V<=O&&(w||(w=[]),w.push({colStart:x?j:V,rowStart:x?V:j,colEnd:x?j:O,rowEnd:x?O:j})),j++,V=L}const v=b.build();v&&(c.valueInserts=v),w&&(c.valueRemoves=w)}const d=t._notifyPending,g=d.all();if(g.length>0){d.clear();const C=t._pendingSpatial;let y;const b=g.length;for(let w=0;w<b;w++){const E=g[w];C.insertNonOverlapping(E,{onIntersect:(x,I)=>(y||(y=[]),y.push({...I}),h=k.unionRanges(h,I),I.value===!1&&(I.value=null),I)})}y&&y.length>0&&(c.pendingUpdates=y,h=k.unionRangesArrays(y,h,Oe))}const m=t._notifySpills,f=m.all();if(f.length>0){m.clear();const C=t._spillSpatial;let y,b,w;const E=f.length;for(let x=0;x<E;x++){const I=f[x],v=I.value;if(v.getCycleId()!==i)y||(y=[]),y.push({colStart:I.colStart,rowStart:I.rowStart,colEnd:I.colEnd,rowEnd:I.rowEnd});else{const R=C.search(I),A=R.length;for(let M=0;M<A;M++){let T=R[M];if(cf(I.rowStart,I.colStart,T)&&v.getCycleId()===i){b||(b=[],w=new Set);const N=Pt(T.colStart)+$t(T.rowStart);if(w.has(N))continue;w.add(N),b.push({colStart:I.colStart,rowStart:I.rowStart,colEnd:I.colEnd,rowEnd:I.rowEnd,value:T.value.getError()})}}}}b&&(c.spillInserts=b,h=k.unionRangesArrays(b,h,Oe)),y&&(c.spillRemoves=y,h=k.unionRangesArrays(y,h,Oe))}const _=t._notifyFormats.all();_.length>0&&(c.formatInserts=_,h=k.unionRangesArrays(_,h,Oe),t._notifyFormats.clear());const p=t._notifyFormulaInsertEntries;if(p){const C=t._formulaSpatial;for(let y=p.length-1;y>=0;y--){const b=p[y];C.search(b).length===0?p.splice(y,1):h=k.unionRanges(h,b,Oe)}c.formulaInserts=p,t._notifyFormulaInsertEntries=void 0}const S=t._notifyFormulaRemoveEntries;S&&(c.formulaRemoves=S,h=k.unionRangesArrays(S,h,Oe),t._notifyFormulaRemoveEntries=void 0),h&&(c.bounds=k.sanitizeRange(h)),Object.keys(c).length===0?c.cycleId=i-1:(c.cycleId=i,t._cycleId++),l&&(c.isFull=!0),t._fullCalcRequired=!1,t._options.onCalculated?.(c),o(c)})})}_setInputs(e,t,n){if(this._calculation.getStatus()===exports.ICalculation.Status.Starting)return this._addToPending(()=>{const I=this._setInputs(e,t,n),v={formulaInserts:I.inserts??F.EmptyArray,formulaRemoves:I.removes??F.EmptyArray,cycleId:this._cycleId,bounds:k.unionRanges(k.unionRangesArrays(I.inserts),k.unionRangesArrays(I.removes))};return Promise.resolve(v)}),Xw;const r=this._values.getOrientation()!==exports.w.Orientation.Row,o=this._spillSpatial,i=this._errorSpatial,a=this._contentfulSpatial,l=[],c=this._formulaSpatial;let h,u,d=!c.isEmpty(),g=d?[]:null,m=this._values;if(e&&e.tuples){if(h=e.tuples,g){let I=e.bounds;if(d)if(I){const A=$o(I,r);l.push(A)}else{const A={colStart:Number.MIN_SAFE_INTEGER,rowStart:Number.MIN_SAFE_INTEGER,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER};l.push(A)}const v={majorStart:0,minorStart:0,majorEnd:0,minorEnd:0},R=h.length;for(let A=0;A<R;A++){const M=h[A],T=M[0];v.majorStart=T,v.majorEnd=T;const N=M[1],B=N.length;for(let D=0;D<B;D++){const P=N[D];v.minorStart=P[0];const L=P[1];v.minorEnd=v.minorStart+L.length-1;const z=$o(v,r);g&&c.search(z).length>0&&g.push(z)}}}u=Fu(e.tuples,r)}(n||h)&&(fi(this._cycleId,n?[n]:F.EmptyArray,u,a,o,m,l,this._notifyValues,this._notifySpills,this._notifyPending,i,r,!1),n&&m.delete(n),h&&m.setValues(h));const f=this._calculation._getContext(),_=this._calculation._getScope();let p,S;_.sheetName=this._options.getSheetName?.();const C=this._getFormulaParser(),y=(I,v)=>{const R=I.rowStart,A=I.colStart,M={...I,value:null};if(c.insertNonOverlapping(M,{noMerge:!0,onIntersect:(T,N)=>T.value===null?null:(S||(S=[]),S.push(T),N)}),v!==null){_.rowIndex=R,_.colIndex=A;const T=C.parse(f,v),N=new un(I,T),B={...I,value:N};p||(p=[]),p.push(B)}},b=g?g.length:0;for(let I=0;I<b;I++)y(g[I],null);const w=t?t.length:0;for(let I=0;I<w;I++){const v=t[I],R=v.value;y(k.sanitizeRange(v),R)}const E=S?S.length:0,x=this._precedentSpatial;for(let I=0;I<E;I++){const v=S[I].value.calcs;if(v){const R=v.length;for(let A=0;A<R;A++){const M=v[A];for(let T=0;T<M.length;T++){const N=M[T];if(N.dynamic){for(let B=0;B<N.dynamic.length;B++){const D=N.dynamic[B];x.remove(D)}N.dynamic=null}}}}}return t&&(c._updateNodes(p,F.EmptyArray),fi(this._cycleId,S,p,a,o,m,l,this._notifyValues,this._notifySpills,this._notifyPending,i,r,!0)),this._invalidate(l),{inserts:this._notifyFormulaInsertEntries??F.EmptyArray,removes:this._notifyFormulaRemoveEntries??F.EmptyArray}}_invalidate(e){if(!e||e.length==0)return;const t=this._invalidations,n=fn(e,exports.w.Orientation.Column,2);for(let r=0;r<n.length;r++)t.insertNonOverlapping(n[r]);this._emitter?.notify("onInvalidate")}_markAndPlan(e,t,n){let r;mo=0,sl=0,Ts=0,fo=0;const o=this._precedentSpatial,i=this._formulaSpatial;rl=0,Ms=0;const a=this._cycleId,l=t.length;for(let d=0;d<l;d++){const g=t[d];g.markId!==n&&(g.markId=n,g.cycleId=a,g.inDegree=0,tl[mo++]=g,nl[Ms++]=g)}const c=(d,g,m)=>{(e||d.state===Vl)&&(r||(r=[]),r.push(g),e||m(d))},h=d=>{d.markId!==n&&(d.markId=n,d.cycleId=a,d.inDegree=0,tl[mo++]=d,nl[Ms++]=d)};for(;rl<Ms;){const d=nl[rl++],g=d.colIndex,m=d.rowIndex;Oe.colStart=g,Oe.rowStart=m,Oe.colEnd=g,Oe.rowEnd=m;const f=o.search(Oe),_=f.length;if(_===0)d.dependents=F.EmptyArray;else for(let p=0;p<_;p++){const S=f[p],C=S.value.once;C?c(C,S,h):Ed(S,m,g,h)}}for(let d=0;d<mo;d++){const g=tl[d],m=g.block,f=g.rowIndex,_=g.colIndex,p=m.formula.getDirectPrecedentsAt(f,_);let S=0;const C=g.precedents;for(let y=0;y<p.length;y++){const b=p[y];if(b.isFormulaError){C[y]=b;continue}{const A=b;A.calc=void 0,C[y]=A}const w=b.colStart,E=b.rowStart,x=b.colEnd,I=b.rowEnd,v=i.search(b),R=v.length;for(let A=0;A<R;A++){const M=v[A],T=M.colStart,N=M.rowStart,B=M.colEnd,D=M.rowEnd,P=Math.max(T,w),L=Math.max(N,E),z=Math.min(B,x),O=Math.min(D,I),j=M.value.calcs;for(let V=L;V<=O;V++){const W=j[V-N];for(let H=P;H<=z;H++){const G=W[H-T];G.markId===n&&(b.calc=G,S++)}}}}g.inDegree=S,g.inDegree===0&&(ol[Ts++]=g)}const u=d=>{d.markId===n&&(d.inDegree--,d.inDegree===0&&(ol[Ts++]=d))};for(;sl<Ts;){const d=ol[sl++];vd[fo++]=d;const g=d.colIndex,m=d.rowIndex;Oe.colStart=g,Oe.rowStart=m,Oe.colEnd=g,Oe.rowEnd=m;const f=o.search(Oe),_=f.length;for(let p=0;p<_;p++){const S=f[p],C=S.value.once;C?c(C,S,u):Ed(S,m,g,u)}}return fo<mo?{completed:!1,onces:r}:{completed:!0,onces:r}}_evaluate(e){const t=this._calculation._getContext(),n=this._calculation._getScope();n.sheetName=this._options.getSheetName?.();let r=Jw;r.length=0;let o=0,i=!0;const a=this._cycleId,l=this._invalidations,c=this._contentfulSpatial,h=this._notifyValues,u=this._notifySpills,d=this._precedentSpatial,g=this._spillSpatial,m=this._values,f=m.getOrientation(),_=f===exports.w.Orientation.Column;let p;n.spillSpatial=this._spillSpatial,n.values=m;const S=t.getEntireCoords.bind(t);let C;for(let y=0;y<fo;y++){const b=vd[y];if(b.state===Nu&&a===b.cycleId){b.state=Vl;continue}if(b.dynamic){for(let q=0;q<b.dynamic.length;q++){const ue=b.dynamic[q];d.remove(ue)}b.dynamic=null}const w=b.block,E=b.colIndex,x=b.rowIndex;let I=e?void 0:b.cachedValue,v=b.error;!v&&I&&I.isFormulaError&&(v=I);let R=!1;const A=b.precedents;if(A){const q=A.length,ue=b.inputs;for(let le=0;le<q;le++){const K=A[le],oe=K.calc;if(oe&&oe.pending){R=!0;continue}if(K.isFormulaError){ue[le]=K;continue}const ie=K.colStart,J=K.rowStart,X=K.colEnd;K.rowEnd!==J||ie!==X?(o>0&&(r.length=o,bd(r,m,h,_),o=0),ue[le]=new Xo(m,null,{...K},null,S)):ue[le]=oe===void 0?K:oe.cachedValue}b.pendingPrecedents=R}const M=_?E:x,T=_?x:E;n.node=b,n.colIndex=E,n.rowIndex=x;const N=w.formula;let B,D;const P=b.pending;let L=P;if((R||b.pendingPromise)&&(L=!0,B=b.cachedValue??null,b.pendingPromise&&(b.pendingResolved?(b.pendingPromise=null,b.pendingResolved=!1,L=!1):(b.pendingPromise.cancelled=!0,B=void 0))),B===void 0&&(n.formula=N,n.colIndex=E,n.rowIndex=x,B=N.evaluate(t,void 0,b.inputs),n.formula=null,D=B&&B.then?B:null,L=!!D),L!==P&&(b.pending=L,p||(p=Ln(_)),p.append(M,T,L)),D&&(B=b.cachedValue??null,!D.__originator)){D.__originator=a;const q=b;As.add(q),q.pendingPromise=D,q.pendingResolved=!1,D.then(ue=>{if(As.delete(q),D.cancelled)return;q.pendingPromise=D,q.pendingResolved=!0;let le=ns(ue,t);le===null&&(le=0),q.cachedValue=le,this._scheduleRecalculation(q)},ue=>{})}let z=1,O=1;const j=I instanceof nt;let V;const W=I instanceof exports.n.Spill;if(j||W){uo.colStart=E,uo.rowStart=x,uo.colEnd=E,uo.rowEnd=x;const q=g.search(uo);for(let ue=0;!V&&ue<q.length;ue++){const le=q[ue];le.colStart===E&&le.rowStart===x&&(V=le)}if(V){if(j){const le=I;z=le.getWidth(),O=le.getHeight()}const ue={colStart:E,rowStart:x,colEnd:E+z-1,rowEnd:x+O-1};g.remove(V),V&&V.value.getError()||(c.insertNonOverlapping({...ue,value:null}),m.delete(ue),h.insertNonOverlapping(ue))}}let H=1,G=1;const $=B,Z=$?.isIRange;let Y,re=B instanceof exports.n.Spill;if(Z&&$.size>1){H=$.getWidth(),G=$.getHeight();const q={colStart:E,rowStart:x,colEnd:E+H-1,rowEnd:x+G-1},ue=t.getEntireCoords(),le=!k.isRangeWithinRange(q,ue);if(le&&(q.colEnd=Math.min(q.colEnd,ue.colEnd),q.rowEnd=Math.min(q.rowEnd,ue.rowEnd)),re=le,!re){const ie=c.search(q);if(re=ie.length>1,!re&&ie.length===1){const J=ie[0],X=k.intersectRanges(q,J,Oe);(X&&(X.rowEnd!==X.rowStart||X.colStart!==X.colEnd)||X.colStart!==E||X.rowStart!==x)&&(re=!0)}}let K,oe;if(re)B=exports.n.BuiltIn.Spill,H=1,G=1,K=[[M,[[T,[B]]]]],m.setValues(K),oe={colStart:E,rowStart:x,colEnd:E,rowEnd:x};else{const ie=Vw($,M,T);ie&&(K=ie.tuples),K&&m.setValues(K),oe=q}Y={...q,value:new er(q,a,re)},g.insert(Y),C=Jl(C,b,q),h.insertNonOverlapping(oe),l.insertNonOverlapping(oe),c.insertNonOverlapping({...oe,value:new Vt(oe,f)})}(!k.isEqualRanges(V,Y)||re||W)&&(V&&u.insert(V),Y&&u.insert(Y)),H===z&&G===O||(b.state=Nu,l.insertNonOverlapping({colStart:E,rowStart:x,colEnd:E+Math.max(H,z)-1,rowEnd:x+Math.max(G,O)-1}),i=!1);let ee=B&&B.isFormulaError?B:null;N.getError()&&(ee=N.getError()),(ee||v&&!e)&&(ee&&!ee.equals(v)||v&&v.equals(ee)),b.cachedValue=B,r[o++]=b}if(n.node=null,n.colIndex=Number.MAX_SAFE_INTEGER,n.rowIndex=Number.MAX_SAFE_INTEGER,p){const y=p.done(!0);this._notifyPending.load(y)}return o>0&&(r.length=o,bd(r,m,h,_),o=0),{completed:i,dynamic:C,count:fo}}async calculate(e){const t=this._calculation.getStatus();if(t===exports.ICalculation.Status.Starting)return void this._addToPending(()=>this.calculate(e));if(t!==exports.ICalculation.Status.Ready)return;let n=this._fullCalcRequired;n||(typeof e=="boolean"?n=e:e&&(n=e.full??!1));const r=this._invalidations;if(this._formulaSpatial.isEmpty()){if(r.clear(),As.size>0){const h=++go;As.forEach(u=>{u.markId=h})}return this._notifyCalculated(e)}let o=n;const i=this._volatile;let a=++go,l=this._collectDirties(a,o,r.all(),i);if(r.clear(),i.clear(),!o&&l.length===0)return this._notifyCalculated(e);o&&this._clearCalcs();const c=this._resetScope();for(;l.length>0;){a=++go;const h=this._markAndPlan(o,l,a).onces;if(h){const d=this._precedentSpatial,g=h.length;for(let m=0;m<g;m++)d.remove(h[m],Cd)}l.length=0;const u=this._evaluate(o);if(u.dynamic&&this._precedentSpatial.load(u.dynamic),c.dynamicPrecedentsInserts&&(this._precedentSpatial.load(c.dynamicPrecedentsInserts),c.dynamicPrecedentsInserts=[]),c.conflatingFormats){const d=c.conflatingFormats.done(!0),g=this._notifyFormats;for(let m=0;m<d.length;m++){const f=d[m];g.insertNonOverlapping(f)}c.conflatingFormats=null}u.completed||(o=!1,a=++go,l=this._collectDirties(a,o,r.all(),i),r.clear())}return this._clearScope(),this._notifyCalculated(e)}_clearScope(){const e=this._calculation._getScope();e&&(e.rowIndex=0,e.colIndex=0,e.node=null,e.values=this._values,e.formulaSpatial=this._formulaSpatial,e.volatile=this._volatile,e.conflatingFormats=null,e.dynamicPrecedentsInserts=null,e.formula=null,e.getEntireCoords=Ai)}_resetScope(){const e=this._calculation._getScope();if(e)return e.rowIndex=0,e.colIndex=0,e.node=null,e.values=this._values,e.formulaSpatial=this._formulaSpatial,e.volatile=this._volatile,e.conflatingFormats=null,e.dynamicPrecedentsInserts=null,e.formula=null,e.getEntireCoords=this._getEntireCoords,e}_clearCalcs(){const e=this._values,t=this._spillSpatial,n=this._contentfulSpatial,r=t.all();for(let o=0;o<r.length;o++){const i=r[o];i.value.getError()||(e.delete(i),n.insertNonOverlapping({...i,value:null}))}t.clear(),this._errorSpatial.clear(),this._pendingSpatial.clear(),this._volatile.clear(),this._clearNotifications()}_clearNotifications(){this._invalidations.clear(),this._notifyValues.clear(),this._notifySpills.clear(),this._notifyFormats.clear(),this._notifyPending.clear()}_clearAll(){this._cycleId!==1&&this._cycleId++,go++,this._formulaSpatial.clear(),this._contentfulSpatial.clear(),this._pendingInvalidations.clear(),this._values.clear(),this._precedentSpatial.clear(),this._volatile.clear(),this._spillSpatial.clear(),this._errorSpatial.clear(),this._pendingSpatial.clear(),this._clearNotifications(),this._notifyFormulaInsertEntries=void 0,this._notifyFormulaRemoveEntries=void 0}_addToPending(e){let t=this._pendingActions;if(!t){this._pendingActions=t=[];const n=this;n._calculation.addListeners({onReady:()=>{(async()=>{const r=n._pendingActions,o=r.length;for(let i=0;i<o;i++){const a=r[i],l=await a.bind(n)();n._options.onCalculated?.(l)}this._pendingActions=null})()},onError:()=>{}},{once:!0})}t.push(e)}fromJSON(e){const t=this._calculation.getStatus();if(t===exports.ICalculation.Status.Starting)return void this._addToPending(()=>Promise.resolve(this.fromJSON(e)));if(t!==exports.ICalculation.Status.Ready)return;this._clearAll();const n={cycleId:0,isFull:!0};if(!e)return n;this._isProcessingJSON=!0;try{if(e.data){const i=e.data;this._values.setValues(i);const a=this._values.getOrientation()===exports.w.Orientation.Column,l=Fu(i,a);this._contentfulSpatial.load(l)}const r=this._formulaSpatial,o=e.formulas;if(o){const i=e.dynamic,a=new Set;if(i){const p=i.length;for(let S=0;S<p;S++){const C=i[S],y=C[0].split(":")[0];a.add(y)}}const l=o.length,c=new Array(l),h=[],u=[],d=this._calculation._getContext(),g=this._calculation._getScope();g.colIndex=0,g.rowIndex=0;const m=this._getFormulaParser();for(let p=0;p<l;p++){const S=o[p],C=S[0],y=Ct(C),b=S[1],w=y.rowStart,E=y.colStart;g.colIndex=E,g.rowIndex=w;let x=m.parse(d,b);const I=x.getDirectPrecedentsAt(w,E,!0,Is,Rs),v=I.length;v===1&&(x=x.wrapImplicit(w,E,a));const R={...y},A=new un(R,x);y.value=A,c[p]=y;const M=y.rowEnd,T=y.colEnd-E,N=M-w,B=[];for(let D=0;D<v;D++){const P=I[D];if(P instanceof exports.n.Known)continue;const L=Is[D],z=Rs[D],O={colStart:P.colStart,rowStart:P.rowStart,colEnd:P.colEnd+(z?0:T),rowEnd:P.rowEnd+(L?0:N),value:{blockEntry:y,width:T+1,height:N+1,index:D,$absWidth:z,$absHeight:L,once:null}};B.push(P),u.push(O)}h.push({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:{tokens:x.getTokens(),references:x.getReferences(),precedents:B}})}if(r.load(c),this._precedentSpatial.load(u),h.length>0&&(n.formulaInserts=h),i){const p=[],S=[];let C;const y=this._values,b=i.length;for(let w=0;w<b;w++){const E=i[w],x=E[0],I=Ct(x),v=E[1],R={...I},A=R.colStart,M=R.rowStart,T=R.colEnd,N=R.rowEnd;vr.colStart=A,vr.rowStart=M,vr.colEnd=A,vr.rowEnd=M;const B=r.search(vr);if(B.length!==1)continue;const D=B[0].value,P=D.ref,L=D.calcs,z=M-P.rowStart,O=A-P.colStart,j=L[z][O];if(v)j.cachedValue=exports.n.BuiltIn.Spill;else{const W=new nt(y,R);j.cachedValue=W}I.value=new er(R,0,v),S.push(I);const V={colStart:A,rowStart:M,colEnd:T,rowEnd:N,value:v};k.isSingleCell(V)||p.push(V),Jl(C,j,R)}this._spillSpatial.load(S),this._precedentSpatial.load(C),p.length>0&&(n.spillInserts=p)}const f=e.volatile,_=f?f.length:0;if(_>0){const p=this._volatile,S=C=>{p.add(C)};for(let C=0;C<_;C++){const y=f[C],b=Ct(y,vr),w=r.search(b),E=w.length;for(let x=0;x<E;x++){const I=w[x];$w(I,b,S)}}}}}catch(r){throw r}finally{this._isProcessingJSON=!1}return n}async toJSON(e=!1){const t=this._formulaSpatial.all(),n=t.length;if(n===0)return null;const r={};if(n>0){const l=new Array(n);for(let c=0;c<n;c++){const h=t[c];l[c]=h.value.toJSON()}r.formulas=l}const o=this._spillSpatial.all(),i=o.length;if(i>0){const l=this._getEntireCoords(),c=new Array(i);for(let h=0;h<i;h++){const u=o[h],d=bn(u,l);c[h]=[d,u.value.getError()]}r.dynamic=c}const a=this._volatile;if(a.size>0){const l=a.values();let c=l.next();const h=this._values.getOrientation()===exports.w.Orientation.Column,u=Ln(!0);for(;!c.done;){const f=c.value;if(Array.isArray(f))for(let _=0;_<f.length;_++){const p=f[_];for(let S=0;S<p.length;S++){const C=p[S],y=C.colIndex,b=C.rowIndex,w=h?y:b,E=h?b:y;u.append(w,E)}}else{const _=f.colIndex,p=f.rowIndex,S=h?_:p,C=h?p:_;u.append(S,C)}c=l.next()}const d=u.done(!0),g=d.length,m=new Array(g);for(let f=0;f<g;f++){const _=d[f],p=bn(_,this._getEntireCoords());m[f]=p}r.volatile=m}return r}}const bd=(s,e,t,n)=>{const r=new exports.Tuple.Builder(Uw),o=Ln(n);s.sort(n?k.columnFirstCellComparator:k.rowFirstCellComparator);const i=s.length;for(let c=0;c<i;c++){const h=s[c],u=h.colIndex,d=h.rowIndex;if(!h.cachedValue?.isIRange){const m=n?u:d,f=n?d:u;let _=h.cachedValue;r.addValue(m,f,_),o.append(m,f)}}const a=r.build();a&&a.tuples&&e.setValues(a.tuples);const l=o.done(!0);for(let c=0;c<l.length;c++){const h=l[c];t.insertNonOverlapping(h)}},$w=(s,e,t)=>{const n=s.colStart,r=s.rowStart,o=s.colEnd,i=s.rowEnd,a=e.colStart,l=e.rowStart,c=e.colEnd,h=e.rowEnd,u=Math.max(n,a),d=Math.max(r,l),g=Math.min(o,c),m=Math.min(i,h),f=s.value.calcs;for(let _=d;_<=m;_++){const p=_-r,S=f[p];for(let C=u;C<=g;C++){const y=C-n;t(S[y],p,y)}}},Ed=(s,e,t,n)=>{const r=s.value,o=r.$absHeight,i=r.$absWidth,a=r.width,l=r.height,c=r.blockEntry.value.calcs,h=t-s.colStart,u=e-s.rowStart,d=Math.min(Math.max(h,0),a-1),g=Math.min(Math.max(u,0),l-1);if(o||i)if(i){const m=c[g];for(let f=0;f<a;f++)n(m[f])}else if(o)for(let m=0;m<l;m++)n(c[m][d]);else for(let m=0;m<l;m++){const f=c[m];for(let _=0;_<a;_++)n(f[_])}else n(c[g][d])},Gw={rowIndex:0,colIndex:0},Oe={rowStart:0,colStart:0,rowEnd:0,colEnd:0},Is=[],Rs=[],vr={rowStart:0,colStart:0,rowEnd:0,colEnd:0},uo={rowStart:0,colStart:0,rowEnd:0,colEnd:0};new exports.n.Calc("Cyclical dependency");const Uw=s=>new Bt(s);let go=0;const ar=1e4,qw=new Array(ar),Jw=new Array(ar),As=new Set,tl=new Array(ar);let mo=0;const nl=new Array(ar);let rl=0,Ms=0;const ol=new Array(ar);let sl=0,Ts=0;const vd=new Array(ar);let fo=0;const xd=new Array(ar),po={colStart:0,rowStart:0,colEnd:0,rowEnd:0},_o={colStart:0,rowStart:0,colEnd:0,rowEnd:0},il=[null,null],Xw=Object.freeze({inserts:F.EmptyArray,removes:F.EmptyArray});function Kw(s,e,t,n){const r=s;if(r?.getSplit){const o=r.getSplit(e,t,n);if(o===void 0)return;e[0].value=o[0],e[1].value=o[1]}return e}class Yw{constructor(e,t=!0){this._options={...ey,...e},this._getFunction=this._options.getFunction,this._isColumn=t}_setInstanceScope(e){this._instanceScope=e}async _initialize(){const e=await rc._validate(!0),t=Zw();this._calcScope=t,this._runtime=new Qw(this._options,e);const{initializeBuiltIns:n}=await Promise.resolve().then(()=>require("./C501EF7RGelm6o3R.cjs")),r=this;return this._builtInFunctions=Object.freeze(n(()=>r)),{builtInFunctions:this._builtInFunctions,calcScope:this._calcScope}}getBuiltInFunctions(){return this._builtInFunctions}getFunction(e){return this._builtInFunctions.get(e)??this._getFunction?.(e)}getNumberFormat(e,t){return exports.NumberFormat.Parser.formatValue(e,t,{date1904:this._options.isDate1904?.()??!1})}getEntireCoords(){return this._calcScope.getEntireCoords()}getFormulaAt(e,t){const n=this._calcScope.formulaSpatial;if(!n)return null;So.colStart=t,So.rowStart=e,So.colEnd=t,So.rowEnd=e;const r=n.search(So);return r.length===0?null:r[0].value.formula.getTextAt(e,t)??null}markVolatile(){const e=this._calcScope,t=e.volatile;t&&t.add(e.node)}formatResults(e){const t=this._calcScope,n=this._isColumn,r=n?t.colIndex:t.rowIndex,o=n?t.rowIndex:t.colIndex;t.conflatingFormats||(t.conflatingFormats=Ln(n)),t.conflatingFormats.append(r,o,e)}getSheetIndex(e){const t=this._calcScope;return e===void 0&&(e=t.sheetName),this._options.getSheetIndex?.(e)??-1}getSheetCount(){return this._options.getSheetCount?.()??1}isValidDate(e){return qr(e)}fromOADate(e){return Jr(e,this._options.isDate1904?.()??!1)}toOADate(e){return Qo(e,this._options.isDate1904?.()??!1)}_fromTuples(e,t=null,n=!1){if(!e)return null;const r=$o(e.bounds,!0),o=this._calcScope,i=this._isColumn?exports.w.Orientation.Column:exports.w.Orientation.Row,a=new Qt({orientation:i,maxCoords:o.getEntireCoords()});return a.setValues(e.tuples),new nt(a,r,t,n)}getValueAt(e,t){return this._calcScope.values.getValueAt(e,t)??null}getSpillAt(e,t){const n=this._calcScope.spillSpatial;if(!n)return null;wo.rowStart=e,wo.colStart=t,wo.rowEnd=e,wo.colEnd=t;const r=n.search(wo);if(r.length===0)return null;for(let o=0;o<r.length;o++){const i=r[o];if(i.rowStart===e&&i.colStart===t)return this.getReference(k.sanitizeRange(i))}return null}getRange(e,t){if(e?.isIRange)return e;let n;const r=Array.isArray(e);if(t=t??r,r)if(Array.isArray(e[0]))n=e;else{if(e[0]?.isIRange)throw exports.n.BuiltIn.Value;n=[e]}else n=[[e]];const o=this._isColumn,i=o?exports.w.Orientation.Column:exports.w.Orientation.Row,a=this._fromTuples(Ii(n,o,Et(0,0,void 0,void 0,o),!0),void 0,t);if(a)return a;const l=new Qt({orientation:i,maxCoords:this._calcScope.getEntireCoords()});return new nt(l,k.EmptyRange,void 0,t)}getPosition(){const e=this._calcScope;return{colIndex:e.colIndex,rowIndex:e.rowIndex}}getReference(e,t){if(!e)throw exports.n.BuiltIn.Ref;const n=this._calcScope,r=n.getEntireCoords;if(typeof e=="string"){if(t)throw exports.n.BuiltIn.Ref;try{const c=Sc(e,r(),os,()=>{throw exports.n.BuiltIn.Ref},t);if(c.length>1)throw exports.n.BuiltIn.Ref;e=c[0]}catch{throw exports.n.BuiltIn.Ref}}if(!e)throw exports.n.BuiltIn.Ref;const o=n.values;let i;const a=n.node;let l;if(a){const c=a.precedents;l=ty(c,e)}if(l){const c=l.calc;i=c&&c.isIReferenceRange?c.cachedValue:new Xo(o,void 0,e,null,r)}else n.dynamicPrecedentsInserts=Jl(n.dynamicPrecedentsInserts,a,e),i=new Xo(o,void 0,e,null,r);return i}getAddress(e,t=!1){e||(e=this.getPosition());const n=this.getEntireCoords().sheetName;return e.colIndex!==void 0?((r,o,i=!1)=>i?ci(r,o):Wa(r,o))(e,n,t):((r,o,i=!1)=>(i?ci({colIndex:r.colStart,rowIndex:r.rowStart,$colIndex:r.$colStart,$rowIndex:r.$rowStart,sheetName:r.sheetName},o):Wa({colIndex:r.colStart,rowIndex:r.rowStart,$colIndex:r.$colStart,$rowIndex:r.$rowStart,sheetName:r.sheetName},o))+":"+(i?ci({colIndex:r.colEnd,rowIndex:r.rowEnd,$colIndex:r.$colEnd,$rowIndex:r.$rowEnd},null):Wa({colIndex:r.colEnd,rowIndex:r.rowEnd,$colIndex:r.$colEnd,$rowIndex:r.$rowEnd},null)))(e,n,t)}parseAsDateTime(e,t=!1){return function(n,r=!1,o=!1){let i=n,a=Kg(n,r,!0);a&&(i=a.leadingText);let l=null;if(i.trim().length>0&&(l=ic(i,r),!l&&o))return null;!l&&a?.leadingText.trim().length>0&&(a=null);let c=0;return l&&(c+=l.asOADate),a&&(c+=a.parsed.oaDateTime),c}(e,this._options.isDate1904?.()??!1,t)}getRuntime(){return this._runtime}get[Symbol.toStringTag](){return"[CalculationContext]"}toString(){let e="";const t=this._instanceScope;let n;return t&&(n=t.toString?.()),n&&n&&(e=`${e}:[${n}]`),e}}class Qw{constructor(e,t){this._options=e,this._license=t}getCurrencySymbol(){return"$"}getNumberDecimalSeparator(){return"."}getNumberGroupSeparator(){return","}isDate1904(){return this._options.isDate1904?.()??!1}getDescription(){return"Calculation Runtime"}getLocation(){return F.isNode()?process.cwd():window.location?.href??"/"}getVersion(){try{const e="0.4.19";if(e.indexOf(".env.")===-1)return`${e}`}catch{return"local"}}getOS(){return F.getOS()}getUser(){return this._license?.licensee?.()??null}}const Zw=()=>({rowIndex:0,colIndex:0,sheetName:null,node:null,values:null,formulaSpatial:null,spillSpatial:null,volatile:null,conflatingFormats:null,dynamicPrecedentsInserts:null,formula:null,getEntireCoords:()=>ts}),ey={getSheetIndex:s=>-1,getSheetCount:()=>1,getSheetName:()=>null,getEntireCoords:()=>ts,getNamed:(s,e)=>null,getFunction:s=>null,isDate1904:()=>!1},ty=(s,e)=>{if(!s)return;const t=s.length;if(t===0)return;const n=e.colStart,r=e.rowStart,o=e.colEnd,i=e.rowEnd;for(let a=0;a<t;a++){const l=s[a],c=l;if(c!==void 0&&l.colStart===n&&l.rowStart===r&&l.colEnd===o&&l.rowEnd===i)return c}return null},So={rowStart:0,colStart:0,rowEnd:0,colEnd:0},wo={rowStart:0,colStart:0,rowEnd:0,colEnd:0};class ny{_setScope(e){this._scope=e}_getScope(e=!1){const t=this._scope;if(!t&&!e)throw new Error("FunctionContext can only be used in a function.");return t}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??ts}isValidDate(e){return this._getScope().isValidDate(e)}parseAsDateTime(e,t){return this._getScope().parseAsDateTime(e,t)}fromOADate(e){return this._getScope().fromOADate(e)}toOADate(e){return this._getScope().toOADate(e)}getRange(e){return this._getScope().getRange(e)}getValueAt(e,t){return this._getScope().getValueAt(e,t)}getPosition(){return this._getScope().getPosition?.()??D_}getReference(e,t){return this._getScope().getReference(e,t)}getFormulaAt(e,t){return this._getScope().getFormulaAt?.(e,t)??null}getSpillAt(e,t){return this._getScope().getSpillAt?.(e,t)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}getRuntime(){return this._getScope().getRuntime()}get[Symbol.toStringTag](){return"[FormulaContext]"}toString(){const e=this._getScope();if(e){const t=e.toString?.();if(t)return t}return e?"":"{NO SCOPE}"}}const hf=new ny,Bi="__SHEETXL";let Qn;const Id={FormulaContext:Qn,ScalarType:U,IRange:exports.w,FormulaError:exports.n,Observable:ig};let pi;function Ec(s){Qn||(Qn=hf,Id.FormulaContext=Qn),pi=globalThis[Bi],globalThis[Bi]=Id,Qn._setScope(s)}function Di(){pi?(globalThis[Bi]=pi,pi=void 0):delete globalThis[Bi],Qn&&Qn._setScope(null)}var Sn;(Sn||(Sn={})).Context={Workbook:"workbook",Sheet:"sheet",Ranges:"ranges",Range:"range",Calculation:"calculation"};class Ko{constructor(e,t,n,r=null,o=!1){this._ct=Sn.Context.Calculation,this._builtIn=!1,this._broadcast=!1,this._pj=null,this._json=e,this._n=e.name,this._d=new iy(e),this._ct=e.context??Sn.Context.Calculation;const i=e.parameters;let a;this._pj=i,t||(console.log(`TypeFunction '${e.name}' was not provided a function implementation.`),t=()=>{}),this._fn=t.bind(this),this._cf=n??oy,this._builtIn=o,a=r?typeof r=="function"?r:()=>Promise.resolve(r):ry(e),this._descFn=a;const l=i?.length??0;let c=l===1||l===2;c&&(i[0].arrayDepth>0||i[0].range)&&(c=!1),c&&l===2&&(i[1].arrayDepth>0||i[1].range)&&(c=!1),this._broadcast=c}execute(...e){const t=this._pj,n=[],r=this._cf?.();Ec(r);let o=!1,i=null;const a=t?.length??0;let l,c=this._broadcast;if(c){const h=Ru(e[0]);if(a===1&&h)c=!1;else if(a===2){const u=Ru(e[1]);h&&u&&(c=!1)}}try{for(let u=0;!o&&u<a;u++){const d=t[u];let g=d.scalar??null;g!==U.Null&&g!=="*"||(g=null);let m=d.range??null;const f=d.rest??!1,_=d.optional??!1;let p=e[u];if(_&&p===null&&(p=void 0),p===void 0){if(_){n.push(void 0);continue}if(!_&&!f)throw u<=e.length?Ad.ARGS_TOO_FEW([d.name],this._n):Ad.PARAM_MISSING(d.name,this._n);if(u>=e.length){o=!0;continue}}const S=d.arrayDepth??0;let C=(d.range?2:0)+S;const y=d.rest??!1;if(y)for(;u<e.length&&!i;)p!==void 0&&(i=Xl(r,n,p,g,m,S,y,C)),p=e[++u];else c&&(m="l",C=2),i=Xl(r,n,p,g,m,S,y,C),o=!!i}if(i)throw i;for(;n.length>0&&n[n.length-1]===void 0;)n.length--;const h=this._fn;if(c){if(n.length===1){const u=n[0];let d=t[0].scalar;d!==U.Null&&d!=="*"||(d=null),l=u.map(g=>{if(g instanceof exports.n.Known)return g;let m=g;try{m=h(m),(Array.isArray(m)||m?.isIRange)&&(m=exports.n.BuiltIn.Value)}catch(f){m=f}return m},{type:d})}if(n.length===2){const u=n[0];let d=t[0].scalar;d!==U.Null&&d!=="*"||(d=null);const g=n[1];let m=t[1].scalar;m!==U.Null&&m!=="*"||(m=null),l=u.broadcast(g,(f,_)=>{if(f instanceof exports.n.Known)return f;if(_ instanceof exports.n.Known)return _;let p;try{p=h(f,_),(Array.isArray(p)||p?.isIRange)&&(p=exports.n.BuiltIn.Value)}catch(S){p=S}return p},{type:d,otherType:m})}}else l=h(...n);l=ns(l,r)}catch(h){throw h}finally{Di()}return l}getName(){return this._n}getDeclaration(){return this._d}async getDescriptor(e){if(this._desc)return this._desc;const t=await Promise.resolve(this._descFn(e));return this._desc=new ay(this,t),this._desc}isBuiltIn(){return this._builtIn}getContext(){const e=this._ct;if(e==="sheet"||e==="workbook"||e==="ranges"||e==="range"){const t=this._json;return t&&t.behavior&&t.behavior.default?"autoRun":"macro"}return"formula"}get[Symbol.toStringTag](){return"[TypedFunction]"}toString(){let e="";const t=this._pj;return t.length>0&&(e=t.map(n=>{let r=n.name;return n.rest&&(r="..."+r),n.optional&&(r+="?"),r+=": "+((o,i)=>{if(i){const a=L_.get(i)??"InvalidRange";return o?`${a}<${Iu.get(o)??"InvalidScalar"}>`:a}return Iu.get(o)??"InvalidScalar"})(n.scalar,n.range),r+="[]".repeat(n.arrayDepth),r}).join(", ")),`${this.getName()}(${e})`}get isIFunction(){return!0}get isITypedFunction(){return!0}}const ry=s=>async e=>{const t={};for(let n=0;n<s.parameters.length;n++)t[s.parameters[n].name]=F.camelToPrettyCase(s.parameters[n].description);return{summary:F.camelToPrettyCase(s.name),parameters:t,category:"User Defined"}},oy=()=>null;class uf{constructor(e){this._s=e.scalar,this._r=e.range??null,this._d=e.arrayDepth??0}getScalarType(){return this._s}getRangeType(){return this._r}getArrayDepth(){return this._d}}class sy extends uf{constructor(e){super(e),this._n=e.name,this._o=e.optional??!1,this._rest=e.rest??!1,this._e=e.enums?Object.freeze(e.enums):F.EmptyArray}getName(){return this._n}isOptional(){return this._o}isRest(){return this._rest}getEnums(){return this._e}}class Rd extends uf{constructor(e){super(e),this._a=e.async??!1,this._stream=e.stream??!1}isAsync(){return this._a}isStreaming(){return this._stream}}class iy{constructor(e){if(this._n=e.name,e.parameters){const t=e.parameters.length,n=new Array(t);for(let r=0;r<t;r++)n[r]=new sy(e.parameters[r]);this._p=Object.freeze(n)}else this._p=F.EmptyArray;e.returnType?this._r=new Rd(e.returnType):this._r=new Rd({scalar:null,arrayDepth:0,range:null})}getName(){return this._n}getParameters(){return this._p}getReturnType(){return this._r}}class ay{constructor(e,t){if(this._n=t.name,this._fn=e,this._s=t.summary??F.camelToPrettyCase(t.name),this._c=t.category??"Uncategorized",this._h=t.hidden??!1,t.links&&t.links.length>0){const n=t.links.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=Object.freeze([t.links[o][0],t.links[o][1]]);this._l=Object.freeze(r)}else this._l=F.EmptyArray;if(t.parameters){for(const n in t.parameters)if(Object.prototype.hasOwnProperty.call(t.parameters,n)){const r=t.parameters[n].description,o=t.parameters[n].example,i=t.parameters[n].defaultValue,a={};r&&(a.description=r),o&&(a.example=o),i!==void 0&&(a.defaultValue=i),Object.freeze(a)}}}getName(){return this._n}getSummary(){return this._s}getCategory(){return this._c}isHidden(){return this._h}getLinks(){return this._l}getParameters(){return this._p}get[Symbol.toStringTag](){return"[Descriptor]"}toString(){const e=this._fn;return`${this.getSummary()}: ${e}`}}const Xl=(s,e,t,n,r,o,i,a)=>{if(t&&t.colStart!==void 0)if(r)t=s.getReference?.(t);else{const l=t.colStart,c=t.rowStart,h=t.colEnd;t=t.rowEnd!==c||l!==h?s.getReference?.(t):s.getValueAt(c,l)}if(a===0){let l=((c,h=null,u=!1)=>{let d=c;for(;Array.isArray(d);){if(d.length>1)return u?exports.n.BuiltIn.Value:d;d=d[0]}if(d?.isIRange){if(d.size!==1)return u?exports.n.BuiltIn.Value:d;d=d.getValueAt(0,0)}return h&&(d=Ot(d,Ze(d,!0),h)),d})(t,n,!0);return l instanceof exports.n.Known?l:void e.push(l)}if(a===2)return lo(s,e,t,n,r,Array.isArray(t));if(a===1||a===3){let l;const c=i?e:[];if(r){const h=Array.isArray(t);if(h){const u=t.length;for(let d=0;!l&&d<u;d++)l=lo(s,c,t[d],n,r,h)}else l=lo(s,c,t,n,r,h)}else if(a===3){let h=(u=>{let d=u,g=0;for(;Array.isArray(d);)g++,d=d[0];return d.isIRange&&(g+=2),g})(t);for(let u=h;u<2;u++)t=[t],h++;if(h===3){const u=t.length;for(let d=0;!l&&d<u;d++)l=lo(s,c,t[d],n,r,!0)}else l=lo(s,c,t,n,r,!0)}else l=Fm(s,c,t,n,r,r!==null);return l?.isFormulaError?l:void(i||e.push(c))}{if(!Array.isArray(t)){if(n&&(t=Ot(t,Ze(t,!0),n,!1),t?.isFormulaError))return e.push(t),t;t=[t]}const l=t.length;for(let c=0;c<l;c++){const h=[],u=Xl(s,h,t[c],n,r,o,i,a-1);if(u?.isFormulaError)return u;h.length>0&&e.push(h)}}},Ad={PARAM_MISSING:(s,e)=>new exports.n.NA(`Parameter ${s} is missing${e?` for ${e}`:""}.`),ARGS_TOO_FEW:(s,e)=>new exports.n.Parse(`Argument type ${s.join(", ")} is missing${e?` for ${e}`:""}.`)};class df{constructor(e){this._emitter=null,this._readonly=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Lt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._readonly=e?.readonlyFunctions,this._initState()}search(e){const t=this._getState();if(!t)return F.EmptyArray;const n=e?.name?e.name.toUpperCase():null,r=e?.type?e.type:null;let o;e?.category&&e.category.toUpperCase(),e?.text&&e.text;const i=(l,c)=>(!n||c===n)&&(!r||l.getContext()===r)&&(o||(o=[]),void o.push(l)),a=this._readonly;return a&&a.forEach(i),t.itemsByKey.forEach(i),o??F.EmptyArray}getByName(e){if(!e)return null;const t=this._getState();if(!t)return null;if(!t)return F.EmptyArray;const n=e.toUpperCase(),r=this._readonly;if(!r||!r.size)return null;let o=r.get(n);return o||(o=t.itemsByKey.get(n),o||null)}getCount(){const e=this._getState();if(!e)return 0;let t=e.itemsByKey.size;return this._readonly&&(t+=this._readonly.size),t}validateName(e){return this._validateName(e)}_validateName(e,t=!1){if(this._closed)throw new Error(Nt)}add(e){if(this._closed)throw new Error(Nt);if(!e)throw new Error("Item must be specified.");let t;if(e.isIFunction){const o=e,i=e._json;t=new Ko(i,o._fn,()=>this._options.context,o._desc)}else{const o=e;t=new Ko(o.declaration,o.execute,()=>this._options.context,o.descriptor)}const n=this._getState(),r=t.getName().toUpperCase();return n.itemsByKey.set(r,t),t}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Nt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update",n){if(!e)return;const r=this._beginCommit(t);try{r.updateState(this,e),r.commit(n)}catch(o){throw r.rollback(),o}}_initState(){this._updateState(e=>({...e,itemsByKey:new Map}),"Initialize",{forceAmend:!0})}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}}class vc extends ir{constructor(e){super(e),this._status=exports.ICalculation.Status.Off,this._statusTransition=null,this._emitter=new st(this)}_getContext(){return this._context}_getScope(){return this._scope}start(){return this._statusTransition||(this._statusTransition=(async()=>{if(this._status===exports.ICalculation.Status.Off)try{this._status=exports.ICalculation.Status.Starting,this._emitter.notify("onStatusChange"),this._emitter.notify("onStarting");const e=this,t=this._options,n=l=>e.getFunctions().getByName(l)??t?.getFunction?.(l),r=new Yw({...t,getFunction:n});this._context=r;const o=await r._initialize(),i=o.builtInFunctions;this._functions=new df({transactions:this._transactions,context:r,readonlyFunctions:i});const a=await Promise.resolve().then(()=>require("./oROZhcugo511lwYD.cjs"));this._formulaParser=new a.FormulaParser,this._scope=o.calcScope,this._status=exports.ICalculation.Status.Ready,this._emitter.notify("onStatusChange"),this._emitter.notify("onReady")}catch(e){throw this._status=exports.ICalculation.Status.Off,this._emitter.notify("onError",e),this._emitter.notify("onStatusChange"),e}finally{this._statusTransition=null}})()),this._statusTransition}_createGraph(e){const t=this._options;return new bc({...t,...e,getFormulaParser:()=>this._formulaParser,calculation:this})}async stop(){this._status===exports.ICalculation.Status.Ready&&(this._status=exports.ICalculation.Status.Stopping,this._emitter.notify("onStatusChange"),this._emitter.notify("onStopping"),this._status=exports.ICalculation.Status.Off,this._emitter.notify("onStatusChange"),this._emitter.notify("onStop"))}getStatus(){return this._status}getFunctions(){return this._checkReady(),this._functions}getRuntime(){return this._checkReady(),this._runtime}_checkReady(){if(this._status!==exports.ICalculation.Status.Ready)throw new Error(this._statusMessage())}_statusMessage(){switch(this._status){case exports.ICalculation.Status.Off:return"Calculation is off";case exports.ICalculation.Status.Starting:return"Calculation is starting";case exports.ICalculation.Status.Ready:return"Calculation is ready";default:return"Unknown calculation status"}}}var Fs,Ns;exports.ICellRange=void 0,exports.ICellRange||(exports.ICellRange={}),exports.ICellHeaderRange=void 0,exports.ICellHeaderRange||(exports.ICellHeaderRange={}),exports.IMovable=void 0,exports.IMovable||(exports.IMovable={}),exports.IAutoFilter=void 0,(Fs=exports.IAutoFilter||(exports.IAutoFilter={})).NumberFilterOperatorType={Equal:"equal",GreaterThan:"greaterThan",GreaterThanOrEqual:"greaterThanOrEqual",LessThan:"lessThan",LessThanOrEqual:"lessThanOrEqual",NotEqual:"notEqual"},Fs.Type={Color:"color",Custom:"custom",Dynamic:"dynamic",Items:"items",Icon:"icon",Top10:"top10"},Fs.DynamicType={AboveAverage:"aboveAverage",BelowAverage:"belowAverage",LastMonth:"lastMonth",LastQuarter:"lastQuarter",LastWeek:"lastWeek",LastYear:"lastYear",M1:"M1",M2:"M2",M3:"M3",M4:"M4",M5:"M5",M6:"M6",M7:"M7",M8:"M8",M9:"M9",M10:"M10",M11:"M11",M12:"M12",NextMonth:"nextMonth",NextQuarter:"nextQuarter",NextWeek:"nextWeek",Null:"null",Q1:"Q1",Q2:"Q2",Q3:"Q3",Q4:"Q4",ThisMonth:"thisMonth",ThisQuarter:"thisQuarter",ThisWeek:"thisWeek",Today:"today",Tomorrow:"tomorrow",YearToDate:"yearToDate",Yesterday:"yesterday"},Fs.DateItemGroupingType={Day:"day",Hour:"hour",Minute:"minute",Month:"month",Second:"Second",Year:"year"},exports.IConditionalFormat=void 0,(Ns=exports.IConditionalFormat||(exports.IConditionalFormat={})).Type={AboveAverage:"aboveAverage",BeginsWith:"beginsWith",CellIs:"cellIs",ColorScale:"colorScale",ContainsBlanks:"containsBlanks",ContainsErrors:"containsErrors",ContainsText:"containsText",DataBar:"dataBar",DuplicateValues:"duplicateValues",EndsWith:"endsWith",Expression:"expression",IconSet:"iconSet",NotContainsBlanks:"notContainsBlanks",NotContainsErrors:"notContainsErrors",NotContainsText:"notContainsText",TimePeriod:"timePeriod",Top10:"top10",UniqueValues:"uniqueValues"},Ns.OperatorType={BeginsWith:"beginsWith",Between:"between",ContainsText:"containsText",EndsWith:"endsWith",Equal:"equal",GreaterThan:"greaterThan",GreaterThanOrEqual:"greaterThanOrEqual",LessThan:"lessThan",LessThanOrEqual:"lessThanOrEqual",NotBetween:"notBetween",NotContains:"notContains",NotEqual:"notEqual"},Ns.TimePeriod={Last7Days:"last7Days",LastMonth:"lastMonth",LastWeek:"lastWeek",NextMonth:"nextMonth",NextWeek:"nextWeek",ThisMonth:"thisMonth",ThisWeek:"thisWeek",Today:"today",Tomorrow:"tomorrow",Yesterday:"yesterday"},Ns.ConditionalBoundsType={Formula:"formula",Max:"max",Min:"min",Num:"num",Percent:"percent",Percentile:"percentile"},exports.ISheetView=void 0,(exports.ISheetView||(exports.ISheetView={})).HeaderTextStyle={A1:"a1",Zero:"zero",One:"one"};class ly{constructor(e,t,n,r){this._mergedReading=[],this._colsReading=[],this._rowsReading=[],this._styles=e,this._topLeft=r??{rowIndex:0,colIndex:0},this._sheet=new Gr({styles:this._styles,date1904:t,container:{getName:()=>n,getIndex:()=>1}}),this._cellUpdater=this._sheet.getEntireRange().startIncrementalUpdates()}applyCSSStyle(e,t){let n=!1;e.style||(e.style={},n=!0);let r=e.style,o={...t};if(t.msoIgnore){const u=t.msoIgnore.split(",");let d=Object.keys(o);for(let g=0;g<d.length;g++){const m=d[g];u.includes(m)&&delete o[m]}}const i=ui(o.fontFamily);r.font={},i&&(r.font.family=i.family,r.font.fallbacks=i.fallbacks,r.font.size=i.size),r.font.size=o.fontSize,r.font.weight=o.fontWeight,r.font.style=o.fontStyle,r.font.fill=o.color;const a=(u=>{if(!u)return rS;let d=exports.IFont.UnderlineStyle.None,g=!1;return(u=u.toLowerCase()).includes("underline")&&(d=exports.IFont.UnderlineStyle.Single),(u.includes("line-through")||u.includes("linethrough"))&&(g=!0),{underline:d,strike:g}})(o.textDecoration);r.font.underline=a.underline,r.font.strike=a.strike,o.textUnderlineStyle&&(r.font.underline=qm(o.textUnderlineStyle)),r.alignment={},o?.textAlign&&(r.alignment.horizontal=(u=>{const d=F.textToKey(u);return kn.get(d)||null})(o.textAlign)),o?.textAlign&&!r.alignment.horizontal&&o?.textAlign!=="general"&&(o.textAlign==="center-across"?r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.CenterContinuous:o.textAlign==="fill"?r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.Fill:o.textAlign==="121"||o.textAlign==="010"?(r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.Distributed,r.alignment.justifyLastLine=o.textAlign==="121"):console.warn("unknown text-align",o.textAlign)),o.verticalAlign&&(o.verticalAlign.toLowerCase()==="super"?r.font.verticalAlign=exports.IFont.VerticalAlignment.Super:o.verticalAlign.toLowerCase()==="sup"?r.font.verticalAlign=exports.IFont.VerticalAlignment.Sub:r.alignment.vertical=(u=>{const d=F.textToKey(u);return hn.get(d)||null})(o.verticalAlign),r.alignment.vertical||(o.verticalAlign==="121"?r.alignment.vertical=exports.ITextFrame.VerticalAlignment.Distributed:console.warn("unknown vertical-align",o.verticalAlign))),o.msoCharIndentCount&&(r.alignment.indent=o.msoCharIndentCount),o.whiteSpace&&(r.alignment.overflow=o.whiteSpace==="no-wrap"||o.whiteSpace==="nowrap"?exports.ITextFrame.Overflow.Visible:exports.ITextFrame.Overflow.Wrap),o.msoTextControl==="shrinktofit"&&(r.alignment.overflow=exports.ITextFrame.Overflow.Shrink);let l=null;if(o.background?l=o.background:o.backgroundColor&&(l=o.backgroundColor),l&&(r.fill={color:l}),o.msoPattern){let u=LS(o.msoPattern);u&&(u.patternType===exports.IFill.BuiltInSheetPattern.Solid?r.fill={color:u.foreground}:u.patternType!==exports.IFill.BuiltInSheetPattern.None&&(l&&(u.background=l),r.fill=u))}o.msoRotate!==void 0&&(r.alignment.rotation=(u=>{let d=parseFloat(u);return isNaN(d)||(d%=360,d>0?d=360-d:d<0&&(d*=-1)),d})(o.msoRotate));const c=(u,d)=>{u&&(r.border||(r.border={}),r.border[u]=d)};o.border&&o.border!=="none"&&(c("top",o.border),c("left",o.border),c("right",o.border),c("bottom",o.border)),o.borderTop&&c("top",o.borderTop),o.borderLeft&&c("left",o.borderLeft),o.borderRight&&c("right",o.borderRight),o.borderBottom&&c("bottom",o.borderBottom),o.msoDiagonalUp&&c("diagonalUp",o.msoDiagonalUp),o.msoDiagonalDown&&c("diagonalDown",o.msoDiagonalDown);let h=r.numberFormat;o.msoNumberFormat&&(h=(u=>{let d=u.replace(/(\\[0-9]{4})/g,g=>String.fromCharCode(parseInt(g.replace(/\\/g,""),16)));return d=d.replace(/(\\.{1})/g,g=>g.substring(g.length-1,g.length)),d.includes("\\")&&(d=d.replace(/(\\.{1})/g,g=>g.substring(g.length-1,g.length))),d=d.replace(/^"(.*)"$/,"$1"),d})(o.msoNumberFormat),h.includes("\\")?h=null:h==="Fixed"?h=exports.NumberFormat.Styles.lookupStyle(r.numberFormat).formatType===exports.NumberFormat.Type.Number?null:exports.NumberFormat.Type.Number:h==="Percent"&&(h=exports.NumberFormat.Styles.lookupStyle(r.numberFormat).formatType===exports.NumberFormat.Type.Percentage?null:exports.NumberFormat.Type.Percentage)),h&&(r.numberFormat=h),e.style=this._styles.normalize(r),n&&Object.keys(e.style).length===0&&delete e.style}onCell(e,t,n,r,o){const i=r(o);let a={value:t!==void 0?t:n??""};if(typeof a.value=="string"&&a.value.length===0&&(a.value=void 0),i&&this.applyCSSStyle(a,i),o?.tagName.toUpperCase()==="TD"){let l=a.style,c=l?.font??{};(o.querySelectorAll("s").length>0||o.querySelectorAll("strike").length>0)&&(c.strike=!0),o.querySelectorAll("sub").length>0&&(c.verticalAlign=exports.IFont.VerticalAlignment.Sub),o.querySelectorAll("sup").length>0&&(c.verticalAlign=exports.IFont.VerticalAlignment.Super),(o.querySelectorAll("b").length>0||o.querySelectorAll("strong").length>0)&&(c.weight=700),o.querySelectorAll("i").length>0&&(c.style=exports.IFont.Style.Italic),o.querySelectorAll("u").length>0&&(c.underline=exports.IFont.UnderlineStyle.Single),Object.keys(c).length>0&&(l||(l={},a.style=l),l.font||(l.font=c));const h=o.querySelectorAll("a");if(h.length>0){const u=h[0].getAttribute("href");u&&(a.hyperlink=u)}}if(!k.isSingleCell(e)){const l={rowStart:this._topLeft.rowIndex+e.rowStart,colStart:this._topLeft.colIndex+e.colStart,rowEnd:this._topLeft.rowIndex+e.rowEnd,colEnd:this._topLeft.colIndex+e.colEnd};this._mergedReading.push(l)}if((a.value!==void 0||a.style||!(Object.keys(a).length<=1))&&(this._cellUpdater.pushAt(this._topLeft.rowIndex+e.rowStart,this._topLeft.colIndex+e.colStart,a),!k.isSingleCell(e)&&i.msoIgnore)){if(i.msoIgnore.includes("colspan")){const l={};i&&this.applyCSSStyle(l,i);const c=e.colEnd-e.colStart;for(let h=1;h<=c;h++)this._cellUpdater.pushAt(this._topLeft.rowIndex+e.rowStart,this._topLeft.colIndex+e.colStart+h,l);e={...e,colEnd:e.colStart}}i.msoIgnore.includes("rowspan")&&(e={...e,rowEnd:e.rowStart})}}onNoTable(e,t,n){this.onCell({rowStart:this._topLeft.rowIndex,colStart:this._topLeft.colIndex,rowEnd:this._topLeft.rowIndex,colEnd:this._topLeft.colIndex},e,null,t,n)}onRowStart(e,t,n,r){const o=n(r);if(o.msoHeightSource!=="userset")return;let i=r.getAttribute("height")??o.height,a=null;if(i&&(a=zr(i,this._styles.getNormal().getFont().getSize(),"px")),a===null)for(let l=0;l<r.cells.length;l++){const c=r.cells[l],h=c.getAttribute("height")??n(c).height;let u=zr(h,this._styles.getNormal().getFont().getSize(),"px");u!==null&&(a=Math.max(u,a??0))}a!==null&&this._rowsReading.push({address:{min:this._topLeft.rowIndex+e,max:this._topLeft.rowIndex+e+t-1},update:{size:a*exports.IFont.getDeviceScale()}})}onColumn(e,t,n,r){const o=n(r);if(o.msoWidthSource!=="userset")return;let i=r.getAttribute("width")??o.width,a=null;i&&(a=zr(i,this._styles.getNormal().getFont().getSize(),"px")),a!==null&&this._colsReading.push({address:{min:this._topLeft.colIndex+e,max:this._topLeft.colIndex+e+t-1},update:{size:a*exports.IFont.getDeviceScale()}})}onDone(){this._colsReading.length>0&&this._sheet.getColumnHeaders().updateHeaderPairs(this._colsReading),this._rowsReading.length>0&&this._sheet.getRowHeaders().updateHeaderPairs(this._rowsReading),this._sheet.doBatch(()=>{this._cellUpdater.apply()}),this._mergedReading.length>0&&this._sheet.getRanges(this._mergedReading).merge()}sheet(){return this._sheet}}let Md=!1;class cy{constructor(e,t){this._mapStylesByName=new Map,this._arrStyleNames=[],this._mapStylesByName=e,this._arrStyleNames=t}setNode(e){this._node=e}addStyle(e,t){t!=null&&(this._node?.styles||(this._node.styles=new Map),this._node.styles.set(e,t))}addAttribute(e,t){t!=null&&(this._node?.attributes||(this._node.attributes=new Map),this._node.attributes.set(e,t),e.toLowerCase()==="rowspan"&&parseInt(t)>1&&(this._node.rowspan=parseInt(t)),e.toLowerCase()==="colspan"&&parseInt(t)>1&&(this._node.colspan=parseInt(t)))}addSharedStyle(e,t){let n=this._mapStylesByName.get(e);n?n={...t}:(this._arrStyleNames.push(e),n=t),this._mapStylesByName.set(e,n)}setPlainText(e){this._node.plainText=e}setHTMLText(e){this._node.htmlText=e.replace(/(?:\r\n|\r|\n)/g,"<br>")}}const Td=s=>{const e={};if(!s)return e;s.endsWith(";")||(s+=";");const t=new RegExp(';(?=([^"]*"[^"]*")*[^"]*$)',"gsm");let n,r=0;for(;(n=t.exec(s))!==null;){try{let o=s.substring(r,n.index).trim();const i=new RegExp(':(?=([^"]*"[^"]*")*[^"]*$)',"gsm");let a,l,c;for(;(c=i.exec(o))!==null;)a=unescape(o.substring(0,c.index)).trim(),l=unescape(o.substring(c.index+1,o.length)).trim();l!==null&&l!=="null"&&(a&&(a=Qg(a)),e[a]=l)}catch(o){console.warn(o)}r=n.index+1}return e},ks=(s,e)=>{const t=[];if(!s)return t;const n=s.children;for(let r=0;r<n.length;r++){const o=n.item(r);if(o.nodeType===1){const i=o.tagName.toUpperCase();e.includes(i)&&t.push(o)}}return t},hy=(s,e,t)=>{try{let n=null,r=null;const o=l=>((c,h)=>{if(!c)return{};let u={},d=h.get(c.localName);d&&(u=Object.assign(u,d));const g=c.getAttribute("class");if(g){const f=h.get("."+g);f&&(u=Object.assign(u,f))}const m=c.getAttribute("style");if(m){const f=Td(m);f&&(u=Object.assign(u,f))}return c.getAttribute("align")&&!u.textAlign&&(u.textAlign=c.getAttribute("align")),u})(l,r);if(s)try{n=[];const l="P, H1, H2, H3, H4, H5, H6, PRE",c=s.querySelector("parsererror");if(c)return console.warn("error",c),!1;const h=s.querySelectorAll("html"),u=h[h.length-1];r=(p=>{const S=p.querySelectorAll("style"),C=new Map;if(S.length<=0)return C;for(let y=0;y<S.length;y++){const b=S[y].childNodes;for(let w=0;w<b.length;w++)if(b[w].nodeType===Node.TEXT_NODE){const E=new RegExp("<!--(.*)-->","gs");let x=b[w].textContent;const I=E.exec(b[w].textContent);if(I&&I.length>1&&(x=I[1]),x=x.replace(/^\s/,""),x?.startsWith("table")){const v=new RegExp("{(.*?)}","gs");let R,A=0;for(;(R=v.exec(x))!==null;)try{const M=x.substring(A,R.index),T=Td(R[1]);C.set(M.trim(),T),A=R.index+R[0].length}catch(M){console.warn(M)}return C}}}return C})(u);const d=u.querySelectorAll("body"),g=d[d.length-1];let f=g.querySelectorAll("table")[0],_=!1;if(!f){let p=g.querySelectorAll("span");f=p[0],_=p.length>1}if(f||(f=ks(g,l)[0]),f||(f=ks(s,l)[0]),f?.nodeName.toUpperCase()==="TABLE"){t.onStart?.(r);const p=f;t.onTableStart?.(o,p);const S=ks(p,"COLGROUP");for(let b=0;S&&b<S.length;b++){const w=ks(S[b],"COL");let E=0;for(let x=0;x<w.length;x++){const I=w[x],v=parseFloat(I.getAttribute("span")),R=isNaN(v)?1:v;t.onColumn?.(E,R,o,I),E+=R}}const C=p.rows;let y=0;for(let b=0;b<C.length;b++){const w=C[b],E=parseFloat(w.getAttribute("span")),x=isNaN(E)?1:E;t.onRowStart?.(y,x,o,w);const I=[];n.push(I);const v=w.cells;for(let R=0;R<v.length;R++){let A=v[R],M=!1;for(let T=0;!M&&T<A.childNodes.length;T++)if(A.childNodes[T].nodeType===8){const N=A.childNodes[T].textContent;if(N!=="[if gte vml 1]"){if(N!=="[if !vml]"){if(N==="[endif]"){const B=A.childNodes[T+1];B?.querySelectorAll&&B.querySelectorAll("table, td").length===2&&(A=B?.querySelectorAll("table, td")[1],M=!0)}}}}I.push({htmlValue:A.textContent?.replace(/^"|"$/gi,""),element:A})}y+=x,t.onRowDow?.(y,x,o,w)}t.onTableDone?.(o,p)}else{if(f?.nodeName.toUpperCase()==="SPAN"){const p=e?e[0]?.[0]:null,S=_&&p?p:f.textContent.replace(/^"|"$/gi,"");return t.onStart?.(r),t.onCell({colStart:0,colEnd:0,rowStart:0,rowEnd:0},e?e[0]?.[0]:null,S,o,f),t.onDone?.(),!0}if(f?.textContent){const p=f.textContent.replace(/^"|"$/gi,"");return t.onStart?.(r),t.onNoTable?.(p,o,f),t.onDone?.(),!0}}}catch(l){console.warn(l),n=null}!n||n.length!==0&&(n.length!==1||n[0]!==null&&n[0].length!==0)||(n=null);const i=e&&(e.length===0||e.length===1&&(e[0]===null||e[0].length===0));n&&i&&(e=null);const a=l=>{const c=new Set;let h=1,u=1;for(let d=0;d<Math.max(e?e.length:0,n?n.length:0);d++){let g=0,m=0,f=n&&n[d]?n[d].length:e[d]?e[d].length:0;for(;m<f;){const _=d+"-"+g;if(!c.has(_)){h=Math.max(h,g+1),u=Math.max(u,d+1);let p=null;const S=n?n[d]?.[m]?.element:void 0;if(S&&(S.getAttribute("rowspan")||S.getAttribute("colspan"))){const C=parseInt(S.getAttribute("colspan"))||1,y=parseInt(S.getAttribute("rowspan"))||1;h=Math.max(h,g+C),u=Math.max(u,d+y),p={rowStart:d,colStart:g,rowEnd:d+Math.max(0,y-1),colEnd:g+Math.max(0,C-1)};for(let b=d;b<d+y;b++)for(let w=g;w<g+C;w++)b===d&&w===g||c.add(b+"-"+w)}else p={rowStart:d,colStart:g,rowEnd:d,colEnd:g};l(p,e?e[d]?.[g]:void 0,n?n[d]?.[m]?.htmlValue:null,o,S||null),m++}g++}}};if(n&&e){let l=0,c=0;a(h=>{l=Math.max(l,h.colEnd+1),c=Math.max(c,h.rowEnd+1)}),e&&n&&(e.length!==c||e[0].length!==l)&&(console.warn("mismatched mimeTypes",e,n),e=null)}return a(t.onCell.bind(t)),t.onDone?.(),!i||n!==null}catch(n){throw console.warn(n),n}};exports.ISheet=void 0,(exports.ISheet||(exports.ISheet={})).Visibility={Visible:"visible",Hidden:"hidden",VeryHidden:"veryHidden"};class Li extends Xi{static{this.instanceCounter=0}constructor(e){if(super(e),!e.content)throw new Error("Content type is required");this._content=e.content,this._uuid=F.uuidV4(),this._optionsMovable=e;const t=this;this._optionsMovable.setContainerZIndexCallback?.(()=>{t._processZIndex()}),this._optionsMovable.setContainerSelectionCallback?.((r,o)=>{t._processContainerSelect(r,o)}),e.json&&this._fromJSON(e.json);const n=this._content.addListeners({onDelete:()=>{t._options.deleteFromContainer&&t._options.deleteFromContainer?.()}},{transactional:!0});this._updateState({contentListenerRemove:n},null,[])}getUUID(){return this._uuid}getContent(){return this._content}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._getEmitter().notify("onBoundsChange"),this._getEmitter().notify("onAnyChange")}_processZIndex(){this._getEmitter().notify("onAnyChange")}_processContainerSelect(e,t){this._getEmitter().notify("onSelectionChange")}isSelected(){return this._optionsMovable.isSelected?.()??!1}async scrollIntoView(e){return this._optionsMovable.scrollIntoView?.(e)??!1}async select(e){if(await this._optionsMovable.select?.(e)===!1)return!1;if(e?.autoFocus!==!1){const t=await this._getEmitter().notify("onRequestFocus",{async:!0});if(!t)return!1;for(let n=0;n<t.length;n++)if(t[n]===!1)return!1}return!0}unselect(){const e=this._optionsMovable.isSelected?.()??!1;return this._optionsMovable.unselect?.(),e}_clone(){const e=this.isSelected(),t=this.getZIndex(),n=this._optionsMovable.getMaxBounds,r=this._options.maxRangeCoords,o=this.getContent(),i={beginPersistResource:this._optionsMovable.beginPersistResource,getBoundsAtCoords:this._optionsMovable.getBoundsAtCoords,getCoordsAtBounds:this._optionsMovable.getCoordsAtBounds,isSelected:()=>e,getZIndex:()=>t,getMaxBounds:n,maxRangeCoords:r,transactions:new Lt({transient:!0}),json:this.toJSON(),initialAnchor:this.getAnchorCoords(),content:o},a=new Li(i),l=this._getState();return a._updateState({...l}),a}getSnapshot(e,t){const n=this._optionsMovable.getCoordsAtBounds(e),r=this._getState().offsets;let o=this.getAnchorCoords();if((r.br.x>0||r.br.y>0)&&(o={...o},o.colEnd-=r.br.x>0?1:0,o.rowEnd-=r.br.y>0?1:0),!k.isRangeWithinRange(o,n))return null;const i=this,a=i._clone(),l=Object.freeze({...t});let c=!1;return{async copyTo(u,d){const g={...l,...d};return await a._doCopy(u,g),g.isCut&&!c&&(i.delete(),c=!0),u.bounds},getCoords:()=>a.getBounds(),getSource:()=>a,getName:()=>a.getName(),getMarkOptions:()=>l,toText:()=>a._toText(),toHtml:()=>a._toHtml(),toImage:()=>a._toImage(),isISnapshot:!0}}async _doCopy(e,t){const n=this._optionsMovable.beginPersistResource(),r=this.toJSON(n.toResourceId.bind(n));r.content.json.name=`${this.getName()} (Copy)`;const o=r.content.json;delete r.content;const i=e.movables;if(!i)throw new Error("Movables is required");const a=e.bounds??this.getBounds();try{await i.add({...r,...t,fromResourceId:n.fromResourceId.bind(n),bounds:a,type:this.getContent().getType(),json:o,description:"Copy Movable"})}finally{n.endPersist()}}_toText(){return this.getContent().toText?.()}_toHtml(){return this.getContent().toHtml?.()}_toImage(){return this.getContent().toImage?.()}setName(e){return this._updateState({name:e},{description:"Set Movable Name"},["onNameChange"]),this}getName(){return this.isClosed()?null:this._getState()?.name}setDescription(e){return this._updateState({description:e},{description:"Set Movable Description"}),this}getDescription(){return this.isClosed()?null:this._getState()?.description}setHidden(e=!1){return this._updateState({hidden:e},{description:"Set Movable Visibility"}),this}isHidden(){return this._getState()?.hidden??!1}setLockAspectRatio(e){return this._updateState({lockAspectRatio:e},{description:"Set Lock Aspect Ratio"}),this}isLockAspectRatio(){return this._getState()?.lockAspectRatio??this._optionsMovable.defaultLockAspectRatio??!1}setRotation(e=0){return this._updateState({rotation:e},{description:"Set Movable Rotation"}),this}getRotation(){return this._getState()?.rotation??0}moveToBack(){return this._optionsMovable.moveToBackOnContainer?.(),this}moveBackward(){return this._optionsMovable.moveBackwardOnContainer?.(),this}moveToFront(){return this._optionsMovable.moveToFrontOnContainer?.(),this}moveForward(){return this._optionsMovable.moveForwardOnContainer?.(),this}getZIndex(){return this._optionsMovable.getZIndex?.()??0}setBounds(e,t){if(!e)return this;let n={...this.getBounds(),...e};if(this._optionsMovable.getMaxBounds&&(n={x:Math.max(n.x,this._optionsMovable.getMaxBounds().x),y:Math.max(n.y,this._optionsMovable.getMaxBounds().y),width:Math.min(n.width,this._optionsMovable.getMaxBounds().width),height:Math.min(n.height,this._optionsMovable.getMaxBounds().height)}),n.width<0||n.height<0)throw new ke;const r=this._updateMovableLocation({bounds:n,anchorType:exports.IAnchored.Type.Absolute}),o=this._beginCommit(t?.description??"Set Movable Bounds");return this._updateState({offsets:r.offsets,anchor:r.anchor},{description:"Update Movable Bounds"}),this._options.setContainerCoords(r.anchor),this._invalidateBounds(),o.commit(),this}_updateMovableLocation(e){let t=e.offsets??{tl:{x:0,y:0},br:{x:0,y:0}},n=e.anchor??this.getAnchorCoords(),r=e.anchorType??this.getAnchorType();const o=e.bounds??this.getBounds();if(o){if(r===exports.IAnchored.Type.Absolute){n=this._optionsMovable.getCoordsAtBounds(o);const i=this._optionsMovable.getBoundsAtCoords(n);t={...t,tl:{x:o.x-i.x,y:o.y-i.y}}}if(r===exports.IAnchored.Type.Absolute||r===exports.IAnchored.Type.OneCell){const i=this._optionsMovable.getBoundsAtCoords({rowStart:n.rowStart,colStart:n.colStart,colEnd:n.colStart,rowEnd:n.rowStart}),a=this._optionsMovable.getCoordsAtBounds({x:i.x,y:i.y,width:o.width+Math.min(i.width,t.tl.x),height:o.height+Math.min(i.height,t.tl.y)});n={...n,colEnd:a.colEnd,rowEnd:a.rowEnd};const l=this._optionsMovable.getBoundsAtCoords({colStart:n.colEnd,rowStart:n.rowEnd,colEnd:n.colEnd,rowEnd:n.rowEnd}),c=o.width-(l.x-i.x-Math.min(t?.tl.x??0,i.width)),h=o.height-(l.y-i.y-Math.min(t?.tl.y??0,i.height));t={...t,br:{x:c,y:h}}}return t!==e.offsets&&(t.br.y<=0&&(t.br={...t.br,y:0},n.rowEnd--),t.br.x<=0&&(t.br={...t.br,x:0},n.colEnd--)),{anchor:n,offsets:t}}}_calcAbsoluteBounds(e,t={tl:{x:0,y:0},br:{x:0,y:0}}){if(!e)return null;const n=this._optionsMovable.getBoundsAtCoords({rowStart:e.rowStart,colStart:e.colStart,colEnd:e.colStart,rowEnd:e.rowStart});let r=t.br.x?0:1,o=t.br.y?0:1;const i=this._optionsMovable.getBoundsAtCoords({colStart:e.colEnd+r,rowStart:e.rowEnd+o,colEnd:e.colEnd+r,rowEnd:e.rowEnd+o}),a=Math.min(n.x+(t?.tl.x??0),n.x+n.width),l=Math.min(n.y+(t?.tl.y??0),n.y+n.height);return{x:a,y:l,width:Math.min(i.x+(t?.br.x??0),i.x+i.width)-a,height:Math.min(i.y+(t?.br.y??0),i.y+i.height)-l}}getBounds(){return this._getState()?.bounds}setAnchorType(e){return F.validEnumValue(exports.IAnchored.Type,e),this._updateState({anchorType:e},{description:"Set Movable Resize Behavior"},["onAnchorTypeChange"]),this}_processContainerShift(e){const t=this.getAnchorType(),n=this._getState()?.offsets;let r=n,o=!1;const i=e.before,a=e.orientation===exports.w.Orientation.Column,l=e.intersect,c=e.amount;let h=e.after;if(t!==exports.IAnchored.Type.Absolute){let g=a?l.colStart:l.rowStart,m=a?i.colStart:i.rowStart;t===exports.IAnchored.Type.TwoCell&&(m=a?i.colEnd:i.rowEnd),o=g<=m}if(o&&(t!==exports.IAnchored.Type.OneCell||h)||(h=i),o&&h&&c<0&&(a?(l.colStart<=i.colStart&&l.colEnd>=i.colStart&&(r={...r,tl:{...r.tl,x:0}}),r.br.x>0&&l.colStart<=i.colEnd&&l.colEnd>=i.colEnd&&(r={...r,br:{...r.br,x:0}},h={...h,colEnd:h.colEnd+1})):(l.rowStart<=i.rowStart&&l.rowEnd>=i.rowStart&&(r={...r,tl:{...r.tl,y:0}}),r.br.y>0&&l.rowStart<=i.rowEnd&&l.rowEnd>=i.rowEnd&&(r={...r,br:{...r.br,y:0}},h={...h,rowEnd:h.rowEnd+1}))),h!==null){const{offsets:g,anchor:m}=this._updateMovableLocation({anchor:h,offsets:r});r=g,h=m}let u=null;const d=this._beginCommit("Shifting Movable Bounds");try{if(n!==r||!k.isEqualRanges(i,h)){const g={offsets:r,anchor:h};this._updateState(g)}this._invalidateBounds(),u=super._processContainerShift({...e,after:h}),d.commit()}catch(g){throw d.rollback(),g}return u}_invalidateBounds(){const e=this.getAnchorCoords();if(e===null)return null;const t=this._getState()?.offsets,n=this._calcAbsoluteBounds(e,t);this._updateState({bounds:n},null,["onBoundsChange"])}_processContainerDelete(){super._processContainerDelete(),this._getState().contentListenerRemove?.(),this.getContent().delete()}_processContainerLayout(){const e=this.getAnchorCoords(),t=this._getState()?.offsets,{offsets:n,anchor:r}=this._updateMovableLocation({anchor:e,offsets:t}),o=this._beginCommit("Updating Movable Bounds");try{if(t!==n||e!==r){const i={offsets:n,anchor:r};this._updateState(i)}this._invalidateBounds(),super._processContainerLayout(),o.commit()}catch(i){throw o.rollback(),i}}_processAnchorCoords(){super._processAnchorCoords()}_fromJSON(e){const t={tl:{x:0,y:0},br:{x:0,y:0}},n={...k.EmptyRange};e.anchor&&(t.tl.x=e.anchor.tl?.x??0,t.tl.y=e.anchor.tl?.y??0,t.br.x=e.anchor.br?.x??0,t.br.y=e.anchor.br?.y??0,n.colStart=e.anchor.tl?.c??0,n.rowStart=e.anchor.tl?.r??0,n.colEnd=Math.max(n.colStart,(e.anchor.br?.c??0)+(t.br.x>0?0:-1)),n.rowEnd=Math.max(n.rowStart,(e.anchor.br?.r??0)+(t.br.y>0?0:-1)));const r=this._beginCommit("Load Movable"),o=e.content.json,i={offsets:t,name:o.name??null,description:o.name??null,hidden:o.hidden??!1,rotation:o.rotation??0,lockAspectRatio:o.lockAspect??null};e.anchorType&&(i.anchorType=e.anchorType),i.name||(i.name=`${this._content.getTypeDescription()} ${++Li.instanceCounter}`),i.bounds=this._calcAbsoluteBounds(n,t),this._updateState(i,{description:"Load Movable"}),this._optionsMovable.setContainerCoords?.(n),r.commit()}toJSON(e){const t=this._getState(),n=t.anchor,r=t.offsets,o={tl:{c:n.colStart,r:n.rowStart},br:{c:n.colEnd+(r.br.x?0:1),r:n.rowEnd+(r.br.y?0:1)}};r&&(r.tl?.x&&(o.tl.x=F.roundAccurately(r.tl.x,1)),r.tl?.y&&(o.tl.y=F.roundAccurately(r.tl.y,1)),r.br?.x&&(o.br.x=F.roundAccurately(r.br.x,1)),r.br?.y&&(o.br.y=F.roundAccurately(r.br.y,1)));const i=this._content.toJSON(e)??{},a={anchor:o,content:{type:this._content.getType(),json:i}},l=t.anchorType;return l&&l!==exports.IAnchored.Type.TwoCell&&(a.anchorType=this.getAnchorType()),t.hidden&&(a.hidden=t.hidden),t.name&&(a.name=t.name),t.description&&(a.name=t.description),t.rotation!==void 0&&t.rotation!==0&&(a.rotation=t.rotation),F.isDefined(t.lockAspectRatio)&&t.lockAspectRatio!==this._optionsMovable.defaultLockAspectRatio&&(a.lockAspect=t.lockAspectRatio),a}get isIMovable(){return!0}}class uy{constructor(e,t,n,r,o,i){this._add=e,this._search=t,this._getCount=n,this._updateSelected=r,this._addListeners=o,this._addImage=i}async add(e){return this._add(e)}search(e){return this._search(e)}getCount(){return this._getCount()}updateSelected(e,t){return this._updateSelected(e,t)}addListeners(e,t){return this._addListeners(e,t)}addImage(e,t){return this._addImage(e,t)}}const al={transactional:!0,ignoreDataChanges:!0};class Fd extends ym{constructor(e){super({...e,type:"namedReference"});const t=this;this._listener=r=>{const o=this._getState().ranges;let i=r.getSource(),a=!1;const l={ranges:i};if(r.trigger==="moveCells"){const u=t._getState(),d=r.getTo(),g=r.getFrom(),m=[];for(let p=0;p<o.getCount();p++){const S=o.at(p);if(m.push(S.getCoords()),!S.isInvalid()){for(let C=0;C<g.getCount();C++){const y=g.at(C).getCoords(),b=S.getCoords();if(!k.isRangeWithinRange(b,y))continue;const w=d.getCoords(),E=w.colStart-y.colStart+b.colStart,x=w.rowStart-y.rowStart+b.rowStart,I={...b,colStart:E,rowStart:x,colEnd:E+(b.colEnd-b.colStart),rowEnd:x+(b.rowEnd-b.rowStart)};(d.size!==1||k.isRangeWithinRange(I,w))&&(m[p]=d.getSource().getRange(I).getCoords(),a=!0)}if(!a)return}}const f=this._options.addressToRanges(m);let _;u.removeListener?.(),f.isInvalid()||(_=f.addListener(t._listener,al)),l.ranges=f,l.removeListener=_}this._updateState(l,null,["onRangesChange"]);const c=i.getCoords();let h=!c||c.length===0;for(let u=0;!h&&u<c.length;u++)if(!c[u]){h=!0;break}h&&t.delete()};const n=e.value;if(n&&!n.isInvalid()){const r=n.addListener(this._listener,al);this._updateState({ranges:n,removeListener:r},null)}}setReference(e){const t=this._options.addressToRanges(e);if(t&&!t.isInvalid()){this._getState().removeListener?.();const r=t.addListener(this._listener,al);this._updateState({ranges:t,removeListener:r},null)}return null}async select(e){return await this._getState().ranges.select(e),this}getRanges(){return this._getState().ranges}setHidden(e=!1,t){return this._updateState({hidden:e},{description:"Set Hidden",...t},[]),this}setScope(e,t){return this._updateState({scope:e},{description:"Set Scope",...t},[]),this}getType(){return"reference"}getValue(){return this._getState().ranges}toJSON(){const e=super._toJSON();return e.ref=this._getState().ranges.toString(),e}_getDescription(){return`Named '${this.getName()}'`}_processDelete(){const e=this._getState();e&&e.removeListener?.(),super._processDelete()}}const Nd="Item must be specified.",kd="Name must be a non-empty string",Od=(s,e=null)=>`Named item '${s}' already exists${e?`in scope ${e}`:""}.`,Bd=s=>{const e=[];for(let t=0;t<s.getCount();t++){let n=null;try{n=s.at(t),n.isICellRange&&(n=n.getFixed(!0))}catch(r){console.warn("Invalid range",r)}e.push(n?n.toString().toLowerCase():Ye)}return e.sort(),e.join(",")},dy=/^[^a-zA-Z_\\]+$/,gy=/^[^a-zA-Z0-9_.]+$/;class gf{constructor(e){this._emitter=null,this._closed=!1,this._lastLookup=F.EmptyArray,this._lastLookupAddress=null,this._lastLookupScope=null,this._lastLookupType=null,this._allowExtrudes=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Lt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){r?.initial||t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._initState(),this._fromJSON(this._options?.json)}search(e){if(this.isClosed())return F.EmptyArray;const t=this._getState();if(!t)return F.EmptyArray;const n=t.itemsSpatial;if(n.isEmpty())return F.EmptyArray;if(e&&e.address===this._lastLookupAddress&&e.scope===this._lastLookupScope&&e.type===this._lastLookupType&&e.allowExtrudes===this._allowExtrudes)return this._lastLookup;this._lastLookupAddress=e?.address??void 0,this._lastLookupScope=e?.scope??void 0,this._lastLookupType=e?.type??void 0,this._allowExtrudes=e?.allowExtrudes??void 0;let r=null;if(e?.address){const h=this._options.addressToRanges(e?.address);if(!h)return console.warn("invalid address",e?.address),this._lastLookup=null,null;r=h.getCoords()}let o=null;if(r){o=[];for(let h=0;h<r.length;h++){const u=n.search(r[h]);for(let d=0;d<u.length;d++)o.push(u[d])}}else o=n.all();if(!o||o.length===0)return this._lastLookup=F.EmptyArray,F.EmptyArray;const i=new Set,a=new Set;o.forEach(h=>{const u=h.value;if(!e?.type||u.getType()===e.type){if(r&&!e?.allowExtrudes){const d=u.getRanges?.();if(!d||d.getCount()===0)return;for(let g=0;g<r.length;g++)if(!k.isRangeWithinRange(h,r[g]))return}!e?.scope||u.getScope()!==e.scope&&e.scope!=="all"?u.getScope()||a.add(u):i.add(u)}});const l=new Map;a.forEach(h=>{l.set(h.getName(),h)}),i.forEach(h=>{l.set(h.getName(),h)});let c=[];return l.forEach(h=>{c.push(h)}),c=c.sort((h,u)=>{let d=h.getType().localeCompare(u.getType());return d!==0?d:h.getName().localeCompare(u.getName())}),this._lastLookup=c,c}lookupByRanges(e){const t=this._options.addressToRanges(e);if(!t||t.getCount()===0)return null;const n=this._getState();if(!n||n.itemsByKey.size===0)return null;const r=Bd(t),o=n.itemsByFullRange.get(r);if(!o)return null;const i=[];return o.forEach(a=>{const l=n.itemsByKey.get(a);l&&i.push(l.item)}),i.length>0?i:null}getByName(e,t=!1){if(!e)return null;const n=this._getState();if(!n||n.itemsByKey.size===0||typeof e!="string")return null;const r=e.toLowerCase(),o=this._options.getCurrentScope();if(!t&&o){const a=r+":"+o.toLowerCase(),l=n.itemsByKey.get(a);if(l)return l.item}return n.itemsByKey.get(r)?.item??null}getCount(){const e=this._getState();return e?e.itemsByKey.size:0}getRanges(e){const t=this._options.addressToRanges(e),n=[];for(let r=0;r<t.getCount();r++){const o=t.at(r).getFixed(!0).getCoords();n.push(o)}return this._options.addressToRanges(n)}findValidName(e,t=null,n=!1){if(!e)throw new Error("A template string must be specified.");const r=this,o=i=>{try{return r._validateName(i,t,n),!0}catch{}return!1};return o(e)?e:Yg(e,o)}validateName(e,t=null,n=!1){return this._validateName(e,t,n)}_validateName(e,t,n=!1){if(this._closed)throw new Error(Nt);if(!e||e.length===0)throw new Error(kd);if(e.length>255)throw new Error("Name must not exceed 255 characters.");if(e.indexOf(" ")!==-1)throw new Error("Name must not contain any spaces.");const r=e.trim().toLowerCase(),o=r.substring(1,e.length-1);if(new RegExp(dy).test(r[0]))throw new Error("First letter must be either a letter, an underscore, or a backslash.");if(new RegExp(gy).test(o))throw new Error("Name must be either letters, numbers, periods or underscores.");if(r.length===1&&(r[0]==="r"||r[0]==="c"))throw new Error("Name can not be 'r' or 'c'.");if(((l,c=G_,h=km,u=!1)=>{let d=Pm(l,u);if(!d||d[2]||!d[1])return!1;const g=Wl(l,Hl);if(!g)return!1;const m=g.rowIndex;if(m<0||m>c)return!1;const f=g.colIndex;return!(f<0||f>=h)})(e))throw new Error("Name can not be an address.");let i=e.toLowerCase()?.trim();t&&(i=i+":"+t.toLowerCase());const a=this._getState()?.itemsByKey.get(i);if(a){const l=a.item.getRanges();if(!n||l||l.getCount()>0)throw new Error(Od(e,t))}}addReference(e,t,n=!1){const r=this._options.addressToRanges(t),o=this.getByName(e);let i=null;const a=this._beginCommit(`${o&&n?"Update":"Insert"} Named '${e}'`);try{if(o){if(!n)throw new Error(Od(e));this._delete(o,{description:`Delete Named '${o.getName()}'`})}i=new Fd({value:r,addressToRanges:this._options.addressToRanges,json:{name:e,ref:r.toString()},transactions:this._transactions}),this.add(i),a.commit()}catch(l){throw a.rollback(),l}return i}add(e){if(this._closed)throw new Error(Nt);if(!e)throw new Error(Nd);if(!e.getName||typeof e=="string")throw new Error("Add must take a 'INamed' object. To add a string use 'addReference'.");if(this._validateName(e.getName(),e.getScope(),!1),this._options.isReadOnly?.())throw new Error("Names are read-only.");const t=this._beginCommit(`Insert Named Item '${e.getName()}'`),n=this._add([e]);if(n===null)return t.rollback(),null;const r=n.itemsByKey.get(e.getName().toLowerCase());return this._updateState(o=>({...o,...n})),t.commit(),r?.item??null}_toKey(e){let t=e.getName().toLowerCase();return t.startsWith("_xlnm.")&&(t=t.substring(6)),e.getScope()?t+":"+e.getScope().toLowerCase():t}_delete(e,t){if(!e)throw new Error(Nd);if(this._closed)throw new Error(Nt);const n=this._beginCommit(t?.description??`Delete Named Item '${e.getName()}'`);let r=null;try{const o=this._getState()?.itemsByKey,i=this._toKey(e);if(r=o.get(i),!r)throw new Error(`Item '${e.getName()}' does not exist.`);const a=this._cloneState();this._index(i,null,a),this._updateState(l=>({...l,...a})),n.commit()}catch(o){throw n.rollback(),o}return this._emitter.notify("onCollectionChange"),r.item}_cloneState(){const e=this._getState();return{itemsBySource:new Map(e.itemsBySource),itemsByKey:new Map(e.itemsByKey),itemsSpatial:e.itemsSpatial.clone(),itemsByFullRange:new Map(e.itemsByFullRange),itemsByPartialRange:new Map(e.itemsByPartialRange)}}_index(e,t,n){const r=n.itemsByKey.get(e);if(r){const i=r.asPartialRanges;if(i)for(let l=0;l<i.length;l++){const c=n.itemsByPartialRange.get(i[l]);if(c)if(c.size===1)n.itemsByPartialRange.delete(i[l]);else{const h=new Set(c);h.delete(e),n.itemsByPartialRange.set(i[l],h)}}const a=r.asFullRange;if(a){const l=n.itemsByFullRange.get(a);if(l)if(l.size===1)n.itemsByFullRange.delete(a);else{const c=new Set(l);c.delete(e),n.itemsByFullRange.set(a,c)}}if(r.nodes)for(let l=0;l<r.nodes.length;l++)n.itemsSpatial.remove(r.nodes[l]);r.unwatch?.(),n.itemsByKey.delete(e),n.itemsBySource.delete(r.item)}let o=null;if(t){let i=[],a=null,l=null;o=t.getRanges?.();const c=this._toKey(t);if(o){const{asFullRange:g,asPartialRanges:m,asRanges:f}=(_=>{const p=_.getCoords(),S=Bd(_),C=S.split(",");return{asFullRange:S,asPartialRanges:C,asRanges:p}})(o);if(a=g,l=m,f){for(let _=0;_<m.length;_++){let p=n.itemsByPartialRange.get(m[_]);const S=p?new Set(p):new Set;S.add(c),n.itemsByPartialRange.set(m[_],S),i.push({...f[_],value:t})}if(n.itemsSpatial.load(i),g){let _=n.itemsByFullRange.get(g);const p=_?new Set(_):new Set;p.add(c),n.itemsByFullRange.set(g,p)}}}const h=this,u=t.addListeners({onDelete:g=>{h._delete(g)},onAnyChange:g=>{const m=h._beginCommit(`Update Named '${g.getName()}'`);try{const f=h._cloneState(),_=f.itemsBySource.get(g).globalKey;h._index(_,g,f),h._updateState(p=>({...p,...f})),m.commit()}catch(f){throw m.rollback(),f}}},{transactional:!0}),d={item:t,asFullRange:a,asPartialRanges:l,unwatch:u,nodes:i,globalKey:c};n.itemsByKey.set(c,d),n.itemsBySource.set(t,d)}}_add(e){if(this._closed)throw new Error(Nt);const t=this._getState();if(!e)return t;const n=this._cloneState();for(let r=0;r<e.length;r++){const o=e[r];if(!o.getName())throw new Error(kd);const i=this._toKey(o);try{this._index(i,o,n)}catch(a){console.warn(`Unable to add named item '${i}'.`,a)}}return n}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Nt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update"){if(!e)return;this._lastLookup=F.EmptyArray,this._lastLookupAddress=null,this._lastLookupType=null,this._lastLookupScope=null;const n=this._beginCommit(t);try{n.updateState(this,e),n.commit()}catch(r){throw n.rollback(),r}}fromJSON(e){if(this._closed)throw new Error(Nt);this._fromJSON(e)}_initState(){this._updateState(e=>({...e,items:new Set,itemsByKey:new Map,itemsSpatial:new Ie,itemsByFullRange:new Map,itemsByPartialRange:new Map}))}_fromJSON(e){const t=this._beginCommit("Load Names");try{if(e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];try{const a=this._options.addressToRanges(i.ref),l=new Fd({value:a,addressToRanges:this._options.addressToRanges,deleteFromContainer:c=>{this._delete(l,c)},json:i,transactions:this._transactions});n.push(l)}catch(a){console.warn("Unable to load named item.",i,a.message)}}const r=this._add(n);this._updateState(o=>({...o,...r}))}t.commit({viewAfter:{initial:!0}})}catch(n){throw t.rollback(),n}}toJSON(){const e=this._getState();if(!e||e.itemsByKey.size===0)return null;const t=[],n=Array.from(e.itemsByKey.keys()).sort();for(let r=0;r<n.length;r++){const o=e.itemsByKey.get(n[r]).item,i=o.toJSON?.();i&&t.push(i)}return t.length===0?null:t}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isNamedCollection(){return!0}}class my extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"chart"}getDescription(){return`Chart: ${this._getState()?.data?.types?.[0]?.type??"unknown"}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"Chart"}}class fy extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"shape"}getDescription(){return`Shape: ${this._getState()?.data}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"Shape"}}class py extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"custom"}getDescription(){return`CustomElement: ${this._getState()?.data}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"CustomElement"}}const Dd=(s,e,t=!0,n=!0)=>{let r=0,o=0;if(!t&&!n)return{x:r,y:o};let i=!1,a=0;do{const l={x:e.x+r,y:e.y+o,width:0,height:0},c=s.search({bounds:l});if(i=!1,c.length>0){for(let h=0;!i&&h<c.length;h++){const u=c[h].getBounds();u.x===l.x&&u.y===l.y&&(i=!0)}i&&(r+=t?16:0,o+=n?16:0)}}while(i&&++a<100);return{x:r,y:o}};class _y{constructor(e,t,n){this._add=e,this._get=t,this._getByName=n}add(e,t){if(!e)throw new Error(ql);return this._add(e,t)}search(e){if(e&&e.name&&Object.keys(e).length===0)return[this._getByName(e.name)];let t;e?.address&&(t=e.address);const n=this._get(t,e?.excludeHidden,e?.fullyContained);if(e?.name){const r=e.name.toLocaleLowerCase();for(let o=0;o<n.length;o++)if(n[o].getName().toLocaleLowerCase()===r)return[n[o]]}return n}getByName(e){if(typeof e!="string")throw new Error("Get by name must take a valid name.");return this._getByName(e)}getCount(){return this._get(null,!1,!1).length}}const ht=(s,e,t)=>{if(!s)return e;let n=e;const r=t===exports.w.Direction.Right||t===exports.w.Direction.Down;for(;;){const o=s(n,!r);if(o===0)return n;r?n+=o:n-=o}},Sy=Object.freeze({colIndex:0,rowIndex:0}),Kl=Object.freeze([]),ll=Object.freeze({cell:k.EmptyCell,ranges:Kl,rangeIndex:-1}),mf=(s,e=exports.w.Direction.Right,t,n,r,o=null)=>{if(o&&k.isEqualSelectionCoords(o,s))return s;const i=s.ranges[s.rangeIndex];if(!k.isRangesIntersect({rowStart:s.cell.rowIndex,colStart:s.cell.colIndex,rowEnd:s.cell.rowIndex,colEnd:s.cell.colIndex},i))return s;let a={...s.cell},l=s.rangeIndex;switch(e){case exports.w.Direction.Right:a.colIndex=ht(r,a.colIndex+1,e);break;case exports.w.Direction.Left:a.colIndex=ht(r,a.colIndex-1,e);break;case exports.w.Direction.Down:a.rowIndex=ht(n,a.rowIndex+1,e);break;case exports.w.Direction.Up:a.rowIndex=ht(n,a.rowIndex-1,e)}const c=d=>{if(d){l=s.rangeIndex>=s.ranges.length-1?0:s.rangeIndex+1;const g=s.ranges[l];a={colIndex:g.colStart,rowIndex:g.rowStart}}else{l=s.rangeIndex<=0?s.ranges.length-1:s.rangeIndex-1;const g=s.ranges[l];a={colIndex:g.colEnd,rowIndex:g.rowEnd}}};if(e===exports.w.Direction.Right&&a.colIndex>i.colEnd&&a.rowIndex===i.rowEnd)c(!0);else if(e===exports.w.Direction.Left&&a.colIndex<i.colStart&&a.rowIndex===i.rowStart)c(!1);else if(e===exports.w.Direction.Down&&a.colIndex===i.colEnd&&a.rowIndex>i.rowEnd)c(!0);else if(e===exports.w.Direction.Up&&a.colIndex===i.colStart&&a.rowIndex<i.rowStart)c(!1);else{let d=a.rowIndex,g=a.colIndex;switch(e){case exports.w.Direction.Right:g>i.colEnd&&(d=ht(n,d+1,e),g=i.colStart,d>i.rowEnd&&(d=i.rowStart));break;case exports.w.Direction.Left:g<i.colStart&&(d=ht(n,d-1,e),g=i.colEnd,d<i.rowStart&&(d=i.rowEnd));break;case exports.w.Direction.Down:d>i.rowEnd&&(g=ht(r,g+1,e),d=i.rowStart,g>i.colEnd&&(g=i.colStart));break;case exports.w.Direction.Up:d<i.rowStart&&(g=ht(r,g-1,e),d=i.rowEnd,g<i.colStart&&(g=i.colEnd))}a={rowIndex:d,colIndex:g}}let h=t(a);if(!k.isRangeWithinRange(h,i)){const d=k.intersectRanges(h,i);d&&(h=d)}let u={rowStart:ht(n,h.rowStart,exports.w.Direction.Down),colStart:ht(r,h.colStart,exports.w.Direction.Right),rowEnd:ht(n,h.rowEnd,exports.w.Direction.Up),colEnd:ht(r,h.colEnd,exports.w.Direction.Left)};if(u.rowStart!==a.rowIndex||u.colStart!==a.colIndex){switch(e){case exports.w.Direction.Right:s.ranges[l].colStart===u.colStart&&s.ranges[l].colEnd===u.colEnd&&(a.rowIndex=u.rowEnd),a.colIndex=u.colEnd;break;case exports.w.Direction.Left:s.ranges[l].colStart===u.colStart&&s.ranges[l].colEnd===u.colEnd&&(a.rowIndex=u.rowStart),a.rowIndex===u.rowStart?a.colIndex=u.colStart+1:a.colIndex=u.colStart;break;case exports.w.Direction.Down:s.ranges[l].rowStart===u.rowStart&&s.ranges[l].rowEnd===u.rowEnd&&(a.colIndex=u.colEnd),a.rowIndex=u.rowEnd;break;case exports.w.Direction.Up:s.ranges[l].rowStart===u.rowStart&&s.ranges[l].rowEnd===u.rowEnd&&(a.colIndex=u.colStart),a.colIndex===u.colStart?a.rowIndex=u.rowStart+1:a.rowIndex=u.rowStart}return o&&console.warn("call recursive > 1"),mf({cell:a,ranges:s.ranges,rangeIndex:l},e,t,n,r,o??s)}return{ranges:s.ranges,cell:a,rangeIndex:l}};class wy{constructor(e){this._adjusting=null,this._emitter=null,this._coords=ll,this._sheet=e.sheet,this._emitter=new st(this);const t=e.sheet;this._adjusting=null,this._hiddenRowsAt=(n,r)=>t.getRowHeaders().hiddenHeadersAt(n,r),this._hiddenColumnsAt=(n,r)=>t.getColumnHeaders().hiddenHeadersAt(n,r),this._getCellCoordsAsRangeCoords=n=>{const r=k.cellToRange(n);if(t.isClosed())return r;const o=t.getRange(r,{excludeHidden:!0}).getMerges();return o.length===0?r:o[0]},this._canSelectionSpanMergedCells=n=>{const r=t.getRange(n);return r.isEntireColumns()||r.isEntireRows()},this._getMergedRanges=n=>t.getRange(n,{excludeHidden:!0}).getMerges(),this._isContentfulCell=()=>!1,this._contentfulCellFinder=(n,r,o,i,a,l)=>{const c=t.getSelectedRange().getExtended(i,n).getCoords();switch(i){case exports.w.Direction.Up:return c.rowStart;case exports.w.Direction.Down:return c.rowEnd;case exports.w.Direction.Left:return c.colStart;case exports.w.Direction.Right:return c.colEnd}},this._scrollCellCoordsIntoView=(n,r)=>t.scrollTo(n,r?{scroll:r}:void 0),this._selectionPolicy=e.selectionPolicy??"multiple",this._newSelectionMode=e.newSelectionMode??"clear"}navigate(e,t=!1,n=!1,r=0){const o=this._coords;if(!o.cell)return this;let i=o.cell,a=o.cell;if(t&&o.ranges.length>0){const S=o.ranges[o.rangeIndex],C=o.cell;switch(e){case exports.w.Direction.Up:a={rowIndex:C.rowIndex===S.rowStart?S.rowEnd:S.rowStart,colIndex:S.colEnd},i={rowIndex:C.rowIndex===S.rowStart?S.rowStart:S.rowEnd,colIndex:S.colStart};break;case exports.w.Direction.Down:a={rowIndex:C.rowIndex===S.rowEnd?S.rowStart:S.rowEnd,colIndex:S.colEnd},i={rowIndex:C.rowIndex===S.rowEnd?S.rowEnd:S.rowStart,colIndex:S.colStart};break;case exports.w.Direction.Left:a={rowIndex:S.rowEnd,colIndex:C.colIndex===S.colStart?S.colEnd:S.colStart},i={rowIndex:S.rowStart,colIndex:C.colIndex===S.colStart?S.colStart:S.colEnd};break;case exports.w.Direction.Right:a={rowIndex:S.rowEnd,colIndex:C.colIndex===S.colEnd?S.colStart:S.colEnd},i={rowIndex:S.rowStart,colIndex:C.colIndex===S.colEnd?S.colEnd:S.colStart}}}const l=this._getCellCoordsAsRangeCoords(a);let{rowStart:c,colStart:h}=l;const u=this._magicCell;if(u)switch(e){case exports.w.Direction.Up:case exports.w.Direction.Down:u.colIndex>=l.colStart&&u.colIndex<=l.colEnd&&(h=u.colIndex);break;case exports.w.Direction.Left:case exports.w.Direction.Right:u.rowIndex>=l.rowStart&&u.rowIndex<=l.rowEnd&&(c=u.rowIndex)}if(!r){const S=this._getMaxRange();switch(e){case exports.w.Direction.Up:c=ht(this._hiddenRowsAt,Math.max(l.rowStart-1,S.rowStart??0),e);break;case exports.w.Direction.Down:c=ht(this._hiddenRowsAt,Math.min(l.rowEnd+1,S.rowEnd??Number.MAX_SAFE_INTEGER),e);break;case exports.w.Direction.Left:h=ht(this._hiddenColumnsAt,Math.max(l.colStart-1,S.colStart??0),e);break;case exports.w.Direction.Right:h=ht(this._hiddenColumnsAt,Math.min(l.colEnd+1,S.colEnd??Number.MAX_SAFE_INTEGER),e)}if(n){const C=this._getMaxRange();let y=0;switch(e){case exports.w.Direction.Up:y=C.rowStart??0,c=this._contentfulCellFinder({...a,colIndex:this._coords.cell.colIndex},this._isContentfulCell,this._hiddenRowsAt,e,!1,Math.max(y,this._hiddenRowsAt(y,!1)));break;case exports.w.Direction.Down:y=C.rowEnd??Number.MAX_SAFE_INTEGER,c=this._contentfulCellFinder({...a,colIndex:this._coords.cell.colIndex},this._isContentfulCell,this._hiddenRowsAt,e,!1,Math.min(y,y-this._hiddenRowsAt(y,!0)));break;case exports.w.Direction.Left:y=C.colStart??0,h=this._contentfulCellFinder({...a,rowIndex:this._coords.cell.rowIndex},this._isContentfulCell,this._hiddenColumnsAt,e,!1,Math.max(y,this._hiddenColumnsAt(y,!1)));break;case exports.w.Direction.Right:y=C.colEnd??Number.MAX_SAFE_INTEGER,h=this._contentfulCellFinder({...a,rowIndex:this._coords.cell.rowIndex},this._isContentfulCell,this._hiddenColumnsAt,e,!1,Math.min(y,y-this._hiddenColumnsAt(y,!0)))}}}let d=null;r&&(d={});const g={rowIndex:c,colIndex:h},m=this._getCellCoordsAsRangeCoords(g),f={rowIndex:m.rowStart,colIndex:m.colStart};t||(this._magicCell=g);const _=this._firstActiveCoords,p=k.isEqualCells(_,f)&&k.isEqualCells(_,i);if(t&&!p?this.modify(f,i):this.clearAndModify(f),d)this._scrollCellCoordsIntoView(d);else{if(t&&_){const S=this._getMaxRange();if(e===exports.w.Direction.Right&&_.colIndex===S.colEnd||e===exports.w.Direction.Left&&_.colIndex===S.colStart||e===exports.w.Direction.Up&&_.rowIndex===S.rowEnd||e===exports.w.Direction.Down&&_.rowIndex===S.rowStart)return this}e===exports.w.Direction.Left||e===exports.w.Direction.Right?this._scrollCellCoordsIntoView({colStart:g.colIndex}):e!==exports.w.Direction.Up&&e!==exports.w.Direction.Down||this._scrollCellCoordsIntoView({rowStart:g.rowIndex})}return this}getCoords(){return this._coords}updateCoords(e){const t=this._coords;if(k.isEqualSelectionCoords(t,e))return;const n=((r,o,i)=>{if(!r)return ll;let a=o.cell;k.isEqualCells(a,r?.cell)||(a=Object.freeze({colIndex:Math.max(0,Math.min(r?.cell?.colIndex??o.cell?.colIndex??0)),rowIndex:Math.max(0,Math.min(r?.cell?.rowIndex??o?.cell?.rowIndex??0))}));const l=r?.ranges?[...r.ranges]:[];let c=!1;const h=l.length;let u=h===0;for(let f=0;f<h;f++){const _=l[f];l[f]=Object.freeze({colStart:Math.max(i.colStart,Math.min(_.colStart,i.colEnd)),colEnd:Math.max(i.colStart,Math.min(_.colEnd,i.colEnd)),rowStart:Math.max(i.rowStart,Math.min(_.rowStart,i.rowEnd)),rowEnd:Math.max(i.rowStart,Math.min(_.rowEnd,i.rowEnd))}),u=u||k.isCellWithinRange(a,_),c=c||Object.keys(_).length>4}let d=o?.ranges??[];!c&&k.isEqualRangesArrays(d,l)||(d=l);let g=r?.rangeIndex??o?.rangeIndex??ll.rangeIndex;if(g=Math.max(-1,Math.min(g,d.length-1)),!u){const f=d[g];let _=a.rowIndex;_<f.rowStart?_=f.rowStart:_>f.rowEnd&&(_=f.rowEnd);let p=a.rowIndex;p<f.colStart?p=f.colStart:p>f.colEnd&&(p=f.colEnd),a=Object.freeze({colIndex:p,rowIndex:_})}return Object.freeze({cell:a,ranges:d,rangeIndex:g})})(e,this._coords,this._getMaxRange());return this._coords=n,!k.isEqualCells(n.cell,t.cell)&&this._scrollCellCoordsIntoView({colStart:n.cell.colIndex,rowStart:n.cell.rowIndex}),this._emitter.notify("onChange"),this}isEntire(){const e=this._coords;if(e.ranges.length===0)return!1;const t=this._getMaxRange();for(let n=0;n<e.ranges.length;n++){const r=e.ranges[n];if(!k.isRangeWithinRange(t,r))return!1}return!0}traverse(e=exports.w.Orientation.Row,t=!1){let n=exports.w.Direction.Right;n=e===exports.w.Orientation.Row?t?exports.w.Direction.Left:exports.w.Direction.Right:t?exports.w.Direction.Up:exports.w.Direction.Down;const r=this._coords;if(r.ranges.length===0)return this.navigate(n);const o=this._getCellCoordsAsRangeCoords(r.cell);if(k.isEqualRangesArrays([o],r.ranges))return this.navigate(n);const i=mf(r,n,this._getCellCoordsAsRangeCoords.bind(this),this._hiddenRowsAt.bind(this),this._hiddenColumnsAt.bind(this));this.updateCoords(i)}clear(){this._setSelectionRanges(Kl)}modify(e,t,n){if(this._selectionPolicy==="single")return;const r=this._coords,o=this._rangesFromCellOptional(r,e,t??r.cell);if(!o)return;const i=r.rangeIndex;this._setSelectionRanges(a=>a.length?a.map((l,c)=>i===c?o:l):[o]),n&&o&&this._setSelectionCell({colIndex:o.colStart,rowIndex:o.rowStart})}append(e,t=e,n){if(this._selectionPolicy!=="multiple"||!e||this._isCellOutOfBounds(e)||this._isCellOutOfBounds(t))return;const r=this._coords,o=this._cellToRangeActual(e,t);if(!o)return;const i=r.ranges.length>0?[...r.ranges]:[this._cellToRangeActual(r.cell,r.cell)];i.push(o);const a={ranges:i,cell:{rowIndex:o.rowStart,colIndex:o.colStart,...n},rangeIndex:i.length-1};k.isEqualSelectionCoords(a,r)||this.updateCoords(a)}clearAndModify(e,t,n){const r=this._coords;e={...r.cell,...e},t=t??e;const o=this._rangesFromCellOptional(r,e,t);if(!o)return;const i={rowIndex:o.rowStart,colIndex:o.colStart},a={...i,...n},l=this._newSelectionMode;l==="clear"?(this._firstActiveCoords=a,this.clear()):l==="modify"?this.modify(i):this.append(i),this._setSelectionCell(a)}setAdjusting(e){this._adjusting=e,this._emitter.notify("onAdjustingChange")}getAdjusting(){return this._adjusting}addListeners(e,t){return this._emitter.addListeners(e,t)}_setSelectionRanges(e){const t=this._coords;let n=typeof e=="function"?e(t.ranges):e??Kl;if(k.isEqualRangesArrays(n,t.ranges))return;let r=Math.max(n.length?0:-1,Math.min(t.rangeIndex,n.length-1)),o=t.cell;r===-1||k.isCellWithinRange(o,n[r])||(o={rowIndex:n[r].rowStart,colIndex:n[r].colStart}),n.length===1&&k.isSingleCell(n[0])&&k.isCellWithinRange(o,n[0])&&(n=[],r=-1);const i={cell:o,ranges:n,rangeIndex:r};k.isEqualSelectionCoords(i,t)||this.updateCoords(i)}_setSelectionCell(e){const t=this._coords,n=e??Sy,r=this._getCellCoordsAsRangeCoords(n);if(!k.isSingleCell(r)&&t.ranges.length===0)return this.updateCoords({ranges:[r],rangeIndex:0,cell:n});if(k.isEqualCells(n,t.cell))return;let o=t.ranges,i=t.rangeIndex;t.ranges.length===1&&(k.isSingleCell(t.ranges[0])&&k.isCellWithinRange(n,t.ranges[0])||!k.isCellWithinRange(n,t.ranges[0]))&&(o=[],i=-1);const a={ranges:o,rangeIndex:i,cell:n};return k.isEqualSelectionCoords(a,t)?void 0:this.updateCoords(a)}_isCellOutOfBounds(e){const t=this._getMaxRange();return e.rowIndex<t.rowStart||e.colIndex<t.colStart||e.colIndex>t.colEnd||e.rowIndex>t.rowEnd}_cellToRangeActual(e,t){const n={rowStart:Math.min(e.rowIndex,t.rowIndex),colStart:Math.min(e.colIndex,t.colIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex),colEnd:Math.max(e.colIndex,t.colIndex)};if(this._canSelectionSpanMergedCells(n))return n;const r=this._getCellCoordsAsRangeCoords(e),o=this._getCellCoordsAsRangeCoords(t),i={rowStart:Math.min(r.rowStart,o.rowStart),colStart:Math.min(r.colStart,o.colStart),rowEnd:Math.max(r.rowEnd,o.rowEnd),colEnd:Math.max(r.colEnd,o.colEnd)},a=this._getMergedRanges(i);return k.extendRangeToUnionRanges(i,a)}_rangesFromCellOptional(e,t,n){const r=e.ranges.length>0?e.ranges[e.rangeIndex]:{rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},o={rowStart:Math.min(t.rowIndex??r.rowStart,n.rowIndex??r.rowStart),colStart:Math.min(t.colIndex??r.colStart,n.colIndex??r.colStart),rowEnd:Math.max(t.rowIndex??r.rowEnd,n.rowIndex??r.rowEnd),colEnd:Math.max(t.colIndex??r.colEnd,n.colIndex??r.colEnd)},i={rowIndex:o.rowStart,colIndex:o.colStart},a={rowIndex:o.rowEnd,colIndex:o.colEnd};if(!(this._isCellOutOfBounds(i)||this._isCellOutOfBounds(a)))return this._cellToRangeActual(i,a)}_getMaxRange(){return this._sheet.getEntireRange().getCoords()}toString(){let e="";return e+=`selection:[${this._sheet.getRange(this._coords.cell).toString()}`,this._coords.ranges&&this._coords.ranges.length>0&&(e+=`, ${this._sheet.getRanges(this._coords.ranges).toString()}`),this._coords.rangeIndex!==void 0&&this._coords.rangeIndex!==-1&&(e+=`, ${this._coords.rangeIndex}`),e+="]",e}}class Pi{constructor(e,t){this._c=e,this._m=t}getModel(){return this._m}getCoords(){return this._c}getPropertiesAt(e,t,n){return this._m.getPropertiesAt(e,t,n)}getSplit(e){const t=this._m;return[new Pi(e[0],t),new Pi(e[1],t)]}}class yy extends ir{constructor(e){if(super({...e}),this._coordsCache=null,!e.json)throw new Error("json is required");this._sheet=e.sheet,this._styles=e.sheet?.getStyles()??new Xr,this._options={...e},e.setOnContainerCoordsChange(this._processCoordsChange.bind(this)),e.setCreateSpatial(this._createSpatial.bind(this)),this._getContainerRanges=e.getContainerRanges,this._setContainerRanges=e.setContainerRanges;const t=this;this._options.transactions.addStateListener(this,{onRestoreOrRevert(){t._coordsCache=null},onBeforeCommitEnd(){t._coordsCache=null}}),this._fromJSON({...e.json})}getRanges(){return this._getContainerRanges()}setRanges(e,t){const n=this.getRanges(),r=this._setContainerRanges(e,t);return this._processCoordsChange({before:n?.getCoords()??null,after:r?.getCoords()??null}),this}setType(e,t){return this._updateState({type:e},{description:"Set Conditional Format Type",...t}),this}getType(){return this._getState().type}setPriority(e,t){return this._updateState({priority:e},{description:"Set Priority",...t}),this}getPriority(){return this._getState().priority}setStopIfTrue(e,t){return this._updateState({stopIfTrue:e},{description:`Set Stop ${e??!1}`,...t}),this}getStopIfTrue(){return this._getState().stopIfTrue??!1}getScalar(){return this._getState().value??null}getColorScale(){return this._getState().colorScale??null}getContainsText(){return this._getState().text}getCustom(){return this._getState().formulas}getDataBar(){return this._getState().dataBar??null}getIconSet(){return this._getState().iconSet}getPresetCriteria(){return this._getState().style}getTopBottom(){return this._getState()}getSnapshot(e){this.toJSON();const t=null,n=this,r=Object.freeze({...e});let o=!1;return{async copyTo(i,a){i.conditionals;const l=i.range;({...r,...a}).isCut&&!o&&(n.delete(),o=!0);const c={colStart:l.colStart,rowStart:l.rowStart,colEnd:t.colEnd-t.colStart+l.colStart,rowEnd:t.rowEnd-t.rowStart+l.rowStart};return console.log("implement copyTo"),c},getCoords:()=>t,getSource:()=>n,getName:()=>"Conditional Format",getMarkOptions:()=>r,isISnapshot:!0}}_processRestoreOrRevert(e,t,n){super._processRestoreOrRevert(e,t,n)}_createSpatial(e){return new Pi(e,this)}_processCoordsChange(e){this._coordsCache=null,e.after?this._emitter.notify("onAnyChange"):this._delete()}update(e,t){if(this.isClosed())throw new Error("Table has been closed. No further operations are allowed.");const n=this._getState(),r=this._beginCommit(t?.description??"Update Conditional Format");try{const o={...n,...e};this._updateState(o,t),this._getEmitter().notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_processDelete(){this._getState(),super._processDelete()}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._getEmitter().notify("onAnyChange")}toJSON(){const e={},t=this._getState();if(t===null)return null;const n=this.getRanges()?.toString();return n?(e.ref=n,e.type=t.type,t.priority!==0&&(e.priority=t.priority),t.stopIfTrue&&(e.stopIfTrue=t.stopIfTrue),t.style&&(e.style=t.style),t.colorScale&&(e.colorScale=t.colorScale),t.dataBar&&(e.dataBar=t.dataBar),t.iconSet&&(e.iconSet=t.iconSet),t.aboveAverage&&(e.aboveAverage=t.aboveAverage),t.equalAverage&&(e.equalAverage=t.equalAverage),t.stdDev!==0&&(e.stdDev=t.stdDev),t.bottom&&(e.bottom=t.bottom),t.percent&&(e.percent=t.percent),t.rank!==0&&(e.rank=t.rank),t.operator&&(e.operator=t.operator),t.formulas&&(e.formulas=t.formulas),t.text&&(e.text=t.text),t.timePeriod&&(e.timePeriod=t.timePeriod),e):null}_fromJSON(e){const t={};t.type=e.type??exports.IConditionalFormat.Type.CellIs,t.priority=e.priority??0,t.stopIfTrue=e.stopIfTrue??!1,t.style=e.style??null,t.colorScale=e.colorScale??null,t.dataBar=e.dataBar??null,t.iconSet=e.iconSet??null,t.aboveAverage=e.aboveAverage??!1,t.equalAverage=e.equalAverage??!1,t.stdDev=e.stdDev??0,t.bottom=e.bottom??!1,t.percent=e.percent??!1,t.rank=e.rank??0,t.operator=e.operator??null,t.formulas=e.formulas??null,t.text=e.text??null,t.timePeriod=e.timePeriod??null,this._updateState(t,{description:"Initialize Conditional Format"})}close(){super.close(),this.isClosed()||(this._updateState({},{description:"Close Conditional"}),this._stylesRemoveListener?.())}getCoords(){return this.getRanges().getCoords()[0]}getPropertiesAt(e,t,n){let r=this._coordsCache;r||(r=this._coordsCache=this.getRanges().getCoords());let o=0,i=0;const a={rowIndex:e,colIndex:t};for(let c=0;c<r.length;c++){const h=r[c];if(k.isCellWithinRange(a,h)){const u=e-h.rowStart,d=t-h.colStart;i=o+(u*(h.colEnd-h.colStart+1)+d+1)}o+=(h.rowEnd-h.rowStart+1)*(h.colEnd-h.colStart+1)}let l={fill:{type:"solid",color:"red"}};return l.fill.color=((c,h,u,d)=>{let g=1;h!==0&&(g=c/h);const m=u[0]+g*(d[0]-u[0]),f=u[1]+g*(d[1]-u[1]),_=u[2]+g*(d[2]-u[2]);return`rgb(${Math.round(m)}, ${Math.round(f)}, ${Math.round(_)})`})(i,o,[255,255,255],[255,0,0]),l}get isIConditionalFormat(){return!0}}class Cy{constructor(e,t){this._add=e,this._get=t}add(e,t){if(!e)throw new Error(Lr);return this._add(e,t)}search(e){let t;return e?.address&&(t=e.address),this._get(t,e?.excludeHidden,e?.fullyContained)}getCount(){return this._get(null,!1,!1).length}}const Ld=(s,e)=>{if(e){if(e.getType()===exports.IFill.Type.Solid)s.background=Yt(e.getColor())||"none",s["mso-pattern"]="black none";else if(e.getType()===exports.IFill.Type.Pattern){const t=e;s.background=Yt(t.getBackground())||"none";const n=Yt(t.getForeground())||"";if(t.getPatternType()===exports.IFill.BuiltInSheetPattern.Solid)s["mso-pattern"]=`${s.background} none`,s.background=n;else{const r=(o=>$e.get(o)?.cssKey??"solid")(t.getPatternType());s["mso-pattern"]=n+(r?" ":"")+r}}else if(e.getType()===exports.IFill.Type.Gradient){const t=e;s.background=Yt(t.getStops()?.[0]?.getColor())||"auto",s.msoGradient=Xm(t)||"auto"}}};class by{constructor(e,t){if(this._visitedStyles=new Map,this._lastStyleClassId=63,this._wroteTD=!1,!e)throw new Error("Can not create with a null sheet.");this._sheet=e,this._includeSizeInCell=t??!1,this._normalStyle=e.getStyles().getNormal()}_createCSSStyle(e){const t=this._normalStyle,n={},r=(d,g)=>d===g||!(d&&!g)&&!(!d&&g)&&g.isEqual?.(d),o=e.getFont(),i=t.getFont();var a;r(o.getFill(),i.getFill())||(n.color=Yt(o.getFill())),r(o.getSize(),i.getSize())||(n["font-size"]=Ku(o.getSize())),r(o.getWeight(),i.getWeight())||(n["font-weight"]=o.getWeight()),r(o.getStyle(),i.getStyle())||(n["font-style"]=o.getStyle()),r(o.getUnderline(),i.getUnderline())||(n["text-decoration"]="underline",n["text-underline-style"]=(a=o.getUnderline())===exports.IFont.UnderlineStyle.Single?"single":a===exports.IFont.UnderlineStyle.Double?"double":a===exports.IFont.UnderlineStyle.SingleAccounting?"single-accounting":a===exports.IFont.UnderlineStyle.DoubleAccounting?"double-accounting":"none"),r(o.getFamily(),i.getFamily())&&r(o.getFallbacks(),i.getFallbacks())||(n["font-family"]=Fi(o.getFamily(),o.getFallbacks())),r(e.getNumberFormat(),t.getNumberFormat())||(n["mso-number-format"]=Zu(e.getNumberFormat()));const l=e.getAlignment(),c=t.getAlignment();if(!r(l.getHorizontal(),c.getHorizontal())){const d=l.getHorizontal();d===exports.ITextFrame.HorizontalAlignment.CenterContinuous?n["text-align"]="center-across":d===exports.ITextFrame.HorizontalAlignment.Fill?n["text-align"]="fill":d===exports.ITextFrame.HorizontalAlignment.Distributed?n["text-align"]=l.getJustifyLastLine()?"121":"010":n["text-align"]=exports.ITextFrame.toCSSHorizontalTextAlign(d)}if(!r(l.getVertical(),c.getVertical())){const d=l.getVertical();d===exports.ITextFrame.VerticalAlignment.Distributed?n["vertical-align"]="121":n["vertical-align"]=Yu(d)}if(!r(l.getOverflow(),c.getOverflow())){const d=l.getOverflow();n["white-space"]=Qu(d),d===exports.ITextFrame.Overflow.Shrink&&(n["mso-text-control"]="shrinktofit")}var h;r(l.getRotation(),c.getRotation())||(n["mso-rotate"]=(h=l.getRotation(),(h%=360)<0&&(h+=360),h>180?h=360-h:h>1&&(h*=-1),h)),r(l.getIndent(),c.getIndent())||(n["mso-char-indent-count"]=l.getIndent()),r(e.getFill(),i.getFill())||Ld(n,e.getFill());const u=e.getBorder();return u.getTop().isNone()||(n["border-top"]=qn(u.getTop())),u.getLeft().isNone()||(n["border-left"]=qn(u.getLeft())),u.getRight().isNone()||(n["border-right"]=qn(u.getRight())),u.getBottom().isNone()||(n["border-bottom"]=qn(u.getBottom())),u.getDiagonalUp().isNone()||(n["border-mso-diagonal-up"]=qn(u.getDiagonalUp())),u.getDiagonalDown().isNone()||(n["border-mso-diagonal-down"]=qn(u.getDiagonalDown())),Object.keys(n).length===0?null:n}_createCSSNormalStyle(){const e=this._normalStyle,t={"padding-top":"1px","padding-left":"1px","padding-right":"1px","mso-ignore":"padding"},n=e.getFont(),r=e.getAlignment();return t.color=Yt(n.getFill()),Ld(t,e.getFill()),t["font-size"]=Ku(n.getSize()),t["font-weight"]=n.getWeight(),t["font-style"]=n.getStyle(),t["text-decoration"]=Um(n.getUnderline(),n.getStrike()),t["font-family"]=Fi(n.getFamily(),n.getFallbacks()),t["mso-font-charset"]="0",t["mso-background-source"]="auto",t["mso-number-format"]=Zu(e.getNumberFormat()),t["text-align"]=exports.ITextFrame.toCSSHorizontalTextAlign(r.getHorizontal()),t["vertical-align"]=Yu(r.getVertical()),t.border="none",t["mso-pattern"]="auto",t["white-space"]=Qu(r.getOverflow()),r.getOverflow()===exports.ITextFrame.Overflow.Shrink&&(t["mso-text-control"]="shrinktofit"),t["mso-rotate"]="0",r.getIndent()>0&&(t["mso-char-indent-count"]=r.getIndent()),t["mso-protection"]="locked visible",t}onCell(e,t,n){let r;const o=e.getSpans();if(o.width>1||o.height>1){if(!e.isTopLeft())return!1;o.height>1&&n.addAttribute("rowspan",o.height),o.width>1&&n.addAttribute("colspan",o.width)}let i=e.toTextUnformatted();e.getNumberFormat().repeatPlaceholder&&(i=e.getNumberFormat().repeatPlaceholder.repeat(5)),n.setPlainText(i||"");const a=e.getStyle(),l=a.getFont();if(l.getVerticalAlignment()===exports.IFont.VerticalAlignment.Super&&(i=`<sup>${i}</sup>`),l.getVerticalAlignment()===exports.IFont.VerticalAlignment.Sub&&(i=`<sub>${i}</sub>`),l.getStrike()&&(i=`<s>${i}</s>`),e.getHyperlink()&&(i=`<a href="${e.getHyperlink().getAddress()}">${i}</a>`),n.setHTMLText(i||"&nbsp"),!this._wroteTD){const h=this._createCSSNormalStyle();n.addSharedStyle("td",h),this._wroteTD=!0}let c=this._visitedStyles.get(a);if(!c){const h=this._createCSSStyle(a);h&&(c="xl"+ ++this._lastStyleClassId,this._visitedStyles.set(a,c),n.addSharedStyle("."+c,h))}if(c&&n.addAttribute("class",c),this._includeSizeInCell){const h=this._sheet.getColumnHeaders().at(t.colIndex).getSize();n.addAttribute("width",h),n.addStyle("width",F.roundAccurately(h/exports.IFont.getDeviceScale(),2)+"pt");const u=this._sheet.getRowHeaders().at(t.rowIndex).getSize();n.addAttribute("height",u),n.addStyle("height",F.roundAccurately(u/exports.IFont.getDeviceScale(),2)+"pt")}return r}onRow(e,t,n,r){const o=e.getSize();r.addAttribute("height",o),r.addStyle("height",F.roundAccurately(o/exports.IFont.getDeviceScale(),2)+"pt"),e.isCustomSize()&&r.addStyle("mso-height-source","userset")}onColumn(e,t,n,r){const o=e.getSize();r.addAttribute("width",o),r.addStyle("width",F.roundAccurately(o/exports.IFont.getDeviceScale(),2)+"pt"),e.isCustomSize()&&r.addStyle("mso-width-source","userset"),n>1&&r.addAttribute("colspan",n)}}const Pd=(s,e,t)=>{const n=s.getOrientation()===se.Column,r=(n?"Column":"Row")+" Copy",o=s.getSnapshot(t);return{...o,getName:()=>r,getCoords:()=>e,copyTo:async(i,a)=>{const l=n?i.getColumnHeaders():i.getRowHeaders(),c={...t,...a};if(c.includeHeaders===!0){const h=await o.copyTo(l,c);return n?{colStart:h.min,rowStart:e.rowStart,colEnd:h.max,rowEnd:e.rowEnd}:{colStart:e.colStart,rowStart:h.min,colEnd:e.colEnd,rowEnd:h.max}}},getMarkOptions:()=>t}},Ey=(s,e,t,n,r,o)=>{const i=t[0];let a,l;const c=()=>{if(l!==void 0)return;const[h,u]=((d,g)=>{const m=g.getRowHeaders(),f=g.getColumnHeaders(),_=g.getUsedRange()?.getCoords(),p=m.getUsedRange()?.getCoords(),S=f.getUsedRange()?.getCoords(),C={...k.EmptyRange,..._,colEnd:Math.max(_?.colEnd??0,S?.max??0),rowEnd:Math.max(_?.rowEnd??0,p?.max??0)},y=new Map,b=[];d.onStart?.();const w={rows:[],cols:[]},E=new cy(y,b);E.setNode(w),d.onTable?.(E,C);let x=0;f.forEachSpan((P,L)=>{const z=L.getCoords();x=x+z.max-z.min+1;const O={};E.setNode(O),d.onColumn?.(L.getCellHeader(),z.min,z.max-z.min+1,E),w.cols.push(O)},{address:C,includeEmpty:!0,includeStyles:!0});let I=0;const v=[];if(m.forEachSpan((P,L)=>{const z=L.getCoords();I=I+z.max-z.min+1,v.push({min:z.min,max:z.max,value:L.getCellHeader()})},{address:C,includeEmpty:!0,includeStyles:!0,excludeHidden:!1}),x*I>5e4){if(!Md)throw Md=!0,new yg("Unable to write more than 50000 cells to system clipboard. Items can still be pasted within the application to but if you want to copy to another application select a smaller set of data.");return[null,null]}let R=0,A=-1,M=null;g.forEach((P,L)=>{const z=L.getCoords(),O=L.getCell();if(z.rowIndex!==A){z.rowIndex>v[R].max&&++R;const V=v[R];M={cells:[]},E.setNode(M),d.onRow?.(V.value,z.rowIndex,1,E),w.rows.push(M),A=z.rowIndex}const j={};E.setNode(j),d.onCell(O,z,E)!==!1&&M.cells.push(j)},{address:C,includeEmpty:!0,excludeHidden:!1}),d.onDone?.(),w.rows.length===0&&w.rows.push({cells:[]});const T=[];for(let P=0;P<b.length;P++){const L=b[P],z=y.get(L);T.push(L);let O="";const j=Object.keys(z);for(let V=0;V<j.length;V++){O+=" ",V===0&&(O+="{");const W=j[V];O+=`${W}:${z[W]};`,V===j.length-1?O+="}":O+=`
33
+ `}T.push(O)}const N=[`<div clipboard-uuid=xxx>
34
+ <html
35
+ xmlns:v="urn:schemas-microsoft-com:vml"
36
+ xmlns:o="urn:schemas-microsoft-com:office:office"
37
+ xmlns:x="urn:schemas-microsoft-com:office:excel"
38
+ xmlns="http://www.w3.org/TR/REC-html40"
39
+ >`];N.push(`<head>
40
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8">
41
+ <meta name=ProgId content=Excel.Sheet>
42
+ <meta name=Generator content="Microsoft Excel 15">`),N.push(`<style>
43
+ table
44
+ {mso-displayed-decimal-separator:"\\.";
45
+ mso-displayed-thousand-separator:"\\,";}
46
+ @page
47
+ {margin:.75in .25in .75in .25in;
48
+ mso-header-margin:.3in;
49
+ mso-footer-margin:.3in;
50
+ mso-horizontal-page-align:center;}
51
+ tr
52
+ {mso-height-source:auto;}
53
+ col
54
+ {mso-width-source:auto;}
55
+ br
56
+ {mso-data-placement:same-cell;}`),T.length>0&&N.push(T.join(`
57
+ `)),N.push("</style>"),N.push("</head>"),N.push("<body>"),N.push("<table>"),N.push("<!--StartFragment-->");const B=P=>{let L=(O=>{let j="";return O&&O.attributes&&O.attributes.length!==0&&O.attributes.forEach((V,W)=>{j.length>0&&(j+=" "),j+=`${W}=${V}`}),j})(P);L.length>0&&(L=" "+L);let z=(O=>{let j="";return O&&O.styles&&O.styles.length!==0&&(O.styles.forEach((V,W)=>{j.length>0&&(j+=";"),j+=W+":"+V}),j.length>0&&(j=`style='${j}'`)),j})(P);return z.length>0&&(z=" "+z),`${L}${z}`},D=[];return w.cols?.forEach(P=>{N.push(` <col${B(P)}>`)}),w.rows.forEach(P=>{N.push(` <tr${B(P)}>`);const L=[];P.cells.forEach(z=>{N.push(` <td${B(z)}>${z.htmlText??z.plainText??""}</td>`);const O=`${F.castToString(z.plainText??"")?.replace(/"/g,'""')}`;L.push(O)}),D.push(L.join(" ")),N.push(" </tr>")}),N.push("<!--EndFragment-->"),N.push("</table>"),N.push("</body>"),N.push("</html>"),N.push("</div>"),[N.join(`
58
+ `),D.join(`
59
+ `).concat(`
60
+ `)]})(new by(e),e.getRange(i));a=h??null,l=u??null};return{copyTo(h,u){const d={...r,...u};return u.isCut,o(h,d)},getMarkOptions:()=>r,getSource:()=>s,getName:()=>n,getCoords:()=>i,toText:()=>(c(),l),toHtml:()=>(c(),a),toImage:()=>null,isISnapshot:!0}},_i=(s,e)=>Math.round(s*e),zd=(s,e,t)=>{const n=[],r=[];if(!s||s.length===0)return{sizes:n,hidden:r};if(!e||!t)return console.warn("_HeaderUtils:default size and scaleFactor should be available"),{sizes:n,hidden:r};let o=0,i=0,a=0,l=null,c=-2;for(let h=0;h<s.length;h++){const u=s[h],d=u.min,g=u.max;o=n.length===0?0:n[n.length-1].runningOffsetMax,n.length>0&&n[n.length-1].spanSize>0&&o++,i<u.min&&n.push({indexMin:i,indexMax:d-1,runningOffsetMin:o,runningOffsetMax:Math.round(o+(d-i)*e*t)-1,runningHiddenRuns:a,spanSize:Math.round(e*t)});const m=n.length,f=n[m-1];o=m===0?0:f.runningOffsetMax,m>0&&f.spanSize>0&&o++;let _=0;u.value.h||(_=_i(u.value?.sz??e,t));const p=_===0?0:-1;_===0&&(a+=g-d+1,c+1===d?l.max=g:(l={min:d,max:g,value:!0},r.push(l)),c=g),m>0&&f.spanSize===_&&f.indexMax+1===d?(f.indexMax=g,f.runningHiddenRuns=a,f.runningOffsetMax=f.runningOffsetMin+(g+1-f.indexMin)*_+p):n.push({indexMin:d,indexMax:g,runningOffsetMin:o,runningOffsetMax:Math.round(o+(g+1-d)*_)+p,runningHiddenRuns:a,spanSize:_}),i=g+1}return{sizes:n,hidden:r}};function cl(s,e,t){t!==void 0&&(t!==null?s[e]=t:delete s[e])}const hl=()=>{},jd=()=>0,vy=()=>!1,ff=(s,e,t,n)=>{if(n!==void 0){if(n===null)return null;if(n?.isICellHeader)return n._headerState;if(n){const r=n,o={...t};let i,a=r.hidden,l=r.size;if(r.size!==void 0){if(typeof l=="function"){const c=t?.sz===void 0?s.getDefaultSize():t?.sz*s.getScaleFactor();l=l?.(c)}if(typeof l=="string"&&(l=zr(l,e.getNormal().getFont().getSize(),"px")),typeof l=="number"){const c=s.getMinSize(),h=s.getMaxSize();l=Math.max(c,Math.min(F.roundAccurately(l,c),h)),r.relativeSize!==!0&&(l/=s.getScaleFactor()),isNaN(l)&&(console.warn("headerSize can not be NaN"),l=void 0),l===0&&(a=!0,l=void 0),i=!r.autoSize}else l===null?(l=null,i=!r.autoSize):l!==void 0&&(console.warn("headerSize can not be type",l),l=void 0)}return cl(o,"sz",l),cl(o,"h",a),cl(o,"csz",i),Object.keys(o).length===0?null:o}}};class xc{constructor(e,t,n){this._sheetHeader=e;const r=this._sheetHeader.getSheet().getStyles();this._styles=r,this._headerState=t,this._template=n}getSize(){const e=this._headerState?.sz;return Math.round(e===void 0?this._sheetHeader.getDefaultSize():e*this._sheetHeader.getScaleFactor())}getDisplayText(){return""+this.asCell().getValue()}getOrientation(){return this._sheetHeader.getOrientation()}isHidden(){return this._headerState?.h??!1}isCustomSize(){return this._headerState?.cs??!1}getSheetHeader(){return this._sheetHeader}getStyle(){return this._headerState?.s??this._styles.getNormal()}asCell(){return this._cellTemplate||(this._cellTemplate=this._sheetHeader.getSheet().createTemporaryCell({style:this.getStyle(),...this._template})),this._cellTemplate}getSizeRelative(){return this.getSize()/this._sheetHeader.getScaleFactor()}createTemporaryCellHeader(e){const t=ff(this._sheetHeader,this._sheetHeader.getSheet().getStyles(),this._headerState,e);return new xc(this._sheetHeader,t,this._template)}isEqual(e){if(!e)return!1;if(e===this)return;const t=e;if(!t.isICellHeader)return!1;const n=this._headerState,r=t._headerState;return n===r||!(n&&!r||r&&!n)&&this.getSize()===t.getSize()&&this.isCustomSize()===t.isCustomSize()&&this.isHidden()===t.isHidden()&&this.getStyle()===t.getStyle()}isEmpty(){const e=this._headerState;return!e||e.sz===void 0&&e.csz===void 0&&!e.cs&&e.h===void 0&&!(!e.s||e.s!==this._styles.getNormal()||e.cs)}get isICellHeader(){return!0}}const Os="The columns are protected. To make a change, unprotect the sheet. You might be requested to enter a password.",Bs="The rows are protected. To make a change, unprotect the sheet. You might be requested to enter a password.",Jn="Rows",Xn="Columns";class Wd{constructor(e){if(this._emitter=null,this._closed=!1,this._scaleFactor=1,this._defaultSize=-1,this._defaultCustomSize=-1,this._defaultPxSize=1,this._isColumn=!0,this._indexedSizes=[],this._indexedHidden=[],this._headerRunCoords=null,this._hasCustomFormats=!1,this._hasStyles=!1,this._hasHidden=!1,this._lastHeaderRead=null,this._readCache=null,this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null,this._options={isProtected:()=>!1,getUpdateId:()=>null,scaleFactor:()=>1,defaultSize:()=>100,minSize:()=>0,maxSize:()=>500,orientation:exports.w.Orientation.Column,createCellHeader:(i,a,l)=>new xc(i,a,l),...e},!this._options.sheet)throw new Error("An ISheet must be provided");if(this._emptyHeader=this._options.createCellHeader(this,null,null),this._scaleFactor=this._options.scaleFactor(),this._defaultSize=this._options.defaultSize(),this._defaultSize<=0)throw new Error("defaultSize must be greater than 0");this._defaultPxSize=_i(this._defaultSize,this._scaleFactor);const t=this._options.orientation===exports.w.Orientation.Column;this._isColumn=t;const n=this._options.maxSheetCoords??{colStart:0,rowStart:0,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER};this._maxSheetCoords=n;const r=t?n.colEnd:n.rowEnd;this._maxDataIndex=r,this._maxRunCoords={min:0,max:r},this._maxDataRange=this.getRange(this._maxRunCoords),this._maxRangeCoords={colStart:0,rowStart:0,colEnd:t?r:0,rowEnd:t?0:r};const o=this;this._options.setContainerShiftedCallback&&this._options.setContainerShiftedCallback((i,a)=>{a<0?o._deleteHeaders(i,-a):o._insertHeaders(i,a)}),this._options.sheet&&(this._sheetRemoveListener=this._options.sheet.addListeners({onProtectionChange(){},onSelectionChange(i){o._selection=i.getSelection().getCoords(),o._selectionRuns=null},onStyleChange:()=>{},onViewChange(){const i={runs:o._headers};o._invalidSizes(),o._emitter.notify("onSizesChange",{params:i})}},{transactional:!1}),o._selection=o._options.sheet.getSelection().getCoords()),this._transactions=this._options.transactions??new Lt({transient:!0}),this._emitter=new st(o,this._transactions),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(i){o._lastHeaders!==i.headers&&o._onHeaderChange()}}),this.fromJSON(this._options?.json)}addListeners(e,t){return this._emitter.addListeners(e,t)}_invalidSizes(){const e=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize,t=this._options.scaleFactor();if(e!==this._defaultSize||t!==this._scaleFactor){this._defaultSize=e,this._scaleFactor=t,this._defaultPxSize=_i(e,t);const n=zd(this._headers,e,t);this._indexedSizes=n.sizes,this._indexedHidden=n.hidden,this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null}}_onHeaderChange(){this._lastHeaders=null;const e=this._headers,t=this._getState();this._defaultCustomSize=t.defaultCustomSize;const n=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize;this._defaultSize=n;const r=this._scaleFactor;this._defaultPxSize=_i(n,r);const o=zd(e,n,r);this._indexedSizes=o.sizes,this._indexedHidden=o.hidden,this._lastHeaderRead=null,this._readCache=dm(this._lastHeaders),this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null;const i=this._options.sheet.getStyles().getNormal();let a=!1,l=!1,c=!1,h=-1;for(let g=e.length-1;g>=0;g--){const m=e[g],f=m.value,_=f.s,p=f.csz||f.sz!==n;h!==-1||!p&&_===i||(h=m.max),a=a||f.cs,l=l||f.s!==i,c=c||f.h||f.sz===0}h=Math.min(h??0,this._maxDataIndex);const u=Math.min(e[0]?.min??h,h);this._headerRunCoords=Object.freeze({min:u,max:h}),this._hasCustomFormats=a,this._hasStyles=l,this._hasHidden=c;const d=t.runs;this._emitter.notify("onSizesChange",{params:d})}getSheet(){return this._options.sheet}getOrientation(){return this._isColumn?exports.w.Orientation.Column:exports.w.Orientation.Row}getTextAt(e){return this._options.getTextAt?.(e)??e+""}_scanHeaders(e,t,n,r,o,i){const a=o?.min??null,l=o?.max??null,c=i?.includeEmpty??!1,h=i?.includeStyles??!1,u=i?.excludeHidden??!1,d=i?.includeSizes??!1,g=this,m=this._options.sheet.getStyles().getNormal(),f=this._defaultSize,_=this._scaleFactor,p=this._emptyHeader;let S;const C={getCoords(){if(!S)throw new Error(Pr);return{min:S.min,max:S.max}},getIndex:()=>S.min,getCellHeader(){if(!S)throw new Error(Pr);return S.value?n(g,S.value):p},getA1(b){if(!S)throw new Error(Pr);return this._parseHeaderRangeAddress({min:a+b,end:a+b})??S}},y=Kh(t,b=>{const w=b.value;if(!c&&!w)return;let E=c;if(d&&!E&&w&&(w.csz||w.sz!==f)&&(E=!0),h&&!E&&w&&(w.s&&w.s!==m||w.cs)&&(E=!0),w&&w.h===!0&&(E=!u),!E)return;let x=f;b.value&&(x=b.value.h?0:b.value?.sz??f),x*=_,S=b;const I=e(x,C);return I&&I.break?I:void 0},a,l);return S=null,y}getRange(e,t){if(!e)throw new Error(Lr);const n=this,r=this._parseHeaderRangeAddress(e);if(r.min<0||r.max>this._maxDataIndex)return function(l){return Object.freeze({getCoords:()=>null,getOrientation:()=>l.getOrientation(),toString:()=>Ye,getA1:()=>Ye,getCount:jd,getVisibleCount:jd,isEntireHeaders:vy,forEach:hl,forEachSpan:hl,forEachVisibleSpan:hl,getUsedRange:_e,getSnapshot:_e,updateHeaders:_e,clear:_e,setHidden:_e,setSize:_e,at:_e,doBatch:_e,getSheetHeader:()=>l,isICellHeaderRange:!0})}(this);const o=(l,c,h,u=n._options.createCellHeader)=>{let d=r;if(c?.address){const m=n._parseHeaderRangeAddress(c?.address);if(m&&(d=Xh(r,m),!d))return}const g=this._scanHeaders(l,h,u,t,d,c);if(g&&g.break)return g.break},i=()=>{const l=n._isColumn?{colStart:r.min,colEnd:r.max}:{rowStart:r.min,rowEnd:r.max};return pn(l,n._maxRangeCoords)??Ye},a={getCoords:()=>r,getA1:i,toString:i,forEach:(l,c)=>{let h=Number.MAX_SAFE_INTEGER,u=null;const d={getIndex:()=>h,getCellHeader:()=>u.getCellHeader(),getA1:g=>u.getA1(g),getCoords:()=>u.getCoords()};return o((g,m)=>{u=m;for(let f=r.min;f<r.max;f++)h=f,l(g,d)},c,this._headers,()=>this.at(void 0))},forEachSpan:(l,c)=>o(l,c,this._headers),forEachVisibleSpan:(l,c)=>{const h=r?.min??null,u=r?.max??null;let d;if(d=c?.includeHidden?l(h,u):Kh(this._indexedHidden,g=>{if(g.value)return;const m=l(g.min,g.max);return m&&m.break?m:void 0},h,u),d&&d.break)return d.break},updateHeaders:(l,c)=>(n.updateHeaderPairs([{address:r,update:l}],{description:c?.description??`Update ${n._isColumn?Xn:Jn} ${toString()}`,...c}),a),setHidden:l=>(n.setHidden(r,l),a),getUsedRange:l=>{const c=n._headerRunCoords;return!c||c.min<0||c.max>n._maxDataIndex?null:Xh(c,r)?n.getRange(c,l):null},getCount:()=>r.max-r.min+1,getVisibleCount:()=>n.getVisibleCount(r.min,r.max),isEntireHeaders:()=>{const l=n._maxRunCoords;return!(r.min>l.min||r.max<l.max)},getSnapshot:l=>this._getSnapshot(r,l),clear:()=>(n._clear(r),a),setSize:(l,c)=>(n.setSize(r,l,c),a),at:l=>n.at(r.min+l),getOrientation:()=>n.getOrientation(),doBatch:(l,c)=>this.doBatch(h=>l(h),c),getSheetHeader:()=>n,isICellHeaderRange:!0};return Object.freeze(a)}getSelectedRange(e){const t=(n=>{if(!n)return null;let r=k.cellToRange(n.cell);for(let o=0;o<n.ranges.length;o++)r=k.unionRanges(r,n.ranges[o]);return r})(this._options.sheet.getSelection().getCoords());return this.getRange(t,e)}getUsedRange(e){return this.getRange(this._headerRunCoords,e)}getEntireRange(e){return e?this.getRange(this._maxRangeCoords,e):this._maxDataRange}at(e){if(e<0||e>this._maxDataIndex)return this._emptyHeader;if(this._lastHeaderRead?.offset===e)return this._lastHeaderRead.header;const t=gm(e,this._readCache);if(!t)return this._emptyHeader;const n=this._options.getTextAt?.(e)??e+"",r=this._options.createCellHeader(this,t,{value:n});return this._lastHeaderRead={offset:e,header:r},r}updateHeaderPairs(e,t){if(this.isProtected())throw new Error(this._isColumn?Os:Bs);return this._updatePairsInternal(e,t)}_parseHeaderRangeAddress(e){if(e==null)throw new Error("Must specify a range.");const t=((n,r,o)=>{if(n==null)return null;let i={};if(typeof n=="number")i.colStart=n,i.colEnd=n,i.rowStart=n,i.rowEnd=n;else if(typeof n=="string"){if(r){if(n.match(/[0-9]+/))throw new Error("Invalid range address for header orientation")}else if(n.match(/[a-zA-Z]+/))throw new Error("Invalid range address for header orientation");let l=Ft(n,o);if(!l){const c=Bm(n.toUpperCase(),!0);c?.colIndex!==void 0&&(i.colStart=c.colIndex,i.colEnd=c.colIndex),c?.rowIndex!==void 0&&(i.rowStart=c.rowIndex,i.rowEnd=c.rowIndex)}i={...i,...l}}const a={min:void 0,max:void 0};return r?(a.min=n.min??n.colStart??i.colStart,a.max=n.max??n.colEnd??i.colEnd):(a.min=n.min??n.rowStart??i.rowStart,a.max=n.max??n.rowEnd??i.rowEnd),a.min===void 0||a.max===void 0?null:a})(e,this._isColumn,this._maxRangeCoords);if(!t)throw new Error("Invalid header range.");return t}update(e,t,n){if(!e||(Array.isArray(e)||(e=[e]),e.length===0))return;const r=[];for(let o=0;o<e.length;o++){const i=this._parseHeaderRangeAddress(e[o]);this.getRange(i).forEachSpan((a,l)=>{const c=l.getCoords();r.push({address:c,update:t})},{includeEmpty:!0})}return this.updateHeaderPairs(r,n),this}setSize(e,t=null,n){(n?.relativeSize??!1)||typeof t!="number"||(t+="px");const r={size:t,autoSize:n?.autoSize??!1},o=`Resize ${this._isColumn?Xn:Jn}`;return this.update(e,r,{description:o,...n}),this}setHidden(e,t=null){const n={hidden:t},r=`${t?"Unhide":"Hide"} ${this._isColumn?Xn:Jn}`;return this.update(e,n,{description:r}),this}_clear(e,t){const n="Clear "+(this._isColumn?"Column Headers":"Row Headers");this.updateHeaderPairs([{address:e,update:null}],{description:n,...t})}_getSnapshot(e,t){if(e.min<0)return F.EmptyArray;t=Object.freeze({...t});const n=this,r=this._getState(),o=(this._isColumn?"Column":"Row")+" Headers";return{copyTo(a,l){const c={...t,...l},h=a.getCoords(),u=h.min-e.min,d=[];if(n._scanHeaders((g,m)=>{const f=m.getCoords();d.push({address:{min:f.min+u,max:f.max+u},update:m.getCellHeader()})},r.headers,n._options.createCellHeader,null,e,{includeSizes:!0,includeStyles:!0}),!c.fitDestination){let g=e.max-e.min+1,m=h.max-h.min+1,f=F.roundAccurately(m/g);if(f>1&&m%g===0){const _=d.length;for(let p=0;p<f;p++)for(let S=0;S<_;S++){const C=d[S],y=C.address,b=(p+1)*g;d.push({address:{min:y.min+b,max:y.max+b},update:C.update})}}}if(a.doBatch(()=>{a.clear(),a.getSheetHeader()._updatePairsInternal(d)},o),c.isCut){const g=n._maxRunCoords;e.min<=g.min&&e.max>=g.max&&n._clear(e)}return h},getCoords:()=>e,toText:()=>null,toHtml:()=>null,toImage:()=>null,getSource:()=>n,getName:()=>o,isISnapshot:!0}}isProtected(){return this._options?.isProtected()??!1}getScaleFactor(){return this._options.scaleFactor()??1}get _headers(){return this._lastHeaders===null&&(this._lastHeaders=this._getState()?.headers),this._lastHeaders}_updatePairsInternal(e,t){if(!e||e.length===0)return null;const n=t?.skipCustomSize??!1,r=this._isColumn,o=this.getSheet().getStyles(),i=this._beginCommit({description:t?.description??`Update ${r?Xn:Jn}`});let a=[...this._getState().headers],l=!1,c=!1;const h=r?exports.IBorder.Edge.Top:exports.IBorder.Edge.Left;exports.IBorder.oppositeEdge(h);const u=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom;exports.IBorder.oppositeEdge(u);const d=this,g=(y,b)=>{if(this.isProtected())throw new Error(this._isColumn?Os:Bs);c=c||b===null,!c&&b&&(c=!!b.isICellHeader||b?.size!==void 0||b?.hidden!==void 0),l=l||b===null||b?.style!==void 0||b?.isICellHeader;const w={onUpdate:(E,x)=>n&&E&&E.csz?E:ff(d,o,E,x),onSplit:E=>[E.value,E.value],onMerge:(E,x,I,v)=>{if(!(E&&!x||!E&&x||!E&&!x)&&E.sz===x.sz&&E.csz===x.csz&&E.h===x.h&&E.cs===x.cs)return E},isCull:(E,x,I)=>E===void 0};a=Xt(Ol(a,{min:y.min,max:y.max,value:b},w))},m=e.length,f=new Array(m);for(let y=0;y<m;y++){const b=e[y],w=this._parseHeaderRangeAddress(b.address);if(w.min<0||w.max>this._maxDataIndex)throw new ke(Mi);g(w,b.update),f[y]=w}let _=!1,p=a.length;if(p>0&&a[0].min===0&&a[p-1].max===this._maxDataIndex){let y=a[0],b=!1,w=-1;for(let I=0;!b&&I<p;I++){const v=a[I],R=v.min;if(w+1!==R){b=!0;continue}const A=v.max;w=A,y.max-y.min<A-R&&(y=v)}b||(this._defaultCustomSize=y.value?.sz??-1,_=!0);const E=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize,x=[];for(let I=0;I<p;I++){const v=a[I],R=v.value;if(R===null)continue;const A=Object.keys(R);A.length!==0&&(A.length!==1||R.sz===void 0||R.sz!==null&&R.sz!==E)&&x.push(v)}a=x,p=a.length}const S=[],C=this._defaultSize;for(let y=0;y<p;y++){const b=a[y],w=b.value;if(w===null)continue;let E=!1;w.sz!==void 0&&w.sz!==C&&(E=!0),w.csz&&(E=!0),w.h&&(E=!0),w.cs&&(E=!0),E&&S.push(b)}return a=S,p=a.length,_&&d._invalidSizes(),this._updateState({headers:a,defaultCustomSize:this._defaultCustomSize,runs:f}),i.commit(),f}hasCustomFormats(){return this._hasCustomFormats}hasCustomStyles(){return this._hasStyles}hasHidden(){return this._hasHidden}getDefaultSize(){return this._defaultPxSize}getMaxSize(){return Math.ceil(this._options.maxSize()*this._options.scaleFactor())}getMinSize(){return Math.floor(this._options.minSize()*this._options.scaleFactor())}findOffset(e){return((t,n,r)=>{if(n<0)return 0;if(!t||t.length===0)return n*r;const o=t[t.length-1];if(n>o.indexMax)return o.runningOffsetMax+Math.round((n-o.indexMax-1)*r+(o.spanSize!==0?1:0));const i=t.length===1?0:F.findEqualOrGreater(t,n,c=>c.indexMax),a=t[i],l=n-a.indexMin;return a.runningOffsetMin+l*a.spanSize})(this._indexedSizes,e,this._defaultPxSize)}findIndex(e){return Math.min(Math.max(0,((t,n,r)=>{if(!t||t.length===0)return Math.floor(n/r);const o=t[t.length-1];if(n>o.runningOffsetMax)return o.indexMax+Math.ceil((n-o.runningOffsetMax)/r);let i=t.length===1?0:F.findEqualOrGreater(t,n,c=>c.runningOffsetMax);const a=t[i];if(a.spanSize===0)return Math.max(0,a.indexMin-1);const l=n-a.runningOffsetMin;return a.indexMin+Math.floor(l/a.spanSize)})(this._indexedSizes,e,this._defaultPxSize)),this._maxDataIndex)}findVisibleIndex(e){return this._lastVisibleRunsRead===e||(this._lastVisibleRunCoords=((t,n,r=Number.MAX_SAFE_INTEGER)=>{if(!t||t.length===0)return{min:n,max:n};let o=t.length-1,i=t[o];if(n>i.indexMax){const l=n-i.runningHiddenRuns;return{min:l,max:l}}o=t.length===1?0:F.findEqualOrGreater(t,n,l=>l.indexMax),i=t[o];const a=i.spanSize===0?Math.max(-1,i.indexMin-1-(t[o-1]?.runningHiddenRuns??1)):n-i.runningHiddenRuns;return{min:a,max:a+Math.min(r+1,i.spanSize===0?1:0)}})(this._indexedSizes,e,this._maxDataIndex),this._lastVisibleRunsRead=e),this._lastVisibleRunCoords}getSpanSize(e,t=e+1){return this.findOffset(t)-this.findOffset(e)}getVisibleCount(e,t){if(e>t)throw new Error("Invalid arguments.");if(e<0||t>this._maxDataIndex)throw new ke;return this._hasHidden?((n,r,o)=>{let i=o-r+1;if(n.length===0)return i;let a=n.length-1,l=n[a];if(r>l.indexMax)return i;a=n.length===1?0:F.findEqualOrGreater(n,r,u=>u.indexMax),l=n[a];let c=l.runningHiddenRuns;if(l.spanSize===0&&r<=l.indexMax){const u=l.indexMax-l.indexMin+1;i-=Math.min(u,l.indexMax-r+1)}o>l.indexMax&&a<n.length&&(a=F.findEqualOrGreater(n,o,u=>u.indexMax),l=n[Math.min(a,n.length-1)]);let h=l.runningHiddenRuns;if(l.spanSize===0&&l.indexMin<=o){const u=l.indexMax-l.indexMin+1;i-=Math.min(u,o-l.indexMin+1),h-=u}return i-=h-c,i})(this._indexedSizes,e,t):t-e+1}isSelectedAll(e){const t=this.getSelectedRuns();if(t.length===0)return!1;const n=F.findEqualOrGreater(t,e,o=>o.max),r=t[n];return!(!r||e<r.min||e>r.max)&&r.value.isSelectedAll}isSelected(e){const t=this.getSelectedRuns();if(t.length===0)return!1;const n=F.findEqualOrGreater(t,e,o=>o.max),r=t[n];return!(!r||e<r.min||e>r.max)}getSelectedRuns(){let e=this._selectionRuns;return e||(this._selection&&(e=((t,n,r)=>{let o=[];n?.ranges&&n.ranges.length>0?o=n.ranges:n?.cell&&(o=[k.cellToRange(n?.cell)]);let i=[];const a=t.getOrientation()===exports.w.Orientation.Column;for(let l=0;o&&l<o.length;l++){const c=o[l],h=a?c.colStart:c.rowStart,u=a?c.colEnd:c.rowEnd,d=a?c.rowStart:c.colStart,g=a?c.rowEnd:c.colEnd,m=a?r.rowStart:r.colStart,f=a?r.rowEnd:r.colEnd,_=d<=m&&g>=f;i=Xt(Ol(i,{min:h,max:u,value:{isSelectedAll:!1}},{onUpdate:(p,S)=>{const C=kl(p,S);return C.isSelectedAll=p?.isSelectedAll||_,C}}))}return i})(this,this._selection,this._maxSheetCoords)),e||(e=F.EmptyArray)),this._selectionRuns=e,this._selectionRuns}hiddenHeadersAt(e,t=!1){if(this._indexedSizes.length===0)return 0;let n=this._indexedSizes.length===1?0:F.findEqualOrGreater(this._indexedSizes,e,o=>o.indexMax),r=this._indexedSizes[n];return!r||r.spanSize!==0||r.indexMin>e||r.indexMax<e?0:t?e-r.indexMin+1:r.indexMax-e+1}_insertHeaders(e,t){if(this.isProtected())throw new Error(this._isColumn?Os:Bs);if(t<=0)return;const n=this._beginCommit({description:`Insert ${this._isColumn?Xn:Jn}`}),r=this._getState();let o=[...r.headers];o=Xt(((a,l,c=1)=>{const h=F.findEqualOrGreater(a,l,m=>m.max),u=a.slice(0,h),d=[],g=[];if(!a[h])return{preceding:u,modified:g,trailing:d};a[h].min>=l?d.push({...a[h],min:a[h].min+c,max:a[h].max+c}):g.push({...a[h],min:a[h].min,max:a[h].max+c});for(let m=h+1;m<a.length;m++)d.push({...a[m],min:a[m].min+c,max:a[m].max+c});return{preceding:u,modified:g,trailing:d}})(o,e,t));const i=[{min:e,max:e+t}];this._updateState({headers:o,runs:Xt(rr([...r?.runs??[],...i]))}),n.commit()}_deleteHeaders(e,t){if(this.isProtected())throw new Error(this._isColumn?Os:Bs);const n=this._beginCommit({description:`Delete ${this._isColumn?Xn:Jn}`}),r=this._getState();let o=[...r.headers];o=Xt(V0(o,e,t));const i=[{min:e,max:e+t}];this._updateState({headers:o,runs:Xt(rr([...r?.runs??[],...i]))}),n.commit()}beginCommit(e){return this._beginCommit(typeof e=="string"?{description:e}:e)}doBatch(e,t){return this._transactions.doBatch(e,typeof t=="string"?{description:t}:{description:"Update Header",...t})}isClosed(){return this._closed}close(){this._sheetRemoveListener?.(),this._emitter.close(),this._transactionsRemoveListener?.(),this._closed=!0}_getState(){return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(e)}_updateState(e){const t=this._transactions.beginCommit();try{t.updateState(this,e),this._onHeaderChange(),t.commit()}catch(n){throw t.rollback(),n}}fromJSON(e){const t=e||{};this._defaultCustomSize=t.defaultSize??-1,this._defaultCustomSize<=0&&(this._defaultCustomSize=-1),this._invalidSizes();const n=this._options.sheet.getStyles().beginPersist();try{const r=[],o=t.headers?t.headers.length:0,i=this._maxDataIndex;for(let a=0;a<o;a++){let l=t.headers[a];if(l.min>=i)continue;let c={min:l.min,max:Math.min(l.max,i)};const h={};l.sz!==void 0&&l.sz!==-1&&(h.sz=l.sz),l.h!==void 0&&(h.h=l.h),l.csz!==void 0&&(h.csz=l.csz),l.cs!==void 0&&(h.cs=l.cs),Object.keys(h).length===0&&(h.cs=!0),c.value=h,r.push(c)}this._updateState({headers:r,defaultCustomSize:this._defaultCustomSize})}finally{n.endPersist()}}toJSON(){if(this._headers.length===0&&this._defaultCustomSize===-1)return null;const e={headers:[]};if(this._defaultCustomSize!==-1&&(e.defaultSize=F.roundAccurately(this._defaultCustomSize,8)),this._headers.length===0)return e;const t=this._defaultCustomSize,n=this.getSheet().getStyles().beginPersist();for(let r=0;r<this._headers.length;r++){const o=this._headers[r],i=o.value;if(!i)continue;const a={min:o.min,max:o.max};i.sz!==void 0&&i.sz!==t&&(a.sz=F.roundAccurately(i.sz,8),i.csz!==void 0&&(a.csz=i.csz)),i.h===!0&&(a.h=i.h),Object.keys(a).length>2&&e.headers.push(a)}return n.endPersist(),e}}class Hd{constructor(e,t,n){this._c=e,this._tvTl=t,this._rsTl=n}tvTl(){return this._tvTl(this._c)}rsTl(){return this._rsTl(this._c)}getCoords(){return this._c}}const pf=s=>{let e="";const t=ci,n=s.length;for(let r=0;r<n;r++){const o=s[r];o.type==="cell"?e+=t(o.value):e+=o.value}return e},_f=(s,e=0,t=0)=>{let n="";const r=zm,o=s.length;for(let i=0;i<o;i++){const a=s[i];a.type==="cell"?n+=r(a.value,e,t):n+=a.value}return n};class xy{constructor(e,t,n){this._c=e,this._tokens=t,this._references=n||F.EmptyArray}getFormulaTextAt(e,t,n=!1){return n?pf(this._tokens):_f(this._tokens,e,t)}getTokensAt(e,t,n){let r=this._tokens;return n!==void 0&&(r=((o,i)=>{const a=o.length,l=[];if(i===void 0)return F.EmptyArray;let c=-1,h=!1;for(let u=0;!h&&u<a;u++){const d=o[u],g=d.evalIndex??Number.MAX_SAFE_INTEGER;if(c===-1){if(g!==i)continue;c=u}g>i?h=!0:l.push(d)}h=!1;for(let u=c-1;!h&&u>=0;u--){const d=o[u];(d.evalIndex??Number.MAX_SAFE_INTEGER)>i?h=!0:l.unshift(d)}return l.length>1&&l[0].type==="whitespace"&&l.shift(),l.length>1&&l[l.length-1].type==="whitespace"&&l.pop(),l})(r,n)),r=((o,i=0,a=0)=>{const l=o.length,c=new Array(l);for(let h=0;h<l;h++){const u=o[h];if(u.type!=="cell"){c[h]=u;continue}const d={...u},g={...d.value};d.value=g,c[h]=d,g.colIndex===Number.MIN_SAFE_INTEGER||g.$colIndex||(g.colIndex+=a),g.rowIndex===Number.MIN_SAFE_INTEGER||g.$rowIndex||(g.rowIndex+=i)}return c})(r,e,t),r}getReferencesAt(e,t){return((n,r=0,o=0)=>{const i=n.length,a=new Array(i);for(let l=0;l<i;l++){const c=n[l];if(typeof c=="string"||c instanceof exports.n.Known){a[l]=c;continue}const h={...c};a[l]=h,h.colStart===Number.MIN_SAFE_INTEGER||h.$colStart||(h.colStart+=o),h.rowStart===Number.MIN_SAFE_INTEGER||h.$rowStart||(h.rowStart+=r),h.colEnd===Number.MIN_SAFE_INTEGER||h.$colEnd||(h.colEnd+=o),h.rowEnd===Number.MIN_SAFE_INTEGER||h.$rowEnd||(h.rowEnd+=r)}return a})(this._references,e,t)}toJSON(){const e=this._c;return[bn(e),this.getFormulaTextAt(e.rowStart,e.colStart)]}getCoords(){return this._c}}class zi{constructor(e,t,n){this.groupId=e,this.uuid=t,this.noShift=n}onRemove(e){}getShifted(e){if(!e.after)return null;const t=this.noShift;return t?void 0:{...e.after,value:new zi(this.groupId,this.uuid,t)}}getSplit(e,t){}copyTo(e,t){return new zi(this.groupId,this.uuid,this.noShift)}canTile(e,t){return!1}}class ji{constructor(e,t,n,r,o,i,a,l,c,h){this.uuid=e,this.spatialsIds=t,this.isRanges=r,this.coords=n,this.sheet=o,this.generation=i,this.handler=a,this.handlerW=l,this.removeListener=c,this.options=h}delete(){this.removeListener()}createRangeEvent(e,t){const n=this;let r;const o=()=>{if(r)return r;const a=n.sheet,l=n.isRanges,c=n.coords;return t||!c||c.length===0?_n(a,a.getEntireRange().getCoords(),null,t):l?(r=a.getRanges(n.coords),r):(r=a.getRange(n.coords[0]),r)},i=e.trigger;return{getSource:o,trigger:i,isTransactional:e.isTransactional??!0,toString:()=>`SheetRangeEvent: ('${i}', ${o().toString()})`,timeStamp:e.timeStamp??Date.now()}}notify(e,t){const n=this.createRangeEvent(e,t),r=this.handler??this.handlerW.deref();try{r?.(n)}catch(o){console.warn(o)}this.options?.once&&this.removeListener()}processRemove(e){const t=this.spatialsIds,n=t.indexOf(e.value.uuid);console.assert(n!==-1,"invalid uuid");const r=this.coords,o=r.slice(0,n).concat(r.slice(n+1)),i=t.slice(0,n).concat(t.slice(n+1));return new ji(this.uuid,i,o,this.isRanges,this.sheet,this.generation,this.handler,this.handlerW,this.removeListener,this.options)}processShift(e){const t=this.spatialsIds.indexOf(e.value.uuid);console.assert(t!==-1,"invalid uuid");const n=[...this.coords];return n[t]={...n[t],...k.sanitizeRange(e)},new ji(this.uuid,this.spatialsIds,n,this.isRanges,this.sheet,this.generation,this.handler,this.handlerW,this.removeListener,this.options)}processSplit(e){}processMerge(e){}}const Sf=Object.freeze({coords:k.EmptyCell,topLeft:Yo.EmptyTopLeft}),Iy=Object.freeze({cell:k.EmptyCell,ranges:F.EmptyArray,rangeIndex:0}),ul=Object.freeze({selection:Iy,topLeft:Yo.EmptyTopLeft,freezePanes:Sf,showRowHeaders:!0,showColumnHeaders:!0,showRowGridlines:!0,showColumnGridlines:!0,rowHeaderStyle:exports.ISheetView.HeaderTextStyle.One,columnHeaderStyle:exports.ISheetView.HeaderTextStyle.A1,showFormulas:!1,showZeros:!0,zoomScale:100,gridLineColor:null});class dl{constructor(e){if(this._emitter=null,!e?.sheet)throw new Error("SheetView requires a sheet.");const t=new st(this);this._emitter=t,this._sheet=e.sheet,this.clear(!1),e.json&&this._fromJSON(e.json)}addListeners(e,t){return this._emitter.addListeners(e,t)}setTopLeft(e){return this._state.topLeft=Object.freeze({left:e?.left??this._state.topLeft.left,top:e?.top??this._state.topLeft.top}),this._emitter.notify("onTopLeftChange"),this}getTopLeft(){return this._state.topLeft}getFreezePanes(){return this._state.freezePanes}setFreezePanes(e){return this._state.freezePanes=this._mergeFreezePanes(e),this._emitter.notify("onFreezeSplitChange"),this}_mergeFreezePanes(e){return e?{...this._state.freezePanes,coords:{colIndex:e?.coords?.colIndex??this._state.freezePanes.coords.colIndex,rowIndex:e?.coords?.rowIndex??this._state.freezePanes.coords.rowIndex},topLeft:{left:e?.topLeft?.left??this._state.topLeft.left,top:e?.topLeft?.top??this._state.topLeft.top}}:Sf}isShowRowHeaders(){return this._state.showRowHeaders}setShowRowHeaders(e){return this._state.showRowHeaders=e,this._notifyAll(),this}isShowColumnHeaders(){return this._state.showColumnHeaders}setShowColumnHeaders(e){return this._state.showColumnHeaders=e,this._notifyAll(),this}isShowRowGridlines(){return this._state.showRowGridlines}setShowRowGridlines(e){return this._state.showRowGridlines=e,this._notifyAll(),this}isShowColumnGridlines(){return this._state.showColumnGridlines}setShowColumnGridlines(e){return this._state.showColumnGridlines=e,this._notifyAll(),this}getRowHeaderStyle(){return this._state.rowHeaderStyle}setRowHeaderStyle(e){return this._state.rowHeaderStyle=e,this._notifyAll(),this}getColumnHeaderStyle(){return this._state.columnHeaderStyle}setColumnHeaderStyle(e){return this._state.columnHeaderStyle=e,this._notifyAll(),this}getZoomScale(){return this._state.zoomScale}setZoomScale(e){return this._state.zoomScale=e,this._notifyAll(),this}isShowFormulas(){return this._state.showFormulas}setShowFormulas(e){return this._state.showFormulas=e,this._notifyAll(),this}isShowZeros(){return this._state.showZeros}setShowZeros(e){return this._state.showZeros=e,this._notifyAll(),this}getGridLineColor(){return this._state.gridLineColor}setGridLineColor(e){return this._state.gridLineColor=e,this._notifyAll(),this}setRangeSelection(e){return this._state.selection=e,this._emitter.notify("onRangeSelectionChange"),this}getRangeSelection(){return this._state.selection}getMovableSelection(){return this._movableSelection}setMovableSelection(e){const t=this._movableSelection;return this._movableSelection=Object.freeze(e??[]),F.isEqualArrays(t,this._movableSelection)||this._emitter.notify("onMovableSelectionChange"),this}selectMovables(e,t=!1){const n=new Set(this._sheet.getMovables().search());let r=null,o=!1;if(t){r=[...this._movableSelection];for(let i=e.length-1;i>=0;i--){const a=e[i];let l=r.indexOf(a);if(l!==i){if(o=!0,!n.has(a))throw new Error(`Movable ${a.getName()} not found in sheet.`);l!==-1&&r.splice(l,1),r.unshift(a)}}}else o=!F.isEqualArrays(e,this._movableSelection),r=[...e];o&&(this._movableSelection=r,this._emitter.notify("onRangeSelectionChange"),this._emitter.notify("onMovableSelectionChange"))}unselectMovables(e){const t=this._movableSelection,n=[];for(let r=0;r<t.length;r++){const o=t[r];e.indexOf(o)===-1&&n.push(o)}return t.length!==n.length&&(this._movableSelection=n,this._emitter.notify("onRangeSelectionChange"),this._emitter.notify("onMovableSelectionChange")),this}_notifyAll(){const e=this._emitter;e.notify("onRangeSelectionChange"),e.notify("onTopLeftChange"),e.notify("onFreezeSplitChange"),e.notify("onAnyChange")}toJSON(){const e={},t=Object.keys(this._state);for(let r=0;r<t.length;r++){const o=this._state[t[r]];o!=null&&o!==ul[t[r]]&&(e[t[r]]=o)}delete e.movableSelection,delete e.gridLineColor,this._state.gridLineColor instanceof Ue&&(e.gridLineColor=this._state.gridLineColor.toString()),delete e.topLeft,!this._state.topLeft||this._state.topLeft.left===0&&this._state.topLeft.top===0||(e.topLeft={left:this._state.topLeft.left??0,top:this._state.topLeft.top??0}),delete e.selection;const n=this._state.selection;if(n){let r={};!n.cell||n.cell.colIndex===0&&n.cell.rowIndex===0||(r.cell=rs(n.cell)),n.ranges&&n.ranges.length>0&&(r.ranges=_c(n.ranges),n.rangeIndex!==void 0&&n.rangeIndex!==-1&&n.rangeIndex!==0&&(r.rangeIndex=n.rangeIndex)),Object.keys(r).length>0&&(e.selection=r)}if(delete e.freezePanes,this._state.freezePanes&&(this._state.freezePanes.coords.colIndex!==0||this._state.freezePanes.coords.rowIndex!==0)){const r={};this._state.freezePanes.coords.colIndex!==0&&(r.c=this._state.freezePanes.coords.colIndex),this._state.freezePanes.coords.rowIndex!==0&&(r.r=this._state.freezePanes.coords.rowIndex),this._state.freezePanes.topLeft.left!==0&&(r.x=this._state.freezePanes.topLeft.left),this._state.freezePanes.topLeft.top!==0&&(r.y=this._state.freezePanes.topLeft.top),e.freezePanes=r}return Object.keys(e).length===0?null:e}_fromJSON(e){let t=JSON.parse(JSON.stringify(e||{}));t?.zoomScale&&(t.zoomScale=F.roundAccurately(parseFloat(e.zoomScale),2));const n=r=>{const o=this._sheet.getRange(r).getBounds(),i=(t.zoomScale??100)/100;return{x:o.x*i,y:o.y*i,width:o.width*i,height:o.height*i}};if(typeof t?.gridLineColor=="string"&&(this._sheet?.getStyles()?t.gridLineColor=this._sheet.getStyles().parseColor(e.gridLineColor):console.warn("Style was created with no styles so gridLineColor can't be parsed.")),t.topLeft)if(typeof t.topLeft=="string"){const r=n(Fr(t.topLeft));t.topLeft={left:r.x,top:r.y}}else t.topLeft=Object.freeze({left:t.topLeft?.left??t?.x??0,top:t.topLeft?.top??t?.y??0});if(t.selection){let r=Fr(t.selection.cell??"A1");if(t.selection.cell=r,t.selection.ranges){let o=Math.max(0,Math.min(t.selection.rangeIndex??t.selection.ranges?.length-1,t.selection.ranges?.length-1));t.selection.rangeIndex=o;let i=!1;for(let a=0;a<t.selection.ranges.length;a++){const l=Ct(t.selection.ranges[a]);t.selection.ranges[a]=l,a===o&&r&&!k.isCellWithinRange(r,l)&&(i=!0)}if(i)for(let a=0;i&&a<t.selection.ranges.length;a++)k.isCellWithinRange(r,t.selection.ranges[a])&&(i=!1,t.selection.rangeIndex=a);i&&(t.selection.ranges.push(k.cellToRange(r)),t.selection.rangeIndex=t.selection.ranges.length-1)}else delete t.selection.rangeIndex}if(t.freezePanes){const r=t.freezePanes;if(typeof r.coords=="string"&&(r.coords=Fr(r.coords)),typeof r.topLeft=="string"){const o=Fr(r.topLeft),i=n({colIndex:o.colIndex+1,rowIndex:o.rowIndex+1}),a=n({colIndex:(r?.coords?.colIndex??-1)+1,rowIndex:(r?.coords?.rowIndex??-1)+1});r.topLeft={left:0,top:0},t.topLeft||(t.topLeft={top:0,left:0}),o.colIndex>0&&(r.topLeft.left=t.topLeft?.left??0,t.topLeft.left=i.x-a.x+r.topLeft.left),o.rowIndex>0&&(r.topLeft.top=t.topLeft?.top??0,t.topLeft.top=i.y-a.y+r.topLeft.top)}t.freezePanes={coords:{colIndex:r?.coords?.colIndex??t.freezePanes?.c??0,rowIndex:r?.coords?.rowIndex??t.freezePanes?.r??0},topLeft:{left:r?.topLeft?.left??t.freezePanes?.x??0,top:r?.topLeft?.top??t.freezePanes?.y??0}}}this.update(t)}clear(e=!0){return this._state={...ul},this._movableSelection=Object.freeze([]),e&&this._notifyAll(),this}update(e){return this._state={...ul,...this._state,...e},this._state.freezePanes=this._mergeFreezePanes(this._state.freezePanes),this._state.zoomScale=Math.min(400,Math.max(10,this._state.zoomScale)),this._notifyAll(),this}get isISheetView(){return!0}}async function Vd(){const{getCrypto:s}=await Promise.resolve().then(()=>require("./B9v3u3hwmPue1Crf.cjs"));return s()}const $d=async(s,e,...t)=>{const n=Ry(...t);return s.subtle.digest(e,n)},Ry=(...s)=>{const e=s.reduce((r,o)=>r+o.byteLength,0),t=new Uint8Array(e);let n=0;return s.forEach(r=>{t.set(new Uint8Array(r),n),n+=r.byteLength}),t.buffer},Gd=s=>{const e=new Uint8Array(s);let t="";for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t)};class dn{static{this.DefaultAlgo="SHA-512"}static{this.DefaultSpinCount=1e5}static async generateSaltAndHash(e,t=dn.DefaultAlgo,n=dn.DefaultSpinCount){if(!e)return null;const r=(await Vd()).getRandomValues(new Uint8Array(16)),o=Gd(r.buffer);return{salt:o,hash:await dn._convertPasswordToHash(e,o,t,n)}}static async verifyPassword(e,t,n=dn.DefaultAlgo,r=dn.DefaultSpinCount){if(!e||!t)throw new Dt;return((o,i)=>{const a=o.length,l=i.length;let c=a===l?0:1;for(let h=0;h<Math.max(a,l);h++)c|=o.charCodeAt(h%a)^i.charCodeAt(h%l);return c===0})(await dn._convertPasswordToHash(e,t.salt,n,r),t.hash)}static async _convertPasswordToHash(e,t,n,r){const o=await Vd();n=n.toUpperCase();const i=(c=>{const h=new ArrayBuffer(2*c.length),u=new DataView(h);for(let d=0;d<c.length;d++)u.setUint16(2*d,c.charCodeAt(d),!0);return new Uint8Array(h)})(e),a=(c=>{const h=atob(c),u=new Uint8Array(h.length);for(let d=0;d<h.length;d++)u[d]=h.charCodeAt(d);return u.buffer})(t);let l=await $d(o,n,a,i.buffer);for(let c=0;c<r;c++){const h=new Uint32Array([c]).buffer;l=await $d(o,n,l,h)}return Gd(l)}}class wf{constructor(e,t=!1){this._emitter=null,this._emitter=new st(this),this.fromJSON(e),this._isReadOnly=t}async lock(e,t,n,r){if(this._isReadOnly)return this;if(this.isLocked()&&!this._isPaused)throw new Error("Cannot lock an already locked object. Use unlock first.");try{this._validatePassword()}catch{throw new Error("A password is already set. Unlock first to change.")}let o;if(t){const i=await dn.generateSaltAndHash(t,n,r);o={salt:i.salt,hash:i.hash},n&&(o.algorithm=n),r&&(o.spinCount=r)}else o=null;return e=e??{},this._updateProperties(e),this._properties=e,this._password=o,this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),this}async unlock(e){if(this._isReadOnly)throw new Error("Cannot unlock a readonly workbook.");return await this._validatePassword(e),this._clearProperties(),this._password=null,this._identities=null,this._password=null,this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),this}checkPassword(e){return this._validatePassword(e)}hasPassword(){return this._password!==null}async pause(e){return this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),await this._validatePassword(e),this._password&&(this._isPaused=!0),this}resume(){return this._isPaused=!1,this}isPaused(){return this._isPaused}isLocked(){return this._properties!==null&&!this._isPaused}isReadOnly(){return this._isReadOnly}async _validatePassword(e){const t=this._password;if(!(e&&e.length!==0||t&&t.hash))return!0;if(!e)throw new Error("Password is required.");if(!await dn.verifyPassword(e,{salt:t.salt,hash:t.hash},t.algorithm,t.spinCount))throw new Error("Invalid password.");return!0}getProperties(){return this._properties}_isPropertyAllowed(e){if(this._isReadOnly)return!1;if(!this.isLocked())return!0;const t=this._properties[e];return typeof t=="boolean"&&t}_updateProperties(e){this._properties={...e,...this._properties??{}}}_clearProperties(){this._properties=null}addListeners(e,t){return this._emitter.addListeners(e,t)}fromJSON(e){this._password=null,this._identities=null,this._isPaused=!1,this._properties=null,this._fromJSON(e??null),e&&(e.password&&(this._password=e.password),e.identities&&(this._identities=e.identities))}_fromJSON(e){}_toJSON(e){return e}toJSON(){if(!this._properties)return null;let e={};return e=this._toJSON(e)??{},this._password&&(e.password=this._password),this._identities&&(e.identities=this._identities),e}}const Ay=Object.freeze({selectLockedCells:!0,selectUnlockedCells:!0,autoFilter:!1,deleteColumns:!1,deleteRows:!1,formatCells:!1,formatColumns:!1,formatRows:!1,insertColumns:!1,insertHyperlinks:!1,insertRows:!1,objects:!1,pivotTables:!1,scenarios:!1,sheet:!1,sort:!1,verifier:null});class Ud extends wf{isAutoFilterAllowed(){return this._isPropertyAllowed("autoFilter")}isDeleteColumnsAllowed(){return this._isPropertyAllowed("deleteColumns")}isDeleteRowsAllowed(){return this._isPropertyAllowed("deleteRows")}isFormatCellsAllowed(){return this._isPropertyAllowed("formatCells")}isFormatColumnsAllowed(){return this._isPropertyAllowed("formatColumns")}isFormatRowsAllowed(){return this._isPropertyAllowed("formatRows")}isInsertColumnsAllowed(){return this._isPropertyAllowed("insertColumns")}isInsertHyperlinksAllowed(){return this._isPropertyAllowed("insertHyperlinks")}isInsertRowsAllowed(){return this._isPropertyAllowed("insertRows")}isObjectsAllowed(){return this._isPropertyAllowed("objects")}isPivotTablesAllowed(){return this._isPropertyAllowed("pivotTables")}isScenariosAllowed(){return this._isPropertyAllowed("scenarios")}isSortAllowed(){return this._isPropertyAllowed("sort")}isSelectLockedCellsAllowed(){return!1}isSelectUnlockedCellsAllowed(){return!1}_updateProperties(e){super._updateProperties(e),this._properties=e}_clearProperties(){super._clearProperties(),this._properties=null}_fromJSON(e){super._fromJSON(e),this._properties=e}_toJSON(e){let t=this._properties;if(t){e={...e,...t};const n=Object.keys(t);for(let r=0;r<n.length;r++){const o=t[n[r]];o!=null&&o!==Ay[n[r]]&&(e[n[r]]=o)}}return super._toJSON(e)}}class ss{constructor(e,t,n){this._coords=Object.freeze(e),this._sheet=t,this._readOnly=n?.readOnly??null}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new ss(e,this._sheet,n)}_createRange(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new is(e,this._sheet,n)}_validateWrite(){const e=this._readOnly;if(e)throw new Error(e)}getCoords(){return this._coords}[Symbol.iterator](){const e=this.entries({excludeCellDetails:!0});return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}entries(e){const t=this.getCoords(),n=e?.reverse??!1;let r=n?t.length-1:0;const o=this;let i=o._createRange(t[r]),a=i.entries(e),l=a.next();return{next(){let c=l;do{if(l.done){if(r=n?r-1:r+1,r>=t.length||r<0)return l=Re,c;i=o._createRange(t[r]),a=i.entries(e)}l=a.next()}while(l.done);return c},[Symbol.iterator](){return this}}}async select(e){const t=await this._sheet._autoSelect(e??!0,De(this.getCoords()));return this._createRanges(t)}calculate(){const e=this.getCoords();return this._sheet._calculate(e),this}addListener2(e,t){return this._sheet._addRangesListeners2(this.getCoords(),e,t,!0)}addListener(e,t){return this._sheet._addRangesListeners(this.getCoords(),e,t)}find(e,t){return this._sheet._find(this.getCoords(),e,t)}getFlattened(e){const t=this.getCoords();if(t.length===1)return this._createRanges(t,e);const n=e?.orientations??exports.w.Orientations.Both,r=n===exports.w.Orientations.Both,o=r?Number.MAX_SAFE_INTEGER:1,i=n===exports.w.Orientations.Row?exports.w.Orientation.Column:exports.w.Orientation.Row;let a=Pl(t,o,i);if(r){const l=Pl(t,o,exports.w.Orientation.Column);l.length<a.length&&(a=l)}return this._createRanges(a,e)}getVisible(e){const t=this._sheet._getVisible(this.getCoords(),e);return t&&t.length!==0?this._createRanges(t,e):null}getFixed(e){const t=[],n=this.getCoords();for(let r=0;r<n.length;r++)t.push(of(n[r],e));return this._createRanges(t,e)}autoFit(e){return this._validateWrite(),this._sheet._autoFit(this.getCoords(),e),this}clear(e,t){return this._validateWrite(),this._sheet._clear(this.getCoords(),e,t),this}updateStyle(e,t){return this._validateWrite(),this._sheet._updateStyles(this.getCoords(),e,t),this}getStyleUpdater(){return this._sheet._getStyleUpdater(this.getCoords())}merge(e){return this._validateWrite(),this._sheet._merge(this.getCoords(),e),this}unmerge(e){return this._validateWrite(),this._sheet._unmerge(this.getCoords(),e),this}getMerges(){return this._sheet._getMerges(this.getCoords(),this._options?.excludeHidden??!1)}insert(e,t){return this._validateWrite(),this._sheet._insertCells(this.getCoords(),e,t),this}delete(e,t){return this._validateWrite(),this._sheet._deleteCells(this.getCoords(),e,t),this}async insertFrom(e,t){this._validateWrite();const n=await this._sheet._insertFrom(this.getCoords(),e,t);return n?this._createRanges([n]):null}async copyFrom(e,t){const n=await this._sheet._copyFrom(this.getCoords()[0],e,t);return n?this._createRanges([n]):null}isInvalidAny(){const e=this.getCoords();if(!e||e.length===0)return!0;for(let t=0;t<e.length;t++)if(e[t]===null)return!0;return!1}getSnapshot(e){return this._sheet._getSnapshot(this.getCoords(),e)}getEntireRows(e,t){return this._createRanges(Oi(this.getCoords(),this._sheet._entireCoords,exports.w.Orientation.Column,e),t)}getEntireColumns(e,t){return this._createRanges(Oi(this.getCoords(),this._sheet._entireCoords,exports.w.Orientation.Row,e),t)}getDefaultShiftOrientation(){return this._sheet._getDefaultShiftOrientation(this.getCoords()[0])}getCount(){return this.getCoords()?.length??0}getCounts(e){return this._sheet._contentCounts(this.getCoords(),e,this._options?.excludeHidden??!1)}isContentful(){return this._sheet._isContentful(this.getCoords(),this._options?.excludeHidden??!1)}getRowCount(){return ld(this.getCoords(),exports.w.Orientation.Row)}getColumnCount(){return ld(this.getCoords(),exports.w.Orientation.Column)}isEntireRowsAny(){return qo(this.getCoords(),this._sheet._entireCoords,!1)}isEntireColumnsAny(){return Jo(this.getCoords(),this._sheet._entireCoords,!1)}isEntireRows(){return qo(this.getCoords(),this._sheet._entireCoords,!0)}isEntireColumns(){return Jo(this.getCoords(),this._sheet._entireCoords,!0)}isOverlapping(){return ko(this.getCoords())}at(e){const t=this.getCoords();if(e<0||e>t.length-1)throw new ke;return this._createRange(t[e])}isReadOnly(){return this._readOnly!==null}isInvalid(){return!1}getA1(){return Dm(this.getCoords(),this._sheet._entireCoords,pn,Hn)}getSource(){return this._sheet}doBatch(e,t){return this._sheet.doBatch(n=>e(n),typeof t=="string"?t:{description:"Ranges Update",...t})}get[Symbol.toStringTag](){return"[SheetRanges]"}toString(){return this.getA1()}get isICellRanges(){return!0}}class is{constructor(e,t,n){this._coords=Object.freeze(e),this._sheet=t,this._readOnly=n?.readOnly??null}getCoords(){return this._coords}_createRange(e,t){const n=this._sheet;if(!e)return _n(n,n._entireCoords);if(n._validateCoords(e),n._closed)return _n(null,n._entireCoords,e);let r=this._options;return t&&(r={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new is(e,this._sheet,r)}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new ss(e,this._sheet,n)}_deriveRanges(e,t){const n=this.getCoords();let r=n;return t&&(r=t(n),!r)?null:this._createRanges(r,e)}_deriveRange(e,t,n){if(!e)return this;let r=this._sheet._rangeToCoords(e);if(!r)return this;const o=this.getCoords();if(Oo(r,o))return this;if(n){const l=n(r,o);if(!l)return this;r={...o,...l}}var i,a;return i=r,(a=o)&&(a.$colStart===void 0?delete i.$colStart:i.$colStart=a.$colStart,a.$rowStart===void 0?delete i.$rowStart:i.$rowStart=a.$rowStart,a.$colEnd===void 0?delete i.$colEnd:i.$colEnd=a.$colEnd,a.$rowEnd===void 0?delete i.$rowEnd:i.$rowEnd=a.$rowEnd),this._createRange(r,Cn(this._options?.getOptions,t))}_validateMaxSize(e=5e4){const t=this.getCoords(),n=this._sheet,r=n._colHeaders.getVisibleCount(t.colStart,t.colEnd);if(n._rowHeaders.getVisibleCount(t.rowStart,t.rowEnd)*r>e)throw new Error(Vm(e))}[Symbol.iterator](){const e=this.entries({excludeCellDetails:!0});return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}entries(e){const t=this.getCoords();let n=t;const r=this._sheet;if(e?.address){const i=r._rangeToCoords(e?.address);if(!i)throw new Error(Go(e?.address));if(n=k.intersectRanges(i,t),!n)return Xe}n.colEnd<n.colStart&&(n.colStart=t.colStart,n.colEnd=t.colEnd),n.rowEnd<n.rowStart&&(n.rowStart=t.rowStart,n.rowEnd=t.rowEnd);const o=this._options?.excludeHidden??!1;return r._cellIterator({excludeHidden:o,...e,includeRangeTypes:!e?.excludeCellDetails,bounds:n})}forEach(e,t){if(!e)return;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value,i=e(o.value,o.context);if(i)return i.break;r=n.next()}}_validateWrite(){const e=this._readOnly;if(e)throw new Error(e)}updateCells(e,t,n){this._validateWrite();const r=this.getCoords();n||(n=r);const o=this._sheet,i=o._isDataColumn,a={majorStart:i?r.colStart:r.rowStart,majorEnd:i?r.colEnd:r.rowEnd,minorStart:i?r.rowStart:r.colStart,minorEnd:i?r.rowEnd:r.colEnd},l=(t?.orientation??exports.w.Orientation.Row)===exports.w.Orientation.Column!==i,c=Ii(Array.isArray(e)?e:[[e]],l,a);return o._updateTuples(c,{description:t?.description??`Set ${k.isSingleCell(n)?"Cell":"Range"} ${pn(n,o._entireCoords)}`,...t},null,{isCell:!0}),this}setValue(e,t){if(Array.isArray(e))throw new Error("'setValue' expects a single value; when working with an array use 'setValue'.");return this._setValueOrValues(e,t)}setValues(e,t){if(!Array.isArray(e))throw new Error("'setValues' expects a 2d array; when working with a single value use 'setValue'.");return this._setValueOrValues(e,t)}_setValueOrValues(e,t){this._validateWrite();let n=this.getCoords(),r=this;const o=this._sheet,i=o._isDataColumn,a=(t?.orientation??exports.w.Orientation.Row)===exports.w.Orientation.Column,l=Array.isArray(e);if(t?.skipBoundsCheck&&l){const d=e;let g=Math.max(0,d.length-1),m=0;for(let S=0;S<d.length;S++)m=Math.max(m,d[S].length-1);const f=a?n.colStart:n.rowStart,_=a?n.rowStart:n.colStart,p={...n,colEnd:a?f+g:_+m,rowEnd:a?_+m:f+g};k.isEqualRanges(p,n)||(n=p,r=this._deriveRange(p,t))}const c={majorStart:i?n.colStart:n.rowStart,majorEnd:i?n.colEnd:n.rowEnd,minorStart:i?n.rowStart:n.colStart,minorEnd:i?n.rowEnd:n.colEnd},h=a!==i;let u=null;return u=l?Ii(Array.isArray(e)?e:[[e]],h,c):ti(e,c,i),o._updateTuples(u,{description:t?.description??`Set ${k.isSingleCell(n)?"Value":"Values"} ${pn(n,o._entireCoords)}`,...t}),r}getValues(e){this._validateMaxSize(e?.maxSize);const t=this.getCoords(),n=this._sheet;return Ja(n._cellIterator.bind(this._sheet),t,!1,e)}getValue(e){const t=this.getCoords();return this._sheet._getScalar(t.rowStart,t.colStart,e?.asJSDate)}calculate(e){return this._sheet._calculate([this.getCoords()],{full:e}),this}getCells(e){this._validateMaxSize(e?.maxSize);const t=this.getCoords(),n=this._sheet;return Ja(n._cellIterator.bind(this._sheet),t,!0,e)}getCell(){const e=this.getCoords(),t=this._sheet,n=Ja(t._cellIterator.bind(this._sheet),{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colStart,rowEnd:e.rowStart},!0,null);return n.length===0?t._emptyCell:n[0][0]}async select(e){const t=this._sheet,n=await t._autoSelect(e??!0,De([this.getCoords()]));return this._createRange(n[0])}find(e,t){return this._sheet._find([this.getCoords()],e,t)}getFixed(e){return this._createRange(of(this.getCoords(),e))}getSurrounding(e){const t=this._sheet;return this._createRange(t._surroundingRegion(this.getCoords(),e))}getExtended(e,t){let n=null;const r=this.getCoords();switch(e){case exports.w.Direction.Up:n={colIndex:r.colStart,rowIndex:r.rowStart};break;case exports.w.Direction.Down:n={colIndex:r.colStart,rowIndex:r.rowEnd};break;case exports.w.Direction.Left:n={colIndex:r.colStart,rowIndex:r.rowStart};break;case exports.w.Direction.Right:n={colIndex:r.colEnd,rowIndex:r.rowStart}}const o=this._sheet,i=t?o._cellToCoords(t):n;if(!k.isCellWithinRange(i,r))throw new Error("Invalid cell.");let a=o._extendRange(e,i);return a=k.unionRanges(r,a),this._createRange(a)}getEntireRows(e,t){const n=this._sheet;return this._createRange(Oi([this.getCoords()],n._entireCoords,exports.w.Orientation.Column,e)[0],t)}getEntireColumns(e,t){const n=this._sheet;return this._createRange(Oi([this.getCoords()],n._entireCoords,exports.w.Orientation.Row,e)[0],t)}getRowHeaders(e){const t=this.getCoords();return this._sheet._rowHeaders.getRange(t,e)}getColumnHeaders(e){const t=this.getCoords();return this._sheet._colHeaders.getRange(t,e)}getDifferences(e,t){return this._deriveRanges(t,n=>{const r=this._sheet,o=r._rangeToCoords(e),i=jl(n,o,exports.w.Orientation.Row);return r._getVisible(i,t)})}getIntersect(e,t){return this._deriveRange(e,t,(n,r)=>k.intersectRanges(n,r))}getUnion(e,t){return this._deriveRange(e,t,(n,r)=>k.unionRanges(n,r))}getResizeTo(e,t,n){if(t=t??0,(e=e??0)<0||t<0)throw new Error("Invalid range. The Range must be at a size of at least 1x1'.");const r=this.getCoords();return this._deriveRange({colStart:r.colStart,rowStart:r.rowStart,colEnd:t+r.colStart-1,rowEnd:e+r.rowStart-1},n)}getResizeBy(e,t,n){e=e??0,t=t??0;const r=this.getCoords();return this._deriveRange({colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd+t,rowEnd:r.rowEnd+e},n)}getOffsetTo(e,t,n){const r=this.getCoords(),o=t,i=e,a={colStart:o,rowStart:i,colEnd:r.colEnd-r.colStart+o,rowEnd:r.rowEnd-r.rowStart+i};return this._deriveRange(a,n)}getOffsetBy(e,t,n){const r=this.getCoords(),o=r.colStart+e,i=r.rowStart+t,a={colStart:o,rowStart:i,colEnd:r.colEnd-r.colStart+o,rowEnd:r.rowEnd-r.rowStart+i};return this._deriveRange(a,n)}getUsedRange(e){const t=this._sheet._getUsedCoords(e);if(!t)return null;const n=k.intersectRanges(t,this.getCoords());return n?this._deriveRange(n,e):null}isEmpty(){const e=this._sheet._getUsedCoords();return e?!k.intersectRanges(e,this.getCoords()):!0}getColumnStart(){return this.getCoords().colStart}getRowStart(){return this.getCoords().rowStart}getColumnEnd(){return this.getCoords().colEnd}getRowEnd(){return this.getCoords().rowEnd}getColumnCount(){const e=this.getCoords();return e.colEnd-e.colStart+1}getRowCount(){const e=this.getCoords();return e.rowEnd-e.rowStart+1}getVisible(e){return this._deriveRanges(e,t=>this._sheet._getVisible([t],e))}isContentful(e){return this._sheet._isContentful([this.getCoords()],e,this._options?.excludeHidden??!1)}getCounts(e){return this._sheet._contentCounts([this.getCoords()],e,this._options?.excludeHidden??!1)}getCount(e){return this._sheet._getCount([this.getCoords()],e,this._options?.excludeHidden??!1)}isEntireRows(){const e=this._sheet;return qo([this.getCoords()],e._entireCoords,!0)}isEntireColumns(){const e=this._sheet;return Jo([this.getCoords()],e._entireCoords,!0)}isEntireRange(){const e=this.getCoords(),t=this._sheet;return Jo([e],t._entireCoords,!0)&&qo([e],t._entireCoords,!0)}getWidth(){const e=this._coords;return e.colEnd-e.colStart+1}getHeight(){const e=this._coords;return e.rowEnd-e.rowStart+1}get size(){const e=this._coords;return e.colEnd-e.colStart+1*(e.rowEnd-e.rowStart+1)}getBounds(){return this._sheet._getBoundsAtCoords(this.getCoords())}isInvalid(){return!1}getDefaultShiftOrientation(){return this._sheet._getDefaultShiftOrientation(this.getCoords())}getDefaultSortCriteria(e,t){return this._sheet._getDefaultSortCriteria(this.getCoords(),e,t)}getMerges(){return this._sheet._getMerges([this.getCoords()],this._options?.excludeHidden??!1)}getSnapshot(e){return this._sheet._getSnapshot([this.getCoords()],e)}isReadOnly(){return this._readOnly!==null}addListener2(e,t){return this._sheet._addRangesListeners2([this.getCoords()],e,t,!1)}addListener(e,t){return this._sheet._addRangesListeners([this.getCoords()],e,t)}getSource(){return this._sheet}autoFill(e,t){this._validateWrite();const n=this._sheet,r=n._rangeToCoords(e,()=>[],!0);return n._autoFill(this.getCoords(),r,t)?this._createRange(r):this}autoFit(e){return this._validateWrite(),this._sheet._autoFit([this.getCoords()],e),this}clear(e,t){return this._validateWrite(),this._sheet._clear([this.getCoords()],e,t),this}setHyperlink(e,t){return this._validateWrite(),this._sheet._setHyperlinks([this.getCoords()],e,t),this}setComments(e,t){return this._validateWrite(),this._sheet._setComments([this.getCoords()],e,t),this}setFormula(e,t){return this._validateWrite(),this._sheet._setFormula([this.getCoords()],e,t),this}updateStyle(e,t){return this._validateWrite(),this._sheet._updateStyles([this.getCoords()],e,t),this}getStyleUpdater(){return this._sheet._getStyleUpdater([this.getCoords()])}merge(e){return this._validateWrite(),this._sheet._merge([this.getCoords()],e),this}unmerge(e){return this._validateWrite(),this._sheet._unmerge([this.getCoords()],e),this}insert(e,t){return this._validateWrite(),this._sheet._insertCells([this.getCoords()],e,t),this}async insertFrom(e,t){this._validateWrite();const n=this._sheet,r=await n._insertFrom([this.getCoords()],e,t);return r?this._createRange(r):null}async copyFrom(e,t){this._validateWrite();const n=this._sheet,r=await n._copyFrom(this.getCoords(),e,t);return r?this._createRange(r):null}delete(e,t){return this._validateWrite(),this._sheet._deleteCells([this.getCoords()],e,t),this}sort(e){this._validateWrite();const t=this.getCoords(),n=this._sheet._sort(t,e);return k.isEqualRanges(n,t)?this:this._createRange(n)}doBatch(e,t){return this._sheet.doBatch(n=>e(n),typeof t=="string"?t:{description:"Range Update",...t})}startIncrementalUpdates(e){return this._sheet._createIncrementalUpdater(e,this)}getA1(){const e=this._sheet;return pn(this.getCoords(),e._entireCoords)}get[Symbol.toStringTag](){return"[SheetRange]"}toString(){const e=this._sheet;return pn(this.getCoords(),e._entireCoords)}get isICellRange(){return!0}}const My=Math.pow(2,14),Ty=Math.pow(2,20),qd=s=>`${s}`,Jd=s=>Pt(s),Xd=s=>`${s+1}`;let Fy=0;const Kd=()=>[];let Ny=0;class Gr{constructor(e){this._lastTransactionUUID=null,this._emitter=null,this._initializing=!0,this._emitterMovables=null,this._rangesListenerSorted=null,this._lastCellDecoded={address:null,coords:null},this._lastCellSelected={coords:null,cell:null},this._lastCellRead={coords:null,cell:null},this._lastValueRead={range:null,isDateOrTime:null},this._lastGetRangeRead={},this._lastUsedCoordsRead={coords:null,range:null},this._lastActiveRead={selection:null,range:null,ranges:null},this._lastRangeRead={address:null,range:null,ranges:null},this._isDataColumn=!0,this._isDate1904=!1,this._colHeaders=null,this._colHeadersShiftCallback=null,this._colHeadersListener=null,this._colHeadersRemoveListener=null,this._rowHeaders=null,this._rowHeadersShiftCallback=null,this._rowHeadersListener=null,this._rowHeadersRemoveListener=null,this._closed=!1;const t=Object.freeze({...e});rc._validate(!0),this._transactions=t.transactions??new Lt,this._ownTransactions=!t.transactions;const n=this._beginCommit({description:"New Sheet"}),r=this;try{this._entireCoords=Object.freeze({colStart:0,rowStart:0,colEnd:(t.maxColumns??My)-1,rowEnd:(t.maxRows??Ty)-1}),this._strings=t.strings??new Ki,this._ownStrings=!t.strings;const o=t.styles??new Xr;this._styles=o,this._ownStyles=!t.styles,this._names=t.names??new gf({addressToRanges:a=>r.getRanges(a),getCurrentScope:()=>r.getName(),isReadOnly:()=>r._options.readonly??!1,transactions:r._transactions}),this._ownNames=!t.names,this._namesRemoveListener=this._names.addListeners({onCollectionChange:a=>{r._calculateFull()}},{transactional:!1}),this._calculation=t.calculation??new vc({getNamed:(a,l)=>{Yd.address=a,Yd.scope=l;const c=this._names.search({address:a,scope:l});return c&&c.length!==0?c[0].getRanges().getCoords():null},getSheetIndex:a=>a===void 0||a===r.getName()?1:0,getSheetCount:()=>1,isDate1904:()=>r.isDate1904(),strings:r._strings,transactions:r._transactions}),this._ownsCalculation=!t.calculation,this._normalStyleRanged=o.getNamed(exports.IStyle.BuiltInName.Normal).getRanged(),this._resources=t.resources??new Cc,this._ownResources=!t.resources;const i=async()=>{this._ownsCalculation&&await this._calculation.start(),this._starting=null};this._starting=i(),t.container?.setNameChangeCallback&&t.container.setNameChangeCallback(()=>{r._emitter.notify("onNameChange");const a=this._getState().rangesListenerMap,l=new Map;a.forEach((h,u)=>{l.set(u,{beforeState:h,afterState:h})});const c=this._beginCommit({description:"Set Name"});c.updateState(r,{}),c.commit({viewAfter:{ranges:[r._entireCoords],listeners:l},forceAmend:!0}),r._calculateFull()}),t.container?.setVisibilityCallback&&t.container.setVisibilityCallback(()=>{r._emitter.notify("onVisibilityChange")}),t.container?.setIndexCallback&&t.container.setIndexCallback(()=>{r._calculateFull()}),this._movables=new uy(this._addMovable.bind(this),this._searchMovables.bind(this),()=>{const a=r._getState();return a?a.movableMapModel?.size??0:0},this._updateSelectedMovables.bind(this),(a,l)=>this._emitterMovables.addListeners(a,l),this._addImage.bind(this)),this._emitterMovables=new st(this._movables,this._transactions),this._tables=new _y(this._addTable.bind(this),(a,l,c)=>{const h=a?this._rangeToCoords(a):this._entireCoords;return r._getRangedEntries("tableSpatial",[h],{excludeHidden:l,fullyContained:c,onEntry:u=>u.model})},a=>{const l=r._getState();return l?l.tableMapName.get(a.toLocaleLowerCase()):null}),this._conditionals=new Cy(this._addConditional.bind(this),(a,l,c)=>{const h=a?this._rangeToCoords(a):this._entireCoords,u=new Set;return r._getRangedEntries("conditionalSpatial",[h],{excludeHidden:l,fullyContained:c,onEntry:d=>{u.add(d.getModel())}}),Array.from(u)}),this._isDate1904=t.date1904??!1,this._options=t,this._emitter=new st(this,this._transactions),this._entireRange=this.getRange(this._entireCoords),this._initState(),t?.container?.beforeFromJSON?.(this),t.json&&this._fromJSON(t.json),n.commit({viewAfter:{initial:!0,skipProtectionCheck:!0}})}catch(o){throw n.rollback(),o}this._initializing=!1}_createRange(e,t,n=null){if(!e)return _n(this,this._entireCoords);if(this._validateCoords(e),this._closed)return _n(null,this._entireCoords,e);n===null&&this._options.readonly&&(n="Readonly sheet");let r=null;return(t||n)&&(r={getOptions:t,readOnly:n}),new is((o=>{if(!o)return null;const i={colStart:o.colIndex??o.colStart??0,rowStart:o.rowIndex??o.rowStart??0,colEnd:o.colIndex??o.colEnd??0,rowEnd:o.rowIndex??o.rowEnd??0};return(o.$colStart||o.$colIndex)&&(i.$colStart=!0),(o.$colEnd||o.$colIndex)&&(i.$colEnd=!0),(o.$rowStart||o.$rowIndex)&&(i.$rowStart=!0),(o.$rowEnd||o.$rowIndex)&&(i.$rowEnd=!0),i})(e),this,r)}_createRanges(e,t,n=null){let r=null;return n===null&&this._options.readonly&&(n="Readonly sheet"),(t||n)&&(r={getOptions:t,readOnly:n}),new ss(e,this,r)}getRange(e,t){let n=!t&&e&&(e.rowStart!==void 0||typeof e=="string");if(n){if(typeof e=="string"){if(this._lastRangeRead.address===e)return this._lastRangeRead.range}else if(e.rowStart!==void 0&&Oo(e,this._lastRangeRead.address))return this._lastRangeRead.range}const r=this._rangesToCoords(e);if(r.length>1)throw new Error(jm);const o=this._createRange(r[0],t);return n&&(this._lastRangeRead.address={...e},this._lastRangeRead.range=o),o}getRanges(e,t){if(!e)throw new Error(Lr);const n=this._rangesToCoords(e);if(n.length===0)throw this._createRangeError(e);return this._createRanges(n,t)}getSelectedRange(e){const t=this.getSelection().getCoords();if(!e&&this._lastActiveRead.selection===t&&this._lastActiveRead.range)return this._lastActiveRead.range;const n=Ar(t),r=this.getRange(n[0]);return e||(this._lastActiveRead.selection=t,this._lastActiveRead.range=r,this._lastActiveRead.ranges=this.getRanges(n)),r}getSelectedRanges(e){const t=this.getSelection().getCoords();if(!e&&this._lastActiveRead.selection===t&&this._lastActiveRead.ranges)return this._lastActiveRead.ranges;const n=Ar(t),r=this.getRanges(n,e);return e||(this._lastActiveRead.selection=t,this._lastActiveRead.ranges=r,this._lastActiveRead.range=this.getRange(n[0])),r}getEntireRange(e){return e?this.getRange(this._entireCoords,e):this._entireRange}getUsedRange(e){const t=this._getUsedCoords(),n=t?this.getRange(t,e):null;return e||(this._lastUsedCoordsRead.coords=t,this._lastUsedCoordsRead.range=n),n}_cellToCoords(e){if(this._lastCellDecoded.address===e)return this._lastCellDecoded.coords;const t=this._rangeToCoords(e);if(!t||!k.isSingleCell(t))throw new Error("Only a single cell is allowed.");const n={colIndex:t.colStart,rowIndex:t.rowStart};return this._lastCellDecoded.address=e,this._lastCellDecoded.coords=n,n}_validateCoords(e,t=Mi){if(!k.isRangeWithinRange(e,this._entireCoords))throw new ke(t);const n=e.colStart,r=e.rowStart,o=e.colEnd,i=e.rowEnd;if(i<r||o<n)throw new Error(Wm);if(!(Number.isInteger(n)&&Number.isFinite(n)&&Number.isInteger(r)&&Number.isFinite(r)&&Number.isInteger(o)&&Number.isFinite(o)&&Number.isInteger(i)&&Number.isFinite(i)))throw new Error("Invalid range. All points must be valid integers.")}_createRangeError(e){return e?new Error(Lr):new Error(Go(e))}_protectionCheck(e=null,t=null,n=null){if(e&&this._closed)return;if(!this._initializing&&this._options.readonly)throw new Error(((a="update")=>`Unable to ${a}, this sheet is readonly.`)(n));t&&!Array.isArray(t)&&(t=[t]);const r=e(t),o=this.getProtection();if(o?.getProperties()){if(r.length===0)throw new Error(Cs);if(r){const a=r.length;for(let l=0;l<a;l++)if(o[r[l]]!==!0)throw new Error(tS())}}}_rangesToCoords(e,t=null,n=!0,r=!1){if(t&&this._closed||e==null)return F.EmptyArray;const o=this,i=Sc(e,this._entireCoords,r?Ft:os,l=>{if(n&&typeof l=="string"){const c=o.getNames()?.getByName(l);if(c)return c.getRanges().getCoords();const h=this._options.resolveRange?.(l);if(h&&h.getSource()===o)return console.warn(ju),[h.getCoords()];throw new Error(`Invalid sheet reference '${l}'.`)}}),a=i.length;for(let l=0;l<a;l++){const c=i[l];if(c){if(r){const h=c.sheetName;if(h&&h!==this.getName())throw new Error(ju)}this._validateCoords(c)}}if(!t)return i;if(i.length===0)throw this._createRangeError(e);return this._protectionCheck(t,i),i}_rangeToCoords(e,t=null,n=!0){if(!e)throw new Error(Lr);const r=t?i=>t(i):void 0,o=this._rangesToCoords(e,r,n);if(o.length===0)throw new Error(Go(e));return o[0]}_collectRanges(e,t=[],n=!0,r=this._getState(),o=!1){if(!n||Object.keys(n).length===0)return;const i=l=>n===!0||n[l]!==void 0,a=(l,c,h)=>{if(n!==!0&&n[l]===void 0)return;const u=c.search(e,!1),d=u.length;if(d===0)return;const g=n[l];for(let m=0;m<d;m++){const f=u[m];if(g&&!k.isRangeWithinRange(e,f))continue;const _=k.intersectRanges(e,f);let p=f.value;p===void 0&&(p=!0),t.push({..._,value:{[h]:p}})}};if(i(Q.Type.Merge)&&r.mergeSpatial){const l=r.mergeSpatial.search(e),c=l.length;for(let h=0;h<c;h++){const u=l[h],d=o?u:k.intersectRanges(e,u);t.push({...d,value:{merge:u.value}})}}if(a(Q.Type.Unlock,r.unlockSpatial,"unlock"),a(Q.Type.Contentful,r.contentfulSpatial,"contentful"),a(Q.Type.Continuous,r.continuousFillSpatial,"continuous"),a(Q.Type.Hyperlink,r.hyperlinkSpatial,"hyperlink"),a(Q.Type.Comments,r.commentsSpatial,"comments"),a(Q.Type.Style,r.directStyleSpatial,"directStyle"),a(Q.Type.Formula,r.formulaSpatial,"formula"),a(Q.Type.Pending,r.pendingSpatial,"pending"),a(Q.Type.CalcError,r.calcErrorsSpatial,"calcError"),a(Q.Type.Spill,r.spillSpatial,"spills"),i(Q.Type.Conditional)&&r.conditionalSpatial){const l=r.conditionalSpatial.search(e),c=n[Q.Type.Conditional],h=l.length;for(let u=0;u<h;u++){const d=l[u],g=k.intersectRanges(e,d);c&&!g||t.push({...g,value:{conditionals:[d.value]}})}}if(i(Q.Type.Table)&&r.tableSpatial){const l=r.tableSpatial.search(e),c=n[Q.Type.Table],h=l.length;for(let u=0;u<h;u++){const d=l[u];if(c&&!k.isRangeWithinRange(e,d))continue;const g=k.intersectRanges(e,d);t.push({...g,value:{table:d.value.model}})}}}_cellIterator(e){const t=this._cellOptions,n=this._strings,r=this._cellStateIterator(e);return{next(o){const i=r.next(o);if(i.done)return Re;const a=i.value,l=new Xa(n,e,t),c=l.context;return{done:!1,value:{value:l.setState(a),context:c}}},[Symbol.iterator](){return this}}}_rangeStateIterator(e){const t=this._getState();if(!t||!e||!e.includeRangeTypes)return Xe;const n=e?.bounds??this._getUsedCoords()??this._entireCoords;let r=null;e.includeRangeTypes===!0?r=Q_:F.isObject(e.includeRangeTypes)&&(r=e.includeRangeTypes);const o=e?.excludeHidden,i=o===!0||o===exports.w.Orientation.Row,a=o===!0||o===exports.w.Orientation.Column,l=[],c=this,h={includeHidden:!a},u={min:n.colStart,max:n.colEnd},d={includeHidden:!i},g={min:n.rowStart,max:n.rowEnd};this._rowHeaders.getRange(g).forEachVisibleSpan((C,y)=>{this._colHeaders.getRange(u).forEachVisibleSpan((b,w)=>{c._collectRanges({rowStart:C,rowEnd:y,colStart:b,colEnd:w},l,r,t)},h)},d);const m=new xi.IteratorInstance(l,e),f=e?.reverse??!1,_=e?.byCell;let p;return{next:C=>{if(p=m.next(C),p.done)return Re;const y=p.value,b=y.range,w={colIndex:b.colStart,rowIndex:b.rowStart},E={colIndex:b.colEnd,rowIndex:b.rowEnd};let x=null;_&&(x={...y.cell});const I=(v=>{if(!v)return null;let R=null;const A=v.length;for(let M=0;M<A;M++){const T=v[M].value;if(!T)continue;R||(R={...R});const N=Object.keys(T),B=N.length;for(let D=0;D<B;D++){const P=N[D],L=R[P];if(L)if(Array.isArray(L)){const z=T[P];if(Array.isArray(z)){const O=z.length;for(let j=0;j<O;j++)L.push(z[j])}else L.push(z)}else R[P]=[L,T[P]];else R[P]=T[P]}}return R})(y.overlaps);return{done:!1,value:{start:f?E:w,end:f?w:E,cell:x,intersection:I}}}}}_cellStateIterator(e){const t=this._getState();if(!t)return Xe;const n=e?.bounds??this._entireCoords,r=e?.orientation??exports.w.Orientation.Row,o=e?.reverse??!1,i=e?.includeEmpty,a={bounds:n,orientation:r,reverse:o};let l;i&&(l={bounds:n,orientation:r,reverse:o});const c=e?.excludeHidden;if(c===!0||c===exports.w.Orientation.Row){const A=qa(this._rowHeaders);a.processRowSkip=so(A),i&&(l.processRowSkip=so(A))}if(c===!0||c===exports.w.Orientation.Column){const A=qa(this._colHeaders);a.processColumnSkip=so(A),i&&(l.processRowSkip=so(A))}const h=i||!e?.ignoreEmptyIntersections;let u=e.includeRangeTypes;u===!0&&(u=Hm);const d=this._getState().contentfulSpatial,g=u?this._rangeStateIterator({bounds:n,orientation:r,reverse:o,includeRangeTypes:u,excludeHidden:e.excludeHidden,byCell:!0}):Xe,m=e?.includeMergeOverflow??!1,f=t?.cellValuesGrid??null;let _=f?f.entries(a):Xe,p=_.next(),S=null,C=null,y=null;p.done||(S=p.value[0],C=p.value[1]);let b=g.next(),w=null;const E=r!==exports.w.Orientation.Row;let x;const I=k.createCellComparator(r,o);let v;if(!b.done){const A=b.value;v=A.start,w=A.intersection}x=A=>{let M=null,T=null,N=null,B=!1,D=!1;if(S&&v){const W=I(S,v);W<0?(M=S,T=C,B=!0):W>0?(M=v,N=w,D=!0):(M=S,T=C,N=w,B=!0,D=!0)}else if(S)M=S,T=C,B=!0;else{if(!v||!h)return Re;M=v,N=w,D=!0}if(B&&(p=_.next(),p.done?S=null:(S=p.value[0],C=p.value[1])),D){const W=h?void 0:S;if(b=g.next(W),b.done)v=null,w=null;else{const H=b.value;v=H.cell,w=H.intersection}}let P=!1;const L=M.rowIndex,z=M.colIndex;E||(P=L===y?.rowIndex);let O=!1;E||(O=L===S?.rowIndex);let j=null;if(P)j=y;else if(m&&!y){qt.rowStart=L,qt.rowEnd=L,qt.colStart=z-5,qt.colEnd=z-1;const W=d.search(qt,!1);if(W.length>0){W.sort(k.columnFirstRangeComparator);const H=W[W.length-1];j={colIndex:H.colStart,rowIndex:H.rowStart}}}let V=null;if(O)V=S;else if(m&&!S){qt.colStart=z+1,qt.rowStart=L,qt.colEnd=z+5,qt.rowEnd=L;const W=d.search(qt,!1);if(W.length>0){W.sort(k.columnFirstRangeComparator);const H=W[0];V={colIndex:H.colStart,rowIndex:H.rowStart}}}return B&&(y=M),{done:!1,value:[M,T,N,j,V]}};let R={next:x,return:A=>null,throw:A=>null};return i&&(R=new Em(R,a)),R}_indexMerges(e,t=null){if(!(e&&e.length!==0||t&&t.length!==0))return;const n=this._getState();if(!n)return;const r=this._beginCommit({description:"indexMerges"}),o=n.mergeSpatial.clone();if(t){const i=t.length;for(let a=0;a<i;a++)o.remove(t[a])}if(e){const i=eS,a=u=>this._getState().cellValuesGrid.getValueAt(u.rowStart,u.colStart),l=u=>{const d=this._getState();if(!d)return;const g=[];return this._collectRanges(u,g,i,d),{...g?.[0]??null}},c=[],h=e.length;for(let u=0;u<h;u++){const d=e[u];c.push({...d,value:new Hd(d,a,l)})}o.load(c)}this._updateState({mergeSpatial:o}),r.commit()}_updateStyles(e,t,n,r=!1){const o=n?.description??"Update Style";this._protectionCheck(()=>["formatCells"],e,o);const i=this._beginCommit({description:o}),a=co(e);try{const l=this._getState();if(!l)return F.EmptyArray;const c=l.directStyleSpatial,h=i.getId(),u=c.clone(h);let d=l.continuousFillSpatial;const g=!d.isEmpty();let m=null;const f=this._styles,_=e.length;for(let p=0;p<_;p++){const S=(x,I)=>{let v=null;const R=qi(0,I,()=>{if(v)return v;const A=x.getCoords();return v=$r(f,x,A),v});return x.cloneWithUpdate(R)},C=e[p],y=C.value,b=y!==void 0?y:t,w=S(new Ke(f,C),b),E=(x,I)=>{if(r&&x.value&&x.value.getProperties()?.numberFormat)return x;const v=k.sanitizeRange(x);let R=null,A=x.value;typeof b=="function"&&A?R=S(A,b):(A||(A=new Ke(f,v)),R=A.cloneWithUpdate(I.value._p??null)),R.isEmpty()&&(R=null);let M=!1;if(R){const T=R._p?.alignment?.horizontal;!T||T!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&T!==exports.ITextFrame.HorizontalAlignment.Fill||(M=!0)}return(M||g)&&(m||(m=[]),m.push({...x,value:M?R:null})),{...I,value:R}};u.insertNonOverlapping({...C,value:w},{onIntersect:E})}if(m){d=d.clone();const p=m.length;for(let S=0;S<p;S++){const C=m[S];d.insertNonOverlapping(C)}}if(this._lastUsedCoordsRead.coords=null,this._updateState({directStyleSpatial:u,continuousFillSpatial:d}),n?.autoFit){const p=typeof n.autoFit=="boolean"?gl:n.autoFit;this._autoFit(e,p)}this._emitter.notify("onStyleChange"),r?i.commit({forceAmend:!0}):this._commitAndAutoSelect(i,a,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_createIncrementalUpdater(e,t=null,n){const r=e?.orientation??exports.w.Orientation.Row,o=e?.allowUnorderedWrites??!1,i=r===exports.w.Orientation.Column,a=this._isDataColumn,l=i!==a,c=this;let h,u,d,g=l?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder,m=null;if(t){const C=t.getCoords(),y=C.colStart,b=C.rowStart,w=C.colEnd,E=C.rowEnd;m=(x,I)=>{if(x<b||x>E||I<y||I>w)throw new ke}}i?(u=(C,y,b)=>(m?.(C,y),g.addValue(y,C,b),h),d=(C,y,b)=>(m?.(C,y+(b?.length??0)),g.addValues(y,C,b),h)):(u=(C,y,b)=>(m?.(C,y),g.addValue(C,y,b),h),d=(C,y,b)=>(m?.(C+(b?.length??0),y),g.addValues(C,y,b),h));const f=C=>{const y=g.build();return y&&c._updateTuples(y,C,null,n),t},_=o!==!1?k.createCellComparator(e?.orientation):null,p=F.isObject(o)?o:void 0;let S=null;return h=Object.freeze({push:(C,y)=>{const b=c._cellToCoords(C);return _&&(S&&_(b,S)<=0&&(f(p),g=l?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder),S=b),u(i?b.colIndex:b.rowIndex,i?b.rowIndex:b.colIndex,y)},pushAt:u,pushMultipleAt:d,apply:f}),h}_updateTuples(e,t,n=void 0,r=null){if(!e)return;const o=r?.isCell??!1,i=r?.isHyperlink??!1,a=e.tuples,l=e.bounds,c=this._beginCommit({description:t?.description??"Update Cells"});let h=null;const u=this._isDataColumn,d=u?exports.w.Orientation.Column:exports.w.Orientation.Row,g=this.getProtection().isLocked(),m=this.getProtection().isFormatCellsAllowed(),f=this._strings,_=l.majorStart,p=l.majorEnd,S=l.minorStart,C=l.minorEnd,y={colStart:u?_:S,rowStart:u?S:_,colEnd:u?p:C,rowEnd:u?C:p},b=this;(n=n??((J,X)=>{b._validateCoords(J,X??Mi)}))(y);const w={[Q.Type.Style]:!1,[Q.Type.Table]:!1};let E=!1;g&&this._hasRangedEntries("unlockSpatial",y)&&(w[Q.Type.Unlock]=!1,E=!0),this._hasRangedEntries("mergeSpatial",y)&&(w[Q.Type.Merge]=!1,E=!0);const x=this._rangeStateIterator({bounds:y,orientation:d,includeRangeTypes:w,reuseIterator:{done:!1,value:null}});let I=x.next(),v=-1,R=-1,A=-1,M=-1,T=null;if(!I.done){const J=I.value,X=J.start,te=J.end;v=u?X.colIndex:X.rowIndex,R=u?te.colIndex:te.rowIndex,A=u?X.rowIndex:X.colIndex,M=u?te.rowIndex:te.colIndex,T=J.intersection}let N=(J,X)=>{do{if(!T||J<=A&&X<A)return null;if(J>=v&&X>=A&&J<=R&&X<=M)return T;if(I=x.next(),I.done)T=null,N=null,E=!1;else{const te=I.value;v=u?te.start.colIndex:te.start.rowIndex,R=u?te.end.colIndex:te.end.rowIndex,A=u?te.start.rowIndex:te.start.colIndex,M=u?te.end.rowIndex:te.end.colIndex,T=te.intersection}}while(T);return T};const B=c.getState(this),D=B.cellValuesGrid.clone(),P=B.calcGraph.clone(),L=B.formulaSpatial.clone(),z=B.spillSpatial.clone(),O=B.pendingSpatial.clone(),j=B.calcErrorsSpatial.clone(),V=B.contentfulSpatial.clone(),W=Ln(u),H=Ln(u,(J,X)=>{if(J===X)return X}),G=Ln(u,(J,X)=>{if(J===X)return X}),$=Ln(u,(J,X)=>{if(J===X)return X}),Z=[];let Y=null,re=null;if(t?.textParser!==!1){const J=t&&t.textParser!==!0?t.textParser:{};re={ignoreQuotePrefix:!1,date1904:this._isDate1904,dateNF:!1,parse:null,...J},Y=new Xa(f,null,this._cellOptions)}const ee=[],q=this._cellOptions,ue=new Map,le=dd,K=(J,X,te)=>{const fe=N?.(X,te);if(fe?.merge){const ye=fe.merge.getCoords(),pe=u?ye.colStart:ye.rowStart,Ae=u?ye.rowStart:ye.colStart;if(pe!==X||Ae!==te)return}if(o&&J&&J.isICell){const ye=J;if(ye.isTopLeft()){const pe=ye.getSpans();Z.push({colStart:u?X:te,rowStart:u?te:X,colEnd:(u?X:te)+pe.width-1,rowEnd:(u?te:X)+pe.height-1})}}let me=Ul(J,q,re,ue);if(me===void 0)return;const de=me.value;if(me.stringToParse){Co[0].colIndex=u?X:te,Co[0].rowIndex=u?te:X,Co[1]=de,Co[2]=fe,Y.setState(Co);const ye=re?.parse(me.stringToParse,Y.context),pe=Ul(ye,q,re,ue,!0);if(Y.clear(),pe===null)return pe;pe!==void 0&&(me={...pe})}if(g){if(g&&(J===null||me.value!==void 0))throw new Error(Cs);if(!m&&me.style!==void 0)throw new Error(Cs)}if(!i){const ye=me.style;ye===void 0||ye===null&&!o||H.append(X,te,ye);const pe=me.hyperlink;pe===void 0||pe===null&&!o||G.append(X,te,pe)}const ce=me.formula;return ce===void 0||ce===null&&!o||$.append(X,te,ce),de};let oe=-1,ie=-1;try{const J=a.length;for(let Le=0;Le<J;Le++){const Ce=a[Le],he=Ce[0];if(oe>=he)throw new exports.Tuple.OutOfOrderError(`Duplicate or out of order major indices: {${he}}.`);if(oe=he,ie=Number.MIN_SAFE_INTEGER,he<_||he>p)throw new ke("Provided major bounds is invalid");const be=Ce[1],xe=[],Ee=be.length;for(let ge=0;ge<Ee;ge++){const ne=be[ge],ve=ne[1],Pe=ve.length;let Me=ne[0],Fe=Me;if(ie>Fe)throw new exports.Tuple.OutOfOrderError(`Duplicate or out of order minor indices: {${Fe}}.`);if(Fe<S||Fe+Pe>C+1)throw new ke("Provided minor bounds is invalid");let it=[];for(let ut=0;ut<Pe;ut++){const dt=ve[ut];let ft=null;if(E||typeof dt!="number"?(E||dt!==null||o)&&(ft=K(dt,he,Fe)):ft=dt,ft==null){if(ft===null&&W.append(he,Fe),it.length>0){const zt=le(it,f);xe.push([Me,zt]),it=[]}Me=Fe+1}else it.push(ft);Fe++}if(ie=Fe,it.length>0){const ut=le(it,f);xe.push([Me,ut]),it=null}}xe.length>0&&ee.push([he,xe])}const X=W.done(),te=X.length;for(let Le=0;Le<te;Le++){const Ce=X[Le];D.delete(X[Le]),V.insertNonOverlapping({...Ce,value:null});const he=P.delete(Ce);this._updateFormulaSpatial(L,null,he)}let fe;ee.length>0&&(D.setValues(ee),fe={tuples:ee,bounds:l});let me,de=$.done();if(de.length>1&&(de=fn(de,exports.w.Orientation.Column,1)),fe||de.length>0){const Le=P.setInputs(fe,de);me=this._updateFormulaSpatial(L,Le.inserts,Le.removes,B.directStyleSpatial)}const ce=gd(ee,u),ye=ce.length;for(let Le=0;Le<ye;Le++)V.insertNonOverlapping(ce[Le]);const pe=H.done();pe.length>0&&this._updateStyles(pe),Z.length>0&&this._merge(Z);const Ae=G.done();if(Ae.length>0&&this._setHyperlinks(Ae),this._updateState({cellValuesGrid:D,contentfulSpatial:V,calcGraph:P,formulaSpatial:L,spillSpatial:z,pendingSpatial:O,calcErrorsSpatial:j}),me&&me.length>0&&this._updateStyles(me,void 0,{},!0),t?.autoFit){const Le=typeof t.autoFit=="boolean"?gl:t.autoFit;this._autoFit([y],Le)}h={ranges:[y]},this._addEvent("data",y),this._commitAndAutoSelect(c,h,t?.autoSelect,{viewAfter:{formulas:[y],ranges:[y]}})}catch(J){throw c.rollback(),J}}_sort(e,t){typeof t=="boolean"&&(t={reverse:t});const n=t?.description??"Sort "+(t?.reverse?"Descending":"Ascending");this._protectionCheck(()=>["sort"],e,n);let r=1,o=1,i=!1;const a=this._getMerges([e]);if(a.length>0){i=!0;let W=a[0];if(r=W.colEnd-W.colStart+1,o=W.rowEnd-W.rowStart+1,(e.colEnd-e.colStart+1)%r!=0||(e.rowEnd-e.rowStart+1)%o!=0)throw new Error(zu);const H=a.length;for(let G=1;G<H;G++){const $=a[G];if($.colEnd-$.colStart+1!==r||$.rowEnd-$.rowStart+1!==o)throw new Error(zu)}}const l=t?.orientation??exports.w.Orientation.Row,c=l===exports.w.Orientation.Row;let h=t?.offset??0,u=e;t?.hasHeader&&(u={...u},c?u.rowStart+=o:u.colStart+=r,h=Math.max(h-1,0));const d={offset:h,reverse:t?.reverse??exports.Sort.DefaultRangeOptions.reverse,collatorOptions:t?.collatorOptions??exports.Sort.DefaultRangeOptions.collatorOptions},g=c?u.colStart:u.rowStart,m=c?u.colEnd-u.colStart:u.rowEnd-u.rowStart,f=[];if(t?.fields){const W=t?.fields.length??0;for(let H=0;H<W;H++){let G=t.fields[H];typeof G=="number"&&(G={offset:G}),f.push(G)}}else f.push(d);const _=f.length;for(let W=0;W<_;W++){const H=f[W]={...d,...f[W]};if(H.offset<0||H.offset>m)throw new ke("The sort offset is outside of the bounds of the sort.");H.offset+=g}const p=[];let S=null,C=null,y=null,b=Number.MIN_SAFE_INTEGER;f.sort((W,H)=>W.offset-H.offset);let w=null;const E=t?.includeHidden??!1;if(!E){const W=qa(c?this._rowHeaders:this._colHeaders);w=so(W)}const x=this._cellIterator({bounds:u,orientation:l,excludeHidden:!E&&l,includeRangeTypes:{[Q.Type.Style]:!1,[Q.Type.Merge]:!1}}),I=c?o:r;let v=(c?u.rowStart:u.colStart)-I,R=x.next();for(;!R.done;){const W=R.value.context,H=W.getCell();if(i&&!H.isTopLeft()){R=x.next();continue}const G=W.getCoords(),$=c?G.rowIndex:G.colIndex,Z=c?G.colIndex:G.rowIndex;if(v!==$){for(v+=I,w&&(v=w(v));v<$;)p.push(null),v+=I;C=[],y=[],S={minorIndex:$,values:C,sortValues:y},p.push(S),v=$,b=f[0].offset}for(;Z>b;){const Y=f[y.length];b=Y?Y.offset:Number.MAX_SAFE_INTEGER,Z>b&&y.push(null)}Z===b&&y.push(H),C.push(H),R=x.next()}if(!S||p.length===0)return;const A=new Map,M=new Map,T=t?.collators??exports.Sort.DefaultCollators,N=T.length;for(let W=0;W<N;W++)A.set(T[W].type,T[W].compare),M.set(T[W].type,W);let B=null,D=null,P=null;p.sort((W,H)=>{const G=f.length;for(let $=0;$<G;$++){const Z=f[$],Y=W?W.sortValues[$]:null,re=H?H.sortValues[$]:null,ee=Y?Y.getValue():null,q=re?re.getValue():null,ue=ee===null,le=q===null;if(ee===q)continue;if(ue&&le)return 0;if(!ue&&le)return-1;if(ue&&!le)return 1;const K=Y.getType(),oe=re.getType();let ie=0;if(K!==oe){let J=M.get(K);ie=M.get(oe)-J}else{let J=D;if(B!==K){J=A.get(K),D=J,B=K;let X=M.get(oe);P={...T[X].defaultOptions,...Z.collatorOptions}}ie=J(ee,q,P)}return Z.reverse&&(ie*=-1),ie}return 0});const L=this._beginCommit({description:n});let z=[u];E||(z=this._getVisible(z,{orientations:c?exports.w.Orientations.Row:exports.w.Orientations.Column})),this._clear(z,void 0,void 0,!0);const O=this._createIncrementalUpdater({orientation:l});let j=c?u.rowStart:u.colStart;const V=p.length;for(let W=0;W<V;W++){const H=p[W];if(w&&(j=w(j)),H){const G=H.values,$=G.length;for(let Z=0;Z<$;Z++){const Y=G[Z],re=c?j:Y.getCoords().rowIndex,ee=c?Y.getCoords().colIndex:j;O.pushAt(re,ee,Y)}}j+=I}return O.apply(),L.commit(),u}_autoFill(e,t,n){const{direction:r,amount:o}=((f,_)=>{let p=exports.w.Direction.Down,S=0;const C={...f};if(_.colStart<f.colStart?(p=exports.w.Direction.Left,S=f.colStart-_.colStart,C.colStart=_.colStart):_.colEnd>f.colEnd?(p=exports.w.Direction.Right,S=_.colEnd-f.colEnd,C.colEnd=_.colEnd):_.rowStart<f.rowStart?(p=exports.w.Direction.Up,S=f.rowStart-_.rowStart,C.rowStart=_.rowStart):_.rowEnd>f.rowEnd&&(p=exports.w.Direction.Down,S=_.rowEnd-f.rowEnd,C.rowEnd=_.rowEnd),!k.isEqualRanges(C,_))throw new Error("Autofill destination must be the same as the range for 3 of the 4 edges.");return{direction:p,amount:S}})(e,t);if(o<=0)return!1;const i=r===exports.w.Direction.Up||r===exports.w.Direction.Down,a=this.getSelection().getCoords(),l=[],c=n?.previewOnly,h=n?.contentsOnly,u=n?.filler??exports.AutoFill.Types.Series,d={...n?.fillerOptions};let g=null,m=null;try{const f={...e};let _={...e};const p=[e],S=this._getMerges(p);if(S.length>0&&!k.isRangeWithinRange(k.unionRangesArrays(S),e))throw new Error(Pu);const C={..._};let y=1;if(r===exports.w.Direction.Left)f.colStart=_.colStart=e.colStart-o,f.colEnd=e.colStart-1,y=S.length===0?y:e.colEnd+1-e.colStart,C.rowStart=C.rowEnd;else if(r===exports.w.Direction.Right)f.colEnd=_.colEnd=e.colEnd+o,f.colStart=e.colEnd+1,y=S.length===0?y:e.colEnd+1-e.colStart,C.rowStart=C.rowEnd;else if(r===exports.w.Direction.Up)f.rowStart=_.rowStart=e.rowStart-o,f.rowEnd=e.rowStart-1,y=S.length===0?y:e.rowEnd+1-e.rowStart,C.colStart=C.colEnd;else{if(r!==exports.w.Direction.Down)throw new Error(fg.MESSAGE_ERROR_INVALID_ARG(r));f.rowEnd=_.rowEnd=e.rowEnd+o,f.rowStart=e.rowEnd+1,y=S.length===0?y:e.rowEnd+1-e.rowStart,C.colStart=C.colEnd}if(o%y!==0)throw new Error((K=>`When filling with merged cells the amount to fill must be a multiple of the input range [${K}].`)(y));const b=i?"rowIndex":"colIndex",w=i?"colIndex":"rowIndex",E=i?e.rowEnd+1-e.rowStart:e.colEnd+1-e.colStart,x=i?e.rowStart:e.colStart,I=i?e.rowEnd:e.colEnd,v=i?t.rowStart:t.colStart,R=i?t.rowEnd:t.colEnd,A=i?r===exports.w.Direction.Down:r===exports.w.Direction.Right;A||(d.reverse=!0);const M=A?I+1:v,T=(A?R:x-1)-M+1,N=i?e.colEnd:e.rowEnd;l.push(k.unionRanges(f,e));const B=[];let D=null;c||(g=this._beginCommit({description:"Auto Fill",operation:{name:"autoFill",params:[e,t,n]}}));const P=this._cellIterator({bounds:c?C:e,reverse:!A,orientation:i?exports.w.Orientation.Column:exports.w.Orientation.Row,includeRangeTypes:{[Q.Type.Style]:!1}});let L=P.next();for(;!L.done;){const K=L.value.context,oe=K.getCell(),ie=K.getCoords();D?.oppositeIndex!==ie[w]&&(D={oppositeIndex:ie[w],lastIndex:A?x-1:I+1,values:[]},B.push(D));const J=ie[b];if(A)for(let te=D.lastIndex+1;te<J;te++)D.values.push(null);else for(let te=D.lastIndex-1;te>J;te--)D.values.push(null);D.lastIndex=J;const X=oe.toDate();if(X)D.values.push(X);else{let te=oe.getValue();D.values.push(te)}L=P.next()}const z=B.length;for(let K=0;K<z;K++){const oe=B[K].values;for(let ie=oe.length;ie<E;ie++)oe.push(null)}const O=(K,oe)=>{if(K.canFill(oe[0],[])){const ie=K.createFillAt(oe,d);if(ie)return ie}return exports.AutoFill.Types.Copy.createFillAt(oe)},j=this;if(c){const K=B[B.length-1];if(B[B.length-1]?.oppositeIndex!==N)return null;const oe=O(u,K.values);return c(ie=>{const J=j._rangeToCoords(ie);let X;r===exports.w.Direction.Down||r===exports.w.Direction.Right?X={rowIndex:J.rowEnd,colIndex:J.colEnd}:r===exports.w.Direction.Left?X={rowIndex:J.rowEnd,colIndex:J.colStart}:r===exports.w.Direction.Up&&(X={rowIndex:J.rowStart,colIndex:J.colEnd});const te=i?X.rowIndex:X.colIndex,fe={value:oe(A?te-x:x-te+E-1)};let me=null;return me=h?this.createTemporaryCell(fe,X):this.createTemporaryCell(null,X).createTemporaryCell(fe),me}),!1}const V=this._createIncrementalUpdater({orientation:i?exports.w.Orientation.Column:exports.w.Orientation.Row}),W=B.length;B.sort((K,oe)=>K.oppositeIndex-oe.oppositeIndex);for(let K=0;K<W;K++){const oe=K,ie=O(u,B[oe].values),J=B[oe].oppositeIndex,X=A?E:E+T-1,te=this.isDate1904();for(let fe=0;fe<T;fe++){let me=ie(X+(A?fe:-fe));qr(me)&&(me=Qo(me,te));const de=M+fe;i?V.pushAt(de,J,me):V.pushAt(J,de,me)}}this._clear([f],n?.contentsOnly?exports.ICell.Content.Formats:void 0),V.apply();const H=this._getMerges([_]),G=k.unionRangesArrays(H);if(H.length>0&&!k.isRangeWithinRange(G,_))throw new Error(Pu);if(H.length>0){const K=[],oe=o/y;if(i){const ie=e.rowEnd-e.rowStart+1,J=r===exports.w.Direction.Up?f.rowStart:e.rowEnd+1,X=H.length;for(let te=0;te<X;te++){const fe=H[te],me=fe.rowStart-e.rowStart,de=fe.rowEnd-fe.rowStart+1;for(let ce=0;ce<oe;ce++){const ye=ce*ie;K.push({colStart:fe.colStart,rowStart:J+ye+me,colEnd:fe.colEnd,rowEnd:J+ye+me+de-1})}}}else{const ie=e.colEnd-e.colStart+1,J=r===exports.w.Direction.Left?f.colStart:e.colEnd+1,X=H.length;for(let te=0;te<X;te++){const fe=H[te],me=fe.colStart-e.colStart,de=fe.colEnd-fe.colStart+1;for(let ce=0;ce<oe;ce++){const ye=ce*ie;K.push({colStart:J+ye+me,rowStart:fe.rowStart,colEnd:J+ye+me+de-1,rowEnd:fe.rowEnd})}}}this._merge(K)}const $=this._getState(),Z={},Y={};Y.directStyleSpatial=$.directStyleSpatial,Y.continuousFillSpatial=$.continuousFillSpatial;let re=e,ee=f;if(!A){let K=(i?_.rowEnd+1-_.rowStart:_.colEnd+1-_.colStart)%E;const oe=i?"rowStart":"colStart",ie=i?"rowEnd":"colEnd";K!==0&&(ee={...f,[ie]:Math.min(f[ie],f[oe]+K)},re={...e,[oe]:e[ie]-K+1},f[oe]=f[oe]+K)}const q=Object.keys(Y),ue=q.length;for(let K=0;K<ue;K++){const oe=q[K],ie=Y[oe].createCopiedEntries(re,ee),J=$[oe].clone(),X=ie.removes,te=X.length;for(let fe=0;fe<te;fe++)J.remove(X[fe]);J.load(ie.inserts),Z[oe]=J}if(A){const K=this.getTables().search({address:{rowIndex:e.rowEnd,colIndex:e.colEnd}});if(K.length===1){const oe=K[0],ie=oe.getRange().getCoords();oe.resize({colStart:ie.colStart,rowStart:ie.rowStart,colEnd:i?ie.colEnd:f.colEnd,rowEnd:i?f.rowEnd:ie.rowEnd})}}const le=$.calcGraph.clone();le.autoFill(e,f),Z.calcGraph=le,this._updateState(Z),m={...a,ranges:l},g.commit({viewBefore:{view:this.getView(),selection:De([e]),selectOptions:n?.autoSelect},viewAfter:{view:this.getView(),selection:m,selectOptions:n?.autoSelect}}),this._autoSelect(n?.autoSelect??!1,m)}catch(f){throw g?.rollback(),f}return!0}_setHyperlinks(e,t,n){const r=n?.description??"Set Hyperlink";this._protectionCheck(()=>["insertHyperlinks","formatCells"],e,r);const o=De(e),i=this._beginCommit({description:r});let a=null;try{const l=this._getState();if(!l)return F.EmptyArray;const c=l.hyperlinkSpatial;let h=c,u=l.directStyleSpatial.clone();const d=e.length;for(let g=0;g<d;g++){const m=e[g];let f=null;const _=m.value,p=_!==void 0?_:t;let S;if(p!==null){if(p.isIHyperlink)S={...p._j},f=p.getDisplayText();else if(typeof p=="string")S={address:p},f=p;else if(p.address){const C=p,y={...C};delete y.displayText,S=y,f=C.displayText??C.address}}else S=null;if(a=k.unionRanges(a,m),c===h&&(h=c.clone()),S!==null||c.size()>0){if(f&&t){const C=this._createIncrementalUpdater({orientation:exports.w.Orientation.Column},void 0,{isHyperlink:!0});for(let y=m.colStart;y<=m.colEnd;y++)for(let b=m.rowStart;b<=m.rowEnd;b++)C.pushAt(b,y,f);C.apply()}if(S===null)this._getRangedEntries("hyperlinkSpatial",[m],{onEntry:(C,y)=>(h.insertNonOverlapping({...y,value:S}),y.value)});else{h.insertNonOverlapping({...m,value:S});const C=this._styles,y=b=>{const w=b.value??new Ke(C,k.sanitizeRange(b));let E={...w.getPropertiesAt(0,0,null)};if(E.named){const x=C.getNamed(E.named)?.getRanged().getPropertiesAt(0,0,null);E=F.mergeContentful(x,E)}return delete E.font,E.named=exports.IStyle.BuiltInName.Hyperlink,{...b,value:w.cloneWithUpdate(E)}};u.insertNonOverlapping({...m,value:null},{onIntersect:y})}}}this._lastUsedCoordsRead.coords=null,this._updateState({hyperlinkSpatial:h,directStyleSpatial:u}),this._commitAndAutoSelect(i,o,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_updateFormulaSpatial(e,t,n,r){if(n){const i=n.length;for(let a=0;a<i;a++){const l=n[a];e.remove(l)}}let o;if(t){const i=[],a=t.length;for(let l=0;l<a;l++){const c=t[l],h=k.sanitizeRange(c),u=new xy(h,c.value.tokens,c.value.references);if(i.push({colStart:h.colStart,rowStart:h.rowStart,colEnd:h.colEnd,rowEnd:h.rowEnd,value:u}),!r)continue;const d=c.value.precedents;let g,m,f=!1;const _=d.length;for(let p=0;!f&&p<_;p++){const S=d[p],C=S.colStart;if(S.colStart===void 0)continue;const y=S.rowStart;Wt.colStart=C,Wt.rowStart=y,Wt.colEnd=C,Wt.rowEnd=y;const b=r.search(Wt)[0];if(b){const w=b.value.getPropertiesAt(y,C,null),E=w?.numberFormat;if(E)if(g){m||(m=exports.NumberFormat.Styles.lookupStyle(g)?.formatType);const x=exports.NumberFormat.Styles.lookupStyle(E)?.formatType;p0(x,m)>0?(m=x,g=E):f=!0}else g=E}}g&&(o||(o=[]),o.push({colStart:h.colStart,rowStart:h.rowStart,colEnd:h.colEnd,rowEnd:h.rowEnd,value:{numberFormat:g}}))}e.load(i)}return o}_realizeCalcedValues(e){if(!e)return;const t=this._getState();if(!t)return;const n=e.valueInserts,r=e.spillRemoves,o=e.errorRemoves,i=t.cellValuesGrid;e.isFull&&(t.calcErrorsSpatial.clear(),t.spillSpatial.clear(),t.pendingSpatial.clear());const a=e.valueRemoves;if(a){const g=t.contentfulSpatial,m=a.length;for(let f=0;f<m;f++){const _=a[f];i.delete(_),g.insertNonOverlapping({..._,value:null})}}if(r){const g=t.spillSpatial,m=r.length;for(let f=0;f<m;f++){const _=r[f];g.remove(_)}}if(o){const g=t.calcErrorsSpatial,m=o.length;for(let f=0;f<m;f++){const _=o[f];g.remove(_)}}this._updateFormulaSpatial(t.formulaSpatial,e.formulaInserts,e.formulaRemoves);const l=e.formatInserts;if(l){const g=l.length;for(let m=0;m<g;m++){const f=l[m],_={numberFormat:f.value};f.value=_}this._updateStyles(l,void 0,{autoFit:!0},!0)}if(n){const g=n.tuples;i.setValues(g);const m=this._isDataColumn,f=m?exports.w.Orientation.Column:exports.w.Orientation.Row,_=t.contentfulSpatial,p=g.length;for(let S=0;S<p;S++){const C=g[S],y=C[0],b=C[1],w=b.length;for(let E=0;E<w;E++){const x=b[E],I=x[0],v=I+x[1].length-1,R={colStart:m?y:I,rowStart:m?I:y,colEnd:m?y:v,rowEnd:m?v:y};_.insertNonOverlapping({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:new Vt(R,f)})}}}const c=e.spillInserts;if(c){const g=c.length;for(let m=0;m<g;m++){const f=c[m],_=f.value;f.value=new er(k.sanitizeRange(f),0,_)}t.spillSpatial.load(c)}const h=e.pendingUpdates;if(h){const g=t.pendingSpatial,m=h.length;for(let f=0;f<m;f++){const _=h[f];_.value===!1&&(_.value=null),g.insertNonOverlapping(_)}}const u=e.errorInserts;u&&t.calcErrorsSpatial.load(u);const d=e.formulaInserts;if(d){const g=fn(d);this._autoFit(g,gl)}if((e.bounds||e.isFull)&&!this._initializing){const g=this._rangesListenerMap;if(g.size>0){const m={isDataChange:!0,isTransactional:!1,timeStamp:Date.now(),isUndo:!1,trigger:"calc"};this._notifyRangeListeners(this._rangeListenerSpatial,g,[e.bounds??this._entireCoords],m)}(c||r)&&this._emitter.notify("onSpillsChange")}}_calculate(e,t){const n=this._getState().calcGraph;n.invalidate(e),n.calculate(t)}_calculateFull(){this._initializing||F.debounce(()=>{this._getState()?.calcGraph.calculate({full:!0})},100)()}_setComments(e,t,n){const r=n?.description??"Set Comments",o=De(e),i=this._beginCommit({description:r});let a=null;try{const l=this._getState();if(!l)return F.EmptyArray;const c=l.commentsSpatial;let h=c;const u=e.length;for(let d=0;d<u;d++){const g=e[d];let m=null;if(t!==null){let f=t;if(!f)continue;m=typeof f=="string"?{content:{runs:{text:f}}}:{...f}}a=k.unionRanges(a,g),c===h&&(h=c.clone()),h.insertNonOverlapping({...g,value:m})}this._lastUsedCoordsRead.coords=null,this._updateState({commentsSpatial:h}),this._commitAndAutoSelect(i,o,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_clear(e,t=null,n,r=!1,o=!1){let i=null,a="Clear",l=!1,c=!1,h=!1,u=!1;t===exports.ICell.Content.Formulas?(a=`${a} Formulas`,u=!0):t===exports.ICell.Content.Values?(a=`${a} Values`,u=!0):t===exports.ICell.Content.Formats?(a=`${a} Formats`,l=!0,i=["formatCells"]):t===exports.ICell.Content.Comments?(a=`${a} Comments`,h=!0):t===exports.ICell.Content.Hyperlinks?(a=`${a} Hyperlinks`,c=!0,i=["formatCells"]):(i=[],a=`${a} All`,u=!0,l=!0,c=!0,h=!0),i!==null&&this._protectionCheck(()=>i,e,n?.description??a);const d=De(e),g=this._beginCommit({description:n?.description??a});let m=this._getState(),f=m.cellValuesGrid,_=m.calcGraph,p=m.contentfulSpatial,S=m.formulaSpatial,C=m.spillSpatial,y=m.pendingSpatial,b=m.calcErrorsSpatial,w=m.rangesListenerSpatial2;u&&(f=f.clone(),_=_.clone(),p=p.clone(),S=S.clone(),C=C.clone(),y=y.clone(),b=b.clone());try{if(c&&this._setHyperlinks(e,null),h&&this._setComments(e,null),l&&(this._updateStyles(e,null),r||this._unmerge(e)),l||u){fi(0,e,[],p,C,f);const E=e.length;for(let x=0;x<E;x++){const I=e[x];if(u){f.delete(I);const A={...I,value:null};p.insertNonOverlapping(A);const M=_.delete(I);this._updateFormulaSpatial(S,null,M)}const v=this.getTables().search({address:I}),R=v.length;for(let A=0;A<R;A++){const M=v[A];k.isRangeWithinRange(M.getAnchorCoords(),I)&&(t===exports.ICell.Content.Formats?M.updateStyleOptions({name:null}):M.delete())}if(l){let A=m.conditionalSpatial;A.size()>0&&(A=A.clone(g.getId()),A.insertNonOverlapping({...I,value:null},{noMerge:!0}),m=this._updateState({conditionalSpatial:A}))}if(o){const A=w.search(I),M=A.length;for(let T=0;T<M;T++){const N=A[T];k.isRangeWithinRange(N,I)&&(w===m.rangesListenerSpatial2&&(w=w.clone()),console.log("cut and move listener"),w.remove(N))}}}}this._updateState({cellValuesGrid:f,calcGraph:_,contentfulSpatial:p,formulaSpatial:S,spillSpatial:C,pendingSpatial:y,calcErrorsSpatial:b,rangesListenerSpatial2:w}),this._commitAndAutoSelect(g,d,n?.autoSelect,{viewAfter:{ranges:e}})}catch(E){throw g.rollback(),E}}_merge(e,t=null){if(this._protectionCheck(Kd,e),e.length===1&&k.isSingleCell(e[0]))return;let n=exports.w.Orientations.Both;t?.orientations?n=t?.orientations:t===exports.w.Orientations.Row?n=exports.w.Orientations.Row:t===exports.w.Orientations.Column&&(n=exports.w.Orientations.Column);const r=t?.discardMultipleValues??!1;let o=De(e);const i=this.getSelection().getCoords();let a=null;const l=this._beginCommit({description:t?.description??"Merge"});let c=e[0];try{const h=this._getMerges(e);if(ko(e)||h.length>0){const g=k.unionRangesArrays(h),m=k.unionRangesArrays(e);if(!(!g&&!m||g&&m&&k.isRangeWithinRange(g,m)))throw console.warn(Lu,e),new Error(Lu);this._unmerge(h)}const u=this._createIncrementalUpdater({orientation:exports.w.Orientation.Column}),d=[];try{const g=this._entireCoords,m=this._getState().contentfulSpatial;let f=!1;const _=C=>{const y={rowIndex:C.rowStart,colIndex:C.colStart};let b=null;if(f){let w=0;const E=m.search(C),x=E.length;for(let I=0;I<x;I++){const v=k.intersectRanges(E[I],C);if(v&&(w+=(v.rowEnd-v.rowStart+1)*(v.colEnd-v.colStart+1)),w>1)throw new Cl("Merging cells would cause some values to be discarded. Use 'discardMultipleValues' option if desired.","discardMultipleValues")}}if(b||(b=y),!k.isEqualCells(b,y)){const w=this.getRange(b).getCell();u.pushAt(C.rowStart,C.colStart,w),u.pushAt(b.rowIndex,b.colIndex,null)}d.push(C),c=k.unionRanges(c,C)},p=[...e].sort(k.createRangeComparator(exports.w.Orientation.Column)),S=p.length;for(let C=0;C<S;C++){const y=p[C];if(!k.isSingleCell(y)){if(a||!i||!k.isCellWithinRange(i.cell,y)||i.cell.rowIndex===y.rowStart&&i.cell.colIndex===y.colStart||(a={...o,cell:{rowIndex:y.rowStart,colIndex:y.colStart}}),!r&&(f=m.search(y).length>0),this._validateOrRemoveOverlaps(y,"merge"),y.colStart<g.colStart||y.rowStart<g.rowStart||y.colEnd>g.colEnd||y.rowEnd>g.rowEnd)throw new Error("We can't merge outside of the maximum cell location.");if(n===exports.w.Orientations.Column){const b=y.rowEnd!==g.rowEnd?y.rowEnd:Math.max(1,g.rowEnd);for(let w=y.rowStart;w<=b;w++)_({...y,rowStart:w,rowEnd:w})}else if(n===exports.w.Orientations.Row){const b=y.colEnd!==g.colEnd?y.colEnd:Math.max(1,g.colEnd);for(let w=y.colStart;w<=b;w++)_({...y,colStart:w,colEnd:w})}else _(y)}}u.apply(),this._indexMerges(d),this._updateState({})}catch(g){throw g.type?new Cl(g.message??"Unable to merge",g.type):new Error(g.message??"Unable to merge")}a&&(o=a,this.getSelection().updateCoords(a)),l.commit({viewAfter:{view:this.getView(),selection:o,merges:e,ranges:e,selectOptions:t?.autoSelect}}),this._autoSelect(t?.autoSelect??!1,o)}catch(h){throw l.rollback(),h}}_unmerge(e,t){if(this._protectionCheck(Kd,e),ko(e))throw new Error("We can't unmerge intersecting ranges.");if(!this._getState())return null;const n=k.unionRangesArrays(e),r=De(e),o=this._beginCommit({description:t?.description??"Unmerge"}),i=o.getState(this).mergeSpatial,a=[];try{const l=e.length;for(let c=0;c<l;c++){const h=e[c],u=i.search(h),d=u.length;for(let g=0;g<d;g++){const m=u[g];if(!k.isSingleCell(h)&&!k.isRangeWithinRange(m,n))throw new Error("We can't unmerge partial cells.");a.push(m)}}if(a.length===0)return o.rollback(),null;this._indexMerges(null,a),this._commitAndAutoSelect(o,r,t?.autoSelect,{viewAfter:{merges:e,ranges:e}})}catch(l){throw o.rollback(),l}}_getMerges(e,t=!1){return e.length===0?F.EmptyArray:this._getRangedEntries("mergeSpatial",e,{excludeHidden:t,fullyContained:!1,onEntry:n=>n.getCoords()})}_clone(){const e={...this._options,container:null};this._ownStyles&&(e.styles=this._styles),this._ownStrings&&(e.strings=this._strings),this._ownResources&&(e.resources=this._resources),this._ownNames&&(e.names=this._names),this._ownsCalculation&&(e.calculation=this._calculation),e.transactions=new Lt({transient:!0});const t=new Gr(e),n=this._transactions.getState(this);t._updateState(n);const r=new dl({sheet:this,json:this.getView().toJSON()});return r.selectMovables(this.getView().getMovableSelection()),t.setView(r),t}_getSnapshot(e,t){if(e.length===0)return F.EmptyArray;const n=this._getState();if(!n)return null;t=Object.freeze({...t});const r=this._clone();r.isMarked=!0;const o=this,i=o.getView(),a="Range",l=[],c=((p,S,C,y)=>{const b=[];let w=null,E=null;const x=C&&C.length>0;if(x){const v=C.length;for(let R=0;R<v;R++){const A=C[R].getSnapshot?.(y);A&&(b.push(A),w=Il(A.getCoords(),w))}}else if(S){const v=S.length;for(let R=0;R<v;R++){const A=S[R],M=p.getMovables().search({excludeHidden:!1,fullyContained:!0,address:A}),T=M.length;for(let N=0;N<T;N++){const B=M[N].getSnapshot?.(y);B&&(b.push(B),w=Il(p.getRange(A).getBounds(),w),E=k.unionRanges(E,A))}}}if(b.length===0)return null;const I=()=>y.description??(b?.length===1?jr(b[0]?.getName()):"Drawings");return{copyTo:async(v,R)=>{const A={...y,...R},M=v.getSource(),T=M.getView(),N=T.getMovableSelection(),B=v.getCoords(),D=A?.isCut??!1,P=T.getMovableSelection();T.selectMovables([]);const L=M.beginCommit(A.description??`${D?"Cut":"Copy"} ${I()}`);try{let z=0,O=0;if(P.length>0&&b.length>0){let W=Number.MAX_SAFE_INTEGER,H=Number.MAX_SAFE_INTEGER;for(let q=0;q<N.length;q++){const ue=N[q].getBounds();W=Math.min(ue.x,W),H=Math.min(ue.y,H)}let G=Number.MAX_SAFE_INTEGER,$=Number.MAX_SAFE_INTEGER;const Z=b.length;for(let q=0;q<Z;q++){const ue=b[q].getCoords();G=Math.min(ue.x,G),$=Math.min(ue.y,$)}z=W-G,O=H-$;const Y=b[0].getCoords(),re={...Y,x:Y.x+z,y:Y.y+O},ee=Dd(M.getMovables(),re);z+=ee.x,O+=ee.y}else if(w){const W=M.getRange(B).getBounds();z=W.x-w.x,O=W.y-w.y}const j=[],V=b.length;for(let W=0;W<V;W++){const H=b[W],G=H.getCoords(),$={...G,x:G.x+z,y:G.y+O};j.push(H.copyTo({movables:M.getMovables(),bounds:$},{autoSelect:{addToSelection:!0},...A}))}await Promise.all(j),L?.updateState(M,W=>W),L.commit({viewBefore:W=>({...W,view:p.getView(),movableSelection:P})})}catch(z){throw L.rollback(),z}return null},getName:I,getCoords:()=>E,getMarkOptions:()=>y,toText:()=>x?b[0].toText?.()??null:null,toHtml:()=>x?b[0].toHtml?.()??null:null,toImage:()=>x?b[0].toImage?.()??null:null,getSource:()=>p,isISnapshot:!0}})(r,e,i.getMovableSelection(),t);if(c){if(i.getMovableSelection().length>0)return c;l.push(c)}if(e.length>1)throw new Error(Wu);const h={singleMerge:null};l.push({copyTo(p,S){const C={...t,...S};let y=null;if(!C.skipBlanks){const w=p.getSource(),E=p.getCoords(),x=ai(E,e[0],C?.fitDestination,C?.transpose);y=w.getRange(x);let I=!1;const v=y.getMerges();if(v.length===1&&k.isEqualRanges(v[0],E))if(k.isSingleCell(e[0]))I=!0;else{const R=(b=_)?{colIndex:b.colStart,rowIndex:b.rowStart}:null;r._getMerges([k.cellToRange(R)]).length===1&&(I=!0)}return I?(h.singleMerge=E,y.clear(C.type??exports.ICell.Content.Values)):y.clear(C.type),x}var b}});const u=r._entireCoords,d=e.length;for(let p=0;p<d;p++){const S=e[p],C=n.rangeListenerSpatial.search(S,!1),y=n.rangesListenerMap;l.push({async copyTo(b,w){if(!w.isCut)return;const E=new Set,x=C.length;for(let I=0;I<x;I++){const v=C[I].value,R=v.id;if(E.has(R))continue;const A=y.get(R);if(E.add(R),A.ranges[v.offset]===null)return;const M={isTransactional:!0,isDataChange:!1,trigger:"moveCells",from:r.getRanges(e),to:b},T=r._createRangeEvent(A.ranges,M);r._notifyRangeListener2(A,T,M)}return null},getMarkOptions:()=>t,getCoords:()=>null,isISnapshot:!0})}const g={excludeHidden:!1,fullyContained:!0,onEntry:p=>p.model};for(let p=0;p<d;p++){const S=e[p],C=r._getRangedEntries("tableSpatial",[S],g),y=C.length;for(let b=0;b<y;b++){const w=C[b],E=w.getAnchorCoords(),x=E.colStart-S.colStart,I=E.rowStart-S.rowStart,v=w.getSnapshot(t);l.push({async copyTo(R,A){const M=R.getSource(),T=R.getCoords();if(r.getProtection().isLocked())return;const N={colStart:T.colStart+x,rowStart:T.rowStart+I,colEnd:T.colEnd+x,rowEnd:T.rowEnd+I};return v.copyTo({tables:M.getTables(),range:N},A)}})}}for(let p=0;p<d;p++){const S=e[p];l.push(Pd(o.getColumnHeaders().getRange(S),S,Object.freeze({...t,includeHeaders:S.rowStart<=u.rowStart&&S.rowEnd>=u.rowEnd})))}for(let p=0;p<d;p++){const S=e[p];l.push(Pd(o.getRowHeaders().getRange(S),S,Object.freeze({...t,includeHeaders:S.colStart<=u.colStart&&S.colEnd>=u.colEnd})))}const m=Ey(o,r,e,a,t,(p,S)=>r._copyRange(o,r,e,p,S,h));l.push(m);const f=r._getState().calcGraph.getSnapshot({range:e[0]});l.push({async copyTo(p,S){const C=p.getSource(),y=p.getCoords();if(r.getProtection().isLocked())return;const b=C._getState().calcGraph;return f.copyTo({calcGraph:b,range:y},S)}});const _=e[0];return((p,S,C,y,b,w,E=null)=>({async copyTo(x,I){let v=null;const R={...b,...I},A=C.beginCommit(R.description??w);try{const M=p.length;for(let T=0;T<M;T++){const N=await p[T].copyTo(x,R);N&&(v=k.unionRanges(v,N))}A.commit()}catch(M){throw A.rollback(),M}return v},getMarkOptions:()=>b,getName:()=>w,getSource:()=>S,getCoords:()=>y,toText(){let x=E?.toText?.()??null;const I=p.length;for(let v=0;!x&&v<I;v++)x=p?.[v].toText?.();return x??null},toHtml(){let x=E?.toHtml?.()??null;const I=p.length;for(let v=0;!x&&v<I;v++)x=p?.[v].toHtml?.();return x??null},toImage(){let x=E?.toImage?.()??null;const I=p.length;for(let v=0;!x&&v<I;v++)x=p?.[v].toImage?.();return x??null},isISnapshot:!0}))(l,o,r,_,t,a,m)}async _copyRange(e,t,n,r,o,i){if(n.length>1)throw new Error("Only a single selection is supported when using 'Insert Copy'.");if(!n||n.length===0)throw new Error("The source has no range.");const a=r.getSource();let l=r.getCoords(),c={...n[0]};const h=(o={...o}).isCut;let u=!o.type||o.type===exports.ICell.Content.Formats,d=!o.type||o.type===exports.ICell.Content.Values,g=!o.type||o.type===exports.ICell.Content.Formats||o.type===exports.ICell.Content.Hyperlinks;const m=a.getEntireRange(),f=m.getCoords(),_=[],p=[],S=[];let C=[],y=[];const b=(o.fitDestination??!1)&&!k.isSingleCell(l),w=ai(l,c,b,o.transpose);if(b&&(c={...c,colEnd:c.colStart+Math.min(w.colEnd-w.colStart,c.colEnd-c.colStart),rowEnd:c.rowStart+Math.min(w.rowEnd-w.rowStart,c.rowEnd-c.rowStart)}),!k.isRangeWithinRange(w,f))throw console.warn(w,f),new Error("We can't paste outside of the sheet bounds.");let E=null;E=o.undoRange?{view:a.getView(),selection:De([o.undoRange.getCoords()])}:{sheet:a,selection:De([w])};const x=a.getTransactions().beginCommit({description:o.description??"Paste"});try{if(!this._getState())return F.EmptyArray;const I=new Set,v=o.transpose;let R=!((v||o.adjustCells)&&u)&&I.size===1;if(R){const H=I.values().next();R=k.isRangeWithinRange(c,H.value.getCoords())&&!Oo(c,H.value.getCoords())}R&&(R=a.getTables().search({address:w}).length===0),v&&(R=!0),i.singleMerge&&(u=!1,g=!1);const A=l.colStart-c.colStart,M=l.rowStart-c.rowStart,T=o.adjustCells;let N={...Z_};if(delete N[Q.Type.Style],!u){const H=this.getProtection().isLocked();N={},H&&(N[Q.Type.Unlock]=!1)}const B=exports.w.Orientation.Column;let D;if(d){D=m.startIncrementalUpdates({orientation:o.transpose?exports.w.Orientation.Row:exports.w.Orientation.Column});const H={orientation:B,includeRangeTypes:N,bounds:c},G=new Xa(this._strings,H,this._cellOptions),$=(ee,q,ue)=>{const le=ee[0],K=G.setState(ee),oe=G.context,ie=oe.getCell(),J=ie.isTopLeft();let X=M,te=A;if(v){const ce=le.colIndex-c.colStart,ye=le.rowIndex-c.rowStart;X=ce+ue+l.rowStart,te=ye+q+l.colStart}else X=M+le.rowIndex+q,te=A+le.colIndex+ue;let fe=!1;const me={value:void 0,style:void 0,hyperlink:void 0};if(d&&(me.value=K,fe=!0),u){const ce=ee[2];ce&&(ce.directStyle||ce.table)&&(me.style=ie.getStyle(!R),fe=!0)}g&&(me.hyperlink=ie.getHyperlink(),fe=!0);let de=me;if(T&&J){const ce=T(K,oe,{rowIndex:X,colIndex:te},o);ce!==void 0&&(de=ce,fe=!0)}if(fe&&(D.pushAt(X,te,de),u)){const ce=ie.getSpans();(ce.width>1||ce.height>1)&&J&&_.push({colStart:te,rowStart:X,colEnd:te+(o.transpose?ce.height:ce.width)-1,rowEnd:X+(o.transpose?ce.width:ce.height)-1})}},Z=this._cellStateIterator(H);let Y={next(){const ee=Z.next();if(ee.done)return Re;const q=ee.value[0];let ue;return ee.value&&(ue=[q,ee.value]),{done:ee.done,value:ue}}};if(!i.singleMerge&&!k.isEqualRanges(w,c)){const ee=w.colEnd-w.colStart+1,q=w.rowEnd-w.rowStart+1;Y=new zl({delegate:Y,bounds:c,orientation:B,dims:{major:o.transpose?q:ee,minor:o.transpose?ee:q}})}let re=Y.next();for(;!re.done;){const ee=re.value,q=ee[1],ue=ee[0],le=q[0];$(q,ue.rowIndex-le.rowIndex,ue.colIndex-le.colIndex),re=Y.next()}}const P=t._getState(),L={},z={transpose:v??!1};u&&(L.directStyleSpatial=P.directStyleSpatial,L.continuousFillSpatial=P.continuousFillSpatial,L.mergeSpatial=P.mergeSpatial),h&&(e._clear([c],void 0,void 0,!1,!0),C.push(c),L.rangesListenerSpatial2=P.rangesListenerSpatial2);const O=a,j=O._getState(),V=Object.keys(L),W=V.length;for(let H=0;H<W;H++){const G=V[H],$=L[G].createCopiedEntries(c,w,z),Z=j[G].clone(),Y=$.removes,re=Y.length;for(let ee=0;ee<re;ee++)Z.remove(Y[ee]);Z.load($.inserts),j[G]=Z}O._updateState(j),C.push(w),y.push(w),p&&p.length>0&&O._colHeaders.updateHeaderPairs(p),S&&S.length>0&&O._rowHeaders.updateHeaderPairs(S),D?.apply(),_.length>0&&a.getRanges(_).merge(),x.commit({viewBefore:E,viewAfter:H=>({...H,view:a.getView(),selection:De(y),ranges:C})})}catch(I){throw console.warn(I),x.rollback(),new Error((v=>`Unable to paste: ${v}`)(I.message),{cause:I})}return k.unionRangesArrays(y)}_snapShotFromSource(e,t){if(e.isISnapshot)return e;const n=e;let r=null;if(n?.isICellRanges)throw new Error(Wu);if(r=n?.isICellRange?n:this.getRange(n),r.isICellRange){const o=r;if(o.isInvalid())throw new Error(Hu);return o.getSnapshot(t)}throw new Error(Hu)}async _copyFrom(e,t,n){if(!t)throw new Error("Both a source and a destination are required to copy.");const r=this._snapShotFromSource(t),o="Paste",i=this._beginCommit({description:n?.description??o});let a=null;try{const l=this.getRange(e);a=await r.copyTo(l,n);const c=r.getName(),h=[a];n?.isCut&&h.push(r.getCoords()),i.commit({description:c?n?.description??`${o} ${c}`:o,viewAfter:{view:this.getView(),selection:De([a]),ranges:h}})}catch(l){throw i.rollback(),l}return a}_createFilter(e,t,n){const r=this;return new sf({initialAnchor:e,maxRangeCoords:this._entireCoords,json:t,transactions:this._transactions,deleteFromContainer:o=>{const i=this._beginCommit({description:o?.description??"Delete Filter"});this._updateState({filter:null}),i.commit()},apply:o=>{console.log("apply Filter",o)},processUpdate:()=>{},isProtected:()=>!r._initializing&&!r.getProtection().isAutoFilterAllowed()})}insertFilter(e){const t=this._rangeToCoords(e,()=>["autoFilter"]);let n=this.getFilter();if(n)return n;n=this._createFilter(t);const r=De([t]),o=this._beginCommit({description:"Insert Filter"});return this._updateState({filter:n}),o.commit({viewAfter:{ranges:[t],view:this.getView(),selection:r,selectOptions:void 0}}),n}getFilter(){return this._getState()?.filter??null}insertSort(e){return this._rangeToCoords(e,()=>["sort"]),null}getSort(){return null}_getDefaultShiftOrientation(e){return Aw(e,this._entireCoords)}_getDefaultSortCriteria(e,t,n){return ud(this,e,n?this._cellToCoords(n):null,t)}async _insertFrom(e,t,n){if(!t)throw new Dt;const r=this._snapShotFromSource(t),o=r.getCoords();let i=ai(e[0],o,n?.fitDestination),a=co([i]),l=a;const c=n?.orientation??this._getDefaultShiftOrientation(i),h=this._beginCommit({description:n?.description??"Insert Copied Cells",autoSelect:n?.autoSelect});try{if(this._insertCells([i],c),await this._copyFrom(i,r,{...n,isCut:!1}),n.isCut){const u={...o};if(a=co([u]),i={...i},this===r.getSource()){if(c===exports.w.Orientation.Row){if(i.colStart<u.colStart&&i.colEnd>=u.colStart||i.colEnd>u.colEnd&&i.colStart<=u.colEnd)throw new Error(Vu);if(u.colStart===i.colStart&&u.colEnd===i.colEnd){const d=u.rowEnd-u.rowStart+1;i.rowStart<=u.rowStart?(u.rowStart+=d,u.rowEnd+=d):(i.rowStart-=d,i.rowEnd-=d)}}else{if(i.rowStart<u.rowStart&&i.rowEnd>=u.rowStart||i.rowEnd>u.rowEnd&&i.rowStart<=u.rowEnd)throw new Error(Vu);if(u.rowStart===i.rowStart&&u.rowEnd===i.rowEnd){const d=u.colEnd-u.colStart+1;i.colStart<=u.colStart?(u.colStart+=d,u.colEnd+=d):(i.colStart-=d,i.colEnd-=d)}}l=co([i])}r.getSource().getRanges([u]).delete(c)}h.commit({viewBefore:{ranges:e,view:this.getView(),selection:a,selectOptions:n?.autoSelect},viewAfter:{ranges:e,view:this.getView(),selection:l,selectOptions:n?.autoSelect}}),this._autoSelect(n?.autoSelect??!1,l)}catch(u){throw h.rollback(),u}return i}_insertCells(e,t,n,r=void 0){const o=this;r=r??((f,_)=>{o._validateCoords(f,_??Va)});const i=n?.description??"Insert Cells",a=(t??this._getDefaultShiftOrientation(e[0]))===exports.w.Orientation.Column;if(this._protectionCheck(()=>[a?"insertColumns":"insertRows"],e,i),ko(e))throw new Error("We can't insert cells with overlapping selections.");const l=this._entireCoords;let c=l.colEnd,h=l.rowEnd;const u=De(e),d=this._beginCommit({description:i,operation:{name:"insertCells"}}),g=d.getState(this),m=a?exports.w.Direction.Right:exports.w.Direction.Down;try{let f=g.cellValuesGrid,_=g.contentfulSpatial,p=g.unlockSpatial,S=g.mergeSpatial,C=g.directStyleSpatial,y=g.continuousFillSpatial,b=g.conditionalSpatial,w=g.hyperlinkSpatial,E=g.commentsSpatial,x=g.movableSpatial,I=g.tableSpatial,v=g.calcGraph,R=g.rangesListenerSpatial2,A=g.rangeListenerSpatial,M=g.rangesListenerMap;const T=new Map,N=Fn(e.slice(),exports.w.Direction.Left),B=N.length;for(let z=0;z<B;z++){const O=N[z];c=Math.min(c,O.colStart),h=Math.min(h,O.rowStart);const j=a?O.colEnd-O.colStart+1:O.rowEnd-O.rowStart+1,V=f.getCoords();if(V){const $={...O,colEnd:a?Math.max(O.colEnd,V?.colEnd??O.colStart)+(O.colEnd-O.colStart+1):O.colStart,rowEnd:a?O.rowStart:Math.max(O.rowEnd,V?.rowEnd??O.rowStart)+(O.rowEnd-O.rowStart+1)},Z=_.search($),Y=Z.length;for(let re=0;re<Y;re++){const ee=Z[re],q={...O};a?q.colEnd=Math.max(q.colEnd,ee.colEnd)+j:q.rowEnd=Math.max(q.rowEnd,ee.rowEnd)+j,r(q)}f=f.clone(),f.shift(O,m),this._updateState({cellValuesGrid:f})}const W=O.colStart<=l.colStart&&O.colEnd>=l.colEnd,H=O.rowStart<=l.rowStart&&O.rowEnd>=l.rowEnd,G=($,Z,Y,re)=>{let ee=null;Y>1&&(ee=$.at(Y-1));const q=re-Y+1;Z?.(Y,q),ee&&$.updateHeaderPairs([{address:{min:Y,max:re},update:ee}])};W&&G(this._rowHeaders,this._rowHeadersShiftCallback,O.rowStart,O.rowEnd),H&&G(this._colHeaders,this._colHeadersShiftCallback,O.colStart,O.colEnd),_=_.shift({range:O,direction:m,cloneIfUpdate:_===g.contentfulSpatial,coordValidator:r}),p=p.shift({range:O,direction:m,cloneIfUpdate:p===g.unlockSpatial,coordValidator:r}),S=S.shift({range:O,direction:m,cloneIfUpdate:S===g.mergeSpatial,coordValidator:r}),C=C.shift({range:O,direction:m,cloneIfUpdate:C===g.directStyleSpatial,coordValidator:r}),y=y.shift({range:O,direction:m,cloneIfUpdate:y===g.continuousFillSpatial,coordValidator:r}),b=b.shift({range:O,direction:m,cloneIfUpdate:b===g.conditionalSpatial,coordValidator:r}),w=w.shift({range:O,direction:m,cloneIfUpdate:w===g.hyperlinkSpatial,coordValidator:r}),E=E.shift({range:O,direction:m,cloneIfUpdate:E===g.commentsSpatial,coordValidator:r}),x=x.shift({range:O,direction:m,cloneIfUpdate:x===g.movableSpatial,coordValidator:r}),I=I.shift({range:O,direction:m,cloneIfUpdate:I===g.tableSpatial,coordValidator:r}),v=v.shift({range:O,direction:m,cloneIfUpdate:v===g.calcGraph}),A=A.shift({range:O,direction:m,cloneIfUpdate:A===g.rangeListenerSpatial,onShift:$=>{M===g.rangesListenerMap&&(M=new Map(M)),this._processListenerShift(M,T,g.rangesListenerMap,$)}}),R=R.shift({range:O,direction:m,cloneIfUpdate:R===g.rangesListenerSpatial2,coordValidator:r})}let D=g.formulaSpatial,P=g.spillSpatial,L=g.pendingSpatial;v!==g.calcGraph&&(D=D.clone(),P=P.clone(),L=L.clone()),this._updateState({contentfulSpatial:_,unlockSpatial:p,mergeSpatial:S,directStyleSpatial:C,continuousFillSpatial:y,conditionalSpatial:b,hyperlinkSpatial:w,commentsSpatial:E,movableSpatial:x,tableSpatial:I,calcGraph:v,formulaSpatial:D,spillSpatial:P,pendingSpatial:L,rangesListenerSpatial2:R,rangeListenerSpatial:A,rangesListenerMap:M}),this._commitAndAutoSelect(d,u,n?.autoSelect,{viewAfter:{ranges:N,listeners:T}})}catch(f){throw console.warn(f),d.rollback(),f instanceof ke?new Error(f.message??Va):f}}_deleteCells(e,t,n){const r=(t??this._getDefaultShiftOrientation(e[0]))===exports.w.Orientation.Column,o=n?.description??"Delete Cells";if(this._protectionCheck(()=>[r?"deleteColumns":"deleteRows"],e,o),ko(e))throw new Error("We can't delete cells with overlapping selections.");const i=this._entireCoords;let a=i.colEnd,l=i.rowEnd;const c=r?exports.w.Direction.Left:exports.w.Direction.Up,h=De(e),u=this._beginCommit({description:o,operation:{name:"deleteCells"}}),d=u.getState(this);try{let g=d.cellValuesGrid,m=d.contentfulSpatial,f=d.mergeSpatial,_=d.unlockSpatial,p=d.directStyleSpatial,S=d.continuousFillSpatial,C=d.conditionalSpatial,y=d.hyperlinkSpatial,b=d.commentsSpatial,w=d.movableSpatial,E=d.movableMapModel,x=d.tableSpatial,I=d.tableMapModel,v=d.calcGraph,R=d.rangesListenerSpatial2,A=d.rangeListenerSpatial,M=d.rangesListenerMap;const T=new Map,N=Fn(e.slice(),exports.w.Direction.Left),B=N.length;for(let D=0;D<B;D++){const P=N[D];a=Math.min(a,P.colStart),l=Math.min(l,P.rowStart),g.getCoords()&&(g=g.clone(),g.shift(P,c),this._updateState({cellValuesGrid:g}));const L=P.colStart<=i.colStart&&P.colEnd>=i.colEnd,z=P.rowStart<=i.rowStart&&P.rowEnd>=i.rowEnd;L&&this._rowHeadersShiftCallback(P.rowStart,-1*(P.rowEnd-P.rowStart+1)),z&&this._colHeadersShiftCallback(P.colStart,-1*(P.colEnd-P.colStart+1)),m=m.shift({range:P,direction:c,cloneIfUpdate:m===d.contentfulSpatial}),_=_.shift({range:P,direction:c,cloneIfUpdate:_===d.unlockSpatial}),f=f.shift({range:P,direction:c,cloneIfUpdate:f===d.mergeSpatial}),p=p.shift({range:P,direction:c,cloneIfUpdate:p===d.directStyleSpatial}),S=S.shift({range:P,direction:c,cloneIfUpdate:S===d.continuousFillSpatial}),C=C.shift({range:P,direction:c,cloneIfUpdate:C===d.conditionalSpatial}),y=y.shift({range:P,direction:c,cloneIfUpdate:y===d.hyperlinkSpatial}),b=b.shift({range:P,direction:c,cloneIfUpdate:b===d.commentsSpatial}),w=w.shift({range:P,direction:c,cloneIfUpdate:w===d.movableSpatial}),x=x.shift({range:P,direction:c,cloneIfUpdate:x===d.tableSpatial}),v=v.shift({range:P,direction:c,cloneIfUpdate:v===d.calcGraph}),A=A.shift({range:P,direction:c,cloneIfUpdate:A===d.rangeListenerSpatial,onShift:O=>{M===d.rangesListenerMap&&(M=new Map(M)),this._processListenerShift(M,T,d.rangesListenerMap,O)}}),R=R.shift({range:P,direction:c,cloneIfUpdate:R===d.rangesListenerSpatial2})}this._updateState({contentfulSpatial:m,unlockSpatial:_,mergeSpatial:f,directStyleSpatial:p,continuousFillSpatial:S,conditionalSpatial:C,hyperlinkSpatial:y,commentsSpatial:b,movableSpatial:w,movableMapModel:E,tableSpatial:x,tableMapModel:I,calcGraph:v,rangesListenerSpatial2:R,rangeListenerSpatial:A,rangesListenerMap:M}),this._commitAndAutoSelect(u,h,n?.autoSelect,{viewAfter:{ranges:N,listeners:T}})}catch(g){throw u.rollback(),g instanceof ke?new Error(g.message??Va):g}}_autoFit(e,t){if(this._closed)throw new Error(St);t={expandOnly:!1,skipCustomSize:!1,minContent:!1,...t};const n="Autofit";let r;const o=Jo(e,this._entireCoords,!0),i=qo(e,this._entireCoords,!0);!o&&i?(t.orientations=t.orientations??exports.w.Orientations.Column,r=`${n} ${Xn}`):!i&&o?(t.orientations=t.orientations??exports.w.Orientations.Row,r=`${n} ${Jn}`):i&&o?(t.orientations=t.orientations??exports.w.Orientations.Both,r=`${n} All`):(t.orientations=t.orientations??exports.w.Orientations.Both,r=`${n}`);let a=t.orientations!==exports.w.Orientations.Row;this._colHeaders.isProtected()&&(a=!1);let l=t.orientations!==exports.w.Orientations.Column;if(this._rowHeaders.isProtected()&&(l=!1),!l&&!a)return;const c=a&&(t.expandOnly===!1||t.expandOnly===exports.w.Orientation.Row),h=l&&(t.expandOnly===!1||t.expandOnly===exports.w.Orientation.Column),u=t.minContent,d=De(e),g=this._beginCommit({description:t.description??r});try{let m=Number.MAX_SAFE_INTEGER,f=Number.MIN_SAFE_INTEGER,_=!1,p="",S=-1,C=!1,y=!1,b=!1,w=Number.MAX_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER;const x=this._styles.getNormal(),I=this._cellOptions,v=t.orientations===exports.w.Orientations.Row,R=new Map,A=Pl(e,1);A.sort(k.createRangeComparator(exports.w.Orientation.Column));const M=A.length,T={skipCustomSize:t.skipCustomSize},N=exports.IFont.getDeviceScale(),B=this._defaultRowHeight()*N,D=(L,z=1)=>{if(L!==0&&L!==null&&!(z>1))return L=Math.max(L,B),O=>h?L:Math.max(O,L)},P=(L,z=1)=>{if(L!==0&&L!==null&&!(z>1))return O=>c?L:Math.max(O,L)};for(let L=0;L<M;L++){const z=[];let O=-1,j=!1,V=x,W=-1,H=1,G=1;const $=A[L];let Z=$.colStart,Y=$.rowStart,re=$.colEnd,ee=$.rowEnd;const q=this._getUsedCoords();(h||c)&&q&&(Z=h?q.colStart:$.colStart,Y=c?q.rowStart:$.rowStart,re=h?q.colEnd:$.colEnd,ee=c?q.rowEnd:$.rowEnd);const ue={includeRangeTypes:{[Q.Type.Style]:!1,[Q.Type.Contentful]:!1},excludeHidden:!1,bounds:{colStart:Z,rowStart:Y,colEnd:re,rowEnd:ee},orientation:exports.w.Orientation.Column},le=l?[]:void 0,K=a?[]:void 0,oe=(Ce,he,be)=>{if(Ce>he)return null;const xe=[];let Ee=Ce;const ge=be?be.length:0;for(let ne=0;ne<ge;ne++){const ve=be[ne],Pe=ve.min,Me=ve.max;if(Ee>=Pe){Ee=Me+1;continue}const Fe={address:{min:Ee,max:Pe-1},update:Qd};xe.push(Fe),Ee=Me+1}if(Ee<=he){const ne={address:{min:Ee,max:he},update:Qd};xe.push(ne)}return xe},ie=this._rangeStateIterator(ue);let J=ie.next();for(;!J.done;){const Ce=J.value,he=Ce.intersection,be=Ce.start,xe=Ce.end;yo.colStart=be.colIndex,yo.rowStart=be.rowIndex,yo.colEnd=xe.colIndex,yo.rowEnd=xe.rowIndex;const Ee=k.intersectRanges(yo,$,ky),ge=ki(0,Ee,he,I).getBestFit();if(l){const ne=Math.max(be.rowIndex,Y),ve={address:{min:ne,max:Math.min(xe.rowIndex,ee)},update:{size:D(ge.height),autoSize:!0}};le.push(ve)}if(a){const ne=Math.max(be.colIndex,Z),ve={address:{min:ne,max:Math.min(xe.colIndex,re)},update:{size:P(ge.width),autoSize:!0}};K.push(ve)}J=ie.next()}if(K){let Ce=this._colHeaders.updateHeaderPairs(K,T);Ce=Xt(rr(qh(Ce)));const he=oe($.colStart,$.colEnd,Ce);he&&this._colHeaders.updateHeaderPairs(he,T)}if(le){let Ce=this._rowHeaders.updateHeaderPairs(le,T);Ce=Xt(rr(qh(Ce)));const he=oe($.rowStart,$.rowEnd,Ce);he&&this._rowHeaders.updateHeaderPairs(he,T)}const X=this._cellStateIterator({...ue,includeRangeTypes:{[Q.Type.Merge]:!1,[Q.Type.Table]:!1,[Q.Type.Style]:!1},ignoreEmptyIntersections:!0});let te,fe,me,de=X.next(),ce=1,ye=1;for(;!de.done;){const Ce=de.value,he=Ce[0],be=Ce[2];let xe=x;const Ee=be?.directStyle??null;Ee===te?xe=fe:(xe=Ee?ki(0,k.cellToRange(he,Oy),be,I):x,fe=xe);let ge=1,ne=1;const ve=be?.merge??null;if(ve===me)ge=ce,ne=ye;else{if(ve){const zt=ve.getCoords();ge=zt.colEnd-zt.colStart+1,ne=zt.rowEnd-zt.rowStart+1}else ge=1,ne=1;ce=ge,ye=ne}const Pe=he.colIndex,Me=he.rowIndex,Fe=Ce[1],it=Ze(Fe),ut=k.isCellWithinRange(he,$);let dt=!1,ft=!1;if(te!==Ee||ge!==H||ne!==G||it===U.String||it===U.Error||ut!==j){if(dt=!0,(ge>1||ne>1||it===U.RichData)&&(ft=!0),!ft&&be){const zt=xe.getAlignment().getHorizontal();zt!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&zt!==exports.ITextFrame.HorizontalAlignment.Fill||(ft=!0)}ft&&(dt=!1)}if(te=Ee,me=ve,(O!==Pe||dt)&&(O!==Pe&&(W=this._colHeaders.getSpanSize(Pe)),O!==-1&&z.push({col:O,style:V,spanWidth:ge,spanHeight:ne,minVal:m,maxVal:f,hasZero:_,text:p,textId:S,hasFalse:y,hasTrue:C,hasEmpty:b,minRow:w,maxRow:E,colWidth:W,measureWidth:-1,measureHeight:-1,isFit:j}),O=Pe,V=xe,j=ut,H=ge,G=ne,m=Number.MAX_SAFE_INTEGER,f=Number.MIN_SAFE_INTEGER,_=!1,p="",S=-1,y=!1,C=!1,b=!1,w=Me),E=Me,!ft)if(Fe===null)b=!0;else switch(it){case U.Number:Fe===0&&(_=!0),m=Math.min(m,Fe),f=Math.max(f,Fe);break;case U.String:p=Fe,S=Fe;break;case U.Error:p=Fe.toString(),S=-1;break;case U.Boolean:Fe?C=!0:y=!0}de=X.next()}O!==-1&&z.push({col:O,style:V,spanWidth:H,spanHeight:G,minVal:m,maxVal:f,hasZero:_,text:p,textId:S,hasFalse:y,hasTrue:C,hasEmpty:b,minRow:w,maxRow:E,colWidth:W,measureWidth:-1,measureHeight:-1,isFit:j});let pe=-1,Ae=-1;const Le=z.length;for(let Ce=0;Ce<Le;Ce++){const he=z[Ce],be=v||!he.isFit,xe=he.maxVal,Ee=he.style,ge=he.colWidth;if(pe=0,Ae=0,xe!==Number.MIN_SAFE_INTEGER){const ve=On(U.Number,Ee,xe,I,ge,u,be);pe=ve.width,Ae=ve.height;const Pe=he.minVal;if(Pe*xe<0){const Me=On(U.Number,Ee,Pe,I,ge,u,be);pe=Math.max(pe,Me.width),Ae=Math.max(Ae,Me.height)}if(he.hasZero&&Pe!==0&&xe!==0){const Me=On(U.Number,Ee,0,I,ge,u,be);pe=Math.max(pe,Me.width),Ae=Math.max(Ae,Me.height)}}const ne=he.text;if(ne.length>0){const ve=On(U.String,Ee,ne,I,ge,u,be,void 0,R);pe=Math.max(pe,ve.width),Ae=Math.max(Ae,ve.height)}if(he.hasTrue||he.hasFalse){const ve=On(U.Boolean,Ee,!he.hasFalse,I,ge,u,be);pe=Math.max(pe,ve.width),Ae=Math.max(Ae,ve.height)}if(he.hasEmpty){const ve=On(U.Boolean,Ee,null,I,ge,u,be);pe=Math.max(pe,ve.width),Ae=Math.max(Ae,ve.height)}he.measureWidth=pe,he.measureHeight=Ae}if(a){const Ce=[];for(let he=0;he<Le;he++){let be=z[he];const xe=be.col;let Ee=z[he+1],ge=be.measureWidth??0;for(;Ee&&Ee.col===xe;)Ee.measureWidth&&(ge=Math.max(Ee.measureWidth??0,ge)),he++,be=z[he],Ee=z[he+1];ge===0&&(ge=null);const ne=P(ge,be.spanWidth);Ce.push({address:{min:xe,max:xe},update:{size:ne,autoSize:!0}})}this._colHeaders.updateHeaderPairs(Ce,T)}if(l){let Ce=1;const he={onUpdate:(ge,ne,ve)=>{if(!(Ce>1))return ge===null?ne:Math.max(ne,ge)}};let be=[];for(let ge=0;ge<Le;ge++){const ne=z[ge];Ce=ne.spanHeight,be=Xt(Ol(be,{min:ne.minRow,max:ne.maxRow,value:ne.measureHeight},he))}const xe=be.length,Ee=new Array(xe);for(let ge=0;ge<xe;ge++){const ne=be[ge],ve=D(ne.value,1),Pe={address:{min:ne.min,max:ne.max},update:{size:ve,autoSize:!0}};Ee[ge]=Pe}this._rowHeaders.updateHeaderPairs(Ee,T)}}this._commitAndAutoSelect(g,d,t?.autoSelect,{viewAfter:{ranges:e}})}catch(m){throw g.rollback(),m}}_createRangeEvent(e,t){const n=this,r=()=>{const i=n._getState();return this._closed||i.deleted?_n(null):e?Array.isArray(e)?n._createRanges(e):n._createRange(e):_n(this,this._entireCoords)},o=t.trigger;return{getSource:r,getFrom:()=>t.from??null,getTo:()=>t.to??null,trigger:o,isUndo:t.isUndo??!1,isDataChange:t.isDataChange??!1,isTransactional:t.isTransactional??!0,toString:()=>`SheetRangeEvent: ('${o}', ${r().toString()})`,timeStamp:t.timeStamp??Date.now()}}_notifyAddressListeners(e,t,n,r){const o=t.entries();let i=o.next();const a=r.trigger;for(;!i.done;){const l=i.value[0];let c=i[1];if(c||(c=e.get(l)),c&&!n.has(l)){let h=!1;const u=c.options;u&&(h=a==="address"?u.ignoreAddressChanges:u.ignoreDataChanges),h!==!0&&c.notify(r),n.add(l)}i=o.next()}}_notifyDataListeners(e,t,n=null,r,o){if(!e)return;const i=n.length;for(let a=0;a<i;a++){const l=n[a];if(!l)continue;const c=e.search(l),h=c.length;for(let u=0;u<h;u++){const d=c[u].value.groupId;if(!r.has(d)){const g=t.get(d);g.options?.ignoreDataChanges!==!0&&g.notify(o),r.add(d)}}}}_notifyRangeListeners(e,t,n=null,r){if(!e)return;const o=new Set;r.timeStamp||(r.timeStamp=Date.now());const i=n.length;for(let a=0;a<i;a++){const l=n[a];if(!l)continue;const c=e.search(l),h=c.length;for(let u=0;u<h;u++){const d=c[u].value.id;if(o.has(d))continue;const g=t.get(d);o.add(d);const m=g.ranges,f=m.length;for(let _=0;_<f;_++){const p=m[_],S=this._createRangeEvent(p,r);this._notifyRangeListener2(g,S,r)}}}}_notifyRangeListener2(e,t=null,n=null){if(e.options?.ignoreDataChanges&&n?.isDataChange)return;const o=e.handler??e.handlerW.deref();if(o)try{o?.(t)}catch(i){console.warn(i)}}_notifyUsedRangeChange(){this._lastCellRead.coords=null,this._lastUsedCoordsRead.coords=null,this._emitter.notify("onUsedRangeChange")}_notifyMergeChange(){this._emitter.notify("onMergesChange")}addListeners(e,t){let n=null;if(e.onLayoutChange){const o=e,i={onSizesChange:()=>{o.onLayoutChange(this)}};n=[],n.push(this._colHeaders.addListeners(i,t)),n.push(this._rowHeaders.addListeners(i,t))}let r=this._emitter.addListeners(e,t);if(n){const o=r;r=()=>{const i=n.length;for(let a=0;a<i;a++)n[a]();o()}}return r}_addRangesListeners(e,t,n){if(this._closed)throw new Error(St);if(!t)throw new Error(Ou);n=n?{...Ls,...n}:Ls;const r=n?.transactional??!1,o=this,i=Fy++%Number.MAX_SAFE_INTEGER,a=()=>{let f=null,_=null;if(r){const y=o._getState();if(!y)return;f=y.rangeListenerSpatial.clone(),_=new Map(y.rangesListenerMap)}else f=o._rangeListenerSpatial,_=o._rangesListenerMap;const p=_.get(i);if(!p)return void console.log("Listener not found");const S=p.ranges,C=S.length;for(let y=0;y<C;y++){const b=k.sanitizeRange(S[y]);b!==null&&f.remove(b,(w,E)=>{if(E.value.id===i)return!0})}if(_.delete(i),r){const y=this._beginCommit({description:"Remove Range Listener"});this._updateState({rangeListenerSpatial:f,rangesListenerMap:_}),y.commit({forceAmend:!0})}},l=[...e];let c={id:i,handler:null,handlerW:null,removeListener:a,options:n,ranges:l};n?.weakly?c.handlerW=new WeakRef(t):c.handler=t;let h=null,u=null,d=null;if(r){d=this._beginCommit({description:"Add Range Listener"});const f=this._getState();h=f.rangeListenerSpatial.clone(),u=new Map(f.rangesListenerMap)}else h=o._rangeListenerSpatial,u=o._rangesListenerMap;const g=[],m=e.length;for(let f=0;f<m;f++){const _={...e[f],value:{id:i,offset:f,options:n}};g.push(_)}return h.load(g),u.set(i,c),d&&(this._updateState({rangeListenerSpatial:h,rangesListenerMap:u}),d.commit({forceAmend:!0})),a}_addRangesListeners2(e,t,n,r){if(this._closed)throw new Error(St);if(!t)throw new Error(Ou);n=n?{...Ls,...n}:Ls;const o=n?.transactional??!1,i=this,a=F.uuidV4(),l=Ny++,c=()=>{let b=null,w=null;const E=i._getState();if(!E)return;b=E.rangesListenerSpatial2.clone(),w=E.rangesListenerMap2;const x=w.get(a);if(x){const v=x?.spatialsIds,R=x?.coords,A=v.length;for(let M=0;M<A;M++){const T=v[M],N=R[M];b.remove(N,(B,D)=>{if(D.value.uuid===T)return!0})}w=new Map(E.rangesListenerMap2),w.delete(a)}const I=this._beginCommit({description:"Remove Range Listener"});this._updateState({rangesListenerMap2:w}),I.commit({forceAmend:!0}),o||this._rangesListenerSorted.delete(l)};let h=null,u=this._beginCommit({description:"Add Range Listener"});const d=this._getState();h=d.rangesListenerSpatial2.clone();let g=null,m=null;n?.weakly?m=new WeakRef(t):g=t;const f=[],_=[...e];let p=[];const S=e.length;for(let b=0;b<S;b++){const w={...e[b]};_[b]=w;const E=F.uuidV4(),x=new zi(a,E,n?.ignoreAddressChanges??!1);p.push(E);const I={...k.sanitizeRange(w),value:x};f.push(I)}h.load(f),n={...n};const C=new ji(a,p,_,r,this,l,g,m,c,n),y=new Map(d.rangesListenerMap2);return y.set(a,C),this._updateState({rangesListenerSpatial2:h,rangesListenerMap2:y}),o||this._rangesListenerSorted.set(l,C),u.commit({forceAmend:!0}),c}_getUsedCoords(e){const t=this._getState();if(!t)return null;let n=t.cellValuesGrid.getCoords();return n=k.unionRanges(t.mergeSpatial.getBoundingCoords(),n),n=k.unionRanges(t.directStyleSpatial.getBoundingCoords(),n),n=k.unionRanges(t.formulaSpatial.getBoundingCoords(),n),n=k.unionRanges(t.spillSpatial.getBoundingCoords(),n),n=k.unionRanges(t.pendingSpatial.getBoundingCoords(),n),n&&(n.colStart=Math.max(n.colStart,this._entireCoords.colStart),n.rowStart=Math.max(n.rowStart,this._entireCoords.rowStart),n.colEnd=Math.min(n.colEnd,this._entireCoords.colEnd),n.rowEnd=Math.min(n.rowEnd,this._entireCoords.rowEnd)),!n||n.rowStart>n.rowEnd||n.colStart>n.colEnd?(this._lastUsedCoordsRead.coords=null,null):(this._lastUsedCoordsRead&&this._lastUsedCoordsRead.coords&&Oo(this._lastUsedCoordsRead.coords,n)||(this._lastUsedCoordsRead.coords=n,this._lastUsedCoordsRead.range=null),this._lastUsedCoordsRead.coords)}_isContentful(e,t){return!!this._contentCounts(e,void 0,t)}_getCount(e,t=!1){const n=this._contentCounts(e,By,t);return n?n[exports.ICell.Content.Values]??0:0}_contentCounts(e,t,n){if(!t){const u=Object.keys(exports.ICell.Content),d=u.length;t=new Array(d);for(let g=0;g<d;g++){const m=u[g];t[g]=exports.ICell.Content[m]}}const r={},o=t.length;let i,a,l=!1;for(let u=0;u<o;u++){const d=t[u];d===exports.ICell.Content.Values?(r[Q.Type.Contentful]=!1,r[Q.Type.Table]=!1):d===exports.ICell.Content.Formulas?r[Q.Type.Formula]=!1:d===exports.ICell.Content.Formats?r[Q.Type.Style]=!1:d===exports.ICell.Content.Tables&&(r[Q.Type.Table]=!1,l=!0)}const c=()=>{i=new Set,a={};for(let u=0;u<o;u++){const d=t[u];a[d]=0}},h=e.length;for(let u=0;u<h;u++){const d=e[u],g=this._rangeStateIterator({includeRangeTypes:r,excludeHidden:n,bounds:d});let m=g.next();for(;!m.done;){a||c();const f=m.value,_=(f.end.colIndex-f.start.colIndex+1)*(f.end.rowIndex-f.start.rowIndex+1),p=f.intersection;if(p){p.contentful&&(a[exports.ICell.Content.Values]+=_),p.formula&&(a[exports.ICell.Content.Formulas]+=_);const S=p.table;S&&(l&&!i.has(S)&&(a[exports.ICell.Content.Tables]+=1,i.add(S)),p.contentful||(a[exports.ICell.Content.Values]+=_))}m=g.next()}}return a}getSelectedCell(){const e=this.getSelection().getCoords().cell,t=this._lastCellSelected;if(t?.cell&&k.isEqualCells(e,t.coords))return t.cell;const n=this.getRange(e).getCell();return this._lastCellSelected={coords:e,cell:n},n}find(e,t){return this.getEntireRange().find(e,t)}_find(e,t,n){if(this._closed)throw new Error(St);if(!t)return null;const r=[...e],o=n?.orientation??exports.w.Orientation.Row,i=n?.reverse,a=!n?.disableWrap,l=n?.from?this._cellToCoords(n?.from):null;let c=null;if(l){let E=-1;for(let T=0;E===-1&&T<r.length;T++)k.isCellWithinRange(l,r[T])&&(E=T);c=k.cellToRange(l);let x=jl(r[E],c,o);x.push(c);const I=k.createRangeComparator(o,i);x.sort(I);let v=-1;const R=x.length;for(let T=0;T<R;T++)I(x[T],c)<=0&&(v=T);r.splice(E,1,...x);const A=E+v,M=[];for(let T=0;T<=A;T++)M.push(r.shift());if(a){const T=M.length;for(let N=0;N<T;N++)r.push(M[N])}}if(r.length===0)return Xe;const h=n?.fields?.includes(exports.ICell.Content.Formulas)??!1,u=n?.fields?.includes(exports.ICell.Content.Values)??!0,d=n?.matchEntireCell??!1,g=n?.matchCase??!1,m=n?.useRegex??!1,f=((E,x,I)=>{const v=x?"":"i";return I?new RegExp(E,v):new RegExp((R=>{let A=R.replace(/[|\\{}()[\]^$+.]/g,"\\$&");return A=A.replace(/~\?/g,"\\?"),A=A.replace(/~\*/g,"\\*"),A=A.replace(/~~/g,"~"),A})(E),v)})(t,g,m),_=t.length;let p=(E,x)=>{const I=A=>{if(!A)return!1;let M=!!A.match(f);return M&&d&&A.length!==_&&(M=!1),M},v=x.getCell();let R=!1;return!R&&h?R=I(v.getFormulaText()??v.toTextUnformatted(!0)):u&&(R=I(v.getNumberFormat().displayText)),R};if(n?.matchCustom){const E=n.matchCustom,x={matchCase:g,matchEntireCell:d,useRegex:m,fields:n?.fields??[exports.ICell.Content.Formulas]};let I,v,R=p;const A=()=>R(I,v);p=(M,T)=>(I=M,v=T,E(M,A,x,T))}let S=-1,C=null,y=Re,b=!1;const w=()=>{if(y.done){if(S++,S>=r.length)return void(b=!0);C=this._cellIterator({reverse:i,orientation:o,includeRangeTypes:!1,bounds:r[S]})}if(y=C.next(),!y.done){const E=y.value;return p(E.value,E.context)}return!1};return{next:()=>{let E=null;for(;!b&&!E;)w()&&(E=y.value.context.getCell());return E?{value:E,done:!1}:Re}}}isDate1904(){return this._isDate1904}_surroundingRegion(e,t){const n=this._getState(),r=t?.contentOnly??!1,o=this._entireCoords;if(!r){const l=n.tableSpatial.search(e);if(l.length>0){const c=l[0].value.model,h=c.getUsedRange().getCoords(),u=c.getRange().getCoords();return k.isEqualRanges(h,e)?u:k.isEqualRanges(u,e)?o:h}}const i=r?e:o;return((l,c,h=2e4)=>{if(!c||c.length===0)return null;let u,d=!1;for(let b=0;b<c.length;b++){const w=c[b];u=k.unionRanges(u,w.getBoundingCoords()),d=d||w.search(l).length>0}if(!u)return null;const g={...k.EmptyRange},m=l;let f=d?{...l}:null;if(!f){const b=x=>{let I=[];const v=c.length;for(let R=0;R<v;R++){const A=c[R].search(x),M=A.length;I=M>0?new Array(M):void 0;for(let T=0;T<M;T++){const N=A[T];I[T]=N}}return I||F.EmptyArray},w=b({colStart:l.colEnd,rowStart:l.rowEnd,colEnd:l.colEnd+1,rowEnd:l.rowEnd+1}),E=w.length;if(E>0){f={...l};for(let x=0;x<E;x++){const I=w[x];f.colEnd=Math.max(f.colEnd,I.colStart),f.rowEnd=Math.max(f.rowEnd,I.rowStart)}}}const _={...k.EmptyRange},p=()=>{const b=c.length;for(let w=0;w<b;w++){const E=c[w].search(g),x=E.length;for(let I=0;I<x;I++){const v=E[I];f=k.unionRanges(f,v,_)}}return f};g.colStart=l.colStart,g.rowStart=l.rowStart,g.colEnd=l.colEnd,g.rowEnd=l.rowEnd,p();const S={...f},C={...k.EmptyRange};let y=0;do{if(g.colStart=C.colStart=S.colStart,g.rowStart=C.rowStart=S.rowStart,g.colEnd=C.colEnd=S.colEnd,g.rowEnd=C.rowEnd=S.rowEnd,S.colStart>u.colStart&&(g.colStart=S.colStart-1,g.colEnd=S.colStart-1,g.rowStart=S.rowStart-1,g.rowEnd=S.rowEnd+1,p()),S.rowStart>u.rowStart&&(g.rowStart=S.rowStart-1,g.rowEnd=S.rowStart-1,g.colStart=S.colStart-1,g.colEnd=S.colEnd+1,p()),S.colEnd<u.colEnd&&(g.colStart=S.colEnd+1,g.colEnd=S.colEnd+1,g.rowStart=S.rowStart-1,g.rowEnd=S.rowEnd+1,p()),S.rowEnd<u.rowEnd&&(g.rowStart=S.rowEnd+1,g.rowEnd=S.rowEnd+1,g.colStart=S.colStart-1,g.colEnd=S.colEnd+1,p()),!f)return null;if(S.colStart=f.colStart,S.rowStart=f.rowStart,S.colEnd=f.colEnd,S.rowEnd=f.rowEnd,k.isEqualRanges(S,C))return k.isEqualRanges(m,S)?null:S;if(k.isEqualRanges(S,m))return null;if(k.isEqualRanges(S,C))return S;y++}while(y<h);return null})(e,[n.contentfulSpatial,n.mergeSpatial,n.formulaSpatial,n.spillSpatial,n.pendingSpatial])||i}_extendRange(e,t){if(this._closed)throw new Error(St);const n=this._entireCoords,r=this,o={excludeHidden:!0,onEntry:(h,u)=>u},i={excludeHidden:!0,onEntry:(h,u)=>h.tvTl()===void 0?null:u};let a;const l=r._getRangedEntries("mergeSpatial",[k.cellToRange(t)],i);l.length>0&&(a=l[0]);const c=[h=>r._getRangedEntries("mergeSpatial",h,i),h=>r._getRangedEntries("contentfulSpatial",h,o)];return((h,u,d,g,m)=>{let f,_,p,S={...u},C=k.cellToRange(S),y=g(C).length>0;if(y){let w=1,E=h===exports.w.Direction.Up||h===exports.w.Direction.Down;d&&(w+=E?d.rowEnd-d.rowStart:d.colEnd-d.colStart),h!==exports.w.Direction.Left&&h!==exports.w.Direction.Up||(w=-w),E?S.rowIndex=S.rowIndex+w:S.colIndex=S.colIndex+w,C=k.cellToRange(S),y=g(C).length>0}switch(h){case exports.w.Direction.Up:C.rowStart=Math.min(m.rowStart,C.rowStart),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Row,!0)),f=u.rowIndex,p=y?_.length===1&&f===_[0].rowStart?m.rowStart:_[0].rowStart:_.length===0?m.rowStart:_[0].rowEnd;break;case exports.w.Direction.Down:C.rowEnd=Math.max(m.rowEnd,C.rowEnd),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Row,!1)),f=u.rowIndex,p=y?_.length===1&&f===_[0].rowEnd?m.rowEnd:_[0].rowEnd:_.length===0?m.rowEnd:_[0].rowStart;break;case exports.w.Direction.Left:C.colStart=Math.min(m.colStart,C.colStart),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Column,!0)),f=u.colIndex,p=y?_.length===1&&f===_[0].colStart?m.colStart:_[0].colStart:_.length===0?m.colStart:_[0].colEnd;break;case exports.w.Direction.Right:C.colEnd=Math.max(m.colEnd,C.colEnd),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Column,!1)),f=u.colIndex,p=y?_.length===1&&f===_[0].colEnd?m.colEnd:_[0].colEnd:_.length===0?m.colEnd:_[0].colStart}if(y&&_.length>1){let w=!1;for(let E=1;!w&&E<_.length;E++){const x=_[E];switch(h){case exports.w.Direction.Up:x.rowEnd<p-1?w=!0:p=Math.min(p,x.rowStart);break;case exports.w.Direction.Down:x.rowStart>p+1?w=!0:p=Math.max(p,x.rowEnd);break;case exports.w.Direction.Left:x.colEnd<p-1?w=!0:p=Math.min(p,x.colStart);break;case exports.w.Direction.Right:x.colStart>p+1?w=!0:p=Math.max(p,x.colEnd)}}}const b=k.cellToRange(u);switch(h){case exports.w.Direction.Up:b.rowStart=p;break;case exports.w.Direction.Down:b.rowEnd=p;break;case exports.w.Direction.Left:b.colStart=p;break;case exports.w.Direction.Right:b.colEnd=p}return b})(e,t,a,h=>{const u=[],d=[h],g=c.length;for(let m=0;m<g;m++){const f=(0,c[m])(d),_=f.length;for(let p=0;p<_;p++){const S=f[p];u.push(S)}}return u},n)}_defaultFontDims(){if(this._defaultFontBoundsCache)return this._defaultFontBoundsCache;const e=this._styles.getNormal();let t=0,n=0;for(let r=0;r<=9;r++){const o=e.measureText(r.toString());t=Math.ceil(Math.max(o.width,t)),n=Math.max(o.lineHeight,n)}return this._defaultFontBoundsCache={width:t,height:n},this._defaultFontBoundsCache}getColumnWidthAsFontUnit(e){const t=Math.round(this._defaultFontDims().width),n=e/(this.getView().isShowFormulas()?2:1);if(!t||!e)return 0;let r=5;return n<r+t&&(r=n*(r/(r+t))),(n-r)/t}_defaultColWidth(){if(this._defaultColWidthCache)return this._defaultColWidthCache;const e=this._defaultFontDims()?.width||7,t=8*Math.round((8*e+5)/8);return this._defaultColWidthCache=t}_defaultRowHeight(){if(this._defaultRowHeightCache)return this._defaultRowHeightCache;let e=this._defaultFontDims();if(!e||e.width===0)return this._defaultRowHeightCache=20/exports.IFont.getDeviceScale(),this._defaultRowHeightCache;const t=this._styles.getNormal(),n=new Map;let r=e.height+2;return this._colHeaders.getUsedRange().forEachSpan((o,i)=>{const a=i.getCellHeader();a?.getStyle()!==t&&(r=Math.max((l=>{let c=n.get(l);return c===void 0&&(c=l.measureText("M").lineHeight+2,n.set(l,c)),c})(a.getStyle()),r))}),this._defaultRowHeightCache=Math.round(r/exports.IFont.getDeviceScale()*4)/4,this._defaultRowHeightCache}getProtection(){return this._protection??null}async _selectSheet(e,t){if(await this._options.container?.requestSelect?.()===!1)return!1;if(t===!1)return!0;const n={coords:e};t!==!0&&t!==void 0&&(n.scrollIntoView=t);const r=await this._emitter.notify("onRequestScrollIntoView",{params:n,async:!0});if(!r)return!1;const o=r.length;for(let i=0;i<o;i++)if(r[i]===!1)return!1;return!0}async scrollTo(e,t){const n={...t,coords:e},r=await this._emitter.notify("onRequestScrollIntoView",{params:n,async:!0});if(!r)return!1;const o=r.length;for(let i=0;i<o;i++)if(r[i]===!1)return!1}async _commitAndAutoSelect(e,t,n=!1,r){return r={...r,viewAfter:{view:this.getView(),selection:t,selectOptions:n,...r?.viewAfter}},e.commit(r),this._autoSelect(n,t)}async _autoSelect(e,t){if(!e)return;e===!0&&(e={autoFocus:!0,scrollIntoView:!0});const n=e?.autoFocus,r=e?.scrollIntoView,o=e?.anchor,i=this.getSelection().getCoords(),a=Ar(t??i),l=this._entireCoords,c=((f,_,p)=>{if(!f||f.length===0||!_)return F.EmptyArray;const S=[...f];for(let C=0;C<S.length;C++){const y={...S[C]};let b=y;const w=_.search(y),E=y.rowStart<=p.rowStart&&y.rowEnd>=p.rowEnd,x=y.colStart<=p.colStart&&y.colStart>=p.colEnd;for(let I=0;I<w.length;I++){const v=w[I];E||(b.colStart=Math.min(b.colStart,v.colStart),b.colEnd=Math.max(b.colEnd,v.colEnd)),x||(b.rowStart=Math.min(b.rowStart,v.rowStart),b.rowEnd=Math.max(b.rowEnd,v.rowEnd))}S[C]=b}return S})(a,this._getState().mergeSpatial,l);let h=-1,u=null;if(!o){const f=i?.cell;for(let _=0;h===-1&&_<c.length;_++){const p=c[_];k.isCellWithinRange(f,p)&&(h=_,u=f)}}const d=co(c,u,h);this.getSelection().updateCoords(d);const g=d.ranges?.[d.rangeIndex]??k.cellToRange(d.cell),m=await this._selectSheet(g,r);if(r!==!1&&m===!1)return c;if(n!==!1){const f=await this._emitter.notify("onRequestFocus");if(!f)return c;const _=f.length;for(let p=0;p<_;p++)if(f[p]===!1)return c}return c}getSelection(){return this._rangeSelection}getView(){return this._view}setView(e){if(this._closed)throw new Error(St);if(!e)throw new Error("View can not be empty.");this._viewRemoveListener?.(),this._view=e,this._viewRemoveListener=e.addListeners(this._viewListener,{transactional:!1});const t=this.getSelection().getCoords();return this._rangeSelection.updateCoords(t),this._emitter.notify("onMovableSelectionChange"),this._emitter.notify("onTopLeftChange"),this._emitter.notify("onFreezeSplitChange"),this._emitter.notify("onViewChange",{source:e}),this}getTabColor(){return this._tabColor}setTabColor(e){if(this._closed)throw new Error(St);return this._tabColor=typeof e=="string"?this._styles.parseColor(e):e??null,this._emitter.notify("onTabColorChange"),this}getRowHeaders(){return this._rowHeaders}getColumnHeaders(){return this._colHeaders}async toJSON(e=!1){if(this._closed)throw new Error(St);await this._emitter.notify("onBeforeSave",{async:!0}),await Promise.resolve(this._starting);let t={};const n=this._getState();if(!n)return t;try{const _=this._strings.beginPersist();try{if(!e){const b=[],w=this._cellStateIterator({includeRangeTypes:!1,orientation:exports.w.Orientation.Column});let E=w.next(),x=Number.MIN_SAFE_INTEGER,I=Number.MIN_SAFE_INTEGER,v=null,R=null,A=null,M=null;for(;!E.done;){const T=E.value[0],N=T.colIndex,B=T.rowIndex;N!==x&&(M&&b.push(M),v=[],A=[],M=[N,A],x=N,I=B-2),B>I+1&&(v=[],R=[B,v],A.push(R));const D=E.value[1],P=Ze(D);let L;if(P===U.Number||P===U.Boolean)L=D;else if(P===U.String)L=""+_.add(D);else if(P===U.Error)L={t:P,v:D.getCode()};else if(P===U.RichData){const z=D,O=z.type,j=z?.toJSON?.();O&&j&&(L={t:P,v:0})}else console.warn("error",L);v.push(L),I=B,E=w.next()}M&&b.push(M),b.length>0&&(t.data=b)}this._ownStrings&&(t.strings=await _.toJSONAsync())}catch(b){console.warn("error",b)}finally{_.endPersist()}const p=this._colHeaders.toJSON();p&&(p.headers&&p.headers.length>0&&(t.cols=p.headers),p.defaultSize!==void 0&&p.defaultSize!==-1&&(t.defaultColSize=p.defaultSize));const S=this._rowHeaders.toJSON();S&&(S.headers&&S.headers.length>0&&(t.rows=S.headers),S.defaultSize!==void 0&&S.defaultSize!==-1&&(t.defaultRowSize=S.defaultSize));const C=this.getProtection().toJSON();C&&(t.protection=C),this._view.setRangeSelection(this.getSelection().getCoords());const y=this._view.toJSON();y&&(t.view=y),this._tabColor&&(t.tabColor=this._tabColor.toString())}catch(_){console.warn(_)}const r=Fn(n.mergeSpatial.all());r.length>0&&(t.merges=_c(r));const o=Fn(n.directStyleSpatial.all());if(o.length>0){const _=this._styles.beginPersist();try{const p=[],S=o.length;for(let C=0;C<S;C++){const y=o[C],b=_.getElementID(y.value.toJSON());p.push({r:exports.AddressUtils.rangeToString(y),v:b})}if(t.directStyles=p,this._ownStyles){const C=_.toJSON();C&&Object.keys(C).length>0&&(t.styles=C)}}catch(p){console.warn(p)}finally{_.endPersist()}}const i=Fn(n.hyperlinkSpatial.all()),a=i.length;if(a>0){const _=[];for(let p=0;p<a;p++){const S=i[p];let C=S.value;_.push({r:exports.AddressUtils.rangeToString(S),v:C})}t.hyperlinks=_}const l=Fn(n.commentsSpatial.all()),c=l.length;if(c>0){const _=[];for(let p=0;p<c;p++){const S=l[p],C={...S.value};C.ref=exports.AddressUtils.rangeToString(S),_.push(C)}t.comments=_}const h=this._resources.beginPersist();try{const _=this.getMovables().search(),p=_.length;if(p>0){const S=[];for(let C=0;C<p;C++)try{const y=_[C].toJSON(h.toResourceId.bind(h));y&&S.push(y)}catch(y){console.warn("Unable to persist movable",y)}S.length>0&&(t.movables=S)}this._ownResources&&(t.resources=await h.toJSONAsync())}catch(_){console.warn(_)}finally{h.endPersist()}const u=Fn(n.tableSpatial.all()),d=u.length;if(d>0){const _=[];for(let p=0;p<d;p++){const S=u[p].value.model.toJSON();_.push(S)}t.tables=_}const g=Array.from(n.conditionalModels.values()),m=g.length;if(m>0){const _=[];for(let p=0;p<m;p++){const S=g[p].model.toJSON();_.push(S)}t.conditionals=_}const f=await n.calcGraph.toJSON(!1);if(f){const _=f.formulas;_&&(t.formulas=_);const p=f.dynamic;p&&(t.dynamicArray=p);const S=f.volatile;S&&(t.volatile=S)}return this._emitter.notify("onSave",{params:t}),t}getStyles(){return this._styles}getResources(){return this._resources}getTransactions(){return this._transactions}getStrings(){return this._strings}_searchMovables(e){const t=e?.excludeHidden??!1,n=e?.bounds,r=e?.fullyContained,o=this,i=e?.address?this._rangeToCoords(e?.address):this._entireCoords;return this._getRangedEntries("movableSpatial",[i],{excludeHidden:t,fullyContained:r,onEntry:c=>{if(e?.type&&c.model.getContent().getType()!==e.type)return null;let h=null;if(t&&(c.model.isHidden()||(h=o._getBoundsAtCoords(c.model.getAnchorCoords()),h.width===0||h.height===0)))return null;if(n){h||(h=o._getBoundsAtCoords(c.model.getAnchorCoords()));const u=h,d=n;if(u.y>d.y+d.height||u.y+u.height<d.y||u.x>d.x+d.width||u.x+u.width<d.x)return null}return c.model}}).sort((c,h)=>c.getZIndex()-h.getZIndex())}_updateSelectedMovables(e,t){const n=this.getView().getMovableSelection();if(!n||n.length===0)return;let r="Movables";if(n.length===1){const i=n[0];r=jr(i.getContent().getType())??"Drawing"}const o=this._beginCommit({description:`${t} ${r}`});try{const i=n.length;for(let a=0;a<i;a++)e(n[a]);o.commit()}catch(i){throw o.rollback(),i}}async _addMovable(e){if(!this.getProtection().isObjectsAllowed())throw new Error(Bu);if(!e)throw new Error("No movable options provided");if(this._closed)throw new Error(St);const t={};e?.type&&(t.content={type:e.type,json:e?.json}),e?.anchorType&&(t.anchorType=e?.anchorType),e.bounds&&(t.anchor=null);const n=this._getState().movableSpatial,r=this._beginCommit({description:e?.description??"Insert Drawing"}),o=this._createMovableEntry(t,n.size(),e.fromResourceId),i=n.clone();i.insert(o);const a=this._getState().movableMapModel,l=new Map(a),c=o.value.model;l.set(c,o),this._updateState({movableSpatial:i,movableMapModel:l}),e.bounds&&o.value.model.setBounds(e.bounds,e);let h=null,u=null;if(e?.autoSelect!==!1){h={view:this.getView(),movableSelection:this.getView().getMovableSelection()};let d=e?.autoSelect??!1;d===!0&&(d={autoFocus:!0,scrollIntoView:!0,addToSelection:!1}),d&&this.getView().selectMovables([o.value.model],d.addToSelection),u=g=>({...g,view:this.getView(),movableSelection:this.getView().getMovableSelection()})}return r.commit({viewBefore:h,viewAfter:u}),this._emitterMovables.notify("onCollectionChange"),this._emitter.notify("onMovablesChange"),o.value.model}async _addImage(e,t={type:"picture"}){if(!e)throw new Error("An image must be provided as a string or a resource option.");if(!this.getProtection().isObjectsAllowed())throw new Error(Bu);const n=this._resources.add(e),r=await n.toBuffer(),o=await n.getType(),i=this._getBoundsAtCoords(Ar(this.getSelection().getCoords())[0]),{naturalDimensions:a,asUrl:l}=await Bo.loadImageDetails(r,o);URL.revokeObjectURL(l);const c={...i,...a,...t?.bounds};if(F.isNullOrUndefined(t?.bounds?.x)||F.isNullOrUndefined(t?.bounds?.y)){const u=Dd(this.getMovables(),c,F.isNullOrUndefined(t?.bounds?.x),F.isNullOrUndefined(t?.bounds?.y));c.x+=u.x,c.y+=u.y}t?.bounds&&t?.json?.lockAspect!==!1&&(F.isNullOrUndefined(t?.bounds.width)&&F.isDefined(t?.bounds.height)&&(c.width=c.height*a.width/a.height),F.isNullOrUndefined(t?.bounds.height)&&F.isDefined(t?.bounds.width)&&(c.height=c.width*a.height/a.width));const h={...t?.json,resId:0};return await this._addMovable({anchorType:exports.IAnchored.Type.OneCell,description:"Insert Image",...t,bounds:c,type:"picture",json:h,fromResourceId:u=>u!==0?(console.warn("received an unexpected resourceId",u),null):n})}getTables(){return this._tables}getConditionals(){return this._conditionals}getMovables(){return this._movables}_doPerfTest(e=1e7,t=!1){const n=Array.from({length:e},(l,c)=>c);let r,o;r=performance.now(),t&&console.profile("nativeArray");const i=[e];for(let l=0;l<e;l++)i.push(l);t&&console.profileEnd("nativeArray"),window.noLoseArray=i,o=performance.now(),console.log(`NativeArray: ${e} records in ${o-r} milliseconds`),r=performance.now(),t&&console.profile("mixedType");const a=Ri.fromArray(n);t&&console.profileEnd("mixedType"),window.noLoseList=a,o=performance.now(),console.log(`MixedTypedList: ${e} records in ${o-r} milliseconds`)}_validateOrRemoveOverlaps(e,t,n=null,r=!1){const o=this;t!=="merge"&&Eu(this._getMerges([e]),e,(c,h)=>{if(h||!r)throw new Error(Du(t));o._unmerge([c])});const i=[],a=this.getTables().search({address:e}),l=a.length;for(let c=0;c<l;c++){const h=a[c];n!==h&&i.push(h.getAnchorCoords())}Eu(i,e,(c,h,u)=>{if(h||!r)throw new Error(Du(t));a[u].delete()})}_addTable(e,t){let n=this._rangeToCoords(e,()=>["objects"]);const r=this._entireCoords;let o=t?.hasHeader;if(n.rowStart===n.rowEnd){if(n.rowEnd===r.rowEnd)throw new Error("A table must have a least two rows; one for the table header and one for data.");n.rowEnd=n.rowEnd+1}o===void 0&&(o=ud(this,n)?.options?.hasHeader??!1);const i=De([n]),a={...n},l=this._beginCommit({description:"Insert Table"});let c=null;try{o||(this._isContentful([n])&&this._insertCells([{...n,rowStart:n.rowStart,rowEnd:n.rowStart}],exports.w.Orientation.Row),n={...n,rowEnd:n.rowEnd+1});const h={...t?.json,ref:n};this._validateOrRemoveOverlaps(n,"table",null,!0),h.styleOptions=t?.json?.styleOptions??{},h.styleOptions.name===void 0&&(t?.styleName?h.styleOptions.name=t.styleName:t?.styleName===void 0&&(h.styleOptions.name=this._styles.getDefaultTableStyle().getName()));const u=t?.isLoad;u!==!0&&(h.filter===void 0&&(h.filter={}),h.sort===void 0&&(h.sort={}));const d=this._createTableEntry(h,o&&!u),g=this._getState(),m=g.tableSpatial.clone();m.insert(d);const f=g.tableMapModel,_=new Map(f),p=d.value.model;_.set(p,d);const S=g.tableMapName,C=new Map(S);C.set(p.getName().toLocaleLowerCase(),p),t?.clearFormatting&&this.getRange(n).updateStyle(null),c=d.value.model,this._updateState({tableSpatial:m,tableMapModel:_,tableMapName:C}),this._emitter.notify("onTablesChange"),u||this._autoFit([c.getHeaderRange().getCoords()],{expandOnly:!0});const y=De([n]);l.commit({viewBefore:{view:this.getView(),selection:i,ranges:[a]},viewAfter:{view:this.getView(),selection:y,ranges:[n]}})}catch(h){throw l.rollback(),h}return c}_addConditional(e,t){const n=this._rangesToCoords(e,()=>["objects"]),r=t?.autoSelect?De(n):null,o=[...n],i=this._beginCommit({description:t?.description??"Insert Conditional"});let a=null;try{const l={...t,ref:o},c=this._getState(),h=c.conditionalSpatial.clone(),u=new Map(c.conditionalModels),d=this._createConditionalEntries(l,h,u);this._updateState({conditionalSpatial:h,conditionalModels:u}),a=d,i.commit({viewBefore:{view:this.getView(),selection:r,ranges:o},viewAfter:{view:this.getView(),selection:r,ranges:o}}),this._autoSelect(t?.autoSelect,r)}catch(l){throw i.rollback(),l}return a}createTemporaryCell(e,t=null){return e?.createTemporaryCell?e:(t?this.getRange(t).getCell():this._emptyCell).createTemporaryCell(e)}_getBoundsAtCoords(e){const t=this._rowHeaders,n=this._colHeaders,r=n.findOffset(e.colStart),o=t.findOffset(e.rowStart);return{x:r,y:o,width:n.findOffset(e.colEnd+1)-r,height:t.findOffset(e.rowEnd+1)-o}}_getCoordsAtBounds(e){const t=this._rowHeaders,n=this._colHeaders;return{colStart:n.findIndex(e.x),rowStart:t.findIndex(e.y),colEnd:n.findIndex(e.x+e.width),rowEnd:t.findIndex(e.y+e.height)}}getRangeAtBounds(e,t){if(!e)throw new Dt;const n=this._getCoordsAtBounds(e);return this.getRange(n,t)}_getVisible(e,t){if(e.length===0)return e;const n=new Ie;n.load(e);const r=t?.orientations??exports.w.Orientations.Both,o=(a,l)=>{const c=n.search(a),h=c.length;for(let u=0;u<h;u++){const d=c[u],g=jl(d,a,l);n.remove(d),n.load(g)}},i=this._cellOptions.maxCoords;if(r===exports.w.Orientations.Both||r===exports.w.Orientations.Row){const a=this._rowHeaders,l=e.length;for(let c=0;c<l;c++){const h=e[c];a.getRange({min:h.rowStart,max:h.rowEnd}).forEachSpan((u,d)=>{if(u!==0)return;const g=d.getCoords();o({colStart:i.colStart,rowStart:g.min,colEnd:i.colEnd,rowEnd:g.max},exports.w.Orientation.Row)})}}if(r===exports.w.Orientations.Both||r===exports.w.Orientations.Column){const a=this._colHeaders,l=e.length;for(let c=0;c<l;c++){const h=e[c];a.getRange({min:h.colStart,max:h.colEnd}).forEachSpan((u,d)=>{if(u!==0)return;const g=d.getCoords();o({colStart:g.min,rowStart:i.rowStart,colEnd:g.max,rowEnd:i.rowEnd},exports.w.Orientation.Column)})}}return n.all()}_hasRangedEntries(e,t){const n=this._getState();if(!n)return F.EmptyArray;const r=n[e];if(!r)throw new Error(`Invalid range key ${e}`);return!(!r||r.isEmpty())&&r.has(t)}_getRangedEntries(e,t,n){if(t.length===0)return F.EmptyArray;const r=n?.excludeHidden??!1,o=n?.fullyContained??!1,i=n?.onEntry??null,a=this._getState();if(!a)return F.EmptyArray;const l=a[e];if(!l)throw new Error(`Invalid range key ${e}`);if(!l||l.isEmpty())return F.EmptyArray;const c=new Set,h=_=>{const p=_.length;for(let S=0;S<p;S++){const C=_[S];c.add(C)}},u=t.length;for(let _=0;_<u;_++){const p=t[_];if(r){if(r===!0){const S={min:p.colStart,max:p.colEnd},C={min:p.rowStart,max:p.rowEnd};this._rowHeaders.getRange(C).forEachVisibleSpan((y,b)=>{this._colHeaders.getRange(S).forEachVisibleSpan((w,E)=>{h(l.search({colStart:w,rowStart:y,colEnd:E,rowEnd:b},o))},Ds)},Ds)}else if(r===exports.w.Orientation.Column){const S={min:p.colStart,max:p.colEnd};this._colHeaders.getRange(S).forEachVisibleSpan((C,y)=>{h(l.search({colStart:C,rowStart:p.rowStart,colEnd:y,rowEnd:p.rowEnd},o))},Ds)}else if(r===exports.w.Orientation.Row){const S={min:p.rowStart,max:p.rowEnd};this._rowHeaders.getRange(S).forEachVisibleSpan((C,y)=>{h(l.search({colStart:p.colStart,rowStart:C,colEnd:p.colEnd,rowEnd:y},o))},Ds)}}else h(l.search(p,o))}if(c.size===0)return F.EmptyArray;const d=Array.from(c.values()),g=n?.sort;g&&d.sort(k.createRangeComparator(g.orientation,g.reverse));let m=[];const f=d.length;for(let _=0;_<f;_++){let p;p=void 0,i&&(p=i(d[_].value,d[_])),p===void 0&&(p=d[_].value),p!==null&&m.push(p)}return m||(m=F.EmptyArray),m}_processAnchorShift(e){let t=e.after;const n=k.sanitizeRange(e.after),r=k.sanitizeRange(e.before);e.after&&this._validateCoords(n,"We can't insert cells because this would push items off the end of the worksheet.");const o=e.before.value.processShiftCallback?.({...e,after:n,before:r});return o&&(Oo(o,n)||(t||(t=e.before),t={...t,...o})),t}_processListenerShift(e,t,n,r){if(r.isSplit||r.before.value.options.ignoreShifts)return[r.before];let o=null;r.after&&(o=k.intersectRanges(k.sanitizeRange(r.after),this._entireCoords),r.after,o.colStart,o.rowStart,o.colEnd,o.rowEnd);const i=r.before.value,a=i.id,l=e.get(a),c={...l},h=[...l.ranges];c.ranges=h,h[i.offset]=o?{...h[i.offset],...o}:null,e.set(a,c);const u=n.get(a);t.set(a,{beforeState:u,afterState:c})}delete(){if(this._closed)return;try{this._emitter.notify("onBeforeDelete")}catch(i){throw i instanceof Error?i:new Error(i.message??"Unable to delete.")}const e=this._beginCommit({description:`Delete Sheet '${this.getName()}'`}),t=this._getState();let n=t.rangeListenerSpatial,r=t.rangesListenerMap;const o=new Map;n=n.shift({range:this._entireCoords,direction:exports.w.Direction.Left,cloneIfUpdate:n===t.rangeListenerSpatial,onShift:i=>{r===t.rangesListenerMap&&(r=new Map(r)),this._processListenerShift(r,o,t.rangesListenerMap,i)}}),this._updateState({rangeListenerSpatial:n,rangesListenerMap:r,deleted:!0}),this._deleteCells([this._entireCoords]),this._emitter.notify("onDelete"),this._rangesListenerMap.forEach((i,a)=>{o.set(a,{beforeState:i,afterState:null})}),e.commit({viewAfter:i=>({...i,view:this.getView(),selection:this.getSelection().getCoords(),listeners:o})})}doBatch(e,t){const n=this;return t=typeof t=="string"?{description:t}:{description:"Update Sheet",...t},this._transactions.doBatch(e,t,(r,o)=>{if(r.getDepth()===0&&(n._lastTransactionUUID=r.getId(),t?.autoSelect)){const i=r.getView()?.selection;i&&n._autoSelect(!0,i)}})}isClosed(){return this._closed}close(){if(this._closed)return;this._protectionRemoveListener?.(),this._protection=new Ud(void 0,this._options.readonly);const e=this._getState().tableMapModel.keys();for(const t of e)t.close();this._searchMovables().forEach(t=>{t.close()}),this._emitter.notify("onClose"),this._ownResources,this._namesRemoveListener?.(),this._ownNames&&this._names.close(),this._ownsCalculation&&this._calculation.close(),this._ownStyles,this._colHeaders.close(),this._rowHeaders.close(),this._emitter.close(),this._transactionsRemoveListener?.(),this._closed=!0}beginCommit(e){if(this._closed)throw new Error(St);return this._beginCommit(typeof e=="string"?{description:e}:e)}_getState(){return this._closed?null:this._transactions.getState(this)}_beginCommit(e){const t=this;return this._transactions.beginCommit(e,n=>{n.getDepth()===0&&(t._lastTransactionUUID=n.getId())})}_updateState(e){if(!e)return;this._lastGetRangeRead=null;const t=this._transactions.beginCommit();let n;try{n=t.updateState(this,e),t.commit()}catch(r){throw t.rollback(),r}return n}_addEvent(e,t){const n=this.getTransactions().getPendingView();if(!n)return;let r=n.events;if(r||(r={},n.events=r),e==="address"){let o=r.address;if(o||(o=new Map,r.address=o),typeof t=="string")o.set(t,null);else{const i=t;if(i.options.ignoreAddressChanges)return;o.set(i.uuid,t)}}else if(e==="data")if(typeof t=="string"){let o=r.dataListeners;o||(o=new Map,r.dataListeners=o),o.set(t,null)}else{let o=r.data;o||(o=[],r.data=o),o.push(t)}}_getScalar(e,t,n=!1){const r=this._getState();let o;if(o===void 0&&(o=r.cellValuesGrid.getValueAt(e,t)),o===void 0)return null;let i=o;if(n&&typeof i=="number"){let a=!1;Wt.colStart=t,Wt.rowStart=e,Wt.colEnd=t,Wt.rowEnd=e;const l=this._lastValueRead,c=this._lastValueRead.range;if(c&&k.isRangeWithinRange(Wt,c))a=l.isDateOrTime;else{const h=r.directStyleSpatial.search(Wt)[0];if(h){const u=h.value.getPropertiesAt(e,t,i),d=u?.numberFormat;d&&(a=Zo(d)||Wi(d)),l.range=h,l.isDateOrTime=a}else l.range=null;a&&(i=Jr(i,this._isDate1904))}}return i}getStyleUpdater(e,t){return null}_initState(){const e=this,t=()=>{e._lastCellDecoded.address=null,e._lastCellSelected.coords=null,e._lastCellRead.coords=null,e._lastValueRead.range=null,e._lastGetRangeRead={},e._lastUsedCoordsRead.coords=null,e._lastActiveRead.selection=null,e._lastRangeRead.address=null};this._transactionsRemoveListener=this._transactions.addStateListener(this,{onBeforeCommitStart(f,_,p){if(!e._initializing&&!_?.skipProtectionCheck&&e.getProtection().isLocked())throw new Error(Cs)},async onBeforeCommitEnd(f,_,p){if(_?.ranges){const S={isDataChange:!0,isTransactional:!0,timeStamp:p.getTimestamp(),trigger:"setCells"},C=f.rangeListenerSpatial,y=f.rangesListenerMap;e._notifyRangeListeners(C,y,_.ranges,S)}if(_?.listeners){const S={isDataChange:!1,isTransactional:!0,timeStamp:p.getTimestamp(),trigger:"shiftCells"},C=f.rangeListenerSpatial,y=f.rangesListenerMap;e._notifyRangeListeners(C,y,_.ranges,S)}},async onRestoreOrRevert(f,_,p,S){if(t(),e._calculateFull(),_&&(_.view===e.getView()&&_.selection&&e._autoSelect(!0,_.selection),_.movableSelection&&e.getView().selectMovables(_.movableSelection)),e._emitter.notify("onInvalidated"),e._emitterMovables.notify("onInvalidated"),e._notifyUsedRangeChange(),e._rangesListenerMap.size>0){const C={isDataChange:!0,isTransactional:!1,timeStamp:p.getTimestamp(),isUndo:S,trigger:"invalidate"},y=f.rangeListenerSpatial,b=f.rangesListenerMap,w=new Set;b.forEach((E,x)=>{const I=E.id;if(w.has(I))return;const v=E.ranges;v&&(w.add(I),e._notifyRangeListeners(y,b,v,C))})}},async onAfterStateChange(f,_,p,S,C){t(),_&&p.getId()!==e._lastTransactionUUID&&_.view===e.getView()&&_.selection&&(S||C)&&e._autoSelect(!0,_.selection),e._lastTransactionUUID=p.getId(),_?.merges&&e._notifyMergeChange();const y=e._rangesListenerSorted;if(y.size>0){e._notifyUsedRangeChange();const b=new Set,w=f.rangesListenerMap2,E={isTransactional:!1,timeStamp:p.getTimestamp()};if((C||S)&&(E.trigger="restore",e._notifyAddressListeners(w,w,b,E),y.size>w.size)){const I=y.values();let v=I.next(),R=!1;for(;!R&&!v.done;){const A=v.value;R=w.has(A.uuid),R||(A.notify(E,"#N/A"),v=I.next())}}const x=_?.events;x&&(x.address&&(E.trigger="address",e._notifyAddressListeners(w,x.address,b,E)),x.dataListeners&&(E.trigger="data",e._notifyAddressListeners(w,x.dataListeners,b,E)),x.data&&(E.trigger="data",e._notifyDataListeners(f.rangesListenerSpatial2,f.rangesListenerMap2,x.data,b,E)))}if(_&&_.ranges&&!_.initial&&f.calcGraph.calculate(),_?.ranges){e._notifyUsedRangeChange();const b=e._rangesListenerMap;if(b.size>0){const w={isDataChange:!0,isTransactional:!1,timeStamp:p.getTimestamp(),isUndo:S,trigger:"setCells"};e._notifyRangeListeners(e._rangeListenerSpatial,b,_.ranges,w)}}},onClose(){const f=e._getState();f&&f.movableSpatial.clear()}});const n=new wy({sheet:this}),r={onChange(){e._emitter.notify("onSelectionChange")}},o=n.addListeners(r,{transactional:!1});this._rangeSelection=n,this._rangeSelectionRemoveListener=o;const i=f=>{const _=e._getState();if(!_)return;const p=_.movableSpatial,S=f.length;for(let C=0;C<S;C++){const y=p.search(f[C]),b=y.length;for(let w=0;w<b;w++)y[w].value.processLayoutCallback?.()}};this._colHeadersListener={onSizesChange:(f,_)=>{const p=[];if(_){const S=_.length;for(let C=0;_&&C<S;C++){const y={colStart:_[C].min,rowStart:e._entireCoords.rowStart,colEnd:e._entireCoords.colEnd,rowEnd:e._entireCoords.rowEnd};p.push(y)}}i(p)}},this._rowHeadersListener={onSizesChange:(f,_)=>{const p=[];if(_){const S=_.length;for(let C=0;C<S;C++){const y=_[C],b={colStart:e._entireCoords.colStart,rowStart:y.min,colEnd:e._entireCoords.colEnd,rowEnd:e._entireCoords.rowEnd};p.push(b)}}i(p)}};let a=new Set;const l={onTopLeftChange(){e._emitter.notify("onTopLeftChange")},onFreezeSplitChange(){e._emitter.notify("onFreezeSplitChange")},onRangeSelectionChange(){const f=e.getSelection().getCoords();e._rangeSelection.updateCoords(f)},onMovableSelectionChange(f){const _=f.getMovableSelection(),p=new Map,S=new Set,C=e._getState().movableMapModel,y=_.length;for(let b=0;b<y;b++){const w=_[b];a.has(w)?a.delete(w):p.set(w,b),S.add(w)}a.forEach(b=>{C.get(b)?.value.processSelectionCallback(!1,!1)}),p.forEach((b,w)=>{C.get(w)?.value.processSelectionCallback(!0,b===0)}),a=S,e._emitter.notify("onMovableSelectionChange")},onAnyChange(){e._emitter.notify("onViewChange")}},c=new dl({sheet:this});this._view=c,this._clearState(),this._viewRemoveListener=c.addListeners(l,{transactional:!1}),this._viewListener=l,this._colHeadersRemoveListener?.();const h=()=>Math.round(this._defaultFontDims().width);this._colHeaders=new Wd({sheet:e,orientation:exports.w.Orientation.Column,maxSheetCoords:this._entireCoords,transactions:this._transactions,isProtected:()=>!e._initializing&&!e.getProtection().isFormatColumnsAllowed(),getTextAt:f=>{const _=this.getView().getColumnHeaderStyle();return _===exports.ISheetView.HeaderTextStyle.A1?Jd(f):_===exports.ISheetView.HeaderTextStyle.Zero?qd(f):_===exports.ISheetView.HeaderTextStyle.One?Xd(f):void 0},defaultSize:()=>{const f=this.getView().isShowFormulas()?2:1;return this._defaultColWidth()/h()*f},scaleFactor:h,maxSize:()=>255,setContainerShiftedCallback:f=>{this._colHeadersShiftCallback=f}}),this._colHeadersRemoveListener=this._colHeaders.addListeners(this._colHeadersListener,{transactional:!0}),this._rowHeadersRemoveListener?.();const u=exports.IFont.getDeviceScale();this._rowHeaders=new Wd({sheet:e,orientation:exports.w.Orientation.Row,maxSheetCoords:this._entireCoords,transactions:this._transactions,isProtected:()=>!e._initializing&&!e.getProtection().isFormatRowsAllowed(),getTextAt:f=>{const _=this.getView().getRowHeaderStyle();return _===exports.ISheetView.HeaderTextStyle.One?Xd(f):_===exports.ISheetView.HeaderTextStyle.Zero?qd(f):_===exports.ISheetView.HeaderTextStyle.A1?Jd(f):void 0},defaultSize:()=>this._defaultRowHeight(),scaleFactor:()=>u,minSize:()=>0,maxSize:()=>409,setContainerShiftedCallback:f=>{this._rowHeadersShiftCallback=f}}),this._rowHeadersRemoveListener=this._rowHeaders.addListeners(this._rowHeadersListener,{transactional:!0}),this._defaultFontBoundsCache=null,this._defaultColWidthCache=null,this._defaultRowHeightCache=null;const d={colStart:0,rowStart:0,colEnd:0,rowEnd:0},g=[d],m={excludeHidden:!0,sort:{orientation:exports.w.Orientation.Column,reverse:!1}};this._cellOptions={resolveRange:f=>{const _=this._rangesToCoords(f);return this._createRange(_[0],null)},date1904:this._isDate1904,sheet:this,normalStyleRanged:this._normalStyleRanged,colHeaders:this._colHeaders,styles:this._styles,maxCoords:this._entireCoords,getRange:this.getRange.bind(this),getProtection:this.getProtection.bind(this),calcGraph:()=>this._getState().calcGraph,nextContentful:(f,_,p=!1)=>{d.colStart=p?_:f.colIndex+1,d.rowStart=f.rowIndex,d.colEnd=p?f.colIndex-1:_,d.rowEnd=f.rowIndex,m.sort.reverse=p;const S=e._getRangedEntries("contentfulSpatial",g,m);if(!S||S.length===0)return _;const C=S[0],y=p?C.getState().colStart:C.getState().colEnd;return p?Math.min(y+1,f.colIndex):Math.max(y-1,f.colIndex)},opener:async(f,_,p,S)=>{if(f.startsWith("#")){f=f.substring(1);const C=this._rangesToCoords(f);return await this._autoSelect(_??!0,De(C)),!0}return window.open(f,p??"_blank",S),!0}},this._emptyCell=new Iw(this._cellOptions)}_clearState(){this._lastGetRangeRead=null,this._lastCellDecoded.address=null,this._lastCellSelected.coords=null,this._lastCellRead.coords=null,this._protectionRemoveListener?.(),this._protection=new Ud(void 0,this._options.readonly),this._protectionRemoveListener=this._protection.addListeners({onChange(){if(e._closed)throw new Error(St);e._getState().movableMapModel.forEach(a=>{a.value.processProtectionCallback?.()}),e._getState().tableMapModel.forEach(a=>{a.value.processProtectionCallback?.()}),e._emitter.notify("onProtectionChange")}}),this._stylesRemoveListener?.();const e=this;this._stylesRemoveListener=this._styles.addListeners({onAnyChange(){e._defaultColWidthCache=null,e._defaultRowHeightCache=null,e._defaultFontBoundsCache=null,e._emitter.notify("onLayoutChange"),e._emitter.notify("onStyleChange")}}),this._view.clear(!1),this._rangeListenerSpatial=new Ie,this._rangesListenerMap=new Map,this._rangesListenerSorted=new Se;const t=a=>{const l=e._getState().rangesListenerSpatial2;if(l.isEmpty())return;const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=l.search(u),g=d.length;for(let m=0;m<g;m++){const f=d[m].value.groupId;e._addEvent("data",f)}}},n=this._entireCoords,r=n.rowEnd,o=n.colEnd,i=this._calculation._createGraph({onCalculated(a){e._realizeCalcedValues(a)},getEntireCoords:()=>e._entireCoords,getSheetName:()=>e.getName()});i.addListeners({onStart(a){},onInvalidate:()=>{}}),this._updateState({rangesListenerSpatial2:new Ie({updateEntryOptions:{onShifted:a=>{let l=e._getState().rangesListenerMap2;if(l.size===0)return;l=new Map(l);const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=u.value.groupId;let g=l.get(d);g=g.processShift(u),e._addEvent("address",g),l.set(d,g)}e._updateState({rangesListenerMap2:l})},onRemoved:a=>{let l=e._getState().rangesListenerMap2;if(l.size===0)return;l=new Map(l);const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=u.value.groupId;let g=l.get(d);g=g.processRemove(u),e._addEvent("address",g),l.set(d,g)}e._updateState({rangesListenerMap2:l})}}}),rangesListenerMap2:new Map,cellValuesGrid:new Qt({orientation:this._isDataColumn?exports.w.Orientation.Column:exports.w.Orientation.Row}),formulaSpatial:new Ie,spillSpatial:new Ie,pendingSpatial:new Ie,calcErrorsSpatial:new Ie,calcGraph:i,directStyleSpatial:new Ie({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0,onUpdated:t,onRemoved:t}}),continuousFillSpatial:new Ie({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0}}),conditionalModels:new Map,conditionalSpatial:new Ie({updateEntryOptions:{onGroupUpdate(a,l){let c=e._getState().conditionalModels,h=c.get(l);if(!h)return;c=new Map(c);const u=h.spatials;h={...h},h.spatials=a,c.set(l,h),e._updateState({conditionalModels:c}),h.processCoordsChange({before:u,after:h.spatials})}}}),mergeSpatial:new Ie({updateEntryOptions:{getShifted:(a,l)=>l?(l.value=new Hd(k.sanitizeRange(l),a.value._tvTl,a.value._rsTl),l):null,getSplit(a,l){throw new Error("We can't insert through merges. Unmerge and try again.")},onUpdated:t,onRemoved:t}}),movableMapModel:new Map,movableSpatial:new Ie({updateEntryOptions:{getShifted(a,l,c){const h=a.value.processShiftCallback?.(c);let u=null;const d=new Map(e._getState().movableMapModel),g=a.value.model;return h?(u={...h,value:{...a.value}},d.set(g,u)):d.delete(g),e._updateState({movableMapModel:d}),u}}}),hyperlinkSpatial:new Ie({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}}),commentsSpatial:new Ie({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0,onUpdated:t,onRemoved:t}}),tableMapModel:new Map,tableMapName:new Map,tableSpatial:new Ie({updateEntryOptions:{getShifted(a,l,c){const h=new Map(e._getState().tableMapModel),u=a.value.model,d=a.value.processShiftCallback?.(c);let g=null;return d?(g={...d,value:{...l.value}},h.set(u,g)):h.delete(u),e._updateState({tableMapModel:h}),g}}}),filter:null,sort:null,rangeListenerSpatial:new Ie,rangesListenerMap:new Map,contentfulSpatial:new Ie({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0,onShifted:a=>{const l=e._getState().rangesListenerSpatial2;if(l.size()===0)return;const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=l.search({colStart:u.colStart,rowStart:u.rowStart,colEnd:o,rowEnd:r}),g=d.length;for(let m=0;m<g;m++){const f=d[m].value.groupId;e._addEvent("data",f)}}},onRemoved:t,onUpdated:t}}),unlockSpatial:new Ie({updateEntryOptions:{isMergeOnShift:!0}}),deleted:!1}),this._defaultFontBoundsCache=null,this._defaultColWidthCache=null,this._defaultRowHeightCache=null}_createTableEntry(e,t=!1){const n={model:null,processShiftCallback:null,processDeleteCallback:null,processProtectionCallback:null,currentName:null,removeListener:null};let r=null;r=typeof e.ref=="string"?Ft(e.ref,this._entireCoords):e.ref;const o={...r,value:n},i=this,a=()=>n.model?i._getState().tableMapModel?.get(n.model):o,l=(u,d)=>!(!k.isEqualRanges(u,d)||u.value.model!==d.value.model),c={transactions:this._transactions,sheet:this,names:this._names,readSheetHeader:t,json:e,maxRangeCoords:this._entireCoords,setNameOnContainer(u){const d=a().value;if(!d.currentName||d.currentName.toLowerCase()===u.toLowerCase())return;const g="Set Table Name";i._protectionCheck(()=>["objects"],void 0,g);const m=i._beginCommit({description:g});try{const f=i._getState()?.tableMapName,_=u.toLocaleLowerCase();if(f.has(_))throw new Error((S=>`Name must be unique: '${S}' is already in use.`)(u));const p=new Map(f);p.delete(d.currentName),d.currentName=_,p.set(_,d.model),i._updateState({tableMapName:p}),m.commit()}catch(f){throw m.rollback(),f}},setContainerCoords(u,d){if(!u)return;const g=i._rangeToCoords(u,()=>["objects"]),m=a();if(!m)return;const f=m.value.model;i._validateOrRemoveOverlaps(g,"table",f);const _=i._beginCommit({description:d?.description??"Resize Table"}),p=i._getState(),S=p.tableSpatial.clone(),C=p.tableMapModel,y=new Map(C);S.remove(m,l);const b={...m,...g};return S.insert(b),y.set(b.value.model,b),i._updateState({tableSpatial:S,tableMapModel:y}),_.commit({viewAfter:{view:i.getView(),selection:De([h.getAnchorCoords()])}}),g},deleteFromContainer(u){const d=a();if(!d)return;const g=d.value.model,m=u?.description??`Delete Table '${g.getName()}`;i._protectionCheck(()=>["objects"],void 0,m);const f=i._beginCommit({description:m}),_=i._getState(),p=_.tableSpatial.clone(),S=_.tableMapModel,C=new Map(S),y=_.tableMapName,b=new Map(y);p.remove(d,l),C.delete(g),b.delete(g.getName().toLocaleLowerCase()),d.value.processDeleteCallback?.(),i._updateState({tableSpatial:p,tableMapModel:C,tableMapName:b}),i._emitter.notify("onTablesChange"),f.commit({viewAfter:{sheet:i,view:i.getView(),selection:De([g.getAnchorCoords()])}})},setContainerDeleteCallback(u){const d=a()?.value??n;d&&(d.processDeleteCallback=u,d.removeListener?.())},isProtected:()=>!i._initializing&&i.getProtection().isLocked(),setContainerProtectionCallback(u){(a()?.value??n).processProtectionCallback=u},setContainerShiftCallback(u){(a()?.value??n).processShiftCallback=u},processTableUpdate(){i._notifyUsedRangeChange()},initialAnchor:r},h=new af(c);return o.value.model=h,o.value.removeListener=h.addListeners({onStyleChange(u){i._emitter.notify("onStyleChange")},onDelete(u){i._emitter.notify("onStyleChange")}},{transactional:!1}),o.value.currentName=h.getName().toLocaleLowerCase(),o}_createConditionalEntries(e,t,n){const r="Conditional Format",o=()=>["objects"],i=e??{};let a=null;const l=this._entireCoords;if(typeof i.ref=="string"){a=[];const p=i.ref.split(","),S=p.length;for(let C=0;C<S;C++){const y=Ft(p[C],l);y&&a.push(y)}}else a=Array.isArray(i.ref)?i.ref:[i.ref];const c=this,h=F.uuidV4(),u={model:null,removeListener:null,processCoordsChange:null,spatials:null};n.set(h,u);const d=()=>u.model?c._getState().conditionalModels.get(h):u;let g=p=>(console.log("default createSpatialEntry",p),null);const m=(p,S,C)=>{if(!u.model)return void(a=p);let y=S.spatials;if(y){const w=y.length;for(let E=0;E<w;E++)C.remove(y[E])}let b=[];if(p){const w=p.length;for(let E=0;E<w;E++){const x=p[E];b.push({...x,value:g(x)})}b.length>0&&C.insertGroup(b,h)}S.spatials=b},f=()=>{const p=d().spatials??a;return p?c.getRanges(p):null};var _;return u.model=(_={sheet:c,transactions:c._transactions,json:e,type:"conditional",setOnContainerCoordsChange:p=>{d().processCoordsChange=p},setCreateSpatial(p){g=p},setContainerRanges:(p,S)=>{const C=c._rangesToCoords(p,o);if(!u.model)return a=C,C&&C.length>0?c.getRanges(C):null;const y=c._beginCommit({description:S?.description??`Set ${r} Ranges`});let b=De(C);try{const w=c._getState();let E=w.conditionalSpatial;E=E.clone();let x=w.conditionalModels;x=new Map(x);let I=d();I={...I},x.set(h,I),m(C,I,E),c._updateState({conditionalSpatial:E,conditionalModels:x}),y.commit({viewBefore:{view:c.getView(),selection:De(f()?.getCoords())},viewAfter:{view:c.getView(),selection:b}}),c._autoSelect(S?.autoSelect,b)}catch(w){throw y.rollback(),w}return C&&C.length>0?c.getRanges(C):null},getContainerRanges:f,deleteFromContainer(p){let S=d();const C=c._beginCommit({description:p?.description??`Set ${r} Ranges`}),y=p?.autoSelect?De(S.spatials):void 0;try{const b=c._getState();let w=b.conditionalSpatial;w=w.clone();let E=b.conditionalModels;E=new Map(E),S={...S},m(null,S,w),E.delete(h),c._updateState({conditionalSpatial:w,conditionalModels:E}),this._commitAndAutoSelect(C,y,p?.autoSelect)}catch(b){throw C.rollback(),b}},isReadOnly:()=>!1,setContainerReadOnlyCallback(p){}},new yy({..._,createDescription:`New ${r}`})),u.removeListener=u.model.addListeners({onAnyChange(p){c._emitter.notify("onStyleChange")}},{transactional:!1}),m(a,u,t),u.model}_createMovableEntry(e,t,n){let r=null;if(e?.anchor)r={colStart:e.anchor.tl?.c??0,rowStart:e.anchor.tl?.r??0,colEnd:e.anchor.br?.c??0,rowEnd:e.anchor.br?.r??0},e.anchor.br?.x||(r.colEnd-=1),e.anchor.br?.y||(r.rowEnd-=1);else{const y=Ar(this.getSelection().getCoords())[0];r={colStart:y.colStart,rowStart:y.rowStart,colEnd:y.colEnd,rowEnd:y.rowEnd}}const o={model:null,processShiftCallback:null,processLayoutCallback:null,processDeleteCallback:null,processZIndexCallback:null,processSelectionCallback:null,processProtectionCallback:null,zIndex:t},i={...r,value:o},a=()=>o.model?h._getState()?.movableMapModel?.get(o.model):i,l=(y,b)=>!(!k.isEqualRanges(y,b)||y.value.model!==b.value.model),c=(y,b,w=!0)=>{if(d)return;const E=a();if(!E)return;const x=b??"Update Drawing";h._protectionCheck(()=>["objects"],void 0,x);const I=h._beginCommit({description:x}),v=h._getState()?.movableSpatial,R=v.clone(),A=h._getState()?.movableMapModel,M=new Map(A);y(E,R,M)!==!1&&(h._updateState({movableSpatial:R,movableMapModel:M}),w&&(h._emitterMovables.notify("onCollectionChange",{source:h,transactional:!0}),h._emitter.notify("onMovablesChange")),I.commit({viewAfter:T=>{if(i.value.model.isSelected()&&!T?.movableSelection?.includes(i.value.model)){const N=[...T?.movableSelection??[]];return N.push(i.value.model),{...T,view:this.getView(),movableSelection:N}}}}))},h=this,u=e.content.type;let d=!0;const g=(y,b,w,E)=>{const x=w.all().sort((D,P)=>D.value.zIndex-P.value.zIndex),I=b.value.zIndex;if((y=Math.max(0,Math.min(x.length-1,y)))===I)return!1;const v=[],R=[],A=[],M=I<y,T=D=>{const P=x[D];v.push(P);const L={...P,value:{...P.value,zIndex:M?D-1:D+1}};P.value.zIndex===I&&(L.value.zIndex=y),R.push(L),E.set(L.value.model,L),A.push(L)};if(M)for(let D=I;D<=y;D++)T(D);else for(let D=I;D>=y;D--)T(D);const N=v.length;for(let D=0;D<N;D++)w.remove(v[D],l);w.load(R);const B=A.length;for(let D=0;D<B;D++)A[D].value.processZIndexCallback?.()},m=()=>h._resources.beginPersist(),f=u==="picture",_={content:null,fromResourceId:n,defaultLockAspectRatio:f,beginPersistResource:m,getMaxBounds:()=>h._getBoundsAtCoords(h._entireCoords),transactions:this._transactions,getBoundsAtCoords:h._getBoundsAtCoords.bind(h),getCoordsAtBounds:h._getCoordsAtBounds.bind(h),scrollIntoView:y=>h._selectSheet(a()?.value.model.getAnchorCoords(),y),select:async y=>{const b=a()?.value.model;if(!b)return!1;try{h.getView().selectMovables([b],y?.addToSelection)}catch(E){return console.warn(E),!1}const w=await h._selectSheet(a()?.value.model.getAnchorCoords(),y?.scrollIntoView);return!y?.scrollIntoView||w!==!1},unselect:()=>{const y=a()?.value.model;return!!y&&(h.getView().unselectMovables([y]),!0)},isSelected:()=>h.getView().getMovableSelection().includes(a()?.value.model),setContainerSelectionCallback(y){(a()?.value??o).processSelectionCallback=y},moveToBackOnContainer:()=>{c((y,b,w)=>g(0,y,b,w),"Move to Back")},moveBackwardOnContainer:()=>{c((y,b,w)=>g(y.value.zIndex-1,y,b,w),"Move Backwards")},moveForwardOnContainer(){c((y,b,w)=>g(y.value.zIndex+1,y,b,w),"Move Forward")},moveToFrontOnContainer(){c((y,b,w)=>g(b.size()-1,y,b,w),"Move To Front")},getZIndex:()=>a()?.value.zIndex??0,setContainerZIndexCallback(y){(a()?.value??o).processZIndexCallback=y},setContainerCoords(y){if(!y)return;const b=h._rangeToCoords(y,()=>["objects"]);return c((w,E,x)=>{const I={...w,...b};E.remove(w,l),E.insert(I),x.set(I.value.model,I)},"Update Drawing",!1),b},deleteFromContainer(y){const b=a();b?.value&&h.getView().unselectMovables([b.value.model]);const w=[];c((x,I,v)=>{v.delete(x.value.model),I.remove(x,l),x.value.processDeleteCallback?.(),w.push(x);const R=x.value.model.getZIndex(),A=I.all().sort((D,P)=>D.value.zIndex-P.value.zIndex),M=[],T=[],N=A.length;for(let D=R+1;D<N;D++){const P=A[D];M.push(P);const L={...P,value:{...P.value,zIndex:D-1}};T.push(L),v.set(L.value.model,L)}const B=M.length;for(let D=0;D<B;D++)I.remove(M[D],l);I.load(T)},y?.description??"Delete Drawing",!0);const E=w.length;for(let x=0;x<E;x++)w[x].value.processZIndexCallback?.()},setContainerDeleteCallback(y){(a()?.value??o).processDeleteCallback=y},isProtected:()=>!h._initializing&&!h.getProtection().isObjectsAllowed(),setContainerProtectionCallback(y){(a()?.value??o).processProtectionCallback=y},setContainerShiftCallback(y){(a()?.value??o).processShiftCallback=y},setContainerLayoutCallback(y){(a()?.value??o).processLayoutCallback=y},initialAnchor:r,maxRangeCoords:this._entireCoords,json:e},p=e.content.json,S={type:u,transactions:this._transactions,beginPersistResource:m,fromResourceId:n,defaultLockAspectRatio:f,json:p};let C=null;if(u==="picture")C=new lf(S);else if(u==="chart")C=new my(S);else if(u==="sp"||u==="cxnSp"||u==="grpSp")C=new fy(S);else{if(u!=="graphicFrame")throw new Error((y=>`Unsupported float type: ${y}`)(u));C=new py(S)}return o.model=new Li({..._,content:C}),d=!1,i}_fromJSON(e){this._initializing=!0,this._emitter.notify("onBeforeLoad",{params:e}),this._clearState();const t=this._beginCommit({description:"Load Sheet",viewAfter:{initial:!0,skipProtectionCheck:!0}}),n=e||{},r=this._strings,o=r.beginPersist(),i=this._resources.beginPersist(),a=this._styles.beginPersist();try{this._ownStrings&&o.fromJSON(n.strings),this._ownResources&&i.fromJSON(n.resources),this._ownStyles&&a.fromJSON(n.styles),this._colHeaders.fromJSON({headers:n.cols,defaultSize:n.defaultColSize}),this._rowHeaders.fromJSON({headers:n.rows,defaultSize:n.defaultRowSize}),this.setView(new dl({sheet:this,json:n.view})),this._rangeSelection.updateCoords(this._view.getRangeSelection()),n.tabColor&&(this._tabColor=this._styles.parseColor(n.tabColor));let l=this._getState();const c=l.cellValuesGrid,h=l.contentfulSpatial,u=n.data,d=u?.length??0,g=dd,m=[];if(d>0){for(let O=0;O<d;O++){let j=u[O];typeof j=="string"&&(j=JSON.parse(j));const V=j[1],W=V.length;let H;for(let G=0;G<W;G++){const $=V[G][1],Z=$.length;for(let Y=0;Y<Z;Y++){let re=$[Y],ee=re?.t;if(ee!==void 0)re=re?.v;else switch(typeof re){case"number":ee=U.Number;break;case"boolean":ee=U.Boolean;break;case"string":ee=U.String,re=parseInt(re)}$[Y]=[re,ee]}H=g(null,r,$),V[G][1]=H}m.push(j)}c.setValues(m);const z=gd(m,this._isDataColumn);h.load(z)}const f=this._entireCoords,_=l.directStyleSpatial,p=l.continuousFillSpatial,S=this._options.styles;if(e.directStyles){const z=[],O=[],j=e.directStyles,V=(W,H)=>{const G=a.getElementJSON(H),$=new Ke(S,k.sanitizeRange(W),G),Z={...W,value:$};z.push(Z);const Y=$._p?.alignment?.horizontal;!Y||Y!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&Y!==exports.ITextFrame.HorizontalAlignment.Fill||O.push(Z)};if(Array.isArray(j)){const W=j.length;for(let H=0;H<W;H++){const G=j[H],$=G.r;V(typeof $=="string"?Ft($,f):$,G.v)}}_.load(z),p.load(O)}l=this._updateState({cellValuesGrid:c,contentfulSpatial:h,directStyleSpatial:_,continuousFillSpatial:p});const C=n.merges;if(C){const z=[],O=C.length;for(let j=0;j<O;j++){const V=Ft(C[j],f);z.push(V)}this._indexMerges(z)}const y=l.hyperlinkSpatial,b=n.hyperlinks;if(b){const z=b,O=[],j=z.length;for(let V=0;V<j;V++){const W=z[V];let H=W.r;H=typeof H=="string"?Ft(H,f):k.sanitizeRange(H);let G=W.v;typeof G=="string"&&(G={address:G}),O.push({...H,value:G})}y.load(O)}const w=l.commentsSpatial,E=n.comments;if(E){const z=E,O=[],j=z.length;for(let V=0;V<j;V++){const W=z[V];let H=W.ref;H=typeof H=="string"?Ft(H,f):k.sanitizeRange(H);const G={...W};delete G.ref,O.push({...H,value:G})}w.load(O)}const x=l.movableMapModel,I=l.movableSpatial;if(n.movables){const z=[],O=n.movables,j=O.length;for(let V=0;V<j;V++){const W=O[V];try{const H=this._createMovableEntry(W,V,i.fromResourceId.bind(i));x.set(H.value.model,H),z.push(H)}catch(H){console.warn("Unable to load movable",V,W,H)}}I.load(z)}const v=l.tableMapModel,R=l.tableMapName,A=l.tableSpatial,M=n.tables;if(M){const z=[],O=M.length;for(let j=0;j<O;j++){const V=M[j],W=this._createTableEntry(V),H=W.value.model;v.set(H,W),R.set(W.value.currentName,H),z.push(W)}A.load(z)}const T=l.conditionalSpatial,N=l.conditionalModels,B=n.conditionals;if(B){const z=B.length;for(let O=0;O<z;O++){const j=B[O];this._createConditionalEntries(j,T,N)}}const D=l.calcGraph,P=D.fromJSON({formulas:n.formulas,data:m,dynamic:n.dynamicArray,volatile:n.volatile});l=this._updateState({hyperlinkSpatial:y,commentsSpatial:w,movableSpatial:I,movableMapModel:x,tableSpatial:A,tableMapModel:v,tableMapName:R,conditionalSpatial:T,conditionalModels:N,calcGraph:D});const L=this._getUsedCoords();L&&this._autoFit([L],{orientations:exports.w.Orientations.Row,skipCustomSize:!0}),t.commit(),P&&this._realizeCalcedValues(P),n.protection&&this._protection.fromJSON(n.protection),this._emitter.notify("onLoad")}finally{a.endPersist(),i.endPersist(),o.endPersist()}this._initializing=!1}getName(){return this._closed?Ye:this._options.container?.getName?.()??null}setName(e){if(this._closed)throw new Error(St);const t=this._options.container?.setName;if(!t)throw new Error("Unable to set name for sheet.");return t(e),this}getVisibility(){return this._closed?exports.ISheet.Visibility.VeryHidden:this._options.container?.getVisibility?.()??exports.ISheet.Visibility.Hidden}setVisibility(e=!0){if(this._closed)throw new Error(St);const t=this._options.container?.setVisibility;if(!t)throw new Error("Unable to set visibility for sheet.");let n;return n=e===!0?exports.ISheet.Visibility.Visible:e===!1?exports.ISheet.Visibility.Hidden:e,t(n),this}async select(e){return await this._options.container?.requestSelect?.(e),this}duplicate(){return this._options.container?.duplicate?.()}setPosition(e){return this._options.container?.setPosition(e),this}getNames(){return this._names}getCalculation(){return this._calculation}get[Symbol.toStringTag](){return"[Sheet]"}toString(){return this.getName()||"(untitled sheet)"}get isISheet(){return!0}}const Yd={address:null,scope:null},ky={colStart:0,rowStart:0,colEnd:0,rowEnd:0},yo={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Oy={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Ds={includeHidden:!1};Object.freeze({[exports.ICell.Content.Values]:Number.MAX_SAFE_INTEGER,[exports.ICell.Content.Formulas]:Number.MAX_SAFE_INTEGER}),Object.freeze({[exports.ICell.Content.Values]:1,[exports.ICell.Content.Formulas]:1});const Ls={ignoreDataChanges:!1},Wt={colStart:-1,rowStart:-1,colEnd:-1,rowEnd:-1},Co=[{colIndex:-1,rowIndex:-1},null,null,null,null],By=[exports.ICell.Content.Values],Qd={size:null,autoSize:!0},gl={skipCustomSize:!0,expandOnly:!0,minContent:!0},qt={rowStart:0,colStart:0,rowEnd:0,colEnd:0},ml={showFormulaBar:!0,showTabs:!0,tabRatio:600,showHorizontalScrollbar:!0,showVerticalScrollbar:!0,showStatusBar:!0,activeSheetId:null};class Yl{constructor(e){this._emitter=null,this._emitter=new st(this),this._state={...ml},e?.json&&this._fromJSON(e?.json)}isShowFormulaBar(){return this._state.showFormulaBar}setShowFormulaBar(e){return this._state.showFormulaBar=e,this._emitter.notify("onViewChange"),this}isShowTabs(){return this._state.showTabs}setShowTabs(e){return this._state.showTabs=e,this._emitter.notify("onViewChange"),this}getTabRatio(){return this._state.tabRatio}setTabRatio(e){return this._state.tabRatio=e,this._emitter.notify("onViewChange"),this}isShowHorizontalScrollbar(){return this._state.showHorizontalScrollbar}setShowHorizontalScrollbar(e){return this._state.showHorizontalScrollbar=e,this._emitter.notify("onViewChange"),this}isShowVerticalScrollbar(){return this._state.showVerticalScrollbar}setShowVerticalScrollbar(e){return this._state.showVerticalScrollbar=e,this._emitter.notify("onViewChange"),this}isShowStatusBar(){return this._state.showStatusBar}setShowStatusBar(e){return this._state.showStatusBar=e,this._emitter.notify("onViewChange"),this}getActiveSheetId(){return this._state.activeSheetId}setActiveSheetId(e){return this._state.activeSheetId=e,this._emitter.notify("onViewChange"),this}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){let e={};const t=Object.keys(this._state);for(let n=0;n<t.length;n++){const r=this._state[t[n]];r!=null&&r!==ml[t[n]]&&(e[t[n]]=r)}return Object.keys(e).length===0&&(e=null),e}_fromJSON(e,t=!0){let n=e||{};this.update(n,t)}update(e,t=!0){this._state={...ml,...this._state,...e},t&&this._emitter.notify("onViewChange")}}class Dy{constructor(e){this._emitter=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Lt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._initState(e?.initial)}add(e,t,n){const r=this;t&&t.addListeners({onDelete:c=>{r._updateState(h=>{if(!h.modules[e])return;const u=h.modules[e];if(u){const d={...h};return r._options.onRemove?.(e,u),r._emitter.notify("onCollectionChange"),delete d.modules[e],d}return h},"Delete Module")}},{once:!0});const o=this._getState()?.modules,i=o?.[e],a=n?.replace??!1;if(i&&!a)throw new Error(`Already existing '${e}'`);const l={...o};t?(l[e]=t,r._options.onAdd?.(e,t),this._updateState({modules:l},a?"Save Scripts":"Add Script")):(delete l[e],r._options.onRemove?.(e,null),this._updateState({modules:l},"Remove Script")),r._emitter.notify("onCollectionChange")}search(e){const t=this._getState();if(!t)return F.EmptyArray;const n=t.modules,r=Object.keys(n),o=r.length;if(o===0)return F.EmptyArray;const i=[],a=e?.name?e.name.toUpperCase():null;for(let l=0;l<o;l++){const c=r[l],h=n[c];let u=!0;a&&a!==c.toUpperCase()&&(u=!1),u&&i.push(h)}return i??F.EmptyArray}getByName(e){if(!e)return null;const t=this._getState();if(!t)return null;const n=e.toUpperCase(),r=t.modules,o=Object.keys(r),i=o.length;for(let a=0;a<i;a++){const l=o[a];if(n===l)return r[l]}return null}getCount(){const e=this._getState();return e?Object.keys(e.modules).length:0}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Nt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update",n){if(!e)return;const r=this._beginCommit(t);try{r.updateState(this,e),r.commit(n)}catch(o){throw r.rollback(),o}}_initState(e){let t=e??{};this._updateState({modules:t},"Initialize",{forceAmend:!0});const n=this._options.onAdd;if(n){const r=Object.keys(t),o=r.length;for(let i=0;i<o;i++){const a=r[i];n(a,t[a])}}}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){const e=this._getState();if(!e)return F.EmptyArray;const t=e.modules,n=Object.keys(t),r=n.length,o={};for(let i=0;i<r;i++){const a=n[i];o[a]=t[a].toJSON()}return o}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}}let fl;const Ps="SheetXL",Ly=fl||(fl=F.deepFreeze({ISheet:{Visibility:exports.ISheet.Visibility},ICell:{Content:exports.ICell.Content,CalcStatus:exports.ICell.CalcStatus},IColor:{Named:exports.IColor.Named,Scheme:exports.IColor.Scheme,Type:exports.IColor.Type,AdjustmentType:exports.IColor.AdjustmentType},Direction:Be}),fl);let zs;class Py extends Ko{constructor(e,t,n,r=null,o=!1){super(e,t,n,r,o)}execute(...e){const t=e[0];if(!t||!t.isIWorkbook)throw new Error(`Macro '${this.getName()}' must be called with a valid workbook as the only argument.`);const n=this._ct;try{const r=[];switch(n){case Sn.Context.Workbook:r.push(t);break;case Sn.Context.Sheet:r.push(t.getSelectedSheet());break;case Sn.Context.Ranges:r.push(t.getSelectedRanges());break;case Sn.Context.Range:r.push(t.getSelectedRange());break;default:throw new Error(`Function '${this.getName()}' is not a valid macro function.`)}const o=async(a,l)=>{const c=await l;if(c!==void 0)if(c!==null){if(Array.isArray(c)){if(Ze(c[0]?.[0]))return void a.setValues(c,{skipBoundsCheck:!0})}else if(Ze(c))return void a.setValues([[c]]);c.isICell?a.updateCells(c):c.isICellRange&&await a.copyFrom(c)}else a.clear()};let i;return(async()=>{const a=(await this.getDescriptor()).getSummary()??`Macro '${this.getName()}'`;return await t.doBatch(async()=>{try{const l=t.getSelectedRange();let c=this._cf();c||(c=function(h){return new Proxy(h,{set:(u,d,g)=>(console.log(`Adding property "${d}" with value:`,g),u[d]=g,!0),deleteProperty:(u,d)=>(console.log(`Deleting property "${d}"`),delete u[d])})}({}));try{Ec({getPosition:()=>l.getCell().getCoords()}),zs=globalThis[Ps],globalThis[Ps]=Ly,i=this._fn.call(c,...r),zs?(globalThis[Ps]=zs,zs=void 0):delete globalThis[Ps],Di()}catch(h){throw h}finally{Di()}await o(l,i)}catch(l){throw l}},a),{params:r,results:i}})()}catch(r){throw r}}}class zy{constructor(e){this._emitter=null;const t=e.json;if(this._json=t,!this._json)throw new Error("Module JSON is required.");this._emitter=new st(this),this._functions=new df({transactions:null,readonlyFunctions:e.readonlyFunctions})}getFunctions(){return this._functions}getSource(){return this._json.source}getLanguage(){return this._json.language||"typescript"}getErrors(){return null}delete(){this._emitter.notify("onDelete")}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){return this._json}}const jy=async(s,e)=>{let t=null;try{Ec(null)}catch(o){console.warn("Error setting global scope",o)}try{t=await new Function("modulePath","return import(modulePath)")(`data:text/javascript,${encodeURIComponent(s.compiled)}`)}catch(o){throw new Error("Invalid Javascript module.",{cause:o})}finally{Di()}if(!e)throw new Error(`No function available for '${s.name??s.commitId}'.`);const n=e.name;let r=t[n];if(!r&&e.behavior.default&&(r=t.default),!r)throw new Error(`Found the descriptor for '${n}' but not the function. The descriptor manifest must be corrupt.`);return r},Zd=async(s,e=!1)=>{const t=s?.functions,n=new Map;if(t)for(let r=0;r<t.length;r++){const o=t[r],i=o[0],a=o[1];let l,c=e?()=>{}:await jy(s,i);l=i.context&&i.context!==Sn.Context.Calculation?new Py(i,c,()=>null,a):new Ko(i,c,()=>null,a),n.set(i.name.toUpperCase(),l)}return new zy({json:s,readonlyFunctions:n})};class Wy{constructor(e){this._options=e,this._initState()}_initState(){}getModules(){return this._modules}async createModule(e){const t=await Promise.resolve().then(()=>require("./CJx8P3pZaRnS6Kny.cjs")).then(r=>r.index),n=await t.ScriptingUtils.compileTypescript(e);return n?await Zd(n,e?.declarationsOnly??!1):null}addModule(e,t,n){this._modules.add(e,t,n)}executeMacro(e,t){const n=this._modules.search({name:t}),r=n.length;for(let o=0;o<r;o++){const i=n[o].getFunctions().getByName(e);if(i)return i.execute(this._options.workbook)}throw new Error(`No macro ${e} found.`)}searchFunction(e){const t=e?.name,n=e?.moduleName,r=e?.type,o=this._modules;if(!o)return F.EmptyArray;const i=o.getCount();if(i===0)return F.EmptyArray;if(n){const l=this._modules.search({name:n});return l.length===0?F.EmptyArray():l[0].getFunctions().search({name:t,type:r})}const a=this._modules.search();for(let l=0;l<i;l++){const c=a[l].getFunctions().search({name:t,type:r});if(c.length>0)return c}return F.EmptyArray}async start(){if(this._modules)return Promise.resolve();const e=this._options?.workbook,t=this._options?.json;let n={};if(t){const a=Object.keys(t);for(let l=0;l<a.length;l++){const c=a[l],h=t[c],u=await Zd(h);n[c]=u}}const r=new Dy({transactions:this._options?.transactions,initial:n,onRemove:this._options?.onRemove,onAdd:this._options?.onAdd});this._modules=r;const o=r.search();if(o.length===0)return Promise.resolve(F.EmptyArray);const i=o.length;for(let a=0;a<i;a++){const l=o[a];try{const c=l.getFunctions().search({type:"autoRun"}),h=c.length;for(let u=0;u<h;u++)await c[u].execute(e)}catch(c){console.error("Error executing autoRun script:",c)}}}toJSON(){const e=this._modules;if(!e)throw new Error("Scripts is initializing.");return e.toJSON()}}const Hy=Object.freeze({lockStructure:!1,lockWindows:!1,lockRevision:!1,workbookPassword:null,revisionsPassword:null});class eg extends wf{isWindowsAllowed(){return this._isPropertyAllowed("windows")}isRevisionAllowed(){return this._isPropertyAllowed("revision")}isStructureAllowed(){return this._isPropertyAllowed("structure")}_fromJSON(e){this._properties=e}_toJSON(e){let t=this._properties;if(t){e={...e,...t};const n=Object.keys(t),r=n.length;for(let o=0;o<r;o++){const i=n[o],a=t[i];a!=null&&a!==Hy[i]&&(e[i]=a)}}return super._toJSON(e)}}const pl=s=>`Invalid SheetKey: ${s}`,_l="A workbook must contain at least one visible worksheet.",tg="Internal error no visible sheetRefs",lt="Workbook has been closed. No further operations are allowed.",Gn="This workbook structure is protected. To make a change, unprotect the workbook. You might be requested to enter a password.",Yi="A sheet name",Ql=`${Yi} can not be blank.`,Vy=`${Yi} can not be longer than 31 characters.`,$y=`${Yi} can not begin or end with a "'" (single quote).`;class Gy{constructor(e,t){this._add=e,this._get=t}add(e){return this._add(e)}search(e){return this._get(e?.name,e?.visibility)}getByName(e){return this._get(e)?.[0]??null}getCount(){return this._get().length}}const Zl=new RegExp(/[\\/\\*?:[\]]+/),Uy=new RegExp(/\(((\d+)(?!.*\d))\)$/,"g"),qy=s=>`Sheet${s+1}`,yf=(s,e)=>({...Pn,getSource:()=>null,toString:()=>Ui(s,e)}),ng=(s,e=!1)=>{if(!s)throw new Error(Ql);if(Zl.test(s)){if(!e)throw new Error((n=>`${n?`'${n}'`:Yi} can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`)(s));s=s.replace(Zl,"")}if(s.length===0)throw new Error(Ql);const t=s.length;if(t>31){if(!e)throw new Error(Vy);s=s.substring(0,31)}if(s.charAt(0)==="'"||s.charAt(t-1)==="'"){if(!e)throw new Error($y);s=s.replace(/^'|'$/g,"")}return s};class Qi extends ss{constructor(e,t,n,r){super(e,t,r),this._workbook=n}getSource(){return this._workbook}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new Qi(e,this._sheet,this._workbook,n)}_createRange(e,t){const n=e?{...e}:null;if(!(n&&this._workbook._getSheetRef(n.sheetName,exports.ISheet.Visibility.VeryHidden))){const o=this._workbook.getSelectedSheet();return delete n?.sheetName,yf(n,n?{sheetName:Ye,...o.getEntireRange().getCoords()}:null)}let r=this._options;return t&&(r={...this._options,getOptions:Cn(this._options.getOptions,t)}),new Zi(e,this._sheet,this._workbook,r)}async select(e){const t=[];let n=null;const r=this.getCoords();for(let l=0;l<r.length;l++){const c=r[l];c&&(n||(n=c.sheetName),c&&c.sheetName===n&&t.push(c))}n||(n=this._workbook.getSelectedSheet().getName());const o=this._workbook.getSheets().getByName(n);if(!o)return;const i=await o.getRanges(t).select(e),a=this._workbook._rangesAddressToCoords(i.getCoords());return this._createRanges(a,e)}addListener(e,t){if(!this.getCoords())return()=>{};const n=this._workbook._sheetToWBEvent(e);return super.addListener(n,t)}get[Symbol.toStringTag](){return"[WorkbookRanges]"}toString(){const e=this.getCoords(),t=this._sheet,n=t.getEntireRange().getCoords(),r={sheetName:t.getName(),...n};return Dm(e,r,Ui,Hn)}}class Zi extends is{constructor(e,t,n,r){super(e,t,r),this._workbook=n}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new Qi(e,this._sheet,this._workbook,n)}_createRange(e,t){const n=this._sheet;if(!e)return _n(n,n._entireCoords);if(n._validateCoords(e),n._closed)return _n(null,n._entireCoords,e);let r=this._options;return t&&(r={...this._options,getOptions:Cn(this._options?.getOptions,t)}),new Zi(e,this._sheet,this._workbook,r)}getSource(){return this._workbook}get[Symbol.toStringTag](){return"[WorkbookRange]"}toString(){const e=this._sheet,t=e?.getEntireRange().getCoords()??null;return Ui(this.getCoords(),{...t,sheetName:e.getName()})}addListener(e,t){if(!this.getCoords())return()=>{};const n=this._workbook._sheetToWBEvent(e);return super.addListener(n,t)}}class Jy{constructor(e){this._lastTransactionUUID=null,this._closed=!1,this._initializing=!0,this._emitter=null,this._names=null,this._calculation=null,this._isDate1904=!1;const t=this,n={...e},r=n.json;delete n.json,this._transactions=n.transactions??new Lt,this._ownTransactions=!n.transactions,this._emitter=new st(this,this._transactions);const o=this._beginCommit({description:(r?"Open":"New")+" Workbook"});try{this._strings=n.strings??new Ki,this._ownStrings=!n.strings,this._resources=n.resources??new Cc,this._ownResources=!n.resources,this._createSheetName=n.createSheetNameCallback??qy;let i=n.createSheetCallback;i||(i=l=>new Gr(l)),this._sheetOnNameChange=new Map,this._sheetOnVisibilityChange=new Map,this._sheetOnIndexChange=new Map,this._createSheet=(l,c,h,u,d)=>{let g=null;const m={date1904:t.isDate1904(),readonly:t._options.readonly??!1,transactions:t._transactions,styles:t._styles,strings:t._strings,resources:t._resources,names:t._names,calculation:t._calculation,resolveRange:f=>t._options.resolveRange?.(f)??t.getRange(f),container:{beforeFromJSON:f=>{g=f,t._addSheetRef({name:c,id:l,visibility:h??exports.ISheet.Visibility.Visible,sheet:f},u)},getName:()=>{const f=t._getSheetRef(g);return f?f.name:t._createSheetName(1)},setName:f=>{t._getSheetRef(g)&&t._setSheetName(g,f)},getIndex:()=>{const f=t._getSheetRef(g);return f?t._findOffsetForId(f.id,t._getSheetRefs(exports.ISheet.Visibility.VeryHidden)):-1},setIndexCallback:f=>{t._sheetOnIndexChange.set(l,f)},setNameChangeCallback:f=>{t._sheetOnNameChange.set(l,f)},getVisibility:()=>{const f=t._getSheetRef(g);return f?f.visibility:exports.ISheet.Visibility.Visible},setVisibility:f=>{t._setSheetVisibility(g,f)},setVisibilityCallback:f=>{t._sheetOnVisibilityChange.set(l,f)},duplicate:()=>t._duplicateSheet(g),setPosition:f=>{const _=t._getSheetRef(g,exports.ISheet.Visibility.VeryHidden);return!!_&&(t._moveSheet(_,f),!0)},requestSelect:async()=>(t._setSelectedSheet(g),await this._emitter.notify("onRequestSelect",{source:t,params:g,async:!0}),t.getSelectedSheet()===g)}};return d&&(m.json=d),g=i(m,c,u,h),g},this._names=n.names??new gf({addressToRanges:l=>t.getRanges(l),getCurrentScope:()=>t.getSelectedSheet().getName(),isReadOnly:()=>t._options.readonly??!1,transactions:t._transactions}),this._ownNames=!n.names,this._calculation=n.calculation??new vc({getNamed:(l,c)=>{try{xr.address=l,xr.scope=c;const h=this._names.search(xr);return h&&h.length!==0?h[0].getRanges().getCoords():null}catch{return null}},getSheetIndex:l=>{if(l===void 0)return t.getSelectedSheetIndex();const c=this._getSheetRefs(exports.ISheet.Visibility.Hidden);l=l.toLowerCase();for(let h=0;h<c.length;h++)if(c[h].name.toLowerCase()===l)return h;try{xr.address=l,xr.scope=void 0;const h=this._names.search(xr);if(!h||h.length===0)return-1;let d=h[0].getRanges().getCoords()?.[0]?.sheetName;if(!d)return-1;const g=this._getSheetRefs(exports.ISheet.Visibility.Hidden);d=d.toLowerCase();for(let m=0;m<g.length;m++)if(g[m].name.toLowerCase()===d)return m}catch{return-1}return-1},getSheetCount:()=>t.getSheets().getCount(),isDate1904:()=>t.isDate1904(),strings:t._strings,transactions:t._transactions}),this._ownsCalculation=!n.calculation,this._scripts=this._createScripts(),this._ownNames=!n.names,this._options={...n};const a=async()=>{this._ownsCalculation&&await this._calculation.start(),await this._scripts.start(),this._starting=null};this._starting=a(),r?this._fromJSON(r):(this._initState(),this._addSheet(!1)),this._emitter.notify("onLoad"),o.commit()}catch(i){throw o.rollback(),i}this._sheets=new Gy(i=>t._addSheetOptions(i),(i,a)=>i?[this.getSheet(i,a)]:this._getSheets(a)),this._initializing=!1}_initState(){let e=this._getSheetRefs();for(let r=e&&e.length-1;r>=0;r--);this._isDate1904=this._options.date1904??!1,this._theme=this._options.theme??new gc().getDefaultTheme(),this._styles=this._options?.styles??new Xr(this._theme),this._ownStyles=!this._options.styles,this._styles.getTheme()||this._styles.setTheme(this.getTheme()),this._activeSheetOffset=0,this.setView(new Yl),this._listenerProtection?.(),this._protection=new eg(void 0,this._options.readonly??!1),this._listenerProtection=this._protection.addListeners({onChange:r=>{t._emitter.notify("onProtectionChange")}});const t=this;this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(r,o,i){if(o&&o.activeSheetId!==void 0&&o.view===t.getView()&&i.getId()===t._lastTransactionUUID&&t._getSheetRef(o.activeSheetId)?.sheet.select(),o&&i.getId()!==t._lastTransactionUUID){let a=t.getView().getActiveSheetId();o.view===t.getView()&&(a=o.activeSheetId);let l=0;try{l=t._findOffsetForId(a,r.sheetRefsVisible)}catch{}t._activeSheetOffset=l}t._lastTransactionUUID=i.getId(),t._notifyAllChange()},onRestoreOrRevert(){t._emitter.notify("onInvalidated")}});const n=this._getState();n?.listenersSheets&&(n?.listenersSheets.forEach(r=>{r()}),n?.listenersSheets.clear()),this._updateState({sheetRefsAll:[],sheetRefsVisibleAndHidden:[],sheetRefsVisible:[],refsById:new Map,sheetsById:new Map,refsByLowerCaseName:new Map,sheetsByLowerCaseName:new Map,refsByInstance:new Map,lastId:-1,sheetsCreated:new Set,listenersSheets:new Map})}getView(){return this._view}setView(e){if(this._closed)throw new Error(lt);if(!e)throw new Error("View can not be empty.");this._listenerWorkbookView?.();const t=this;return this._listenerWorkbookView=e.addListeners({onViewChange:n=>{const r=t._getState();this._activeSheetOffset=this._findOffsetForId(this._view.getActiveSheetId(),r.sheetRefsVisible),t._emitter.notify("onViewChange")}}),this._view=e,t._emitter.notify("onViewChange"),this}isDate1904(){return this._isDate1904}setDate1904(e){if(this._closed)throw new Error(lt);return this._isDate1904=e,this._notifyAllChange(),this}getStyles(){return this._styles}getResources(){return this._resources}getTransactions(){return this._transactions}getStrings(){return this._strings}getTheme(){return this._theme}setTheme(e){if(this._closed)throw new Error(lt);if(!e)throw new Error("A value must be provided.");const t=this._theme;return this._theme=e,this.getStyles().setTheme(e),this._emitter.notify("onThemeChange"),t}getSelectedSheetIndex(){return this._activeSheetOffset}getSelectedSheet(){const e=this._getSheetRef(this.getSelectedSheetIndex());return e?e?.sheet:null}getSheet(e,t=exports.ISheet.Visibility.Visible){const n=this._getSheetRef(e,t);if(!n)throw new ke(`Sheet '${e}' not found.`);return n.sheet}getSheetAt(e,t=exports.ISheet.Visibility.Visible){const n=this._getSheetRef(e,t);if(!n)throw new ke((r=>`No sheet found at ${r}.`)(e));return n.sheet}getSheets(){return this._sheets}_getSheets(e=exports.ISheet.Visibility.Visible){const t=this._getSheetRefs(e),n=[];for(let r=0;r<t.length;r++)n.push(t[r].sheet);return n}_getSheetRefs(e=exports.ISheet.Visibility.Visible){if(this._closed)return F.EmptyArray;const t=this._getState();return t?e===exports.ISheet.Visibility.Visible?t.sheetRefsVisible:e===exports.ISheet.Visibility.Hidden?t.sheetRefsVisibleAndHidden:e===exports.ISheet.Visibility.VeryHidden?t.sheetRefsAll:F.EmptyArray:[]}_getSheetRef(e,t=exports.ISheet.Visibility.Visible){if(this._closed)return null;let n=null;return typeof e=="number"?this._getSheetRefs(t)[e]:(typeof e=="string"?n=this._getState().refsByLowerCaseName.get(e.toLowerCase()):e instanceof Gr?n=this._getState().refsByInstance.get(e):e?.id&&e.sheet&&(n=this._getState().refsById.get(e.id)),n)}_validateNewSheetName(e,t=!0){if(e==null)return e;if(ng(e),t&&this._getState().sheetsByLowerCaseName.has(e.toLowerCase()))throw new Error("That name is already taken. Try a different one.");return e.substring(0,31)}findValidSheetName(e){e&&(e=ng(e,!0));try{return((t,n)=>{try{if(n(t))return t}catch{}let r,o,i=Uy.exec(t);for(i!==null?(r=t.substring(0,i.index),o=parseFloat(i[1])):(r=t+" ",o=1);o<256;){o++;const a="("+o+")",l=r.substring(0,31-a.length)+a;try{if(n(l))return l}catch{}}throw new Error(t+" is not a valid sheet name")})(e,t=>this._validateNewSheetName(t))}catch{return this._nextSheetName()}}isValidSheetNameCharacter(e){return!Zl.test(e)}_addSheetOptions(e){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);let t=null;e={...e,description:e?.description??"Add Sheet"};const n=this.beginCommit(e);try{t=this._addSheet(!0,e.name,e.index??null);const r=this.getView().getActiveSheetId();let o,i;if(e.autoSelect!==!1){let a=this.getView().getActiveSheetId();a=this._getSheetRef(t).id,e?.autoSelect&&(o={view:this.getView(),activeSheetId:r},i={view:this.getView(),activeSheetId:a})}if(n.commit({description:`Add Sheet '${t.getName()}'`,viewBefore:o,viewAfter:i}),e.autoSelect!==!1){const a=typeof e.autoSelect=="boolean"?void 0:e.autoSelect;t.select(a)}}catch(r){throw n.rollback(),r}return t}_nextSheetName(e=null){let t=e?e.toLowerCase():null;const n=this._getState(),r=n.sheetsByLowerCaseName;if(e&&r.has(t))throw new Error((i=>`The sheet name '${i}' already exist in workbook.`)(e));t=(e=this._validateNewSheetName(e))?e.toLowerCase():null;let o=n.lastId+1;for(;!e;){const i=this._createSheetName(o),a=i.toLowerCase();r.has(a)?o++:e=i}return this._updateState({lastId:o}),e}_addSheet(e,t=null,n=null){t=this._nextSheetName(t);const r=this._getState(),o=this._createSheet(r.lastId,t,exports.ISheet.Visibility.Visible,n,null);if(!o)throw new Error(Ql);return e&&this._emitter.notify("onSheetsChange"),o}_updateSheetRefStates(e){if(this._closed)throw new Error(lt);if(!this._initializing&&!this.getProtection().isStructureAllowed())throw new Error(Gn);const t=e,n=[],r=[];for(let o=0;o<t.length;o++)t[o].visibility===exports.ISheet.Visibility.Visible?(n.push(t[o]),r.push(t[o])):t[o].visibility===exports.ISheet.Visibility.Hidden&&r.push(t[o]);this._updateState({sheetRefsAll:t,sheetRefsVisible:n,sheetRefsVisibleAndHidden:r})}_addSheetRef(e,t=null){const n=this._getState(),r=n.sheetRefsAll,o=Math.max(0,Math.min(r.length,t??r.length));let i=[...r.slice(0,o),e,...r.slice(o)];this._updateSheetRefStates(i);const a=e.sheet,l=e.name.toLowerCase(),c=new Map(n.refsById);c.set(e.id,e);const h=new Map(n.refsByLowerCaseName);h.set(l,e);const u=new Map(n.refsByInstance);u.set(a,e);const d=new Map(n.sheetsById);d.set(e.id,a);const g=new Map(n.sheetsByLowerCaseName);g.set(l,a);const m=this;let f=n.listenersSheets;if(a!==void 0){const S=a.addListeners({onBeforeDelete:C=>{m._validateDeleteSheet(C)},onDelete(C){let y=m._getSheetRef(C,exports.ISheet.Visibility.VeryHidden);if(!y)return;const b=m._beginCommit({description:`Remove Sheet ${y.name}`});try{const w=m._getState(),E=w.sheetRefsAll,x=m._findOffsetForId(y.id,E);let I=[...E];I.splice(x,1),m._updateSheetRefStates(I);const v=new Map(w.refsById);v.delete(y.id);const R=new Map(w.sheetsById);R.delete(y.id);const A=y.name.toLowerCase(),M=new Map(w.refsByLowerCaseName);M.delete(A);const T=new Map(w.sheetsByLowerCaseName);T.delete(A);const N=new Map(w.refsByInstance);N.delete(C),w.listenersSheets.get(y.id)();const B=new Map(w.listenersSheets);B.delete(y.id),m._adjustRemoveSelectionIfRequired(x,y.id),m._adjustSheetNamesIfRequired(),m._emitter.notify("onSheetsChange");const D=new Set(w.sheetsCreated);D.has(a)&&D.delete(a),m._updateState({refsById:v,sheetsById:R,refsByLowerCaseName:M,sheetsByLowerCaseName:T,refsByInstance:N,sheetsCreated:D,listenersSheets:B}),b.commit()}catch(w){throw b.rollback(),w}}});f=new Map(n.listenersSheets),f.set(e.id,S)}let _=n.lastId;_!==-1&&(_=Math.max(_,e.id)),this._updateState({lastId:_}),this._updateState({refsById:c,refsByLowerCaseName:h,refsByInstance:u,sheetsById:d,sheetsByLowerCaseName:g,listenersSheets:f}),this._adjustSheetNamesIfRequired();const p=new Set(this._getState().sheetsCreated);return p.add(e.sheet),this._updateState({sheetsCreated:p}),e}_adjustRemoveSelectionIfRequired(e,t){if(this._view.getActiveSheetId()===t){let n;const r=this._getState().sheetRefsVisible;n=e<r.length?r[e].id:r[e-1].id,this._view.setActiveSheetId(n)}}_adjustSheetNamesIfRequired(){const e=this._getState(),t=e.lastId;if(t===-1)return;let n=this._view.getActiveSheetId();n==null&&(this._view.setActiveSheetId(t),n=t),e.refsById.get(n).visibility===exports.ISheet.Visibility.Visible&&(this._activeSheetOffset=this._findOffsetForId(n,e.sheetRefsVisible))}_validateDeleteSheet(e){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);let t=this._getSheetRef(e);if(!t)throw new Error((r=>`Invalid reference for delete: ${r}`)(e));const n=this._getState().sheetRefsVisible;if(n.length===1&&n[0].id===t.id)throw new Error(_l)}_findOffsetForId(e,t){for(let n=0;n<t.length;n++)if(t[n].id===e)return n;throw new Error(tg)}find(e,t){if(this._closed)throw new Error(lt);const n=this._getSheets();if(n.length===1)return n[0].find(e,t);const r=!t?.reverse;let o=t?.disableWrap??!1;const i=this.getSelectedSheetIndex();let a=i,l=n[a],c=!1;t={...t,disableWrap:!0};let h,u=l.find(e,t),d=u.next(),g=!1;if(t?.from){const _=this._rangesAddressToCoords(t?.from);h={colIndex:_[0].colStart,rowIndex:_[0].rowStart}}else h={colIndex:0,rowIndex:0};const m=k.createCellComparator(t?.orientation,t?.reverse);delete(t={...t}).from;const f=()=>{if(!g&&d.done&&(c&&a===i?g=!0:r?(a++,a>n.length-1&&(a=0,c=!0)):(a--,a<0&&(a=n.length-1,c=!0)),o&&c&&(g=!0),!g))return l=n[a],u=l.find(e,t),d=u.next(),d;if(!g&&c&&a===i&&(d.done||!d.done&&m(d.value.getCoords(),h)>=0)&&(g=!0),g)return Re;const _=d;return d=u.next(),_};return{next:()=>{let _=f();for(;!g&&_.done;)_=f();return _}}}replace(e,t,n){let r=0,o=null;const i=typeof t=="function",a=n?.maxCount??Number.MAX_SAFE_INTEGER;let l=n.maxCount?"":"All";const c=typeof t=="string"?` with '${Zg(t)}'`:"";let h=n?.description??"Replace";const u=this._transactions.beginCommit({description:h});try{let d=null,g=null,m=e.next();for(;!m.done&&r<a;){const f=m.value,_=f.getSource();_!==d&&(d=_,g!==null&&g.apply(),g=d.getEntireRange().startIncrementalUpdates({orientation:n?.orientation,allowUnorderedWrites:!0}));const p=i?t(f):t;p!==void 0&&p!==f&&(g.push(f,p),r++,o=f),m=e.next()}g?.apply(),r===1&&a===1&&o&&(l=o.getA1()),u.commit({description:n?.description??`Replace ${l}${c}`})}catch(d){throw u.rollback(),d}return{count:r,last:o}}_nextSheetIndex(e,t=this._getSheetRefs()){return t.length===1?0:(e===void 0&&(e=this.getSelectedSheetIndex()),(e=Math.max(0,Math.min(e,t.length-1)))>=t.length-1?0:e+1)}_prevSheetIndex(e,t=this._getSheetRefs()){return t.length===1?0:(e===void 0&&(e=this.getSelectedSheetIndex()),(e=Math.max(0,Math.min(e,t.length-1)))<=0?t.length-1:e-1)}getNextSheet(e){if(this._closed)throw new Error(lt);const t=this._getSheetRefs();return t[this._nextSheetIndex(e,t)]?.sheet??null}getPreviousSheet(e){if(this._closed)throw new Error(lt);const t=this._getSheetRefs();return t[this._prevSheetIndex(e,t)]?.sheet??null}async _duplicateSheet(e){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);const t=this._getSheetRefs(),n=this.getSelectedSheetIndex();let r=null;if(e){if(r=this._getSheetRef(e),!r)throw new Error(pl(r))}else r=t[n];if(!r)return null;const o=r.sheet,i=this._strings.beginPersist(),a=this.getResources().beginPersist(),l=this.getStyles().beginPersist();let c=null;const h=this.beginCommit(`Duplicate '${o.getName()}'`);try{const u=this._getState().refsByInstance.get(o),d=await o.toJSON(),g=t.length+1,m=this.findValidSheetName(u.name),f=this._createSheet(g,m,u.visibility,n,d);this._emitter.notify("onSheetsChange"),c=f,h.commit()}catch(u){throw h.rollback(),u}finally{l.endPersist(),a.endPersist(),i.endPersist()}return c}_createRange(e,t){const n=e?{...e}:null;if(!(n&&this._getSheetRef(n.sheetName,exports.ISheet.Visibility.VeryHidden))){const i=this.getSelectedSheet();return i?(delete n?.sheetName,yf(n,n?{sheetName:Ye,...i.getEntireRange().getCoords()}:null)):void console.warn(tg)}const r=this.getSelectedSheet();let o=null;return t&&(o={getOptions:t}),new Zi(e,r,this,o)}_createRanges(e,t){const n=this.getSelectedSheet();let r=null;return t&&(r={getOptions:t}),new Qi(e,n,this,r)}getRange(e,t){try{const n=this._rangesAddressToCoords(e);if(n.length!==1)throw new Error(jm);return this._createRange(n[0],t)}catch(n){throw n instanceof ke?new ke(n.message):new Error(n.message??Go(e))}}getRanges(e,t){const n=this._rangesAddressToCoords(e);if(n.length===0)throw new Error(Go(e));return this._createRanges(n,t)}_activeRangeCoords(){const e=this.getSelectedSheet(),t=Ar(e.getSelection().getCoords()),n=e.getName(),r=[];for(let o=0;o<t.length;o++)r.push({sheetName:n,...t[o]});return r}getSelectedRange(e){return this.getRange(this._activeRangeCoords()[0],e)}getSelectedRanges(e){return this.getRanges(this._activeRangeCoords(),e)}getSelectedCell(){return this.getSelectedSheet().getSelectedCell()}_rangesAddressToCoords(e,t=!0,n=exports.ISheet.Visibility.Hidden){if(!e)throw new Error(Lr);const r=this.getSelectedSheet(),o=r?.getEntireRange().getCoords(),i={...o},a=r?.getName();if(a&&(i.sheetName=a),typeof e=="string"){const h=e.trim().toLowerCase();if(h==="r"||h==="c"){const u=this.getSelectedCell().getCoords(),d={};h==="r"?d.rowStart=d.rowEnd=u.rowIndex:d.colStart=d.colEnd=u.colIndex,e=d}}const l=this,c=Sc(e,i,os,h=>{if(!t)return null;if(typeof h=="string"){const u=l.getNames().getByName(h);if(u)return u.getRanges()?.getCoords()}throw new Error(`Invalid sheet reference '${h}'.`)});for(let h=0;h<c.length;h++)this._validateCoords(c[h],n);return c}_validateCoords(e,t=exports.ISheet.Visibility.Visible,n=Mi){if(e===null)return;const r=this.getSheet(e.sheetName,t).getEntireRange().getCoords();if(!k.isRangeWithinRange(e,r))throw new ke(n);if(e.rowEnd<e.rowStart||e.colEnd<e.colStart)throw new Error(Wm)}_updateSheetRef(e,t){const n=this._getState();let r=[...n.sheetRefsAll];r[this._findOffsetForId(e.id,n.sheetRefsAll)]=t,this._updateSheetRefStates(r);const o=new Map(n.refsById);o.set(e.id,t);const i=e.name.toLowerCase(),a=t.name.toLowerCase(),l=new Map(n.refsByLowerCaseName);l.delete(i),l.set(a,t);const c=new Map(n.sheetsByLowerCaseName);let h=c.get(i);c.delete(i),c.set(a,h);const u=new Map(n.refsByInstance);return u.set(h,t),this._updateState({refsById:o,refsByLowerCaseName:l,sheetsByLowerCaseName:c,refsByInstance:u}),t}_setSheetName(e,t){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);const n=this._getSheetRef(e);if(!n)throw new Error(pl(e));if(t===n.name)return n.sheet;t=this._validateNewSheetName(t);const r=Object.freeze({...n,name:t});let o=null;const i=this.beginCommit("Rename Sheet");try{const a=this._updateSheetRef(n,r);this._adjustSheetNamesIfRequired(),this._sheetOnNameChange.forEach((l,c)=>{n.id===c&&l()}),this._emitter.notify("onSheetsChange"),o=a.sheet,i.commit()}catch(a){throw i.rollback(),a}return o}_setSheetVisibility(e,t=exports.ISheet.Visibility.Visible){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);const n=this._getSheetRef(e);if(!n)return null;if(t===n.visibility)return;let r=null,o="";t===exports.ISheet.Visibility.Visible?o="Unhide Sheet":t===exports.ISheet.Visibility.Hidden?o="Hide Sheet":t===exports.ISheet.Visibility.VeryHidden&&(o="Very Hide Sheet");const i=this.beginCommit(o);try{const a=this._getState().sheetRefsVisible;if(t!==exports.ISheet.Visibility.Visible&&a.length===1&&a[0].id===n.id)throw new Error(_l);const l={...n,visibility:t};let c=-1;t!==exports.ISheet.Visibility.Visible&&(c=this._findOffsetForId(n.id,a));const h=this._updateSheetRef(n,l);t!==exports.ISheet.Visibility.Visible&&this._adjustRemoveSelectionIfRequired(c,n.id),r=h.sheet,this._adjustSheetNamesIfRequired(),i.commit()}catch(a){throw i.rollback(),a}return this._sheetOnVisibilityChange.forEach((a,l)=>{n.id===l&&a()}),this._emitter.notify("onSheetsChange"),r}_moveSheet(e,t){if(this._closed)throw new Error(lt);if(!this.getProtection().isStructureAllowed())throw new Error(Gn);let n=null;const r=this.beginCommit(`Move Sheet '${e.name}'`);try{const o=this._getState(),i=o.sheetRefsVisible;if(t<0||t>i.length-1)throw new Error(`Invalid to index: ${t}`);const a={view:this.getView(),activeSheetId:this.getView().getActiveSheetId()},l=o.sheetRefsAll,c=this._findOffsetForId(e.id,l),h=this._findOffsetForId(i[t].id,l);if(c===h)return;const u=l[c];let d=[...l];d.splice(c,1),d.splice(h,0,u),this._updateSheetRefStates(d),this._adjustSheetNamesIfRequired(),this._sheetOnIndexChange.forEach((g,m)=>{m>=c&&m<=h&&g()}),this._emitter.notify("onSheetsChange"),n=u.sheet,r.commit({viewBefore:a,viewAfter:{view:this.getView(),activeSheetId:this.getView().getActiveSheetId()}})}catch(o){throw r.rollback(),o}return n}_setSelectedSheet(e){if(this._closed)throw new Error(lt);const t=this._getSheetRef(e);if(!t)throw new Error(pl(e));let n=null;return t.visibility!==exports.ISheet.Visibility.Visible&&this._setSheetVisibility(t,exports.ISheet.Visibility.Visible),this._view.setActiveSheetId(t.id),n=t.sheet,n}getProtection(){return this._protection}getNames(){return this._names}getCalculation(){return this._calculation}getScripts(){return this._scripts??null}_notifyAllChange(){this._emitter.notify("onSheetsChange"),this._emitter.notify("onViewChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}_sheetToWBEvent(e){const t=this;return n=>{const r=()=>{const i=n.getSource();if(i.isICellRanges){const a=[...i.getCoords()];for(let l=0;l<a.length;l++){const c=a[l];!c.sheetName&&i.getSource().getName()&&(a[l]={...c,sheetName:i.getSource().getName()})}return t.getRanges(a)}if(i.isICellRange){const a=i.getCoords(),l=i.getSource().getName();return t.getRange({...a,sheetName:l})}},o={getSource:r,trigger:n.trigger,getFrom:()=>t.getRanges(n.getFrom()),getTo:()=>t.getRange(n.getTo()),isDataChange:n.isDataChange,isTransactional:n.isTransactional,isUndo:n.isUndo,toString:()=>`WorkbookRangeEvent: ('${n.trigger}', ${r().toString()})`,timeStamp:Date.now()};e(o)}}_fromJSON(e){if(this._emitter.notify("onBeforeLoad",{params:e}),this._initState(),!e.sheets||e.sheets.length===0)throw new Error(_l);e.theme&&(this._theme=new vi(e.theme),this._styles.setTheme(this._theme));const t=this._strings.beginPersist(),n=this._resources.beginPersist(),r=this._styles.beginPersist();try{t.fromJSON(e.strings),n.fromJSON(e.resources),r.fromJSON(e.styles),e.date1904&&(this._isDate1904=!0),e.view||(e.view={});const o=e.sheets,i=o.length;let a=e.view.activeSheetId??null;a!==null&&(a=Math.min(Math.max(1,a),i));let l=null;for(let h=0;h<i;h++){const u=o[h],d=u.visibility||exports.ISheet.Visibility.Visible,g=h+1;d===exports.ISheet.Visibility.Visible?l=g:a!==null&&a===g&&(a=null),this._createSheet(g,u.name,d,void 0,u.sheet)}this._updateState({lastId:l}),e.names&&this._names.fromJSON(e.names),e.view.activeSheetId=a??l,this.setView(new Yl({json:e.view})),this._adjustSheetNamesIfRequired(),this._listenerProtection?.();const c=this;this._protection=new eg(e?.protection,this._options?.readonly),this._listenerProtection=this._protection.addListeners({onChange:h=>{c._emitter.notify("onProtectionChange",{source:h})}}),e.scripts&&(this._scripts=this._createScripts(e.scripts)),this._emitter.notify("onLoad")}finally{r.endPersist(),n.endPersist(),t.endPersist()}}_createScripts(e){return new Wy({transactions:this._transactions,json:e,workbook:this,onAdd:(t,n)=>{const r=this._calculation;r.getStatus()!==exports.ICalculation.Status.Off&&r.start().then(()=>{const o=n.getFunctions().search({type:"formula"});for(let i=0;i<o.length;i++){const a=o[i];this._calculation.getFunctions().add(a)}})},onRemove:(t,n)=>{}})}async toJSON(e=!1){if(this._closed)throw new Error(lt);await this._emitter.notify("onBeforeSave",{async:!0});const t={sheets:[]};await Promise.resolve(this._starting);const n=this._theme.toJSON();(n?Object.keys(n).length:0)>0&&(t.theme=n);const r=this._strings.beginPersist(),o=this._resources.beginPersist(),i=this._styles.beginPersist();try{const a=this._getSheetRef(this.getSelectedSheetIndex()).id;let l=a,c=null;const h=this._getState(),u=h.sheetRefsAll,d=h.sheetsById;for(let C=0;C<u.length;C++){const y=u[C],b=C+1,w=await d.get(y.id).toJSON(e),E={name:y.name,sheet:w};y.visibility===exports.ISheet.Visibility.Visible?c=b:E.visibility=y.visibility,y.id===a&&(l=b),t.sheets.push(E)}const g=i.toJSON();g&&Object.keys(g).length>0&&(t.styles=g);const m=this.getProtection().toJSON();m&&(t.protection=m);const f=await r.toJSONAsync();f&&f.length>0&&(t.strings=f);const _=await o.toJSONAsync();_&&_.length>0&&(t.resources=_);const p=this._names.toJSON();p&&p.length>0&&(t.names=p);const S=this._view.toJSON();S&&(l!==c?S.activeSheetId=l:delete S.activeSheetId,Object.keys(S).length>0&&(t.view=S))}finally{i.endPersist(),o.endPersist(),r.endPersist()}if(this._scripts){const a=this._scripts.toJSON();a&&Object.keys(a).length>0&&(t.scripts=a)}return this._isDate1904&&(t.date1904=!0),this._emitter.notify("onSave",{params:t}),t}isClosed(){return this._closed}close(){if(this._closed)return;this._emitter.notify("onClose");const e=this._getState();e.listenersSheets.forEach(n=>{n()}),e.listenersSheets.clear();const t=e.sheetRefsAll;for(let n=t.length-1;n>=0;n--)try{t[n].sheet.close()}catch(r){console.warn("error on close",r)}this._ownResources,this._ownNames&&this._names.close(),this._ownsCalculation&&this._calculation.close(),this._ownStyles,this._transactionsRemoveListener?.(),this._closed=!0}beginCommit(e){if(this._closed)throw new Error(lt);return this._beginCommit(typeof e=="string"?{description:e}:e)}doBatch(e,t){const n=this;return t=typeof t=="string"?{description:t}:{description:"Update Workbook",...t},this._transactions.doBatch(e,t,(r,o)=>{r.getDepth()===0&&(n._lastTransactionUUID=r.getId())})}_beginCommit(e){const t=this;return this._transactions.beginCommit(typeof e=="string"?{description:e}:e,n=>{n.getDepth()===0&&(t._lastTransactionUUID=n.getId())})}_getState(){return this._transactions.getState(this)}_updateState(e,t="Update Workbook"){if(!e)return;const n=this._beginCommit(t);try{n.updateState(this,e),n.commit()}catch(r){throw n.rollback(),r}}get options(){return this._options}get[Symbol.toStringTag](){return"[Workbook]"}toString(){return""}get isIWorkbook(){return!0}}const xr={address:null,scope:null};exports.$t=wg,exports.Calculation=vc,exports.Color=Ue,exports.ExternalRangeClipboardItem=class{constructor(s,e,t,n){if(this._parsed=void 0,!s)throw new Dt("nativeItems are required.");this._native=s,this._markOptions=Object.freeze(e??{}),this._styles=t,this._isDate1904=n}getItemType(){return"range"}isCut(){return!1}toText(){return this._native?.text}toHtml(){return this._native?.html?.documentElement.outerHTML||null}toImage(){return this._native?.image}getItem(){const s=this._parsed;if(s===void 0)throw new Error("Must call 'parse()' before getItem().");if(s===null)return null;if(this._snapshot)return this._snapshot;const e=this;return this._snapshot={copyTo:(t,n)=>s.copyTo(t,{...e._markOptions,...n}),getMarkOptions:()=>e._markOptions,getName:()=>s?.getName()??"Clipboard Data",getCoords:()=>s?.getCoords?.()??null,toText:()=>e.toText(),toHtml:()=>e.toHtml(),toImage:()=>e.toImage(),getSource:()=>s?.getSource?.()??null,isISnapshot:!0},this._snapshot}async parse(){let s,e=this._native?.text,t=this._native.html;if(t===null&&e&&e.includes("<table"))try{const n=new DOMParser().parseFromString(e,Te.html),r=n.querySelector("parsererror");if(r)throw new Error("Unable to parse: "+r);t=n,e=null}catch{console.warn("Discovered text as html table but could could not parse.")}try{const n=new ly(this._styles,this._isDate1904,t?"HTML":"Text"),r=await Promise.resolve(e?((i,a=" ")=>new Promise((l,c)=>{Promise.resolve().then(()=>require("./CBHpVFiJCCNa32Qd.cjs")).then(h=>h.papaparse_min).then(h=>{try{const u=h.parse(i,{delimiter:a}).data;u.length>1&&(u[u.length-1].length===0||u[u.length-1].length===1&&u[u.length-1][0].length===0)&&u.pop(),l(u)}catch(u){console.warn(u),c(u)}},h=>{c(h)})}))(e):[[]]);let o;if(hy(t,r,n)?(s=n.sheet(),o=s.getUsedRange()):t=null,o)return this._parsed={async copyTo(i,a){return(await i.copyFrom(o,a))?.getCoords()??null},getCoords:()=>o.getCoords(),getSource:()=>s,getName:()=>s.getName()},!0}catch(n){throw n}if(!e&&!t&&this._native.image){const n=this;return this._parsed={async copyTo(r,o){const i=r.getSource(),a=await i.getMovables().addImage({buffer:n._native.image.arrayBuffer()},{type:"picture",description:"Copy Image from Clipboard"});return i.getView().selectMovables([a]),null},getName:()=>"Image"},!0}return!1}get isClipboardItem(){return!0}},exports.FormulaContext=hf,exports.GeomUtils=sp,exports.Gt=Yo,exports.Ht=Yn,exports.I=ag,exports.IFontCollection=N0,exports.Kt=k,exports.LicenseManager=rc,exports.M=U,exports.Picture=lf,exports.Qt=Bo,exports.RangeClipboardItem=class{constructor(s){if(!s)throw new Dt("snapshot is required.");this._snapshot=s}getItemType(){return"range"}getItem(){return this._snapshot}editMode(){return this._snapshot?.getMarkOptions().editMode??null}isCut(){return this._snapshot?.getMarkOptions().isCut??!1}getName(){return this._snapshot.getName()}toText(){return this._snapshot.toText()}toHtml(){return this._snapshot.toHtml()}toImage(){return this._snapshot.toImage()}get isClipboardItem(){return!0}},exports.Resource=mi,exports.ResourceCollection=Cc,exports.Sheet=Gr,exports.SimpleFontFace=lm,exports.StringCollection=Ki,exports.StyleCollection=Xr,exports.Table=af,exports.TextUtils=R0,exports.Theme=vi,exports.ThemeCollection=gc,exports.TransactionStore=Lt,exports.TransactionUndoManager=class extends qc{constructor(s,e=50){super(e),this._transactions=s;const t=this;s?.addListener({onCommitEnd:n=>{n.getDescription()&&t.addUndoOperation({description:n.getDescription(),undo:()=>(s.revert(n.getId()),()=>{s.restore(n.getId())})})}})}clear(){super.clear()}close(){this._removeLister()}},exports.TypedFunction=Ko,exports.Vt=cn,exports.Workbook=Jy,exports.WorkbookView=Yl,exports.Wt=Be,exports.Xt=Mr,exports.Yt=F,exports.Zt=fg,exports.ae=tc,exports.coerceScalar=Ot,exports.colToString=Pt,exports.defaultGetEntireCoords=Ai,exports.ee=class{constructor(){this._resolve=null,this._result=void 0,this._handled=null,this._reject=null,this._error=void 0,this._promise=null,this._promise=new Promise((s,e)=>{this._resolve=s,this._reject=e,this._handled==="resolve"?s(this._result):this._handled==="reject"&&e(this._error)})}resolve(s){this._resolve?this._resolve(s):this._handled||(this._result=s),this._handled="resolve"}reject(s){this._reject?this._reject(s):this._handled||(this._error=s),this._handled="reject"}async wait(){await this._promise}},exports.getDefaultExportFromCjs=hc,exports.gridFromArray=Nm,exports.h=Te,exports.ie=Cl,exports.j=ig,exports.k=Ur,exports.le=Xf,exports.minCoerce=ns,exports.ne=ke,exports.oe=Dt,exports.re=yg,exports.rowToString=$t,exports.se=qc,exports.te=Ws,exports.toAbsoluteRange=(s,e,t,n)=>{let r=s.colStart,o=s.rowStart,i=s.colEnd,a=s.rowEnd;const l=s.$colStart??!1,c=s.$rowStart??!1,h=s.$colEnd??!1,u=s.$rowEnd??!1;if(l||r===Number.MIN_SAFE_INTEGER||(r+=t),c||o===Number.MIN_SAFE_INTEGER||(o+=e),h||i===Number.MAX_SAFE_INTEGER||(i+=t),u||a===Number.MAX_SAFE_INTEGER||(a+=e),r>i){const g=r;r=i,i=g}if(o>a){const g=o;o=a,a=g}let d;return n?(d=n,d.colStart=r,d.rowStart=o,d.colEnd=i,d.rowEnd=a,d.$colStart=l,d.$rowStart=c,d.$colEnd=h,d.$rowEnd=u):d={colStart:r,rowStart:o,colEnd:i,rowEnd:a,$colStart:l,$rowStart:c,$colEnd:h,$rowEnd:u},s.sheetName&&(d.sheetName=s.sheetName),d},exports.tokensToA1=_f,exports.tokensToR1C1=pf,exports.typeFromJsValue=Ze,exports.ut=El,exports.y=se,exports.z=kf;