@viji-dev/sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +70 -63
  2. package/bin/viji.js +9 -29
  3. package/dist/assets/artist-dts-BHUsvSI6.js +613 -0
  4. package/dist/assets/artist-dts-p5-Cyw8vmy_.js +736 -0
  5. package/dist/assets/core-CiQx3w0t.js +12 -0
  6. package/dist/assets/dark-plus-C3mMm8J8.js +1 -0
  7. package/dist/assets/docs-api-PBLtY4Ni.js +12381 -0
  8. package/dist/assets/engine-javascript-CXyY7cc8.js +141 -0
  9. package/dist/assets/essentia-wasm.web-0S-sW98u-CYV1l1zv.js +38 -0
  10. package/dist/assets/essentia.js-core.es-DnrJE0uR-DOSrF5_G.js +32 -0
  11. package/dist/assets/glsl-DMyvO4G4.js +1 -0
  12. package/dist/assets/index-BhFxsauQ.js +215 -0
  13. package/dist/assets/index-BqhVeA7U.css +1 -0
  14. package/dist/assets/index-T4TOjvD0.js +1 -0
  15. package/dist/assets/index-Wz9WqGqz.js +52 -0
  16. package/dist/assets/index-t24aGwla.js +1 -0
  17. package/dist/assets/javascript-wDzz0qaB.js +1 -0
  18. package/dist/assets/shader-uniforms-GdaUkQPK.js +1 -0
  19. package/dist/assets/typescript-BPQ3VLAy.js +1 -0
  20. package/dist/assets/viji.worker-CQSJ0SiO-ljtBlcNZ.js +27018 -0
  21. package/{index.html → dist/index.html} +2 -1
  22. package/package.json +31 -35
  23. package/src/cli/commands/build.js +50 -99
  24. package/src/cli/commands/create.js +49 -46
  25. package/src/cli/commands/dev.js +30 -97
  26. package/src/cli/server/dev-server.js +233 -0
  27. package/src/cli/server/scene-scanner.js +93 -0
  28. package/src/cli/server/vite-scene-plugin.d.ts +2 -0
  29. package/src/cli/server/vite-scene-plugin.js +134 -0
  30. package/src/cli/utils/cli-utils.js +29 -139
  31. package/src/cli/utils/scene-compiler.js +10 -17
  32. package/src/templates/scene-templates.js +85 -0
  33. package/.gitignore +0 -29
  34. package/eslint.config.js +0 -37
  35. package/postcss.config.js +0 -6
  36. package/scenes/audio-visualizer/main.js +0 -287
  37. package/scenes/core-demo/main.js +0 -532
  38. package/scenes/demo-scene/main.js +0 -619
  39. package/scenes/global.d.ts +0 -15
  40. package/scenes/particle-system/main.js +0 -349
  41. package/scenes/tsconfig.json +0 -12
  42. package/scenes/video-mirror/main.ts +0 -436
  43. package/src/App.css +0 -42
  44. package/src/App.tsx +0 -279
  45. package/src/cli/commands/init.js +0 -262
  46. package/src/components/SDKPage.tsx +0 -337
  47. package/src/components/core/CoreContainer.tsx +0 -126
  48. package/src/components/ui/DeviceSelectionList.tsx +0 -137
  49. package/src/components/ui/FPSCounter.tsx +0 -78
  50. package/src/components/ui/FileDropzonePanel.tsx +0 -120
  51. package/src/components/ui/FileListPanel.tsx +0 -285
  52. package/src/components/ui/InputExpansionPanel.tsx +0 -31
  53. package/src/components/ui/MediaPlayerControls.tsx +0 -191
  54. package/src/components/ui/MenuContainer.tsx +0 -71
  55. package/src/components/ui/ParametersMenu.tsx +0 -797
  56. package/src/components/ui/ProjectSwitcherMenu.tsx +0 -192
  57. package/src/components/ui/QuickInputControls.tsx +0 -542
  58. package/src/components/ui/SDKMenuSystem.tsx +0 -96
  59. package/src/components/ui/SettingsMenu.tsx +0 -346
  60. package/src/components/ui/SimpleInputControls.tsx +0 -137
  61. package/src/index.css +0 -68
  62. package/src/main.tsx +0 -10
  63. package/src/scenes-hmr.ts +0 -158
  64. package/src/services/project-filesystem.ts +0 -436
  65. package/src/stores/scene-player/index.ts +0 -3
  66. package/src/stores/scene-player/input-manager.store.ts +0 -1045
  67. package/src/stores/scene-player/scene-session.store.ts +0 -659
  68. package/src/styles/globals.css +0 -111
  69. package/src/templates/minimal-template.js +0 -11
  70. package/src/utils/debounce.js +0 -34
  71. package/src/vite-env.d.ts +0 -1
  72. package/tailwind.config.js +0 -18
  73. package/tsconfig.app.json +0 -27
  74. package/tsconfig.json +0 -27
  75. package/tsconfig.node.json +0 -27
  76. package/vite.config.ts +0 -54
  77. /package/{public → dist}/favicon.png +0 -0
@@ -0,0 +1,141 @@
1
+ var mr=class{regexps;constructor(e,r={}){this.patterns=e,this.options=r;const{forgiving:t=!1,cache:n,regexConstructor:a}=r;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(s=>{if(typeof s!="string")return s;const o=n?.get(s);if(o){if(o instanceof RegExp)return o;if(t)return null;throw o}try{const i=a(s);return n?.set(s,i),i}catch(i){if(n?.set(s,i),t)return null;throw i}})}findNextMatchSync(e,r,t){const n=typeof e=="string"?e:e.content,a=[];function s(o,i,u=0){return{index:o,captureIndices:i.indices.map(c=>c==null?{start:4294967295,end:4294967295,length:0}:{start:c[0]+u,end:c[1]+u,length:c[1]-c[0]})}}for(let o=0;o<this.regexps.length;o++){const i=this.regexps[o];if(i)try{i.lastIndex=r;const u=i.exec(n);if(!u)continue;if(u.index===r)return s(o,u,0);a.push([o,u,0])}catch(u){if(this.options.forgiving)continue;throw u}}if(a.length){const o=Math.min(...a.map(i=>i[1].index));for(const[i,u,c]of a)if(u.index===o)return s(i,u,c)}return null}};function H(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function yr(e,r,t){return e.has(r)||e.set(r,t),e.get(r)}const Ce=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),x=String.raw;function j(e,r){if(e==null)throw new Error(r??"Value expected");return e}const He=x`\[\^?`,je=`c.? | C(?:-.?)?|${x`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${x`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${x`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${x`o\{[^\}]*\}?`}|${x`\d{1,3}`}`,xe=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,K=new RegExp(x`
2
+ \\ (?:
3
+ ${je}
4
+ | [gk]<[^>]*>?
5
+ | [gk]'[^']*'?
6
+ | .
7
+ )
8
+ | \( (?:
9
+ \? (?:
10
+ [:=!>({]
11
+ | <[=!]
12
+ | <[^>]*>
13
+ | '[^']*'
14
+ | ~\|?
15
+ | #(?:[^)\\]|\\.?)*
16
+ | [^:)]*[:)]
17
+ )?
18
+ | \*[^\)]*\)?
19
+ )?
20
+ | (?:${xe.source})+
21
+ | ${He}
22
+ | .
23
+ `.replace(/\s+/g,""),"gsu"),ie=new RegExp(x`
24
+ \\ (?:
25
+ ${je}
26
+ | .
27
+ )
28
+ | \[:(?:\^?\p{Alpha}+|\^):\]
29
+ | ${He}
30
+ | &&
31
+ | .
32
+ `.replace(/\s+/g,""),"gsu");function br(e,r={}){const t={flags:"",...r,rules:{captureGroup:!1,singleline:!1,...r.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const n=Or(t.flags),a=[n.extended],s={captureGroup:t.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(l){a.push(l)},replaceCurrentModX(l){a[a.length-1]=l},singleline:t.rules.singleline};let o=[],i;for(K.lastIndex=0;i=K.exec(e);){const l=Cr(s,e,i[0],K.lastIndex);l.tokens?o.push(...l.tokens):l.token&&o.push(l.token),l.lastIndex!==void 0&&(K.lastIndex=l.lastIndex)}const u=[];let c=0;o.filter(l=>l.type==="GroupOpen").forEach(l=>{l.kind==="capturing"?l.number=++c:l.raw==="("&&u.push(l)}),c||u.forEach((l,f)=>{l.kind="capturing",l.number=f+1});const p=c||u.length;return{tokens:o.map(l=>l.type==="EscapedNumber"?Tr(l,p):l).flat(),flags:n}}function Cr(e,r,t,n){const[a,s]=t;if(t==="["||t==="[^"){const o=xr(r,t,n);return{tokens:o.tokens,lastIndex:o.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(s))return{token:Ie(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return{token:Nr(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return{token:Ze(t)}}if(s==="K")return{token:Qe("keep",t)};if(s==="N"||s==="R")return{token:U("newline",t,{negate:s==="N"})};if(s==="O")return{token:U("any",t)};if(s==="X")return{token:U("text_segment",t)};const o=Xe(t,{inCharClass:!1});return Array.isArray(o)?{tokens:o}:{token:o}}if(a==="("){if(s==="*")return{token:Pr(t)};if(t==="(?{")throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(r[n]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:n+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return{token:Gr(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,t==="("&&!e.captureGroup||t==="(?:")return{token:z("group",t)};if(t==="(?>")return{token:z("atomic",t)};if(t==="(?="||t==="(?!"||t==="(?<="||t==="(?<!")return{token:z(t[2]==="<"?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if(t==="("&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return{token:z("capturing",t,{...t!=="("&&{name:t.slice(3,-1)}})};if(t.startsWith("(?~")){if(t==="(?~|")throw new Error(`Unsupported absence function kind "${t}"`);return{token:z("absence_repeater",t)}}throw t==="(?("?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(t===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:vr(t)}}if(e.getCurrentModX()){if(t==="#"){const o=r.indexOf(`
33
+ `,n);return{lastIndex:o===-1?r.length:o}}if(/^\s$/.test(t)){const o=/\s+/y;return o.lastIndex=n,{lastIndex:o.exec(r)?o.lastIndex:n}}}if(t===".")return{token:U("dot",t)};if(t==="^"||t==="$"){const o=e.singleline?{"^":x`\A`,$:x`\Z`}[t]:t;return{token:Ie(o,t)}}return t==="|"?{token:$r(t)}:xe.test(t)?{tokens:Br(t)}:{token:L(H(t),t)}}function xr(e,r,t){const n=[Se(r[1]==="^",r)];let a=1,s;for(ie.lastIndex=t;s=ie.exec(e);){const o=s[0];if(o[0]==="["&&o[1]!==":")a++,n.push(Se(o[1]==="^",o));else if(o==="]"){if(n.at(-1).type==="CharacterClassOpen")n.push(L(93,o));else if(a--,n.push(Er(o)),!a)break}else{const i=kr(o);Array.isArray(i)?n.push(...i):n.push(i)}}return{tokens:n,lastIndex:ie.lastIndex||e.length}}function kr(e){if(e[0]==="\\")return Xe(e,{inCharClass:!0});if(e[0]==="["){const r=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!r||!Ce.has(r.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return U("posix",e,{value:r.groups.name,negate:!!r.groups.negate})}return e==="-"?Ar(e):e==="&&"?Ir(e):L(H(e),e)}function Xe(e,{inCharClass:r}){const t=e[1];if(t==="c"||t==="C")return Fr(e);if("dDhHsSwW".includes(t))return Rr(e);if(e.startsWith(x`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Ur(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const n=e.split(/\\x/).slice(1).map(o=>parseInt(o,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(n)),s=new TextEncoder;return[...a].map(o=>{const i=[...s.encode(o)].map(u=>`\\x${u.toString(16)}`).join("");return L(H(o),i)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return L(Dr(e),e);if(ve.has(t))return L(ve.get(t),e);if(/\d/.test(t))return Sr(r,e);if(e==="\\")throw new Error(x`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return L(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function $r(e){return{type:"Alternator",raw:e}}function Ie(e,r){return{type:"Assertion",kind:e,raw:r}}function Ze(e){return{type:"Backreference",raw:e}}function L(e,r){return{type:"Character",value:e,raw:r}}function Er(e){return{type:"CharacterClassClose",raw:e}}function Ar(e){return{type:"CharacterClassHyphen",raw:e}}function Ir(e){return{type:"CharacterClassIntersector",raw:e}}function Se(e,r){return{type:"CharacterClassOpen",negate:e,raw:r}}function U(e,r,t={}){return{type:"CharacterSet",kind:e,...t,raw:r}}function Qe(e,r,t={}){return e==="keep"?{type:"Directive",kind:e,raw:r}:{type:"Directive",kind:e,flags:j(t.flags),raw:r}}function Sr(e,r){return{type:"EscapedNumber",inCharClass:e,raw:r}}function vr(e){return{type:"GroupClose",raw:e}}function z(e,r,t={}){return{type:"GroupOpen",kind:e,...t,raw:r}}function _r(e,r,t,n){return{type:"NamedCallout",kind:e,tag:r,arguments:t,raw:n}}function Mr(e,r,t,n){return{type:"Quantifier",kind:e,min:r,max:t,raw:n}}function Nr(e){return{type:"Subroutine",raw:e}}const Lr=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),ve=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Fr(e){const r=e[1]==="c"?e[2]:e[3];if(!r||!/[A-Za-z]/.test(r))throw new Error(`Unsupported control character "${e}"`);return L(H(r.toUpperCase())-64,e)}function Gr(e,r){let{on:t,off:n}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;n??="";const a=(r.getCurrentModX()||t.includes("x"))&&!n.includes("x"),s=Me(t),o=Me(n),i={};if(s&&(i.enable=s),o&&(i.disable=o),e.endsWith(")"))return r.replaceCurrentModX(a),Qe("flags",e,{flags:i});if(e.endsWith(":"))return r.pushModX(a),r.numOpenGroups++,z("group",e,{...(s||o)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function Pr(e){const r=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!r)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:t,tag:n,args:a}=r.groups;if(!t)throw new Error(`Invalid named callout "${e}"`);if(n==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const s=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[o,i,u]=s,c=Lr.has(t)?t.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof o=="string")throw new Error(`Named callout argument must be a number "${o}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(s.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof o=="number"||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument three must be a tag or number "${u}"`);break;case"custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return _r(c,n??null,a?.split(",")??null,e)}function _e(e){let r=null,t,n;if(e[0]==="{"){const{minStr:a,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+a>o||s&&+s>o)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+a,n=s===void 0?+a:s===""?1/0:+s,t>n&&(r="possessive",[t,n]=[n,t]),e.endsWith("?")){if(r==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');r="lazy"}else r||(r="greedy")}else t=e[0]==="+"?1:0,n=e[0]==="?"?1:1/0,r=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Mr(r,t,n,e)}function Rr(e){const r=e[1].toLowerCase();return U({d:"digit",h:"hex",s:"space",w:"word"}[r],e,{negate:e[1]!==r})}function Ur(e){const{p:r,neg:t,value:n}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return U("property",e,{value:n,negate:r==="P"&&!t||r==="p"&&!!t})}function Me(e){const r={};return e.includes("i")&&(r.ignoreCase=!0),e.includes("m")&&(r.dotAll=!0),e.includes("x")&&(r.extended=!0),Object.keys(r).length?r:null}function Or(e){const r={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let t=0;t<e.length;t++){const n=e[t];if(!"imxDPSWy".includes(n))throw new Error(`Invalid flag "${n}"`);if(n==="y"){if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');r.textSegmentMode=e[t+2]==="g"?"grapheme":"word",t+=3;continue}r[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[n]]=!0}return r}function Dr(e){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}"`);const r=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(r,16)}function Tr(e,r){const{raw:t,inCharClass:n}=e,a=t.slice(1);if(!n&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=r))return[Ze(t)];const s=[],o=a.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){const u=o[i];let c;if(i===0&&u!=="8"&&u!=="9"){if(c=parseInt(u,8),c>127)throw new Error(x`Octal encoded byte above 177 unsupported "${t}"`)}else c=H(u);s.push(L(c,(i===0?"\\":"")+u))}return s}function Br(e){const r=[],t=new RegExp(xe,"gy");let n;for(;n=t.exec(e);){const a=n[0];if(a[0]==="{"){const s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(s){const{min:o,max:i}=s.groups;if(+o>+i&&a.endsWith("?")){t.lastIndex--,r.push(_e(a.slice(0,-1)));continue}}}r.push(_e(a))}return r}function qe(e,r){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const t=e.body[0];return!r||Object.keys(r).every(n=>r[n]===t[n])}function Vr(e){return zr.has(e.type)}const zr=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Je(e,r={}){const t={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r,rules:{captureGroup:!1,singleline:!1,...r.rules}},n=br(e,{flags:t.flags,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline}}),a=(f,g)=>{const d=n.tokens[s.nextIndex];switch(s.parent=f,s.nextIndex++,d.type){case"Alternator":return O();case"Assertion":return Wr(d);case"Backreference":return Hr(d,s);case"Character":return ne(d.value,{useLastValid:!!g.isCheckingRangeEnd});case"CharacterClassHyphen":return jr(d,s,g);case"CharacterClassOpen":return Xr(d,s,g);case"CharacterSet":return Zr(d,s);case"Directive":return et(d.kind,{flags:d.flags});case"GroupOpen":return Qr(d,s,g);case"NamedCallout":return tt(d.kind,d.tag,d.arguments);case"Quantifier":return qr(d,s);case"Subroutine":return Jr(d,s);default:throw new Error(`Unexpected token type "${d.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:t.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:t.skipBackrefValidation,skipLookbehindValidation:t.skipLookbehindValidation,skipPropertyNameValidation:t.skipPropertyNameValidation,subroutines:[],tokens:n.tokens,unicodePropertyMap:t.unicodePropertyMap,walk:a},o=st(rt(n.flags));let i=o.body[0];for(;s.nextIndex<n.tokens.length;){const f=a(i,{});f.type==="Alternative"?(o.body.push(f),i=f):i.body.push(f)}const{capturingGroups:u,hasNumberedRef:c,namedGroupsByName:p,subroutines:l}=s;if(c&&p.size&&!t.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:f}of l)if(typeof f=="number"){if(f>u.length)throw new Error("Subroutine uses a group number that's not defined");f&&(u[f-1].isSubroutined=!0)}else if(p.has(f)){if(p.get(f).length>1)throw new Error(x`Subroutine uses a duplicate group name "\g<${f}>"`);p.get(f)[0].isSubroutined=!0}else throw new Error(x`Subroutine uses a group name that's not defined "\g<${f}>"`);return o}function Wr({kind:e}){return ge(j({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===x`\B`||e===x`\Y`})}function Hr({raw:e},r){const t=/^\\k[<']/.test(e),n=t?e.slice(3,-1):e.slice(1),a=(s,o=!1)=>{const i=r.capturingGroups.length;let u=!1;if(s>i)if(r.skipBackrefValidation)u=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=!0,he(o?i+1-s:s,{orphan:u})};if(t){const s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);if(s)return a(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(n))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(n))throw new Error(`Group name not defined to the left "${e}"`);return he(n)}return a(+n)}function jr(e,r,t){const{tokens:n,walk:a}=r,s=r.parent,o=s.body.at(-1),i=n[r.nextIndex];if(!t.isCheckingRangeEnd&&o&&o.type!=="CharacterClass"&&o.type!=="CharacterClassRange"&&i&&i.type!=="CharacterClassOpen"&&i.type!=="CharacterClassClose"&&i.type!=="CharacterClassIntersector"){const u=a(s,{...t,isCheckingRangeEnd:!0});if(o.type==="Character"&&u.type==="Character")return s.body.pop(),Yr(o,u);throw new Error("Invalid character class range")}return ne(H("-"))}function Xr({negate:e},r,t){const{tokens:n,walk:a}=r,s=n[r.nextIndex],o=[re()];let i=Fe(s);for(;i.type!=="CharacterClassClose";){if(i.type==="CharacterClassIntersector")o.push(re()),r.nextIndex++;else{const c=o.at(-1);c.body.push(a(c,t))}i=Fe(n[r.nextIndex],s)}const u=re({negate:e});return o.length===1?u.body=o[0].body:(u.kind="intersection",u.body=o.map(c=>c.body.length===1?c.body[0]:c)),r.nextIndex++,u}function Zr({kind:e,negate:r,value:t},n){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:s,unicodePropertyMap:o}=n;if(e==="property"){const i=se(t);if(Ce.has(i)&&!o?.has(i))e="posix",t=i;else return W(t,{negate:r,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:s,unicodePropertyMap:o})}return e==="posix"?nt(t,{negate:r}):we(e,{negate:r})}function Qr(e,r,t){const{tokens:n,capturingGroups:a,namedGroupsByName:s,skipLookbehindValidation:o,walk:i}=r,u=at(e),c=u.type==="AbsenceFunction",p=Le(u),l=p&&u.negate;if(u.type==="CapturingGroup"&&(a.push(u),u.name&&yr(s,u.name,[]).push(u)),c&&t.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let f=Ge(n[r.nextIndex]);for(;f.type!=="GroupClose";){if(f.type==="Alternator")u.body.push(O()),r.nextIndex++;else{const g=u.body.at(-1),d=i(g,{...t,isInAbsenceFunction:t.isInAbsenceFunction||c,isInLookbehind:t.isInLookbehind||p,isInNegLookbehind:t.isInNegLookbehind||l});if(g.body.push(d),(p||t.isInLookbehind)&&!o){const w="Lookbehind includes a pattern not allowed by Oniguruma";if(l||t.isInNegLookbehind){if(Ne(d)||d.type==="CapturingGroup")throw new Error(w)}else if(Ne(d)||Le(d)&&d.negate)throw new Error(w)}}f=Ge(n[r.nextIndex])}return r.nextIndex++,u}function qr({kind:e,min:r,max:t},n){const a=n.parent,s=a.body.at(-1);if(!s||!Vr(s))throw new Error("Quantifier requires a repeatable token");const o=Ye(e,r,t,s);return a.body.pop(),o}function Jr({raw:e},r){const{capturingGroups:t,subroutines:n}=r;let a=e.slice(3,-1);const s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(s){const i=+s.groups.num,u=t.length;if(r.hasNumberedRef=!0,a={"":i,"+":u+i,"-":u+1-i}[s.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const o=er(a);return n.push(o),o}function Kr(e,r){return{type:"AbsenceFunction",kind:e,body:q(r?.body)}}function O(e){return{type:"Alternative",body:rr(e?.body)}}function ge(e,r){const t={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(t.negate=!!r?.negate),t}function he(e,r){const t=!!r?.orphan;return{type:"Backreference",ref:e,...t&&{orphan:t}}}function Ke(e,r){const t={name:void 0,isSubroutined:!1,...r};if(t.name!==void 0&&!ot(t.name))throw new Error(`Group name "${t.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...t.name&&{name:t.name},...t.isSubroutined&&{isSubroutined:t.isSubroutined},body:q(r?.body)}}function ne(e,r){const t={useLastValid:!1,...r};if(e>1114111){const n=e.toString(16);if(t.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${n}}"`):new Error(`Invalid code point out of range in JS "\\x{${n}}"`)}return{type:"Character",value:e}}function re(e){const r={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:r.kind,negate:r.negate,body:rr(e?.body)}}function Yr(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:r}}function we(e,r){const t=!!r?.negate,n={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(n.negate=t),(e==="text_segment"||e==="newline"&&!t)&&(n.variableLength=!0),n}function et(e,r={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:j(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function rt(e){return{type:"Flags",...e}}function v(e){const r=e?.atomic,t=e?.flags;if(r&&t)throw new Error("Atomic group cannot have flags");return{type:"Group",...r&&{atomic:r},...t&&{flags:t},body:q(e?.body)}}function R(e){const r={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:q(e?.body)}}function tt(e,r,t){return{type:"NamedCallout",kind:e,tag:r,arguments:t}}function nt(e,r){const t=!!r?.negate;if(!Ce.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:t}}function Ye(e,r,t,n){if(r>t)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:r,max:t,body:n}}function st(e,r){return{type:"Regex",body:q(r?.body),flags:e}}function er(e){return{type:"Subroutine",ref:e}}function W(e,r){const t={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r};let n=t.unicodePropertyMap?.get(se(e));if(!n){if(t.normalizeUnknownPropertyNames)n=it(e);else if(t.unicodePropertyMap&&!t.skipPropertyNameValidation)throw new Error(x`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:n??e,negate:t.negate}}function at({flags:e,kind:r,name:t,negate:n,number:a}){switch(r){case"absence_repeater":return Kr("repeater");case"atomic":return v({atomic:!0});case"capturing":return Ke(a,{name:t});case"group":return v({flags:e});case"lookahead":case"lookbehind":return R({behind:r==="lookbehind",negate:n});default:throw new Error(`Unexpected group kind "${r}"`)}}function q(e){if(e===void 0)e=[O()];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");return e}function rr(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function Ne(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Le(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function ot(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function it(e){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())}function se(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Fe(e,r){return j(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function Ge(e){return j(e,"Unclosed group")}function Z(e,r,t=null){function n(s,o){for(let i=0;i<s.length;i++){const u=a(s[i],o,i,s);i=Math.max(-1,i+u)}}function a(s,o=null,i=null,u=null){let c=0,p=!1;const l={node:s,parent:o,key:i,container:u,root:e,remove(){Y(u).splice(Math.max(0,B(i)+c),1),c--,p=!0},removeAllNextSiblings(){return Y(u).splice(B(i)+1)},removeAllPrevSiblings(){const y=B(i)+c;return c-=y,Y(u).splice(0,Math.max(0,y))},replaceWith(y,$={}){const E=!!$.traverse;u?u[Math.max(0,B(i)+c)]=y:j(o,"Can't replace root node")[i]=y,E&&a(y,o,i,u),p=!0},replaceWithMultiple(y,$={}){const E=!!$.traverse;if(Y(u).splice(Math.max(0,B(i)+c),1,...y),c+=y.length-1,E){let k=0;for(let A=0;A<y.length;A++)k+=a(y[A],o,B(i)+A+k,u)}p=!0},skip(){p=!0}},{type:f}=s,g=r["*"],d=r[f],w=typeof g=="function"?g:g?.enter,m=typeof d=="function"?d:d?.enter;if(w?.(l,t),m?.(l,t),!p)switch(f){case"AbsenceFunction":case"CapturingGroup":case"Group":n(s.body,s);break;case"Alternative":case"CharacterClass":n(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(s.min,s,"min"),a(s.max,s,"max");break;case"LookaroundAssertion":n(s.body,s);break;case"Quantifier":a(s.body,s,"body");break;case"Regex":n(s.body,s),a(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${f}"`)}return d?.exit?.(l,t),g?.exit?.(l,t),c}return a(e),e}function Y(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function B(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const ut=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function ct(e,r){for(let t=0;t<e.length;t++)e[t]>=r&&e[t]++}function lt(e,r,t,n){return e.slice(0,r)+n+e.slice(r+t.length)}const S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ke(e,r,t,n){const a=new RegExp(String.raw`${r}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1];let o=0,i="";for(const u of e.matchAll(a)){const{0:c,groups:{$skip:p}}=u;if(!p&&(!n||n===S.DEFAULT==!o)){t instanceof Function?i+=t(u,{context:o?S.CHAR_CLASS:S.DEFAULT,negated:s[s.length-1]}):i+=t;continue}c[0]==="["?(o++,s.push(c[1]==="^")):c==="]"&&o&&(o--,s.pop()),i+=c}return i}function tr(e,r,t,n){ke(e,r,t,n)}function pt(e,r,t=0,n){if(!new RegExp(r,"su").test(e))return null;const a=new RegExp(`${r}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=t;let s=0,o;for(;o=a.exec(e);){const{0:i,groups:{$skip:u}}=o;if(!u&&(!n||n===S.DEFAULT==!s))return o;i==="["?s++:i==="]"&&s&&s--,a.lastIndex==o.index&&a.lastIndex++}return null}function ee(e,r,t){return!!pt(e,r,0,t)}function ft(e,r){const t=/\\?./gsu;t.lastIndex=r;let n=e.length,a=0,s=1,o;for(;o=t.exec(e);){const[i]=o;if(i==="[")a++;else if(a)i==="]"&&a--;else if(i==="(")s++;else if(i===")"&&(s--,!s)){n=o.index;break}}return e.slice(r,n)}const Pe=new RegExp(String.raw`(?<noncapturingStart>${ut})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function dt(e,r){const t=r?.hiddenCaptures??[];let n=r?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:n,hiddenCaptures:t};const a="(?>",s="(?:(?=(",o=[0],i=[];let u=0,c=0,p=NaN,l;do{l=!1;let f=0,g=0,d=!1,w;for(Pe.lastIndex=Number.isNaN(p)?0:p+s.length;w=Pe.exec(e);){const{0:m,index:y,groups:{capturingStart:$,noncapturingStart:E}}=w;if(m==="[")f++;else if(f)m==="]"&&f--;else if(m===a&&!d)p=y,d=!0;else if(d&&E)g++;else if($)d?g++:(u++,o.push(u+c));else if(m===")"&&d){if(!g){c++;const k=u+c;if(e=`${e.slice(0,p)}${s}${e.slice(p+a.length,y)}))<$$${k}>)${e.slice(y+1)}`,l=!0,i.push(k),ct(t,k),n.size){const A=new Map;n.forEach((J,D)=>{A.set(D>=k?D+1:D,J.map(T=>T>=k?T+1:T))}),n=A}break}g--}}}while(l);return t.push(...i),e=ke(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:f,groups:{backrefNum:g,wrappedBackrefNum:d}})=>{if(g){const w=+g;if(w>o.length-1)throw new Error(`Backref "${f}" greater than number of captures`);return`\\${o[w]}`}return`\\${d}`},S.DEFAULT),{pattern:e,captureTransfers:n,hiddenCaptures:t}}const nr=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,ue=new RegExp(String.raw`
34
+ \\(?: \d+
35
+ | c[A-Za-z]
36
+ | [gk]<[^>]+>
37
+ | [pPu]\{[^\}]+\}
38
+ | u[A-Fa-f\d]{4}
39
+ | x[A-Fa-f\d]{2}
40
+ )
41
+ | \((?: \? (?: [:=!>]
42
+ | <(?:[=!]|[^>]+>)
43
+ | [A-Za-z\-]+:
44
+ | \(DEFINE\)
45
+ ))?
46
+ | (?<qBase>${nr})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
47
+ | \\?.
48
+ `.replace(/\s+/g,""),"gsu");function gt(e){if(!new RegExp(`${nr}\\+`).test(e))return{pattern:e};const r=[];let t=null,n=null,a="",s=0,o;for(ue.lastIndex=0;o=ue.exec(e);){const{0:i,index:u,groups:{qBase:c,qMod:p,invalidQ:l}}=o;if(i==="[")s||(n=u),s++;else if(i==="]")s?s--:n=null;else if(!s)if(p==="+"&&a&&!a.startsWith("(")){if(l)throw new Error(`Invalid quantifier "${i}"`);let f=-1;if(/^\{\d+\}$/.test(c))e=lt(e,u+c.length,p,"");else{if(a===")"||a==="]"){const g=a===")"?t:n;if(g===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,g)}(?>${e.slice(g,u)}${c})${e.slice(u+i.length)}`}else e=`${e.slice(0,u-a.length)}(?>${a}${c})${e.slice(u+i.length)}`;f+=4}ue.lastIndex+=f}else i[0]==="("?r.push(u):i===")"&&(t=r.length?r.pop():null);a=i}return{pattern:e}}const I=String.raw,ht=I`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,me=I`\(\?R=(?<rDepth>[^\)]+)\)|${ht}`,ae=I`\(\?<(?![=!])(?<captureName>[^>]+)>`,sr=I`${ae}|(?<unnamed>\()(?!\?)`,P=new RegExp(I`${ae}|${me}|\(\?|\\?.`,"gsu"),ce="Cannot use multiple overlapping recursions";function wt(e,r){const{hiddenCaptures:t,mode:n}={hiddenCaptures:[],mode:"plugin",...r};let a=r?.captureTransfers??new Map;if(!new RegExp(me,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:t};if(n==="plugin"&&ee(e,I`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const s=[],o=ee(e,I`\\[1-9]`,S.DEFAULT),i=new Map,u=[];let c=!1,p=0,l=0,f;for(P.lastIndex=0;f=P.exec(e);){const{0:g,groups:{captureName:d,rDepth:w,gRNameOrNum:m,gRDepth:y}}=f;if(g==="[")p++;else if(p)g==="]"&&p--;else if(w){if(Re(w),c)throw new Error(ce);if(o)throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const $=e.slice(0,f.index),E=e.slice(P.lastIndex);if(ee(E,me,S.DEFAULT))throw new Error(ce);const k=+w-1;e=Ue($,E,k,!1,t,s,l),a=De(a,$,k,s.length,0,l);break}else if(m){Re(y);let $=!1;for(const X of u)if(X.name===m||X.num===+m){if($=!0,X.hasRecursedWithin)throw new Error(ce);break}if(!$)throw new Error(I`Recursive \g cannot be used outside the referenced group "${n==="external"?m:I`\g<${m}&R=${y}>`}"`);const E=i.get(m),k=ft(e,E);if(o&&ee(k,I`${ae}|\((?!\?)`,S.DEFAULT))throw new Error(`${n==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const A=e.slice(E,f.index),J=k.slice(A.length+g.length),D=s.length,T=+y-1,Ae=Ue(A,J,T,!0,t,s,l);a=De(a,A,T,s.length-D,D,l);const hr=e.slice(0,E),wr=e.slice(E+k.length);e=`${hr}${Ae}${wr}`,P.lastIndex+=Ae.length-g.length-A.length-J.length,u.forEach(X=>X.hasRecursedWithin=!0),c=!0}else if(d)l++,i.set(String(l),P.lastIndex),i.set(d,P.lastIndex),u.push({num:l,name:d});else if(g[0]==="("){const $=g==="(";$&&(l++,i.set(String(l),P.lastIndex)),u.push($?{num:l}:{})}else g===")"&&u.pop()}return t.push(...s),{pattern:e,captureTransfers:a,hiddenCaptures:t}}function Re(e){const r=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(r);if(e=+e,e<2||e>100)throw new Error(r)}function Ue(e,r,t,n,a,s,o){const i=new Set;n&&tr(e+r,ae,({groups:{captureName:c}})=>{i.add(c)},S.DEFAULT);const u=[t,n?i:null,a,s,o];return`${e}${Oe(`(?:${e}`,"forward",...u)}(?:)${Oe(`${r})`,"backward",...u)}${r}`}function Oe(e,r,t,n,a,s,o){const u=p=>r==="forward"?p+2:t-p+2-1;let c="";for(let p=0;p<t;p++){const l=u(p);c+=ke(e,I`${sr}|\\k<(?<backref>[^>]+)>`,({0:f,groups:{captureName:g,unnamed:d,backref:w}})=>{if(w&&n&&!n.has(w))return f;const m=`_$${l}`;if(d||g){const y=o+s.length+1;return s.push(y),mt(a,y),d?f:`(?<${g}${m}>`}return I`\k<${w}${m}>`},S.DEFAULT)}return c}function mt(e,r){for(let t=0;t<e.length;t++)e[t]>=r&&e[t]++}function De(e,r,t,n,a,s){if(e.size&&n){let o=0;tr(r,sr,()=>o++,S.DEFAULT);const i=s-o+a,u=new Map;return e.forEach((c,p)=>{const l=(n-o*t)/t,f=o*t,g=p>i+o?p+n:p,d=[];for(const w of c)if(w<=i)d.push(w);else if(w>i+o+l)d.push(w+n);else if(w<=i+o)for(let m=0;m<=t;m++)d.push(w+o*m);else for(let m=0;m<=t;m++)d.push(w+f+l*m);u.set(g,d)}),u}return e}var C=String.fromCodePoint,h=String.raw,_={},oe=globalThis.RegExp;_.flagGroups=(()=>{try{new oe("(?i:)")}catch{return!1}return!0})();_.unicodeSets=(()=>{try{new oe("[[]]","v")}catch{return!1}return!0})();_.bugFlagVLiteralHyphenIsRange=_.unicodeSets?(()=>{try{new oe(h`[\d\-a]`,"v")}catch{return!0}return!1})():!1;_.bugNestedClassIgnoresNegation=_.unicodeSets&&new oe("[[^a]]","v").test("a");function te(e,{enable:r,disable:t}){return{dotAll:!t?.dotAll&&!!(r?.dotAll||e.dotAll),ignoreCase:!t?.ignoreCase&&!!(r?.ignoreCase||e.ignoreCase)}}function Q(e,r,t){return e.has(r)||e.set(r,t),e.get(r)}function ye(e,r){return Te[e]>=Te[r]}function yt(e,r){if(e==null)throw new Error(r??"Value expected");return e}var Te={ES2025:2025,ES2024:2024,ES2018:2018},bt={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ar(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!bt[e.target])throw new Error(`Unexpected target "${e.target}"`);const r={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return r.target==="auto"&&(r.target=_.flagGroups?"ES2025":_.unicodeSets?"ES2024":"ES2018"),r}var Ct="[ -\r ]",xt=new Set([C(304),C(305)]),M=h`[\p{L}\p{M}\p{N}\p{Pc}]`;function or(e){if(xt.has(e))return[e];const r=new Set,t=e.toLowerCase(),n=t.toUpperCase(),a=Et.get(t),s=kt.get(t),o=$t.get(t);return[...n].length===1&&r.add(n),o&&r.add(o),a&&r.add(a),r.add(t),s&&r.add(s),[...r]}var $e=new Map(`C Other
49
+ Cc Control cntrl
50
+ Cf Format
51
+ Cn Unassigned
52
+ Co Private_Use
53
+ Cs Surrogate
54
+ L Letter
55
+ LC Cased_Letter
56
+ Ll Lowercase_Letter
57
+ Lm Modifier_Letter
58
+ Lo Other_Letter
59
+ Lt Titlecase_Letter
60
+ Lu Uppercase_Letter
61
+ M Mark Combining_Mark
62
+ Mc Spacing_Mark
63
+ Me Enclosing_Mark
64
+ Mn Nonspacing_Mark
65
+ N Number
66
+ Nd Decimal_Number digit
67
+ Nl Letter_Number
68
+ No Other_Number
69
+ P Punctuation punct
70
+ Pc Connector_Punctuation
71
+ Pd Dash_Punctuation
72
+ Pe Close_Punctuation
73
+ Pf Final_Punctuation
74
+ Pi Initial_Punctuation
75
+ Po Other_Punctuation
76
+ Ps Open_Punctuation
77
+ S Symbol
78
+ Sc Currency_Symbol
79
+ Sk Modifier_Symbol
80
+ Sm Math_Symbol
81
+ So Other_Symbol
82
+ Z Separator
83
+ Zl Line_Separator
84
+ Zp Paragraph_Separator
85
+ Zs Space_Separator
86
+ ASCII
87
+ ASCII_Hex_Digit AHex
88
+ Alphabetic Alpha
89
+ Any
90
+ Assigned
91
+ Bidi_Control Bidi_C
92
+ Bidi_Mirrored Bidi_M
93
+ Case_Ignorable CI
94
+ Cased
95
+ Changes_When_Casefolded CWCF
96
+ Changes_When_Casemapped CWCM
97
+ Changes_When_Lowercased CWL
98
+ Changes_When_NFKC_Casefolded CWKCF
99
+ Changes_When_Titlecased CWT
100
+ Changes_When_Uppercased CWU
101
+ Dash
102
+ Default_Ignorable_Code_Point DI
103
+ Deprecated Dep
104
+ Diacritic Dia
105
+ Emoji
106
+ Emoji_Component EComp
107
+ Emoji_Modifier EMod
108
+ Emoji_Modifier_Base EBase
109
+ Emoji_Presentation EPres
110
+ Extended_Pictographic ExtPict
111
+ Extender Ext
112
+ Grapheme_Base Gr_Base
113
+ Grapheme_Extend Gr_Ext
114
+ Hex_Digit Hex
115
+ IDS_Binary_Operator IDSB
116
+ IDS_Trinary_Operator IDST
117
+ ID_Continue IDC
118
+ ID_Start IDS
119
+ Ideographic Ideo
120
+ Join_Control Join_C
121
+ Logical_Order_Exception LOE
122
+ Lowercase Lower
123
+ Math
124
+ Noncharacter_Code_Point NChar
125
+ Pattern_Syntax Pat_Syn
126
+ Pattern_White_Space Pat_WS
127
+ Quotation_Mark QMark
128
+ Radical
129
+ Regional_Indicator RI
130
+ Sentence_Terminal STerm
131
+ Soft_Dotted SD
132
+ Terminal_Punctuation Term
133
+ Unified_Ideograph UIdeo
134
+ Uppercase Upper
135
+ Variation_Selector VS
136
+ White_Space space
137
+ XID_Continue XIDC
138
+ XID_Start XIDS`.split(/\s/).map(e=>[se(e),e])),kt=new Map([["s",C(383)],[C(383),"s"]]),$t=new Map([[C(223),C(7838)],[C(107),C(8490)],[C(229),C(8491)],[C(969),C(8486)]]),Et=new Map([F(453),F(456),F(459),F(498),...le(8072,8079),...le(8088,8095),...le(8104,8111),F(8124),F(8140),F(8188)]),At=new Map([["alnum",h`[\p{Alpha}\p{Nd}]`],["alpha",h`\p{Alpha}`],["ascii",h`\p{ASCII}`],["blank",h`[\p{Zs}\t]`],["cntrl",h`\p{Cc}`],["digit",h`\p{Nd}`],["graph",h`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",h`\p{Lower}`],["print",h`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",h`[\p{P}\p{S}]`],["space",h`\p{space}`],["upper",h`\p{Upper}`],["word",h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",h`\p{AHex}`]]);function It(e,r){const t=[];for(let n=e;n<=r;n++)t.push(n);return t}function F(e){const r=C(e);return[r.toLowerCase(),r]}function le(e,r){return It(e,r).map(t=>F(t))}var ir=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function St(e,r){const t={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...r};ur(e);const n={accuracy:t.accuracy,asciiWordBoundaries:t.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ye(t.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Z(e,vt,n);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:n.subroutineRefMap};Z(e,_t,s);const o={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return Z(e,Mt,o),e._originMap=s.groupOriginByCopy,e._strategy=n.strategy,e}var vt={AbsenceFunction({node:e,parent:r,replaceWith:t}){const{body:n,kind:a}=e;if(a==="repeater"){const s=v();s.body[0].body.push(R({negate:!0,body:n}),W("Any"));const o=v();o.body[0].body.push(Ye("greedy",0,1/0,s)),t(b(o,r),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:r,key:t},{flagDirectivesByAlt:n}){const a=e.body.filter(s=>s.kind==="flags");for(let s=t+1;s<r.body.length;s++){const o=r.body[s];Q(n,o,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:r}){if(r.get(e)?.length){const t=lr(r.get(e));if(t){const n=v({flags:t});n.body[0].body=e.body,e.body=[b(n,e)]}}}},Assertion({node:e,parent:r,key:t,container:n,root:a,remove:s,replaceWith:o},i){const{kind:u,negate:c}=e,{asciiWordBoundaries:p,avoidSubclass:l,supportedGNodes:f,wordIsAscii:g}=i;if(u==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(u==="line_end")o(b(R({body:[O({body:[ge("string_end")]}),O({body:[ne(10)]})]}),r));else if(u==="line_start")o(b(N(h`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),r));else if(u==="search_start")if(f.has(e))a.flags.sticky=!0,s();else{const d=n[t-1];if(d&&Rt(d))o(b(R({negate:!0}),r));else{if(l)throw new Error(h`Uses "\G" in a way that requires a subclass`);o(G(ge("string_start"),r)),i.strategy="clip_search"}}else if(!(u==="string_end"||u==="string_start"))if(u==="string_end_newline")o(b(N(h`(?=\n?\z)`),r));else if(u==="word_boundary"){if(!g&&!p){const d=`(?:(?<=${M})(?!${M})|(?<!${M})(?=${M}))`,w=`(?:(?<=${M})(?=${M})|(?<!${M})(?!${M}))`;o(b(N(c?w:d),r))}}else throw new Error(`Unexpected assertion kind "${u}"`)},Backreference({node:e},{jsGroupNameMap:r}){let{ref:t}=e;typeof t=="string"&&!fe(t)&&(t=pe(t,r),e.ref=t)},CapturingGroup({node:e},{jsGroupNameMap:r,subroutineRefMap:t}){let{name:n}=e;n&&!fe(n)&&(n=pe(n,r),e.name=n),t.set(e.number,e),n&&t.set(n,e)},CharacterClassRange({node:e,parent:r,replaceWith:t}){if(r.kind==="intersection"){const n=re({body:[e]});t(b(n,r),{traverse:!0})}},CharacterSet({node:e,parent:r,replaceWith:t},{accuracy:n,minTargetEs2024:a,digitIsAscii:s,spaceIsAscii:o,wordIsAscii:i}){const{kind:u,negate:c,value:p}=e;if(s&&(u==="digit"||p==="digit")){t(G(we("digit",{negate:c}),r));return}if(o&&(u==="space"||p==="space")){t(b(de(N(Ct),c),r));return}if(i&&(u==="word"||p==="word")){t(G(we("word",{negate:c}),r));return}if(u==="any")t(G(W("Any"),r));else if(u==="digit")t(G(W("Nd",{negate:c}),r));else if(u!=="dot")if(u==="text_segment"){if(n==="strict")throw new Error(h`Use of "\X" requires non-strict accuracy`);const l="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=h`\p{RI}{2}|${l}(?:\u200D${l})*`;t(b(N(h`(?>\r\n|${a?h`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),r))}else if(u==="hex")t(G(W("AHex",{negate:c}),r));else if(u==="newline")t(b(N(c?`[^
139
+ ]`:`(?>\r
140
+ ?|[
141
+ \v\f…\u2028\u2029])`),r));else if(u==="posix")if(!a&&(p==="graph"||p==="print")){if(n==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let l={graph:"!-~",print:" -~"}[p];c&&(l=`\0-${C(l.codePointAt(0)-1)}${C(l.codePointAt(2)+1)}-􏿿`),t(b(N(`[${l}]`),r))}else t(b(de(N(At.get(p)),c),r));else if(u==="property")$e.has(se(p))||(e.key="sc");else if(u==="space")t(G(W("space",{negate:c}),r));else if(u==="word")t(b(de(N(M),c),r));else throw new Error(`Unexpected character set kind "${u}"`)},Directive({node:e,parent:r,root:t,remove:n,replaceWith:a,removeAllPrevSiblings:s,removeAllNextSiblings:o}){const{kind:i,flags:u}=e;if(i==="flags")if(!u.enable&&!u.disable)n();else{const c=v({flags:u});c.body[0].body=o(),a(b(c,r),{traverse:!0})}else if(i==="keep"){const c=t.body[0],l=t.body.length===1&&qe(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:t;if(r.parent!==l||l.body.length>1)throw new Error(h`Uses "\K" in a way that's unsupported`);const f=R({behind:!0});f.body[0].body=s(),a(b(f,r))}else throw new Error(`Unexpected directive kind "${i}"`)},Flags({node:e,parent:r}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),r.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:r,disable:t}=e.flags;r?.extended&&delete r.extended,t?.extended&&delete t.extended,r?.dotAll&&t?.dotAll&&delete r.dotAll,r?.ignoreCase&&t?.ignoreCase&&delete r.ignoreCase,r&&!Object.keys(r).length&&delete e.flags.enable,t&&!Object.keys(t).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},r){const{kind:t}=e;t==="lookbehind"&&(r.passedLookbehind=!0)},NamedCallout({node:e,parent:r,replaceWith:t}){const{kind:n}=e;if(n==="fail")t(b(R({negate:!0}),r));else throw new Error(`Unsupported named callout "(*${n.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const r=v();r.body[0].body.push(e.body),e.body=b(r,e)}},Regex:{enter({node:e},{supportedGNodes:r}){const t=[];let n=!1,a=!1;for(const s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{const o=fr(s.body);o?(n=!0,Array.isArray(o)?t.push(...o):t.push(o)):a=!0}n&&!a&&t.forEach(s=>r.add(s))},exit(e,{accuracy:r,passedLookbehind:t,strategy:n}){if(r==="strict"&&t&&n)throw new Error(h`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:r}){let{ref:t}=e;typeof t=="string"&&!fe(t)&&(t=pe(t,r),e.ref=t)}},_t={Backreference({node:e},{multiplexCapturesToLeftByRef:r,reffedNodesByReferencer:t}){const{orphan:n,ref:a}=e;n||t.set(e,[...r.get(a).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:r,replaceWith:t,skip:n},{groupOriginByCopy:a,groupsByName:s,multiplexCapturesToLeftByRef:o,openRefs:i,reffedNodesByReferencer:u}){const c=a.get(e);if(c&&i.has(e.number)){const l=G(Be(e.number),r);u.set(l,i.get(e.number)),t(l);return}i.set(e.number,e),o.set(e.number,[]),e.name&&Q(o,e.name,[]);const p=o.get(e.name??e.number);for(let l=0;l<p.length;l++){const f=p[l];if(c===f.node||c&&c===f.origin||e===f.origin){p.splice(l,1);break}}if(o.get(e.number).push({node:e,origin:c}),e.name&&o.get(e.name).push({node:e,origin:c}),e.name){const l=Q(s,e.name,new Map);let f=!1;if(c)f=!0;else for(const g of l.values())if(!g.hasDuplicateNameToRemove){f=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}},exit({node:e},{openRefs:r}){r.delete(e.number)}},Group:{enter({node:e},r){r.prevFlags=r.currentFlags,e.flags&&(r.currentFlags=te(r.currentFlags,e.flags))},exit(e,r){r.currentFlags=r.prevFlags}},Subroutine({node:e,parent:r,replaceWith:t},n){const{isRecursive:a,ref:s}=e;if(a){let p=r;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===s||p.number===s)););n.reffedNodesByReferencer.set(e,p);return}const o=n.subroutineRefMap.get(s),i=s===0,u=i?Be(0):cr(o,n.groupOriginByCopy,null);let c=u;if(!i){const p=lr(Ft(o,f=>f.type==="Group"&&!!f.flags)),l=p?te(n.globalFlags,p):n.globalFlags;Nt(l,n.currentFlags)||(c=v({flags:Gt(l)}),c.body[0].body.push(u))}t(b(c,r),{traverse:!i})}},Mt={Backreference({node:e,parent:r,replaceWith:t},n){if(e.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,e.ref);return}const s=n.reffedNodesByReferencer.get(e).filter(o=>Lt(o,e));if(!s.length)t(b(R({negate:!0}),r));else if(s.length>1){const o=v({atomic:!0,body:s.reverse().map(i=>O({body:[he(i.number)]}))});t(b(o,r))}else e.ref=s[0].number},CapturingGroup({node:e},r){e.number=++r.numCapturesToLeft,e.name&&r.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},r){const t=Math.max(r.highestOrphanBackref-r.numCapturesToLeft,0);for(let n=0;n<t;n++){const a=Ke();e.body.at(-1).body.push(a)}}},Subroutine({node:e},r){!e.isRecursive||e.ref===0||(e.ref=r.reffedNodesByReferencer.get(e).number)}};function ur(e){Z(e,{"*"({node:r,parent:t}){r.parent=t}})}function Nt(e,r){return e.dotAll===r.dotAll&&e.ignoreCase===r.ignoreCase}function Lt(e,r){let t=r;do{if(t.type==="Regex")return!1;if(t.type==="Alternative")continue;if(t===e)return!1;const n=pr(t.parent);for(const a of n){if(a===t)break;if(a===e||dr(a,e))return!0}}while(t=t.parent);throw new Error("Unexpected path")}function cr(e,r,t,n){const a=Array.isArray(e)?[]:{};for(const[s,o]of Object.entries(e))s==="parent"?a.parent=Array.isArray(t)?n:t:o&&typeof o=="object"?a[s]=cr(o,r,a,t):(s==="type"&&o==="CapturingGroup"&&r.set(a,r.get(e)??e),a[s]=o);return a}function Be(e){const r=er(e);return r.isRecursive=!0,r}function Ft(e,r){const t=[];for(;e=e.parent;)(!r||r(e))&&t.push(e);return t}function pe(e,r){if(r.has(e))return r.get(e);const t=`$${r.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return r.set(e,t),t}function lr(e){const r=["dotAll","ignoreCase"],t={enable:{},disable:{}};return e.forEach(({flags:n})=>{r.forEach(a=>{n.enable?.[a]&&(delete t.disable[a],t.enable[a]=!0),n.disable?.[a]&&(t.disable[a]=!0)})}),Object.keys(t.enable).length||delete t.enable,Object.keys(t.disable).length||delete t.disable,t.enable||t.disable?t:null}function Gt({dotAll:e,ignoreCase:r}){const t={};return(e||r)&&(t.enable={},e&&(t.enable.dotAll=!0),r&&(t.enable.ignoreCase=!0)),(!e||!r)&&(t.disable={},!e&&(t.disable.dotAll=!0),!r&&(t.disable.ignoreCase=!0)),t}function pr(e){if(!e)throw new Error("Node expected");const{body:r}=e;return Array.isArray(r)?r:r?[r]:null}function fr(e){const r=e.find(t=>t.kind==="search_start"||Ut(t,{negate:!1})||!Pt(t));if(!r)return null;if(r.kind==="search_start")return r;if(r.type==="LookaroundAssertion")return r.body[0].body[0];if(r.type==="CapturingGroup"||r.type==="Group"){const t=[];for(const n of r.body){const a=fr(n.body);if(!a)return null;Array.isArray(a)?t.push(...a):t.push(a)}return t}return null}function dr(e,r){const t=pr(e)??[];for(const n of t)if(n===r||dr(n,r))return!0;return!1}function Pt({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Rt(e){const r=["Character","CharacterClass","CharacterSet"];return r.includes(e.type)||e.type==="Quantifier"&&e.min&&r.includes(e.body.type)}function Ut(e,r){const t={negate:null,...r};return e.type==="LookaroundAssertion"&&(t.negate===null||e.negate===t.negate)&&e.body.length===1&&qe(e.body[0],{type:"Assertion",kind:"search_start"})}function fe(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function N(e,r){const n=Je(e,{...r,unicodePropertyMap:$e}).body;return n.length>1||n[0].body.length>1?v({body:n}):n[0].body[0]}function de(e,r){return e.negate=r,e}function G(e,r){return e.parent=r,e}function b(e,r){return ur(e),e.parent=r,e}function Ot(e,r){const t=ar(r),n=ye(t.target,"ES2024"),a=ye(t.target,"ES2025"),s=t.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,i=null;if(!a){const g=[e.flags.ignoreCase];Z(e,Dt,{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(d){g.push(d)},setHasCasedChar(){g.at(-1)?o=!0:i=!0}})}const u={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)};let c=e;const p={accuracy:t.accuracy,appliedGlobalFlags:u,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!a&&o&&i),useFlagMods:a,useFlagV:n,verbose:t.verbose};function l(g){return p.lastNode=c,c=g,yt(Tt[g.type],`Unexpected node type "${g.type}"`)(g,p,l)}const f={pattern:e.body.map(l).join("|"),flags:l(e.flags),options:{...e.options}};return n||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],p.captureMap.forEach((g,d)=>{g.hidden&&f._hiddenCaptures.push(d),g.transferTo&&Q(f._captureTransfers,g.transferTo,[]).push(d)}),f}var Dt={"*":{enter({node:e},r){if(ze(e)){const t=r.getCurrentModI();r.pushModI(e.flags?te({ignoreCase:t},e.flags).ignoreCase:t)}},exit({node:e},r){ze(e)&&r.popModI()}},Backreference(e,r){r.setHasCasedChar()},Character({node:e},r){Ee(C(e.value))&&r.setHasCasedChar()},CharacterClassRange({node:e,skip:r},t){r(),gr(e,{firstOnly:!0}).length&&t.setHasCasedChar()},CharacterSet({node:e},r){e.kind==="property"&&ir.has(e.value)&&r.setHasCasedChar()}},Tt={Alternative({body:e},r,t){return e.map(t).join("")},Assertion({kind:e,negate:r}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return r?h`\B`:h`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},r){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!r.useFlagMods&&r.accuracy==="strict"&&r.currentFlags.ignoreCase&&!r.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,r,t){const{body:n,name:a,number:s}=e,o={ignoreCase:r.currentFlags.ignoreCase},i=r.originMap.get(e);return i&&(o.hidden=!0,s>i.number&&(o.transferTo=i.number)),r.captureMap.set(s,o),`(${a?`?<${a}>`:""}${n.map(t).join("|")})`},Character({value:e},r){const t=C(e),n=V(e,{escDigit:r.lastNode.type==="Backreference",inCharClass:r.inCharClass,useFlagV:r.useFlagV});if(n!==t)return n;if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase&&Ee(t)){const a=or(t);return r.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return t},CharacterClass(e,r,t){const{kind:n,negate:a,parent:s}=e;let{body:o}=e;if(n==="intersection"&&!r.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");_.bugFlagVLiteralHyphenIsRange&&r.useFlagV&&o.some(We)&&(o=[ne(45),...o.filter(c=>!We(c))]);const i=()=>`[${a?"^":""}${o.map(t).join(n==="intersection"?"&&":"")}]`;if(!r.inCharClass){if((!r.useFlagV||_.bugNestedClassIgnoresNegation)&&!a){const p=o.filter(l=>l.type==="CharacterClass"&&l.kind==="union"&&l.negate);if(p.length){const l=v(),f=l.body[0];return l.parent=s,f.parent=l,o=o.filter(g=>!p.includes(g)),e.body=o,o.length?(e.parent=f,f.body.push(e)):l.body.pop(),p.forEach(g=>{const d=O({body:[g]});g.parent=d,d.parent=l,l.body.push(d)}),t(l)}}r.inCharClass=!0;const c=i();return r.inCharClass=!1,c}const u=o[0];if(n==="union"&&!a&&u&&((!r.useFlagV||!r.verbose)&&s.kind==="union"&&!(_.bugFlagVLiteralHyphenIsRange&&r.useFlagV)||!r.verbose&&s.kind==="intersection"&&o.length===1&&u.type!=="CharacterClassRange"))return o.map(t).join("");if(!r.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(e,r){const t=e.min.value,n=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:r.useFlagV},s=V(t,a),o=V(n,a),i=new Set;if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase){const u=gr(e);Ht(u).forEach(p=>{i.add(Array.isArray(p)?`${V(p[0],a)}-${V(p[1],a)}`:V(p,a))})}return`${s}-${o}${[...i].join("")}`},CharacterSet({kind:e,negate:r,value:t,key:n},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":h`[^\n]`;if(e==="digit")return r?h`\D`:h`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&ir.has(t))throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);return`${r?h`\P`:h`\p`}{${n?`${n}=`:""}${t}}`}if(e==="word")return r?h`\W`:h`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,r){return(r.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:r,flags:t,parent:n},a,s){const o=a.currentFlags;t&&(a.currentFlags=te(o,t));const i=r.map(s).join("|"),u=!a.verbose&&r.length===1&&n.type!=="Quantifier"&&!e&&(!a.useFlagMods||!t)?i:`(?${jt(e,t,a.useFlagMods)}${i})`;return a.currentFlags=o,u},LookaroundAssertion({body:e,kind:r,negate:t},n,a){return`(?${`${r==="lookahead"?"":"<"}${t?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,r,t){return t(e.body)+Xt(e)},Subroutine({isRecursive:e,ref:r},t){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const n=t.recursionLimit;return r===0?`(?R=${n})`:h`\g<${r}&R=${n}>`}},Bt=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Vt=new Set(["-","\\","]","^","["]),zt=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Ve=new Map([[9,h`\t`],[10,h`\n`],[11,h`\v`],[12,h`\f`],[13,h`\r`],[8232,h`\u2028`],[8233,h`\u2029`],[65279,h`\uFEFF`]]),Wt=/^\p{Cased}$/u;function Ee(e){return Wt.test(e)}function gr(e,r){const t=!!r?.firstOnly,n=e.min.value,a=e.max.value,s=[];if(n<65&&(a===65535||a>=131071)||n===65536&&a>=131071)return s;for(let o=n;o<=a;o++){const i=C(o);if(!Ee(i))continue;const u=or(i).filter(c=>{const p=c.codePointAt(0);return p<n||p>a});if(u.length&&(s.push(...u),t))break}return s}function V(e,{escDigit:r,inCharClass:t,useFlagV:n}){if(Ve.has(e))return Ve.get(e);if(e<32||e>126&&e<160||e>262143||r&&Zt(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=t?n?zt:Vt:Bt,s=C(e);return(a.has(s)?"\\":"")+s}function Ht(e){const r=e.map(a=>a.codePointAt(0)).sort((a,s)=>a-s),t=[];let n=null;for(let a=0;a<r.length;a++)r[a+1]===r[a]+1?n??=r[a]:n===null?t.push(r[a]):(t.push([n,r[a]]),n=null);return t}function jt(e,r,t){if(e)return">";let n="";if(r&&t){const{enable:a,disable:s}=r;n=(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${n}:`}function Xt({kind:e,max:r,min:t}){let n;return!t&&r===1?n="?":!t&&r===1/0?n="*":t===1&&r===1/0?n="+":t===r?n=`{${t}}`:n=`{${t},${r===1/0?"":r}}`,n+{greedy:"",lazy:"?",possessive:"+"}[e]}function ze({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Zt(e){return e>47&&e<58}function We({type:e,value:r}){return e==="Character"&&r===45}var Qt=class be extends RegExp{#r=new Map;#e=null;#n;#t=null;#s=null;rawOptions={};get source(){return this.#n||"(?:)"}constructor(r,t,n){const a=!!n?.lazyCompile;if(r instanceof RegExp){if(n)throw new Error("Cannot provide options when copying a regexp");const s=r;super(s,t),this.#n=s.source,s instanceof be&&(this.#r=s.#r,this.#t=s.#t,this.#s=s.#s,this.rawOptions=s.rawOptions)}else{const s={hiddenCaptures:[],strategy:null,transfers:[],...n};super(a?"":r,t),this.#n=r,this.#r=Jt(s.hiddenCaptures,s.transfers),this.#s=s.strategy,this.rawOptions=n??{}}a||(this.#e=this)}exec(r){if(!this.#e){const{lazyCompile:a,...s}=this.rawOptions;this.#e=new be(this.#n,this.flags,s)}const t=this.global||this.sticky,n=this.lastIndex;if(this.#s==="clip_search"&&t&&n){this.lastIndex=0;const a=this.#a(r.slice(n));return a&&(qt(a,n,r,this.hasIndices),this.lastIndex+=n),a}return this.#a(r)}#a(r){this.#e.lastIndex=this.lastIndex;const t=super.exec.call(this.#e,r);if(this.lastIndex=this.#e.lastIndex,!t||!this.#r.size)return t;const n=[...t];t.length=1;let a;this.hasIndices&&(a=[...t.indices],t.indices.length=1);const s=[0];for(let o=1;o<n.length;o++){const{hidden:i,transferTo:u}=this.#r.get(o)??{};if(i?s.push(null):(s.push(t.length),t.push(n[o]),this.hasIndices&&t.indices.push(a[o])),u&&n[o]!==void 0){const c=s[u];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(t[c]=n[o],this.hasIndices&&(t.indices[c]=a[o]),t.groups){this.#t||(this.#t=Kt(this.source));const p=this.#t.get(u);p&&(t.groups[p]=n[o],this.hasIndices&&(t.indices.groups[p]=a[o]))}}}return t}};function qt(e,r,t,n){if(e.index+=r,e.input=t,n){const a=e.indices;for(let o=0;o<a.length;o++){const i=a[o];i&&(a[o]=[i[0]+r,i[1]+r])}const s=a.groups;s&&Object.keys(s).forEach(o=>{const i=s[o];i&&(s[o]=[i[0]+r,i[1]+r])})}}function Jt(e,r){const t=new Map;for(const n of e)t.set(n,{hidden:!0});for(const[n,a]of r)for(const s of a)Q(t,s,{}).transferTo=n;return t}function Kt(e){const r=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,t=new Map;let n=0,a=0,s;for(;s=r.exec(e);){const{0:o,groups:{capture:i,name:u}}=s;o==="["?n++:n?o==="]"&&n--:i&&(a++,u&&t.set(a,u))}return t}function Yt(e,r){const t=en(e,r);return t.options?new Qt(t.pattern,t.flags,t.options):new RegExp(t.pattern,t.flags)}function en(e,r){const t=ar(r),n=Je(e,{flags:t.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline},skipBackrefValidation:t.rules.allowOrphanBackrefs,unicodePropertyMap:$e}),a=St(n,{accuracy:t.accuracy,asciiWordBoundaries:t.rules.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,bestEffortTarget:t.target}),s=Ot(a,t),o=wt(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),i=gt(o.pattern),u=dt(i.pattern,{captureTransfers:o.captureTransfers,hiddenCaptures:o.hiddenCaptures}),c={pattern:u.pattern,flags:`${t.hasIndices?"d":""}${t.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(t.avoidSubclass){if(t.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=u.hiddenCaptures.sort((d,w)=>d-w),l=Array.from(u.captureTransfers),f=a._strategy,g=c.pattern.length>=t.lazyCompileLength;(p.length||l.length||f||g)&&(c.options={...p.length&&{hiddenCaptures:p},...l.length&&{transfers:l},...f&&{strategy:f},...g&&{lazyCompile:g}})}return c}function rn(e,r){return Yt(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...r})}function tn(e={}){const r=Object.assign({target:"auto",cache:new Map},e);return r.regexConstructor||=t=>rn(t,{target:r.target}),{createScanner(t){return new mr(t,r)},createString(t){return{content:t}}}}export{mr as JavaScriptScanner,tn as createJavaScriptRegexEngine,rn as defaultJavaScriptRegexConstructor};