@lexical/code-shiki 0.35.1-nightly.20250924.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,13 @@ import { CodeNode } from '@lexical/code';
10
10
  export interface Tokenizer {
11
11
  defaultLanguage: string;
12
12
  defaultTheme: string;
13
- $tokenize(codeNode: CodeNode, language?: string): LexicalNode[];
13
+ $tokenize: (codeNode: CodeNode, language?: string) => LexicalNode[];
14
14
  }
15
15
  export declare const ShikiTokenizer: Tokenizer;
16
16
  export declare function registerCodeHighlighting(editor: LexicalEditor, tokenizer?: Tokenizer): () => void;
17
+ /**
18
+ * Add code highlighting support for code blocks with Shiki
19
+ */
20
+ export declare const CodeHighlighterShikiExtension: import("lexical").LexicalExtension<{
21
+ tokenizer: Tokenizer;
22
+ }, "@lexical/code-shiki", unknown, unknown>;
@@ -8468,14 +8468,14 @@ const m$1=o$1`\[\^?`,b$1=`c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\
8468
8468
  | ${m$1}
8469
8469
  | &&
8470
8470
  | .
8471
- `.replace(/\s+/g,""),"gsu");function M$1(e,n={}){const t={flags:"",...n,rules:{captureGroup:!1,singleline:!1,...n.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const o=Y(t.flags),s=[o.extended],a={captureGroup:t.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop();},pushModX(u){s.push(u);},replaceCurrentModX(u){s[s.length-1]=u;},singleline:t.rules.singleline};let r=[],i;for(C$1.lastIndex=0;i=C$1.exec(e);){const u=F$1(a,e,i[0],C$1.lastIndex);u.tokens?r.push(...u.tokens):u.token&&r.push(u.token),u.lastIndex!==void 0&&(C$1.lastIndex=u.lastIndex);}const l=[];let c=0;r.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++c:u.raw==="("&&l.push(u);}),c||l.forEach((u,S)=>{u.kind="capturing",u.number=S+1;});const g=c||l.length;return {tokens:r.map(u=>u.type==="EscapedNumber"?ee$1(u,g):u).flat(),flags:o}}function F$1(e,n,t,o){const[s,a]=t;if(t==="["||t==="[^"){const r=K$1(n,t,o);return {tokens:r.tokens,lastIndex:r.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(a))return {token:w$1(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:R$1(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:A$1(t)}}if(a==="K")return {token:I$1("keep",t)};if(a==="N"||a==="R")return {token:k$1("newline",t,{negate:a==="N"})};if(a==="O")return {token:k$1("any",t)};if(a==="X")return {token:k$1("text_segment",t)};const r=x(t,{inCharClass:!1});return Array.isArray(r)?{tokens:r}:{token:r}}if(s==="("){if(a==="*")return {token:j(t)};if(t==="(?{")throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(n[o]!==")")throw new Error('Unclosed comment group "(?#"');return {lastIndex:o+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return {token:L$1(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,t==="("&&!e.captureGroup||t==="(?:")return {token:f$1("group",t)};if(t==="(?>")return {token:f$1("atomic",t)};if(t==="(?="||t==="(?!"||t==="(?<="||t==="(?<!")return {token:f$1(t[2]==="<"?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if(t==="("&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return {token:f$1("capturing",t,{...t!=="("&&{name:t.slice(3,-1)}})};if(t.startsWith("(?~")){if(t==="(?~|")throw new Error(`Unsupported absence function kind "${t}"`);return {token:f$1("absence_repeater",t)}}throw t==="(?("?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(t===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return {token:Q$1(t)}}if(e.getCurrentModX()){if(t==="#"){const r=n.indexOf(`
8472
- `,o);return {lastIndex:r===-1?n.length:r}}if(/^\s$/.test(t)){const r=/\s+/y;return r.lastIndex=o,{lastIndex:r.exec(n)?r.lastIndex:o}}}if(t===".")return {token:k$1("dot",t)};if(t==="^"||t==="$"){const r=e.singleline?{"^":o$1`\A`,$:o$1`\Z`}[t]:t;return {token:w$1(r,t)}}return t==="|"?{token:P$1(t)}:y$1.test(t)?{tokens:te$1(t)}:{token:d(r$2(t),t)}}function K$1(e,n,t){const o=[E$1(n[1]==="^",n)];let s=1,a;for(T$1.lastIndex=t;a=T$1.exec(e);){const r=a[0];if(r[0]==="["&&r[1]!==":")s++,o.push(E$1(r[1]==="^",r));else if(r==="]"){if(o.at(-1).type==="CharacterClassOpen")o.push(d(93,r));else if(s--,o.push(z$1(r)),!s)break}else {const i=X$1(r);Array.isArray(i)?o.push(...i):o.push(i);}}return {tokens:o,lastIndex:T$1.lastIndex||e.length}}function X$1(e){if(e[0]==="\\")return x(e,{inCharClass:!0});if(e[0]==="["){const n=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!n||!i.has(n.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return k$1("posix",e,{value:n.groups.name,negate:!!n.groups.negate})}return e==="-"?U$1(e):e==="&&"?H(e):d(r$2(e),e)}function x(e,{inCharClass:n}){const t=e[1];if(t==="c"||t==="C")return Z(e);if("dDhHsSwW".includes(t))return q(e);if(e.startsWith(o$1`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return V$1(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const o=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(o)),a=new TextEncoder;return [...s].map(i=>{const l=[...a.encode(i)].map(c=>`\\x${c.toString(16)}`).join("");return d(r$2(i),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return d(J$1(e),e);if($$1.has(t))return d($$1.get(t),e);if(/\d/.test(t))return W$1(n,e);if(e==="\\")throw new Error(o$1`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return d(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function P$1(e){return {type:"Alternator",raw:e}}function w$1(e,n){return {type:"Assertion",kind:e,raw:n}}function A$1(e){return {type:"Backreference",raw:e}}function d(e,n){return {type:"Character",value:e,raw:n}}function z$1(e){return {type:"CharacterClassClose",raw:e}}function U$1(e){return {type:"CharacterClassHyphen",raw:e}}function H(e){return {type:"CharacterClassIntersector",raw:e}}function E$1(e,n){return {type:"CharacterClassOpen",negate:e,raw:n}}function k$1(e,n,t={}){return {type:"CharacterSet",kind:e,...t,raw:n}}function I$1(e,n,t={}){return e==="keep"?{type:"Directive",kind:e,raw:n}:{type:"Directive",kind:e,flags:u(t.flags),raw:n}}function W$1(e,n){return {type:"EscapedNumber",inCharClass:e,raw:n}}function Q$1(e){return {type:"GroupClose",raw:e}}function f$1(e,n,t={}){return {type:"GroupOpen",kind:e,...t,raw:n}}function D$1(e,n,t,o){return {type:"NamedCallout",kind:e,tag:n,arguments:t,raw:o}}function _$1(e,n,t,o){return {type:"Quantifier",kind:e,min:n,max:t,raw:o}}function R$1(e){return {type:"Subroutine",raw:e}}const B$1=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$$1=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Z(e){const n=e[1]==="c"?e[2]:e[3];if(!n||!/[A-Za-z]/.test(n))throw new Error(`Unsupported control character "${e}"`);return d(r$2(n.toUpperCase())-64,e)}function L$1(e,n){let{on:t,off:o}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;o??="";const s=(n.getCurrentModX()||t.includes("x"))&&!o.includes("x"),a=v(t),r=v(o),i={};if(a&&(i.enable=a),r&&(i.disable=r),e.endsWith(")"))return n.replaceCurrentModX(s),I$1("flags",e,{flags:i});if(e.endsWith(":"))return n.pushModX(s),n.numOpenGroups++,f$1("group",e,{...(a||r)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function j(e){const n=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!n)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:t,tag:o,args:s}=n.groups;if(!t)throw new Error(`Invalid named callout "${e}"`);if(o==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=s?s.split(",").filter(g=>g!=="").map(g=>/^[+-]?\d+$/.test(g)?+g:g):[],[r,i,l]=a,c=B$1.has(t)?t.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case"error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof r=="string")throw new Error(`Named callout argument must be a number "${r}"`);break;case"max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(a.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof r=="number"||!/^[<>X]$/.test(r)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);break;case"cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return D$1(c,o??null,s?.split(",")??null,e)}function O$1(e){let n=null,t,o;if(e[0]==="{"){const{minStr:s,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,r=1e5;if(+s>r||a&&+a>r)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,o=a===void 0?+s:a===""?1/0:+a,t>o&&(n="possessive",[t,o]=[o,t]),e.endsWith("?")){if(n==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');n="lazy";}else n||(n="greedy");}else t=e[0]==="+"?1:0,o=e[0]==="?"?1:1/0,n=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return _$1(n,t,o,e)}function q(e){const n=e[1].toLowerCase();return k$1({d:"digit",h:"hex",s:"space",w:"word"}[n],e,{negate:e[1]!==n})}function V$1(e){const{p:n,neg:t,value:o}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return k$1("property",e,{value:o,negate:n==="P"&&!t||n==="p"&&!!t})}function v(e){const n={};return e.includes("i")&&(n.ignoreCase=!0),e.includes("m")&&(n.dotAll=!0),e.includes("x")&&(n.extended=!0),Object.keys(n).length?n:null}function Y(e){const n={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let t=0;t<e.length;t++){const o=e[t];if(!"imxDPSWy".includes(o))throw new Error(`Invalid flag "${o}"`);if(o==="y"){if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');n.textSegmentMode=e[t+2]==="g"?"grapheme":"word",t+=3;continue}n[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[o]]=!0;}return n}function J$1(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const n=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(n,16)}function ee$1(e,n){const{raw:t,inCharClass:o}=e,s=t.slice(1);if(!o&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=n))return [A$1(t)];const a=[],r=s.match(/^[0-7]+|\d/g);for(let i=0;i<r.length;i++){const l=r[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`)}else c=r$2(l);a.push(d(c,(i===0?"\\":"")+l));}return a}function te$1(e){const n=[],t=new RegExp(y$1,"gy");let o;for(;o=t.exec(e);){const s=o[0];if(s[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(a){const{min:r,max:i}=a.groups;if(+r>+i&&s.endsWith("?")){t.lastIndex--,n.push(O$1(s.slice(0,-1)));continue}}}n.push(O$1(s));}return n}
8471
+ `.replace(/\s+/g,""),"gsu");function M$1(e,n={}){const t={flags:"",...n,rules:{captureGroup:false,singleline:false,...n.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const o=Y(t.flags),s=[o.extended],a={captureGroup:t.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop();},pushModX(u){s.push(u);},replaceCurrentModX(u){s[s.length-1]=u;},singleline:t.rules.singleline};let r=[],i;for(C$1.lastIndex=0;i=C$1.exec(e);){const u=F$1(a,e,i[0],C$1.lastIndex);u.tokens?r.push(...u.tokens):u.token&&r.push(u.token),u.lastIndex!==void 0&&(C$1.lastIndex=u.lastIndex);}const l=[];let c=0;r.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++c:u.raw==="("&&l.push(u);}),c||l.forEach((u,S)=>{u.kind="capturing",u.number=S+1;});const g=c||l.length;return {tokens:r.map(u=>u.type==="EscapedNumber"?ee$1(u,g):u).flat(),flags:o}}function F$1(e,n,t,o){const[s,a]=t;if(t==="["||t==="[^"){const r=K$1(n,t,o);return {tokens:r.tokens,lastIndex:r.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(a))return {token:w$1(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:R$1(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:A$1(t)}}if(a==="K")return {token:I$1("keep",t)};if(a==="N"||a==="R")return {token:k$1("newline",t,{negate:a==="N"})};if(a==="O")return {token:k$1("any",t)};if(a==="X")return {token:k$1("text_segment",t)};const r=x(t,{inCharClass:false});return Array.isArray(r)?{tokens:r}:{token:r}}if(s==="("){if(a==="*")return {token:j(t)};if(t==="(?{")throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(n[o]!==")")throw new Error('Unclosed comment group "(?#"');return {lastIndex:o+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return {token:L$1(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,t==="("&&!e.captureGroup||t==="(?:")return {token:f$1("group",t)};if(t==="(?>")return {token:f$1("atomic",t)};if(t==="(?="||t==="(?!"||t==="(?<="||t==="(?<!")return {token:f$1(t[2]==="<"?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if(t==="("&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return {token:f$1("capturing",t,{...t!=="("&&{name:t.slice(3,-1)}})};if(t.startsWith("(?~")){if(t==="(?~|")throw new Error(`Unsupported absence function kind "${t}"`);return {token:f$1("absence_repeater",t)}}throw t==="(?("?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(t===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return {token:Q$1(t)}}if(e.getCurrentModX()){if(t==="#"){const r=n.indexOf(`
8472
+ `,o);return {lastIndex:r===-1?n.length:r}}if(/^\s$/.test(t)){const r=/\s+/y;return r.lastIndex=o,{lastIndex:r.exec(n)?r.lastIndex:o}}}if(t===".")return {token:k$1("dot",t)};if(t==="^"||t==="$"){const r=e.singleline?{"^":o$1`\A`,$:o$1`\Z`}[t]:t;return {token:w$1(r,t)}}return t==="|"?{token:P$1(t)}:y$1.test(t)?{tokens:te$1(t)}:{token:d(r$2(t),t)}}function K$1(e,n,t){const o=[E$1(n[1]==="^",n)];let s=1,a;for(T$1.lastIndex=t;a=T$1.exec(e);){const r=a[0];if(r[0]==="["&&r[1]!==":")s++,o.push(E$1(r[1]==="^",r));else if(r==="]"){if(o.at(-1).type==="CharacterClassOpen")o.push(d(93,r));else if(s--,o.push(z$1(r)),!s)break}else {const i=X$1(r);Array.isArray(i)?o.push(...i):o.push(i);}}return {tokens:o,lastIndex:T$1.lastIndex||e.length}}function X$1(e){if(e[0]==="\\")return x(e,{inCharClass:true});if(e[0]==="["){const n=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!n||!i.has(n.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return k$1("posix",e,{value:n.groups.name,negate:!!n.groups.negate})}return e==="-"?U$1(e):e==="&&"?H(e):d(r$2(e),e)}function x(e,{inCharClass:n}){const t=e[1];if(t==="c"||t==="C")return Z(e);if("dDhHsSwW".includes(t))return q(e);if(e.startsWith(o$1`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return V$1(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const o=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(o)),a=new TextEncoder;return [...s].map(i=>{const l=[...a.encode(i)].map(c=>`\\x${c.toString(16)}`).join("");return d(r$2(i),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return d(J$1(e),e);if($$1.has(t))return d($$1.get(t),e);if(/\d/.test(t))return W$1(n,e);if(e==="\\")throw new Error(o$1`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return d(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function P$1(e){return {type:"Alternator",raw:e}}function w$1(e,n){return {type:"Assertion",kind:e,raw:n}}function A$1(e){return {type:"Backreference",raw:e}}function d(e,n){return {type:"Character",value:e,raw:n}}function z$1(e){return {type:"CharacterClassClose",raw:e}}function U$1(e){return {type:"CharacterClassHyphen",raw:e}}function H(e){return {type:"CharacterClassIntersector",raw:e}}function E$1(e,n){return {type:"CharacterClassOpen",negate:e,raw:n}}function k$1(e,n,t={}){return {type:"CharacterSet",kind:e,...t,raw:n}}function I$1(e,n,t={}){return e==="keep"?{type:"Directive",kind:e,raw:n}:{type:"Directive",kind:e,flags:u(t.flags),raw:n}}function W$1(e,n){return {type:"EscapedNumber",inCharClass:e,raw:n}}function Q$1(e){return {type:"GroupClose",raw:e}}function f$1(e,n,t={}){return {type:"GroupOpen",kind:e,...t,raw:n}}function D$1(e,n,t,o){return {type:"NamedCallout",kind:e,tag:n,arguments:t,raw:o}}function _$1(e,n,t,o){return {type:"Quantifier",kind:e,min:n,max:t,raw:o}}function R$1(e){return {type:"Subroutine",raw:e}}const B$1=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$$1=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Z(e){const n=e[1]==="c"?e[2]:e[3];if(!n||!/[A-Za-z]/.test(n))throw new Error(`Unsupported control character "${e}"`);return d(r$2(n.toUpperCase())-64,e)}function L$1(e,n){let{on:t,off:o}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;o??="";const s=(n.getCurrentModX()||t.includes("x"))&&!o.includes("x"),a=v(t),r=v(o),i={};if(a&&(i.enable=a),r&&(i.disable=r),e.endsWith(")"))return n.replaceCurrentModX(s),I$1("flags",e,{flags:i});if(e.endsWith(":"))return n.pushModX(s),n.numOpenGroups++,f$1("group",e,{...(a||r)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function j(e){const n=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!n)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:t,tag:o,args:s}=n.groups;if(!t)throw new Error(`Invalid named callout "${e}"`);if(o==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=s?s.split(",").filter(g=>g!=="").map(g=>/^[+-]?\d+$/.test(g)?+g:g):[],[r,i,l]=a,c=B$1.has(t)?t.toLowerCase():"custom";switch(c){case "fail":case "mismatch":case "skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case "error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof r=="string")throw new Error(`Named callout argument must be a number "${r}"`);break;case "max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(a.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case "count":case "total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof r=="number"||!/^[<>X]$/.test(r)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);break;case "cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case "custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return D$1(c,o??null,s?.split(",")??null,e)}function O$1(e){let n=null,t,o;if(e[0]==="{"){const{minStr:s,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,r=1e5;if(+s>r||a&&+a>r)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,o=a===void 0?+s:a===""?1/0:+a,t>o&&(n="possessive",[t,o]=[o,t]),e.endsWith("?")){if(n==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');n="lazy";}else n||(n="greedy");}else t=e[0]==="+"?1:0,o=e[0]==="?"?1:1/0,n=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return _$1(n,t,o,e)}function q(e){const n=e[1].toLowerCase();return k$1({d:"digit",h:"hex",s:"space",w:"word"}[n],e,{negate:e[1]!==n})}function V$1(e){const{p:n,neg:t,value:o}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return k$1("property",e,{value:o,negate:n==="P"&&!t||n==="p"&&!!t})}function v(e){const n={};return e.includes("i")&&(n.ignoreCase=true),e.includes("m")&&(n.dotAll=true),e.includes("x")&&(n.extended=true),Object.keys(n).length?n:null}function Y(e){const n={ignoreCase:false,dotAll:false,extended:false,digitIsAscii:false,posixIsAscii:false,spaceIsAscii:false,wordIsAscii:false,textSegmentMode:null};for(let t=0;t<e.length;t++){const o=e[t];if(!"imxDPSWy".includes(o))throw new Error(`Invalid flag "${o}"`);if(o==="y"){if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');n.textSegmentMode=e[t+2]==="g"?"grapheme":"word",t+=3;continue}n[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[o]]=true;}return n}function J$1(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const n=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(n,16)}function ee$1(e,n){const{raw:t,inCharClass:o}=e,s=t.slice(1);if(!o&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=n))return [A$1(t)];const a=[],r=s.match(/^[0-7]+|\d/g);for(let i=0;i<r.length;i++){const l=r[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`)}else c=r$2(l);a.push(d(c,(i===0?"\\":"")+l));}return a}function te$1(e){const n=[],t=new RegExp(y$1,"gy");let o;for(;o=t.exec(e);){const s=o[0];if(s[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(a){const{min:r,max:i}=a.groups;if(+r>+i&&s.endsWith("?")){t.lastIndex--,n.push(O$1(s.slice(0,-1)));continue}}}n.push(O$1(s));}return n}
8473
8473
 
8474
- function o(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return !1;const r=e.body[0];return !t||Object.keys(t).every(n=>t[n]===r[n])}function s(e){return y.has(e.type)}const y=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);
8474
+ function o(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return false;const r=e.body[0];return !t||Object.keys(t).every(n=>t[n]===r[n])}function s(e){return y.has(e.type)}const y=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);
8475
8475
 
8476
- function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r,rules:{captureGroup:!1,singleline:!1,...r.rules}},t=M$1(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,N)=>{const u=t.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,u.type){case"Alternator":return b();case"Assertion":return W(u);case"Backreference":return X(u,o);case"Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case"CharacterClassHyphen":return ee(u,o,N);case"CharacterClassOpen":return re(u,o,N);case"CharacterSet":return ne(u,o);case"Directive":return I(u.kind,{flags:u.flags});case"GroupOpen":return te(u,o,N);case"NamedCallout":return U(u.kind,u.tag,u.arguments);case"Quantifier":return oe(u,o);case"Subroutine":return ae(u,o);default:throw new Error(`Unexpected token type "${u.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:t.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=B(T(t.flags));let d=i.body[0];for(;o.nextIndex<t.tokens.length;){const p=s(d,{});p.type==="Alternative"?(i.body.push(p),d=p):d.body.push(p);}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=o;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=!0);}else if(c.has(p)){if(c.get(p).length>1)throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0;}else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);return i}function W({kind:e}){return F(u({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===o$1`\B`||e===o$1`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),t=n?e.slice(3,-1):e.slice(1),s=(o,i=!1)=>{const d=r.capturingGroups.length;let a=!1;if(o>d)if(r.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=!0,k(i?d+1-o:o,{orphan:a})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(t))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(t))throw new Error(`Group name not defined to the left "${e}"`);return k(t)}return s(+t)}function ee(e,r,n){const{tokens:t,walk:s}=r,o=r.parent,i=o.body.at(-1),d=t[r.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const a=s(o,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&a.type==="Character")return o.body.pop(),L(i,a);throw new Error("Invalid character class range")}return m(r$2("-"))}function re({negate:e},r,n){const{tokens:t,walk:s}=r,o=t[r.nextIndex],i=[C()];let d=z(o);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")i.push(C()),r.nextIndex++;else {const l=i.at(-1);l.body.push(s(l,n));}d=z(t[r.nextIndex],o);}const a=C({negate:e});return i.length===1?a.body=i[0].body:(a.kind="intersection",a.body=i.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},t){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1}=t;if(e==="property"){const d=w(n);if(i.has(d)&&!i$1?.has(d))e="posix",n=d;else return Q(n,{negate:r,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:t,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:d}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(s.push(a),a.name&&l$1(o,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(t[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else {const N=a.body.at(-1),u=d(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!i){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(t[r.nextIndex]);}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},t){const s$1=t.parent,o=s$1.body.at(-1);if(!o||!s(o))throw new Error("Quantifier requires a repeatable token");const i=_(e,r,n,o);return s$1.body.pop(),i}function ae({raw:e},r){const{capturingGroups:n,subroutines:t}=r;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const d=+o.groups.num,a=n.length;if(r.hasNumberedRef=!0,s={"":d,"+":a+d,"-":a+1-d}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=O(s);return t.push(i),i}function G(e,r){return {type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return {type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return (e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return {type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:!1,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return {type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:!1,...r};if(e>1114111){const t=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return {type:"Character",value:e}}function C(e){const r={kind:"union",negate:!1,...e};return {type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return {type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,t={type:"CharacterSet",kind:e};return (e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(t.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(t.variableLength=!0),t}function I(e,r={}){if(e==="keep")return {type:"Directive",kind:e};if(e==="flags")return {type:"Directive",kind:e,flags:u(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return {type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return {type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:!1,negate:!1,...e};return {type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return {type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!i.has(e))throw new Error(`Invalid POSIX class "${e}"`);return {type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,t){if(r>n)throw new Error("Invalid reversed quantifier range");return {type:"Quantifier",kind:e,min:r,max:n,body:t}}function B(e,r){return {type:"Regex",body:h(r?.body),flags:e}}function O(e){return {type:"Subroutine",ref:e}}function Q(e,r){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r};let t=n.unicodePropertyMap?.get(w(e));if(!t){if(n.normalizeUnknownPropertyNames)t=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(o$1`Invalid Unicode property "\p{${e}}"`)}return {type:"CharacterSet",kind:"property",value:t??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:t,number:s}){switch(r){case"absence_repeater":return G("repeater");case"atomic":return A({atomic:!0});case"capturing":return P(s,{name:n});case"group":return A({flags:e});case"lookahead":case"lookbehind":return K({behind:r==="lookbehind",negate:t});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){return u(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function D(e){return u(e,"Unclosed group")}
8476
+ function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:false,skipBackrefValidation:false,skipLookbehindValidation:false,skipPropertyNameValidation:false,unicodePropertyMap:null,...r,rules:{captureGroup:false,singleline:false,...r.rules}},t=M$1(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,N)=>{const u=t.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,u.type){case "Alternator":return b();case "Assertion":return W(u);case "Backreference":return X(u,o);case "Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case "CharacterClassHyphen":return ee(u,o,N);case "CharacterClassOpen":return re(u,o,N);case "CharacterSet":return ne(u,o);case "Directive":return I(u.kind,{flags:u.flags});case "GroupOpen":return te(u,o,N);case "NamedCallout":return U(u.kind,u.tag,u.arguments);case "Quantifier":return oe(u,o);case "Subroutine":return ae(u,o);default:throw new Error(`Unexpected token type "${u.type}"`)}},o={capturingGroups:[],hasNumberedRef:false,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:t.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=B(T(t.flags));let d=i.body[0];for(;o.nextIndex<t.tokens.length;){const p=s(d,{});p.type==="Alternative"?(i.body.push(p),d=p):d.body.push(p);}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=o;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=true);}else if(c.has(p)){if(c.get(p).length>1)throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=true;}else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);return i}function W({kind:e}){return F(u({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===o$1`\B`||e===o$1`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),t=n?e.slice(3,-1):e.slice(1),s=(o,i=false)=>{const d=r.capturingGroups.length;let a=false;if(o>d)if(r.skipBackrefValidation)a=true;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=true,k(i?d+1-o:o,{orphan:a})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(t))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(t))throw new Error(`Group name not defined to the left "${e}"`);return k(t)}return s(+t)}function ee(e,r,n){const{tokens:t,walk:s}=r,o=r.parent,i=o.body.at(-1),d=t[r.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const a=s(o,{...n,isCheckingRangeEnd:true});if(i.type==="Character"&&a.type==="Character")return o.body.pop(),L(i,a);throw new Error("Invalid character class range")}return m(r$2("-"))}function re({negate:e},r,n){const{tokens:t,walk:s}=r,o=t[r.nextIndex],i=[C()];let d=z(o);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")i.push(C()),r.nextIndex++;else {const l=i.at(-1);l.body.push(s(l,n));}d=z(t[r.nextIndex],o);}const a=C({negate:e});return i.length===1?a.body=i[0].body:(a.kind="intersection",a.body=i.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},t){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1}=t;if(e==="property"){const d=w(n);if(i.has(d)&&!i$1?.has(d))e="posix",n=d;else return Q(n,{negate:r,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:t,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:d}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(s.push(a),a.name&&l$1(o,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(t[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else {const N=a.body.at(-1),u=d(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!i){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(t[r.nextIndex]);}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},t){const s$1=t.parent,o=s$1.body.at(-1);if(!o||!s(o))throw new Error("Quantifier requires a repeatable token");const i=_(e,r,n,o);return s$1.body.pop(),i}function ae({raw:e},r){const{capturingGroups:n,subroutines:t}=r;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const d=+o.groups.num,a=n.length;if(r.hasNumberedRef=true,s={"":d,"+":a+d,"-":a+1-d}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=O(s);return t.push(i),i}function G(e,r){return {type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return {type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return (e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return {type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:false,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return {type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:false,...r};if(e>1114111){const t=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return {type:"Character",value:e}}function C(e){const r={kind:"union",negate:false,...e};return {type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return {type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,t={type:"CharacterSet",kind:e};return (e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(t.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(t.variableLength=true),t}function I(e,r={}){if(e==="keep")return {type:"Directive",kind:e};if(e==="flags")return {type:"Directive",kind:e,flags:u(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return {type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return {type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:false,negate:false,...e};return {type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return {type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!i.has(e))throw new Error(`Invalid POSIX class "${e}"`);return {type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,t){if(r>n)throw new Error("Invalid reversed quantifier range");return {type:"Quantifier",kind:e,min:r,max:n,body:t}}function B(e,r){return {type:"Regex",body:h(r?.body),flags:e}}function O(e){return {type:"Subroutine",ref:e}}function Q(e,r){const n={negate:false,normalizeUnknownPropertyNames:false,skipPropertyNameValidation:false,unicodePropertyMap:null,...r};let t=n.unicodePropertyMap?.get(w(e));if(!t){if(n.normalizeUnknownPropertyNames)t=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(o$1`Invalid Unicode property "\p{${e}}"`)}return {type:"CharacterSet",kind:"property",value:t??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:t,number:s}){switch(r){case "absence_repeater":return G("repeater");case "atomic":return A({atomic:true});case "capturing":return P(s,{name:n});case "group":return A({flags:e});case "lookahead":case "lookbehind":return K({behind:r==="lookbehind",negate:t});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){return u(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function D(e){return u(e,"Unclosed group")}
8477
8477
 
8478
- function S(a,v,N=null){function u$1(e,s){for(let t=0;t<e.length;t++){const r=n(e[t],s,t,e);t=Math.max(-1,t+r);}}function n(e,s=null,t=null,r=null){let i=0,c=!1;const d={node:e,parent:s,key:t,container:r,root:a,remove(){f(r).splice(Math.max(0,l(t)+i),1),i--,c=!0;},removeAllNextSiblings(){return f(r).splice(l(t)+1)},removeAllPrevSiblings(){const o=l(t)+i;return i-=o,f(r).splice(0,Math.max(0,o))},replaceWith(o,y={}){const b=!!y.traverse;r?r[Math.max(0,l(t)+i)]=o:u(s,"Can't replace root node")[t]=o,b&&n(o,s,t,r),c=!0;},replaceWithMultiple(o,y={}){const b=!!y.traverse;if(f(r).splice(Math.max(0,l(t)+i),1,...o),i+=o.length-1,b){let g=0;for(let x=0;x<o.length;x++)g+=n(o[x],s,l(t)+x+g,r);}c=!0;},skip(){c=!0;}},{type:m}=e,h=v["*"],p=v[m],R=typeof h=="function"?h:h?.enter,P=typeof p=="function"?p:p?.enter;if(R?.(d,N),P?.(d,N),!c)switch(m){case"AbsenceFunction":case"CapturingGroup":case"Group":u$1(e.body,e);break;case"Alternative":case"CharacterClass":u$1(e.body,e);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":n(e.min,e,"min"),n(e.max,e,"max");break;case"LookaroundAssertion":u$1(e.body,e);break;case"Quantifier":n(e.body,e,"body");break;case"Regex":u$1(e.body,e),n(e.flags,e,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return p?.exit?.(d,N),h?.exit?.(d,N),i}return n(a),a}function f(a){if(!Array.isArray(a))throw new Error("Container expected");return a}function l(a){if(typeof a!="number")throw new Error("Numeric key expected");return a}
8478
+ function S(a,v,N=null){function u$1(e,s){for(let t=0;t<e.length;t++){const r=n(e[t],s,t,e);t=Math.max(-1,t+r);}}function n(e,s=null,t=null,r=null){let i=0,c=false;const d={node:e,parent:s,key:t,container:r,root:a,remove(){f(r).splice(Math.max(0,l(t)+i),1),i--,c=true;},removeAllNextSiblings(){return f(r).splice(l(t)+1)},removeAllPrevSiblings(){const o=l(t)+i;return i-=o,f(r).splice(0,Math.max(0,o))},replaceWith(o,y={}){const b=!!y.traverse;r?r[Math.max(0,l(t)+i)]=o:u(s,"Can't replace root node")[t]=o,b&&n(o,s,t,r),c=true;},replaceWithMultiple(o,y={}){const b=!!y.traverse;if(f(r).splice(Math.max(0,l(t)+i),1,...o),i+=o.length-1,b){let g=0;for(let x=0;x<o.length;x++)g+=n(o[x],s,l(t)+x+g,r);}c=true;},skip(){c=true;}},{type:m}=e,h=v["*"],p=v[m],R=typeof h=="function"?h:h?.enter,P=typeof p=="function"?p:p?.enter;if(R?.(d,N),P?.(d,N),!c)switch(m){case "AbsenceFunction":case "CapturingGroup":case "Group":u$1(e.body,e);break;case "Alternative":case "CharacterClass":u$1(e.body,e);break;case "Assertion":case "Backreference":case "Character":case "CharacterSet":case "Directive":case "Flags":case "NamedCallout":case "Subroutine":break;case "CharacterClassRange":n(e.min,e,"min"),n(e.max,e,"max");break;case "LookaroundAssertion":u$1(e.body,e);break;case "Quantifier":n(e.body,e,"body");break;case "Regex":u$1(e.body,e),n(e.flags,e,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return p?.exit?.(d,N),h?.exit?.(d,N),i}return n(a),a}function f(a){if(!Array.isArray(a))throw new Error("Container expected");return a}function l(a){if(typeof a!="number")throw new Error("Numeric key expected");return a}
8479
8479
 
8480
8480
  // Separating some utils for improved tree shaking of the `./internals` export
8481
8481
 
@@ -13706,6 +13706,21 @@ function registerCodeHighlighting(editor, tokenizer) {
13706
13706
  return utils.mergeRegister(...registrations);
13707
13707
  }
13708
13708
 
13709
+ /**
13710
+ * Add code highlighting support for code blocks with Shiki
13711
+ */
13712
+ const CodeHighlighterShikiExtension = lexical.defineExtension({
13713
+ config: {
13714
+ tokenizer: ShikiTokenizer
13715
+ },
13716
+ dependencies: [code.CodeExtension],
13717
+ name: '@lexical/code-shiki',
13718
+ register: (editor, {
13719
+ tokenizer
13720
+ }) => registerCodeHighlighting(editor, tokenizer)
13721
+ });
13722
+
13723
+ exports.CodeHighlighterShikiExtension = CodeHighlighterShikiExtension;
13709
13724
  exports.ShikiTokenizer = ShikiTokenizer;
13710
13725
  exports.getCodeLanguageOptions = getCodeLanguageOptions;
13711
13726
  exports.getCodeThemeOptions = getCodeThemeOptions;
@@ -6,9 +6,9 @@
6
6
  *
7
7
  */
8
8
 
9
- import { $isCodeNode, $createCodeHighlightNode, DEFAULT_CODE_LANGUAGE, CodeNode, CodeHighlightNode, $isCodeHighlightNode, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $getEndOfCodeInLine } from '@lexical/code';
9
+ import { $isCodeNode, $createCodeHighlightNode, CodeExtension, DEFAULT_CODE_LANGUAGE, CodeNode, CodeHighlightNode, $isCodeHighlightNode, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $getEndOfCodeInLine } from '@lexical/code';
10
10
  import { mergeRegister } from '@lexical/utils';
11
- import { $getNodeByKey, $createLineBreakNode, $createTabNode, TextNode, KEY_TAB_COMMAND, COMMAND_PRIORITY_LOW, INSERT_TAB_COMMAND, $getSelection, $insertNodes, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, KEY_ARROW_UP_COMMAND, $isRangeSelection, KEY_ARROW_DOWN_COMMAND, MOVE_TO_START, MOVE_TO_END, $createTextNode, $isLineBreakNode, $isTextNode, $createPoint, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret, $getSiblingCaret, $isTabNode } from 'lexical';
11
+ import { $getNodeByKey, $createLineBreakNode, $createTabNode, defineExtension, TextNode, KEY_TAB_COMMAND, COMMAND_PRIORITY_LOW, INSERT_TAB_COMMAND, $getSelection, $insertNodes, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, KEY_ARROW_UP_COMMAND, $isRangeSelection, KEY_ARROW_DOWN_COMMAND, MOVE_TO_START, MOVE_TO_END, $isLineBreakNode, $createTextNode, $createPoint, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret, $getSiblingCaret, $isTabNode, $isTextNode } from 'lexical';
12
12
 
13
13
  /**
14
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -8466,14 +8466,14 @@ const m$1=o$1`\[\^?`,b$1=`c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\
8466
8466
  | ${m$1}
8467
8467
  | &&
8468
8468
  | .
8469
- `.replace(/\s+/g,""),"gsu");function M$1(e,n={}){const t={flags:"",...n,rules:{captureGroup:!1,singleline:!1,...n.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const o=Y(t.flags),s=[o.extended],a={captureGroup:t.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop();},pushModX(u){s.push(u);},replaceCurrentModX(u){s[s.length-1]=u;},singleline:t.rules.singleline};let r=[],i;for(C$1.lastIndex=0;i=C$1.exec(e);){const u=F$1(a,e,i[0],C$1.lastIndex);u.tokens?r.push(...u.tokens):u.token&&r.push(u.token),u.lastIndex!==void 0&&(C$1.lastIndex=u.lastIndex);}const l=[];let c=0;r.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++c:u.raw==="("&&l.push(u);}),c||l.forEach((u,S)=>{u.kind="capturing",u.number=S+1;});const g=c||l.length;return {tokens:r.map(u=>u.type==="EscapedNumber"?ee$1(u,g):u).flat(),flags:o}}function F$1(e,n,t,o){const[s,a]=t;if(t==="["||t==="[^"){const r=K$1(n,t,o);return {tokens:r.tokens,lastIndex:r.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(a))return {token:w$1(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:R$1(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:A$1(t)}}if(a==="K")return {token:I$1("keep",t)};if(a==="N"||a==="R")return {token:k$1("newline",t,{negate:a==="N"})};if(a==="O")return {token:k$1("any",t)};if(a==="X")return {token:k$1("text_segment",t)};const r=x(t,{inCharClass:!1});return Array.isArray(r)?{tokens:r}:{token:r}}if(s==="("){if(a==="*")return {token:j(t)};if(t==="(?{")throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(n[o]!==")")throw new Error('Unclosed comment group "(?#"');return {lastIndex:o+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return {token:L$1(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,t==="("&&!e.captureGroup||t==="(?:")return {token:f$1("group",t)};if(t==="(?>")return {token:f$1("atomic",t)};if(t==="(?="||t==="(?!"||t==="(?<="||t==="(?<!")return {token:f$1(t[2]==="<"?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if(t==="("&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return {token:f$1("capturing",t,{...t!=="("&&{name:t.slice(3,-1)}})};if(t.startsWith("(?~")){if(t==="(?~|")throw new Error(`Unsupported absence function kind "${t}"`);return {token:f$1("absence_repeater",t)}}throw t==="(?("?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(t===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return {token:Q$1(t)}}if(e.getCurrentModX()){if(t==="#"){const r=n.indexOf(`
8470
- `,o);return {lastIndex:r===-1?n.length:r}}if(/^\s$/.test(t)){const r=/\s+/y;return r.lastIndex=o,{lastIndex:r.exec(n)?r.lastIndex:o}}}if(t===".")return {token:k$1("dot",t)};if(t==="^"||t==="$"){const r=e.singleline?{"^":o$1`\A`,$:o$1`\Z`}[t]:t;return {token:w$1(r,t)}}return t==="|"?{token:P$1(t)}:y$1.test(t)?{tokens:te$1(t)}:{token:d(r$2(t),t)}}function K$1(e,n,t){const o=[E$1(n[1]==="^",n)];let s=1,a;for(T$1.lastIndex=t;a=T$1.exec(e);){const r=a[0];if(r[0]==="["&&r[1]!==":")s++,o.push(E$1(r[1]==="^",r));else if(r==="]"){if(o.at(-1).type==="CharacterClassOpen")o.push(d(93,r));else if(s--,o.push(z$1(r)),!s)break}else {const i=X$1(r);Array.isArray(i)?o.push(...i):o.push(i);}}return {tokens:o,lastIndex:T$1.lastIndex||e.length}}function X$1(e){if(e[0]==="\\")return x(e,{inCharClass:!0});if(e[0]==="["){const n=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!n||!i.has(n.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return k$1("posix",e,{value:n.groups.name,negate:!!n.groups.negate})}return e==="-"?U$1(e):e==="&&"?H(e):d(r$2(e),e)}function x(e,{inCharClass:n}){const t=e[1];if(t==="c"||t==="C")return Z(e);if("dDhHsSwW".includes(t))return q(e);if(e.startsWith(o$1`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return V$1(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const o=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(o)),a=new TextEncoder;return [...s].map(i=>{const l=[...a.encode(i)].map(c=>`\\x${c.toString(16)}`).join("");return d(r$2(i),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return d(J$1(e),e);if($$1.has(t))return d($$1.get(t),e);if(/\d/.test(t))return W$1(n,e);if(e==="\\")throw new Error(o$1`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return d(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function P$1(e){return {type:"Alternator",raw:e}}function w$1(e,n){return {type:"Assertion",kind:e,raw:n}}function A$1(e){return {type:"Backreference",raw:e}}function d(e,n){return {type:"Character",value:e,raw:n}}function z$1(e){return {type:"CharacterClassClose",raw:e}}function U$1(e){return {type:"CharacterClassHyphen",raw:e}}function H(e){return {type:"CharacterClassIntersector",raw:e}}function E$1(e,n){return {type:"CharacterClassOpen",negate:e,raw:n}}function k$1(e,n,t={}){return {type:"CharacterSet",kind:e,...t,raw:n}}function I$1(e,n,t={}){return e==="keep"?{type:"Directive",kind:e,raw:n}:{type:"Directive",kind:e,flags:u(t.flags),raw:n}}function W$1(e,n){return {type:"EscapedNumber",inCharClass:e,raw:n}}function Q$1(e){return {type:"GroupClose",raw:e}}function f$1(e,n,t={}){return {type:"GroupOpen",kind:e,...t,raw:n}}function D$1(e,n,t,o){return {type:"NamedCallout",kind:e,tag:n,arguments:t,raw:o}}function _$1(e,n,t,o){return {type:"Quantifier",kind:e,min:n,max:t,raw:o}}function R$1(e){return {type:"Subroutine",raw:e}}const B$1=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$$1=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Z(e){const n=e[1]==="c"?e[2]:e[3];if(!n||!/[A-Za-z]/.test(n))throw new Error(`Unsupported control character "${e}"`);return d(r$2(n.toUpperCase())-64,e)}function L$1(e,n){let{on:t,off:o}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;o??="";const s=(n.getCurrentModX()||t.includes("x"))&&!o.includes("x"),a=v(t),r=v(o),i={};if(a&&(i.enable=a),r&&(i.disable=r),e.endsWith(")"))return n.replaceCurrentModX(s),I$1("flags",e,{flags:i});if(e.endsWith(":"))return n.pushModX(s),n.numOpenGroups++,f$1("group",e,{...(a||r)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function j(e){const n=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!n)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:t,tag:o,args:s}=n.groups;if(!t)throw new Error(`Invalid named callout "${e}"`);if(o==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=s?s.split(",").filter(g=>g!=="").map(g=>/^[+-]?\d+$/.test(g)?+g:g):[],[r,i,l]=a,c=B$1.has(t)?t.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case"error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof r=="string")throw new Error(`Named callout argument must be a number "${r}"`);break;case"max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(a.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof r=="number"||!/^[<>X]$/.test(r)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);break;case"cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return D$1(c,o??null,s?.split(",")??null,e)}function O$1(e){let n=null,t,o;if(e[0]==="{"){const{minStr:s,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,r=1e5;if(+s>r||a&&+a>r)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,o=a===void 0?+s:a===""?1/0:+a,t>o&&(n="possessive",[t,o]=[o,t]),e.endsWith("?")){if(n==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');n="lazy";}else n||(n="greedy");}else t=e[0]==="+"?1:0,o=e[0]==="?"?1:1/0,n=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return _$1(n,t,o,e)}function q(e){const n=e[1].toLowerCase();return k$1({d:"digit",h:"hex",s:"space",w:"word"}[n],e,{negate:e[1]!==n})}function V$1(e){const{p:n,neg:t,value:o}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return k$1("property",e,{value:o,negate:n==="P"&&!t||n==="p"&&!!t})}function v(e){const n={};return e.includes("i")&&(n.ignoreCase=!0),e.includes("m")&&(n.dotAll=!0),e.includes("x")&&(n.extended=!0),Object.keys(n).length?n:null}function Y(e){const n={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let t=0;t<e.length;t++){const o=e[t];if(!"imxDPSWy".includes(o))throw new Error(`Invalid flag "${o}"`);if(o==="y"){if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');n.textSegmentMode=e[t+2]==="g"?"grapheme":"word",t+=3;continue}n[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[o]]=!0;}return n}function J$1(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const n=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(n,16)}function ee$1(e,n){const{raw:t,inCharClass:o}=e,s=t.slice(1);if(!o&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=n))return [A$1(t)];const a=[],r=s.match(/^[0-7]+|\d/g);for(let i=0;i<r.length;i++){const l=r[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`)}else c=r$2(l);a.push(d(c,(i===0?"\\":"")+l));}return a}function te$1(e){const n=[],t=new RegExp(y$1,"gy");let o;for(;o=t.exec(e);){const s=o[0];if(s[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(a){const{min:r,max:i}=a.groups;if(+r>+i&&s.endsWith("?")){t.lastIndex--,n.push(O$1(s.slice(0,-1)));continue}}}n.push(O$1(s));}return n}
8469
+ `.replace(/\s+/g,""),"gsu");function M$1(e,n={}){const t={flags:"",...n,rules:{captureGroup:false,singleline:false,...n.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const o=Y(t.flags),s=[o.extended],a={captureGroup:t.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop();},pushModX(u){s.push(u);},replaceCurrentModX(u){s[s.length-1]=u;},singleline:t.rules.singleline};let r=[],i;for(C$1.lastIndex=0;i=C$1.exec(e);){const u=F$1(a,e,i[0],C$1.lastIndex);u.tokens?r.push(...u.tokens):u.token&&r.push(u.token),u.lastIndex!==void 0&&(C$1.lastIndex=u.lastIndex);}const l=[];let c=0;r.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++c:u.raw==="("&&l.push(u);}),c||l.forEach((u,S)=>{u.kind="capturing",u.number=S+1;});const g=c||l.length;return {tokens:r.map(u=>u.type==="EscapedNumber"?ee$1(u,g):u).flat(),flags:o}}function F$1(e,n,t,o){const[s,a]=t;if(t==="["||t==="[^"){const r=K$1(n,t,o);return {tokens:r.tokens,lastIndex:r.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(a))return {token:w$1(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:R$1(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return {token:A$1(t)}}if(a==="K")return {token:I$1("keep",t)};if(a==="N"||a==="R")return {token:k$1("newline",t,{negate:a==="N"})};if(a==="O")return {token:k$1("any",t)};if(a==="X")return {token:k$1("text_segment",t)};const r=x(t,{inCharClass:false});return Array.isArray(r)?{tokens:r}:{token:r}}if(s==="("){if(a==="*")return {token:j(t)};if(t==="(?{")throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(n[o]!==")")throw new Error('Unclosed comment group "(?#"');return {lastIndex:o+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return {token:L$1(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,t==="("&&!e.captureGroup||t==="(?:")return {token:f$1("group",t)};if(t==="(?>")return {token:f$1("atomic",t)};if(t==="(?="||t==="(?!"||t==="(?<="||t==="(?<!")return {token:f$1(t[2]==="<"?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if(t==="("&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return {token:f$1("capturing",t,{...t!=="("&&{name:t.slice(3,-1)}})};if(t.startsWith("(?~")){if(t==="(?~|")throw new Error(`Unsupported absence function kind "${t}"`);return {token:f$1("absence_repeater",t)}}throw t==="(?("?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(t===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return {token:Q$1(t)}}if(e.getCurrentModX()){if(t==="#"){const r=n.indexOf(`
8470
+ `,o);return {lastIndex:r===-1?n.length:r}}if(/^\s$/.test(t)){const r=/\s+/y;return r.lastIndex=o,{lastIndex:r.exec(n)?r.lastIndex:o}}}if(t===".")return {token:k$1("dot",t)};if(t==="^"||t==="$"){const r=e.singleline?{"^":o$1`\A`,$:o$1`\Z`}[t]:t;return {token:w$1(r,t)}}return t==="|"?{token:P$1(t)}:y$1.test(t)?{tokens:te$1(t)}:{token:d(r$2(t),t)}}function K$1(e,n,t){const o=[E$1(n[1]==="^",n)];let s=1,a;for(T$1.lastIndex=t;a=T$1.exec(e);){const r=a[0];if(r[0]==="["&&r[1]!==":")s++,o.push(E$1(r[1]==="^",r));else if(r==="]"){if(o.at(-1).type==="CharacterClassOpen")o.push(d(93,r));else if(s--,o.push(z$1(r)),!s)break}else {const i=X$1(r);Array.isArray(i)?o.push(...i):o.push(i);}}return {tokens:o,lastIndex:T$1.lastIndex||e.length}}function X$1(e){if(e[0]==="\\")return x(e,{inCharClass:true});if(e[0]==="["){const n=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!n||!i.has(n.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return k$1("posix",e,{value:n.groups.name,negate:!!n.groups.negate})}return e==="-"?U$1(e):e==="&&"?H(e):d(r$2(e),e)}function x(e,{inCharClass:n}){const t=e[1];if(t==="c"||t==="C")return Z(e);if("dDhHsSwW".includes(t))return q(e);if(e.startsWith(o$1`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return V$1(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{const o=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(o)),a=new TextEncoder;return [...s].map(i=>{const l=[...a.encode(i)].map(c=>`\\x${c.toString(16)}`).join("");return d(r$2(i),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(t==="u"||t==="x")return d(J$1(e),e);if($$1.has(t))return d($$1.get(t),e);if(/\d/.test(t))return W$1(n,e);if(e==="\\")throw new Error(o$1`Incomplete escape "\"`);if(t==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return d(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function P$1(e){return {type:"Alternator",raw:e}}function w$1(e,n){return {type:"Assertion",kind:e,raw:n}}function A$1(e){return {type:"Backreference",raw:e}}function d(e,n){return {type:"Character",value:e,raw:n}}function z$1(e){return {type:"CharacterClassClose",raw:e}}function U$1(e){return {type:"CharacterClassHyphen",raw:e}}function H(e){return {type:"CharacterClassIntersector",raw:e}}function E$1(e,n){return {type:"CharacterClassOpen",negate:e,raw:n}}function k$1(e,n,t={}){return {type:"CharacterSet",kind:e,...t,raw:n}}function I$1(e,n,t={}){return e==="keep"?{type:"Directive",kind:e,raw:n}:{type:"Directive",kind:e,flags:u(t.flags),raw:n}}function W$1(e,n){return {type:"EscapedNumber",inCharClass:e,raw:n}}function Q$1(e){return {type:"GroupClose",raw:e}}function f$1(e,n,t={}){return {type:"GroupOpen",kind:e,...t,raw:n}}function D$1(e,n,t,o){return {type:"NamedCallout",kind:e,tag:n,arguments:t,raw:o}}function _$1(e,n,t,o){return {type:"Quantifier",kind:e,min:n,max:t,raw:o}}function R$1(e){return {type:"Subroutine",raw:e}}const B$1=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$$1=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Z(e){const n=e[1]==="c"?e[2]:e[3];if(!n||!/[A-Za-z]/.test(n))throw new Error(`Unsupported control character "${e}"`);return d(r$2(n.toUpperCase())-64,e)}function L$1(e,n){let{on:t,off:o}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;o??="";const s=(n.getCurrentModX()||t.includes("x"))&&!o.includes("x"),a=v(t),r=v(o),i={};if(a&&(i.enable=a),r&&(i.disable=r),e.endsWith(")"))return n.replaceCurrentModX(s),I$1("flags",e,{flags:i});if(e.endsWith(":"))return n.pushModX(s),n.numOpenGroups++,f$1("group",e,{...(a||r)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function j(e){const n=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!n)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:t,tag:o,args:s}=n.groups;if(!t)throw new Error(`Invalid named callout "${e}"`);if(o==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=s?s.split(",").filter(g=>g!=="").map(g=>/^[+-]?\d+$/.test(g)?+g:g):[],[r,i,l]=a,c=B$1.has(t)?t.toLowerCase():"custom";switch(c){case "fail":case "mismatch":case "skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case "error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof r=="string")throw new Error(`Named callout argument must be a number "${r}"`);break;case "max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(a.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case "count":case "total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof r=="number"||!/^[<>X]$/.test(r)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${r}"`);break;case "cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof r=="string"&&!/^[A-Za-z_]\w*$/.test(r))throw new Error(`Named callout argument one must be a tag or number "${r}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case "custom":throw new Error(`Undefined callout name "${t}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return D$1(c,o??null,s?.split(",")??null,e)}function O$1(e){let n=null,t,o;if(e[0]==="{"){const{minStr:s,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,r=1e5;if(+s>r||a&&+a>r)throw new Error("Quantifier value unsupported in Oniguruma");if(t=+s,o=a===void 0?+s:a===""?1/0:+a,t>o&&(n="possessive",[t,o]=[o,t]),e.endsWith("?")){if(n==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');n="lazy";}else n||(n="greedy");}else t=e[0]==="+"?1:0,o=e[0]==="?"?1:1/0,n=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return _$1(n,t,o,e)}function q(e){const n=e[1].toLowerCase();return k$1({d:"digit",h:"hex",s:"space",w:"word"}[n],e,{negate:e[1]!==n})}function V$1(e){const{p:n,neg:t,value:o}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return k$1("property",e,{value:o,negate:n==="P"&&!t||n==="p"&&!!t})}function v(e){const n={};return e.includes("i")&&(n.ignoreCase=true),e.includes("m")&&(n.dotAll=true),e.includes("x")&&(n.extended=true),Object.keys(n).length?n:null}function Y(e){const n={ignoreCase:false,dotAll:false,extended:false,digitIsAscii:false,posixIsAscii:false,spaceIsAscii:false,wordIsAscii:false,textSegmentMode:null};for(let t=0;t<e.length;t++){const o=e[t];if(!"imxDPSWy".includes(o))throw new Error(`Invalid flag "${o}"`);if(o==="y"){if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');n.textSegmentMode=e[t+2]==="g"?"grapheme":"word",t+=3;continue}n[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[o]]=true;}return n}function J$1(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const n=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(n,16)}function ee$1(e,n){const{raw:t,inCharClass:o}=e,s=t.slice(1);if(!o&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=n))return [A$1(t)];const a=[],r=s.match(/^[0-7]+|\d/g);for(let i=0;i<r.length;i++){const l=r[i];let c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(o$1`Octal encoded byte above 177 unsupported "${t}"`)}else c=r$2(l);a.push(d(c,(i===0?"\\":"")+l));}return a}function te$1(e){const n=[],t=new RegExp(y$1,"gy");let o;for(;o=t.exec(e);){const s=o[0];if(s[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(a){const{min:r,max:i}=a.groups;if(+r>+i&&s.endsWith("?")){t.lastIndex--,n.push(O$1(s.slice(0,-1)));continue}}}n.push(O$1(s));}return n}
8471
8471
 
8472
- function o(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return !1;const r=e.body[0];return !t||Object.keys(t).every(n=>t[n]===r[n])}function s(e){return y.has(e.type)}const y=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);
8472
+ function o(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return false;const r=e.body[0];return !t||Object.keys(t).every(n=>t[n]===r[n])}function s(e){return y.has(e.type)}const y=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);
8473
8473
 
8474
- function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r,rules:{captureGroup:!1,singleline:!1,...r.rules}},t=M$1(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,N)=>{const u=t.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,u.type){case"Alternator":return b();case"Assertion":return W(u);case"Backreference":return X(u,o);case"Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case"CharacterClassHyphen":return ee(u,o,N);case"CharacterClassOpen":return re(u,o,N);case"CharacterSet":return ne(u,o);case"Directive":return I(u.kind,{flags:u.flags});case"GroupOpen":return te(u,o,N);case"NamedCallout":return U(u.kind,u.tag,u.arguments);case"Quantifier":return oe(u,o);case"Subroutine":return ae(u,o);default:throw new Error(`Unexpected token type "${u.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:t.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=B(T(t.flags));let d=i.body[0];for(;o.nextIndex<t.tokens.length;){const p=s(d,{});p.type==="Alternative"?(i.body.push(p),d=p):d.body.push(p);}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=o;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=!0);}else if(c.has(p)){if(c.get(p).length>1)throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0;}else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);return i}function W({kind:e}){return F(u({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===o$1`\B`||e===o$1`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),t=n?e.slice(3,-1):e.slice(1),s=(o,i=!1)=>{const d=r.capturingGroups.length;let a=!1;if(o>d)if(r.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=!0,k(i?d+1-o:o,{orphan:a})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(t))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(t))throw new Error(`Group name not defined to the left "${e}"`);return k(t)}return s(+t)}function ee(e,r,n){const{tokens:t,walk:s}=r,o=r.parent,i=o.body.at(-1),d=t[r.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const a=s(o,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&a.type==="Character")return o.body.pop(),L(i,a);throw new Error("Invalid character class range")}return m(r$2("-"))}function re({negate:e},r,n){const{tokens:t,walk:s}=r,o=t[r.nextIndex],i=[C()];let d=z(o);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")i.push(C()),r.nextIndex++;else {const l=i.at(-1);l.body.push(s(l,n));}d=z(t[r.nextIndex],o);}const a=C({negate:e});return i.length===1?a.body=i[0].body:(a.kind="intersection",a.body=i.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},t){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1}=t;if(e==="property"){const d=w(n);if(i.has(d)&&!i$1?.has(d))e="posix",n=d;else return Q(n,{negate:r,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:t,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:d}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(s.push(a),a.name&&l$1(o,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(t[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else {const N=a.body.at(-1),u=d(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!i){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(t[r.nextIndex]);}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},t){const s$1=t.parent,o=s$1.body.at(-1);if(!o||!s(o))throw new Error("Quantifier requires a repeatable token");const i=_(e,r,n,o);return s$1.body.pop(),i}function ae({raw:e},r){const{capturingGroups:n,subroutines:t}=r;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const d=+o.groups.num,a=n.length;if(r.hasNumberedRef=!0,s={"":d,"+":a+d,"-":a+1-d}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=O(s);return t.push(i),i}function G(e,r){return {type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return {type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return (e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return {type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:!1,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return {type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:!1,...r};if(e>1114111){const t=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return {type:"Character",value:e}}function C(e){const r={kind:"union",negate:!1,...e};return {type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return {type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,t={type:"CharacterSet",kind:e};return (e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(t.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(t.variableLength=!0),t}function I(e,r={}){if(e==="keep")return {type:"Directive",kind:e};if(e==="flags")return {type:"Directive",kind:e,flags:u(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return {type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return {type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:!1,negate:!1,...e};return {type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return {type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!i.has(e))throw new Error(`Invalid POSIX class "${e}"`);return {type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,t){if(r>n)throw new Error("Invalid reversed quantifier range");return {type:"Quantifier",kind:e,min:r,max:n,body:t}}function B(e,r){return {type:"Regex",body:h(r?.body),flags:e}}function O(e){return {type:"Subroutine",ref:e}}function Q(e,r){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...r};let t=n.unicodePropertyMap?.get(w(e));if(!t){if(n.normalizeUnknownPropertyNames)t=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(o$1`Invalid Unicode property "\p{${e}}"`)}return {type:"CharacterSet",kind:"property",value:t??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:t,number:s}){switch(r){case"absence_repeater":return G("repeater");case"atomic":return A({atomic:!0});case"capturing":return P(s,{name:n});case"group":return A({flags:e});case"lookahead":case"lookbehind":return K({behind:r==="lookbehind",negate:t});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){return u(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function D(e){return u(e,"Unclosed group")}
8474
+ function J(e,r={}){const n={flags:"",normalizeUnknownPropertyNames:false,skipBackrefValidation:false,skipLookbehindValidation:false,skipPropertyNameValidation:false,unicodePropertyMap:null,...r,rules:{captureGroup:false,singleline:false,...r.rules}},t=M$1(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,N)=>{const u=t.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,u.type){case "Alternator":return b();case "Assertion":return W(u);case "Backreference":return X(u,o);case "Character":return m(u.value,{useLastValid:!!N.isCheckingRangeEnd});case "CharacterClassHyphen":return ee(u,o,N);case "CharacterClassOpen":return re(u,o,N);case "CharacterSet":return ne(u,o);case "Directive":return I(u.kind,{flags:u.flags});case "GroupOpen":return te(u,o,N);case "NamedCallout":return U(u.kind,u.tag,u.arguments);case "Quantifier":return oe(u,o);case "Subroutine":return ae(u,o);default:throw new Error(`Unexpected token type "${u.type}"`)}},o={capturingGroups:[],hasNumberedRef:false,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:t.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=B(T(t.flags));let d=i.body[0];for(;o.nextIndex<t.tokens.length;){const p=s(d,{});p.type==="Alternative"?(i.body.push(p),d=p):d.body.push(p);}const{capturingGroups:a,hasNumberedRef:l,namedGroupsByName:c,subroutines:f}=o;if(l&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of f)if(typeof p=="number"){if(p>a.length)throw new Error("Subroutine uses a group number that's not defined");p&&(a[p-1].isSubroutined=true);}else if(c.has(p)){if(c.get(p).length>1)throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=true;}else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p}>"`);return i}function W({kind:e}){return F(u({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===o$1`\B`||e===o$1`\Y`})}function X({raw:e},r){const n=/^\\k[<']/.test(e),t=n?e.slice(3,-1):e.slice(1),s=(o,i=false)=>{const d=r.capturingGroups.length;let a=false;if(o>d)if(r.skipBackrefValidation)a=true;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return r.hasNumberedRef=true,k(i?d+1-o:o,{orphan:a})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(t))throw new Error(`Invalid backref name "${e}"`);if(!r.namedGroupsByName.has(t))throw new Error(`Group name not defined to the left "${e}"`);return k(t)}return s(+t)}function ee(e,r,n){const{tokens:t,walk:s}=r,o=r.parent,i=o.body.at(-1),d=t[r.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const a=s(o,{...n,isCheckingRangeEnd:true});if(i.type==="Character"&&a.type==="Character")return o.body.pop(),L(i,a);throw new Error("Invalid character class range")}return m(r$2("-"))}function re({negate:e},r,n){const{tokens:t,walk:s}=r,o=t[r.nextIndex],i=[C()];let d=z(o);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")i.push(C()),r.nextIndex++;else {const l=i.at(-1);l.body.push(s(l,n));}d=z(t[r.nextIndex],o);}const a=C({negate:e});return i.length===1?a.body=i[0].body:(a.kind="intersection",a.body=i.map(l=>l.body.length===1?l.body[0]:l)),r.nextIndex++,a}function ne({kind:e,negate:r,value:n},t){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1}=t;if(e==="property"){const d=w(n);if(i.has(d)&&!i$1?.has(d))e="posix",n=d;else return Q(n,{negate:r,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i$1})}return e==="posix"?R(n,{negate:r}):E(e,{negate:r})}function te(e,r,n){const{tokens:t,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:d}=r,a=ie(e),l=a.type==="AbsenceFunction",c=$(a),f=c&&a.negate;if(a.type==="CapturingGroup"&&(s.push(a),a.name&&l$1(o,a.name,[]).push(a)),l&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=D(t[r.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")a.body.push(b()),r.nextIndex++;else {const N=a.body.at(-1),u=d(N,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||f});if(N.body.push(u),(c||n.isInLookbehind)&&!i){const v="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(M(u)||u.type==="CapturingGroup")throw new Error(v)}else if(M(u)||$(u)&&u.negate)throw new Error(v)}}p=D(t[r.nextIndex]);}return r.nextIndex++,a}function oe({kind:e,min:r,max:n},t){const s$1=t.parent,o=s$1.body.at(-1);if(!o||!s(o))throw new Error("Quantifier requires a repeatable token");const i=_(e,r,n,o);return s$1.body.pop(),i}function ae({raw:e},r){const{capturingGroups:n,subroutines:t}=r;let s=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const d=+o.groups.num,a=n.length;if(r.hasNumberedRef=true,s={"":d,"+":a+d,"-":a+1-d}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=O(s);return t.push(i),i}function G(e,r){return {type:"AbsenceFunction",kind:e,body:h(r?.body)}}function b(e){return {type:"Alternative",body:V(e?.body)}}function F(e,r){const n={type:"Assertion",kind:e};return (e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!r?.negate),n}function k(e,r){const n=!!r?.orphan;return {type:"Backreference",ref:e,...n&&{orphan:n}}}function P(e,r){const n={name:void 0,isSubroutined:false,...r};if(n.name!==void 0&&!se(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return {type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:h(r?.body)}}function m(e,r){const n={useLastValid:false,...r};if(e>1114111){const t=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${t}}"`):new Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return {type:"Character",value:e}}function C(e){const r={kind:"union",negate:false,...e};return {type:"CharacterClass",kind:r.kind,negate:r.negate,body:V(e?.body)}}function L(e,r){if(r.value<e.value)throw new Error("Character class range out of order");return {type:"CharacterClassRange",min:e,max:r}}function E(e,r){const n=!!r?.negate,t={type:"CharacterSet",kind:e};return (e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(t.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(t.variableLength=true),t}function I(e,r={}){if(e==="keep")return {type:"Directive",kind:e};if(e==="flags")return {type:"Directive",kind:e,flags:u(r.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function T(e){return {type:"Flags",...e}}function A(e){const r=e?.atomic,n=e?.flags;if(r&&n)throw new Error("Atomic group cannot have flags");return {type:"Group",...r&&{atomic:r},...n&&{flags:n},body:h(e?.body)}}function K(e){const r={behind:false,negate:false,...e};return {type:"LookaroundAssertion",kind:r.behind?"lookbehind":"lookahead",negate:r.negate,body:h(e?.body)}}function U(e,r,n){return {type:"NamedCallout",kind:e,tag:r,arguments:n}}function R(e,r){const n=!!r?.negate;if(!i.has(e))throw new Error(`Invalid POSIX class "${e}"`);return {type:"CharacterSet",kind:"posix",value:e,negate:n}}function _(e,r,n,t){if(r>n)throw new Error("Invalid reversed quantifier range");return {type:"Quantifier",kind:e,min:r,max:n,body:t}}function B(e,r){return {type:"Regex",body:h(r?.body),flags:e}}function O(e){return {type:"Subroutine",ref:e}}function Q(e,r){const n={negate:false,normalizeUnknownPropertyNames:false,skipPropertyNameValidation:false,unicodePropertyMap:null,...r};let t=n.unicodePropertyMap?.get(w(e));if(!t){if(n.normalizeUnknownPropertyNames)t=de(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(o$1`Invalid Unicode property "\p{${e}}"`)}return {type:"CharacterSet",kind:"property",value:t??e,negate:n.negate}}function ie({flags:e,kind:r,name:n,negate:t,number:s}){switch(r){case "absence_repeater":return G("repeater");case "atomic":return A({atomic:true});case "capturing":return P(s,{name:n});case "group":return A({flags:e});case "lookahead":case "lookbehind":return K({behind:r==="lookbehind",negate:t});default:throw new Error(`Unexpected group kind "${r}"`)}}function h(e){if(e===void 0)e=[b()];else if(!Array.isArray(e)||!e.length||!e.every(r=>r.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function V(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(r=>!!r.type))throw new Error("Invalid body; expected array of nodes");return e}function M(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function $(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function se(e){return /^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function de(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function w(e){return e.replace(/[- _]+/g,"").toLowerCase()}function z(e,r){return u(e,`${r?.type==="Character"&&r.value===93?"Empty":"Unclosed"} character class`)}function D(e){return u(e,"Unclosed group")}
8475
8475
 
8476
- function S(a,v,N=null){function u$1(e,s){for(let t=0;t<e.length;t++){const r=n(e[t],s,t,e);t=Math.max(-1,t+r);}}function n(e,s=null,t=null,r=null){let i=0,c=!1;const d={node:e,parent:s,key:t,container:r,root:a,remove(){f(r).splice(Math.max(0,l(t)+i),1),i--,c=!0;},removeAllNextSiblings(){return f(r).splice(l(t)+1)},removeAllPrevSiblings(){const o=l(t)+i;return i-=o,f(r).splice(0,Math.max(0,o))},replaceWith(o,y={}){const b=!!y.traverse;r?r[Math.max(0,l(t)+i)]=o:u(s,"Can't replace root node")[t]=o,b&&n(o,s,t,r),c=!0;},replaceWithMultiple(o,y={}){const b=!!y.traverse;if(f(r).splice(Math.max(0,l(t)+i),1,...o),i+=o.length-1,b){let g=0;for(let x=0;x<o.length;x++)g+=n(o[x],s,l(t)+x+g,r);}c=!0;},skip(){c=!0;}},{type:m}=e,h=v["*"],p=v[m],R=typeof h=="function"?h:h?.enter,P=typeof p=="function"?p:p?.enter;if(R?.(d,N),P?.(d,N),!c)switch(m){case"AbsenceFunction":case"CapturingGroup":case"Group":u$1(e.body,e);break;case"Alternative":case"CharacterClass":u$1(e.body,e);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":n(e.min,e,"min"),n(e.max,e,"max");break;case"LookaroundAssertion":u$1(e.body,e);break;case"Quantifier":n(e.body,e,"body");break;case"Regex":u$1(e.body,e),n(e.flags,e,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return p?.exit?.(d,N),h?.exit?.(d,N),i}return n(a),a}function f(a){if(!Array.isArray(a))throw new Error("Container expected");return a}function l(a){if(typeof a!="number")throw new Error("Numeric key expected");return a}
8476
+ function S(a,v,N=null){function u$1(e,s){for(let t=0;t<e.length;t++){const r=n(e[t],s,t,e);t=Math.max(-1,t+r);}}function n(e,s=null,t=null,r=null){let i=0,c=false;const d={node:e,parent:s,key:t,container:r,root:a,remove(){f(r).splice(Math.max(0,l(t)+i),1),i--,c=true;},removeAllNextSiblings(){return f(r).splice(l(t)+1)},removeAllPrevSiblings(){const o=l(t)+i;return i-=o,f(r).splice(0,Math.max(0,o))},replaceWith(o,y={}){const b=!!y.traverse;r?r[Math.max(0,l(t)+i)]=o:u(s,"Can't replace root node")[t]=o,b&&n(o,s,t,r),c=true;},replaceWithMultiple(o,y={}){const b=!!y.traverse;if(f(r).splice(Math.max(0,l(t)+i),1,...o),i+=o.length-1,b){let g=0;for(let x=0;x<o.length;x++)g+=n(o[x],s,l(t)+x+g,r);}c=true;},skip(){c=true;}},{type:m}=e,h=v["*"],p=v[m],R=typeof h=="function"?h:h?.enter,P=typeof p=="function"?p:p?.enter;if(R?.(d,N),P?.(d,N),!c)switch(m){case "AbsenceFunction":case "CapturingGroup":case "Group":u$1(e.body,e);break;case "Alternative":case "CharacterClass":u$1(e.body,e);break;case "Assertion":case "Backreference":case "Character":case "CharacterSet":case "Directive":case "Flags":case "NamedCallout":case "Subroutine":break;case "CharacterClassRange":n(e.min,e,"min"),n(e.max,e,"max");break;case "LookaroundAssertion":u$1(e.body,e);break;case "Quantifier":n(e.body,e,"body");break;case "Regex":u$1(e.body,e),n(e.flags,e,"flags");break;default:throw new Error(`Unexpected node type "${m}"`)}return p?.exit?.(d,N),h?.exit?.(d,N),i}return n(a),a}function f(a){if(!Array.isArray(a))throw new Error("Container expected");return a}function l(a){if(typeof a!="number")throw new Error("Numeric key expected");return a}
8477
8477
 
8478
8478
  // Separating some utils for improved tree shaking of the `./internals` export
8479
8479
 
@@ -13704,4 +13704,18 @@ function registerCodeHighlighting(editor, tokenizer) {
13704
13704
  return mergeRegister(...registrations);
13705
13705
  }
13706
13706
 
13707
- export { ShikiTokenizer, getCodeLanguageOptions, getCodeThemeOptions, isCodeLanguageLoaded, loadCodeLanguage, loadCodeTheme, normalizeCodeLanguage, registerCodeHighlighting };
13707
+ /**
13708
+ * Add code highlighting support for code blocks with Shiki
13709
+ */
13710
+ const CodeHighlighterShikiExtension = defineExtension({
13711
+ config: {
13712
+ tokenizer: ShikiTokenizer
13713
+ },
13714
+ dependencies: [CodeExtension],
13715
+ name: '@lexical/code-shiki',
13716
+ register: (editor, {
13717
+ tokenizer
13718
+ }) => registerCodeHighlighting(editor, tokenizer)
13719
+ });
13720
+
13721
+ export { CodeHighlighterShikiExtension, ShikiTokenizer, getCodeLanguageOptions, getCodeThemeOptions, isCodeLanguageLoaded, loadCodeLanguage, loadCodeTheme, normalizeCodeLanguage, registerCodeHighlighting };
@@ -6,7 +6,21 @@
6
6
  *
7
7
  * @flow strict
8
8
  */
9
+ import type {
10
+ LexicalExtension,
11
+ LexicalNode,
12
+ ExtensionConfigBase,
13
+ } from 'lexical';
14
+ import type {CodeNode} from '@lexical/code';
9
15
 
10
16
  /**
11
17
  * LexicalCodeShiki
12
18
  */
19
+
20
+ export type Tokenizer = {
21
+ defaultLanguage: string;
22
+ defaultTheme: string;
23
+ $tokenize: (codeNode: CodeNode, language?: string) => LexicalNode[];
24
+ }
25
+ declare export var ShikiTokenizer: Tokenizer;
26
+ declare export var CodeHighlighterShikiExtension: LexicalExtension<{tokenizer: Tokenizer}, "@lexical/code-shiki", void, void>;
@@ -9,6 +9,7 @@
9
9
  import * as modDev from './LexicalCodeShiki.dev.mjs';
10
10
  import * as modProd from './LexicalCodeShiki.prod.mjs';
11
11
  const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
+ export const CodeHighlighterShikiExtension = mod.CodeHighlighterShikiExtension;
12
13
  export const ShikiTokenizer = mod.ShikiTokenizer;
13
14
  export const getCodeLanguageOptions = mod.getCodeLanguageOptions;
14
15
  export const getCodeThemeOptions = mod.getCodeThemeOptions;
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalCodeShiki.dev.mjs') : import('./LexicalCodeShiki.prod.mjs'));
10
+ export const CodeHighlighterShikiExtension = mod.CodeHighlighterShikiExtension;
10
11
  export const ShikiTokenizer = mod.ShikiTokenizer;
11
12
  export const getCodeLanguageOptions = mod.getCodeLanguageOptions;
12
13
  export const getCodeThemeOptions = mod.getCodeThemeOptions;