@sheetxl/sdk 0.4.13 → 0.4.14

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 (166) hide show
  1. package/browser/cjs/8JuguQ-v_wjzRAJQ.cjs +6 -0
  2. package/browser/cjs/B06_i0NVsMlV7sL3.cjs +15 -0
  3. package/browser/cjs/BMzm6e19THp5R5SS.cjs +6 -0
  4. package/browser/{esm/bC-pS6WlvqHBcNXl.mjs → cjs/BSQ6GwaDgEhp4-Jm.cjs} +3 -4
  5. package/browser/cjs/BSaEFx_1qH-bqkxA.cjs +32 -0
  6. package/browser/cjs/BeFLdMQtixEQOMIf.cjs +6 -0
  7. package/browser/cjs/Bypbx3PA2wZ-MxR7.cjs +1501 -0
  8. package/browser/cjs/C4rkyi5ne70h0eUM.cjs +13 -0
  9. package/browser/cjs/CK7GKaY19eDwb72K.cjs +6 -0
  10. package/browser/cjs/CQtudwvjokdRI8w7.cjs +6 -0
  11. package/browser/cjs/CZpCJ_mGf8uvTyHs.cjs +6 -0
  12. package/browser/cjs/CeW7HtHiebPU1ZrI.cjs +6 -0
  13. package/browser/cjs/CpD5wln4iVlrPfkY.cjs +6 -0
  14. package/browser/cjs/CxNcIlUbtVSt64Tm.cjs +6 -0
  15. package/browser/cjs/D0KawW_CBCzUbAwf.cjs +6 -0
  16. package/browser/cjs/D1hmSqsrlX7CR2o_.cjs +6 -0
  17. package/browser/cjs/D4c1Sr1XvF3nMs-j.cjs +6 -0
  18. package/browser/cjs/D6h0MMq-X27_iD6g.cjs +6 -0
  19. package/browser/cjs/DE3tCi_X6QIZF8tS.cjs +6 -0
  20. package/browser/cjs/DNRSQjR0UdY_4fl9.cjs +6 -0
  21. package/browser/cjs/DSUl7vRzR8mV1Myf.cjs +6 -0
  22. package/browser/cjs/DTAOALsCBhuSuEiG.cjs +6 -0
  23. package/browser/cjs/DaV0-3D2kIZdcEfA.cjs +6 -0
  24. package/browser/cjs/DejSF-jvG3xB_8YE.cjs +60 -0
  25. package/browser/cjs/Depd1YehybNaiyCe.cjs +6 -0
  26. package/browser/cjs/Dq9JXD1VUC_eXNv8.cjs +7 -0
  27. package/browser/cjs/DveSU-1M1dKih8ss.cjs +6 -0
  28. package/browser/cjs/QgxQTHhUBOvKb5Sp.cjs +6 -0
  29. package/browser/cjs/index.cjs +3 -4
  30. package/browser/cjs/is67OzV6HSQv8hND.cjs +6 -0
  31. package/browser/cjs/mD326DVwUY2qz53z.cjs +6 -0
  32. package/browser/cjs/p9-P5tsRY2aEac88.cjs +124 -0
  33. package/browser/cjs/rdaInA-ytvORY7dI.cjs +6 -0
  34. package/browser/cjs/v59Hlj7XX2HjAklI.cjs +6 -0
  35. package/{node/esm/CoowIrBw0vTXnosY.mjs → browser/esm/0y8470lJoPLFzYRG.mjs} +1 -1
  36. package/{node/esm/DQvu2JlpO07Yqcvx.mjs → browser/esm/6ofNyUJ2bff5hQAb.mjs} +1 -1
  37. package/browser/esm/8jrILMSMxtRYp4Ml.mjs +10 -0
  38. package/browser/esm/{DQ6InIROOs1_L5ez.mjs → B1U-ZkWRkC7EsWhJ.mjs} +7 -2
  39. package/browser/esm/BaQ-kJ0S48-mIDOB.mjs +10 -0
  40. package/browser/esm/Bg1s7CT60pr7m6Wv.mjs +24266 -0
  41. package/browser/esm/BjMYkedmgsLBSeIL.mjs +24 -0
  42. package/{node/esm/Dlftv7TykJRVk7Wx.mjs → browser/esm/BwAtcwzMrBFQsJrt.mjs} +1 -1
  43. package/browser/esm/CA81BqhGVQdWnnU-.mjs +3974 -0
  44. package/browser/esm/CASK_saDBb0E8-gc.mjs +5651 -0
  45. package/browser/esm/CEPVn5ObLgMnhFuG.mjs +10 -0
  46. package/{node/esm/cWKERSoNy_Mo5gOQ.mjs → browser/esm/CJSlOHcd-GRplhJb.mjs} +1 -1
  47. package/browser/esm/CXCFBAK8GNqcf4NZ.mjs +426 -0
  48. package/browser/esm/CZH9NjmkPt5qOZvo.mjs +10 -0
  49. package/{node/esm/axtXmmwYm1aHBXjg.mjs → browser/esm/Co_XNsi04fa0kXfc.mjs} +1 -1
  50. package/browser/esm/D2d6F8a0L2i5KG9B.mjs +1575 -0
  51. package/{node/esm/DMhTOGJLYCiHGnjP.mjs → browser/esm/D5MCJciGCVt9S3_d.mjs} +1 -1
  52. package/{node/esm/CBdo244r3xwae4_o.mjs → browser/esm/D5m4uOGT4rzpeawH.mjs} +1 -1
  53. package/browser/esm/D799n_-syMIKHsZB.mjs +21 -0
  54. package/browser/esm/D7vGd1TA1pYs2r8i.mjs +10 -0
  55. package/{node/esm/dRD2c-s3aQJNoK6m.mjs → browser/esm/DDcxalm5bxkWR6yr.mjs} +1 -1
  56. package/{node/esm/DLDt1F5JzQq5aKdG.mjs → browser/esm/DGSd15RAMHKU4TTh.mjs} +1 -1
  57. package/browser/esm/DML06qJVWAeMmTeF.mjs +29 -0
  58. package/{node/esm/C6FEsnCdmUvcIDzA.mjs → browser/esm/Dq1c2fRK8fy1wIZ0.mjs} +1 -1
  59. package/{node/esm/DZl6ZagrmdiXKi9x.mjs → browser/esm/Ds3gLJ0AViDNAZBb.mjs} +1 -1
  60. package/{node/esm/Bb5FApoZ10dDGlM-.mjs → browser/esm/Dv-eMLsSU3GgM0IG.mjs} +1 -1
  61. package/{node/esm/j5mlBPjSlgnHX9pH.mjs → browser/esm/IF7Bu3bAljYlYAhG.mjs} +1 -1
  62. package/browser/esm/Ijz2AYZo5041p_E0.mjs +820 -0
  63. package/{node/esm/L0bRh78pniyMZ_3v.mjs → browser/esm/_9LudTdmURafvtbM.mjs} +1 -1
  64. package/{node/esm/tw0tbG4pvPai6vfe.mjs → browser/esm/c0yMyZrKHAQcuk34.mjs} +1 -1
  65. package/browser/esm/c8TPaGQuorNwRY5P.mjs +472 -0
  66. package/browser/esm/flS4x_DXemCnqZYx.mjs +10 -0
  67. package/browser/esm/index.mjs +84 -2
  68. package/{node/esm/Bq3GEYeFkbO3vHHx.mjs → browser/esm/utnJnW2cCjLr_J5j.mjs} +1 -1
  69. package/licenses/dependencies.txt +3 -3
  70. package/node/esm/0y8470lJoPLFzYRG.mjs +10 -0
  71. package/node/esm/6ofNyUJ2bff5hQAb.mjs +10 -0
  72. package/node/esm/{BmkbBs1Yla2RsZ_s.mjs → BAJg2qwLifwsMs48.mjs} +1 -1
  73. package/node/esm/{Dxqu9uwKDQHBrAqJ.mjs → BVwiUEUE8Kq6Q-Md.mjs} +2 -2
  74. package/node/esm/{DOdqJUKquKrouyJg.mjs → Be8IGMeEVQrqyIbz.mjs} +1 -1
  75. package/node/esm/{CKO3kzDC1TBjmP6a.mjs → BkSSbBdHw5fSDT9u.mjs} +1 -1
  76. package/node/esm/{n0CrIZcZCwIu-yiw.mjs → BlMT23s2F34fCyyF.mjs} +1 -1
  77. package/node/esm/BwAtcwzMrBFQsJrt.mjs +10 -0
  78. package/node/esm/CJSlOHcd-GRplhJb.mjs +10 -0
  79. package/node/esm/{CsI4IQyunxqLyMWY.mjs → Cg0Rg6HBC4czGxnY.mjs} +1 -1
  80. package/node/esm/{B-cEaNMrVscFjP28.mjs → Ciz3vgy9vMXs8dGv.mjs} +1 -1
  81. package/node/esm/{DNLKWsIB7wfMRm8a.mjs → CmZcNpOTEY__HcNE.mjs} +2 -2
  82. package/node/esm/Co_XNsi04fa0kXfc.mjs +10 -0
  83. package/node/esm/{moaVD3gybeaMfy_q.mjs → D-ebNw7-IJtP0UVf.mjs} +1 -1
  84. package/node/esm/{BZScF0z5mvap-tCk.mjs → D1IiK4HwSFrtL98j.mjs} +1 -1
  85. package/node/esm/D5MCJciGCVt9S3_d.mjs +10 -0
  86. package/node/esm/D5m4uOGT4rzpeawH.mjs +10 -0
  87. package/node/esm/DDcxalm5bxkWR6yr.mjs +10 -0
  88. package/{browser/cjs/DOptrVmGD_5mAjIJ.cjs → node/esm/DGSd15RAMHKU4TTh.mjs} +5 -2
  89. package/node/esm/Dbv1kS3xRdworJhn.mjs +80 -0
  90. package/node/esm/{DHJoU9KsVtSXERyd.mjs → DmYC6rfHbxzRi-xv.mjs} +4 -4
  91. package/node/esm/Dq1c2fRK8fy1wIZ0.mjs +10 -0
  92. package/node/esm/Ds3gLJ0AViDNAZBb.mjs +10 -0
  93. package/node/esm/Dv-eMLsSU3GgM0IG.mjs +10 -0
  94. package/node/esm/{G0slAplR6jB1csaY.mjs → Dw228_AFFTiN-qSG.mjs} +1 -1
  95. package/node/esm/{o47K-SM01hvIUrc0.mjs → HHRD6y1sXoRYiRM-.mjs} +2 -2
  96. package/node/esm/IF7Bu3bAljYlYAhG.mjs +10 -0
  97. package/node/esm/_9LudTdmURafvtbM.mjs +10 -0
  98. package/node/esm/c0yMyZrKHAQcuk34.mjs +10 -0
  99. package/node/esm/{DNTdUrrAs4YsX782.mjs → igBKvoiyyirwpnsa.mjs} +1 -1
  100. package/node/esm/index.mjs +3449 -3206
  101. package/node/esm/utnJnW2cCjLr_J5j.mjs +10 -0
  102. package/package.json +4 -4
  103. package/browser/cjs/99FHKXLdlCef5nfT.cjs +0 -7
  104. package/browser/cjs/B5eveWag0dzzgkgX.cjs +0 -7
  105. package/browser/cjs/BJA1_CndBCMNr53J.cjs +0 -7
  106. package/browser/cjs/BVE8RsCx6dH-PJ3G.cjs +0 -7
  107. package/browser/cjs/BbvyF-KASTBWusEs.cjs +0 -7
  108. package/browser/cjs/BfAJd561Nzaudhz_.cjs +0 -7
  109. package/browser/cjs/BlgZLqYSIZleOo8h.cjs +0 -7
  110. package/browser/cjs/BpoOeB751mnCS6V-.cjs +0 -7
  111. package/browser/cjs/CE7l7CfFaLMonVMB.cjs +0 -7
  112. package/browser/cjs/CHBhqMbMhjW9YdAF.cjs +0 -7
  113. package/browser/cjs/CIJiAsckzAZgx8n4.cjs +0 -7
  114. package/browser/cjs/CgOy3BgHFueAFAeL.cjs +0 -7
  115. package/browser/cjs/Cl0gNER1w9A58kbc.cjs +0 -13
  116. package/browser/cjs/CmBrJtijpbCUSPWR.cjs +0 -10
  117. package/browser/cjs/CuYGUMy7ROX5G_sm.cjs +0 -7
  118. package/browser/cjs/Czqso66RMuDka4LC.cjs +0 -7
  119. package/browser/cjs/D-NvwNeGLHGiv00z.cjs +0 -7
  120. package/browser/cjs/DHVBvApvjbLRsOju.cjs +0 -7
  121. package/browser/cjs/DORshTQEHNF0VHvp.cjs +0 -7
  122. package/browser/cjs/DRKq7WhWW37UIj1Q.cjs +0 -7
  123. package/browser/cjs/DhWK7BDP7ZhYYPga.cjs +0 -7
  124. package/browser/cjs/DpSwAPYhahtG5EKw.cjs +0 -7
  125. package/browser/cjs/DvioTOgF2jNUKBcT.cjs +0 -7
  126. package/browser/cjs/DwSf7lami5Uh2Uh6.cjs +0 -7
  127. package/browser/cjs/Dy6R4NfGavsHaUnQ.cjs +0 -10
  128. package/browser/cjs/HEI6Q0oyMX2A1gth.cjs +0 -7
  129. package/browser/cjs/_Lz_D28ElE-H04r8.cjs +0 -7
  130. package/browser/cjs/hONph4eRHAvmiEYv.cjs +0 -7
  131. package/browser/cjs/nQYA0VPzyPNFcvaF.cjs +0 -7
  132. package/browser/cjs/pPrxgr769sUGB5WL.cjs +0 -7
  133. package/browser/cjs/sqCd-isdKO-WsW_F.cjs +0 -7
  134. package/browser/cjs/xobXrowL2Qx-kWv9.cjs +0 -7
  135. package/browser/esm/4lHZjpF3_ugmKKui.mjs +0 -7
  136. package/browser/esm/67bnWHzYa5DZMY6A.mjs +0 -7
  137. package/browser/esm/BDYJEEaksgeY1UaE.mjs +0 -7
  138. package/browser/esm/BG0zhw4ripZzsL-w.mjs +0 -7
  139. package/browser/esm/BOfILXwwP1BW8Bsw.mjs +0 -7
  140. package/browser/esm/BPEwv5xX4DLnd-8o.mjs +0 -7
  141. package/browser/esm/BUeaoQihd7nbjV5D.mjs +0 -7
  142. package/browser/esm/Bb8asJ4COo3sy4Gt.mjs +0 -7
  143. package/browser/esm/BbJAEyq0pAF7biF-.mjs +0 -7
  144. package/browser/esm/BuoPWoEzsXvQsZFU.mjs +0 -7
  145. package/browser/esm/By_8JXNSh9nnHyBW.mjs +0 -7
  146. package/browser/esm/C4K5CBXvVExqCdpa.mjs +0 -7
  147. package/browser/esm/CKUiTXSrn9Xg_ph1.mjs +0 -10
  148. package/browser/esm/CLP8NgXNjnLl-iMQ.mjs +0 -7
  149. package/browser/esm/CVGuaXPdnO65bXE5.mjs +0 -7
  150. package/browser/esm/ClgHaEbC8eHvV73x.mjs +0 -7
  151. package/browser/esm/CoZh7nD_zQLfTNcp.mjs +0 -7
  152. package/browser/esm/D2jQMy8XvCDNeRaM.mjs +0 -7
  153. package/browser/esm/D3D_Ad9RkEvBe7Wz.mjs +0 -7
  154. package/browser/esm/D5dJ7VFFZvIOU2As.mjs +0 -7
  155. package/browser/esm/D8vW0N6EH97lDhnP.mjs +0 -7
  156. package/browser/esm/DB9YIl5l53cTx_qf.mjs +0 -7
  157. package/browser/esm/DFbUKmUyr8XjG6uR.mjs +0 -7
  158. package/browser/esm/DROuUTBh0ijsxsde.mjs +0 -7
  159. package/browser/esm/Dq1V1gMAXsC87zqO.mjs +0 -13
  160. package/browser/esm/Ds_YxbxItIu7PKA-.mjs +0 -7
  161. package/browser/esm/Ho-V23ZRWrnAVftS.mjs +0 -7
  162. package/browser/esm/j21djw_rEjBtpjRd.mjs +0 -7
  163. package/browser/esm/kXWocze33jAxVJq6.mjs +0 -10
  164. package/browser/esm/qi0568hNwcdjIMy6.mjs +0 -7
  165. package/browser/esm/yVExwiZwWE8vLSFO.mjs +0 -7
  166. package/node/esm/k3luU7uFD82_cpo4.mjs +0 -80
@@ -1,7 +0,0 @@
1
- /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.13
3
- *
4
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- import{n as e,j as t,c as n,e as r,t as i,g as o,a as s,b as a,d as c,f as u,h as l,r as h,m as f,i as d}from"./kXWocze33jAxVJq6.mjs";var p="object"==typeof global&&global&&global.Object===Object&&global,m="object"==typeof self&&self&&self.Object===Object&&self,E=p||m||Function("return this")(),g=E.Symbol,T=Object.prototype,A=T.hasOwnProperty,I=T.toString,v=g?g.toStringTag:void 0;var N=Object.prototype.toString;var y=g?g.toStringTag:void 0;function R(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":y&&y in Object(e)?function(e){var t=A.call(e,v),n=e[v];try{e[v]=void 0;var r=!0}catch(e){}var i=I.call(e);return r&&(t?e[v]=n:delete e[v]),i}(e):function(e){return N.call(e)}(e)}function O(e){return null!=e&&"object"==typeof e}function S(e){return"symbol"==typeof e||O(e)&&"[object Symbol]"==R(e)}function _(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var L=Array.isArray,x=g?g.prototype:void 0,C=x?x.toString:void 0;function k(e){if("string"==typeof e)return e;if(L(e))return _(e,k)+"";if(S(e))return C?C.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var b=/\s/;var P=/^\s+/;function w(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&b.test(e.charAt(t)););return t}(e)+1).replace(P,""):e}function M(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var U=/^[-+]0x[0-9a-f]+$/i,F=/^0b[01]+$/i,D=/^0o[0-7]+$/i,j=parseInt;var B=1/0;function $(e){return e?(e=function(e){if("number"==typeof e)return e;if(S(e))return NaN;if(M(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=M(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=w(e);var n=F.test(e);return n||D.test(e)?j(e.slice(2),n?2:8):U.test(e)?NaN:+e}(e))===B||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function W(e){var t=$(e),n=t%1;return t==t?n?t-n:t:0}function G(e){return e}function K(e){if(!M(e))return!1;var t=R(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var z,V=E["__core-js_shared__"],H=(z=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var Y=Function.prototype.toString;function X(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var q=/^\[object .+?Constructor\]$/,Z=Function.prototype,Q=Object.prototype,J=Z.toString,ee=Q.hasOwnProperty,te=RegExp("^"+J.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ne(e){return!(!M(e)||(t=e,H&&H in t))&&(K(e)?te:q).test(X(e));var t}function re(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return ne(n)?n:void 0}var ie=re(E,"WeakMap"),oe=Object.create,se=function(){function e(){}return function(t){if(!M(t))return{};if(oe)return oe(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function ae(){}var ce=Date.now;var ue,le,he,fe=function(){try{var e=re(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),de=fe?function(e,t){return fe(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:G,pe=(ue=de,le=0,he=0,function(){var e=ce(),t=16-(e-he);if(he=e,t>0){if(++le>=800)return arguments[0]}else le=0;return ue.apply(void 0,arguments)});function me(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function Ee(e,t,n,r){for(var i=e.length,o=n+-1;++o<i;)if(t(e[o],o,e))return o;return-1}function ge(e){return e!=e}function Te(e,t,n){return t==t?function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):Ee(e,ge,n)}function Ae(e,t){return!!(null==e?0:e.length)&&Te(e,t,0)>-1}var Ie=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Ie.test(e))&&e>-1&&e%1==0&&e<t}function Ne(e,t,n){"__proto__"==t&&fe?fe(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ye(e,t){return e===t||e!=e&&t!=t}var Re=Object.prototype.hasOwnProperty;function Oe(e,t,n){var r=e[t];Re.call(e,t)&&ye(r,n)&&(void 0!==n||t in e)||Ne(e,t,n)}function Se(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var a=t[o],c=void 0;void 0===c&&(c=e[a]),i?Ne(n,a,c):Oe(n,a,c)}return n}var _e=Math.max;function Le(e,t){return pe(function(e,t,n){return t=_e(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=_e(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=n(s),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,a)}}(e,t,G),e+"")}function xe(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Ce(e){return null!=e&&xe(e.length)&&!K(e)}function ke(e,t,n){if(!M(n))return!1;var r=typeof t;return!!("number"==r?Ce(n)&&ve(t,n.length):"string"==r&&t in n)&&ye(n[t],e)}var be=Object.prototype;function Pe(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||be)}function we(e){return O(e)&&"[object Arguments]"==R(e)}var Me=Object.prototype,Ue=Me.hasOwnProperty,Fe=Me.propertyIsEnumerable,De=we(function(){return arguments}())?we:function(e){return O(e)&&Ue.call(e,"callee")&&!Fe.call(e,"callee")};var je="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=je&&"object"==typeof module&&module&&!module.nodeType&&module,$e=Be&&Be.exports===je?E.Buffer:void 0,We=($e?$e.isBuffer:void 0)||function(){return!1},Ge={};function Ke(e){return function(t){return e(t)}}Ge["[object Float32Array]"]=Ge["[object Float64Array]"]=Ge["[object Int8Array]"]=Ge["[object Int16Array]"]=Ge["[object Int32Array]"]=Ge["[object Uint8Array]"]=Ge["[object Uint8ClampedArray]"]=Ge["[object Uint16Array]"]=Ge["[object Uint32Array]"]=!0,Ge["[object Arguments]"]=Ge["[object Array]"]=Ge["[object ArrayBuffer]"]=Ge["[object Boolean]"]=Ge["[object DataView]"]=Ge["[object Date]"]=Ge["[object Error]"]=Ge["[object Function]"]=Ge["[object Map]"]=Ge["[object Number]"]=Ge["[object Object]"]=Ge["[object RegExp]"]=Ge["[object Set]"]=Ge["[object String]"]=Ge["[object WeakMap]"]=!1;var ze="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ve=ze&&"object"==typeof module&&module&&!module.nodeType&&module,He=Ve&&Ve.exports===ze&&p.process,Ye=function(){try{var e=Ve&&Ve.require&&Ve.require("util").types;return e||He&&He.binding&&He.binding("util")}catch(e){}}(),Xe=Ye&&Ye.isTypedArray,qe=Xe?Ke(Xe):function(e){return O(e)&&xe(e.length)&&!!Ge[R(e)]},Ze=Object.prototype.hasOwnProperty;function Qe(e,t){var n=L(e),r=!n&&De(e),i=!n&&!r&&We(e),o=!n&&!r&&!i&&qe(e),s=n||r||i||o,a=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],c=a.length;for(var u in e)!t&&!Ze.call(e,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ve(u,c))||a.push(u);return a}function Je(e,t){return function(n){return e(t(n))}}var et=Je(Object.keys,Object),tt=Object.prototype.hasOwnProperty;function nt(e){if(!Pe(e))return et(e);var t=[];for(var n in Object(e))tt.call(e,n)&&"constructor"!=n&&t.push(n);return t}function rt(e){return Ce(e)?Qe(e):nt(e)}var it,ot=Object.prototype.hasOwnProperty,st=(it=function(e,t){if(Pe(t)||Ce(t))Se(t,rt(t),e);else for(var n in t)ot.call(t,n)&&Oe(e,n,t[n])},Le(function(e,t){var n=-1,r=t.length,i=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(i=it.length>3&&"function"==typeof i?(r--,i):void 0,o&&ke(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var s=t[n];s&&it(e,s,n,i)}return e}));var at=Object.prototype.hasOwnProperty;function ct(e){if(!M(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=Pe(e),n=[];for(var r in e)("constructor"!=r||!t&&at.call(e,r))&&n.push(r);return n}function ut(e){return Ce(e)?Qe(e,!0):ct(e)}var lt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ht=/^\w*$/;function ft(e,t){if(L(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!S(e))||(ht.test(e)||!lt.test(e)||null!=t&&e in Object(t))}var dt=re(Object,"create");var pt=Object.prototype.hasOwnProperty;var mt=Object.prototype.hasOwnProperty;function Et(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function gt(e,t){for(var n=e.length;n--;)if(ye(e[n][0],t))return n;return-1}Et.prototype.clear=function(){this.__data__=dt?dt(null):{},this.size=0},Et.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Et.prototype.get=function(e){var t=this.__data__;if(dt){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return pt.call(t,e)?t[e]:void 0},Et.prototype.has=function(e){var t=this.__data__;return dt?void 0!==t[e]:mt.call(t,e)},Et.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=dt&&void 0===t?"__lodash_hash_undefined__":t,this};var Tt=Array.prototype.splice;function At(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}At.prototype.clear=function(){this.__data__=[],this.size=0},At.prototype.delete=function(e){var t=this.__data__,n=gt(t,e);return!(n<0)&&(n==t.length-1?t.pop():Tt.call(t,n,1),--this.size,!0)},At.prototype.get=function(e){var t=this.__data__,n=gt(t,e);return n<0?void 0:t[n][1]},At.prototype.has=function(e){return gt(this.__data__,e)>-1},At.prototype.set=function(e,t){var n=this.__data__,r=gt(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var It=re(E,"Map");function vt(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function Nt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Nt.prototype.clear=function(){this.size=0,this.__data__={hash:new Et,map:new(It||At),string:new Et}},Nt.prototype.delete=function(e){var t=vt(this,e).delete(e);return this.size-=t?1:0,t},Nt.prototype.get=function(e){return vt(this,e).get(e)},Nt.prototype.has=function(e){return vt(this,e).has(e)},Nt.prototype.set=function(e,t){var n=vt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function yt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(yt.Cache||Nt),n}yt.Cache=Nt;var Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ot=/\\(\\)?/g,St=function(e){var t=yt(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Rt,function(e,n,r,i){t.push(r?i.replace(Ot,"$1"):n||e)}),t});function _t(e,t){return L(e)?e:ft(e,t)?[e]:St(function(e){return null==e?"":k(e)}(e))}function Lt(e){if("string"==typeof e||S(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function xt(e,t){for(var n=0,r=(t=_t(t,e)).length;null!=e&&n<r;)e=e[Lt(t[n++])];return n&&n==r?e:void 0}function Ct(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var kt=g?g.isConcatSpreadable:void 0;function bt(e){return L(e)||De(e)||!!(kt&&e&&e[kt])}function Pt(e,t,n,r,i){var o=-1,s=e.length;for(n||(n=bt),i||(i=[]);++o<s;){var a=e[o];n(a)?Ct(i,a):r||(i[i.length]=a)}return i}function wt(e){return(null==e?0:e.length)?Pt(e):[]}var Mt=Je(Object.getPrototypeOf,Object);function Ut(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o}function Ft(e,t,n,r){var i=-1,o=null==e?0:e.length;for(r&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}function Dt(e){var t=this.__data__=new At(e);this.size=t.size}Dt.prototype.clear=function(){this.__data__=new At,this.size=0},Dt.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Dt.prototype.get=function(e){return this.__data__.get(e)},Dt.prototype.has=function(e){return this.__data__.has(e)},Dt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof At){var r=n.__data__;if(!It||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Nt(r)}return n.set(e,t),this.size=n.size,this};var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=jt&&"object"==typeof module&&module&&!module.nodeType&&module,$t=Bt&&Bt.exports===jt?E.Buffer:void 0,Wt=$t?$t.allocUnsafe:void 0;function Gt(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}function Kt(){return[]}var zt=Object.prototype.propertyIsEnumerable,Vt=Object.getOwnPropertySymbols,Ht=Vt?function(e){return null==e?[]:(e=Object(e),Gt(Vt(e),function(t){return zt.call(e,t)}))}:Kt;var Yt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Ct(t,Ht(e)),e=Mt(e);return t}:Kt;function Xt(e,t,n){var r=t(e);return L(e)?r:Ct(r,n(e))}function qt(e){return Xt(e,rt,Ht)}var Zt=re(E,"DataView"),Qt=re(E,"Promise"),Jt=re(E,"Set"),en="[object Map]",tn="[object Promise]",nn="[object Set]",rn="[object WeakMap]",on="[object DataView]",sn=X(Zt),an=X(It),cn=X(Qt),un=X(Jt),ln=X(ie),hn=R;(Zt&&hn(new Zt(new ArrayBuffer(1)))!=on||It&&hn(new It)!=en||Qt&&hn(Qt.resolve())!=tn||Jt&&hn(new Jt)!=nn||ie&&hn(new ie)!=rn)&&(hn=function(e){var t=R(e),n="[object Object]"==t?e.constructor:void 0,r=n?X(n):"";if(r)switch(r){case sn:return on;case an:return en;case cn:return tn;case un:return nn;case ln:return rn}return t});var fn=Object.prototype.hasOwnProperty;var dn=E.Uint8Array;var pn=/\w*$/;var mn=g?g.prototype:void 0,En=mn?mn.valueOf:void 0;function gn(e,t,n){var r,i,o,s,a,c=e.constructor;switch(t){case"[object ArrayBuffer]":return a=new(s=e).constructor(s.byteLength),new dn(a).set(new dn(s)),a;case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return o=(i=e).buffer,new i.constructor(o,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e){var t=e.buffer;return new e.constructor(t,e.byteOffset,e.length)}(e);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,pn.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return r=e,En?Object(En.call(r)):{}}}var Tn=Ye&&Ye.isMap,An=Tn?Ke(Tn):function(e){return O(e)&&"[object Map]"==hn(e)};var In=Ye&&Ye.isSet,vn=In?Ke(In):function(e){return O(e)&&"[object Set]"==hn(e)},Nn="[object Arguments]",yn="[object Function]",Rn="[object Object]",On={};function Sn(e,t,n,r,i,o){var s;if(void 0!==s)return s;if(!M(e))return e;var a=L(e);if(a)return s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&fn.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(e,s);var c=hn(e),u=c==yn||"[object GeneratorFunction]"==c;if(We(e))return function(e){var t=e.length,n=Wt?Wt(t):new e.constructor(t);return e.copy(n),n}(e);if(c==Rn||c==Nn||u&&!i)return s=u?{}:function(e){return"function"!=typeof e.constructor||Pe(e)?{}:se(Mt(e))}(e),function(e,t){return Se(e,Ht(e),t)}(e,function(e,t){return e&&Se(t,rt(t),e)}(s,e));if(!On[c])return i?e:{};s=gn(e,c),o||(o=new Dt);var l=o.get(e);if(l)return l;o.set(e,s),vn(e)?e.forEach(function(r){s.add(Sn(r,t,n,r,e,o))}):An(e)&&e.forEach(function(r,i){s.set(i,Sn(r,t,n,i,e,o))});var h=a?void 0:qt(e);return me(h||e,function(r,i){h&&(r=e[i=r]),Oe(s,i,Sn(r,t,n,i,e,o))}),s}On[Nn]=On["[object Array]"]=On["[object ArrayBuffer]"]=On["[object DataView]"]=On["[object Boolean]"]=On["[object Date]"]=On["[object Float32Array]"]=On["[object Float64Array]"]=On["[object Int8Array]"]=On["[object Int16Array]"]=On["[object Int32Array]"]=On["[object Map]"]=On["[object Number]"]=On[Rn]=On["[object RegExp]"]=On["[object Set]"]=On["[object String]"]=On["[object Symbol]"]=On["[object Uint8Array]"]=On["[object Uint8ClampedArray]"]=On["[object Uint16Array]"]=On["[object Uint32Array]"]=!0,On["[object Error]"]=On[yn]=On["[object WeakMap]"]=!1;function _n(e){return Sn(e,4)}function Ln(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var o=e[t];o&&(i[r++]=o)}return i}function xn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Nt;++t<n;)this.add(e[t])}function Cn(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function kn(e,t){return e.has(t)}xn.prototype.add=xn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},xn.prototype.has=function(e){return this.__data__.has(e)};function bn(e,t,n,r,i,o){var s=1&n,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var h=-1,f=!0,d=2&n?new xn:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var p=e[h],m=t[h];if(r)var E=s?r(m,p,h,t,e,o):r(p,m,h,e,t,o);if(void 0!==E){if(E)continue;f=!1;break}if(d){if(!Cn(t,function(e,t){if(!kn(d,t)&&(p===e||i(p,e,n,r,o)))return d.push(t)})){f=!1;break}}else if(p!==m&&!i(p,m,n,r,o)){f=!1;break}}return o.delete(e),o.delete(t),f}function Pn(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function wn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Mn=g?g.prototype:void 0,Un=Mn?Mn.valueOf:void 0;var Fn=Object.prototype.hasOwnProperty;var Dn="[object Arguments]",jn="[object Array]",Bn="[object Object]",$n=Object.prototype.hasOwnProperty;function Wn(e,t,n,r,i,o){var s=L(e),a=L(t),c=s?jn:hn(e),u=a?jn:hn(t),l=(c=c==Dn?Bn:c)==Bn,h=(u=u==Dn?Bn:u)==Bn,f=c==u;if(f&&We(e)){if(!We(t))return!1;s=!0,l=!1}if(f&&!l)return o||(o=new Dt),s||qe(e)?bn(e,t,n,r,i,o):function(e,t,n,r,i,o,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new dn(e),new dn(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ye(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Pn;case"[object Set]":var c=1&r;if(a||(a=wn),e.size!=t.size&&!c)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var l=bn(a(e),a(t),r,i,o,s);return s.delete(e),l;case"[object Symbol]":if(Un)return Un.call(e)==Un.call(t)}return!1}(e,t,c,n,r,i,o);if(!(1&n)){var d=l&&$n.call(e,"__wrapped__"),p=h&&$n.call(t,"__wrapped__");if(d||p){var m=d?e.value():e,E=p?t.value():t;return o||(o=new Dt),i(m,E,n,r,o)}}return!!f&&(o||(o=new Dt),function(e,t,n,r,i,o){var s=1&n,a=qt(e),c=a.length;if(c!=qt(t).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in t:Fn.call(t,l)))return!1}var h=o.get(e),f=o.get(t);if(h&&f)return h==t&&f==e;var d=!0;o.set(e,t),o.set(t,e);for(var p=s;++u<c;){var m=e[l=a[u]],E=t[l];if(r)var g=s?r(E,m,l,t,e,o):r(m,E,l,e,t,o);if(!(void 0===g?m===E||i(m,E,n,r,o):g)){d=!1;break}p||(p="constructor"==l)}if(d&&!p){var T=e.constructor,A=t.constructor;T==A||!("constructor"in e)||!("constructor"in t)||"function"==typeof T&&T instanceof T&&"function"==typeof A&&A instanceof A||(d=!1)}return o.delete(e),o.delete(t),d}(e,t,n,r,i,o))}function Gn(e,t,n,r,i){return e===t||(null==e||null==t||!O(e)&&!O(t)?e!=e&&t!=t:Wn(e,t,n,r,Gn,i))}function Kn(e){return e==e&&!M(e)}function zn(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function Vn(e){var t=function(e){for(var t=rt(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Kn(i)]}return t}(e);return 1==t.length&&t[0][2]?zn(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,r){var i=n.length,o=i;if(null==e)return!o;for(e=Object(e);i--;){var s=n[i];if(s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){var a=(s=n[i])[0],c=e[a],u=s[1];if(s[2]){if(void 0===c&&!(a in e))return!1}else if(!Gn(u,c,3,r,new Dt))return!1}return!0}(n,0,t)}}function Hn(e,t){return null!=e&&t in Object(e)}function Yn(e,t,n){for(var r=-1,i=(t=_t(t,e)).length,o=!1;++r<i;){var s=Lt(t[r]);if(!(o=null!=e&&n(e,s)))break;e=e[s]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&xe(i)&&ve(s,i)&&(L(e)||De(e))}function Xn(e,t){return ft(e)&&Kn(t)?zn(Lt(e),t):function(n){var r=function(e,t,n){var r=null==e?void 0:xt(e,t);return void 0===r?n:r}(n,e);return void 0===r&&r===t?function(e,t){return null!=e&&Yn(e,t,Hn)}(n,e):Gn(t,r,3)}}function qn(e){return ft(e)?(t=Lt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return xt(t,e)}}(e);var t}function Zn(e){return"function"==typeof e?e:null==e?G:"object"==typeof e?L(e)?Xn(e[0],e[1]):Vn(e):qn(e)}function Qn(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i<o;){var s=e[i];t(r,s,n(s),e)}return r}var Jn=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),s=o.length;s--;){var a=o[++r];if(!1===t(i[a],a,i))break}return e};var er,tr=(er=function(e,t){return e&&Jn(e,t,rt)},function(e,t){if(null==e)return e;if(!Ce(e))return er(e,t);for(var n=e.length,r=-1,i=Object(e);++r<n&&!1!==t(i[r],r,i););return e});function nr(e,t,n,r){return tr(e,function(e,i,o){t(r,e,n(e),o)}),r}var rr=Object.prototype,ir=rr.hasOwnProperty,or=Le(function(e,t){e=Object(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&ke(t[0],t[1],i)&&(r=1);++n<r;)for(var o=t[n],s=ut(o),a=-1,c=s.length;++a<c;){var u=s[a],l=e[u];(void 0===l||ye(l,rr[u])&&!ir.call(e,u))&&(e[u]=o[u])}return e});function sr(e){return O(e)&&Ce(e)}var ar=Le(function(e,t){return sr(e)?function(e,t,n,r){var i=-1,o=Ae,s=!0,a=e.length,c=[],u=t.length;if(!a)return c;t.length>=200&&(o=kn,s=!1,t=new xn(t));e:for(;++i<a;){var l=e[i],h=l;if(l=0!==l?l:0,s&&h==h){for(var f=u;f--;)if(t[f]===h)continue e;c.push(l)}else o(t,h,r)||c.push(l)}return c}(e,Pt(t,0,sr,!0)):[]});function cr(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function ur(e,t,n){var r=null==e?0:e.length;return r?Ut(e,(t=void 0===t?1:W(t))<0?0:t,r):[]}function lr(e,t,n){var r=null==e?0:e.length;return r?Ut(e,0,(t=r-(t=void 0===t?1:W(t)))<0?0:t):[]}function hr(e,t){var n;return(L(e)?me:tr)(e,"function"==typeof(n=t)?n:G)}function fr(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function dr(e,t){var n=!0;return tr(e,function(e,r,i){return n=!!t(e,r,i)}),n}function pr(e,t,n){return(L(e)?fr:dr)(e,Zn(t))}function mr(e,t){var n=[];return tr(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function Er(e,t){return(L(e)?Gt:mr)(e,Zn(t))}var gr=Math.max;var Tr,Ar=(Tr=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:W(n);return i<0&&(i=gr(r+i,0)),Ee(e,Zn(t),i)},function(e,t,n){var r=Object(e);if(!Ce(e)){var i=Zn(t);e=rt(e),t=function(e){return i(r[e],e,r)}}var o=Tr(e,t,n);return o>-1?r[i?e[o]:o]:void 0});function Ir(e){return e&&e.length?e[0]:void 0}function vr(e,t){var n=-1,r=Ce(e)?Array(e.length):[];return tr(e,function(e,i,o){r[++n]=t(e,i,o)}),r}function Nr(e,t){return(L(e)?_:vr)(e,Zn(t))}function yr(e,t){return Pt(Nr(e,t))}var Rr,Or,Sr=Object.prototype.hasOwnProperty,_r=(Rr=function(e,t,n){Sr.call(e,n)?e[n].push(t):Ne(e,n,[t])},function(e,t){var n=L(e)?Qn:nr,r=Or?Or():{};return n(e,Rr,Zn(t),r)}),Lr=Object.prototype.hasOwnProperty;function xr(e,t){return null!=e&&Lr.call(e,t)}function Cr(e,t){return null!=e&&Yn(e,t,xr)}function kr(e){return"string"==typeof e||!L(e)&&O(e)&&"[object String]"==R(e)}function br(e){return null==e?[]:function(e,t){return _(t,function(t){return e[t]})}(e,rt(e))}var Pr=Math.max;function wr(e,t,n,r){e=Ce(e)?e:br(e),n=n?W(n):0;var i=e.length;return n<0&&(n=Pr(i+n,0)),kr(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Te(e,t,n)>-1}function Mr(e,t,n){if(!(null==e?0:e.length))return-1;return Te(e,t,0)}var Ur=Object.prototype.hasOwnProperty;function Fr(e){if(null==e)return!0;if(Ce(e)&&(L(e)||"string"==typeof e||"function"==typeof e.splice||We(e)||qe(e)||De(e)))return!e.length;var t=hn(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(Pe(e))return!nt(e).length;for(var n in e)if(Ur.call(e,n))return!1;return!0}var Dr=Ye&&Ye.isRegExp,jr=Dr?Ke(Dr):function(e){return O(e)&&"[object RegExp]"==R(e)};function Br(e){return void 0===e}function $r(e,t,n,r){if(!M(e))return e;for(var i=-1,o=(t=_t(t,e)).length,s=o-1,a=e;null!=a&&++i<o;){var c=Lt(t[i]),u=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(i!=s){var l=a[c];void 0===(u=void 0)&&(u=M(l)?l:ve(t[i+1])?[]:{})}Oe(a,c,u),a=a[c]}return e}function Wr(e,t){if(null==e)return{};var n=_(function(e){return Xt(e,ut,Yt)}(e),function(e){return[e]});return t=Zn(t),function(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],a=xt(e,s);n(a,s)&&$r(o,_t(s,e),a)}return o}(e,n,function(e,n){return t(e,n[0])})}function Gr(e,t,n,r,i){return i(e,function(e,i,o){n=r?(r=!1,e):t(n,e,i,o)}),n}function Kr(e,t,n){var r=L(e)?Ft:Gr,i=arguments.length<3;return r(e,Zn(t),n,i,tr)}function zr(e,t){return(L(e)?Gt:mr)(e,function(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}(Zn(t)))}function Vr(e,t){var n;return tr(e,function(e,r,i){return!(n=t(e,r,i))}),!!n}function Hr(e,t,n){return(L(e)?Cn:Vr)(e,Zn(t))}var Yr=Jt&&1/wn(new Jt([,-0]))[1]==1/0?function(e){return new Jt(e)}:ae;function Xr(e){return e&&e.length?function(e,t,n){var r=-1,i=Ae,o=e.length,s=!0,a=[],c=a;if(o>=200){var u=Yr(e);if(u)return wn(u);s=!1,i=kn,c=new xn}else c=a;e:for(;++r<o;){var l=e[r],h=l;if(l=0!==l?l:0,s&&h==h){for(var f=c.length;f--;)if(c[f]===h)continue e;a.push(l)}else i(c,h,n)||(c!==a&&c.push(h),a.push(l))}return a}(e):[]}function qr(e){console&&console.error&&console.error(`Error: ${e}`)}function Zr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function Qr(e){const t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}}function Jr(e){function t(){}t.prototype=e;const n=new t;function r(){return typeof n.bar}return r(),r(),e}function ei(e){return kr((t=e).LABEL)&&""!==t.LABEL?e.LABEL:e.name;var t}class ti{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),hr(this.definition,t=>{t.accept(e)})}}class ni extends ti{constructor(e){super([]),this.idx=1,st(this,Wr(e,e=>void 0!==e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class ri extends ti{constructor(e){super(e.definition),this.orgText="",st(this,Wr(e,e=>void 0!==e))}}class ii extends ti{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,st(this,Wr(e,e=>void 0!==e))}}class oi extends ti{constructor(e){super(e.definition),this.idx=1,st(this,Wr(e,e=>void 0!==e))}}class si extends ti{constructor(e){super(e.definition),this.idx=1,st(this,Wr(e,e=>void 0!==e))}}class ai extends ti{constructor(e){super(e.definition),this.idx=1,st(this,Wr(e,e=>void 0!==e))}}class ci extends ti{constructor(e){super(e.definition),this.idx=1,st(this,Wr(e,e=>void 0!==e))}}class ui extends ti{constructor(e){super(e.definition),this.idx=1,st(this,Wr(e,e=>void 0!==e))}}class li extends ti{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,st(this,Wr(e,e=>void 0!==e))}}class hi{constructor(e){this.idx=1,st(this,Wr(e,e=>void 0!==e))}accept(e){e.visit(this)}}function fi(e){function t(e){return Nr(e,fi)}if(e instanceof ni){const t={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return kr(e.label)&&(t.label=e.label),t}if(e instanceof ii)return{type:"Alternative",definition:t(e.definition)};if(e instanceof oi)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof si)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof ai)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:fi(new hi({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ui)return{type:"RepetitionWithSeparator",idx:e.idx,separator:fi(new hi({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ci)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof li)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof hi){const t={type:"Terminal",name:e.terminalType.name,label:ei(e.terminalType),idx:e.idx};kr(e.label)&&(t.terminalLabel=e.label);const n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=jr(n)?n.source:n),t}if(e instanceof ri)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}class di{visit(e){const t=e;switch(t.constructor){case ni:return this.visitNonTerminal(t);case ii:return this.visitAlternative(t);case oi:return this.visitOption(t);case si:return this.visitRepetitionMandatory(t);case ai:return this.visitRepetitionMandatoryWithSeparator(t);case ui:return this.visitRepetitionWithSeparator(t);case ci:return this.visitRepetition(t);case li:return this.visitAlternation(t);case hi:return this.visitTerminal(t);case ri:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function pi(e,t=[]){return!!(e instanceof oi||e instanceof ci||e instanceof ui)||(e instanceof li?Hr(e.definition,e=>pi(e,t)):!(e instanceof ni&&wr(t,e))&&(e instanceof ti&&(e instanceof ni&&t.push(e),pr(e.definition,e=>pi(e,t)))))}function mi(e){if(e instanceof ni)return"SUBRULE";if(e instanceof oi)return"OPTION";if(e instanceof li)return"OR";if(e instanceof si)return"AT_LEAST_ONE";if(e instanceof ai)return"AT_LEAST_ONE_SEP";if(e instanceof ui)return"MANY_SEP";if(e instanceof ci)return"MANY";if(e instanceof hi)return"CONSUME";throw Error("non exhaustive match")}class Ei{walk(e,t=[]){hr(e.definition,(n,r)=>{const i=ur(e.definition,r+1);if(n instanceof ni)this.walkProdRef(n,i,t);else if(n instanceof hi)this.walkTerminal(n,i,t);else if(n instanceof ii)this.walkFlat(n,i,t);else if(n instanceof oi)this.walkOption(n,i,t);else if(n instanceof si)this.walkAtLeastOne(n,i,t);else if(n instanceof ai)this.walkAtLeastOneSep(n,i,t);else if(n instanceof ui)this.walkManySep(n,i,t);else if(n instanceof ci)this.walkMany(n,i,t);else{if(!(n instanceof li))throw Error("non exhaustive match");this.walkOr(n,i,t)}})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){const r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){const r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){const r=[new oi({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){const r=gi(e,t,n);this.walk(e,r)}walkMany(e,t,n){const r=[new oi({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){const r=gi(e,t,n);this.walk(e,r)}walkOr(e,t,n){const r=t.concat(n);hr(e.definition,e=>{const t=new ii({definition:[e]});this.walk(t,r)})}}function gi(e,t,n){return[new oi({definition:[new hi({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function Ti(e){if(e instanceof ni)return Ti(e.referencedRule);if(e instanceof hi)return[e.terminalType];if(function(e){return e instanceof ii||e instanceof oi||e instanceof ci||e instanceof si||e instanceof ai||e instanceof ui||e instanceof hi||e instanceof ri}(e))return function(e){let t=[];const n=e.definition;let r,i=0,o=n.length>i,s=!0;for(;o&&s;)r=n[i],s=pi(r),t=t.concat(Ti(r)),i+=1,o=n.length>i;return Xr(t)}(e);if(function(e){return e instanceof li}(e))return function(e){const t=Nr(e.definition,e=>Ti(e));return Xr(wt(t))}(e);throw Error("non exhaustive match")}const Ai="_~IN~_";class Ii extends Ei{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){const r=(i=e.referencedRule,o=e.idx,i.name+o+Ai+this.topProd.name);var i,o;const s=t.concat(n),a=Ti(new ii({definition:s}));this.follows[r]=a}}function vi(e){return e.charCodeAt(0)}function Ni(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function yi(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function Ri(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function Oi(e){return"Character"===e.type}const Si=[];for(let e=vi("0");e<=vi("9");e++)Si.push(e);const _i=[vi("_")].concat(Si);for(let e=vi("a");e<=vi("z");e++)_i.push(e);for(let e=vi("A");e<=vi("Z");e++)_i.push(e);const Li=[vi(" "),vi("\f"),vi("\n"),vi("\r"),vi("\t"),vi("\v"),vi("\t"),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi(" "),vi("\u2028"),vi("\u2029"),vi(" "),vi(" "),vi(" "),vi("\ufeff")],xi=/[0-9a-fA-F]/,Ci=/[0-9]/,ki=/[1-9]/;class bi{visitChildren(e){for(const t in e){const n=e[t];e.hasOwnProperty(t)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}let Pi={};const wi=new class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");const t=this.disjunction();this.consumeChar("/");const n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":yi(n,"global");break;case"i":yi(n,"ignoreCase");break;case"m":yi(n,"multiLine");break;case"u":yi(n,"unicode");break;case"y":yi(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:t,loc:this.loc(0)}}disjunction(){const e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){const e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead"}Ri(t);const n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}return function(){throw Error("Internal Error - Should never get here!")}()}quantifier(e=!1){let t;const n=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":const n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;Ri(t)}if(!0!==e||void 0!==t)return Ri(t)?("?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t):void 0}atom(){let e;const t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}if(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),Ri(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[vi("\n"),vi("\r"),vi("\u2028"),vi("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=Si;break;case"D":e=Si,t=!0;break;case"s":e=Li;break;case"S":e=Li,t=!0;break;case"w":e=_i;break;case"W":e=_i,t=!0}if(Ri(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=vi("\f");break;case"n":e=vi("\n");break;case"r":e=vi("\r");break;case"t":e=vi("\t");break;case"v":e=vi("\v")}if(Ri(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:vi("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:vi(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:vi(this.popChar())}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const t=this.classAtom();if(t.type,Oi(t)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,Oi(n)){if(n.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:n.value})}else Ni(t.value,e),e.push(vi("-")),Ni(n.value,e)}else Ni(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:vi("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),e=!1;else this.groupIdx++;const t=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(!1===ki.test(e))throw Error("Expecting a positive integer");for(;Ci.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===Ci.test(e))throw Error("Expecting an integer");for(;Ci.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:vi(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return"-"===this.peekChar()&&this.isClassAtom(1)}isDigit(){return Ci.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2));default:return!1}}isQuantifier(){const e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let n=0;n<e;n++){const e=this.popChar();if(!1===xi.test(e))throw Error("Expecting a HexDecimal digits");t+=e}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};function Mi(e){const t=e.toString();if(Pi.hasOwnProperty(t))return Pi[t];{const e=wi.pattern(t);return Pi[t]=e,e}}const Ui="Complement Sets are not supported for first char optimization",Fi='Unable to use "first char" lexer optimizations:\n';function Di(e,t=!1){try{const t=Mi(e);return ji(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===Ui)t&&Zr(`${Fi}\tUnable to optimize: < ${e.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),qr(`${Fi}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function ji(e,t,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)ji(e.value[r],t,n);break;case"Alternative":const r=e.value;for(let e=0;e<r.length;e++){const i=r[e];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const o=i;switch(o.type){case"Character":Bi(o.value,t,n);break;case"Set":if(!0===o.complement)throw Error(Ui);hr(o.value,e=>{if("number"==typeof e)Bi(e,t,n);else{const r=e;if(!0===n)for(let e=r.from;e<=r.to;e++)Bi(e,t,n);else{for(let e=r.from;e<=r.to&&e<co;e++)Bi(e,t,n);if(r.to>=co){const e=r.from>=co?r.from:co,n=r.to,i=lo(e),o=lo(n);for(let e=i;e<=o;e++)t[e]=e}}}});break;case"Group":ji(o.value,t,n);break;default:throw Error("Non Exhaustive Match")}const s=void 0!==o.quantifier&&0===o.quantifier.atLeast;if("Group"===o.type&&!1===Wi(o)||"Group"!==o.type&&!1===s)break}break;default:throw Error("non exhaustive match!")}return br(t)}function Bi(e,t,n){const r=lo(e);t[r]=r,!0===n&&function(e,t){const n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){const e=lo(r.charCodeAt(0));t[e]=e}else{const e=n.toLowerCase();if(e!==n){const n=lo(e.charCodeAt(0));t[n]=n}}}(e,t)}function $i(e,t){return Ar(e.value,e=>{if("number"==typeof e)return wr(t,e);{const n=e;return void 0!==Ar(t,e=>n.from<=e&&e<=n.to)}})}function Wi(e){const t=e.quantifier;return!(!t||0!==t.atLeast)||!!e.value&&(L(e.value)?pr(e.value,Wi):Wi(e.value))}class Gi extends bi{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}super.visitChildren(e)}}visitCharacter(e){wr(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===$i(e,this.targetCharCodes)&&(this.found=!0):void 0!==$i(e,this.targetCharCodes)&&(this.found=!0)}}function Ki(e,t){if(t instanceof RegExp){const n=Mi(t),r=new Gi(e);return r.visit(n),r.found}return void 0!==Ar(t,t=>wr(e,t.charCodeAt(0)))}const zi="PATTERN",Vi="defaultMode",Hi="modes";let Yi="boolean"==typeof new RegExp("(?:)").sticky;function Xi(e,t){const n=(t=or(t,{useSticky:Yi,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",()=>{!function(){if(Fr(uo)){uo=new Array(65536);for(let e=0;e<65536;e++)uo[e]=e>255?255+~~(e/255):e}}()}),n("Reject Lexer.NA",()=>{r=zr(e,e=>e[zi]===Ro.NA)});let i,o,s,a,c,u,l,h,f,d,p,m=!1;n("Transform Patterns",()=>{m=!1,i=Nr(r,e=>{const n=e[zi];if(jr(n)){const e=n.source;return 1!==e.length||"^"===e||"$"===e||"."===e||n.ignoreCase?2!==e.length||"\\"!==e[0]||wr(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?t.useSticky?eo(n):Ji(n):e[1]:e}if(K(n))return m=!0,{exec:n};if("object"==typeof n)return m=!0,n;if("string"==typeof n){if(1===n.length)return n;{const e=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=new RegExp(e);return t.useSticky?eo(r):Ji(r)}}throw Error("non exhaustive match")})}),n("misc mapping",()=>{o=Nr(r,e=>e.tokenTypeIdx),s=Nr(r,e=>{const t=e.GROUP;if(t!==Ro.SKIPPED){if(kr(t))return t;if(Br(t))return!1;throw Error("non exhaustive match")}}),a=Nr(r,e=>{const t=e.LONGER_ALT;if(t){return L(t)?Nr(t,e=>Mr(r,e)):[Mr(r,t)]}}),c=Nr(r,e=>e.PUSH_MODE),u=Nr(r,e=>Cr(e,"POP_MODE"))}),n("Line Terminator Handling",()=>{const e=so(t.lineTerminatorCharacters);l=Nr(r,e=>!1),"onlyOffset"!==t.positionTracking&&(l=Nr(r,t=>Cr(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===oo(t,e)&&Ki(e,t.PATTERN)))}),n("Misc Mapping #2",()=>{h=Nr(r,no),f=Nr(i,ro),d=Kr(r,(e,t)=>{const n=t.GROUP;return kr(n)&&n!==Ro.SKIPPED&&(e[n]=[]),e},{}),p=Nr(i,(e,t)=>({pattern:i[t],longerAlt:a[t],canLineTerminator:l[t],isCustom:h[t],short:f[t],group:s[t],push:c[t],pop:u[t],tokenTypeIdx:o[t],tokenType:r[t]}))});let E=!0,g=[];return t.safeMode||n("First Char Optimization",()=>{g=Kr(r,(e,n,r)=>{if("string"==typeof n.PATTERN){const t=lo(n.PATTERN.charCodeAt(0));ao(e,t,p[r])}else if(L(n.START_CHARS_HINT)){let t;hr(n.START_CHARS_HINT,n=>{const i=lo("string"==typeof n?n.charCodeAt(0):n);t!==i&&(t=i,ao(e,i,p[r]))})}else if(jr(n.PATTERN))if(n.PATTERN.unicode)E=!1,t.ensureOptimizations&&qr(`${Fi}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const i=Di(n.PATTERN,t.ensureOptimizations);Fr(i)&&(E=!1),hr(i,t=>{ao(e,t,p[r])})}else t.ensureOptimizations&&qr(`${Fi}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return e},[])}),{emptyGroups:d,patternIdxToConfig:p,charCodeToPatternIdxToConfig:g,hasCustom:m,canBeOptimized:E}}function qi(e,t){let n=[];const r=function(e){const t=Er(e,e=>!Cr(e,zi)),n=Nr(t,e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:No.MISSING_PATTERN,tokenTypes:[e]})),r=ar(e,t);return{errors:n,valid:r}}(e);n=n.concat(r.errors);const i=function(e){const t=Er(e,e=>{const t=e[zi];return!(jr(t)||K(t)||Cr(t,"exec")||kr(t))}),n=Nr(t,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:No.INVALID_PATTERN,tokenTypes:[e]})),r=ar(e,t);return{errors:n,valid:r}}(r.valid),o=i.valid;return n=n.concat(i.errors),n=n.concat(function(e){let t=[];const n=Er(e,e=>jr(e[zi]));return t=t.concat(function(e){class t extends bi{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}const n=Er(e,e=>{const n=e.PATTERN;try{const e=Mi(n),r=new t;return r.visit(e),r.found}catch(e){return Zi.test(n.source)}}),r=Nr(n,e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:No.EOI_ANCHOR_FOUND,tokenTypes:[e]}));return r}(n)),t=t.concat(function(e){class t extends bi{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}const n=Er(e,e=>{const n=e.PATTERN;try{const e=Mi(n),r=new t;return r.visit(e),r.found}catch(e){return Qi.test(n.source)}}),r=Nr(n,e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:No.SOI_ANCHOR_FOUND,tokenTypes:[e]}));return r}(n)),t=t.concat(function(e){const t=Er(e,e=>{const t=e[zi];return t instanceof RegExp&&(t.multiline||t.global)}),n=Nr(t,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:No.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}));return n}(n)),t=t.concat(function(e){const t=[];let n=Nr(e,n=>Kr(e,(e,r)=>(n.PATTERN.source!==r.PATTERN.source||wr(t,r)||r.PATTERN===Ro.NA||(t.push(r),e.push(r)),e),[]));n=Ln(n);const r=Nr(Er(n,e=>e.length>1),e=>{const t=Nr(e,e=>e.name);return{message:`The same RegExp pattern ->${Ir(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:No.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}});return r}(n)),t=t.concat(function(e){const t=Er(e,e=>e.PATTERN.test("")),n=Nr(t,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:No.EMPTY_MATCH_PATTERN,tokenTypes:[e]}));return n}(n)),t}(o)),n=n.concat(function(e){const t=Er(e,e=>{if(!Cr(e,"GROUP"))return!1;const t=e.GROUP;return t!==Ro.SKIPPED&&t!==Ro.NA&&!kr(t)}),n=Nr(t,e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:No.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}));return n}(o)),n=n.concat(function(e,t){const n=Er(e,e=>void 0!==e.PUSH_MODE&&!wr(t,e.PUSH_MODE)),r=Nr(n,e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:No.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}));return r}(o,t)),n=n.concat(function(e){const t=[],n=Kr(e,(e,t,n)=>{const r=t.PATTERN;return r===Ro.NA||(kr(r)?e.push({str:r,idx:n,tokenType:t}):jr(r)&&(i=r,void 0===Ar([".","\\","[","]","|","^","$","(",")","?","*","+","{"],e=>-1!==i.source.indexOf(e)))&&e.push({str:r.source,idx:n,tokenType:t})),e;var i},[]);return hr(e,(e,r)=>{hr(n,({str:n,idx:i,tokenType:o})=>{if(r<i&&function(e,t){if(jr(t)){const n=t.exec(e);return null!==n&&0===n.index}if(K(t))return t(e,0,[],{});if(Cr(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(n,e.PATTERN)){const n=`Token: ->${o.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:No.UNREACHABLE_PATTERN,tokenTypes:[e,o]})}})}),t}(o)),n}const Zi=/[^\\][$]/;const Qi=/[^\\[][\^]|^\^/;function Ji(e){const t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function eo(e){const t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function to(e,t,n){const r=[];let i=!1;const o=zr(Ln(wt(br(e.modes))),e=>e[zi]===Ro.NA),s=so(n);return t&&hr(o,e=>{const t=oo(e,s);if(!1!==t){const n=function(e,t){if(t.issue===No.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===No.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${e.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),i={message:n,type:t.issue,tokenType:e};r.push(i)}else Cr(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(i=!0):Ki(s,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:No.NO_LINE_BREAKS_FLAGS}),r}function no(e){const t=e.PATTERN;if(jr(t))return!1;if(K(t))return!0;if(Cr(t,"exec"))return!0;if(kr(t))return!1;throw Error("non exhaustive match")}function ro(e){return!(!kr(e)||1!==e.length)&&e.charCodeAt(0)}const io={test:function(e){const t=e.length;for(let n=this.lastIndex;n<t;n++){const t=e.charCodeAt(n);if(10===t)return this.lastIndex=n+1,!0;if(13===t)return 10===e.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function oo(e,t){if(Cr(e,"LINE_BREAKS"))return!1;if(jr(e.PATTERN)){try{Ki(t,e.PATTERN)}catch(e){return{issue:No.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(kr(e.PATTERN))return!1;if(no(e))return{issue:No.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function so(e){return Nr(e,e=>kr(e)?e.charCodeAt(0):e)}function ao(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}const co=256;let uo=[];function lo(e){return e<co?e:uo[e]}function ho(e,t){const n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]}function fo(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let po=1;const mo={};function Eo(e){const t=function(e){let t=_n(e),n=e,r=!0;for(;r;){n=Ln(wt(Nr(n,e=>e.CATEGORIES)));const e=ar(n,t);t=t.concat(e),Fr(e)?r=!1:n=e}return t}(e);!function(e){hr(e,e=>{To(e)||(mo[po]=e,e.tokenTypeIdx=po++),Ao(e)&&!L(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Ao(e)||(e.CATEGORIES=[]),Cr(e,"categoryMatches")||(e.categoryMatches=[]),function(e){return Cr(e,"categoryMatchesMap")}(e)||(e.categoryMatchesMap={})})}(t),function(e){hr(e,e=>{go([],e)})}(t),function(e){hr(e,e=>{e.categoryMatches=[],hr(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(mo[n].tokenTypeIdx)})})}(t),hr(t,e=>{e.isParent=e.categoryMatches.length>0})}function go(e,t){hr(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),hr(t.CATEGORIES,n=>{const r=e.concat(t);wr(r,n)||go(r,n)})}function To(e){return Cr(e,"tokenTypeIdx")}function Ao(e){return Cr(e,"CATEGORIES")}function Io(e){return Cr(e,"tokenTypeIdx")}const vo={buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,n,r,i)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`};var No;!function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"}(No||(No={}));const yo={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:vo,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(yo);class Ro{constructor(e,t=yo){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=Qr(t),o=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=st({},yo,t);const n=this.config.traceInitPerf;!0===n?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof n&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,r=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===yo.lineTerminatorsPattern)this.config.lineTerminatorsPattern=io;else if(this.config.lineTerminatorCharacters===yo.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),L(e)?n={modes:{defaultMode:_n(e)},defaultMode:Vi}:(r=!1,n=_n(e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e){const t=[];return Cr(e,Vi)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+Vi+"> property in its definition\n",type:No.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Cr(e,Hi)||t.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:No.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Cr(e,Hi)&&Cr(e,Vi)&&!Cr(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${Vi}: <${e.defaultMode}>which does not exist\n`,type:No.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Cr(e,Hi)&&hr(e.modes,(e,n)=>{hr(e,(r,i)=>{Br(r)?t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,type:No.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Cr(r,"LONGER_ALT")&&hr(L(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT],i=>{Br(i)||wr(e,i)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${r.name}> outside of mode <${n}>\n`,type:No.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),t}(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(to(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},hr(n.modes,(e,t)=>{n.modes[t]=zr(e,e=>Br(e))});const i=rt(n.modes);if(hr(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(qi(e,i))}),Fr(this.lexerDefinitionErrors)){let r;Eo(e),this.TRACE_INIT("analyzeTokenTypes",()=>{r=Xi(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=st({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!Fr(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const e=Nr(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+e)}hr(this.lexerDefinitionWarning,e=>{Zr(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Yi?(this.chopInput=G,this.match=this.matchWithTest):(this.updateLastIndex=ae,this.match=this.matchWithExec),r&&(this.handleModes=ae),!1===this.trackStartLines&&(this.computeNewColumn=G),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=ae),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else{if(!/onlyOffset/i.test(this.config.positionTracking))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const e=Kr(this.canModeBeOptimized,(e,t,n)=>(!1===t&&e.push(n),e),[]);if(t.ensureOptimizations&&!Fr(e))throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Pi={}}),this.TRACE_INIT("toFastProperties",()=>{Jr(this)})})}tokenize(e,t=this.defaultMode){if(!Fr(this.lexerDefinitionErrors)){const e=Nr(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,o,s,a,c,u,l,h,f,d,p,m,E;const g=e,T=g.length;let A=0,I=0;const v=this.hasCustom?0:Math.floor(e.length/10),N=new Array(v),y=[];let R=this.trackStartLines?1:void 0,O=this.trackStartLines?1:void 0;const S=function(e){const t={};return hr(rt(e),n=>{const r=e[n];if(!L(r))throw Error("non exhaustive match");t[n]=[]}),t}(this.emptyGroups),_=this.trackStartLines,x=this.config.lineTerminatorsPattern;let C=0,k=[],b=[];const P=[],w=[];let M;function U(){return k}function F(e){const t=lo(e),n=b[t];return void 0===n?w:n}Object.freeze(w);const D=e=>{if(1===P.length&&void 0===e.tokenType.PUSH_MODE){const t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);y.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{P.pop();const e=cr(P);k=this.patternIdxToConfig[e],b=this.charCodeToPatternIdxToConfig[e],C=k.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=b&&t?F:U}};function j(e){P.push(e),b=this.charCodeToPatternIdxToConfig[e],k=this.patternIdxToConfig[e],C=k.length,C=k.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=b&&t?F:U}let B;j.call(this,t);const $=this.config.recoveryEnabled;for(;A<T;){a=null;const t=g.charCodeAt(A),v=M(t),L=v.length;for(n=0;n<L;n++){B=v[n];const r=B.pattern;c=null;const l=B.short;if(!1!==l?t===l&&(a=r):!0===B.isCustom?(E=r.exec(g,A,N,S),null!==E?(a=E[0],void 0!==E.payload&&(c=E.payload)):a=null):(this.updateLastIndex(r,A),a=this.match(r,e,A)),null!==a){if(s=B.longerAlt,void 0!==s){const t=s.length;for(i=0;i<t;i++){const t=k[s[i]],n=t.pattern;if(u=null,!0===t.isCustom?(E=n.exec(g,A,N,S),null!==E?(o=E[0],void 0!==E.payload&&(u=E.payload)):o=null):(this.updateLastIndex(n,A),o=this.match(n,e,A)),o&&o.length>a.length){a=o,c=u,B=t;break}}}break}}if(null!==a){if(l=a.length,h=B.group,void 0!==h&&(f=B.tokenTypeIdx,d=this.createTokenInstance(a,A,f,B.tokenType,R,O,l),this.handlePayload(d,c),!1===h?I=this.addToken(N,I,d):S[h].push(d)),e=this.chopInput(e,l),A+=l,O=this.computeNewColumn(O,l),!0===_&&!0===B.canLineTerminator){let e,t,n=0;x.lastIndex=0;do{e=x.test(a),!0===e&&(t=x.lastIndex-1,n++)}while(!0===e);0!==n&&(R+=n,O=l-t,this.updateTokenEndLineColumnLocation(d,h,t,n,R,O,l))}this.handleModes(B,D,j,d)}else{const t=A,n=R,i=O;let o=!1===$;for(;!1===o&&A<T;)for(e=this.chopInput(e,1),A++,r=0;r<C;r++){const t=k[r],n=t.pattern,i=t.short;if(!1!==i?g.charCodeAt(A)===i&&(o=!0):!0===t.isCustom?o=null!==n.exec(g,A,N,S):(this.updateLastIndex(n,A),o=null!==n.exec(e)),!0===o)break}if(p=A-t,O=this.computeNewColumn(O,p),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(g,t,p,n,i),y.push({offset:t,line:n,column:i,length:p,message:m}),!1===$)break}}return this.hasCustom||(N.length=I),{tokens:N,groups:S,errors:y}}handleModes(e,t,n,r){if(!0===e.pop){const i=e.push;t(r),void 0!==i&&n.call(this,i)}else void 0!==e.push&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,o,s){let a,c;void 0!==t&&(a=n===s-1,c=a?-1:0,1===r&&!0===a||(e.endLine=i+c,e.endColumn=o-1-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,o){return{image:e,startOffset:t,startLine:i,startColumn:o,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,o,s){return{image:e,startOffset:t,endOffset:t+s-1,startLine:i,endLine:i,startColumn:o,endColumn:o+s-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}matchWithTest(e,t,n){return!0===e.test(t)?t.substring(n,e.lastIndex):null}matchWithExec(e,t){const n=e.exec(t);return null!==n?n[0]:null}}function Oo(e){return So(e)?e.LABEL:e.name}function So(e){return kr(e.LABEL)&&""!==e.LABEL}Ro.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",Ro.NA=/NOT_APPLICABLE/;const _o="parent",Lo="categories",xo="label",Co="group",ko="push_mode",bo="pop_mode",Po="longer_alt",wo="line_breaks",Mo="start_chars_hint";function Uo(e){return function(e){const t=e.pattern,n={};n.name=e.name,Br(t)||(n.PATTERN=t);if(Cr(e,_o))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";Cr(e,Lo)&&(n.CATEGORIES=e[Lo]);Eo([n]),Cr(e,xo)&&(n.LABEL=e[xo]);Cr(e,Co)&&(n.GROUP=e[Co]);Cr(e,bo)&&(n.POP_MODE=e[bo]);Cr(e,ko)&&(n.PUSH_MODE=e[ko]);Cr(e,Po)&&(n.LONGER_ALT=e[Po]);Cr(e,wo)&&(n.LINE_BREAKS=e[wo]);Cr(e,Mo)&&(n.START_CHARS_HINT=e[Mo]);return n}(e)}const Fo=Uo({name:"EOF",pattern:Ro.NA});function Do(e,t,n,r,i,o,s,a){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:o,startColumn:s,endColumn:a,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}Eo([Fo]);const jo={buildMismatchTokenMessage:({expected:e,actual:t,previous:n,ruleName:r})=>`Expecting ${So(e)?`--\x3e ${Oo(e)} <--`:`token of type --\x3e ${e.name} <--`} but found --\x3e '${t.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){const o="Expecting: ",s="\nbut found: '"+Ir(t).image+"'";if(r)return o+r+s;{const t=Nr(Kr(e,(e,t)=>e.concat(t),[]),e=>`[${Nr(e,e=>Oo(e)).join(", ")}]`);return o+`one of these possible Token sequences:\n${Nr(t,(e,t)=>` ${t+1}. ${e}`).join("\n")}`+s}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){const i="Expecting: ",o="\nbut found: '"+Ir(t).image+"'";if(n)return i+n+o;return i+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${Nr(e,e=>`[${Nr(e,e=>Oo(e)).join(",")}]`).join(" ,")}>`+o}};Object.freeze(jo);const Bo={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},$o={buildDuplicateFoundError(e,t){const n=e.name,r=Ir(t),i=r.idx,o=mi(r),s=(a=r)instanceof hi?a.terminalType.name:a instanceof ni?a.nonTerminalName:"";var a;let c=`->${o}${i>0?i:""}<- ${s?`with argument: ->${s}<-`:""}\n appears more than once (${t.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){const t=Nr(e.prefixPath,e=>Oo(e)).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){const t=Nr(e.prefixPath,e=>Oo(e)).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;let r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r},buildEmptyRepetitionError(e){let t=mi(e.repetition);0!==e.repetition.idx&&(t+=e.repetition.idx);return`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){const t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --\x3e ${Nr(e.leftRecursionPath,e=>e.name).concat([t]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;t=e.topLevelRule instanceof ri?e.topLevelRule.name:e.topLevelRule;return`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class Wo extends di{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){hr(br(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:ua.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Go extends Ei{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=_n(this.path.ruleStack).reverse(),this.occurrenceStack=_n(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){Fr(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Ko extends Go{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const e=t.concat(n),r=new ii({definition:e});this.possibleTokTypes=Ti(r),this.found=!0}}}class zo extends Ei{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Vo extends zo{walkMany(e,t,n){if(e.idx===this.occurrence){const e=Ir(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof hi&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}}class Ho extends zo{walkManySep(e,t,n){if(e.idx===this.occurrence){const e=Ir(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof hi&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}}class Yo extends zo{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){const e=Ir(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof hi&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}}class Xo extends zo{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){const e=Ir(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof hi&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}}function qo(e,t,n=[]){n=_n(n);let r=[],i=0;function o(o){const s=qo(o.concat(ur(e,i+1)),t,n);return r.concat(s)}for(;n.length<t&&i<e.length;){const t=e[i];if(t instanceof ii)return o(t.definition);if(t instanceof ni)return o(t.definition);if(t instanceof oi)r=o(t.definition);else{if(t instanceof si){return o(t.definition.concat([new ci({definition:t.definition})]))}if(t instanceof ai){return o([new ii({definition:t.definition}),new ci({definition:[new hi({terminalType:t.separator})].concat(t.definition)})])}if(t instanceof ui){const e=t.definition.concat([new ci({definition:[new hi({terminalType:t.separator})].concat(t.definition)})]);r=o(e)}else if(t instanceof ci){const e=t.definition.concat([new ci({definition:t.definition})]);r=o(e)}else{if(t instanceof li)return hr(t.definition,e=>{!1===Fr(e.definition)&&(r=o(e.definition))}),r;if(!(t instanceof hi))throw Error("non exhaustive match");n.push(t.terminalType)}}i++}return r.push({partialPath:n,suffixDef:ur(e,i)}),r}function Zo(e,t,n,r){const i="EXIT_NONE_TERMINAL",o=[i],s="EXIT_ALTERNATIVE";let a=!1;const c=t.length,u=c-r-1,l=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!Fr(h);){const e=h.pop();if(e===s){a&&cr(h).idx<=u&&h.pop();continue}const r=e.def,f=e.idx,d=e.ruleStack,p=e.occurrenceStack;if(Fr(r))continue;const m=r[0];if(m===i){const e={idx:f,def:ur(r),ruleStack:lr(d),occurrenceStack:lr(p)};h.push(e)}else if(m instanceof hi)if(f<c-1){const e=f+1;if(n(t[e],m.terminalType)){const t={idx:e,def:ur(r),ruleStack:d,occurrenceStack:p};h.push(t)}}else{if(f!==c-1)throw Error("non exhaustive match");l.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:d,occurrenceStack:p}),a=!0}else if(m instanceof ni){const e=_n(d);e.push(m.nonTerminalName);const t=_n(p);t.push(m.idx);const n={idx:f,def:m.definition.concat(o,ur(r)),ruleStack:e,occurrenceStack:t};h.push(n)}else if(m instanceof oi){const e={idx:f,def:ur(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t={idx:f,def:m.definition.concat(ur(r)),ruleStack:d,occurrenceStack:p};h.push(t)}else if(m instanceof si){const e=new ci({definition:m.definition,idx:m.idx}),t={idx:f,def:m.definition.concat([e],ur(r)),ruleStack:d,occurrenceStack:p};h.push(t)}else if(m instanceof ai){const e=new hi({terminalType:m.separator}),t=new ci({definition:[e].concat(m.definition),idx:m.idx}),n={idx:f,def:m.definition.concat([t],ur(r)),ruleStack:d,occurrenceStack:p};h.push(n)}else if(m instanceof ui){const e={idx:f,def:ur(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t=new hi({terminalType:m.separator}),n=new ci({definition:[t].concat(m.definition),idx:m.idx}),i={idx:f,def:m.definition.concat([n],ur(r)),ruleStack:d,occurrenceStack:p};h.push(i)}else if(m instanceof ci){const e={idx:f,def:ur(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t=new ci({definition:m.definition,idx:m.idx}),n={idx:f,def:m.definition.concat([t],ur(r)),ruleStack:d,occurrenceStack:p};h.push(n)}else if(m instanceof li)for(let e=m.definition.length-1;e>=0;e--){const t={idx:f,def:m.definition[e].definition.concat(ur(r)),ruleStack:d,occurrenceStack:p};h.push(t),h.push(s)}else if(m instanceof ii)h.push({idx:f,def:m.definition.concat(ur(r)),ruleStack:d,occurrenceStack:p});else{if(!(m instanceof ri))throw Error("non exhaustive match");h.push(Qo(m,f,d,p))}}return l}function Qo(e,t,n,r){const i=_n(n);i.push(e.name);const o=_n(r);return o.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:o}}var Jo;function es(e){if(e instanceof oi||"Option"===e)return Jo.OPTION;if(e instanceof ci||"Repetition"===e)return Jo.REPETITION;if(e instanceof si||"RepetitionMandatory"===e)return Jo.REPETITION_MANDATORY;if(e instanceof ai||"RepetitionMandatoryWithSeparator"===e)return Jo.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof ui||"RepetitionWithSeparator"===e)return Jo.REPETITION_WITH_SEPARATOR;if(e instanceof li||"Alternation"===e)return Jo.ALTERNATION;throw Error("non exhaustive match")}function ts(e,t,n,r){const i=e.length,o=pr(e,e=>pr(e,e=>1===e.length));if(t)return function(t){const r=Nr(t,e=>e.GATE);for(let t=0;t<i;t++){const i=e[t],o=i.length,s=r[t];if(void 0===s||!1!==s.call(this))e:for(let e=0;e<o;e++){const r=i[e],o=r.length;for(let e=0;e<o;e++){const t=this.LA(e+1);if(!1===n(t,r[e]))continue e}return t}}};if(o&&!r){const t=Kr(Nr(e,e=>wt(e)),(e,t,n)=>(hr(t,t=>{Cr(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),hr(t.categoryMatches,t=>{Cr(e,t)||(e[t]=n)})}),e),{});return function(){const e=this.LA(1);return t[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){const r=e[t],i=r.length;e:for(let e=0;e<i;e++){const i=r[e],o=i.length;for(let e=0;e<o;e++){const t=this.LA(e+1);if(!1===n(t,i[e]))continue e}return t}}}}function ns(e,t,n){const r=pr(e,e=>1===e.length),i=e.length;if(r&&!n){const t=wt(e);if(1===t.length&&Fr(t[0].categoryMatches)){const e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{const e=Kr(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,hr(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){const t=this.LA(1);return!0===e[t.tokenTypeIdx]}}}return function(){e:for(let n=0;n<i;n++){const r=e[n],i=r.length;for(let e=0;e<i;e++){const n=this.LA(e+1);if(!1===t(n,r[e]))continue e}return!0}return!1}}!function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"}(Jo||(Jo={}));class rs extends Ei{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)}walkOption(e,t,n){this.checkIsTarget(e,Jo.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Jo.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Jo.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Jo.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Jo.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}}class is extends di{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx!==this.targetOccurrence||this.targetProdType!==t||void 0!==this.targetRef&&e!==this.targetRef||(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Jo.OPTION)}visitRepetition(e){this.checkIsTarget(e,Jo.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Jo.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Jo.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Jo.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Jo.ALTERNATION)}}function os(e){const t=new Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function ss(e){let t=[""];for(let n=0;n<e.length;n++){const r=e[n],i=[];for(let e=0;e<t.length;e++){const n=t[e];i.push(n+"_"+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){const t="_"+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function as(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;const i=e[r];for(let e=0;e<t.length;e++){if(!0===i[t[e]])return!1}}return!0}function cs(e,t){const n=Nr(e,e=>qo([e],1)),r=os(n.length),i=Nr(n,e=>{const t={};return hr(e,e=>{hr(ss(e.partialPath),e=>{t[e]=!0})}),t});let o=n;for(let e=1;e<=t;e++){const n=o;o=os(n.length);for(let s=0;s<n.length;s++){const a=n[s];for(let n=0;n<a.length;n++){const c=a[n].partialPath,u=a[n].suffixDef,l=ss(c);if(as(i,l,s)||Fr(u)||c.length===t){const e=r[s];if(!1===hs(e,c)){e.push(c);for(let e=0;e<l.length;e++){const t=l[e];i[s][t]=!0}}}else{const t=qo(u,e+1,c);o[s]=o[s].concat(t),hr(t,e=>{hr(ss(e.partialPath),e=>{i[s][e]=!0})})}}}}return r}function us(e,t,n,r){const i=new is(e,Jo.ALTERNATION,r);return t.accept(i),cs(i.result,n)}function ls(e,t,n,r){const i=new is(e,n);t.accept(i);const o=i.result,s=new rs(t,e,n).startWalking();return cs([new ii({definition:o}),new ii({definition:s})],r)}function hs(e,t){e:for(let n=0;n<e.length;n++){const r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){const n=t[e],i=r[e];if(!1===(n===i||void 0!==i.categoryMatchesMap[n.tokenTypeIdx]))continue e}return!0}}return!1}function fs(e){return pr(e,e=>pr(e,e=>pr(e,e=>Fr(e.categoryMatches))))}function ds(e,t,n,r){const i=yr(e,e=>function(e,t){const n=new Es;e.accept(n);const r=n.allProductions,i=_r(r,ps),o=Nr(br(Wr(i,e=>e.length>1)),n=>{const r=Ir(n),i=t.buildDuplicateFoundError(e,n),o=mi(r),s={message:i,type:ua.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:o,occurrence:r.idx},a=ms(r);return a&&(s.parameter=a),s});return o}(e,n)),o=function(e,t,n){const r=[],i=Nr(t,e=>e.name);return hr(e,e=>{const t=e.name;if(wr(i,t)){const i=n.buildNamespaceConflictError(e);r.push({message:i,type:ua.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}(e,t,n),s=yr(e,e=>function(e,t){const n=new As;e.accept(n);const r=yr(n.alternations,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:ua.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[]);return r}(e,n)),a=yr(e,t=>function(e,t,n,r){const i=[],o=Kr(t,(t,n)=>n.name===e.name?t+1:t,0);if(o>1){const t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:ua.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}(t,e,r,n));return i.concat(o,s,a)}function ps(e){return`${mi(e)}_#_${e.idx}_#_${ms(e)}`}function ms(e){return e instanceof hi?e.terminalType.name:e instanceof ni?e.nonTerminalName:""}class Es extends di{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}function gs(e,t,n,r=[]){const i=[],o=Ts(t.definition);if(Fr(o))return[];{const t=e.name;wr(o,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:ua.LEFT_RECURSION,ruleName:t});const s=yr(ar(o,r.concat([e])),t=>{const i=_n(r);return i.push(t),gs(e,t,n,i)});return i.concat(s)}}function Ts(e){let t=[];if(Fr(e))return t;const n=Ir(e);if(n instanceof ni)t.push(n.referencedRule);else if(n instanceof ii||n instanceof oi||n instanceof si||n instanceof ai||n instanceof ui||n instanceof ci)t=t.concat(Ts(n.definition));else if(n instanceof li)t=wt(Nr(n.definition,e=>Ts(e.definition)));else if(!(n instanceof hi))throw Error("non exhaustive match");const r=pi(n),i=e.length>1;if(r&&i){const n=ur(e);return t.concat(Ts(n))}return t}class As extends di{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Is(e,t,n){const r=new As;e.accept(r);let i=r.alternations;i=zr(i,e=>!0===e.ignoreAmbiguities);const o=yr(i,r=>{const i=r.idx,o=r.maxLookahead||t,s=us(i,e,o,r),a=function(e,t,n,r){const i=[],o=Kr(e,(n,r,o)=>(!0===t.definition[o].ignoreAmbiguities||hr(r,r=>{const s=[o];hr(e,(e,n)=>{o!==n&&hs(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&s.push(n)}),s.length>1&&!hs(i,r)&&(i.push(r),n.push({alts:s,path:r}))}),n),[]),s=Nr(o,e=>{const i=Nr(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ua.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}});return s}(s,r,e,n),c=function(e,t,n,r){const i=Kr(e,(e,t,n)=>{const r=Nr(t,e=>({idx:n,path:e}));return e.concat(r)},[]),o=Ln(yr(i,e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];const o=e.idx,s=e.path;return Nr(Er(i,e=>{return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<o&&(n=e.path,r=s,n.length<r.length&&pr(n,(e,t)=>{const n=r[t];return e===n||n.categoryMatchesMap[e.tokenTypeIdx]}));var n,r}),e=>{const i=[e.idx+1,o+1],s=0===t.idx?"":t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ua.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:s,alternatives:i}})}));return o}(s,r,e,n);return a.concat(c)});return o}class vs extends di{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}function Ns(e){const t=or(e,{errMsgProvider:Bo}),n={};return hr(e.rules,e=>{n[e.name]=e}),function(e,t){const n=new Wo(e,t);return n.resolveRefs(),n.errors}(n,t.errMsgProvider)}const ys="MismatchedTokenException",Rs="NoViableAltException",Os="EarlyExitException",Ss="NotAllInputParsedException",_s=[ys,Rs,Os,Ss];function Ls(e){return wr(_s,e.name)}Object.freeze(_s);class xs extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class Cs extends xs{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=ys}}class ks extends xs{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Rs}}class bs extends xs{constructor(e,t){super(e,t),this.name=Ss}}class Ps extends xs{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Os}}const ws={},Ms="InRuleRecoveryException";class Us extends Error{constructor(e){super(e),this.name=Ms}}function Fs(e,t,n,r,i,o,s){const a=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[a];if(void 0===c){const e=this.getCurrRuleFullName();c=new o(this.getGAstProductions()[e],i).startWalking(),this.firstAfterRepMap[a]=c}let u=c.token,l=c.occurrence;const h=c.isEndOfRule;1===this.RULE_STACK.length&&h&&void 0===u&&(u=Fo,l=1),void 0!==u&&void 0!==l&&this.shouldInRepetitionRecoveryBeTried(u,l,s)&&this.tryInRepetitionRecovery(e,t,n,u)}const Ds=1024,js=1280,Bs=1536;function $s(e,t,n){return n|t|e}class Ws{constructor(e){var t;this.maxLookahead=null!==(t=null==e?void 0:e.maxLookahead)&&void 0!==t?t:aa.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(Fr(t)){const n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return yr(e,e=>gs(e,e,$o))}validateEmptyOrAlternatives(e){return yr(e,e=>function(e,t){const n=new As;return e.accept(n),yr(n.alternations,n=>yr(lr(n.definition),(r,i)=>Fr(Zo([r],[],ho,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:ua.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}(e,$o))}validateAmbiguousAlternationAlternatives(e,t){return yr(e,e=>Is(e,t,$o))}validateSomeNonEmptyLookaheadPath(e,t){return function(e,t,n){const r=[];return hr(e,e=>{const i=new vs;e.accept(i),hr(i.allProductions,i=>{const o=es(i),s=i.maxLookahead||t;if(Fr(wt(ls(i.idx,e,o,s)[0]))){const t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:ua.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}(e,t,$o)}buildLookaheadForAlternation(e){return function(e,t,n,r,i,o){const s=us(e,t,n);return o(s,r,fs(s)?fo:ho,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,ts)}buildLookaheadForOptional(e){return function(e,t,n,r,i,o){const s=ls(e,t,i,n),a=fs(s)?fo:ho;return o(s[0],a,r)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,es(e.prodType),ns)}}const Gs=new class extends di{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};function Ks(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function zs(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Vs(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function Hs(e,t){const n=rt(e),r=n.length;for(let i=0;i<r;i++){const r=e[n[i]],o=r.length;for(let e=0;e<o;e++){const n=r[e];void 0===n.tokenTypeIdx&&this[n.name](n.children,t)}}}function Ys(e,t){const n=function(){};Vs(n,e+"BaseSemantics");const r={visit:function(e,t){if(L(e)&&(e=e[0]),!Br(e))return this[e.name](e.children,t)},validateVisitor:function(){const e=function(e,t){const n=function(e,t){const n=Er(t,t=>!1===K(e[t])),r=Nr(n,t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Xs.MISSING_METHOD,methodName:t}));return Ln(r)}(e,t);return n}(this,t);if(!Fr(e)){const t=Nr(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(n.prototype=r).constructor=n,n._RULE_NAMES=t,n}var Xs;!function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"}(Xs||(Xs={}));const qs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(qs);const Zs=!0,Qs=Math.pow(2,8)-1,Js=Uo({name:"RECORDING_PHASE_TOKEN",pattern:Ro.NA});Eo([Js]);const ea=Do(Js,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(ea);const ta={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function na(e,t,n,r=!1){oa(n);const i=cr(this.recordingProdStack),o=K(t)?t:t.DEF,s=new e({definition:[],idx:n});return r&&(s.separator=t.SEP),Cr(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),o.call(this),i.definition.push(s),this.recordingProdStack.pop(),qs}function ra(e,t){oa(t);const n=cr(this.recordingProdStack),r=!1===L(e),i=!1===r?e:e.DEF,o=new li({definition:[],idx:t,ignoreAmbiguities:r&&!0===e.IGNORE_AMBIGUITIES});Cr(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD);const s=Hr(i,e=>K(e.GATE));return o.hasPredicates=s,n.definition.push(o),hr(i,e=>{const t=new ii({definition:[]});o.definition.push(t),Cr(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:Cr(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),qs}function ia(e){return 0===e?"":`${e}`}function oa(e){if(e<0||e>Qs){const t=new Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${Qs+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}const sa=Do(Fo,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(sa);const aa=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:jo,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ca=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ua,la,ha;!function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"}(ua||(ua={}));class fa{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const t=this.className;this.TRACE_INIT("toFastProps",()=>{Jr(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),hr(this.definedRulesNames,e=>{const t=this[e].originalGrammarAction;let n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Ns({rules:br(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(Fr(n)&&!1===this.skipValidations){const n=(e={rules:br(this.gastProductionsCache),tokenTypes:br(this.tokensMap),errMsgProvider:$o,grammarName:t},ds((e=or(e,{errMsgProvider:$o})).rules,e.tokenTypes,e.errMsgProvider,e.grammarName)),r=function(e){return Nr(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:ua.CUSTOM_LOOKAHEAD_VALIDATION},e))}({lookaheadStrategy:this.lookaheadStrategy,rules:br(this.gastProductionsCache),tokenTypes:br(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(n,r)}var e}),Fr(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const e=function(e){const t={};return hr(e,e=>{const n=new Ii(e).startWalking();st(t,n)}),t}(br(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var e,t;null===(t=(e=this.lookaheadStrategy).initialize)||void 0===t||t.call(e,{rules:br(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(br(this.gastProductionsCache))})),!fa.DEFER_DEFINITION_ERRORS_HANDLING&&!Fr(this.definitionErrors))throw e=Nr(this.definitionErrors,e=>e.message),new Error(`Parser Definition Errors detected:\n ${e.join("\n-------------------------------\n")}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),Cr(t,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=Cr(t,"skipValidations")?t.skipValidations:aa.skipValidations}}fa.DEFER_DEFINITION_ERRORS_HANDLING=!1,la=fa,ha=[class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=Cr(e,"recoveryEnabled")?e.recoveryEnabled:aa.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Fs)}getTokenToInsert(e){const t=Do(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){const i=this.findReSyncTokenType(),o=this.exportLexerState(),s=[];let a=!1;const c=this.LA(1);let u=this.LA(1);const l=()=>{const e=this.LA(0),t=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),n=new Cs(t,c,this.LA(0));n.resyncedTokens=lr(s),this.SAVE_ERROR(n)};for(;!a;){if(this.tokenMatcher(u,r))return void l();if(n.call(this))return l(),void e.apply(this,t);this.tokenMatcher(u,i)?a=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,s))}this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,t,n){return!1!==n&&!this.tokenMatcher(this.LA(1),e)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t))}getFollowsForInRuleRecovery(e,t){const n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new Us("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(Fr(t))return!1;const n=this.LA(1);return void 0!==Ar(t,e=>this.tokenMatcher(n,e))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey();return wr(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA(1),n=2;for(;;){const r=Ar(e,e=>ho(t,e));if(void 0!==r)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return ws;const e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return Nr(e,(n,r)=>0===r?ws:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return wt(Nr(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===ws)return[Fo];const t=e.ruleName+e.idxInCallingRule+Ai+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Fo)||t.push(e),t}reSyncTo(e){const t=[];let n=this.LA(1);for(;!1===this.tokenMatcher(n,e);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return lr(t)}attemptInRepetitionRecovery(e,t,n,r,i,o,s){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:_n(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return Nr(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}},class{initLooksAhead(e){this.dynamicTokensEnabled=Cr(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:aa.dynamicTokensEnabled,this.maxLookahead=Cr(e,"maxLookahead")?e.maxLookahead:aa.maxLookahead,this.lookaheadStrategy=Cr(e,"lookaheadStrategy")?e.lookaheadStrategy:new Ws({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){hr(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{const{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:s}=function(e){Gs.reset(),e.accept(Gs);const t=Gs.dslMethods;return Gs.reset(),t}(e);hr(t,t=>{const n=0===t.idx?"":t.idx;this.TRACE_INIT(`${mi(t)}${n}`,()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=$s(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),hr(n,t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,mi(t))}),hr(r,t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,mi(t))}),hr(i,t=>{this.computeLookaheadFunc(e,t.idx,Ds,"RepetitionMandatory",t.maxLookahead,mi(t))}),hr(o,t=>{this.computeLookaheadFunc(e,t.idx,Bs,"RepetitionMandatoryWithSeparator",t.maxLookahead,mi(t))}),hr(s,t=>{this.computeLookaheadFunc(e,t.idx,js,"RepetitionWithSeparator",t.maxLookahead,mi(t))})})})}computeLookaheadFunc(e,t,n,r,i,o){this.TRACE_INIT(`${o}${0===t?"":t}`,()=>{const o=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),s=$s(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(s,o)})}getKeyForAutomaticLookahead(e,t){return $s(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Cr(e,"nodeLocationTracking")?e.nodeLocationTracking:aa.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=zs,this.setNodeLocationFromNode=zs,this.cstPostRule=ae,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ae,this.setNodeLocationFromNode=ae,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ks,this.setNodeLocationFromNode=Ks,this.cstPostRule=ae,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ae,this.setNodeLocationFromNode=ae,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);this.setNodeLocationFromToken=ae,this.setNodeLocationFromNode=ae,this.cstPostRule=ae,this.setInitialNodeLocation=ae}else this.cstInvocationStateUpdate=ae,this.cstFinallyStateUpdate=ae,this.cstPostTerminal=ae,this.cstPostNonTerminal=ae,this.cstPostRule=ae}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){const t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){const t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){const t=this.LA(0),n=e.location;n.startOffset<=t.startOffset==1?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){const t=this.LA(0),n=e.location;n.startOffset<=t.startOffset==1?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];var r,i,o;i=t,o=e,void 0===(r=n).children[o]?r.children[o]=[i]:r.children[o].push(i),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];!function(e,t,n){void 0===e.children[t]?e.children[t]=[n]:e.children[t].push(n)}(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(Br(this.baseCstVisitorConstructor)){const e=Ys(this.className,rt(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Br(this.baseCstVisitorWithDefaultsConstructor)){const e=function(e,t,n){const r=function(){};Vs(r,e+"BaseSemanticsWithDefaults");const i=Object.create(n.prototype);return hr(t,e=>{i[e]=Hs}),(r.prototype=i).constructor=r,r}(this.className,rt(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){const e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):sa}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?sa:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=fo,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},Cr(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(L(e)){if(Fr(e))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(L(e))this.tokensMap=Kr(e,(e,t)=>(e[t.name]=t,e),{});else if(Cr(e,"modes")&&pr(wt(br(e.modes)),Io)){const t=Xr(wt(br(e.modes)));this.tokensMap=Kr(t,(e,t)=>(e[t.name]=t,e),{})}else{if(!M(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=_n(e)}this.tokensMap.EOF=Fo;const n=pr(Cr(e,"modes")?wt(br(e.modes)):br(e),e=>Fr(e.categoryMatches));this.tokenMatcher=n?fo:ho,Eo(br(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=Cr(n,"resyncEnabled")?n.resyncEnabled:ca.resyncEnabled,i=Cr(n,"recoveryValueFunc")?n.recoveryValueFunc:ca.recoveryValueFunc,o=this.ruleShortNameIdx<<12;let s;return this.ruleShortNameIdx++,this.shortRuleNameToFull[o]=e,this.fullRuleNameToShort[e]=o,s=!0===this.outputCst?function(...n){try{this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,n);const r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(s,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){const r=1===this.RULE_STACK.length,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Ls(e)){const t=e;if(i){const r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(r)return this.moveToTerminatedState(),n(e);throw t}throw e}optionInternal(e,t){const n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof e){r=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else r=e;if(!0===i.call(this))return r.call(this)}atLeastOneInternal(e,t){const n=this.getKeyForAutomaticLookahead(Ds,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;if(!0!==i.call(this))throw this.raiseEarlyExitException(e,Jo.REPETITION_MANDATORY,t.ERR_MSG);{let e=this.doSingleRepetition(r);for(;!0===i.call(this)&&!0===e;)e=this.doSingleRepetition(r)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Ds,e,Yo)}atLeastOneSepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(Bs,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(e,Jo.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);{r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Xo],t,Bs,e,Xo)}}manyInternal(e,t){const n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;let o=!0;for(;!0===i.call(this)&&!0===o;)o=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,768,e,Vo,o)}manySepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(js,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Ho],t,js,e,Ho)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Bs,e,i)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const n=this.getKeyForAutomaticLookahead(256,t),r=L(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(void 0!==i)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){const e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new bs(t,e))}}subruleInternal(e,t,n){let r;try{const i=void 0!==n?n.ARGS:void 0;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw Ls(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{const t=this.LA(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r;const i=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Cs(r,t,i))}consumeInternalRecovery(e,t,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;{const r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===Ms?n:e}}}saveRecogState(){const e=this.errors,t=_n(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Fo)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=ca){if(wr(this.definedRulesNames,e)){const t={message:$o.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ua.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);const r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=ca){const r=function(e,t,n){const r=[];let i;return wr(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:ua.INVALID_RULE_OVERRIDE,ruleName:e})),r}(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);const i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);const n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(Ls(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Nr(br(this.gastProductionsCache),fi)}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Cr(e,"errorMessageProvider")?e.errorMessageProvider:aa.errorMessageProvider}SAVE_ERROR(e){if(Ls(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:_n(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return _n(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){const r=this.getCurrRuleFullName(),i=ls(e,this.getGAstProductions()[r],t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));const s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new Ps(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const n=this.getCurrRuleFullName(),r=us(e,this.getGAstProductions()[n],this.maxLookahead),i=[];for(let e=1;e<=this.maxLookahead;e++)i.push(this.LA(e));const o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ks(s,this.LA(1),o))}},class{initContentAssist(){}computeContentAssist(e,t){const n=this.gastProductionsCache[e];if(Br(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Zo([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const t=Ir(e.ruleStack),n=this.getGAstProductions()[t];return new Ko(n,e).startWalking()}},class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const t=e>0?e:"";this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let t=0;t<10;t++){const n=t>0?t:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return sa}topLevelRuleRecord(e,t){try{const n=new ri({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(t){throw e}throw e}}optionInternalRecord(e,t){return na.call(this,oi,e,t)}atLeastOneInternalRecord(e,t){na.call(this,si,t,e)}atLeastOneSepFirstInternalRecord(e,t){na.call(this,ai,t,e,Zs)}manyInternalRecord(e,t){na.call(this,ci,t,e)}manySepFirstInternalRecord(e,t){na.call(this,ui,t,e,Zs)}orInternalRecord(e,t){return ra.call(this,e,t)}subruleInternalRecord(e,t,n){if(oa(t),!e||!1===Cr(e,"ruleName")){const n=new Error(`<SUBRULE${ia(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=cr(this.recordingProdStack),i=e.ruleName,o=new ni({idx:t,nonTerminalName:i,label:null==n?void 0:n.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?ta:qs}consumeInternalRecord(e,t,n){if(oa(t),!To(e)){const n=new Error(`<CONSUME${ia(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=cr(this.recordingProdStack),i=new hi({idx:t,terminalType:e,label:null==n?void 0:n.LABEL});return r.definition.push(i),ea}},class{initPerformanceTracer(e){if(Cr(e,"traceInitPerf")){const t=e.traceInitPerf,n="number"==typeof t;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=aa.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=Qr(t),o=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}}],ha.forEach(e=>{const t=e.prototype;Object.getOwnPropertyNames(t).forEach(n=>{if("constructor"===n)return;const r=Object.getOwnPropertyDescriptor(t,n);r&&(r.get||r.set)?Object.defineProperty(la.prototype,n,r):la.prototype[n]=e.prototype[n]})});class da extends fa{constructor(e,t=aa){const n=_n(t);n.outputCst=!1,super(e,n)}}const pa=Uo({name:"WhiteSpace",pattern:/\s+/,group:Ro.SKIPPED}),ma=Uo({name:"String",pattern:/"(""|[^"])*"/}),Ea=Uo({name:"SingleQuotedString",pattern:/'(''|[^'])*'/}),ga=Uo({name:"SheetQuoted",pattern:/'((?![\\/[\]*?:]).)+?'!/}),Ta=Uo({name:"FunctionToken",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\(/}),Aa=Uo({name:"NamedTableReference",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\[/}),Ia=Uo({name:"BracketedString",pattern:/\[([^[\]]*)\]/,longer_alt:[Aa,ma]}),va=Uo({name:"LiteralError",pattern:/#PARSE!|#NULL!|#DIV\/0!|#VALUE!|#NUM!|#FIELD!|#N\/A|#GETTING_DATA|#SPILL!|#CONNECT!|#BLOCKED!|#UNKNOWN!|#FIELD!|#CALC!|#BUSY!|#PYTHON!|#TIMEOUT!/}),Na=Uo({name:"RefError",pattern:/#REF!|#NAME\?/}),ya=Uo({name:"Sheet",pattern:/[A-Za-z_.\d\u007F-\uFFFF]+!/}),Ra=/^[a-zA-Z_][a-zA-Z0-9_.?]*:?/,Oa=Uo({name:"Name",pattern:{exec:(e,t)=>{try{const n=Ra.exec(e.substring(t));if(n){const e=n[0];if(e.endsWith(":")){const t=e.length;return"."===e[t-2]?[e.substring(0,t-2)]:[e.substring(0,t-1)]}return[e]}}catch(e){console.warn("Error parsing name",e)}return null}},line_breaks:!1,start_chars_hint:(()=>{const e=[];for(let t=65;t<=90;t++)e.push(t);for(let t=97;t<=122;t++)e.push(t);for(let t=48;t<=57;t++)e.push(t);return e})()}),Sa=Uo({name:"Cell",pattern:/[$]?[A-Za-z]{1,3}[$]?[1-9][0-9]*/,longer_alt:Oa}),_a=Uo({name:"Column",pattern:/[$]?[A-Za-z]{1,3}/,longer_alt:Oa}),La=Uo({name:"AbsRow",pattern:/[$][0-9]+/,longer_alt:Oa}),xa=Uo({name:"NumberToken",pattern:/[0-9]+[.]?[0-9]*([eE][+-][0-9]+)?/}),Ca=Uo({name:"Boolean",pattern:/TRUE|FALSE/i}),ka=Uo({name:"Comma",pattern:/,/}),ba=Uo({name:"RangeUnion",pattern:/:/}),Pa=Uo({name:"RangeTrimFull",pattern:/\.:\./}),wa=Uo({name:"RangeTrimLeading",pattern:/\.:/}),Ma=Uo({name:"RangeTrimTrailing",pattern:/:\./}),Ua=Uo({name:"Semicolon",pattern:/;/}),Fa=Uo({name:"OpenParen",pattern:/\(/}),Da=Uo({name:"CloseParen",pattern:/\)/}),ja=Uo({name:"OpenSquareParen",pattern:/\[/}),Ba=Uo({name:"CloseSquareParen",pattern:/]/});Uo({name:"exclamationMark",pattern:/!/});const $a=Uo({name:"OpenCurlyParen",pattern:/{/}),Wa=Uo({name:"CloseCurlyParen",pattern:/}/}),Ga=Uo({name:"QuoteS",pattern:/'/}),Ka=Uo({name:"MulOp",pattern:/\*/}),za=Uo({name:"PlusOp",pattern:/\+/}),Va=Uo({name:"DivOp",pattern:/\//}),Ha=Uo({name:"MinOp",pattern:/-/}),Ya=Uo({name:"ImplicitIntersectOp",pattern:/@/}),Xa=Uo({name:"ConcatOp",pattern:/&/}),qa=Uo({name:"ExOp",pattern:/\^/}),Za=Uo({name:"PercentOp",pattern:/%/}),Qa=Uo({name:"TableSpecifier",pattern:/#(All|Data|Headers|Totals|This Row)/i}),Ja=Uo({name:"ArrayAnchorOp",pattern:/#/,longer_alt:[Qa,va,Na]}),ec=Uo({name:"GtOp",pattern:/>/}),tc=Uo({name:"EqOp",pattern:/=/}),nc=Uo({name:"LtOp",pattern:/</}),rc=[pa,ma,ga,Ea,Ta,Aa,Ia,va,Na,ya,Sa,Ca,_a,La,Qa,Ja,Ya,Oa,xa,ka,Pa,wa,Ma,ba,Ua,Fa,Da,ja,Ba,$a,Wa,Ga,Ka,za,Va,Ha,Xa,qa,Ka,Za,Uo({name:"NeqOp",pattern:/<>/}),Uo({name:"GteOp",pattern:/>=/}),Uo({name:"LteOp",pattern:/<=/}),ec,tc,nc],ic=new Ro(rc,{ensureOptimizations:!0}),oc={};rc.forEach(e=>{oc[e.name]=e});const sc={boolean:3,string:2,number:1},ac=(e,t)=>{let n=e+t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},cc=(e,t)=>{let n=e-t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},uc=(e,t)=>{let n=e*t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},lc=(e,t)=>{if(0===t)return 1/0;let n=e/t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},hc=(e,t)=>{const n=e**t;return isFinite(n)?n:Number.NaN},fc=(e="",t="")=>{null===e&&(e=""),null===t&&(t="");return"boolean"===typeof e&&(e=e?"TRUE":"FALSE"),"boolean"===typeof t&&(t=t?"TRUE":"FALSE"),""+e+t},dc=(e=null,t=null)=>typeof e===typeof t&&e===t,pc=(e=null,t=null)=>typeof e!==typeof t||e!==t,mc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e>t:sc[n]>sc[r]},Ec=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e>=t:sc[n]>=sc[r]},gc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e<t:sc[n]<sc[r]},Tc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e<=t:sc[n]<=sc[r]},Ac={type:r.Number,coerce:!0,includeBoolean:!0,includeMistyped:!0,mismatchFill:e.BuiltIn.NA},Ic={type:r.String,coerce:!0,includeMistyped:!0,mismatchFill:e.BuiltIn.NA},vc={type:null,coerce:!0,includeMistyped:!0,mismatchFill:e.BuiltIn.NA},Nc=(t,o,s,a)=>{if(null!==o&&void 0!==o.colStart&&(o=t.getValueAt(o.rowStart,o.colStart)),null!==s&&void 0!==s.colStart&&(s=t.getValueAt(s.rowStart,s.colStart)),"number"==typeof o&&"number"==typeof s)return a(o,s);let c,u;if(o?.isIRange?c=o:s?.isIRange&&(u=s),!c&&!u){const t=!1;return o=n(o,i(o,!0),r.Number,!0,t),s=n(s,i(s,!0),r.Number,!0,t),o instanceof e.Value?o:s instanceof e.Value?s:a(o,s)}return c||(c=t.getRange(o)),c.broadcast(s,a,Ac).fillEmpty(0)},yc=(e,t,n,r)=>{let i,o;return null!==t&&void 0!==t.colStart&&(t=e.getValueAt(t.rowStart,t.colStart)),null!==n&&void 0!==n.colStart&&(n=e.getValueAt(n.rowStart,n.colStart)),t?.isIRange?(i=t,o=n):n?.isIRange&&(i=n,o=t),i?i.broadcast(o,r,vc):r(t,n)},Rc=(t,o)=>{null==o&&(o=0);let s,a=1;if("+"===t)return o;if("-"!==t)throw new e.Value(`Unrecognized prefix: ${t}`);return a=-a,o?.isIRange&&(s=o),s?s.broadcast(a,uc,vc):"number"!=typeof(o=n(o,i(o,!0),r.Number))||isNaN(o)?e.BuiltIn.Value:o*a},Oc=(t,n,r,i)=>{if(!n)return e.BuiltIn.Ref;if(n.isIReferenceRange&&(n=n.getCoords()),void 0===n.colStart)return e.BuiltIn.Ref;if(r.isIReferenceRange&&(r=r.getCoords()),void 0===r.colStart)return e.BuiltIn.Ref;const o=i(n,r);return o?t.getReference(o):e.BuiltIn.Null},Sc={"+":(e,t,n)=>Nc(e,t,n,ac),"-":(e,t,n)=>Nc(e,t,n,cc),"*":(e,t,n)=>Nc(e,t,n,uc),"/":(e,t,n)=>Nc(e,t,n,lc),"^":(e,t,n)=>Nc(e,t,n,hc)," ":(e,n,r,i)=>Oc(e,n,r,t.intersectRanges),":":(e,n,r,i)=>Oc(e,n,r,t.unionRanges),".:.":(e,n,r,i)=>{const o=Oc(e,n,r,t.unionRanges);return e.getFunction("TRIMRANGE").execute(o,3,3)},".:":(e,n,r,i)=>{const o=Oc(e,n,r,t.unionRanges);return e.getFunction("TRIMRANGE").execute(o,1,1)},":.":(e,n,r,i)=>{const o=Oc(e,n,r,t.unionRanges);return e.getFunction("TRIMRANGE").execute(o,2,2)},"&":(e,t,o)=>((e,t,o,s)=>{if(null!==t&&void 0!==t.colStart&&(t=e.getValueAt(t.rowStart,t.colStart)),null!==o&&void 0!==o.colStart&&(o=e.getValueAt(o.rowStart,o.colStart)),"string"==typeof t&&"string"==typeof o)return s(t,o);let a,c;return t?.isIRange?a=t:o?.isIRange&&(c=o),a||c?(a||(a=e.getRange(t)),a.broadcast(o,s,Ic)):s(t=n(t,i(t,!0),r.String),o=n(o,i(o,!0),r.String))})(e,t,o,fc),"=":(e,t,n)=>yc(e,t,n,dc),"<>":(e,t,n)=>yc(e,t,n,pc),">":(e,t,n)=>yc(e,t,n,mc),"<":(e,t,n)=>yc(e,t,n,gc),">=":(e,t,n)=>yc(e,t,n,Ec),"<=":(e,t,n)=>yc(e,t,n,Tc)},_c={"-":(e,t)=>Rc("-",t),"+":(e,t)=>Rc("+",t),"@":(t,n)=>{if(!n||!n.isIReferenceRange)return n;const r=n.getCoords(),i=n,o=t.getPosition(),s=i.getHeight(),a=i.getWidth();if(a>1&&s>1)return e.BuiltIn.Value;if(s>1){const e=o.rowIndex-r.rowStart;if(e>=0&&e<s)return i.getValueAt(e,0)}else{if(!(a>1))return i.getValueAt(0,0);{const e=o.colIndex-r.colStart;if(e>=0&&e<a)return i.getValueAt(0,e)}}return e.BuiltIn.Value}},Lc={"%":(e,t)=>Nc(e,t,100,lc),"#":(t,n)=>{const r=t.getSpillAt(n.rowStart,n.colStart);return r||e.BuiltIn.Ref}};function xc(e){const t=(e=e.toUpperCase()).length;let n=0;for(let r=0;r<t;r++){const i=e.charCodeAt(r);isNaN(i)||(n+=(i-64)*26**(t-r-1))}return n}function Cc(e){return{type:"cell",value:Object.freeze({colIndex:e.colIndex,rowIndex:e.rowIndex,$colIndex:e.$colIndex||!1,$rowIndex:e.$rowIndex||!1}),inputs:null,isReference:!0}}function kc(e,t){const n=e.startsWith("$");n&&(e=e.substring(1));let r=parseInt(e)-1;return n||r===Number.MIN_SAFE_INTEGER||(r-=t.colIndex),{type:"cell",value:Object.freeze({colIndex:Number.MIN_SAFE_INTEGER,$colIndex:!1,rowIndex:r,$rowIndex:n}),inputs:null,isReference:!0}}function bc(e,t){return{type:"function",value:e=e.toUpperCase(),inputs:t}}function Pc(e,t){return{type:"tableReference",value:e,inputs:t}}function wc(e){return{type:"tableSpecifier",value:e,inputs:null,isReference:!0}}function Mc(e,t,n,r=!1){const i={type:"infix",value:e,inputs:[t,n]};return r&&(i.isReference=!0),i}function Uc(e,t,n=!1){const r={type:"postfix",value:e,inputs:[t]};return n&&(r.isReference=!0),r}function Fc(e,t,n=!1){const r={type:"prefix",value:e,inputs:[t]};return n&&(r.isReference=!0),r}function Dc(e){return{type:"named",value:e,inputs:null,isReference:!0}}function jc(e){return{type:"number",value:Number(e),isLiteral:!0}}function Bc(e){let t=e;const n=e&&e.length>1&&'"'===e[0]&&'"'===e[e.length-1];return n&&(t=e.substring(1,e.length-1)),{type:n?"quotedString":"string",value:t,isLiteral:!0}}function $c(e){return{type:"boolean",value:"TRUE"===e||"TRUE"===e.toUpperCase(),isLiteral:!0}}function Wc(t){return{type:"error",value:e.getBuiltInByLabel(t.toUpperCase()),isLiteral:!0}}function Gc(t){return{type:"error",value:t?e.getBuiltInByLabel(t.toUpperCase()):e.BuiltIn.Ref,inputs:null,isReference:!0}}function Kc(e,t){const n=function e(n,r){const i=n.inputs;let o;if(i){const t=i.length;for(let r=0;r<t;r++){const t=i[r],s=e(t,n);s!==t&&(o||(o=[...i]),o[r]=s)}}const s=o?{...n,inputs:o}:n,a=t(s,r);return void 0===a?s:a}(e,void 0);return n||this}function zc(e,t){let n=0,r=Kc(e,e=>{const t={...e};return t.evalIndex=n++,t});const i=new Array(n),s=new Set,a=new Map;let c;const u=new Map,l=[],h=[];r=Kc(r,(e,t)=>{const n=e.type,r=e.evalIndex;if(i[r]=null,e.isReference){const t=e,r={node:e,index:u.size,op:null,value:null,inputs:null};if(u.set(t,r),"cell"===n){const n=t.value;return n.$colIndex&&(r.hasHorizontalAbs=!0),n.$rowIndex&&(r.hasVerticalAbs=!0),r.value=a.size,a.set(t,a.size),s.add(r),e.refIndex=h.length,void h.push(r.index)}if("infix"===n||"prefix"===n||"postfix"===n||"spill"===n){const n=t.inputs,i=n.length,o=e.value;r.op=o;const a=new Array(i);r.inputs=a;for(let e=0;e<i;e++){const t=n[e],i=u.get(t);i&&(i.hasHorizontalAbs&&(r.hasHorizontalAbs=!0),i.hasVerticalAbs&&(r.hasVerticalAbs=!0)),a[e]=i?i.index:-1,s.delete(i)}if(s.add(r),qc.includes(o)){const t=n[0],i=!!t&&"cell"===t.type,o=n[1],s=!!o&&"cell"===o.type;i&&s&&(h.splice(o.refIndex,1),o.refIndex=t.refIndex,e.refIndex=t.refIndex,h[t.refIndex]=r.index)}else"#"===o&&(e.refIndex=n[0].refIndex);return void l.push(e)}if("error"===n||"named"===n){c||(c=new Map);const i=t.value;let o=c.get(i);return r.op=n,void 0===o&&(o=c.size,c.set(i,o)),r.value=o,s.add(r),e.refIndex=h.length,void h.push(r.index)}"tableReference"===n&&(r.op=n),"tableSpecifier"===n&&(r.op=n),"structuredArg"===n&&(r.op=n)}else if(t&&t.isReference){const t=e,n={node:e,index:u.size,op:"function",value:e.value,inputs:null};u.set(t,n)}if(e.isLiteral)if("array"!==n)i[r]=e.value;else{const t=e.value,n=t.length,s=new Array(n);for(let e=0;e<n;e++){const n=t[e].value,r=n.length,i=new Array(r);for(let e=0;e<r;e++){const t=n[e];let r=t.value;if("prefix"===t.type){const e=t.value;r=t.inputs[0].value,"-"===e&&(r=-r)}i[e]=r}s[e]=i}i[r]=o(s)}else{if("empty"!==n)return l.push(e),e;i[r]=void 0}});const f=new Array(a.size);a.forEach((e,t)=>{const n=t.value,r=n.colIndex,i=n.rowIndex,o=n.$colIndex,s=n.$rowIndex,a={colStart:r,rowStart:i,colEnd:r,rowEnd:i,$colStart:o,$rowStart:s,$colEnd:o,$rowEnd:s};r===Number.MIN_SAFE_INTEGER&&(a.colEnd=Number.MAX_SAFE_INTEGER),i===Number.MIN_SAFE_INTEGER&&(a.rowEnd=Number.MAX_SAFE_INTEGER),n.sheetName&&(a.sheetName=n.sheetName),f[e]=a});const d=f.length,p=new Array(d);for(let e=0;e<d;e++)p[e]={colStart:0,rowStart:0,colEnd:0,rowEnd:0,sheetName:null};const m=new Array(u.size);let E;u.forEach(e=>{m[e.index]=e}),c&&(E=[],c.forEach((e,t)=>{E.push(t)}));const g=[];s.forEach(e=>{g.push(e.index)});const T=l.length;for(let e=0;e<T;e++){const t=l[e],n=t.type;if("infix"===n){const e=t.value;t.fn=Sc[e]}else if("prefix"===n){const e=t.value;t.fn=_c[e]}else if("postfix"===n){const e=t.value;t.fn=Lc[e]}}const A=function(e){const t=[],n=(e,n)=>{const r={type:e.type,value:e.value};void 0!==e.evalIndex&&(r.evalIndex=e.evalIndex),void 0!==e.refIndex&&(r.refIndex=e.refIndex),n&&(r.ctx=n),t.push(r)},r=(e,n,r,i)=>{if(null==n)return;if(t.length>1&&"whitespace"===e&&"whitespace"===t[t.length-1].type)return;const o={type:e,value:n};r&&(o.ctx=r),void 0!==i&&(o.evalIndex=i),t.push(o)};!function e(t,i,o){const s=t.evalIndex??o??0,a=t.type,c=(t,n,i)=>{if(!t)return;const o=t.length;for(let s=0;s<o;s++)e(t[s],n,i),s<o-1&&r("comma",",",n)};if(t.isLiteral){if(r("whitespace",t.wsBefore,i),"array"===a){r("type","{",i);const n=t.value,o=n.length;for(let t=0;t<o;t++){const a=n[t],c=a.value,u=c.length;for(let t=0;t<u;t++){const n=c[t];r("whitespace",n.wsBefore,i),e(n,i,s),r("whitespace",n.wsAfter,i),t<u-1&&r("comma",",",i)}t<o-1&&(r("whitespace",a.wsBefore,i),r("comma",";",i),r("whitespace",a.wsAfter,i))}t.error||r("type","}",i)}else"quotedString"===a?(t={type:a,value:'"'+t.value+'"'},n(t,i)):n(t,i);r("whitespace",t.wsAfter,i)}else if("infix"===a)e(t.inputs[0],i,s),r("whitespace",t.wsBefore,i),n(t,i),r("whitespace",t.wsAfter,i),e(t.inputs[1],i,s);else if("prefix"===a)r("whitespace",t.wsBefore,i),n(t,i),r("whitespace",t.wsAfter,i),e(t.inputs[0],i,s);else if("postfix"===a)e(t.inputs[0],i,s),r("whitespace",t.wsBefore,i),n(t,i),r("whitespace",t.wsAfter,i);else{r("whitespace",t.wsBefore,i);const o=t.inputs;switch(a){case"function":n(t,i);const u={name:String(t.value),argIndex:-1};if(r("paren","(",u,t.evalIndex),o){const t=o.length;for(let n=0;n<t;n++){const i={...u,argIndex:n};e(o[n],i,s),n<t-1&&r("comma",",",i)}}t.error||r("paren",")",u,t.evalIndex);break;case"cell":n(t,i);break;case"paren":r(a,"(",i,s),c(o,i,s),t.error||r(a,")",i,s);break;case"squareParen":r(a,"[",i,s),c(o,i,s),t.error||r(a,"]",i,s);break;case"tableReference":n(t,i);const l={name:String(t.value),argIndex:-1};if(r("paren","[",l),o){const t=o.length;for(let n=0;n<t;n++){const i={...l,argIndex:n};e(o[n],i,s),n<t-1&&r("comma",",",i)}}t.error||r("paren","]",l);break;default:void 0!==t.value&&n(t,i),o&&o.forEach(t=>e(t,i,s))}r("whitespace",t.wsAfter,i)}}(e);const i=t.length;for(let e=0;e<i;e++){const n=t[e];if("whitespace"===n.type&&void 0===n.evalIndex){const r=t[e+1];r&&void 0!==r.evalIndex&&(n.evalIndex=r.evalIndex)}}return t}(r);return{ast:r,evaluations:i,executions:l,precedentsAbsolute:p,precedentsExecute:m,precedentsNamed:E,precedentsRelative:f,precedentsRoot:g,references:h,tokens:A,error:t}}function Vc(t,n){let r,i=-1,o="";Number.isSafeInteger(t.previousToken?.startLine)?(i=t.previousToken.startLine,r=t.previousToken.endColumn+1):Number.isSafeInteger(t.token?.startLine)&&(i=t.token.startLine,r=t.token.startColumn),-1!==i?(o+="\n"+n.split("\n")[i-1]+"\n",o+=Array(r-1).fill(" ").join("")+"^\n",o+=`Error at position ${i}:${r}\n`+t.message,t.errorLocation={line:i,column:r}):o=n+"\n"+t.message;const s=new e.Parse(o);return s.details=t,s}const Hc=function(e,t){return t.wsBefore&&(e.wsBefore=t.wsBefore),t.wsAfter&&(e.wsAfter=t.wsAfter),t.image&&(e.image=t.image),e},Yc="_XLFN.",Xc=Object.freeze([[":",".:.",".:",,":."],["^"],["*","/"],["+","-"],["&"],["<",">","=","<>","<=",">="]]),qc=Object.freeze([":",".:.",".:",,":."]),Zc=Object.freeze([":"," ",".:.",".:",,":."]),Qc=Object.freeze(["@"]),Jc=Object.freeze(["#"]),eu=Object.freeze(Zc.concat(Qc).concat(Jc)),{String:tu,SheetQuoted:nu,SingleQuotedString:ru,FunctionToken:iu,NamedTableReference:ou,LiteralError:su,RefError:au,Cell:cu,Sheet:uu,Name:lu,NumberToken:hu,Boolean:fu,Column:du,AbsRow:pu,ImplicitIntersectOp:mu,Comma:Eu,RangeUnion:gu,RangeTrimFull:Tu,RangeTrimLeading:Au,RangeTrimTrailing:Iu,Semicolon:vu,OpenParen:Nu,CloseParen:yu,OpenSquareParen:Ru,CloseSquareParen:Ou,OpenCurlyParen:Su,CloseCurlyParen:_u,MulOp:Lu,PlusOp:xu,DivOp:Cu,MinOp:ku,ConcatOp:bu,ExOp:Pu,PercentOp:wu,ArrayAnchorOp:Mu,TableSpecifier:Uu,BracketedString:Fu,NeqOp:Du,GteOp:ju,LteOp:Bu,GtOp:$u,EqOp:Wu,LtOp:Gu}=oc;class Ku extends da{constructor(){super(oc,{nodeLocationTracking:"full",maxLookahead:1,skipValidations:!0,recoveryEnabled:!0}),this.position={colIndex:0,rowIndex:0},this.astErrors=[];const e=this,t=(t,n,r)=>{let i;e.CONSUME(n);const o=e.getLexerPosition();i=e.ACTION(()=>(i={type:t,value:null,inputs:null},this._ensureWhitespace(i,o,!0)));const s=[],a=e.SUBRULE(e.intersectOp);a&&s.push(a);const c=e.SUBRULE(e.group),u=e.OPTION(()=>this.CONSUME(r));return i=e.ACTION(()=>{if(c)for(let e=0;e<c.length;e++)s.push(c[e]);return i&&(u||this._reportError(i,"Missing closing parenthesis",o),i.inputs=s),this._ensureWhitespace(i,e.getLexerPosition(),!1,!0)}),i};e.RULE("infixOp",()=>{const t=[],n=[e.SUBRULE(e.postfixOp)];return e.MANY(()=>{const r=e.OR(e.c1||(e.c1=[{ALT:()=>e.CONSUME(gu).image},{ALT:()=>e.CONSUME(xu).image},{ALT:()=>e.CONSUME(ku).image},{ALT:()=>e.CONSUME(Lu).image},{ALT:()=>e.CONSUME(Cu).image},{ALT:()=>e.CONSUME(Pu).image},{ALT:()=>e.CONSUME(bu).image},{ALT:()=>e.CONSUME($u).image},{ALT:()=>e.CONSUME(Wu).image},{ALT:()=>e.CONSUME(Gu).image},{ALT:()=>e.CONSUME(Du).image},{ALT:()=>e.CONSUME(ju).image},{ALT:()=>e.CONSUME(Bu).image},{ALT:()=>e.CONSUME(Tu).image},{ALT:()=>e.CONSUME(Au).image},{ALT:()=>e.CONSUME(Iu).image}]));t.push([r,e.getLexerPosition(),eu.includes(r)]),n.push(e.SUBRULE2(e.postfixOp))}),e.ACTION(()=>{let e=t.length;const r=Xc.length;for(let i=0;e>0&&i<r;i++){const r=Xc[i];let o=t.length;for(let i=0;i<o;i++){const s=t[i],a=s[0];if(!r.includes(a))continue;let c=Mc(a,n[i],n[i+1],s[2]);c=this._ensureWhitespace(c,s[1]),t.splice(i,1),n.splice(i,2,c),i--,o--,e--}}}),n[0]}),e.RULE("plusMinusOp",()=>e.OR([{ALT:()=>e.CONSUME(xu).image},{ALT:()=>e.CONSUME(ku).image}])),e.RULE("postfixOp",()=>{let t=e.SUBRULE(e.prefixOp);const n=[];return e.MANY(()=>{const t=e.OR([{ALT:()=>e.CONSUME(wu).image},{ALT:()=>e.CONSUME(Mu).image}]);e.ACTION(()=>{n.push([t,e.getLexerPosition()])})}),e.ACTION(()=>{const e=n.length;if(0!==e)for(let r=0;r<e;r++){const e=n[r],i=e[0],o=e[1],s=eu.includes(i);t=Uc(i,t,s),t=this._ensureWhitespace(t,o)}}),t}),e.RULE("prefixOp",()=>{const t=[];e.MANY(()=>{const n=e.OR([{ALT:()=>e.CONSUME(xu).image},{ALT:()=>e.CONSUME(ku).image},{ALT:()=>e.CONSUME(mu).image}]);e.ACTION(()=>{t.push([n,e.getLexerPosition()])})});let n=e.SUBRULE(e.formula);return e.ACTION(()=>{const e=t.length;if(0!==e)for(let r=e-1;r>=0;r--){const e=t[r],i=e[0],o=e[1],s=eu.includes(i);n=Fc(i,n,s),n=this._ensureWhitespace(n,o)}}),n}),e.RULE("intersectOp",()=>{const t=[e.SUBRULE(e.infixOp)];return e.MANY(()=>{e.OPTION({GATE:()=>{const t=e.LA(0);return e.LA(1).startOffset>t.endOffset+1},DEF:()=>{t.push(e.SUBRULE3(e.infixOp))}})}),e.ACTION(()=>{for(;t.length>1;){let e=t.length-1;for(let n=0;n<e;n++){const r=t[n],i=t[n+1],o=Mc(" ",r,i,!0);if(delete r.wsAfter,i.wsBefore){const e=i.wsBefore.slice(0,-1),t=e.length;delete i.wsBefore,t>0&&(o.wsBefore=e)}n+1<e&&delete i.wsAfter,t.splice(n,2,o),n--,e--}}}),t[0]}),e.RULE("formula",()=>e.OR9([{ALT:()=>e.SUBRULE(e.referenceWithoutInfix)},{ALT:()=>e.SUBRULE(e.function)},{ALT:()=>e.SUBRULE(e.paren)},{ALT:()=>e.SUBRULE(e.namedTableReference)},{ALT:()=>e.SUBRULE(e.bracketedString)},{ALT:()=>e.SUBRULE(e.squareParen)},{ALT:()=>e.SUBRULE(e.literal)},{ALT:()=>e.SUBRULE(e.literalArray)}])),e.RULE("group",()=>{const t=[];return e.MANY(()=>{e.CONSUME(Eu);const n=e.SUBRULE2(e.intersectOp);e.ACTION(()=>{t.push(n)})}),t}),e.RULE("paren",()=>t("paren",Nu,yu)),e.RULE("literalArray",()=>{let t={type:"row",value:[],isLiteral:!0};e.CONSUME(Su);const n=e.getLexerPosition();let r=e.ACTION(()=>this._ensureWhitespace({type:"array",value:[t],isLiteral:!0},n,!0));const i=e.SUBRULE(e.literalForArray);e.ACTION(()=>{t.value.push(i)}),e.MANY(()=>{const n=e.OR([{ALT:()=>e.CONSUME(Eu).image},{ALT:()=>e.CONSUME(vu).image}]),i=e.SUBRULE2(e.literalForArray);e.ACTION(()=>{","===n||(t={type:"row",value:[],isLiteral:!0},r.value.push(t)),t.value.push(i)})});const o=e.OPTION(()=>this.CONSUME(_u));return r=e.ACTION(()=>(o||this._reportError(r,"Missing closing parenthesis '}'",n),this._ensureWhitespace(r,e.getLexerPosition(),!1,!0))),r}),e.RULE("literalForArray",()=>e.OR([{ALT:()=>{const t=e.OPTION(()=>e.SUBRULE(e.plusMinusOp)),n=e.CONSUME(hu),r=e.ACTION(()=>this._ensureWhitespace(jc(n.image),e.getLexerPosition()));return t?e.ACTION(()=>function(e,t){return{type:"prefix",value:e,inputs:[t]}}(t,r)):r}},{ALT:()=>{const t=e.CONSUME(tu);return e.ACTION(()=>this._ensureWhitespace(Bc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(fu);return e.ACTION(()=>this._ensureWhitespace($c(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(su);return e.ACTION(()=>this._ensureWhitespace(Wc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(au);return e.ACTION(()=>this._ensureWhitespace(Gc(t.image),e.getLexerPosition()))}}])),e.RULE("literal",()=>e.OR([{ALT:()=>{const t=e.CONSUME(hu);return e.ACTION(()=>this._ensureWhitespace(jc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(tu);return e.ACTION(()=>this._ensureWhitespace(Bc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(fu);return e.ACTION(()=>this._ensureWhitespace($c(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(su);return e.ACTION(()=>this._ensureWhitespace(Wc(t.image),e.getLexerPosition()))}}])),e.RULE("function",()=>{const t=e.CONSUME(iu).image.slice(0,-1),n=e.getLexerPosition(),r=e.SUBRULE(e.functionArguments);let i=e.ACTION(()=>this._ensureWhitespace(bc(t,r),n,!0));const o=e.OPTION(()=>this.CONSUME(yu));return i=e.ACTION(()=>(o||this._reportError(i,"Missing closing parenthesis ')'",n),this._ensureWhitespace(i,e.getLexerPosition(),!1,!0))),i}),e.RULE("functionArguments",()=>{const t=[];return e.MANY2(()=>{let n;e.CONSUME2(Eu),n=e.ACTION(()=>this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),t.push(n)}),e.OPTION(()=>{t.push(e.SUBRULE(e.intersectOp)),e.MANY(()=>{let n;e.CONSUME1(Eu),n=e.ACTION(()=>this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),t.push(n),e.OPTION3(()=>{t.pop(),t.push(e.SUBRULE2(e.intersectOp))})})}),t}),e.RULE("bracketedString",()=>{const t=e.CONSUME(Fu),n=e.getLexerPosition();return e.ACTION(()=>{const r=t.image;let i=Pc("",[wc(r.substring(1,r.length-1))]);return i=this._ensureWhitespace(i,n,!0,!1),i=this._ensureWhitespace(i,e.getLexerPosition(),!1,!0),i})}),e.RULE("squareParen",()=>{e.CONSUME(Ru);const t=e.getLexerPosition();let n=Pc("",[e.SUBRULE(e.structuredArgument)]);const r=e.OPTION(()=>this.CONSUME(Ou));return e.ACTION(()=>{r||this._reportError(n,"Missing closing parenthesis ']'",t),n=this._ensureWhitespace(n,t,!0,!1),n=this._ensureWhitespace(n,e.getLexerPosition(),!1,!0)}),n}),e.RULE("namedTableReference",()=>{const t=e.CONSUME(ou).image.slice(0,-1),n=e.getLexerPosition(),r=e.SUBRULE(e.structuredArguments);let i=e.ACTION(()=>this._ensureWhitespace(Pc(t,r),n,!0));const o=e.OPTION(()=>this.CONSUME(Ou));return i=e.ACTION(()=>(o||this._reportError(i,"Missing closing parenthesis ']'",n),this._ensureWhitespace(i,e.getLexerPosition(),!1,!0))),i}),e.RULE("structuredArguments",()=>{const t=[];return e.MANY2(()=>{e.CONSUME2(Eu),e.ACTION(()=>{t.push(this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0))})}),e.OPTION(()=>{const n=e.SUBRULE(e.structuredArgument);e.ACTION(()=>{n&&t.push(n)}),e.MANY(()=>{e.CONSUME1(Eu),e.OPTION3(()=>{let n=e.SUBRULE2(e.structuredArgument);e.ACTION(()=>{n||(n=this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),t.push(n)})})})}),t}),e.RULE("structuredArgument",()=>{const t=e.OPTION(()=>e.CONSUME(mu)),n=e.getLexerPosition(),r=e.OPTION2(()=>this.CONSUME(Ru));let i=e.OR([{ALT:()=>{const t=e.CONSUME(Uu);return e.ACTION(()=>this._ensureWhitespace(wc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Fu);return e.ACTION(()=>this._ensureWhitespace(wc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(lu);return e.ACTION(()=>this._ensureWhitespace(Dc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(ru);return e.ACTION(()=>this._ensureWhitespace(Bc(t.image),e.getLexerPosition()))}}]);if(r){const t=e.OPTION3(()=>this.CONSUME(yu));e.ACTION(()=>(t||this._reportError(i,"Missing closing parenthesis ']'",n),this._ensureWhitespace(i,e.getLexerPosition(),!1,!0))),i={type:"structuredArg",value:null,inputs:[i]}}return e.ACTION(()=>{t&&(i=Fc(t.image,i,!0),i=this._ensureWhitespace(i,e.getLexerPosition()))}),i}),e.RULE("referenceWithoutInfix",()=>e.OR([{ALT:()=>e.SUBRULE(e.reference)},{ALT:()=>{const t=e.SUBRULE(e.prefixSheetName),n=e.SUBRULE2(e.formula);return e.ACTION(()=>{if((e=n)&&e.isFormulaError)return n;var e;n.ref&&(n.ref.sheet=t)}),n}}])),e.RULE("reference",()=>{const t=e.OPTION4(()=>e.CONSUME(mu));let n=e.OR([{ALT:()=>{const t=e.CONSUME(cu),n=e.getLexerPosition(),r=e.OPTION(()=>e.CONSUME(Mu));return e.ACTION(()=>{const i=this._ensureWhitespace(function(e,t){const n=e.match(/([$]?)([A-Za-z]{1,3})([$]?)([1-9][0-9]*)/);let r=xc(n[2])-1;const i=1===n[1].length;let o=+n[4]-1;const s=1===n[3].length;return i||r===Number.MIN_SAFE_INTEGER||(r-=t.colIndex),s||o===Number.MIN_SAFE_INTEGER||(o-=t.rowIndex),{type:"cell",value:Object.freeze({colIndex:r,rowIndex:o,$colIndex:i,$rowIndex:s}),inputs:null,isReference:!0}}(t.image,e.position),n);return r?this._ensureWhitespace(Uc("#",i,!0),n):i})}},{ALT:()=>{const t=e.CONSUME(lu);return e.ACTION(()=>this._ensureWhitespace(Dc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(du);return e.ACTION(()=>this._ensureWhitespace(function(e,t){const n=e.startsWith("$");n&&(e=e.substring(1));let r=xc(e)-1;return n||r===Number.MIN_SAFE_INTEGER||(r-=t.colIndex),{type:"cell",value:Object.freeze({colIndex:r,rowIndex:Number.MIN_SAFE_INTEGER,$colIndex:n,$rowIndex:!1}),inputs:null,isReference:!0}}(t.image,e.position),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(pu);return e.ACTION(()=>this._ensureWhitespace(kc(t.image,e.position),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(au);return e.ACTION(()=>this._ensureWhitespace(Gc(t.image),e.getLexerPosition()))}}]);return e.ACTION(()=>{t&&(n=Fc(t,n,!0),n=this._ensureWhitespace(n,e.getLexerPosition()))}),n}),e.RULE("prefixSheetName",()=>e.OR([{ALT:()=>e.CONSUME(uu).image.slice(0,-1)},{ALT:()=>e.CONSUME(nu).image.slice(1,-2).replace(/''/g,"'")}])),e.performSelfAnalysis()}_reportError(e,t,n=void 0,r="SyntaxError"){void 0===n&&(n=this.getLexerPosition()),e.error=!0,this.astErrors.push({name:r,message:t,previousToken:this.input[n],ast:e})}_ensureWhitespace(e,t,n=!1,r=!1){if(!e)return console.warn("node is null"),e;const i=this.input,o=i[t];if(e.image||(e.image=o.image),!r){const n=o.startOffset,r=i[t-1],s=r?.endOffset??-1;s+1<n&&(e.wsBefore=" ".repeat(n-s-1))}if(!n){const n=o.endOffset,r=i[t+1],s=r?.startOffset??this.inputTextLength;n+1<s&&(e.wsAfter=" ".repeat(s-n-1))}return e}_createAST(t,n){const r=function(t){const n=ic.tokenize(t);if(n.errors.length>0){const r=n.errors[0],i=r.line,o=r.column;let s="\n"+t.split("\n")[i-1]+"\n";throw s+=Array(o-1).fill(" ").join("")+"^\n",r.message=s+`Error at position ${i}:${o}\n`+r.message,r.errorLocation={line:i,column:o},new e.Parse(r.message,{line:i,column:o,offset:r.offset,length:r.length})}return n}(n);let i;if(!r)return i={type:"text",value:n},i;const o=r.tokens;this.input=o,this.inputTextLength=n.length;const s=t.getPosition();return this.position=s,this.astErrors=[],this.reset(),i=this.intersectOp(),i=Kc(i,(e,t)=>{let n=e.type;if("function"===n&&e.value&&e.value.toUpperCase().startsWith(Yc)){const t=e.value.substring(6);let r=e.image.substring(6),i=e;"ANCHORARRAY"===t?(i=Uc("#",e.inputs[0],!0),r="#"):"SINGLE"===t?(i=Fc("@",e.inputs[0],!0),r="@"):i=bc(t,e.inputs),Hc(i,e),i.image=r,n=(e=i).type}const r=t?.isReference;if(r){const n=t.value;if((":"===n||".:."===n||".:"===n||":."===n)&&Number.isInteger(e.value)){const n=t.inputs[0]===e?t.inputs[1]:t.inputs[0];if(n&&Number.isInteger(n.value)){const t=kc(e.image,s);return Hc(t,e),t}}}else if("cell"===n){const t=e.value;if(t.rowIndex===Number.MIN_SAFE_INTEGER||t.colIndex>=16384){const t=Dc(e.image);return Hc(t,e),t}}return e}),i}build(t,n){if(0===n.length)throw Error("Input must not be empty.");let r,i,o;try{r=this._createAST(t,n)}catch(t){o=t instanceof e.Parse?t:new e.Parse(t.message,t)}const a=this.errors;if(a.length>0){o=Vc(a[0],n)}const c=this.astErrors;if(c.length>0){o=Vc(c[0],n)}return i=r?zc(r,o):{ast:null,evaluations:s.EmptyArray,executions:s.EmptyArray,precedentsAbsolute:s.EmptyArray,precedentsExecute:s.EmptyArray,precedentsNamed:null,precedentsRelative:s.EmptyArray,precedentsRoot:s.EmptyArray,references:s.EmptyArray,tokens:s.EmptyArray,error:o},i}}class zu{constructor(e,t){this._options=e,this._compiled=t}getTextAt(e,t,n=!1){return n?c(this._compiled.tokens):a(this._compiled.tokens,e,t)}getTokens(){return this._compiled.tokens}getError(){return this._compiled.error??null}isEquals(e){if(!(e&&e instanceof zu))return!1;if(this===e)return!0;const t=this._compiled.tokens,n=e._compiled.tokens;if(t.length!==n.length)return!1;return c(t)===c(n)}getReferences(){const e=this._compiled,t=e.references,n=t.length;if(0===n)return s.EmptyArray;const r=e.precedentsExecute,i=e.precedentsRelative,o=new Array(n);for(let s=0;s<n;s++){const n=r[t[s]],a=n.inputs;if(a&&2===a.length){const e=i[r[a[0]].value],t=i[r[a[1]].value];o[s]={colStart:e.colStart,rowStart:e.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd,$colStart:e.$colStart,$rowStart:e.$rowStart,$colEnd:t.$colEnd,$rowEnd:t.$rowEnd,sheetName:e.sheetName}}else if("cell"===n.node.type){const e=i[n.value];o[s]={...e}}else if("named"===n.op){const t=e.precedentsNamed;o[s]=t[n.value]}else"error"===n.op&&(o[s]=n.node.value)}return o}setReferenceAt(e,n){const r=this._compiled,i=r.references;if(0===i.length)return s.EmptyArray;const o=r.precedentsExecute,a=i[e];if(void 0===a)throw new Error(`Invalid reference index: ${e}`);const c=o[a],u=c.node,l=u.inputs??s.EmptyArray;let h,f,d=!1;n&&(h={colIndex:n.colStart,rowIndex:n.rowStart,$colIndex:n.$colStart??!1,$rowIndex:n.$rowStart??!1},n.sheetName&&(h.sheetName=n.sheetName),d=!t.isSingleCell(n),d&&(f={colIndex:n.colEnd,rowIndex:n.rowEnd,$colIndex:n.$colEnd??!1,$rowIndex:n.$rowEnd??!1},n.colEnd===Number.MAX_SAFE_INTEGER&&(f.colIndex=Number.MIN_SAFE_INTEGER),n.rowEnd===Number.MAX_SAFE_INTEGER&&(f.rowIndex=Number.MIN_SAFE_INTEGER)));const p=2===l.length;let m=-1,E=-1;if(p)m=l[0].evalIndex,E=l[1].evalIndex;else{if("cell"!==u.type)throw"named"===c.op?new Error("Cannot setReference for a named reference"):new Error(`Invalidate reference index: ${e}`);m=u.evalIndex}const g=this._compiled.ast,T=Kc(g,e=>{if(!e||!e.isReference)return;const t=e.type;if(!n&&qc.includes(e.value)){const e=l[0],t=l[1];let n=e.evalIndex===m,r=t.evalIndex===E;if(n||r){const e=Gc();return e.image="#REF!",e}}if(!("cell"===t||"error"===t))return;const r=e.evalIndex;let i,o=r===m;if(o||r===E){if(n)if(p===d){let t=o?h:f;i={...e},i.value=t,i.image=null}else i=d?Mc(":",Cc(h),Cc(f),!0):Cc(h);else i=Gc(),i.image="#REF!";return i}});if(T===g)return this;const A=zc(T,this._compiled.error),I=this._options;return new zu(I,A)}_resolveNamed(t,n,r,i){const o=this._options?.getNamed;if(!o)return e.BuiltIn.Name;let s=o?.(t,this._options.getSheetName?.())?.[0];return s?(s.isFormulaError||(s=u(s,n,r,i)),s):e.BuiltIn.Name}getDirectPrecedentsAt(n,r,i=!1,o,a){const c=this._compiled,l=c.precedentsRoot,h=l.length;if(0===h)return s.EmptyArray;const f=c.precedentsRelative,d=c.precedentsAbsolute,p=f.length;for(let e=0;e<p;e++){const t=f[e];let i=d[e],o=u(t,n,r,i);d[e]=o}let m=!1;const E=c.precedentsExecute,g=E.length,T=Vu;for(let i=0;i<g;i++){const o=E[i],s=o.op;if(!s){const e=d[o.value];T[o.index]=e;continue}if("named"===s){m=!0,T[o.index]=this._resolveNamed(o.node.value,n,r);continue}if("error"===s){T[o.index]=o.node.value;continue}if("@"===s||"#"===s){T[o.index]=T[o.inputs[0]];continue}const a=o.inputs;if(!a)continue;let c=T[a[0]];if(void 0===c){T[o.index]=e.BuiltIn.Value;continue}if(c.isFormulaError){T[o.index]=c;continue}let u,l=T[a[1]];void 0!==l?l.isFormulaError?T[o.index]=l:(" "===s?u=t.intersectRanges(c,l):":"!==s&&".:."!==s&&":."!==s&&".:"!==s||(u=T[o.index]=t.unionRanges(c,l)),T[o.index]=u??e.BuiltIn.Null):T[o.index]=e.BuiltIn.Value}const A=new Array(h);for(let e=0;e<h;e++){const t=l[e],n=T[t];if(A[e]=void 0!==n?.rowStart?{...n}:n,o||a){const r=E[t];m&&"named"===r.op?(o&&(o[e]=n.$colStart||n.$colEnd),a&&(a[e]=n.$rowStart||n.$rowEnd)):(o&&(o[e]=r.hasVerticalAbs),a&&(a[e]=r.hasHorizontalAbs))}}return A}evaluate(t,n,r){const i=t.getPosition(),o=i?.rowIndex??0,s=i?.colIndex??0;let a=this._compiled;if(void 0!==n){let e;if(Kc(a.ast,t=>{t.evalIndex===n&&(e=t)}),!e)throw new Error(`Invalid evalIndex: ${n}`);a=zc(e,a.error)}if(a.error)return a.error;const c=a.evaluations,l=a.executions;let h,d;r||(r=this._resolvePrecedents(t));const p=a.precedentsExecute,m=a.precedentsRelative,E=a.precedentsAbsolute,g=p.length;for(let e=0;e<g;e++){const n=p[e],r=n.op;if(r){if("named"===r){const e=n.node;let r=this._resolveNamed(n.node.value,o,s);void 0!==r?.colStart&&(r=t.getReference(r)),c[e.evalIndex]=r}else if("error"===r){const e=n.node;c[e.evalIndex]=n.node.value}}else{const t=m[n.value];let r=E[e];const i=u(t,o,s,r),a=n.node;c[a.evalIndex]=i}}const T=a.precedentsRoot,A=T.length;if(A!==r.length)return e.BuiltIn.Parse;for(let e=0;e<A;e++){const t=p[T[e]].node;let n=r[e];n.isIRange&&"cell"===t.type&&n.size>1&&(n=n.getValueAt(0,0)??null),c[t.evalIndex]=n}let I;const v=n=>{const r=n.inputs,i=r?r.length:0;let o;switch(n.type){case"infix":const s=n.value;let a=c[r[0].evalIndex],u=c[r[1].evalIndex];if("+"===s&&"number"==typeof a&&"number"==typeof u){const e=a+u;return Math.abs(e)<99e-14?0:e}if("-"===s&&"number"==typeof a&&"number"==typeof u){const e=a-u;return Math.abs(e)<99e-14?0:e}if(a&&a.isFormulaError)return a;if(u&&u.isFormulaError)return u;const l=n.fn;return o=l?l(t,a,u):e.BuiltIn.Value,o=f(o,null),o;case"function":I||(I=new Array(i)),I.length!==i&&(I.length=i);for(let e=0;e<i;e++)I[e]=c[r[e].evalIndex];return o=this._callFunction(t,n,I),o&&"function"==typeof o.then?o.then(r=>{r=f(r,t),o instanceof e.Known&&(d=o),c[n.evalIndex]=r}).catch(t=>{const r=t instanceof e.Known?t:new e.Value("Uncaught error",{cause:t});c[n.evalIndex]=r}):o instanceof e.Known&&(d=o),o;case"prefix":case"postfix":let h=c[r[0].evalIndex];if(h&&h.isFormulaError)return h;const p=n.fn;return o=p?p(t,h):e.BuiltIn.Value,o;case"paren":if(1===i)return c[r[0].evalIndex];{const e=new Array(i);for(let t=0;t<i;t++)e[t]=c[r[t].evalIndex];return e}case"named":return null;case"empty":return}};let N=l.length;for(let e=0;e<N;e++){const t=l[e];if(d)return d;if(h)h=h.then(()=>{const e=v(t);return c[t.evalIndex]=e,e});else{const e=v(t);c[t.evalIndex]=e,e&&"function"==typeof e.then&&(h=e)}}if(h)return h.then(()=>{const e=c[c.length-1];return this._finalizeReturnValue(t,e)});const y=c[c.length-1];return this._finalizeReturnValue(t,y)}_resolvePrecedents(t){const n=t.getPosition(),r=n?.rowIndex??0,i=n?.colIndex??0;const o=this.getDirectPrecedentsAt(r,i),a=o.length;let c;if(a>0){c=new Array(a);for(let n=0;n<a;n++){const r=o[n];if(r instanceof e.Known)c[n]=r;else if(Array.isArray(r)){const e=new Array(r.length);for(let n=0;n<r.length;n++)e[n]=t.getReference(r[n]);c[n]=e}else c[n]=t.getReference(r)}}else c=s.EmptyArray;return c}wrapImplicit(e,t,n){const r=this._compiled.ast;if(!r||!r.isReference)return this;if("cell"===r.type)return this;if("@"===r.value)return this;if(!n)return this;const i=l(t)+h(e);if(n.has(i))return this;const o=zc(Fc("@",r,!0),this._compiled.error);return new zu(this._options,o)}_callFunction(t,n,r){const i=n?.cacheFn??t.getFunction(n.value);if(!i)return new e.Parse;const o=i.isBuiltIn();let s;o?n.cacheFn=i:this._context=t;try{s=i.execute(...r)}catch(t){s=t instanceof e.Known?t:new e.Value(t.message,{cause:t})}return o||(this._context=null),void 0===s?new e.Parse:s}_finalizeReturnValue(t,n){if(n&&void 0!==n.colStart&&(n=t.getValueAt(n.rowStart,n.colStart)),Array.isArray(n))if(1===n.length&&Array.isArray(n[0])&&1===n[0].length)n=n[0][0],Array.isArray(n)&&(n=e.BuiltIn.Value);else try{n=t.getRange(n)}catch(t){n=e.BuiltIn.Value}return n?.isIRange?1===n.size?(n=n.getValueAt(0,0,Hu),null===(n=f(n,t))&&(n=0)):n=n.fillEmpty(0):null===(n=f(n,t))&&(n=0),n}get[Symbol.toStringTag](){return"[FormulaBlock]"}toString(){const e=this._compiled;if(e.error)return e.error.toString();const t=this._context;if(t){const e=t.getPosition();return this.getTextAt(e.rowIndex,e.colIndex)}return c(e.tokens)}}const Vu=new Array(20);for(let e=0;e<Vu.length;e++)Vu[e]={colStart:0,rowStart:0,colEnd:0,rowEnd:0,sheetName:null};const Hu={type:null};class Yu{constructor(e){this._options={getEntireCoords:d,...e},this._astBuilder=new Ku}parse(e,t){const n=e.getPosition();n.sheetName;const r=this._astBuilder.build(e,t);return new zu(this._options,r)}eval(e,t){return this.parse(e,t).evaluate(e)}}export{Yu as FormulaParser};
@@ -1,7 +0,0 @@
1
- /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.13
3
- *
4
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- const t={CONVERT:{s:"Converts a number from one measurement system to another",p:{number:{d:"is the value in from_unit to convert."},fromUnit:{d:"is the units for number."},toUnit:{d:"is the units for the result"}}}};export{t as default};
@@ -1,7 +0,0 @@
1
- /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.13
3
- *
4
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- const t="text/html",e="text/plain",r="image/png",n=Object.freeze({left:0,top:0}),o=Object.freeze({left:0,top:0,bottom:0,right:0}),a=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:a,EmptyRect:o,EmptyTopLeft:n},Symbol.toStringTag,{value:"Module"}));const i="column",l="row",s=Object.freeze({colIndex:0,rowIndex:0}),c=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),u=(t,e)=>t.colStart===e.colStart?t.rowStart-e.rowStart:t.colStart-e.colStart,d=(t,e)=>t.rowStart===e.rowStart?t.colStart-e.colStart:t.rowStart-e.rowStart,f=(t,e)=>t.rowEnd===e.rowEnd?e.colEnd-t.colEnd:e.rowEnd-t.rowEnd,p=(t,e)=>t.colEnd===e.colEnd?e.rowEnd-t.rowEnd:e.colEnd-t.colEnd,w=(t,e)=>t.colIndex===e.colIndex?t.rowIndex-e.rowIndex:t.colIndex-e.colIndex,h=(t,e)=>t.rowIndex===e.rowIndex?t.colIndex-e.colIndex:t.rowIndex-e.rowIndex,y=(t=l,e=!1)=>e?t!==i?f:p:t!==i?d:u,g=(t,e)=>t===e||!(!t||!e)&&t.rowIndex===e.rowIndex&&t.colIndex===e.colIndex,b=(t,e)=>t===e||!(!t||!e)&&t.rowStart===e.rowStart&&t.rowEnd===e.rowEnd&&t.colStart===e.colStart&&t.colEnd===e.colEnd,m=(t,e)=>!(!t||!e||t.colStart>e.colEnd||e.colStart>t.colEnd||t.rowStart>e.rowEnd||e.rowStart>t.rowEnd),E=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!b(t[r],e[r]))return!1;return!0},S=(t,e,r)=>{if(!t&&!e)return null;if(!t)return r?e:{...e};if(!e)return r?t:{...t};const n=Math.min(t.colStart,e.colStart),o=Math.min(t.rowStart,e.rowStart),a=Math.max(t.colEnd,e.colEnd),i=Math.max(t.rowEnd,e.rowEnd);let l=r;return l?(l.colStart=n,l.rowStart=o,l.colEnd=a,l.rowEnd=i):l={colStart:n,rowStart:o,colEnd:a,rowEnd:i},l},v=(t,e)=>{if(!e||0===e.length)return t;const r={...t};for(let t=0;t<e.length;t++){const n=e[t];m(r,n)&&(r.rowStart=Math.min(r.rowStart,n.rowStart),r.colStart=Math.min(r.colStart,n.colStart),r.rowEnd=Math.max(r.rowEnd,n.rowEnd),r.colEnd=Math.max(r.colEnd,n.colEnd))}return r},x=[null,null],_=(t,e,r)=>{if(t[0].value===t[1].value)return e};function O(t,e=2,r,n=l,o){let a=[...t];if(e<=0||t.length<=1)return a;let s=n===i,c=0,u=!1;do{const t=a.sort(y(s?l:i));a=[],a.push(t[0]);const e=t.length;let d=0,f=t[0],p=f.colStart,w=f.rowStart,h=f.colEnd,g=f.rowEnd;for(let i=1;i<e;i++){const e=t[i];let l=!1;if(l=s?f&&w===e.rowStart&&g===e.rowEnd&&h+1===e.colStart:f&&p===e.colStart&&h===e.colEnd&&g+1===e.rowStart,l){let t={colStart:p,rowStart:w,colEnd:s?e.colEnd:h,rowEnd:s?g:e.rowEnd};if(void 0!==f.value&&(t.value=f.value),r){const a=o??[null,null];a[0]=f,a[1]=e,t=r(a,t,n)}if(t){a[d]=t,u=!0,f=t,p=f.colStart,w=f.rowStart,h=f.colEnd,g=f.rowEnd;continue}}a[++d]=e,f=e,p=f.colStart,w=f.rowStart,h=f.colEnd,g=f.rowEnd}c++,s=!s,1===c&&(u=!0)}while(c<e&&u&&a.length>1);return a}Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:s,EmptyRange:c,cellToRange:(t,e)=>{if(!t)return null;let r=e;return r||(r={...t},delete r.colIndex,delete r.rowIndex),r.colStart=t.colIndex??0,r.rowStart=t.rowIndex??0,r.colEnd=t.colIndex??0,r.rowEnd=t.rowIndex??0,r},columnFirstCellComparator:w,columnFirstRangeComparator:u,createCellComparator:(t=l,e=!1)=>e?t!==i?(t,e)=>t.rowIndex===e.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex:(t,e)=>t.colIndex===e.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex:t!==i?h:w,createConflatingRanges:(t,e=!1)=>{const r=[];let n,o,a=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;return{append:(i,l,c)=>{let u=!0;const d=void 0!==c;if(d){const r=t?t(o,c,e):o===c?c:void 0;void 0===r?u=!1:c=r}if(u&&l===s+1&&i===a)return e?n.rowEnd=l:n.colEnd=l,s=l,void(o=c);n&&r.push(n);const f=e?i:l,p=e?l:i;n={colStart:f,rowStart:p,colEnd:f,rowEnd:p},d&&(n.value=c),a=i,s=l,o=c},done:t=>(n&&(r.push(n),n=null),t?O(r,3,!0===t?_:t,e?i:l,x):r)}},createRangeComparator:y,defaultRange:(t,e,r)=>t?r?(r.colStart=t.colStart??e.colStart,r.rowStart=t.rowStart??e.rowStart,r.colEnd=t.colEnd??e.colEnd,r.rowEnd=t.rowEnd??e.rowEnd,r):{colStart:t.colStart??e.colStart,rowStart:t.rowStart??e.rowStart,colEnd:t.colEnd??e.colEnd,rowEnd:t.rowEnd??e.rowEnd}:e,extendRangeToIntersectingRanges:v,extendRangeToUnionRanges:(t,e)=>{if(!e||0===e.length)return t;let r=t,n=null;for(;!b(r,n);)n=r,r=v(n,e);return r},indexOfCoords:(t,e)=>{const r={colStart:t.colIndex,rowStart:t.rowIndex,colEnd:t.colIndex,rowEnd:t.rowIndex};for(let t=e.length-1;t>=0;t--)if(m(r,e[t]))return t;return-1},intersectRanges:(t,e,r)=>{if(!t)return r?e:{...e};if(!e)return r?t:{...t};if(!t&&!e||t.rowStart>e.rowEnd||t.rowEnd<e.rowStart||t.colStart>e.colEnd||t.colEnd<e.colStart)return null;const n=Math.max(t.colStart,e.colStart),o=Math.max(t.rowStart,e.rowStart),a=Math.min(t.colEnd,e.colEnd),i=Math.min(t.rowEnd,e.rowEnd);let l=r;return l?(l.colStart=n,l.rowStart=o,l.colEnd=a,l.rowEnd=i):l={colStart:n,rowStart:o,colEnd:a,rowEnd:i},l},isCellWithinRange:(t,e)=>!(!t||!e||t.rowIndex<e.rowStart||t.rowIndex>e.rowEnd||t.colIndex<e.colStart||t.colIndex>e.colEnd),isEqualCells:g,isEqualRanges:b,isEqualRangesArrays:E,isEqualSelectionCoords:(t,e)=>t===e||!(!t||!e)&&t.rangeIndex===e.rangeIndex&&!!g(t.cell,e.cell)&&E(t.ranges,e.ranges),isRangeWithinRange:(t,e)=>!(t.rowStart<e.rowStart||t.rowEnd>e.rowEnd||t.colStart<e.colStart||t.colEnd>e.colEnd),isRangesIntersect:m,isSingleCell:t=>!!t&&t.rowEnd===t.rowStart&&t.colStart===t.colEnd,isValidRange:t=>!(!t||"number"!=typeof t.colStart||t.colStart<0||"number"!=typeof t.colEnd||t.colEnd<t.colStart||"number"!=typeof t.rowStart||t.rowStart<0||"number"!=typeof t.rowEnd||t.rowEnd<t.rowStart),mergeRangedValues:O,rowFirstCellComparator:h,rowFirstRangeComparator:d,sanitizeRange:t=>t?{colStart:t.colIndex??t.colStart??0,rowStart:t.rowIndex??t.rowStart??0,colEnd:t.colIndex??t.colEnd??0,rowEnd:t.rowIndex??t.rowEnd??0}:null,translateRange:(t,e=-t.rowStart,r=-t.colStart,n)=>n?(n.colStart=t.colStart+r,n.rowStart=t.rowStart+e,n.colEnd=t.colEnd+r,n.rowEnd=t.rowEnd+e,n):{colStart:t.colStart+r,rowStart:t.rowStart+e,colEnd:t.colEnd+r,rowEnd:t.rowEnd+e},unionRanges:S,unionRangesArrays:(t,e,r)=>{if(!t||0===t.length)return null;if(1===t.length&&!e)return t[0];let n=t[0];for(let e=1;e<t.length;e++)n=S(n,t[e],r);return e&&(n=S(n,e,r)),n}},Symbol.toStringTag,{value:"Module"}));const I="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function j(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){const e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||t.$$typeof===I}(t)}function T(t,e){return!1!==e.clone&&e.isMergeableObject(t)?A((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function C(t,e,r){return t.concat(e).map(function(t){return T(t,r)})}function M(t){return Object.keys(t).concat((e=t,Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]));var e}function R(t,e){try{return e in t}catch{return!1}}function A(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||C,r.isMergeableObject=r.isMergeableObject||j,r.cloneUnlessOtherwiseSpecified=T;const n=Array.isArray(e);return n===Array.isArray(t)?n?r.arrayMerge(t,e,r):function(t,e,r){const n={};return r.isMergeableObject(t)&&M(t).forEach(function(e){n[e]=T(t[e],r)}),M(e).forEach(function(o){var a,i;R(a=t,i=o)&&(!Object.hasOwnProperty.call(a,i)||!Object.propertyIsEnumerable.call(a,i))||(R(t,o)&&r.isMergeableObject(e[o])?n[o]=function(t,e){if(!e.customMerge)return A;const r=e.customMerge(t);return"function"==typeof r?r:A}(o,r)(t[o],e[o],r):n[o]=T(e[o],r))}),n}(t,e,r):T(e,r)}A.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return A(t,r,e)},{})};const F=Object.freeze([]),L=Object.freeze({}),U=t=>t,P=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}),k=(t,e)=>t===e||!(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)&&t.every((t,r)=>t===e[r]),N=t=>"object"==typeof t&&!Array.isArray(t)&&null!==t,B=t=>"object"!=typeof t||Array.isArray(t)||null===t?t:(Object.keys(t).forEach(function(e){t[e]&&"object"==typeof t[e]?B(t[e]):null!==t[e]&&void 0!==t[e]||delete t[e],"object"==typeof t[e]&&0===Object.keys(t[e]).length&&delete t[e]}),0===Object.keys(t).length?null:t),z=(t,e)=>!(t!==e&&!k(t,e)&&!t.isEqual?.(e)),q=(t,e,r=z)=>{if(null==t||t===e)return null;if(!t||"object"!=typeof t||Array.isArray(t)||t.isImmutable?.())return r(t,e)?null:t;const n=Object.keys(t);if(0===n.length)return null;let o=!1;for(let a=0;a<n.length;a++){const i=n[a];null===q(t[i],e?.[i],r)&&(o=!0,delete t[i])}return o&&0===Object.keys(t).length?null:void 0},D="object"==typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now(),$=t=>null==t,W=(t,e)=>!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top),V=!(typeof window>"u"||!window.document||!window.document.createElement),G={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},J=()=>{if(H())return G.Node;const t=void 0!==globalThis.navigator&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return t?/(win32|win64|windows|wince)/i.test(t)?G.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(t)?G.MacOS:/(iphone|ipad|ipod)/i.test(t)?G.IOS:/android/.test(t)?G.Android:/linux/.test(t)?G.Linux:/^((?!chrome|android|).)*safari/i.test(t)?G.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(t)?G.Firefox:G.Unknown:G.Unknown};function H(){return typeof process<"u"&&"node"===process.release?.name||(typeof process<"u"&&process.browser,!1)}const K=(t,e=!1)=>(document.hasFocus()||e)&&(t===document.activeElement||t?.contains(document.activeElement)),Y=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:F,EmptyObject:L,OSType:G,arrayMove:function(t,e,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(e,1)[0]),n},asNumber:t=>{const e=1*t;return Number.isFinite(e)?e:0},camelToPrettyCase:t=>1===t.length?t.toUpperCase():t.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).trim(),canUseDOM:V,cancelTimeout:t=>{cancelAnimationFrame(t.id)},castToString:t=>null==t||void 0===t?"":"string"!=typeof t?""+t:t,cloneObject:t=>$(t)?t:JSON.parse(JSON.stringify(t)),consoleWithNoSource:(...t)=>new Promise(e=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,t),e()})}),debounce:function(t,e=300,r=!1){let n,o,a,i,l=0;function s(){let c=Date.now()-l;c<e&&c>=0?n=setTimeout(s,e-c):(n=null,r||(i=t.apply(a,o),a=o=null))}null==e&&(e=100);const c=function(){a=globalThis,o=arguments,l=Date.now();var c=r&&!n;return n||(n=setTimeout(s,e)),c&&(i=t.apply(a,o),a=o=null),i};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(i=t.apply(a,o),a=o=null,clearTimeout(n),n=null)},c},deepEqual:function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;let n,o,a;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;0!==o--;)if(!t(e[o],r[o]))return!1;return!0}if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(o of e.entries())if(!r.has(o[0]))return!1;for(o of e.entries())if(!t(o[1],r.get(o[0])))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(o of e.entries())if(!r.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(r)){if(n=e.length,n!=r.length)return!1;for(o=n;0!==o--;)if(e[o]!==r[o])return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(a=Object.keys(e),n=a.length,n!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,a[o]))return!1;for(o=n;0!==o--;){let n=a[o];if(!("_owner"===n&&e.$$typeof||t(e[n],r[n])))return!1}return!0}return e!=e&&r!=r},deepFreeze:function t(e){return Object.freeze(e),Object.keys(e).forEach(r=>{"object"!=typeof e[r]||null===e[r]||Object.isFrozen(e[r])||t(e[r])}),e},deepMerge:A,diffValues:(t,e)=>{const r={},n=Object.keys(e),o=n.length;for(let a=0;a<o;a++){const o=n[a];t[o]!==e[o]&&(void 0===t[o]?r[o]=e[o]:r[o]=t[o])}return 0===Object.keys(r).length?null:r},findEqualOrGreater:function(t,e,r=U){let n=0,o=t.length-1;for(;n<=o;){let a=Math.floor((n+o)/2),i=r(t[a]);if(i===e)return a;i<e?n=a+1:o=a-1}return n},findEqualOrLesser:function(t,e,r=U){let n=t.length-1,o=0;for(;n>=o;){let a=Math.floor((n+o)/2),i=r(t[a]);if(i===e)return a;i>e?n=a-1:o=a+1}return n},findNextStep:(t,e=!0,r=15,n=10,o=400)=>{const a=Math.max(t-n,0)+(e?1:-1);return Math.min(o,Math[e?"ceil":"floor"](a/r)*r+n)},getDPI:()=>{let t=1;return"object"==typeof window&&(t=window.devicePixelRatio||1),t},getFromPath:(t,e)=>{const r=e.split(".");let n=t;for(let t=0;t<r.length;t++){const e=r[t];if(!n)return null;let o=n[e];if("function"==typeof o&&(o=o.bind(n)()),!o||!N(o))return o;n=o}return n??null},getOS:J,hasFocus:K,isDefined:t=>null!=t,isEmpty:t=>null==t||""===t,isEqualArrays:k,isEqualBounds:(t,e)=>t===e||!(t&&!e||e&&!t)&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEqualObjectKeys:(t,e)=>{if(t===e)return!0;if(t&&!e||e&&!t)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;n<r.length;n++)if(t[r[n]]!==e[r[n]])return!1;return!0},isNode:H,isNullOrUndefined:$,isNumeric:t=>{const e=1*t;return Number.isFinite(e)&&"number"==typeof e},isObject:N,isPromiseLike:t=>!!t&&"function"==typeof t.then,isRectInsideRect:(t,e)=>t.top>=e.top&&t.bottom<=e.bottom&&t.left>=e.left&&t.right<=e.right,isRectIntersect:W,mergeContentful:(...t)=>{const e=t.length;if(e>0&&void 0!==t[e-1]&&!N(t[e-1]))return t[e-1];let r=t[0]||{};for(let n=1;n<e;n++)r=A(r,t[n]||{},{arrayMerge:(t,e)=>[...e]});return r},nextTick:t=>{typeof window<"u"&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>{t()}):("function"==typeof setImmediate?setImmediate:setTimeout)(()=>{t()})},openFileDialog:(t="*.*")=>new Promise((e,r)=>{if(!V)return void r("Unable to open dialog with no dom.");const n=document.createElement("input");n.type="file",n.accept=t;let o=null,a=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{o||a||(a=!0,e(null))},1e3)},{once:!0,passive:!0}),n.onchange=()=>{if(o=n.files[0],o){if(a)return void console.warn("File open detected after faux cancel.",o);e(o)}},n.autofocus=!0,n.click()}),rafThrottle:t=>{let e,r=!1,n=function(){r=!1,t(e)};return function(t){e=t,e&&e.persist&&e.persist(),r||(r=!0,requestAnimationFrame(n))}},removeEmptyProperties:B,removeEqualValues:q,removeListenerAll:t=>{if(!t)return[];for(let e=0;e<t.length;e++)t[e]&&t[e]();return[]},requestTimeout:(t,e)=>{const r=D(),n={id:requestAnimationFrame(function o(){D()-r>=e?t.call(null):n.id=requestAnimationFrame(o)})};return n},roundAccurately:(t,e=0)=>{if(null==t||!isFinite(t))return null;const r=10**e;return Number(Math.round(t*r)/r)},setToPath:(t,e,r)=>{const n=e.split(".");let o=t;if(!o)throw new Error("Can not set path to a null path.");for(let t=0;o&&t<n.length-1;t++){const e=n[t];let r=o[e];if(null==r&&(r={},o[e]=r),!N(r))throw new Error("Can not set path to a non object path.");o=r}if("number"!=typeof r&&"boolean"!=typeof r&&"string"!=typeof r&&!N(r))throw new Error(`Can not set path to ${r} that is not a a supported primitive.`);return o[n[n.length-1]]=r,t},splitNumber:t=>{let e=Math.abs(t);if(isNaN(e)||!isFinite(t))return null;let r=0|e,n=e-r,o=0,a=0,i=1;if(n>5e-8)for(;a<8&&Math.abs(o/i-n)>5e-8;)a++,i*=10,o=Math.round(n*i);return{ip:Math.trunc(t),fp:o,ipLength:Math.ceil(Math.log10(r+1)),fpLength:a}},subtractRect:(t,e,r=!1)=>{if(!e)return[t];if(!W(t,e))return[];const n=[];let o=t;const a=()=>{e.top>o.top&&e.top<o.bottom&&(n.push({...o,bottom:e.top}),o={...o,top:e.top})},i=()=>{e.bottom>o.top&&e.bottom<o.bottom&&(n.push({...o,top:e.bottom}),o={...o,bottom:e.bottom})},l=()=>{e.right>o.left&&e.right<o.right&&(n.push({...o,left:e.right}),o={...o,right:e.right})},s=()=>{e.left>o.left&&e.left<o.right&&(n.push({...o,right:e.left}),o={...o,left:e.left})};return r?(s(),l(),a(),i()):(a(),i(),l(),s()),n},textToKey:t=>t.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(t,e){let r=null;return(...n)=>{const o=Date.now();(!r||o-r>=e)&&(r=o,t(...n))}},toSafeJSON:function t(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof e.toJSON)return e.toJSON();if(Array.isArray(e))return e.map(e=>t(e));if("function"==typeof e.toString&&e.toString!==Object.prototype.toString)return e.toString();const r={};for(const n in e)e.hasOwnProperty(n)&&(r[n]=t(e[n]));return r},transpose:t=>{if(!t)return t;const e=t.length,r=t[0].length,n=[];for(let t=0;t<r;t++)n[t]=Array(e);for(let o=0;o<e;o++)for(let e=0;e<r;e++)n[e][o]=t[o][e];return n},uuidV4:P,validEnumValue:(t,e)=>{if(!Object.values(t).includes(e))throw new Error(`Invalid type: ${e??"null"}. Must be one of: ${Object.values(e).join(", ")}.`)},whenFocus:async(t,e=!1)=>new Promise(r=>{K(t,e)?r(!0):t.addEventListener("focusin",()=>{r(!0)},{once:!0}),t.focus()})},Symbol.toStringTag,{value:"Module"}));Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:t=>`Invalid argument: '${t}'.`},Symbol.toStringTag,{value:"Module"}));const Z=t=>{const e=new Uint8Array(t),r=e.byteLength;let n="";for(let t=0;t<r;t++)n+=String.fromCharCode(e[t]);if(typeof window<"u"&&"function"==typeof globalThis.btoa)return globalThis.btoa(n);if(typeof Buffer<"u")return Buffer.from(n,"binary").toString("base64");throw new Error("Unsupported environment")},X=t=>new Promise((e,r)=>{if(t)if(typeof FileReader<"u"){const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=()=>{r(n.error)},n.readAsText(t)}else if(typeof Buffer<"u"){const n=t=>Buffer.from(t).toString("utf-8");t.arrayBuffer().then(t=>{e(n(t))}).catch(t=>{r(t)})}else r(new Error("Unsupported environment"));else e("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:Z,base64ToArrayBuffer:t=>{const e=typeof window<"u"&&"function"==typeof globalThis.atob?globalThis.atob(t):Buffer.from(t,"base64").toString("binary"),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer},blobToString:X},Symbol.toStringTag,{value:"Module"}));const Q="data:image/png;base64,",tt="Unable to resolve image.",et=t=>new Promise(async(e,r)=>{let n=null;try{n=new Image,n.src=t,n.addEventListener("load",function(){e({width:n.naturalWidth,height:n.naturalHeight})},{once:!0}),n.addEventListener("error",function(){URL.revokeObjectURL(t),r("Invalid Image")},{once:!0}),await n.decode("sync")}catch{n?.src&&URL.revokeObjectURL(n.src)}n||r(tt)}),rt="image/svg+xml";var nt,ot;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Q,getImageDataUrl:(t,e=1)=>new Promise(async(r,n)=>{let o=null;try{o=new Image,o.src=t,o.addEventListener("load",function(){try{const t=document.createElement("canvas");t.width=o.naturalWidth,t.height=o.naturalHeight,t.getContext("2d").drawImage(o,0,0);const n=t.toDataURL("image/png",e);r({elemImg:o,dataUrl:n})}catch(e){URL.revokeObjectURL(t),n(e)}},{once:!0}),o.addEventListener("error",function(){URL.revokeObjectURL(t),n("Invalid Image")},{once:!0}),await o.decode("sync")}catch{o?.src&&URL.revokeObjectURL(o.src)}o||n(tt)}),loadImageDetails:async(t,e=null)=>{let r=null;const n=async()=>{try{const n=e??"image/*",o=URL.createObjectURL(new Blob([t],{type:n})),a=await et(o);r={mimeType:n,naturalDimensions:a,asUrl:o}}catch{}},o=async()=>{try{const n=(new TextDecoder).decode(t),o=URL.createObjectURL(new Blob([n],{type:rt})),a=await et(o);r={mimeType:e??rt,naturalDimensions:a,asUrl:o,asSVGText:n}}catch{}};if(e===rt?await o():e.startsWith("image/")?await n():(await n(),r||await o()),!r)throw new Error("Failed to load image");return r}},Symbol.toStringTag,{value:"Module"})),(ot=nt||(nt={})).resolveTypedUpdates=(t,e,r,n)=>{if(null===t)return t;if(void 0===t)return n;let o=t;if(e?.shorthand){const n=e?.shorthand(t,r);void 0!==n&&(o=n)}if(null!==o&&e?.getSubType){const t=e.getSubType(o);t&&(e=t)}const a=e?.properties,i=e?.arrayType??!1;let l=o;if(e&&e.merge&&l&&n)l=e.merge(l,n,r);else if(!i&&a){const t=Object.keys({...o,...n});l=null;for(let e=0;e<t.length;e++){const i=t[e];let s,c=o[i];if(void 0!==c){const t=a[i];s=t?(0,ot.resolveTypedUpdates)(c,t,r,n?.[i]):c}else s=n?.[i];null!=s&&(l=l??{},l[i]=s)}}return l};const at="The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",it="You do not have permissions to access the clipboard.\nAll copy and paste operations will be limited to the browser tab.",lt={Safari:"The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",Perms:it,PermsWrite:J()===G.Safari?at:it,PermsRead:J()===G.Safari?at:it},st=async()=>new Promise(t=>{document.hasFocus()?t():globalThis.addEventListener?.("focus",()=>{t()},{once:!0}),document.activeElement.focus?.()}),ct=async(t,e,r)=>{if(J()===G.Safari)return await r(new Error(lt.Safari));try{const n=async t=>{try{return await t()}catch(t){if(t.message?.includes("Document is not focused"))return!1;throw t}},o=await(globalThis?.navigator?.permissions?.query({name:t,allowWithoutGesture:!0,allowWithoutSanitization:!0}));let a=!1;if("prompt"===o.state&&(a=await n(e)),a||"granted"!==o.state||(a=await e()),!a)return await r(new Error(o.state))}catch(t){return"No valid data on clipboard"===t.message||"DataError"===t.name?void 0:await r(t)}},ut=async e=>{try{return await e.read({unsanitized:[t]})}catch{}return await e.read()};if(!globalThis.ClipboardItem){const t=(t,e)=>new Blob([e],{type:t});class e{constructor(e,r){this._items={},this._types=Object.keys(e);const n={},o=Object.keys(e);for(let r=0;r<o.length;r++){const a=o[r];let i=e[a];n[a]="string"==typeof i?t(a,i):i}this._items=n,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(t){return Promise.resolve(this._items[t])}supports(t){return!0}}globalThis.ClipboardItem=e}const dt=async(e,r=t)=>new Promise(async(t,n)=>{try{const n=await(async(t,e)=>{if(!t)return null;const r=await ut(t);let n=!1;for(let t=0;!n&&r&&t<r.length;t++)if(n=r[t].types.includes(e),n)return await r[t].getType(e);return n?void 0:null})(e,r);if(n){const e=new FileReader;e.onload=()=>{t(e.result)},e.onerror=()=>{t("")},e.readAsText(n)}else t("")}catch(t){n(t)}}),ft=async(e,r=t)=>{const n=await dt(e,r);if(!n)return null;let o=null;try{o=(new DOMParser).parseFromString(n,t)}catch{console.warn("Can't parse html from clipboard.")}return o},pt="clipboard-uuid",wt="web text/uuid",ht=t=>`<div style="display:none" ${pt}="${t}"/>`,yt=(e,r)=>{let n=null;try{const o=(new DOMParser).parseFromString(r,t);o.body.firstElementChild.setAttribute(pt,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(t){console.warn("Can't embed uuid.",t)}return n},gt=(t,e)=>{if(!e||!t)return!1;try{const r=e.querySelectorAll(`[${pt}="${t}"]`);if(r&&1===r.length)return!0;if(e.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};class bt{constructor(t){if(void 0===t?.nativeClipboard||!0===t?.nativeClipboard)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{!0===t?.nativeClipboard&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=!1===t?.nativeClipboard?null:t?.nativeClipboard;this._disableCheckOnFocus=t?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await ct("clipboard-read",async()=>{await st();const e=await dt(this._nativeClipboard,wt);if(!this._state||e&&e===this._state.uuid)return!0;const r=await ft(this._nativeClipboard,t);return!this._state||(gt(this._state.uuid,r)||this.clear(),!0)},async t=>{"denied"===t?.message||t.message?.includes("Document is not focused")||J()===G.Safari||console.warn("Unable to detect clipboard changes: ",t)})}_init(){const t=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{t._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",t._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",e=>{t._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await ct("clipboard-read",async()=>{if(await st(),this._state?.uuid){const r=await dt(this._nativeClipboard,wt);if(r&&r===e._state.uuid)return!0;const n=await ft(this._nativeClipboard,t);if(gt(e._state?.uuid,n))return!0}return e._state={items:await ut(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(t){return this._write({uuid:P(),items:t,ref:null})}async _write(n){if(!this._nativeClipboard)return this._state=n,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const o=this,a=[],i=n.uuid;let l=n.items??[];const s=()=>{o._state={uuid:i,ref:n.ref,items:a},o.dispatchEvent(new Event("clipboardwrite")),o.dispatchEvent(new Event("clipboardchange"))};await ct("clipboard-write",async()=>{await st(),i&&0===l.length&&(l.push(new ClipboardItem({[wt]:new Blob([i],{type:wt})})),l.push(new ClipboardItem({[t]:new Blob([ht(i)],{type:t})})));for(let n=0;n<Math.min(1,l.length);n++){const o=l[n];let s=o.types.indexOf(t),c=null;if(-1!==s){const e=await o.getType(t);c=await X(e),c&&(c=yt(i,c))}if(!c&&o.types.includes(e)){const t=await o.getType(e);if(t){let e=null;"string"==typeof t?(console.warn("text as string",t),e=t):e=await X(t),e&&(c=`<div ${pt}="${i}">${e}</div>`)}}if(!c&&o.types.includes(r)){const t=await o.getType(r),e=Z(await t.arrayBuffer());c=`<div ${pt}="${i}"><img src="${Q+e}"/></div>`}!c&&i&&(c=ht(i));const u=new Blob([c??""],{type:t}),d={};for(let t=0;t<o.types.length;t++){const e=o.types[t];d[e]=t===s?u:o.getType(e)}c&&-1===s&&(d[t]=u),i&&(d[wt]=new Blob([i],{type:wt})),a.push(new ClipboardItem(d))}try{a&&0!==a.length?await this._nativeClipboard.write(a):await(async t=>{t&&await t.writeText("")})(this._nativeClipboard)}catch(t){t.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",t)}return s(),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorwrite")),s()})}async writeReference(n){if(!n)return void this.clear();let o=null;const a={};try{const t=await(n.toText?.())??null;t&&(a[e]=new Blob([t??""],{type:e}))}catch(t){o=t}try{const e=await(n.toHtml?.())??null;e&&(a[t]=new Blob([e],{type:t}))}catch(t){o=t,console.warn("export to html",t)}try{const t=await(n.toImage?.())??null;t&&(a[r]=t)}catch(t){o=t,console.warn("export to png",t)}const i=this._write({uuid:P(),ref:n,items:Object.keys(a).length>0?[new ClipboardItem(a)]:null});if(o)throw o;return i}clear(t=!1){this._state&&(this._state=null,t&&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(t,r)=>{const n=await this.read();let o=null;for(let t=0;!o&&n&&t<n.length;t++)n[t].types.includes(e)&&(o=await n[t].getType(e));if(!o)return void t("");const a=new FileReader;a.onload=()=>{t(a.result)},a.readAsText(o),a.onerror=t=>{r(t)}})}async writeText(t){const r=[new ClipboardItem({[e]:new Blob([t],{type:e})})];return this._write({uuid:P(),items:r,ref:null})}addEventListener(t,e,r={}){const n=r?.capture?this._listenersCapture:this._listeners;let o=n.get(t);o||(o=new Map,n.set(t,o)),o.set(e,"boolean"==typeof r?{}:r)}dispatchEvent(t){if(!t)return;const e=e=>{const r=e.get(t.type);r&&r.forEach((e,n)=>{try{"function"==typeof n?n(t):n.handleEvent&&n.handleEvent(t),e.once&&r.delete(n)}catch(t){console.warn(t)}})};return e(this._listenersCapture),e(this._listeners),!0}removeEventListener(t,e,r){const n=r?.capture?this._listenersCapture:this._listeners,o=n.get(t);o&&(o.delete(e),0===o.size&&n.delete(t))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}}var mt;(mt=bt||(bt={})).ErrorMessages=lt,mt.Global=new mt;let Et=null,St=null,vt=null;const xt=Object.freeze({compileTypescript:async function(t){if(!t?.source)return null;if(St&&Y.deepEqual(St,t))return Et;const e=await async function(){if(vt)return vt;const{TypeScriptCompiler:t}=await import("./CoZh7nD_zQLfTNcp.mjs");return vt=new t,vt}(),r=await e.compileModule(t);return Et=r,St=t,r}}),_t=Object.freeze(Object.defineProperty({__proto__:null,ScriptingUtils:xt},Symbol.toStringTag,{value:"Module"}));export{Y as $,_t as i};