| 44 | `,a);return{lastIndex:r===-1?e.length:r}}if(/^\s$/.test(t)){const r=/\s+/y;return r.lastIndex=a,{lastIndex:r.exec(e)?r.lastIndex:a}}}if(t===".")return{token:be("dot",t)};if(t==="^"||t==="$"){const r=n.singleline?{"^":P`\A`,$:P`\Z`}[t]:t;return{token:_a(r,t)}}return t==="|"?{token:lo(t)}:Xn.test(t)?{tokens:Eo(t)}:{token:Q(Ee(t),t)}}function oo(n,e,t){const a=[xa(e[1]==="^",e)];let s=1,i;for(Yn.lastIndex=t;i=Yn.exec(n);){const r=i[0];if(r[0]==="["&&r[1]!==":")s++,a.push(xa(r[1]==="^",r));else if(r==="]"){if(a.at(-1).type==="CharacterClassOpen")a.push(Q(93,r));else if(s--,a.push(uo(r)),!s)break}else{const c=co(r);Array.isArray(c)?a.push(...c):a.push(c)}}return{tokens:a,lastIndex:Yn.lastIndex||n.length}}function co(n){if(n[0]==="\\")return ya(n,{inCharClass:!0});if(n[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(n);if(!e||!Vn.has(e.groups.name))throw new Error(`Invalid POSIX class "${n}"`);return be("posix",n,{value:e.groups.name,negate:!!e.groups.negate})}return n==="-"?mo(n):n==="&&"?po(n):Q(Ee(n),n)}function ya(n,{inCharClass:e}){const t=n[1];if(t==="c"||t==="C")return $o(n);if("dDhHsSwW".includes(t))return ko(n);if(n.startsWith(P`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${n}"`);if(/^\\[pP]\{/.test(n)){if(n.length===3)throw new Error(`Incomplete or invalid Unicode property "${n}"`);return jo(n)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(n))try{const a=n.split(/\\x/).slice(1).map(r=>parseInt(r,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(a)),i=new TextEncoder;return[...s].map(r=>{const c=[...i.encode(r)].map(o=>`\\x${o.toString(16)}`).join("");return Q(Ee(r),c)})}catch(a){throw new Error(`Multibyte code "${n}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return Q(Co(n),n);if(ka.has(t))return Q(ka.get(t),n);if(/\d/.test(t))return go(e,n);if(n==="\\")throw new Error(P`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${n}"`);if([...n].length===2)return Q(n.codePointAt(1),n);throw new Error(`Unexpected escape "${n}"`)}function lo(n){return{type:"Alternator",raw:n}}function _a(n,e){return{type:"Assertion",kind:n,raw:e}}function $a(n){return{type:"Backreference",raw:n}}function Q(n,e){return{type:"Character",value:n,raw:e}}function uo(n){return{type:"CharacterClassClose",raw:n}}function mo(n){return{type:"CharacterClassHyphen",raw:n}}function po(n){return{type:"CharacterClassIntersector",raw:n}}function xa(n,e){return{type:"CharacterClassOpen",negate:n,raw:e}}function be(n,e,t={}){return{type:"CharacterSet",kind:n,...t,raw:e}}function wa(n,e,t={}){return n==="keep"?{type:"Directive",kind:n,raw:e}:{type:"Directive",kind:n,flags:qe(t.flags),raw:e}}function go(n,e){return{type:"EscapedNumber",inCharClass:n,raw:e}}function bo(n){return{type:"GroupClose",raw:n}}function Ae(n,e,t={}){return{type:"GroupOpen",kind:n,...t,raw:e}}function ho(n,e,t,a){return{type:"NamedCallout",kind:n,tag:e,arguments:t,raw:a}}function fo(n,e,t,a){return{type:"Quantifier",kind:n,min:e,max:t,raw:a}}function yo(n){return{type:"Subroutine",raw:n}}const _o=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),ka=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function $o(n){const e=n[1]==="c"?n[2]:n[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${n}"`);return Q(Ee(e.toUpperCase())-64,n)}function xo(n,e){let{on:t,off:a}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(n).groups;a!=null||(a="");const s=(e.getCurrentModX()||t.includes("x"))&&!a.includes("x"),i=va(t),r=va(a),c={};if(i&&(c.enable=i),r&&(c.disable=r),n.endsWith(")"))return e.replaceCurrentModX(s),wa("flags",n,{flags:c});if(n.endsWith(":"))return e.pushModX(s),e.numOpenGroups++,Ae("group",n,{...(i||r)&&{flags:c}});throw new Error(`Unexpected flag modifier "${n}"`)}function wo(n){var u;const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(n);if(!e)throw new Error(`Incomplete or invalid named callout "${n}"`);const{name:t,tag:a,args:s}=e.groups;if(!t)throw new Error(`Invalid named callout "${n}"`);if(a==="")throw new Error(`Named callout tag with empty value not allowed "${n}"`);const i=s?s.split(",").filter(m=>m!=="").map(m=>/^[+-]?\d+$/.test(m)?+m:m):[],[r,c,o]=i,l=_o.has(t)?t.toLowerCase():"custom";switch(l){case"fail":case"mismatch":case"skip":if(i.length>0)throw new Error(`Named callout arguments not allowed "${i}"`);break;case"error":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(typeof r=="string")throw new Error(`Named callout argument must be a number "${r}"`);break;case"max":if(!i.length||i.length>2)throw new Error(`Named callout must have one or two arguments "${i}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(i.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(i.length>1)throw new Error(`Named callout allows only one argument "${i}"`);if(i.length===1&&(typeof r=="number"||!/^[<>X]$/.test(r)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);break;case"cmp":if(i.length!==3)throw new Error(`Named callout must have three arguments "${i}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument three must be a tag or number "${o}"`);break;case"custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${l}"`)}return ho(l,a!=null?a:null,(u=s==null?void 0:s.split(","))!=null?u:null,n)}function ja(n){let e=null,t,a;if(n[0]==="{"){const{minStr:s,maxStr:i}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(n).groups,r=1e5;if(+s>r||i&&+i>r)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,a=i===void 0?+s:i===""?1/0:+i,t>a&&(e="possessive",[t,a]=[a,t]),n.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else t=n[0]==="+"?1:0,a=n[0]==="?"?1:1/0,e=n[1]==="+"?"possessive":n[1]==="?"?"lazy":"greedy";return fo(e,t,a,n)}function ko(n){const e=n[1].toLowerCase();return be({d:"digit",h:"hex",s:"space",w:"word"}[e],n,{negate:n[1]!==e})}function jo(n){const{p:e,neg:t,value:a}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(n).groups;return be("property",n,{value:a,negate:e==="P"&&!t||e==="p"&&!!t})}function va(n){const e={};return n.includes("i")&&(e.ignoreCase=!0),n.includes("m")&&(e.dotAll=!0),n.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function vo(n){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let t=0;t<n.length;t++){const a=n[t];if(!"imxDPSWy".includes(a))throw new Error(`Invalid flag "${a}"`);if(a==="y"){if(!/^y{[gw]}/.test(n.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=n[t+2]==="g"?"grapheme":"word",t+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[a]]=!0}return e}function Co(n){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(n))throw new Error(`Incomplete or invalid escape "${n}"`);const e=n[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(n).groups.hex:n.slice(2);return parseInt(e,16)}function So(n,e){const{raw:t,inCharClass:a}=n,s=t.slice(1);if(!a&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[$a(t)];const i=[],r=s.match(/^[0-7]+|\d/g);for(let c=0;c<r.length;c++){const o=r[c];let l;if(c===0&&o!=="8"&&o!=="9"){if(l=parseInt(o,8),l>127)throw new Error(P`Octal encoded byte above 177 unsupported "${t}"`)}else l=Ee(o);i.push(Q(l,(c===0?"\\":"")+o))}return i}function Eo(n){const e=[],t=new RegExp(Xn,"gy");let a;for(;a=t.exec(n);){const s=a[0];if(s[0]==="{"){const i=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(i){const{min:r,max:c}=i.groups;if(+r>+c&&s.endsWith("?")){t.lastIndex--,e.push(ja(s.slice(0,-1)));continue}}}e.push(ja(s))}return e}function Ca(n,e){if(!Array.isArray(n.body))throw new Error("Expected node with body array");if(n.body.length!==1)return!1;const t=n.body[0];return!e||Object.keys(e).every(a=>e[a]===t[a])}function qo(n){return Ao.has(n.type)}const Ao=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Sa(n,e={}){const t={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},a=io(n,{flags:t.flags,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline}}),s=(p,g)=>{const d=a.tokens[i.nextIndex];switch(i.parent=p,i.nextIndex++,d.type){case"Alternator":return he();case"Assertion":return No(d);case"Backreference":return Fo(d,i);case"Character":return gn(d.value,{useLastValid:!!g.isCheckingRangeEnd});case"CharacterClassHyphen":return Bo(d,i,g);case"CharacterClassOpen":return Go(d,i,g);case"CharacterSet":return Io(d,i);case"Directive":return Oo(d.kind,{flags:d.flags});case"GroupOpen":return Ro(d,i,g);case"NamedCallout":return Do(d.kind,d.tag,d.arguments);case"Quantifier":return Po(d,i);case"Subroutine":return zo(d,i);default:throw new Error(`Unexpected token type "${d.type}"`)}},i={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:t.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:t.skipBackrefValidation,skipLookbehindValidation:t.skipLookbehindValidation,skipPropertyNameValidation:t.skipPropertyNameValidation,subroutines:[],tokens:a.tokens,unicodePropertyMap:t.unicodePropertyMap,walk:s},r=Zo(Mo(a.flags));let c=r.body[0];for(;i.nextIndex<a.tokens.length;){const p=s(c,{});p.type==="Alternative"?(r.body.push(p),c=p):c.body.push(p)}const{capturingGroups:o,hasNumberedRef:l,namedGroupsByName:u,subroutines:m}=i;if(l&&u.size&&!t.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of m)if(typeof p=="number"){if(p>o.length)throw new Error("Subroutine uses a group number that's not defined");p&&(o[p-1].isSubroutined=!0)}else if(u.has(p)){if(u.get(p).length>1)throw new Error(P`Subroutine uses a duplicate group name "\g<${p}>"`);u.get(p)[0].isSubroutined=!0}else throw new Error(P`Subroutine uses a group name that's not defined "\g<${p}>"`);return r}function No({kind:n}){return Jn(qe({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[n],`Unexpected assertion kind "${n}"`),{negate:n===P`\B`||n===P`\Y`})}function Fo({raw:n},e){const t=/^\\k[<']/.test(n),a=t?n.slice(3,-1):n.slice(1),s=(i,r=!1)=>{const c=e.capturingGroups.length;let o=!1;if(i>c)if(e.skipBackrefValidation)o=!0;else throw new Error(`Not enough capturing groups defined to the left "${n}"`);return e.hasNumberedRef=!0,Qn(r?c+1-i:i,{orphan:o})};if(t){const 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 "${n}"`);if(!e.namedGroupsByName.has(a))throw new Error(`Group name not defined to the left "${n}"`);return Qn(a)}return s(+a)}function Bo(n,e,t){const{tokens:a,walk:s}=e,i=e.parent,r=i.body.at(-1),c=a[e.nextIndex];if(!t.isCheckingRangeEnd&&r&&r.type!=="CharacterClass"&&r.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const o=s(i,{...t,isCheckingRangeEnd:!0});if(r.type==="Character"&&o.type==="Character")return i.body.pop(),To(r,o);throw new Error("Invalid character class range")}return gn(Ee("-"))}function Go({negate:n},e,t){const{tokens:a,walk:s}=e,i=a[e.nextIndex],r=[bn()];let c=Ga(i);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")r.push(bn()),e.nextIndex++;else{const l=r.at(-1);l.body.push(s(l,t))}c=Ga(a[e.nextIndex],i)}const o=bn({negate:n});return r.length===1?o.body=r[0].body:(o.kind="intersection",o.body=r.map(l=>l.body.length===1?l.body[0]:l)),e.nextIndex++,o}function Io({kind:n,negate:e,value:t},a){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:r}=a;if(n==="property"){const c=hn(t);if(Vn.has(c)&&!(r!=null&&r.has(c)))n="posix",t=c;else return Ne(t,{negate:e,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:i,unicodePropertyMap:r})}return n==="posix"?Uo(t,{negate:e}):Kn(n,{negate:e})}function Ro(n,e,t){const{tokens:a,capturingGroups:s,namedGroupsByName:i,skipLookbehindValidation:r,walk:c}=e,o=Ho(n),l=o.type==="AbsenceFunction",u=Ba(o),m=u&&o.negate;if(o.type==="CapturingGroup"&&(s.push(o),o.name&&so(i,o.name,[]).push(o)),l&&t.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=Ia(a[e.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")o.body.push(he()),e.nextIndex++;else{const g=o.body.at(-1),d=c(g,{...t,isInAbsenceFunction:t.isInAbsenceFunction||l,isInLookbehind:t.isInLookbehind||u,isInNegLookbehind:t.isInNegLookbehind||m});if(g.body.push(d),(u||t.isInLookbehind)&&!r){const f="Lookbehind includes a pattern not allowed by Oniguruma";if(m||t.isInNegLookbehind){if(Fa(d)||d.type==="CapturingGroup")throw new Error(f)}else if(Fa(d)||Ba(d)&&d.negate)throw new Error(f)}}p=Ia(a[e.nextIndex])}return e.nextIndex++,o}function Po({kind:n,min:e,max:t},a){const s=a.parent,i=s.body.at(-1);if(!i||!qo(i))throw new Error("Quantifier requires a repeatable token");const r=qa(n,e,t,i);return s.body.pop(),r}function zo({raw:n},e){const{capturingGroups:t,subroutines:a}=e;let s=n.slice(3,-1);const i=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(i){const c=+i.groups.num,o=t.length;if(e.hasNumberedRef=!0,s={"":c,"+":o+c,"-":o+1-c}[i.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const r=Aa(s);return a.push(r),r}function Lo(n,e){return{type:"AbsenceFunction",kind:n,body:Ze(e==null?void 0:e.body)}}function he(n){return{type:"Alternative",body:Na(n==null?void 0:n.body)}}function Jn(n,e){const t={type:"Assertion",kind:n};return(n==="word_boundary"||n==="text_segment_boundary")&&(t.negate=!!(e!=null&&e.negate)),t}function Qn(n,e){const t=!!(e!=null&&e.orphan);return{type:"Backreference",ref:n,...t&&{orphan:t}}}function Ea(n,e){const t={name:void 0,isSubroutined:!1,...e};if(t.name!==void 0&&!Wo(t.name))throw new Error(`Group name "${t.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:n,...t.name&&{name:t.name},...t.isSubroutined&&{isSubroutined:t.isSubroutined},body:Ze(e==null?void 0:e.body)}}function gn(n,e){const t={useLastValid:!1,...e};if(n>1114111){const a=n.toString(16);if(t.useLastValid)n=1114111;else throw n>1310719?new Error(`Invalid code point out of range "\\x{${a}}"`):new Error(`Invalid code point out of range in JS "\\x{${a}}"`)}return{type:"Character",value:n}}function bn(n){const e={kind:"union",negate:!1,...n};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:Na(n==null?void 0:n.body)}}function To(n,e){if(e.value<n.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:n,max:e}}function Kn(n,e){const t=!!(e!=null&&e.negate),a={type:"CharacterSet",kind:n};return(n==="digit"||n==="hex"||n==="newline"||n==="space"||n==="word")&&(a.negate=t),(n==="text_segment"||n==="newline"&&!t)&&(a.variableLength=!0),a}function Oo(n,e={}){if(n==="keep")return{type:"Directive",kind:n};if(n==="flags")return{type:"Directive",kind:n,flags:qe(e.flags)};throw new Error(`Unexpected directive kind "${n}"`)}function Mo(n){return{type:"Flags",...n}}function X(n){const e=n==null?void 0:n.atomic,t=n==null?void 0:n.flags;if(e&&t)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...t&&{flags:t},body:Ze(n==null?void 0:n.body)}}function fe(n){const e={behind:!1,negate:!1,...n};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:Ze(n==null?void 0:n.body)}}function Do(n,e,t){return{type:"NamedCallout",kind:n,tag:e,arguments:t}}function Uo(n,e){const t=!!(e!=null&&e.negate);if(!Vn.has(n))throw new Error(`Invalid POSIX class "${n}"`);return{type:"CharacterSet",kind:"posix",value:n,negate:t}}function qa(n,e,t,a){if(e>t)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:n,min:e,max:t,body:a}}function Zo(n,e){return{type:"Regex",body:Ze(e==null?void 0:e.body),flags:n}}function Aa(n){return{type:"Subroutine",ref:n}}function Ne(n,e){var s;const t={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let a=(s=t.unicodePropertyMap)==null?void 0:s.get(hn(n));if(!a){if(t.normalizeUnknownPropertyNames)a=Vo(n);else if(t.unicodePropertyMap&&!t.skipPropertyNameValidation)throw new Error(P`Invalid Unicode property "\p{${n}}"`)}return{type:"CharacterSet",kind:"property",value:a!=null?a:n,negate:t.negate}}function Ho({flags:n,kind:e,name:t,negate:a,number:s}){switch(e){case"absence_repeater":return Lo("repeater");case"atomic":return X({atomic:!0});case"capturing":return Ea(s,{name:t});case"group":return X({flags:n});case"lookahead":case"lookbehind":return fe({behind:e==="lookbehind",negate:a});default:throw new Error(`Unexpected group kind "${e}"`)}}function Ze(n){if(n===void 0)n=[he()];else if(!Array.isArray(n)||!n.length||!n.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return n}function Na(n){if(n===void 0)n=[];else if(!Array.isArray(n)||!n.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return n}function Fa(n){return n.type==="LookaroundAssertion"&&n.kind==="lookahead"}function Ba(n){return n.type==="LookaroundAssertion"&&n.kind==="lookbehind"}function Wo(n){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(n)}function Vo(n){return n.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function hn(n){return n.replace(/[- _]+/g,"").toLowerCase()}function Ga(n,e){return qe(n,`${(e==null?void 0:e.type)==="Character"&&e.value===93?"Empty":"Unclosed"} character class`)}function Ia(n){return qe(n,"Unclosed group")}function He(n,e,t=null){function a(i,r){for(let c=0;c<i.length;c++){const o=s(i[c],r,c,i);c=Math.max(-1,c+o)}}function s(i,r=null,c=null,o=null){var _,x;let l=0,u=!1;const m={node:i,parent:r,key:c,container:o,root:n,remove(){fn(o).splice(Math.max(0,Fe(c)+l),1),l--,u=!0},removeAllNextSiblings(){return fn(o).splice(Fe(c)+1)},removeAllPrevSiblings(){const y=Fe(c)+l;return l-=y,fn(o).splice(0,Math.max(0,y))},replaceWith(y,w={}){const C=!!w.traverse;o?o[Math.max(0,Fe(c)+l)]=y:qe(r,"Can't replace root node")[c]=y,C&&s(y,r,c,o),u=!0},replaceWithMultiple(y,w={}){const C=!!w.traverse;if(fn(o).splice(Math.max(0,Fe(c)+l),1,...y),l+=y.length-1,C){let E=0;for(let S=0;S<y.length;S++)E+=s(y[S],r,Fe(c)+S+E,o)}u=!0},skip(){u=!0}},{type:p}=i,g=e["*"],d=e[p],f=typeof g=="function"?g:g==null?void 0:g.enter,$=typeof d=="function"?d:d==null?void 0:d.enter;if(f==null||f(m,t),$==null||$(m,t),!u)switch(p){case"AbsenceFunction":case"CapturingGroup":case"Group":a(i.body,i);break;case"Alternative":case"CharacterClass":a(i.body,i);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(i.min,i,"min"),s(i.max,i,"max");break;case"LookaroundAssertion":a(i.body,i);break;case"Quantifier":s(i.body,i,"body");break;case"Regex":a(i.body,i),s(i.flags,i,"flags");break;default:throw new Error(`Unexpected node type "${p}"`)}return(_=d==null?void 0:d.exit)==null||_.call(d,m,t),(x=g==null?void 0:g.exit)==null||x.call(g,m,t),l}return s(n),n}function fn(n){if(!Array.isArray(n))throw new Error("Container expected");return n}function Fe(n){if(typeof n!="number")throw new Error("Numeric key expected");return n}const Xo=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Yo(n,e){for(let t=0;t<n.length;t++)n[t]>=e&&n[t]++}function Jo(n,e,t,a){return n.slice(0,e)+a+n.slice(e+t.length)}const Z=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function et(n,e,t,a){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1];let r=0,c="";for(const o of n.matchAll(s)){const{0:l,groups:{$skip:u}}=o;if(!u&&(!a||a===Z.DEFAULT==!r)){t instanceof Function?c+=t(o,{context:r?Z.CHAR_CLASS:Z.DEFAULT,negated:i[i.length-1]}):c+=t;continue}l[0]==="["?(r++,i.push(l[1]==="^")):l==="]"&&r&&(r--,i.pop()),c+=l}return c}function Ra(n,e,t,a){et(n,e,t,a)}function Qo(n,e,t=0,a){if(!new RegExp(e,"su").test(n))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=t;let i=0,r;for(;r=s.exec(n);){const{0:c,groups:{$skip:o}}=r;if(!o&&(!a||a===Z.DEFAULT==!i))return r;c==="["?i++:c==="]"&&i&&i--,s.lastIndex==r.index&&s.lastIndex++}return null}function yn(n,e,t){return!!Qo(n,e,0,t)}function Ko(n,e){const t=/\\?./gsu;t.lastIndex=e;let a=n.length,s=0,i=1,r;for(;r=t.exec(n);){const[c]=r;if(c==="[")s++;else if(s)c==="]"&&s--;else if(c==="(")i++;else if(c===")"&&(i--,!i)){a=r.index;break}}return n.slice(e,a)}const Pa=new RegExp(String.raw`(?<noncapturingStart>${Xo})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function ec(n,e){var p,g;const t=(p=e==null?void 0:e.hiddenCaptures)!=null?p:[];let a=(g=e==null?void 0:e.captureTransfers)!=null?g:new Map;if(!/\(\?>/.test(n))return{pattern:n,captureTransfers:a,hiddenCaptures:t};const s="(?>",i="(?:(?=(",r=[0],c=[];let o=0,l=0,u=NaN,m;do{m=!1;let d=0,f=0,$=!1,_;for(Pa.lastIndex=Number.isNaN(u)?0:u+i.length;_=Pa.exec(n);){const{0:x,index:y,groups:{capturingStart:w,noncapturingStart:C}}=_;if(x==="[")d++;else if(d)x==="]"&&d--;else if(x===s&&!$)u=y,$=!0;else if($&&C)f++;else if(w)$?f++:(o++,r.push(o+l));else if(x===")"&&$){if(!f){l++;const E=o+l;if(n=`${n.slice(0,u)}${i}${n.slice(u+s.length,y)}))<$$${E}>)${n.slice(y+1)}`,m=!0,c.push(E),Yo(t,E),a.size){const S=new Map;a.forEach((D,G)=>{S.set(G>=E?G+1:G,D.map(T=>T>=E?T+1:T))}),a=S}break}f--}}}while(m);return t.push(...c),n=et(n,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:d,groups:{backrefNum:f,wrappedBackrefNum:$}})=>{if(f){const _=+f;if(_>r.length-1)throw new Error(`Backref "${d}" greater than number of captures`);return`\\${r[_]}`}return`\\${$}`},Z.DEFAULT),{pattern:n,captureTransfers:a,hiddenCaptures:t}}const za=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,nt=new RegExp(String.raw` |