Comparing version 4.3.2 to 4.3.3
@@ -1,5 +0,5 @@ | ||
var Regex=(()=>{var B=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var be=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},Oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Le(t))!_e.call(e,s)&&s!==n&&B(e,s,{get:()=>t[s],enumerable:!(r=Ce(t,s))||r.enumerable});return e};var De=e=>Oe(B({},"__esModule",{value:!0}),e);var ze={};be(ze,{pattern:()=>Q,regex:()=>je,rewrite:()=>qe});var E=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function N(e,t,n,r){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),i=[!1],o=0,a="";for(let u of e.matchAll(s)){let{0:c,groups:{$skip:p}}=u;if(!p&&(!r||r===E.DEFAULT==!o)){n instanceof Function?a+=n(u,{context:o?E.CHAR_CLASS:E.DEFAULT,negated:i[i.length-1]}):a+=n;continue}c[0]==="["?(o++,i.push(c[1]==="^")):c==="]"&&o&&(o--,i.pop()),a+=c}return a}function x(e,t,n,r){N(e,t,n,r)}function v(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 i=0,o;for(;o=s.exec(e);){let{0:a,groups:{$skip:u}}=o;if(!u&&(!r||r===E.DEFAULT==!i))return o;a==="["?i++:a==="]"&&i&&i--,s.lastIndex==o.index&&s.lastIndex++}return null}function V(e,t,n){return!!v(e,t,0,n)}function W(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,i=1,o;for(;o=n.exec(e);){let[a]=o;if(a==="[")s++;else if(s)a==="]"&&s--;else if(a==="(")i++;else if(a===")"&&(i--,!i)){r=o.index;break}}return e.slice(t,r)}var $=class{#e;constructor(t){this.#e=t}toString(){return String(this.#e)}};function Q(e,...t){if(Array.isArray(e?.raw))return new $(e.raw.flatMap((n,r)=>r<e.raw.length-1?[n,t[r]]:n).join(""));if(!t.length)return new $(e??"");throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)}var f={DEFAULT:"R_DEFAULT",CHAR_CLASS:"R_CHAR_CLASS",GROUP_NAME:"R_GROUP_NAME",ENCLOSED_TOKEN:"R_ENCLOSED_TOKEN",INTERVAL_QUANTIFIER:"R_INTERVAL_QUANTIFIER",INVALID_INCOMPLETE_TOKEN:"R_INVALID_INCOMPLETE_TOKEN"},g={DEFAULT:"CC_DEFAULT",RANGE:"CC_RANGE",ENCLOSED_TOKEN:"CC_ENCLOSED_TOKEN",Q_TOKEN:"CC_Q_TOKEN",INVALID_INCOMPLETE_TOKEN:"CC_INVALID_INCOMPLETE_TOKEN"},G=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),oe=(()=>{try{new RegExp("","v")}catch{return!1}return!0})(),b="&!#$%*+,.:;<=>?@^`~",I="$E$",j=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,O=String.raw`\((?!\?)(?!(?<=\(\?\()DEFINE\))|${j}`,D=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function z(e,t){return t===E.CHAR_CLASS?e.replace(new RegExp(String.raw`[()\[\]{}|\\/\-${b}]`,"g"),"\\$&"):e.replace(/[()\[\]{}|\\^$*+?.]/g,"\\$&")}function q(e){return e.replace(new RegExp(`^([${b}])(?!\\1)`),(t,n,r)=>`\\${t}${r+1===e.length?"":t}`)}function ie(e){return e.replace(/^\^/,"\\^^")}function M(e,t){return N(e,String.raw`\\0(?!\d)`,"\\x00",t)}function re(e,t,n){let r=0;for(let[s]of e.matchAll(new RegExp(`[${z(t+n,E.CHAR_CLASS)}]`,"g")))if(r+=s===t?1:-1,r<0)return n;return r>0?t:""}function ae(e,t,n){let r=e.replace(/\\./gsu,"");if(r.endsWith("\\"))return"\\";if(t===f.DEFAULT)return re(r,"(",")");if(t===f.CHAR_CLASS&&!(n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN))return re(r,"[","]");if(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER||n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN){if(r.includes("}"))return"}"}else if(t===f.GROUP_NAME&&r.includes(">"))return">";return""}var se=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})},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` | ||
(?<groupN>\(\?<(?![=!])|\\[gk]<) | ||
| (?<enclosedT>\\[pPu]\{) | ||
| (?<qT>\\q\{) | ||
| (?<enclosedPU>\\[pPu]\{) | ||
| (?<enclosedQ>\\q\{) | ||
| (?<intervalQ>\{) | ||
@@ -14,5 +14,5 @@ | (?<incompleteT>\\(?: $ | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function R(e,{regexContext:t=f.DEFAULT,charClassContext:n=g.DEFAULT,charClassDepth:r=0,lastPos:s=0}={}){se.lastIndex=s;let i;for(;i=se.exec(e);){let{0:o,groups:{groupN:a,enclosedT:u,qT:c,intervalQ:p,incompleteT:m}}=i;o==="["?(r++,t=f.CHAR_CLASS,n=g.DEFAULT):o==="]"&&t===f.CHAR_CLASS?(r&&r--,r||(t=f.DEFAULT),n=g.DEFAULT):t===f.CHAR_CLASS?m?n=g.INVALID_INCOMPLETE_TOKEN:o==="-"?n=g.RANGE:u?n=g.ENCLOSED_TOKEN:c?n=g.Q_TOKEN:(o==="}"&&(n===g.ENCLOSED_TOKEN||n===g.Q_TOKEN)||n===g.INVALID_INCOMPLETE_TOKEN||n===g.RANGE)&&(n=g.DEFAULT):m?t=f.INVALID_INCOMPLETE_TOKEN:a?t=f.GROUP_NAME:u?t=f.ENCLOSED_TOKEN:p?t=f.INTERVAL_QUANTIFIER:(o===">"&&t===f.GROUP_NAME||o==="}"&&(t===f.ENCLOSED_TOKEN||t===f.INTERVAL_QUANTIFIER)||t===f.INVALID_INCOMPLETE_TOKEN)&&(t=f.DEFAULT)}return{regexContext:t,charClassContext:n,charClassDepth:r,lastPos:e.length}}function U(e){let t=0;return x(e,O,()=>t++,E.DEFAULT),t}function ue(e,t){return N(e,String.raw`\\(?<num>[1-9]\d*)`,({groups:{num:n}})=>`\\${+n+t}`,E.DEFAULT)}function F(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var Re=["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Flag_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence","RGI_Emoji"].join("|"),Ue=new RegExp(String.raw` | ||
`.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>${Re})\} | ||
| p\{(?<pStrProp>${Fe})\} | ||
| [pP]\{[^\}]+\} | ||
@@ -27,8 +27,8 @@ | (?<qStrProp>q) | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function Z(e){let t=!1,n;for(let{0:r,groups:s}of e.matchAll(Ue)){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 le(e,t,n,r){let s={raw:[]},i=[],o;return e.raw.forEach((a,u)=>{let c=n(a,{...o,lastPos:0},r);if(s.raw.push(c.transformed),o=c.runningContext,u<e.raw.length-1){let p=t[u];if(p instanceof $){let m=n(p,{...o,lastPos:0},r);i.push(Q(m.transformed)),o=m.runningContext}else i.push(p)}}),{template:s,substitutions:i}}var Fe=new RegExp(String.raw` | ||
${D} | ||
`.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` | ||
${_} | ||
| \(\?< | ||
| (?<backrefNum>\\[1-9]\d*) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function ce(e,t){e=String(e);let n="",r="";for(let{0:s,groups:{backrefNum:i}}of e.matchAll(Fe)){n+=s,t=R(n,t);let{regexContext:o}=t;if(o===f.DEFAULT)if(s==="(")r+="(?:";else{if(i)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 fe=/^\s$/,Pe=/^\\[\s#]$/,J=/^[ \t]$/,ke=/^\\[ \t]$/,xe=new RegExp(String.raw` | ||
`.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` | ||
\\(?: [gk]< | ||
@@ -42,9 +42,9 @@ | [pPu]\{ | ||
| \[\^ | ||
| ${D} | ||
| ${_} | ||
| \(\?< | ||
| (?<dp>[${b}])\k<dp> | ||
| (?<dp>[${T}])\k<dp> | ||
| -- | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function pe(e,t,n){e=String(e);let r=!1,s=!1,i=!1,o="",a="",u="",c="",p=!1,m=(l,{prefix:d=!0,postfix:A=!1}={})=>(l=(p&&d?"(?:)":"")+l+(A?"(?:)":""),p=!1,l);for(let{0:l,index:d}of e.matchAll(xe)){if(i){l===` | ||
`&&(i=!1,p=!0);continue}if(r){if(fe.test(l))continue;r=!1,p=!0}else if(s){if(J.test(l))continue;s=!1}o+=l,t=R(o,t);let{regexContext:A,charClassContext:h}=t;if(l==="-"&&A===f.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===f.DEFAULT&&/^(?:[?*+]|\?\?)$/.test(l)||A===f.INTERVAL_QUANTIFIER&&l==="{")a+=m(l,{prefix:!1,postfix:u==="("&&l==="?"});else if(A===f.DEFAULT)fe.test(l)?r=!0:l.startsWith("#")?i=!0:Pe.test(l)?a+=m(l[1],{prefix:!1}):a+=m(l);else if(A===f.CHAR_CLASS&&l!=="["&&l!=="[^")if(J.test(l)&&(h===g.DEFAULT||h===g.RANGE||h===g.Q_TOKEN))s=!0;else{if(h===g.INVALID_INCOMPLETE_TOKEN)throw new Error(`Invalid incomplete token in character class: "${l}"`);if(ke.test(l)&&(h===g.DEFAULT||h===g.Q_TOKEN))a+=m(l[1],{prefix:!1});else if(h===g.DEFAULT){let T=e[d+1]??"",S=M(l);(J.test(T)||l==="^")&&(S=q(S)),a+=m(S)}else a+=m(l)}else a+=m(l);r||s||i||(u=l,c=h)}return{transformed:a,runningContext:t}}function de(e){let t=String.raw`\(\?:\)`;e=N(e,`(?:${t}){2,}`,"(?:)",E.DEFAULT);let n=I.replace(/\$/g,"\\$");return e=N(e,String.raw`(?:${t}(?=[)|.[$\\]|\((?!DEFINE)|$)|(?<=[()|.\]^>]|\\[bBdDfnrsStvwW]|\(\?(?:[:=!]|<[=!])|^)${t}(?![?*+{]))(?!${n})`,"",E.DEFAULT),e}var Ee=new RegExp(String.raw`(?<noncapturingStart>${D})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function ge(e,t){if(!/\(\?>/.test(e))return e;let n="(?>",r=`(?:(?=(${t.useEmulationGroups?I:""}`,s=[0],i=0,o=0,a=NaN,u;do{u=!1;let c=0,p=0,m=!1,l;for(Ee.lastIndex=Number.isNaN(a)?0:a+r.length;l=Ee.exec(e);){let{0:d,index:A,groups:{capturingStart:h,noncapturingStart:T}}=l;if(d==="[")c++;else if(c)d==="]"&&c--;else if(d===n&&!m)a=A,m=!0;else if(m&&T)p++;else if(h)m?p++:(i++,s.push(i+o));else if(d===")"&&m){if(!p){o++,e=`${e.slice(0,a)}${r}${e.slice(a+n.length,A)}))<$$${o+i}>)${e.slice(A+1)}`,u=!0;break}p--}}}while(u);return e=N(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:c,groups:{backrefNum:p,wrappedBackrefNum:m}})=>{if(p){let l=+p;if(l>s.length-1)throw new Error(`Backref "${c}" greater than number of captures`);return`\\${s[l]}`}return`\\${m}`},E.DEFAULT),e}var me=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,X=new RegExp(String.raw` | ||
`.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+ | ||
@@ -62,19 +62,19 @@ | c[A-Za-z] | ||
))? | ||
| (?<qBase>${me})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| (?<qBase>${Ae})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function he(e){if(!new RegExp(`${me}\\+`).test(e))return e;let t=[],n=null,r=null,s="",i=0,o;for(X.lastIndex=0;o=X.exec(e);){let{0:a,index:u,groups:{qBase:c,qMod:p,invalidQ:m}}=o;if(a==="[")i||(r=u),i++;else if(a==="]")i?i--:r=null;else if(!i)if(p==="+"&&s&&!s.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${a}"`);let l=-1;if(/^\{\d+\}$/.test(c))e=F(e,u+c.length,p,"");else{if(s===")"||s==="]"){let d=s===")"?n:r;if(d===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,d)}(?>${e.slice(d,u)}${c})${e.slice(u+a.length)}`}else e=`${e.slice(0,u-s.length)}(?>${s}${c})${e.slice(u+a.length)}`;l+=4}X.lastIndex+=l}else a[0]==="("?t.push(u):a===")"&&(n=t.length?t.pop():null);s=a}return e}function Ae(e,t){let n=we(e,{includeContents:!0}),r=Me(e,n,t.useEmulationGroups);return Ke(r,n)}var Ge=String.raw`\\g<(?<subroutineName>[^>&]+)>`,K=new RegExp(String.raw` | ||
${Ge} | ||
| (?<capturingStart>${O}) | ||
`.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} | ||
| (?<capturingStart>${U}) | ||
| \\(?<backrefNum>[1-9]\d*) | ||
| \\k<(?<backrefName>[^>]+)> | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function Me(e,t,n){if(!/\\g</.test(e))return e;let r=V(e,"\\\\(?:[1-9]|k<[^>]+>)",E.DEFAULT),s=r?`(${n?I:""}`:"(?:",i=new Map,o=[],a=[0],u=0,c=0,p=0,m=0,l=0,d=e,A;for(K.lastIndex=0;A=K.exec(d);){let{0:h,index:T,groups:{subroutineName:S,capturingStart:H,backrefNum:P,backrefName:y}}=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(i.has(S))throw new Error(`Subroutine ${h} followed a recursive reference`);let w=t.get(S).contents,L=`${s}${w})`;r&&(p=0,c++),i.set(S,{unclosedGroupCount:ye(L)}),o.push(S),d=F(d,T,h,L),K.lastIndex-=h.length-s.length}else if(H)i.size?(r&&(p++,c++),h!=="("&&(d=F(d,T,h,s),K.lastIndex-=h.length-s.length)):r&&(a.push(ee(a)+1+c-m),m=c,u++);else if((P||y)&&i.size){let w=P?+P:t.get(y)?.groupNum,L=!1;for(let C of o){let _=t.get(C);if(w>=_.groupNum&&w<=_.groupNum+_.numCaptures){L=!0;break}}if(L){let C=t.get(ee(o)),_=u+c-p,k=`\\k<$$b${w}s${_}r${C.groupNum}c${C.numCaptures}>`;d=F(d,T,h,k),K.lastIndex+=k.length-h.length}}else if(h===")"&&i.size){let w=i.get(ee(o));w.unclosedGroupCount--,w.unclosedGroupCount||i.delete(o.pop())}}return r&&(d=N(d,String.raw`\\(?:(?<bNum>[1-9]\d*)|k<\$\$b(?<bNumSub>\d+)s(?<subNum>\d+)r(?<refNum>\d+)c(?<refCaps>\d+)>)`,({0:h,groups:{bNum:T,bNumSub:S,subNum:H,refNum:P,refCaps:y}})=>{if(T){let k=+T;if(k>a.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${a[k]}`}let w=+S,L=+H,C=+P,_=+y;return w<C||w>C+_?`\\${a[w]}`:`\\${L-C+w}`},E.DEFAULT)),d}var Y=new RegExp(String.raw`${j}|\(\?:\)|(?<invalid>\\?.)`,"gsu");function Ke(e,t){let n=v(e,String.raw`\(\?\(DEFINE\)`,0,E.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(Y.lastIndex=0;s=Y.exec(r.contents);){let{captureName:i,invalid:o}=s.groups;if(i){let a=Ne(r.contents,s),u;if(!t.get(i).isUnique)u=i;else{let c=we(a.contents);for(let p of c.keys())if(!t.get(p).isUnique){u=p;break}}if(u)throw new Error(`Duplicate group name "${u}" within DEFINE`);Y.lastIndex=a.afterPos}else if(o)throw new Error("DEFINE group includes unsupported syntax at top level")}return e.slice(0,n.index)}function ye(e){let t=0;return x(e,"\\(",()=>t++,E.DEFAULT),t}function ve(e,t){let n=0,r=0,s;for(;s=v(e,O,r,E.DEFAULT);){let{0:i,index:o,groups:{captureName:a}}=s;if(n++,a===t)break;r=o+i.length}return n}function Ne(e,t){let n=t.index+t[0].length,r=W(e,n),s=n+r.length+1;return{contents:r,afterPos:s}}function we(e,{includeContents:t}={}){let n=new Map;return x(e,j,({0:r,index:s,groups:{captureName:i}})=>{if(n.has(i))n.get(i).isUnique=!1;else{let o={isUnique:!0};if(t){let a=W(e,s+r.length);Object.assign(o,{contents:a,groupNum:ve(e,i),numCaptures:U(a)})}n.set(i,o)}},E.DEFAULT),n}function ee(e){return e[e.length-1]}var Ve="&!#%,:;<=>@`~",Qe=new RegExp(String.raw` | ||
`.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>[${b}])\k<dp> | ||
| (?<dp>[${T}])\k<dp> | ||
| -- | ||
| \\(?<vOnlyEscape>[${Ve}]) | ||
| \\(?<vOnlyEscape>[${He}]) | ||
| \\[pPu]\{[^}]+\} | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function Se(e){let t='Invalid unescaped "-" in character class',n=!1,r="";for(let{0:s,groups:{dp:i,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(i)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 je=(e,...t)=>{if(Array.isArray(e?.raw))return te({},e,...t);if((typeof e=="string"||e===void 0)&&!t.length)return te.bind(null,{flags:e??""});if({}.toString.call(e)==="[object Object]"&&!t.length)return te.bind(null,e);throw new Error(`Unexpected arguments: ${JSON.stringify([e,...t])}`)},te=(e,t,...n)=>{let r=Te(e),s=$e(t,n,r),i=0,o="",a;if(s.template.raw.forEach((u,c)=>{let p=!!(s.template.raw[c]||s.template.raw[c+1]);i+=U(u),o+=M(u,E.CHAR_CLASS),a=R(o,a);let{regexContext:m,charClassContext:l}=a;if(c<s.template.raw.length-1){let d=s.substitutions[c];o+=He(d,r.flags,m,l,p,i),d instanceof RegExp?i+=U(d.source):d instanceof $&&(i+=U(String(d)))}}),o=Ie(o,r),r.subclass){let u=We(o);return new ne(u.expression,r.flags,{captureMap:u.captureMap})}return new RegExp(o,r.flags)};function qe(e="",t={}){let n=Te(t);if(n.subclass)throw new Error("Cannot use option subclass");return{expression:Ie($e({raw:[e]},[],n).template.raw[0],n),flags:n.flags}}function Te(e){let t={flags:"",subclass:!1,plugins:[],unicodeSetsPlugin:Se,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:oe);return t.flags+=n?"v":"u",n&&(t.unicodeSetsPlugin=null),t}function $e(e,t,n){let r=[];n.disable.x||r.push(pe),n.disable.n||r.push(ce);for(let s of r)({template:e,substitutions:t}=le(e,t,s,n));return{template:e,substitutions:t}}function Ie(e,t){let{flags:n,plugins:r,unicodeSetsPlugin:s,disable:i,subclass:o}=t;return[...r,...i.subroutines?[]:[Ae],...i.atomic?[]:[he,ge],...i.x?[]:[de],...s?[s]:[]].forEach(a=>e=a(e,{flags:n,useEmulationGroups:o})),e}var ne=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 He(e,t,n,r,s,i){if(e instanceof RegExp&&n!==f.DEFAULT)throw new Error("Cannot interpolate a RegExp at this position because the syntax context does not match");if(n===f.INVALID_INCOMPLETE_TOKEN||r===g.INVALID_INCOMPLETE_TOKEN)throw new Error("Interpolation preceded by invalid incomplete token");let o=e instanceof $,a="";if(!(e instanceof RegExp)){e=String(e),o||(a=z(e,n===f.CHAR_CLASS?E.CHAR_CLASS:E.DEFAULT));let u=ae(a||e,n,r);if(u)throw new Error(`Unescaped stray "${u}" in the interpolated value would have side effects outside it`)}if(n===f.ENCLOSED_TOKEN||n===f.INTERVAL_QUANTIFIER||n===f.GROUP_NAME||r===g.ENCLOSED_TOKEN||r===g.Q_TOKEN)return o?String(e):a;if(n===f.CHAR_CLASS){if(o){if(V(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=ie(q(e));return Z(e)?`[${u}]`:M(u)}return Z(a)?`[${a}]`:a}if(e instanceof RegExp){let u=Be(e,t),c=ue(u.value,i);return u.usedModifier?c:`(?:${c})`}return o?`(?:${e})`:s?`(?:${a})`:a}function Be(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(G)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")&&(G?n.s=e.dotAll:s=N(s,"\\.",e.dotAll?"[^]":`[^${r}]`,E.DEFAULT)),e.multiline!==t.includes("m")&&(G?n.m=e.multiline:(s=N(s,"\\^",e.multiline?`(?<=^|[${r}])`:"(?<![^])",E.DEFAULT),s=N(s,"\\$",e.multiline?`(?=$|[${r}])`:"(?![^])",E.DEFAULT))),G){let i=Object.keys(n),o=i.filter(u=>n[u]===!0).join(""),a=i.filter(u=>n[u]===!1).join("");if(a&&(o+=`-${a}`),o)return{value:`(?${o}:${s})`,usedModifier:!0}}return{value:s}}function We(e){let t=I.replace(/\$/g,"\\$"),n=[!0];return e=N(e,`(?:${O})(?<mark>${t})?`,({0:r,groups:{mark:s}})=>s?(n.push(!1),r.slice(0,-I.length)):(n.push(!0),r),E.DEFAULT),{captureMap:n,expression:e}}return De(ze);})(); | ||
`.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);})(); | ||
//# sourceMappingURL=regex.min.js.map |
{ | ||
"name": "regex", | ||
"version": "4.3.2", | ||
"version": "4.3.3", | ||
"description": "Regex template tag with extended syntax, context-aware interpolation, and always-on best practices", | ||
@@ -17,2 +17,3 @@ "author": "Steven Levithan", | ||
"types": "./types/regex.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
@@ -42,8 +43,8 @@ "bundle:global": "esbuild src/regex.js --global-name=Regex --bundle --minify --sourcemap --outfile=dist/regex.min.js", | ||
"devDependencies": { | ||
"esbuild": "^0.23.1", | ||
"esbuild": "^0.24.0", | ||
"expect-type": "^0.20.0", | ||
"jasmine": "^5.3.0", | ||
"regex-utilities": "^2.3.0", | ||
"typescript": "^5.5.4" | ||
"typescript": "^5.6.2" | ||
} | ||
} |
@@ -10,5 +10,5 @@ <div align="center"> | ||
[![build status](https://github.com/slevithan/regex/workflows/CI/badge.svg)](https://github.com/slevithan/regex/actions) | ||
[![npm](https://img.shields.io/npm/v/regex)](https://www.npmjs.com/package/regex) | ||
[![bundle size](https://deno.bundlejs.com/badge?q=regex&treeshake=[*])](https://bundlejs.com/?q=regex&treeshake=[*]) | ||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![bundle][bundle-src]][bundle-href] | ||
</div> | ||
@@ -47,2 +47,3 @@ | ||
- [Options](#-options) | ||
- [Returning a string](#returning-a-string) | ||
- [Performance](#-performance) | ||
@@ -123,3 +124,3 @@ - [Compatibility](#-compatibility) | ||
<script type="module"> | ||
import {regex, pattern} from 'https://cdn.jsdelivr.net/npm/regex@4.3.2/+esm'; | ||
import {regex, pattern} from 'https://esm.run/regex'; | ||
// … | ||
@@ -133,3 +134,3 @@ </script> | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/regex@4.3.2/dist/regex.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/regex/dist/regex.min.js"></script> | ||
<script> | ||
@@ -328,3 +329,3 @@ const {regex, pattern} = Regex; | ||
> [!NOTE] | ||
> Subroutines are based on the feature in PCRE and Perl. PCRE allows several syntax options including `\g<name>`, whereas Perl uses `(?&name)`. Ruby also supports subroutines (and uses the `\g<name>` syntax), but it has behavior differences that make its subroutines not always act as independent subpatterns. | ||
> Subroutines are based on the feature in PCRE and Perl. PCRE allows several syntax options including `\g<name>`, whereas Perl uses `(?&name)`. Ruby also supports subroutines (and uses the `\g<name>` syntax), but it has behavior differences related to backreferences and duplicate group names. | ||
@@ -549,3 +550,3 @@ ### Subroutine definition groups | ||
<details> | ||
<summary>👉 <b>Show me some edge cases</b></summary> | ||
<summary>👉 <b>Show some edge cases</b></summary> | ||
@@ -559,5 +560,5 @@ First, let's consider: | ||
Although `[^…]` is a negated character class, `^` ***within*** a class doesn't need to be escaped, even with the strict escaping rules of flags <kbd>u</kbd> and <kbd>v</kbd>. | ||
Although `[^…]` is a negated character class, `^` *within* a class doesn't need to be escaped, even with the strict escaping rules of flags <kbd>u</kbd> and <kbd>v</kbd>. | ||
Both of these examples therefore match a literal `^`. The interpolated patterns don't change the meaning of the surrounding character class. However, note that the `^` is not simply escaped. `` pattern`^^` `` embedded in character class context would still correctly lead to an "invalid set operation" error due to the use of a reserved double-punctuator. | ||
Both of these examples therefore match a literal `^` or `a`. The interpolated patterns don't change the meaning of the surrounding character class. However, note that the `^` is not simply escaped, as it would be with `` regex`[${'^'}a]` ``. You can see this by the fact that embedding `` pattern`^^` `` in a character class correctly leads to an "invalid set operation" error due to the use of a reserved double-punctuator. | ||
@@ -684,8 +685,12 @@ > If you wanted to dynamically choose whether to negate a character class, you could put the whole character class inside the pattern. | ||
- *Atomized* means that the value is treated as a complete unit; it isn't related to the *atomic groups* feature. Example: In default context, `${x}*` matches any number of the value specified by `x`, and not just its last token. In character class context, subtraction and intersection operators apply to the entire atom. | ||
<details> | ||
<summary>👉 <b>Show more details</b></summary> | ||
- *Atomized* means that the value is treated as a complete unit; it isn't related to the *atomic groups* feature. For example, in default context, `${foo}*` matches any number of `foo`; not just its last token. In character class context, subtraction and intersection operators apply to the entire atom. | ||
- *Sandboxed* means that the value can't change the meaning or error status of characters outside of the interpolation, and vice versa. | ||
- Character classes have a sub-context on the borders of ranges. Only one character node (e.g. `a` or `\u0061`) can be interpolated at these positions. | ||
- Numbers interpolated into an enclosed `\u{…}` context are converted to hexadecimal. | ||
- The implementation details vary for how `regex` accomplishes sandboxing and atomization, based on the details of the specific pattern. But the concepts should always hold up. | ||
</details> | ||
> The implementation details vary for how `regex` accomplishes sandboxing and atomization, based on the details of the specific pattern. But the concepts should always hold up. | ||
## 🔩 Options | ||
@@ -724,3 +729,3 @@ | ||
<details> | ||
<summary>👉 <b>See details for each option</b></summary> | ||
<summary>👉 <b>Show details for each option</b></summary> | ||
@@ -790,3 +795,3 @@ **`flags`** — For providing flags when using an options object. | ||
- 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/Edge 125 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. | ||
- 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. | ||
@@ -843,1 +848,10 @@ ## 🙋 FAQ | ||
© 2024–present. MIT License. | ||
<!-- Badges --> | ||
[npm-version-src]: https://img.shields.io/npm/v/regex?color=78C372 | ||
[npm-version-href]: https://npmjs.com/package/regex | ||
[npm-downloads-src]: https://img.shields.io/npm/dm/regex?color=78C372 | ||
[npm-downloads-href]: https://npmjs.com/package/regex | ||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/regex?color=78C372&label=minzip | ||
[bundle-href]: https://bundlephobia.com/result?p=regex |
@@ -38,2 +38,3 @@ export type InterpolatedValue = string | RegExp | Pattern | number; | ||
}; | ||
import { pattern } from './pattern.js'; | ||
/** | ||
@@ -81,3 +82,2 @@ @typedef {string | RegExp | Pattern | number} InterpolatedValue | ||
export const regex: RegexTag<RegExp>; | ||
import { pattern } from './pattern.js'; | ||
/** | ||
@@ -84,0 +84,0 @@ Returns the processed expression and flags as strings. |
@@ -83,4 +83,5 @@ /** | ||
let CHAR_CLASS: string; | ||
let ENCLOSED_P: string; | ||
let ENCLOSED_U: string; | ||
let GROUP_NAME: string; | ||
let ENCLOSED_TOKEN: string; | ||
let INTERVAL_QUANTIFIER: string; | ||
@@ -92,9 +93,13 @@ let INVALID_INCOMPLETE_TOKEN: string; | ||
export { DEFAULT_1 as DEFAULT }; | ||
export let RANGE: string; | ||
let ENCLOSED_TOKEN_1: string; | ||
export { ENCLOSED_TOKEN_1 as ENCLOSED_TOKEN }; | ||
export let Q_TOKEN: string; | ||
let ENCLOSED_P_1: string; | ||
export { ENCLOSED_P_1 as ENCLOSED_P }; | ||
export let ENCLOSED_Q: string; | ||
let ENCLOSED_U_1: string; | ||
export { ENCLOSED_U_1 as ENCLOSED_U }; | ||
let INVALID_INCOMPLETE_TOKEN_1: string; | ||
export { INVALID_INCOMPLETE_TOKEN_1 as INVALID_INCOMPLETE_TOKEN }; | ||
export let RANGE: string; | ||
} | ||
export const enclosedTokenRegexContexts: any; | ||
export const enclosedTokenCharClassContexts: any; | ||
export const patternModsSupported: boolean; | ||
@@ -101,0 +106,0 @@ export const flagVSupported: boolean; |
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
453567
2872
847