@sheetxl/sdk 0.4.9 → 0.4.11

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 (167) hide show
  1. package/browser/cjs/1aBi7EjSv7rlHImN.cjs +7 -0
  2. package/browser/cjs/2U_vaFrfcRohWzeU.cjs +7 -0
  3. package/browser/cjs/2nOrVMTAGGx_9TGL.cjs +7 -0
  4. package/browser/cjs/36TOhwWf_rpUol3H.cjs +7 -0
  5. package/browser/cjs/5zykq8Nm9_DGD2DJ.cjs +7 -0
  6. package/browser/cjs/7sNFPxy75NuqCDQh.cjs +7 -0
  7. package/browser/cjs/B73Zu8_s9vFWOh_O.cjs +7 -0
  8. package/browser/cjs/BAsFktGxZpUGmZLe.cjs +7 -0
  9. package/browser/cjs/BEsz-1T9Bb9AaMYL.cjs +7 -0
  10. package/browser/cjs/B_NhkERIkAJotIbp.cjs +7 -0
  11. package/browser/cjs/BdTk8Nhw8G_OzMbe.cjs +7 -0
  12. package/browser/cjs/Bo-zjba28_CWMlTu.cjs +7 -0
  13. package/browser/cjs/C06jNASkAfV7kAJt.cjs +7 -0
  14. package/browser/cjs/C9wOzvC_v6DonctC.cjs +7 -0
  15. package/browser/cjs/CMCnH7IuCm_auikF.cjs +7 -0
  16. package/browser/cjs/CVXGzVLWLx2CJQm9.cjs +13 -0
  17. package/browser/cjs/CaFJIY4BbuoM7WDD.cjs +7 -0
  18. package/{node/esm/CT933Kus8lsY5BJ2.mjs → browser/cjs/CcEyzUYgzJ50PUJe.cjs} +2 -5
  19. package/browser/cjs/Ch3tbUYQx16tKF7k.cjs +7 -0
  20. package/browser/cjs/Cv7d06asyk54h4qg.cjs +7 -0
  21. package/browser/cjs/DDRgvBqROJxESdD7.cjs +7 -0
  22. package/browser/cjs/DHpCAbHLYqvLP0Z6.cjs +7 -0
  23. package/browser/cjs/DNv6ybWP5Fldgc2s.cjs +7 -0
  24. package/browser/cjs/Dl3IO1DS4B5jgpKI.cjs +7 -0
  25. package/browser/cjs/DtBxSbHruNTMTsh-.cjs +10 -0
  26. package/browser/cjs/EU56rWjRMrkea9af.cjs +7 -0
  27. package/browser/cjs/Yi2_Rw5GDVzd_VxU.cjs +7 -0
  28. package/browser/cjs/ZJKVquWhB5WR-iPJ.cjs +7 -0
  29. package/browser/cjs/ZcKbNkAX98aqbRl3.cjs +7 -0
  30. package/browser/cjs/index.cjs +4 -3
  31. package/browser/cjs/kyw6u7fpNVXpqgsI.cjs +7 -0
  32. package/browser/cjs/nQY-7MdNrbTu3EmK.cjs +7 -0
  33. package/browser/cjs/trblZTDJ1nAz0rWR.cjs +7 -0
  34. package/browser/cjs/uyHKBD07R0GGZXep.cjs +10 -0
  35. package/browser/esm/1RkwhM87R80gyTMd.mjs +7 -0
  36. package/browser/esm/5w39mZuW-sWnmmdV.mjs +7 -0
  37. package/browser/esm/A8C5de6v1CBMgJZq.mjs +7 -0
  38. package/browser/esm/B9JgD2n0XcFJj3bo.mjs +7 -0
  39. package/browser/esm/BEs22-ynP5XGO3w2.mjs +7 -0
  40. package/browser/esm/BHc7eG4nZizeMBb5.mjs +7 -0
  41. package/browser/esm/BO0ncqgpx-62w_oX.mjs +7 -0
  42. package/browser/esm/BQCIUvZDEabV77HK.mjs +7 -0
  43. package/browser/esm/BVi-ZLSVMKE-zvx4.mjs +7 -0
  44. package/browser/esm/BsDRByzxyMQ1n9k6.mjs +7 -0
  45. package/browser/esm/BuUARF4geX1QlFaV.mjs +7 -0
  46. package/browser/esm/Bv47rNz3qnYylQjD.mjs +7 -0
  47. package/browser/esm/C-CL0OoNkb1zC70z.mjs +7 -0
  48. package/browser/esm/CK55N2ZgYHqyYvC2.mjs +7 -0
  49. package/browser/esm/{leTtDbQ6871lFfJe.mjs → CM_TdYA35a4ZBdwx.mjs} +2 -7
  50. package/browser/esm/COIpRrbH0PIAxGAv.mjs +7 -0
  51. package/browser/esm/CV82qaLuZfxcBBSy.mjs +10 -0
  52. package/browser/esm/CW0tmrVd5h3U4RZa.mjs +7 -0
  53. package/browser/esm/ChEVz9V1woVRX6WL.mjs +7 -0
  54. package/browser/esm/CuVRE_tWXcHiZiqD.mjs +7 -0
  55. package/browser/esm/DCgtfzoZVReua9he.mjs +7 -0
  56. package/browser/esm/DS7nkzMuzXOAIPF2.mjs +7 -0
  57. package/browser/esm/DTfK5ukJi2A2cG4a.mjs +13 -0
  58. package/browser/esm/Dk8xANVVmSj4hMfy.mjs +7 -0
  59. package/browser/esm/DkBcYI5GMfGWjMpw.mjs +7 -0
  60. package/browser/esm/DoolQNF8KdKfxJym.mjs +7 -0
  61. package/browser/esm/Du5u3LhdTaqIps_D.mjs +7 -0
  62. package/browser/esm/DyvAZkeumXN8GHi4.mjs +7 -0
  63. package/browser/esm/PVTl6mvmxvLJIzh9.mjs +7 -0
  64. package/browser/esm/Y5czqevaHtgUcl4L.mjs +7 -0
  65. package/browser/esm/iKCrpPPbOnKlkUDb.mjs +7 -0
  66. package/browser/esm/index.mjs +2 -84
  67. package/browser/esm/lfu13YaazVLqtmeU.mjs +10 -0
  68. package/browser/esm/s7QvhDE2kJkgBcZ8.mjs +7 -0
  69. package/licenses/dependencies.txt +3 -3
  70. package/node/esm/3LAM4nbl-SF93GnL.mjs +80 -0
  71. package/{browser/esm/6U_gCZNSSMBtVpQI.mjs → node/esm/BMXFtr-jXZGBZS1-.mjs} +1 -1
  72. package/node/esm/{CYI5_V7h9SYP9uuu.mjs → BmYqJNOwK3UJW3Xe.mjs} +1 -1
  73. package/node/esm/{DxQdDzIhBW98FzK0.mjs → C9U5rfU-8XoDc_V8.mjs} +4 -4
  74. package/node/esm/{BMwuCJEUqdaa7U-p.mjs → CFWQqFvDJMGXn8Qq.mjs} +1 -1
  75. package/node/esm/{De2OxC60SZUNAEyp.mjs → CFsZ2V-cxUHf5_Sy.mjs} +1 -1
  76. package/node/esm/{BIsxN-sskhnDr5fG.mjs → COCgGLfPgG-NG4Ei.mjs} +1 -1
  77. package/node/esm/{Dfr8q3AEbG7QZ6Xr.mjs → CW0oFlrKt5Uj6nuK.mjs} +1 -1
  78. package/node/esm/{CswjcUAc3OQ1SAwa.mjs → CXrQQnxTwsX0wNvN.mjs} +2 -2
  79. package/node/esm/{-vEyF-b1iAJfL3xp.mjs → CfeR1dXEw7Hep352.mjs} +1 -1
  80. package/node/esm/{Cu9r1uru0-RQmPlz.mjs → Ck1Jwm7rnsCLVeO1.mjs} +1 -1
  81. package/node/esm/{V08nP8uFHLrde5Md.mjs → Cn1RL1hYSYnF25uZ.mjs} +1 -1
  82. package/{browser/esm/P_0pzZ_mRTUIQOo8.mjs → node/esm/CnhQwEj214g59Jgw.mjs} +1 -1
  83. package/{browser/esm/CatWZ5LT2Nm4rT4U.mjs → node/esm/Cuk6l5jbAp5qG99L.mjs} +1 -1
  84. package/node/esm/{DYiuMNxXQxzsyogd.mjs → D8Hpg5A5WcmsFCPu.mjs} +1 -1
  85. package/node/esm/{bLL4P-mQqtHnzf3p.mjs → D90o-RTQ6VATF0Rk.mjs} +1 -1
  86. package/{browser/esm/CT933Kus8lsY5BJ2.mjs → node/esm/DLdBwr1RlyAhJCV0.mjs} +1 -1
  87. package/{browser/esm/225JOcHgUUs1EIBP.mjs → node/esm/DRM7eoEZII5c6Rbr.mjs} +1 -1
  88. package/{browser/esm/SwZDnMDw8b9gb6VD.mjs → node/esm/DSPiPnJGbhnNKLaY.mjs} +1 -1
  89. package/node/esm/{LpwVK3fzNuCZJlGb.mjs → DUlT61b-CgdPCdu7.mjs} +1 -1
  90. package/{browser/esm/BEWDCb-GzXXALTyM.mjs → node/esm/DWlgrg4IlFnKTR6y.mjs} +1 -1
  91. package/node/esm/{CydkHy4FDohjJzxv.mjs → DbLo1yZBy3dKaDrf.mjs} +1 -1
  92. package/node/esm/{Br12zSs0kOLavLkw.mjs → DpmEPBmhU3gneOpb.mjs} +1 -1
  93. package/{browser/esm/_N05nCCXsyDthwPS.mjs → node/esm/JIc401vM9srbtF9d.mjs} +1 -1
  94. package/node/esm/{Dtn71I8yWx6At8T4.mjs → KATYAmh0NIiQ-uaD.mjs} +1 -1
  95. package/node/esm/{DU-md5cmoqIFoIRF.mjs → QvMgUimFvzdL6-mo.mjs} +2 -2
  96. package/node/esm/{DRFDJvGYzZ2y7MNr.mjs → VINTYbFQolKKX9Cn.mjs} +1 -1
  97. package/node/esm/index.mjs +21 -16
  98. package/node/esm/{DtJRjSTG45Z8JwZ-.mjs → jqWzWUQAPXE6S4pP.mjs} +1 -1
  99. package/node/esm/{D8eFLYgEWXBVLJzP.mjs → p6tOM2g4fibuTbKy.mjs} +1 -1
  100. package/node/esm/{bz-ja27axdBXn18A.mjs → sroYp2c6WrIr_3vO.mjs} +2 -2
  101. package/node/esm/{BRW_h-uc47yzfnF7.mjs → uUNVoKRRBhW28hYx.mjs} +1 -1
  102. package/package.json +4 -4
  103. package/browser/cjs/B-re3P7cjOaJW97v.cjs +0 -6
  104. package/browser/cjs/B4xf1YLqOOQ2BAAw.cjs +0 -6
  105. package/browser/cjs/BQX47jn1fcYJXavn.cjs +0 -6
  106. package/browser/cjs/BZSt5E8X7SYSVhPs.cjs +0 -6
  107. package/browser/cjs/B_RNceQBZ8p6fj3Q.cjs +0 -6
  108. package/browser/cjs/BbwQg7G0IFkXlUYY.cjs +0 -6
  109. package/browser/cjs/BjwfHgXl1fEZAU3g.cjs +0 -60
  110. package/browser/cjs/Bm5UJ5gS-Q06VEPK.cjs +0 -7
  111. package/browser/cjs/C3td5E8SlcrJ5Mv-.cjs +0 -15
  112. package/browser/cjs/CGHOtBonLRy9pyo4.cjs +0 -6
  113. package/browser/cjs/CS2JAHasZYfPuOEI.cjs +0 -6
  114. package/browser/cjs/CSkIIY8fgAYcsfJ0.cjs +0 -6
  115. package/browser/cjs/CTM9G6roqBNmXvvV.cjs +0 -6
  116. package/browser/cjs/Cje8OteEkSLIh4eg.cjs +0 -6
  117. package/browser/cjs/CnRawGcFEjRg8E7W.cjs +0 -6
  118. package/browser/cjs/Cq-KGEktCK47S1ii.cjs +0 -6
  119. package/browser/cjs/CqczY8H5IIx8Ki4Z.cjs +0 -6
  120. package/browser/cjs/DLVyZuPozs2kGRVY.cjs +0 -6
  121. package/browser/cjs/DQtLMWxJks5D1_ut.cjs +0 -6
  122. package/browser/cjs/DSeBxJODV2wiVBFh.cjs +0 -6
  123. package/browser/cjs/DSx2MKFyVvU32PBX.cjs +0 -6
  124. package/browser/cjs/DlgBYRYQwJb2Cmz0.cjs +0 -124
  125. package/browser/cjs/DmMxyZPbvj8EvAvA.cjs +0 -6
  126. package/browser/cjs/DxXvv5mYl4GyI4oU.cjs +0 -13
  127. package/browser/cjs/K35RWj2GxR0lKfCY.cjs +0 -32
  128. package/browser/cjs/L5ui83i8s4hwRnmo.cjs +0 -6
  129. package/browser/cjs/Ntd4n6__drNXyV8Q.cjs +0 -6
  130. package/browser/cjs/OpVs8OmX1WcXQ1RU.cjs +0 -6
  131. package/browser/cjs/WZhB_pgRZi4U_oXo.cjs +0 -6
  132. package/browser/cjs/eL9bgEPz6WhChraJ.cjs +0 -6
  133. package/browser/cjs/nRRE57j_GGf6KVD8.cjs +0 -6
  134. package/browser/cjs/pPmY7gcYQCH96lE4.cjs +0 -6
  135. package/browser/cjs/xjh_alRipVqo8cZy.cjs +0 -1501
  136. package/browser/esm/-vEyF-b1iAJfL3xp.mjs +0 -10
  137. package/browser/esm/9sdhSM-1zkdTJ6pD.mjs +0 -5651
  138. package/browser/esm/B5GEE2P8-Fc2ApiM.mjs +0 -426
  139. package/browser/esm/BMWawWgFuxMRf1cM.mjs +0 -10
  140. package/browser/esm/BRW_h-uc47yzfnF7.mjs +0 -10
  141. package/browser/esm/BhPXhyivX9t4qJ2l.mjs +0 -820
  142. package/browser/esm/Br12zSs0kOLavLkw.mjs +0 -10
  143. package/browser/esm/BsN1Iav913PM0DTb.mjs +0 -21
  144. package/browser/esm/C8aGSiCyYUCLobsp.mjs +0 -10
  145. package/browser/esm/CYI5_V7h9SYP9uuu.mjs +0 -10
  146. package/browser/esm/Cu1bjUPEdAVn7e23.mjs +0 -10
  147. package/browser/esm/CydkHy4FDohjJzxv.mjs +0 -10
  148. package/browser/esm/CzRlLyr7iG0quh7r.mjs +0 -472
  149. package/browser/esm/DStq39R2rKQKUU7b.mjs +0 -24
  150. package/browser/esm/DbT42LuoRjjQ7Rtu.mjs +0 -3974
  151. package/browser/esm/DdU01D1n6S9BZnIr.mjs +0 -10
  152. package/browser/esm/De2OxC60SZUNAEyp.mjs +0 -10
  153. package/browser/esm/DtJRjSTG45Z8JwZ-.mjs +0 -10
  154. package/browser/esm/DwOgeqVyZwdrw1FB.mjs +0 -24004
  155. package/browser/esm/HTu8yzgCTwbf9HU4.mjs +0 -29
  156. package/browser/esm/LpwVK3fzNuCZJlGb.mjs +0 -10
  157. package/browser/esm/PC3F5BEQCLQN_a3x.mjs +0 -10
  158. package/browser/esm/cthDTk2_8Syhe1Uh.mjs +0 -10
  159. package/browser/esm/eYXmF3L6pehVXEBJ.mjs +0 -1575
  160. package/node/esm/225JOcHgUUs1EIBP.mjs +0 -10
  161. package/node/esm/6U_gCZNSSMBtVpQI.mjs +0 -10
  162. package/node/esm/BEWDCb-GzXXALTyM.mjs +0 -10
  163. package/node/esm/CatWZ5LT2Nm4rT4U.mjs +0 -10
  164. package/node/esm/D6NZZinV6uCFvvPK.mjs +0 -80
  165. package/node/esm/P_0pzZ_mRTUIQOo8.mjs +0 -10
  166. package/node/esm/SwZDnMDw8b9gb6VD.mjs +0 -10
  167. package/node/esm/_N05nCCXsyDthwPS.mjs +0 -10
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.11
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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./DtBxSbHruNTMTsh-.cjs");var t="object"==typeof global&&global&&global.Object===Object&&global,n="object"==typeof self&&self&&self.Object===Object&&self,r=t||n||Function("return this")(),i=r.Symbol,o=Object.prototype,s=o.hasOwnProperty,a=o.toString,c=i?i.toStringTag:void 0;var u=Object.prototype.toString;var l=i?i.toStringTag:void 0;function h(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":l&&l in Object(e)?function(e){var t=s.call(e,c),n=e[c];try{e[c]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[c]=n:delete e[c]),i}(e):function(e){return u.call(e)}(e)}function f(e){return null!=e&&"object"==typeof e}function d(e){return"symbol"==typeof e||f(e)&&"[object Symbol]"==h(e)}function p(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 m=Array.isArray,E=i?i.prototype:void 0,g=E?E.toString:void 0;function T(e){if("string"==typeof e)return e;if(m(e))return p(e,T)+"";if(d(e))return g?g.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var A=/\s/;var I=/^\s+/;function v(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&A.test(e.charAt(t)););return t}(e)+1).replace(I,""):e}function N(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var y=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,O=/^0o[0-7]+$/i,S=parseInt;var _=1/0;function L(e){return e?(e=function(e){if("number"==typeof e)return e;if(d(e))return NaN;if(N(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=N(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=v(e);var n=R.test(e);return n||O.test(e)?S(e.slice(2),n?2:8):y.test(e)?NaN:+e}(e))===_||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function x(e){var t=L(e),n=t%1;return t==t?n?t-n:t:0}function C(e){return e}function k(e){if(!N(e))return!1;var t=h(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var b,P=r["__core-js_shared__"],w=(b=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"";var M=Function.prototype.toString;function U(e){if(null!=e){try{return M.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var F=/^\[object .+?Constructor\]$/,D=Function.prototype,j=Object.prototype,B=D.toString,$=j.hasOwnProperty,W=RegExp("^"+B.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function G(e){return!(!N(e)||(t=e,w&&w in t))&&(k(e)?W:F).test(U(e));var t}function K(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return G(n)?n:void 0}var z=K(r,"WeakMap"),V=Object.create,H=function(){function e(){}return function(t){if(!N(t))return{};if(V)return V(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Y(){}var X=Date.now;var q,Z,Q,J=function(){try{var e=K(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),ee=J?function(e,t){return J(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:C,te=(q=ee,Z=0,Q=0,function(){var e=X(),t=16-(e-Q);if(Q=e,t>0){if(++Z>=800)return arguments[0]}else Z=0;return q.apply(void 0,arguments)});function ne(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function re(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 ie(e){return e!=e}function oe(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):re(e,ie,n)}function se(e,t){return!!(null==e?0:e.length)&&oe(e,t,0)>-1}var ae=/^(?:0|[1-9]\d*)$/;function ce(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&ae.test(e))&&e>-1&&e%1==0&&e<t}function ue(e,t,n){"__proto__"==t&&J?J(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function le(e,t){return e===t||e!=e&&t!=t}var he=Object.prototype.hasOwnProperty;function fe(e,t,n){var r=e[t];he.call(e,t)&&le(r,n)&&(void 0!==n||t in e)||ue(e,t,n)}function de(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?ue(n,a,c):fe(n,a,c)}return n}var pe=Math.max;function me(e,t){return te(function(e,t,n){return t=pe(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=pe(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,C),e+"")}function Ee(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function ge(e){return null!=e&&Ee(e.length)&&!k(e)}function Te(e,t,n){if(!N(n))return!1;var r=typeof t;return!!("number"==r?ge(n)&&ce(t,n.length):"string"==r&&t in n)&&le(n[t],e)}var Ae=Object.prototype;function Ie(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ae)}function ve(e){return f(e)&&"[object Arguments]"==h(e)}var Ne=Object.prototype,ye=Ne.hasOwnProperty,Re=Ne.propertyIsEnumerable,Oe=ve(function(){return arguments}())?ve:function(e){return f(e)&&ye.call(e,"callee")&&!Re.call(e,"callee")};var Se="object"==typeof exports&&exports&&!exports.nodeType&&exports,_e=Se&&"object"==typeof module&&module&&!module.nodeType&&module,Le=_e&&_e.exports===Se?r.Buffer:void 0,xe=(Le?Le.isBuffer:void 0)||function(){return!1},Ce={};function ke(e){return function(t){return e(t)}}Ce["[object Float32Array]"]=Ce["[object Float64Array]"]=Ce["[object Int8Array]"]=Ce["[object Int16Array]"]=Ce["[object Int32Array]"]=Ce["[object Uint8Array]"]=Ce["[object Uint8ClampedArray]"]=Ce["[object Uint16Array]"]=Ce["[object Uint32Array]"]=!0,Ce["[object Arguments]"]=Ce["[object Array]"]=Ce["[object ArrayBuffer]"]=Ce["[object Boolean]"]=Ce["[object DataView]"]=Ce["[object Date]"]=Ce["[object Error]"]=Ce["[object Function]"]=Ce["[object Map]"]=Ce["[object Number]"]=Ce["[object Object]"]=Ce["[object RegExp]"]=Ce["[object Set]"]=Ce["[object String]"]=Ce["[object WeakMap]"]=!1;var be="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pe=be&&"object"==typeof module&&module&&!module.nodeType&&module,we=Pe&&Pe.exports===be&&t.process,Me=function(){try{var e=Pe&&Pe.require&&Pe.require("util").types;return e||we&&we.binding&&we.binding("util")}catch(e){}}(),Ue=Me&&Me.isTypedArray,Fe=Ue?ke(Ue):function(e){return f(e)&&Ee(e.length)&&!!Ce[h(e)]},De=Object.prototype.hasOwnProperty;function je(e,t){var n=m(e),r=!n&&Oe(e),i=!n&&!r&&xe(e),o=!n&&!r&&!i&&Fe(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&&!De.call(e,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ce(u,c))||a.push(u);return a}function Be(e,t){return function(n){return e(t(n))}}var $e=Be(Object.keys,Object),We=Object.prototype.hasOwnProperty;function Ge(e){if(!Ie(e))return $e(e);var t=[];for(var n in Object(e))We.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Ke(e){return ge(e)?je(e):Ge(e)}var ze,Ve=Object.prototype.hasOwnProperty,He=(ze=function(e,t){if(Ie(t)||ge(t))de(t,Ke(t),e);else for(var n in t)Ve.call(t,n)&&fe(e,n,t[n])},me(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=ze.length>3&&"function"==typeof i?(r--,i):void 0,o&&Te(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var s=t[n];s&&ze(e,s,n,i)}return e}));var Ye=Object.prototype.hasOwnProperty;function Xe(e){if(!N(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=Ie(e),n=[];for(var r in e)("constructor"!=r||!t&&Ye.call(e,r))&&n.push(r);return n}function qe(e){return ge(e)?je(e,!0):Xe(e)}var Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qe=/^\w*$/;function Je(e,t){if(m(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!d(e))||(Qe.test(e)||!Ze.test(e)||null!=t&&e in Object(t))}var et=K(Object,"create");var tt=Object.prototype.hasOwnProperty;var nt=Object.prototype.hasOwnProperty;function rt(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 it(e,t){for(var n=e.length;n--;)if(le(e[n][0],t))return n;return-1}rt.prototype.clear=function(){this.__data__=et?et(null):{},this.size=0},rt.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},rt.prototype.get=function(e){var t=this.__data__;if(et){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return tt.call(t,e)?t[e]:void 0},rt.prototype.has=function(e){var t=this.__data__;return et?void 0!==t[e]:nt.call(t,e)},rt.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=et&&void 0===t?"__lodash_hash_undefined__":t,this};var ot=Array.prototype.splice;function st(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])}}st.prototype.clear=function(){this.__data__=[],this.size=0},st.prototype.delete=function(e){var t=this.__data__,n=it(t,e);return!(n<0)&&(n==t.length-1?t.pop():ot.call(t,n,1),--this.size,!0)},st.prototype.get=function(e){var t=this.__data__,n=it(t,e);return n<0?void 0:t[n][1]},st.prototype.has=function(e){return it(this.__data__,e)>-1},st.prototype.set=function(e,t){var n=this.__data__,r=it(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var at=K(r,"Map");function ct(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 ut(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])}}ut.prototype.clear=function(){this.size=0,this.__data__={hash:new rt,map:new(at||st),string:new rt}},ut.prototype.delete=function(e){var t=ct(this,e).delete(e);return this.size-=t?1:0,t},ut.prototype.get=function(e){return ct(this,e).get(e)},ut.prototype.has=function(e){return ct(this,e).has(e)},ut.prototype.set=function(e,t){var n=ct(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function lt(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(lt.Cache||ut),n}lt.Cache=ut;var ht=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ft=/\\(\\)?/g,dt=function(e){var t=lt(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(ht,function(e,n,r,i){t.push(r?i.replace(ft,"$1"):n||e)}),t});function pt(e,t){return m(e)?e:Je(e,t)?[e]:dt(function(e){return null==e?"":T(e)}(e))}function mt(e){if("string"==typeof e||d(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Et(e,t){for(var n=0,r=(t=pt(t,e)).length;null!=e&&n<r;)e=e[mt(t[n++])];return n&&n==r?e:void 0}function gt(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Tt=i?i.isConcatSpreadable:void 0;function At(e){return m(e)||Oe(e)||!!(Tt&&e&&e[Tt])}function It(e,t,n,r,i){var o=-1,s=e.length;for(n||(n=At),i||(i=[]);++o<s;){var a=e[o];n(a)?gt(i,a):r||(i[i.length]=a)}return i}function vt(e){return(null==e?0:e.length)?It(e):[]}var Nt=Be(Object.getPrototypeOf,Object);function yt(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 Rt(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 Ot(e){var t=this.__data__=new st(e);this.size=t.size}Ot.prototype.clear=function(){this.__data__=new st,this.size=0},Ot.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Ot.prototype.get=function(e){return this.__data__.get(e)},Ot.prototype.has=function(e){return this.__data__.has(e)},Ot.prototype.set=function(e,t){var n=this.__data__;if(n instanceof st){var r=n.__data__;if(!at||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ut(r)}return n.set(e,t),this.size=n.size,this};var St="object"==typeof exports&&exports&&!exports.nodeType&&exports,_t=St&&"object"==typeof module&&module&&!module.nodeType&&module,Lt=_t&&_t.exports===St?r.Buffer:void 0,xt=Lt?Lt.allocUnsafe:void 0;function Ct(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 bt=Object.prototype.propertyIsEnumerable,Pt=Object.getOwnPropertySymbols,wt=Pt?function(e){return null==e?[]:(e=Object(e),Ct(Pt(e),function(t){return bt.call(e,t)}))}:kt;var Mt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)gt(t,wt(e)),e=Nt(e);return t}:kt;function Ut(e,t,n){var r=t(e);return m(e)?r:gt(r,n(e))}function Ft(e){return Ut(e,Ke,wt)}var Dt=K(r,"DataView"),jt=K(r,"Promise"),Bt=K(r,"Set"),$t="[object Map]",Wt="[object Promise]",Gt="[object Set]",Kt="[object WeakMap]",zt="[object DataView]",Vt=U(Dt),Ht=U(at),Yt=U(jt),Xt=U(Bt),qt=U(z),Zt=h;(Dt&&Zt(new Dt(new ArrayBuffer(1)))!=zt||at&&Zt(new at)!=$t||jt&&Zt(jt.resolve())!=Wt||Bt&&Zt(new Bt)!=Gt||z&&Zt(new z)!=Kt)&&(Zt=function(e){var t=h(e),n="[object Object]"==t?e.constructor:void 0,r=n?U(n):"";if(r)switch(r){case Vt:return zt;case Ht:return $t;case Yt:return Wt;case Xt:return Gt;case qt:return Kt}return t});var Qt=Object.prototype.hasOwnProperty;var Jt=r.Uint8Array;var en=/\w*$/;var tn=i?i.prototype:void 0,nn=tn?tn.valueOf:void 0;function rn(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 Jt(a).set(new Jt(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,en.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return r=e,nn?Object(nn.call(r)):{}}}var on=Me&&Me.isMap,sn=on?ke(on):function(e){return f(e)&&"[object Map]"==Zt(e)};var an=Me&&Me.isSet,cn=an?ke(an):function(e){return f(e)&&"[object Set]"==Zt(e)},un="[object Arguments]",ln="[object Function]",hn="[object Object]",fn={};function dn(e,t,n,r,i,o){var s;if(void 0!==s)return s;if(!N(e))return e;var a=m(e);if(a)return s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Qt.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=Zt(e),u=c==ln||"[object GeneratorFunction]"==c;if(xe(e))return function(e){var t=e.length,n=xt?xt(t):new e.constructor(t);return e.copy(n),n}(e);if(c==hn||c==un||u&&!i)return s=u?{}:function(e){return"function"!=typeof e.constructor||Ie(e)?{}:H(Nt(e))}(e),function(e,t){return de(e,wt(e),t)}(e,function(e,t){return e&&de(t,Ke(t),e)}(s,e));if(!fn[c])return i?e:{};s=rn(e,c),o||(o=new Ot);var l=o.get(e);if(l)return l;o.set(e,s),cn(e)?e.forEach(function(r){s.add(dn(r,t,n,r,e,o))}):sn(e)&&e.forEach(function(r,i){s.set(i,dn(r,t,n,i,e,o))});var h=a?void 0:Ft(e);return ne(h||e,function(r,i){h&&(r=e[i=r]),fe(s,i,dn(r,t,n,i,e,o))}),s}fn[un]=fn["[object Array]"]=fn["[object ArrayBuffer]"]=fn["[object DataView]"]=fn["[object Boolean]"]=fn["[object Date]"]=fn["[object Float32Array]"]=fn["[object Float64Array]"]=fn["[object Int8Array]"]=fn["[object Int16Array]"]=fn["[object Int32Array]"]=fn["[object Map]"]=fn["[object Number]"]=fn[hn]=fn["[object RegExp]"]=fn["[object Set]"]=fn["[object String]"]=fn["[object Symbol]"]=fn["[object Uint8Array]"]=fn["[object Uint8ClampedArray]"]=fn["[object Uint16Array]"]=fn["[object Uint32Array]"]=!0,fn["[object Error]"]=fn[ln]=fn["[object WeakMap]"]=!1;function pn(e){return dn(e,4)}function mn(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 En(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new ut;++t<n;)this.add(e[t])}function gn(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 Tn(e,t){return e.has(t)}En.prototype.add=En.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},En.prototype.has=function(e){return this.__data__.has(e)};function An(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 En: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(!gn(t,function(e,t){if(!Tn(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 In(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function vn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Nn=i?i.prototype:void 0,yn=Nn?Nn.valueOf:void 0;var Rn=Object.prototype.hasOwnProperty;var On="[object Arguments]",Sn="[object Array]",_n="[object Object]",Ln=Object.prototype.hasOwnProperty;function xn(e,t,n,r,i,o){var s=m(e),a=m(t),c=s?Sn:Zt(e),u=a?Sn:Zt(t),l=(c=c==On?_n:c)==_n,h=(u=u==On?_n:u)==_n,f=c==u;if(f&&xe(e)){if(!xe(t))return!1;s=!0,l=!1}if(f&&!l)return o||(o=new Ot),s||Fe(e)?An(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 Jt(e),new Jt(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return le(+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=In;case"[object Set]":var c=1&r;if(a||(a=vn),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=An(a(e),a(t),r,i,o,s);return s.delete(e),l;case"[object Symbol]":if(yn)return yn.call(e)==yn.call(t)}return!1}(e,t,c,n,r,i,o);if(!(1&n)){var d=l&&Ln.call(e,"__wrapped__"),p=h&&Ln.call(t,"__wrapped__");if(d||p){var E=d?e.value():e,g=p?t.value():t;return o||(o=new Ot),i(E,g,n,r,o)}}return!!f&&(o||(o=new Ot),function(e,t,n,r,i,o){var s=1&n,a=Ft(e),c=a.length;if(c!=Ft(t).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in t:Rn.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 Cn(e,t,n,r,i){return e===t||(null==e||null==t||!f(e)&&!f(t)?e!=e&&t!=t:xn(e,t,n,r,Cn,i))}function kn(e){return e==e&&!N(e)}function bn(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function Pn(e){var t=function(e){for(var t=Ke(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]?bn(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(!Cn(u,c,3,r,new Ot))return!1}return!0}(n,0,t)}}function wn(e,t){return null!=e&&t in Object(e)}function Mn(e,t,n){for(var r=-1,i=(t=pt(t,e)).length,o=!1;++r<i;){var s=mt(t[r]);if(!(o=null!=e&&n(e,s)))break;e=e[s]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&Ee(i)&&ce(s,i)&&(m(e)||Oe(e))}function Un(e,t){return Je(e)&&kn(t)?bn(mt(e),t):function(n){var r=function(e,t,n){var r=null==e?void 0:Et(e,t);return void 0===r?n:r}(n,e);return void 0===r&&r===t?function(e,t){return null!=e&&Mn(e,t,wn)}(n,e):Cn(t,r,3)}}function Fn(e){return Je(e)?(t=mt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Et(t,e)}}(e);var t}function Dn(e){return"function"==typeof e?e:null==e?C:"object"==typeof e?m(e)?Un(e[0],e[1]):Pn(e):Fn(e)}function jn(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 Bn=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 $n,Wn=($n=function(e,t){return e&&Bn(e,t,Ke)},function(e,t){if(null==e)return e;if(!ge(e))return $n(e,t);for(var n=e.length,r=-1,i=Object(e);++r<n&&!1!==t(i[r],r,i););return e});function Gn(e,t,n,r){return Wn(e,function(e,i,o){t(r,e,n(e),o)}),r}var Kn=Object.prototype,zn=Kn.hasOwnProperty,Vn=me(function(e,t){e=Object(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&Te(t[0],t[1],i)&&(r=1);++n<r;)for(var o=t[n],s=qe(o),a=-1,c=s.length;++a<c;){var u=s[a],l=e[u];(void 0===l||le(l,Kn[u])&&!zn.call(e,u))&&(e[u]=o[u])}return e});function Hn(e){return f(e)&&ge(e)}var Yn=me(function(e,t){return Hn(e)?function(e,t,n,r){var i=-1,o=se,s=!0,a=e.length,c=[],u=t.length;if(!a)return c;t.length>=200&&(o=Tn,s=!1,t=new En(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,It(t,0,Hn,!0)):[]});function Xn(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function qn(e,t,n){var r=null==e?0:e.length;return r?yt(e,(t=void 0===t?1:x(t))<0?0:t,r):[]}function Zn(e,t,n){var r=null==e?0:e.length;return r?yt(e,0,(t=r-(t=void 0===t?1:x(t)))<0?0:t):[]}function Qn(e,t){var n;return(m(e)?ne:Wn)(e,"function"==typeof(n=t)?n:C)}function Jn(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 er(e,t){var n=!0;return Wn(e,function(e,r,i){return n=!!t(e,r,i)}),n}function tr(e,t,n){return(m(e)?Jn:er)(e,Dn(t))}function nr(e,t){var n=[];return Wn(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function rr(e,t){return(m(e)?Ct:nr)(e,Dn(t))}var ir=Math.max;var or,sr=(or=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:x(n);return i<0&&(i=ir(r+i,0)),re(e,Dn(t),i)},function(e,t,n){var r=Object(e);if(!ge(e)){var i=Dn(t);e=Ke(e),t=function(e){return i(r[e],e,r)}}var o=or(e,t,n);return o>-1?r[i?e[o]:o]:void 0});function ar(e){return e&&e.length?e[0]:void 0}function cr(e,t){var n=-1,r=ge(e)?Array(e.length):[];return Wn(e,function(e,i,o){r[++n]=t(e,i,o)}),r}function ur(e,t){return(m(e)?p:cr)(e,Dn(t))}function lr(e,t){return It(ur(e,t))}var hr,fr,dr=Object.prototype.hasOwnProperty,pr=(hr=function(e,t,n){dr.call(e,n)?e[n].push(t):ue(e,n,[t])},function(e,t){var n=m(e)?jn:Gn,r=fr?fr():{};return n(e,hr,Dn(t),r)}),mr=Object.prototype.hasOwnProperty;function Er(e,t){return null!=e&&mr.call(e,t)}function gr(e,t){return null!=e&&Mn(e,t,Er)}function Tr(e){return"string"==typeof e||!m(e)&&f(e)&&"[object String]"==h(e)}function Ar(e){return null==e?[]:function(e,t){return p(t,function(t){return e[t]})}(e,Ke(e))}var Ir=Math.max;function vr(e,t,n,r){e=ge(e)?e:Ar(e),n=n?x(n):0;var i=e.length;return n<0&&(n=Ir(i+n,0)),Tr(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&oe(e,t,n)>-1}function Nr(e,t,n){if(!(null==e?0:e.length))return-1;return oe(e,t,0)}var yr=Object.prototype.hasOwnProperty;function Rr(e){if(null==e)return!0;if(ge(e)&&(m(e)||"string"==typeof e||"function"==typeof e.splice||xe(e)||Fe(e)||Oe(e)))return!e.length;var t=Zt(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(Ie(e))return!Ge(e).length;for(var n in e)if(yr.call(e,n))return!1;return!0}var Or=Me&&Me.isRegExp,Sr=Or?ke(Or):function(e){return f(e)&&"[object RegExp]"==h(e)};function _r(e){return void 0===e}function Lr(e,t,n,r){if(!N(e))return e;for(var i=-1,o=(t=pt(t,e)).length,s=o-1,a=e;null!=a&&++i<o;){var c=mt(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=N(l)?l:ce(t[i+1])?[]:{})}fe(a,c,u),a=a[c]}return e}function xr(e,t){if(null==e)return{};var n=p(function(e){return Ut(e,qe,Mt)}(e),function(e){return[e]});return t=Dn(t),function(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],a=Et(e,s);n(a,s)&&Lr(o,pt(s,e),a)}return o}(e,n,function(e,n){return t(e,n[0])})}function Cr(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=m(e)?Rt:Cr,i=arguments.length<3;return r(e,Dn(t),n,i,Wn)}function br(e,t){return(m(e)?Ct:nr)(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)}}(Dn(t)))}function Pr(e,t){var n;return Wn(e,function(e,r,i){return!(n=t(e,r,i))}),!!n}function wr(e,t,n){return(m(e)?gn:Pr)(e,Dn(t))}var Mr=Bt&&1/vn(new Bt([,-0]))[1]==1/0?function(e){return new Bt(e)}:Y;function Ur(e){return e&&e.length?function(e,t,n){var r=-1,i=se,o=e.length,s=!0,a=[],c=a;if(o>=200){var u=Mr(e);if(u)return vn(u);s=!1,i=Tn,c=new En}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 Fr(e){console&&console.error&&console.error(`Error: ${e}`)}function Dr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function jr(e){const t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}}function Br(e){function t(){}t.prototype=e;const n=new t;function r(){return typeof n.bar}return r(),r(),e}function $r(e){return Tr((t=e).LABEL)&&""!==t.LABEL?e.LABEL:e.name;var t}class Wr{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),Qn(this.definition,t=>{t.accept(e)})}}class Gr extends Wr{constructor(e){super([]),this.idx=1,He(this,xr(e,e=>void 0!==e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class Kr extends Wr{constructor(e){super(e.definition),this.orgText="",He(this,xr(e,e=>void 0!==e))}}class zr extends Wr{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,He(this,xr(e,e=>void 0!==e))}}class Vr extends Wr{constructor(e){super(e.definition),this.idx=1,He(this,xr(e,e=>void 0!==e))}}class Hr extends Wr{constructor(e){super(e.definition),this.idx=1,He(this,xr(e,e=>void 0!==e))}}class Yr extends Wr{constructor(e){super(e.definition),this.idx=1,He(this,xr(e,e=>void 0!==e))}}class Xr extends Wr{constructor(e){super(e.definition),this.idx=1,He(this,xr(e,e=>void 0!==e))}}class qr extends Wr{constructor(e){super(e.definition),this.idx=1,He(this,xr(e,e=>void 0!==e))}}class Zr extends Wr{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,He(this,xr(e,e=>void 0!==e))}}class Qr{constructor(e){this.idx=1,He(this,xr(e,e=>void 0!==e))}accept(e){e.visit(this)}}function Jr(e){function t(e){return ur(e,Jr)}if(e instanceof Gr){const t={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Tr(e.label)&&(t.label=e.label),t}if(e instanceof zr)return{type:"Alternative",definition:t(e.definition)};if(e instanceof Vr)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof Hr)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Yr)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Jr(new Qr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof qr)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Jr(new Qr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof Xr)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof Zr)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof Qr){const t={type:"Terminal",name:e.terminalType.name,label:$r(e.terminalType),idx:e.idx};Tr(e.label)&&(t.terminalLabel=e.label);const n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=Sr(n)?n.source:n),t}if(e instanceof Kr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}class ei{visit(e){const t=e;switch(t.constructor){case Gr:return this.visitNonTerminal(t);case zr:return this.visitAlternative(t);case Vr:return this.visitOption(t);case Hr:return this.visitRepetitionMandatory(t);case Yr:return this.visitRepetitionMandatoryWithSeparator(t);case qr:return this.visitRepetitionWithSeparator(t);case Xr:return this.visitRepetition(t);case Zr:return this.visitAlternation(t);case Qr:return this.visitTerminal(t);case Kr: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 ti(e,t=[]){return!!(e instanceof Vr||e instanceof Xr||e instanceof qr)||(e instanceof Zr?wr(e.definition,e=>ti(e,t)):!(e instanceof Gr&&vr(t,e))&&(e instanceof Wr&&(e instanceof Gr&&t.push(e),tr(e.definition,e=>ti(e,t)))))}function ni(e){if(e instanceof Gr)return"SUBRULE";if(e instanceof Vr)return"OPTION";if(e instanceof Zr)return"OR";if(e instanceof Hr)return"AT_LEAST_ONE";if(e instanceof Yr)return"AT_LEAST_ONE_SEP";if(e instanceof qr)return"MANY_SEP";if(e instanceof Xr)return"MANY";if(e instanceof Qr)return"CONSUME";throw Error("non exhaustive match")}class ri{walk(e,t=[]){Qn(e.definition,(n,r)=>{const i=qn(e.definition,r+1);if(n instanceof Gr)this.walkProdRef(n,i,t);else if(n instanceof Qr)this.walkTerminal(n,i,t);else if(n instanceof zr)this.walkFlat(n,i,t);else if(n instanceof Vr)this.walkOption(n,i,t);else if(n instanceof Hr)this.walkAtLeastOne(n,i,t);else if(n instanceof Yr)this.walkAtLeastOneSep(n,i,t);else if(n instanceof qr)this.walkManySep(n,i,t);else if(n instanceof Xr)this.walkMany(n,i,t);else{if(!(n instanceof Zr))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 Vr({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){const r=ii(e,t,n);this.walk(e,r)}walkMany(e,t,n){const r=[new Vr({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){const r=ii(e,t,n);this.walk(e,r)}walkOr(e,t,n){const r=t.concat(n);Qn(e.definition,e=>{const t=new zr({definition:[e]});this.walk(t,r)})}}function ii(e,t,n){return[new Vr({definition:[new Qr({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function oi(e){if(e instanceof Gr)return oi(e.referencedRule);if(e instanceof Qr)return[e.terminalType];if(function(e){return e instanceof zr||e instanceof Vr||e instanceof Xr||e instanceof Hr||e instanceof Yr||e instanceof qr||e instanceof Qr||e instanceof Kr}(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=ti(r),t=t.concat(oi(r)),i+=1,o=n.length>i;return Ur(t)}(e);if(function(e){return e instanceof Zr}(e))return function(e){const t=ur(e.definition,e=>oi(e));return Ur(vt(t))}(e);throw Error("non exhaustive match")}const si="_~IN~_";class ai extends ri{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+si+this.topProd.name);var i,o;const s=t.concat(n),a=oi(new zr({definition:s}));this.follows[r]=a}}function ci(e){return e.charCodeAt(0)}function ui(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function li(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function hi(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function fi(e){return"Character"===e.type}const di=[];for(let e=ci("0");e<=ci("9");e++)di.push(e);const pi=[ci("_")].concat(di);for(let e=ci("a");e<=ci("z");e++)pi.push(e);for(let e=ci("A");e<=ci("Z");e++)pi.push(e);const mi=[ci(" "),ci("\f"),ci("\n"),ci("\r"),ci("\t"),ci("\v"),ci("\t"),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci(" "),ci("\u2028"),ci("\u2029"),ci(" "),ci(" "),ci(" "),ci("\ufeff")],Ei=/[0-9a-fA-F]/,gi=/[0-9]/,Ti=/[1-9]/;class Ai{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 Ii={};const vi=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":li(n,"global");break;case"i":li(n,"ignoreCase");break;case"m":li(n,"multiLine");break;case"u":li(n,"unicode");break;case"y":li(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"}hi(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;hi(t)}if(!0!==e||void 0!==t)return hi(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()),hi(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[ci("\n"),ci("\r"),ci("\u2028"),ci("\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=di;break;case"D":e=di,t=!0;break;case"s":e=mi;break;case"S":e=mi,t=!0;break;case"w":e=pi;break;case"W":e=pi,t=!0}if(hi(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=ci("\f");break;case"n":e=ci("\n");break;case"r":e=ci("\r");break;case"t":e=ci("\t");break;case"v":e=ci("\v")}if(hi(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:ci("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:ci(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:ci(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,fi(t)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,fi(n)){if(n.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:n.value})}else ui(t.value,e),e.push(ci("-")),ui(n.value,e)}else ui(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:ci("\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===Ti.test(e))throw Error("Expecting a positive integer");for(;gi.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===gi.test(e))throw Error("Expecting an integer");for(;gi.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:ci(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 gi.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===Ei.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 Ni(e){const t=e.toString();if(Ii.hasOwnProperty(t))return Ii[t];{const e=vi.pattern(t);return Ii[t]=e,e}}const yi="Complement Sets are not supported for first char optimization",Ri='Unable to use "first char" lexer optimizations:\n';function Oi(e,t=!1){try{const t=Ni(e);return Si(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===yi)t&&Dr(`${Ri}\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."),Fr(`${Ri}\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 Si(e,t,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)Si(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":_i(o.value,t,n);break;case"Set":if(!0===o.complement)throw Error(yi);Qn(o.value,e=>{if("number"==typeof e)_i(e,t,n);else{const r=e;if(!0===n)for(let e=r.from;e<=r.to;e++)_i(e,t,n);else{for(let e=r.from;e<=r.to&&e<Xi;e++)_i(e,t,n);if(r.to>=Xi){const e=r.from>=Xi?r.from:Xi,n=r.to,i=Zi(e),o=Zi(n);for(let e=i;e<=o;e++)t[e]=e}}}});break;case"Group":Si(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===xi(o)||"Group"!==o.type&&!1===s)break}break;default:throw Error("non exhaustive match!")}return Ar(t)}function _i(e,t,n){const r=Zi(e);t[r]=r,!0===n&&function(e,t){const n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){const e=Zi(r.charCodeAt(0));t[e]=e}else{const e=n.toLowerCase();if(e!==n){const n=Zi(e.charCodeAt(0));t[n]=n}}}(e,t)}function Li(e,t){return sr(e.value,e=>{if("number"==typeof e)return vr(t,e);{const n=e;return void 0!==sr(t,e=>n.from<=e&&e<=n.to)}})}function xi(e){const t=e.quantifier;return!(!t||0!==t.atLeast)||!!e.value&&(m(e.value)?tr(e.value,xi):xi(e.value))}class Ci extends Ai{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){vr(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===Li(e,this.targetCharCodes)&&(this.found=!0):void 0!==Li(e,this.targetCharCodes)&&(this.found=!0)}}function ki(e,t){if(t instanceof RegExp){const n=Ni(t),r=new Ci(e);return r.visit(n),r.found}return void 0!==sr(t,t=>vr(e,t.charCodeAt(0)))}const bi="PATTERN",Pi="defaultMode",wi="modes";let Mi="boolean"==typeof new RegExp("(?:)").sticky;function Ui(e,t){const n=(t=Vn(t,{useSticky:Mi,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",()=>{!function(){if(Rr(qi)){qi=new Array(65536);for(let e=0;e<65536;e++)qi[e]=e>255?255+~~(e/255):e}}()}),n("Reject Lexer.NA",()=>{r=br(e,e=>e[bi]===lo.NA)});let i,o,s,a,c,u,l,h,f,d,p,E=!1;n("Transform Patterns",()=>{E=!1,i=ur(r,e=>{const n=e[bi];if(Sr(n)){const e=n.source;return 1!==e.length||"^"===e||"$"===e||"."===e||n.ignoreCase?2!==e.length||"\\"!==e[0]||vr(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?t.useSticky?$i(n):Bi(n):e[1]:e}if(k(n))return E=!0,{exec:n};if("object"==typeof n)return E=!0,n;if("string"==typeof n){if(1===n.length)return n;{const e=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=new RegExp(e);return t.useSticky?$i(r):Bi(r)}}throw Error("non exhaustive match")})}),n("misc mapping",()=>{o=ur(r,e=>e.tokenTypeIdx),s=ur(r,e=>{const t=e.GROUP;if(t!==lo.SKIPPED){if(Tr(t))return t;if(_r(t))return!1;throw Error("non exhaustive match")}}),a=ur(r,e=>{const t=e.LONGER_ALT;if(t){return m(t)?ur(t,e=>Nr(r,e)):[Nr(r,t)]}}),c=ur(r,e=>e.PUSH_MODE),u=ur(r,e=>gr(e,"POP_MODE"))}),n("Line Terminator Handling",()=>{const e=Hi(t.lineTerminatorCharacters);l=ur(r,e=>!1),"onlyOffset"!==t.positionTracking&&(l=ur(r,t=>gr(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===Vi(t,e)&&ki(e,t.PATTERN)))}),n("Misc Mapping #2",()=>{h=ur(r,Gi),f=ur(i,Ki),d=kr(r,(e,t)=>{const n=t.GROUP;return Tr(n)&&n!==lo.SKIPPED&&(e[n]=[]),e},{}),p=ur(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 g=!0,T=[];return t.safeMode||n("First Char Optimization",()=>{T=kr(r,(e,n,r)=>{if("string"==typeof n.PATTERN){const t=Zi(n.PATTERN.charCodeAt(0));Yi(e,t,p[r])}else if(m(n.START_CHARS_HINT)){let t;Qn(n.START_CHARS_HINT,n=>{const i=Zi("string"==typeof n?n.charCodeAt(0):n);t!==i&&(t=i,Yi(e,i,p[r]))})}else if(Sr(n.PATTERN))if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&Fr(`${Ri}\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=Oi(n.PATTERN,t.ensureOptimizations);Rr(i)&&(g=!1),Qn(i,t=>{Yi(e,t,p[r])})}else t.ensureOptimizations&&Fr(`${Ri}\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`),g=!1;return e},[])}),{emptyGroups:d,patternIdxToConfig:p,charCodeToPatternIdxToConfig:T,hasCustom:E,canBeOptimized:g}}function Fi(e,t){let n=[];const r=function(e){const t=rr(e,e=>!gr(e,bi)),n=ur(t,e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:co.MISSING_PATTERN,tokenTypes:[e]})),r=Yn(e,t);return{errors:n,valid:r}}(e);n=n.concat(r.errors);const i=function(e){const t=rr(e,e=>{const t=e[bi];return!(Sr(t)||k(t)||gr(t,"exec")||Tr(t))}),n=ur(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:co.INVALID_PATTERN,tokenTypes:[e]})),r=Yn(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=rr(e,e=>Sr(e[bi]));return t=t.concat(function(e){class t extends Ai{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}const n=rr(e,e=>{const n=e.PATTERN;try{const e=Ni(n),r=new t;return r.visit(e),r.found}catch(e){return Di.test(n.source)}}),r=ur(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:co.EOI_ANCHOR_FOUND,tokenTypes:[e]}));return r}(n)),t=t.concat(function(e){class t extends Ai{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}const n=rr(e,e=>{const n=e.PATTERN;try{const e=Ni(n),r=new t;return r.visit(e),r.found}catch(e){return ji.test(n.source)}}),r=ur(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:co.SOI_ANCHOR_FOUND,tokenTypes:[e]}));return r}(n)),t=t.concat(function(e){const t=rr(e,e=>{const t=e[bi];return t instanceof RegExp&&(t.multiline||t.global)}),n=ur(t,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:co.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}));return n}(n)),t=t.concat(function(e){const t=[];let n=ur(e,n=>kr(e,(e,r)=>(n.PATTERN.source!==r.PATTERN.source||vr(t,r)||r.PATTERN===lo.NA||(t.push(r),e.push(r)),e),[]));n=mn(n);const r=ur(rr(n,e=>e.length>1),e=>{const t=ur(e,e=>e.name);return{message:`The same RegExp pattern ->${ar(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:co.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}});return r}(n)),t=t.concat(function(e){const t=rr(e,e=>e.PATTERN.test("")),n=ur(t,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:co.EMPTY_MATCH_PATTERN,tokenTypes:[e]}));return n}(n)),t}(o)),n=n.concat(function(e){const t=rr(e,e=>{if(!gr(e,"GROUP"))return!1;const t=e.GROUP;return t!==lo.SKIPPED&&t!==lo.NA&&!Tr(t)}),n=ur(t,e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:co.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}));return n}(o)),n=n.concat(function(e,t){const n=rr(e,e=>void 0!==e.PUSH_MODE&&!vr(t,e.PUSH_MODE)),r=ur(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:co.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===lo.NA||(Tr(r)?e.push({str:r,idx:n,tokenType:t}):Sr(r)&&(i=r,void 0===sr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],e=>-1!==i.source.indexOf(e)))&&e.push({str:r.source,idx:n,tokenType:t})),e;var i},[]);return Qn(e,(e,r)=>{Qn(n,({str:n,idx:i,tokenType:o})=>{if(r<i&&function(e,t){if(Sr(t)){const n=t.exec(e);return null!==n&&0===n.index}if(k(t))return t(e,0,[],{});if(gr(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:co.UNREACHABLE_PATTERN,tokenTypes:[e,o]})}})}),t}(o)),n}const Di=/[^\\][$]/;const ji=/[^\\[][\^]|^\^/;function Bi(e){const t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function $i(e){const t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function Wi(e,t,n){const r=[];let i=!1;const o=br(mn(vt(Ar(e.modes))),e=>e[bi]===lo.NA),s=Hi(n);return t&&Qn(o,e=>{const t=Vi(e,s);if(!1!==t){const n=function(e,t){if(t.issue===co.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===co.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 gr(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:co.NO_LINE_BREAKS_FLAGS}),r}function Gi(e){const t=e.PATTERN;if(Sr(t))return!1;if(k(t))return!0;if(gr(t,"exec"))return!0;if(Tr(t))return!1;throw Error("non exhaustive match")}function Ki(e){return!(!Tr(e)||1!==e.length)&&e.charCodeAt(0)}const zi={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 Vi(e,t){if(gr(e,"LINE_BREAKS"))return!1;if(Sr(e.PATTERN)){try{ki(t,e.PATTERN)}catch(e){return{issue:co.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(Tr(e.PATTERN))return!1;if(Gi(e))return{issue:co.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function Hi(e){return ur(e,e=>Tr(e)?e.charCodeAt(0):e)}function Yi(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}const Xi=256;let qi=[];function Zi(e){return e<Xi?e:qi[e]}function Qi(e,t){const n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]}function Ji(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let eo=1;const to={};function no(e){const t=function(e){let t=pn(e),n=e,r=!0;for(;r;){n=mn(vt(ur(n,e=>e.CATEGORIES)));const e=Yn(n,t);t=t.concat(e),Rr(e)?r=!1:n=e}return t}(e);!function(e){Qn(e,e=>{io(e)||(to[eo]=e,e.tokenTypeIdx=eo++),oo(e)&&!m(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),oo(e)||(e.CATEGORIES=[]),gr(e,"categoryMatches")||(e.categoryMatches=[]),function(e){return gr(e,"categoryMatchesMap")}(e)||(e.categoryMatchesMap={})})}(t),function(e){Qn(e,e=>{ro([],e)})}(t),function(e){Qn(e,e=>{e.categoryMatches=[],Qn(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(to[n].tokenTypeIdx)})})}(t),Qn(t,e=>{e.isParent=e.categoryMatches.length>0})}function ro(e,t){Qn(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),Qn(t.CATEGORIES,n=>{const r=e.concat(t);vr(r,n)||ro(r,n)})}function io(e){return gr(e,"tokenTypeIdx")}function oo(e){return gr(e,"CATEGORIES")}function so(e){return gr(e,"tokenTypeIdx")}const ao={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 co;!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"}(co||(co={}));const uo={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ao,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(uo);class lo{constructor(e,t=uo){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}=jr(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=He({},uo,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===uo.lineTerminatorsPattern)this.config.lineTerminatorsPattern=zi;else if(this.config.lineTerminatorCharacters===uo.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),m(e)?n={modes:{defaultMode:pn(e)},defaultMode:Pi}:(r=!1,n=pn(e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e){const t=[];return gr(e,Pi)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+Pi+"> property in its definition\n",type:co.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),gr(e,wi)||t.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:co.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),gr(e,wi)&&gr(e,Pi)&&!gr(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${Pi}: <${e.defaultMode}>which does not exist\n`,type:co.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),gr(e,wi)&&Qn(e.modes,(e,n)=>{Qn(e,(r,i)=>{_r(r)?t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,type:co.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):gr(r,"LONGER_ALT")&&Qn(m(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT],i=>{_r(i)||vr(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:co.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(Wi(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},Qn(n.modes,(e,t)=>{n.modes[t]=br(e,e=>_r(e))});const i=Ke(n.modes);if(Qn(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(Fi(e,i))}),Rr(this.lexerDefinitionErrors)){let r;no(e),this.TRACE_INIT("analyzeTokenTypes",()=>{r=Ui(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=He({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!Rr(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const e=ur(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+e)}Qn(this.lexerDefinitionWarning,e=>{Dr(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(Mi?(this.chopInput=C,this.match=this.matchWithTest):(this.updateLastIndex=Y,this.match=this.matchWithExec),r&&(this.handleModes=Y),!1===this.trackStartLines&&(this.computeNewColumn=C),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=Y),/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&&!Rr(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",()=>{Ii={}}),this.TRACE_INIT("toFastProperties",()=>{Br(this)})})}tokenize(e,t=this.defaultMode){if(!Rr(this.lexerDefinitionErrors)){const e=ur(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,E,g;const T=e,A=T.length;let I=0,v=0;const N=this.hasCustom?0:Math.floor(e.length/10),y=new Array(N),R=[];let O=this.trackStartLines?1:void 0,S=this.trackStartLines?1:void 0;const _=function(e){const t={};return Qn(Ke(e),n=>{const r=e[n];if(!m(r))throw Error("non exhaustive match");t[n]=[]}),t}(this.emptyGroups),L=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=Zi(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);R.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{P.pop();const e=Xn(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(;I<A;){a=null;const t=T.charCodeAt(I),m=M(t),N=m.length;for(n=0;n<N;n++){B=m[n];const r=B.pattern;c=null;const l=B.short;if(!1!==l?t===l&&(a=r):!0===B.isCustom?(g=r.exec(T,I,y,_),null!==g?(a=g[0],void 0!==g.payload&&(c=g.payload)):a=null):(this.updateLastIndex(r,I),a=this.match(r,e,I)),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?(g=n.exec(T,I,y,_),null!==g?(o=g[0],void 0!==g.payload&&(u=g.payload)):o=null):(this.updateLastIndex(n,I),o=this.match(n,e,I)),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,I,f,B.tokenType,O,S,l),this.handlePayload(d,c),!1===h?v=this.addToken(y,v,d):_[h].push(d)),e=this.chopInput(e,l),I+=l,S=this.computeNewColumn(S,l),!0===L&&!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&&(O+=n,S=l-t,this.updateTokenEndLineColumnLocation(d,h,t,n,O,S,l))}this.handleModes(B,D,j,d)}else{const t=I,n=O,i=S;let o=!1===$;for(;!1===o&&I<A;)for(e=this.chopInput(e,1),I++,r=0;r<C;r++){const t=k[r],n=t.pattern,i=t.short;if(!1!==i?T.charCodeAt(I)===i&&(o=!0):!0===t.isCustom?o=null!==n.exec(T,I,y,_):(this.updateLastIndex(n,I),o=null!==n.exec(e)),!0===o)break}if(p=I-t,S=this.computeNewColumn(S,p),E=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(T,t,p,n,i),R.push({offset:t,line:n,column:i,length:p,message:E}),!1===$)break}}return this.hasCustom||(y.length=v),{tokens:y,groups:_,errors:R}}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 ho(e){return fo(e)?e.LABEL:e.name}function fo(e){return Tr(e.LABEL)&&""!==e.LABEL}lo.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.",lo.NA=/NOT_APPLICABLE/;const po="parent",mo="categories",Eo="label",go="group",To="push_mode",Ao="pop_mode",Io="longer_alt",vo="line_breaks",No="start_chars_hint";function yo(e){return function(e){const t=e.pattern,n={};n.name=e.name,_r(t)||(n.PATTERN=t);if(gr(e,po))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";gr(e,mo)&&(n.CATEGORIES=e[mo]);no([n]),gr(e,Eo)&&(n.LABEL=e[Eo]);gr(e,go)&&(n.GROUP=e[go]);gr(e,Ao)&&(n.POP_MODE=e[Ao]);gr(e,To)&&(n.PUSH_MODE=e[To]);gr(e,Io)&&(n.LONGER_ALT=e[Io]);gr(e,vo)&&(n.LINE_BREAKS=e[vo]);gr(e,No)&&(n.START_CHARS_HINT=e[No]);return n}(e)}const Ro=yo({name:"EOF",pattern:lo.NA});function Oo(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}}no([Ro]);const So={buildMismatchTokenMessage:({expected:e,actual:t,previous:n,ruleName:r})=>`Expecting ${fo(e)?`--\x3e ${ho(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: '"+ar(t).image+"'";if(r)return o+r+s;{const t=ur(kr(e,(e,t)=>e.concat(t),[]),e=>`[${ur(e,e=>ho(e)).join(", ")}]`);return o+`one of these possible Token sequences:\n${ur(t,(e,t)=>` ${t+1}. ${e}`).join("\n")}`+s}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){const i="Expecting: ",o="\nbut found: '"+ar(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 <${ur(e,e=>`[${ur(e,e=>ho(e)).join(",")}]`).join(" ,")}>`+o}};Object.freeze(So);const _o={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},Lo={buildDuplicateFoundError(e,t){const n=e.name,r=ar(t),i=r.idx,o=ni(r),s=(a=r)instanceof Qr?a.terminalType.name:a instanceof Gr?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=ur(e.prefixPath,e=>ho(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=ur(e.prefixPath,e=>ho(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=ni(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 ${ur(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 Kr?e.topLevelRule.name:e.topLevelRule;return`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class xo extends ei{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Qn(Ar(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:qs.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Co extends ri{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=pn(this.path.ruleStack).reverse(),this.occurrenceStack=pn(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(){Rr(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class ko extends Co{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 zr({definition:e});this.possibleTokTypes=oi(r),this.found=!0}}}class bo extends ri{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 Po extends bo{walkMany(e,t,n){if(e.idx===this.occurrence){const e=ar(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof Qr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}}class wo extends bo{walkManySep(e,t,n){if(e.idx===this.occurrence){const e=ar(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof Qr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}}class Mo extends bo{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){const e=ar(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof Qr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}}class Uo extends bo{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){const e=ar(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof Qr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}}function Fo(e,t,n=[]){n=pn(n);let r=[],i=0;function o(o){const s=Fo(o.concat(qn(e,i+1)),t,n);return r.concat(s)}for(;n.length<t&&i<e.length;){const t=e[i];if(t instanceof zr)return o(t.definition);if(t instanceof Gr)return o(t.definition);if(t instanceof Vr)r=o(t.definition);else{if(t instanceof Hr){return o(t.definition.concat([new Xr({definition:t.definition})]))}if(t instanceof Yr){return o([new zr({definition:t.definition}),new Xr({definition:[new Qr({terminalType:t.separator})].concat(t.definition)})])}if(t instanceof qr){const e=t.definition.concat([new Xr({definition:[new Qr({terminalType:t.separator})].concat(t.definition)})]);r=o(e)}else if(t instanceof Xr){const e=t.definition.concat([new Xr({definition:t.definition})]);r=o(e)}else{if(t instanceof Zr)return Qn(t.definition,e=>{!1===Rr(e.definition)&&(r=o(e.definition))}),r;if(!(t instanceof Qr))throw Error("non exhaustive match");n.push(t.terminalType)}}i++}return r.push({partialPath:n,suffixDef:qn(e,i)}),r}function Do(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:[]});!Rr(h);){const e=h.pop();if(e===s){a&&Xn(h).idx<=u&&h.pop();continue}const r=e.def,f=e.idx,d=e.ruleStack,p=e.occurrenceStack;if(Rr(r))continue;const m=r[0];if(m===i){const e={idx:f,def:qn(r),ruleStack:Zn(d),occurrenceStack:Zn(p)};h.push(e)}else if(m instanceof Qr)if(f<c-1){const e=f+1;if(n(t[e],m.terminalType)){const t={idx:e,def:qn(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 Gr){const e=pn(d);e.push(m.nonTerminalName);const t=pn(p);t.push(m.idx);const n={idx:f,def:m.definition.concat(o,qn(r)),ruleStack:e,occurrenceStack:t};h.push(n)}else if(m instanceof Vr){const e={idx:f,def:qn(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t={idx:f,def:m.definition.concat(qn(r)),ruleStack:d,occurrenceStack:p};h.push(t)}else if(m instanceof Hr){const e=new Xr({definition:m.definition,idx:m.idx}),t={idx:f,def:m.definition.concat([e],qn(r)),ruleStack:d,occurrenceStack:p};h.push(t)}else if(m instanceof Yr){const e=new Qr({terminalType:m.separator}),t=new Xr({definition:[e].concat(m.definition),idx:m.idx}),n={idx:f,def:m.definition.concat([t],qn(r)),ruleStack:d,occurrenceStack:p};h.push(n)}else if(m instanceof qr){const e={idx:f,def:qn(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t=new Qr({terminalType:m.separator}),n=new Xr({definition:[t].concat(m.definition),idx:m.idx}),i={idx:f,def:m.definition.concat([n],qn(r)),ruleStack:d,occurrenceStack:p};h.push(i)}else if(m instanceof Xr){const e={idx:f,def:qn(r),ruleStack:d,occurrenceStack:p};h.push(e),h.push(s);const t=new Xr({definition:m.definition,idx:m.idx}),n={idx:f,def:m.definition.concat([t],qn(r)),ruleStack:d,occurrenceStack:p};h.push(n)}else if(m instanceof Zr)for(let e=m.definition.length-1;e>=0;e--){const t={idx:f,def:m.definition[e].definition.concat(qn(r)),ruleStack:d,occurrenceStack:p};h.push(t),h.push(s)}else if(m instanceof zr)h.push({idx:f,def:m.definition.concat(qn(r)),ruleStack:d,occurrenceStack:p});else{if(!(m instanceof Kr))throw Error("non exhaustive match");h.push(jo(m,f,d,p))}}return l}function jo(e,t,n,r){const i=pn(n);i.push(e.name);const o=pn(r);return o.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:o}}var Bo;function $o(e){if(e instanceof Vr||"Option"===e)return Bo.OPTION;if(e instanceof Xr||"Repetition"===e)return Bo.REPETITION;if(e instanceof Hr||"RepetitionMandatory"===e)return Bo.REPETITION_MANDATORY;if(e instanceof Yr||"RepetitionMandatoryWithSeparator"===e)return Bo.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof qr||"RepetitionWithSeparator"===e)return Bo.REPETITION_WITH_SEPARATOR;if(e instanceof Zr||"Alternation"===e)return Bo.ALTERNATION;throw Error("non exhaustive match")}function Wo(e,t,n,r){const i=e.length,o=tr(e,e=>tr(e,e=>1===e.length));if(t)return function(t){const r=ur(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(ur(e,e=>vt(e)),(e,t,n)=>(Qn(t,t=>{gr(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),Qn(t.categoryMatches,t=>{gr(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 Go(e,t,n){const r=tr(e,e=>1===e.length),i=e.length;if(r&&!n){const t=vt(e);if(1===t.length&&Rr(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,Qn(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"}(Bo||(Bo={}));class Ko extends ri{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,Bo.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Bo.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Bo.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Bo.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Bo.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}}class zo extends ei{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,Bo.OPTION)}visitRepetition(e){this.checkIsTarget(e,Bo.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Bo.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Bo.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Bo.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Bo.ALTERNATION)}}function Vo(e){const t=new Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function Ho(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 Yo(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 Xo(e,t){const n=ur(e,e=>Fo([e],1)),r=Vo(n.length),i=ur(n,e=>{const t={};return Qn(e,e=>{Qn(Ho(e.partialPath),e=>{t[e]=!0})}),t});let o=n;for(let e=1;e<=t;e++){const n=o;o=Vo(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=Ho(c);if(Yo(i,l,s)||Rr(u)||c.length===t){const e=r[s];if(!1===Qo(e,c)){e.push(c);for(let e=0;e<l.length;e++){const t=l[e];i[s][t]=!0}}}else{const t=Fo(u,e+1,c);o[s]=o[s].concat(t),Qn(t,e=>{Qn(Ho(e.partialPath),e=>{i[s][e]=!0})})}}}}return r}function qo(e,t,n,r){const i=new zo(e,Bo.ALTERNATION,r);return t.accept(i),Xo(i.result,n)}function Zo(e,t,n,r){const i=new zo(e,n);t.accept(i);const o=i.result,s=new Ko(t,e,n).startWalking();return Xo([new zr({definition:o}),new zr({definition:s})],r)}function Qo(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 Jo(e){return tr(e,e=>tr(e,e=>tr(e,e=>Rr(e.categoryMatches))))}function es(e,t,n,r){const i=lr(e,e=>function(e,t){const n=new rs;e.accept(n);const r=n.allProductions,i=pr(r,ts),o=ur(Ar(xr(i,e=>e.length>1)),n=>{const r=ar(n),i=t.buildDuplicateFoundError(e,n),o=ni(r),s={message:i,type:qs.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:o,occurrence:r.idx},a=ns(r);return a&&(s.parameter=a),s});return o}(e,n)),o=function(e,t,n){const r=[],i=ur(t,e=>e.name);return Qn(e,e=>{const t=e.name;if(vr(i,t)){const i=n.buildNamespaceConflictError(e);r.push({message:i,type:qs.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}(e,t,n),s=lr(e,e=>function(e,t){const n=new ss;e.accept(n);const r=lr(n.alternations,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:qs.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[]);return r}(e,n)),a=lr(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:qs.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}(t,e,r,n));return i.concat(o,s,a)}function ts(e){return`${ni(e)}_#_${e.idx}_#_${ns(e)}`}function ns(e){return e instanceof Qr?e.terminalType.name:e instanceof Gr?e.nonTerminalName:""}class rs extends ei{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 is(e,t,n,r=[]){const i=[],o=os(t.definition);if(Rr(o))return[];{const t=e.name;vr(o,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:qs.LEFT_RECURSION,ruleName:t});const s=lr(Yn(o,r.concat([e])),t=>{const i=pn(r);return i.push(t),is(e,t,n,i)});return i.concat(s)}}function os(e){let t=[];if(Rr(e))return t;const n=ar(e);if(n instanceof Gr)t.push(n.referencedRule);else if(n instanceof zr||n instanceof Vr||n instanceof Hr||n instanceof Yr||n instanceof qr||n instanceof Xr)t=t.concat(os(n.definition));else if(n instanceof Zr)t=vt(ur(n.definition,e=>os(e.definition)));else if(!(n instanceof Qr))throw Error("non exhaustive match");const r=ti(n),i=e.length>1;if(r&&i){const n=qn(e);return t.concat(os(n))}return t}class ss extends ei{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function as(e,t,n){const r=new ss;e.accept(r);let i=r.alternations;i=br(i,e=>!0===e.ignoreAmbiguities);const o=lr(i,r=>{const i=r.idx,o=r.maxLookahead||t,s=qo(i,e,o,r),a=function(e,t,n,r){const i=[],o=kr(e,(n,r,o)=>(!0===t.definition[o].ignoreAmbiguities||Qn(r,r=>{const s=[o];Qn(e,(e,n)=>{o!==n&&Qo(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&s.push(n)}),s.length>1&&!Qo(i,r)&&(i.push(r),n.push({alts:s,path:r}))}),n),[]),s=ur(o,e=>{const i=ur(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:qs.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=ur(t,e=>({idx:n,path:e}));return e.concat(r)},[]),o=mn(lr(i,e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];const o=e.idx,s=e.path;return ur(rr(i,e=>{return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<o&&(n=e.path,r=s,n.length<r.length&&tr(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:qs.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:s,alternatives:i}})}));return o}(s,r,e,n);return a.concat(c)});return o}class cs extends ei{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 us(e){const t=Vn(e,{errMsgProvider:_o}),n={};return Qn(e.rules,e=>{n[e.name]=e}),function(e,t){const n=new xo(e,t);return n.resolveRefs(),n.errors}(n,t.errMsgProvider)}const ls="MismatchedTokenException",hs="NoViableAltException",fs="EarlyExitException",ds="NotAllInputParsedException",ps=[ls,hs,fs,ds];function ms(e){return vr(ps,e.name)}Object.freeze(ps);class Es 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 gs extends Es{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=ls}}class Ts extends Es{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=hs}}class As extends Es{constructor(e,t){super(e,t),this.name=ds}}class Is extends Es{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=fs}}const vs={},Ns="InRuleRecoveryException";class ys extends Error{constructor(e){super(e),this.name=Ns}}function Rs(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=Ro,l=1),void 0!==u&&void 0!==l&&this.shouldInRepetitionRecoveryBeTried(u,l,s)&&this.tryInRepetitionRecovery(e,t,n,u)}const Os=1024,Ss=1280,_s=1536;function Ls(e,t,n){return n|t|e}class xs{constructor(e){var t;this.maxLookahead=null!==(t=null==e?void 0:e.maxLookahead)&&void 0!==t?t:Ys.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(Rr(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 lr(e,e=>is(e,e,Lo))}validateEmptyOrAlternatives(e){return lr(e,e=>function(e,t){const n=new ss;return e.accept(n),lr(n.alternations,n=>lr(Zn(n.definition),(r,i)=>Rr(Do([r],[],Qi,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:qs.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}(e,Lo))}validateAmbiguousAlternationAlternatives(e,t){return lr(e,e=>as(e,t,Lo))}validateSomeNonEmptyLookaheadPath(e,t){return function(e,t,n){const r=[];return Qn(e,e=>{const i=new cs;e.accept(i),Qn(i.allProductions,i=>{const o=$o(i),s=i.maxLookahead||t;if(Rr(vt(Zo(i.idx,e,o,s)[0]))){const t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:qs.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}(e,t,Lo)}buildLookaheadForAlternation(e){return function(e,t,n,r,i,o){const s=qo(e,t,n);return o(s,r,Jo(s)?Ji:Qi,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Wo)}buildLookaheadForOptional(e){return function(e,t,n,r,i,o){const s=Zo(e,t,i,n),a=Jo(s)?Ji:Qi;return o(s[0],a,r)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,$o(e.prodType),Go)}}const Cs=new class extends ei{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 bs(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 Ps(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function ws(e,t){const n=Ke(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 Ms(e,t){const n=function(){};Ps(n,e+"BaseSemantics");const r={visit:function(e,t){if(m(e)&&(e=e[0]),!_r(e))return this[e.name](e.children,t)},validateVisitor:function(){const e=function(e,t){const n=function(e,t){const n=rr(t,t=>!1===k(e[t])),r=ur(n,t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Us.MISSING_METHOD,methodName:t}));return mn(r)}(e,t);return n}(this,t);if(!Rr(e)){const t=ur(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 Us;!function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"}(Us||(Us={}));const Fs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Fs);const Ds=!0,js=Math.pow(2,8)-1,Bs=yo({name:"RECORDING_PHASE_TOKEN",pattern:lo.NA});no([Bs]);const $s=Oo(Bs,"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($s);const Ws={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 Gs(e,t,n,r=!1){Vs(n);const i=Xn(this.recordingProdStack),o=k(t)?t:t.DEF,s=new e({definition:[],idx:n});return r&&(s.separator=t.SEP),gr(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),o.call(this),i.definition.push(s),this.recordingProdStack.pop(),Fs}function Ks(e,t){Vs(t);const n=Xn(this.recordingProdStack),r=!1===m(e),i=!1===r?e:e.DEF,o=new Zr({definition:[],idx:t,ignoreAmbiguities:r&&!0===e.IGNORE_AMBIGUITIES});gr(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD);const s=wr(i,e=>k(e.GATE));return o.hasPredicates=s,n.definition.push(o),Qn(i,e=>{const t=new zr({definition:[]});o.definition.push(t),gr(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:gr(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),Fs}function zs(e){return 0===e?"":`${e}`}function Vs(e){if(e<0||e>js){const t=new Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${js+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}const Hs=Oo(Ro,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Hs);const Ys=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:So,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Xs=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var qs,Zs;!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"}(qs||(qs={}));class Qs{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",()=>{Br(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),Qn(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=us({rules:Ar(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(Rr(n)&&!1===this.skipValidations){const n=(e={rules:Ar(this.gastProductionsCache),tokenTypes:Ar(this.tokensMap),errMsgProvider:Lo,grammarName:t},es((e=Vn(e,{errMsgProvider:Lo})).rules,e.tokenTypes,e.errMsgProvider,e.grammarName)),r=function(e){return ur(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:qs.CUSTOM_LOOKAHEAD_VALIDATION},e))}({lookaheadStrategy:this.lookaheadStrategy,rules:Ar(this.gastProductionsCache),tokenTypes:Ar(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(n,r)}var e}),Rr(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const e=function(e){const t={};return Qn(e,e=>{const n=new ai(e).startWalking();He(t,n)}),t}(Ar(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:Ar(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Ar(this.gastProductionsCache))})),!Qs.DEFER_DEFINITION_ERRORS_HANDLING&&!Rr(this.definitionErrors))throw e=ur(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),gr(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=gr(t,"skipValidations")?t.skipValidations:Ys.skipValidations}}Qs.DEFER_DEFINITION_ERRORS_HANDLING=!1,Zs=Qs,[class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=gr(e,"recoveryEnabled")?e.recoveryEnabled:Ys.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Rs)}getTokenToInsert(e){const t=Oo(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 gs(t,c,this.LA(0));n.resyncedTokens=Zn(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 ys("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(Rr(t))return!1;const n=this.LA(1);return void 0!==sr(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 vr(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA(1),n=2;for(;;){const r=sr(e,e=>Qi(t,e));if(void 0!==r)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return vs;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 ur(e,(n,r)=>0===r?vs:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return vt(ur(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===vs)return[Ro];const t=e.ruleName+e.idxInCallingRule+si+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ro)||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 Zn(t)}attemptInRepetitionRecovery(e,t,n,r,i,o,s){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:pn(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return ur(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}},class{initLooksAhead(e){this.dynamicTokensEnabled=gr(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:Ys.dynamicTokensEnabled,this.maxLookahead=gr(e,"maxLookahead")?e.maxLookahead:Ys.maxLookahead,this.lookaheadStrategy=gr(e,"lookaheadStrategy")?e.lookaheadStrategy:new xs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){Qn(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{const{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:s}=function(e){Cs.reset(),e.accept(Cs);const t=Cs.dslMethods;return Cs.reset(),t}(e);Qn(t,t=>{const n=0===t.idx?"":t.idx;this.TRACE_INIT(`${ni(t)}${n}`,()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=Ls(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),Qn(n,t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,ni(t))}),Qn(r,t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,ni(t))}),Qn(i,t=>{this.computeLookaheadFunc(e,t.idx,Os,"RepetitionMandatory",t.maxLookahead,ni(t))}),Qn(o,t=>{this.computeLookaheadFunc(e,t.idx,_s,"RepetitionMandatoryWithSeparator",t.maxLookahead,ni(t))}),Qn(s,t=>{this.computeLookaheadFunc(e,t.idx,Ss,"RepetitionWithSeparator",t.maxLookahead,ni(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=Ls(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(s,o)})}getKeyForAutomaticLookahead(e,t){return Ls(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=gr(e,"nodeLocationTracking")?e.nodeLocationTracking:Ys.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=bs,this.setNodeLocationFromNode=bs,this.cstPostRule=Y,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=Y,this.setNodeLocationFromNode=Y,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=Y,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=Y,this.setNodeLocationFromNode=Y,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=Y,this.setNodeLocationFromNode=Y,this.cstPostRule=Y,this.setInitialNodeLocation=Y}else this.cstInvocationStateUpdate=Y,this.cstFinallyStateUpdate=Y,this.cstPostTerminal=Y,this.cstPostNonTerminal=Y,this.cstPostRule=Y}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(_r(this.baseCstVisitorConstructor)){const e=Ms(this.className,Ke(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(_r(this.baseCstVisitorWithDefaultsConstructor)){const e=function(e,t,n){const r=function(){};Ps(r,e+"BaseSemanticsWithDefaults");const i=Object.create(n.prototype);return Qn(t,e=>{i[e]=ws}),(r.prototype=i).constructor=r,r}(this.className,Ke(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)):Hs}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Hs: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=Ji,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},gr(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(m(e)){if(Rr(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(m(e))this.tokensMap=kr(e,(e,t)=>(e[t.name]=t,e),{});else if(gr(e,"modes")&&tr(vt(Ar(e.modes)),so)){const t=Ur(vt(Ar(e.modes)));this.tokensMap=kr(t,(e,t)=>(e[t.name]=t,e),{})}else{if(!N(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=pn(e)}this.tokensMap.EOF=Ro;const n=tr(gr(e,"modes")?vt(Ar(e.modes)):Ar(e),e=>Rr(e.categoryMatches));this.tokenMatcher=n?Ji:Qi,no(Ar(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=gr(n,"resyncEnabled")?n.resyncEnabled:Xs.resyncEnabled,i=gr(n,"recoveryValueFunc")?n.recoveryValueFunc:Xs.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(ms(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(Os,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,Bo.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,Os,e,Mo)}atLeastOneSepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(_s,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,Bo.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,Uo],t,_s,e,Uo)}}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,Po,o)}manySepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(Ss,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,wo],t,Ss,e,wo)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,_s,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=m(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 As(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 ms(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 gs(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===Ns?n:e}}}saveRecogState(){const e=this.errors,t=pn(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),Ro)}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=Xs){if(vr(this.definedRulesNames,e)){const t={message:Lo.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:qs.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=Xs){const r=function(e,t,n){const r=[];let i;return vr(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:qs.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(ms(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return ur(Ar(this.gastProductionsCache),Jr)}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=gr(e,"errorMessageProvider")?e.errorMessageProvider:Ys.errorMessageProvider}SAVE_ERROR(e){if(ms(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:pn(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return pn(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){const r=this.getCurrRuleFullName(),i=Zo(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 Is(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const n=this.getCurrRuleFullName(),r=qo(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 Ts(s,this.LA(1),o))}},class{initContentAssist(){}computeContentAssist(e,t){const n=this.gastProductionsCache[e];if(_r(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Do([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const t=ar(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 Hs}topLevelRuleRecord(e,t){try{const n=new Kr({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 Gs.call(this,Vr,e,t)}atLeastOneInternalRecord(e,t){Gs.call(this,Hr,t,e)}atLeastOneSepFirstInternalRecord(e,t){Gs.call(this,Yr,t,e,Ds)}manyInternalRecord(e,t){Gs.call(this,Xr,t,e)}manySepFirstInternalRecord(e,t){Gs.call(this,qr,t,e,Ds)}orInternalRecord(e,t){return Ks.call(this,e,t)}subruleInternalRecord(e,t,n){if(Vs(t),!e||!1===gr(e,"ruleName")){const n=new Error(`<SUBRULE${zs(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=Xn(this.recordingProdStack),i=e.ruleName,o=new Gr({idx:t,nonTerminalName:i,label:null==n?void 0:n.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?Ws:Fs}consumeInternalRecord(e,t,n){if(Vs(t),!io(e)){const n=new Error(`<CONSUME${zs(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=Xn(this.recordingProdStack),i=new Qr({idx:t,terminalType:e,label:null==n?void 0:n.LABEL});return r.definition.push(i),$s}},class{initPerformanceTracer(e){if(gr(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=Ys.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}=jr(t),o=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}}].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(Zs.prototype,n,r):Zs.prototype[n]=e.prototype[n]})});class Js extends Qs{constructor(e,t=Ys){const n=pn(t);n.outputCst=!1,super(e,n)}}const ea=yo({name:"WhiteSpace",pattern:/\s+/,group:lo.SKIPPED}),ta=yo({name:"String",pattern:/"(""|[^"])*"/}),na=yo({name:"SingleQuotedString",pattern:/'(''|[^'])*'/}),ra=yo({name:"SheetQuoted",pattern:/'((?![\\/[\]*?:]).)+?'!/}),ia=yo({name:"FunctionToken",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\(/}),oa=yo({name:"NamedTableReference",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\[/}),sa=yo({name:"BracketedString",pattern:/\[([^[\]]*)\]/,longer_alt:[oa,ta]}),aa=yo({name:"LiteralError",pattern:/#PARSE!|#NULL!|#DIV\/0!|#VALUE!|#NUM!|#FIELD!|#N\/A|#GETTING_DATA|#SPILL!|#CONNECT!|#BLOCKED!|#UNKNOWN!|#FIELD!|#CALC!|#BUSY!|#PYTHON!|#TIMEOUT!/}),ca=yo({name:"RefError",pattern:/#REF!|#NAME\?/}),ua=yo({name:"Sheet",pattern:/[A-Za-z_.\d\u007F-\uFFFF]+!/}),la=/^[a-zA-Z_][a-zA-Z0-9_.?]*:?/,ha=yo({name:"Name",pattern:{exec:(e,t)=>{try{const n=la.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})()}),fa=yo({name:"Cell",pattern:/[$]?[A-Za-z]{1,3}[$]?[1-9][0-9]*/,longer_alt:ha}),da=yo({name:"Column",pattern:/[$]?[A-Za-z]{1,3}/,longer_alt:ha}),pa=yo({name:"AbsRow",pattern:/[$][0-9]+/,longer_alt:ha}),ma=yo({name:"NumberToken",pattern:/[0-9]+[.]?[0-9]*([eE][+-][0-9]+)?/}),Ea=yo({name:"Boolean",pattern:/TRUE|FALSE/i}),ga=yo({name:"Comma",pattern:/,/}),Ta=yo({name:"RangeUnion",pattern:/:/}),Aa=yo({name:"RangeTrimFull",pattern:/\.:\./}),Ia=yo({name:"RangeTrimLeading",pattern:/\.:/}),va=yo({name:"RangeTrimTrailing",pattern:/:\./}),Na=yo({name:"Semicolon",pattern:/;/}),ya=yo({name:"OpenParen",pattern:/\(/}),Ra=yo({name:"CloseParen",pattern:/\)/}),Oa=yo({name:"OpenSquareParen",pattern:/\[/}),Sa=yo({name:"CloseSquareParen",pattern:/]/});yo({name:"exclamationMark",pattern:/!/});const _a=yo({name:"OpenCurlyParen",pattern:/{/}),La=yo({name:"CloseCurlyParen",pattern:/}/}),xa=yo({name:"QuoteS",pattern:/'/}),Ca=yo({name:"MulOp",pattern:/\*/}),ka=yo({name:"PlusOp",pattern:/\+/}),ba=yo({name:"DivOp",pattern:/\//}),Pa=yo({name:"MinOp",pattern:/-/}),wa=yo({name:"ImplicitIntersectOp",pattern:/@/}),Ma=yo({name:"ConcatOp",pattern:/&/}),Ua=yo({name:"ExOp",pattern:/\^/}),Fa=yo({name:"PercentOp",pattern:/%/}),Da=yo({name:"TableSpecifier",pattern:/#(All|Data|Headers|Totals|This Row)/i}),ja=yo({name:"ArrayAnchorOp",pattern:/#/,longer_alt:[Da,aa,ca]}),Ba=yo({name:"GtOp",pattern:/>/}),$a=yo({name:"EqOp",pattern:/=/}),Wa=yo({name:"LtOp",pattern:/</}),Ga=[ea,ta,ra,na,ia,oa,sa,aa,ca,ua,fa,Ea,da,pa,Da,ja,wa,ha,ma,ga,Aa,Ia,va,Ta,Na,ya,Ra,Oa,Sa,_a,La,xa,Ca,ka,ba,Pa,Ma,Ua,Ca,Fa,yo({name:"NeqOp",pattern:/<>/}),yo({name:"GteOp",pattern:/>=/}),yo({name:"LteOp",pattern:/<=/}),Ba,$a,Wa],Ka=new lo(Ga,{ensureOptimizations:!0}),za={};Ga.forEach(e=>{za[e.name]=e});const Va={boolean:3,string:2,number:1},Ha=(e,t)=>{let n=e+t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},Ya=(e,t)=>{let n=e-t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},Xa=(e,t)=>{let n=e*t;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},qa=(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},Za=(e,t)=>{const n=e**t;return isFinite(n)?n:Number.NaN},Qa=(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},Ja=(e=null,t=null)=>typeof e===typeof t&&e===t,ec=(e=null,t=null)=>typeof e!==typeof t||e!==t,tc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e>t:Va[n]>Va[r]},nc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e>=t:Va[n]>=Va[r]},rc=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e<t:Va[n]<Va[r]},ic=(e=null,t=null)=>{const n=typeof e,r=typeof t;return n===r?e<=t:Va[n]<=Va[r]},oc={type:e.e.Number,coerce:!0,includeBoolean:!0,includeMistyped:!0,mismatchFill:e.n.BuiltIn.NA},sc={type:e.e.String,coerce:!0,includeMistyped:!0,mismatchFill:e.n.BuiltIn.NA},ac={type:null,coerce:!0,includeMistyped:!0,mismatchFill:e.n.BuiltIn.NA},cc=(t,n,r,i)=>{if(null!==n&&void 0!==n.colStart&&(n=t.getValueAt(n.rowStart,n.colStart)),null!==r&&void 0!==r.colStart&&(r=t.getValueAt(r.rowStart,r.colStart)),"number"==typeof n&&"number"==typeof r)return i(n,r);let o,s;if(n?.isIRange?o=n:r?.isIRange&&(s=r),!o&&!s){const t=!1;return n=e.coerceScalar(n,e.typeFromJsValue(n,!0),e.e.Number,!0,t),r=e.coerceScalar(r,e.typeFromJsValue(r,!0),e.e.Number,!0,t),n instanceof e.n.Value?n:r instanceof e.n.Value?r:i(n,r)}return o||(o=t.getRange(n)),o.broadcast(r,i,oc).fillEmpty(0)},uc=(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,ac):r(t,n)},lc=(t,n)=>{null==n&&(n=0);let r,i=1;if("+"===t)return n;if("-"!==t)throw new e.n.Value(`Unrecognized prefix: ${t}`);return i=-i,n?.isIRange&&(r=n),r?r.broadcast(i,Xa,ac):"number"!=typeof(n=e.coerceScalar(n,e.typeFromJsValue(n,!0),e.e.Number))||isNaN(n)?e.n.BuiltIn.Value:n*i},hc=(t,n,r,i)=>{if(!n)return e.n.BuiltIn.Ref;if(n.isIReferenceRange&&(n=n.getCoords()),void 0===n.colStart)return e.n.BuiltIn.Ref;if(r.isIReferenceRange&&(r=r.getCoords()),void 0===r.colStart)return e.n.BuiltIn.Ref;const o=i(n,r);return o?t.getReference(o):e.n.BuiltIn.Null},fc={"+":(e,t,n)=>cc(e,t,n,Ha),"-":(e,t,n)=>cc(e,t,n,Ya),"*":(e,t,n)=>cc(e,t,n,Xa),"/":(e,t,n)=>cc(e,t,n,qa),"^":(e,t,n)=>cc(e,t,n,Za)," ":(t,n,r,i)=>hc(t,n,r,e.j.intersectRanges),":":(t,n,r,i)=>hc(t,n,r,e.j.unionRanges),".:.":(t,n,r,i)=>{const o=hc(t,n,r,e.j.unionRanges);return t.getFunction("TRIMRANGE").execute(o,3,3)},".:":(t,n,r,i)=>{const o=hc(t,n,r,e.j.unionRanges);return t.getFunction("TRIMRANGE").execute(o,1,1)},":.":(t,n,r,i)=>{const o=hc(t,n,r,e.j.unionRanges);return t.getFunction("TRIMRANGE").execute(o,2,2)},"&":(t,n,r)=>((t,n,r,i)=>{if(null!==n&&void 0!==n.colStart&&(n=t.getValueAt(n.rowStart,n.colStart)),null!==r&&void 0!==r.colStart&&(r=t.getValueAt(r.rowStart,r.colStart)),"string"==typeof n&&"string"==typeof r)return i(n,r);let o,s;return n?.isIRange?o=n:r?.isIRange&&(s=r),o||s?(o||(o=t.getRange(n)),o.broadcast(r,i,sc)):i(n=e.coerceScalar(n,e.typeFromJsValue(n,!0),e.e.String),r=e.coerceScalar(r,e.typeFromJsValue(r,!0),e.e.String))})(t,n,r,Qa),"=":(e,t,n)=>uc(e,t,n,Ja),"<>":(e,t,n)=>uc(e,t,n,ec),">":(e,t,n)=>uc(e,t,n,tc),"<":(e,t,n)=>uc(e,t,n,rc),">=":(e,t,n)=>uc(e,t,n,nc),"<=":(e,t,n)=>uc(e,t,n,ic)},dc={"-":(e,t)=>lc("-",t),"+":(e,t)=>lc("+",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.n.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.n.BuiltIn.Value}},pc={"%":(e,t)=>cc(e,t,100,qa),"#":(t,n)=>{const r=t.getSpillAt(n.rowStart,n.colStart);return r||e.n.BuiltIn.Ref}};function mc(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 Ec(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 gc(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 Tc(e,t){return{type:"function",value:e=e.toUpperCase(),inputs:t}}function Ac(e,t){return{type:"tableReference",value:e,inputs:t}}function Ic(e){return{type:"tableSpecifier",value:e,inputs:null,isReference:!0}}function vc(e,t,n,r=!1){const i={type:"infix",value:e,inputs:[t,n]};return r&&(i.isReference=!0),i}function Nc(e,t,n=!1){const r={type:"postfix",value:e,inputs:[t]};return n&&(r.isReference=!0),r}function yc(e,t,n=!1){const r={type:"prefix",value:e,inputs:[t]};return n&&(r.isReference=!0),r}function Rc(e){return{type:"named",value:e,inputs:null,isReference:!0}}function Oc(e){return{type:"number",value:Number(e),isLiteral:!0}}function Sc(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 Lc(t){return{type:"error",value:e.n.getBuiltInByLabel(t.toUpperCase()),isLiteral:!0}}function xc(t){return{type:"error",value:t?e.n.getBuiltInByLabel(t.toUpperCase()):e.n.BuiltIn.Ref,inputs:null,isReference:!0}}function Cc(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 kc(t,n){let r=0,i=Cc(t,e=>{const t={...e};return t.evalIndex=r++,t});const o=new Array(r),s=new Set,a=new Map;let c;const u=new Map,l=[],h=[];i=Cc(i,(t,n)=>{const r=t.type,i=t.evalIndex;if(o[i]=null,t.isReference){const e=t,n={node:t,index:u.size,op:null,value:null,inputs:null};if(u.set(e,n),"cell"===r){const r=e.value;return r.$colIndex&&(n.hasHorizontalAbs=!0),r.$rowIndex&&(n.hasVerticalAbs=!0),n.value=a.size,a.set(e,a.size),s.add(n),t.refIndex=h.length,void h.push(n.index)}if("infix"===r||"prefix"===r||"postfix"===r||"spill"===r){const r=e.inputs,i=r.length,o=t.value;n.op=o;const a=new Array(i);n.inputs=a;for(let e=0;e<i;e++){const t=r[e],i=u.get(t);i&&(i.hasHorizontalAbs&&(n.hasHorizontalAbs=!0),i.hasVerticalAbs&&(n.hasVerticalAbs=!0)),a[e]=i?i.index:-1,s.delete(i)}if(s.add(n),Uc.includes(o)){const e=r[0],i=!!e&&"cell"===e.type,o=r[1],s=!!o&&"cell"===o.type;i&&s&&(h.splice(o.refIndex,1),o.refIndex=e.refIndex,t.refIndex=e.refIndex,h[e.refIndex]=n.index)}else"#"===o&&(t.refIndex=r[0].refIndex);return void l.push(t)}if("error"===r||"named"===r){c||(c=new Map);const i=e.value;let o=c.get(i);return n.op=r,void 0===o&&(o=c.size,c.set(i,o)),n.value=o,s.add(n),t.refIndex=h.length,void h.push(n.index)}"tableReference"===r&&(n.op=r),"tableSpecifier"===r&&(n.op=r),"structuredArg"===r&&(n.op=r)}else if(n&&n.isReference){const e=t,n={node:t,index:u.size,op:"function",value:t.value,inputs:null};u.set(e,n)}if(t.isLiteral)if("array"!==r)o[i]=t.value;else{const n=t.value,r=n.length,s=new Array(r);for(let e=0;e<r;e++){const t=n[e].value,r=t.length,i=new Array(r);for(let e=0;e<r;e++){const n=t[e];let r=n.value;if("prefix"===n.type){const e=n.value;r=n.inputs[0].value,"-"===e&&(r=-r)}i[e]=r}s[e]=i}o[i]=e.gridFromArray(s)}else{if("empty"!==r)return l.push(t),t;o[i]=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=fc[e]}else if("prefix"===n){const e=t.value;t.fn=dc[e]}else if("postfix"===n){const e=t.value;t.fn=pc[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}(i);return{ast:i,evaluations:o,executions:l,precedentsAbsolute:p,precedentsExecute:m,precedentsNamed:E,precedentsRelative:f,precedentsRoot:g,references:h,tokens:A,error:n}}function bc(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.n.Parse(o);return s.details=t,s}const Pc=function(e,t){return t.wsBefore&&(e.wsBefore=t.wsBefore),t.wsAfter&&(e.wsAfter=t.wsAfter),t.image&&(e.image=t.image),e},wc="_XLFN.",Mc=Object.freeze([[":",".:.",".:",,":."],["^"],["*","/"],["+","-"],["&"],["<",">","=","<>","<=",">="]]),Uc=Object.freeze([":",".:.",".:",,":."]),Fc=Object.freeze([":"," ",".:.",".:",,":."]),Dc=Object.freeze(["@"]),jc=Object.freeze(["#"]),Bc=Object.freeze(Fc.concat(Dc).concat(jc)),{String:$c,SheetQuoted:Wc,SingleQuotedString:Gc,FunctionToken:Kc,NamedTableReference:zc,LiteralError:Vc,RefError:Hc,Cell:Yc,Sheet:Xc,Name:qc,NumberToken:Zc,Boolean:Qc,Column:Jc,AbsRow:eu,ImplicitIntersectOp:tu,Comma:nu,RangeUnion:ru,RangeTrimFull:iu,RangeTrimLeading:ou,RangeTrimTrailing:su,Semicolon:au,OpenParen:cu,CloseParen:uu,OpenSquareParen:lu,CloseSquareParen:hu,OpenCurlyParen:fu,CloseCurlyParen:du,MulOp:pu,PlusOp:mu,DivOp:Eu,MinOp:gu,ConcatOp:Tu,ExOp:Au,PercentOp:Iu,ArrayAnchorOp:vu,TableSpecifier:Nu,BracketedString:yu,NeqOp:Ru,GteOp:Ou,LteOp:Su,GtOp:_u,EqOp:Lu,LtOp:xu}=za;class Cu extends Js{constructor(){super(za,{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(ru).image},{ALT:()=>e.CONSUME(mu).image},{ALT:()=>e.CONSUME(gu).image},{ALT:()=>e.CONSUME(pu).image},{ALT:()=>e.CONSUME(Eu).image},{ALT:()=>e.CONSUME(Au).image},{ALT:()=>e.CONSUME(Tu).image},{ALT:()=>e.CONSUME(_u).image},{ALT:()=>e.CONSUME(Lu).image},{ALT:()=>e.CONSUME(xu).image},{ALT:()=>e.CONSUME(Ru).image},{ALT:()=>e.CONSUME(Ou).image},{ALT:()=>e.CONSUME(Su).image},{ALT:()=>e.CONSUME(iu).image},{ALT:()=>e.CONSUME(ou).image},{ALT:()=>e.CONSUME(su).image}]));t.push([r,e.getLexerPosition(),Bc.includes(r)]),n.push(e.SUBRULE2(e.postfixOp))}),e.ACTION(()=>{let e=t.length;const r=Mc.length;for(let i=0;e>0&&i<r;i++){const r=Mc[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=vc(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(mu).image},{ALT:()=>e.CONSUME(gu).image}])),e.RULE("postfixOp",()=>{let t=e.SUBRULE(e.prefixOp);const n=[];return e.MANY(()=>{const t=e.OR([{ALT:()=>e.CONSUME(Iu).image},{ALT:()=>e.CONSUME(vu).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=Bc.includes(i);t=Nc(i,t,s),t=this._ensureWhitespace(t,o)}}),t}),e.RULE("prefixOp",()=>{const t=[];e.MANY(()=>{const n=e.OR([{ALT:()=>e.CONSUME(mu).image},{ALT:()=>e.CONSUME(gu).image},{ALT:()=>e.CONSUME(tu).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=Bc.includes(i);n=yc(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=vc(" ",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(nu);const n=e.SUBRULE2(e.intersectOp);e.ACTION(()=>{t.push(n)})}),t}),e.RULE("paren",()=>t("paren",cu,uu)),e.RULE("literalArray",()=>{let t={type:"row",value:[],isLiteral:!0};e.CONSUME(fu);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(nu).image},{ALT:()=>e.CONSUME(au).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(du));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(Zc),r=e.ACTION(()=>this._ensureWhitespace(Oc(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($c);return e.ACTION(()=>this._ensureWhitespace(Sc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Qc);return e.ACTION(()=>this._ensureWhitespace(_c(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Vc);return e.ACTION(()=>this._ensureWhitespace(Lc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Hc);return e.ACTION(()=>this._ensureWhitespace(xc(t.image),e.getLexerPosition()))}}])),e.RULE("literal",()=>e.OR([{ALT:()=>{const t=e.CONSUME(Zc);return e.ACTION(()=>this._ensureWhitespace(Oc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME($c);return e.ACTION(()=>this._ensureWhitespace(Sc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Qc);return e.ACTION(()=>this._ensureWhitespace(_c(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Vc);return e.ACTION(()=>this._ensureWhitespace(Lc(t.image),e.getLexerPosition()))}}])),e.RULE("function",()=>{const t=e.CONSUME(Kc).image.slice(0,-1),n=e.getLexerPosition(),r=e.SUBRULE(e.functionArguments);let i=e.ACTION(()=>this._ensureWhitespace(Tc(t,r),n,!0));const o=e.OPTION(()=>this.CONSUME(uu));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(nu),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(nu),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(yu),n=e.getLexerPosition();return e.ACTION(()=>{const r=t.image;let i=Ac("",[Ic(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(lu);const t=e.getLexerPosition();let n=Ac("",[e.SUBRULE(e.structuredArgument)]);const r=e.OPTION(()=>this.CONSUME(hu));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(zc).image.slice(0,-1),n=e.getLexerPosition(),r=e.SUBRULE(e.structuredArguments);let i=e.ACTION(()=>this._ensureWhitespace(Ac(t,r),n,!0));const o=e.OPTION(()=>this.CONSUME(hu));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(nu),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(nu),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(tu)),n=e.getLexerPosition(),r=e.OPTION2(()=>this.CONSUME(lu));let i=e.OR([{ALT:()=>{const t=e.CONSUME(Nu);return e.ACTION(()=>this._ensureWhitespace(Ic(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(yu);return e.ACTION(()=>this._ensureWhitespace(Ic(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(qc);return e.ACTION(()=>this._ensureWhitespace(Rc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Gc);return e.ACTION(()=>this._ensureWhitespace(Sc(t.image),e.getLexerPosition()))}}]);if(r){const t=e.OPTION3(()=>this.CONSUME(uu));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=yc(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(tu));let n=e.OR([{ALT:()=>{const t=e.CONSUME(Yc),n=e.getLexerPosition(),r=e.OPTION(()=>e.CONSUME(vu));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=mc(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(Nc("#",i,!0),n):i})}},{ALT:()=>{const t=e.CONSUME(qc);return e.ACTION(()=>this._ensureWhitespace(Rc(t.image),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Jc);return e.ACTION(()=>this._ensureWhitespace(function(e,t){const n=e.startsWith("$");n&&(e=e.substring(1));let r=mc(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(eu);return e.ACTION(()=>this._ensureWhitespace(gc(t.image,e.position),e.getLexerPosition()))}},{ALT:()=>{const t=e.CONSUME(Hc);return e.ACTION(()=>this._ensureWhitespace(xc(t.image),e.getLexerPosition()))}}]);return e.ACTION(()=>{t&&(n=yc(t,n,!0),n=this._ensureWhitespace(n,e.getLexerPosition()))}),n}),e.RULE("prefixSheetName",()=>e.OR([{ALT:()=>e.CONSUME(Xc).image.slice(0,-1)},{ALT:()=>e.CONSUME(Wc).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=Ka.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.n.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=Cc(i,(e,t)=>{let n=e.type;if("function"===n&&e.value&&e.value.toUpperCase().startsWith(wc)){const t=e.value.substring(6);let r=e.image.substring(6),i=e;"ANCHORARRAY"===t?(i=Nc("#",e.inputs[0],!0),r="#"):"SINGLE"===t?(i=yc("@",e.inputs[0],!0),r="@"):i=Tc(t,e.inputs),Pc(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=gc(e.image,s);return Pc(t,e),t}}}else if("cell"===n){const t=e.value;if(t.rowIndex===Number.MIN_SAFE_INTEGER||t.colIndex>=16384){const t=Rc(e.image);return Pc(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.n.Parse?t:new e.n.Parse(t.message,t)}const s=this.errors;if(s.length>0){o=bc(s[0],n)}const a=this.astErrors;if(a.length>0){o=bc(a[0],n)}return i=r?kc(r,o):{ast:null,evaluations:e.et.EmptyArray,executions:e.et.EmptyArray,precedentsAbsolute:e.et.EmptyArray,precedentsExecute:e.et.EmptyArray,precedentsNamed:null,precedentsRelative:e.et.EmptyArray,precedentsRoot:e.et.EmptyArray,references:e.et.EmptyArray,tokens:e.et.EmptyArray,error:o},i}}class ku{constructor(e,t){this._options=e,this._compiled=t}getTextAt(t,n,r=!1){return r?e.tokensToR1C1(this._compiled.tokens):e.tokensToA1(this._compiled.tokens,t,n)}getTokens(){return this._compiled.tokens}getError(){return this._compiled.error??null}isEquals(t){if(!(t&&t instanceof ku))return!1;if(this===t)return!0;const n=this._compiled.tokens,r=t._compiled.tokens;if(n.length!==r.length)return!1;return e.tokensToR1C1(n)===e.tokensToR1C1(r)}getReferences(){const t=this._compiled,n=t.references,r=n.length;if(0===r)return e.et.EmptyArray;const i=t.precedentsExecute,o=t.precedentsRelative,s=new Array(r);for(let e=0;e<r;e++){const r=i[n[e]],a=r.inputs;if(a&&2===a.length){const t=o[i[a[0]].value],n=o[i[a[1]].value];s[e]={colStart:t.colStart,rowStart:t.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,$colStart:t.$colStart,$rowStart:t.$rowStart,$colEnd:n.$colEnd,$rowEnd:n.$rowEnd,sheetName:t.sheetName}}else if("cell"===r.node.type){const t=o[r.value];s[e]={...t}}else if("named"===r.op){const n=t.precedentsNamed;s[e]=n[r.value]}else"error"===r.op&&(s[e]=r.node.value)}return s}setReferenceAt(t,n){const r=this._compiled,i=r.references;if(0===i.length)return e.et.EmptyArray;const o=r.precedentsExecute,s=i[t];if(void 0===s)throw new Error(`Invalid reference index: ${t}`);const a=o[s],c=a.node,u=c.inputs??e.et.EmptyArray;let l,h,f=!1;n&&(l={colIndex:n.colStart,rowIndex:n.rowStart,$colIndex:n.$colStart??!1,$rowIndex:n.$rowStart??!1},n.sheetName&&(l.sheetName=n.sheetName),f=!e.j.isSingleCell(n),f&&(h={colIndex:n.colEnd,rowIndex:n.rowEnd,$colIndex:n.$colEnd??!1,$rowIndex:n.$rowEnd??!1},n.colEnd===Number.MAX_SAFE_INTEGER&&(h.colIndex=Number.MIN_SAFE_INTEGER),n.rowEnd===Number.MAX_SAFE_INTEGER&&(h.rowIndex=Number.MIN_SAFE_INTEGER)));const d=2===u.length;let p=-1,m=-1;if(d)p=u[0].evalIndex,m=u[1].evalIndex;else{if("cell"!==c.type)throw"named"===a.op?new Error("Cannot setReference for a named reference"):new Error(`Invalidate reference index: ${t}`);p=c.evalIndex}const E=this._compiled.ast,g=Cc(E,e=>{if(!e||!e.isReference)return;const t=e.type;if(!n&&Uc.includes(e.value)){const e=u[0],t=u[1];let n=e.evalIndex===p,r=t.evalIndex===m;if(n||r){const e=xc();return e.image="#REF!",e}}if(!("cell"===t||"error"===t))return;const r=e.evalIndex;let i,o=r===p;if(o||r===m){if(n)if(d===f){let t=o?l:h;i={...e},i.value=t,i.image=null}else i=f?vc(":",Ec(l),Ec(h),!0):Ec(l);else i=xc(),i.image="#REF!";return i}});if(g===E)return this;const T=kc(g,this._compiled.error),A=this._options;return new ku(A,T)}_resolveNamed(t,n,r,i){const o=this._options?.getNamed;if(!o)return e.n.BuiltIn.Name;let s=o?.(t,this._options.getSheetName?.())?.[0];return s?(s.isFormulaError||(s=e.toAbsoluteRange(s,n,r,i)),s):e.n.BuiltIn.Name}getDirectPrecedentsAt(t,n,r=!1,i,o){const s=this._compiled,a=s.precedentsRoot,c=a.length;if(0===c)return e.et.EmptyArray;const u=s.precedentsRelative,l=s.precedentsAbsolute,h=u.length;for(let r=0;r<h;r++){const i=u[r];let o=l[r],s=e.toAbsoluteRange(i,t,n,o);l[r]=s}let f=!1;const d=s.precedentsExecute,p=d.length,m=bu;for(let r=0;r<p;r++){const i=d[r],o=i.op;if(!o){const e=l[i.value];m[i.index]=e;continue}if("named"===o){f=!0,m[i.index]=this._resolveNamed(i.node.value,t,n);continue}if("error"===o){m[i.index]=i.node.value;continue}if("@"===o||"#"===o){m[i.index]=m[i.inputs[0]];continue}const s=i.inputs;if(!s)continue;let a=m[s[0]];if(void 0===a){m[i.index]=e.n.BuiltIn.Value;continue}if(a.isFormulaError){m[i.index]=a;continue}let c,u=m[s[1]];void 0!==u?u.isFormulaError?m[i.index]=u:(" "===o?c=e.j.intersectRanges(a,u):":"!==o&&".:."!==o&&":."!==o&&".:"!==o||(c=m[i.index]=e.j.unionRanges(a,u)),m[i.index]=c??e.n.BuiltIn.Null):m[i.index]=e.n.BuiltIn.Value}const E=new Array(c);for(let e=0;e<c;e++){const t=a[e],n=m[t];if(E[e]=void 0!==n?.rowStart?{...n}:n,i||o){const r=d[t];f&&"named"===r.op?(i&&(i[e]=n.$colStart||n.$colEnd),o&&(o[e]=n.$rowStart||n.$rowEnd)):(i&&(i[e]=r.hasVerticalAbs),o&&(o[e]=r.hasHorizontalAbs))}}return E}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(Cc(a.ast,t=>{t.evalIndex===n&&(e=t)}),!e)throw new Error(`Invalid evalIndex: ${n}`);a=kc(e,a.error)}if(a.error)return a.error;const c=a.evaluations,u=a.executions;let l,h;r||(r=this._resolvePrecedents(t));const f=a.precedentsExecute,d=a.precedentsRelative,p=a.precedentsAbsolute,m=f.length;for(let n=0;n<m;n++){const r=f[n],i=r.op;if(i){if("named"===i){const e=r.node;let n=this._resolveNamed(r.node.value,o,s);void 0!==n?.colStart&&(n=t.getReference(n)),c[e.evalIndex]=n}else if("error"===i){const e=r.node;c[e.evalIndex]=r.node.value}}else{const t=d[r.value];let i=p[n];const a=e.toAbsoluteRange(t,o,s,i),u=r.node;c[u.evalIndex]=a}}const E=a.precedentsRoot,g=E.length;if(g!==r.length)return e.n.BuiltIn.Parse;for(let e=0;e<g;e++){const t=f[E[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 T;const A=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.n.BuiltIn.Value,o=e.minCoerce(o,null),o;case"function":T||(T=new Array(i)),T.length!==i&&(T.length=i);for(let e=0;e<i;e++)T[e]=c[r[e].evalIndex];return o=this._callFunction(t,n,T),o&&"function"==typeof o.then?o.then(r=>{r=e.minCoerce(r,t),o instanceof e.n.Known&&(h=o),c[n.evalIndex]=r}).catch(t=>{const r=t instanceof e.n.Known?t:new e.n.Value("Uncaught error",{cause:t});c[n.evalIndex]=r}):o instanceof e.n.Known&&(h=o),o;case"prefix":case"postfix":let f=c[r[0].evalIndex];if(f&&f.isFormulaError)return f;const d=n.fn;return o=d?d(t,f):e.n.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 I=u.length;for(let e=0;e<I;e++){const t=u[e];if(h)return h;if(l)l=l.then(()=>{const e=A(t);return c[t.evalIndex]=e,e});else{const e=A(t);c[t.evalIndex]=e,e&&"function"==typeof e.then&&(l=e)}}if(l)return l.then(()=>{const e=c[c.length-1];return this._finalizeReturnValue(t,e)});const v=c[c.length-1];return this._finalizeReturnValue(t,v)}_resolvePrecedents(t){const n=t.getPosition(),r=n?.rowIndex??0,i=n?.colIndex??0;const o=this.getDirectPrecedentsAt(r,i),s=o.length;let a;if(s>0){a=new Array(s);for(let n=0;n<s;n++){const r=o[n];if(r instanceof e.n.Known)a[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]);a[n]=e}else a[n]=t.getReference(r)}}else a=e.et.EmptyArray;return a}wrapImplicit(t,n,r){const i=this._compiled.ast;if(!i||!i.isReference)return this;if("cell"===i.type)return this;if("@"===i.value)return this;if(!r)return this;const o=e.colToString(n)+e.rowToString(t);if(r.has(o))return this;const s=kc(yc("@",i,!0),this._compiled.error);return new ku(this._options,s)}_callFunction(t,n,r){const i=n?.cacheFn??t.getFunction(n.value);if(!i)return new e.n.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.n.Known?t:new e.n.Value(t.message,{cause:t})}return o||(this._context=null),void 0===s?new e.n.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.n.BuiltIn.Value);else try{n=t.getRange(n)}catch(t){n=e.n.BuiltIn.Value}return n?.isIRange?1===n.size?(n=n.getValueAt(0,0,Pu),null===(n=e.minCoerce(n,t))&&(n=0)):n=n.fillEmpty(0):null===(n=e.minCoerce(n,t))&&(n=0),n}get[Symbol.toStringTag](){return"[FormulaBlock]"}toString(){const t=this._compiled;if(t.error)return t.error.toString();const n=this._context;if(n){const e=n.getPosition();return this.getTextAt(e.rowIndex,e.colIndex)}return e.tokensToR1C1(t.tokens)}}const bu=new Array(20);for(let e=0;e<bu.length;e++)bu[e]={colStart:0,rowStart:0,colEnd:0,rowEnd:0,sheetName:null};const Pu={type:null};exports.FormulaParser=class{constructor(t){this._options={getEntireCoords:e.defaultGetEntireCoords,...t},this._astBuilder=new Cu}parse(e,t){const n=e.getPosition();n.sheetName;const r=this._astBuilder.build(e,t);return new ku(this._options,r)}eval(e,t){return this.parse(e,t).evaluate(e)}};