oniguruma-to-es
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,4 +0,4 @@ | ||
var OnigurumaToES=(()=>{var oe=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var _t=Object.prototype.hasOwnProperty;var kt=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},St=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of At(t))!_t.call(e,s)&&s!==n&&oe(e,s,{get:()=>t[s],enumerable:!(a=wt(t,s))||a.enumerable});return e};var yt=e=>St(oe({},"__esModule",{value:!0}),e);var Dr={};kt(Dr,{EmulatedRegExp:()=>ae,toDetails:()=>Et,toOnigurumaAst:()=>Or,toRegExp:()=>Ur});var Z={ES2018:2018,ES2024:2024,ES2025:2025};function J(e){if(e?.target!==void 0&&!Z[e.target])throw new Error(`Unexpected target "${e.target}"`);return{accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,maxRecursionDepth:6,target:"ES2024",tmGrammar:!1,verbose:!1,...e}}var _=String.fromCodePoint,g=String.raw;function M(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function O(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function j(e,t){return Z[e]>=Z[t]}function I(e,t){if(!e)throw new Error(t??"Value expected");return e}var xt=new Set([_(304),_(305)]);function ce(e){if(xt.has(e))return[e];let t=new Set,n=e.toLowerCase(),a=n.toUpperCase(),s=It.get(n),i=Ft.get(n);return[...a].length===1&&t.add(a),t.add(n),s&&t.add(s),i&&t.add(i),[...t]}var ue=new Set(["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"]),le=new Map;for(let e of ue)le.set(K(e),e);var bt=new Set(["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji","RGI_Emoji_Flag_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence"]),pe=new Map;for(let e of bt)pe.set(K(e),e);var ye=new Set("Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo Extended_Pictographic Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi EBase EComp EMod EPres ExtPict Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz".split(" ")),Ft=new Map([[_(223),_(7838)],[_(107),_(8490)],[_(229),_(8491)],[_(969),_(8486)]]),It=new Map([L(453),L(456),L(459),L(498),...ie(8072,8079),...ie(8088,8095),...ie(8104,8111),L(8124),L(8140),L(8188)]),Y=new Map([["alnum",g`[\p{Alpha}\p{Nd}]`],["alpha",g`\p{Alpha}`],["ascii",g`\p{ASCII}`],["blank",g`[\p{Zs}\t]`],["cntrl",g`\p{cntrl}`],["digit",g`\p{Nd}`],["graph",g`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",g`\p{Lower}`],["print",g`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",g`[\p{P}\p{S}]`],["space",g`\p{space}`],["upper",g`\p{Upper}`],["word",g`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",g`\p{AHex}`]]),xe=new Set(["alnum","blank","graph","print","word","xdigit"]);function $t(e,t){let n=[];for(let a=e;a<=t;a++)n.push(a);return n}function K(e){return e.replace(/[- _]+/g,"").toLowerCase()}function L(e){let t=_(e);return[t.toLowerCase(),t]}function ie(e,t){return $t(e,t).map(n=>L(n))}var fe=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var d={Alternator:"Alternator",Assertion:"Assertion",Backreference:"Backreference",Character:"Character",CharacterClassClose:"CharacterClassClose",CharacterClassHyphen:"CharacterClassHyphen",CharacterClassIntersector:"CharacterClassIntersector",CharacterClassOpen:"CharacterClassOpen",CharacterSet:"CharacterSet",Directive:"Directive",GroupClose:"GroupClose",GroupOpen:"GroupOpen",Subroutine:"Subroutine",Quantifier:"Quantifier",VariableLengthCharacterSet:"VariableLengthCharacterSet",EscapedNumber:"EscapedNumber"},k={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},H={flags:"flags",keep:"keep"},y={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},be=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),$e=g`\[\^?\]?`,Ne=`c.? | C(?:-.?)?|${g`[pP]\{(?:\^?[\x20\w]+\})?`}|${g`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${g`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${g`o\{[^\}]*\}?`}|${g`\d{1,3}`}`,ve=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ee=new RegExp(g` | ||
var OnigurumaToES=(()=>{var ie=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.prototype.hasOwnProperty;var xt=(e,t)=>{for(var n in t)ie(e,n,{get:t[n],enumerable:!0})},Ft=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yt(t))!bt.call(e,s)&&s!==n&&ie(e,s,{get:()=>t[s],enumerable:!(a=kt(t,s))||a.enumerable});return e};var It=e=>Ft(ie({},"__esModule",{value:!0}),e);var Vr={};xt(Vr,{EmulatedRegExp:()=>oe,toDetails:()=>_t,toOnigurumaAst:()=>Mr,toRegExp:()=>Br});var Y={ES2018:2018,ES2024:2024,ES2025:2025};function ee(e){if(e?.target!==void 0&&!Y[e.target])throw new Error(`Unexpected target "${e.target}"`);return{accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,maxRecursionDepth:5,target:"ES2024",tmGrammar:!1,verbose:!1,...e}}var A=String.fromCodePoint,g=String.raw;function M(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function B(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function L(e,t){return e.alternatives.length===1&&e.alternatives[0].elements.length===1&&(!t||t(e.alternatives[0].elements[0]))}function H(e,t){return Y[e]>=Y[t]}function F(e,t){if(!e)throw new Error(t??"Value expected");return e}var $t=new Set([A(304),A(305)]);function ue(e){if($t.has(e))return[e];let t=new Set,n=e.toLowerCase(),a=n.toUpperCase(),s=Pt.get(n),i=vt.get(n);return[...a].length===1&&t.add(a),t.add(n),s&&t.add(s),i&&t.add(i),[...t]}var le=new Set(["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"]),pe=new Map;for(let e of le)pe.set(Q(e),e);var Nt=new Set(["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji","RGI_Emoji_Flag_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence"]),fe=new Map;for(let e of Nt)fe.set(Q(e),e);var xe=new Set("Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo Extended_Pictographic Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi EBase EComp EMod EPres ExtPict Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz".split(" ")),vt=new Map([[A(223),A(7838)],[A(107),A(8490)],[A(229),A(8491)],[A(969),A(8486)]]),Pt=new Map([G(453),G(456),G(459),G(498),...ce(8072,8079),...ce(8088,8095),...ce(8104,8111),G(8124),G(8140),G(8188)]),te=new Map([["alnum",g`[\p{Alpha}\p{Nd}]`],["alpha",g`\p{Alpha}`],["ascii",g`\p{ASCII}`],["blank",g`[\p{Zs}\t]`],["cntrl",g`\p{cntrl}`],["digit",g`\p{Nd}`],["graph",g`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",g`\p{Lower}`],["print",g`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",g`[\p{P}\p{S}]`],["space",g`\p{space}`],["upper",g`\p{Upper}`],["word",g`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",g`\p{AHex}`]]),Fe=new Set(["alnum","blank","graph","print","word","xdigit"]);function Gt(e,t){let n=[];for(let a=e;a<=t;a++)n.push(a);return n}function Q(e){return e.replace(/[- _]+/g,"").toLowerCase()}function G(e){let t=A(e);return[t.toLowerCase(),t]}function ce(e,t){return Gt(e,t).map(n=>G(n))}var ge=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var h={Alternator:"Alternator",Assertion:"Assertion",Backreference:"Backreference",Character:"Character",CharacterClassClose:"CharacterClassClose",CharacterClassHyphen:"CharacterClassHyphen",CharacterClassIntersector:"CharacterClassIntersector",CharacterClassOpen:"CharacterClassOpen",CharacterSet:"CharacterSet",Directive:"Directive",GroupClose:"GroupClose",GroupOpen:"GroupOpen",Subroutine:"Subroutine",Quantifier:"Quantifier",VariableLengthCharacterSet:"VariableLengthCharacterSet",EscapedNumber:"EscapedNumber"},S={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},W={flags:"flags",keep:"keep"},k={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},Ie=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),ve=g`\[\^?\]?`,Pe=`c.? | C(?:-.?)?|${g`[pP]\{(?:\^?[\x20\w]+\})?`}|${g`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${g`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${g`o\{[^\}]*\}?`}|${g`\d{1,3}`}`,Ge=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,re=new RegExp(g` | ||
\\ (?: | ||
${Ne} | ||
${Pe} | ||
| [gk]<[^>]*>? | ||
@@ -16,21 +16,21 @@ | [gk]'[^']*'? | ||
)?)? | ||
| ${ve.source} | ||
| ${$e} | ||
| ${Ge.source} | ||
| ${ve} | ||
| . | ||
`.replace(/\s+/g,""),"gsu"),ge=new RegExp(g` | ||
`.replace(/\s+/g,""),"gsu"),he=new RegExp(g` | ||
\\ (?: | ||
${Ne} | ||
${Pe} | ||
| . | ||
) | ||
| \[:[^:]*:\] | ||
| ${$e} | ||
| ${ve} | ||
| && | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function Q(e,t=""){if(typeof e!="string")throw new Error("String expected as pattern");if(!/^[imx]*$/.test(t))throw new Error(`Flags "${t}" unsupported in Oniguruma`);let n=[t.includes("x")],a={getCurrentModX:()=>n.at(-1),numOpenGroups:0,popModX(){n.pop()},pushModX(l){n.push(l)},replaceCurrentModX(l){n[n.length-1]=l}},s=[],i;for(ee.lastIndex=0;i=ee.exec(e);){let l=Nt(a,e,i[0],ee.lastIndex);l.tokens?s.push(...l.tokens):l.token&&s.push(l.token),l.lastIndex!==void 0&&(ee.lastIndex=l.lastIndex)}let o=[],c=0;s.forEach(l=>{l.type===d.GroupOpen&&(l.kind===y.capturing?(c++,l.number=c):l.raw==="("&&o.push(l))}),c||o.forEach((l,f)=>{l.kind=y.capturing,l.number=f+1});let u=c||o.length;return s=s.map(l=>l.type===d.EscapedNumber?Dt(l,u):l).flat(),{tokens:s,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:t.includes("x")}}}function Nt(e,t,n,a){let[s,i,o]=n;if(s==="["){let c=vt(t,n,a);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(s==="\\"){if("AbBGzZ".includes(i))return{token:E(d.Assertion,n,{kind:n})};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:E(d.Subroutine,n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:E(d.Backreference,n)}}if(i==="K")return{token:E(d.Directive,n,{kind:H.keep})};if(i==="N")return{token:E(d.CharacterSet,n,{kind:k.non_newline})};if(i==="O")return{token:E(d.CharacterSet,n,{kind:k.any})};if("RX".includes(i))return{token:E(d.VariableLengthCharacterSet,n,{kind:n})};if("yY".includes(i))throw new Error(`Unsupported grapheme boundary "${n}"`);let c=Pe(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(s==="("){if(o==="#"){if(t[a]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:a+1}}if("-imx".includes(o))return{token:Tt(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("||n==="(?:")return{token:E(d.GroupOpen,n,{kind:y.group})};if(n==="(?>")return{token:E(d.GroupOpen,n,{kind:y.atomic})};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:E(d.GroupOpen,n,{kind:o==="<"?y.lookbehind:y.lookahead,negate:n.endsWith("!")})};if(o==="<"||o==="'")return{token:E(d.GroupOpen,n,{kind:y.capturing,name:n.slice(3,-1)})};throw o==="("?new Error(`Unsupported conditional "${n}"`):o==="~"?new Error(`Unsupported absence operator "${n}"`):n==="(?"?new Error("Invalid group"):new Error(`Unexpected group "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:E(d.GroupClose,n)}}if(n==="#"&&e.getCurrentModX()){let c=t.indexOf(` | ||
`,a);return{lastIndex:c===-1?t.length:c}}if(/^\s$/.test(n)&&e.getCurrentModX()){let c=/\s+/y;return c.lastIndex=a,{lastIndex:c.exec(t)?c.lastIndex:a}}return n==="."?{token:E(d.CharacterSet,n,{kind:k.dot})}:n==="^"||n==="$"?{token:E(d.Assertion,n,{kind:n})}:n==="|"?{token:E(d.Alternator,n)}:ve.test(n)?{token:Lt(n)}:(Ge(n),{token:E(d.Character,n,{value:n.codePointAt(0)})})}function vt(e,t,n){Ie(t);let a=[E(d.CharacterClassOpen,t,{negate:t[1]==="^"})],s=1,i;for(ge.lastIndex=n;i=ge.exec(e);){let o=i[0];if(o[0]==="["&&o[1]!==":")Ie(o),s++,a.push(E(d.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(s--,a.push(E(d.CharacterClassClose,o)),!s)break}else{let c=Pt(o);Array.isArray(c)?a.push(...c):a.push(c)}}return{tokens:a,lastIndex:ge.lastIndex||e.length}}function Pt(e){if(e[0]==="\\")return Pe(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Y.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return E(d.CharacterSet,e,{kind:k.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?E(d.CharacterClassHyphen,e):e==="&&"?E(d.CharacterClassIntersector,e):(Ge(e),E(d.Character,e,{value:e.codePointAt(0)}))}function Pe(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Gt(e);if("dDhHsSwW".includes(n))return Rt(e);if(e.startsWith(g`\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");return Ot(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let a=e.split(/\\x/).slice(1).map(c=>parseInt(c,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(a)),i=new TextEncoder;return[...s].map(c=>{let u=[...i.encode(c)].map(l=>`\\x${l.toString(16)}`).join("");return E(d.Character,u,{value:c.codePointAt(0)})})}catch{throw new Error(`Too short or invalid multibyte code "${e}"`)}if(n==="u"||n==="x")return E(d.Character,e,{value:Ut(e)});if(be.has(n))return E(d.Character,e,{value:be.get(n)});if(/\d/.test(n))return E(d.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(g`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return E(d.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function E(e,t,n){return{type:e,raw:t,...n}}function Gt(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return E(d.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Tt(e,t){let{on:n,off:a}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(e).groups;a??="";let s=(t.getCurrentModX()||n.includes("x"))&&!a.includes("x"),i=Fe(n),o=Fe(a),c={};if(i&&(c.enable=i),o&&(c.disable=o),e.endsWith(")"))return t.replaceCurrentModX(s),E(d.Directive,e,{kind:H.flags,flags:c});if(e.endsWith(":")){t.pushModX(s),t.numOpenGroups++;let u=E(d.GroupOpen,e,{kind:y.group});return(i||o)&&(u.flags=c),u}throw new Error(`Unexpected flag modifier "${e}"`)}function Lt(e){let t={};if(e[0]==="{"){let{min:n,max:a}=/^\{(?<min>\d*)(?:,(?<max>\d*))?/.exec(e).groups,s=1e5;if(+n>s||+a>s)throw new Error("Quantifier value unsupported in Oniguruma");t.min=+n,t.max=a===void 0?+n:a===""?1/0:+a,t.greedy=!e.endsWith("?"),t.possessive=!1}else t.min=e[0]==="+"?1:0,t.max=e[0]==="?"?1:1/0,t.greedy=e[1]!=="?",t.possessive=e[1]==="+";return E(d.Quantifier,e,t)}function Rt(e){let t=e[1].toLowerCase();return E(d.CharacterSet,e,{kind:{d:k.digit,h:k.hex,s:k.space,w:k.word}[t],negate:e[1]!==t})}function Ot(e){let{p:t,neg:n,value:a}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[ \w]+)/.exec(e).groups,s=t==="P"&&!n||t==="p"&&!!n;return E(d.CharacterSet,e,{kind:k.property,negate:s,value:a})}function Fe(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Ut(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}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2),n=parseInt(t,16);if(n>1310719)throw new Error(`Invalid out of range "${e}"`);if(n>1114111)throw new Error(`Invalid out of range in JS "${e}"`);return n}function Dt(e,t){let{raw:n,inCharClass:a}=e,s=n.slice(1);if(!a&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=t))return[E(d.Backreference,n)];let i=[],o=s.match(/^[0-7]+|\d/g);for(let c=0;c<o.length;c++){let u=o[c],l;if(c===0&&u!=="8"&&u!=="9"){if(l=parseInt(u,8),l>127)throw new Error(g`Octal encoded byte above 177 unsupported "${n}"`)}else l=u.codePointAt(0);i.push(E(d.Character,(c===0?"\\":"")+u,{value:l}))}return i}function Ie(e){if(e.endsWith("]"))throw new Error(`Empty character class "${e}" unsupported in Oniguruma`)}function Ge(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function G(e,t,n){let a=e.node;for(;a.parent;)a=a.parent;function s(o,c){for(let u=0;u<o.length;u++){let l=i(o[u],c,u,o);u=Math.max(-1,u+l)}}function i(o,c=null,u=null,l=null){let f=0,h=!1,C={node:o,parent:c,key:u,container:l,ast:a,remove(){I(l,"Container expected").splice(Math.max(0,u+f),1),f-=1},removeAllNextSiblings(){return I(l,"Container expected").splice(u+1)},removeAllPrevSiblings(){let T=u+f;return f-=T,I(l,"Container expected").splice(0,Math.max(0,T))},replaceWith(T){Mt(T,c),l?l[Math.max(0,u+f)]=T:c[u]=T},skip(){h=!0}},m=Te(o).find(T=>!!n[T]),A=m&&n[m],S=typeof A=="function"?A:A?.enter,F=A?.exit;if(S?.(C,t),!h)switch(o.type){case p.Regex:i(o.pattern,o,"pattern"),i(o.flags,o,"flags");break;case p.Alternative:case p.CharacterClass:s(o.elements,o);break;case p.Assertion:$(o)&&s(o.alternatives,o);break;case p.Backreference:case p.Character:case p.CharacterSet:case p.Directive:case p.Flags:case p.Recursion:case p.Subroutine:case p.VariableLengthCharacterSet:break;case p.CapturingGroup:case p.Group:case p.Pattern:s(o.alternatives,o);break;case p.CharacterClassIntersection:s(o.classes,o);break;case p.CharacterClassRange:i(o.min,o,"min"),i(o.max,o,"max");break;case p.Quantifier:i(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return F?.(C,t),f}i(e.node,e.parent,e.key,e.container)}function Mt(e,t){"parent"in t&&(e.parent=t)}var p={Alternative:"Alternative",Assertion:"Assertion",Backreference:"Backreference",CapturingGroup:"CapturingGroup",Character:"Character",CharacterClass:"CharacterClass",CharacterClassIntersection:"CharacterClassIntersection",CharacterClassRange:"CharacterClassRange",CharacterSet:"CharacterSet",Directive:"Directive",Flags:"Flags",Group:"Group",Pattern:"Pattern",Quantifier:"Quantifier",Regex:"Regex",Subroutine:"Subroutine",VariableLengthCharacterSet:"VariableLengthCharacterSet",Recursion:"Recursion"},Le={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Te(e){let{type:t}=e,n=[Le.AnyNode];return($(e)||t===p.CapturingGroup||t===p.Group)&&n.push(Le.AnyGroup),n.push(t),n}var w={line_end:"line_end",line_start:"line_start",lookahead:"lookahead",lookbehind:"lookbehind",search_start:"search_start",string_end:"string_end",string_end_newline:"string_end_newline",string_start:"string_start",word_boundary:"word_boundary"},x=k,q=H,W={grapheme:"grapheme",newline:"newline"};function z({tokens:e,flags:t},n){let a={skipBackrefValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...n},s={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:a.skipBackrefValidation,skipPropertyNameValidation:a.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:a.verbose,walk:i};function i(C,m){let A=e[s.current];switch(s.parent=C,s.token=A,s.current++,A.type){case d.Alternator:return v();case d.Assertion:return Ue(A);case d.Backreference:return Bt(s);case d.Character:return De(A.value);case d.CharacterClassHyphen:return Vt(s,m);case d.CharacterClassOpen:return jt(s,m);case d.CharacterSet:return Kt(s);case d.Directive:return Zt(A);case d.GroupOpen:return Ht(s,m);case d.Quantifier:return Qt(s);case d.Subroutine:return Wt(s);case d.VariableLengthCharacterSet:return nr(A.kind);default:throw new Error(`Unexpected token type "${A.type}"`)}}let o=tr(Yt(),Jt(t)),c=o.pattern.alternatives[0];for(;s.current<e.length;){let C=i(c,{});C.type===p.Alternative?(o.pattern.alternatives.push(C),c=C):c.elements.push(C)}let{capturingGroups:u,hasNumberedRef:l,namedGroupsByName:f,subroutines:h}=s;if(l&&f.size)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:C}of h)if(typeof C=="number"){if(C>u.length)throw new Error("Subroutine uses a group number that's not defined")}else if(f.has(C)){if(f.get(C).length>1)throw new Error(g`Subroutine uses a duplicate group name "\g<${C}>"`)}else throw new Error(g`Subroutine uses a group name that's not defined "\g<${C}>"`);return G({node:o},null,{AnyNode({node:C,parent:m}){C.parent=m}}),o}function Bt(e){let{raw:t}=e.token,n=/^\\k[<']/.test(t),a=n?t.slice(3,-1):t.slice(1),s=(i,o=!1)=>{let c=e.capturingGroups.length,u=!1;if(i>c)if(e.skipBackrefValidation)u=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,te(o?c+1-i:i,{orphan:u})};if(n){let i=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(a);if(i)return s(+i.groups.num,!!i.groups.sign);if(/[-+]/.test(a))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(a))throw new Error(`Group name not defined to the left "${t}"`);return te(a)}return s(+a)}function Vt(e,t){let{parent:n,tokens:a,walk:s}=e,i=n.elements.at(-1),o=a[e.current];if(i&&i.type!==p.CharacterClass&&i.type!==p.CharacterClassRange&&o&&o.type!==d.CharacterClassOpen&&o.type!==d.CharacterClassClose&&o.type!==d.CharacterClassIntersector){let c=s(n,t);if(i.type===p.Character&&c.type===p.Character)return n.elements.pop(),Xt(i,c);throw new Error("Invalid character class range")}return De(45)}function jt(e,t){let{token:n,tokens:a,verbose:s,walk:i}=e,o=de({negate:n.negate}),c=o.elements[0],u=Re(a[e.current]);for(;u.type!==d.CharacterClassClose;){if(u.type===d.CharacterClassIntersector)c.classes.push(de({negate:!1,baseOnly:!0})),e.current++;else{let l=c.classes.at(-1);l.elements.push(i(l,t))}u=Re(a[e.current])}if(s||ir(c),c.classes.length===1){let l=c.classes[0];l.negate=o.negate!==l.negate,o=l}return e.current++,o}function Kt({token:e,skipPropertyNameValidation:t}){let{kind:n,negate:a,value:s}=e;if(n===k.property){let o=K(s);if(xe.has(o))n=k.posix,s=o;else return U(s,{negate:a,skipPropertyNameValidation:t})}let i={type:p.CharacterSet,kind:I(x[n],`Unexpected character set kind "${n}"`)};return(n===k.digit||n===k.hex||n===k.posix||n===k.space||n===k.word)&&(i.negate=a,n===k.posix&&(i.value=s)),i}function Ht(e,t){let{token:n,tokens:a,capturingGroups:s,namedGroupsByName:i,verbose:o,walk:c}=e,u=qt(n);u.type===p.CapturingGroup&&(s.push(u),u.name&&O(i,u.name,[]).push(u));let l=Oe(a[e.current]);for(;l.type!==d.GroupClose;){if(l.type===d.Alternator)u.alternatives.push(v()),e.current++;else{let f=u.alternatives.at(-1);f.elements.push(c(f,t))}l=Oe(a[e.current])}return o||(u=ar(u)),e.current++,u}function Qt({token:e,parent:t}){let{min:n,max:a,greedy:s,possessive:i}=e,o=t.elements.at(-1);if(!o||o.type===p.Assertion||o.type===p.Directive)throw new Error("Quantifier requires a repeatable token");let c=er(o,n,a,s,i);return t.elements.pop(),c}function Wt(e){let{token:t,capturingGroups:n,subroutines:a}=e,s=t.raw.slice(3,-1),i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(i){let c=+i.groups.num,u=n.length;if(e.hasNumberedRef=!0,s={"":c,"+":u+c,"-":u+1-c}[i.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);let o=rr(s);return a.push(o),o}function v(){return{type:p.Alternative,elements:[]}}function Ue({type:e,kind:t,negate:n}){if(e===d.GroupOpen)return re({behind:t===y.lookbehind,negate:n});let a=I({"^":w.line_start,$:w.line_end,"\\A":w.string_start,"\\b":w.word_boundary,"\\B":w.word_boundary,"\\G":w.search_start,"\\z":w.string_end,"\\Z":w.string_end_newline}[t],`Unexpected assertion kind "${t}"`),s={type:p.Assertion,kind:a};return a===w.word_boundary&&(s.negate=t===g`\B`),s}function te(e,{orphan:t}={}){return{type:p.Backreference,...t&&{orphan:t},ref:e}}function qt(e){let{kind:t,number:n,name:a,flags:s}=e;switch(t){case y.atomic:return N({atomic:!0});case y.capturing:return he(n,a);case y.group:return N({flags:s});case y.lookahead:case y.lookbehind:return Ue(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function he(e,t){let n=t!==void 0;if(n&&!or(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:p.CapturingGroup,number:e,...n&&{name:t},alternatives:[v()]}}function De(e){return{type:p.Character,value:e}}function de(e){let t={baseOnly:!1,negate:!1,...e};return{type:p.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[zt()]}}function zt(){return{type:p.CharacterClassIntersection,classes:[de({negate:!1,baseOnly:!0})]}}function Xt(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:p.CharacterClassRange,min:e,max:t}}function Zt({kind:e,flags:t}){let n={type:p.Directive,kind:I(q[e],`Unexpected directive kind "${e}"`)};return e===H.flags&&(n.flags=t),n}function Jt({ignoreCase:e,dotAll:t,extended:n}){return{type:p.Flags,ignoreCase:e,dotAll:t,extended:n}}function N({atomic:e,flags:t}={}){return{type:p.Group,...e&&{atomic:e},...t&&{flags:t},alternatives:[v()]}}function re({behind:e=!1,negate:t=!1}={}){return{type:p.Assertion,kind:e?w.lookbehind:w.lookahead,negate:t,alternatives:[v()]}}function Yt(){return{type:p.Pattern,alternatives:[v()]}}function er(e,t,n,a,s){if(n<t)throw new Error("Quantifier range out of order");return{type:p.Quantifier,min:t,max:n,greedy:a,possessive:s,element:e}}function tr(e,t){return{type:p.Regex,pattern:e,flags:t}}function rr(e){return{type:p.Subroutine,ref:e}}function U(e,t){let n={negate:!1,skipPropertyNameValidation:!1,...t};return{type:p.CharacterSet,kind:x.property,value:n.skipPropertyNameValidation?e:sr(e),negate:n.negate}}function nr(e){return{type:p.VariableLengthCharacterSet,kind:I({"\\R":W.newline,"\\X":W.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function sr(e){let t=K(e);if(pe.has(t))throw new Error(g`Unicode property "\p{${e}}" unsupported in Oniguruma`);let n=le.get(t);return n||e.trim().replace(/\s+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,a=>a[0].toUpperCase()+a.slice(1).toLowerCase())}function ar(e){let t=e.alternatives[0],n=t.elements[0];return e.type===p.Group&&e.alternatives.length===1&&t.elements.length===1&&n.type===p.Group&&!(e.atomic&&n.flags)&&!(e.flags&&(n.atomic||n.flags))?(e.atomic?n.atomic=!0:e.flags&&(n.flags=e.flags),n):e}function $({type:e,kind:t}){return e===p.Assertion&&(t===w.lookahead||t===w.lookbehind)}function or(e){return!/^(?:[-\d]|$)/.test(e)}function ir(e){for(let t=0;t<e.classes.length;t++){let n=e.classes[t],a=n.elements[0];n.elements.length===1&&a.type===p.CharacterClass&&(e.classes[t]=a,a.negate=n.negate!==a.negate)}}function Re(e){return I(e,"Unclosed character class")}function Oe(e){return I(e,"Unclosed group")}function Be(e,t){let n=e.pattern.alternatives,a=n[0].elements[0];if(n.length>1||!a)return null;let s=n[0].elements.length===1&&(a.type===p.CapturingGroup||a.type===p.Group)&&a.alternatives.length===1,i=s?a.alternatives[0]:n[0],o=s?i.elements[0]:a;if(!o)return null;if((o.type===p.CapturingGroup||o.type===p.Group)&&o.alternatives.length===2&&o.alternatives[0].elements.length===1&&o.alternatives[1].elements.length===1){let u=o.alternatives[0].elements[0],l=o.alternatives[1].elements[0];if(u.kind===w.line_start&&l.kind===w.search_start||u.kind===w.search_start&&l.kind===w.line_start)return u.kind===w.line_start?o.alternatives.pop():o.alternatives.shift(),{name:"line_or_search_start"}}if(Me(o))return o.parent.elements.shift(),{name:"not_search_start"};let c=i.elements.findIndex(u=>Me(u));if(c>-1&&i.elements.every(u=>u.type===p.Assertion))return i.elements.splice(c,1),{name:"not_search_start"};if($(o)&&!o.negate&&o.alternatives.length>1){let u=[],l=!1;if(o.alternatives.forEach(f=>{f.elements.length===1&&f.elements[0].kind===w.search_start?l=!0:u.push(f)}),l&&u.length){let f=!0;if(u.some(h=>h.elements.some(C=>C.type===p.CapturingGroup||C.type===p.Group||C.type===p.Subroutine||$(C))))if(t==="loose")f=!1;else throw new Error(r`Uses "\G" in a way that's unsupported`);if(f){let h=R(N(),[R(v(),[U("<<",{skipPropertyNameValidation:!0})]),...u,R(v(),[U(">>",{skipPropertyNameValidation:!0})])]);return h.parent=o.parent,o.parent.elements[0]=h,{name:"after_search_start_or_subpattern"}}}}return null}function Me(e){return $(e)&&e.negate&&e.alternatives.length===1&&e.alternatives[0].elements.length===1&&e.alternatives[0].elements[0].kind===w.search_start}var Ce=String.raw,Ve=Ce`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,je=Ce`\u{E0061}-\u{E007A}`,Ke=()=>new RegExp(Ce`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${je}]{2}[\u{E0030}-\u{E0039}${je}]{1,3}\u{E007F}|${Ve}(?:\u200D${Ve})*`,"gu");function Qe(e,t){let n={accuracy:"default",avoidSubclass:!1,bestEffortTarget:"ES2025",...t},a=n.avoidSubclass?null:Be(e,n.accuracy),s={accuracy:n.accuracy,flagDirectivesByAlt:new Map,minTargetEs2024:j(n.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set};G({node:e},s,We);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsWithDuplicateNamesToRemove:new Set,multiplexCapturesToLeftByRef:new Map,namedGroupsInScopeByAlt:new Map,openDirectCaptures:new Set,openSubroutineRefs:new Set,reffedNodesByBackreference:new Map,subroutineRefMap:s.subroutineRefMap};G({node:e},o,qe);let c={groupsWithDuplicateNamesToRemove:o.groupsWithDuplicateNamesToRemove,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByBackreference:o.reffedNodesByBackreference};return G({node:e},c,cr),a&&(e._strategy=a),e}var We={Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:a}){let s=e.elements.filter(i=>i.kind===q.flags);for(let i=n+1;i<t.alternatives.length;i++){let o=t.alternatives[i];O(a,o,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Xe(t.get(e));if(n){let a=X(N({flags:n}),e.elements);a.parent=e,e.elements=[a]}}}},Assertion({node:e,ast:t,remove:n,replaceWith:a},{accuracy:s,supportedGNodes:i}){let{kind:o,negate:c}=e;if(o===w.line_end)a(P(g`(?=\z|\n)`));else if(o===w.line_start)a(P(g`(?<=\A|\n)`));else if(o===w.search_start){if(!i.has(e)&&s!=="loose")throw new Error(g`Uses "\G" in a way that's unsupported`);t.flags.sticky=!0,n()}else if(o===w.string_end_newline)a(P(g`(?=\n?\z)`));else if(o===w.word_boundary){let u=g`[\p{L}\p{N}\p{Pc}]`,l=`(?:(?<=${u})(?!${u})|(?<!${u})(?=${u}))`,f=`(?:(?<=${u})(?=${u})|(?<!${u})(?!${u}))`;a(P(c?f:l))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:n,number:a}=e;if(n&&!gr(n))throw new Error(`Group name "${n}" invalid in JS`);t.set(n??a,e)},CharacterSet({node:e,replaceWith:t},{accuracy:n,minTargetEs2024:a}){let{kind:s,negate:i,value:o}=e;if(s===x.any)t(U("Any"));else if(s===x.hex)t(U("AHex",{negate:i}));else if(s===x.non_newline)t(P(g`[^\n]`));else if(s===x.posix)if(!a&&(o==="graph"||o==="print")){if(n==="strict")throw new Error(`POSIX class "${o}" requires min target ES2024 or non-strict accuracy`);let c={graph:"!-~",print:" -~"}[o];i&&(c=`\0-${_(c.codePointAt(0)-1)}${_(c.codePointAt(2)+1)}-\u{10FFFF}`),t(P(`[${c}]`))}else{let c=P(Y.get(o));c.negate=i,t(c)}else if(s===x.property)ue.has(o)||(e.key="sc");else if(s===x.space){let c=P(`[ | ||
\v\f\r]`);c.negate=i,t(c)}},Directive(e,t){let{node:n,parent:a,ast:s,remove:i,replaceWith:o,removeAllPrevSiblings:c,removeAllNextSiblings:u}=e,{kind:l,flags:f}=n;if(l===q.flags)if(!f.enable&&!f.disable)i();else{let h=X(N({flags:f}),u());o(h),et(h,e,t,We)}else if(l===q.keep){if(a.parent!==s.pattern||s.pattern.alternatives.length>1)throw new Error(g`Uses "\K" in a way that's unsupported`);o(X(re({behind:!0}),c()))}},Flags({node:e,parent:t}){delete e.extended,Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},Pattern({node:e},{accuracy:t,supportedGNodes:n}){let a=[],s=!1,i=!1;for(let o of e.alternatives){let c=Je(o.elements);c?(s=!0,Array.isArray(c)?a.push(...c):a.push(c)):i=!0}if(s&&i&&t!=="loose")throw new Error(g`Uses "\G" in a way that's unsupported`);a.forEach(o=>n.add(o))},Quantifier({node:e}){if(e.element.type===p.Quantifier){let t=X(N(),[e.element]);t.parent=e,e.element=t}},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:n,minTargetEs2024:a}){let{kind:s}=e;if(s===W.newline)t(P(`(?>\r | ||
`.replace(/\s+/g,""),"gsu");function q(e,t=""){if(typeof e!="string")throw new Error("String expected as pattern");if(!/^[imx]*$/.test(t))throw new Error(`Flags "${t}" unsupported in Oniguruma`);let n=[t.includes("x")],a={getCurrentModX:()=>n.at(-1),numOpenGroups:0,popModX(){n.pop()},pushModX(l){n.push(l)},replaceCurrentModX(l){n[n.length-1]=l}},s=[],i;for(re.lastIndex=0;i=re.exec(e);){let l=Rt(a,e,i[0],re.lastIndex);l.tokens?s.push(...l.tokens):l.token&&s.push(l.token),l.lastIndex!==void 0&&(re.lastIndex=l.lastIndex)}let o=[],c=0;s.forEach(l=>{l.type===h.GroupOpen&&(l.kind===k.capturing?(c++,l.number=c):l.raw==="("&&o.push(l))}),c||o.forEach((l,f)=>{l.kind=k.capturing,l.number=f+1});let u=c||o.length;return s=s.map(l=>l.type===h.EscapedNumber?jt(l,u):l).flat(),{tokens:s,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:t.includes("x")}}}function Rt(e,t,n,a){let[s,i,o]=n;if(s==="["){let c=Tt(t,n,a);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(s==="\\"){if("AbBGzZ".includes(i))return{token:E(h.Assertion,n,{kind:n})};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:E(h.Subroutine,n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:E(h.Backreference,n)}}if(i==="K")return{token:E(h.Directive,n,{kind:W.keep})};if(i==="N")return{token:E(h.CharacterSet,n,{kind:S.non_newline})};if(i==="O")return{token:E(h.CharacterSet,n,{kind:S.any})};if("RX".includes(i))return{token:E(h.VariableLengthCharacterSet,n,{kind:n})};if("yY".includes(i))throw new Error(`Unsupported grapheme boundary "${n}"`);let c=Re(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(s==="("){if(o==="#"){if(t[a]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:a+1}}if("-imx".includes(o))return{token:Ut(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("||n==="(?:")return{token:E(h.GroupOpen,n,{kind:k.group})};if(n==="(?>")return{token:E(h.GroupOpen,n,{kind:k.atomic})};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:E(h.GroupOpen,n,{kind:o==="<"?k.lookbehind:k.lookahead,negate:n.endsWith("!")})};if(o==="<"||o==="'")return{token:E(h.GroupOpen,n,{kind:k.capturing,name:n.slice(3,-1)})};throw o==="("?new Error(`Unsupported conditional "${n}"`):o==="~"?new Error(`Unsupported absence operator "${n}"`):n==="(?"?new Error("Invalid group"):new Error(`Unexpected group "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:E(h.GroupClose,n)}}if(n==="#"&&e.getCurrentModX()){let c=t.indexOf(` | ||
`,a);return{lastIndex:c===-1?t.length:c}}if(/^\s$/.test(n)&&e.getCurrentModX()){let c=/\s+/y;return c.lastIndex=a,{lastIndex:c.exec(t)?c.lastIndex:a}}return n==="."?{token:E(h.CharacterSet,n,{kind:S.dot})}:n==="^"||n==="$"?{token:E(h.Assertion,n,{kind:n})}:n==="|"?{token:E(h.Alternator,n)}:Ge.test(n)?{token:Dt(n)}:(Te(n),{token:E(h.Character,n,{value:n.codePointAt(0)})})}function Tt(e,t,n){Ne(t);let a=[E(h.CharacterClassOpen,t,{negate:t[1]==="^"})],s=1,i;for(he.lastIndex=n;i=he.exec(e);){let o=i[0];if(o[0]==="["&&o[1]!==":")Ne(o),s++,a.push(E(h.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(s--,a.push(E(h.CharacterClassClose,o)),!s)break}else{let c=Lt(o);Array.isArray(c)?a.push(...c):a.push(c)}}return{tokens:a,lastIndex:he.lastIndex||e.length}}function Lt(e){if(e[0]==="\\")return Re(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!te.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return E(h.CharacterSet,e,{kind:S.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?E(h.CharacterClassHyphen,e):e==="&&"?E(h.CharacterClassIntersector,e):(Te(e),E(h.Character,e,{value:e.codePointAt(0)}))}function Re(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Ot(e);if("dDhHsSwW".includes(n))return Mt(e);if(e.startsWith(g`\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");return Bt(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let a=e.split(/\\x/).slice(1).map(c=>parseInt(c,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(a)),i=new TextEncoder;return[...s].map(c=>{let u=[...i.encode(c)].map(l=>`\\x${l.toString(16)}`).join("");return E(h.Character,u,{value:c.codePointAt(0)})})}catch{throw new Error(`Too short or invalid multibyte code "${e}"`)}if(n==="u"||n==="x")return E(h.Character,e,{value:Vt(e)});if(Ie.has(n))return E(h.Character,e,{value:Ie.get(n)});if(/\d/.test(n))return E(h.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(g`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return E(h.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function E(e,t,n){return{type:e,raw:t,...n}}function Ot(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return E(h.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Ut(e,t){let{on:n,off:a}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(e).groups;a??="";let s=(t.getCurrentModX()||n.includes("x"))&&!a.includes("x"),i=$e(n),o=$e(a),c={};if(i&&(c.enable=i),o&&(c.disable=o),e.endsWith(")"))return t.replaceCurrentModX(s),E(h.Directive,e,{kind:W.flags,flags:c});if(e.endsWith(":")){t.pushModX(s),t.numOpenGroups++;let u=E(h.GroupOpen,e,{kind:k.group});return(i||o)&&(u.flags=c),u}throw new Error(`Unexpected flag modifier "${e}"`)}function Dt(e){let t={};if(e[0]==="{"){let{min:n,max:a}=/^\{(?<min>\d*)(?:,(?<max>\d*))?/.exec(e).groups,s=1e5;if(+n>s||+a>s)throw new Error("Quantifier value unsupported in Oniguruma");t.min=+n,t.max=a===void 0?+n:a===""?1/0:+a,t.greedy=!e.endsWith("?"),t.possessive=!1}else t.min=e[0]==="+"?1:0,t.max=e[0]==="?"?1:1/0,t.greedy=e[1]!=="?",t.possessive=e[1]==="+";return E(h.Quantifier,e,t)}function Mt(e){let t=e[1].toLowerCase();return E(h.CharacterSet,e,{kind:{d:S.digit,h:S.hex,s:S.space,w:S.word}[t],negate:e[1]!==t})}function Bt(e){let{p:t,neg:n,value:a}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[ \w]+)/.exec(e).groups,s=t==="P"&&!n||t==="p"&&!!n;return E(h.CharacterSet,e,{kind:S.property,negate:s,value:a})}function $e(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Vt(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}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2),n=parseInt(t,16);if(n>1310719)throw new Error(`Invalid out of range "${e}"`);if(n>1114111)throw new Error(`Invalid out of range in JS "${e}"`);return n}function jt(e,t){let{raw:n,inCharClass:a}=e,s=n.slice(1);if(!a&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=t))return[E(h.Backreference,n)];let i=[],o=s.match(/^[0-7]+|\d/g);for(let c=0;c<o.length;c++){let u=o[c],l;if(c===0&&u!=="8"&&u!=="9"){if(l=parseInt(u,8),l>127)throw new Error(g`Octal encoded byte above 177 unsupported "${n}"`)}else l=u.codePointAt(0);i.push(E(h.Character,(c===0?"\\":"")+u,{value:l}))}return i}function Ne(e){if(e.endsWith("]"))throw new Error(`Empty character class "${e}" unsupported in Oniguruma`)}function Te(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function P(e,t,n){let a=e.node;for(;a.parent;)a=a.parent;function s(o,c){for(let u=0;u<o.length;u++){let l=i(o[u],c,u,o);u=Math.max(-1,u+l)}}function i(o,c=null,u=null,l=null){let f=0,d=!1,C={node:o,parent:c,key:u,container:l,ast:a,remove(){F(l,"Container expected").splice(Math.max(0,u+f),1),f-=1},removeAllNextSiblings(){return F(l,"Container expected").splice(u+1)},removeAllPrevSiblings(){let x=u+f;return f-=x,F(l,"Container expected").splice(0,Math.max(0,x))},replaceWith(x){Kt(x,c),l?l[Math.max(0,u+f)]=x:c[u]=x},skip(){d=!0}},m=Le(o).find(x=>!!n[x]),_=m&&n[m],T=typeof _=="function"?_:_?.enter,D=_?.exit;if(T?.(C,t),!d)switch(o.type){case p.Regex:i(o.pattern,o,"pattern"),i(o.flags,o,"flags");break;case p.Alternative:case p.CharacterClass:s(o.elements,o);break;case p.Assertion:I(o)&&s(o.alternatives,o);break;case p.Backreference:case p.Character:case p.CharacterSet:case p.Directive:case p.Flags:case p.Recursion:case p.Subroutine:case p.VariableLengthCharacterSet:break;case p.CapturingGroup:case p.Group:case p.Pattern:s(o.alternatives,o);break;case p.CharacterClassIntersection:s(o.classes,o);break;case p.CharacterClassRange:i(o.min,o,"min"),i(o.max,o,"max");break;case p.Quantifier:i(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return D?.(C,t),f}i(e.node,e.parent,e.key,e.container)}function Kt(e,t){"parent"in t&&(e.parent=t)}var p={Alternative:"Alternative",Assertion:"Assertion",Backreference:"Backreference",CapturingGroup:"CapturingGroup",Character:"Character",CharacterClass:"CharacterClass",CharacterClassIntersection:"CharacterClassIntersection",CharacterClassRange:"CharacterClassRange",CharacterSet:"CharacterSet",Directive:"Directive",Flags:"Flags",Group:"Group",Pattern:"Pattern",Quantifier:"Quantifier",Regex:"Regex",Subroutine:"Subroutine",VariableLengthCharacterSet:"VariableLengthCharacterSet",Recursion:"Recursion"},Oe={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Le(e){let{type:t}=e,n=[Oe.AnyNode];return(I(e)||t===p.CapturingGroup||t===p.Group)&&n.push(Oe.AnyGroup),n.push(t),n}var w={line_end:"line_end",line_start:"line_start",lookahead:"lookahead",lookbehind:"lookbehind",search_start:"search_start",string_end:"string_end",string_end_newline:"string_end_newline",string_start:"string_start",word_boundary:"word_boundary"},y=S,X=W,z={grapheme:"grapheme",newline:"newline"};function Z({tokens:e,flags:t},n){let a={skipBackrefValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...n},s={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:a.skipBackrefValidation,skipPropertyNameValidation:a.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:a.verbose,walk:i};function i(C,m){let _=e[s.current];switch(s.parent=C,s.token=_,s.current++,_.type){case h.Alternator:return N();case h.Assertion:return Me(_);case h.Backreference:return Ht(s);case h.Character:return Be(_.value);case h.CharacterClassHyphen:return Qt(s,m);case h.CharacterClassOpen:return Wt(s,m);case h.CharacterSet:return qt(s);case h.Directive:return tr(_);case h.GroupOpen:return zt(s,m);case h.Quantifier:return Xt(s);case h.Subroutine:return Zt(s);case h.VariableLengthCharacterSet:return ir(_.kind);default:throw new Error(`Unexpected token type "${_.type}"`)}}let o=ar(nr(),rr(t)),c=o.pattern.alternatives[0];for(;s.current<e.length;){let C=i(c,{});C.type===p.Alternative?(o.pattern.alternatives.push(C),c=C):c.elements.push(C)}let{capturingGroups:u,hasNumberedRef:l,namedGroupsByName:f,subroutines:d}=s;if(l&&f.size)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:C}of d)if(typeof C=="number"){if(C>u.length)throw new Error("Subroutine uses a group number that's not defined")}else if(f.has(C)){if(f.get(C).length>1)throw new Error(g`Subroutine uses a duplicate group name "\g<${C}>"`)}else throw new Error(g`Subroutine uses a group name that's not defined "\g<${C}>"`);return P({node:o},null,{AnyNode({node:C,parent:m}){C.parent=m}}),o}function Ht(e){let{raw:t}=e.token,n=/^\\k[<']/.test(t),a=n?t.slice(3,-1):t.slice(1),s=(i,o=!1)=>{let c=e.capturingGroups.length,u=!1;if(i>c)if(e.skipBackrefValidation)u=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,ne(o?c+1-i:i,{orphan:u})};if(n){let i=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(a);if(i)return s(+i.groups.num,!!i.groups.sign);if(/[-+]/.test(a))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(a))throw new Error(`Group name not defined to the left "${t}"`);return ne(a)}return s(+a)}function Qt(e,t){let{parent:n,tokens:a,walk:s}=e,i=n.elements.at(-1),o=a[e.current];if(i&&i.type!==p.CharacterClass&&i.type!==p.CharacterClassRange&&o&&o.type!==h.CharacterClassOpen&&o.type!==h.CharacterClassClose&&o.type!==h.CharacterClassIntersector){let c=s(n,t);if(i.type===p.Character&&c.type===p.Character)return n.elements.pop(),er(i,c);throw new Error("Invalid character class range")}return Be(45)}function Wt(e,t){let{token:n,tokens:a,verbose:s,walk:i}=e,o=de({negate:n.negate}),c=o.elements[0],u=Ue(a[e.current]);for(;u.type!==h.CharacterClassClose;){if(u.type===h.CharacterClassIntersector)c.classes.push(de({negate:!1,baseOnly:!0})),e.current++;else{let l=c.classes.at(-1);l.elements.push(i(l,t))}u=Ue(a[e.current])}if(s||pr(c),c.classes.length===1){let l=c.classes[0];l.negate=o.negate!==l.negate,o=l}return e.current++,o}function qt({token:e,skipPropertyNameValidation:t}){let{kind:n,negate:a,value:s}=e;if(n===S.property){let o=Q(s);if(Fe.has(o))n=S.posix,s=o;else return O(s,{negate:a,skipPropertyNameValidation:t})}let i={type:p.CharacterSet,kind:F(y[n],`Unexpected character set kind "${n}"`)};return(n===S.digit||n===S.hex||n===S.posix||n===S.space||n===S.word)&&(i.negate=a,n===S.posix&&(i.value=s)),i}function zt(e,t){let{token:n,tokens:a,capturingGroups:s,namedGroupsByName:i,verbose:o,walk:c}=e,u=Jt(n);u.type===p.CapturingGroup&&(s.push(u),u.name&&B(i,u.name,[]).push(u));let l=De(a[e.current]);for(;l.type!==h.GroupClose;){if(l.type===h.Alternator)u.alternatives.push(N()),e.current++;else{let f=u.alternatives.at(-1);f.elements.push(c(f,t))}l=De(a[e.current])}return o||(u=ur(u)),e.current++,u}function Xt({token:e,parent:t}){let{min:n,max:a,greedy:s,possessive:i}=e,o=t.elements.at(-1);if(!o||o.type===p.Assertion||o.type===p.Directive)throw new Error("Quantifier requires a repeatable token");let c=sr(o,n,a,s,i);return t.elements.pop(),c}function Zt(e){let{token:t,capturingGroups:n,subroutines:a}=e,s=t.raw.slice(3,-1),i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(i){let c=+i.groups.num,u=n.length;if(e.hasNumberedRef=!0,s={"":c,"+":u+c,"-":u+1-c}[i.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);let o=or(s);return a.push(o),o}function N(){return{type:p.Alternative,elements:[]}}function Me({type:e,kind:t,negate:n}){if(e===h.GroupOpen)return se({behind:t===k.lookbehind,negate:n});let a=F({"^":w.line_start,$:w.line_end,"\\A":w.string_start,"\\b":w.word_boundary,"\\B":w.word_boundary,"\\G":w.search_start,"\\z":w.string_end,"\\Z":w.string_end_newline}[t],`Unexpected assertion kind "${t}"`),s={type:p.Assertion,kind:a};return a===w.word_boundary&&(s.negate=t===g`\B`),s}function ne(e,{orphan:t}={}){return{type:p.Backreference,...t&&{orphan:t},ref:e}}function Jt(e){let{kind:t,number:n,name:a,flags:s}=e;switch(t){case k.atomic:return $({atomic:!0});case k.capturing:return Ce(n,a);case k.group:return $({flags:s});case k.lookahead:case k.lookbehind:return Me(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function Ce(e,t){let n=t!==void 0;if(n&&!lr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:p.CapturingGroup,number:e,...n&&{name:t},alternatives:[N()]}}function Be(e){return{type:p.Character,value:e}}function de(e){let t={baseOnly:!1,negate:!1,...e};return{type:p.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[Yt()]}}function Yt(){return{type:p.CharacterClassIntersection,classes:[de({negate:!1,baseOnly:!0})]}}function er(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:p.CharacterClassRange,min:e,max:t}}function tr({kind:e,flags:t}){let n={type:p.Directive,kind:F(X[e],`Unexpected directive kind "${e}"`)};return e===W.flags&&(n.flags=t),n}function rr({ignoreCase:e,dotAll:t,extended:n}){return{type:p.Flags,ignoreCase:e,dotAll:t,extended:n}}function $({atomic:e,flags:t}={}){return{type:p.Group,...e&&{atomic:e},...t&&{flags:t},alternatives:[N()]}}function se({behind:e=!1,negate:t=!1}={}){return{type:p.Assertion,kind:e?w.lookbehind:w.lookahead,negate:t,alternatives:[N()]}}function nr(){return{type:p.Pattern,alternatives:[N()]}}function sr(e,t,n,a,s){if(n<t)throw new Error("Quantifier range out of order");return{type:p.Quantifier,min:t,max:n,greedy:a,possessive:s,element:e}}function ar(e,t){return{type:p.Regex,pattern:e,flags:t}}function or(e){return{type:p.Subroutine,ref:e}}function O(e,t){let n={negate:!1,skipPropertyNameValidation:!1,...t};return{type:p.CharacterSet,kind:y.property,value:n.skipPropertyNameValidation?e:cr(e),negate:n.negate}}function ir(e){return{type:p.VariableLengthCharacterSet,kind:F({"\\R":z.newline,"\\X":z.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function cr(e){let t=Q(e);if(fe.has(t))throw new Error(g`Unicode property "\p{${e}}" unsupported in Oniguruma`);let n=pe.get(t);return n||e.trim().replace(/\s+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,a=>a[0].toUpperCase()+a.slice(1).toLowerCase())}function ur(e){let t=e.alternatives[0].elements[0];return e.type===p.Group&&L(e,n=>n.type===p.Group)&&!(e.atomic&&t.flags)&&!(e.flags&&(t.atomic||t.flags))?(e.atomic?t.atomic=!0:e.flags&&(t.flags=e.flags),t):e}function I({type:e,kind:t}){return e===p.Assertion&&(t===w.lookahead||t===w.lookbehind)}function lr(e){return!/^(?:[-\d]|$)/.test(e)}function pr(e){for(let t=0;t<e.classes.length;t++){let n=e.classes[t],a=n.elements[0];n.elements.length===1&&a.type===p.CharacterClass&&(e.classes[t]=a,a.negate=n.negate!==a.negate)}}function Ue(e){return F(e,"Unclosed character class")}function De(e){return F(e,"Unclosed group")}function je(e,t){let n=e.pattern.alternatives,a=n[0].elements[0];if(n.length>1||!a)return null;let s=L(e.pattern,u=>u.type===p.CapturingGroup||u.type===p.Group)&&a.alternatives.length===1,i=s?a.alternatives[0]:n[0],o=s?i.elements[0]:a;if(!o)return null;if((o.type===p.CapturingGroup||o.type===p.Group)&&o.alternatives.length===2&&o.alternatives[0].elements.length===1&&o.alternatives[1].elements.length===1){let u=o.alternatives[0].elements[0],l=o.alternatives[1].elements[0];if(u.kind===w.line_start&&l.kind===w.search_start||u.kind===w.search_start&&l.kind===w.line_start)return u.kind===w.line_start?o.alternatives.pop():o.alternatives.shift(),{name:"line_or_search_start"}}if(Ve(o))return o.parent.elements.shift(),{name:"not_search_start"};let c=i.elements.findIndex(u=>Ve(u));if(c>-1&&i.elements.every(u=>u.type===p.Assertion))return i.elements.splice(c,1),{name:"not_search_start"};if(o.kind===w.lookbehind&&!o.negate&&o.alternatives.length>1){let u=[],l=!1;if(o.alternatives.forEach(f=>{f.elements.length===1&&f.elements[0].kind===w.search_start?l=!0:u.push(f)}),l&&u.length){let f=!0;if(u.some(d=>d.elements.some(C=>C.type===p.CapturingGroup||C.type===p.Group||C.type===p.Subroutine||I(C))))if(t==="loose")f=!1;else throw new Error(r`Uses "\G" in a way that's unsupported`);if(f){let d=R($(),[R(N(),[O("<<",{skipPropertyNameValidation:!0})]),...u,R(N(),[O(">>",{skipPropertyNameValidation:!0})])]);return d.parent=o.parent,o.parent.elements[0]=d,{name:"after_search_start_or_subpattern"}}}}return null}function Ve(e){return I(e)&&e.negate&&L(e,t=>t.kind===w.search_start)}var me=String.raw,Ke=me`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,He=me`\u{E0061}-\u{E007A}`,Qe=()=>new RegExp(me`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${He}]{2}[\u{E0030}-\u{E0039}${He}]{1,3}\u{E007F}|${Ke}(?:\u200D${Ke})*`,"gu");function qe(e,t){let n={accuracy:"default",avoidSubclass:!1,bestEffortTarget:"ES2025",...t},a=n.avoidSubclass?null:je(e,n.accuracy),s={accuracy:n.accuracy,flagDirectivesByAlt:new Map,minTargetEs2024:H(n.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set};P({node:e},s,ze);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:s.subroutineRefMap};P({node:e},o,Xe);let c={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return P({node:e},c,fr),a&&(e._strategy=a),e}var ze={Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:a}){let s=e.elements.filter(i=>i.kind===X.flags);for(let i=n+1;i<t.alternatives.length;i++){let o=t.alternatives[i];B(a,o,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Ye(t.get(e));if(n){let a=J($({flags:n}),e.elements);a.parent=e,e.elements=[a]}}}},Assertion({node:e,ast:t,remove:n,replaceWith:a},{accuracy:s,supportedGNodes:i}){let{kind:o,negate:c}=e;if(o===w.line_end)a(v(g`(?=\z|\n)`));else if(o===w.line_start)a(v(g`(?<=\A|\n)`));else if(o===w.search_start){if(!i.has(e)&&s!=="loose")throw new Error(g`Uses "\G" in a way that's unsupported`);t.flags.sticky=!0,n()}else if(o===w.string_end_newline)a(v(g`(?=\n?\z)`));else if(o===w.word_boundary){let u=g`[\p{L}\p{N}\p{Pc}]`,l=`(?:(?<=${u})(?!${u})|(?<!${u})(?=${u}))`,f=`(?:(?<=${u})(?=${u})|(?<!${u})(?!${u}))`;a(v(c?f:l))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:n,number:a}=e;if(n&&!Cr(n))throw new Error(`Group name "${n}" invalid in JS`);t.set(n??a,e)},CharacterSet({node:e,replaceWith:t},{accuracy:n,minTargetEs2024:a}){let{kind:s,negate:i,value:o}=e;if(s===y.any)t(O("Any"));else if(s===y.hex)t(O("AHex",{negate:i}));else if(s===y.non_newline)t(v(g`[^\n]`));else if(s===y.posix)if(!a&&(o==="graph"||o==="print")){if(n==="strict")throw new Error(`POSIX class "${o}" requires min target ES2024 or non-strict accuracy`);let c={graph:"!-~",print:" -~"}[o];i&&(c=`\0-${A(c.codePointAt(0)-1)}${A(c.codePointAt(2)+1)}-\u{10FFFF}`),t(v(`[${c}]`))}else{let c=v(te.get(o));c.negate=i,t(c)}else if(s===y.property)le.has(o)||(e.key="sc");else if(s===y.space){let c=v(`[ | ||
\v\f\r]`);c.negate=i,t(c)}},Directive(e,t){let{node:n,parent:a,ast:s,remove:i,replaceWith:o,removeAllPrevSiblings:c,removeAllNextSiblings:u}=e,{kind:l,flags:f}=n;if(l===X.flags)if(!f.enable&&!f.disable)i();else{let d=J($({flags:f}),u());o(d),nt(d,e,t,ze)}else if(l===X.keep){if(a.parent!==s.pattern||s.pattern.alternatives.length>1)throw new Error(g`Uses "\K" in a way that's unsupported`);o(J(se({behind:!0}),c()))}},Flags({node:e,parent:t}){delete e.extended,Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},Pattern({node:e},{accuracy:t,supportedGNodes:n}){let a=[],s=!1,i=!1;for(let o of e.alternatives){let c=tt(o.elements);c?(s=!0,Array.isArray(c)?a.push(...c):a.push(c)):i=!0}if(s&&i&&t!=="loose")throw new Error(g`Uses "\G" in a way that's unsupported`);a.forEach(o=>n.add(o))},Quantifier({node:e}){if(e.element.type===p.Quantifier){let t=J($(),[e.element]);t.parent=e,e.element=t}},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:n,minTargetEs2024:a}){let{kind:s}=e;if(s===z.newline)t(v(`(?>\r | ||
?|[ | ||
\v\f\x85\u2028\u2029])`));else if(s===W.grapheme){if(n==="strict")throw new Error(g`Use of "\X" requires non-strict accuracy`);let i=a?g`\p{RGI_Emoji}`:Ke().source.replace(/\\u\{/g,g`\x{`);t(P(g`(?>\r\n|${i}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${s}"`)}},qe={Alternative({node:e},{namedGroupsInScopeByAlt:t}){let n=ne(e);if(n){let a=t.get(n);a&&t.set(e,a)}},Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByBackreference:n}){let{orphan:a,ref:s}=e;a||n.set(e,[...t.get(s).map(({node:i})=>i)])},CapturingGroup:{enter({node:e,replaceWith:t,skip:n},{groupOriginByCopy:a,groupsWithDuplicateNamesToRemove:s,multiplexCapturesToLeftByRef:i,namedGroupsInScopeByAlt:o,openDirectCaptures:c,openSubroutineRefs:u}){let{name:l,number:f}=e,h=l??f,C=a.get(e),m=ne(e);if(u.has(h))throw new Error("Unsupported indirect recursion");if(C?u.add(h):c.add(e),c.has(C)){t(He(h)),n();return}let A=O(i,h,[]);for(let S=0;S<A.length;S++){let F=A[S];if(C===F.node||C&&C===F.origin||e===F.origin){A.splice(S,1);break}}if(A.push({node:e,origin:C}),l){let S=O(o,m,new Map);S.has(l)&&s.add(S.get(l)),S.set(l,e);let F=ne(m);if(F)do O(o,F,new Map).set(l,e);while(F=ne(F))}},exit({node:e},{groupOriginByCopy:t,openDirectCaptures:n,openSubroutineRefs:a}){let{name:s,number:i}=e;t.get(e)?a.delete(s??i):n.delete(e)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=M(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine(e,t){let{node:n,replaceWith:a}=e,{ref:s}=n,i=t.subroutineRefMap.get(s),o=s===0,c=o?He(s):ze(i,t.groupOriginByCopy,null),u=c;if(!o){let l=Xe(pr(i,h=>h.type===p.Group&&!!h.flags)),f=l?M(t.globalFlags,l):t.globalFlags;ur(f,t.currentFlags)||(u=X(N({flags:fr(f)}),[c]))}a(u),o||et(u,e,t,qe)}},cr={Backreference({node:e,replaceWith:t},n){if(e.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,e.ref);return}let s=n.reffedNodesByBackreference.get(e).filter(i=>lr(i,e));if(!s.length)t(re({negate:!0}));else if(s.length>1){let i=s.map(o=>R(v(),[te(o.number)]));t(R(N(),i))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,t.groupsWithDuplicateNamesToRemove.has(e)&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let a=0;a<n;a++){let s=he();e.pattern.alternatives.at(-1).elements.push(s)}}}};function R(e,t){return t.forEach(n=>n.parent=e),e[me(e)]=t,e}function ur(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function lr(e,t){let n=t;do{if(n.type===p.Pattern)return!1;if(n.type===p.Alternative)continue;if(n===e)return!1;let a=Ze(n.parent);for(let s of a){if(s===n)break;if(s===e||Ye(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function ze(e,t,n,a){let s=Array.isArray(e)?[]:{};for(let[i,o]of Object.entries(e))i==="parent"?s.parent=Array.isArray(n)?a:n:o&&typeof o=="object"?s[i]=ze(o,t,s,n):(i==="type"&&o===p.CapturingGroup&&t.set(s,t.get(e)??e),s[i]=o);return s}function He(e){return{type:p.Recursion,ref:e}}function pr(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function me(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function Xe(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:a})=>{t.forEach(s=>{a.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),a.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function fr({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Ze(e){if(!e)throw new Error("Node expected");if(e.type===p.Quantifier)return[e.element];let t=me(e);return t&&e[t]}function Je(e){if(!e.length)return null;let t=e[0];if($(t)&&!t.negate&&t.alternatives.length===1&&t.alternatives[0].elements.length){let a=t.alternatives[0].elements,s=t.kind===w.lookahead?0:a.length-1;if(a[s].kind===w.search_start)return a[s]}let n=e.find(a=>a.kind===w.search_start?!0:a.type!==p.Directive&&a.type!==p.Assertion&&!(a.type===p.Quantifier&&!a.min));if(!n)return null;if(n.kind===w.search_start)return n;if(n.type===p.Group||n.type===p.CapturingGroup){let a=[];for(let s of n.alternatives){let i=Je(s.elements);if(!i)return null;Array.isArray(i)?a.push(...i):a.push(i)}return a}return null}function ne(e){for(;e=e.parent;)if(e.type===p.Alternative)return e;return null}function Ye(e,t){let n=Ze(e)??[];for(let a of n)if(a===t||Ye(a,t))return!0;return!1}function gr(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function P(e,{skipPropertyNameValidation:t}={}){let a=z(Q(e),{skipPropertyNameValidation:t}).pattern.alternatives;return a.length>1||a[0].elements.length>1?R(N(),a):a[0].elements[0]}function X(e,t){let n=me(e);return e[n][0].parent=e,t&&R(e[n][0],t),e}function et(e,{parent:t,key:n,container:a},s,i){G({node:e,parent:t,key:n,container:a},s,i)}function rt(e,t){let n=J(t),a=j(n.target,"ES2024"),s=j(n.target,"ES2025"),i=n.maxRecursionDepth;if(i!==null&&(!Number.isInteger(i)||i<2||i>100))throw new Error("Invalid maxRecursionDepth; use 2-100 or null");let o=null,c=null;if(!s){let m=[e.flags.ignoreCase];G({node:e},{getCurrentModI:()=>m.at(-1),popModI(){m.pop()},pushModI(A){m.push(A)},setHasCasedChar(){m.at(-1)?o=!0:c=!0}},dr)}let u={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!c)},l=null,f={accuracy:n.accuracy,appliedGlobalFlags:u,captureFlagIMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},groupNames:new Set,inCharClass:!1,lastNode:l,maxRecursionDepth:i,useAppliedIgnoreCase:!!(!s&&o&&c),useDuplicateNames:s,useFlagMods:s,useFlagV:a,usePostEs2018Properties:a,verbose:n.verbose};function h(m){switch(f.lastNode=l,l=m,m.type){case p.Regex:return{pattern:h(m.pattern),flags:h(m.flags),options:{...m.options}};case p.Alternative:return m.elements.map(h).join("");case p.Assertion:return wr(m,f,h);case p.Backreference:return Ar(m,f);case p.CapturingGroup:return _r(m,f,h);case p.Character:return kr(m,f);case p.CharacterClass:return Sr(m,f,h);case p.CharacterClassIntersection:if(!f.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return m.classes.map(h).join("&&");case p.CharacterClassRange:return yr(m,f);case p.CharacterSet:return xr(m,f);case p.Flags:return br(m,f);case p.Group:return Fr(m,f,h);case p.Pattern:return m.alternatives.map(h).join("|");case p.Quantifier:return h(m.element)+vr(m);case p.Recursion:return Ir(m,f);default:throw new Error(`Unexpected node type "${m.type}"`)}}let C=h(e);return a||(delete C.options.force.v,C.options.disable.v=!0,C.options.unicodeSetsPlugin=null),C}var dr={AnyGroup:{enter({node:e},t){let n=t.getCurrentModI();t.pushModI(e.flags?M({ignoreCase:n},e.flags).ignoreCase:n)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Ee(_(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),nt(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===x.property&&fe.has(e.value)&&t.setHasCasedChar()}},hr=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Cr=new Set(["-","\\","]","^"]),mr=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),tt=new Map([[9,g`\t`],[10,g`\n`],[11,g`\v`],[12,g`\f`],[13,g`\r`],[8232,g`\u2028`],[8233,g`\u2029`],[65279,g`\uFEFF`]]),Er=/^\p{Cased}$/u;function Ee(e){return Er.test(e)}function wr(e,t,n){let{kind:a,negate:s,alternatives:i}=e;if($(e))return`(?${`${a===w.lookahead?"":"<"}${s?"!":"="}`}${i.map(n).join("|")})`;if(a===w.string_end)return"$";if(a===w.string_start)return"^";throw new Error(`Unexpected assertion kind "${a}"`)}function Ar({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureFlagIMap.get(e))throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function _r({name:e,number:t,alternatives:n},a,s){return e&&(a.groupNames.has(e)?a.useDuplicateNames||(e=null):a.groupNames.add(e)),a.captureFlagIMap.set(t,a.currentFlags.ignoreCase),`(${e?`?<${e}>`:""}${n.map(s).join("|")})`}function kr({value:e},t){let n=_(e),a=B(e,{isAfterBackref:t.lastNode.type===p.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(a!==n)return a;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Ee(n)){let s=ce(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n}function Sr({negate:e,parent:t,elements:n},a,s){if(!e&&(!a.useFlagV||!a.verbose)&&t.type===p.CharacterClass&&n[0].type!==p.CharacterClassIntersection||!a.verbose&&t.type===p.CharacterClassIntersection&&n.length===1&&n[0].type!==p.CharacterClassRange)return n.map(s).join("");if(!a.useFlagV&&t.type===p.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");a.inCharClass=!0;let i=`[${e?"^":""}${n.map(s).join("")}]`;return a.inCharClass=!1,i}function yr(e,t){let n=e.min.value,a=e.max.value,s={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},i=B(n,s),o=B(a,s),c="";if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let u=nt(e);$r(u).forEach(f=>{c+=Array.isArray(f)?`${B(f[0],s)}-${B(f[1],s)}`:B(f,s)})}return`${i}-${o}${c}`}function xr({kind:e,negate:t,value:n,key:a},s){if(e===x.dot)return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":g`[^\n]`;if(e===x.digit)return t?g`\D`:g`\d`;if(e===x.property){if(!s.usePostEs2018Properties&&ye.has(n))throw new Error(`Unicode property "${n}" unavailable in target ES2018`);if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&fe.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?g`\P`:g`\p`}{${a?`${a}=`:""}${n}}`}if(e===x.word)return t?g`\W`:g`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function br(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function Fr({atomic:e,flags:t,parent:n,alternatives:a},s,i){let o=s.currentFlags;t&&(s.currentFlags=M(o,t));let c=a.map(i).join("|"),u=!s.verbose&&a.length===1&&n.type!==p.Quantifier&&!e&&(!s.useFlagMods||!t)?c:`(?${Nr(e,t,s.useFlagMods)}${c})`;return s.currentFlags=o,u}function Ir({ref:e},t){let n=t.maxRecursionDepth;if(!n)throw new Error("Use of recursion disabled");if(t.accuracy==="strict")throw new Error("Use of recursion requires non-strict accuracy due to depth limit");return e===0?`(?R=${n})`:g`\g<${e}&R=${n}>`}function nt(e,{firstOnly:t}={}){let n=e.min.value,a=e.max.value,s=[];if(n<65&&(a===65535||a>=131071)||n===65536&&a>=131071)return s;for(let i=n;i<=a;i++){let o=_(i);if(!Ee(o))continue;let c=ce(o).filter(u=>{let l=u.codePointAt(0);return l<n||l>a});if(c.length&&(s.push(...c),t))break}return s}function B(e,{isAfterBackref:t,inCharClass:n,useFlagV:a}){if(tt.has(e))return tt.get(e);if(e<32||e>126&&e<160||e>262143||t&&Pr(e))return e>255?g`\u{${e.toString(16).toUpperCase()}}`:g`\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let s=n?a?mr:Cr:hr,i=_(e);return(s.has(i)?"\\":"")+i}function $r(e){let t=e.map(s=>s.codePointAt(0)).sort((s,i)=>s-i),n=[],a=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?a??=t[s]:a===null?n.push(t[s]):(n.push([a,t[s]]),a=null);return n}function Nr(e,t,n){if(e)return">";let a="";if(t&&n){let{enable:s,disable:i}=t;a=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(i?"-":"")+(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")}return`${a}:`}function vr({min:e,max:t,greedy:n,possessive:a}){let s;return!e&&t===1?s="?":!e&&t===1/0?s="*":e===1&&t===1/0?s="+":e===t?s=`{${e}}`:s=`{${e},${t===1/0?"":t}}`,s+(a?"+":n?"":"?")}function Pr(e){return e>47&&e<58}var b=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function V(e,t,n,a){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1],o=0,c="";for(let u of e.matchAll(s)){let{0:l,groups:{$skip:f}}=u;if(!f&&(!a||a===b.DEFAULT==!o)){n instanceof Function?c+=n(u,{context:o?b.CHAR_CLASS:b.DEFAULT,negated:i[i.length-1]}):c+=n;continue}l[0]==="["?(o++,i.push(l[1]==="^")):l==="]"&&o&&(o--,i.pop()),c+=l}return c}function we(e,t,n,a){V(e,t,n,a)}function Gr(e,t,n=0,a){if(!new RegExp(t,"su").test(e))return null;let s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let i=0,o;for(;o=s.exec(e);){let{0:c,groups:{$skip:u}}=o;if(!u&&(!a||a===b.DEFAULT==!i))return o;c==="["?i++:c==="]"&&i&&i--,s.lastIndex==o.index&&s.lastIndex++}return null}function se(e,t,n){return!!Gr(e,t,0,n)}function st(e,t){let n=/\\?./gsu;n.lastIndex=t;let a=e.length,s=0,i=1,o;for(;o=n.exec(e);){let[c]=o;if(c==="[")s++;else if(s)c==="]"&&s--;else if(c==="(")i++;else if(c===")"&&(i--,!i)){a=o.index;break}}return e.slice(t,a)}var at={DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_U:"ENCLOSED_U",GROUP_NAME:"GROUP_NAME",INTERVAL_QUANTIFIER:"INTERVAL_QUANTIFIER",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN"},Ae={DEFAULT:"DEFAULT",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_Q:"ENCLOSED_Q",ENCLOSED_U:"ENCLOSED_U",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN",RANGE:"RANGE"},Pn=new Set([at.ENCLOSED_P,at.ENCLOSED_U]),Gn=new Set([Ae.ENCLOSED_P,Ae.ENCLOSED_Q,Ae.ENCLOSED_U]),Tn=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Ln=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),ot="$E$";var Tr=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,Rn=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${Tr}`,it=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;var Lr=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),On=new RegExp(String.raw` | ||
\v\f\x85\u2028\u2029])`));else if(s===z.grapheme){if(n==="strict")throw new Error(g`Use of "\X" requires non-strict accuracy`);let i=a?g`\p{RGI_Emoji}`:Qe().source.replace(/\\u\{/g,g`\x{`);t(v(g`(?>\r\n|${i}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${s}"`)}},Xe={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:a,ref:s}=e;a||n.set(e,[...t.get(s).map(({node:i})=>i)])},Recursion({node:e},{reffedNodesByReferencer:t}){let{ref:n}=e,a=e.parent;for(;(a=a.parent)&&!(a.type===p.CapturingGroup&&(a.name===n||a.number===n)););t.set(e,a)},CapturingGroup:{enter({node:e,replaceWith:t,skip:n},{groupOriginByCopy:a,groupsByName:s,multiplexCapturesToLeftByRef:i,openRefs:o,reffedNodesByReferencer:c}){let u=a.get(e),l=e.name??e.number;if(u&&o.has(l)){let d=We(l);c.set(d,o.get(l)),t(d),n();return}o.set(l,e);let f=B(i,l,[]);for(let d=0;d<f.length;d++){let C=f[d];if(u===C.node||u&&u===C.origin||e===C.origin){f.splice(d,1);break}}if(f.push({node:e,origin:u}),e.name){let d=B(s,e.name,new Map);for(let C of d.values())!C.hasDuplicateNameToRemove&&Ze(C.node,e,{ancestorsParticipate:!0})&&(C.hasDuplicateNameToRemove=!0);s.get(e.name).set(e,{node:e})}},exit({node:e},{openRefs:t}){t.delete(e.name??e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=M(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine(e,t){let{node:n,replaceWith:a}=e,{ref:s}=n,i=t.subroutineRefMap.get(s),o=s===0,c=o?We(s):Je(i,t.groupOriginByCopy,null),u=c;if(!o){let l=Ye(hr(i,d=>d.type===p.Group&&!!d.flags)),f=l?M(t.globalFlags,l):t.globalFlags;gr(f,t.currentFlags)||(u=J($({flags:dr(f)}),[c]))}a(u),o||nt(u,e,t,Xe)}},fr={Backreference({node:e,replaceWith:t},n){if(e.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,e.ref);return}let s=n.reffedNodesByReferencer.get(e).filter(i=>Ze(i,e,{ancestorsParticipate:!1}));if(!s.length)t(se({negate:!0}));else if(s.length>1){let i=s.map(o=>R(N(),[ne(o.number)]));t(R($(),i))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Recursion({node:e},t){e.ref!==0&&(e.ref=t.reffedNodesByReferencer.get(e).number)},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let a=0;a<n;a++){let s=Ce();e.pattern.alternatives.at(-1).elements.push(s)}}}};function R(e,t){return t.forEach(n=>n.parent=e),e[Ee(e)]=t,e}function gr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Ze(e,t,{ancestorsParticipate:n}){let a=t;do{if(a.type===p.Pattern)return!1;if(a.type===p.Alternative)continue;if(a===e)return n;let s=et(a.parent);for(let i of s){if(i===a)break;if(i===e||rt(i,e))return!0}}while(a=a.parent);throw new Error("Unexpected path")}function Je(e,t,n,a){let s=Array.isArray(e)?[]:{};for(let[i,o]of Object.entries(e))i==="parent"?s.parent=Array.isArray(n)?a:n:o&&typeof o=="object"?s[i]=Je(o,t,s,n):(i==="type"&&o===p.CapturingGroup&&t.set(s,t.get(e)??e),s[i]=o);return s}function We(e){return{type:p.Recursion,ref:e}}function hr(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Ee(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function Ye(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:a})=>{t.forEach(s=>{a.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),a.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function dr({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function et(e){if(!e)throw new Error("Node expected");if(e.type===p.Quantifier)return[e.element];let t=Ee(e);return t&&e[t]}function tt(e){function t(s){return s.kind===w.search_start||I(s)&&!s.negate&&L(s,i=>i.kind===w.search_start)}function n(s){return s.type===p.Assertion||s.type===p.Directive||s.type===p.Quantifier&&!s.min}let a=e.find(s=>t(s)||!n(s));if(!a)return null;if(a.kind===w.search_start)return a;if(I(a))return a.alternatives[0].elements[0];if(a.type===p.Group||a.type===p.CapturingGroup){let s=[];for(let i of a.alternatives){let o=tt(i.elements);if(!o)return null;Array.isArray(o)?s.push(...o):s.push(o)}return s}return null}function rt(e,t){let n=et(e)??[];for(let a of n)if(a===t||rt(a,t))return!0;return!1}function Cr(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function v(e,{skipPropertyNameValidation:t}={}){let a=Z(q(e),{skipPropertyNameValidation:t}).pattern.alternatives;return a.length>1||a[0].elements.length>1?R($(),a):a[0].elements[0]}function J(e,t){let n=Ee(e);return e[n][0].parent=e,t&&R(e[n][0],t),e}function nt(e,{parent:t,key:n,container:a},s,i){P({node:e,parent:t,key:n,container:a},s,i)}function at(e,t){let n=ee(t),a=H(n.target,"ES2024"),s=H(n.target,"ES2025"),i=n.maxRecursionDepth;if(i!==null&&(!Number.isInteger(i)||i<2||i>100))throw new Error("Invalid maxRecursionDepth; use 2-100 or null");let o=null,c=null;if(!s){let m=[e.flags.ignoreCase];P({node:e},{getCurrentModI:()=>m.at(-1),popModI(){m.pop()},pushModI(_){m.push(_)},setHasCasedChar(){m.at(-1)?o=!0:c=!0}},mr)}let u={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!c)},l=null,f={accuracy:n.accuracy,appliedGlobalFlags:u,captureFlagIMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},groupNames:new Set,inCharClass:!1,lastNode:l,maxRecursionDepth:i,useAppliedIgnoreCase:!!(!s&&o&&c),useDuplicateNames:s,useFlagMods:s,useFlagV:a,usePostEs2018Properties:a,verbose:n.verbose};function d(m){switch(f.lastNode=l,l=m,m.type){case p.Regex:return{pattern:d(m.pattern),flags:d(m.flags),options:{...m.options}};case p.Alternative:return m.elements.map(d).join("");case p.Assertion:return Sr(m,f,d);case p.Backreference:return kr(m,f);case p.CapturingGroup:return yr(m,f,d);case p.Character:return br(m,f);case p.CharacterClass:return xr(m,f,d);case p.CharacterClassIntersection:if(!f.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return m.classes.map(d).join("&&");case p.CharacterClassRange:return Fr(m,f);case p.CharacterSet:return Ir(m,f);case p.Flags:return $r(m,f);case p.Group:return Nr(m,f,d);case p.Pattern:return m.alternatives.map(d).join("|");case p.Quantifier:return d(m.element)+Rr(m);case p.Recursion:return vr(m,f);default:throw new Error(`Unexpected node type "${m.type}"`)}}let C=d(e);return a||(delete C.options.force.v,C.options.disable.v=!0,C.options.unicodeSetsPlugin=null),C}var mr={AnyGroup:{enter({node:e},t){let n=t.getCurrentModI();t.pushModI(e.flags?M({ignoreCase:n},e.flags).ignoreCase:n)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){we(A(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),ot(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===y.property&&ge.has(e.value)&&t.setHasCasedChar()}},Er=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),wr=new Set(["-","\\","]","^"]),_r=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),st=new Map([[9,g`\t`],[10,g`\n`],[11,g`\v`],[12,g`\f`],[13,g`\r`],[8232,g`\u2028`],[8233,g`\u2029`],[65279,g`\uFEFF`]]),Ar=/^\p{Cased}$/u;function we(e){return Ar.test(e)}function Sr(e,t,n){let{kind:a,negate:s,alternatives:i}=e;if(I(e))return`(?${`${a===w.lookahead?"":"<"}${s?"!":"="}`}${i.map(n).join("|")})`;if(a===w.string_end)return"$";if(a===w.string_start)return"^";throw new Error(`Unexpected assertion kind "${a}"`)}function kr({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureFlagIMap.get(e))throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function yr({name:e,number:t,alternatives:n},a,s){return e&&(a.groupNames.has(e)?a.useDuplicateNames||(e=null):a.groupNames.add(e)),a.captureFlagIMap.set(t,a.currentFlags.ignoreCase),`(${e?`?<${e}>`:""}${n.map(s).join("|")})`}function br({value:e},t){let n=A(e),a=V(e,{isAfterBackref:t.lastNode.type===p.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(a!==n)return a;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&we(n)){let s=ue(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n}function xr({negate:e,parent:t,elements:n},a,s){if(!e&&(!a.useFlagV||!a.verbose)&&t.type===p.CharacterClass&&n[0].type!==p.CharacterClassIntersection||!a.verbose&&t.type===p.CharacterClassIntersection&&n.length===1&&n[0].type!==p.CharacterClassRange)return n.map(s).join("");if(!a.useFlagV&&t.type===p.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");a.inCharClass=!0;let i=`[${e?"^":""}${n.map(s).join("")}]`;return a.inCharClass=!1,i}function Fr(e,t){let n=e.min.value,a=e.max.value,s={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},i=V(n,s),o=V(a,s),c="";if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let u=ot(e);Pr(u).forEach(f=>{c+=Array.isArray(f)?`${V(f[0],s)}-${V(f[1],s)}`:V(f,s)})}return`${i}-${o}${c}`}function Ir({kind:e,negate:t,value:n,key:a},s){if(e===y.dot)return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":g`[^\n]`;if(e===y.digit)return t?g`\D`:g`\d`;if(e===y.property){if(!s.usePostEs2018Properties&&xe.has(n))throw new Error(`Unicode property "${n}" unavailable in target ES2018`);if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&ge.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?g`\P`:g`\p`}{${a?`${a}=`:""}${n}}`}if(e===y.word)return t?g`\W`:g`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function $r(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function Nr({atomic:e,flags:t,parent:n,alternatives:a},s,i){let o=s.currentFlags;t&&(s.currentFlags=M(o,t));let c=a.map(i).join("|"),u=!s.verbose&&a.length===1&&n.type!==p.Quantifier&&!e&&(!s.useFlagMods||!t)?c:`(?${Gr(e,t,s.useFlagMods)}${c})`;return s.currentFlags=o,u}function vr({ref:e},t){let n=t.maxRecursionDepth;if(!n)throw new Error("Use of recursion disabled");if(t.accuracy==="strict")throw new Error("Use of recursion requires non-strict accuracy due to depth limit");return e===0?`(?R=${n})`:g`\g<${e}&R=${n}>`}function ot(e,{firstOnly:t}={}){let n=e.min.value,a=e.max.value,s=[];if(n<65&&(a===65535||a>=131071)||n===65536&&a>=131071)return s;for(let i=n;i<=a;i++){let o=A(i);if(!we(o))continue;let c=ue(o).filter(u=>{let l=u.codePointAt(0);return l<n||l>a});if(c.length&&(s.push(...c),t))break}return s}function V(e,{isAfterBackref:t,inCharClass:n,useFlagV:a}){if(st.has(e))return st.get(e);if(e<32||e>126&&e<160||e>262143||t&&Tr(e))return e>255?g`\u{${e.toString(16).toUpperCase()}}`:g`\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let s=n?a?_r:wr:Er,i=A(e);return(s.has(i)?"\\":"")+i}function Pr(e){let t=e.map(s=>s.codePointAt(0)).sort((s,i)=>s-i),n=[],a=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?a??=t[s]:a===null?n.push(t[s]):(n.push([a,t[s]]),a=null);return n}function Gr(e,t,n){if(e)return">";let a="";if(t&&n){let{enable:s,disable:i}=t;a=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(i?"-":"")+(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")}return`${a}:`}function Rr({min:e,max:t,greedy:n,possessive:a}){let s;return!e&&t===1?s="?":!e&&t===1/0?s="*":e===1&&t===1/0?s="+":e===t?s=`{${e}}`:s=`{${e},${t===1/0?"":t}}`,s+(a?"+":n?"":"?")}function Tr(e){return e>47&&e<58}var b=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function j(e,t,n,a){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1],o=0,c="";for(let u of e.matchAll(s)){let{0:l,groups:{$skip:f}}=u;if(!f&&(!a||a===b.DEFAULT==!o)){n instanceof Function?c+=n(u,{context:o?b.CHAR_CLASS:b.DEFAULT,negated:i[i.length-1]}):c+=n;continue}l[0]==="["?(o++,i.push(l[1]==="^")):l==="]"&&o&&(o--,i.pop()),c+=l}return c}function _e(e,t,n,a){j(e,t,n,a)}function Lr(e,t,n=0,a){if(!new RegExp(t,"su").test(e))return null;let s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let i=0,o;for(;o=s.exec(e);){let{0:c,groups:{$skip:u}}=o;if(!u&&(!a||a===b.DEFAULT==!i))return o;c==="["?i++:c==="]"&&i&&i--,s.lastIndex==o.index&&s.lastIndex++}return null}function ae(e,t,n){return!!Lr(e,t,0,n)}function it(e,t){let n=/\\?./gsu;n.lastIndex=t;let a=e.length,s=0,i=1,o;for(;o=n.exec(e);){let[c]=o;if(c==="[")s++;else if(s)c==="]"&&s--;else if(c==="(")i++;else if(c===")"&&(i--,!i)){a=o.index;break}}return e.slice(t,a)}var ct={DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_U:"ENCLOSED_U",GROUP_NAME:"GROUP_NAME",INTERVAL_QUANTIFIER:"INTERVAL_QUANTIFIER",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN"},Ae={DEFAULT:"DEFAULT",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_Q:"ENCLOSED_Q",ENCLOSED_U:"ENCLOSED_U",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN",RANGE:"RANGE"},Ln=new Set([ct.ENCLOSED_P,ct.ENCLOSED_U]),On=new Set([Ae.ENCLOSED_P,Ae.ENCLOSED_Q,Ae.ENCLOSED_U]),Un=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Dn=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),ut="$E$";var Or=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,Mn=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${Or}`,lt=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;var Ur=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),Bn=new RegExp(String.raw` | ||
\\(?: c[A-Za-z] | ||
| p\{(?<pStrProp>${Lr})\} | ||
| p\{(?<pStrProp>${Ur})\} | ||
| [pP]\{[^\}]+\} | ||
@@ -45,3 +45,3 @@ | (?<qStrProp>q) | ||
| . | ||
`.replace(/\s+/g,""),"gsu");var Un=new RegExp(String.raw` | ||
`.replace(/\s+/g,""),"gsu");var Vn=new RegExp(String.raw` | ||
(?<groupN>\(\?<(?![=!])|\\[gk]<) | ||
@@ -59,3 +59,3 @@ | (?<enclosedPU>\\[pPu]\{) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ct(e,t,n,a){return e.slice(0,t)+a+e.slice(t+n.length)}var ut=new RegExp(String.raw`(?<noncapturingStart>${it})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function lt(e,t){if(!/\(\?>/.test(e))return e;let n="(?>",a=`(?:(?=(${t?.useEmulationGroups?ot:""}`,s=[0],i=0,o=0,c=NaN,u;do{u=!1;let l=0,f=0,h=!1,C;for(ut.lastIndex=Number.isNaN(c)?0:c+a.length;C=ut.exec(e);){let{0:m,index:A,groups:{capturingStart:S,noncapturingStart:F}}=C;if(m==="[")l++;else if(l)m==="]"&&l--;else if(m===n&&!h)c=A,h=!0;else if(h&&F)f++;else if(S)h?f++:(i++,s.push(i+o));else if(m===")"&&h){if(!f){o++,e=`${e.slice(0,c)}${a}${e.slice(c+n.length,A)}))<$$${o+i}>)${e.slice(A+1)}`,u=!0;break}f--}}}while(u);return e=V(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:l,groups:{backrefNum:f,wrappedBackrefNum:h}})=>{if(f){let C=+f;if(C>s.length-1)throw new Error(`Backref "${l}" greater than number of captures`);return`\\${s[C]}`}return`\\${h}`},b.DEFAULT),e}var pt=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,_e=new RegExp(String.raw` | ||
`.replace(/\s+/g,""),"gsu");function pt(e,t,n,a){return e.slice(0,t)+a+e.slice(t+n.length)}var ft=new RegExp(String.raw`(?<noncapturingStart>${lt})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function gt(e,t){if(!/\(\?>/.test(e))return e;let n="(?>",a=`(?:(?=(${t?.useEmulationGroups?ut:""}`,s=[0],i=0,o=0,c=NaN,u;do{u=!1;let l=0,f=0,d=!1,C;for(ft.lastIndex=Number.isNaN(c)?0:c+a.length;C=ft.exec(e);){let{0:m,index:_,groups:{capturingStart:T,noncapturingStart:D}}=C;if(m==="[")l++;else if(l)m==="]"&&l--;else if(m===n&&!d)c=_,d=!0;else if(d&&D)f++;else if(T)d?f++:(i++,s.push(i+o));else if(m===")"&&d){if(!f){o++,e=`${e.slice(0,c)}${a}${e.slice(c+n.length,_)}))<$$${o+i}>)${e.slice(_+1)}`,u=!0;break}f--}}}while(u);return e=j(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:l,groups:{backrefNum:f,wrappedBackrefNum:d}})=>{if(f){let C=+f;if(C>s.length-1)throw new Error(`Backref "${l}" greater than number of captures`);return`\\${s[C]}`}return`\\${d}`},b.DEFAULT),e}var ht=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Se=new RegExp(String.raw` | ||
\\(?: \d+ | ||
@@ -73,5 +73,5 @@ | c[A-Za-z] | ||
))? | ||
| (?<qBase>${pt})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| (?<qBase>${ht})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ft(e){if(!new RegExp(`${pt}\\+`).test(e))return e;let t=[],n=null,a=null,s="",i=0,o;for(_e.lastIndex=0;o=_e.exec(e);){let{0:c,index:u,groups:{qBase:l,qMod:f,invalidQ:h}}=o;if(c==="[")i||(a=u),i++;else if(c==="]")i?i--:a=null;else if(!i)if(f==="+"&&s&&!s.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${c}"`);let C=-1;if(/^\{\d+\}$/.test(l))e=ct(e,u+l.length,f,"");else{if(s===")"||s==="]"){let m=s===")"?n:a;if(m===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,m)}(?>${e.slice(m,u)}${l})${e.slice(u+c.length)}`}else e=`${e.slice(0,u-s.length)}(?>${s}${l})${e.slice(u+c.length)}`;C+=4}_e.lastIndex+=C}else c[0]==="("?t.push(u):c===")"&&(n=t.length?t.pop():null);s=c}return e}var Rr=String.raw`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ke=String.raw`\(\?R=(?<rDepth>[^\)]+)\)|${Rr}`,Se=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,D=new RegExp(String.raw`${Se}|${ke}|\\?.`,"gsu");function mt(e){if(!new RegExp(ke,"su").test(e))return e;if(se(e,String.raw`\\[1-9]`,b.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion; use named backref");if(se(e,String.raw`\(\?\(DEFINE\)`,b.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let t=new Map,n=[],a=0,s=0,i;for(D.lastIndex=0;i=D.exec(e);){let{0:o,groups:{captureName:c,rDepth:u,gRNameOrNum:l,gRDepth:f}}=i;if(o==="[")a++;else if(a)o==="]"&&a--;else if(u){gt(u);let h=e.slice(0,i.index),C=e.slice(D.lastIndex);return dt(C),ht(h,C,+u,!1)}else if(l){if(gt(f),dt(e.slice(D.lastIndex)),!n.some(S=>S.name===l||S.num===+l))throw new Error(`Recursion via \\g<${l}&R=${f}> must be used within the referenced group`);let h=t.get(l),C=st(e,h),m=e.slice(h,i.index),A=C.slice(m.length+o.length);return e.slice(0,h)+ht(m,A,+f,!0)+e.slice(h+C.length)}else if(c)s++,t.set(String(s),D.lastIndex),t.set(c,D.lastIndex),n.push({num:s,name:c});else if(o.startsWith("(")){let h=o==="(";h&&(s++,t.set(String(s),D.lastIndex)),n.push(h?{num:s}:{})}else o===")"&&n.pop()}return e}function gt(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function dt(e){if(se(e,ke,b.DEFAULT))throw new Error("Recursion can only be used once per regex")}function ht(e,t,n,a){let s=new Set;a&&we(e+t,Se,({groups:{captureName:o}})=>{s.add(o)},b.DEFAULT);let i=n-1;return`${e}${Ct(`(?:${e}`,i,a?s:null)}(?:)${Ct(`${t})`,i,a?s:null,"backward")}${t}`}function Ct(e,t,n,a="forward"){let i=c=>a==="backward"?t-c+2-1:c+2,o="";for(let c=0;c<t;c++){let u=i(c);o+=V(e,String.raw`${Se}|\\k<(?<backref>[^>]+)>`,({0:l,groups:{captureName:f,backref:h}})=>{if(h&&n&&!n.has(h))return l;let C=`_$${u}`;return f?`(?<${f}${C}>`:`\\k<${h}${C}>`},b.DEFAULT)}return o}function Et(e,t){let n=J(t),a=Q(e,n.flags),s=z(a,{skipBackrefValidation:n.tmGrammar,verbose:n.verbose}),i=Qe(s,{accuracy:n.accuracy,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=rt(i,n),c=lt(ft(mt(o.pattern))),u;i._strategy&&(c=c.replace(/\(\?:\\p{sc=<<}\|(.*?)\|\\p{sc=>>}\)/s,(f,h)=>(u=h,"")));let l={pattern:c,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};return i._strategy&&(l.strategy={...i._strategy},u&&(l.strategy.subpattern=u)),l}function Or(e,t){return z(Q(e,t?.flags))}function Ur(e,t){let n=Et(e,t);return n.strategy?new ae(n.pattern,n.flags,n.strategy):new RegExp(n.pattern,n.flags)}var ae=class e extends RegExp{#e;constructor(t,n,a){super(t,n),a?this.#e=a:t instanceof e&&(this.#e=t.#e)}exec(t){let n=this.global||this.sticky,a=this.lastIndex,s=RegExp.prototype.exec;if(this.#e.name==="line_or_search_start"&&n&&this.lastIndex){this.lastIndex=0;let o=s.call(this,t.slice(a));return o&&(o.input=t,o.index+=a,this.lastIndex+=a),o}let i=n?this:new RegExp(this,`g${this.flags}`);if(this.#e.name==="not_search_start"){let o=s.call(this,t);return o?.index===a&&(i.lastIndex=o.index+1,o=s.call(i,t)),o}if(this.#e.name==="after_search_start_or_subpattern"){let o=s.call(this,t);if(!o||o.index===a)return o;let c=new RegExp(`(?:${this.#e.subpattern})$`);for(;o;){if(c.exec(t.slice(0,o.index)))return o;i.lastIndex=o.index+1,o=s.call(i,t)}return o}return s.call(this,t)}};return yt(Dr);})(); | ||
`.replace(/\s+/g,""),"gsu");function dt(e){if(!new RegExp(`${ht}\\+`).test(e))return e;let t=[],n=null,a=null,s="",i=0,o;for(Se.lastIndex=0;o=Se.exec(e);){let{0:c,index:u,groups:{qBase:l,qMod:f,invalidQ:d}}=o;if(c==="[")i||(a=u),i++;else if(c==="]")i?i--:a=null;else if(!i)if(f==="+"&&s&&!s.startsWith("(")){if(d)throw new Error(`Invalid quantifier "${c}"`);let C=-1;if(/^\{\d+\}$/.test(l))e=pt(e,u+l.length,f,"");else{if(s===")"||s==="]"){let m=s===")"?n:a;if(m===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,m)}(?>${e.slice(m,u)}${l})${e.slice(u+c.length)}`}else e=`${e.slice(0,u-s.length)}(?>${s}${l})${e.slice(u+c.length)}`;C+=4}Se.lastIndex+=C}else c[0]==="("?t.push(u):c===")"&&(n=t.length?t.pop():null);s=c}return e}var Dr=String.raw`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ye=String.raw`\(\?R=(?<rDepth>[^\)]+)\)|${Dr}`,be=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,U=new RegExp(String.raw`${be}|${ye}|\(\?|\\?.`,"gsu"),ke="Cannot use multiple overlapping recursions";function wt(e){if(!new RegExp(ye,"su").test(e))return e;if(ae(e,String.raw`\\[1-9]`,b.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion");if(ae(e,String.raw`\(\?\(DEFINE\)`,b.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let t=new Map,n=[],a=!1,s=0,i=0,o;for(U.lastIndex=0;o=U.exec(e);){let{0:c,groups:{captureName:u,rDepth:l,gRNameOrNum:f,gRDepth:d}}=o;if(c==="[")s++;else if(s)c==="]"&&s--;else if(l){if(Ct(l),a)throw new Error(ke);let C=e.slice(0,o.index),m=e.slice(U.lastIndex);if(ae(m,ye,b.DEFAULT))throw new Error(ke);return mt(C,m,+l,!1)}else if(f){Ct(d);let C=!1;for(let K of n)if(K.name===f||K.num===+f){if(C=!0,K.hasRecursedWithin)throw new Error(ke);break}if(!C)throw new Error(`Recursive \\g cannot be used outside the referenced group "\\g<${f}&R=${d}>"`);let m=t.get(f),_=it(e,m),T=e.slice(m,o.index),D=_.slice(T.length+c.length),x=mt(T,D,+d,!0),At=e.slice(0,m),St=e.slice(m+_.length);e=`${At}${x}${St}`,U.lastIndex+=x.length-c.length-T.length-D.length,n.forEach(K=>K.hasRecursedWithin=!0),a=!0}else if(u)i++,t.set(String(i),U.lastIndex),t.set(u,U.lastIndex),n.push({num:i,name:u});else if(c.startsWith("(")){let C=c==="(";C&&(i++,t.set(String(i),U.lastIndex)),n.push(C?{num:i}:{})}else c===")"&&n.pop()}return e}function Ct(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function mt(e,t,n,a){let s=new Set;a&&_e(e+t,be,({groups:{captureName:o}})=>{s.add(o)},b.DEFAULT);let i=n-1;return`${e}${Et(`(?:${e}`,i,a?s:null)}(?:)${Et(`${t})`,i,a?s:null,"backward")}${t}`}function Et(e,t,n,a="forward"){let i=c=>a==="backward"?t-c+2-1:c+2,o="";for(let c=0;c<t;c++){let u=i(c);o+=j(e,String.raw`${be}|\\k<(?<backref>[^>]+)>`,({0:l,groups:{captureName:f,backref:d}})=>{if(d&&n&&!n.has(d))return l;let C=`_$${u}`;return f?`(?<${f}${C}>`:`\\k<${d}${C}>`},b.DEFAULT)}return o}function _t(e,t){let n=ee(t),a=q(e,n.flags),s=Z(a,{skipBackrefValidation:n.tmGrammar,verbose:n.verbose}),i=qe(s,{accuracy:n.accuracy,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=at(i,n),c=gt(dt(wt(o.pattern))),u;i._strategy&&(c=c.replace(/\(\?:\\p{sc=<<}\|(.*?)\|\\p{sc=>>}\)/s,(f,d)=>(u=d,"")));let l={pattern:c,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};return i._strategy&&(l.strategy={...i._strategy},u&&(l.strategy.subpattern=u)),l}function Mr(e,t){return Z(q(e,t?.flags))}function Br(e,t){let n=_t(e,t);return n.strategy?new oe(n.pattern,n.flags,n.strategy):new RegExp(n.pattern,n.flags)}var oe=class e extends RegExp{#e;constructor(t,n,a){super(t,n),a?this.#e=a:t instanceof e&&(this.#e=t.#e)}exec(t){let n=this.global||this.sticky,a=this.lastIndex,s=RegExp.prototype.exec;if(this.#e.name==="line_or_search_start"&&n&&this.lastIndex){this.lastIndex=0;let i=s.call(this,t.slice(a));return i&&(i.input=t,i.index+=a,this.lastIndex+=a),i}if(this.#e.name==="not_search_start"){let i=s.call(this,t);if(i?.index===a){let o=n?this:new RegExp(this.source,`g${this.flags}`);o.lastIndex=i.index+1,i=s.call(o,t)}return i}if(this.#e.name==="after_search_start_or_subpattern"){let i=s.call(this,t);if(!i||i.index===a)return i;let o=new RegExp(`(?<=${this.#e.subpattern})${this.source}`,this.flags);return o.lastIndex=a,i=s.call(o,t),this.lastIndex=o.lastIndex,i}return s.call(this,t)}};return It(Vr);})(); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "oniguruma-to-es", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Convert Oniguruma patterns to native JavaScript RegExp", | ||
@@ -47,3 +47,3 @@ "author": "Steven Levithan", | ||
"regex": "^4.4.0", | ||
"regex-recursion": "^4.1.0" | ||
"regex-recursion": "^4.2.1" | ||
}, | ||
@@ -50,0 +50,0 @@ "devDependencies": { |
@@ -220,5 +220,5 @@ # Oniguruma-To-ES | ||
*Default: `6`.* | ||
*Default: `5`.* | ||
Specifies the recursion depth limit. Supported values are integers `2` to `100` and `null`. If `null`, any use of recursion results in an error. | ||
Specifies the recursion depth limit. Supported values are integers `2`–`100` and `null`. If `null`, any use of recursion results in an error. | ||
@@ -230,5 +230,3 @@ Since recursion isn't infinite-depth like in Oniguruma, use of recursion also results in an error if using strict `accuracy`. | ||
Using a high limit has a (usually tiny) impact on transpilation and regex performance. Generally, this is only a problem if the regex has an existing issue with runaway backtracking that recursion exacerbates. | ||
Higher limits have no effect on regexes that don't use recursion, so you should feel free to increase this if helpful. | ||
Using a high limit has a small impact on performance. Generally, this is only a problem if the regex has an existing issue with runaway backtracking that recursion exacerbates. Higher limits have no effect on regexes that don't use recursion, so you should feel free to increase this if helpful. | ||
</details> | ||
@@ -959,3 +957,3 @@ | ||
5. It's not an error for *numbered* backreferences to come before their referenced group in Oniguruma, but an error is the best path for Oniguruma-To-ES because (1) most placements are mistakes and can never match (based on the Oniguruma behavior for backreferences to nonparticipating groups), (2) erroring matches the behavior of named backreferences, and (3) the edge cases where they're matchable rely on rules for backreference resetting within quantified groups that are different in JavaScript and aren't emulatable. Note that it's not a backreference in the first place if using `\10` or higher and not as many capturing groups are defined to the left (it's an octal or identity escape). | ||
6. The recursion depth limit is specified by option `maxRecursionDepth`. Some forms of recursion (multiple recursions in the same pattern, and recursion with backreferences) aren't yet supported. Patterns that would error in Oniguruma due to triggering infinite recursion might find a match in Oniguruma-To-ES since recursion is bounded (future versions will detect this and error at transpilation time). | ||
6. The recursion depth limit is specified by option `maxRecursionDepth`. Use of backreferences with recursion isn't yet supported. Patterns that would error in Oniguruma due to triggering infinite recursion might find a match in Oniguruma-To-ES since recursion is bounded (future versions will detect this and error at transpilation time). | ||
@@ -962,0 +960,0 @@ ## ㊗️ Unicode / mixed case-sensitivity |
@@ -30,3 +30,3 @@ export type RegexAst = { | ||
to representing native ES2025 `RegExp` but with some added features (atomic groups, possessive | ||
quantifiers, recursion). The AST doesn't use some of Regex+'s extended features like flag `x` or | ||
quantifiers, recursion). The AST doesn't use some of Regex+'s extended features like flag x or | ||
subroutines because they follow PCRE behavior and work somewhat differently than in Oniguruma. The | ||
@@ -33,0 +33,0 @@ AST represents what's needed to precisely reproduce Oniguruma behavior using Regex+. |
@@ -10,2 +10,3 @@ export const cp: any; | ||
export function getOrCreate(map: any, key: any, defaultValue: any): any; | ||
export function hasOnlyChild(node: any, kidFn: any): any; | ||
/** | ||
@@ -12,0 +13,0 @@ @param {keyof Target} target |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
683144
307575
4025
986
Updatedregex-recursion@^4.2.1