import{J as q,S as v,m as Q,A as w,b as F,w as Z,K as I,o as J,E as B,Q as x,C as oe,F as T,_ as ue,P as ce,k as le,O as pe}from"./vendor-oniguruma-parser-C0D4_9rT.js";import{p as fe,a as ge}from"./vendor-regex-BBWcyTkg.js";import{r as de}from"./vendor-regex-recursion-JU4mF-dD.js";var C=String.fromCodePoint,f=String.raw,_={flagGroups:(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),unicodeSets:(()=>{try{new RegExp("[[]]","v")}catch{return!1}return!0})()};_.bugFlagVLiteralHyphenIsRange=_.unicodeSets?(()=>{try{new RegExp(f`[\d\-a]`,"v")}catch{return!0}return!1})():!1;_.bugNestedClassIgnoresNegation=_.unicodeSets&&new RegExp("[[^a]]","v").test("a");function k(e,{enable:r,disable:t}){return{dotAll:!t?.dotAll&&!!(r?.dotAll||e.dotAll),ignoreCase:!t?.ignoreCase&&!!(r?.ignoreCase||e.ignoreCase)}}function M(e,r,t){return e.has(r)||e.set(r,t),e.get(r)}function R(e,r){return j[e]>=j[r]}function he(e,r){if(e==null)throw new Error(r??"Value expected");return e}var j={ES2025:2025,ES2024:2024,ES2018:2018},Ce={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function X(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!Ce[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 ye="[	-\r ]",be=new Set([C(304),C(305)]),b=f`[\p{L}\p{M}\p{N}\p{Pc}]`;function K(e){if(be.has(e))return[e];const r=new Set,t=e.toLowerCase(),s=t.toUpperCase(),n=_e.get(t),a=me.get(t),i=we.get(t);return[...s].length===1&&r.add(s),i&&r.add(i),n&&r.add(n),r.add(t),a&&r.add(a),[...r]}var U=new Map(`C Other
Cc Control cntrl
Cf Format
Cn Unassigned
Co Private_Use
Cs Surrogate
L Letter
LC Cased_Letter
Ll Lowercase_Letter
Lm Modifier_Letter
Lo Other_Letter
Lt Titlecase_Letter
Lu Uppercase_Letter
M Mark Combining_Mark
Mc Spacing_Mark
Me Enclosing_Mark
Mn Nonspacing_Mark
N Number
Nd Decimal_Number digit
Nl Letter_Number
No Other_Number
P Punctuation punct
Pc Connector_Punctuation
Pd Dash_Punctuation
Pe Close_Punctuation
Pf Final_Punctuation
Pi Initial_Punctuation
Po Other_Punctuation
Ps Open_Punctuation
S Symbol
Sc Currency_Symbol
Sk Modifier_Symbol
Sm Math_Symbol
So Other_Symbol
Z Separator
Zl Line_Separator
Zp Paragraph_Separator
Zs Space_Separator
ASCII
ASCII_Hex_Digit AHex
Alphabetic Alpha
Any
Assigned
Bidi_Control Bidi_C
Bidi_Mirrored Bidi_M
Case_Ignorable CI
Cased
Changes_When_Casefolded CWCF
Changes_When_Casemapped CWCM
Changes_When_Lowercased CWL
Changes_When_NFKC_Casefolded CWKCF
Changes_When_Titlecased CWT
Changes_When_Uppercased CWU
Dash
Default_Ignorable_Code_Point DI
Deprecated Dep
Diacritic Dia
Emoji
Emoji_Component EComp
Emoji_Modifier EMod
Emoji_Modifier_Base EBase
Emoji_Presentation EPres
Extended_Pictographic ExtPict
Extender Ext
Grapheme_Base Gr_Base
Grapheme_Extend Gr_Ext
Hex_Digit Hex
IDS_Binary_Operator IDSB
IDS_Trinary_Operator IDST
ID_Continue IDC
ID_Start IDS
Ideographic Ideo
Join_Control Join_C
Logical_Order_Exception LOE
Lowercase Lower
Math
Noncharacter_Code_Point NChar
Pattern_Syntax Pat_Syn
Pattern_White_Space Pat_WS
Quotation_Mark QMark
Radical
Regional_Indicator RI
Sentence_Terminal STerm
Soft_Dotted SD
Terminal_Punctuation Term
Unified_Ideograph UIdeo
Uppercase Upper
Variation_Selector VS
White_Space space
XID_Continue XIDC
XID_Start XIDS`.split(/\s/).map(e=>[Z(e),e])),me=new Map([["s",C(383)],[C(383),"s"]]),we=new Map([[C(223),C(7838)],[C(107),C(8490)],[C(229),C(8491)],[C(969),C(8486)]]),_e=new Map([S(453),S(456),S(459),S(498),...$(8072,8079),...$(8088,8095),...$(8104,8111),S(8124),S(8140),S(8188)]),Se=new Map([["alnum",f`[\p{Alpha}\p{Nd}]`],["alpha",f`\p{Alpha}`],["ascii",f`\p{ASCII}`],["blank",f`[\p{Zs}\t]`],["cntrl",f`\p{Cc}`],["digit",f`\p{Nd}`],["graph",f`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",f`\p{Lower}`],["print",f`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",f`[\p{P}\p{S}]`],["space",f`\p{space}`],["upper",f`\p{Upper}`],["word",f`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",f`\p{AHex}`]]);function Ee(e,r){const t=[];for(let s=e;s<=r;s++)t.push(s);return t}function S(e){const r=C(e);return[r.toLowerCase(),r]}function $(e,r){return Ee(e,r).map(t=>S(t))}var Y=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Ae(e,r){const t={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...r};ee(e);const s={accuracy:t.accuracy,asciiWordBoundaries:t.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:R(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};v(e,Ie,s);const n={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:n,prevFlags:null,globalFlags:n,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:s.subroutineRefMap};v(e,xe,a);const i={groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer};return v(e,ve,i),e._originMap=a.groupOriginByCopy,e._strategy=s.strategy,e}var Ie={AbsenceFunction({node:e,parent:r,replaceWith:t}){const{body:s,kind:n}=e;if(n==="repeater"){const a=w();a.body[0].body.push(I({negate:!0,body:s}),x("Any"));const i=w();i.body[0].body.push(ue("greedy",0,1/0,a)),t(h(i,r),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:r,key:t},{flagDirectivesByAlt:s}){const n=e.body.filter(a=>a.kind==="flags");for(let a=t+1;a<r.body.length;a++){const i=r.body[a];M(s,i,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:r}){if(r.get(e)?.length){const t=te(r.get(e));if(t){const s=w({flags:t});s.body[0].body=e.body,e.body=[h(s,e)]}}}},Assertion({node:e,parent:r,key:t,container:s,root:n,remove:a,replaceWith:i},u){const{kind:o,negate:c}=e,{asciiWordBoundaries:l,avoidSubclass:p,supportedGNodes:g,wordIsAscii:d}=u;if(o==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(o==="line_end")i(h(I({body:[F({body:[T("string_end")]}),F({body:[Q(10)]})]}),r));else if(o==="line_start")i(h(m(f`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),r));else if(o==="search_start")if(g.has(e))n.flags.sticky=!0,a();else{const y=s[t-1];if(y&&Pe(y))i(h(I({negate:!0}),r));else{if(p)throw new Error(f`Uses "\G" in a way that requires a subclass`);i(E(T("string_start"),r)),u.strategy="clip_search"}}else if(!(o==="string_end"||o==="string_start"))if(o==="string_end_newline")i(h(m(f`(?=\n?\z)`),r));else if(o==="word_boundary"){if(!d&&!l){const y=`(?:(?<=${b})(?!${b})|(?<!${b})(?=${b}))`,L=`(?:(?<=${b})(?=${b})|(?<!${b})(?!${b}))`;i(h(m(c?L:y),r))}}else throw new Error(`Unexpected assertion kind "${o}"`)},Backreference({node:e},{jsGroupNameMap:r}){let{ref:t}=e;typeof t=="string"&&!N(t)&&(t=P(t,r),e.ref=t)},CapturingGroup({node:e},{jsGroupNameMap:r,subroutineRefMap:t}){let{name:s}=e;s&&!N(s)&&(s=P(s,r),e.name=s),t.set(e.number,e),s&&t.set(s,e)},CharacterClassRange({node:e,parent:r,replaceWith:t}){if(r.kind==="intersection"){const s=oe({body:[e]});t(h(s,r),{traverse:!0})}},CharacterSet({node:e,parent:r,replaceWith:t},{accuracy:s,minTargetEs2024:n,digitIsAscii:a,spaceIsAscii:i,wordIsAscii:u}){const{kind:o,negate:c,value:l}=e;if(a&&(o==="digit"||l==="digit")){t(E(B("digit",{negate:c}),r));return}if(i&&(o==="space"||l==="space")){t(h(G(m(ye),c),r));return}if(u&&(o==="word"||l==="word")){t(E(B("word",{negate:c}),r));return}if(o==="any")t(E(x("Any"),r));else if(o==="digit")t(E(x("Nd",{negate:c}),r));else if(o!=="dot")if(o==="text_segment"){if(s==="strict")throw new Error(f`Use of "\X" requires non-strict accuracy`);const p="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=f`\p{RI}{2}|${p}(?:\u200D${p})*`;t(h(m(f`(?>\r\n|${n?f`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),r))}else if(o==="hex")t(E(x("AHex",{negate:c}),r));else if(o==="newline")t(h(m(c?`[^
]`:`(?>\r
?|[
\v\f\u2028\u2029])`),r));else if(o==="posix")if(!n&&(l==="graph"||l==="print")){if(s==="strict")throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);let p={graph:"!-~",print:" -~"}[l];c&&(p=`\0-${C(p.codePointAt(0)-1)}${C(p.codePointAt(2)+1)}-􏿿`),t(h(m(`[${p}]`),r))}else t(h(G(m(Se.get(l)),c),r));else if(o==="property")U.has(Z(l))||(e.key="sc");else if(o==="space")t(E(x("space",{negate:c}),r));else if(o==="word")t(h(G(m(b),c),r));else throw new Error(`Unexpected character set kind "${o}"`)},Directive({node:e,parent:r,root:t,remove:s,replaceWith:n,removeAllPrevSiblings:a,removeAllNextSiblings:i}){const{kind:u,flags:o}=e;if(u==="flags")if(!o.enable&&!o.disable)s();else{const c=w({flags:o});c.body[0].body=i(),n(h(c,r),{traverse:!0})}else if(u==="keep"){const c=t.body[0],p=t.body.length===1&&J(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:t;if(r.parent!==p||p.body.length>1)throw new Error(f`Uses "\K" in a way that's unsupported`);const g=I({behind:!0});g.body[0].body=a(),n(h(g,r))}else throw new Error(`Unexpected directive kind "${u}"`)},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:s}=e;if(s==="fail")t(h(I({negate:!0}),r));else throw new Error(`Unsupported named callout "(*${s.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const r=w();r.body[0].body.push(e.body),e.body=h(r,e)}},Regex:{enter({node:e},{supportedGNodes:r}){const t=[];let s=!1,n=!1;for(const a of e.body)if(a.body.length===1&&a.body[0].kind==="search_start")a.body.pop();else{const i=ne(a.body);i?(s=!0,Array.isArray(i)?t.push(...i):t.push(i)):n=!0}s&&!n&&t.forEach(a=>r.add(a))},exit(e,{accuracy:r,passedLookbehind:t,strategy:s}){if(r==="strict"&&t&&s)throw new Error(f`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:r}){let{ref:t}=e;typeof t=="string"&&!N(t)&&(t=P(t,r),e.ref=t)}},xe={Backreference({node:e},{multiplexCapturesToLeftByRef:r,reffedNodesByReferencer:t}){const{orphan:s,ref:n}=e;s||t.set(e,[...r.get(n).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,parent:r,replaceWith:t,skip:s},{groupOriginByCopy:n,groupsByName:a,multiplexCapturesToLeftByRef:i,openRefs:u,reffedNodesByReferencer:o}){const c=n.get(e);if(c&&u.has(e.number)){const p=E(V(e.number),r);o.set(p,u.get(e.number)),t(p);return}u.set(e.number,e),i.set(e.number,[]),e.name&&M(i,e.name,[]);const l=i.get(e.name??e.number);for(let p=0;p<l.length;p++){const g=l[p];if(c===g.node||c&&c===g.origin||e===g.origin){l.splice(p,1);break}}if(i.get(e.number).push({node:e,origin:c}),e.name&&i.get(e.name).push({node:e,origin:c}),e.name){const p=M(a,e.name,new Map);let g=!1;if(c)g=!0;else for(const d of p.values())if(!d.hasDuplicateNameToRemove){g=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},exit({node:e},{openRefs:r}){r.delete(e.number)}},Group:{enter({node:e},r){r.prevFlags=r.currentFlags,e.flags&&(r.currentFlags=k(r.currentFlags,e.flags))},exit(e,r){r.currentFlags=r.prevFlags}},Subroutine({node:e,parent:r,replaceWith:t},s){const{isRecursive:n,ref:a}=e;if(n){let l=r;for(;(l=l.parent)&&!(l.type==="CapturingGroup"&&(l.name===a||l.number===a)););s.reffedNodesByReferencer.set(e,l);return}const i=s.subroutineRefMap.get(a),u=a===0,o=u?V(0):re(i,s.groupOriginByCopy,null);let c=o;if(!u){const l=te(ke(i,g=>g.type==="Group"&&!!g.flags)),p=l?k(s.globalFlags,l):s.globalFlags;Me(p,s.currentFlags)||(c=w({flags:Le(p)}),c.body[0].body.push(o))}t(h(c,r),{traverse:!u})}},ve={Backreference({node:e,parent:r,replaceWith:t},s){if(e.orphan){s.highestOrphanBackref=Math.max(s.highestOrphanBackref,e.ref);return}const a=s.reffedNodesByReferencer.get(e).filter(i=>Fe(i,e));if(!a.length)t(h(I({negate:!0}),r));else if(a.length>1){const i=w({atomic:!0,body:a.reverse().map(u=>F({body:[le(u.number)]}))});t(h(i,r))}else e.ref=a[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 s=0;s<t;s++){const n=ce();e.body.at(-1).body.push(n)}}},Subroutine({node:e},r){!e.isRecursive||e.ref===0||(e.ref=r.reffedNodesByReferencer.get(e).number)}};function ee(e){v(e,{"*"({node:r,parent:t}){r.parent=t}})}function Me(e,r){return e.dotAll===r.dotAll&&e.ignoreCase===r.ignoreCase}function Fe(e,r){let t=r;do{if(t.type==="Regex")return!1;if(t.type==="Alternative")continue;if(t===e)return!1;const s=se(t.parent);for(const n of s){if(n===t)break;if(n===e||ae(n,e))return!0}}while(t=t.parent);throw new Error("Unexpected path")}function re(e,r,t,s){const n=Array.isArray(e)?[]:{};for(const[a,i]of Object.entries(e))a==="parent"?n.parent=Array.isArray(t)?s:t:i&&typeof i=="object"?n[a]=re(i,r,n,t):(a==="type"&&i==="CapturingGroup"&&r.set(n,r.get(e)??e),n[a]=i);return n}function V(e){const r=pe(e);return r.isRecursive=!0,r}function ke(e,r){const t=[];for(;e=e.parent;)(!r||r(e))&&t.push(e);return t}function P(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 te(e){const r=["dotAll","ignoreCase"],t={enable:{},disable:{}};return e.forEach(({flags:s})=>{r.forEach(n=>{s.enable?.[n]&&(delete t.disable[n],t.enable[n]=!0),s.disable?.[n]&&(t.disable[n]=!0)})}),Object.keys(t.enable).length||delete t.enable,Object.keys(t.disable).length||delete t.disable,t.enable||t.disable?t:null}function Le({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 se(e){if(!e)throw new Error("Node expected");const{body:r}=e;return Array.isArray(r)?r:r?[r]:null}function ne(e){const r=e.find(t=>t.kind==="search_start"||Ne(t,{negate:!1})||!$e(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 s of r.body){const n=ne(s.body);if(!n)return null;Array.isArray(n)?t.push(...n):t.push(n)}return t}return null}function ae(e,r){const t=se(e)??[];for(const s of t)if(s===r||ae(s,r))return!0;return!1}function $e({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Pe(e){const r=["Character","CharacterClass","CharacterSet"];return r.includes(e.type)||e.type==="Quantifier"&&e.min&&r.includes(e.body.type)}function Ne(e,r){const t={negate:null,...r};return e.type==="LookaroundAssertion"&&(t.negate===null||e.negate===t.negate)&&e.body.length===1&&J(e.body[0],{type:"Assertion",kind:"search_start"})}function N(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function m(e,r){const s=q(e,{...r,unicodePropertyMap:U}).body;return s.length>1||s[0].body.length>1?w({body:s}):s[0].body[0]}function G(e,r){return e.negate=r,e}function E(e,r){return e.parent=r,e}function h(e,r){return ee(e),e.parent=r,e}function Ge(e,r){const t=X(r),s=R(t.target,"ES2024"),n=R(t.target,"ES2025"),a=t.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,u=null;if(!n){const d=[e.flags.ignoreCase];v(e,Re,{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(y){d.push(y)},setHasCasedChar(){d.at(-1)?i=!0:u=!0}})}const o={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!u)};let c=e;const l={accuracy:t.accuracy,appliedGlobalFlags:o,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!n&&i&&u),useFlagMods:n,useFlagV:s,verbose:t.verbose};function p(d){return l.lastNode=c,c=d,he(Oe[d.type],`Unexpected node type "${d.type}"`)(d,l,p)}const g={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:{...e.options}};return s||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],l.captureMap.forEach((d,y)=>{d.hidden&&g._hiddenCaptures.push(y),d.transferTo&&M(g._captureTransfers,d.transferTo,[]).push(y)}),g}var Re={"*":{enter({node:e},r){if(z(e)){const t=r.getCurrentModI();r.pushModI(e.flags?k({ignoreCase:t},e.flags).ignoreCase:t)}},exit({node:e},r){z(e)&&r.popModI()}},Backreference(e,r){r.setHasCasedChar()},Character({node:e},r){D(C(e.value))&&r.setHasCasedChar()},CharacterClassRange({node:e,skip:r},t){r(),ie(e,{firstOnly:!0}).length&&t.setHasCasedChar()},CharacterSet({node:e},r){e.kind==="property"&&Y.has(e.value)&&r.setHasCasedChar()}},Oe={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?f`\B`:f`\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:s,name:n,number:a}=e,i={ignoreCase:r.currentFlags.ignoreCase},u=r.originMap.get(e);return u&&(i.hidden=!0,a>u.number&&(i.transferTo=u.number)),r.captureMap.set(a,i),`(${n?`?<${n}>`:""}${s.map(t).join("|")})`},Character({value:e},r){const t=C(e),s=A(e,{escDigit:r.lastNode.type==="Backreference",inCharClass:r.inCharClass,useFlagV:r.useFlagV});if(s!==t)return s;if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase&&D(t)){const n=K(t);return r.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return t},CharacterClass(e,r,t){const{kind:s,negate:n,parent:a}=e;let{body:i}=e;if(s==="intersection"&&!r.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");_.bugFlagVLiteralHyphenIsRange&&r.useFlagV&&i.some(W)&&(i=[Q(45),...i.filter(c=>!W(c))]);const u=()=>`[${n?"^":""}${i.map(t).join(s==="intersection"?"&&":"")}]`;if(!r.inCharClass){if((!r.useFlagV||_.bugNestedClassIgnoresNegation)&&!n){const l=i.filter(p=>p.type==="CharacterClass"&&p.kind==="union"&&p.negate);if(l.length){const p=w(),g=p.body[0];return p.parent=a,g.parent=p,i=i.filter(d=>!l.includes(d)),e.body=i,i.length?(e.parent=g,g.body.push(e)):p.body.pop(),l.forEach(d=>{const y=F({body:[d]});d.parent=y,y.parent=p,p.body.push(y)}),t(p)}}r.inCharClass=!0;const c=u();return r.inCharClass=!1,c}const o=i[0];if(s==="union"&&!n&&o&&((!r.useFlagV||!r.verbose)&&a.kind==="union"&&!(_.bugFlagVLiteralHyphenIsRange&&r.useFlagV)||!r.verbose&&a.kind==="intersection"&&i.length===1&&o.type!=="CharacterClassRange"))return i.map(t).join("");if(!r.useFlagV&&a.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return u()},CharacterClassRange(e,r){const t=e.min.value,s=e.max.value,n={escDigit:!1,inCharClass:!0,useFlagV:r.useFlagV},a=A(t,n),i=A(s,n),u=new Set;if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase){const o=ie(e);je(o).forEach(l=>{u.add(Array.isArray(l)?`${A(l[0],n)}-${A(l[1],n)}`:A(l,n))})}return`${a}-${i}${[...u].join("")}`},CharacterSet({kind:e,negate:r,value:t,key:s},n){if(e==="dot")return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":f`[^\n]`;if(e==="digit")return r?f`\D`:f`\d`;if(e==="property"){if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&Y.has(t))throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);return`${r?f`\P`:f`\p`}{${s?`${s}=`:""}${t}}`}if(e==="word")return r?f`\W`:f`\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:s},n,a){const i=n.currentFlags;t&&(n.currentFlags=k(i,t));const u=r.map(a).join("|"),o=!n.verbose&&r.length===1&&s.type!=="Quantifier"&&!e&&(!n.useFlagMods||!t)?u:`(?${Ve(e,t,n.useFlagMods)}${u})`;return n.currentFlags=i,o},LookaroundAssertion({body:e,kind:r,negate:t},s,n){return`(?${`${r==="lookahead"?"":"<"}${t?"!":"="}`}${e.map(n).join("|")})`},Quantifier(e,r,t){return t(e.body)+He(e)},Subroutine({isRecursive:e,ref:r},t){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const s=t.recursionLimit;return r===0?`(?R=${s})`:f`\g<${r}&R=${s}>`}},Ue=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),De=new Set(["-","\\","]","^","["]),Be=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),H=new Map([[9,f`\t`],[10,f`\n`],[11,f`\v`],[12,f`\f`],[13,f`\r`],[8232,f`\u2028`],[8233,f`\u2029`],[65279,f`\uFEFF`]]),Te=new RegExp("^\\p{Cased}$","u");function D(e){return Te.test(e)}function ie(e,r){const t=!!r?.firstOnly,s=e.min.value,n=e.max.value,a=[];if(s<65&&(n===65535||n>=131071)||s===65536&&n>=131071)return a;for(let i=s;i<=n;i++){const u=C(i);if(!D(u))continue;const o=K(u).filter(c=>{const l=c.codePointAt(0);return l<s||l>n});if(o.length&&(a.push(...o),t))break}return a}function A(e,{escDigit:r,inCharClass:t,useFlagV:s}){if(H.has(e))return H.get(e);if(e<32||e>126&&e<160||e>262143||r&&ze(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const n=t?s?Be:De:Ue,a=C(e);return(n.has(a)?"\\":"")+a}function je(e){const r=e.map(n=>n.codePointAt(0)).sort((n,a)=>n-a),t=[];let s=null;for(let n=0;n<r.length;n++)r[n+1]===r[n]+1?s??=r[n]:s===null?t.push(r[n]):(t.push([s,r[n]]),s=null);return t}function Ve(e,r,t){if(e)return">";let s="";if(r&&t){const{enable:n,disable:a}=r;s=(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")+(a?"-":"")+(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")}return`${s}:`}function He({kind:e,max:r,min:t}){let s;return!t&&r===1?s="?":!t&&r===1/0?s="*":t===1&&r===1/0?s="+":t===r?s=`{${t}}`:s=`{${t},${r===1/0?"":r}}`,s+{greedy:"",lazy:"?",possessive:"+"}[e]}function z({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function ze(e){return e>47&&e<58}function W({type:e,value:r}){return e==="Character"&&r===45}var We=class O extends RegExp{#r=new Map;#e=null;#s;#t=null;#n=null;rawOptions={};get source(){return this.#s||"(?:)"}constructor(r,t,s){const n=!!s?.lazyCompile;if(r instanceof RegExp){if(s)throw new Error("Cannot provide options when copying a regexp");const a=r;super(a,t),this.#s=a.source,a instanceof O&&(this.#r=a.#r,this.#t=a.#t,this.#n=a.#n,this.rawOptions=a.rawOptions)}else{const a={hiddenCaptures:[],strategy:null,transfers:[],...s};super(n?"":r,t),this.#s=r,this.#r=Qe(a.hiddenCaptures,a.transfers),this.#n=a.strategy,this.rawOptions=s??{}}n||(this.#e=this)}exec(r){if(!this.#e){const{lazyCompile:n,...a}=this.rawOptions;this.#e=new O(this.#s,this.flags,a)}const t=this.global||this.sticky,s=this.lastIndex;if(this.#n==="clip_search"&&t&&s){this.lastIndex=0;const n=this.#a(r.slice(s));return n&&(qe(n,s,r,this.hasIndices),this.lastIndex+=s),n}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 s=[...t];t.length=1;let n;this.hasIndices&&(n=[...t.indices],t.indices.length=1);const a=[0];for(let i=1;i<s.length;i++){const{hidden:u,transferTo:o}=this.#r.get(i)??{};if(u?a.push(null):(a.push(t.length),t.push(s[i]),this.hasIndices&&t.indices.push(n[i])),o&&s[i]!==void 0){const c=a[o];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(t[c]=s[i],this.hasIndices&&(t.indices[c]=n[i]),t.groups){this.#t||(this.#t=Ze(this.source));const l=this.#t.get(o);l&&(t.groups[l]=s[i],this.hasIndices&&(t.indices.groups[l]=n[i]))}}}return t}};function qe(e,r,t,s){if(e.index+=r,e.input=t,s){const n=e.indices;for(let i=0;i<n.length;i++){const u=n[i];u&&(n[i]=[u[0]+r,u[1]+r])}const a=n.groups;a&&Object.keys(a).forEach(i=>{const u=a[i];u&&(a[i]=[u[0]+r,u[1]+r])})}}function Qe(e,r){const t=new Map;for(const s of e)t.set(s,{hidden:!0});for(const[s,n]of r)for(const a of n)M(t,a,{}).transferTo=s;return t}function Ze(e){const r=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,t=new Map;let s=0,n=0,a;for(;a=r.exec(e);){const{0:i,groups:{capture:u,name:o}}=a;i==="["?s++:s?i==="]"&&s--:u&&(n++,o&&t.set(n,o))}return t}function er(e,r){const t=Je(e,r);return t.options?new We(t.pattern,t.flags,t.options):new RegExp(t.pattern,t.flags)}function Je(e,r){const t=X(r),s=q(e,{flags:t.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline},skipBackrefValidation:t.rules.allowOrphanBackrefs,unicodePropertyMap:U}),n=Ae(s,{accuracy:t.accuracy,asciiWordBoundaries:t.rules.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,bestEffortTarget:t.target}),a=Ge(n,t),i=de(a.pattern,{captureTransfers:a._captureTransfers,hiddenCaptures:a._hiddenCaptures,mode:"external"}),u=fe(i.pattern),o=ge(u.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:o.pattern,flags:`${t.hasIndices?"d":""}${t.global?"g":""}${a.flags}${a.options.disable.v?"u":"v"}`};if(t.avoidSubclass){if(t.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const l=o.hiddenCaptures.sort((y,L)=>y-L),p=Array.from(o.captureTransfers),g=n._strategy,d=c.pattern.length>=t.lazyCompileLength;(l.length||p.length||g||d)&&(c.options={...l.length&&{hiddenCaptures:l},...p.length&&{transfers:p},...g&&{strategy:g},...d&&{lazyCompile:d}})}return c}export{er as t};
