likec4 1.55.1 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__app__/chunks/AIChat2.mjs +2 -0
- package/__app__/chunks/DiagramActorProvider.mjs +10 -0
- package/__app__/chunks/EmbedPage.mjs +1 -0
- package/__app__/chunks/ExportPage.mjs +2 -0
- package/__app__/chunks/LikeC4Diagram.mjs +19 -0
- package/__app__/chunks/LikeC4Styles.mjs +48 -0
- package/__app__/chunks/Markdown.mjs +1 -0
- package/__app__/chunks/NavigationPanel.mjs +1 -0
- package/__app__/chunks/ViewReact.mjs +1 -0
- package/__app__/chunks/adhoc-editor.mjs +1 -0
- package/__app__/chunks/aichat.mjs +1 -0
- package/__app__/chunks/box.mjs +1 -0
- package/__app__/chunks/create-style-context.mjs +1 -0
- package/__app__/chunks/css.mjs +1 -0
- package/__app__/chunks/factory.mjs +1 -0
- package/__app__/chunks/hooks.mjs +1 -0
- package/__app__/chunks/hstack.mjs +1 -0
- package/__app__/chunks/libs/@dagrejs/dagre.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/core.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/dom.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/react.mjs +1 -0
- package/__app__/chunks/libs/@mantine/core.mjs +41 -0
- package/__app__/chunks/libs/@mantine/hooks.mjs +1 -0
- package/__app__/chunks/libs/@nanostores/react.mjs +1 -0
- package/__app__/chunks/libs/@react-hookz/web.mjs +1 -0
- package/__app__/chunks/libs/@tabler/icons-react.mjs +358 -0
- package/__app__/chunks/libs/@tanstack/ai-client.mjs +2 -0
- package/__app__/chunks/libs/@tanstack/ai-react-ui.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/ai-react.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/ai.mjs +2 -0
- package/__app__/chunks/libs/@tanstack/history.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/react-router.mjs +3 -0
- package/__app__/chunks/libs/@tanstack/router-core.mjs +1 -0
- package/__app__/chunks/libs/@xstate/react.mjs +1 -0
- package/__app__/chunks/libs/@xstate/store.mjs +1 -0
- package/__app__/chunks/libs/@xyflow/react.mjs +7 -0
- package/__app__/chunks/libs/@zag-js/anatomy.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/collection.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/core.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/react.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/tree-view.mjs +1 -0
- package/__app__/chunks/libs/bezier-js.mjs +1 -0
- package/__app__/chunks/libs/copy-anything.mjs +1 -0
- package/__app__/chunks/libs/d3-path.mjs +1 -0
- package/__app__/chunks/libs/d3-shape.mjs +1 -0
- package/__app__/chunks/libs/fast-equals.mjs +1 -0
- package/__app__/chunks/libs/framer-motion.mjs +9 -0
- package/__app__/chunks/libs/html-to-image.mjs +2 -0
- package/__app__/chunks/libs/motion-dom.mjs +1 -0
- package/__app__/chunks/libs/nanostores.mjs +1 -0
- package/__app__/chunks/libs/react-error-boundary.mjs +1 -0
- package/__app__/chunks/libs/react-resizable-panels.mjs +1 -0
- package/__app__/chunks/libs/remeda.mjs +1 -0
- package/__app__/chunks/libs/superjson.mjs +1 -0
- package/__app__/chunks/libs/zod.mjs +64 -0
- package/__app__/chunks/rolldown-runtime.mjs +1 -0
- package/__app__/chunks/styles.css.mjs +1 -0
- package/__app__/chunks/txt.mjs +1 -0
- package/__app__/chunks/useLikeC4Project.mjs +1 -0
- package/__app__/codegen/react.mjs +11 -0
- package/__app__/codegen/webcomponent.mjs +942 -0
- package/__app__/src/aichat/index.mjs +1 -0
- package/__app__/src/fonts.css +1 -1
- package/__app__/src/main.mjs +45 -0
- package/__app__/src/pages/AdHocViewEditor.mjs +1 -0
- package/__app__/src/pages/EmbedPage.mjs +1 -0
- package/__app__/src/pages/ExportPage.mjs +1 -0
- package/__app__/src/pages/ProjectsOverview.mjs +1 -0
- package/__app__/src/pages/ViewAsD2.mjs +1 -0
- package/__app__/src/pages/ViewAsDot.mjs +1 -0
- package/__app__/src/pages/ViewAsMmd.mjs +1 -0
- package/__app__/src/pages/ViewAsPuml.mjs +1 -0
- package/__app__/src/pages/ViewEditor.mjs +1 -0
- package/__app__/src/pages/ViewReact.mjs +1 -0
- package/__app__/src/style.css +1 -1
- package/config/schema.json +14 -41
- package/dist/chunks/enableServer.mjs +1 -0
- package/dist/chunks/filenames.mjs +17 -0
- package/dist/{_chunks → chunks}/index.d.mts +2 -1
- package/dist/{_chunks → chunks}/index2.d.mts +639 -388
- package/dist/chunks/libs/@chevrotain/gast.mjs +1 -0
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
- package/dist/chunks/libs/@chevrotain/utils.mjs +1 -0
- package/dist/chunks/libs/@hono/mcp.mjs +70 -0
- package/dist/chunks/libs/@hono/node-server.mjs +1 -0
- package/dist/{_chunks → chunks}/libs/@logtape/logtape.d.mts +2 -0
- package/dist/chunks/libs/@logtape/logtape.mjs +4 -0
- package/dist/chunks/libs/@lume/kiwi.mjs +1 -0
- package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +12 -0
- package/dist/chunks/libs/@ts-graphviz/ast.mjs +3 -0
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +9 -0
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -0
- package/dist/chunks/libs/ajv.mjs +1 -0
- package/dist/chunks/libs/ansi-align.mjs +2 -0
- package/dist/chunks/libs/ansi-regex.mjs +1 -0
- package/dist/chunks/libs/ansi-styles.mjs +1 -0
- package/dist/chunks/libs/atomically.mjs +1 -0
- package/dist/chunks/libs/birpc.mjs +1 -0
- package/dist/chunks/libs/boxen.mjs +22 -0
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -0
- package/dist/chunks/libs/chevrotain.mjs +58 -0
- package/dist/chunks/libs/conf.mjs +1 -0
- package/dist/chunks/libs/defu.mjs +1 -0
- package/dist/chunks/libs/destr.mjs +1 -0
- package/dist/chunks/libs/eventemitter3.mjs +1 -0
- package/dist/chunks/libs/find-up-simple.mjs +1 -0
- package/dist/chunks/libs/get-port.mjs +1 -0
- package/dist/chunks/libs/hono.mjs +1 -0
- package/dist/chunks/libs/is-docker.mjs +1 -0
- package/dist/chunks/libs/is-error-instance.mjs +1 -0
- package/dist/chunks/libs/is-inside-container.mjs +1 -0
- package/dist/chunks/libs/is-plain-obj.mjs +1 -0
- package/dist/chunks/libs/isexe.mjs +1 -0
- package/dist/chunks/libs/json5.mjs +14 -0
- package/dist/chunks/libs/khroma.mjs +1 -0
- package/dist/chunks/libs/ky.mjs +3 -0
- package/dist/{_chunks → chunks}/libs/langium.d.mts +9 -9
- package/dist/chunks/libs/langium.mjs +32 -0
- package/dist/chunks/libs/merge-error-cause.mjs +2 -0
- package/dist/chunks/libs/p-debounce.mjs +1 -0
- package/dist/chunks/libs/p-limit.mjs +1 -0
- package/dist/chunks/libs/p-queue.mjs +1 -0
- package/dist/chunks/libs/p-timeout.mjs +1 -0
- package/dist/chunks/libs/package-manager-detector.mjs +1 -0
- package/dist/chunks/libs/package-up.mjs +1 -0
- package/dist/chunks/libs/pako.mjs +3 -0
- package/dist/chunks/libs/parse-ms.mjs +1 -0
- package/dist/chunks/libs/pathe.mjs +1 -0
- package/dist/chunks/libs/picomatch.mjs +1 -0
- package/dist/chunks/libs/pretty-ms.mjs +1 -0
- package/dist/chunks/libs/remeda.mjs +1 -0
- package/dist/chunks/libs/safe-stringify.mjs +1 -0
- package/dist/chunks/libs/strip-indent.mjs +1 -0
- package/dist/chunks/libs/tinyrainbow.mjs +1 -0
- package/dist/chunks/libs/ts-graphviz.mjs +1 -0
- package/dist/chunks/libs/ufo.mjs +1 -0
- package/dist/chunks/libs/unctx.mjs +1 -0
- package/dist/chunks/libs/unstorage.mjs +1 -0
- package/dist/chunks/libs/vscode-languageserver.mjs +1 -0
- package/dist/chunks/libs/which.mjs +1 -0
- package/dist/chunks/libs/word-wrap.mjs +12 -0
- package/dist/{_chunks → chunks}/libs/zod.d.mts +62 -25
- package/dist/chunks/node.mjs +93 -0
- package/dist/chunks/plugin.mjs +593 -0
- package/dist/chunks/rolldown-runtime.mjs +1 -0
- package/dist/chunks/sequence-view.mjs +1 -0
- package/dist/cli/index.mjs +188 -59
- package/dist/config/index.d.mts +1 -2
- package/dist/config/index.mjs +1 -1
- package/dist/index.d.mts +2 -135
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +3 -2
- package/dist/model/index.mjs +1 -1
- package/dist/vite-plugin/index.d.mts +90 -9
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -0
- package/dist/{_chunks/libs/@nanostores/react.d.mts → vite-plugin/internal/index.d.mts} +103 -45
- package/dist/vite-plugin/internal/index.mjs +1 -0
- package/package.json +74 -80
- package/react/index.d.mts +84 -78
- package/react/index.mjs +51954 -53701
- package/vite-plugin/internal/package.json +2 -2
- package/vite-plugin-modules.d.ts +18 -0
- package/__app__/react/likec4.tsx +0 -25
- package/__app__/src/ProjectsOverview.js +0 -16
- package/__app__/src/const.js +0 -19
- package/__app__/src/likec4.js +0 -21254
- package/__app__/src/main.js +0 -7
- package/__app__/src/routes/index.js +0 -324
- package/__app__/src/routes/projects.js +0 -193
- package/__app__/src/routes/single.js +0 -1983
- package/__app__/src/vendors.js +0 -52683
- package/__app__/src/webcomponent.js +0 -68
- package/dist/THIRD-PARTY-LICENSES.md +0 -1609
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -30
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
- package/dist/_chunks/libs/@chevrotain/types.d.mts +0 -1
- package/dist/_chunks/libs/@chevrotain/utils.mjs +0 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +0 -45
- package/dist/_chunks/libs/@hono/node-server.mjs +0 -1
- package/dist/_chunks/libs/@logtape/logtape.mjs +0 -4
- package/dist/_chunks/libs/@lume/kiwi.mjs +0 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
- package/dist/_chunks/libs/@nanostores/react.mjs +0 -1
- package/dist/_chunks/libs/ajv.mjs +0 -1
- package/dist/_chunks/libs/ansi-align.mjs +0 -2
- package/dist/_chunks/libs/ansi-regex.mjs +0 -1
- package/dist/_chunks/libs/ansi-styles.mjs +0 -1
- package/dist/_chunks/libs/atomically.mjs +0 -1
- package/dist/_chunks/libs/birpc.mjs +0 -1
- package/dist/_chunks/libs/boxen.mjs +0 -22
- package/dist/_chunks/libs/chevrotain-allstar.mjs +0 -2
- package/dist/_chunks/libs/chevrotain.mjs +0 -58
- package/dist/_chunks/libs/conf.mjs +0 -1
- package/dist/_chunks/libs/defu.mjs +0 -1
- package/dist/_chunks/libs/destr.mjs +0 -1
- package/dist/_chunks/libs/esm-env.mjs +0 -1
- package/dist/_chunks/libs/eventemitter3.mjs +0 -1
- package/dist/_chunks/libs/fast-equals.mjs +0 -1
- package/dist/_chunks/libs/find-up-simple.mjs +0 -1
- package/dist/_chunks/libs/get-port.mjs +0 -1
- package/dist/_chunks/libs/is-docker.mjs +0 -1
- package/dist/_chunks/libs/is-error-instance.mjs +0 -1
- package/dist/_chunks/libs/is-inside-container.mjs +0 -1
- package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
- package/dist/_chunks/libs/isexe.mjs +0 -1
- package/dist/_chunks/libs/json5.mjs +0 -14
- package/dist/_chunks/libs/khroma.mjs +0 -1
- package/dist/_chunks/libs/ky.mjs +0 -3
- package/dist/_chunks/libs/langium.mjs +0 -33
- package/dist/_chunks/libs/merge-error-cause.mjs +0 -2
- package/dist/_chunks/libs/p-limit.mjs +0 -1
- package/dist/_chunks/libs/p-queue.mjs +0 -1
- package/dist/_chunks/libs/p-timeout.mjs +0 -1
- package/dist/_chunks/libs/package-manager-detector.mjs +0 -1
- package/dist/_chunks/libs/package-up.mjs +0 -1
- package/dist/_chunks/libs/pako.mjs +0 -1
- package/dist/_chunks/libs/parse-ms.mjs +0 -1
- package/dist/_chunks/libs/pathe.mjs +0 -1
- package/dist/_chunks/libs/picomatch.mjs +0 -1
- package/dist/_chunks/libs/pretty-ms.mjs +0 -1
- package/dist/_chunks/libs/remeda.mjs +0 -2
- package/dist/_chunks/libs/safe-stringify.mjs +0 -1
- package/dist/_chunks/libs/strip-indent.mjs +0 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +0 -1
- package/dist/_chunks/libs/ts-graphviz.d.mts +0 -10
- package/dist/_chunks/libs/ts-graphviz.mjs +0 -4
- package/dist/_chunks/libs/ufo.mjs +0 -1
- package/dist/_chunks/libs/unstorage.mjs +0 -1
- package/dist/_chunks/libs/vscode-languageserver.mjs +0 -1
- package/dist/_chunks/libs/which.mjs +0 -1
- package/dist/_chunks/libs/word-wrap.mjs +0 -12
- package/dist/_chunks/node.mjs +0 -76
- package/dist/_chunks/rolldown-runtime.mjs +0 -1
- package/dist/_chunks/sequence.mjs +0 -1
- package/dist/_chunks/src.mjs +0 -17
- package/dist/_chunks/src2.mjs +0 -499
- package/dist/vite-plugin/internal.d.mts +0 -44
- package/dist/vite-plugin/internal.mjs +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import{i as e}from"../rolldown-runtime.mjs";import{n as t,t as n}from"./@chevrotain/regexp-to-ast.mjs";import{$ as r,A as i,B as a,C as o,D as s,E as c,F as l,G as u,H as d,I as f,J as p,K as m,L as h,M as g,N as _,O as v,P as y,Q as ee,R as te,S as b,T as x,U as S,V as C,W as w,X as ne,Y as T,Z as E,_ as D,_t as O,a as k,at as re,b as A,c as j,ct as ie,d as M,dt as ae,et as oe,f as N,ft as se,g as ce,gt as le,h as P,i as ue,it as de,j as fe,k as pe,l as F,lt as I,m as me,mt as he,n as ge,nt as _e,o as L,ot as ve,p as ye,pt as R,q as be,r as xe,rt as Se,s as z,st as Ce,t as B,tt as we,u as V,ut as Te,v as Ee,vt as De,w as H,x as U,y as W,z as Oe}from"./@chevrotain/gast.mjs";import{i as ke,n as Ae,r as je,t as Me}from"./@chevrotain/utils.mjs";var Ne=Object.create,Pe=function(){function object(){}return function(e){if(!se(e))return{};if(Ne)return Ne(e);object.prototype=e;var t=new object;return object.prototype=void 0,t}}();function noop(){}function copyArray(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function arrayIncludes(e,t){return!!(e!=null&&e.length)&&ve(e,t,0)>-1}var Fe=O?O.isConcatSpreadable:void 0;function isFlattenable(e){return R(e)||E(e)||!!(Fe&&e&&e[Fe])}function baseFlatten(e,t,n,r,i){var a=-1,o=e.length;for(n||=isFlattenable,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?baseFlatten(s,t-1,n,r,i):d(i,s):r||(i[i.length]=s)}return i}function flatten(e){return e!=null&&e.length?baseFlatten(e,1):[]}function baseSlice(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function arrayReduce(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function baseAssign(e,t){return e&&_e(t,u(t),e)}function baseAssignIn(e,t){return e&&_e(t,S(t),e)}var Ie=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Le=Ie&&typeof module==`object`&&module&&!module.nodeType&&module,Re=Le&&Le.exports===Ie?De.Buffer:void 0,ze=Re?Re.allocUnsafe:void 0;function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=ze?ze(n):new e.constructor(n);return e.copy(r),r}function copySymbols(e,t){return _e(e,te(e),t)}function copySymbolsIn(e,t){return _e(e,h(e),t)}var Be=Object.prototype.hasOwnProperty;function initCloneArray(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&Be.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new g(t).set(new g(e)),t}function cloneDataView(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var Ve=/\w*$/;function cloneRegExp(e){var t=new e.constructor(e.source,Ve.exec(e));return t.lastIndex=e.lastIndex,t}var He=O?O.prototype:void 0,Ue=He?He.valueOf:void 0;function cloneSymbol(e){return Ue?Object(Ue.call(e)):{}}function cloneTypedArray(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var We=`[object Boolean]`,Ge=`[object Date]`,Ke=`[object Map]`,qe=`[object Number]`,Je=`[object RegExp]`,Ye=`[object Set]`,Xe=`[object String]`,Ze=`[object Symbol]`,Qe=`[object ArrayBuffer]`,$e=`[object DataView]`,et=`[object Float32Array]`,tt=`[object Float64Array]`,nt=`[object Int8Array]`,rt=`[object Int16Array]`,it=`[object Int32Array]`,at=`[object Uint8Array]`,ot=`[object Uint8ClampedArray]`,st=`[object Uint16Array]`,ct=`[object Uint32Array]`;function initCloneByTag(e,t,n){var r=e.constructor;switch(t){case Qe:return cloneArrayBuffer(e);case We:case Ge:return new r(+e);case $e:return cloneDataView(e,n);case et:case tt:case nt:case rt:case it:case at:case ot:case st:case ct:return cloneTypedArray(e,n);case Ke:return new r;case qe:case Xe:return new r(e);case Je:return cloneRegExp(e);case Ye:return new r;case Ze:return cloneSymbol(e)}}function initCloneObject(e){return typeof e.constructor==`function`&&!ee(e)?Pe(C(e)):{}}var lt=`[object Map]`;function baseIsMap(e){return le(e)&&_(e)==lt}var ut=p&&p.isMap,dt=ut?T(ut):baseIsMap,ft=`[object Set]`;function baseIsSet(e){return le(e)&&_(e)==ft}var pt=p&&p.isSet,mt=pt?T(pt):baseIsSet,ht=1,gt=2,_t=4,vt=`[object Arguments]`,yt=`[object Array]`,bt=`[object Boolean]`,xt=`[object Date]`,St=`[object Error]`,Ct=`[object Function]`,wt=`[object GeneratorFunction]`,Tt=`[object Map]`,Et=`[object Number]`,Dt=`[object Object]`,Ot=`[object RegExp]`,kt=`[object Set]`,At=`[object String]`,jt=`[object Symbol]`,Mt=`[object WeakMap]`,Nt=`[object ArrayBuffer]`,Pt=`[object DataView]`,Ft=`[object Float32Array]`,It=`[object Float64Array]`,Lt=`[object Int8Array]`,Rt=`[object Int16Array]`,zt=`[object Int32Array]`,Bt=`[object Uint8Array]`,Vt=`[object Uint8ClampedArray]`,Ht=`[object Uint16Array]`,Ut=`[object Uint32Array]`,G={};G[vt]=G[yt]=G[Nt]=G[Pt]=G[bt]=G[xt]=G[Ft]=G[It]=G[Lt]=G[Rt]=G[zt]=G[Tt]=G[Et]=G[Dt]=G[Ot]=G[kt]=G[At]=G[jt]=G[Bt]=G[Vt]=G[Ht]=G[Ut]=!0,G[St]=G[Ct]=G[Mt]=!1;function baseClone(e,t,n,r,i,o){var s,c=t&ht,d=t>,p=t&_t;if(n&&(s=i?n(e,r,i,o):n(e)),s!==void 0)return s;if(!se(e))return e;var m=R(e);if(m){if(s=initCloneArray(e),!c)return copyArray(e,s)}else{var h=_(e),g=h==Ct||h==wt;if(ne(e))return cloneBuffer(e,c);if(h==Dt||h==vt||g&&!i){if(s=d||g?{}:initCloneObject(e),!c)return d?copySymbolsIn(e,baseAssignIn(s,e)):copySymbols(e,baseAssign(s,e))}else{if(!G[h])return i?e:{};s=initCloneByTag(e,h,c)}}o||=new a;var v=o.get(e);if(v)return v;o.set(e,s),mt(e)?e.forEach(function(r){s.add(baseClone(r,t,n,r,e,o))}):dt(e)&&e.forEach(function(r,i){s.set(i,baseClone(r,t,n,i,e,o))});var y=m?void 0:(p?d?l:f:d?S:u)(e);return ie(y||e,function(r,i){y&&(i=r,r=e[i]),Se(s,i,baseClone(r,t,n,i,e,o))}),s}var Wt=4;function clone(e){return baseClone(e,Wt)}function compact(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function arrayAggregator(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function baseAggregator(e,t,n,r){return c(e,function(e,i,a){t(r,e,n(e),a)}),r}function createAggregator(e,t){return function(n,r){var i=R(n)?arrayAggregator:baseAggregator,a=t?t():{};return i(n,e,s(r,2),a)}}var Gt=Object.prototype,Kt=Gt.hasOwnProperty,qt=we(function(e,t){e=Object(e);var n=-1,i=t.length,a=i>2?t[2]:void 0;for(a&&r(t[0],t[1],a)&&(i=1);++n<i;)for(var o=t[n],s=S(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===void 0||de(d,Gt[u])&&!Kt.call(e,u))&&(e[u]=o[u])}return e});function isArrayLikeObject(e){return le(e)&&oe(e)}function arrayIncludesWith(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var Jt=200;function baseDifference(e,t,n,r){var a=-1,o=arrayIncludes,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=he(t,T(n))),r?(o=arrayIncludesWith,s=!1):t.length>=Jt&&(o=i,s=!1,t=new fe(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var Yt=we(function(e,t){return isArrayLikeObject(e)?baseDifference(e,baseFlatten(t,1,isArrayLikeObject,!0)):[]});function last(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function drop(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ae(t),baseSlice(e,t<0?0:t,r)):[]}function dropRight(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ae(t),t=r-t,baseSlice(e,0,t<0?0:t)):[]}function baseFilter(e,t){var n=[];return c(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function filter(e,t){return(R(e)?Oe:baseFilter)(e,s(t,3))}function createFind(e){return function(t,predicate,n){var r=Object(t);if(!oe(t)){var i=s(predicate,3);t=u(t),predicate=function(e){return i(r[e],e,r)}}var a=e(t,predicate,n);return a>-1?r[i?t[a]:a]:void 0}}var Xt=Math.max;function findIndex(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ae(n);return i<0&&(i=Xt(r+i,0)),Ce(e,s(t,3),i)}var K=createFind(findIndex);function head(e){return e&&e.length?e[0]:void 0}function flatMap(e,t){return baseFlatten(o(e,t),1)}var Zt=Object.prototype.hasOwnProperty,Qt=createAggregator(function(e,t,n){Zt.call(e,n)?e[n].push(t):re(e,n,[t])}),$t=Object.prototype.hasOwnProperty;function baseHas(e,t){return e!=null&&$t.call(e,t)}function has(e,t){return e!=null&&v(e,t,baseHas)}var en=Math.max;function indexOf(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ae(n);return i<0&&(i=en(r+i,0)),ve(e,t,i)}var tn=`[object Map]`,nn=`[object Set]`,rn=Object.prototype.hasOwnProperty;function isEmpty(e){if(e==null)return!0;if(oe(e)&&(R(e)||typeof e==`string`||typeof e.splice==`function`||ne(e)||be(e)||E(e)))return!e.length;var t=_(e);if(t==tn||t==nn)return!e.size;if(ee(e))return!m(e).length;for(var n in e)if(rn.call(e,n))return!1;return!0}function isUndefined(e){return e===void 0}var an=`Expected a function`;function negate(e){if(typeof e!=`function`)throw TypeError(an);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)}}function baseReduce(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function reduce(e,t,n){var r=R(e)?arrayReduce:baseReduce,i=arguments.length<3;return r(e,s(t,4),n,i,c)}function reject(e,t){return(R(e)?Oe:baseFilter)(e,negate(s(t,3)))}var on=y&&1/pe(new y([,-0]))[1]==1/0?function(e){return new y(e)}:noop,sn=200;function baseUniq(e,t,n){var r=-1,a=arrayIncludes,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=arrayIncludesWith;else if(o>=sn){var u=t?null:on(e);if(u)return pe(u);s=!1,a=i,l=new fe}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function uniq(e){return e&&e.length?baseUniq(e):[]}var RestWalker=class{walk(e,t=[]){x(e.definition,(n,r)=>{let i=drop(e.definition,r+1);if(n instanceof j)this.walkProdRef(n,i,t);else if(n instanceof P)this.walkTerminal(n,i,t);else if(n instanceof z)this.walkFlat(n,i,t);else if(n instanceof F)this.walkOption(n,i,t);else if(n instanceof M)this.walkAtLeastOne(n,i,t);else if(n instanceof N)this.walkAtLeastOneSep(n,i,t);else if(n instanceof ye)this.walkManySep(n,i,t);else if(n instanceof V)this.walkMany(n,i,t);else if(n instanceof L)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new F({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new F({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);x(e.definition,e=>{let t=new z({definition:[e]});this.walk(t,r)})}};function restForRepetitionWithSeparator(e,t,n){return[new F({definition:[new P({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function first(e){if(e instanceof j)return first(e.referencedRule);if(e instanceof P)return firstForTerminal(e);if(ue(e))return firstForSequence(e);if(ge(e))return firstForBranching(e);throw Error(`non exhaustive match`)}function firstForSequence(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=xe(a),t=t.concat(first(a)),r+=1,i=n.length>r;return uniq(t)}function firstForBranching(e){return uniq(flatten(o(e.definition,e=>first(e))))}function firstForTerminal(e){return[e.terminalType]}const cn=`_~IN~_`;var ResyncFollowsWalker=class extends RestWalker{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=buildBetweenProdsFollowPrefix(e.referencedRule,e.idx)+this.topProd.name,i=first(new z({definition:t.concat(n)}));this.follows[r]=i}};function computeAllProdsFollows(e){let t={};return x(e,e=>{w(t,new ResyncFollowsWalker(e).startWalking())}),t}function buildBetweenProdsFollowPrefix(e,t){return e.name+t+cn}let ln={};const un=new t;function getRegExpAst(e){let t=e.toString();if(ln.hasOwnProperty(t))return ln[t];{let e=un.pattern(t);return ln[t]=e,e}}function clearRegExpParserCache(){ln={}}const dn=`Complement Sets are not supported for first char optimization`,fn=`Unable to use "first char" lexer optimizations:
|
|
2
|
+
`;function getOptimizedStartCodesIndices(e,t=!1){try{let t=getRegExpAst(e);return firstCharOptimizedIndices(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===dn)t&&ke(`${fn}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
|
|
3
|
+
This will disable the lexer's first char optimizations.
|
|
4
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
|
|
5
|
+
This will disable the lexer's first char optimizations.
|
|
6
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),je(`${fn}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function firstCharOptimizedIndices(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)firstCharOptimizedIndices(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:addOptimizedIdxToResult(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(dn);x(a.value,e=>{if(typeof e==`number`)addOptimizedIdxToResult(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)addOptimizedIdxToResult(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)addOptimizedIdxToResult(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=charCodeToOptimizedIndex(e),a=charCodeToOptimizedIndex(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:firstCharOptimizedIndices(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&isWholeOptional(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return U(t)}function addOptimizedIdxToResult(e,t,n){let r=charCodeToOptimizedIndex(e);t[r]=r,n===!0&&handleIgnoreCase(e,t)}function handleIgnoreCase(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=charCodeToOptimizedIndex(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=charCodeToOptimizedIndex(e.charCodeAt(0));t[n]=n}}}function findCode(e,t){return K(e.value,e=>{if(typeof e==`number`)return A(t,e);{let n=e;return K(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function isWholeOptional(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?R(e.value)?H(e.value,isWholeOptional):isWholeOptional(e.value):!1}var CharCodeFinder=class extends n{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){A(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?findCode(e,this.targetCharCodes)===void 0&&(this.found=!0):findCode(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function canMatchCharCode(e,t){if(t instanceof RegExp){let n=getRegExpAst(t),r=new CharCodeFinder(e);return r.visit(n),r.found}else return K(t,t=>A(e,t.charCodeAt(0)))!==void 0}const q=`PATTERN`,pn=`defaultMode`;let mn=typeof RegExp(`(?:)`).sticky==`boolean`;function analyzeTokenTypes(e,t){t=qt(t,{useSticky:mn,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
|
|
7
|
+
`],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{initCharCodeToOptimizedIndexMap()});let r;n(`Reject Lexer.NA`,()=>{r=reject(e,e=>e[q]===Lexer.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=o(r,e=>{let n=e[q];if(W(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!A([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?addStickyFlag(n):addStartOfInput(n)}else if(I(n))return i=!0,{exec:n};else if(typeof n==`object`)return i=!0,n;else if(typeof n==`string`){if(n.length===1)return n;{let e=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),r=new RegExp(e);return t.useSticky?addStickyFlag(r):addStartOfInput(r)}}else throw Error(`non exhaustive match`)})});let s,c,l,u,d;n(`misc mapping`,()=>{s=o(r,e=>e.tokenTypeIdx),c=o(r,e=>{let t=e.GROUP;if(t!==Lexer.SKIPPED){if(b(t))return t;if(isUndefined(t))return!1;throw Error(`non exhaustive match`)}}),l=o(r,e=>{let t=e.LONGER_ALT;if(t)return R(t)?o(t,e=>indexOf(r,e)):[indexOf(r,t)]}),u=o(r,e=>e.PUSH_MODE),d=o(r,e=>has(e,`POP_MODE`))});let f;n(`Line Terminator Handling`,()=>{let e=getCharCodes(t.lineTerminatorCharacters);f=o(r,e=>!1),t.positionTracking!==`onlyOffset`&&(f=o(r,t=>has(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:checkLineBreaksIssues(t,e)===!1&&canMatchCharCode(e,t.PATTERN)))});let p,m,h,g;n(`Misc Mapping #2`,()=>{p=o(r,isCustomPattern),m=o(a,isShortPattern),h=reduce(r,(e,t)=>{let n=t.GROUP;return b(n)&&n!==Lexer.SKIPPED&&(e[n]=[]),e},{}),g=o(a,(e,t)=>({pattern:a[t],longerAlt:l[t],canLineTerminator:f[t],isCustom:p[t],short:m[t],group:c[t],push:u[t],pop:d[t],tokenTypeIdx:s[t],tokenType:r[t]}))});let _=!0,v=[];return t.safeMode||n(`First Char Optimization`,()=>{v=reduce(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)addToMapOfArrays(e,charCodeToOptimizedIndex(n.PATTERN.charCodeAt(0)),g[r]);else if(R(n.START_CHARS_HINT)){let t;x(n.START_CHARS_HINT,n=>{let i=charCodeToOptimizedIndex(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,addToMapOfArrays(e,i,g[r]))})}else if(W(n.PATTERN))if(n.PATTERN.unicode)_=!1,t.ensureOptimizations&&je(`${fn}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
8
|
+
This will disable the lexer's first char optimizations.
|
|
9
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=getOptimizedStartCodesIndices(n.PATTERN,t.ensureOptimizations);isEmpty(i)&&(_=!1),x(i,t=>{addToMapOfArrays(e,t,g[r])})}else t.ensureOptimizations&&je(`${fn}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
|
|
10
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return e},[])}),{emptyGroups:h,patternIdxToConfig:g,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:_}}function validatePatterns(e,t){let n=[],r=findMissingPatterns(e);n=n.concat(r.errors);let i=findInvalidPatterns(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(validateRegExpPattern(a)),n=n.concat(findInvalidGroupType(a)),n=n.concat(findModesThatDoNotExist(a,t)),n=n.concat(findUnreachablePatterns(a)),n}function validateRegExpPattern(e){let t=[],n=filter(e,e=>W(e[q]));return t=t.concat(findEndOfInputAnchor(n)),t=t.concat(findStartOfInputAnchor(n)),t=t.concat(findUnsupportedFlags(n)),t=t.concat(findDuplicatePatterns(n)),t=t.concat(findEmptyMatchRegExps(n)),t}function findMissingPatterns(e){let t=filter(e,e=>!has(e,q));return{errors:o(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:J.MISSING_PATTERN,tokenTypes:[e]})),valid:Yt(e,t)}}function findInvalidPatterns(e){let t=filter(e,e=>{let t=e[q];return!W(t)&&!I(t)&&!has(t,`exec`)&&!b(t)});return{errors:o(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:J.INVALID_PATTERN,tokenTypes:[e]})),valid:Yt(e,t)}}const hn=/[^\\][$]/;function findEndOfInputAnchor(e){class EndAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return o(filter(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new EndAnchorFinder;return n.visit(e),n.found}catch{return hn.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
11
|
+
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
12
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findEmptyMatchRegExps(e){return o(filter(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:J.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}const gn=/[^\\[][\^]|^\^/;function findStartOfInputAnchor(e){class StartAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return o(filter(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new StartAnchorFinder;return n.visit(e),n.found}catch{return gn.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
|
|
13
|
+
Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
14
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findUnsupportedFlags(e){return o(filter(e,e=>{let t=e[q];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:J.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function findDuplicatePatterns(e){let t=[],n=o(e,n=>reduce(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!A(t,r)&&r.PATTERN!==Lexer.NA?(t.push(r),e.push(r),e):e,[]));return n=compact(n),o(filter(n,e=>e.length>1),e=>{let t=o(e,e=>e.name);return{message:`The same RegExp pattern ->${head(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:J.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function findInvalidGroupType(e){return o(filter(e,e=>{if(!has(e,`GROUP`))return!1;let t=e.GROUP;return t!==Lexer.SKIPPED&&t!==Lexer.NA&&!b(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:J.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function findModesThatDoNotExist(e,t){return o(filter(e,e=>e.PUSH_MODE!==void 0&&!A(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:J.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function findUnreachablePatterns(e){let t=[],n=reduce(e,(e,t,n)=>{let r=t.PATTERN;return r===Lexer.NA||(b(r)?e.push({str:r,idx:n,tokenType:t}):W(r)&&noMetaChar(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return x(e,(e,r)=>{x(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&testTokenType(n,e.PATTERN)){let n=`Token: ->${a.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:J.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function testTokenType(e,t){if(W(t)){let n=t.exec(e);return n!==null&&n.index===0}else if(I(t))return t(e,0,[],{});else if(has(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}function noMetaChar(e){return K([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function addStartOfInput(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}function addStickyFlag(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function performRuntimeChecks(e,t,n){let r=[];return has(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition
|
|
15
|
+
`,type:J.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),has(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
|
|
16
|
+
`,type:J.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),has(e,`modes`)&&has(e,`defaultMode`)&&!has(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${pn}: <${e.defaultMode}>which does not exist\n`,type:J.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),has(e,`modes`)&&x(e.modes,(e,t)=>{x(e,(n,i)=>{isUndefined(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:J.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):has(n,`LONGER_ALT`)&&x(R(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!isUndefined(i)&&!A(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:J.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function performWarningRuntimeChecks(e,t,n){let r=[],i=!1,a=reject(compact(flatten(U(e.modes))),e=>e[q]===Lexer.NA),o=getCharCodes(n);return t&&x(a,e=>{let t=checkLineBreaksIssues(e,o);if(t!==!1){let n={message:buildLineBreakIssueMessage(e,t),type:t.issue,tokenType:e};r.push(n)}else has(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):canMatchCharCode(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
|
|
17
|
+
This Lexer has been defined to track line and column information,
|
|
18
|
+
But none of the Token Types can be identified as matching a line terminator.
|
|
19
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
20
|
+
for details.`,type:J.NO_LINE_BREAKS_FLAGS}),r}function cloneEmptyGroups(e){let t={};return x(u(e),n=>{let r=e[n];if(R(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function isCustomPattern(e){let t=e.PATTERN;if(W(t))return!1;if(I(t)||has(t,`exec`))return!0;if(b(t))return!1;throw Error(`non exhaustive match`)}function isShortPattern(e){return b(e)&&e.length===1?e.charCodeAt(0):!1}const _n={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return e.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function checkLineBreaksIssues(e,t){if(has(e,`LINE_BREAKS`))return!1;if(W(e.PATTERN)){try{canMatchCharCode(t,e.PATTERN)}catch(e){return{issue:J.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(b(e.PATTERN))return!1;else if(isCustomPattern(e))return{issue:J.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}function buildLineBreakIssueMessage(e,t){if(t.issue===J.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
21
|
+
\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===J.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
22
|
+
\tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function getCharCodes(e){return o(e,e=>b(e)?e.charCodeAt(0):e)}function addToMapOfArrays(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}let vn=[];function charCodeToOptimizedIndex(e){return e<256?e:vn[e]}function initCharCodeToOptimizedIndexMap(){if(isEmpty(vn)){vn=Array(65536);for(let e=0;e<65536;e++)vn[e]=e>255?255+~~(e/255):e}}function tokenStructuredMatcher(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[n]===!0}function tokenStructuredMatcherNoCategories(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let yn=1;const bn={};function augmentTokenTypes(e){let t=expandCategories(e);assignTokenDefaultProps(t),assignCategoriesMapProp(t),assignCategoriesTokensProp(t),x(t,e=>{e.isParent=e.categoryMatches.length>0})}function expandCategories(e){let t=clone(e),n=e,r=!0;for(;r;){n=compact(flatten(o(n,e=>e.CATEGORIES)));let e=Yt(n,t);t=t.concat(e),isEmpty(e)?r=!1:n=e}return t}function assignTokenDefaultProps(e){x(e,e=>{hasShortKeyProperty(e)||(bn[yn]=e,e.tokenTypeIdx=yn++),hasCategoriesProperty(e)&&!R(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),hasCategoriesProperty(e)||(e.CATEGORIES=[]),hasExtendingTokensTypesProperty(e)||(e.categoryMatches=[]),hasExtendingTokensTypesMapProperty(e)||(e.categoryMatchesMap={})})}function assignCategoriesTokensProp(e){x(e,e=>{e.categoryMatches=[],x(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(bn[n].tokenTypeIdx)})})}function assignCategoriesMapProp(e){x(e,e=>{singleAssignCategoriesToksMap([],e)})}function singleAssignCategoriesToksMap(e,t){x(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),x(t.CATEGORIES,n=>{let r=e.concat(t);A(r,n)||singleAssignCategoriesToksMap(r,n)})}function hasShortKeyProperty(e){return has(e,`tokenTypeIdx`)}function hasCategoriesProperty(e){return has(e,`CATEGORIES`)}function hasExtendingTokensTypesProperty(e){return has(e,`categoryMatches`)}function hasExtendingTokensTypesMapProperty(e){return has(e,`categoryMatchesMap`)}function isTokenType(e){return has(e,`tokenTypeIdx`)}const xn={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}};var J;(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`})(J||={});const Sn={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
23
|
+
`,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:xn,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Sn);var Lexer=class{constructor(e,t=Sn){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(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
24
|
+
a boolean 2nd argument is no longer supported`);this.config=w({},Sn,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(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===Sn.lineTerminatorsPattern)this.config.lineTerminatorsPattern=_n;else if(this.config.lineTerminatorCharacters===Sn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
25
|
+
For 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),R(e)?n={modes:{defaultMode:clone(e)},defaultMode:pn}:(r=!1,n=clone(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(performRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(performWarningRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},x(n.modes,(e,t)=>{n.modes[t]=reject(e,e=>isUndefined(e))});let i=u(n.modes);if(x(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(validatePatterns(e,i))}),isEmpty(this.lexerDefinitionErrors)){augmentTokenTypes(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=analyzeTokenTypes(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=w({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!isEmpty(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=o(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
26
|
+
`);throw Error(`Errors detected in definition of Lexer:
|
|
27
|
+
`+e)}x(this.lexerDefinitionWarning,e=>{ke(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(mn?(this.chopInput=Te,this.match=this.matchWithTest):(this.updateLastIndex=noop,this.match=this.matchWithExec),r&&(this.handleModes=noop),this.trackStartLines===!1&&(this.computeNewColumn=Te),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=noop),/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))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=reduce(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!isEmpty(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
28
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{clearRegExpParserCache()}),this.TRACE_INIT(`toFastProperties`,()=>{Me(this)})})}tokenize(e,t=this.defaultMode){if(!isEmpty(this.lexerDefinitionErrors)){let e=o(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
|
|
29
|
+
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
30
|
+
`+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,v=_.length,y=0,ee=0,te=this.hasCustom?0:Math.floor(e.length/10),b=Array(te),x=[],S=this.trackStartLines?1:void 0,C=this.trackStartLines?1:void 0,w=cloneEmptyGroups(this.emptyGroups),ne=this.trackStartLines,T=this.config.lineTerminatorsPattern,E=0,D=[],O=[],k=[],re=[];Object.freeze(re);let A;function getPossiblePatternsSlow(){return D}function getPossiblePatternsOptimized(e){let t=charCodeToOptimizedIndex(e),n=O[t];return n===void 0?re:n}let pop_mode=e=>{if(k.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);x.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{k.pop();let e=last(k);D=this.patternIdxToConfig[e],O=this.charCodeToPatternIdxToConfig[e],E=D.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;A=O&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}};function push_mode(e){k.push(e),O=this.charCodeToPatternIdxToConfig[e],D=this.patternIdxToConfig[e],E=D.length,E=D.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;A=O&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}push_mode.call(this,t);let j,ie=this.config.recoveryEnabled;for(;y<v;){s=null;let t=_.charCodeAt(y),te=A(t),O=te.length;for(n=0;n<O;n++){j=te[n];let r=j.pattern;c=null;let u=j.short;if(u===!1?j.isCustom===!0?(g=r.exec(_,y,b,w),g===null?s=null:(s=g[0],g.payload!==void 0&&(c=g.payload))):(this.updateLastIndex(r,y),s=this.match(r,e,y)):t===u&&(s=r),s!==null){if(o=j.longerAlt,o!==void 0){let t=o.length;for(i=0;i<t;i++){let t=D[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(_,y,b,w),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(this.updateLastIndex(n,y),a=this.match(n,e,y)),a&&a.length>s.length){s=a,c=l,j=t;break}}}break}}if(s!==null){if(u=s.length,d=j.group,d!==void 0&&(f=j.tokenTypeIdx,p=this.createTokenInstance(s,y,f,j.tokenType,S,C,u),this.handlePayload(p,c),d===!1?ee=this.addToken(b,ee,p):w[d].push(p)),e=this.chopInput(e,u),y+=u,C=this.computeNewColumn(C,u),ne===!0&&j.canLineTerminator===!0){let e=0,t,n;T.lastIndex=0;do t=T.test(s),t===!0&&(n=T.lastIndex-1,e++);while(t===!0);e!==0&&(S+=e,C=u-n,this.updateTokenEndLineColumnLocation(p,d,n,e,S,C,u))}this.handleModes(j,pop_mode,push_mode,p)}else{let t=y,n=S,i=C,a=ie===!1;for(;a===!1&&y<v;)for(e=this.chopInput(e,1),y++,r=0;r<E;r++){let t=D[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(_,y,b,w)!==null:(this.updateLastIndex(n,y),a=n.exec(e)!==null):_.charCodeAt(y)===i&&(a=!0),a===!0)break}if(m=y-t,C=this.computeNewColumn(C,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,t,m,n,i),x.push({offset:t,line:n,column:i,length:m,message:h}),ie===!1)break}}return this.hasCustom||(b.length=ee),{tokens:b,groups:w,errors:x}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,r===1&&s===!0||(e.endLine=i+c,e.endColumn=a-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,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchWithExec(e,t){let n=e.exec(t);return n===null?null:n[0]}};Lexer.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.`,Lexer.NA=/NOT_APPLICABLE/;function tokenLabel(e){return hasTokenLabel(e)?e.LABEL:e.name}function hasTokenLabel(e){return b(e.LABEL)&&e.LABEL!==``}const Cn=`categories`,wn=`label`,Tn=`group`,En=`push_mode`,Dn=`pop_mode`,On=`longer_alt`,kn=`line_breaks`,An=`start_chars_hint`;function createToken(e){return createTokenInternal(e)}function createTokenInternal(e){let t=e.pattern,n={};if(n.name=e.name,isUndefined(t)||(n.PATTERN=t),has(e,`parent`))throw`The parent property is no longer supported.
|
|
31
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return has(e,Cn)&&(n.CATEGORIES=e[Cn]),augmentTokenTypes([n]),has(e,wn)&&(n.LABEL=e[wn]),has(e,Tn)&&(n.GROUP=e[Tn]),has(e,Dn)&&(n.POP_MODE=e[Dn]),has(e,En)&&(n.PUSH_MODE=e[En]),has(e,On)&&(n.LONGER_ALT=e[On]),has(e,kn)&&(n.LINE_BREAKS=e[kn]),has(e,An)&&(n.START_CHARS_HINT=e[An]),n}const Y=createToken({name:`EOF`,pattern:Lexer.NA});augmentTokenTypes([Y]);function createTokenInstance(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function tokenMatcher(e,t){return tokenStructuredMatcher(e,t)}const jn={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${hasTokenLabel(e)?`--> ${tokenLabel(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
|
|
32
|
+
but found: '`+head(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${o(o(reduce(e,(e,t)=>e.concat(t),[]),e=>`[${o(e,e=>tokenLabel(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
|
|
33
|
+
`)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
|
|
34
|
+
but found: '`+head(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${o(e,e=>`[${o(e,e=>tokenLabel(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(jn);const Mn={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
|
|
35
|
+
inside top level rule: ->`+e.name+`<-`}},X={buildDuplicateFoundError(e,t){function getExtraProductionArgument(e){return e instanceof P?e.terminalType.name:e instanceof j?e.nonTerminalName:``}let n=e.name,r=head(t),i=r.idx,a=B(r),o=getExtraProductionArgument(r),s=`->${a}${i>0?i:``}<- ${o?`with argument: ->${o}<-`:``}
|
|
36
|
+
appears more than once (${t.length} times) in the top level rule: ->${n}<-.
|
|
37
|
+
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
38
|
+
`;return s=s.replace(/[ \t]+/g,` `),s=s.replace(/\s\s+/g,`
|
|
39
|
+
`),s},buildNamespaceConflictError(e){return`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){let t=o(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``: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){let t=o(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx,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
|
|
40
|
+
For Further details.`,r},buildEmptyRepetitionError(e){let t=B(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`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){return`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){let 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} --> ${o(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof me?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function resolveGrammar$1(e,t){let n=new GastRefResolverVisitor(e,t);return n.resolveRefs(),n.errors}e(resolveGrammar$1,`resolveGrammar`);var GastRefResolverVisitor=class extends k{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){x(U(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},AbstractNextPossibleTokensWalker=class extends RestWalker{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=clone(this.path.ruleStack).reverse(),this.occurrenceStack=clone(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){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){isEmpty(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},NextAfterTokenWalker=class extends AbstractNextPossibleTokensWalker{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){let e=new z({definition:t.concat(n)});this.possibleTokTypes=first(e),this.found=!0}}},AbstractNextTerminalAfterProductionWalker=class extends RestWalker{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}},NextTerminalAfterManyWalker=class extends AbstractNextTerminalAfterProductionWalker{walkMany(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},NextTerminalAfterManySepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},NextTerminalAfterAtLeastOneWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},NextTerminalAfterAtLeastOneSepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function possiblePathsFrom(e,t,n=[]){n=clone(n);let r=[],i=0;function remainingPathWith(t){return t.concat(drop(e,i+1))}function getAlternativesForProd(e){let i=possiblePathsFrom(remainingPathWith(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof z||t instanceof j)return getAlternativesForProd(t.definition);if(t instanceof F)r=getAlternativesForProd(t.definition);else if(t instanceof M)return getAlternativesForProd(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof N)return getAlternativesForProd([new z({definition:t.definition}),new V({definition:[new P({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof ye)r=getAlternativesForProd(t.definition.concat([new V({definition:[new P({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof V)r=getAlternativesForProd(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof L)return x(t.definition,e=>{isEmpty(e.definition)===!1&&(r=getAlternativesForProd(e.definition))}),r;else if(t instanceof P)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:drop(e,i)}),r}function nextPossibleTokensAfter(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!isEmpty(d);){let e=d.pop();if(e===o){s&&last(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(isEmpty(r))continue;let h=r[0];if(h===i){let e={idx:f,def:drop(r),ruleStack:dropRight(p),occurrenceStack:dropRight(m)};d.push(e)}else if(h instanceof P)if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`);else if(h instanceof j){let e=clone(p);e.push(h.nonTerminalName);let t=clone(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,drop(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof F){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof M){let e=new V({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof N){let e=new V({definition:[new P({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof ye){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new V({definition:[new P({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof V){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new V({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof L)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof z)d.push({idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof me)d.push(expandTopLevelRule(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function expandTopLevelRule(e,t,n,r){let i=clone(n);i.push(e.name);let a=clone(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(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`})(Z||={});function getProdType(e){if(e instanceof F||e===`Option`)return Z.OPTION;if(e instanceof V||e===`Repetition`)return Z.REPETITION;if(e instanceof M||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof N||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof ye||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof L||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function getLookaheadPaths(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=getProdType(r);return a===Z.ALTERNATION?getLookaheadPathsForOr(t,n,i):getLookaheadPathsForOptionalProd(t,n,a,i)}function buildLookaheadFuncForOr(e,t,n,r,i,a){let o=getLookaheadPathsForOr(e,t,n);return a(o,r,areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,i)}function buildLookaheadFuncForOptionalProd(e,t,n,r,i,a){let o=getLookaheadPathsForOptionalProd(e,t,i,n),s=areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher;return a(o[0],s,r)}function buildAlternativesLookAheadFunc(e,t,n,r){let i=e.length,a=H(e,e=>H(e,e=>e.length===1));if(t)return function(t){let r=o(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=reduce(o(e,e=>flatten(e)),(e,t,n)=>(x(t,t=>{has(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),x(t.categoryMatches,t=>{has(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function buildSingleAlternativeLookaheadFunction(e,t,n){let r=H(e,e=>e.length===1),i=e.length;if(r&&!n){let t=flatten(e);if(t.length===1&&isEmpty(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=reduce(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,x(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var RestDefinitionFinderWalker=class extends RestWalker{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):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},InsideDefinitionFinderVisitor=class extends k{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&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function initializeArrayOfArrays(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function pathToHashKeys(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function isUniquePrefixHash(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function lookAheadSequenceFromAlternatives(e,t){let n=o(e,e=>possiblePathsFrom([e],1)),r=initializeArrayOfArrays(n.length),i=o(n,e=>{let t={};return x(e,e=>{x(pathToHashKeys(e.partialPath),e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=initializeArrayOfArrays(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=pathToHashKeys(c);if(isUniquePrefixHash(i,u,o)||isEmpty(l)||c.length===t){let e=r[o];if(containsPath(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=possiblePathsFrom(l,e+1,c);a[o]=a[o].concat(t),x(t,e=>{x(pathToHashKeys(e.partialPath),e=>{i[o][e]=!0})})}}}}return r}function getLookaheadPathsForOr(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,Z.ALTERNATION,r);return t.accept(i),lookAheadSequenceFromAlternatives(i.result,n)}function getLookaheadPathsForOptionalProd(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,n);t.accept(i);let a=i.result,o=new RestDefinitionFinderWalker(t,e,n).startWalking();return lookAheadSequenceFromAlternatives([new z({definition:a}),new z({definition:o})],r)}function containsPath(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function isStrictPrefixOfPath(e,t){return e.length<t.length&&H(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function areTokenCategoriesNotUsed(e){return H(e,e=>H(e,e=>H(e,e=>isEmpty(e.categoryMatches))))}function validateLookahead(e){return o(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function validateGrammar$1(e,t,n,r){let i=flatMap(e,e=>validateDuplicateProductions(e,n)),a=checkTerminalAndNoneTerminalsNameSpace(e,t,n),o=flatMap(e,e=>validateTooManyAlts(e,n)),s=flatMap(e,t=>validateRuleDoesNotAlreadyExist(t,e,r,n));return i.concat(a,o,s)}e(validateGrammar$1,`validateGrammar`);function validateDuplicateProductions(e,t){let n=new OccurrenceValidationCollector;e.accept(n);let r=n.allProductions;return o(U(Ee(Qt(r,identifyProductionForDuplicates),e=>e.length>1)),n=>{let r=head(n),i=t.buildDuplicateFoundError(e,n),a=B(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=getExtraProductionArgument(r);return s&&(o.parameter=s),o})}function identifyProductionForDuplicates(e){return`${B(e)}_#_${e.idx}_#_${getExtraProductionArgument(e)}`}function getExtraProductionArgument(e){return e instanceof P?e.terminalType.name:e instanceof j?e.nonTerminalName:``}var OccurrenceValidationCollector=class extends k{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 validateRuleDoesNotAlreadyExist(e,t,n,r){let i=[];if(reduce(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function validateRuleIsOverridden(e,t,n){let r=[],i;return A(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:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function validateNoLeftRecursion(e,t,n,r=[]){let i=[],a=getFirstNoneTerminal(t.definition);if(isEmpty(a))return[];{let t=e.name;A(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=flatMap(Yt(a,r.concat([e])),t=>{let i=clone(r);return i.push(t),validateNoLeftRecursion(e,t,n,i)});return i.concat(o)}}function getFirstNoneTerminal(e){let t=[];if(isEmpty(e))return t;let n=head(e);if(n instanceof j)t.push(n.referencedRule);else if(n instanceof z||n instanceof F||n instanceof M||n instanceof N||n instanceof ye||n instanceof V)t=t.concat(getFirstNoneTerminal(n.definition));else if(n instanceof L)t=flatten(o(n.definition,e=>getFirstNoneTerminal(e.definition)));else if(!(n instanceof P))throw Error(`non exhaustive match`);let r=xe(n),i=e.length>1;if(r&&i){let n=drop(e);return t.concat(getFirstNoneTerminal(n))}else return t}var OrCollector=class extends k{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function validateEmptyOrAlternative(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>flatMap(dropRight(n.definition),(r,i)=>isEmpty(nextPossibleTokensAfter([r],[],tokenStructuredMatcher,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function validateAmbiguousAlternationAlternatives(e,t,n){let r=new OrCollector;e.accept(r);let i=r.alternations;return i=reject(i,e=>e.ignoreAmbiguities===!0),flatMap(i,r=>{let i=r.idx,a=getLookaheadPathsForOr(i,e,r.maxLookahead||t,r),o=checkAlternativesAmbiguities(a,r,e,n),s=checkPrefixAlternativesAmbiguities(a,r,e,n);return o.concat(s)})}var RepetitionCollector=class extends k{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 validateTooManyAlts(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function validateSomeNonEmptyLookaheadPath(e,t,n){let r=[];return x(e,e=>{let i=new RepetitionCollector;e.accept(i);let a=i.allProductions;x(a,i=>{let a=getProdType(i),o=i.maxLookahead||t,s=i.idx,c=getLookaheadPathsForOptionalProd(s,e,a,o)[0];if(isEmpty(flatten(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function checkAlternativesAmbiguities(e,t,n,r){let i=[];return o(reduce(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||x(r,r=>{let o=[a];x(e,(e,n)=>{a!==n&&containsPath(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!containsPath(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=o(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function checkPrefixAlternativesAmbiguities(e,t,n,r){let i=reduce(e,(e,t,n)=>{let r=o(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return compact(flatMap(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,s=e.path;return o(filter(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&isStrictPrefixOfPath(e.path,s)),e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function checkTerminalAndNoneTerminalsNameSpace(e,t,n){let r=[],i=o(t,e=>e.name);return x(e,e=>{let t=e.name;if(A(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function resolveGrammar(e){let t=qt(e,{errMsgProvider:Mn}),n={};return x(e.rules,e=>{n[e.name]=e}),resolveGrammar$1(n,t.errMsgProvider)}function validateGrammar(e){return e=qt(e,{errMsgProvider:X}),validateGrammar$1(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const Nn=`MismatchedTokenException`,Pn=`NoViableAltException`,Fn=`EarlyExitException`,In=`NotAllInputParsedException`,Ln=[Nn,Pn,Fn,In];Object.freeze(Ln);function isRecognitionException(e){return A(Ln,e.name)}var RecognitionException=class 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)}},MismatchedTokenException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Nn}},NoViableAltException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Pn}},NotAllInputParsedException=class extends RecognitionException{constructor(e,t){super(e,t),this.name=In}},EarlyExitException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Fn}};const Rn={};var InRuleRecoveryException=class extends Error{constructor(e){super(e),this.name=`InRuleRecoveryException`}},Recoverable=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=has(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=attemptInRepetitionRecovery)}getTokenToInsert(e){let t=createTokenInstance(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){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),generateErrorMessage=()=>{let e=this.LA(0),t=new MismatchedTokenException(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=dropRight(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){generateErrorMessage();return}else if(n.call(this)){generateErrorMessage(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let 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)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new InRuleRecoveryException(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||isEmpty(t))return!1;let n=this.LA(1);return K(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return A(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=K(e,e=>tokenMatcher(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Rn;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return o(e,(n,r)=>r===0?Rn:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return flatten(o(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Rn)return[Y];let t=e.ruleName+e.idxInCallingRule+cn+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Y)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return dropRight(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:clone(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return o(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function attemptInRepetitionRecovery(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Y,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const zn=1024,Bn=1280,Vn=1536;function getKeyForAutomaticLookahead(e,t,n){return n|t|e}var LLkLookaheadStrategy=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(isEmpty(t)){let 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 flatMap(e,e=>validateNoLeftRecursion(e,e,X))}validateEmptyOrAlternatives(e){return flatMap(e,e=>validateEmptyOrAlternative(e,X))}validateAmbiguousAlternationAlternatives(e,t){return flatMap(e,e=>validateAmbiguousAlternationAlternatives(e,t,X))}validateSomeNonEmptyLookaheadPath(e,t){return validateSomeNonEmptyLookaheadPath(e,t,X)}buildLookaheadForAlternation(e){return buildLookaheadFuncForOr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,buildAlternativesLookAheadFunc)}buildLookaheadForOptional(e){return buildLookaheadFuncForOptionalProd(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,getProdType(e.prodType),buildSingleAlternativeLookaheadFunction)}},LooksAhead=class{initLooksAhead(e){this.dynamicTokensEnabled=has(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=has(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=has(e,`lookaheadStrategy`)?e.lookaheadStrategy:new LLkLookaheadStrategy({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){x(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=collectMethods(e);x(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${B(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),x(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,B(t))}),x(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,B(t))}),x(i,t=>{this.computeLookaheadFunc(e,t.idx,zn,`RepetitionMandatory`,t.maxLookahead,B(t))}),x(a,t=>{this.computeLookaheadFunc(e,t.idx,Vn,`RepetitionMandatoryWithSeparator`,t.maxLookahead,B(t))}),x(o,t=>{this.computeLookaheadFunc(e,t.idx,Bn,`RepetitionWithSeparator`,t.maxLookahead,B(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return getKeyForAutomaticLookahead(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},DslMethodsCollectorVisitor=class extends k{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)}};const Hn=new DslMethodsCollectorVisitor;function collectMethods(e){Hn.reset(),e.accept(Hn);let t=Hn.dslMethods;return Hn.reset(),t}function setNodeLocationOnlyOffset(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function setNodeLocationFull(e,t){isNaN(e.startOffset)===!0?(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&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function addTerminalToCst(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function addNoneTerminalToCst(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function defineNameProp(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function defaultVisit(e,t){let n=u(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function createBaseSemanticVisitorConstructor(e,t){let derivedConstructor=function(){};return defineNameProp(derivedConstructor,e+`BaseSemantics`),derivedConstructor.prototype={visit:function(e,t){if(R(e)&&(e=e[0]),!isUndefined(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=validateVisitor(this,t);if(!isEmpty(e)){let t=o(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
|
|
41
|
+
|
|
42
|
+
`).replace(/\n/g,`
|
|
43
|
+
`)}`)}}},derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor._RULE_NAMES=t,derivedConstructor}function createBaseVisitorConstructorWithDefaults(e,t,n){let derivedConstructor=function(){};defineNameProp(derivedConstructor,e+`BaseSemanticsWithDefaults`);let r=Object.create(n.prototype);return x(t,e=>{r[e]=defaultVisit}),derivedConstructor.prototype=r,derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor}var Un;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Un||={});function validateVisitor(e,t){return validateMissingCstMethods(e,t)}function validateMissingCstMethods(e,t){return compact(o(filter(t,t=>I(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Un.MISSING_METHOD,methodName:t})))}var TreeBuilder=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=has(e,`nodeLocationTracking`)?e.nodeLocationTracking:Q.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=noop,this.cstFinallyStateUpdate=noop,this.cstPostTerminal=noop,this.cstPostNonTerminal=noop,this.cstPostRule=noop;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationFull,this.setNodeLocationFromNode=setNodeLocationFull,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationOnlyOffset,this.setNodeLocationFromNode=setNodeLocationOnlyOffset,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=noop,this.setInitialNodeLocation=noop;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}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){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addTerminalToCst(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addNoneTerminalToCst(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(isUndefined(this.baseCstVisitorConstructor)){let e=createBaseSemanticVisitorConstructor(this.className,u(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(isUndefined(this.baseCstVisitorWithDefaultsConstructor)){let e=createBaseVisitorConstructorWithDefaults(this.className,u(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},LexerAdapter=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)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)):Jn}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Jn: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()}},RecognizerApi=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=Yn){if(A(this.definedRulesNames,e)){let t={message:X.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Yn){let r=validateRuleIsOverridden(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return ce(U(this.gastProductionsCache))}},RecognizerEngine=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=tokenStructuredMatcherNoCategories,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},has(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
44
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
45
|
+
For Further details.`);if(R(e)){if(isEmpty(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
46
|
+
Note that the first argument for the parser constructor
|
|
47
|
+
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
48
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
49
|
+
For Further details.`)}if(R(e))this.tokensMap=reduce(e,(e,t)=>(e[t.name]=t,e),{});else if(has(e,`modes`)&&H(flatten(U(e.modes)),isTokenType)){let t=uniq(flatten(U(e.modes)));this.tokensMap=reduce(t,(e,t)=>(e[t.name]=t,e),{})}else if(se(e))this.tokensMap=clone(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=Y;let n=H(has(e,`modes`)?flatten(U(e.modes)):U(e),e=>isEmpty(e.categoryMatches));this.tokenMatcher=n?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,augmentTokenTypes(U(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.`);let r=has(n,`resyncEnabled`)?n.resyncEnabled:Yn.resyncEnabled,i=has(n,`recoveryValueFunc`)?n.recoveryValueFunc:Yn.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function invokeRuleWithTry(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let 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 invokeRuleWithTryCst(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(isRecognitionException(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r))if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}else return n(e);else{if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}}else if(r)return this.moveToTerminatedState(),n(e);else throw t}else throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof e!=`function`){r=e.DEF;let t=e.GATE;if(t!==void 0){let e=lookAheadFunc;lookAheadFunc=()=>t.call(this)&&e.call(this)}}else r=e;if(lookAheadFunc.call(this)===!0)return r.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(zn,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookAheadFunc;lookAheadFunc=()=>e.call(this)&&t.call(this)}}else r=t;if(lookAheadFunc.call(this)===!0){let e=this.doSingleRepetition(r);for(;lookAheadFunc.call(this)===!0&&e===!0;)e=this.doSingleRepetition(r)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],lookAheadFunc,zn,e,NextTerminalAfterAtLeastOneWalker)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Vn,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterAtLeastOneSepWalker],separatorLookAheadFunc,Vn,e,NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let lookaheadFunction=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookaheadFunction;lookaheadFunction=()=>e.call(this)&&t.call(this)}}else r=t;let i=!0;for(;lookaheadFunction.call(this)===!0&&i===!0;)i=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],lookaheadFunction,768,e,NextTerminalAfterManyWalker,i)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Bn,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterManySepWalker],separatorLookAheadFunc,Bn,e,NextTerminalAfterManySepWalker)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Vn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=R(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)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(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new NotAllInputParsedException(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw isRecognitionException(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new MismatchedTokenException(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}else throw n}saveRecogState(){let e=this.errors,t=clone(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 this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Y)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},ErrorHandler=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=has(e,`errorMessageProvider`)?e.errorMessageProvider:Q.errorMessageProvider}SAVE_ERROR(e){if(isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:clone(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return clone(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=getLookaheadPathsForOptionalProd(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new EarlyExitException(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=getLookaheadPathsForOr(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new NoViableAltException(s,this.LA(1),o))}},ContentAssist=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(isUndefined(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return nextPossibleTokensAfter([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=head(e.ruleStack),n=this.getGAstProductions()[t];return new NextAfterTokenWalker(n,e).startWalking()}};const Wn={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(Wn);const Gn=createToken({name:`RECORDING_PHASE_TOKEN`,pattern:Lexer.NA});augmentTokenTypes([Gn]);const Kn=createTokenInstance(Gn,`This IToken indicates the Parser is in Recording Phase
|
|
50
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Kn);const qn={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
51
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var GastRecorder=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++){let 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`,()=>{let e=this;for(let t=0;t<10;t++){let 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 Jn}topLevelRuleRecord(e,t){try{let n=new me({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
|
|
52
|
+
This error was thrown during the "grammar recording phase" For more info see:
|
|
53
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return recordProd.call(this,F,e,t)}atLeastOneInternalRecord(e,t){recordProd.call(this,M,t,e)}atLeastOneSepFirstInternalRecord(e,t){recordProd.call(this,N,t,e,!0)}manyInternalRecord(e,t){recordProd.call(this,V,t,e)}manySepFirstInternalRecord(e,t){recordProd.call(this,ye,t,e,!0)}orInternalRecord(e,t){return recordOrProd.call(this,e,t)}subruleInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!e||has(e,`ruleName`)===!1){let n=Error(`<SUBRULE${getIdxSuffix(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}let r=last(this.recordingProdStack),i=e.ruleName,a=new j({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?qn:Wn}consumeInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!hasShortKeyProperty(e)){let n=Error(`<CONSUME${getIdxSuffix(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}let r=last(this.recordingProdStack),i=new P({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Kn}};function recordProd(e,t,n,r=!1){assertMethodIdxIsValid(n);let i=last(this.recordingProdStack),a=I(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),has(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),Wn}function recordOrProd(e,t){assertMethodIdxIsValid(t);let n=last(this.recordingProdStack),r=R(e)===!1,i=r===!1?e:e.DEF,a=new L({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return has(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=D(i,e=>I(e.GATE)),n.definition.push(a),x(i,e=>{let t=new z({definition:[]});a.definition.push(t),has(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:has(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),Wn}function getIdxSuffix(e){return e===0?``:`${e}`}function assertMethodIdxIsValid(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var PerformanceTracer=class{initPerformanceTracer(e){if(has(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Q.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function applyMixins(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}const Jn=createTokenInstance(Y,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Jn);const Q=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:jn,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Yn=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});var $;(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`})($||={});function EMPTY_ALT(e=void 0){return function(){return e}}var Xn=class Parser{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT(`toFastProps`,()=>{Me(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),x(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,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=resolveGrammar({rules:U(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(isEmpty(n)&&this.skipValidations===!1){let e=validateGrammar({rules:U(this.gastProductionsCache),tokenTypes:U(this.tokensMap),errMsgProvider:X,grammarName:t}),n=validateLookahead({lookaheadStrategy:this.lookaheadStrategy,rules:U(this.gastProductionsCache),tokenTypes:U(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(e,n)}}),isEmpty(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=computeAllProdsFollows(U(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:U(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(U(this.gastProductionsCache))})),!Parser.DEFER_DEFINITION_ERRORS_HANDLING&&!isEmpty(this.definitionErrors))throw e=o(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${e.join(`
|
|
54
|
+
-------------------------------
|
|
55
|
+
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let 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),has(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
56
|
+
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
57
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
58
|
+
For further details.`);this.skipValidations=has(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};Xn.DEFER_DEFINITION_ERRORS_HANDLING=!1,applyMixins(Xn,[Recoverable,LooksAhead,TreeBuilder,LexerAdapter,RecognizerEngine,RecognizerApi,ErrorHandler,ContentAssist,GastRecorder,PerformanceTracer]);var EmbeddedActionsParser=class extends Xn{constructor(e,t=Q){let n=clone(t);n.outputCst=!1,super(e,n)}};export{jn as a,tokenMatcher as c,baseUniq as d,reduce as f,flatten as g,filter as h,getLookaheadPaths as i,Lexer as l,flatMap as m,EmbeddedActionsParser as n,Y as o,isEmpty as p,LLkLookaheadStrategy as r,tokenLabel as s,EMPTY_ALT as t,xn as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,t}from"../rolldown-runtime.mjs";import{t as n}from"./atomically.mjs";import{g as r}from"./@modelcontextprotocol/sdk.mjs";import{t as i}from"./ajv.mjs";import{isDeepStrictEqual as a}from"node:util";import o from"node:path";import s from"node:os";import c from"node:fs";import l from"node:crypto";import u from"node:process";import d from"node:assert";const isObject=e=>{let t=typeof e;return e!==null&&(t===`object`||t===`function`)},f=new Set([`__proto__`,`prototype`,`constructor`]),p=1e6,isDigit=e=>e>=`0`&&e<=`9`;function shouldCoerceToNumber(e){if(e===`0`)return!0;if(/^[1-9]\d*$/.test(e)){let t=Number.parseInt(e,10);return t<=2**53-1&&t<=p}return!1}function processSegment(e,t){return f.has(e)?!1:(e&&shouldCoerceToNumber(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function parsePath(e){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);let t=[],n=``,r=`start`,i=!1,a=0;for(let o of e){if(a++,i){n+=o,i=!1;continue}if(o===`\\`){if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);i=!0,r=r===`start`?`property`:r;continue}switch(o){case`.`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`property`;break}if(!processSegment(n,t))return[];n=``,r=`property`;break;case`[`:if(r===`index`)throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`){r=`index`;break}if(r===`property`||r===`start`){if((n||r===`property`)&&!processSegment(n,t))return[];n=``}r=`index`;break;case`]`:if(r===`index`){if(n===``)n=(t.pop()||``)+`[]`,r=`property`;else{let e=Number.parseInt(n,10);!Number.isNaN(e)&&Number.isFinite(e)&&e>=0&&e<=2**53-1&&e<=p&&n===String(e)?t.push(e):t.push(n),n=``,r=`indexEnd`}break}if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);n+=o;break;default:if(r===`index`&&!isDigit(o))throw Error(`Invalid character '${o}' in an index at position ${a}`);if(r===`indexEnd`)throw Error(`Invalid character '${o}' after an index at position ${a}`);r===`start`&&(r=`property`),n+=o}}switch(i&&(n+=`\\`),r){case`property`:if(!processSegment(n,t))return[];break;case`index`:throw Error(`Index was not closed`);case`start`:t.push(``);break}return t}function normalizePath(e){if(typeof e==`string`)return parsePath(e);if(Array.isArray(e)){let t=[];for(let[n,r]of e.entries()){if(typeof r!=`string`&&typeof r!=`number`)throw TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof r}`);if(typeof r==`number`&&!Number.isFinite(r))throw TypeError(`Path segment at index ${n} must be a finite number, got ${r}`);if(f.has(r))return[];typeof r==`string`&&shouldCoerceToNumber(r)?t.push(Number.parseInt(r,10)):t.push(r)}return t}return[]}function getProperty(e,t,n){if(!isObject(e)||typeof t!=`string`&&!Array.isArray(t))return n===void 0?e:n;let r=normalizePath(t);if(r.length===0)return n;for(let t=0;t<r.length;t++){let i=r[t];if(e=e[i],e==null){if(t!==r.length-1)return n;break}}return e===void 0?n:e}function setProperty(e,t,n){if(!isObject(e)||typeof t!=`string`&&!Array.isArray(t))return e;let r=e,i=normalizePath(t);if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];if(t===i.length-1)e[r]=n;else if(!isObject(e[r])){let n=typeof i[t+1]==`number`;e[r]=n?[]:{}}e=e[r]}return r}function deleteProperty(e,t){if(!isObject(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=normalizePath(t);if(n.length===0)return!1;for(let t=0;t<n.length;t++){let r=n[t];if(t===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;if(e=e[r],!isObject(e))return!1}}function hasProperty(e,t){if(!isObject(e)||typeof t!=`string`&&!Array.isArray(t))return!1;let n=normalizePath(t);if(n.length===0)return!1;for(let t of n){if(!isObject(e)||!(t in e))return!1;e=e[t]}return!0}const m=s.homedir(),h=s.tmpdir(),{env:g}=u,macos=e=>{let t=o.join(m,`Library`);return{data:o.join(t,`Application Support`,e),config:o.join(t,`Preferences`,e),cache:o.join(t,`Caches`,e),log:o.join(t,`Logs`,e),temp:o.join(h,e)}},windows=e=>{let t=g.APPDATA||o.join(m,`AppData`,`Roaming`),n=g.LOCALAPPDATA||o.join(m,`AppData`,`Local`);return{data:o.join(n,e,`Data`),config:o.join(t,e,`Config`),cache:o.join(n,e,`Cache`),log:o.join(n,e,`Log`),temp:o.join(h,e)}},linux=e=>{let t=o.basename(m);return{data:o.join(g.XDG_DATA_HOME||o.join(m,`.local`,`share`),e),config:o.join(g.XDG_CONFIG_HOME||o.join(m,`.config`),e),cache:o.join(g.XDG_CACHE_HOME||o.join(m,`.cache`),e),log:o.join(g.XDG_STATE_HOME||o.join(m,`.local`,`state`),e),temp:o.join(h,t,e)}};function envPaths(e,{suffix:t=`nodejs`}={}){if(typeof e!=`string`)throw TypeError(`Expected a string, got ${typeof e}`);return t&&(e+=`-${t}`),u.platform===`darwin`?macos(e):u.platform===`win32`?windows(e):linux(e)}var _=i(),v=e(r(),1);const copyProperty=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!canCopyProperty(i,a)&&r||Object.defineProperty(e,n,a)},canCopyProperty=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},changePrototype=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},wrappedToString=(e,t)=>`/* Wrapped ${e}*/\n${t}`,y=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),ee=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),changeToString=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=wrappedToString.bind(null,r,t.toString());Object.defineProperty(i,"name",ee);let{writable:a,enumerable:o,configurable:s}=y;Object.defineProperty(e,"toString",{value:i,writable:a,enumerable:o,configurable:s})};function mimicFunction(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))copyProperty(e,t,r,n);return changePrototype(e,t),changeToString(e,t,r),e}const debounceFunction=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);let{wait:n=0,maxWait:r=1/0,before:i=!1,after:a=!0}=t;if(n<0||r<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!a)throw Error("Both `before` and `after` are false, function wouldn't be called.");let o,s,c,debouncedFunction=function(...t){let l=this,later=()=>{o=void 0,s&&=(clearTimeout(s),void 0),a&&(c=e.apply(l,t))},maxLater=()=>{s=void 0,o&&=(clearTimeout(o),void 0),a&&(c=e.apply(l,t))},u=i&&!o;return clearTimeout(o),o=setTimeout(later,n),r>0&&r!==1/0&&!s&&(s=setTimeout(maxLater,r)),u&&(c=e.apply(l,t)),c};return mimicFunction(debouncedFunction,e),debouncedFunction.cancel=()=>{o&&=(clearTimeout(o),void 0),s&&=(clearTimeout(s),void 0)},debouncedFunction};var b=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),x=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),S=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=b(),a=x();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],makeSafeRegex=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},createToken=(e,t,n)=>{let r=makeSafeRegex(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};createToken(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),createToken(`NUMERICIDENTIFIERLOOSE`,`\\d+`),createToken(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),createToken(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),createToken(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),createToken(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),createToken(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),createToken(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),createToken(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),createToken(`BUILDIDENTIFIER`,`${f}+`),createToken(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),createToken(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),createToken(`FULL`,`^${c[u.FULLPLAIN]}$`),createToken(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),createToken(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),createToken(`GTLT`,`((?:<|>)?=?)`),createToken(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),createToken(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),createToken(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),createToken(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),createToken(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),createToken(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),createToken(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),createToken(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),createToken(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),createToken(`COERCERTL`,c[u.COERCE],!0),createToken(`COERCERTLFULL`,c[u.COERCEFULL],!0),createToken(`LONETILDE`,`(?:~>?)`),createToken(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,createToken(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),createToken(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),createToken(`LONECARET`,`(?:\\^)`),createToken(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,createToken(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),createToken(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),createToken(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),createToken(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),createToken(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,createToken(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),createToken(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),createToken(`STAR`,`(<|>)?=?\\s*\\*`),createToken(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),createToken(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),C=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({}),parseOptions=e=>e?typeof e==`object`?e:n:r;t.exports=parseOptions})),w=t(((e,t)=>{let n=/^[0-9]+$/,compareIdentifiers=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1},rcompareIdentifiers=(e,t)=>compareIdentifiers(t,e);t.exports={compareIdentifiers,rcompareIdentifiers}})),T=t(((e,t)=>{let n=x(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=b(),{safeRe:a,t:o}=S(),s=C(),{compareIdentifiers:c}=w();t.exports=class SemVer{constructor(e,t){if(t=s(t),e instanceof SemVer){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let c=e.trim().match(t.loose?a[o.LOOSE]:a[o.FULL]);if(!c)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);c[4]?this.prerelease=c[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=c[5]?c[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(e){if(n(`SemVer.compare`,this.version,this.options,e),!(e instanceof SemVer)){if(typeof e==`string`&&e===this.version)return 0;e=new SemVer(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof SemVer||(e=new SemVer(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:+(this.patch>e.patch)}comparePre(e){if(e instanceof SemVer||(e=new SemVer(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],i=e.prerelease[t];if(n(`prerelease compare`,t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return c(r,i)}while(++t)}compareBuild(e){e instanceof SemVer||(e=new SemVer(e,this.options));let t=0;do{let r=this.build[t],i=e.build[t];if(n(`build compare`,t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return c(r,i)}while(++t)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),E=t(((e,t)=>{let n=T(),parse=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}};t.exports=parse})),D=t(((e,t)=>{let n=E(),valid=(e,t)=>{let r=n(e,t);return r?r.version:null};t.exports=valid})),O=t(((e,t)=>{let n=E(),clean=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null};t.exports=clean})),te=t(((e,t)=>{let n=T(),inc=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}};t.exports=inc})),ne=t(((e,t)=>{let n=E(),diff=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`};t.exports=diff})),k=t(((e,t)=>{let n=T(),major=(e,t)=>new n(e,t).major;t.exports=major})),re=t(((e,t)=>{let n=T(),minor=(e,t)=>new n(e,t).minor;t.exports=minor})),ie=t(((e,t)=>{let n=T(),patch=(e,t)=>new n(e,t).patch;t.exports=patch})),ae=t(((e,t)=>{let n=E(),prerelease=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null};t.exports=prerelease})),A=t(((e,t)=>{let n=T(),compare=(e,t,r)=>new n(e,r).compare(new n(t,r));t.exports=compare})),oe=t(((e,t)=>{let n=A(),rcompare=(e,t,r)=>n(t,e,r);t.exports=rcompare})),se=t(((e,t)=>{let n=A(),compareLoose=(e,t)=>n(e,t,!0);t.exports=compareLoose})),j=t(((e,t)=>{let n=T(),compareBuild=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)};t.exports=compareBuild})),M=t(((e,t)=>{let n=j(),sort=(e,t)=>e.sort((e,r)=>n(e,r,t));t.exports=sort})),N=t(((e,t)=>{let n=j(),rsort=(e,t)=>e.sort((e,r)=>n(r,e,t));t.exports=rsort})),P=t(((e,t)=>{let n=A(),gt=(e,t,r)=>n(e,t,r)>0;t.exports=gt})),F=t(((e,t)=>{let n=A(),lt=(e,t,r)=>n(e,t,r)<0;t.exports=lt})),I=t(((e,t)=>{let n=A(),eq=(e,t,r)=>n(e,t,r)===0;t.exports=eq})),L=t(((e,t)=>{let n=A(),neq=(e,t,r)=>n(e,t,r)!==0;t.exports=neq})),R=t(((e,t)=>{let n=A(),gte=(e,t,r)=>n(e,t,r)>=0;t.exports=gte})),z=t(((e,t)=>{let n=A(),lte=(e,t,r)=>n(e,t,r)<=0;t.exports=lte})),B=t(((e,t)=>{let n=I(),r=L(),i=P(),a=R(),o=F(),s=z(),cmp=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}};t.exports=cmp})),V=t(((e,t)=>{let n=T(),r=E(),{safeRe:i,t:a}=S(),coerce=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)};t.exports=coerce})),H=t(((e,t)=>{var LRUCache=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}};t.exports=LRUCache})),U=t(((e,t)=>{let n=/\s+/g;t.exports=class Range{constructor(e,t){if(t=i(t),e instanceof Range)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new Range(e.raw,t);if(e instanceof a)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!isNullSet(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&isAny(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,hyphenReplace(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let h=e.split(` `).map(e=>parseComparator(e,this.options)).join(` `).split(/\s+/).map(e=>replaceGTE0(e,this.options));i&&(h=h.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,h);let g=new Map,_=h.map(e=>new a(e,this.options));for(let e of _){if(isNullSet(e))return[e];g.set(e.value,e)}g.size>1&&g.has(``)&&g.delete(``);let v=[...g.values()];return r.set(t,v),v}intersects(e,t){if(!(e instanceof Range))throw TypeError(`a Range is required`);return this.set.some(n=>isSatisfiable(n,t)&&e.set.some(e=>isSatisfiable(e,t)&&n.every(n=>e.every(e=>n.intersects(e,t)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(testSet(this.set[t],e,this.options))return!0;return!1}};let r=new(H()),i=C(),a=W(),o=x(),s=T(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=S(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=b(),isNullSet=e=>e.value===`<0.0.0-0`,isAny=e=>e.value===``,isSatisfiable=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},parseComparator=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=replaceCarets(e,t),o(`caret`,e),e=replaceTildes(e,t),o(`tildes`,e),e=replaceXRanges(e,t),o(`xrange`,e),e=replaceStars(e,t),o(`stars`,e),e),isX=e=>!e||e.toLowerCase()===`x`||e===`*`,replaceTildes=(e,t)=>e.trim().split(/\s+/).map(e=>replaceTilde(e,t)).join(` `),replaceTilde=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return isX(n)?s=``:isX(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:isX(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},replaceCarets=(e,t)=>e.trim().split(/\s+/).map(e=>replaceCaret(e,t)).join(` `),replaceCaret=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return isX(n)?c=``:isX(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:isX(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},replaceXRanges=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>replaceXRange(e,t)).join(` `)),replaceXRange=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=isX(i),u=l||isX(a),d=u||isX(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},replaceStars=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),replaceGTE0=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),hyphenReplace=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=isX(r)?``:isX(i)?`>=${r}.0.0${e?`-0`:``}`:isX(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=isX(l)?``:isX(u)?`<${+l+1}.0.0-0`:isX(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),testSet=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),W=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class Comparator{static get ANY(){return n}constructor(e,t){if(t=r(t),e instanceof Comparator){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(` `),s(`comparator`,e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof Comparator))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new l(e.value,t).test(this.value):e.operator===``?e.value===``?!0:new l(this.value,t).test(e.semver):(t=r(t),t.includePrerelease&&(this.value===`<0.0.0-0`||e.value===`<0.0.0-0`)||!t.includePrerelease&&(this.value.startsWith(`<0.0.0`)||e.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&e.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&e.operator.startsWith(`<`)||this.semver.version===e.semver.version&&this.operator.includes(`=`)&&e.operator.includes(`=`)||o(this.semver,`<`,e.semver,t)&&this.operator.startsWith(`>`)&&e.operator.startsWith(`<`)||o(this.semver,`>`,e.semver,t)&&this.operator.startsWith(`<`)&&e.operator.startsWith(`>`)))}};let r=C(),{safeRe:i,t:a}=S(),o=B(),s=x(),c=T(),l=U()})),G=t(((e,t)=>{let n=U(),satisfies=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)};t.exports=satisfies})),ce=t(((e,t)=>{let n=U(),toComparators=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `));t.exports=toComparators})),le=t(((e,t)=>{let n=T(),r=U(),maxSatisfying=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a};t.exports=maxSatisfying})),ue=t(((e,t)=>{let n=T(),r=U(),minSatisfying=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a};t.exports=minSatisfying})),de=t(((e,t)=>{let n=T(),r=U(),i=P(),minVersion=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null};t.exports=minVersion})),fe=t(((e,t)=>{let n=U(),validRange=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}};t.exports=validRange})),K=t(((e,t)=>{let n=T(),r=W(),{ANY:i}=r,a=U(),o=G(),s=P(),c=F(),l=z(),u=R(),outside=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0};t.exports=outside})),pe=t(((e,t)=>{let n=K(),gtr=(e,t,r)=>n(e,t,`>`,r);t.exports=gtr})),me=t(((e,t)=>{let n=K(),ltr=(e,t,r)=>n(e,t,`<`,r);t.exports=ltr})),he=t(((e,t)=>{let n=U(),intersects=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r));t.exports=intersects})),ge=t(((e,t)=>{let n=G(),r=A();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),_e=t(((e,t)=>{let n=U(),r=W(),{ANY:i}=r,a=G(),o=A(),subset=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=simpleSubset(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},s=[new r(`>=0.0.0-0`)],c=[new r(`>=0.0.0`)],simpleSubset=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?s:c}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=c}let r=new Set,l,u;for(let t of e)t.operator===`>`||t.operator===`>=`?l=higherGT(l,t,n):t.operator===`<`||t.operator===`<=`?u=lowerLT(u,t,n):r.add(t.semver);if(r.size>1)return null;let d;if(l&&u&&(d=o(l.semver,u.semver,n),d>0||d===0&&(l.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(l&&!a(e,String(l),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let f,p,m,h,g=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,_=l&&!n.includePrerelease&&l.semver.prerelease.length?l.semver:!1;g&&g.prerelease.length===1&&u.operator===`<`&&g.prerelease[0]===0&&(g=!1);for(let e of t){if(h=h||e.operator===`>`||e.operator===`>=`,m=m||e.operator===`<`||e.operator===`<=`,l){if(_&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===_.major&&e.semver.minor===_.minor&&e.semver.patch===_.patch&&(_=!1),e.operator===`>`||e.operator===`>=`){if(f=higherGT(l,e,n),f===e&&f!==l)return!1}else if(l.operator===`>=`&&!a(l.semver,String(e),n))return!1}if(u){if(g&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===g.major&&e.semver.minor===g.minor&&e.semver.patch===g.patch&&(g=!1),e.operator===`<`||e.operator===`<=`){if(p=lowerLT(u,e,n),p===e&&p!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||l)&&d!==0)return!1}return!(l&&m&&!u&&d!==0||u&&h&&!l&&d!==0||_||g)},higherGT=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},lowerLT=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=subset})),q=t(((e,t)=>{let n=S(),r=b(),i=T(),a=w();t.exports={parse:E(),valid:D(),clean:O(),inc:te(),diff:ne(),major:k(),minor:re(),patch:ie(),prerelease:ae(),compare:A(),rcompare:oe(),compareLoose:se(),compareBuild:j(),sort:M(),rsort:N(),gt:P(),lt:F(),eq:I(),neq:L(),gte:R(),lte:z(),cmp:B(),coerce:V(),Comparator:W(),Range:U(),satisfies:G(),toComparators:ce(),maxSatisfying:le(),minSatisfying:ue(),minVersion:de(),validRange:fe(),outside:K(),gtr:pe(),ltr:me(),intersects:he(),simplifyRange:ge(),subset:_e(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}})),J=e(q(),1);const ve=Object.prototype.toString;function isType(e,t,n){return e?e.constructor===t?!0:ve.call(e)===n:!1}function isUint8Array(e){return isType(e,Uint8Array,`[object Uint8Array]`)}function isArrayBuffer(e){return isType(e,ArrayBuffer,`[object ArrayBuffer]`)}function isUint8ArrayOrArrayBuffer(e){return isUint8Array(e)||isArrayBuffer(e)}function assertUint8Array(e){if(!isUint8Array(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function assertUint8ArrayOrArrayBuffer(e){if(!isUint8ArrayOrArrayBuffer(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function concatUint8Arrays(e,t){if(e.length===0)return new Uint8Array;t??=e.reduce((e,t)=>e+t.length,0);let n=new Uint8Array(t),r=0;for(let t of e)assertUint8Array(t),n.set(t,r),r+=t.length;return n}const Y={utf8:new globalThis.TextDecoder(`utf8`)};function uint8ArrayToString(e,t=`utf8`){return assertUint8ArrayOrArrayBuffer(e),Y[t]??=new globalThis.TextDecoder(t),Y[t].decode(e)}function assertString(e){if(typeof e!=`string`)throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}const ye=new globalThis.TextEncoder;function stringToUint8Array(e){return assertString(e),ye.encode(e)}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));const X=`aes-256-cbc`,Z=new Set([`aes-256-cbc`,`aes-256-gcm`,`aes-256-ctr`]),isSupportedEncryptionAlgorithm=e=>typeof e==`string`&&Z.has(e),createPlainObject=()=>Object.create(null),isExist=e=>e!==void 0,checkValueType=(e,t)=>{let n=new Set([`undefined`,`symbol`,`function`]),r=typeof t;if(n.has(r))throw TypeError(`Setting a value of type \`${r}\` for key \`${e}\` is not allowed as it's not supported by JSON`)},Q=`__internal__`,$=`${Q}.migrations.version`;var Conf=class{path;events;#e;#t;#n;#r;#i={};#a=!1;#o;#s;#c;constructor(e={}){let t=this.#l(e);this.#r=t,this.#u(t),this.#f(t),this.#p(t),this.events=new EventTarget,this.#t=t.encryptionKey,this.#n=t.encryptionAlgorithm??X,this.path=this.#m(t),this.#h(t),t.watch&&this._watch()}get(e,t){if(this.#r.accessPropertiesByDotNotation)return this._get(e,t);let{store:n}=this;return e in n?n[e]:t}set(e,t){if(typeof e!=`string`&&typeof e!=`object`)throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof e}`);if(typeof e!=`object`&&t===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(e))throw TypeError(`Please don't use the ${Q} key, as it's used to manage this module internal operations.`);let{store:n}=this,set=(e,t)=>{if(checkValueType(e,t),this.#r.accessPropertiesByDotNotation)setProperty(n,e,t);else{if(e===`__proto__`||e===`constructor`||e===`prototype`)return;n[e]=t}};if(typeof e==`object`){let t=e;for(let[e,n]of Object.entries(t))set(e,n)}else set(e,t);this.store=n}has(e){return this.#r.accessPropertiesByDotNotation?hasProperty(this.store,e):e in this.store}appendToArray(e,t){checkValueType(e,t);let n=this.#r.accessPropertiesByDotNotation?this._get(e,[]):e in this.store?this.store[e]:[];if(!Array.isArray(n))throw TypeError(`The key \`${e}\` is already set to a non-array value`);this.set(e,[...n,t])}reset(...e){for(let t of e)isExist(this.#i[t])&&this.set(t,this.#i[t])}delete(e){let{store:t}=this;this.#r.accessPropertiesByDotNotation?deleteProperty(t,e):delete t[e],this.store=t}clear(){let e=createPlainObject();for(let t of Object.keys(this.#i))isExist(this.#i[t])&&(checkValueType(t,this.#i[t]),this.#r.accessPropertiesByDotNotation?setProperty(e,t,this.#i[t]):e[t]=this.#i[t]);this.store=e}onDidChange(e,t){if(typeof e!=`string`)throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof e}`);if(typeof t!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`);return this._handleValueChange(()=>this.get(e),t)}onDidAnyChange(e){if(typeof e!=`function`)throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof e}`);return this._handleStoreChange(e)}get size(){return Object.keys(this.store).filter(e=>!this._isReservedKeyPath(e)).length}get store(){try{let e=c.readFileSync(this.path,this.#t?null:`utf8`),t=this._decryptData(e),parseStore=e=>{let t=this._deserialize(e);return this.#a||this._validate(t),Object.assign(createPlainObject(),t)};return parseStore(t)}catch(e){if(e?.code===`ENOENT`)return this._ensureDirectory(),createPlainObject();if(this.#r.clearInvalidConfig){let t=e;if(t.name===`SyntaxError`||t.message?.startsWith(`Config schema violation:`)||t.message===`Failed to decrypt config data.`)return createPlainObject()}throw e}}set store(e){if(this._ensureDirectory(),!hasProperty(e,Q))try{let t=c.readFileSync(this.path,this.#t?null:`utf8`),n=this._decryptData(t),r=this._deserialize(n);hasProperty(r,Q)&&setProperty(e,Q,getProperty(r,Q))}catch{}this.#a||this._validate(e),this._write(e),this.events.dispatchEvent(new Event(`change`))}*[Symbol.iterator](){for(let[e,t]of Object.entries(this.store))this._isReservedKeyPath(e)||(yield[e,t])}_closeWatcher(){this.#o&&=(this.#o.close(),void 0),this.#s&&=(c.unwatchFile(this.path),!1),this.#c=void 0}_decryptData(e){let t=this.#t;if(!t)return typeof e==`string`?e:uint8ArrayToString(e);let n=this.#n,r=n===`aes-256-gcm`?16:0,i=`:`.codePointAt(0),a=typeof e==`string`?e.codePointAt(16):e[16];if(!(i!==void 0&&a===i)){if(n===`aes-256-cbc`)return typeof e==`string`?e:uint8ArrayToString(e);throw Error(`Failed to decrypt config data.`)}let getEncryptedPayload=e=>{if(r===0)return{ciphertext:e};let t=e.length-r;if(t<0)throw Error(`Invalid authentication tag length.`);return{ciphertext:e.slice(0,t),authenticationTag:e.slice(t)}},o=e.slice(0,16),s=e.slice(17),c=typeof s==`string`?stringToUint8Array(s):s,decrypt=e=>{let{ciphertext:r,authenticationTag:i}=getEncryptedPayload(c),a=l.pbkdf2Sync(t,e,1e4,32,`sha512`),s=l.createDecipheriv(n,a,o);return i&&s.setAuthTag(i),uint8ArrayToString(concatUint8Arrays([s.update(r),s.final()]))};try{return decrypt(o)}catch{try{return decrypt(o.toString())}catch{}}if(n===`aes-256-cbc`)return typeof e==`string`?e:uint8ArrayToString(e);throw Error(`Failed to decrypt config data.`)}_handleStoreChange(e){let t=this.store,onChange=()=>{let n=t,r=this.store;a(r,n)||(t=r,e.call(this,r,n))};return this.events.addEventListener(`change`,onChange),()=>{this.events.removeEventListener(`change`,onChange)}}_handleValueChange(e,t){let n=e(),onChange=()=>{let r=n,i=e();a(i,r)||(n=i,t.call(this,i,r))};return this.events.addEventListener(`change`,onChange),()=>{this.events.removeEventListener(`change`,onChange)}}_deserialize=e=>JSON.parse(e);_serialize=e=>JSON.stringify(e,void 0,` `);_validate(e){if(!this.#e||this.#e(e)||!this.#e.errors)return;let t=this.#e.errors.map(({instancePath:e,message:t=``})=>`\`${e.slice(1)}\` ${t}`);throw Error(`Config schema violation: `+t.join(`; `))}_ensureDirectory(){c.mkdirSync(o.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e),r=this.#t;if(r){let e=l.randomBytes(16),n=l.pbkdf2Sync(r,e,1e4,32,`sha512`),i=l.createCipheriv(this.#n,n,e),a=concatUint8Arrays([i.update(stringToUint8Array(t)),i.final()]),o=[e,stringToUint8Array(`:`),a];this.#n===`aes-256-gcm`&&o.push(i.getAuthTag()),t=concatUint8Arrays(o)}if(u.env.SNAP)c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});else try{n(this.path,t,{mode:this.#r.configFileMode})}catch(e){if(e?.code===`EXDEV`){c.writeFileSync(this.path,t,{mode:this.#r.configFileMode});return}throw e}}_watch(){if(this._ensureDirectory(),c.existsSync(this.path)||this._write(createPlainObject()),u.platform===`win32`||u.platform===`darwin`){this.#c??=debounceFunction(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:100});let e=o.dirname(this.path),t=o.basename(this.path);this.#o=c.watch(e,{persistent:!1,encoding:`utf8`},(e,n)=>{n&&n!==t||typeof this.#c==`function`&&this.#c()})}else this.#c??=debounceFunction(()=>{this.events.dispatchEvent(new Event(`change`))},{wait:1e3}),c.watchFile(this.path,{persistent:!1},(e,t)=>{typeof this.#c==`function`&&this.#c()}),this.#s=!0}_migrate(e,t,n){let r=this._get($,`0.0.0`),i=Object.keys(e).filter(e=>this._shouldPerformMigration(e,r,t)),a=structuredClone(this.store);for(let o of i)try{n&&n(this,{fromVersion:r,toVersion:o,finalVersion:t,versions:i});let s=e[o];s?.(this),this._set($,o),r=o,a=structuredClone(this.store)}catch(e){this.store=a;let t=e instanceof Error?e.message:String(e);throw Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${t}`)}(this._isVersionInRangeFormat(r)||!J.default.eq(r,t))&&this._set($,t)}_containsReservedKey(e){return typeof e==`string`?this._isReservedKeyPath(e):!e||typeof e!=`object`?!1:this._objectContainsReservedKey(e)}_objectContainsReservedKey(e){if(!e||typeof e!=`object`)return!1;for(let[t,n]of Object.entries(e))if(this._isReservedKeyPath(t)||this._objectContainsReservedKey(n))return!0;return!1}_isReservedKeyPath(e){return e===Q||e.startsWith(`${Q}.`)}_isVersionInRangeFormat(e){return J.default.clean(e)===null}_shouldPerformMigration(e,t,n){return this._isVersionInRangeFormat(e)?t!==`0.0.0`&&J.default.satisfies(t,e)?!1:J.default.satisfies(n,e):!(J.default.lte(e,t)||J.default.gt(e,n))}_get(e,t){return getProperty(this.store,e,t)}_set(e,t){let{store:n}=this;setProperty(n,e,t),this.store=n}#l(e){let t={configName:`config`,fileExtension:`json`,projectSuffix:`nodejs`,clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...e};if(t.encryptionAlgorithm??=X,!isSupportedEncryptionAlgorithm(t.encryptionAlgorithm))throw TypeError(`The \`encryptionAlgorithm\` option must be one of: ${[...Z].join(`, `)}`);if(!t.cwd){if(!t.projectName)throw Error("Please specify the `projectName` option.");t.cwd=envPaths(t.projectName,{suffix:t.projectSuffix}).config}return typeof t.fileExtension==`string`&&(t.fileExtension=t.fileExtension.replace(/^\.+/,``)),t}#u(e){if(!(e.schema??e.ajvOptions??e.rootSchema))return;if(e.schema&&typeof e.schema!=`object`)throw TypeError("The `schema` option must be an object.");let t=v.default.default,n=new _.Ajv2020({allErrors:!0,useDefaults:!0,...e.ajvOptions});t(n);let r={...e.rootSchema,type:`object`,properties:e.schema};this.#e=n.compile(r),this.#d(e.schema)}#d(e){let t=Object.entries(e??{});for(let[e,n]of t){if(!n||typeof n!=`object`||!Object.hasOwn(n,`default`))continue;let{default:t}=n;t!==void 0&&(this.#i[e]=t)}}#f(e){e.defaults&&Object.assign(this.#i,e.defaults)}#p(e){e.serialize&&(this._serialize=e.serialize),e.deserialize&&(this._deserialize=e.deserialize)}#m(e){let t=typeof e.fileExtension==`string`?e.fileExtension:void 0,n=t?`.${t}`:``;return o.resolve(e.cwd,`${e.configName??`config`}${n}`)}#h(e){if(e.migrations){this.#g(e),this._validate(this.store);return}let t=this.store,n=Object.assign(createPlainObject(),e.defaults??{},t);this._validate(n);try{d.deepEqual(t,n)}catch{this.store=n}}#g(e){let{migrations:t,projectVersion:n}=e;if(t){if(!n)throw Error("Please specify the `projectVersion` option.");this.#a=!0;try{let r=this.store,i=Object.assign(createPlainObject(),e.defaults??{},r);try{d.deepEqual(r,i)}catch{this._write(i)}this._migrate(t,n,e.beforeEachMigration)}finally{this.#a=!1}}}};export{q as n,Conf as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function _defu(e,t,n=`.`,r){if(!isPlainObject(t))return _defu(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(Array.isArray(a)&&Array.isArray(i[t])?i[t]=[...a,...i[t]]:isPlainObject(a)&&isPlainObject(i[t])?i[t]=_defu(a,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=a))}return i}function createDefu(e){return(...t)=>t.reduce((t,n)=>_defu(t,n,``,e),{})}const e=createDefu();export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";const e=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,t=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function jsonParseTransform(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){warnKeyDropped(e);return}return t}function warnKeyDropped(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function destr(r,i={}){if(typeof r!=`string`)return r;if(r[0]===`"`&&r[r.length-1]===`"`&&r.indexOf(`\\`)===-1)return r.slice(1,-1);let a=r.trim();if(a.length<=9)switch(a.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!n.test(r)){if(i.strict)throw SyntaxError(`[destr] Invalid JSON`);return r}try{if(e.test(r)||t.test(r)){if(i.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(r,jsonParseTransform)}return JSON.parse(r)}catch(e){if(i.strict)throw e;return r}}export{destr as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,t}from"../rolldown-runtime.mjs";var n=e(t(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function Events(){}Object.create&&(Events.prototype=Object.create(null),new Events().__proto__||(r=!1));function EE(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function addListener(e,t,n,i,a){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var o=new EE(n,i||e,a),s=r?r+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function clearEvent(e,t){--e._eventsCount===0?e._events=new Events:delete e._events[t]}function EventEmitter(){this._events=new Events,this._eventsCount=0}EventEmitter.prototype.eventNames=function eventNames(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},EventEmitter.prototype.listeners=function listeners(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},EventEmitter.prototype.listenerCount=function listenerCount(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},EventEmitter.prototype.emit=function emit(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},EventEmitter.prototype.on=function on(e,t,n){return addListener(this,e,t,n,!1)},EventEmitter.prototype.once=function once(e,t,n){return addListener(this,e,t,n,!0)},EventEmitter.prototype.removeListener=function removeListener(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return clearEvent(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&clearEvent(this,a);else{for(var s=0,c=[],l=o.length;s<l;s++)(o[s].fn!==t||i&&!o[s].once||n&&o[s].context!==n)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:clearEvent(this,a)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(e){var t;return e?(t=r?r+e:e,this._events[t]&&clearEvent(this,t)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=r,EventEmitter.EventEmitter=EventEmitter,t!==void 0&&(t.exports=EventEmitter)}))(),1);export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import e from"node:path";import t from"node:fs";import"node:fs/promises";import{fileURLToPath as n}from"node:url";import r from"node:process";const toPath=e=>e instanceof URL?n(e):e;function findUpSync(n,{cwd:i=r.cwd(),type:a=`file`,stopAt:o}={}){let s=e.resolve(toPath(i)??``),{root:c}=e.parse(s);for(o=e.resolve(s,toPath(o)??c);s&&s!==o&&s!==c;){let r=e.isAbsolute(n)?n:e.join(s,n);try{let e=t.statSync(r,{throwIfNoEntry:!1});if(a===`file`&&e?.isFile()||a===`directory`&&e?.isDirectory())return r}catch{}s=e.dirname(s)}}export{findUpSync as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import e from"node:os";import t from"node:net";var Locked=class extends Error{constructor(e){super(`${e} is locked`)}};const n={old:new Set,young:new Set},r=1024,i=65535;let a;const getLocalHosts=()=>{let t=e.networkInterfaces(),n=new Set([void 0,`0.0.0.0`]);for(let e of Object.values(t))for(let t of e)n.add(t.address);return n},checkAvailablePort=e=>new Promise((n,r)=>{let i=t.createServer();i.unref(),i.on(`error`,r),i.listen(e,()=>{let{port:e}=i.address();i.close(()=>{n(e)})})}),getAvailablePort=async(e,t)=>{if(e.host||e.port===0)return checkAvailablePort(e);for(let n of t)try{await checkAvailablePort({port:e.port,host:n})}catch(e){if(![`EADDRNOTAVAIL`,`EINVAL`].includes(e.code))throw e}return e.port},portCheckSequence=function*(e){e&&(yield*e),yield 0};async function getPorts(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port==`number`?[e.port]:e.port),e.exclude)){let t=e.exclude;if(typeof t[Symbol.iterator]!=`function`)throw TypeError("The `exclude` option must be an iterable.");for(let e of t){if(typeof e!=`number`)throw TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(e))throw TypeError(`Number ${e} in the exclude option is not a safe integer and can't be used`)}r=new Set(t)}a===void 0&&(a=setTimeout(()=>{a=void 0,n.old=n.young,n.young=new Set},15e3),a.unref&&a.unref());let i=getLocalHosts();for(let a of portCheckSequence(t))try{if(r.has(a))continue;let t=await getAvailablePort({...e,port:a},i);for(;n.old.has(t)||n.young.has(t);){if(a!==0)throw new Locked(a);t=await getAvailablePort({...e,port:a},i)}return n.young.add(t),t}catch(e){if(![`EADDRINUSE`,`EACCES`].includes(e.code)&&!(e instanceof Locked))throw e}throw Error(`No available ports found`)}function portNumbers(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw TypeError("`from` and `to` must be integer numbers");if(e<r||e>i)throw RangeError(`'from' must be between ${r} and ${i}`);if(t<r||t>i)throw RangeError(`'to' must be between ${r} and ${i}`);if(e>t)throw RangeError("`to` must be greater than or equal to `from`");let generator=function*(e,t){for(let n=e;n<=t;n++)yield n};return generator(e,t)}export{portNumbers as n,getPorts as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import{a as e,i as t}from"./@hono/mcp.mjs";var compose=(e,t,n)=>(r,i)=>{let a=-1;return dispatch(0);async function dispatch(o){if(o<=a)throw Error(`next() called multiple times`);a=o;let s,c=!1,l;if(e[o]?(l=e[o][0][0],r.req.routeIndex=o):l=o===e.length&&i||void 0,l)try{s=await l(r,()=>dispatch(o+1))}catch(e){if(e instanceof Error&&t)r.error=e,s=await t(e,r),c=!0;else throw e}else r.finalized===!1&&n&&(s=await n(r));return s&&(r.finalized===!1||c)&&(r.res=s),r}},n=Symbol(),parseBody=async(e,t=Object.create(null))=>{let{all:n=!1,dot:r=!1}=t,i=(e instanceof HonoRequest?e.raw.headers:e.headers).get(`Content-Type`);return i?.startsWith(`multipart/form-data`)||i?.startsWith(`application/x-www-form-urlencoded`)?parseFormData(e,{all:n,dot:r}):{}};async function parseFormData(e,t){let n=await e.formData();return n?convertFormDataToBodyData(n,t):{}}function convertFormDataToBodyData(e,t){let n=Object.create(null);return e.forEach((e,r)=>{t.all||r.endsWith(`[]`)?handleParsingAllValues(n,r,e):n[r]=e}),t.dot&&Object.entries(n).forEach(([e,t])=>{e.includes(`.`)&&(handleParsingNestedValues(n,e,t),delete n[e])}),n}var handleParsingAllValues=(e,t,n)=>{e[t]===void 0?t.endsWith(`[]`)?e[t]=[n]:e[t]=n:Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]},handleParsingNestedValues=(e,t,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let r=e,i=t.split(`.`);i.forEach((e,t)=>{t===i.length-1?r[e]=n:((!r[e]||typeof r[e]!=`object`||Array.isArray(r[e])||r[e]instanceof File)&&(r[e]=Object.create(null)),r=r[e])})},splitPath=e=>{let t=e.split(`/`);return t[0]===``&&t.shift(),t},splitRoutingPath=e=>{let{groups:t,path:n}=extractGroupsFromPath(e);return replaceGroupMarks(splitPath(n),t)},extractGroupsFromPath=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,n)=>{let r=`@${n}`;return t.push([r,e]),r}),{groups:t,path:e}},replaceGroupMarks=(e,t)=>{for(let n=t.length-1;n>=0;n--){let[r]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(r)){e[i]=e[i].replace(r,t[n][1]);break}}return e},r={},getPattern=(e,t)=>{if(e===`*`)return`*`;let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let i=`${e}#${t}`;return r[i]||(n[2]?r[i]=t&&t[0]!==`:`&&t[0]!==`*`?[i,n[1],RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],RegExp(`^${n[2]}$`)]:r[i]=[e,n[1],!0]),r[i]}return null},tryDecode=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},tryDecodeURI=e=>tryDecode(e,decodeURI),getPath=e=>{let t=e.url,n=t.indexOf(`/`,t.indexOf(`:`)+4),r=n;for(;r<t.length;r++){let e=t.charCodeAt(r);if(e===37){let e=t.indexOf(`?`,r),i=t.indexOf(`#`,r),a=e===-1?i===-1?void 0:i:i===-1?e:Math.min(e,i),o=t.slice(n,a);return tryDecodeURI(o.includes(`%25`)?o.replace(/%25/g,`%2525`):o)}else if(e===63||e===35)break}return t.slice(n,r)},getPathNoStrict=e=>{let t=getPath(e);return t.length>1&&t.at(-1)===`/`?t.slice(0,-1):t},mergePath=(e,t,...n)=>(n.length&&(t=mergePath(t,...n)),`${e?.[0]===`/`?``:`/`}${e}${t===`/`?``:`${e?.at(-1)===`/`?``:`/`}${t?.[0]===`/`?t.slice(1):t}`}`),checkOptionalParameter=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(`:`))return null;let t=e.split(`/`),n=[],r=``;return t.forEach(e=>{if(e!==``&&!/\:/.test(e))r+=`/`+e;else if(/\:/.test(e))if(/\?/.test(e)){n.length===0&&r===``?n.push(`/`):n.push(r);let t=e.replace(`?`,``);r+=`/`+t,n.push(r)}else r+=`/`+e}),n.filter((e,t,n)=>n.indexOf(e)===t)},_decodeURI=e=>/[%+]/.test(e)?(e.indexOf(`+`)!==-1&&(e=e.replace(/\+/g,` `)),e.indexOf(`%`)===-1?e:tryDecode(e,a)):e,_getQueryParam=(e,t,n)=>{let r;if(!n&&t&&!/[%+]/.test(t)){let n=e.indexOf(`?`,8);if(n===-1)return;for(e.startsWith(t,n+1)||(n=e.indexOf(`&${t}`,n+1));n!==-1;){let r=e.charCodeAt(n+t.length+1);if(r===61){let r=n+t.length+2,i=e.indexOf(`&`,r);return _decodeURI(e.slice(r,i===-1?void 0:i))}else if(r==38||isNaN(r))return``;n=e.indexOf(`&${t}`,n+1)}if(r=/[%+]/.test(e),!r)return}let i={};r??=/[%+]/.test(e);let a=e.indexOf(`?`,8);for(;a!==-1;){let t=e.indexOf(`&`,a+1),o=e.indexOf(`=`,a);o>t&&t!==-1&&(o=-1);let s=e.slice(a+1,o===-1?t===-1?void 0:t:o);if(r&&(s=_decodeURI(s)),a=t,s===``)continue;let c;o===-1?c=``:(c=e.slice(o+1,t===-1?void 0:t),r&&(c=_decodeURI(c))),n?(i[s]&&Array.isArray(i[s])||(i[s]=[]),i[s].push(c)):i[s]??=c}return t?i[t]:i},i=_getQueryParam,getQueryParams=(e,t)=>_getQueryParam(e,t,!0),a=decodeURIComponent,tryDecodeURIComponent=e=>tryDecode(e,a),HonoRequest=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t=`/`,n=[[]]){this.raw=e,this.path=t,this.#t=n,this.#e={}}param(e){return e?this.#n(e):this.#r()}#n(e){let t=this.#t[0][this.routeIndex][1][e],n=this.#i(t);return n&&/\%/.test(n)?tryDecodeURIComponent(n):n}#r(){let e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(let n of t){let t=this.#i(this.#t[0][this.routeIndex][1][n]);t!==void 0&&(e[n]=/\%/.test(t)?tryDecodeURIComponent(t):t)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return i(this.url,e)}queries(e){return getQueryParams(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,n)=>{t[n]=e}),t}async parseBody(e){return parseBody(this,e)}#a=e=>{let{bodyCache:t,raw:n}=this,r=t[e];if(r)return r;let i=Object.keys(t)[0];return i?t[i].then(t=>(i===`json`&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=n[e]()};json(){return this.#a(`text`).then(e=>JSON.parse(e))}text(){return this.#a(`text`)}arrayBuffer(){return this.#a(`arrayBuffer`)}blob(){return this.#a(`blob`)}formData(){return this.#a(`formData`)}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[n](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},o=`text/plain; charset=UTF-8`,setDefaultContentType=(e,t)=>({"Content-Type":e,...t}),createResponseInstance=(e,t)=>new Response(e,t),Context=class{#e;#t;env={};#n;finalized=!1;error;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t){this.#e=e,t&&(this.#i=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#d=t.path,this.#u=t.matchResult)}get req(){return this.#t??=new HonoRequest(this.#e,this.#d,this.#u),this.#t}get event(){if(this.#i&&`respondWith`in this.#i)return this.#i;throw Error(`This context has no FetchEvent`)}get executionCtx(){if(this.#i)return this.#i;throw Error(`This context has no ExecutionContext`)}get res(){return this.#a||=createResponseInstance(null,{headers:this.#l??=new Headers})}set res(e){if(this.#a&&e){e=createResponseInstance(e.body,e);for(let[t,n]of this.#a.headers.entries())if(t!==`content-type`)if(t===`set-cookie`){let t=this.#a.headers.getSetCookie();e.headers.delete(`set-cookie`);for(let n of t)e.headers.append(`set-cookie`,n)}else e.headers.set(t,n)}this.#a=e,this.finalized=!0}render=(...e)=>(this.#s??=e=>this.html(e),this.#s(...e));setLayout=e=>this.#o=e;getLayout=()=>this.#o;setRenderer=e=>{this.#s=e};header=(e,t,n)=>{this.finalized&&(this.#a=createResponseInstance(this.#a.body,this.#a));let r=this.#a?this.#a.headers:this.#l??=new Headers;t===void 0?r.delete(e):n?.append?r.append(e,t):r.set(e,t)};status=e=>{this.#r=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=e=>this.#n?this.#n.get(e):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#f(e,t,n){let r=this.#a?new Headers(this.#a.headers):this.#l??new Headers;if(typeof t==`object`&&`headers`in t){let e=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(let[t,n]of e)t.toLowerCase()===`set-cookie`?r.append(t,n):r.set(t,n)}if(n)for(let[e,t]of Object.entries(n))if(typeof t==`string`)r.set(e,t);else{r.delete(e);for(let n of t)r.append(e,n)}return createResponseInstance(e,{status:typeof t==`number`?t:t?.status??this.#r,headers:r})}newResponse=(...e)=>this.#f(...e);body=(e,t,n)=>this.#f(e,t,n);text=(e,t,n)=>!this.#l&&!this.#r&&!t&&!n&&!this.finalized?new Response(e):this.#f(e,t,setDefaultContentType(o,n));json=(e,t,n)=>this.#f(JSON.stringify(e),t,setDefaultContentType(`application/json`,n));html=(n,r,i)=>{let res=e=>this.#f(e,r,setDefaultContentType(`text/html; charset=UTF-8`,i));return typeof n==`object`?e(n,t.Stringify,!1,{}).then(res):res(n)};redirect=(e,t)=>{let n=String(e);return this.header(`Location`,/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>createResponseInstance(),this.#c(this))},s=[`get`,`post`,`put`,`delete`,`options`,`patch`],c=`Can not add a route since the matcher is already built.`,UnsupportedPathError=class extends Error{},l=`__COMPOSED_HANDLER`,notFoundHandler=e=>e.text(`404 Not Found`,404),errorHandler=(e,t)=>{if(`getResponse`in e){let n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text(`Internal Server Error`,500)},u=class _Hono{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath=`/`;#e=`/`;routes=[];constructor(e={}){[...s,`all`].forEach(e=>{this[e]=(t,...n)=>(typeof t==`string`?this.#e=t:this.#r(e,this.#e,t),n.forEach(t=>{this.#r(e,this.#e,t)}),this)}),this.on=(e,t,...n)=>{for(let r of[t].flat()){this.#e=r;for(let t of[e].flat())n.map(e=>{this.#r(t.toUpperCase(),this.#e,e)})}return this},this.use=(e,...t)=>(typeof e==`string`?this.#e=e:(this.#e=`*`,t.unshift(e)),t.forEach(e=>{this.#r(`ALL`,this.#e,e)}),this);let{strict:t,...n}=e;Object.assign(this,n),this.getPath=t??!0?e.getPath??getPath:getPathNoStrict}#t(){let e=new _Hono({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#n=this.#n,e.routes=this.routes,e}#n=notFoundHandler;errorHandler=errorHandler;route(e,t){let n=this.basePath(e);return t.routes.map(e=>{let handler;t.errorHandler===errorHandler?handler=e.handler:(handler=async(n,r)=>(await compose([],t.errorHandler)(n,()=>e.handler(n,r))).res,handler[l]=e.handler),n.#r(e.method,e.path,handler)}),this}basePath(e){let t=this.#t();return t._basePath=mergePath(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#n=e,this);mount(e,t,n){let r,i;n&&(typeof n==`function`?i=n:(i=n.optionHandler,r=n.replaceRequest===!1?e=>e:n.replaceRequest));let a=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};r||=(()=>{let t=mergePath(this._basePath,e),n=t===`/`?0:t.length;return e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||`/`,new Request(t,e)}})();let handler=async(e,n)=>{let i=await t(r(e.req.raw),...a(e));if(i)return i;await n()};return this.#r(`ALL`,mergePath(e,`*`),handler),this}#r(e,t,n){e=e.toUpperCase(),t=mergePath(this._basePath,t);let r={basePath:this._basePath,path:t,method:e,handler:n};this.router.add(e,t,[n,r]),this.routes.push(r)}#i(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#a(e,t,n,r){if(r===`HEAD`)return(async()=>new Response(null,await this.#a(e,t,n,`GET`)))();let i=this.getPath(e,{env:n}),a=this.router.match(r,i),o=new Context(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:this.#n});if(a[0].length===1){let e;try{e=a[0][0][0][0](o,async()=>{o.res=await this.#n(o)})}catch(e){return this.#i(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#n(o))).catch(e=>this.#i(e,o)):e??this.#n(o)}let s=compose(a[0],this.errorHandler,this.#n);return(async()=>{try{let e=await s(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#i(e,o)}})()}fetch=(e,...t)=>this.#a(e,t[1],t[0],e.method);request=(e,t,n,r)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,r):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${mergePath(`/`,e)}`,t),n,r));fire=()=>{addEventListener(`fetch`,e=>{e.respondWith(this.#a(e.request,e,void 0,e.request.method))})}},d=[];function match(e,t){let n=this.buildAllMatchers(),match2=((e,t)=>{let r=n[e]||n.ALL,i=r[2][t];if(i)return i;let a=t.match(r[0]);if(!a)return[[],d];let o=a.indexOf(``,1);return[r[1][o],a]});return this.match=match2,match2(e,t)}var f=`[^/]+`,p=`.*`,m=`(?:|/.*)`,h=Symbol(),g=new Set(`.\\+*[^]$()`);function compareKey(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===p||e===m?1:t===p||t===m?-1:e===f?1:t===f?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var _=class _Node{#e;#t;#n=Object.create(null);insert(e,t,n,r,i){if(e.length===0){if(this.#e!==void 0)throw h;if(i)return;this.#e=t;return}let[a,...o]=e,s=a===`*`?o.length===0?[``,``,p]:[``,``,f]:a===`/*`?[``,``,m]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),c;if(s){let e=s[1],t=s[2]||f;if(e&&s[2]&&(t===`.*`||(t=t.replace(/^\((?!\?:)(?=[^)]+\)$)/,`(?:`),/\((?!\?:)/.test(t))))throw h;if(c=this.#n[t],!c){if(Object.keys(this.#n).some(e=>e!==p&&e!==m))throw h;if(i)return;c=this.#n[t]=new _Node,e!==``&&(c.#t=r.varIndex++)}!i&&e!==``&&n.push([e,c.#t])}else if(c=this.#n[a],!c){if(Object.keys(this.#n).some(e=>e.length>1&&e!==p&&e!==m))throw h;if(i)return;c=this.#n[a]=new _Node}c.insert(o,t,n,r,i)}buildRegExpStr(){let e=Object.keys(this.#n).sort(compareKey).map(e=>{let t=this.#n[e];return(typeof t.#t==`number`?`(${e})@${t.#t}`:g.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return typeof this.#e==`number`&&e.unshift(`#${this.#e}`),e.length===0?``:e.length===1?e[0]:`(?:`+e.join(`|`)+`)`}},Trie=class{#e={varIndex:0};#t=new _;insert(e,t,n){let r=[],i=[];for(let t=0;;){let n=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let r=`@\\${t}`;return i[t]=[r,e],t++,n=!0,r}),!n)break}let a=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let n=a.length-1;n>=0;n--)if(a[n].indexOf(t)!==-1){a[n]=a[n].replace(t,i[e][1]);break}}return this.#t.insert(a,t,r,this.#e,n),r}buildRegExp(){let e=this.#t.buildRegExpStr();if(e===``)return[/^$/,[],[]];let t=0,n=[],r=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,a)=>i===void 0?(a===void 0||(r[Number(a)]=++t),``):(n[++t]=Number(i),`$()`)),[RegExp(`^${e}`),n,r]}},v=[/^$/,[],Object.create(null)],y=Object.create(null);function buildWildcardRegExp(e){return y[e]??=RegExp(e===`*`?``:`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:`(?:|/.*)`)}$`)}function clearWildcardRegExpCache(){y=Object.create(null)}function buildMatcherFromPreprocessedRoutes(e){let t=new Trie,n=[];if(e.length===0)return v;let r=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[n,r])=>e?1:n?-1:t.length-r.length),i=Object.create(null);for(let e=0,a=-1,o=r.length;e<o;e++){let[o,s,c]=r[e];o?i[s]=[c.map(([e])=>[e,Object.create(null)]),d]:a++;let l;try{l=t.insert(s,a,o)}catch(e){throw e===h?new UnsupportedPathError(s):e}o||(n[a]=c.map(([e,t])=>{let n=Object.create(null);for(--t;t>=0;t--){let[e,r]=l[t];n[e]=r}return[e,n]}))}let[a,o,s]=t.buildRegExp();for(let e=0,t=n.length;e<t;e++)for(let t=0,r=n[e].length;t<r;t++){let r=n[e][t]?.[1];if(!r)continue;let i=Object.keys(r);for(let e=0,t=i.length;e<t;e++)r[i[e]]=s[r[i[e]]]}let c=[];for(let e in o)c[e]=n[o[e]];return[a,c,i]}function findMiddleware(e,t){if(e){for(let n of Object.keys(e).sort((e,t)=>t.length-e.length))if(buildWildcardRegExp(n).test(t))return[...e[n]]}}var RegExpRouter=class{name=`RegExpRouter`;#e;#t;constructor(){this.#e={ALL:Object.create(null)},this.#t={ALL:Object.create(null)}}add(e,t,n){let r=this.#e,i=this.#t;if(!r||!i)throw Error(c);r[e]||[r,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t.ALL).forEach(n=>{t[e][n]=[...t.ALL[n]]})}),t===`/*`&&(t=`*`);let a=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let o=buildWildcardRegExp(t);e===`ALL`?Object.keys(r).forEach(e=>{r[e][t]||=findMiddleware(r[e],t)||findMiddleware(r.ALL,t)||[]}):r[e][t]||=findMiddleware(r[e],t)||findMiddleware(r.ALL,t)||[],Object.keys(r).forEach(t=>{(e===`ALL`||e===t)&&Object.keys(r[t]).forEach(e=>{o.test(e)&&r[t][e].push([n,a])})}),Object.keys(i).forEach(t=>{(e===`ALL`||e===t)&&Object.keys(i[t]).forEach(e=>o.test(e)&&i[t][e].push([n,a]))});return}let o=checkOptionalParameter(t)||[t];for(let t=0,s=o.length;t<s;t++){let c=o[t];Object.keys(i).forEach(o=>{(e===`ALL`||e===o)&&(i[o][c]||=[...findMiddleware(r[o],c)||findMiddleware(r.ALL,c)||[]],i[o][c].push([n,a-s+t+1]))})}}match=match;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#n(t)}),this.#e=this.#t=void 0,clearWildcardRegExpCache(),e}#n(e){let t=[],n=e===`ALL`;return[this.#e,this.#t].forEach(r=>{let i=r[e]?Object.keys(r[e]).map(t=>[t,r[e][t]]):[];i.length===0?e!==`ALL`&&t.push(...Object.keys(r.ALL).map(e=>[e,r.ALL[e]])):(n||=!0,t.push(...i))}),n?buildMatcherFromPreprocessedRoutes(t):null}},SmartRouter=class{name=`SmartRouter`;#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw Error(c);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw Error(`Fatal error`);let n=this.#e,r=this.#t,i=n.length,a=0,o;for(;a<i;a++){let i=n[a];try{for(let e=0,t=r.length;e<t;e++)i.add(...r[e]);o=i.match(e,t)}catch(e){if(e instanceof UnsupportedPathError)continue;throw e}this.match=i.match.bind(i),this.#e=[i],this.#t=void 0;break}if(a===i)throw Error(`Fatal error`);return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#t||this.#e.length!==1)throw Error(`No active router has been determined yet.`);return this.#e[0]}},b=Object.create(null),hasChildren=e=>{for(let t in e)return!0;return!1},x=class _Node{#e;#t;#n;#r=0;#i=b;constructor(e,t,n){if(this.#t=n||Object.create(null),this.#e=[],e&&t){let n=Object.create(null);n[e]={handler:t,possibleKeys:[],score:0},this.#e=[n]}this.#n=[]}insert(e,t,n){this.#r=++this.#r;let r=this,i=splitRoutingPath(t),a=[];for(let e=0,t=i.length;e<t;e++){let t=i[e],n=i[e+1],o=getPattern(t,n),s=Array.isArray(o)?o[0]:t;if(s in r.#t){r=r.#t[s],o&&a.push(o[1]);continue}r.#t[s]=new _Node,o&&(r.#n.push(o),a.push(o[1])),r=r.#t[s]}return r.#e.push({[e]:{handler:n,possibleKeys:a.filter((e,t,n)=>n.indexOf(e)===t),score:this.#r}}),r}#a(e,t,n,r,i){for(let a=0,o=t.#e.length;a<o;a++){let o=t.#e[a],s=o[n]||o.ALL,c={};if(s!==void 0&&(s.params=Object.create(null),e.push(s),r!==b||i&&i!==b))for(let e=0,t=s.possibleKeys.length;e<t;e++){let t=s.possibleKeys[e],n=c[s.score];s.params[t]=i?.[t]&&!n?i[t]:r[t]??i?.[t],c[s.score]=!0}}}search(e,t){let n=[];this.#i=b;let r=[this],i=splitPath(t),a=[],o=i.length,s=null;for(let c=0;c<o;c++){let l=i[c],u=c===o-1,d=[];for(let f=0,p=r.length;f<p;f++){let p=r[f],m=p.#t[l];m&&(m.#i=p.#i,u?(m.#t[`*`]&&this.#a(n,m.#t[`*`],e,p.#i),this.#a(n,m,e,p.#i)):d.push(m));for(let r=0,f=p.#n.length;r<f;r++){let f=p.#n[r],m=p.#i===b?{}:{...p.#i};if(f===`*`){let t=p.#t[`*`];t&&(this.#a(n,t,e,p.#i),t.#i=m,d.push(t));continue}let[h,g,_]=f;if(!l&&!(_ instanceof RegExp))continue;let v=p.#t[h];if(_ instanceof RegExp){if(s===null){s=Array(o);let e=+(t[0]===`/`);for(let t=0;t<o;t++)s[t]=e,e+=i[t].length+1}let r=t.substring(s[c]),l=_.exec(r);if(l){if(m[g]=l[0],this.#a(n,v,e,p.#i,m),hasChildren(v.#t)){v.#i=m;let e=l[0].match(/\//)?.length??0;(a[e]||=[]).push(v)}continue}}(_===!0||_.test(l))&&(m[g]=l,u?(this.#a(n,v,e,m,p.#i),v.#t[`*`]&&this.#a(n,v.#t[`*`],e,m,p.#i)):(v.#i=m,d.push(v)))}}let f=a.shift();r=f?d.concat(f):d}return n.length>1&&n.sort((e,t)=>e.score-t.score),[n.map(({handler:e,params:t})=>[e,t])]}},TrieRouter=class{name=`TrieRouter`;#e;constructor(){this.#e=new x}add(e,t,n){let r=checkOptionalParameter(t);if(r){for(let t=0,i=r.length;t<i;t++)this.#e.insert(e,r[t],n);return}this.#e.insert(e,t,n)}match(e,t){return this.#e.search(e,t)}},Hono=class extends u{constructor(e={}){super(e),this.router=e.router??new SmartRouter({routers:[new RegExpRouter,new TrieRouter]})}};export{Hono as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import e from"node:fs";let t;function hasDockerEnv(){try{return e.statSync(`/.dockerenv`),!0}catch{return!1}}function hasDockerCGroup(){try{return e.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function isDocker(){return t===void 0&&(t=hasDockerEnv()||hasDockerCGroup()),t}export{isDocker as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";const isErrorInstance=e=>isInstanceOfError(e)||hasErrorTag(e),isInstanceOfError=e=>{try{return e instanceof Error}catch{return!1}},hasErrorTag=t=>{try{return e.has(Object.prototype.toString.call(t))}catch{return!1}},e=new Set([`[object Error]`,`[object DOMException]`,`[object DOMError]`,`[object Exception]`]);export{isErrorInstance as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";import{t as e}from"./is-docker.mjs";import t from"node:fs";let n;const hasContainerEnv=()=>{try{return t.statSync(`/run/.containerenv`),!0}catch{return!1}};function isInsideContainer(){return n===void 0&&(n=hasContainerEnv()||e()),n}export{isInsideContainer as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../rolldown-runtime.mjs";function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}export{isPlainObject as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t,r as n}from"../rolldown-runtime.mjs";import{statSync as r}from"node:fs";import{stat as i}from"node:fs/promises";var a=n({isexe:()=>o,sync:()=>s}),o,s,c,checkMode,l=t((()=>{o=e(async(e,t={})=>{let{ignoreErrors:n=!1}=t;try{return c(await i(e),t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},`isexe`),s=e((e,t={})=>{let{ignoreErrors:n=!1}=t;try{return c(r(e),t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},`sync`),c=e((e,t)=>e.isFile()&&checkMode(e,t),`checkStat`),checkMode=(e,t)=>{let n=t.uid??process.getuid?.(),r=t.groups??process.getgroups?.()??[],i=t.gid??process.getgid?.()??r[0];if(n===void 0||i===void 0)throw Error(`cannot get uid or gid`);let a=new Set([i,...r]),o=e.mode,s=e.uid,c=e.gid;return!!(o&1||o&8&&a.has(c)||o&64&&s===n||o&72&&n===0)}})),u=n({isexe:()=>d,sync:()=>f}),d,f,checkPathExt,checkStat,p=t((()=>{d=e(async(e,t={})=>{let{ignoreErrors:n=!1}=t;try{return checkStat(await i(e),e,t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},`isexe`),f=e((e,t={})=>{let{ignoreErrors:n=!1}=t;try{return checkStat(r(e),e,t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},`sync`),checkPathExt=(e,t)=>{let{pathExt:n=process.env.PATHEXT||``}=t,r=n.split(`;`);if(r.indexOf(``)!==-1)return!0;for(let t=0;t<r.length;t++){let n=r[t].toLowerCase(),i=e.substring(e.length-n.length).toLowerCase();if(n&&i===n)return!0}return!1},checkStat=(e,t,n)=>e.isFile()&&checkPathExt(t,n)})),m=t((()=>{})),h=n({isexe:()=>_,posix:()=>a,sync:()=>v,win32:()=>u}),g,_,v,y=t((()=>{l(),p(),m(),g=(process.env._ISEXE_TEST_PLATFORM_||process.platform)===`win32`?u:a,_=g.isexe,v=g.sync}));export{h as n,y as t};
|