Comparing version 4.3.3 to 4.4.0
@@ -1,2 +0,14 @@ | ||
var Regex=(()=>{var z=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Te(t))!Ue.call(e,s)&&s!==n&&z(e,s,{get:()=>t[s],enumerable:!(r=be(t,s))||r.enumerable});return e};var Re=e=>Pe(z({},"__esModule",{value:!0}),e);var Je={};_e(Je,{pattern:()=>H,regex:()=>Be,rewrite:()=>Ke});var d=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function w(e,t,n,r){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1],o=0,i="";for(let u of e.matchAll(s)){let{0:c,groups:{$skip:f}}=u;if(!f&&(!r||r===d.DEFAULT==!o)){n instanceof Function?i+=n(u,{context:o?d.CHAR_CLASS:d.DEFAULT,negated:a[a.length-1]}):i+=n;continue}c[0]==="["?(o++,a.push(c[1]==="^")):c==="]"&&o&&(o--,a.pop()),i+=c}return i}function x(e,t,n,r){w(e,t,n,r)}function j(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let a=0,o;for(;o=s.exec(e);){let{0:i,groups:{$skip:u}}=o;if(!u&&(!r||r===d.DEFAULT==!a))return o;i==="["?a++:i==="]"&&a&&a--,s.lastIndex==o.index&&s.lastIndex++}return null}function Q(e,t,n){return!!j(e,t,0,n)}function Z(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,a=1,o;for(;o=n.exec(e);){let[i]=o;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")a++;else if(i===")"&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var L=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function H(e,...t){if(Array.isArray(e?.raw))return new L(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new L(e===void 0?"":e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var p={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"},E={DEFAULT:"DEFAULT",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_Q:"ENCLOSED_Q",ENCLOSED_U:"ENCLOSED_U",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN",RANGE:"RANGE"},q=new Set([p.ENCLOSED_P,p.ENCLOSED_U]),G=new Set([E.ENCLOSED_P,E.ENCLOSED_Q,E.ENCLOSED_U]),M=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),ie=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),T="&!#$%*+,.:;<=>?@^`~",$="$E$",B=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,U=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${B}`,_=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function J(e,t){return t===d.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${T}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function K(e){return e.replace(new RegExp(`^([${T}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function ue(e){return e.replace(/^\^/,"\\^^")}function y(e,t){return w(e,String.raw`\\0(?!\d)`,"\\x00",t)}function oe(e,t,n){let r=0;for(let[s]of e.matchAll(new RegExp(`[${J(t+n,d.CHAR_CLASS)}]`,"g")))if(r+=s===t?1:-1,r<0)return n;return r>0?t:""}function le(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===p.DEFAULT)return oe(r,"(",")");if(t===p.CHAR_CLASS&&!G.has(n))return oe(r,"[","]");if(t===p.INTERVAL_QUANTIFIER||q.has(t)||G.has(n)){if(r.includes("}"))return"}"}else if(t===p.GROUP_NAME&&r.includes(">"))return">";return""}var ae=new RegExp(String.raw` | ||
var Regex=(()=>{var z=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},Re=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Te(t))!Ue.call(e,s)&&s!==n&&z(e,s,{get:()=>t[s],enumerable:!(r=be(t,s))||r.enumerable});return e};var Fe=e=>Re(z({},"__esModule",{value:!0}),e);var Je={};_e(Je,{pattern:()=>j,regex:()=>Be,rewrite:()=>Ke});var L=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function j(e,...t){if(Array.isArray(e?.raw))return new L(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new L(e===void 0?"":e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var d=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function w(e,t,n,r){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1],o=0,i="";for(let u of e.matchAll(s)){let{0:c,groups:{$skip:f}}=u;if(!f&&(!r||r===d.DEFAULT==!o)){n instanceof Function?i+=n(u,{context:o?d.CHAR_CLASS:d.DEFAULT,negated:a[a.length-1]}):i+=n;continue}c[0]==="["?(o++,a.push(c[1]==="^")):c==="]"&&o&&(o--,a.pop()),i+=c}return i}function x(e,t,n,r){w(e,t,n,r)}function Q(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let a=0,o;for(;o=s.exec(e);){let{0:i,groups:{$skip:u}}=o;if(!u&&(!r||r===d.DEFAULT==!a))return o;i==="["?a++:i==="]"&&a&&a--,s.lastIndex==o.index&&s.lastIndex++}return null}function H(e,t,n){return!!Q(e,t,0,n)}function Z(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,a=1,o;for(;o=n.exec(e);){let[i]=o;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")a++;else if(i===")"&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var p={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"},g={DEFAULT:"DEFAULT",ENCLOSED_P:"ENCLOSED_P",ENCLOSED_Q:"ENCLOSED_Q",ENCLOSED_U:"ENCLOSED_U",INVALID_INCOMPLETE_TOKEN:"INVALID_INCOMPLETE_TOKEN",RANGE:"RANGE"},q=new Set([p.ENCLOSED_P,p.ENCLOSED_U]),G=new Set([g.ENCLOSED_P,g.ENCLOSED_Q,g.ENCLOSED_U]),M=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),ie=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),$="$E$",T="&!#$%*+,.:;<=>?@^`~",B=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,U=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${B}`,_=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function ue(e,t){return w(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,d.DEFAULT)}var Oe=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),Pe=new RegExp(String.raw` | ||
\\(?: c[A-Za-z] | ||
| p\{(?<pStrProp>${Oe})\} | ||
| [pP]\{[^\}]+\} | ||
| (?<qStrProp>q) | ||
| u(?:[A-Fa-f\d]{4}|\{[A-Fa-f\d]+\}) | ||
| x[A-Fa-f\d]{2} | ||
| . | ||
) | ||
| -- | ||
| && | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function J(e){let t=!1,n;for(let{0:r,groups:s}of e.matchAll(Pe)){if(s.pStrProp||s.qStrProp||r==="["&&t)return!0;if(["-","--","&&"].includes(r))t=!1;else if(r!=="["&&r!=="]"){if(t||n==="]")return!0;t=!0}n=r}return!1}function R(e){let t=0;return x(e,U,()=>t++,d.DEFAULT),t}function X(e,t){return t===d.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${T}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function le(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===p.DEFAULT)return ae(r,"(",")");if(t===p.CHAR_CLASS&&!G.has(n))return ae(r,"[","]");if(t===p.INTERVAL_QUANTIFIER||q.has(t)||G.has(n)){if(r.includes("}"))return"}"}else if(t===p.GROUP_NAME&&r.includes(">"))return">";return""}var oe=new RegExp(String.raw` | ||
(?<groupN>\(\?<(?![=!])|\\[gk]<) | ||
@@ -14,15 +26,26 @@ | (?<enclosedPU>\\[pPu]\{) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function P(e,{regexContext:t=p.DEFAULT,charClassContext:n=E.DEFAULT,charClassDepth:r=0,lastPos:s=0}={}){ae.lastIndex=s;let a;for(;a=ae.exec(e);){let{0:o,groups:{groupN:i,enclosedPU:u,enclosedQ:c,intervalQ:f,incompleteT:g}}=a;o==="["?(r++,t=p.CHAR_CLASS,n=E.DEFAULT):o==="]"&&t===p.CHAR_CLASS?(r&&r--,r||(t=p.DEFAULT),n=E.DEFAULT):t===p.CHAR_CLASS?g?n=E.INVALID_INCOMPLETE_TOKEN:o==="-"?n=E.RANGE:u?n=o[1]==="u"?E.ENCLOSED_U:E.ENCLOSED_P:c?n=E.ENCLOSED_Q:(o==="}"&&G.has(n)||n===E.INVALID_INCOMPLETE_TOKEN||n===E.RANGE)&&(n=E.DEFAULT):g?t=p.INVALID_INCOMPLETE_TOKEN:i?t=p.GROUP_NAME:u?t=o[1]==="u"?p.ENCLOSED_U:p.ENCLOSED_P:f?t=p.INTERVAL_QUANTIFIER:(o===">"&&t===p.GROUP_NAME||o==="}"&&(t===p.INTERVAL_QUANTIFIER||q.has(t))||t===p.INVALID_INCOMPLETE_TOKEN)&&(t=p.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function R(e){let t=0;return x(e,U,()=>t++,d.DEFAULT),t}function ce(e,t){return w(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,d.DEFAULT)}function F(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Fe=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),Oe=new RegExp(String.raw` | ||
\\(?: c[A-Za-z] | ||
| p\{(?<pStrProp>${Fe})\} | ||
| [pP]\{[^\}]+\} | ||
| (?<qStrProp>q) | ||
| u(?:[A-Fa-f\d]{4}|\{[A-Fa-f\d]+\}) | ||
`.replace(/\s+/g,""),"gsu");function F(e,{regexContext:t=p.DEFAULT,charClassContext:n=g.DEFAULT,charClassDepth:r=0,lastPos:s=0}={}){oe.lastIndex=s;let a;for(;a=oe.exec(e);){let{0:o,groups:{groupN:i,enclosedPU:u,enclosedQ:c,intervalQ:f,incompleteT:E}}=a;o==="["?(r++,t=p.CHAR_CLASS,n=g.DEFAULT):o==="]"&&t===p.CHAR_CLASS?(r&&r--,r||(t=p.DEFAULT),n=g.DEFAULT):t===p.CHAR_CLASS?E?n=g.INVALID_INCOMPLETE_TOKEN:o==="-"?n=g.RANGE:u?n=o[1]==="u"?g.ENCLOSED_U:g.ENCLOSED_P:c?n=g.ENCLOSED_Q:(o==="}"&&G.has(n)||n===g.INVALID_INCOMPLETE_TOKEN||n===g.RANGE)&&(n=g.DEFAULT):E?t=p.INVALID_INCOMPLETE_TOKEN:i?t=p.GROUP_NAME:u?t=o[1]==="u"?p.ENCLOSED_U:p.ENCLOSED_P:f?t=p.INTERVAL_QUANTIFIER:(o===">"&&t===p.GROUP_NAME||o==="}"&&(t===p.INTERVAL_QUANTIFIER||q.has(t))||t===p.INVALID_INCOMPLETE_TOKEN)&&(t=p.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function ae(e,t,n){let r=0;for(let[s]of e.matchAll(new RegExp(`[${X(t+n,d.CHAR_CLASS)}]`,"g")))if(r+=s===t?1:-1,r<0)return n;return r>0?t:""}function ce(e,t,n,r){let s={raw:[]},a=[],o;return e.raw.forEach((i,u)=>{let c=n(i,{...o,lastPos:0},r);if(s.raw.push(c.transformed),o=c.runningContext,u<e.raw.length-1){let f=t[u];if(f instanceof L){let E=n(f,{...o,lastPos:0},r);a.push(j(E.transformed)),o=E.runningContext}else a.push(f)}}),{template:s,substitutions:a}}function fe(e){return e.replace(/^\^/,"\\^^")}function K(e){return e.replace(new RegExp(`^([${T}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function y(e,t){return w(e,String.raw`\\0(?!\d)`,"\\x00",t)}function O(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var pe=new RegExp(String.raw`(?<noncapturingStart>${_})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function de(e,t){if(!/\(\?>/.test(e))return e;let n="(?>",r=`(?:(?=(${t?.useEmulationGroups?$:""}`,s=[0],a=0,o=0,i=NaN,u;do{u=!1;let c=0,f=0,E=!1,l;for(pe.lastIndex=Number.isNaN(i)?0:i+r.length;l=pe.exec(e);){let{0:m,index:A,groups:{capturingStart:h,noncapturingStart:C}}=l;if(m==="[")c++;else if(c)m==="]"&&c--;else if(m===n&&!E)i=A,E=!0;else if(E&&C)f++;else if(h)E?f++:(a++,s.push(a+o));else if(m===")"&&E){if(!f){o++,e=`${e.slice(0,i)}${r}${e.slice(i+n.length,A)}))<$$${o+a}>)${e.slice(A+1)}`,u=!0;break}f--}}}while(u);return e=w(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:c,groups:{backrefNum:f,wrappedBackrefNum:E}})=>{if(f){let l=+f;if(l>s.length-1)throw new Error(`Backref "${c}" greater than number of captures`);return`\\${s[l]}`}return`\\${E}`},d.DEFAULT),e}var Ee=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Y=new RegExp(String.raw` | ||
\\(?: \d+ | ||
| c[A-Za-z] | ||
| [gk]<[^>]+> | ||
| [pPu]\{[^\}]+\} | ||
| u[A-Fa-f\d]{4} | ||
| x[A-Fa-f\d]{2} | ||
| . | ||
) | ||
) | ||
| \((?: \? (?: [:=!>] | ||
| <(?:[=!]|[^>]+>) | ||
| [A-Za-z\-]+: | ||
| \(DEFINE\) | ||
))? | ||
| (?<qBase>${Ee})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ge(e){if(!new RegExp(`${Ee}\\+`).test(e))return e;let t=[],n=null,r=null,s="",a=0,o;for(Y.lastIndex=0;o=Y.exec(e);){let{0:i,index:u,groups:{qBase:c,qMod:f,invalidQ:E}}=o;if(i==="[")a||(r=u),a++;else if(i==="]")a?a--:r=null;else if(!a)if(f==="+"&&s&&!s.startsWith("(")){if(E)throw new Error(`Invalid quantifier "${i}"`);let l=-1;if(/^\{\d+\}$/.test(c))e=O(e,u+c.length,f,"");else{if(s===")"||s==="]"){let m=s===")"?n:r;if(m===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,m)}(?>${e.slice(m,u)}${c})${e.slice(u+i.length)}`}else e=`${e.slice(0,u-s.length)}(?>${s}${c})${e.slice(u+i.length)}`;l+=4}Y.lastIndex+=l}else i[0]==="("?t.push(u):i===")"&&(n=t.length?t.pop():null);s=i}return e}var ke="&!#%,:;<=>@`~",xe=new RegExp(String.raw` | ||
\[\^?-? | ||
| --?\] | ||
| (?<dp>[${T}])\k<dp> | ||
| -- | ||
| && | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function X(e){let t=!1,n;for(let{0:r,groups:s}of e.matchAll(Oe)){if(s.pStrProp||s.qStrProp||r==="["&&t)return!0;if(["-","--","&&"].includes(r))t=!1;else if(r!=="["&&r!=="]"){if(t||n==="]")return!0;t=!0}n=r}return!1}function fe(e,t,n,r){let s={raw:[]},a=[],o;return e.raw.forEach((i,u)=>{let c=n(i,{...o,lastPos:0},r);if(s.raw.push(c.transformed),o=c.runningContext,u<e.raw.length-1){let f=t[u];if(f instanceof L){let g=n(f,{...o,lastPos:0},r);a.push(H(g.transformed)),o=g.runningContext}else a.push(f)}}),{template:s,substitutions:a}}var ke=new RegExp(String.raw` | ||
| \\(?<vOnlyEscape>[${ke}]) | ||
| \\[pPu]\{[^}]+\} | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function me(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:s,groups:{dp:a,vOnlyEscape:o}}of e.matchAll(xe)){if(s[0]==="["){if(n)throw new Error("Invalid nested character class when flag v not supported; possibly from interpolation");if(s.endsWith("-"))throw new Error(t);n=!0}else if(s.endsWith("]")){if(s[0]==="-")throw new Error(t);n=!1}else if(n){if(s==="&&"||s==="--")throw new Error(`Invalid set operator "${s}" when flag v not supported`);if(a)throw new Error(`Invalid double punctuator "${s}", reserved by flag v`);if("(){}/|".includes(s))throw new Error(`Invalid unescaped "${s}" in character class`);if(o){r+=o;continue}}r+=s}return r}var Ge=new RegExp(String.raw` | ||
${_} | ||
@@ -32,3 +55,3 @@ | \(\?< | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function pe(e,t){e=String(e);let n="",r="";for(let{0:s,groups:{backrefNum:a}}of e.matchAll(ke)){n+=s,t=P(n,t);let{regexContext:o}=t;if(o===p.DEFAULT)if(s==="(")r+="(?:";else{if(a)throw new Error(`Invalid decimal escape "${s}" with implicit flag n; replace with named backreference`);r+=s}else r+=s}return{transformed:r,runningContext:t}}var de=/^\s$/,xe=/^\\[\s#]$/,Y=/^[ \t]$/,Ge=/^\\[ \t]$/,Me=new RegExp(String.raw` | ||
`.replace(/\s+/g,""),"gsu");function he(e,t){e=String(e);let n="",r="";for(let{0:s,groups:{backrefNum:a}}of e.matchAll(Ge)){n+=s,t=F(n,t);let{regexContext:o}=t;if(o===p.DEFAULT)if(s==="(")r+="(?:";else{if(a)throw new Error(`Invalid decimal escape "${s}" with implicit flag n; replace with named backreference`);r+=s}else r+=s}return{transformed:r,runningContext:t}}var Ae=/^\s$/,Me=/^\\[\s#]$/,ee=/^[ \t]$/,ye=/^\\[ \t]$/,ve=new RegExp(String.raw` | ||
\\(?: [gk]< | ||
@@ -47,20 +70,5 @@ | [pPu]\{ | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ge(e,t,n){e=String(e);let r=!1,s=!1,a=!1,o="",i="",u="",c="",f=!1,g=(l,{prefix:m=!0,postfix:A=!1}={})=>(l=(f&&m?"(?:)":"")+l+(A?"(?:)":""),f=!1,l);for(let{0:l,index:m}of e.matchAll(Me)){if(a){l===` | ||
`&&(a=!1,f=!0);continue}if(r){if(de.test(l))continue;r=!1,f=!0}else if(s){if(Y.test(l))continue;s=!1}o+=l,t=P(o,t);let{regexContext:A,charClassContext:h}=t;if(l==="-"&&A===p.CHAR_CLASS&&c===E.RANGE&&(n.flags.includes("v")||n.unicodeSetsPlugin))throw new Error("Invalid unescaped hyphen as the end value for a range");if(A===p.DEFAULT&&/^(?:[?*+]|\?\?)$/.test(l)||A===p.INTERVAL_QUANTIFIER&&l==="{")i+=g(l,{prefix:!1,postfix:u==="("&&l==="?"});else if(A===p.DEFAULT)de.test(l)?r=!0:l.startsWith("#")?a=!0:xe.test(l)?i+=g(l[1],{prefix:!1}):i+=g(l);else if(A===p.CHAR_CLASS&&l!=="["&&l!=="[^")if(Y.test(l)&&(h===E.DEFAULT||h===E.ENCLOSED_Q||h===E.RANGE))s=!0;else{if(h===E.INVALID_INCOMPLETE_TOKEN)throw new Error(`Invalid incomplete token in character class: "${l}"`);if(Ge.test(l)&&(h===E.DEFAULT||h===E.ENCLOSED_Q))i+=g(l[1],{prefix:!1});else if(h===E.DEFAULT){let C=e[m+1]??"",S=y(l);(Y.test(C)||l==="^")&&(S=K(S)),i+=g(S)}else i+=g(l)}else i+=g(l);r||s||a||(u=l,c=h)}return{transformed:i,runningContext:t}}function Ee(e){let t=String.raw`\(\?:\)`;e=w(e,`(?:${t}){2,}`,"(?:)",d.DEFAULT);let n=$.replace(/\$/g,"\\$");return e=w(e,String.raw`(?:${t}(?=[)|.[$\\]|\((?!DEFINE)|$)|(?<=[()|.\]^>]|\\[bBdDfnrsStvwW]|\(\?(?:[:=!]|<[=!])|^)${t}(?![?*+{]))(?!${n})`,"",d.DEFAULT),e}var me=new RegExp(String.raw`(?<noncapturingStart>${_})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function he(e,t){if(!/\(\?>/.test(e))return e;let n="(?>",r=`(?:(?=(${t.useEmulationGroups?$:""}`,s=[0],a=0,o=0,i=NaN,u;do{u=!1;let c=0,f=0,g=!1,l;for(me.lastIndex=Number.isNaN(i)?0:i+r.length;l=me.exec(e);){let{0:m,index:A,groups:{capturingStart:h,noncapturingStart:C}}=l;if(m==="[")c++;else if(c)m==="]"&&c--;else if(m===n&&!g)i=A,g=!0;else if(g&&C)f++;else if(h)g?f++:(a++,s.push(a+o));else if(m===")"&&g){if(!f){o++,e=`${e.slice(0,i)}${r}${e.slice(i+n.length,A)}))<$$${o+a}>)${e.slice(A+1)}`,u=!0;break}f--}}}while(u);return e=w(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:c,groups:{backrefNum:f,wrappedBackrefNum:g}})=>{if(f){let l=+f;if(l>s.length-1)throw new Error(`Backref "${c}" greater than number of captures`);return`\\${s[l]}`}return`\\${g}`},d.DEFAULT),e}var Ae=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,ee=new RegExp(String.raw` | ||
\\(?: \d+ | ||
| c[A-Za-z] | ||
| [gk]<[^>]+> | ||
| [pPu]\{[^\}]+\} | ||
| u[A-Fa-f\d]{4} | ||
| x[A-Fa-f\d]{2} | ||
) | ||
| \((?: \? (?: [:=!>] | ||
| <(?:[=!]|[^>]+>) | ||
| [A-Za-z\-]+: | ||
| \(DEFINE\) | ||
))? | ||
| (?<qBase>${Ae})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function we(e){if(!new RegExp(`${Ae}\\+`).test(e))return e;let t=[],n=null,r=null,s="",a=0,o;for(ee.lastIndex=0;o=ee.exec(e);){let{0:i,index:u,groups:{qBase:c,qMod:f,invalidQ:g}}=o;if(i==="[")a||(r=u),a++;else if(i==="]")a?a--:r=null;else if(!a)if(f==="+"&&s&&!s.startsWith("(")){if(g)throw new Error(`Invalid quantifier "${i}"`);let l=-1;if(/^\{\d+\}$/.test(c))e=F(e,u+c.length,f,"");else{if(s===")"||s==="]"){let m=s===")"?n:r;if(m===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,m)}(?>${e.slice(m,u)}${c})${e.slice(u+i.length)}`}else e=`${e.slice(0,u-s.length)}(?>${s}${c})${e.slice(u+i.length)}`;l+=4}ee.lastIndex+=l}else i[0]==="("?t.push(u):i===")"&&(n=t.length?t.pop():null);s=i}return e}function Se(e,t){let n=Ce(e,{includeContents:!0}),r=ve(e,n,t.useEmulationGroups);return Ve(r,n)}var ye=String.raw`\\g<(?<subroutineName>[^>&]+)>`,v=new RegExp(String.raw` | ||
${ye} | ||
`.replace(/\s+/g,""),"gsu");function we(e,t,n){e=String(e);let r=!1,s=!1,a=!1,o="",i="",u="",c="",f=!1,E=(l,{prefix:m=!0,postfix:A=!1}={})=>(l=(f&&m?"(?:)":"")+l+(A?"(?:)":""),f=!1,l);for(let{0:l,index:m}of e.matchAll(ve)){if(a){l===` | ||
`&&(a=!1,f=!0);continue}if(r){if(Ae.test(l))continue;r=!1,f=!0}else if(s){if(ee.test(l))continue;s=!1}o+=l,t=F(o,t);let{regexContext:A,charClassContext:h}=t;if(l==="-"&&A===p.CHAR_CLASS&&c===g.RANGE&&(n.flags.includes("v")||n.unicodeSetsPlugin))throw new Error("Invalid unescaped hyphen as the end value for a range");if(A===p.DEFAULT&&/^(?:[?*+]|\?\?)$/.test(l)||A===p.INTERVAL_QUANTIFIER&&l==="{")i+=E(l,{prefix:!1,postfix:u==="("&&l==="?"});else if(A===p.DEFAULT)Ae.test(l)?r=!0:l.startsWith("#")?a=!0:Me.test(l)?i+=E(l[1],{prefix:!1}):i+=E(l);else if(A===p.CHAR_CLASS&&l!=="["&&l!=="[^")if(ee.test(l)&&(h===g.DEFAULT||h===g.ENCLOSED_Q||h===g.RANGE))s=!0;else{if(h===g.INVALID_INCOMPLETE_TOKEN)throw new Error(`Invalid incomplete token in character class: "${l}"`);if(ye.test(l)&&(h===g.DEFAULT||h===g.ENCLOSED_Q))i+=E(l[1],{prefix:!1});else if(h===g.DEFAULT){let C=e[m+1]??"",S=y(l);(ee.test(C)||l==="^")&&(S=K(S)),i+=E(S)}else i+=E(l)}else i+=E(l);r||s||a||(u=l,c=h)}return{transformed:i,runningContext:t}}function Ne(e){let t=String.raw`\(\?:\)`;e=w(e,`(?:${t}){2,}`,"(?:)",d.DEFAULT);let n=$.replace(/\$/g,"\\$");return e=w(e,String.raw`(?:${t}(?=[)|.[$\\]|\((?!DEFINE)|$)|(?<=[()|.\]^>]|\\[bBdDfnrsStvwW]|\(\?(?:[:=!]|<[=!])|^)${t}(?![?*+{]))(?!${n})`,"",d.DEFAULT),e}function Ce(e,t){let n=Le(e,{includeContents:!0}),r=je(e,n,!!t?.useEmulationGroups);return Qe(r,n)}var Ve=String.raw`\\g<(?<subroutineName>[^>&]+)>`,v=new RegExp(String.raw` | ||
${Ve} | ||
| (?<capturingStart>${U}) | ||
@@ -70,11 +78,3 @@ | \\(?<backrefNum>[1-9]\d*) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ve(e,t,n){if(!/\\g</.test(e))return e;let r=Q(e,"\\\\(?:[1-9]|k<[^>]+>)",d.DEFAULT),s=r?`(${n?$:""}`:"(?:",a=new Map,o=[],i=[0],u=0,c=0,f=0,g=0,l=0,m=e,A;for(v.lastIndex=0;A=v.exec(m);){let{0:h,index:C,groups:{subroutineName:S,capturingStart:W,backrefNum:O,backrefName:V}}=A;if(h==="[")l++;else if(l)h==="]"&&l--;else if(S){if(!t.has(S))throw new Error(`Invalid named capture referenced by subroutine ${h}`);if(a.has(S))throw new Error(`Subroutine ${h} followed a recursive reference`);let N=t.get(S).contents,D=`${s}${N})`;r&&(f=0,c++),a.set(S,{unclosedGroupCount:je(D)}),o.push(S),m=F(m,C,h,D),v.lastIndex-=h.length-s.length}else if(W)a.size?(r&&(f++,c++),h!=="("&&(m=F(m,C,h,s),v.lastIndex-=h.length-s.length)):r&&(i.push(ne(i)+1+c-g),g=c,u++);else if((O||V)&&a.size){let N=O?+O:t.get(V)?.groupNum,D=!1;for(let I of o){let b=t.get(I);if(N>=b.groupNum&&N<=b.groupNum+b.numCaptures){D=!0;break}}if(D){let I=t.get(ne(o)),b=u+c-f,k=`\\k<$$b${N}s${b}r${I.groupNum}c${I.numCaptures}>`;m=F(m,C,h,k),v.lastIndex+=k.length-h.length}}else if(h===")"&&a.size){let N=a.get(ne(o));N.unclosedGroupCount--,N.unclosedGroupCount||a.delete(o.pop())}}return r&&(m=w(m,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:C,bNumSub:S,subNum:W,refNum:O,refCaps:V}})=>{if(C){let k=+C;if(k>i.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${i[k]}`}let N=+S,D=+W,I=+O,b=+V;return N<I||N>I+b?`\\${i[N]}`:`\\${D-I+N}`},d.DEFAULT)),m}var te=new RegExp(String.raw`${B}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function Ve(e,t){let n=j(e,String.raw`\(\?\(DEFINE\)`,0,d.DEFAULT);if(!n)return e;let r=Ne(e,n);if(r.afterPos<e.length)throw new Error("DEFINE group allowed only at the end of a regex");if(r.afterPos>e.length)throw new Error("DEFINE group is unclosed");let s;for(te.lastIndex=0;s=te.exec(r.contents);){let{captureName:a,invalid:o}=s.groups;if(a){let i=Ne(r.contents,s),u;if(!t.get(a).isUnique)u=a;else{let c=Ce(i.contents);for(let f of c.keys())if(!t.get(f).isUnique){u=f;break}}if(u)throw new Error(`Duplicate group name "${u}" within DEFINE`);te.lastIndex=i.afterPos}else if(o)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function je(e){let t=0;return x(e,"\\(",()=>t++,d.DEFAULT),t}function Qe(e,t){let n=0,r=0,s;for(;s=j(e,U,r,d.DEFAULT);){let{0:a,index:o,groups:{captureName:i}}=s;if(n++,i===t)break;r=o+a.length}return n}function Ne(e,t){let n=t.index+t[0].length,r=Z(e,n),s=n+r.length+1;return{contents:r,afterPos:s}}function Ce(e,{includeContents:t}={}){let n=new Map;return x(e,B,({0:r,index:s,groups:{captureName:a}})=>{if(n.has(a))n.get(a).isUnique=!1;else{let o={isUnique:!0};if(t){let i=Z(e,s+r.length);Object.assign(o,{contents:i,groupNum:Qe(e,a),numCaptures:R(i)})}n.set(a,o)}},d.DEFAULT),n}function ne(e){return e[e.length-1]}var He="&!#%,:;<=>@`~",qe=new RegExp(String.raw` | ||
\[\^?-? | ||
| --?\] | ||
| (?<dp>[${T}])\k<dp> | ||
| -- | ||
| \\(?<vOnlyEscape>[${He}]) | ||
| \\[pPu]\{[^}]+\} | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function Le(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:s,groups:{dp:a,vOnlyEscape:o}}of e.matchAll(qe)){if(s[0]==="["){if(n)throw new Error("Invalid nested character class when flag v not supported; possibly from interpolation");if(s.endsWith("-"))throw new Error(t);n=!0}else if(s.endsWith("]")){if(s[0]==="-")throw new Error(t);n=!1}else if(n){if(s==="&&"||s==="--")throw new Error(`Invalid set operator "${s}" when flag v not supported`);if(a)throw new Error(`Invalid double punctuator "${s}", reserved by flag v`);if("(){}/|".includes(s))throw new Error(`Invalid unescaped "${s}" in character class`);if(o){r+=o;continue}}r+=s}return r}var Be=(e,...t)=>{if(Array.isArray(e?.raw))return re({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return re.bind(null,{flags:e??""});if({}.toString.call(e)==="[object Object]"&&!t.length)return re.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},re=(e,t,...n)=>{let r=$e(e),s=Ie(t,n,r),a=0,o="",i;s.template.raw.forEach((c,f)=>{let g=!!(s.template.raw[f]||s.template.raw[f+1]);a+=R(c),o+=y(c,d.CHAR_CLASS),i=P(o,i);let{regexContext:l,charClassContext:m}=i;if(f<s.template.raw.length-1){let A=s.substitutions[f];o+=We(A,r.flags,l,m,g,a),A instanceof RegExp?a+=R(A.source):A instanceof L&&(a+=R(String(A)))}}),o=De(o,r);let u;r.subclass&&({expression:o,captureMap:u}=Ze(o));try{return r.subclass?new se(o,r.flags,{captureMap:u}):new RegExp(o,r.flags)}catch(c){let f=c.message.replace(/ \/.+\/[a-z]*:/,"");throw c.message=`${f}: /${o}/${r.flags}`,c}};function Ke(e="",t={}){let n=$e(t);if(n.subclass)throw new Error("Cannot use option subclass");return{expression:De(Ie({raw:[e]},[],n).template.raw[0],n),flags:n.flags}}function $e(e){let t={flags:"",subclass:!1,plugins:[],unicodeSetsPlugin:Le,disable:{},force:{},...e};if(/[nuvx]/.test(t.flags))throw new Error("Implicit flags v/u/x/n cannot be explicitly added");let n=t.force.v||(t.disable.v?!1:ie);return t.flags+=n?"v":"u",n&&(t.unicodeSetsPlugin=null),t}function Ie(e,t,n){let r=[];n.disable.x||r.push(ge),n.disable.n||r.push(pe);for(let s of r)({template:e,substitutions:t}=fe(e,t,s,n));return{template:e,substitutions:t}}function De(e,t){let{flags:n,plugins:r,unicodeSetsPlugin:s,disable:a,subclass:o}=t;return[...r,...a.subroutines?[]:[Se],...a.atomic?[]:[we,he],...a.x?[]:[Ee],...s?[s]:[]].forEach(i=>e=i(e,{flags:n,useEmulationGroups:o})),e}var se=class e extends RegExp{#e;constructor(t,n,r){super(t,n),r?this.#e=r.captureMap:t instanceof e&&(this.#e=t.#e)}exec(t){let n=RegExp.prototype.exec.call(this,t);if(!n||!this.#e)return n;let r=[...n];n.length=1;for(let s=1;s<r.length;s++)this.#e[s]&&n.push(r[s]);return n}};function We(e,t,n,r,s,a){if(e instanceof RegExp&&n!==p.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===p.INVALID_INCOMPLETE_TOKEN||r===E.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");if(typeof e=="number"&&(n===p.ENCLOSED_U||r===E.ENCLOSED_U))return e.toString(16);let o=e instanceof L,i="";if(!(e instanceof RegExp)){e=String(e),o||(i=J(e,n===p.CHAR_CLASS?d.CHAR_CLASS:d.DEFAULT));let u=le(i||e,n,r);if(u)throw new Error(`Unescaped stray "${u}" in the interpolated value would have side effects outside it`)}if(n===p.INTERVAL_QUANTIFIER||n===p.GROUP_NAME||q.has(n)||G.has(r))return o?String(e):i;if(n===p.CHAR_CLASS){if(o){if(Q(String(e),"^-|^&&|-$|&&$"))throw new Error("Cannot use range or set operator at boundary of interpolated pattern; move the operation into the pattern or the operator outside of it");let u=ue(K(e));return X(e)?`[${u}]`:y(u)}return X(i)?`[${i}]`:i}if(e instanceof RegExp){let u=ze(e,t),c=ce(u.value,a);return u.usedModifier?c:`(?:${c})`}return o?`(?:${e})`:s?`(?:${i})`:i}function ze(e,t){let n={i:null,m:null,s:null},r="\\n\\r\\u2028\\u2029",s=e.source;if(e.ignoreCase!==t.includes("i"))if(M)n.i=e.ignoreCase;else throw new Error("Pattern modifiers not supported, so flag i on the outer and interpolated regex must match");if(e.dotAll!==t.includes("s")&&(M?n.s=e.dotAll:s=w(s,"\\.",e.dotAll?"[^]":`[^${r}]`,d.DEFAULT)),e.multiline!==t.includes("m")&&(M?n.m=e.multiline:(s=w(s,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",d.DEFAULT),s=w(s,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",d.DEFAULT))),M){let a=Object.keys(n),o=a.filter(u=>n[u]===!0).join(""),i=a.filter(u=>n[u]===!1).join("");if(i&&(o+=`-${i}`),o)return{value:`(?${o}:${s})`,usedModifier:!0}}return{value:s}}function Ze(e){let t=$.replace(/\$/g,"\\$"),n=[!0];return e=w(e,`(?:${U})(?<mark>${t})?`,({0:r,groups:{mark:s}})=>s?(n.push(!1),r.slice(0,-$.length)):(n.push(!0),r),d.DEFAULT),{captureMap:n,expression:e}}return Re(Je);})(); | ||
`.replace(/\s+/g,""),"gsu");function je(e,t,n){if(!/\\g</.test(e))return e;let r=H(e,"\\\\(?:[1-9]|k<[^>]+>)",d.DEFAULT),s=r?`(${n?$:""}`:"(?:",a=new Map,o=[],i=[0],u=0,c=0,f=0,E=0,l=0,m=e,A;for(v.lastIndex=0;A=v.exec(m);){let{0:h,index:C,groups:{subroutineName:S,capturingStart:W,backrefNum:P,backrefName:V}}=A;if(h==="[")l++;else if(l)h==="]"&&l--;else if(S){if(!t.has(S))throw new Error(`Invalid named capture referenced by subroutine ${h}`);if(a.has(S))throw new Error(`Subroutine ${h} followed a recursive reference`);let N=t.get(S).contents,D=`${s}${N})`;r&&(f=0,c++),a.set(S,{unclosedGroupCount:He(D)}),o.push(S),m=O(m,C,h,D),v.lastIndex-=h.length-s.length}else if(W)a.size?(r&&(f++,c++),h!=="("&&(m=O(m,C,h,s),v.lastIndex-=h.length-s.length)):r&&(i.push(ne(i)+1+c-E),E=c,u++);else if((P||V)&&a.size){let N=P?+P:t.get(V)?.groupNum,D=!1;for(let I of o){let b=t.get(I);if(N>=b.groupNum&&N<=b.groupNum+b.numCaptures){D=!0;break}}if(D){let I=t.get(ne(o)),b=u+c-f,k=`\\k<$$b${N}s${b}r${I.groupNum}c${I.numCaptures}>`;m=O(m,C,h,k),v.lastIndex+=k.length-h.length}}else if(h===")"&&a.size){let N=a.get(ne(o));N.unclosedGroupCount--,N.unclosedGroupCount||a.delete(o.pop())}}return r&&(m=w(m,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:C,bNumSub:S,subNum:W,refNum:P,refCaps:V}})=>{if(C){let k=+C;if(k>i.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${i[k]}`}let N=+S,D=+W,I=+P,b=+V;return N<I||N>I+b?`\\${i[N]}`:`\\${D-I+N}`},d.DEFAULT)),m}var te=new RegExp(String.raw`${B}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function Qe(e,t){let n=Q(e,String.raw`\(\?\(DEFINE\)`,0,d.DEFAULT);if(!n)return e;let r=Se(e,n);if(r.afterPos<e.length)throw new Error("DEFINE group allowed only at the end of a regex");if(r.afterPos>e.length)throw new Error("DEFINE group is unclosed");let s;for(te.lastIndex=0;s=te.exec(r.contents);){let{captureName:a,invalid:o}=s.groups;if(a){let i=Se(r.contents,s),u;if(!t.get(a).isUnique)u=a;else{let c=Le(i.contents);for(let f of c.keys())if(!t.get(f).isUnique){u=f;break}}if(u)throw new Error(`Duplicate group name "${u}" within DEFINE`);te.lastIndex=i.afterPos}else if(o)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function He(e){let t=0;return x(e,"\\(",()=>t++,d.DEFAULT),t}function qe(e,t){let n=0,r=0,s;for(;s=Q(e,U,r,d.DEFAULT);){let{0:a,index:o,groups:{captureName:i}}=s;if(n++,i===t)break;r=o+a.length}return n}function Se(e,t){let n=t.index+t[0].length,r=Z(e,n),s=n+r.length+1;return{contents:r,afterPos:s}}function Le(e,{includeContents:t}={}){let n=new Map;return x(e,B,({0:r,index:s,groups:{captureName:a}})=>{if(n.has(a))n.get(a).isUnique=!1;else{let o={isUnique:!0};if(t){let i=Z(e,s+r.length);Object.assign(o,{contents:i,groupNum:qe(e,a),numCaptures:R(i)})}n.set(a,o)}},d.DEFAULT),n}function ne(e){return e[e.length-1]}var Be=(e,...t)=>{if(Array.isArray(e?.raw))return re({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return re.bind(null,{flags:e??""});if({}.toString.call(e)==="[object Object]"&&!t.length)return re.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},re=(e,t,...n)=>{let r=$e(e),s=Ie(t,n,r),a=0,o="",i;s.template.raw.forEach((c,f)=>{let E=!!(s.template.raw[f]||s.template.raw[f+1]);a+=R(c),o+=y(c,d.CHAR_CLASS),i=F(o,i);let{regexContext:l,charClassContext:m}=i;if(f<s.template.raw.length-1){let A=s.substitutions[f];o+=We(A,r.flags,l,m,E,a),A instanceof RegExp?a+=R(A.source):A instanceof L&&(a+=R(String(A)))}}),o=De(o,r);let u;r.subclass&&({expression:o,captureMap:u}=Ze(o));try{return r.subclass?new se(o,r.flags,{captureMap:u}):new RegExp(o,r.flags)}catch(c){let f=c.message.replace(/ \/.+\/[a-z]*:/,"");throw c.message=`${f}: /${o}/${r.flags}`,c}};function Ke(e="",t={}){let n=$e(t);if(n.subclass)throw new Error("Cannot use option subclass");return{expression:De(Ie({raw:[e]},[],n).template.raw[0],n),flags:n.flags}}function $e(e){let t={flags:"",subclass:!1,plugins:[],unicodeSetsPlugin:me,disable:{},force:{},...e};if(/[nuvx]/.test(t.flags))throw new Error("Implicit flags v/u/x/n cannot be explicitly added");let n=t.force.v||(t.disable.v?!1:ie);return t.flags+=n?"v":"u",n&&(t.unicodeSetsPlugin=null),t}function Ie(e,t,n){let r=[];n.disable.x||r.push(we),n.disable.n||r.push(he);for(let s of r)({template:e,substitutions:t}=ce(e,t,s,n));return{template:e,substitutions:t}}function De(e,t){let{flags:n,plugins:r,unicodeSetsPlugin:s,disable:a,subclass:o}=t;return[...r,...a.subroutines?[]:[Ce],...a.atomic?[]:[ge,de],...a.x?[]:[Ne],...s?[s]:[]].forEach(i=>e=i(e,{flags:n,useEmulationGroups:o})),e}var se=class e extends RegExp{#e;constructor(t,n,r){super(t,n),r?this.#e=r.captureMap:t instanceof e&&(this.#e=t.#e)}exec(t){let n=RegExp.prototype.exec.call(this,t);if(!n||!this.#e)return n;let r=[...n];n.length=1;for(let s=1;s<r.length;s++)this.#e[s]&&n.push(r[s]);return n}};function We(e,t,n,r,s,a){if(e instanceof RegExp&&n!==p.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===p.INVALID_INCOMPLETE_TOKEN||r===g.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");if(typeof e=="number"&&(n===p.ENCLOSED_U||r===g.ENCLOSED_U))return e.toString(16);let o=e instanceof L,i="";if(!(e instanceof RegExp)){e=String(e),o||(i=X(e,n===p.CHAR_CLASS?d.CHAR_CLASS:d.DEFAULT));let u=le(i||e,n,r);if(u)throw new Error(`Unescaped stray "${u}" in the interpolated value would have side effects outside it`)}if(n===p.INTERVAL_QUANTIFIER||n===p.GROUP_NAME||q.has(n)||G.has(r))return o?String(e):i;if(n===p.CHAR_CLASS){if(o){if(H(String(e),"^-|^&&|-$|&&$"))throw new Error("Cannot use range or set operator at boundary of interpolated pattern; move the operation into the pattern or the operator outside of it");let u=fe(K(e));return J(e)?`[${u}]`:y(u)}return J(i)?`[${i}]`:i}if(e instanceof RegExp){let u=ze(e,t),c=ue(u.value,a);return u.usedModifier?c:`(?:${c})`}return o?`(?:${e})`:s?`(?:${i})`:i}function ze(e,t){let n={i:null,m:null,s:null},r="\\n\\r\\u2028\\u2029",s=e.source;if(e.ignoreCase!==t.includes("i"))if(M)n.i=e.ignoreCase;else throw new Error("Pattern modifiers not supported, so flag i on the outer and interpolated regex must match");if(e.dotAll!==t.includes("s")&&(M?n.s=e.dotAll:s=w(s,"\\.",e.dotAll?"[^]":`[^${r}]`,d.DEFAULT)),e.multiline!==t.includes("m")&&(M?n.m=e.multiline:(s=w(s,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",d.DEFAULT),s=w(s,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",d.DEFAULT))),M){let a=Object.keys(n),o=a.filter(u=>n[u]===!0).join(""),i=a.filter(u=>n[u]===!1).join("");if(i&&(o+=`-${i}`),o)return{value:`(?${o}:${s})`,usedModifier:!0}}return{value:s}}function Ze(e){let t=$.replace(/\$/g,"\\$"),n=[!0];return e=w(e,`(?:${U})(?<mark>${t})?`,({0:r,groups:{mark:s}})=>s?(n.push(!1),r.slice(0,-$.length)):(n.push(!0),r),d.DEFAULT),{captureMap:n,expression:e}}return Fe(Je);})(); | ||
//# sourceMappingURL=regex.min.js.map |
{ | ||
"name": "regex", | ||
"version": "4.3.3", | ||
"version": "4.4.0", | ||
"description": "Regex template tag with extended syntax, context-aware interpolation, and always-on best practices", | ||
@@ -13,2 +13,6 @@ "author": "Steven Levithan", | ||
"require": "./dist/regex.cjs" | ||
}, | ||
"./atomic": { | ||
"types": "./types/atomic.d.ts", | ||
"import": "./src/atomic.js" | ||
} | ||
@@ -18,3 +22,2 @@ }, | ||
"types": "./types/regex.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
@@ -33,2 +36,3 @@ "bundle:global": "esbuild src/regex.js --global-name=Regex --bundle --minify --sourcemap --outfile=dist/regex.min.js", | ||
"dist", | ||
"src", | ||
"types" | ||
@@ -46,7 +50,7 @@ ], | ||
"esbuild": "^0.24.0", | ||
"expect-type": "^0.20.0", | ||
"jasmine": "^5.3.0", | ||
"expect-type": "^1.1.0", | ||
"jasmine": "^5.4.0", | ||
"regex-utilities": "^2.3.0", | ||
"typescript": "^5.6.2" | ||
"typescript": "^5.6.3" | ||
} | ||
} |
@@ -115,3 +115,3 @@ <div align="center"> | ||
```js | ||
import {regex, pattern} from 'regex'; | ||
import {regex} from 'regex'; | ||
``` | ||
@@ -123,4 +123,4 @@ | ||
<script type="module"> | ||
import {regex, pattern} from 'https://esm.run/regex'; | ||
// … | ||
import {regex} from 'https://esm.run/regex'; | ||
const re = regex`…`; | ||
</script> | ||
@@ -135,3 +135,4 @@ ``` | ||
<script> | ||
const {regex, pattern} = Regex; | ||
const {regex} = Regex; | ||
const re = regex`…`; | ||
</script> | ||
@@ -222,3 +223,3 @@ ``` | ||
Like atomic groups, possessive quantifiers are mostly useful for performance and preventing ReDoS, but they can also be used to eliminate certain matches. For example, `` regex`a++.` `` matches one or more `a` followed by a character other than `a`. Unlike `/a+./`, it won't match a sequence of only `a` characters like `'aaa'`. The possessive `++` doesn't give back any of the `a`s it matched, so there's nothing left for the following `.` to match. | ||
Like atomic groups, possessive quantifiers are mostly useful for performance and preventing ReDoS, but they can also be used to eliminate certain matches. For example, `` regex`a++.` `` matches one or more `a` followed by a character other than `a`. Unlike `/a+./`, it won't match a sequence of only `a` characters like `'aaa'`. The possessive `++` doesn't give back any of the `a`s it matched, so in this case there's nothing left for the following `.` to match. | ||
@@ -540,3 +541,3 @@ Here's how possessive quantifier syntax compares to the greedy and lazy quantifiers that JavaScript supports natively: | ||
For all of these cases, you can interpolate `pattern(str)` to avoid escaping special characters in the string or creating an intermediary `RegExp` instance. You can also use `` pattern`…` `` as a tag, as shorthand for ``pattern(String.raw`…`)``. | ||
For all of these cases, you can `import {pattern} from 'regex'` and then interpolate `pattern(str)` to avoid escaping special characters in the string or creating an intermediary `RegExp` instance. You can also use `` pattern`…` `` as a tag, as shorthand for ``pattern(String.raw`…`)``. | ||
@@ -652,28 +653,28 @@ Apart from edge cases, `pattern` just embeds the provided string or other value directly. But because it handles the edge cases, patterns can safely be interpolated anywhere in a regex without worrying about their meaning being changed by (or making unintended changes in meaning to) the surrounding pattern. | ||
</tr> | ||
<tr> | ||
<td>Default<br><br><br></td> | ||
<td><code>regex`${'^.+'}`</code><br><br><br></td> | ||
<td>• Sandboxed <br> • Atomized <br> • Escaped <br><br></td> | ||
<td>• Sandboxed <br> • Atomized <br><br><br></td> | ||
<tr valign="top"> | ||
<td>Default</td> | ||
<td><code>regex`${'^.+'}`</code></td> | ||
<td>• Sandboxed <br> • Atomized <br> • Escaped</td> | ||
<td>• Sandboxed <br> • Atomized</td> | ||
<td>• Sandboxed <br> • Atomized <br> • Backrefs adjusted <br> • Flags localized</td> | ||
</tr> | ||
<tr> | ||
<tr valign="top"> | ||
<td>Character class: <code>[…]</code>, <code>[^…]</code>, <code>[[…]]</code>, etc.</td> | ||
<td><code>regex`[${'a-z'}]`</code><br><br></td> | ||
<td><code>regex`[${'a-z'}]`</code></td> | ||
<td>• Sandboxed <br> • Atomized <br> • Escaped</td> | ||
<td>• Sandboxed <br> • Atomized <br><br></td> | ||
<td><i>Error</i> <br><br><br></td> | ||
<td>• Sandboxed <br> • Atomized</td> | ||
<td><i>Error</i></td> | ||
</tr> | ||
<tr> | ||
<tr valign="top"> | ||
<td>Interval quantifier: <code>{…}</code></td> | ||
<td><code>regex`.{1,${5}}`</code></td> | ||
<td rowspan="3">• Sandboxed <br> • Escaped <br><br><br></td> | ||
<td rowspan="3">• Sandboxed <br><br><br><br></td> | ||
<td rowspan="3"><i>Error</i> <br><br><br><br></td> | ||
<td rowspan="3">• Sandboxed <br> • Escaped</td> | ||
<td rowspan="3">• Sandboxed</td> | ||
<td rowspan="3"><i>Error</i></td> | ||
</tr> | ||
<tr> | ||
<tr valign="top"> | ||
<td>Enclosed token: <code>\p{…}</code>, <code>\P{…}</code>, <code>\u{…}</code>, <code>[\q{…}]</code></td> | ||
<td><code>regex`\u{${'A0'}}`</code></td> | ||
</tr> | ||
<tr> | ||
<tr valign="top"> | ||
<td>Group name: <code>(?<…>)</code>, <code>\k<…></code>, <code>\g<…></code></td> | ||
@@ -792,3 +793,3 @@ <td><code>regex`…\k<${'a'}>`</code></td> | ||
- To ensure atomization, `regex` uses nested character classes (which require flag <kbd>v</kbd>) when interpolating more than one token at a time *inside character classes*. A descriptive error is thrown when this isn't supported, which you can avoid by not interpolating multi-token patterns or strings into character classes. There's also an easy workaround: put the whole character class in a `pattern` and interpolate a string into the pattern. | ||
- Using an interpolated `RegExp` instance with a different value for flag <kbd>i</kbd> than its outer regex relies on [pattern modifiers](https://github.com/tc39/proposal-regexp-modifiers), a bleeding-edge feature available in Chrome 125, Edge 125, Opera 111, and Firefox 132. A descriptive error is thrown in environments without support, which you can avoid by aligning the use of flag <kbd>i</kbd> on inner and outer regexes. Local-only application of other flags doesn't rely on this feature. | ||
- Using an interpolated `RegExp` instance with a different value for flag <kbd>i</kbd> than its outer regex relies on [pattern modifiers](https://github.com/tc39/proposal-regexp-modifiers), a bleeding-edge feature available in Node.js 23, Chrome/Edge 125, Firefox 132, and Opera 111. A descriptive error is thrown in environments without support, which you can avoid by aligning the use of flag <kbd>i</kbd> on inner and outer regexes. Local-only application of other flags doesn't rely on this feature. | ||
@@ -842,3 +843,3 @@ ## 🙋 FAQ | ||
If you want to support this project, I'd love your help by contributing improvements, sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) future development. | ||
If you want to support this project, I'd love your help by contributing improvements, sharing it with others, or [sponsoring](https://github.com/sponsors/slevithan) ongoing development. | ||
@@ -845,0 +846,0 @@ © 2024–present. MIT License. |
/** | ||
@typedef {import('./regex.js').PluginData} PluginData | ||
*/ | ||
/** | ||
Apply transformations for atomic groups: `(?>…)`. | ||
@param {string} expression | ||
@param {PluginData} data | ||
@param {import('./regex.js').PluginData} [data] | ||
@returns {string} | ||
*/ | ||
export function atomicPlugin(expression: string, data: PluginData): string; | ||
export function atomic(expression: string, data?: import("./regex.js").PluginData): string; | ||
/** | ||
@@ -19,3 +16,2 @@ Transform posessive quantifiers into atomic groups. The posessessive quantifiers are: | ||
*/ | ||
export function possessivePlugin(expression: string): string; | ||
export type PluginData = import("./regex.js").PluginData; | ||
export function possessive(expression: string): string; |
@@ -5,2 +5,1 @@ export function flagNPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./utils.js").RegexTagOptions>): { | ||
}; | ||
export type Preprocessor = import("./utils.js").Preprocessor; |
@@ -10,3 +10,2 @@ export function flagXPreprocessor(value: import("./utils.js").InterpolatedValue, runningContext: import("./utils.js").RunningContext, options: Required<import("./utils.js").RegexTagOptions>): { | ||
*/ | ||
export function cleanPlugin(expression: string): string; | ||
export type Preprocessor = import("./utils.js").Preprocessor; | ||
export function clean(expression: string): string; |
/** | ||
@typedef {import('./regex.js').PluginData} PluginData | ||
*/ | ||
/** | ||
@param {string} expression | ||
@param {PluginData} data | ||
@param {import('./regex.js').PluginData} [data] | ||
@returns {string} | ||
*/ | ||
export function subroutinesPlugin(expression: string, data: PluginData): string; | ||
export type PluginData = import("./regex.js").PluginData; | ||
export function subroutines(expression: string, data?: import("./regex.js").PluginData): string; | ||
export type NamedCapturingGroupsMap = Map<string, { | ||
@@ -12,0 +8,0 @@ isUnique: boolean; |
/** | ||
@param {string} expression | ||
@param {number} precedingCaptures | ||
@returns {string} | ||
*/ | ||
export function adjustNumberedBackrefs(expression: string, precedingCaptures: number): string; | ||
export function containsCharClassUnion(charClassPattern: any): boolean; | ||
/** | ||
@param {string} expression | ||
@returns {number} | ||
*/ | ||
export function countCaptures(expression: string): number; | ||
/** | ||
Escape special characters for the given context, assuming flag v. | ||
@@ -8,11 +20,2 @@ @param {string} str String to escape | ||
export function escapeV(str: string, context: "DEFAULT" | "CHAR_CLASS"): string; | ||
export function sandboxLoneDoublePunctuatorChar(str: any): any; | ||
export function sandboxLoneCharClassCaret(str: any): any; | ||
/** | ||
Converts `\0` tokens to `\x00` in the given context. | ||
@param {string} str | ||
@param {'DEFAULT' | 'CHAR_CLASS'} [context] `Context` option from lib `regex-utilities` | ||
@returns {string} | ||
*/ | ||
export function sandboxUnsafeNulls(str: string, context?: "DEFAULT" | "CHAR_CLASS"): string; | ||
export function getBreakoutChar(expression: any, regexContext: any, charClassContext: any): any; | ||
@@ -36,22 +39,2 @@ /** | ||
/** | ||
@param {string} expression | ||
@returns {number} | ||
*/ | ||
export function countCaptures(expression: string): number; | ||
/** | ||
@param {string} expression | ||
@param {number} precedingCaptures | ||
@returns {string} | ||
*/ | ||
export function adjustNumberedBackrefs(expression: string, precedingCaptures: number): string; | ||
/** | ||
@param {string} str | ||
@param {number} pos | ||
@param {string} oldValue | ||
@param {string} newValue | ||
@returns {string} | ||
*/ | ||
export function spliceStr(str: string, pos: number, oldValue: string, newValue: string): string; | ||
export function containsCharClassUnion(charClassPattern: any): boolean; | ||
/** | ||
@typedef {import('./regex.js').InterpolatedValue} InterpolatedValue | ||
@@ -82,2 +65,19 @@ @typedef {import('./regex.js').RawTemplate} RawTemplate | ||
}; | ||
export function sandboxLoneCharClassCaret(str: any): any; | ||
export function sandboxLoneDoublePunctuatorChar(str: any): any; | ||
/** | ||
Converts `\0` tokens to `\x00` in the given context. | ||
@param {string} str | ||
@param {'DEFAULT' | 'CHAR_CLASS'} [context] `Context` option from lib `regex-utilities` | ||
@returns {string} | ||
*/ | ||
export function sandboxUnsafeNulls(str: string, context?: "DEFAULT" | "CHAR_CLASS"): string; | ||
/** | ||
@param {string} str | ||
@param {number} pos | ||
@param {string} oldValue | ||
@param {string} newValue | ||
@returns {string} | ||
*/ | ||
export function spliceStr(str: string, pos: number, oldValue: string, newValue: string): string; | ||
export namespace RegexContext { | ||
@@ -108,4 +108,4 @@ let DEFAULT: string; | ||
export const flagVSupported: boolean; | ||
export const emulationGroupMarker: "$E$"; | ||
export const doublePunctuatorChars: "&!#$%*+,.:;<=>?@^`~"; | ||
export const emulationGroupMarker: "$E$"; | ||
export const namedCapturingDelim: any; | ||
@@ -112,0 +112,0 @@ export const capturingDelim: any; |
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
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
512683
25
4435
848