@pagesmith/docs 0.1.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/README.md +374 -0
- package/dist/abap-DriO5VG6.mjs +5 -0
- package/dist/abap-DriO5VG6.mjs.map +1 -0
- package/dist/actionscript-3-G6toewHp.mjs +5 -0
- package/dist/actionscript-3-G6toewHp.mjs.map +1 -0
- package/dist/ada-C_QiJ0Pq.mjs +5 -0
- package/dist/ada-C_QiJ0Pq.mjs.map +1 -0
- package/dist/andromeeda-CoIEPgYR.mjs +6 -0
- package/dist/andromeeda-CoIEPgYR.mjs.map +1 -0
- package/dist/angular-html-D9wIlok7.mjs +35 -0
- package/dist/angular-html-D9wIlok7.mjs.map +1 -0
- package/dist/angular-ts-Dxk7hl9Z.mjs +29 -0
- package/dist/angular-ts-Dxk7hl9Z.mjs.map +1 -0
- package/dist/apache-B1aRGcgY.mjs +5 -0
- package/dist/apache-B1aRGcgY.mjs.map +1 -0
- package/dist/apex-FoK4UgwA.mjs +5 -0
- package/dist/apex-FoK4UgwA.mjs.map +1 -0
- package/dist/apl-DwmTqCJs.mjs +19 -0
- package/dist/apl-DwmTqCJs.mjs.map +1 -0
- package/dist/applescript-eBeY0Hp4.mjs +5 -0
- package/dist/applescript-eBeY0Hp4.mjs.map +1 -0
- package/dist/ara-CkIucGv1.mjs +5 -0
- package/dist/ara-CkIucGv1.mjs.map +1 -0
- package/dist/asciidoc-AIdrECCR.mjs +5 -0
- package/dist/asciidoc-AIdrECCR.mjs.map +1 -0
- package/dist/asm-CflFLM6a.mjs +5 -0
- package/dist/asm-CflFLM6a.mjs.map +1 -0
- package/dist/astro-DLt5gl0n.mjs +21 -0
- package/dist/astro-DLt5gl0n.mjs.map +1 -0
- package/dist/aurora-x-DbqEqkUT.mjs +6 -0
- package/dist/aurora-x-DbqEqkUT.mjs.map +1 -0
- package/dist/awk-Br_61sCS.mjs +5 -0
- package/dist/awk-Br_61sCS.mjs.map +1 -0
- package/dist/ayu-dark-DdJXJf7U.mjs +6 -0
- package/dist/ayu-dark-DdJXJf7U.mjs.map +1 -0
- package/dist/ayu-light-Bg-9Hujp.mjs +6 -0
- package/dist/ayu-light-Bg-9Hujp.mjs.map +1 -0
- package/dist/ayu-mirage-7v6-qMvl.mjs +6 -0
- package/dist/ayu-mirage-7v6-qMvl.mjs.map +1 -0
- package/dist/ballerina-D-8GYl8R.mjs +5 -0
- package/dist/ballerina-D-8GYl8R.mjs.map +1 -0
- package/dist/bat-CJ4nIaxw.mjs +5 -0
- package/dist/bat-CJ4nIaxw.mjs.map +1 -0
- package/dist/beancount-DFPOglwN.mjs +5 -0
- package/dist/beancount-DFPOglwN.mjs.map +1 -0
- package/dist/berry-DiM_rwEt.mjs +5 -0
- package/dist/berry-DiM_rwEt.mjs.map +1 -0
- package/dist/bibtex-ryU9pJLB.mjs +5 -0
- package/dist/bibtex-ryU9pJLB.mjs.map +1 -0
- package/dist/bicep-DFoNCrG3.mjs +5 -0
- package/dist/bicep-DFoNCrG3.mjs.map +1 -0
- package/dist/bird2-C3EaFiUY.mjs +5 -0
- package/dist/bird2-C3EaFiUY.mjs.map +1 -0
- package/dist/blade-Cwq7FVfH.mjs +23 -0
- package/dist/blade-Cwq7FVfH.mjs.map +1 -0
- package/dist/bsl-Ci4vkNj8.mjs +8 -0
- package/dist/bsl-Ci4vkNj8.mjs.map +1 -0
- package/dist/c-D7oHDxxD.mjs +8 -0
- package/dist/c-D7oHDxxD.mjs.map +1 -0
- package/dist/c3-D5hU-x2t.mjs +5 -0
- package/dist/c3-D5hU-x2t.mjs.map +1 -0
- package/dist/cadence-B-Z42oTz.mjs +5 -0
- package/dist/cadence-B-Z42oTz.mjs.map +1 -0
- package/dist/cairo-BpET0YK1.mjs +8 -0
- package/dist/cairo-BpET0YK1.mjs.map +1 -0
- package/dist/catppuccin-frappe-0BRWFMtJ.mjs +6 -0
- package/dist/catppuccin-frappe-0BRWFMtJ.mjs.map +1 -0
- package/dist/catppuccin-latte-VaqpfzxV.mjs +6 -0
- package/dist/catppuccin-latte-VaqpfzxV.mjs.map +1 -0
- package/dist/catppuccin-macchiato-qrypRbXk.mjs +6 -0
- package/dist/catppuccin-macchiato-qrypRbXk.mjs.map +1 -0
- package/dist/catppuccin-mocha-Dvb6gv4O.mjs +6 -0
- package/dist/catppuccin-mocha-Dvb6gv4O.mjs.map +1 -0
- package/dist/clarity-egx-5RLz.mjs +5 -0
- package/dist/clarity-egx-5RLz.mjs.map +1 -0
- package/dist/cli/bin.d.mts +1 -0
- package/dist/cli/bin.mjs +115 -0
- package/dist/cli/bin.mjs.map +1 -0
- package/dist/clojure-N5xIuTbG.mjs +5 -0
- package/dist/clojure-N5xIuTbG.mjs.map +1 -0
- package/dist/cmake-CYzXNVI_.mjs +5 -0
- package/dist/cmake-CYzXNVI_.mjs.map +1 -0
- package/dist/cobol-DuznKErk.mjs +13 -0
- package/dist/cobol-DuznKErk.mjs.map +1 -0
- package/dist/codeowners-BaallJaj.mjs +5 -0
- package/dist/codeowners-BaallJaj.mjs.map +1 -0
- package/dist/codeql-BIahF8Ga.mjs +5 -0
- package/dist/codeql-BIahF8Ga.mjs.map +1 -0
- package/dist/coffee-t6lXzaXy.mjs +8 -0
- package/dist/coffee-t6lXzaXy.mjs.map +1 -0
- package/dist/common-lisp-bLMBDFt9.mjs +5 -0
- package/dist/common-lisp-bLMBDFt9.mjs.map +1 -0
- package/dist/coq-h9z5p2Ui.mjs +5 -0
- package/dist/coq-h9z5p2Ui.mjs.map +1 -0
- package/dist/cpp-D6_V2gI1.mjs +27 -0
- package/dist/cpp-D6_V2gI1.mjs.map +1 -0
- package/dist/crystal-BH-Qv6Rl.mjs +21 -0
- package/dist/crystal-BH-Qv6Rl.mjs.map +1 -0
- package/dist/csharp-BbHR3YVQ.mjs +5 -0
- package/dist/csharp-BbHR3YVQ.mjs.map +1 -0
- package/dist/css-Wu--EEs5.mjs +8 -0
- package/dist/css-Wu--EEs5.mjs.map +1 -0
- package/dist/csv-CRvIpAc5.mjs +5 -0
- package/dist/csv-CRvIpAc5.mjs.map +1 -0
- package/dist/cue-B8A_h-kS.mjs +5 -0
- package/dist/cue-B8A_h-kS.mjs.map +1 -0
- package/dist/cypher-B8mmimml.mjs +5 -0
- package/dist/cypher-B8mmimml.mjs.map +1 -0
- package/dist/d-Ddz3GmKc.mjs +5 -0
- package/dist/d-Ddz3GmKc.mjs.map +1 -0
- package/dist/dark-plus-BjClkp3W.mjs +6 -0
- package/dist/dark-plus-BjClkp3W.mjs.map +1 -0
- package/dist/dart-BOQAkR91.mjs +5 -0
- package/dist/dart-BOQAkR91.mjs.map +1 -0
- package/dist/dax-D3YKmfop.mjs +5 -0
- package/dist/dax-D3YKmfop.mjs.map +1 -0
- package/dist/desktop-wo52vLHj.mjs +5 -0
- package/dist/desktop-wo52vLHj.mjs.map +1 -0
- package/dist/diff-nA9OrLiI.mjs +5 -0
- package/dist/diff-nA9OrLiI.mjs.map +1 -0
- package/dist/docker-BgWkJ5L9.mjs +5 -0
- package/dist/docker-BgWkJ5L9.mjs.map +1 -0
- package/dist/dotenv-90bAk1yC.mjs +5 -0
- package/dist/dotenv-90bAk1yC.mjs.map +1 -0
- package/dist/dracula-EYPvHKFq.mjs +6 -0
- package/dist/dracula-EYPvHKFq.mjs.map +1 -0
- package/dist/dracula-soft-Bb4JppaT.mjs +6 -0
- package/dist/dracula-soft-Bb4JppaT.mjs.map +1 -0
- package/dist/dream-maker-DbEH6ABX.mjs +5 -0
- package/dist/dream-maker-DbEH6ABX.mjs.map +1 -0
- package/dist/edge-CiNxTnJq.mjs +15 -0
- package/dist/edge-CiNxTnJq.mjs.map +1 -0
- package/dist/elixir-M-tyUuPQ.mjs +8 -0
- package/dist/elixir-M-tyUuPQ.mjs.map +1 -0
- package/dist/elm-CPy7ntV_.mjs +8 -0
- package/dist/elm-CPy7ntV_.mjs.map +1 -0
- package/dist/emacs-lisp-Brxx0Sbt.mjs +5 -0
- package/dist/emacs-lisp-Brxx0Sbt.mjs.map +1 -0
- package/dist/engine-javascript-CjxD84Z_.mjs +3058 -0
- package/dist/engine-javascript-CjxD84Z_.mjs.map +1 -0
- package/dist/engine-oniguruma-B2buYh9y.mjs +389 -0
- package/dist/engine-oniguruma-B2buYh9y.mjs.map +1 -0
- package/dist/erb-CP0kP8S1.mjs +13 -0
- package/dist/erb-CP0kP8S1.mjs.map +1 -0
- package/dist/erlang-Ji96SB8L.mjs +8 -0
- package/dist/erlang-Ji96SB8L.mjs.map +1 -0
- package/dist/everforest-dark-mXu75VmU.mjs +6 -0
- package/dist/everforest-dark-mXu75VmU.mjs.map +1 -0
- package/dist/everforest-light-B0xAPlUp.mjs +6 -0
- package/dist/everforest-light-B0xAPlUp.mjs.map +1 -0
- package/dist/fennel-DZeZiT-Z.mjs +5 -0
- package/dist/fennel-DZeZiT-Z.mjs.map +1 -0
- package/dist/fish-BW_XyVWl.mjs +5 -0
- package/dist/fish-BW_XyVWl.mjs.map +1 -0
- package/dist/fluent-D5wjIx4S.mjs +5 -0
- package/dist/fluent-D5wjIx4S.mjs.map +1 -0
- package/dist/fortran-fixed-form-pFDq8aul.mjs +8 -0
- package/dist/fortran-fixed-form-pFDq8aul.mjs.map +1 -0
- package/dist/fortran-free-form-B6T0euh-.mjs +5 -0
- package/dist/fortran-free-form-B6T0euh-.mjs.map +1 -0
- package/dist/fsharp-DFzfL_uZ.mjs +8 -0
- package/dist/fsharp-DFzfL_uZ.mjs.map +1 -0
- package/dist/gdresource-DZkMKM9Q.mjs +13 -0
- package/dist/gdresource-DZkMKM9Q.mjs.map +1 -0
- package/dist/gdscript-DwtQqEcX.mjs +5 -0
- package/dist/gdscript-DwtQqEcX.mjs.map +1 -0
- package/dist/gdshader-rDwkUCaa.mjs +5 -0
- package/dist/gdshader-rDwkUCaa.mjs.map +1 -0
- package/dist/genie-BfhM6kGv.mjs +5 -0
- package/dist/genie-BfhM6kGv.mjs.map +1 -0
- package/dist/gherkin-G-JA03FJ.mjs +5 -0
- package/dist/gherkin-G-JA03FJ.mjs.map +1 -0
- package/dist/git-commit-drj2jjWh.mjs +8 -0
- package/dist/git-commit-drj2jjWh.mjs.map +1 -0
- package/dist/git-rebase-CaohyQnS.mjs +8 -0
- package/dist/git-rebase-CaohyQnS.mjs.map +1 -0
- package/dist/github-dark-CTenoRQ8.mjs +6 -0
- package/dist/github-dark-CTenoRQ8.mjs.map +1 -0
- package/dist/github-dark-default-Con6b1h-.mjs +6 -0
- package/dist/github-dark-default-Con6b1h-.mjs.map +1 -0
- package/dist/github-dark-dimmed-CaAnvWw3.mjs +6 -0
- package/dist/github-dark-dimmed-CaAnvWw3.mjs.map +1 -0
- package/dist/github-dark-high-contrast-COm7y1Rv.mjs +6 -0
- package/dist/github-dark-high-contrast-COm7y1Rv.mjs.map +1 -0
- package/dist/github-light-D74aa4dO.mjs +6 -0
- package/dist/github-light-D74aa4dO.mjs.map +1 -0
- package/dist/github-light-default-BBVzuVUz.mjs +6 -0
- package/dist/github-light-default-BBVzuVUz.mjs.map +1 -0
- package/dist/github-light-high-contrast-CqxSzsLD.mjs +6 -0
- package/dist/github-light-high-contrast-CqxSzsLD.mjs.map +1 -0
- package/dist/gleam-DzWkrReo.mjs +5 -0
- package/dist/gleam-DzWkrReo.mjs.map +1 -0
- package/dist/glimmer-js-BNQY0kPX.mjs +17 -0
- package/dist/glimmer-js-BNQY0kPX.mjs.map +1 -0
- package/dist/glimmer-ts-DO-qafJY.mjs +17 -0
- package/dist/glimmer-ts-DO-qafJY.mjs.map +1 -0
- package/dist/glsl-wU4MxvvQ.mjs +10 -0
- package/dist/glsl-wU4MxvvQ.mjs.map +1 -0
- package/dist/gn-DVz3m6tN.mjs +5 -0
- package/dist/gn-DVz3m6tN.mjs.map +1 -0
- package/dist/gnuplot-D4teOAbn.mjs +5 -0
- package/dist/gnuplot-D4teOAbn.mjs.map +1 -0
- package/dist/go-DcqYXZDE.mjs +5 -0
- package/dist/go-DcqYXZDE.mjs.map +1 -0
- package/dist/graphql-CAmmtGyG.mjs +19 -0
- package/dist/graphql-CAmmtGyG.mjs.map +1 -0
- package/dist/groovy-BdsJaZey.mjs +5 -0
- package/dist/groovy-BdsJaZey.mjs.map +1 -0
- package/dist/gruvbox-dark-hard-CGsJkBU-.mjs +6 -0
- package/dist/gruvbox-dark-hard-CGsJkBU-.mjs.map +1 -0
- package/dist/gruvbox-dark-medium-uVadnpDA.mjs +6 -0
- package/dist/gruvbox-dark-medium-uVadnpDA.mjs.map +1 -0
- package/dist/gruvbox-dark-soft-CGpZgcKq.mjs +6 -0
- package/dist/gruvbox-dark-soft-CGpZgcKq.mjs.map +1 -0
- package/dist/gruvbox-light-hard-BXZeSfoD.mjs +6 -0
- package/dist/gruvbox-light-hard-BXZeSfoD.mjs.map +1 -0
- package/dist/gruvbox-light-medium-D7mAxe90.mjs +6 -0
- package/dist/gruvbox-light-medium-D7mAxe90.mjs.map +1 -0
- package/dist/gruvbox-light-soft-enFNSJ1V.mjs +6 -0
- package/dist/gruvbox-light-soft-enFNSJ1V.mjs.map +1 -0
- package/dist/hack-DgaC5QUw.mjs +13 -0
- package/dist/hack-DgaC5QUw.mjs.map +1 -0
- package/dist/haml-1vrxYPQe.mjs +15 -0
- package/dist/haml-1vrxYPQe.mjs.map +1 -0
- package/dist/handlebars-BOf036w9.mjs +17 -0
- package/dist/handlebars-BOf036w9.mjs.map +1 -0
- package/dist/haskell-BgXObw3Z.mjs +5 -0
- package/dist/haskell-BgXObw3Z.mjs.map +1 -0
- package/dist/haxe-SN6gQnv7.mjs +5 -0
- package/dist/haxe-SN6gQnv7.mjs.map +1 -0
- package/dist/hcl-DfQ78ybU.mjs +5 -0
- package/dist/hcl-DfQ78ybU.mjs.map +1 -0
- package/dist/hjson-DsbHj1Vu.mjs +5 -0
- package/dist/hjson-DsbHj1Vu.mjs.map +1 -0
- package/dist/hlsl-DErhWTj4.mjs +5 -0
- package/dist/hlsl-DErhWTj4.mjs.map +1 -0
- package/dist/horizon-bright-BLpSmqnO.mjs +6 -0
- package/dist/horizon-bright-BLpSmqnO.mjs.map +1 -0
- package/dist/horizon-mHk0xSKw.mjs +6 -0
- package/dist/horizon-mHk0xSKw.mjs.map +1 -0
- package/dist/houston-CJWIjsF-.mjs +6 -0
- package/dist/houston-CJWIjsF-.mjs.map +1 -0
- package/dist/html-derivative-CoKpUZPA.mjs +8 -0
- package/dist/html-derivative-CoKpUZPA.mjs.map +1 -0
- package/dist/html-hLCdjm8s.mjs +15 -0
- package/dist/html-hLCdjm8s.mjs.map +1 -0
- package/dist/http-Cu2vb2m1.mjs +17 -0
- package/dist/http-Cu2vb2m1.mjs.map +1 -0
- package/dist/hurl-DXLUiPe9.mjs +15 -0
- package/dist/hurl-DXLUiPe9.mjs.map +1 -0
- package/dist/hxml-D53ff3CT.mjs +8 -0
- package/dist/hxml-D53ff3CT.mjs.map +1 -0
- package/dist/hy-V5YDnsp0.mjs +5 -0
- package/dist/hy-V5YDnsp0.mjs.map +1 -0
- package/dist/imba-Dj8CXVx-.mjs +5 -0
- package/dist/imba-Dj8CXVx-.mjs.map +1 -0
- package/dist/index.d.mts +102 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/ini-BBJUwrOG.mjs +5 -0
- package/dist/ini-BBJUwrOG.mjs.map +1 -0
- package/dist/java-YvKbK6tX.mjs +8 -0
- package/dist/java-YvKbK6tX.mjs.map +1 -0
- package/dist/javascript-YIAaXWRu.mjs +8 -0
- package/dist/javascript-YIAaXWRu.mjs.map +1 -0
- package/dist/jinja-ENyZ39OR.mjs +12 -0
- package/dist/jinja-ENyZ39OR.mjs.map +1 -0
- package/dist/jison-a-QW5GR4.mjs +8 -0
- package/dist/jison-a-QW5GR4.mjs.map +1 -0
- package/dist/json-D_p_sVuw.mjs +8 -0
- package/dist/json-D_p_sVuw.mjs.map +1 -0
- package/dist/json5-DC6Kkd4p.mjs +5 -0
- package/dist/json5-DC6Kkd4p.mjs.map +1 -0
- package/dist/jsonc-CXqrxP7Z.mjs +5 -0
- package/dist/jsonc-CXqrxP7Z.mjs.map +1 -0
- package/dist/jsonl-CzqgMhZd.mjs +5 -0
- package/dist/jsonl-CzqgMhZd.mjs.map +1 -0
- package/dist/jsonnet-Hvy31yDW.mjs +5 -0
- package/dist/jsonnet-Hvy31yDW.mjs.map +1 -0
- package/dist/jssm-CKXXM0Nd.mjs +5 -0
- package/dist/jssm-CKXXM0Nd.mjs.map +1 -0
- package/dist/jsx-Cmr67-nO.mjs +8 -0
- package/dist/jsx-Cmr67-nO.mjs.map +1 -0
- package/dist/julia-apY6-EoT.mjs +19 -0
- package/dist/julia-apY6-EoT.mjs.map +1 -0
- package/dist/just-DPxowZX-.mjs +21 -0
- package/dist/just-DPxowZX-.mjs.map +1 -0
- package/dist/kanagawa-dragon-bgbtpXkX.mjs +6 -0
- package/dist/kanagawa-dragon-bgbtpXkX.mjs.map +1 -0
- package/dist/kanagawa-lotus-CAjM2aBD.mjs +6 -0
- package/dist/kanagawa-lotus-CAjM2aBD.mjs.map +1 -0
- package/dist/kanagawa-wave-gUF-XydY.mjs +6 -0
- package/dist/kanagawa-wave-gUF-XydY.mjs.map +1 -0
- package/dist/kdl-DakeRkny.mjs +5 -0
- package/dist/kdl-DakeRkny.mjs.map +1 -0
- package/dist/kotlin-Cy2z7uIJ.mjs +5 -0
- package/dist/kotlin-Cy2z7uIJ.mjs.map +1 -0
- package/dist/kusto-8vFexomq.mjs +5 -0
- package/dist/kusto-8vFexomq.mjs.map +1 -0
- package/dist/laserwave-afq0Xxwk.mjs +6 -0
- package/dist/laserwave-afq0Xxwk.mjs.map +1 -0
- package/dist/latex-D_F2h8-H.mjs +8 -0
- package/dist/latex-D_F2h8-H.mjs.map +1 -0
- package/dist/lean-IHm98qhW.mjs +5 -0
- package/dist/lean-IHm98qhW.mjs.map +1 -0
- package/dist/less-D6RfQ6-S.mjs +5 -0
- package/dist/less-D6RfQ6-S.mjs.map +1 -0
- package/dist/light-plus-Dwa6Dmsm.mjs +6 -0
- package/dist/light-plus-Dwa6Dmsm.mjs.map +1 -0
- package/dist/liquid-DK7BdQ-d.mjs +17 -0
- package/dist/liquid-DK7BdQ-d.mjs.map +1 -0
- package/dist/llvm-CbsqsAF1.mjs +5 -0
- package/dist/llvm-CbsqsAF1.mjs.map +1 -0
- package/dist/log-CutLVNLV.mjs +5 -0
- package/dist/log-CutLVNLV.mjs.map +1 -0
- package/dist/logo-DNTC5lxi.mjs +5 -0
- package/dist/logo-DNTC5lxi.mjs.map +1 -0
- package/dist/lua-NCVDi2Y_.mjs +10 -0
- package/dist/lua-NCVDi2Y_.mjs.map +1 -0
- package/dist/luau-Z-b9t2YR.mjs +5 -0
- package/dist/luau-Z-b9t2YR.mjs.map +1 -0
- package/dist/make-D7o-TjTO.mjs +5 -0
- package/dist/make-D7o-TjTO.mjs.map +1 -0
- package/dist/markdown-CEvLuIE_.mjs +5 -0
- package/dist/markdown-CEvLuIE_.mjs.map +1 -0
- package/dist/markdown-config-BGDiDMhB.d.mts +2094 -0
- package/dist/markdown-config-BGDiDMhB.d.mts.map +1 -0
- package/dist/marko-DyPWMVoi.mjs +17 -0
- package/dist/marko-DyPWMVoi.mjs.map +1 -0
- package/dist/material-theme-BMSwLkhz.mjs +6 -0
- package/dist/material-theme-BMSwLkhz.mjs.map +1 -0
- package/dist/material-theme-darker-DREhSOvw.mjs +6 -0
- package/dist/material-theme-darker-DREhSOvw.mjs.map +1 -0
- package/dist/material-theme-lighter-egkNOF68.mjs +6 -0
- package/dist/material-theme-lighter-egkNOF68.mjs.map +1 -0
- package/dist/material-theme-ocean-CNqBAXQm.mjs +6 -0
- package/dist/material-theme-ocean-CNqBAXQm.mjs.map +1 -0
- package/dist/material-theme-palenight-DtcONgpr.mjs +6 -0
- package/dist/material-theme-palenight-DtcONgpr.mjs.map +1 -0
- package/dist/matlab-DHZHeFXY.mjs +5 -0
- package/dist/matlab-DHZHeFXY.mjs.map +1 -0
- package/dist/mdc-MKPEEsGA.mjs +15 -0
- package/dist/mdc-MKPEEsGA.mjs.map +1 -0
- package/dist/mdx-ClLOyMcG.mjs +5 -0
- package/dist/mdx-ClLOyMcG.mjs.map +1 -0
- package/dist/mermaid-CfX58h2h.mjs +5 -0
- package/dist/mermaid-CfX58h2h.mjs.map +1 -0
- package/dist/min-dark-CvIB8xOx.mjs +6 -0
- package/dist/min-dark-CvIB8xOx.mjs.map +1 -0
- package/dist/min-light-DnoFQoeu.mjs +6 -0
- package/dist/min-light-DnoFQoeu.mjs.map +1 -0
- package/dist/mipsasm-BPlrYcYb.mjs +5 -0
- package/dist/mipsasm-BPlrYcYb.mjs.map +1 -0
- package/dist/mojo-C5Qzk_lA.mjs +5 -0
- package/dist/mojo-C5Qzk_lA.mjs.map +1 -0
- package/dist/monokai-CmoRmG4x.mjs +6 -0
- package/dist/monokai-CmoRmG4x.mjs.map +1 -0
- package/dist/moonbit-BzaO7bLo.mjs +5 -0
- package/dist/moonbit-BzaO7bLo.mjs.map +1 -0
- package/dist/move-CAZmkwHx.mjs +5 -0
- package/dist/move-CAZmkwHx.mjs.map +1 -0
- package/dist/narrat-DN2gLj7A.mjs +5 -0
- package/dist/narrat-DN2gLj7A.mjs.map +1 -0
- package/dist/nextflow-DhVPPjdW.mjs +8 -0
- package/dist/nextflow-DhVPPjdW.mjs.map +1 -0
- package/dist/nextflow-groovy-DJq82mRo.mjs +5 -0
- package/dist/nextflow-groovy-DJq82mRo.mjs.map +1 -0
- package/dist/nginx-CU-DGOv1.mjs +8 -0
- package/dist/nginx-CU-DGOv1.mjs.map +1 -0
- package/dist/night-owl-Cs13ScSs.mjs +6 -0
- package/dist/night-owl-Cs13ScSs.mjs.map +1 -0
- package/dist/night-owl-light--HbEFF7Y.mjs +6 -0
- package/dist/night-owl-light--HbEFF7Y.mjs.map +1 -0
- package/dist/nim-3UbGj8cc.mjs +23 -0
- package/dist/nim-3UbGj8cc.mjs.map +1 -0
- package/dist/nix-CjXcUl9k.mjs +9 -0
- package/dist/nix-CjXcUl9k.mjs.map +1 -0
- package/dist/nord-C9GqXk2p.mjs +6 -0
- package/dist/nord-C9GqXk2p.mjs.map +1 -0
- package/dist/nushell-C4iFdrTc.mjs +5 -0
- package/dist/nushell-C4iFdrTc.mjs.map +1 -0
- package/dist/objective-c-CXuDGuMm.mjs +5 -0
- package/dist/objective-c-CXuDGuMm.mjs.map +1 -0
- package/dist/objective-cpp-V9yvCIRm.mjs +5 -0
- package/dist/objective-cpp-V9yvCIRm.mjs.map +1 -0
- package/dist/ocaml-D9fCj6sT.mjs +5 -0
- package/dist/ocaml-D9fCj6sT.mjs.map +1 -0
- package/dist/odin-CAKGLqrj.mjs +5 -0
- package/dist/odin-CAKGLqrj.mjs.map +1 -0
- package/dist/one-dark-pro-DW7BmY6Q.mjs +6 -0
- package/dist/one-dark-pro-DW7BmY6Q.mjs.map +1 -0
- package/dist/one-light-DCu0Wv9N.mjs +6 -0
- package/dist/one-light-DCu0Wv9N.mjs.map +1 -0
- package/dist/openscad-BdLZBBab.mjs +5 -0
- package/dist/openscad-BdLZBBab.mjs.map +1 -0
- package/dist/pascal-nsk9MKFb.mjs +5 -0
- package/dist/pascal-nsk9MKFb.mjs.map +1 -0
- package/dist/perl-DI9oLKmv.mjs +19 -0
- package/dist/perl-DI9oLKmv.mjs.map +1 -0
- package/dist/php-DJjzFdsM.mjs +21 -0
- package/dist/php-DJjzFdsM.mjs.map +1 -0
- package/dist/pkl-BVtC2QFe.mjs +5 -0
- package/dist/pkl-BVtC2QFe.mjs.map +1 -0
- package/dist/plastic-qUgYNoeW.mjs +6 -0
- package/dist/plastic-qUgYNoeW.mjs.map +1 -0
- package/dist/plsql-BwM0DOLE.mjs +5 -0
- package/dist/plsql-BwM0DOLE.mjs.map +1 -0
- package/dist/po-D39EqRsl.mjs +5 -0
- package/dist/po-D39EqRsl.mjs.map +1 -0
- package/dist/poimandres-DPRzGPvx.mjs +6 -0
- package/dist/poimandres-DPRzGPvx.mjs.map +1 -0
- package/dist/polar-DCBzWT3J.mjs +5 -0
- package/dist/polar-DCBzWT3J.mjs.map +1 -0
- package/dist/postcss-L6y-bzEw.mjs +5 -0
- package/dist/postcss-L6y-bzEw.mjs.map +1 -0
- package/dist/powerquery-BHkUTyux.mjs +5 -0
- package/dist/powerquery-BHkUTyux.mjs.map +1 -0
- package/dist/powershell-C80dlfD8.mjs +5 -0
- package/dist/powershell-C80dlfD8.mjs.map +1 -0
- package/dist/preset.d.mts +15 -0
- package/dist/preset.d.mts.map +1 -0
- package/dist/preset.mjs +19 -0
- package/dist/preset.mjs.map +1 -0
- package/dist/prisma-D407qtUw.mjs +5 -0
- package/dist/prisma-D407qtUw.mjs.map +1 -0
- package/dist/prolog-CSrn8-6K.mjs +5 -0
- package/dist/prolog-CSrn8-6K.mjs.map +1 -0
- package/dist/proto-ClvDy0H0.mjs +5 -0
- package/dist/proto-ClvDy0H0.mjs.map +1 -0
- package/dist/pug-Cyyu0V2y.mjs +15 -0
- package/dist/pug-Cyyu0V2y.mjs.map +1 -0
- package/dist/puppet-D5ZQtSNi.mjs +5 -0
- package/dist/puppet-D5ZQtSNi.mjs.map +1 -0
- package/dist/purescript-30PxZSjT.mjs +5 -0
- package/dist/purescript-30PxZSjT.mjs.map +1 -0
- package/dist/python-CpiNX4Ip.mjs +5 -0
- package/dist/python-CpiNX4Ip.mjs.map +1 -0
- package/dist/qml-PuKhTmY-.mjs +8 -0
- package/dist/qml-PuKhTmY-.mjs.map +1 -0
- package/dist/qmldir-BTwcIF6g.mjs +5 -0
- package/dist/qmldir-BTwcIF6g.mjs.map +1 -0
- package/dist/qss-DcpQyHuk.mjs +5 -0
- package/dist/qss-DcpQyHuk.mjs.map +1 -0
- package/dist/r-DcW8EcF5.mjs +8 -0
- package/dist/r-DcW8EcF5.mjs.map +1 -0
- package/dist/racket-D-BwrG5z.mjs +5 -0
- package/dist/racket-D-BwrG5z.mjs.map +1 -0
- package/dist/raku-CM1N1WTp.mjs +5 -0
- package/dist/raku-CM1N1WTp.mjs.map +1 -0
- package/dist/razor-C912Hs6M.mjs +13 -0
- package/dist/razor-C912Hs6M.mjs.map +1 -0
- package/dist/red-DhGHw_i_.mjs +6 -0
- package/dist/red-DhGHw_i_.mjs.map +1 -0
- package/dist/reg-MlBfIgTN.mjs +5 -0
- package/dist/reg-MlBfIgTN.mjs.map +1 -0
- package/dist/regexp-CEVpExph.mjs +8 -0
- package/dist/regexp-CEVpExph.mjs.map +1 -0
- package/dist/rel-Dg_W2E_N.mjs +5 -0
- package/dist/rel-Dg_W2E_N.mjs.map +1 -0
- package/dist/riscv-BoH7mqNI.mjs +5 -0
- package/dist/riscv-BoH7mqNI.mjs.map +1 -0
- package/dist/ron-DbOWX1T7.mjs +5 -0
- package/dist/ron-DbOWX1T7.mjs.map +1 -0
- package/dist/rose-pine-78rugKGO.mjs +6 -0
- package/dist/rose-pine-78rugKGO.mjs.map +1 -0
- package/dist/rose-pine-dawn-C_mYSEtu.mjs +6 -0
- package/dist/rose-pine-dawn-C_mYSEtu.mjs.map +1 -0
- package/dist/rose-pine-moon-Cz7-JQvG.mjs +6 -0
- package/dist/rose-pine-moon-Cz7-JQvG.mjs.map +1 -0
- package/dist/rosmsg-Ca1BpyBh.mjs +5 -0
- package/dist/rosmsg-Ca1BpyBh.mjs.map +1 -0
- package/dist/rst-DbIJV67W.mjs +25 -0
- package/dist/rst-DbIJV67W.mjs.map +1 -0
- package/dist/ruby-D-Lps7Dp.mjs +33 -0
- package/dist/ruby-D-Lps7Dp.mjs.map +1 -0
- package/dist/rust-Dk6HN1uF.mjs +5 -0
- package/dist/rust-Dk6HN1uF.mjs.map +1 -0
- package/dist/sas-QckC_qvJ.mjs +8 -0
- package/dist/sas-QckC_qvJ.mjs.map +1 -0
- package/dist/sass-BWOQVuIy.mjs +5 -0
- package/dist/sass-BWOQVuIy.mjs.map +1 -0
- package/dist/scala-BoffQEnY.mjs +5 -0
- package/dist/scala-BoffQEnY.mjs.map +1 -0
- package/dist/schemas/index.d.mts +1615 -0
- package/dist/schemas/index.d.mts.map +1 -0
- package/dist/schemas/index.mjs +263 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas-By1qE0sQ.mjs +3881 -0
- package/dist/schemas-By1qE0sQ.mjs.map +1 -0
- package/dist/scheme-C2D8wvUe.mjs +5 -0
- package/dist/scheme-C2D8wvUe.mjs.map +1 -0
- package/dist/scss-D1vWunvk.mjs +10 -0
- package/dist/scss-D1vWunvk.mjs.map +1 -0
- package/dist/sdbl-DkThjfrg.mjs +5 -0
- package/dist/sdbl-DkThjfrg.mjs.map +1 -0
- package/dist/shaderlab-D0NLokaw.mjs +8 -0
- package/dist/shaderlab-D0NLokaw.mjs.map +1 -0
- package/dist/shellscript-BHpEag8P.mjs +8 -0
- package/dist/shellscript-BHpEag8P.mjs.map +1 -0
- package/dist/shellsession-CSdmCfg4.mjs +8 -0
- package/dist/shellsession-CSdmCfg4.mjs.map +1 -0
- package/dist/site-D8l4ghX0.mjs +71441 -0
- package/dist/site-D8l4ghX0.mjs.map +1 -0
- package/dist/slack-dark-Cj8kL6BM.mjs +6 -0
- package/dist/slack-dark-Cj8kL6BM.mjs.map +1 -0
- package/dist/slack-ochin-B4Rna-gD.mjs +6 -0
- package/dist/slack-ochin-B4Rna-gD.mjs.map +1 -0
- package/dist/smalltalk-ZNQAnLNC.mjs +5 -0
- package/dist/smalltalk-ZNQAnLNC.mjs.map +1 -0
- package/dist/snazzy-light-CF7MTUt6.mjs +6 -0
- package/dist/snazzy-light-CF7MTUt6.mjs.map +1 -0
- package/dist/solarized-dark-DBFHIE1d.mjs +6 -0
- package/dist/solarized-dark-DBFHIE1d.mjs.map +1 -0
- package/dist/solarized-light-Del516-O.mjs +6 -0
- package/dist/solarized-light-Del516-O.mjs.map +1 -0
- package/dist/solidity-Ddf3MOD2.mjs +5 -0
- package/dist/solidity-Ddf3MOD2.mjs.map +1 -0
- package/dist/soy-PW0jpJKW.mjs +8 -0
- package/dist/soy-PW0jpJKW.mjs.map +1 -0
- package/dist/sparql-rX-q1CB9.mjs +8 -0
- package/dist/sparql-rX-q1CB9.mjs.map +1 -0
- package/dist/splunk-DcREbx5k.mjs +5 -0
- package/dist/splunk-DcREbx5k.mjs.map +1 -0
- package/dist/sql-Cq_hpY16.mjs +8 -0
- package/dist/sql-Cq_hpY16.mjs.map +1 -0
- package/dist/ssh-config-DIv0Kb8E.mjs +5 -0
- package/dist/ssh-config-DIv0Kb8E.mjs.map +1 -0
- package/dist/stata-rEmfzZT7.mjs +8 -0
- package/dist/stata-rEmfzZT7.mjs.map +1 -0
- package/dist/stylus-DHanz1Kd.mjs +5 -0
- package/dist/stylus-DHanz1Kd.mjs.map +1 -0
- package/dist/surrealql-BdfgI90j.mjs +8 -0
- package/dist/surrealql-BdfgI90j.mjs.map +1 -0
- package/dist/svelte-DFFWgqCr.mjs +17 -0
- package/dist/svelte-DFFWgqCr.mjs.map +1 -0
- package/dist/swift-Ci7klDIa.mjs +5 -0
- package/dist/swift-Ci7klDIa.mjs.map +1 -0
- package/dist/synthwave-84-T5fF9-Op.mjs +6 -0
- package/dist/synthwave-84-T5fF9-Op.mjs.map +1 -0
- package/dist/system-verilog-tLSd9PYh.mjs +5 -0
- package/dist/system-verilog-tLSd9PYh.mjs.map +1 -0
- package/dist/systemd-C_LIvN4y.mjs +5 -0
- package/dist/systemd-C_LIvN4y.mjs.map +1 -0
- package/dist/talonscript-2cIfb9F4.mjs +5 -0
- package/dist/talonscript-2cIfb9F4.mjs.map +1 -0
- package/dist/tasl-iwLzpKVu.mjs +5 -0
- package/dist/tasl-iwLzpKVu.mjs.map +1 -0
- package/dist/tcl-DR2zhegR.mjs +5 -0
- package/dist/tcl-DR2zhegR.mjs.map +1 -0
- package/dist/templ-BDCp727o.mjs +15 -0
- package/dist/templ-BDCp727o.mjs.map +1 -0
- package/dist/terraform-BH4YC6Zk.mjs +5 -0
- package/dist/terraform-BH4YC6Zk.mjs.map +1 -0
- package/dist/tex-DGRDr7pd.mjs +8 -0
- package/dist/tex-DGRDr7pd.mjs.map +1 -0
- package/dist/tokyo-night-YpyXNs_N.mjs +6 -0
- package/dist/tokyo-night-YpyXNs_N.mjs.map +1 -0
- package/dist/toml-CECsyL8x.mjs +5 -0
- package/dist/toml-CECsyL8x.mjs.map +1 -0
- package/dist/ts-tags-BsG9I5cd.mjs +61 -0
- package/dist/ts-tags-BsG9I5cd.mjs.map +1 -0
- package/dist/tsv-BwwAUdIn.mjs +5 -0
- package/dist/tsv-BwwAUdIn.mjs.map +1 -0
- package/dist/tsx-qx39NaGS.mjs +8 -0
- package/dist/tsx-qx39NaGS.mjs.map +1 -0
- package/dist/turtle-D8n7HFvE.mjs +5 -0
- package/dist/turtle-D8n7HFvE.mjs.map +1 -0
- package/dist/twig-DsMUiWk8.mjs +21 -0
- package/dist/twig-DsMUiWk8.mjs.map +1 -0
- package/dist/typescript-BZXFn-rd.mjs +8 -0
- package/dist/typescript-BZXFn-rd.mjs.map +1 -0
- package/dist/typespec-ClgDzShT.mjs +5 -0
- package/dist/typespec-ClgDzShT.mjs.map +1 -0
- package/dist/typst-CMN2lhh3.mjs +5 -0
- package/dist/typst-CMN2lhh3.mjs.map +1 -0
- package/dist/v-CA1cYsER.mjs +5 -0
- package/dist/v-CA1cYsER.mjs.map +1 -0
- package/dist/vala-DuBY1WKl.mjs +5 -0
- package/dist/vala-DuBY1WKl.mjs.map +1 -0
- package/dist/vb-XQBHWfW8.mjs +5 -0
- package/dist/vb-XQBHWfW8.mjs.map +1 -0
- package/dist/verilog-CWqhvrSz.mjs +5 -0
- package/dist/verilog-CWqhvrSz.mjs.map +1 -0
- package/dist/vesper-CigfTEKg.mjs +6 -0
- package/dist/vesper-CigfTEKg.mjs.map +1 -0
- package/dist/vhdl-C67Bhzjr.mjs +5 -0
- package/dist/vhdl-C67Bhzjr.mjs.map +1 -0
- package/dist/viml-C26cD_wa.mjs +5 -0
- package/dist/viml-C26cD_wa.mjs.map +1 -0
- package/dist/vitesse-black-DYCj3nJd.mjs +6 -0
- package/dist/vitesse-black-DYCj3nJd.mjs.map +1 -0
- package/dist/vitesse-dark-BMGIMsRz.mjs +6 -0
- package/dist/vitesse-dark-BMGIMsRz.mjs.map +1 -0
- package/dist/vitesse-light-SKJOp9ZR.mjs +6 -0
- package/dist/vitesse-light-SKJOp9ZR.mjs.map +1 -0
- package/dist/vue-bb5YUHg6.mjs +33 -0
- package/dist/vue-bb5YUHg6.mjs.map +1 -0
- package/dist/vue-html-ypB-H6rb.mjs +8 -0
- package/dist/vue-html-ypB-H6rb.mjs.map +1 -0
- package/dist/vue-vine-Cl_j-Bb5.mjs +21 -0
- package/dist/vue-vine-Cl_j-Bb5.mjs.map +1 -0
- package/dist/vyper-gBkdcGC5.mjs +5 -0
- package/dist/vyper-gBkdcGC5.mjs.map +1 -0
- package/dist/wasm-B1KmdQo5.mjs +9 -0
- package/dist/wasm-B1KmdQo5.mjs.map +1 -0
- package/dist/wasm-D4mFcPzE.mjs +5 -0
- package/dist/wasm-D4mFcPzE.mjs.map +1 -0
- package/dist/wenyan-D1TI9OZw.mjs +5 -0
- package/dist/wenyan-D1TI9OZw.mjs.map +1 -0
- package/dist/wgsl-DzVADIua.mjs +5 -0
- package/dist/wgsl-DzVADIua.mjs.map +1 -0
- package/dist/wikitext-DPnM1XoL.mjs +5 -0
- package/dist/wikitext-DPnM1XoL.mjs.map +1 -0
- package/dist/wit-Bewokpy8.mjs +5 -0
- package/dist/wit-Bewokpy8.mjs.map +1 -0
- package/dist/wolfram-DVQXO29Z.mjs +5 -0
- package/dist/wolfram-DVQXO29Z.mjs.map +1 -0
- package/dist/xml-TYYGqgP3.mjs +10 -0
- package/dist/xml-TYYGqgP3.mjs.map +1 -0
- package/dist/xsl-BOev1i40.mjs +8 -0
- package/dist/xsl-BOev1i40.mjs.map +1 -0
- package/dist/yaml-Xue9e-YO.mjs +8 -0
- package/dist/yaml-Xue9e-YO.mjs.map +1 -0
- package/dist/zenscript-CwrU69w6.mjs +5 -0
- package/dist/zenscript-CwrU69w6.mjs.map +1 -0
- package/dist/zig-NT9tMYQ2.mjs +5 -0
- package/dist/zig-NT9tMYQ2.mjs.map +1 -0
- package/package.json +78 -0
- package/theme/components/DocFooter.tsx +59 -0
- package/theme/components/DocHeader.tsx +72 -0
- package/theme/components/DocSidebar.tsx +90 -0
- package/theme/components/DocTOC.tsx +25 -0
- package/theme/components/Html.tsx +107 -0
- package/theme/layouts/DocHome.tsx +212 -0
- package/theme/layouts/DocNotFound.tsx +55 -0
- package/theme/layouts/DocPage.tsx +74 -0
- package/theme/runtime/main.ts +16 -0
- package/theme/runtime/search.ts +65 -0
- package/theme/runtime/sidebar.ts +135 -0
- package/theme/runtime/toc-highlight.ts +73 -0
- package/theme/styles/code/inline.css +26 -0
- package/theme/styles/components/not-found.css +85 -0
- package/theme/styles/components/search.css +300 -0
- package/theme/styles/content/alerts.css +87 -0
- package/theme/styles/content/prose.css +225 -0
- package/theme/styles/content/toc.css +90 -0
- package/theme/styles/foundations/fonts.css +37 -0
- package/theme/styles/foundations/reset.css +49 -0
- package/theme/styles/foundations/tokens.css +66 -0
- package/theme/styles/layout/footer.css +119 -0
- package/theme/styles/layout/grid.css +98 -0
- package/theme/styles/layout/header.css +153 -0
- package/theme/styles/layout/home.css +449 -0
- package/theme/styles/layout/sidebar.css +239 -0
- package/theme/styles/main.css +19 -0
|
@@ -0,0 +1,3058 @@
|
|
|
1
|
+
//#region ../../node_modules/oniguruma-parser/dist/utils.js
|
|
2
|
+
function r$2(e) {
|
|
3
|
+
if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
|
|
4
|
+
return e.codePointAt(0);
|
|
5
|
+
}
|
|
6
|
+
function l$1(e, t, n) {
|
|
7
|
+
return e.has(t) || e.set(t, n), e.get(t);
|
|
8
|
+
}
|
|
9
|
+
const i = new Set([
|
|
10
|
+
"alnum",
|
|
11
|
+
"alpha",
|
|
12
|
+
"ascii",
|
|
13
|
+
"blank",
|
|
14
|
+
"cntrl",
|
|
15
|
+
"digit",
|
|
16
|
+
"graph",
|
|
17
|
+
"lower",
|
|
18
|
+
"print",
|
|
19
|
+
"punct",
|
|
20
|
+
"space",
|
|
21
|
+
"upper",
|
|
22
|
+
"word",
|
|
23
|
+
"xdigit"
|
|
24
|
+
]), o$1 = String.raw;
|
|
25
|
+
function u(e, t) {
|
|
26
|
+
if (e == null) throw new Error(t ?? "Value expected");
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ../../node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
|
|
31
|
+
const m$1 = o$1`\[\^?`, b$1 = `c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${o$1`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${o$1`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${o$1`o\{[^\}]*\}?`}|${o$1`\d{1,3}`}`, y$1 = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, C$1 = new RegExp(o$1`
|
|
32
|
+
\\ (?:
|
|
33
|
+
${b$1}
|
|
34
|
+
| [gk]<[^>]*>?
|
|
35
|
+
| [gk]'[^']*'?
|
|
36
|
+
| .
|
|
37
|
+
)
|
|
38
|
+
| \( (?:
|
|
39
|
+
\? (?:
|
|
40
|
+
[:=!>({]
|
|
41
|
+
| <[=!]
|
|
42
|
+
| <[^>]*>
|
|
43
|
+
| '[^']*'
|
|
44
|
+
| ~\|?
|
|
45
|
+
| #(?:[^)\\]|\\.?)*
|
|
46
|
+
| [^:)]*[:)]
|
|
47
|
+
)?
|
|
48
|
+
| \*[^\)]*\)?
|
|
49
|
+
)?
|
|
50
|
+
| (?:${y$1.source})+
|
|
51
|
+
| ${m$1}
|
|
52
|
+
| .
|
|
53
|
+
`.replace(/\s+/g, ""), "gsu"), T$1 = new RegExp(o$1`
|
|
54
|
+
\\ (?:
|
|
55
|
+
${b$1}
|
|
56
|
+
| .
|
|
57
|
+
)
|
|
58
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
59
|
+
| ${m$1}
|
|
60
|
+
| &&
|
|
61
|
+
| .
|
|
62
|
+
`.replace(/\s+/g, ""), "gsu");
|
|
63
|
+
function M$1(e, n = {}) {
|
|
64
|
+
const t = {
|
|
65
|
+
flags: "",
|
|
66
|
+
...n,
|
|
67
|
+
rules: {
|
|
68
|
+
captureGroup: !1,
|
|
69
|
+
singleline: !1,
|
|
70
|
+
...n.rules
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (typeof e != "string") throw new Error("String expected as pattern");
|
|
74
|
+
const o = Y(t.flags), s = [o.extended], a = {
|
|
75
|
+
captureGroup: t.rules.captureGroup,
|
|
76
|
+
getCurrentModX() {
|
|
77
|
+
return s.at(-1);
|
|
78
|
+
},
|
|
79
|
+
numOpenGroups: 0,
|
|
80
|
+
popModX() {
|
|
81
|
+
s.pop();
|
|
82
|
+
},
|
|
83
|
+
pushModX(u) {
|
|
84
|
+
s.push(u);
|
|
85
|
+
},
|
|
86
|
+
replaceCurrentModX(u) {
|
|
87
|
+
s[s.length - 1] = u;
|
|
88
|
+
},
|
|
89
|
+
singleline: t.rules.singleline
|
|
90
|
+
};
|
|
91
|
+
let r = [], i;
|
|
92
|
+
for (C$1.lastIndex = 0; i = C$1.exec(e);) {
|
|
93
|
+
const u = F$1(a, e, i[0], C$1.lastIndex);
|
|
94
|
+
u.tokens ? r.push(...u.tokens) : u.token && r.push(u.token), u.lastIndex !== void 0 && (C$1.lastIndex = u.lastIndex);
|
|
95
|
+
}
|
|
96
|
+
const l = [];
|
|
97
|
+
let c = 0;
|
|
98
|
+
r.filter((u) => u.type === "GroupOpen").forEach((u) => {
|
|
99
|
+
u.kind === "capturing" ? u.number = ++c : u.raw === "(" && l.push(u);
|
|
100
|
+
}), c || l.forEach((u, S) => {
|
|
101
|
+
u.kind = "capturing", u.number = S + 1;
|
|
102
|
+
});
|
|
103
|
+
const g = c || l.length;
|
|
104
|
+
return {
|
|
105
|
+
tokens: r.map((u) => u.type === "EscapedNumber" ? ee$1(u, g) : u).flat(),
|
|
106
|
+
flags: o
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function F$1(e, n, t, o) {
|
|
110
|
+
const [s, a] = t;
|
|
111
|
+
if (t === "[" || t === "[^") {
|
|
112
|
+
const r = K$1(n, t, o);
|
|
113
|
+
return {
|
|
114
|
+
tokens: r.tokens,
|
|
115
|
+
lastIndex: r.lastIndex
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (s === "\\") {
|
|
119
|
+
if ("AbBGyYzZ".includes(a)) return { token: w$1(t, t) };
|
|
120
|
+
if (/^\\g[<']/.test(t)) {
|
|
121
|
+
if (!/^\\g(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
|
|
122
|
+
return { token: R$1(t) };
|
|
123
|
+
}
|
|
124
|
+
if (/^\\k[<']/.test(t)) {
|
|
125
|
+
if (!/^\\k(?:<[^>]+>|'[^']+')$/.test(t)) throw new Error(`Invalid group name "${t}"`);
|
|
126
|
+
return { token: A$1(t) };
|
|
127
|
+
}
|
|
128
|
+
if (a === "K") return { token: I$1("keep", t) };
|
|
129
|
+
if (a === "N" || a === "R") return { token: k$1("newline", t, { negate: a === "N" }) };
|
|
130
|
+
if (a === "O") return { token: k$1("any", t) };
|
|
131
|
+
if (a === "X") return { token: k$1("text_segment", t) };
|
|
132
|
+
const r = x(t, { inCharClass: !1 });
|
|
133
|
+
return Array.isArray(r) ? { tokens: r } : { token: r };
|
|
134
|
+
}
|
|
135
|
+
if (s === "(") {
|
|
136
|
+
if (a === "*") return { token: j(t) };
|
|
137
|
+
if (t === "(?{") throw new Error(`Unsupported callout "${t}"`);
|
|
138
|
+
if (t.startsWith("(?#")) {
|
|
139
|
+
if (n[o] !== ")") throw new Error("Unclosed comment group \"(?#\"");
|
|
140
|
+
return { lastIndex: o + 1 };
|
|
141
|
+
}
|
|
142
|
+
if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: L$1(t, e) };
|
|
143
|
+
if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f$1("group", t) };
|
|
144
|
+
if (t === "(?>") return { token: f$1("atomic", t) };
|
|
145
|
+
if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f$1(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
|
|
146
|
+
if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f$1("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
|
|
147
|
+
if (t.startsWith("(?~")) {
|
|
148
|
+
if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
|
|
149
|
+
return { token: f$1("absence_repeater", t) };
|
|
150
|
+
}
|
|
151
|
+
throw t === "(?(" ? /* @__PURE__ */ new Error(`Unsupported conditional "${t}"`) : /* @__PURE__ */ new Error(`Invalid or unsupported group option "${t}"`);
|
|
152
|
+
}
|
|
153
|
+
if (t === ")") {
|
|
154
|
+
if (e.popModX(), e.numOpenGroups--, e.numOpenGroups < 0) throw new Error("Unmatched \")\"");
|
|
155
|
+
return { token: Q$1(t) };
|
|
156
|
+
}
|
|
157
|
+
if (e.getCurrentModX()) {
|
|
158
|
+
if (t === "#") {
|
|
159
|
+
const r = n.indexOf(`
|
|
160
|
+
`, o);
|
|
161
|
+
return { lastIndex: r === -1 ? n.length : r };
|
|
162
|
+
}
|
|
163
|
+
if (/^\s$/.test(t)) {
|
|
164
|
+
const r = /\s+/y;
|
|
165
|
+
return r.lastIndex = o, { lastIndex: r.exec(n) ? r.lastIndex : o };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (t === ".") return { token: k$1("dot", t) };
|
|
169
|
+
if (t === "^" || t === "$") return { token: w$1(e.singleline ? {
|
|
170
|
+
"^": o$1`\A`,
|
|
171
|
+
$: o$1`\Z`
|
|
172
|
+
}[t] : t, t) };
|
|
173
|
+
return t === "|" ? { token: P$1(t) } : y$1.test(t) ? { tokens: te$1(t) } : { token: d(r$2(t), t) };
|
|
174
|
+
}
|
|
175
|
+
function K$1(e, n, t) {
|
|
176
|
+
const o = [E$1(n[1] === "^", n)];
|
|
177
|
+
let s = 1, a;
|
|
178
|
+
for (T$1.lastIndex = t; a = T$1.exec(e);) {
|
|
179
|
+
const r = a[0];
|
|
180
|
+
if (r[0] === "[" && r[1] !== ":") s++, o.push(E$1(r[1] === "^", r));
|
|
181
|
+
else if (r === "]") {
|
|
182
|
+
if (o.at(-1).type === "CharacterClassOpen") o.push(d(93, r));
|
|
183
|
+
else if (s--, o.push(z$1(r)), !s) break;
|
|
184
|
+
} else {
|
|
185
|
+
const i = X$1(r);
|
|
186
|
+
Array.isArray(i) ? o.push(...i) : o.push(i);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
tokens: o,
|
|
191
|
+
lastIndex: T$1.lastIndex || e.length
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function X$1(e) {
|
|
195
|
+
if (e[0] === "\\") return x(e, { inCharClass: !0 });
|
|
196
|
+
if (e[0] === "[") {
|
|
197
|
+
const n = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
|
|
198
|
+
if (!n || !i.has(n.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
|
|
199
|
+
return k$1("posix", e, {
|
|
200
|
+
value: n.groups.name,
|
|
201
|
+
negate: !!n.groups.negate
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return e === "-" ? U$1(e) : e === "&&" ? H(e) : d(r$2(e), e);
|
|
205
|
+
}
|
|
206
|
+
function x(e, { inCharClass: n }) {
|
|
207
|
+
const t = e[1];
|
|
208
|
+
if (t === "c" || t === "C") return Z(e);
|
|
209
|
+
if ("dDhHsSwW".includes(t)) return q(e);
|
|
210
|
+
if (e.startsWith(o$1`\o{`)) throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);
|
|
211
|
+
if (/^\\[pP]\{/.test(e)) {
|
|
212
|
+
if (e.length === 3) throw new Error(`Incomplete or invalid Unicode property "${e}"`);
|
|
213
|
+
return V$1(e);
|
|
214
|
+
}
|
|
215
|
+
if (/^\\x[89A-Fa-f]\p{AHex}/u.test(e)) try {
|
|
216
|
+
const o = e.split(/\\x/).slice(1).map((i) => parseInt(i, 16)), s = new TextDecoder("utf-8", {
|
|
217
|
+
ignoreBOM: !0,
|
|
218
|
+
fatal: !0
|
|
219
|
+
}).decode(new Uint8Array(o)), a = new TextEncoder();
|
|
220
|
+
return [...s].map((i) => {
|
|
221
|
+
const l = [...a.encode(i)].map((c) => `\\x${c.toString(16)}`).join("");
|
|
222
|
+
return d(r$2(i), l);
|
|
223
|
+
});
|
|
224
|
+
} catch {
|
|
225
|
+
throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`);
|
|
226
|
+
}
|
|
227
|
+
if (t === "u" || t === "x") return d(J$1(e), e);
|
|
228
|
+
if ($$1.has(t)) return d($$1.get(t), e);
|
|
229
|
+
if (/\d/.test(t)) return W$1(n, e);
|
|
230
|
+
if (e === "\\") throw new Error(o$1`Incomplete escape "\"`);
|
|
231
|
+
if (t === "M") throw new Error(`Unsupported meta "${e}"`);
|
|
232
|
+
if ([...e].length === 2) return d(e.codePointAt(1), e);
|
|
233
|
+
throw new Error(`Unexpected escape "${e}"`);
|
|
234
|
+
}
|
|
235
|
+
function P$1(e) {
|
|
236
|
+
return {
|
|
237
|
+
type: "Alternator",
|
|
238
|
+
raw: e
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function w$1(e, n) {
|
|
242
|
+
return {
|
|
243
|
+
type: "Assertion",
|
|
244
|
+
kind: e,
|
|
245
|
+
raw: n
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function A$1(e) {
|
|
249
|
+
return {
|
|
250
|
+
type: "Backreference",
|
|
251
|
+
raw: e
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function d(e, n) {
|
|
255
|
+
return {
|
|
256
|
+
type: "Character",
|
|
257
|
+
value: e,
|
|
258
|
+
raw: n
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function z$1(e) {
|
|
262
|
+
return {
|
|
263
|
+
type: "CharacterClassClose",
|
|
264
|
+
raw: e
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function U$1(e) {
|
|
268
|
+
return {
|
|
269
|
+
type: "CharacterClassHyphen",
|
|
270
|
+
raw: e
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function H(e) {
|
|
274
|
+
return {
|
|
275
|
+
type: "CharacterClassIntersector",
|
|
276
|
+
raw: e
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function E$1(e, n) {
|
|
280
|
+
return {
|
|
281
|
+
type: "CharacterClassOpen",
|
|
282
|
+
negate: e,
|
|
283
|
+
raw: n
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function k$1(e, n, t = {}) {
|
|
287
|
+
return {
|
|
288
|
+
type: "CharacterSet",
|
|
289
|
+
kind: e,
|
|
290
|
+
...t,
|
|
291
|
+
raw: n
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function I$1(e, n, t = {}) {
|
|
295
|
+
return e === "keep" ? {
|
|
296
|
+
type: "Directive",
|
|
297
|
+
kind: e,
|
|
298
|
+
raw: n
|
|
299
|
+
} : {
|
|
300
|
+
type: "Directive",
|
|
301
|
+
kind: e,
|
|
302
|
+
flags: u(t.flags),
|
|
303
|
+
raw: n
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function W$1(e, n) {
|
|
307
|
+
return {
|
|
308
|
+
type: "EscapedNumber",
|
|
309
|
+
inCharClass: e,
|
|
310
|
+
raw: n
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function Q$1(e) {
|
|
314
|
+
return {
|
|
315
|
+
type: "GroupClose",
|
|
316
|
+
raw: e
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function f$1(e, n, t = {}) {
|
|
320
|
+
return {
|
|
321
|
+
type: "GroupOpen",
|
|
322
|
+
kind: e,
|
|
323
|
+
...t,
|
|
324
|
+
raw: n
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function D$1(e, n, t, o) {
|
|
328
|
+
return {
|
|
329
|
+
type: "NamedCallout",
|
|
330
|
+
kind: e,
|
|
331
|
+
tag: n,
|
|
332
|
+
arguments: t,
|
|
333
|
+
raw: o
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function _$1(e, n, t, o) {
|
|
337
|
+
return {
|
|
338
|
+
type: "Quantifier",
|
|
339
|
+
kind: e,
|
|
340
|
+
min: n,
|
|
341
|
+
max: t,
|
|
342
|
+
raw: o
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function R$1(e) {
|
|
346
|
+
return {
|
|
347
|
+
type: "Subroutine",
|
|
348
|
+
raw: e
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const B$1 = new Set([
|
|
352
|
+
"COUNT",
|
|
353
|
+
"CMP",
|
|
354
|
+
"ERROR",
|
|
355
|
+
"FAIL",
|
|
356
|
+
"MAX",
|
|
357
|
+
"MISMATCH",
|
|
358
|
+
"SKIP",
|
|
359
|
+
"TOTAL_COUNT"
|
|
360
|
+
]), $$1 = new Map([
|
|
361
|
+
["a", 7],
|
|
362
|
+
["b", 8],
|
|
363
|
+
["e", 27],
|
|
364
|
+
["f", 12],
|
|
365
|
+
["n", 10],
|
|
366
|
+
["r", 13],
|
|
367
|
+
["t", 9],
|
|
368
|
+
["v", 11]
|
|
369
|
+
]);
|
|
370
|
+
function Z(e) {
|
|
371
|
+
const n = e[1] === "c" ? e[2] : e[3];
|
|
372
|
+
if (!n || !/[A-Za-z]/.test(n)) throw new Error(`Unsupported control character "${e}"`);
|
|
373
|
+
return d(r$2(n.toUpperCase()) - 64, e);
|
|
374
|
+
}
|
|
375
|
+
function L$1(e, n) {
|
|
376
|
+
let { on: t, off: o } = /^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;
|
|
377
|
+
o ??= "";
|
|
378
|
+
const s = (n.getCurrentModX() || t.includes("x")) && !o.includes("x"), a = v(t), r = v(o), i = {};
|
|
379
|
+
if (a && (i.enable = a), r && (i.disable = r), e.endsWith(")")) return n.replaceCurrentModX(s), I$1("flags", e, { flags: i });
|
|
380
|
+
if (e.endsWith(":")) return n.pushModX(s), n.numOpenGroups++, f$1("group", e, { ...(a || r) && { flags: i } });
|
|
381
|
+
throw new Error(`Unexpected flag modifier "${e}"`);
|
|
382
|
+
}
|
|
383
|
+
function j(e) {
|
|
384
|
+
const n = /\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);
|
|
385
|
+
if (!n) throw new Error(`Incomplete or invalid named callout "${e}"`);
|
|
386
|
+
const { name: t, tag: o, args: s } = n.groups;
|
|
387
|
+
if (!t) throw new Error(`Invalid named callout "${e}"`);
|
|
388
|
+
if (o === "") throw new Error(`Named callout tag with empty value not allowed "${e}"`);
|
|
389
|
+
const a = s ? s.split(",").filter((g) => g !== "").map((g) => /^[+-]?\d+$/.test(g) ? +g : g) : [], [r, i, l] = a, c = B$1.has(t) ? t.toLowerCase() : "custom";
|
|
390
|
+
switch (c) {
|
|
391
|
+
case "fail":
|
|
392
|
+
case "mismatch":
|
|
393
|
+
case "skip":
|
|
394
|
+
if (a.length > 0) throw new Error(`Named callout arguments not allowed "${a}"`);
|
|
395
|
+
break;
|
|
396
|
+
case "error":
|
|
397
|
+
if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
|
|
398
|
+
if (typeof r == "string") throw new Error(`Named callout argument must be a number "${r}"`);
|
|
399
|
+
break;
|
|
400
|
+
case "max":
|
|
401
|
+
if (!a.length || a.length > 2) throw new Error(`Named callout must have one or two arguments "${a}"`);
|
|
402
|
+
if (typeof r == "string" && !/^[A-Za-z_]\w*$/.test(r)) throw new Error(`Named callout argument one must be a tag or number "${r}"`);
|
|
403
|
+
if (a.length === 2 && (typeof i == "number" || !/^[<>X]$/.test(i))) throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);
|
|
404
|
+
break;
|
|
405
|
+
case "count":
|
|
406
|
+
case "total_count":
|
|
407
|
+
if (a.length > 1) throw new Error(`Named callout allows only one argument "${a}"`);
|
|
408
|
+
if (a.length === 1 && (typeof r == "number" || !/^[<>X]$/.test(r))) throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);
|
|
409
|
+
break;
|
|
410
|
+
case "cmp":
|
|
411
|
+
if (a.length !== 3) throw new Error(`Named callout must have three arguments "${a}"`);
|
|
412
|
+
if (typeof r == "string" && !/^[A-Za-z_]\w*$/.test(r)) throw new Error(`Named callout argument one must be a tag or number "${r}"`);
|
|
413
|
+
if (typeof i == "number" || !/^(?:[<>!=]=|[<>])$/.test(i)) throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);
|
|
414
|
+
if (typeof l == "string" && !/^[A-Za-z_]\w*$/.test(l)) throw new Error(`Named callout argument three must be a tag or number "${l}"`);
|
|
415
|
+
break;
|
|
416
|
+
case "custom": throw new Error(`Undefined callout name "${t}"`);
|
|
417
|
+
default: throw new Error(`Unexpected named callout kind "${c}"`);
|
|
418
|
+
}
|
|
419
|
+
return D$1(c, o ?? null, s?.split(",") ?? null, e);
|
|
420
|
+
}
|
|
421
|
+
function O$1(e) {
|
|
422
|
+
let n = null, t, o;
|
|
423
|
+
if (e[0] === "{") {
|
|
424
|
+
const { minStr: s, maxStr: a } = /^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups, r = 1e5;
|
|
425
|
+
if (+s > r || a && +a > r) throw new Error("Quantifier value unsupported in Oniguruma");
|
|
426
|
+
if (t = +s, o = a === void 0 ? +s : a === "" ? Infinity : +a, t > o && (n = "possessive", [t, o] = [o, t]), e.endsWith("?")) {
|
|
427
|
+
if (n === "possessive") throw new Error("Unsupported possessive interval quantifier chain with \"?\"");
|
|
428
|
+
n = "lazy";
|
|
429
|
+
} else n || (n = "greedy");
|
|
430
|
+
} else t = e[0] === "+" ? 1 : 0, o = e[0] === "?" ? 1 : Infinity, n = e[1] === "+" ? "possessive" : e[1] === "?" ? "lazy" : "greedy";
|
|
431
|
+
return _$1(n, t, o, e);
|
|
432
|
+
}
|
|
433
|
+
function q(e) {
|
|
434
|
+
const n = e[1].toLowerCase();
|
|
435
|
+
return k$1({
|
|
436
|
+
d: "digit",
|
|
437
|
+
h: "hex",
|
|
438
|
+
s: "space",
|
|
439
|
+
w: "word"
|
|
440
|
+
}[n], e, { negate: e[1] !== n });
|
|
441
|
+
}
|
|
442
|
+
function V$1(e) {
|
|
443
|
+
const { p: n, neg: t, value: o } = /^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;
|
|
444
|
+
return k$1("property", e, {
|
|
445
|
+
value: o,
|
|
446
|
+
negate: n === "P" && !t || n === "p" && !!t
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function v(e) {
|
|
450
|
+
const n = {};
|
|
451
|
+
return e.includes("i") && (n.ignoreCase = !0), e.includes("m") && (n.dotAll = !0), e.includes("x") && (n.extended = !0), Object.keys(n).length ? n : null;
|
|
452
|
+
}
|
|
453
|
+
function Y(e) {
|
|
454
|
+
const n = {
|
|
455
|
+
ignoreCase: !1,
|
|
456
|
+
dotAll: !1,
|
|
457
|
+
extended: !1,
|
|
458
|
+
digitIsAscii: !1,
|
|
459
|
+
posixIsAscii: !1,
|
|
460
|
+
spaceIsAscii: !1,
|
|
461
|
+
wordIsAscii: !1,
|
|
462
|
+
textSegmentMode: null
|
|
463
|
+
};
|
|
464
|
+
for (let t = 0; t < e.length; t++) {
|
|
465
|
+
const o = e[t];
|
|
466
|
+
if (!"imxDPSWy".includes(o)) throw new Error(`Invalid flag "${o}"`);
|
|
467
|
+
if (o === "y") {
|
|
468
|
+
if (!/^y{[gw]}/.test(e.slice(t))) throw new Error("Invalid or unspecified flag \"y\" mode");
|
|
469
|
+
n.textSegmentMode = e[t + 2] === "g" ? "grapheme" : "word", t += 3;
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
n[{
|
|
473
|
+
i: "ignoreCase",
|
|
474
|
+
m: "dotAll",
|
|
475
|
+
x: "extended",
|
|
476
|
+
D: "digitIsAscii",
|
|
477
|
+
P: "posixIsAscii",
|
|
478
|
+
S: "spaceIsAscii",
|
|
479
|
+
W: "wordIsAscii"
|
|
480
|
+
}[o]] = !0;
|
|
481
|
+
}
|
|
482
|
+
return n;
|
|
483
|
+
}
|
|
484
|
+
function J$1(e) {
|
|
485
|
+
if (/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e)) throw new Error(`Incomplete or invalid escape "${e}"`);
|
|
486
|
+
const n = e[2] === "{" ? /^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex : e.slice(2);
|
|
487
|
+
return parseInt(n, 16);
|
|
488
|
+
}
|
|
489
|
+
function ee$1(e, n) {
|
|
490
|
+
const { raw: t, inCharClass: o } = e, s = t.slice(1);
|
|
491
|
+
if (!o && (s !== "0" && s.length === 1 || s[0] !== "0" && +s <= n)) return [A$1(t)];
|
|
492
|
+
const a = [], r = s.match(/^[0-7]+|\d/g);
|
|
493
|
+
for (let i = 0; i < r.length; i++) {
|
|
494
|
+
const l = r[i];
|
|
495
|
+
let c;
|
|
496
|
+
if (i === 0 && l !== "8" && l !== "9") {
|
|
497
|
+
if (c = parseInt(l, 8), c > 127) throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`);
|
|
498
|
+
} else c = r$2(l);
|
|
499
|
+
a.push(d(c, (i === 0 ? "\\" : "") + l));
|
|
500
|
+
}
|
|
501
|
+
return a;
|
|
502
|
+
}
|
|
503
|
+
function te$1(e) {
|
|
504
|
+
const n = [], t = new RegExp(y$1, "gy");
|
|
505
|
+
let o;
|
|
506
|
+
for (; o = t.exec(e);) {
|
|
507
|
+
const s = o[0];
|
|
508
|
+
if (s[0] === "{") {
|
|
509
|
+
const a = /^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);
|
|
510
|
+
if (a) {
|
|
511
|
+
const { min: r, max: i } = a.groups;
|
|
512
|
+
if (+r > +i && s.endsWith("?")) {
|
|
513
|
+
t.lastIndex--, n.push(O$1(s.slice(0, -1)));
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
n.push(O$1(s));
|
|
519
|
+
}
|
|
520
|
+
return n;
|
|
521
|
+
}
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region ../../node_modules/oniguruma-parser/dist/parser/node-utils.js
|
|
524
|
+
function o(e, t) {
|
|
525
|
+
if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
|
|
526
|
+
if (e.body.length !== 1) return !1;
|
|
527
|
+
const r = e.body[0];
|
|
528
|
+
return !t || Object.keys(t).every((n) => t[n] === r[n]);
|
|
529
|
+
}
|
|
530
|
+
function s(e) {
|
|
531
|
+
return y.has(e.type);
|
|
532
|
+
}
|
|
533
|
+
const y = new Set([
|
|
534
|
+
"AbsenceFunction",
|
|
535
|
+
"Backreference",
|
|
536
|
+
"CapturingGroup",
|
|
537
|
+
"Character",
|
|
538
|
+
"CharacterClass",
|
|
539
|
+
"CharacterSet",
|
|
540
|
+
"Group",
|
|
541
|
+
"Quantifier",
|
|
542
|
+
"Subroutine"
|
|
543
|
+
]);
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region ../../node_modules/oniguruma-parser/dist/parser/parse.js
|
|
546
|
+
function J(e, r = {}) {
|
|
547
|
+
const n = {
|
|
548
|
+
flags: "",
|
|
549
|
+
normalizeUnknownPropertyNames: !1,
|
|
550
|
+
skipBackrefValidation: !1,
|
|
551
|
+
skipLookbehindValidation: !1,
|
|
552
|
+
skipPropertyNameValidation: !1,
|
|
553
|
+
unicodePropertyMap: null,
|
|
554
|
+
...r,
|
|
555
|
+
rules: {
|
|
556
|
+
captureGroup: !1,
|
|
557
|
+
singleline: !1,
|
|
558
|
+
...r.rules
|
|
559
|
+
}
|
|
560
|
+
}, t = M$1(e, {
|
|
561
|
+
flags: n.flags,
|
|
562
|
+
rules: {
|
|
563
|
+
captureGroup: n.rules.captureGroup,
|
|
564
|
+
singleline: n.rules.singleline
|
|
565
|
+
}
|
|
566
|
+
}), s = (p, N) => {
|
|
567
|
+
const u = t.tokens[o.nextIndex];
|
|
568
|
+
switch (o.parent = p, o.nextIndex++, u.type) {
|
|
569
|
+
case "Alternator": return b();
|
|
570
|
+
case "Assertion": return W(u);
|
|
571
|
+
case "Backreference": return X(u, o);
|
|
572
|
+
case "Character": return m(u.value, { useLastValid: !!N.isCheckingRangeEnd });
|
|
573
|
+
case "CharacterClassHyphen": return ee(u, o, N);
|
|
574
|
+
case "CharacterClassOpen": return re(u, o, N);
|
|
575
|
+
case "CharacterSet": return ne(u, o);
|
|
576
|
+
case "Directive": return I(u.kind, { flags: u.flags });
|
|
577
|
+
case "GroupOpen": return te(u, o, N);
|
|
578
|
+
case "NamedCallout": return U(u.kind, u.tag, u.arguments);
|
|
579
|
+
case "Quantifier": return oe(u, o);
|
|
580
|
+
case "Subroutine": return ae(u, o);
|
|
581
|
+
default: throw new Error(`Unexpected token type "${u.type}"`);
|
|
582
|
+
}
|
|
583
|
+
}, o = {
|
|
584
|
+
capturingGroups: [],
|
|
585
|
+
hasNumberedRef: !1,
|
|
586
|
+
namedGroupsByName: /* @__PURE__ */ new Map(),
|
|
587
|
+
nextIndex: 0,
|
|
588
|
+
normalizeUnknownPropertyNames: n.normalizeUnknownPropertyNames,
|
|
589
|
+
parent: null,
|
|
590
|
+
skipBackrefValidation: n.skipBackrefValidation,
|
|
591
|
+
skipLookbehindValidation: n.skipLookbehindValidation,
|
|
592
|
+
skipPropertyNameValidation: n.skipPropertyNameValidation,
|
|
593
|
+
subroutines: [],
|
|
594
|
+
tokens: t.tokens,
|
|
595
|
+
unicodePropertyMap: n.unicodePropertyMap,
|
|
596
|
+
walk: s
|
|
597
|
+
}, i = B(T(t.flags));
|
|
598
|
+
let d = i.body[0];
|
|
599
|
+
for (; o.nextIndex < t.tokens.length;) {
|
|
600
|
+
const p = s(d, {});
|
|
601
|
+
p.type === "Alternative" ? (i.body.push(p), d = p) : d.body.push(p);
|
|
602
|
+
}
|
|
603
|
+
const { capturingGroups: a, hasNumberedRef: l, namedGroupsByName: c, subroutines: f } = o;
|
|
604
|
+
if (l && c.size && !n.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
|
|
605
|
+
for (const { ref: p } of f) if (typeof p == "number") {
|
|
606
|
+
if (p > a.length) throw new Error("Subroutine uses a group number that's not defined");
|
|
607
|
+
p && (a[p - 1].isSubroutined = !0);
|
|
608
|
+
} else if (c.has(p)) {
|
|
609
|
+
if (c.get(p).length > 1) throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);
|
|
610
|
+
c.get(p)[0].isSubroutined = !0;
|
|
611
|
+
} else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);
|
|
612
|
+
return i;
|
|
613
|
+
}
|
|
614
|
+
function W({ kind: e }) {
|
|
615
|
+
return F(u({
|
|
616
|
+
"^": "line_start",
|
|
617
|
+
$: "line_end",
|
|
618
|
+
"\\A": "string_start",
|
|
619
|
+
"\\b": "word_boundary",
|
|
620
|
+
"\\B": "word_boundary",
|
|
621
|
+
"\\G": "search_start",
|
|
622
|
+
"\\y": "text_segment_boundary",
|
|
623
|
+
"\\Y": "text_segment_boundary",
|
|
624
|
+
"\\z": "string_end",
|
|
625
|
+
"\\Z": "string_end_newline"
|
|
626
|
+
}[e], `Unexpected assertion kind "${e}"`), { negate: e === o$1`\B` || e === o$1`\Y` });
|
|
627
|
+
}
|
|
628
|
+
function X({ raw: e }, r) {
|
|
629
|
+
const n = /^\\k[<']/.test(e), t = n ? e.slice(3, -1) : e.slice(1), s = (o, i = !1) => {
|
|
630
|
+
const d = r.capturingGroups.length;
|
|
631
|
+
let a = !1;
|
|
632
|
+
if (o > d) if (r.skipBackrefValidation) a = !0;
|
|
633
|
+
else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
|
|
634
|
+
return r.hasNumberedRef = !0, k(i ? d + 1 - o : o, { orphan: a });
|
|
635
|
+
};
|
|
636
|
+
if (n) {
|
|
637
|
+
const o = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);
|
|
638
|
+
if (o) return s(+o.groups.num, !!o.groups.sign);
|
|
639
|
+
if (/[-+]/.test(t)) throw new Error(`Invalid backref name "${e}"`);
|
|
640
|
+
if (!r.namedGroupsByName.has(t)) throw new Error(`Group name not defined to the left "${e}"`);
|
|
641
|
+
return k(t);
|
|
642
|
+
}
|
|
643
|
+
return s(+t);
|
|
644
|
+
}
|
|
645
|
+
function ee(e, r, n) {
|
|
646
|
+
const { tokens: t, walk: s } = r, o = r.parent, i = o.body.at(-1), d = t[r.nextIndex];
|
|
647
|
+
if (!n.isCheckingRangeEnd && i && i.type !== "CharacterClass" && i.type !== "CharacterClassRange" && d && d.type !== "CharacterClassOpen" && d.type !== "CharacterClassClose" && d.type !== "CharacterClassIntersector") {
|
|
648
|
+
const a = s(o, {
|
|
649
|
+
...n,
|
|
650
|
+
isCheckingRangeEnd: !0
|
|
651
|
+
});
|
|
652
|
+
if (i.type === "Character" && a.type === "Character") return o.body.pop(), L(i, a);
|
|
653
|
+
throw new Error("Invalid character class range");
|
|
654
|
+
}
|
|
655
|
+
return m(r$2("-"));
|
|
656
|
+
}
|
|
657
|
+
function re({ negate: e }, r, n) {
|
|
658
|
+
const { tokens: t, walk: s } = r, o = t[r.nextIndex], i = [C()];
|
|
659
|
+
let d = z(o);
|
|
660
|
+
for (; d.type !== "CharacterClassClose";) {
|
|
661
|
+
if (d.type === "CharacterClassIntersector") i.push(C()), r.nextIndex++;
|
|
662
|
+
else {
|
|
663
|
+
const l = i.at(-1);
|
|
664
|
+
l.body.push(s(l, n));
|
|
665
|
+
}
|
|
666
|
+
d = z(t[r.nextIndex], o);
|
|
667
|
+
}
|
|
668
|
+
const a = C({ negate: e });
|
|
669
|
+
return i.length === 1 ? a.body = i[0].body : (a.kind = "intersection", a.body = i.map((l) => l.body.length === 1 ? l.body[0] : l)), r.nextIndex++, a;
|
|
670
|
+
}
|
|
671
|
+
function ne({ kind: e, negate: r, value: n }, t) {
|
|
672
|
+
const { normalizeUnknownPropertyNames: s, skipPropertyNameValidation: o, unicodePropertyMap: i$1 } = t;
|
|
673
|
+
if (e === "property") {
|
|
674
|
+
const d = w(n);
|
|
675
|
+
if (i.has(d) && !i$1?.has(d)) e = "posix", n = d;
|
|
676
|
+
else return Q(n, {
|
|
677
|
+
negate: r,
|
|
678
|
+
normalizeUnknownPropertyNames: s,
|
|
679
|
+
skipPropertyNameValidation: o,
|
|
680
|
+
unicodePropertyMap: i$1
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
return e === "posix" ? R(n, { negate: r }) : E(e, { negate: r });
|
|
684
|
+
}
|
|
685
|
+
function te(e, r, n) {
|
|
686
|
+
const { tokens: t, capturingGroups: s, namedGroupsByName: o, skipLookbehindValidation: i, walk: d } = r, a = ie(e), l = a.type === "AbsenceFunction", c = $(a), f = c && a.negate;
|
|
687
|
+
if (a.type === "CapturingGroup" && (s.push(a), a.name && l$1(o, a.name, []).push(a)), l && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
|
|
688
|
+
let p = D(t[r.nextIndex]);
|
|
689
|
+
for (; p.type !== "GroupClose";) {
|
|
690
|
+
if (p.type === "Alternator") a.body.push(b()), r.nextIndex++;
|
|
691
|
+
else {
|
|
692
|
+
const N = a.body.at(-1), u = d(N, {
|
|
693
|
+
...n,
|
|
694
|
+
isInAbsenceFunction: n.isInAbsenceFunction || l,
|
|
695
|
+
isInLookbehind: n.isInLookbehind || c,
|
|
696
|
+
isInNegLookbehind: n.isInNegLookbehind || f
|
|
697
|
+
});
|
|
698
|
+
if (N.body.push(u), (c || n.isInLookbehind) && !i) {
|
|
699
|
+
const v = "Lookbehind includes a pattern not allowed by Oniguruma";
|
|
700
|
+
if (f || n.isInNegLookbehind) {
|
|
701
|
+
if (M(u) || u.type === "CapturingGroup") throw new Error(v);
|
|
702
|
+
} else if (M(u) || $(u) && u.negate) throw new Error(v);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
p = D(t[r.nextIndex]);
|
|
706
|
+
}
|
|
707
|
+
return r.nextIndex++, a;
|
|
708
|
+
}
|
|
709
|
+
function oe({ kind: e, min: r, max: n }, t) {
|
|
710
|
+
const s$1 = t.parent, o = s$1.body.at(-1);
|
|
711
|
+
if (!o || !s(o)) throw new Error("Quantifier requires a repeatable token");
|
|
712
|
+
const i = _(e, r, n, o);
|
|
713
|
+
return s$1.body.pop(), i;
|
|
714
|
+
}
|
|
715
|
+
function ae({ raw: e }, r) {
|
|
716
|
+
const { capturingGroups: n, subroutines: t } = r;
|
|
717
|
+
let s = e.slice(3, -1);
|
|
718
|
+
const o = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);
|
|
719
|
+
if (o) {
|
|
720
|
+
const d = +o.groups.num, a = n.length;
|
|
721
|
+
if (r.hasNumberedRef = !0, s = {
|
|
722
|
+
"": d,
|
|
723
|
+
"+": a + d,
|
|
724
|
+
"-": a + 1 - d
|
|
725
|
+
}[o.groups.sign], s < 1) throw new Error("Invalid subroutine number");
|
|
726
|
+
} else s === "0" && (s = 0);
|
|
727
|
+
const i = O(s);
|
|
728
|
+
return t.push(i), i;
|
|
729
|
+
}
|
|
730
|
+
function G(e, r) {
|
|
731
|
+
if (e !== "repeater") throw new Error(`Unexpected absence function kind "${e}"`);
|
|
732
|
+
return {
|
|
733
|
+
type: "AbsenceFunction",
|
|
734
|
+
kind: e,
|
|
735
|
+
body: h(r?.body)
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function b(e) {
|
|
739
|
+
return {
|
|
740
|
+
type: "Alternative",
|
|
741
|
+
body: V(e?.body)
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function F(e, r) {
|
|
745
|
+
const n = {
|
|
746
|
+
type: "Assertion",
|
|
747
|
+
kind: e
|
|
748
|
+
};
|
|
749
|
+
return (e === "word_boundary" || e === "text_segment_boundary") && (n.negate = !!r?.negate), n;
|
|
750
|
+
}
|
|
751
|
+
function k(e, r) {
|
|
752
|
+
const n = !!r?.orphan;
|
|
753
|
+
return {
|
|
754
|
+
type: "Backreference",
|
|
755
|
+
ref: e,
|
|
756
|
+
...n && { orphan: n }
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function P(e, r) {
|
|
760
|
+
const n = {
|
|
761
|
+
name: void 0,
|
|
762
|
+
isSubroutined: !1,
|
|
763
|
+
...r
|
|
764
|
+
};
|
|
765
|
+
if (n.name !== void 0 && !se(n.name)) throw new Error(`Group name "${n.name}" invalid in Oniguruma`);
|
|
766
|
+
return {
|
|
767
|
+
type: "CapturingGroup",
|
|
768
|
+
number: e,
|
|
769
|
+
...n.name && { name: n.name },
|
|
770
|
+
...n.isSubroutined && { isSubroutined: n.isSubroutined },
|
|
771
|
+
body: h(r?.body)
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function m(e, r) {
|
|
775
|
+
const n = {
|
|
776
|
+
useLastValid: !1,
|
|
777
|
+
...r
|
|
778
|
+
};
|
|
779
|
+
if (e > 1114111) {
|
|
780
|
+
const t = e.toString(16);
|
|
781
|
+
if (n.useLastValid) e = 1114111;
|
|
782
|
+
else throw e > 1310719 ? /* @__PURE__ */ new Error(`Invalid code point out of range "\\x{${t}}"`) : /* @__PURE__ */ new Error(`Invalid code point out of range in JS "\\x{${t}}"`);
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
type: "Character",
|
|
786
|
+
value: e
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function C(e) {
|
|
790
|
+
const r = {
|
|
791
|
+
kind: "union",
|
|
792
|
+
negate: !1,
|
|
793
|
+
...e
|
|
794
|
+
};
|
|
795
|
+
return {
|
|
796
|
+
type: "CharacterClass",
|
|
797
|
+
kind: r.kind,
|
|
798
|
+
negate: r.negate,
|
|
799
|
+
body: V(e?.body)
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function L(e, r) {
|
|
803
|
+
if (r.value < e.value) throw new Error("Character class range out of order");
|
|
804
|
+
return {
|
|
805
|
+
type: "CharacterClassRange",
|
|
806
|
+
min: e,
|
|
807
|
+
max: r
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function E(e, r) {
|
|
811
|
+
const n = !!r?.negate, t = {
|
|
812
|
+
type: "CharacterSet",
|
|
813
|
+
kind: e
|
|
814
|
+
};
|
|
815
|
+
return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (t.negate = n), (e === "text_segment" || e === "newline" && !n) && (t.variableLength = !0), t;
|
|
816
|
+
}
|
|
817
|
+
function I(e, r = {}) {
|
|
818
|
+
if (e === "keep") return {
|
|
819
|
+
type: "Directive",
|
|
820
|
+
kind: e
|
|
821
|
+
};
|
|
822
|
+
if (e === "flags") return {
|
|
823
|
+
type: "Directive",
|
|
824
|
+
kind: e,
|
|
825
|
+
flags: u(r.flags)
|
|
826
|
+
};
|
|
827
|
+
throw new Error(`Unexpected directive kind "${e}"`);
|
|
828
|
+
}
|
|
829
|
+
function T(e) {
|
|
830
|
+
return {
|
|
831
|
+
type: "Flags",
|
|
832
|
+
...e
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function A(e) {
|
|
836
|
+
const r = e?.atomic, n = e?.flags;
|
|
837
|
+
if (r && n) throw new Error("Atomic group cannot have flags");
|
|
838
|
+
return {
|
|
839
|
+
type: "Group",
|
|
840
|
+
...r && { atomic: r },
|
|
841
|
+
...n && { flags: n },
|
|
842
|
+
body: h(e?.body)
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function K(e) {
|
|
846
|
+
const r = {
|
|
847
|
+
behind: !1,
|
|
848
|
+
negate: !1,
|
|
849
|
+
...e
|
|
850
|
+
};
|
|
851
|
+
return {
|
|
852
|
+
type: "LookaroundAssertion",
|
|
853
|
+
kind: r.behind ? "lookbehind" : "lookahead",
|
|
854
|
+
negate: r.negate,
|
|
855
|
+
body: h(e?.body)
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function U(e, r, n) {
|
|
859
|
+
return {
|
|
860
|
+
type: "NamedCallout",
|
|
861
|
+
kind: e,
|
|
862
|
+
tag: r,
|
|
863
|
+
arguments: n
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function R(e, r) {
|
|
867
|
+
const n = !!r?.negate;
|
|
868
|
+
if (!i.has(e)) throw new Error(`Invalid POSIX class "${e}"`);
|
|
869
|
+
return {
|
|
870
|
+
type: "CharacterSet",
|
|
871
|
+
kind: "posix",
|
|
872
|
+
value: e,
|
|
873
|
+
negate: n
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function _(e, r, n, t) {
|
|
877
|
+
if (r > n) throw new Error("Invalid reversed quantifier range");
|
|
878
|
+
return {
|
|
879
|
+
type: "Quantifier",
|
|
880
|
+
kind: e,
|
|
881
|
+
min: r,
|
|
882
|
+
max: n,
|
|
883
|
+
body: t
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function B(e, r) {
|
|
887
|
+
return {
|
|
888
|
+
type: "Regex",
|
|
889
|
+
body: h(r?.body),
|
|
890
|
+
flags: e
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
function O(e) {
|
|
894
|
+
return {
|
|
895
|
+
type: "Subroutine",
|
|
896
|
+
ref: e
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function Q(e, r) {
|
|
900
|
+
const n = {
|
|
901
|
+
negate: !1,
|
|
902
|
+
normalizeUnknownPropertyNames: !1,
|
|
903
|
+
skipPropertyNameValidation: !1,
|
|
904
|
+
unicodePropertyMap: null,
|
|
905
|
+
...r
|
|
906
|
+
};
|
|
907
|
+
let t = n.unicodePropertyMap?.get(w(e));
|
|
908
|
+
if (!t) {
|
|
909
|
+
if (n.normalizeUnknownPropertyNames) t = de(e);
|
|
910
|
+
else if (n.unicodePropertyMap && !n.skipPropertyNameValidation) throw new Error(o$1`Invalid Unicode property "\p{${e}}"`);
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
type: "CharacterSet",
|
|
914
|
+
kind: "property",
|
|
915
|
+
value: t ?? e,
|
|
916
|
+
negate: n.negate
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
function ie({ flags: e, kind: r, name: n, negate: t, number: s }) {
|
|
920
|
+
switch (r) {
|
|
921
|
+
case "absence_repeater": return G("repeater");
|
|
922
|
+
case "atomic": return A({ atomic: !0 });
|
|
923
|
+
case "capturing": return P(s, { name: n });
|
|
924
|
+
case "group": return A({ flags: e });
|
|
925
|
+
case "lookahead":
|
|
926
|
+
case "lookbehind": return K({
|
|
927
|
+
behind: r === "lookbehind",
|
|
928
|
+
negate: t
|
|
929
|
+
});
|
|
930
|
+
default: throw new Error(`Unexpected group kind "${r}"`);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
function h(e) {
|
|
934
|
+
if (e === void 0) e = [b()];
|
|
935
|
+
else if (!Array.isArray(e) || !e.length || !e.every((r) => r.type === "Alternative")) throw new Error("Invalid body; expected array of one or more Alternative nodes");
|
|
936
|
+
return e;
|
|
937
|
+
}
|
|
938
|
+
function V(e) {
|
|
939
|
+
if (e === void 0) e = [];
|
|
940
|
+
else if (!Array.isArray(e) || !e.every((r) => !!r.type)) throw new Error("Invalid body; expected array of nodes");
|
|
941
|
+
return e;
|
|
942
|
+
}
|
|
943
|
+
function M(e) {
|
|
944
|
+
return e.type === "LookaroundAssertion" && e.kind === "lookahead";
|
|
945
|
+
}
|
|
946
|
+
function $(e) {
|
|
947
|
+
return e.type === "LookaroundAssertion" && e.kind === "lookbehind";
|
|
948
|
+
}
|
|
949
|
+
function se(e) {
|
|
950
|
+
return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e);
|
|
951
|
+
}
|
|
952
|
+
function de(e) {
|
|
953
|
+
return e.trim().replace(/[- _]+/g, "_").replace(/[A-Z][a-z]+(?=[A-Z])/g, "$&_").replace(/[A-Za-z]+/g, (r) => r[0].toUpperCase() + r.slice(1).toLowerCase());
|
|
954
|
+
}
|
|
955
|
+
function w(e) {
|
|
956
|
+
return e.replace(/[- _]+/g, "").toLowerCase();
|
|
957
|
+
}
|
|
958
|
+
function z(e, r) {
|
|
959
|
+
return u(e, `${r?.type === "Character" && r.value === 93 ? "Empty" : "Unclosed"} character class`);
|
|
960
|
+
}
|
|
961
|
+
function D(e) {
|
|
962
|
+
return u(e, "Unclosed group");
|
|
963
|
+
}
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region ../../node_modules/oniguruma-parser/dist/traverser/traverse.js
|
|
966
|
+
function S(a, v, N = null) {
|
|
967
|
+
function u$1(e, s) {
|
|
968
|
+
for (let t = 0; t < e.length; t++) {
|
|
969
|
+
const r = n(e[t], s, t, e);
|
|
970
|
+
t = Math.max(-1, t + r);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
function n(e, s = null, t = null, r = null) {
|
|
974
|
+
let i = 0, c = !1;
|
|
975
|
+
const d = {
|
|
976
|
+
node: e,
|
|
977
|
+
parent: s,
|
|
978
|
+
key: t,
|
|
979
|
+
container: r,
|
|
980
|
+
root: a,
|
|
981
|
+
remove() {
|
|
982
|
+
f(r).splice(Math.max(0, l(t) + i), 1), i--, c = !0;
|
|
983
|
+
},
|
|
984
|
+
removeAllNextSiblings() {
|
|
985
|
+
return f(r).splice(l(t) + 1);
|
|
986
|
+
},
|
|
987
|
+
removeAllPrevSiblings() {
|
|
988
|
+
const o = l(t) + i;
|
|
989
|
+
return i -= o, f(r).splice(0, Math.max(0, o));
|
|
990
|
+
},
|
|
991
|
+
replaceWith(o, y = {}) {
|
|
992
|
+
const b = !!y.traverse;
|
|
993
|
+
r ? r[Math.max(0, l(t) + i)] = o : u(s, "Can't replace root node")[t] = o, b && n(o, s, t, r), c = !0;
|
|
994
|
+
},
|
|
995
|
+
replaceWithMultiple(o, y = {}) {
|
|
996
|
+
const b = !!y.traverse;
|
|
997
|
+
if (f(r).splice(Math.max(0, l(t) + i), 1, ...o), i += o.length - 1, b) {
|
|
998
|
+
let g = 0;
|
|
999
|
+
for (let x = 0; x < o.length; x++) g += n(o[x], s, l(t) + x + g, r);
|
|
1000
|
+
}
|
|
1001
|
+
c = !0;
|
|
1002
|
+
},
|
|
1003
|
+
skip() {
|
|
1004
|
+
c = !0;
|
|
1005
|
+
}
|
|
1006
|
+
}, { type: m } = e, h = v["*"], p = v[m], R = typeof h == "function" ? h : h?.enter, P = typeof p == "function" ? p : p?.enter;
|
|
1007
|
+
if (R?.(d, N), P?.(d, N), !c) switch (m) {
|
|
1008
|
+
case "AbsenceFunction":
|
|
1009
|
+
case "CapturingGroup":
|
|
1010
|
+
case "Group":
|
|
1011
|
+
u$1(e.body, e);
|
|
1012
|
+
break;
|
|
1013
|
+
case "Alternative":
|
|
1014
|
+
case "CharacterClass":
|
|
1015
|
+
u$1(e.body, e);
|
|
1016
|
+
break;
|
|
1017
|
+
case "Assertion":
|
|
1018
|
+
case "Backreference":
|
|
1019
|
+
case "Character":
|
|
1020
|
+
case "CharacterSet":
|
|
1021
|
+
case "Directive":
|
|
1022
|
+
case "Flags":
|
|
1023
|
+
case "NamedCallout":
|
|
1024
|
+
case "Subroutine": break;
|
|
1025
|
+
case "CharacterClassRange":
|
|
1026
|
+
n(e.min, e, "min"), n(e.max, e, "max");
|
|
1027
|
+
break;
|
|
1028
|
+
case "LookaroundAssertion":
|
|
1029
|
+
u$1(e.body, e);
|
|
1030
|
+
break;
|
|
1031
|
+
case "Quantifier":
|
|
1032
|
+
n(e.body, e, "body");
|
|
1033
|
+
break;
|
|
1034
|
+
case "Regex":
|
|
1035
|
+
u$1(e.body, e), n(e.flags, e, "flags");
|
|
1036
|
+
break;
|
|
1037
|
+
default: throw new Error(`Unexpected node type "${m}"`);
|
|
1038
|
+
}
|
|
1039
|
+
return p?.exit?.(d, N), h?.exit?.(d, N), i;
|
|
1040
|
+
}
|
|
1041
|
+
return n(a), a;
|
|
1042
|
+
}
|
|
1043
|
+
function f(a) {
|
|
1044
|
+
if (!Array.isArray(a)) throw new Error("Container expected");
|
|
1045
|
+
return a;
|
|
1046
|
+
}
|
|
1047
|
+
function l(a) {
|
|
1048
|
+
if (typeof a != "number") throw new Error("Numeric key expected");
|
|
1049
|
+
return a;
|
|
1050
|
+
}
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region ../../node_modules/regex/src/utils-internals.js
|
|
1053
|
+
const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
|
|
1054
|
+
/**
|
|
1055
|
+
Updates the array in place by incrementing each value greater than or equal to the threshold.
|
|
1056
|
+
@param {Array<number>} arr
|
|
1057
|
+
@param {number} threshold
|
|
1058
|
+
*/
|
|
1059
|
+
function incrementIfAtLeast$1(arr, threshold) {
|
|
1060
|
+
for (let i = 0; i < arr.length; i++) if (arr[i] >= threshold) arr[i]++;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
@param {string} str
|
|
1064
|
+
@param {number} pos
|
|
1065
|
+
@param {string} oldValue
|
|
1066
|
+
@param {string} newValue
|
|
1067
|
+
@returns {string}
|
|
1068
|
+
*/
|
|
1069
|
+
function spliceStr(str, pos, oldValue, newValue) {
|
|
1070
|
+
return str.slice(0, pos) + newValue + str.slice(pos + oldValue.length);
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region ../../node_modules/regex-utilities/src/index.js
|
|
1074
|
+
const Context = Object.freeze({
|
|
1075
|
+
DEFAULT: "DEFAULT",
|
|
1076
|
+
CHAR_CLASS: "CHAR_CLASS"
|
|
1077
|
+
});
|
|
1078
|
+
/**
|
|
1079
|
+
Replaces all unescaped instances of a regex pattern in the given context, using a replacement
|
|
1080
|
+
string or callback.
|
|
1081
|
+
|
|
1082
|
+
Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
|
|
1083
|
+
with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
|
|
1084
|
+
@param {string} expression Search target
|
|
1085
|
+
@param {string} needle Search as a regex pattern, with flags `su` applied
|
|
1086
|
+
@param {string | (match: RegExpExecArray, details: {
|
|
1087
|
+
context: 'DEFAULT' | 'CHAR_CLASS';
|
|
1088
|
+
negated: boolean;
|
|
1089
|
+
}) => string} replacement
|
|
1090
|
+
@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
|
|
1091
|
+
@returns {string} Updated expression
|
|
1092
|
+
@example
|
|
1093
|
+
const str = '.\\.\\\\.[[\\.].].';
|
|
1094
|
+
replaceUnescaped(str, '\\.', '@');
|
|
1095
|
+
// → '@\\.\\\\@[[\\.]@]@'
|
|
1096
|
+
replaceUnescaped(str, '\\.', '@', Context.DEFAULT);
|
|
1097
|
+
// → '@\\.\\\\@[[\\.].]@'
|
|
1098
|
+
replaceUnescaped(str, '\\.', '@', Context.CHAR_CLASS);
|
|
1099
|
+
// → '.\\.\\\\.[[\\.]@].'
|
|
1100
|
+
*/
|
|
1101
|
+
function replaceUnescaped(expression, needle, replacement, context) {
|
|
1102
|
+
const re = new RegExp(String.raw`${needle}|(?<$skip>\[\^?|\\?.)`, "gsu");
|
|
1103
|
+
const negated = [false];
|
|
1104
|
+
let numCharClassesOpen = 0;
|
|
1105
|
+
let result = "";
|
|
1106
|
+
for (const match of expression.matchAll(re)) {
|
|
1107
|
+
const { 0: m, groups: { $skip } } = match;
|
|
1108
|
+
if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) {
|
|
1109
|
+
if (replacement instanceof Function) result += replacement(match, {
|
|
1110
|
+
context: numCharClassesOpen ? Context.CHAR_CLASS : Context.DEFAULT,
|
|
1111
|
+
negated: negated[negated.length - 1]
|
|
1112
|
+
});
|
|
1113
|
+
else result += replacement;
|
|
1114
|
+
continue;
|
|
1115
|
+
}
|
|
1116
|
+
if (m[0] === "[") {
|
|
1117
|
+
numCharClassesOpen++;
|
|
1118
|
+
negated.push(m[1] === "^");
|
|
1119
|
+
} else if (m === "]" && numCharClassesOpen) {
|
|
1120
|
+
numCharClassesOpen--;
|
|
1121
|
+
negated.pop();
|
|
1122
|
+
}
|
|
1123
|
+
result += m;
|
|
1124
|
+
}
|
|
1125
|
+
return result;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
Runs a callback for each unescaped instance of a regex pattern in the given context.
|
|
1129
|
+
|
|
1130
|
+
Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
|
|
1131
|
+
with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
|
|
1132
|
+
@param {string} expression Search target
|
|
1133
|
+
@param {string} needle Search as a regex pattern, with flags `su` applied
|
|
1134
|
+
@param {(match: RegExpExecArray, details: {
|
|
1135
|
+
context: 'DEFAULT' | 'CHAR_CLASS';
|
|
1136
|
+
negated: boolean;
|
|
1137
|
+
}) => void} callback
|
|
1138
|
+
@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
|
|
1139
|
+
*/
|
|
1140
|
+
function forEachUnescaped(expression, needle, callback, context) {
|
|
1141
|
+
replaceUnescaped(expression, needle, callback, context);
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
Returns a match object for the first unescaped instance of a regex pattern in the given context, or
|
|
1145
|
+
`null`.
|
|
1146
|
+
|
|
1147
|
+
Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
|
|
1148
|
+
with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
|
|
1149
|
+
@param {string} expression Search target
|
|
1150
|
+
@param {string} needle Search as a regex pattern, with flags `su` applied
|
|
1151
|
+
@param {number} [pos] Offset to start the search
|
|
1152
|
+
@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
|
|
1153
|
+
@returns {RegExpExecArray | null}
|
|
1154
|
+
*/
|
|
1155
|
+
function execUnescaped(expression, needle, pos = 0, context) {
|
|
1156
|
+
if (!new RegExp(needle, "su").test(expression)) return null;
|
|
1157
|
+
const re = new RegExp(`${needle}|(?<$skip>\\\\?.)`, "gsu");
|
|
1158
|
+
re.lastIndex = pos;
|
|
1159
|
+
let numCharClassesOpen = 0;
|
|
1160
|
+
let match;
|
|
1161
|
+
while (match = re.exec(expression)) {
|
|
1162
|
+
const { 0: m, groups: { $skip } } = match;
|
|
1163
|
+
if (!$skip && (!context || context === Context.DEFAULT === !numCharClassesOpen)) return match;
|
|
1164
|
+
if (m === "[") numCharClassesOpen++;
|
|
1165
|
+
else if (m === "]" && numCharClassesOpen) numCharClassesOpen--;
|
|
1166
|
+
if (re.lastIndex == match.index) re.lastIndex++;
|
|
1167
|
+
}
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
Checks whether an unescaped instance of a regex pattern appears in the given context.
|
|
1172
|
+
|
|
1173
|
+
Doesn't skip over complete multicharacter tokens (only `\` plus its folowing char) so must be used
|
|
1174
|
+
with knowledge of what's safe to do given regex syntax. Assumes UnicodeSets-mode syntax.
|
|
1175
|
+
@param {string} expression Search target
|
|
1176
|
+
@param {string} needle Search as a regex pattern, with flags `su` applied
|
|
1177
|
+
@param {'DEFAULT' | 'CHAR_CLASS'} [context] All contexts if not specified
|
|
1178
|
+
@returns {boolean} Whether the pattern was found
|
|
1179
|
+
*/
|
|
1180
|
+
function hasUnescaped(expression, needle, context) {
|
|
1181
|
+
return !!execUnescaped(expression, needle, 0, context);
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
Extracts the full contents of a group (subpattern) from the given expression, accounting for
|
|
1185
|
+
escaped characters, nested groups, and character classes. The group is identified by the position
|
|
1186
|
+
where its contents start (the string index just after the group's opening delimiter). Returns the
|
|
1187
|
+
rest of the string if the group is unclosed.
|
|
1188
|
+
|
|
1189
|
+
Assumes UnicodeSets-mode syntax.
|
|
1190
|
+
@param {string} expression Search target
|
|
1191
|
+
@param {number} contentsStartPos
|
|
1192
|
+
@returns {string}
|
|
1193
|
+
*/
|
|
1194
|
+
function getGroupContents(expression, contentsStartPos) {
|
|
1195
|
+
const token = /\\?./gsu;
|
|
1196
|
+
token.lastIndex = contentsStartPos;
|
|
1197
|
+
let contentsEndPos = expression.length;
|
|
1198
|
+
let numCharClassesOpen = 0;
|
|
1199
|
+
let numGroupsOpen = 1;
|
|
1200
|
+
let match;
|
|
1201
|
+
while (match = token.exec(expression)) {
|
|
1202
|
+
const [m] = match;
|
|
1203
|
+
if (m === "[") numCharClassesOpen++;
|
|
1204
|
+
else if (!numCharClassesOpen) {
|
|
1205
|
+
if (m === "(") numGroupsOpen++;
|
|
1206
|
+
else if (m === ")") {
|
|
1207
|
+
numGroupsOpen--;
|
|
1208
|
+
if (!numGroupsOpen) {
|
|
1209
|
+
contentsEndPos = match.index;
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
} else if (m === "]") numCharClassesOpen--;
|
|
1214
|
+
}
|
|
1215
|
+
return expression.slice(contentsStartPos, contentsEndPos);
|
|
1216
|
+
}
|
|
1217
|
+
//#endregion
|
|
1218
|
+
//#region ../../node_modules/regex/src/atomic.js
|
|
1219
|
+
/**
|
|
1220
|
+
@import {PluginData, PluginResult} from './regex.js';
|
|
1221
|
+
*/
|
|
1222
|
+
const atomicPluginToken = new RegExp(String.raw`(?<noncapturingStart>${noncapturingDelim})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
|
|
1223
|
+
/**
|
|
1224
|
+
Apply transformations for atomic groups: `(?>…)`.
|
|
1225
|
+
@param {string} expression
|
|
1226
|
+
@param {PluginData} [data]
|
|
1227
|
+
@returns {Required<PluginResult>}
|
|
1228
|
+
*/
|
|
1229
|
+
function atomic(expression, data) {
|
|
1230
|
+
const hiddenCaptures = data?.hiddenCaptures ?? [];
|
|
1231
|
+
let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
|
|
1232
|
+
if (!/\(\?>/.test(expression)) return {
|
|
1233
|
+
pattern: expression,
|
|
1234
|
+
captureTransfers,
|
|
1235
|
+
hiddenCaptures
|
|
1236
|
+
};
|
|
1237
|
+
const aGDelim = "(?>";
|
|
1238
|
+
const emulatedAGDelim = "(?:(?=(";
|
|
1239
|
+
const captureNumMap = [0];
|
|
1240
|
+
const addedHiddenCaptures = [];
|
|
1241
|
+
let numCapturesBeforeAG = 0;
|
|
1242
|
+
let numAGs = 0;
|
|
1243
|
+
let aGPos = NaN;
|
|
1244
|
+
let hasProcessedAG;
|
|
1245
|
+
do {
|
|
1246
|
+
hasProcessedAG = false;
|
|
1247
|
+
let numCharClassesOpen = 0;
|
|
1248
|
+
let numGroupsOpenInAG = 0;
|
|
1249
|
+
let inAG = false;
|
|
1250
|
+
let match;
|
|
1251
|
+
atomicPluginToken.lastIndex = Number.isNaN(aGPos) ? 0 : aGPos + 7;
|
|
1252
|
+
while (match = atomicPluginToken.exec(expression)) {
|
|
1253
|
+
const { 0: m, index, groups: { capturingStart, noncapturingStart } } = match;
|
|
1254
|
+
if (m === "[") numCharClassesOpen++;
|
|
1255
|
+
else if (!numCharClassesOpen) {
|
|
1256
|
+
if (m === aGDelim && !inAG) {
|
|
1257
|
+
aGPos = index;
|
|
1258
|
+
inAG = true;
|
|
1259
|
+
} else if (inAG && noncapturingStart) numGroupsOpenInAG++;
|
|
1260
|
+
else if (capturingStart) if (inAG) numGroupsOpenInAG++;
|
|
1261
|
+
else {
|
|
1262
|
+
numCapturesBeforeAG++;
|
|
1263
|
+
captureNumMap.push(numCapturesBeforeAG + numAGs);
|
|
1264
|
+
}
|
|
1265
|
+
else if (m === ")" && inAG) {
|
|
1266
|
+
if (!numGroupsOpenInAG) {
|
|
1267
|
+
numAGs++;
|
|
1268
|
+
const addedCaptureNum = numCapturesBeforeAG + numAGs;
|
|
1269
|
+
expression = `${expression.slice(0, aGPos)}${emulatedAGDelim}${expression.slice(aGPos + 3, index)}))<$$${addedCaptureNum}>)${expression.slice(index + 1)}`;
|
|
1270
|
+
hasProcessedAG = true;
|
|
1271
|
+
addedHiddenCaptures.push(addedCaptureNum);
|
|
1272
|
+
incrementIfAtLeast$1(hiddenCaptures, addedCaptureNum);
|
|
1273
|
+
if (captureTransfers.size) {
|
|
1274
|
+
const newCaptureTransfers = /* @__PURE__ */ new Map();
|
|
1275
|
+
captureTransfers.forEach((from, to) => {
|
|
1276
|
+
newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f) => f >= addedCaptureNum ? f + 1 : f));
|
|
1277
|
+
});
|
|
1278
|
+
captureTransfers = newCaptureTransfers;
|
|
1279
|
+
}
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
numGroupsOpenInAG--;
|
|
1283
|
+
}
|
|
1284
|
+
} else if (m === "]") numCharClassesOpen--;
|
|
1285
|
+
}
|
|
1286
|
+
} while (hasProcessedAG);
|
|
1287
|
+
hiddenCaptures.push(...addedHiddenCaptures);
|
|
1288
|
+
expression = replaceUnescaped(expression, String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`, ({ 0: m, groups: { backrefNum, wrappedBackrefNum } }) => {
|
|
1289
|
+
if (backrefNum) {
|
|
1290
|
+
const bNum = +backrefNum;
|
|
1291
|
+
if (bNum > captureNumMap.length - 1) throw new Error(`Backref "${m}" greater than number of captures`);
|
|
1292
|
+
return `\\${captureNumMap[bNum]}`;
|
|
1293
|
+
}
|
|
1294
|
+
return `\\${wrappedBackrefNum}`;
|
|
1295
|
+
}, Context.DEFAULT);
|
|
1296
|
+
return {
|
|
1297
|
+
pattern: expression,
|
|
1298
|
+
captureTransfers,
|
|
1299
|
+
hiddenCaptures
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
const baseQuantifier = String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`;
|
|
1303
|
+
const possessivePluginToken = new RegExp(String.raw`
|
|
1304
|
+
\\(?: \d+
|
|
1305
|
+
| c[A-Za-z]
|
|
1306
|
+
| [gk]<[^>]+>
|
|
1307
|
+
| [pPu]\{[^\}]+\}
|
|
1308
|
+
| u[A-Fa-f\d]{4}
|
|
1309
|
+
| x[A-Fa-f\d]{2}
|
|
1310
|
+
)
|
|
1311
|
+
| \((?: \? (?: [:=!>]
|
|
1312
|
+
| <(?:[=!]|[^>]+>)
|
|
1313
|
+
| [A-Za-z\-]+:
|
|
1314
|
+
| \(DEFINE\)
|
|
1315
|
+
))?
|
|
1316
|
+
| (?<qBase>${baseQuantifier})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
1317
|
+
| \\?.
|
|
1318
|
+
`.replace(/\s+/g, ""), "gsu");
|
|
1319
|
+
/**
|
|
1320
|
+
Transform posessive quantifiers into atomic groups. The posessessive quantifiers are:
|
|
1321
|
+
`?+`, `*+`, `++`, `{N}+`, `{N,}+`, `{N,N}+`.
|
|
1322
|
+
This follows Java, PCRE, Perl, and Python.
|
|
1323
|
+
Possessive quantifiers in Oniguruma and Onigmo are only: `?+`, `*+`, `++`.
|
|
1324
|
+
@param {string} expression
|
|
1325
|
+
@returns {PluginResult}
|
|
1326
|
+
*/
|
|
1327
|
+
function possessive(expression) {
|
|
1328
|
+
if (!new RegExp(`${baseQuantifier}\\+`).test(expression)) return { pattern: expression };
|
|
1329
|
+
const openGroupIndices = [];
|
|
1330
|
+
let lastGroupIndex = null;
|
|
1331
|
+
let lastCharClassIndex = null;
|
|
1332
|
+
let lastToken = "";
|
|
1333
|
+
let numCharClassesOpen = 0;
|
|
1334
|
+
let match;
|
|
1335
|
+
possessivePluginToken.lastIndex = 0;
|
|
1336
|
+
while (match = possessivePluginToken.exec(expression)) {
|
|
1337
|
+
const { 0: m, index, groups: { qBase, qMod, invalidQ } } = match;
|
|
1338
|
+
if (m === "[") {
|
|
1339
|
+
if (!numCharClassesOpen) lastCharClassIndex = index;
|
|
1340
|
+
numCharClassesOpen++;
|
|
1341
|
+
} else if (m === "]") if (numCharClassesOpen) numCharClassesOpen--;
|
|
1342
|
+
else lastCharClassIndex = null;
|
|
1343
|
+
else if (!numCharClassesOpen) {
|
|
1344
|
+
if (qMod === "+" && lastToken && !lastToken.startsWith("(")) {
|
|
1345
|
+
if (invalidQ) throw new Error(`Invalid quantifier "${m}"`);
|
|
1346
|
+
let charsAdded = -1;
|
|
1347
|
+
if (/^\{\d+\}$/.test(qBase)) expression = spliceStr(expression, index + qBase.length, qMod, "");
|
|
1348
|
+
else {
|
|
1349
|
+
if (lastToken === ")" || lastToken === "]") {
|
|
1350
|
+
const nodeIndex = lastToken === ")" ? lastGroupIndex : lastCharClassIndex;
|
|
1351
|
+
if (nodeIndex === null) throw new Error(`Invalid unmatched "${lastToken}"`);
|
|
1352
|
+
expression = `${expression.slice(0, nodeIndex)}(?>${expression.slice(nodeIndex, index)}${qBase})${expression.slice(index + m.length)}`;
|
|
1353
|
+
} else expression = `${expression.slice(0, index - lastToken.length)}(?>${lastToken}${qBase})${expression.slice(index + m.length)}`;
|
|
1354
|
+
charsAdded += 4;
|
|
1355
|
+
}
|
|
1356
|
+
possessivePluginToken.lastIndex += charsAdded;
|
|
1357
|
+
} else if (m[0] === "(") openGroupIndices.push(index);
|
|
1358
|
+
else if (m === ")") lastGroupIndex = openGroupIndices.length ? openGroupIndices.pop() : null;
|
|
1359
|
+
}
|
|
1360
|
+
lastToken = m;
|
|
1361
|
+
}
|
|
1362
|
+
return { pattern: expression };
|
|
1363
|
+
}
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region ../../node_modules/regex-recursion/src/index.js
|
|
1366
|
+
const r$1 = String.raw;
|
|
1367
|
+
const recursiveToken = r$1`\(\?R=(?<rDepth>[^\)]+)\)|${r$1`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`;
|
|
1368
|
+
const namedCaptureDelim = r$1`\(\?<(?![=!])(?<captureName>[^>]+)>`;
|
|
1369
|
+
const captureDelim = r$1`${namedCaptureDelim}|(?<unnamed>\()(?!\?)`;
|
|
1370
|
+
const token = new RegExp(r$1`${namedCaptureDelim}|${recursiveToken}|\(\?|\\?.`, "gsu");
|
|
1371
|
+
const overlappingRecursionMsg = "Cannot use multiple overlapping recursions";
|
|
1372
|
+
/**
|
|
1373
|
+
@param {string} pattern
|
|
1374
|
+
@param {{
|
|
1375
|
+
flags?: string;
|
|
1376
|
+
captureTransfers?: Map<number, Array<number>>;
|
|
1377
|
+
hiddenCaptures?: Array<number>;
|
|
1378
|
+
mode?: 'plugin' | 'external';
|
|
1379
|
+
}} [data]
|
|
1380
|
+
@returns {{
|
|
1381
|
+
pattern: string;
|
|
1382
|
+
captureTransfers: Map<number, Array<number>>;
|
|
1383
|
+
hiddenCaptures: Array<number>;
|
|
1384
|
+
}}
|
|
1385
|
+
*/
|
|
1386
|
+
function recursion(pattern, data) {
|
|
1387
|
+
const { hiddenCaptures, mode } = {
|
|
1388
|
+
hiddenCaptures: [],
|
|
1389
|
+
mode: "plugin",
|
|
1390
|
+
...data
|
|
1391
|
+
};
|
|
1392
|
+
let captureTransfers = data?.captureTransfers ?? /* @__PURE__ */ new Map();
|
|
1393
|
+
if (!new RegExp(recursiveToken, "su").test(pattern)) return {
|
|
1394
|
+
pattern,
|
|
1395
|
+
captureTransfers,
|
|
1396
|
+
hiddenCaptures
|
|
1397
|
+
};
|
|
1398
|
+
if (mode === "plugin" && hasUnescaped(pattern, r$1`\(\?\(DEFINE\)`, Context.DEFAULT)) throw new Error("DEFINE groups cannot be used with recursion");
|
|
1399
|
+
const addedHiddenCaptures = [];
|
|
1400
|
+
const hasNumberedBackref = hasUnescaped(pattern, r$1`\\[1-9]`, Context.DEFAULT);
|
|
1401
|
+
const groupContentsStartPos = /* @__PURE__ */ new Map();
|
|
1402
|
+
const openGroups = [];
|
|
1403
|
+
let hasRecursed = false;
|
|
1404
|
+
let numCharClassesOpen = 0;
|
|
1405
|
+
let numCapturesPassed = 0;
|
|
1406
|
+
let match;
|
|
1407
|
+
token.lastIndex = 0;
|
|
1408
|
+
while (match = token.exec(pattern)) {
|
|
1409
|
+
const { 0: m, groups: { captureName, rDepth, gRNameOrNum, gRDepth } } = match;
|
|
1410
|
+
if (m === "[") numCharClassesOpen++;
|
|
1411
|
+
else if (!numCharClassesOpen) {
|
|
1412
|
+
if (rDepth) {
|
|
1413
|
+
assertMaxInBounds(rDepth);
|
|
1414
|
+
if (hasRecursed) throw new Error(overlappingRecursionMsg);
|
|
1415
|
+
if (hasNumberedBackref) throw new Error(`${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with global recursion`);
|
|
1416
|
+
const left = pattern.slice(0, match.index);
|
|
1417
|
+
const right = pattern.slice(token.lastIndex);
|
|
1418
|
+
if (hasUnescaped(right, recursiveToken, Context.DEFAULT)) throw new Error(overlappingRecursionMsg);
|
|
1419
|
+
const reps = +rDepth - 1;
|
|
1420
|
+
pattern = makeRecursive(left, right, reps, false, hiddenCaptures, addedHiddenCaptures, numCapturesPassed);
|
|
1421
|
+
captureTransfers = mapCaptureTransfers(captureTransfers, left, reps, addedHiddenCaptures.length, 0, numCapturesPassed);
|
|
1422
|
+
break;
|
|
1423
|
+
} else if (gRNameOrNum) {
|
|
1424
|
+
assertMaxInBounds(gRDepth);
|
|
1425
|
+
let isWithinReffedGroup = false;
|
|
1426
|
+
for (const g of openGroups) if (g.name === gRNameOrNum || g.num === +gRNameOrNum) {
|
|
1427
|
+
isWithinReffedGroup = true;
|
|
1428
|
+
if (g.hasRecursedWithin) throw new Error(overlappingRecursionMsg);
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
if (!isWithinReffedGroup) throw new Error(r$1`Recursive \g cannot be used outside the referenced group "${mode === "external" ? gRNameOrNum : r$1`\g<${gRNameOrNum}&R=${gRDepth}>`}"`);
|
|
1432
|
+
const startPos = groupContentsStartPos.get(gRNameOrNum);
|
|
1433
|
+
const groupContents = getGroupContents(pattern, startPos);
|
|
1434
|
+
if (hasNumberedBackref && hasUnescaped(groupContents, r$1`${namedCaptureDelim}|\((?!\?)`, Context.DEFAULT)) throw new Error(`${mode === "external" ? "Backrefs" : "Numbered backrefs"} cannot be used with recursion of capturing groups`);
|
|
1435
|
+
const groupContentsLeft = pattern.slice(startPos, match.index);
|
|
1436
|
+
const groupContentsRight = groupContents.slice(groupContentsLeft.length + m.length);
|
|
1437
|
+
const numAddedHiddenCapturesPreExpansion = addedHiddenCaptures.length;
|
|
1438
|
+
const reps = +gRDepth - 1;
|
|
1439
|
+
const expansion = makeRecursive(groupContentsLeft, groupContentsRight, reps, true, hiddenCaptures, addedHiddenCaptures, numCapturesPassed);
|
|
1440
|
+
captureTransfers = mapCaptureTransfers(captureTransfers, groupContentsLeft, reps, addedHiddenCaptures.length - numAddedHiddenCapturesPreExpansion, numAddedHiddenCapturesPreExpansion, numCapturesPassed);
|
|
1441
|
+
pattern = `${pattern.slice(0, startPos)}${expansion}${pattern.slice(startPos + groupContents.length)}`;
|
|
1442
|
+
token.lastIndex += expansion.length - m.length - groupContentsLeft.length - groupContentsRight.length;
|
|
1443
|
+
openGroups.forEach((g) => g.hasRecursedWithin = true);
|
|
1444
|
+
hasRecursed = true;
|
|
1445
|
+
} else if (captureName) {
|
|
1446
|
+
numCapturesPassed++;
|
|
1447
|
+
groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
|
|
1448
|
+
groupContentsStartPos.set(captureName, token.lastIndex);
|
|
1449
|
+
openGroups.push({
|
|
1450
|
+
num: numCapturesPassed,
|
|
1451
|
+
name: captureName
|
|
1452
|
+
});
|
|
1453
|
+
} else if (m[0] === "(") {
|
|
1454
|
+
const isUnnamedCapture = m === "(";
|
|
1455
|
+
if (isUnnamedCapture) {
|
|
1456
|
+
numCapturesPassed++;
|
|
1457
|
+
groupContentsStartPos.set(String(numCapturesPassed), token.lastIndex);
|
|
1458
|
+
}
|
|
1459
|
+
openGroups.push(isUnnamedCapture ? { num: numCapturesPassed } : {});
|
|
1460
|
+
} else if (m === ")") openGroups.pop();
|
|
1461
|
+
} else if (m === "]") numCharClassesOpen--;
|
|
1462
|
+
}
|
|
1463
|
+
hiddenCaptures.push(...addedHiddenCaptures);
|
|
1464
|
+
return {
|
|
1465
|
+
pattern,
|
|
1466
|
+
captureTransfers,
|
|
1467
|
+
hiddenCaptures
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
@param {string} max
|
|
1472
|
+
*/
|
|
1473
|
+
function assertMaxInBounds(max) {
|
|
1474
|
+
const errMsg = `Max depth must be integer between 2 and 100; used ${max}`;
|
|
1475
|
+
if (!/^[1-9]\d*$/.test(max)) throw new Error(errMsg);
|
|
1476
|
+
max = +max;
|
|
1477
|
+
if (max < 2 || max > 100) throw new Error(errMsg);
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
@param {string} left
|
|
1481
|
+
@param {string} right
|
|
1482
|
+
@param {number} reps
|
|
1483
|
+
@param {boolean} isSubpattern
|
|
1484
|
+
@param {Array<number>} hiddenCaptures
|
|
1485
|
+
@param {Array<number>} addedHiddenCaptures
|
|
1486
|
+
@param {number} numCapturesPassed
|
|
1487
|
+
@returns {string}
|
|
1488
|
+
*/
|
|
1489
|
+
function makeRecursive(left, right, reps, isSubpattern, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
|
|
1490
|
+
const namesInRecursed = /* @__PURE__ */ new Set();
|
|
1491
|
+
if (isSubpattern) forEachUnescaped(left + right, namedCaptureDelim, ({ groups: { captureName } }) => {
|
|
1492
|
+
namesInRecursed.add(captureName);
|
|
1493
|
+
}, Context.DEFAULT);
|
|
1494
|
+
const rest = [
|
|
1495
|
+
reps,
|
|
1496
|
+
isSubpattern ? namesInRecursed : null,
|
|
1497
|
+
hiddenCaptures,
|
|
1498
|
+
addedHiddenCaptures,
|
|
1499
|
+
numCapturesPassed
|
|
1500
|
+
];
|
|
1501
|
+
return `${left}${repeatWithDepth(`(?:${left}`, "forward", ...rest)}(?:)${repeatWithDepth(`${right})`, "backward", ...rest)}${right}`;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
@param {string} pattern
|
|
1505
|
+
@param {'forward' | 'backward'} direction
|
|
1506
|
+
@param {number} reps
|
|
1507
|
+
@param {Set<string> | null} namesInRecursed
|
|
1508
|
+
@param {Array<number>} hiddenCaptures
|
|
1509
|
+
@param {Array<number>} addedHiddenCaptures
|
|
1510
|
+
@param {number} numCapturesPassed
|
|
1511
|
+
@returns {string}
|
|
1512
|
+
*/
|
|
1513
|
+
function repeatWithDepth(pattern, direction, reps, namesInRecursed, hiddenCaptures, addedHiddenCaptures, numCapturesPassed) {
|
|
1514
|
+
const startNum = 2;
|
|
1515
|
+
const getDepthNum = (i) => direction === "forward" ? i + startNum : reps - i + startNum - 1;
|
|
1516
|
+
let result = "";
|
|
1517
|
+
for (let i = 0; i < reps; i++) {
|
|
1518
|
+
const depthNum = getDepthNum(i);
|
|
1519
|
+
result += replaceUnescaped(pattern, r$1`${captureDelim}|\\k<(?<backref>[^>]+)>`, ({ 0: m, groups: { captureName, unnamed, backref } }) => {
|
|
1520
|
+
if (backref && namesInRecursed && !namesInRecursed.has(backref)) return m;
|
|
1521
|
+
const suffix = `_$${depthNum}`;
|
|
1522
|
+
if (unnamed || captureName) {
|
|
1523
|
+
const addedCaptureNum = numCapturesPassed + addedHiddenCaptures.length + 1;
|
|
1524
|
+
addedHiddenCaptures.push(addedCaptureNum);
|
|
1525
|
+
incrementIfAtLeast(hiddenCaptures, addedCaptureNum);
|
|
1526
|
+
return unnamed ? m : `(?<${captureName}${suffix}>`;
|
|
1527
|
+
}
|
|
1528
|
+
return r$1`\k<${backref}${suffix}>`;
|
|
1529
|
+
}, Context.DEFAULT);
|
|
1530
|
+
}
|
|
1531
|
+
return result;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
Updates the array in place by incrementing each value greater than or equal to the threshold.
|
|
1535
|
+
@param {Array<number>} arr
|
|
1536
|
+
@param {number} threshold
|
|
1537
|
+
*/
|
|
1538
|
+
function incrementIfAtLeast(arr, threshold) {
|
|
1539
|
+
for (let i = 0; i < arr.length; i++) if (arr[i] >= threshold) arr[i]++;
|
|
1540
|
+
}
|
|
1541
|
+
/**
|
|
1542
|
+
@param {Map<number, Array<number>>} captureTransfers
|
|
1543
|
+
@param {string} left
|
|
1544
|
+
@param {number} reps
|
|
1545
|
+
@param {number} numCapturesAddedInExpansion
|
|
1546
|
+
@param {number} numAddedHiddenCapturesPreExpansion
|
|
1547
|
+
@param {number} numCapturesPassed
|
|
1548
|
+
@returns {Map<number, Array<number>>}
|
|
1549
|
+
*/
|
|
1550
|
+
function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExpansion, numAddedHiddenCapturesPreExpansion, numCapturesPassed) {
|
|
1551
|
+
if (captureTransfers.size && numCapturesAddedInExpansion) {
|
|
1552
|
+
let numCapturesInLeft = 0;
|
|
1553
|
+
forEachUnescaped(left, captureDelim, () => numCapturesInLeft++, Context.DEFAULT);
|
|
1554
|
+
const recursionDelimCaptureNum = numCapturesPassed - numCapturesInLeft + numAddedHiddenCapturesPreExpansion;
|
|
1555
|
+
const newCaptureTransfers = /* @__PURE__ */ new Map();
|
|
1556
|
+
captureTransfers.forEach((from, to) => {
|
|
1557
|
+
const numCapturesInRight = (numCapturesAddedInExpansion - numCapturesInLeft * reps) / reps;
|
|
1558
|
+
const numCapturesAddedInLeft = numCapturesInLeft * reps;
|
|
1559
|
+
const newTo = to > recursionDelimCaptureNum + numCapturesInLeft ? to + numCapturesAddedInExpansion : to;
|
|
1560
|
+
const newFrom = [];
|
|
1561
|
+
for (const f of from) if (f <= recursionDelimCaptureNum) newFrom.push(f);
|
|
1562
|
+
else if (f > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) newFrom.push(f + numCapturesAddedInExpansion);
|
|
1563
|
+
else if (f <= recursionDelimCaptureNum + numCapturesInLeft) for (let i = 0; i <= reps; i++) newFrom.push(f + numCapturesInLeft * i);
|
|
1564
|
+
else for (let i = 0; i <= reps; i++) newFrom.push(f + numCapturesAddedInLeft + numCapturesInRight * i);
|
|
1565
|
+
newCaptureTransfers.set(newTo, newFrom);
|
|
1566
|
+
});
|
|
1567
|
+
return newCaptureTransfers;
|
|
1568
|
+
}
|
|
1569
|
+
return captureTransfers;
|
|
1570
|
+
}
|
|
1571
|
+
//#endregion
|
|
1572
|
+
//#region ../../node_modules/oniguruma-to-es/dist/esm/index.js
|
|
1573
|
+
var cp = String.fromCodePoint;
|
|
1574
|
+
var r = String.raw;
|
|
1575
|
+
var envFlags = {};
|
|
1576
|
+
var globalRegExp = globalThis.RegExp;
|
|
1577
|
+
envFlags.flagGroups = (() => {
|
|
1578
|
+
try {
|
|
1579
|
+
new globalRegExp("(?i:)");
|
|
1580
|
+
} catch {
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
return true;
|
|
1584
|
+
})();
|
|
1585
|
+
envFlags.unicodeSets = (() => {
|
|
1586
|
+
try {
|
|
1587
|
+
new globalRegExp("[[]]", "v");
|
|
1588
|
+
} catch {
|
|
1589
|
+
return false;
|
|
1590
|
+
}
|
|
1591
|
+
return true;
|
|
1592
|
+
})();
|
|
1593
|
+
envFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() => {
|
|
1594
|
+
try {
|
|
1595
|
+
new globalRegExp(r`[\d\-a]`, "v");
|
|
1596
|
+
} catch {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
return false;
|
|
1600
|
+
})() : false;
|
|
1601
|
+
envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new globalRegExp("[[^a]]", "v").test("a");
|
|
1602
|
+
function getNewCurrentFlags(current, { enable, disable }) {
|
|
1603
|
+
return {
|
|
1604
|
+
dotAll: !disable?.dotAll && !!(enable?.dotAll || current.dotAll),
|
|
1605
|
+
ignoreCase: !disable?.ignoreCase && !!(enable?.ignoreCase || current.ignoreCase)
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
function getOrInsert(map, key, defaultValue) {
|
|
1609
|
+
if (!map.has(key)) map.set(key, defaultValue);
|
|
1610
|
+
return map.get(key);
|
|
1611
|
+
}
|
|
1612
|
+
function isMinTarget(target, min) {
|
|
1613
|
+
return EsVersion[target] >= EsVersion[min];
|
|
1614
|
+
}
|
|
1615
|
+
function throwIfNullish(value, msg) {
|
|
1616
|
+
if (value == null) throw new Error(msg ?? "Value expected");
|
|
1617
|
+
return value;
|
|
1618
|
+
}
|
|
1619
|
+
var EsVersion = {
|
|
1620
|
+
ES2025: 2025,
|
|
1621
|
+
ES2024: 2024,
|
|
1622
|
+
ES2018: 2018
|
|
1623
|
+
};
|
|
1624
|
+
var Target = (
|
|
1625
|
+
/** @type {const} */
|
|
1626
|
+
{
|
|
1627
|
+
auto: "auto",
|
|
1628
|
+
ES2025: "ES2025",
|
|
1629
|
+
ES2024: "ES2024",
|
|
1630
|
+
ES2018: "ES2018"
|
|
1631
|
+
});
|
|
1632
|
+
function getOptions(options = {}) {
|
|
1633
|
+
if ({}.toString.call(options) !== "[object Object]") throw new Error("Unexpected options");
|
|
1634
|
+
if (options.target !== void 0 && !Target[options.target]) throw new Error(`Unexpected target "${options.target}"`);
|
|
1635
|
+
const opts = {
|
|
1636
|
+
accuracy: "default",
|
|
1637
|
+
avoidSubclass: false,
|
|
1638
|
+
flags: "",
|
|
1639
|
+
global: false,
|
|
1640
|
+
hasIndices: false,
|
|
1641
|
+
lazyCompileLength: Infinity,
|
|
1642
|
+
target: "auto",
|
|
1643
|
+
verbose: false,
|
|
1644
|
+
...options,
|
|
1645
|
+
rules: {
|
|
1646
|
+
allowOrphanBackrefs: false,
|
|
1647
|
+
asciiWordBoundaries: false,
|
|
1648
|
+
captureGroup: false,
|
|
1649
|
+
recursionLimit: 20,
|
|
1650
|
+
singleline: false,
|
|
1651
|
+
...options.rules
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
if (opts.target === "auto") opts.target = envFlags.flagGroups ? "ES2025" : envFlags.unicodeSets ? "ES2024" : "ES2018";
|
|
1655
|
+
return opts;
|
|
1656
|
+
}
|
|
1657
|
+
var asciiSpaceChar = "[ -\r ]";
|
|
1658
|
+
var CharsWithoutIgnoreCaseExpansion = /* @__PURE__ */ new Set([cp(304), cp(305)]);
|
|
1659
|
+
var defaultWordChar = r`[\p{L}\p{M}\p{N}\p{Pc}]`;
|
|
1660
|
+
function getIgnoreCaseMatchChars(char) {
|
|
1661
|
+
if (CharsWithoutIgnoreCaseExpansion.has(char)) return [char];
|
|
1662
|
+
const set = /* @__PURE__ */ new Set();
|
|
1663
|
+
const lower = char.toLowerCase();
|
|
1664
|
+
const upper = lower.toUpperCase();
|
|
1665
|
+
const title = LowerToTitleCaseMap.get(lower);
|
|
1666
|
+
const altLower = LowerToAlternativeLowerCaseMap.get(lower);
|
|
1667
|
+
const altUpper = LowerToAlternativeUpperCaseMap.get(lower);
|
|
1668
|
+
if ([...upper].length === 1) set.add(upper);
|
|
1669
|
+
altUpper && set.add(altUpper);
|
|
1670
|
+
title && set.add(title);
|
|
1671
|
+
set.add(lower);
|
|
1672
|
+
altLower && set.add(altLower);
|
|
1673
|
+
return [...set];
|
|
1674
|
+
}
|
|
1675
|
+
var JsUnicodePropertyMap = /* @__PURE__ */ new Map(`C Other
|
|
1676
|
+
Cc Control cntrl
|
|
1677
|
+
Cf Format
|
|
1678
|
+
Cn Unassigned
|
|
1679
|
+
Co Private_Use
|
|
1680
|
+
Cs Surrogate
|
|
1681
|
+
L Letter
|
|
1682
|
+
LC Cased_Letter
|
|
1683
|
+
Ll Lowercase_Letter
|
|
1684
|
+
Lm Modifier_Letter
|
|
1685
|
+
Lo Other_Letter
|
|
1686
|
+
Lt Titlecase_Letter
|
|
1687
|
+
Lu Uppercase_Letter
|
|
1688
|
+
M Mark Combining_Mark
|
|
1689
|
+
Mc Spacing_Mark
|
|
1690
|
+
Me Enclosing_Mark
|
|
1691
|
+
Mn Nonspacing_Mark
|
|
1692
|
+
N Number
|
|
1693
|
+
Nd Decimal_Number digit
|
|
1694
|
+
Nl Letter_Number
|
|
1695
|
+
No Other_Number
|
|
1696
|
+
P Punctuation punct
|
|
1697
|
+
Pc Connector_Punctuation
|
|
1698
|
+
Pd Dash_Punctuation
|
|
1699
|
+
Pe Close_Punctuation
|
|
1700
|
+
Pf Final_Punctuation
|
|
1701
|
+
Pi Initial_Punctuation
|
|
1702
|
+
Po Other_Punctuation
|
|
1703
|
+
Ps Open_Punctuation
|
|
1704
|
+
S Symbol
|
|
1705
|
+
Sc Currency_Symbol
|
|
1706
|
+
Sk Modifier_Symbol
|
|
1707
|
+
Sm Math_Symbol
|
|
1708
|
+
So Other_Symbol
|
|
1709
|
+
Z Separator
|
|
1710
|
+
Zl Line_Separator
|
|
1711
|
+
Zp Paragraph_Separator
|
|
1712
|
+
Zs Space_Separator
|
|
1713
|
+
ASCII
|
|
1714
|
+
ASCII_Hex_Digit AHex
|
|
1715
|
+
Alphabetic Alpha
|
|
1716
|
+
Any
|
|
1717
|
+
Assigned
|
|
1718
|
+
Bidi_Control Bidi_C
|
|
1719
|
+
Bidi_Mirrored Bidi_M
|
|
1720
|
+
Case_Ignorable CI
|
|
1721
|
+
Cased
|
|
1722
|
+
Changes_When_Casefolded CWCF
|
|
1723
|
+
Changes_When_Casemapped CWCM
|
|
1724
|
+
Changes_When_Lowercased CWL
|
|
1725
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
1726
|
+
Changes_When_Titlecased CWT
|
|
1727
|
+
Changes_When_Uppercased CWU
|
|
1728
|
+
Dash
|
|
1729
|
+
Default_Ignorable_Code_Point DI
|
|
1730
|
+
Deprecated Dep
|
|
1731
|
+
Diacritic Dia
|
|
1732
|
+
Emoji
|
|
1733
|
+
Emoji_Component EComp
|
|
1734
|
+
Emoji_Modifier EMod
|
|
1735
|
+
Emoji_Modifier_Base EBase
|
|
1736
|
+
Emoji_Presentation EPres
|
|
1737
|
+
Extended_Pictographic ExtPict
|
|
1738
|
+
Extender Ext
|
|
1739
|
+
Grapheme_Base Gr_Base
|
|
1740
|
+
Grapheme_Extend Gr_Ext
|
|
1741
|
+
Hex_Digit Hex
|
|
1742
|
+
IDS_Binary_Operator IDSB
|
|
1743
|
+
IDS_Trinary_Operator IDST
|
|
1744
|
+
ID_Continue IDC
|
|
1745
|
+
ID_Start IDS
|
|
1746
|
+
Ideographic Ideo
|
|
1747
|
+
Join_Control Join_C
|
|
1748
|
+
Logical_Order_Exception LOE
|
|
1749
|
+
Lowercase Lower
|
|
1750
|
+
Math
|
|
1751
|
+
Noncharacter_Code_Point NChar
|
|
1752
|
+
Pattern_Syntax Pat_Syn
|
|
1753
|
+
Pattern_White_Space Pat_WS
|
|
1754
|
+
Quotation_Mark QMark
|
|
1755
|
+
Radical
|
|
1756
|
+
Regional_Indicator RI
|
|
1757
|
+
Sentence_Terminal STerm
|
|
1758
|
+
Soft_Dotted SD
|
|
1759
|
+
Terminal_Punctuation Term
|
|
1760
|
+
Unified_Ideograph UIdeo
|
|
1761
|
+
Uppercase Upper
|
|
1762
|
+
Variation_Selector VS
|
|
1763
|
+
White_Space space
|
|
1764
|
+
XID_Continue XIDC
|
|
1765
|
+
XID_Start XIDS`.split(/\s/).map((p) => [w(p), p]));
|
|
1766
|
+
var LowerToAlternativeLowerCaseMap = /* @__PURE__ */ new Map([["s", cp(383)], [cp(383), "s"]]);
|
|
1767
|
+
var LowerToAlternativeUpperCaseMap = /* @__PURE__ */ new Map([
|
|
1768
|
+
[cp(223), cp(7838)],
|
|
1769
|
+
[cp(107), cp(8490)],
|
|
1770
|
+
[cp(229), cp(8491)],
|
|
1771
|
+
[cp(969), cp(8486)]
|
|
1772
|
+
]);
|
|
1773
|
+
var LowerToTitleCaseMap = new Map([
|
|
1774
|
+
titleEntry(453),
|
|
1775
|
+
titleEntry(456),
|
|
1776
|
+
titleEntry(459),
|
|
1777
|
+
titleEntry(498),
|
|
1778
|
+
...titleRange(8072, 8079),
|
|
1779
|
+
...titleRange(8088, 8095),
|
|
1780
|
+
...titleRange(8104, 8111),
|
|
1781
|
+
titleEntry(8124),
|
|
1782
|
+
titleEntry(8140),
|
|
1783
|
+
titleEntry(8188)
|
|
1784
|
+
]);
|
|
1785
|
+
var PosixClassMap = /* @__PURE__ */ new Map([
|
|
1786
|
+
["alnum", r`[\p{Alpha}\p{Nd}]`],
|
|
1787
|
+
["alpha", r`\p{Alpha}`],
|
|
1788
|
+
["ascii", r`\p{ASCII}`],
|
|
1789
|
+
["blank", r`[\p{Zs}\t]`],
|
|
1790
|
+
["cntrl", r`\p{Cc}`],
|
|
1791
|
+
["digit", r`\p{Nd}`],
|
|
1792
|
+
["graph", r`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],
|
|
1793
|
+
["lower", r`\p{Lower}`],
|
|
1794
|
+
["print", r`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],
|
|
1795
|
+
["punct", r`[\p{P}\p{S}]`],
|
|
1796
|
+
["space", r`\p{space}`],
|
|
1797
|
+
["upper", r`\p{Upper}`],
|
|
1798
|
+
["word", r`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],
|
|
1799
|
+
["xdigit", r`\p{AHex}`]
|
|
1800
|
+
]);
|
|
1801
|
+
function range(start, end) {
|
|
1802
|
+
const range2 = [];
|
|
1803
|
+
for (let i = start; i <= end; i++) range2.push(i);
|
|
1804
|
+
return range2;
|
|
1805
|
+
}
|
|
1806
|
+
function titleEntry(codePoint) {
|
|
1807
|
+
const char = cp(codePoint);
|
|
1808
|
+
return [char.toLowerCase(), char];
|
|
1809
|
+
}
|
|
1810
|
+
function titleRange(start, end) {
|
|
1811
|
+
return range(start, end).map((codePoint) => titleEntry(codePoint));
|
|
1812
|
+
}
|
|
1813
|
+
var UnicodePropertiesWithSpecificCase = /* @__PURE__ */ new Set([
|
|
1814
|
+
"Lower",
|
|
1815
|
+
"Lowercase",
|
|
1816
|
+
"Upper",
|
|
1817
|
+
"Uppercase",
|
|
1818
|
+
"Ll",
|
|
1819
|
+
"Lowercase_Letter",
|
|
1820
|
+
"Lt",
|
|
1821
|
+
"Titlecase_Letter",
|
|
1822
|
+
"Lu",
|
|
1823
|
+
"Uppercase_Letter"
|
|
1824
|
+
]);
|
|
1825
|
+
function transform(ast, options) {
|
|
1826
|
+
const opts = {
|
|
1827
|
+
accuracy: "default",
|
|
1828
|
+
asciiWordBoundaries: false,
|
|
1829
|
+
avoidSubclass: false,
|
|
1830
|
+
bestEffortTarget: "ES2025",
|
|
1831
|
+
...options
|
|
1832
|
+
};
|
|
1833
|
+
addParentProperties(ast);
|
|
1834
|
+
const firstPassState = {
|
|
1835
|
+
accuracy: opts.accuracy,
|
|
1836
|
+
asciiWordBoundaries: opts.asciiWordBoundaries,
|
|
1837
|
+
avoidSubclass: opts.avoidSubclass,
|
|
1838
|
+
flagDirectivesByAlt: /* @__PURE__ */ new Map(),
|
|
1839
|
+
jsGroupNameMap: /* @__PURE__ */ new Map(),
|
|
1840
|
+
minTargetEs2024: isMinTarget(opts.bestEffortTarget, "ES2024"),
|
|
1841
|
+
passedLookbehind: false,
|
|
1842
|
+
strategy: null,
|
|
1843
|
+
subroutineRefMap: /* @__PURE__ */ new Map(),
|
|
1844
|
+
supportedGNodes: /* @__PURE__ */ new Set(),
|
|
1845
|
+
digitIsAscii: ast.flags.digitIsAscii,
|
|
1846
|
+
spaceIsAscii: ast.flags.spaceIsAscii,
|
|
1847
|
+
wordIsAscii: ast.flags.wordIsAscii
|
|
1848
|
+
};
|
|
1849
|
+
S(ast, FirstPassVisitor, firstPassState);
|
|
1850
|
+
const globalFlags = {
|
|
1851
|
+
dotAll: ast.flags.dotAll,
|
|
1852
|
+
ignoreCase: ast.flags.ignoreCase
|
|
1853
|
+
};
|
|
1854
|
+
const secondPassState = {
|
|
1855
|
+
currentFlags: globalFlags,
|
|
1856
|
+
prevFlags: null,
|
|
1857
|
+
globalFlags,
|
|
1858
|
+
groupOriginByCopy: /* @__PURE__ */ new Map(),
|
|
1859
|
+
groupsByName: /* @__PURE__ */ new Map(),
|
|
1860
|
+
multiplexCapturesToLeftByRef: /* @__PURE__ */ new Map(),
|
|
1861
|
+
openRefs: /* @__PURE__ */ new Map(),
|
|
1862
|
+
reffedNodesByReferencer: /* @__PURE__ */ new Map(),
|
|
1863
|
+
subroutineRefMap: firstPassState.subroutineRefMap
|
|
1864
|
+
};
|
|
1865
|
+
S(ast, SecondPassVisitor, secondPassState);
|
|
1866
|
+
S(ast, ThirdPassVisitor, {
|
|
1867
|
+
groupsByName: secondPassState.groupsByName,
|
|
1868
|
+
highestOrphanBackref: 0,
|
|
1869
|
+
numCapturesToLeft: 0,
|
|
1870
|
+
reffedNodesByReferencer: secondPassState.reffedNodesByReferencer
|
|
1871
|
+
});
|
|
1872
|
+
ast._originMap = secondPassState.groupOriginByCopy;
|
|
1873
|
+
ast._strategy = firstPassState.strategy;
|
|
1874
|
+
return ast;
|
|
1875
|
+
}
|
|
1876
|
+
var FirstPassVisitor = {
|
|
1877
|
+
AbsenceFunction({ node, parent, replaceWith }) {
|
|
1878
|
+
const { body, kind } = node;
|
|
1879
|
+
if (kind === "repeater") {
|
|
1880
|
+
const innerGroup = A();
|
|
1881
|
+
innerGroup.body[0].body.push(K({
|
|
1882
|
+
negate: true,
|
|
1883
|
+
body
|
|
1884
|
+
}), Q("Any"));
|
|
1885
|
+
const outerGroup = A();
|
|
1886
|
+
outerGroup.body[0].body.push(_("greedy", 0, Infinity, innerGroup));
|
|
1887
|
+
replaceWith(setParentDeep(outerGroup, parent), { traverse: true });
|
|
1888
|
+
} else throw new Error(`Unsupported absence function "(?~|"`);
|
|
1889
|
+
},
|
|
1890
|
+
Alternative: {
|
|
1891
|
+
enter({ node, parent, key }, { flagDirectivesByAlt }) {
|
|
1892
|
+
const flagDirectives = node.body.filter((el) => el.kind === "flags");
|
|
1893
|
+
for (let i = key + 1; i < parent.body.length; i++) {
|
|
1894
|
+
const forwardSiblingAlt = parent.body[i];
|
|
1895
|
+
getOrInsert(flagDirectivesByAlt, forwardSiblingAlt, []).push(...flagDirectives);
|
|
1896
|
+
}
|
|
1897
|
+
},
|
|
1898
|
+
exit({ node }, { flagDirectivesByAlt }) {
|
|
1899
|
+
if (flagDirectivesByAlt.get(node)?.length) {
|
|
1900
|
+
const flags = getCombinedFlagModsFromFlagNodes(flagDirectivesByAlt.get(node));
|
|
1901
|
+
if (flags) {
|
|
1902
|
+
const flagGroup = A({ flags });
|
|
1903
|
+
flagGroup.body[0].body = node.body;
|
|
1904
|
+
node.body = [setParentDeep(flagGroup, node)];
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
},
|
|
1909
|
+
Assertion({ node, parent, key, container, root, remove, replaceWith }, state) {
|
|
1910
|
+
const { kind, negate } = node;
|
|
1911
|
+
const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state;
|
|
1912
|
+
if (kind === "text_segment_boundary") throw new Error(`Unsupported text segment boundary "\\${negate ? "Y" : "y"}"`);
|
|
1913
|
+
else if (kind === "line_end") replaceWith(setParentDeep(K({ body: [b({ body: [F("string_end")] }), b({ body: [m(10)] })] }), parent));
|
|
1914
|
+
else if (kind === "line_start") replaceWith(setParentDeep(parseFragment(r`(?<=\A|\n(?!\z))`, { skipLookbehindValidation: true }), parent));
|
|
1915
|
+
else if (kind === "search_start") if (supportedGNodes.has(node)) {
|
|
1916
|
+
root.flags.sticky = true;
|
|
1917
|
+
remove();
|
|
1918
|
+
} else {
|
|
1919
|
+
const prev = container[key - 1];
|
|
1920
|
+
if (prev && isAlwaysNonZeroLength(prev)) replaceWith(setParentDeep(K({ negate: true }), parent));
|
|
1921
|
+
else if (avoidSubclass) throw new Error(r`Uses "\G" in a way that requires a subclass`);
|
|
1922
|
+
else {
|
|
1923
|
+
replaceWith(setParent(F("string_start"), parent));
|
|
1924
|
+
state.strategy = "clip_search";
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
else if (kind === "string_end" || kind === "string_start") {} else if (kind === "string_end_newline") replaceWith(setParentDeep(parseFragment(r`(?=\n?\z)`), parent));
|
|
1928
|
+
else if (kind === "word_boundary") {
|
|
1929
|
+
if (!wordIsAscii && !asciiWordBoundaries) {
|
|
1930
|
+
const b = `(?:(?<=${defaultWordChar})(?!${defaultWordChar})|(?<!${defaultWordChar})(?=${defaultWordChar}))`;
|
|
1931
|
+
const B = `(?:(?<=${defaultWordChar})(?=${defaultWordChar})|(?<!${defaultWordChar})(?!${defaultWordChar}))`;
|
|
1932
|
+
replaceWith(setParentDeep(parseFragment(negate ? B : b), parent));
|
|
1933
|
+
}
|
|
1934
|
+
} else throw new Error(`Unexpected assertion kind "${kind}"`);
|
|
1935
|
+
},
|
|
1936
|
+
Backreference({ node }, { jsGroupNameMap }) {
|
|
1937
|
+
let { ref } = node;
|
|
1938
|
+
if (typeof ref === "string" && !isValidJsGroupName(ref)) {
|
|
1939
|
+
ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
|
|
1940
|
+
node.ref = ref;
|
|
1941
|
+
}
|
|
1942
|
+
},
|
|
1943
|
+
CapturingGroup({ node }, { jsGroupNameMap, subroutineRefMap }) {
|
|
1944
|
+
let { name } = node;
|
|
1945
|
+
if (name && !isValidJsGroupName(name)) {
|
|
1946
|
+
name = getAndStoreJsGroupName(name, jsGroupNameMap);
|
|
1947
|
+
node.name = name;
|
|
1948
|
+
}
|
|
1949
|
+
subroutineRefMap.set(node.number, node);
|
|
1950
|
+
if (name) subroutineRefMap.set(name, node);
|
|
1951
|
+
},
|
|
1952
|
+
CharacterClassRange({ node, parent, replaceWith }) {
|
|
1953
|
+
if (parent.kind === "intersection") replaceWith(setParentDeep(C({ body: [node] }), parent), { traverse: true });
|
|
1954
|
+
},
|
|
1955
|
+
CharacterSet({ node, parent, replaceWith }, { accuracy, minTargetEs2024, digitIsAscii, spaceIsAscii, wordIsAscii }) {
|
|
1956
|
+
const { kind, negate, value } = node;
|
|
1957
|
+
if (digitIsAscii && (kind === "digit" || value === "digit")) {
|
|
1958
|
+
replaceWith(setParent(E("digit", { negate }), parent));
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (spaceIsAscii && (kind === "space" || value === "space")) {
|
|
1962
|
+
replaceWith(setParentDeep(setNegate(parseFragment(asciiSpaceChar), negate), parent));
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
if (wordIsAscii && (kind === "word" || value === "word")) {
|
|
1966
|
+
replaceWith(setParent(E("word", { negate }), parent));
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
if (kind === "any") replaceWith(setParent(Q("Any"), parent));
|
|
1970
|
+
else if (kind === "digit") replaceWith(setParent(Q("Nd", { negate }), parent));
|
|
1971
|
+
else if (kind === "dot") {} else if (kind === "text_segment") {
|
|
1972
|
+
if (accuracy === "strict") throw new Error(r`Use of "\X" requires non-strict accuracy`);
|
|
1973
|
+
const eBase = "\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?";
|
|
1974
|
+
const emoji = r`\p{RI}{2}|${eBase}(?:\u200D${eBase})*`;
|
|
1975
|
+
replaceWith(setParentDeep(parseFragment(r`(?>\r\n|${minTargetEs2024 ? r`\p{RGI_Emoji}` : emoji}|\P{M}\p{M}*)`, { skipPropertyNameValidation: true }), parent));
|
|
1976
|
+
} else if (kind === "hex") replaceWith(setParent(Q("AHex", { negate }), parent));
|
|
1977
|
+
else if (kind === "newline") replaceWith(setParentDeep(parseFragment(negate ? "[^\n]" : "(?>\r\n?|[\n\v\f
\u2028\u2029])"), parent));
|
|
1978
|
+
else if (kind === "posix") if (!minTargetEs2024 && (value === "graph" || value === "print")) {
|
|
1979
|
+
if (accuracy === "strict") throw new Error(`POSIX class "${value}" requires min target ES2024 or non-strict accuracy`);
|
|
1980
|
+
let ascii = {
|
|
1981
|
+
graph: "!-~",
|
|
1982
|
+
print: " -~"
|
|
1983
|
+
}[value];
|
|
1984
|
+
if (negate) ascii = `\0-${cp(ascii.codePointAt(0) - 1)}${cp(ascii.codePointAt(2) + 1)}-\u{10FFFF}`;
|
|
1985
|
+
replaceWith(setParentDeep(parseFragment(`[${ascii}]`), parent));
|
|
1986
|
+
} else replaceWith(setParentDeep(setNegate(parseFragment(PosixClassMap.get(value)), negate), parent));
|
|
1987
|
+
else if (kind === "property") {
|
|
1988
|
+
if (!JsUnicodePropertyMap.has(w(value))) node.key = "sc";
|
|
1989
|
+
} else if (kind === "space") replaceWith(setParent(Q("space", { negate }), parent));
|
|
1990
|
+
else if (kind === "word") replaceWith(setParentDeep(setNegate(parseFragment(defaultWordChar), negate), parent));
|
|
1991
|
+
else throw new Error(`Unexpected character set kind "${kind}"`);
|
|
1992
|
+
},
|
|
1993
|
+
Directive({ node, parent, root, remove, replaceWith, removeAllPrevSiblings, removeAllNextSiblings }) {
|
|
1994
|
+
const { kind, flags } = node;
|
|
1995
|
+
if (kind === "flags") if (!flags.enable && !flags.disable) remove();
|
|
1996
|
+
else {
|
|
1997
|
+
const flagGroup = A({ flags });
|
|
1998
|
+
flagGroup.body[0].body = removeAllNextSiblings();
|
|
1999
|
+
replaceWith(setParentDeep(flagGroup, parent), { traverse: true });
|
|
2000
|
+
}
|
|
2001
|
+
else if (kind === "keep") {
|
|
2002
|
+
const firstAlt = root.body[0];
|
|
2003
|
+
const topLevel = root.body.length === 1 && o(firstAlt, { type: "Group" }) && firstAlt.body[0].body.length === 1 ? firstAlt.body[0] : root;
|
|
2004
|
+
if (parent.parent !== topLevel || topLevel.body.length > 1) throw new Error(r`Uses "\K" in a way that's unsupported`);
|
|
2005
|
+
const lookbehind = K({ behind: true });
|
|
2006
|
+
lookbehind.body[0].body = removeAllPrevSiblings();
|
|
2007
|
+
replaceWith(setParentDeep(lookbehind, parent));
|
|
2008
|
+
} else throw new Error(`Unexpected directive kind "${kind}"`);
|
|
2009
|
+
},
|
|
2010
|
+
Flags({ node, parent }) {
|
|
2011
|
+
if (node.posixIsAscii) throw new Error("Unsupported flag \"P\"");
|
|
2012
|
+
if (node.textSegmentMode === "word") throw new Error("Unsupported flag \"y{w}\"");
|
|
2013
|
+
[
|
|
2014
|
+
"digitIsAscii",
|
|
2015
|
+
"extended",
|
|
2016
|
+
"posixIsAscii",
|
|
2017
|
+
"spaceIsAscii",
|
|
2018
|
+
"wordIsAscii",
|
|
2019
|
+
"textSegmentMode"
|
|
2020
|
+
].forEach((f) => delete node[f]);
|
|
2021
|
+
Object.assign(node, {
|
|
2022
|
+
global: false,
|
|
2023
|
+
hasIndices: false,
|
|
2024
|
+
multiline: false,
|
|
2025
|
+
sticky: node.sticky ?? false
|
|
2026
|
+
});
|
|
2027
|
+
parent.options = {
|
|
2028
|
+
disable: {
|
|
2029
|
+
x: true,
|
|
2030
|
+
n: true
|
|
2031
|
+
},
|
|
2032
|
+
force: { v: true }
|
|
2033
|
+
};
|
|
2034
|
+
},
|
|
2035
|
+
Group({ node }) {
|
|
2036
|
+
if (!node.flags) return;
|
|
2037
|
+
const { enable, disable } = node.flags;
|
|
2038
|
+
enable?.extended && delete enable.extended;
|
|
2039
|
+
disable?.extended && delete disable.extended;
|
|
2040
|
+
enable?.dotAll && disable?.dotAll && delete enable.dotAll;
|
|
2041
|
+
enable?.ignoreCase && disable?.ignoreCase && delete enable.ignoreCase;
|
|
2042
|
+
enable && !Object.keys(enable).length && delete node.flags.enable;
|
|
2043
|
+
disable && !Object.keys(disable).length && delete node.flags.disable;
|
|
2044
|
+
!node.flags.enable && !node.flags.disable && delete node.flags;
|
|
2045
|
+
},
|
|
2046
|
+
LookaroundAssertion({ node }, state) {
|
|
2047
|
+
const { kind } = node;
|
|
2048
|
+
if (kind === "lookbehind") state.passedLookbehind = true;
|
|
2049
|
+
},
|
|
2050
|
+
NamedCallout({ node, parent, replaceWith }) {
|
|
2051
|
+
const { kind } = node;
|
|
2052
|
+
if (kind === "fail") replaceWith(setParentDeep(K({ negate: true }), parent));
|
|
2053
|
+
else throw new Error(`Unsupported named callout "(*${kind.toUpperCase()}"`);
|
|
2054
|
+
},
|
|
2055
|
+
Quantifier({ node }) {
|
|
2056
|
+
if (node.body.type === "Quantifier") {
|
|
2057
|
+
const group = A();
|
|
2058
|
+
group.body[0].body.push(node.body);
|
|
2059
|
+
node.body = setParentDeep(group, node);
|
|
2060
|
+
}
|
|
2061
|
+
},
|
|
2062
|
+
Regex: {
|
|
2063
|
+
enter({ node }, { supportedGNodes }) {
|
|
2064
|
+
const leadingGs = [];
|
|
2065
|
+
let hasAltWithLeadG = false;
|
|
2066
|
+
let hasAltWithoutLeadG = false;
|
|
2067
|
+
for (const alt of node.body) if (alt.body.length === 1 && alt.body[0].kind === "search_start") alt.body.pop();
|
|
2068
|
+
else {
|
|
2069
|
+
const leadingG = getLeadingG(alt.body);
|
|
2070
|
+
if (leadingG) {
|
|
2071
|
+
hasAltWithLeadG = true;
|
|
2072
|
+
Array.isArray(leadingG) ? leadingGs.push(...leadingG) : leadingGs.push(leadingG);
|
|
2073
|
+
} else hasAltWithoutLeadG = true;
|
|
2074
|
+
}
|
|
2075
|
+
if (hasAltWithLeadG && !hasAltWithoutLeadG) leadingGs.forEach((g) => supportedGNodes.add(g));
|
|
2076
|
+
},
|
|
2077
|
+
exit(_, { accuracy, passedLookbehind, strategy }) {
|
|
2078
|
+
if (accuracy === "strict" && passedLookbehind && strategy) throw new Error(r`Uses "\G" in a way that requires non-strict accuracy`);
|
|
2079
|
+
}
|
|
2080
|
+
},
|
|
2081
|
+
Subroutine({ node }, { jsGroupNameMap }) {
|
|
2082
|
+
let { ref } = node;
|
|
2083
|
+
if (typeof ref === "string" && !isValidJsGroupName(ref)) {
|
|
2084
|
+
ref = getAndStoreJsGroupName(ref, jsGroupNameMap);
|
|
2085
|
+
node.ref = ref;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
var SecondPassVisitor = {
|
|
2090
|
+
Backreference({ node }, { multiplexCapturesToLeftByRef, reffedNodesByReferencer }) {
|
|
2091
|
+
const { orphan, ref } = node;
|
|
2092
|
+
if (!orphan) reffedNodesByReferencer.set(node, [...multiplexCapturesToLeftByRef.get(ref).map(({ node: node2 }) => node2)]);
|
|
2093
|
+
},
|
|
2094
|
+
CapturingGroup: {
|
|
2095
|
+
enter({ node, parent, replaceWith, skip }, { groupOriginByCopy, groupsByName, multiplexCapturesToLeftByRef, openRefs, reffedNodesByReferencer }) {
|
|
2096
|
+
const origin = groupOriginByCopy.get(node);
|
|
2097
|
+
if (origin && openRefs.has(node.number)) {
|
|
2098
|
+
const recursion2 = setParent(createRecursion(node.number), parent);
|
|
2099
|
+
reffedNodesByReferencer.set(recursion2, openRefs.get(node.number));
|
|
2100
|
+
replaceWith(recursion2);
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
openRefs.set(node.number, node);
|
|
2104
|
+
multiplexCapturesToLeftByRef.set(node.number, []);
|
|
2105
|
+
if (node.name) getOrInsert(multiplexCapturesToLeftByRef, node.name, []);
|
|
2106
|
+
const multiplexNodes = multiplexCapturesToLeftByRef.get(node.name ?? node.number);
|
|
2107
|
+
for (let i = 0; i < multiplexNodes.length; i++) {
|
|
2108
|
+
const multiplex = multiplexNodes[i];
|
|
2109
|
+
if (origin === multiplex.node || origin && origin === multiplex.origin || node === multiplex.origin) {
|
|
2110
|
+
multiplexNodes.splice(i, 1);
|
|
2111
|
+
break;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
multiplexCapturesToLeftByRef.get(node.number).push({
|
|
2115
|
+
node,
|
|
2116
|
+
origin
|
|
2117
|
+
});
|
|
2118
|
+
if (node.name) multiplexCapturesToLeftByRef.get(node.name).push({
|
|
2119
|
+
node,
|
|
2120
|
+
origin
|
|
2121
|
+
});
|
|
2122
|
+
if (node.name) {
|
|
2123
|
+
const groupsWithSameName = getOrInsert(groupsByName, node.name, /* @__PURE__ */ new Map());
|
|
2124
|
+
let hasDuplicateNameToRemove = false;
|
|
2125
|
+
if (origin) hasDuplicateNameToRemove = true;
|
|
2126
|
+
else for (const groupInfo of groupsWithSameName.values()) if (!groupInfo.hasDuplicateNameToRemove) {
|
|
2127
|
+
hasDuplicateNameToRemove = true;
|
|
2128
|
+
break;
|
|
2129
|
+
}
|
|
2130
|
+
groupsByName.get(node.name).set(node, {
|
|
2131
|
+
node,
|
|
2132
|
+
hasDuplicateNameToRemove
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
exit({ node }, { openRefs }) {
|
|
2137
|
+
openRefs.delete(node.number);
|
|
2138
|
+
}
|
|
2139
|
+
},
|
|
2140
|
+
Group: {
|
|
2141
|
+
enter({ node }, state) {
|
|
2142
|
+
state.prevFlags = state.currentFlags;
|
|
2143
|
+
if (node.flags) state.currentFlags = getNewCurrentFlags(state.currentFlags, node.flags);
|
|
2144
|
+
},
|
|
2145
|
+
exit(_, state) {
|
|
2146
|
+
state.currentFlags = state.prevFlags;
|
|
2147
|
+
}
|
|
2148
|
+
},
|
|
2149
|
+
Subroutine({ node, parent, replaceWith }, state) {
|
|
2150
|
+
const { isRecursive, ref } = node;
|
|
2151
|
+
if (isRecursive) {
|
|
2152
|
+
let reffed = parent;
|
|
2153
|
+
while (reffed = reffed.parent) if (reffed.type === "CapturingGroup" && (reffed.name === ref || reffed.number === ref)) break;
|
|
2154
|
+
state.reffedNodesByReferencer.set(node, reffed);
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
const reffedGroupNode = state.subroutineRefMap.get(ref);
|
|
2158
|
+
const isGlobalRecursion = ref === 0;
|
|
2159
|
+
const expandedSubroutine = isGlobalRecursion ? createRecursion(0) : cloneCapturingGroup(reffedGroupNode, state.groupOriginByCopy, null);
|
|
2160
|
+
let replacement = expandedSubroutine;
|
|
2161
|
+
if (!isGlobalRecursion) {
|
|
2162
|
+
const reffedGroupFlagMods = getCombinedFlagModsFromFlagNodes(getAllParents(reffedGroupNode, (p) => p.type === "Group" && !!p.flags));
|
|
2163
|
+
const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state.globalFlags, reffedGroupFlagMods) : state.globalFlags;
|
|
2164
|
+
if (!areFlagsEqual(reffedGroupFlags, state.currentFlags)) {
|
|
2165
|
+
replacement = A({ flags: getFlagModsFromFlags(reffedGroupFlags) });
|
|
2166
|
+
replacement.body[0].body.push(expandedSubroutine);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
replaceWith(setParentDeep(replacement, parent), { traverse: !isGlobalRecursion });
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
var ThirdPassVisitor = {
|
|
2173
|
+
Backreference({ node, parent, replaceWith }, state) {
|
|
2174
|
+
if (node.orphan) {
|
|
2175
|
+
state.highestOrphanBackref = Math.max(state.highestOrphanBackref, node.ref);
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
const participants = state.reffedNodesByReferencer.get(node).filter((reffed) => canParticipateWithNode(reffed, node));
|
|
2179
|
+
if (!participants.length) replaceWith(setParentDeep(K({ negate: true }), parent));
|
|
2180
|
+
else if (participants.length > 1) replaceWith(setParentDeep(A({
|
|
2181
|
+
atomic: true,
|
|
2182
|
+
body: participants.reverse().map((reffed) => b({ body: [k(reffed.number)] }))
|
|
2183
|
+
}), parent));
|
|
2184
|
+
else node.ref = participants[0].number;
|
|
2185
|
+
},
|
|
2186
|
+
CapturingGroup({ node }, state) {
|
|
2187
|
+
node.number = ++state.numCapturesToLeft;
|
|
2188
|
+
if (node.name) {
|
|
2189
|
+
if (state.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) delete node.name;
|
|
2190
|
+
}
|
|
2191
|
+
},
|
|
2192
|
+
Regex: { exit({ node }, state) {
|
|
2193
|
+
const numCapsNeeded = Math.max(state.highestOrphanBackref - state.numCapturesToLeft, 0);
|
|
2194
|
+
for (let i = 0; i < numCapsNeeded; i++) {
|
|
2195
|
+
const emptyCapture = P();
|
|
2196
|
+
node.body.at(-1).body.push(emptyCapture);
|
|
2197
|
+
}
|
|
2198
|
+
} },
|
|
2199
|
+
Subroutine({ node }, state) {
|
|
2200
|
+
if (!node.isRecursive || node.ref === 0) return;
|
|
2201
|
+
node.ref = state.reffedNodesByReferencer.get(node).number;
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
function addParentProperties(root) {
|
|
2205
|
+
S(root, { "*"({ node, parent }) {
|
|
2206
|
+
node.parent = parent;
|
|
2207
|
+
} });
|
|
2208
|
+
}
|
|
2209
|
+
function areFlagsEqual(a, b) {
|
|
2210
|
+
return a.dotAll === b.dotAll && a.ignoreCase === b.ignoreCase;
|
|
2211
|
+
}
|
|
2212
|
+
function canParticipateWithNode(capture, node) {
|
|
2213
|
+
let rightmostPoint = node;
|
|
2214
|
+
do {
|
|
2215
|
+
if (rightmostPoint.type === "Regex") return false;
|
|
2216
|
+
if (rightmostPoint.type === "Alternative") continue;
|
|
2217
|
+
if (rightmostPoint === capture) return false;
|
|
2218
|
+
const kidsOfParent = getKids(rightmostPoint.parent);
|
|
2219
|
+
for (const kid of kidsOfParent) {
|
|
2220
|
+
if (kid === rightmostPoint) break;
|
|
2221
|
+
if (kid === capture || isAncestorOf(kid, capture)) return true;
|
|
2222
|
+
}
|
|
2223
|
+
} while (rightmostPoint = rightmostPoint.parent);
|
|
2224
|
+
throw new Error("Unexpected path");
|
|
2225
|
+
}
|
|
2226
|
+
function cloneCapturingGroup(obj, originMap, up, up2) {
|
|
2227
|
+
const store = Array.isArray(obj) ? [] : {};
|
|
2228
|
+
for (const [key, value] of Object.entries(obj)) if (key === "parent") store.parent = Array.isArray(up) ? up2 : up;
|
|
2229
|
+
else if (value && typeof value === "object") store[key] = cloneCapturingGroup(value, originMap, store, up);
|
|
2230
|
+
else {
|
|
2231
|
+
if (key === "type" && value === "CapturingGroup") originMap.set(store, originMap.get(obj) ?? obj);
|
|
2232
|
+
store[key] = value;
|
|
2233
|
+
}
|
|
2234
|
+
return store;
|
|
2235
|
+
}
|
|
2236
|
+
function createRecursion(ref) {
|
|
2237
|
+
const node = O(ref);
|
|
2238
|
+
node.isRecursive = true;
|
|
2239
|
+
return node;
|
|
2240
|
+
}
|
|
2241
|
+
function getAllParents(node, filterFn) {
|
|
2242
|
+
const results = [];
|
|
2243
|
+
while (node = node.parent) if (!filterFn || filterFn(node)) results.push(node);
|
|
2244
|
+
return results;
|
|
2245
|
+
}
|
|
2246
|
+
function getAndStoreJsGroupName(name, map) {
|
|
2247
|
+
if (map.has(name)) return map.get(name);
|
|
2248
|
+
const jsName = `$${map.size}_${name.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu, "_")}`;
|
|
2249
|
+
map.set(name, jsName);
|
|
2250
|
+
return jsName;
|
|
2251
|
+
}
|
|
2252
|
+
function getCombinedFlagModsFromFlagNodes(flagNodes) {
|
|
2253
|
+
const flagProps = ["dotAll", "ignoreCase"];
|
|
2254
|
+
const combinedFlags = {
|
|
2255
|
+
enable: {},
|
|
2256
|
+
disable: {}
|
|
2257
|
+
};
|
|
2258
|
+
flagNodes.forEach(({ flags }) => {
|
|
2259
|
+
flagProps.forEach((prop) => {
|
|
2260
|
+
if (flags.enable?.[prop]) {
|
|
2261
|
+
delete combinedFlags.disable[prop];
|
|
2262
|
+
combinedFlags.enable[prop] = true;
|
|
2263
|
+
}
|
|
2264
|
+
if (flags.disable?.[prop]) combinedFlags.disable[prop] = true;
|
|
2265
|
+
});
|
|
2266
|
+
});
|
|
2267
|
+
if (!Object.keys(combinedFlags.enable).length) delete combinedFlags.enable;
|
|
2268
|
+
if (!Object.keys(combinedFlags.disable).length) delete combinedFlags.disable;
|
|
2269
|
+
if (combinedFlags.enable || combinedFlags.disable) return combinedFlags;
|
|
2270
|
+
return null;
|
|
2271
|
+
}
|
|
2272
|
+
function getFlagModsFromFlags({ dotAll, ignoreCase }) {
|
|
2273
|
+
const mods = {};
|
|
2274
|
+
if (dotAll || ignoreCase) {
|
|
2275
|
+
mods.enable = {};
|
|
2276
|
+
dotAll && (mods.enable.dotAll = true);
|
|
2277
|
+
ignoreCase && (mods.enable.ignoreCase = true);
|
|
2278
|
+
}
|
|
2279
|
+
if (!dotAll || !ignoreCase) {
|
|
2280
|
+
mods.disable = {};
|
|
2281
|
+
!dotAll && (mods.disable.dotAll = true);
|
|
2282
|
+
!ignoreCase && (mods.disable.ignoreCase = true);
|
|
2283
|
+
}
|
|
2284
|
+
return mods;
|
|
2285
|
+
}
|
|
2286
|
+
function getKids(node) {
|
|
2287
|
+
if (!node) throw new Error("Node expected");
|
|
2288
|
+
const { body } = node;
|
|
2289
|
+
return Array.isArray(body) ? body : body ? [body] : null;
|
|
2290
|
+
}
|
|
2291
|
+
function getLeadingG(els) {
|
|
2292
|
+
const firstToConsider = els.find((el) => el.kind === "search_start" || isLoneGLookaround(el, { negate: false }) || !isAlwaysZeroLength(el));
|
|
2293
|
+
if (!firstToConsider) return null;
|
|
2294
|
+
if (firstToConsider.kind === "search_start") return firstToConsider;
|
|
2295
|
+
if (firstToConsider.type === "LookaroundAssertion") return firstToConsider.body[0].body[0];
|
|
2296
|
+
if (firstToConsider.type === "CapturingGroup" || firstToConsider.type === "Group") {
|
|
2297
|
+
const gNodesForGroup = [];
|
|
2298
|
+
for (const alt of firstToConsider.body) {
|
|
2299
|
+
const leadingG = getLeadingG(alt.body);
|
|
2300
|
+
if (!leadingG) return null;
|
|
2301
|
+
Array.isArray(leadingG) ? gNodesForGroup.push(...leadingG) : gNodesForGroup.push(leadingG);
|
|
2302
|
+
}
|
|
2303
|
+
return gNodesForGroup;
|
|
2304
|
+
}
|
|
2305
|
+
return null;
|
|
2306
|
+
}
|
|
2307
|
+
function isAncestorOf(node, descendant) {
|
|
2308
|
+
const kids = getKids(node) ?? [];
|
|
2309
|
+
for (const kid of kids) if (kid === descendant || isAncestorOf(kid, descendant)) return true;
|
|
2310
|
+
return false;
|
|
2311
|
+
}
|
|
2312
|
+
function isAlwaysZeroLength({ type }) {
|
|
2313
|
+
return type === "Assertion" || type === "Directive" || type === "LookaroundAssertion";
|
|
2314
|
+
}
|
|
2315
|
+
function isAlwaysNonZeroLength(node) {
|
|
2316
|
+
const types = [
|
|
2317
|
+
"Character",
|
|
2318
|
+
"CharacterClass",
|
|
2319
|
+
"CharacterSet"
|
|
2320
|
+
];
|
|
2321
|
+
return types.includes(node.type) || node.type === "Quantifier" && node.min && types.includes(node.body.type);
|
|
2322
|
+
}
|
|
2323
|
+
function isLoneGLookaround(node, options) {
|
|
2324
|
+
const opts = {
|
|
2325
|
+
negate: null,
|
|
2326
|
+
...options
|
|
2327
|
+
};
|
|
2328
|
+
return node.type === "LookaroundAssertion" && (opts.negate === null || node.negate === opts.negate) && node.body.length === 1 && o(node.body[0], {
|
|
2329
|
+
type: "Assertion",
|
|
2330
|
+
kind: "search_start"
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
function isValidJsGroupName(name) {
|
|
2334
|
+
return /^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(name);
|
|
2335
|
+
}
|
|
2336
|
+
function parseFragment(pattern, options) {
|
|
2337
|
+
const alts = J(pattern, {
|
|
2338
|
+
...options,
|
|
2339
|
+
unicodePropertyMap: JsUnicodePropertyMap
|
|
2340
|
+
}).body;
|
|
2341
|
+
if (alts.length > 1 || alts[0].body.length > 1) return A({ body: alts });
|
|
2342
|
+
return alts[0].body[0];
|
|
2343
|
+
}
|
|
2344
|
+
function setNegate(node, negate) {
|
|
2345
|
+
node.negate = negate;
|
|
2346
|
+
return node;
|
|
2347
|
+
}
|
|
2348
|
+
function setParent(node, parent) {
|
|
2349
|
+
node.parent = parent;
|
|
2350
|
+
return node;
|
|
2351
|
+
}
|
|
2352
|
+
function setParentDeep(node, parent) {
|
|
2353
|
+
addParentProperties(node);
|
|
2354
|
+
node.parent = parent;
|
|
2355
|
+
return node;
|
|
2356
|
+
}
|
|
2357
|
+
function generate(ast, options) {
|
|
2358
|
+
const opts = getOptions(options);
|
|
2359
|
+
const minTargetEs2024 = isMinTarget(opts.target, "ES2024");
|
|
2360
|
+
const minTargetEs2025 = isMinTarget(opts.target, "ES2025");
|
|
2361
|
+
const recursionLimit = opts.rules.recursionLimit;
|
|
2362
|
+
if (!Number.isInteger(recursionLimit) || recursionLimit < 2 || recursionLimit > 20) throw new Error("Invalid recursionLimit; use 2-20");
|
|
2363
|
+
let hasCaseInsensitiveNode = null;
|
|
2364
|
+
let hasCaseSensitiveNode = null;
|
|
2365
|
+
if (!minTargetEs2025) {
|
|
2366
|
+
const iStack = [ast.flags.ignoreCase];
|
|
2367
|
+
S(ast, FlagModifierVisitor, {
|
|
2368
|
+
getCurrentModI: () => iStack.at(-1),
|
|
2369
|
+
popModI() {
|
|
2370
|
+
iStack.pop();
|
|
2371
|
+
},
|
|
2372
|
+
pushModI(isIOn) {
|
|
2373
|
+
iStack.push(isIOn);
|
|
2374
|
+
},
|
|
2375
|
+
setHasCasedChar() {
|
|
2376
|
+
if (iStack.at(-1)) hasCaseInsensitiveNode = true;
|
|
2377
|
+
else hasCaseSensitiveNode = true;
|
|
2378
|
+
}
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
const appliedGlobalFlags = {
|
|
2382
|
+
dotAll: ast.flags.dotAll,
|
|
2383
|
+
ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) && !hasCaseSensitiveNode)
|
|
2384
|
+
};
|
|
2385
|
+
let lastNode = ast;
|
|
2386
|
+
const state = {
|
|
2387
|
+
accuracy: opts.accuracy,
|
|
2388
|
+
appliedGlobalFlags,
|
|
2389
|
+
captureMap: /* @__PURE__ */ new Map(),
|
|
2390
|
+
currentFlags: {
|
|
2391
|
+
dotAll: ast.flags.dotAll,
|
|
2392
|
+
ignoreCase: ast.flags.ignoreCase
|
|
2393
|
+
},
|
|
2394
|
+
inCharClass: false,
|
|
2395
|
+
lastNode,
|
|
2396
|
+
originMap: ast._originMap,
|
|
2397
|
+
recursionLimit,
|
|
2398
|
+
useAppliedIgnoreCase: !!(!minTargetEs2025 && hasCaseInsensitiveNode && hasCaseSensitiveNode),
|
|
2399
|
+
useFlagMods: minTargetEs2025,
|
|
2400
|
+
useFlagV: minTargetEs2024,
|
|
2401
|
+
verbose: opts.verbose
|
|
2402
|
+
};
|
|
2403
|
+
function gen(node) {
|
|
2404
|
+
state.lastNode = lastNode;
|
|
2405
|
+
lastNode = node;
|
|
2406
|
+
return throwIfNullish(generator[node.type], `Unexpected node type "${node.type}"`)(node, state, gen);
|
|
2407
|
+
}
|
|
2408
|
+
const result = {
|
|
2409
|
+
pattern: ast.body.map(gen).join("|"),
|
|
2410
|
+
flags: gen(ast.flags),
|
|
2411
|
+
options: { ...ast.options }
|
|
2412
|
+
};
|
|
2413
|
+
if (!minTargetEs2024) {
|
|
2414
|
+
delete result.options.force.v;
|
|
2415
|
+
result.options.disable.v = true;
|
|
2416
|
+
result.options.unicodeSetsPlugin = null;
|
|
2417
|
+
}
|
|
2418
|
+
result._captureTransfers = /* @__PURE__ */ new Map();
|
|
2419
|
+
result._hiddenCaptures = [];
|
|
2420
|
+
state.captureMap.forEach((value, key) => {
|
|
2421
|
+
if (value.hidden) result._hiddenCaptures.push(key);
|
|
2422
|
+
if (value.transferTo) getOrInsert(result._captureTransfers, value.transferTo, []).push(key);
|
|
2423
|
+
});
|
|
2424
|
+
return result;
|
|
2425
|
+
}
|
|
2426
|
+
var FlagModifierVisitor = {
|
|
2427
|
+
"*": {
|
|
2428
|
+
enter({ node }, state) {
|
|
2429
|
+
if (isAnyGroup(node)) {
|
|
2430
|
+
const currentModI = state.getCurrentModI();
|
|
2431
|
+
state.pushModI(node.flags ? getNewCurrentFlags({ ignoreCase: currentModI }, node.flags).ignoreCase : currentModI);
|
|
2432
|
+
}
|
|
2433
|
+
},
|
|
2434
|
+
exit({ node }, state) {
|
|
2435
|
+
if (isAnyGroup(node)) state.popModI();
|
|
2436
|
+
}
|
|
2437
|
+
},
|
|
2438
|
+
Backreference(_, state) {
|
|
2439
|
+
state.setHasCasedChar();
|
|
2440
|
+
},
|
|
2441
|
+
Character({ node }, state) {
|
|
2442
|
+
if (charHasCase(cp(node.value))) state.setHasCasedChar();
|
|
2443
|
+
},
|
|
2444
|
+
CharacterClassRange({ node, skip }, state) {
|
|
2445
|
+
skip();
|
|
2446
|
+
if (getCasesOutsideCharClassRange(node, { firstOnly: true }).length) state.setHasCasedChar();
|
|
2447
|
+
},
|
|
2448
|
+
CharacterSet({ node }, state) {
|
|
2449
|
+
if (node.kind === "property" && UnicodePropertiesWithSpecificCase.has(node.value)) state.setHasCasedChar();
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
var generator = {
|
|
2453
|
+
Alternative({ body }, _, gen) {
|
|
2454
|
+
return body.map(gen).join("");
|
|
2455
|
+
},
|
|
2456
|
+
Assertion({ kind, negate }) {
|
|
2457
|
+
if (kind === "string_end") return "$";
|
|
2458
|
+
if (kind === "string_start") return "^";
|
|
2459
|
+
if (kind === "word_boundary") return negate ? r`\B` : r`\b`;
|
|
2460
|
+
throw new Error(`Unexpected assertion kind "${kind}"`);
|
|
2461
|
+
},
|
|
2462
|
+
Backreference({ ref }, state) {
|
|
2463
|
+
if (typeof ref !== "number") throw new Error("Unexpected named backref in transformed AST");
|
|
2464
|
+
if (!state.useFlagMods && state.accuracy === "strict" && state.currentFlags.ignoreCase && !state.captureMap.get(ref).ignoreCase) throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
|
|
2465
|
+
return "\\" + ref;
|
|
2466
|
+
},
|
|
2467
|
+
CapturingGroup(node, state, gen) {
|
|
2468
|
+
const { body, name, number } = node;
|
|
2469
|
+
const data = { ignoreCase: state.currentFlags.ignoreCase };
|
|
2470
|
+
const origin = state.originMap.get(node);
|
|
2471
|
+
if (origin) {
|
|
2472
|
+
data.hidden = true;
|
|
2473
|
+
if (number > origin.number) data.transferTo = origin.number;
|
|
2474
|
+
}
|
|
2475
|
+
state.captureMap.set(number, data);
|
|
2476
|
+
return `(${name ? `?<${name}>` : ""}${body.map(gen).join("|")})`;
|
|
2477
|
+
},
|
|
2478
|
+
Character({ value }, state) {
|
|
2479
|
+
const char = cp(value);
|
|
2480
|
+
const escaped = getCharEscape(value, {
|
|
2481
|
+
escDigit: state.lastNode.type === "Backreference",
|
|
2482
|
+
inCharClass: state.inCharClass,
|
|
2483
|
+
useFlagV: state.useFlagV
|
|
2484
|
+
});
|
|
2485
|
+
if (escaped !== char) return escaped;
|
|
2486
|
+
if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && charHasCase(char)) {
|
|
2487
|
+
const cases = getIgnoreCaseMatchChars(char);
|
|
2488
|
+
return state.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
|
|
2489
|
+
}
|
|
2490
|
+
return char;
|
|
2491
|
+
},
|
|
2492
|
+
CharacterClass(node, state, gen) {
|
|
2493
|
+
const { kind, negate, parent } = node;
|
|
2494
|
+
let { body } = node;
|
|
2495
|
+
if (kind === "intersection" && !state.useFlagV) throw new Error("Use of character class intersection requires min target ES2024");
|
|
2496
|
+
if (envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV && body.some(isLiteralHyphen)) body = [m(45), ...body.filter((kid) => !isLiteralHyphen(kid))];
|
|
2497
|
+
const genClass = () => `[${negate ? "^" : ""}${body.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
|
|
2498
|
+
if (!state.inCharClass) {
|
|
2499
|
+
if ((!state.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate) {
|
|
2500
|
+
const negatedChildClasses = body.filter((kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate);
|
|
2501
|
+
if (negatedChildClasses.length) {
|
|
2502
|
+
const group = A();
|
|
2503
|
+
const groupFirstAlt = group.body[0];
|
|
2504
|
+
group.parent = parent;
|
|
2505
|
+
groupFirstAlt.parent = group;
|
|
2506
|
+
body = body.filter((kid) => !negatedChildClasses.includes(kid));
|
|
2507
|
+
node.body = body;
|
|
2508
|
+
if (body.length) {
|
|
2509
|
+
node.parent = groupFirstAlt;
|
|
2510
|
+
groupFirstAlt.body.push(node);
|
|
2511
|
+
} else group.body.pop();
|
|
2512
|
+
negatedChildClasses.forEach((cc) => {
|
|
2513
|
+
const newAlt = b({ body: [cc] });
|
|
2514
|
+
cc.parent = newAlt;
|
|
2515
|
+
newAlt.parent = group;
|
|
2516
|
+
group.body.push(newAlt);
|
|
2517
|
+
});
|
|
2518
|
+
return gen(group);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
state.inCharClass = true;
|
|
2522
|
+
const result = genClass();
|
|
2523
|
+
state.inCharClass = false;
|
|
2524
|
+
return result;
|
|
2525
|
+
}
|
|
2526
|
+
const firstEl = body[0];
|
|
2527
|
+
if (kind === "union" && !negate && firstEl && ((!state.useFlagV || !state.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV) || !state.verbose && parent.kind === "intersection" && body.length === 1 && firstEl.type !== "CharacterClassRange")) return body.map(gen).join("");
|
|
2528
|
+
if (!state.useFlagV && parent.type === "CharacterClass") throw new Error("Uses nested character class in a way that requires min target ES2024");
|
|
2529
|
+
return genClass();
|
|
2530
|
+
},
|
|
2531
|
+
CharacterClassRange(node, state) {
|
|
2532
|
+
const min = node.min.value;
|
|
2533
|
+
const max = node.max.value;
|
|
2534
|
+
const escOpts = {
|
|
2535
|
+
escDigit: false,
|
|
2536
|
+
inCharClass: true,
|
|
2537
|
+
useFlagV: state.useFlagV
|
|
2538
|
+
};
|
|
2539
|
+
const minStr = getCharEscape(min, escOpts);
|
|
2540
|
+
const maxStr = getCharEscape(max, escOpts);
|
|
2541
|
+
const extraChars = /* @__PURE__ */ new Set();
|
|
2542
|
+
if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase) getCodePointRangesFromChars(getCasesOutsideCharClassRange(node)).forEach((value) => {
|
|
2543
|
+
extraChars.add(Array.isArray(value) ? `${getCharEscape(value[0], escOpts)}-${getCharEscape(value[1], escOpts)}` : getCharEscape(value, escOpts));
|
|
2544
|
+
});
|
|
2545
|
+
return `${minStr}-${maxStr}${[...extraChars].join("")}`;
|
|
2546
|
+
},
|
|
2547
|
+
CharacterSet({ kind, negate, value, key }, state) {
|
|
2548
|
+
if (kind === "dot") return state.currentFlags.dotAll ? state.appliedGlobalFlags.dotAll || state.useFlagMods ? "." : "[^]" : r`[^\n]`;
|
|
2549
|
+
if (kind === "digit") return negate ? r`\D` : r`\d`;
|
|
2550
|
+
if (kind === "property") {
|
|
2551
|
+
if (state.useAppliedIgnoreCase && state.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) throw new Error(`Unicode property "${value}" can't be case-insensitive when other chars have specific case`);
|
|
2552
|
+
return `${negate ? r`\P` : r`\p`}{${key ? `${key}=` : ""}${value}}`;
|
|
2553
|
+
}
|
|
2554
|
+
if (kind === "word") return negate ? r`\W` : r`\w`;
|
|
2555
|
+
throw new Error(`Unexpected character set kind "${kind}"`);
|
|
2556
|
+
},
|
|
2557
|
+
Flags(node, state) {
|
|
2558
|
+
return (state.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "");
|
|
2559
|
+
},
|
|
2560
|
+
Group({ atomic: atomic2, body, flags, parent }, state, gen) {
|
|
2561
|
+
const currentFlags = state.currentFlags;
|
|
2562
|
+
if (flags) state.currentFlags = getNewCurrentFlags(currentFlags, flags);
|
|
2563
|
+
const contents = body.map(gen).join("|");
|
|
2564
|
+
const result = !state.verbose && body.length === 1 && parent.type !== "Quantifier" && !atomic2 && (!state.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state.useFlagMods)}${contents})`;
|
|
2565
|
+
state.currentFlags = currentFlags;
|
|
2566
|
+
return result;
|
|
2567
|
+
},
|
|
2568
|
+
LookaroundAssertion({ body, kind, negate }, _, gen) {
|
|
2569
|
+
return `(?${`${kind === "lookahead" ? "" : "<"}${negate ? "!" : "="}`}${body.map(gen).join("|")})`;
|
|
2570
|
+
},
|
|
2571
|
+
Quantifier(node, _, gen) {
|
|
2572
|
+
return gen(node.body) + getQuantifierStr(node);
|
|
2573
|
+
},
|
|
2574
|
+
Subroutine({ isRecursive, ref }, state) {
|
|
2575
|
+
if (!isRecursive) throw new Error("Unexpected non-recursive subroutine in transformed AST");
|
|
2576
|
+
const limit = state.recursionLimit;
|
|
2577
|
+
return ref === 0 ? `(?R=${limit})` : r`\g<${ref}&R=${limit}>`;
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
var BaseEscapeChars = /* @__PURE__ */ new Set([
|
|
2581
|
+
"$",
|
|
2582
|
+
"(",
|
|
2583
|
+
")",
|
|
2584
|
+
"*",
|
|
2585
|
+
"+",
|
|
2586
|
+
".",
|
|
2587
|
+
"?",
|
|
2588
|
+
"[",
|
|
2589
|
+
"\\",
|
|
2590
|
+
"]",
|
|
2591
|
+
"^",
|
|
2592
|
+
"{",
|
|
2593
|
+
"|",
|
|
2594
|
+
"}"
|
|
2595
|
+
]);
|
|
2596
|
+
var CharClassEscapeChars = /* @__PURE__ */ new Set([
|
|
2597
|
+
"-",
|
|
2598
|
+
"\\",
|
|
2599
|
+
"]",
|
|
2600
|
+
"^",
|
|
2601
|
+
"["
|
|
2602
|
+
]);
|
|
2603
|
+
var CharClassEscapeCharsFlagV = /* @__PURE__ */ new Set([
|
|
2604
|
+
"(",
|
|
2605
|
+
")",
|
|
2606
|
+
"-",
|
|
2607
|
+
"/",
|
|
2608
|
+
"[",
|
|
2609
|
+
"\\",
|
|
2610
|
+
"]",
|
|
2611
|
+
"^",
|
|
2612
|
+
"{",
|
|
2613
|
+
"|",
|
|
2614
|
+
"}",
|
|
2615
|
+
"!",
|
|
2616
|
+
"#",
|
|
2617
|
+
"$",
|
|
2618
|
+
"%",
|
|
2619
|
+
"&",
|
|
2620
|
+
"*",
|
|
2621
|
+
"+",
|
|
2622
|
+
",",
|
|
2623
|
+
".",
|
|
2624
|
+
":",
|
|
2625
|
+
";",
|
|
2626
|
+
"<",
|
|
2627
|
+
"=",
|
|
2628
|
+
">",
|
|
2629
|
+
"?",
|
|
2630
|
+
"@",
|
|
2631
|
+
"`",
|
|
2632
|
+
"~"
|
|
2633
|
+
]);
|
|
2634
|
+
var CharCodeEscapeMap = /* @__PURE__ */ new Map([
|
|
2635
|
+
[9, r`\t`],
|
|
2636
|
+
[10, r`\n`],
|
|
2637
|
+
[11, r`\v`],
|
|
2638
|
+
[12, r`\f`],
|
|
2639
|
+
[13, r`\r`],
|
|
2640
|
+
[8232, r`\u2028`],
|
|
2641
|
+
[8233, r`\u2029`],
|
|
2642
|
+
[65279, r`\uFEFF`]
|
|
2643
|
+
]);
|
|
2644
|
+
var casedRe = /^\p{Cased}$/u;
|
|
2645
|
+
function charHasCase(char) {
|
|
2646
|
+
return casedRe.test(char);
|
|
2647
|
+
}
|
|
2648
|
+
function getCasesOutsideCharClassRange(node, options) {
|
|
2649
|
+
const firstOnly = !!options?.firstOnly;
|
|
2650
|
+
const min = node.min.value;
|
|
2651
|
+
const max = node.max.value;
|
|
2652
|
+
const found = [];
|
|
2653
|
+
if (min < 65 && (max === 65535 || max >= 131071) || min === 65536 && max >= 131071) return found;
|
|
2654
|
+
for (let i = min; i <= max; i++) {
|
|
2655
|
+
const char = cp(i);
|
|
2656
|
+
if (!charHasCase(char)) continue;
|
|
2657
|
+
const charsOutsideRange = getIgnoreCaseMatchChars(char).filter((caseOfChar) => {
|
|
2658
|
+
const num = caseOfChar.codePointAt(0);
|
|
2659
|
+
return num < min || num > max;
|
|
2660
|
+
});
|
|
2661
|
+
if (charsOutsideRange.length) {
|
|
2662
|
+
found.push(...charsOutsideRange);
|
|
2663
|
+
if (firstOnly) break;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
return found;
|
|
2667
|
+
}
|
|
2668
|
+
function getCharEscape(codePoint, { escDigit, inCharClass, useFlagV }) {
|
|
2669
|
+
if (CharCodeEscapeMap.has(codePoint)) return CharCodeEscapeMap.get(codePoint);
|
|
2670
|
+
if (codePoint < 32 || codePoint > 126 && codePoint < 160 || codePoint > 262143 || escDigit && isDigitCharCode(codePoint)) return codePoint > 255 ? `\\u{${codePoint.toString(16).toUpperCase()}}` : `\\x${codePoint.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
2671
|
+
const escapeChars = inCharClass ? useFlagV ? CharClassEscapeCharsFlagV : CharClassEscapeChars : BaseEscapeChars;
|
|
2672
|
+
const char = cp(codePoint);
|
|
2673
|
+
return (escapeChars.has(char) ? "\\" : "") + char;
|
|
2674
|
+
}
|
|
2675
|
+
function getCodePointRangesFromChars(chars) {
|
|
2676
|
+
const codePoints = chars.map((char) => char.codePointAt(0)).sort((a, b) => a - b);
|
|
2677
|
+
const values = [];
|
|
2678
|
+
let start = null;
|
|
2679
|
+
for (let i = 0; i < codePoints.length; i++) if (codePoints[i + 1] === codePoints[i] + 1) start ??= codePoints[i];
|
|
2680
|
+
else if (start === null) values.push(codePoints[i]);
|
|
2681
|
+
else {
|
|
2682
|
+
values.push([start, codePoints[i]]);
|
|
2683
|
+
start = null;
|
|
2684
|
+
}
|
|
2685
|
+
return values;
|
|
2686
|
+
}
|
|
2687
|
+
function getGroupPrefix(atomic2, flagMods, useFlagMods) {
|
|
2688
|
+
if (atomic2) return ">";
|
|
2689
|
+
let mods = "";
|
|
2690
|
+
if (flagMods && useFlagMods) {
|
|
2691
|
+
const { enable, disable } = flagMods;
|
|
2692
|
+
mods = (enable?.ignoreCase ? "i" : "") + (enable?.dotAll ? "s" : "") + (disable ? "-" : "") + (disable?.ignoreCase ? "i" : "") + (disable?.dotAll ? "s" : "");
|
|
2693
|
+
}
|
|
2694
|
+
return `${mods}:`;
|
|
2695
|
+
}
|
|
2696
|
+
function getQuantifierStr({ kind, max, min }) {
|
|
2697
|
+
let base;
|
|
2698
|
+
if (!min && max === 1) base = "?";
|
|
2699
|
+
else if (!min && max === Infinity) base = "*";
|
|
2700
|
+
else if (min === 1 && max === Infinity) base = "+";
|
|
2701
|
+
else if (min === max) base = `{${min}}`;
|
|
2702
|
+
else base = `{${min},${max === Infinity ? "" : max}}`;
|
|
2703
|
+
return base + {
|
|
2704
|
+
greedy: "",
|
|
2705
|
+
lazy: "?",
|
|
2706
|
+
possessive: "+"
|
|
2707
|
+
}[kind];
|
|
2708
|
+
}
|
|
2709
|
+
function isAnyGroup({ type }) {
|
|
2710
|
+
return type === "CapturingGroup" || type === "Group" || type === "LookaroundAssertion";
|
|
2711
|
+
}
|
|
2712
|
+
function isDigitCharCode(value) {
|
|
2713
|
+
return value > 47 && value < 58;
|
|
2714
|
+
}
|
|
2715
|
+
function isLiteralHyphen({ type, value }) {
|
|
2716
|
+
return type === "Character" && value === 45;
|
|
2717
|
+
}
|
|
2718
|
+
var EmulatedRegExp = class _EmulatedRegExp extends RegExp {
|
|
2719
|
+
/**
|
|
2720
|
+
@type {Map<number, {
|
|
2721
|
+
hidden?: true;
|
|
2722
|
+
transferTo?: number;
|
|
2723
|
+
}>}
|
|
2724
|
+
*/
|
|
2725
|
+
#captureMap = /* @__PURE__ */ new Map();
|
|
2726
|
+
/**
|
|
2727
|
+
@type {RegExp | EmulatedRegExp | null}
|
|
2728
|
+
*/
|
|
2729
|
+
#compiled = null;
|
|
2730
|
+
/**
|
|
2731
|
+
@type {string}
|
|
2732
|
+
*/
|
|
2733
|
+
#pattern;
|
|
2734
|
+
/**
|
|
2735
|
+
@type {Map<number, string>?}
|
|
2736
|
+
*/
|
|
2737
|
+
#nameMap = null;
|
|
2738
|
+
/**
|
|
2739
|
+
@type {string?}
|
|
2740
|
+
*/
|
|
2741
|
+
#strategy = null;
|
|
2742
|
+
/**
|
|
2743
|
+
Can be used to serialize the instance.
|
|
2744
|
+
@type {EmulatedRegExpOptions}
|
|
2745
|
+
*/
|
|
2746
|
+
rawOptions = {};
|
|
2747
|
+
get source() {
|
|
2748
|
+
return this.#pattern || "(?:)";
|
|
2749
|
+
}
|
|
2750
|
+
/**
|
|
2751
|
+
@overload
|
|
2752
|
+
@param {string} pattern
|
|
2753
|
+
@param {string} [flags]
|
|
2754
|
+
@param {EmulatedRegExpOptions} [options]
|
|
2755
|
+
*/
|
|
2756
|
+
/**
|
|
2757
|
+
@overload
|
|
2758
|
+
@param {EmulatedRegExp} pattern
|
|
2759
|
+
@param {string} [flags]
|
|
2760
|
+
*/
|
|
2761
|
+
constructor(pattern, flags, options) {
|
|
2762
|
+
const lazyCompile = !!options?.lazyCompile;
|
|
2763
|
+
if (pattern instanceof RegExp) {
|
|
2764
|
+
if (options) throw new Error("Cannot provide options when copying a regexp");
|
|
2765
|
+
const re = pattern;
|
|
2766
|
+
super(re, flags);
|
|
2767
|
+
this.#pattern = re.source;
|
|
2768
|
+
if (re instanceof _EmulatedRegExp) {
|
|
2769
|
+
this.#captureMap = re.#captureMap;
|
|
2770
|
+
this.#nameMap = re.#nameMap;
|
|
2771
|
+
this.#strategy = re.#strategy;
|
|
2772
|
+
this.rawOptions = re.rawOptions;
|
|
2773
|
+
}
|
|
2774
|
+
} else {
|
|
2775
|
+
const opts = {
|
|
2776
|
+
hiddenCaptures: [],
|
|
2777
|
+
strategy: null,
|
|
2778
|
+
transfers: [],
|
|
2779
|
+
...options
|
|
2780
|
+
};
|
|
2781
|
+
super(lazyCompile ? "" : pattern, flags);
|
|
2782
|
+
this.#pattern = pattern;
|
|
2783
|
+
this.#captureMap = createCaptureMap(opts.hiddenCaptures, opts.transfers);
|
|
2784
|
+
this.#strategy = opts.strategy;
|
|
2785
|
+
this.rawOptions = options ?? {};
|
|
2786
|
+
}
|
|
2787
|
+
if (!lazyCompile) this.#compiled = this;
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
Called internally by all String/RegExp methods that use regexes.
|
|
2791
|
+
@override
|
|
2792
|
+
@param {string} str
|
|
2793
|
+
@returns {RegExpExecArray?}
|
|
2794
|
+
*/
|
|
2795
|
+
exec(str) {
|
|
2796
|
+
if (!this.#compiled) {
|
|
2797
|
+
const { lazyCompile, ...rest } = this.rawOptions;
|
|
2798
|
+
this.#compiled = new _EmulatedRegExp(this.#pattern, this.flags, rest);
|
|
2799
|
+
}
|
|
2800
|
+
const useLastIndex = this.global || this.sticky;
|
|
2801
|
+
const pos = this.lastIndex;
|
|
2802
|
+
if (this.#strategy === "clip_search" && useLastIndex && pos) {
|
|
2803
|
+
this.lastIndex = 0;
|
|
2804
|
+
const match = this.#execCore(str.slice(pos));
|
|
2805
|
+
if (match) {
|
|
2806
|
+
adjustMatchDetailsForOffset(match, pos, str, this.hasIndices);
|
|
2807
|
+
this.lastIndex += pos;
|
|
2808
|
+
}
|
|
2809
|
+
return match;
|
|
2810
|
+
}
|
|
2811
|
+
return this.#execCore(str);
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
Adds support for hidden and transfer captures.
|
|
2815
|
+
@param {string} str
|
|
2816
|
+
@returns
|
|
2817
|
+
*/
|
|
2818
|
+
#execCore(str) {
|
|
2819
|
+
this.#compiled.lastIndex = this.lastIndex;
|
|
2820
|
+
const match = super.exec.call(this.#compiled, str);
|
|
2821
|
+
this.lastIndex = this.#compiled.lastIndex;
|
|
2822
|
+
if (!match || !this.#captureMap.size) return match;
|
|
2823
|
+
const matchCopy = [...match];
|
|
2824
|
+
match.length = 1;
|
|
2825
|
+
let indicesCopy;
|
|
2826
|
+
if (this.hasIndices) {
|
|
2827
|
+
indicesCopy = [...match.indices];
|
|
2828
|
+
match.indices.length = 1;
|
|
2829
|
+
}
|
|
2830
|
+
const mappedNums = [0];
|
|
2831
|
+
for (let i = 1; i < matchCopy.length; i++) {
|
|
2832
|
+
const { hidden, transferTo } = this.#captureMap.get(i) ?? {};
|
|
2833
|
+
if (hidden) mappedNums.push(null);
|
|
2834
|
+
else {
|
|
2835
|
+
mappedNums.push(match.length);
|
|
2836
|
+
match.push(matchCopy[i]);
|
|
2837
|
+
if (this.hasIndices) match.indices.push(indicesCopy[i]);
|
|
2838
|
+
}
|
|
2839
|
+
if (transferTo && matchCopy[i] !== void 0) {
|
|
2840
|
+
const to = mappedNums[transferTo];
|
|
2841
|
+
if (!to) throw new Error(`Invalid capture transfer to "${to}"`);
|
|
2842
|
+
match[to] = matchCopy[i];
|
|
2843
|
+
if (this.hasIndices) match.indices[to] = indicesCopy[i];
|
|
2844
|
+
if (match.groups) {
|
|
2845
|
+
if (!this.#nameMap) this.#nameMap = createNameMap(this.source);
|
|
2846
|
+
const name = this.#nameMap.get(transferTo);
|
|
2847
|
+
if (name) {
|
|
2848
|
+
match.groups[name] = matchCopy[i];
|
|
2849
|
+
if (this.hasIndices) match.indices.groups[name] = indicesCopy[i];
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
return match;
|
|
2855
|
+
}
|
|
2856
|
+
};
|
|
2857
|
+
function adjustMatchDetailsForOffset(match, offset, input, hasIndices) {
|
|
2858
|
+
match.index += offset;
|
|
2859
|
+
match.input = input;
|
|
2860
|
+
if (hasIndices) {
|
|
2861
|
+
const indices = match.indices;
|
|
2862
|
+
for (let i = 0; i < indices.length; i++) {
|
|
2863
|
+
const arr = indices[i];
|
|
2864
|
+
if (arr) indices[i] = [arr[0] + offset, arr[1] + offset];
|
|
2865
|
+
}
|
|
2866
|
+
const groupIndices = indices.groups;
|
|
2867
|
+
if (groupIndices) Object.keys(groupIndices).forEach((key) => {
|
|
2868
|
+
const arr = groupIndices[key];
|
|
2869
|
+
if (arr) groupIndices[key] = [arr[0] + offset, arr[1] + offset];
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
function createCaptureMap(hiddenCaptures, transfers) {
|
|
2874
|
+
const captureMap = /* @__PURE__ */ new Map();
|
|
2875
|
+
for (const num of hiddenCaptures) captureMap.set(num, { hidden: true });
|
|
2876
|
+
for (const [to, from] of transfers) for (const num of from) getOrInsert(captureMap, num, {}).transferTo = to;
|
|
2877
|
+
return captureMap;
|
|
2878
|
+
}
|
|
2879
|
+
function createNameMap(pattern) {
|
|
2880
|
+
const re = /(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu;
|
|
2881
|
+
const map = /* @__PURE__ */ new Map();
|
|
2882
|
+
let numCharClassesOpen = 0;
|
|
2883
|
+
let numCaptures = 0;
|
|
2884
|
+
let match;
|
|
2885
|
+
while (match = re.exec(pattern)) {
|
|
2886
|
+
const { 0: m, groups: { capture, name } } = match;
|
|
2887
|
+
if (m === "[") numCharClassesOpen++;
|
|
2888
|
+
else if (!numCharClassesOpen) {
|
|
2889
|
+
if (capture) {
|
|
2890
|
+
numCaptures++;
|
|
2891
|
+
if (name) map.set(numCaptures, name);
|
|
2892
|
+
}
|
|
2893
|
+
} else if (m === "]") numCharClassesOpen--;
|
|
2894
|
+
}
|
|
2895
|
+
return map;
|
|
2896
|
+
}
|
|
2897
|
+
function toRegExp(pattern, options) {
|
|
2898
|
+
const d = toRegExpDetails(pattern, options);
|
|
2899
|
+
if (d.options) return new EmulatedRegExp(d.pattern, d.flags, d.options);
|
|
2900
|
+
return new RegExp(d.pattern, d.flags);
|
|
2901
|
+
}
|
|
2902
|
+
function toRegExpDetails(pattern, options) {
|
|
2903
|
+
const opts = getOptions(options);
|
|
2904
|
+
const regexPlusAst = transform(J(pattern, {
|
|
2905
|
+
flags: opts.flags,
|
|
2906
|
+
normalizeUnknownPropertyNames: true,
|
|
2907
|
+
rules: {
|
|
2908
|
+
captureGroup: opts.rules.captureGroup,
|
|
2909
|
+
singleline: opts.rules.singleline
|
|
2910
|
+
},
|
|
2911
|
+
skipBackrefValidation: opts.rules.allowOrphanBackrefs,
|
|
2912
|
+
unicodePropertyMap: JsUnicodePropertyMap
|
|
2913
|
+
}), {
|
|
2914
|
+
accuracy: opts.accuracy,
|
|
2915
|
+
asciiWordBoundaries: opts.rules.asciiWordBoundaries,
|
|
2916
|
+
avoidSubclass: opts.avoidSubclass,
|
|
2917
|
+
bestEffortTarget: opts.target
|
|
2918
|
+
});
|
|
2919
|
+
const generated = generate(regexPlusAst, opts);
|
|
2920
|
+
const recursionResult = recursion(generated.pattern, {
|
|
2921
|
+
captureTransfers: generated._captureTransfers,
|
|
2922
|
+
hiddenCaptures: generated._hiddenCaptures,
|
|
2923
|
+
mode: "external"
|
|
2924
|
+
});
|
|
2925
|
+
const atomicResult = atomic(possessive(recursionResult.pattern).pattern, {
|
|
2926
|
+
captureTransfers: recursionResult.captureTransfers,
|
|
2927
|
+
hiddenCaptures: recursionResult.hiddenCaptures
|
|
2928
|
+
});
|
|
2929
|
+
const details = {
|
|
2930
|
+
pattern: atomicResult.pattern,
|
|
2931
|
+
flags: `${opts.hasIndices ? "d" : ""}${opts.global ? "g" : ""}${generated.flags}${generated.options.disable.v ? "u" : "v"}`
|
|
2932
|
+
};
|
|
2933
|
+
if (opts.avoidSubclass) {
|
|
2934
|
+
if (opts.lazyCompileLength !== Infinity) throw new Error("Lazy compilation requires subclass");
|
|
2935
|
+
} else {
|
|
2936
|
+
const hiddenCaptures = atomicResult.hiddenCaptures.sort((a, b) => a - b);
|
|
2937
|
+
const transfers = Array.from(atomicResult.captureTransfers);
|
|
2938
|
+
const strategy = regexPlusAst._strategy;
|
|
2939
|
+
const lazyCompile = details.pattern.length >= opts.lazyCompileLength;
|
|
2940
|
+
if (hiddenCaptures.length || transfers.length || strategy || lazyCompile) details.options = {
|
|
2941
|
+
...hiddenCaptures.length && { hiddenCaptures },
|
|
2942
|
+
...transfers.length && { transfers },
|
|
2943
|
+
...strategy && { strategy },
|
|
2944
|
+
...lazyCompile && { lazyCompile }
|
|
2945
|
+
};
|
|
2946
|
+
}
|
|
2947
|
+
return details;
|
|
2948
|
+
}
|
|
2949
|
+
//#endregion
|
|
2950
|
+
//#region ../../node_modules/@shikijs/engine-javascript/dist/shared/engine-javascript.hzpS1_41.mjs
|
|
2951
|
+
const MAX = 4294967295;
|
|
2952
|
+
var JavaScriptScanner = class {
|
|
2953
|
+
constructor(patterns, options = {}) {
|
|
2954
|
+
this.patterns = patterns;
|
|
2955
|
+
this.options = options;
|
|
2956
|
+
const { forgiving = false, cache, regexConstructor } = options;
|
|
2957
|
+
if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
|
|
2958
|
+
this.regexps = patterns.map((p) => {
|
|
2959
|
+
if (typeof p !== "string") return p;
|
|
2960
|
+
const cached = cache?.get(p);
|
|
2961
|
+
if (cached) {
|
|
2962
|
+
if (cached instanceof RegExp) return cached;
|
|
2963
|
+
if (forgiving) return null;
|
|
2964
|
+
throw cached;
|
|
2965
|
+
}
|
|
2966
|
+
try {
|
|
2967
|
+
const regex = regexConstructor(p);
|
|
2968
|
+
cache?.set(p, regex);
|
|
2969
|
+
return regex;
|
|
2970
|
+
} catch (e) {
|
|
2971
|
+
cache?.set(p, e);
|
|
2972
|
+
if (forgiving) return null;
|
|
2973
|
+
throw e;
|
|
2974
|
+
}
|
|
2975
|
+
});
|
|
2976
|
+
}
|
|
2977
|
+
regexps;
|
|
2978
|
+
findNextMatchSync(string, startPosition, _options) {
|
|
2979
|
+
const str = typeof string === "string" ? string : string.content;
|
|
2980
|
+
const pending = [];
|
|
2981
|
+
function toResult(index, match, offset = 0) {
|
|
2982
|
+
return {
|
|
2983
|
+
index,
|
|
2984
|
+
captureIndices: match.indices.map((indice) => {
|
|
2985
|
+
if (indice == null) return {
|
|
2986
|
+
start: MAX,
|
|
2987
|
+
end: MAX,
|
|
2988
|
+
length: 0
|
|
2989
|
+
};
|
|
2990
|
+
return {
|
|
2991
|
+
start: indice[0] + offset,
|
|
2992
|
+
end: indice[1] + offset,
|
|
2993
|
+
length: indice[1] - indice[0]
|
|
2994
|
+
};
|
|
2995
|
+
})
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
for (let i = 0; i < this.regexps.length; i++) {
|
|
2999
|
+
const regexp = this.regexps[i];
|
|
3000
|
+
if (!regexp) continue;
|
|
3001
|
+
try {
|
|
3002
|
+
regexp.lastIndex = startPosition;
|
|
3003
|
+
const match = regexp.exec(str);
|
|
3004
|
+
if (!match) continue;
|
|
3005
|
+
if (match.index === startPosition) return toResult(i, match, 0);
|
|
3006
|
+
pending.push([
|
|
3007
|
+
i,
|
|
3008
|
+
match,
|
|
3009
|
+
0
|
|
3010
|
+
]);
|
|
3011
|
+
} catch (e) {
|
|
3012
|
+
if (this.options.forgiving) continue;
|
|
3013
|
+
throw e;
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
if (pending.length) {
|
|
3017
|
+
const minIndex = Math.min(...pending.map((m) => m[1].index));
|
|
3018
|
+
for (const [i, match, offset] of pending) if (match.index === minIndex) return toResult(i, match, offset);
|
|
3019
|
+
}
|
|
3020
|
+
return null;
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
//#endregion
|
|
3024
|
+
//#region ../../node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
|
|
3025
|
+
function defaultJavaScriptRegexConstructor(pattern, options) {
|
|
3026
|
+
return toRegExp(pattern, {
|
|
3027
|
+
global: true,
|
|
3028
|
+
hasIndices: true,
|
|
3029
|
+
lazyCompileLength: 3e3,
|
|
3030
|
+
rules: {
|
|
3031
|
+
allowOrphanBackrefs: true,
|
|
3032
|
+
asciiWordBoundaries: true,
|
|
3033
|
+
captureGroup: true,
|
|
3034
|
+
recursionLimit: 5,
|
|
3035
|
+
singleline: true
|
|
3036
|
+
},
|
|
3037
|
+
...options
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
function createJavaScriptRegexEngine(options = {}) {
|
|
3041
|
+
const _options = Object.assign({
|
|
3042
|
+
target: "auto",
|
|
3043
|
+
cache: /* @__PURE__ */ new Map()
|
|
3044
|
+
}, options);
|
|
3045
|
+
_options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
|
|
3046
|
+
return {
|
|
3047
|
+
createScanner(patterns) {
|
|
3048
|
+
return new JavaScriptScanner(patterns, _options);
|
|
3049
|
+
},
|
|
3050
|
+
createString(s) {
|
|
3051
|
+
return { content: s };
|
|
3052
|
+
}
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
//#endregion
|
|
3056
|
+
export { createJavaScriptRegexEngine };
|
|
3057
|
+
|
|
3058
|
+
//# sourceMappingURL=engine-javascript-CjxD84Z_.mjs.map
|