@malloy-publisher/app 0.0.187 → 0.0.188

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.
@@ -0,0 +1 @@
1
+ import{d as o,j as a,i as e}from"./index-BL2TJgTw.js";function i(){const t=o();return a.jsx(e,{onClickProject:t})}export{i as default};
@@ -1,2 +1,2 @@
1
- import{a as V,g as F,r as g,R as _,b as X,c as S,d as M,e as A,j as t,f as m,h as w,i as v,k as I,P as Y,m as R,l as J,n as z,B as K,o as N,p as Z,T as U,q,t as oo,u as eo,v as b,C as j,w as ro,x as to,I as so,M as ao,y as $,S as no,z as lo,A as io,O as co}from"./index-DjdBB2D6.js";function po(o,e,r,s,n){const[a,i]=g.useState(()=>n&&r?r(o).matches:s?s(o).matches:e);return X(()=>{if(!r)return;const p=r(o),u=()=>{i(p.matches)};return u(),p.addEventListener("change",u),()=>{p.removeEventListener("change",u)}},[o,r]),a}const uo={..._},L=uo.useSyncExternalStore;function go(o,e,r,s,n){const a=g.useCallback(()=>e,[e]),i=g.useMemo(()=>{if(n&&r)return()=>r(o).matches;if(s!==null){const{matches:c}=s(o);return()=>c}return a},[a,o,s,n,r]),[p,u]=g.useMemo(()=>{if(r===null)return[a,()=>()=>{}];const c=r(o);return[()=>c.matches,l=>(c.addEventListener("change",l),()=>{c.removeEventListener("change",l)})]},[a,r,o]);return L(u,p,i)}function O(o={}){const{themeId:e}=o;return function(s,n={}){let a=V();a&&e&&(a=a[e]||a);const i=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:p=!1,matchMedia:u=i?window.matchMedia:null,ssrMatchMedia:d=null,noSsr:c=!1}=F({name:"MuiUseMediaQuery",props:n,theme:a});let l=typeof s=="function"?s(a):s;return l=l.replace(/^@media( ?)/m,""),l.includes("print")&&console.warn(["MUI: You have provided a `print` query to the `useMediaQuery` hook.","Using the print media query to modify print styles can lead to unexpected results.","Consider using the `displayPrint` field in the `sx` prop instead.","More information about `displayPrint` on our docs: https://mui.com/system/display/#display-in-print."].join(`
1
+ import{u as V,g as F,r as g,R as _,a as X,b as S,c as M,e as A,j as t,s as m,f as w,h as v,k as I,P as Y,m as R,l as J,n as z,B as K,o as N,p as Z,T as U,q,t as oo,d as eo,v as b,C as j,w as ro,x as to,I as so,M as ao,y as $,S as no,z as lo,A as io,O as co}from"./index-BL2TJgTw.js";function po(o,e,r,s,n){const[a,i]=g.useState(()=>n&&r?r(o).matches:s?s(o).matches:e);return X(()=>{if(!r)return;const p=r(o),u=()=>{i(p.matches)};return u(),p.addEventListener("change",u),()=>{p.removeEventListener("change",u)}},[o,r]),a}const uo={..._},L=uo.useSyncExternalStore;function go(o,e,r,s,n){const a=g.useCallback(()=>e,[e]),i=g.useMemo(()=>{if(n&&r)return()=>r(o).matches;if(s!==null){const{matches:c}=s(o);return()=>c}return a},[a,o,s,n,r]),[p,u]=g.useMemo(()=>{if(r===null)return[a,()=>()=>{}];const c=r(o);return[()=>c.matches,l=>(c.addEventListener("change",l),()=>{c.removeEventListener("change",l)})]},[a,r,o]);return L(u,p,i)}function O(o={}){const{themeId:e}=o;return function(s,n={}){let a=V();a&&e&&(a=a[e]||a);const i=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:p=!1,matchMedia:u=i?window.matchMedia:null,ssrMatchMedia:d=null,noSsr:c=!1}=F({name:"MuiUseMediaQuery",props:n,theme:a});let l=typeof s=="function"?s(a):s;return l=l.replace(/^@media( ?)/m,""),l.includes("print")&&console.warn(["MUI: You have provided a `print` query to the `useMediaQuery` hook.","Using the print media query to modify print styles can lead to unexpected results.","Consider using the `displayPrint` field in the `sx` prop instead.","More information about `displayPrint` on our docs: https://mui.com/system/display/#display-in-print."].join(`
2
2
  `)),(L!==void 0?go:po)(l,p,u,d,c)}}O();function xo(o){return S("MuiAppBar",o)}M("MuiAppBar",["root","positionFixed","positionAbsolute","positionSticky","positionStatic","positionRelative","colorDefault","colorPrimary","colorSecondary","colorInherit","colorTransparent","colorError","colorInfo","colorSuccess","colorWarning"]);const mo=o=>{const{color:e,position:r,classes:s}=o,n={root:["root",`color${v(e)}`,`position${v(r)}`]};return I(n,xo,s)},D=(o,e)=>o?`${o?.replace(")","")}, ${e})`:e,bo=m(Y,{name:"MuiAppBar",slot:"Root",overridesResolver:(o,e)=>{const{ownerState:r}=o;return[e.root,e[`position${v(r.position)}`],e[`color${v(r.color)}`]]}})(R(({theme:o})=>({display:"flex",flexDirection:"column",width:"100%",boxSizing:"border-box",flexShrink:0,variants:[{props:{position:"fixed"},style:{position:"fixed",zIndex:(o.vars||o).zIndex.appBar,top:0,left:"auto",right:0,"@media print":{position:"absolute"}}},{props:{position:"absolute"},style:{position:"absolute",zIndex:(o.vars||o).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"sticky"},style:{position:"sticky",zIndex:(o.vars||o).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"static"},style:{position:"static"}},{props:{position:"relative"},style:{position:"relative"}},{props:{color:"inherit"},style:{"--AppBar-color":"inherit"}},{props:{color:"default"},style:{"--AppBar-background":o.vars?o.vars.palette.AppBar.defaultBg:o.palette.grey[100],"--AppBar-color":o.vars?o.vars.palette.text.primary:o.palette.getContrastText(o.palette.grey[100]),...o.applyStyles("dark",{"--AppBar-background":o.vars?o.vars.palette.AppBar.defaultBg:o.palette.grey[900],"--AppBar-color":o.vars?o.vars.palette.text.primary:o.palette.getContrastText(o.palette.grey[900])})}},...Object.entries(o.palette).filter(J(["contrastText"])).map(([e])=>({props:{color:e},style:{"--AppBar-background":(o.vars??o).palette[e].main,"--AppBar-color":(o.vars??o).palette[e].contrastText}})),{props:e=>e.enableColorOnDark===!0&&!["inherit","transparent"].includes(e.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)"}},{props:e=>e.enableColorOnDark===!1&&!["inherit","transparent"].includes(e.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...o.applyStyles("dark",{backgroundColor:o.vars?D(o.vars.palette.AppBar.darkBg,"var(--AppBar-background)"):null,color:o.vars?D(o.vars.palette.AppBar.darkColor,"var(--AppBar-color)"):null})}},{props:{color:"transparent"},style:{"--AppBar-background":"transparent","--AppBar-color":"inherit",backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...o.applyStyles("dark",{backgroundImage:"none"})}}]}))),fo=g.forwardRef(function(e,r){const s=A({props:e,name:"MuiAppBar"}),{className:n,color:a="primary",enableColorOnDark:i=!1,position:p="fixed",...u}=s,d={...s,color:a,position:p,enableColorOnDark:i},c=mo(d);return t.jsx(bo,{square:!0,component:"header",ownerState:d,elevation:4,className:w(c.root,n,p==="fixed"&&"mui-fixed"),ref:r,...u})}),ho=z(t.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})),yo=m(K,{name:"MuiBreadcrumbCollapsed"})(R(({theme:o})=>({display:"flex",marginLeft:`calc(${o.spacing(1)} * 0.5)`,marginRight:`calc(${o.spacing(1)} * 0.5)`,...o.palette.mode==="light"?{backgroundColor:o.palette.grey[100],color:o.palette.grey[700]}:{backgroundColor:o.palette.grey[700],color:o.palette.grey[100]},borderRadius:2,"&:hover, &:focus":{...o.palette.mode==="light"?{backgroundColor:o.palette.grey[200]}:{backgroundColor:o.palette.grey[600]}},"&:active":{boxShadow:o.shadows[0],...o.palette.mode==="light"?{backgroundColor:N(o.palette.grey[200],.12)}:{backgroundColor:N(o.palette.grey[600],.12)}}}))),vo=m(ho)({width:24,height:16});function Bo(o){const{slots:e={},slotProps:r={},...s}=o,n=o;return t.jsx("li",{children:t.jsx(yo,{focusRipple:!0,...s,ownerState:n,children:t.jsx(vo,{as:e.CollapsedIcon,ownerState:n,...r.collapsedIcon})})})}function ko(o){return S("MuiBreadcrumbs",o)}const Co=M("MuiBreadcrumbs",["root","ol","li","separator"]),jo=o=>{const{classes:e}=o;return I({root:["root"],li:["li"],ol:["ol"],separator:["separator"]},ko,e)},So=m(U,{name:"MuiBreadcrumbs",slot:"Root",overridesResolver:(o,e)=>[{[`& .${Co.li}`]:e.li},e.root]})({}),Mo=m("ol",{name:"MuiBreadcrumbs",slot:"Ol"})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"}),Ao=m("li",{name:"MuiBreadcrumbs",slot:"Separator"})({display:"flex",userSelect:"none",marginLeft:8,marginRight:8});function wo(o,e,r,s){return o.reduce((n,a,i)=>(i<o.length-1?n=n.concat(a,t.jsx(Ao,{"aria-hidden":!0,className:e,ownerState:s,children:r},`separator-${i}`)):n.push(a),n),[])}const Io=g.forwardRef(function(e,r){const s=A({props:e,name:"MuiBreadcrumbs"}),{children:n,className:a,component:i="nav",slots:p={},slotProps:u={},expandText:d="Show path",itemsAfterCollapse:c=1,itemsBeforeCollapse:l=1,maxItems:h=8,separator:B="/",...Q}=s,[T,W]=g.useState(!1),f={...s,component:i,expanded:T,expandText:d,itemsAfterCollapse:c,itemsBeforeCollapse:l,maxItems:h,separator:B},y=jo(f),H=Z({elementType:p.CollapsedIcon,externalSlotProps:u.collapsedIcon,ownerState:f}),P=g.useRef(null),G=x=>{const C=()=>{W(!0);const E=P.current.querySelector("a[href],button,[tabindex]");E&&E.focus()};return l+c>=x.length?x:[...x.slice(0,l),t.jsx(Bo,{"aria-label":d,slots:{CollapsedIcon:p.CollapsedIcon},slotProps:{collapsedIcon:H},onClick:C},"ellipsis"),...x.slice(x.length-c,x.length)]},k=g.Children.toArray(n).filter(x=>g.isValidElement(x)).map((x,C)=>t.jsx("li",{className:y.li,children:x},`child-${C}`));return t.jsx(So,{ref:r,component:i,color:"textSecondary",className:w(y.root,a),ownerState:f,...Q,children:t.jsx(Mo,{className:y.ol,ref:P,ownerState:f,children:wo(T||h&&k.length<=h?k:G(k),y.separator,B,f)})})});function Ro(o){return S("MuiToolbar",o)}M("MuiToolbar",["root","gutters","regular","dense"]);const zo=o=>{const{classes:e,disableGutters:r,variant:s}=o;return I({root:["root",!r&&"gutters",s]},Ro,e)},To=m("div",{name:"MuiToolbar",slot:"Root",overridesResolver:(o,e)=>{const{ownerState:r}=o;return[e.root,!r.disableGutters&&e.gutters,e[r.variant]]}})(R(({theme:o})=>({position:"relative",display:"flex",alignItems:"center",variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:o.spacing(2),paddingRight:o.spacing(2),[o.breakpoints.up("sm")]:{paddingLeft:o.spacing(3),paddingRight:o.spacing(3)}}},{props:{variant:"dense"},style:{minHeight:48}},{props:{variant:"regular"},style:o.mixins.toolbar}]}))),Po=g.forwardRef(function(e,r){const s=A({props:e,name:"MuiToolbar"}),{className:n,component:a="div",disableGutters:i=!1,variant:p="regular",...u}=s,d={...s,component:a,disableGutters:i,variant:p},c=zo(d);return t.jsx(To,{as:a,className:w(c.root,n),ref:r,ownerState:d,...u})}),Eo=O({themeId:q}),No=z(t.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),$o=z(t.jsx("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}));function Do(){const o=oo(),e=o["*"],r=eo();return t.jsx(b,{sx:{display:"flex",alignItems:"center"},children:t.jsxs(Io,{"aria-label":"breadcrumb",separator:t.jsx(No,{sx:{fontSize:14,color:"text.secondary"}}),sx:{"& .MuiBreadcrumbs-separator":{margin:"0 6px"}},children:[o.projectName&&t.jsx(j,{onClick:s=>r(`/${o.projectName}/`,s),label:o.projectName,size:"medium",sx:{backgroundColor:"white",color:"primary.main",fontWeight:500,height:"32px",fontSize:"1rem",cursor:"pointer","&:hover":{backgroundColor:"primary.100"}}}),o.packageName&&t.jsx(j,{onClick:s=>r(`/${o.projectName}/${o.packageName}/`,s),label:o.packageName,size:"medium",sx:{backgroundColor:"white",color:"primary.main",fontWeight:500,height:"32px",fontSize:"1rem",cursor:"pointer","&:hover":{backgroundColor:"secondary.100"}}}),e&&t.jsx(j,{onClick:s=>r(`/${o.projectName}/${o.packageName}/${e}`,s),label:e,size:"medium",sx:{backgroundColor:"white",color:"primary.main",fontWeight:500,height:"32px",fontSize:"1rem",cursor:"pointer","&:hover":{backgroundColor:"grey.200"}}})]})})}function Uo({logoHeader:o,endCap:e}){const r=ro(),s=to(),n=Eo(s.breakpoints.down("sm")),[a,i]=g.useState(null),p=!!a,u=l=>{i(l.currentTarget)},d=()=>i(null),c=[{label:"Malloy Docs",link:"https://docs.malloydata.dev/documentation/",sx:{color:"#14b3cb"}},{label:"Publisher Docs",link:"https://github.com/malloydata/publisher/blob/main/README.md",sx:{color:"#14b3cb"}},{label:"Publisher API",link:"/api-doc.html",sx:{color:"#14b3cb"}}];return t.jsxs(fo,{position:"sticky",elevation:0,sx:{backgroundColor:"background.paper",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(Po,{sx:{justifyContent:"space-between",flexWrap:"nowrap",minHeight:44},children:[o||t.jsxs(b,{sx:{display:"flex",alignItems:"center",gap:1,cursor:"pointer"},onClick:()=>r("/"),children:[t.jsx(b,{component:"img",src:"/logo.svg",alt:"Malloy",sx:{width:28,height:28}}),t.jsx(U,{variant:"h6",sx:{color:"text.primary",fontWeight:700,letterSpacing:"-0.025em",fontSize:{xs:"1.1rem",sm:"1.25rem"}},children:"Malloy Publisher"})]}),n?t.jsxs(t.Fragment,{children:[t.jsx(so,{color:"inherit",onClick:u,children:t.jsx($o,{})}),t.jsxs(ao,{anchorEl:a,open:p,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:[c.map(l=>t.jsx($,{onClick:()=>{d(),window.location.href=l.link},sx:l.sx,children:l.label},l.label)),e&&t.jsx($,{children:e})]})]}):t.jsxs(no,{direction:"row",spacing:2,alignItems:"center",children:[c.map(l=>t.jsx(lo,{href:l.link,sx:l.sx,children:l.label},l.label)),e]})]}),t.jsx(b,{sx:{borderTop:"1px solid white",paddingLeft:"16px",paddingRight:"16px",marginBottom:"1px",overflowX:"auto"},children:t.jsx(Do,{})})]})}function Oo({headerProps:o}){return t.jsxs(b,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh"},children:[t.jsx(Uo,{...o}),t.jsx(io,{maxWidth:"xl",component:"main",sx:{flex:1,display:"flex",flexDirection:"column",py:2,gap:2},children:t.jsx(b,{sx:{flex:1},children:t.jsx(co,{})})})]})}export{Oo as default};
@@ -1 +1 @@
1
- import{t as n,j as e,D as i,E as t,F as c}from"./index-DjdBB2D6.js";function o(){const a=n(),r=a["*"];if(!a.projectName)return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})});if(!a.packageName)return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});const s=i({projectName:a.projectName,packageName:a.packageName,modelPath:r});return r?.endsWith(".malloy")?e.jsx(t,{resourceUri:s,runOnDemand:!0,maxResultSize:512*1024}):r?.endsWith(".malloynb")?e.jsx(c,{resourceUri:s,maxResultSize:1024*1024}):e.jsx("div",{children:e.jsxs("h2",{children:["Unrecognized file type: ",r]})})}export{o as default};
1
+ import{t as n,j as e,D as i,E as t,F as c}from"./index-BL2TJgTw.js";function o(){const a=n(),r=a["*"];if(!a.projectName)return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})});if(!a.packageName)return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});const s=i({projectName:a.projectName,packageName:a.packageName,modelPath:r});return r?.endsWith(".malloy")?e.jsx(t,{resourceUri:s,runOnDemand:!0,maxResultSize:512*1024}):r?.endsWith(".malloynb")?e.jsx(c,{resourceUri:s,maxResultSize:1024*1024}):e.jsx("div",{children:e.jsxs("h2",{children:["Unrecognized file type: ",r]})})}export{o as default};
@@ -0,0 +1 @@
1
+ import{t as n,d as c,j as e,D as t,G as o}from"./index-BL2TJgTw.js";function l(){const{projectName:s,packageName:a}=n(),r=c();if(s)if(a){const i=t({projectName:s,packageName:a});return e.jsx(o,{onClickPackageFile:r,resourceUri:i})}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})})}export{l as default};
@@ -0,0 +1 @@
1
+ import{d as a,t as n,j as e,D as o,H as c}from"./index-BL2TJgTw.js";function u(){const r=a(),{projectName:s}=n();if(s){const t=o({projectName:s});return e.jsx(c,{onSelectPackage:r,resourceUri:t})}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})})}export{u as default};
@@ -1 +1 @@
1
- import{J as o,j as r,A as s,S as n,v as t,T as a}from"./index-DjdBB2D6.js";function x(){const e=o();return console.error(e),r.jsx(s,{maxWidth:"lg",component:"main",sx:{display:"flex",flexDirection:"column",my:2,gap:0},children:r.jsxs(n,{sx:{m:"auto",flexDirection:"column"},children:[r.jsx(t,{sx:{height:"300px"}}),r.jsx("img",{src:"/error.png"}),r.jsx(a,{variant:"subtitle1",children:"An unexpected error occurred"})]})})}export{x as default};
1
+ import{J as o,j as r,A as s,S as n,v as t,T as a}from"./index-BL2TJgTw.js";function x(){const e=o();return console.error(e),r.jsx(s,{maxWidth:"lg",component:"main",sx:{display:"flex",flexDirection:"column",my:2,gap:0},children:r.jsxs(n,{sx:{m:"auto",flexDirection:"column"},children:[r.jsx(t,{sx:{height:"300px"}}),r.jsx("img",{src:"/error.png"}),r.jsx(a,{variant:"subtitle1",children:"An unexpected error occurred"})]})})}export{x as default};
@@ -1 +1 @@
1
- import{t as a,j as e,D as t,K as c}from"./index-DjdBB2D6.js";function d(){const{workspace:r,workbookPath:s,projectName:i,packageName:n}=a();if(r)if(s)if(i)if(n){const o=t({projectName:i,packageName:n});return e.jsx(c,{workbookPath:{path:s,workspace:r},resourceUri:o},`${s}`)}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workbook path"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workspace"})})}export{d as default};
1
+ import{t as a,j as e,D as t,Z as c}from"./index-BL2TJgTw.js";function d(){const{workspace:r,workbookPath:s,projectName:i,packageName:n}=a();if(r)if(s)if(i)if(n){const o=t({projectName:i,packageName:n});return e.jsx(c,{workbookPath:{path:s,workspace:r},resourceUri:o},`${s}`)}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing project name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workbook path"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workspace"})})}export{d as default};
@@ -0,0 +1,148 @@
1
+ import{createOnigurumaEngine as At,getDefaultWasmLoader as Gr,loadWasm as Mr}from"./engine-oniguruma-C4vnmooL.es-jdkXmgTr.js";import{Q as Cn,K as Br,L as Or,N as Fr,U as jr,V as Dr,W as Wr,X as Dt,Y as xt}from"./index-BL2TJgTw.js";let V=class extends Error{constructor(t){super(t),this.name="ShikiError"}},Ee=!1,wn=!1;function Zi(t=!0,e=!1){Ee=t,wn=e}function F(t,e=3){if(Ee&&!(typeof Ee=="number"&&e>Ee)){if(wn)throw new Error(`[SHIKI DEPRECATE]: ${t}`);console.trace(`[SHIKI DEPRECATE]: ${t}`)}}function Ur(t){return vt(t)}function vt(t){return Array.isArray(t)?qr(t):t instanceof RegExp?t:typeof t=="object"?Hr(t):t}function qr(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=vt(t[n]);return e}function Hr(t){let e={};for(let n in t)e[n]=vt(t[n]);return e}function Sn(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function An(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?An(t.substring(0,t.length-1)):t.substr(~e+1)}var Ke=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(t){return t===null?!1:(Ke.lastIndex=0,Ke.test(t))}static replaceCaptures(t,e,n){return t.replace(Ke,(r,s,a,o)=>{let i=n[parseInt(s||a,10)];if(i){let c=e.substring(i.start,i.end);for(;c[0]===".";)c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function xn(t,e){return t<e?-1:t>e?1:0}function vn(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let a=xn(t[s],e[s]);if(a!==0)return a}return 0}return n-r}function Wt(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function En(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Nn=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Re=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(Qr(t),e)}static createFromParsedTheme(t,e){return Zr(t,e)}_cachedMatchRoot=new Nn(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,n=this._cachedMatchRoot.get(e).find(r=>zr(t.parent,r.parentScopes));return n?new In(n.fontStyle,n.foreground,n.background):null}},Ye=class Ne{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Ne(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Ne(n,e[r]);return n}push(e){return new Ne(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function zr(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!Vr(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function Vr(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var In=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function Qr(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,a=e.length;s<a;s++){let o=e[s];if(!o.settings)continue;let i;if(typeof o.scope=="string"){let h=o.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(o.scope)?i=o.scope:i=[""];let c=-1;if(typeof o.settings.fontStyle=="string"){c=0;let h=o.settings.fontStyle.split(" ");for(let d=0,p=h.length;d<p;d++)switch(h[d]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof o.settings.foreground=="string"&&Wt(o.settings.foreground)&&(l=o.settings.foreground);let u=null;typeof o.settings.background=="string"&&Wt(o.settings.background)&&(u=o.settings.background);for(let h=0,d=i.length;h<d;h++){let p=i[h].trim().split(" "),g=p[p.length-1],k=null;p.length>1&&(k=p.slice(0,p.length-1),k.reverse()),n[r++]=new Xr(g,k,s,c,l,u)}}return n}var Xr=class{constructor(t,e,n,r,s,a){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=a}},z=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(z||{});function Zr(t,e){t.sort((c,l)=>{let u=xn(c.scope,l.scope);return u!==0||(u=vn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let a=new Kr(e),o=new In(n,a.getId(r),a.getId(s)),i=new Jr(new ut(0,null,-1,0,0),[]);for(let c=0,l=t.length;c<l;c++){let u=t[c];i.insert(0,u.scope,u.parentScopes,u.fontStyle,a.getId(u.foreground),a.getId(u.background))}return new Re(a,o,i)}var Kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},Yr=Object.freeze([]),ut=class $n{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,a){this.scopeDepth=e,this.parentScopes=n||Yr,this.fontStyle=r,this.foreground=s,this.background=a}clone(){return new $n(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Jr=class ht{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const a=n.parentScopes[s].length-e.parentScopes[r].length;if(a!==0)return a;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,a;if(r===-1?(s=e,a=""):(s=e.substring(0,r),a=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ht._cmpBySpecificity),n}insert(e,n,r,s,a,o){if(n===""){this._doInsertHere(e,r,s,a,o);return}let i=n.indexOf("."),c,l;i===-1?(c=n,l=""):(c=n.substring(0,i),l=n.substring(i+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ht(this._mainRule.clone(),ut.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(e+1,l,r,s,a,o)}_doInsertHere(e,n,r,s,a){if(n===null){this._mainRule.acceptOverwrite(e,r,s,a);return}for(let o=0,i=this._rulesWithParentScopes.length;o<i;o++){let c=this._rulesWithParentScopes[o];if(vn(c.parentScopes,n)===0){c.acceptOverwrite(e,r,s,a);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new ut(e,n,r,s,a))}},ie=class M{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=M.getLanguageId(e),r=M.getTokenType(e),s=M.getFontStyle(e),a=M.getForeground(e),o=M.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,a,o,i){let c=M.getLanguageId(e),l=M.getTokenType(e),u=M.containsBalancedBrackets(e)?1:0,h=M.getFontStyle(e),d=M.getForeground(e),p=M.getBackground(e);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),a!==-1&&(h=a),o!==0&&(d=o),i!==0&&(p=i),(c<<0|l<<8|u<<10|h<<11|d<<15|p<<24)>>>0}};function Pe(t,e){const n=[],r=es(t);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=o();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function a(){if(s==="-"){s=r.next();const c=a();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=i();return s===")"&&(s=r.next()),c}if(Ut(s)){const c=[];do c.push(s),s=r.next();while(Ut(s));return l=>e(c,l)}return null}function o(){const c=[];let l=a();for(;l;)c.push(l),l=a();return u=>c.every(h=>h(u))}function i(){const c=[];let l=o();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=o()}return u=>c.some(h=>h(u))}}function Ut(t){return!!t&&!!t.match(/[\w\.:]+/)}function es(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Rn(t){typeof t.dispose=="function"&&t.dispose()}var de=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},ts=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},ns=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},rs=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new de(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new ns;for(const n of t)ss(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof de){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function ss(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const a=n.lookup(e);t instanceof de?Ie({baseGrammar:a,selfGrammar:s},r):pt(t.ruleName,{baseGrammar:a,selfGrammar:s,repository:s.repository},r);const o=n.injections(t.scopeName);if(o)for(const i of o)r.add(new de(i))}function pt(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Te([r],e,n)}}function Ie(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Te(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Te(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Te(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Sn({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Te(r.patterns,{...e,repository:s},n);const a=r.include;if(!a)continue;const o=Pn(a);switch(o.kind){case 0:Ie({...e,selfGrammar:e.baseGrammar},n);break;case 1:Ie(e,n);break;case 2:pt(o.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const c={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};o.kind===4?pt(o.ruleName,c,n):Ie(c,n)}else o.kind===4?n.add(new ts(o.scopeName,o.ruleName)):n.add(new de(o.scopeName));break}}}var as=class{kind=0},os=class{kind=1},is=class{constructor(t){this.ruleName=t}kind=2},cs=class{constructor(t){this.scopeName=t}kind=3},ls=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Pn(t){if(t==="$base")return new as;if(t==="$self")return new os;const e=t.indexOf("#");if(e===-1)return new cs(t);if(e===0)return new is(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new ls(n,r)}}var us=/\\(\d+)/,qt=/\\(\d+)/g,hs=-1,Tn=-2,ke=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${An(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:we.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,t,e)}},ps=class extends ke{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},ds=class extends ke{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new ge(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ht=class extends ke{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},dt=class extends ke{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,a,o,i,c,l){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this._end=new ge(o||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Le=class extends ke{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,a,o,i,c){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this.whileCaptures=i,this._while=new ge(o,Tn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new fe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Ln=class R{static createCaptureRule(e,n,r,s,a){return e.registerRule(o=>new ps(n,o,r,s,a))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new ds(e.$vscodeTextmateLocation,e.id,e.name,e.match,R._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Sn({},r,e.repository));let a=e.patterns;return typeof a>"u"&&e.include&&(a=[{include:e.include}]),new Ht(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,R._compilePatterns(a,n,r))}return e.while?new Le(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,R._compileCaptures(e.whileCaptures||e.captures,n,r),R._compilePatterns(e.patterns,n,r)):new dt(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,R._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,R._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let a=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);i>a&&(a=i)}for(let o=0;o<=a;o++)s[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);let c=0;e[o].patterns&&(c=R.getCompiledRuleId(e[o],n,r)),s[i]=R.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let a=0,o=e.length;a<o;a++){const i=e[a];let c=-1;if(i.include){const l=Pn(i.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,d=l.kind===4?l.ruleName:null,p=n.getExternalGrammar(h,r);if(p)if(d){let g=p.repository[d];g&&(c=R.getCompiledRuleId(g,n,p.repository))}else c=R.getCompiledRuleId(p.repository.$self,n,p.repository);break}}else c=R.getCompiledRuleId(i,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Ht||l instanceof dt||l instanceof Le)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},ge=class Gn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,a=[],o=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(a.push(e.substring(s,i)),a.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(o=!0),i++}this.hasAnchor=o,s===0?this.source=e:(a.push(e.substring(s,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=us.test(this.source):this.hasBackReferences=!1}clone(){return new Gn(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return qt.lastIndex=0,this.source.replace(qt,(s,a)=>En(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],a,o,i,c;for(a=0,o=this.source.length;a<o;a++)i=this.source.charAt(a),e[a]=i,n[a]=i,r[a]=i,s[a]=i,i==="\\"&&a+1<o&&(c=this.source.charAt(a+1),c==="A"?(e[a+1]="￿",n[a+1]="￿",r[a+1]="A",s[a+1]="A"):c==="G"?(e[a+1]="￿",n[a+1]="G",r[a+1]="￿",s[a+1]="G"):(e[a+1]=c,n[a+1]=c,r[a+1]=c,s[a+1]=c),a++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},fe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new zt(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new zt(t,r,this._items.map(s=>s.ruleId))}},zt=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
2
+ `)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Je=class{constructor(t,e){this.languageId=t,this.tokenType=e}},gs=class gt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new Je(e,8),this._embeddedLanguagesMatcher=new fs(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?gt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new Je(0,0);_getBasicScopeAttributes=new Nn(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new Je(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(gt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},fs=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>En(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},Vt=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Mn(t,e,n,r,s,a,o,i){const c=e.content.length;let l=!1,u=-1;if(o){const p=ms(t,e,n,r,s,a);s=p.stack,r=p.linePos,n=p.isFirstLine,u=p.anchorPosition}const h=Date.now();for(;!l;){if(i!==0&&Date.now()-h>i)return new Vt(s,!0);d()}return new Vt(s,!1);function d(){const p=bs(t,e,n,r,s,u);if(!p){a.produce(s,c),l=!0;return}const g=p.captureIndices,k=p.matchedRuleId,m=g&&g.length>0?g[0].end>r:!1;if(k===hs){const C=s.getRule(t);a.produce(s,g[0].start),s=s.withContentNameScopesList(s.nameScopesList),ue(t,e,n,s,a,C.endCaptures,g),a.produce(s,g[0].end);const b=s;if(s=s.parent,u=b.getAnchorPos(),!m&&b.getEnterPos()===r){s=b,a.produce(s,c),l=!0;return}}else{const C=t.getRule(k);a.produce(s,g[0].start);const b=s,w=C.getName(e.content,g),I=s.contentNameScopesList.pushAttributed(w,t);if(s=s.push(k,r,u,g[0].end===c,null,I,I),C instanceof dt){const v=C;ue(t,e,n,s,a,v.beginCaptures,g),a.produce(s,g[0].end),u=g[0].end;const j=v.getContentName(e.content,g),L=I.pushAttributed(j,t);if(s=s.withContentNameScopesList(L),v.endHasBackReferences&&(s=s.withEndRule(v.getEndWithResolvedBackReferences(e.content,g))),!m&&b.hasSameRuleAs(s)){s=s.pop(),a.produce(s,c),l=!0;return}}else if(C instanceof Le){const v=C;ue(t,e,n,s,a,v.beginCaptures,g),a.produce(s,g[0].end),u=g[0].end;const j=v.getContentName(e.content,g),L=I.pushAttributed(j,t);if(s=s.withContentNameScopesList(L),v.whileHasBackReferences&&(s=s.withEndRule(v.getWhileWithResolvedBackReferences(e.content,g))),!m&&b.hasSameRuleAs(s)){s=s.pop(),a.produce(s,c),l=!0;return}}else if(ue(t,e,n,s,a,C.captures,g),a.produce(s,g[0].end),s=s.pop(),!m){s=s.safePop(),a.produce(s,c),l=!0;return}}g[0].end>r&&(r=g[0].end,n=!1)}}function ms(t,e,n,r,s,a){let o=s.beginRuleCapturedEOL?0:-1;const i=[];for(let c=s;c;c=c.pop()){const l=c.getRule(t);l instanceof Le&&i.push({rule:l,stack:c})}for(let c=i.pop();c;c=i.pop()){const{ruleScanner:l,findOptions:u}=ks(c.rule,t,c.stack.endRule,n,r===o),h=l.findNextMatchSync(e,r,u);if(h){if(h.ruleId!==Tn){s=c.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(a.produce(c.stack,h.captureIndices[0].start),ue(t,e,n,c.stack,a,c.rule.whileCaptures,h.captureIndices),a.produce(c.stack,h.captureIndices[0].end),o=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:o,isFirstLine:n}}function bs(t,e,n,r,s,a){const o=ys(t,e,n,r,s,a),i=t.getInjections();if(i.length===0)return o;const c=_s(i,t,e,n,r,s,a);if(!c)return o;if(!o)return c;const l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function ys(t,e,n,r,s,a){const o=s.getRule(t),{ruleScanner:i,findOptions:c}=Bn(o,t,s.endRule,n,r===a),l=i.findNextMatchSync(e,r,c);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function _s(t,e,n,r,s,a,o){let i=Number.MAX_VALUE,c=null,l,u=0;const h=a.contentNameScopesList.getScopeNames();for(let d=0,p=t.length;d<p;d++){const g=t[d];if(!g.matcher(h))continue;const k=e.getRule(g.ruleId),{ruleScanner:m,findOptions:C}=Bn(k,e,null,r,s===o),b=m.findNextMatchSync(n,s,C);if(!b)continue;const w=b.captureIndices[0].start;if(!(w>=i)&&(i=w,c=b.captureIndices,l=b.ruleId,u=g.priority,i===s))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function Bn(t,e,n,r,s){return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function ks(t,e,n,r,s){return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function ue(t,e,n,r,s,a,o){if(a.length===0)return;const i=e.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let h=0;h<c;h++){const d=a[h];if(d===null)continue;const p=o[h];if(p.length===0)continue;if(p.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=p.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,p.start):s.produce(r,p.start),d.retokenizeCapturedWithRuleId){const k=d.getName(i,o),m=r.contentNameScopesList.pushAttributed(k,t),C=d.getContentName(i,o),b=m.pushAttributed(C,t),w=r.push(d.retokenizeCapturedWithRuleId,p.start,-1,!1,null,m,b),I=t.createOnigString(i.substring(0,p.end));Mn(t,I,n&&p.start===0,p.start,w,s,!1,0),Rn(I);continue}const g=d.getName(i,o);if(g!==null){const k=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(g,t);l.push(new Cs(k,p.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Cs=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function ws(t,e,n,r,s,a,o,i){return new As(t,e,n,r,s,a,o,i)}function Qt(t,e,n,r,s){const a=Pe(e,Ge),o=Ln.getCompiledRuleId(n,r,s.repository);for(const i of a)t.push({debugSelector:e,matcher:i.matcher,ruleId:o,grammar:s,priority:i.priority})}function Ge(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let s=n;s<e.length;s++)if(Ss(e[s],r))return n=s+1,!0;return!1})}function Ss(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var As=class{constructor(t,e,n,r,s,a,o,i){if(this._rootScopeName=t,this.balancedBracketSelectors=a,this._onigLib=i,this._basicScopeAttributesProvider=new gs(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=Xt(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const c of Object.keys(s)){const l=Pe(c,Ge);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const s=r.injections;if(s)for(let o in s)Qt(e,o,s[o],this,r);const a=this._grammarRepository.injections(n);a&&a.forEach(o=>{const i=this.getExternalGrammar(o);if(i){const c=i.injectionSelector;c&&Qt(e,c,i,this,i)}})}return e.sort((s,a)=>s.priority-a.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=Xt(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Ln.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===ft.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=ie.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),d=this.getRule(this._rootId).getName(null,null);let p;d?p=he.createRootAndLookUpScopeName(d,h,this):p=he.createRoot("unknown",h),e=new ft(null,this._rootId,-1,-1,!1,null,p,p)}else s=!1,e.reset();t=t+`
3
+ `;const a=this.createOnigString(t),o=a.content.length,i=new vs(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Mn(this,a,s,0,e,i,!0,r);return Rn(a),{lineLength:o,lineTokens:i,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Xt(t,e){return t=Ur(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var he=class D{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const a of n)s=Ye.push(s,a.scopeNames),r=new D(r,s,a.encodedTokenAttributes);return r}static createRoot(e,n){return new D(null,new Ye(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),a=new Ye(null,e),o=r.themeProvider.themeMatch(a),i=D.mergeAttributes(n,s,o);return new D(null,a,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return D.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,a=0,o=0;return r!==null&&(s=r.fontStyle,a=r.foregroundId,o=r.backgroundId),ie.set(e,n.languageId,n.tokenType,null,s,a,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return D._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const a of r)s=D._pushAttributed(s,a,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),a=e.scopePath.push(n),o=r.themeProvider.themeMatch(a),i=D.mergeAttributes(e.tokenAttributes,s,o);return new D(e,a,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},ft=class Y{constructor(e,n,r,s,a,o,i,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=o,this.nameScopesList=i,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new Y(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:Y._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?he.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){Y._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,a,o,i){return new Y(this,e,n,r,s,a,o,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new Y(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=he.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new Y(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,he.fromExtension(r,n.contentNameScopesList))}},xs=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Pe(n,Ge).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Pe(n,Ge).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},vs=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const a=t?.getScopeNames()??[];for(const o of this._tokenTypeOverrides)o.matcher(a)&&(r=ie.set(r,0,o.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(a))}if(s&&(r=ie.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Es=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let a=this._rawGrammars.get(t);if(!a)return null;this._grammars.set(t,ws(t,a,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},Ns=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Es(Re.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,e){this._syncRegistry.setTheme(Re.createFromRawTheme(t,e))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,e,n){return this.loadGrammarWithConfiguration(t,e,{embeddedLanguages:n})}loadGrammarWithConfiguration(t,e,n){return this._loadGrammar(t,e,n.embeddedLanguages,n.tokenTypes,new xs(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,e,n,r,s){const a=new rs(this._syncRegistry,t);for(;a.Q.length>0;)a.Q.map(o=>this._loadSingleGrammar(o.scopeName)),a.processQueue();return this._grammarForScopeName(t,e,n,r,s)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const e=this._options.loadGrammar(t);if(e){const n=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(e,n)}}addGrammar(t,e=[],n=0,r=null){return this._syncRegistry.addGrammar(t,e),this._grammarForScopeName(t.scopeName,n,r)}_grammarForScopeName(t,e=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(t,e,n,r,s)}},mt=ft.NULL;const Is=/["&'<>`]/g,$s=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Rs=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Ps=/[|\\{}()[\]^$+*?.]/g,Zt=new WeakMap;function Ts(t,e){if(t=t.replace(e.subset?Ls(e.subset):Is,r),e.subset||e.escapeOnly)return t;return t.replace($s,n).replace(Rs,r);function n(s,a,o){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,o.charCodeAt(a+2),e)}function r(s,a,o){return e.format(s.charCodeAt(0),o.charCodeAt(a+1),e)}}function Ls(t){let e=Zt.get(t);return e||(e=Gs(t),Zt.set(t,e)),e}function Gs(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(Ps,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Ms=/[\dA-Fa-f]/;function Bs(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!Ms.test(String.fromCharCode(e))?r:r+";"}const Os=/\d/;function Fs(t,e,n){const r="&#"+String(t);return n&&e&&!Os.test(String.fromCharCode(e))?r:r+";"}const js=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],et={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Ds=["cent","copy","divide","gt","lt","not","para","times"],On={}.hasOwnProperty,bt={};let Se;for(Se in et)On.call(et,Se)&&(bt[et[Se]]=Se);const Ws=/[^\dA-Za-z]/;function Us(t,e,n,r){const s=String.fromCharCode(t);if(On.call(bt,s)){const a=bt[s],o="&"+a;return n&&js.includes(a)&&!Ds.includes(a)&&(!r||e&&e!==61&&Ws.test(String.fromCharCode(e)))?o:o+";"}return""}function qs(t,e,n){let r=Bs(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=Us(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const a=Fs(t,e,n.omitOptionalSemicolons);a.length<r.length&&(r=a)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function ae(t,e){return Ts(t,Object.assign({format:qs},e))}const Hs=/^>|^->|<!--|-->|--!>|<!-$/g,zs=[">"],Vs=["<",">"];function Qs(t,e,n,r){return r.settings.bogusComments?"<?"+ae(t.value,Object.assign({},r.settings.characterReferences,{subset:zs}))+">":"<!--"+t.value.replace(Hs,s)+"-->";function s(a){return ae(a,Object.assign({},r.settings.characterReferences,{subset:Vs}))}}function Xs(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const N=jn(1),Fn=jn(-1),Zs=[];function jn(t){return e;function e(n,r,s){const a=n?n.children:Zs;let o=(r||0)+t,i=a[o];if(!s)for(;i&&xt(i);)o+=t,i=a[o];return i}}const Ks={}.hasOwnProperty;function Dn(t){return e;function e(n,r,s){return Ks.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const Et=Dn({body:Js,caption:tt,colgroup:tt,dd:ra,dt:na,head:tt,html:Ys,li:ta,optgroup:sa,option:aa,p:ea,rp:Kt,rt:Kt,tbody:ia,td:Yt,tfoot:ca,th:Yt,thead:oa,tr:la});function tt(t,e,n){const r=N(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&xt(r.value.charAt(0)))}function Ys(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function Js(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function ea(t,e,n){const r=N(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function ta(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="li"}function na(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function ra(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Kt(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function sa(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function aa(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function oa(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function ia(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function ca(t,e,n){return!N(n,e)}function la(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Yt(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const ua=Dn({body:da,colgroup:ga,head:pa,html:ha,tbody:fa});function ha(t){const e=N(t,-1);return!e||e.type!=="comment"}function pa(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function da(t){const e=N(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&xt(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function ga(t,e,n){const r=Fn(n,e),s=N(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Et(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function fa(t,e,n){const r=Fn(n,e),s=N(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Et(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Ae={name:[[`
4
+ \f\r &/=>`.split(""),`
5
+ \f\r "&'/=>\``.split("")],[`\0
6
+ \f\r "&'/<=>`.split(""),`\0
7
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
8
+ \f\r &>`.split(""),`\0
9
+ \f\r "&'<=>\``.split("")],[`\0
10
+ \f\r "&'<=>\``.split(""),`\0
11
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function ma(t,e,n,r){const s=r.schema,a=s.space==="svg"?!1:r.settings.omitOptionalTags;let o=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const i=[];let c;s.space==="html"&&t.tagName==="svg"&&(r.schema=Cn);const l=ba(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(o=!1),(l||!a||!ua(t,e,n))&&(i.push("<",t.tagName,l?" "+l:""),o&&(s.space==="svg"||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c==="/"||c&&c!=='"'&&c!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!o&&(!a||!Et(t,e,n))&&i.push("</"+t.tagName+">"),i.join("")}function ba(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const a=ya(t,s,e[s]);a&&n.push(a)}}for(;++r<n.length;){const a=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&a!=='"'&&a!=="'"&&(n[r]+=" ")}return n.join("")}function ya(t,e,n){const r=jr(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,a=t.settings.allowDangerousCharacters?0:1;let o=t.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const c=ae(r.attribute,Object.assign({},t.settings.characterReferences,{subset:Ae.name[s][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Dr:Wr)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?c:(t.settings.preferUnquoted&&(i=ae(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:Ae.unquoted[s][a]}))),i!==n&&(t.settings.quoteSmart&&Dt(n,o)>Dt(n,t.alternative)&&(o=t.alternative),i=o+ae(n,Object.assign({},t.settings.characterReferences,{subset:(o==="'"?Ae.single:Ae.double)[s][a],attribute:!0}))+o),c+(i&&"="+i))}const _a=["<","&"];function Wn(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:ae(t.value,Object.assign({},r.settings.characterReferences,{subset:_a}))}function ka(t,e,n,r){return r.settings.allowDangerousHtml?t.value:Wn(t,e,n,r)}function Ca(t,e,n,r){return r.all(t)}const wa=Fr("type",{invalid:Sa,unknown:Aa,handlers:{comment:Qs,doctype:Xs,element:ma,raw:ka,root:Ca,text:Wn}});function Sa(t){throw new Error("Expected node, not `"+t+"`")}function Aa(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const xa={},va={},Ea=[];function Na(t,e){const n=e||xa,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Ia,all:$a,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Or,characterReferences:n.characterReferences||va,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Cn:Br,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function Ia(t,e,n){return wa(t,e,n,this)}function $a(t){const e=[],n=t&&t.children||Ea;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}const Nt=String.raw,Jt=Nt`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,en=Nt`\u{E0061}-\u{E007A}`,Ra=()=>new RegExp(Nt`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${en}]{2}[\u{E0030}-\u{E0039}${en}]{1,3}\u{E007F}|${Jt}(?:\u200D${Jt})*`,"gu"),B=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function We(t,e,n,r){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1];let o=0,i="";for(const c of t.matchAll(s)){const{0:l,groups:{$skip:u}}=c;if(!u&&(!r||r===B.DEFAULT==!o)){n instanceof Function?i+=n(c,{context:o?B.CHAR_CLASS:B.DEFAULT,negated:a[a.length-1]}):i+=n;continue}l[0]==="["?(o++,a.push(l[1]==="^")):l==="]"&&o&&(o--,a.pop()),i+=l}return i}function Pa(t,e,n,r){We(t,e,n,r)}function Ta(t,e,n=0,r){if(!new RegExp(e,"su").test(t))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let a=0,o;for(;o=s.exec(t);){const{0:i,groups:{$skip:c}}=o;if(!c&&(!r||r===B.DEFAULT==!a))return o;i==="["?a++:i==="]"&&a&&a--,s.lastIndex==o.index&&s.lastIndex++}return null}function xe(t,e,n){return!!Ta(t,e,0,n)}function La(t,e){const n=/\\?./gsu;n.lastIndex=e;let r=t.length,s=0,a=1,o;for(;o=n.exec(t);){const[i]=o;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")a++;else if(i===")"&&(a--,!a)){r=o.index;break}}return t.slice(e,r)}const te="$E$";class It extends RegExp{_captureMap;_namesByIndex;constructor(e,n,r){if(e instanceof RegExp&&r)throw new Error("Cannot provide options when copying a regexp");const s=!!r?.useEmulationGroups,a=s?Ga(e):null;super(a?.expression||e,n);const o=s?a:e instanceof It?e:null;o&&(this._captureMap=o._captureMap,this._namesByIndex=o._namesByIndex)}exec(e){const n=RegExp.prototype.exec.call(this,e);if(!n||!this._captureMap)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);for(let a=1;a<r.length;a++)if(this._captureMap[a].exclude){const o=this._captureMap[a].transfer;if(o&&n.length>o){n[o]=r[a];const i=this._namesByIndex[o];i&&(n.groups[i]=r[a],this.hasIndices&&(n.indices.groups[i]=s[a])),this.hasIndices&&(n.indices[o]=s[a])}}else n.push(r[a]),this.hasIndices&&n.indices.push(s[a]);return n}}function Ga(t){const e=te.replace(/\$/g,"\\$"),n=[{exclude:!1}],r={0:""};let s=0;return t=We(t,String.raw`\((?:(?!\?)|\?<(?![=!])(?<name>[^>]+)>)(?<mark>(?:\$(?<transfer>[1-9]\d*))?${e})?`,({0:a,groups:{name:o,mark:i,transfer:c}})=>i?(n.push({exclude:!0,transfer:c&&+c}),a.slice(0,-i.length)):(s++,o&&(r[s]=o),n.push({exclude:!1}),a),B.DEFAULT),{_captureMap:n,_namesByIndex:r,expression:t}}const Ma=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Ba(t,e,n,r){return t.slice(0,e)+r+t.slice(e+n.length)}const tn=new RegExp(String.raw`(?<noncapturingStart>${Ma})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Oa(t,e){if(!/\(\?>/.test(t))return t;const n="(?>",r=`(?:(?=(${e?.useEmulationGroups?te:""}`,s=[0];let a=0,o=0,i=NaN,c;do{c=!1;let l=0,u=0,h=!1,d;for(tn.lastIndex=Number.isNaN(i)?0:i+r.length;d=tn.exec(t);){const{0:p,index:g,groups:{capturingStart:k,noncapturingStart:m}}=d;if(p==="[")l++;else if(l)p==="]"&&l--;else if(p===n&&!h)i=g,h=!0;else if(h&&m)u++;else if(k)h?u++:(a++,s.push(a+o));else if(p===")"&&h){if(!u){o++,t=`${t.slice(0,i)}${r}${t.slice(i+n.length,g)}))<$$${o+a}>)${t.slice(g+1)}`,c=!0;break}u--}}}while(c);return t=We(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:l,groups:{backrefNum:u,wrappedBackrefNum:h}})=>{if(u){const d=+u;if(d>s.length-1)throw new Error(`Backref "${l}" greater than number of captures`);return`\\${s[d]}`}return`\\${h}`},B.DEFAULT),t}const Un=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,nt=new RegExp(String.raw`
12
+ \\(?: \d+
13
+ | c[A-Za-z]
14
+ | [gk]<[^>]+>
15
+ | [pPu]\{[^\}]+\}
16
+ | u[A-Fa-f\d]{4}
17
+ | x[A-Fa-f\d]{2}
18
+ )
19
+ | \((?: \? (?: [:=!>]
20
+ | <(?:[=!]|[^>]+>)
21
+ | [A-Za-z\-]+:
22
+ | \(DEFINE\)
23
+ ))?
24
+ | (?<qBase>${Un})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
25
+ | \\?.
26
+ `.replace(/\s+/g,""),"gsu");function Fa(t){if(!new RegExp(`${Un}\\+`).test(t))return t;const e=[];let n=null,r=null,s="",a=0,o;for(nt.lastIndex=0;o=nt.exec(t);){const{0:i,index:c,groups:{qBase:l,qMod:u,invalidQ:h}}=o;if(i==="[")a||(r=c),a++;else if(i==="]")a?a--:r=null;else if(!a)if(u==="+"&&s&&!s.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${i}"`);let d=-1;if(/^\{\d+\}$/.test(l))t=Ba(t,c+l.length,u,"");else{if(s===")"||s==="]"){const p=s===")"?n:r;if(p===null)throw new Error(`Invalid unmatched "${s}"`);t=`${t.slice(0,p)}(?>${t.slice(p,c)}${l})${t.slice(c+i.length)}`}else t=`${t.slice(0,c-s.length)}(?>${s}${l})${t.slice(c+i.length)}`;d+=4}nt.lastIndex+=d}else i[0]==="("?e.push(c):i===")"&&(n=e.length?e.pop():null);s=i}return t}const G=String.raw,ja=G`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,yt=G`\(\?R=(?<rDepth>[^\)]+)\)|${ja}`,Ue=G`\(\?<(?![=!])(?<captureName>[^>]+)>`,X=new RegExp(G`${Ue}|${yt}|\(\?|\\?.`,"gsu"),rt="Cannot use multiple overlapping recursions",_t=new RegExp(G`(?:\$[1-9]\d*)?${te.replace(/\$/g,G`\$`)}`,"y");function Da(t,e){if(!new RegExp(yt,"su").test(t))return t;if(xe(t,G`\(\?\(DEFINE\)`,B.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const n=!!e?.useEmulationGroups,r=xe(t,G`\\[1-9]`,B.DEFAULT),s=new Map,a=[];let o=!1,i=0,c=0,l;for(X.lastIndex=0;l=X.exec(t);){const{0:u,groups:{captureName:h,rDepth:d,gRNameOrNum:p,gRDepth:g}}=l;if(u==="[")i++;else if(i)u==="]"&&i--;else if(d){if(nn(d),o)throw new Error(rt);if(r)throw new Error("Numbered backrefs cannot be used with global recursion");const k=t.slice(0,l.index),m=t.slice(X.lastIndex);if(xe(m,yt,B.DEFAULT))throw new Error(rt);return rn(k,m,+d,!1,n)}else if(p){nn(g);let k=!1;for(const L of a)if(L.name===p||L.num===+p){if(k=!0,L.hasRecursedWithin)throw new Error(rt);break}if(!k)throw new Error(G`Recursive \g cannot be used outside the referenced group "\g<${p}&R=${g}>"`);const m=s.get(p),C=La(t,m);if(r&&xe(C,G`${Ue}|\((?!\?)`,B.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion of capturing groups");const b=t.slice(m,l.index),w=C.slice(b.length+u.length),I=rn(b,w,+g,!0,n),v=t.slice(0,m),j=t.slice(m+C.length);t=`${v}${I}${j}`,X.lastIndex+=I.length-u.length-b.length-w.length,a.forEach(L=>L.hasRecursedWithin=!0),o=!0}else if(h)c++,s.set(String(c),X.lastIndex),s.set(h,X.lastIndex),a.push({num:c,name:h});else if(u.startsWith("(")){const k=u==="(";k&&(c++,s.set(String(c),X.lastIndex+(n?Wa(t,X.lastIndex):0))),a.push(k?{num:c}:{})}else u===")"&&a.pop()}return t}function nn(t){const e=`Max depth must be integer between 2 and 100; used ${t}`;if(!/^[1-9]\d*$/.test(t))throw new Error(e);if(t=+t,t<2||t>100)throw new Error(e)}function rn(t,e,n,r,s){const a=new Set;r&&Pa(t+e,Ue,({groups:{captureName:i}})=>{a.add(i)},B.DEFAULT);const o=n-1;return`${t}${sn(`(?:${t}`,o,r?a:null,"forward",s)}(?:)${sn(`${e})`,o,r?a:null,"backward",s)}${e}`}function sn(t,e,n,r,s){const a=i=>r==="backward"?e-i+2-1:i+2;let o="";for(let i=0;i<e;i++){const c=a(i);o+=We(t,G`${Ue}|\\k<(?<backref>[^>]+)>${s?G`|(?<unnamed>\()(?!\?)(?:${_t.source})?`:""}`,({0:l,index:u,groups:{captureName:h,backref:d,unnamed:p}})=>{if(d&&n&&!n.has(d))return l;if(p)return`(${te}`;const g=`_$${c}`;return h?`(?<${h}${g}>${s?te:""}`:G`\k<${d}${g}>`},B.DEFAULT)}return o}function Wa(t,e){_t.lastIndex=e;const n=_t.exec(t);return n?n[0].length:0}var E=String.fromCodePoint,_=String.raw,Ua=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),qa=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function Me(t,{enable:e,disable:n}){return{dotAll:!n?.dotAll&&!!(e?.dotAll||t.dotAll),ignoreCase:!n?.ignoreCase&&!!(e?.ignoreCase||t.ignoreCase)}}function Be(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}function kt(t,e){return an[t]>=an[e]}function Q(t,e){if(!t)throw new Error(e??"Value expected");return t}var an={ES2025:2025,ES2024:2024,ES2018:2018},Ha={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function qn(t){if(t?.target!==void 0&&!Ha[t.target])throw new Error(`Unexpected target "${t.target}"`);const e={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,target:"auto",verbose:!1,...t,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...t?.rules}};return e.target==="auto"&&(e.target=Ua?"ES2025":qa?"ES2024":"ES2018"),e}var za=new Set([E(304),E(305)]);function Hn(t){if(za.has(t))return[t];const e=new Set,n=t.toLowerCase(),r=n.toUpperCase(),s=Za.get(n),a=Qa.get(n),o=Xa.get(n);return[...r].length===1&&e.add(r),o&&e.add(o),s&&e.add(s),e.add(n),a&&e.add(a),[...e]}var zn=new Set(`C Other
27
+ Cc Control cntrl
28
+ Cf Format
29
+ Cn Unassigned
30
+ Co Private_Use
31
+ Cs Surrogate
32
+ L Letter
33
+ LC Cased_Letter
34
+ Ll Lowercase_Letter
35
+ Lm Modifier_Letter
36
+ Lo Other_Letter
37
+ Lt Titlecase_Letter
38
+ Lu Uppercase_Letter
39
+ M Mark Combining_Mark
40
+ Mc Spacing_Mark
41
+ Me Enclosing_Mark
42
+ Mn Nonspacing_Mark
43
+ N Number
44
+ Nd Decimal_Number digit
45
+ Nl Letter_Number
46
+ No Other_Number
47
+ P Punctuation punct
48
+ Pc Connector_Punctuation
49
+ Pd Dash_Punctuation
50
+ Pe Close_Punctuation
51
+ Pf Final_Punctuation
52
+ Pi Initial_Punctuation
53
+ Po Other_Punctuation
54
+ Ps Open_Punctuation
55
+ S Symbol
56
+ Sc Currency_Symbol
57
+ Sk Modifier_Symbol
58
+ Sm Math_Symbol
59
+ So Other_Symbol
60
+ Z Separator
61
+ Zl Line_Separator
62
+ Zp Paragraph_Separator
63
+ Zs Space_Separator
64
+ ASCII
65
+ ASCII_Hex_Digit AHex
66
+ Alphabetic Alpha
67
+ Any
68
+ Assigned
69
+ Bidi_Control Bidi_C
70
+ Bidi_Mirrored Bidi_M
71
+ Case_Ignorable CI
72
+ Cased
73
+ Changes_When_Casefolded CWCF
74
+ Changes_When_Casemapped CWCM
75
+ Changes_When_Lowercased CWL
76
+ Changes_When_NFKC_Casefolded CWKCF
77
+ Changes_When_Titlecased CWT
78
+ Changes_When_Uppercased CWU
79
+ Dash
80
+ Default_Ignorable_Code_Point DI
81
+ Deprecated Dep
82
+ Diacritic Dia
83
+ Emoji
84
+ Emoji_Component EComp
85
+ Emoji_Modifier EMod
86
+ Emoji_Modifier_Base EBase
87
+ Emoji_Presentation EPres
88
+ Extended_Pictographic ExtPict
89
+ Extender Ext
90
+ Grapheme_Base Gr_Base
91
+ Grapheme_Extend Gr_Ext
92
+ Hex_Digit Hex
93
+ IDS_Binary_Operator IDSB
94
+ IDS_Trinary_Operator IDST
95
+ ID_Continue IDC
96
+ ID_Start IDS
97
+ Ideographic Ideo
98
+ Join_Control Join_C
99
+ Logical_Order_Exception LOE
100
+ Lowercase Lower
101
+ Math
102
+ Noncharacter_Code_Point NChar
103
+ Pattern_Syntax Pat_Syn
104
+ Pattern_White_Space Pat_WS
105
+ Quotation_Mark QMark
106
+ Radical
107
+ Regional_Indicator RI
108
+ Sentence_Terminal STerm
109
+ Soft_Dotted SD
110
+ Terminal_Punctuation Term
111
+ Unified_Ideograph UIdeo
112
+ Uppercase Upper
113
+ Variation_Selector VS
114
+ White_Space space
115
+ XID_Continue XIDC
116
+ XID_Start XIDS`.split(/\s/)),Vn=new Map;for(const t of zn)Vn.set(qe(t),t);var Va=new Set(["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji","RGI_Emoji_Flag_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence"]),Qn=new Map;for(const t of Va)Qn.set(qe(t),t);var Qa=new Map([["s",E(383)],[E(383),"s"]]),Xa=new Map([[E(223),E(7838)],[E(107),E(8490)],[E(229),E(8491)],[E(969),E(8486)]]),Za=new Map([Z(453),Z(456),Z(459),Z(498),...st(8072,8079),...st(8088,8095),...st(8104,8111),Z(8124),Z(8140),Z(8188)]),Xn=new Map([["alnum",_`[\p{Alpha}\p{Nd}]`],["alpha",_`\p{Alpha}`],["ascii",_`\p{ASCII}`],["blank",_`[\p{Zs}\t]`],["cntrl",_`\p{cntrl}`],["digit",_`\p{Nd}`],["graph",_`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",_`\p{Lower}`],["print",_`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",_`[\p{P}\p{S}]`],["space",_`\p{space}`],["upper",_`\p{Upper}`],["word",_`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",_`\p{AHex}`]]),Ka=new Set(["alnum","blank","graph","print","word","xdigit"]);function Ya(t,e){const n=[];for(let r=t;r<=e;r++)n.push(r);return n}function qe(t){return t.replace(/[- _]+/g,"").toLowerCase()}function Z(t){const e=E(t);return[e.toLowerCase(),e]}function st(t,e){return Ya(t,e).map(n=>Z(n))}var Zn=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]),y={Alternator:"Alternator",Assertion:"Assertion",Backreference:"Backreference",Character:"Character",CharacterClassClose:"CharacterClassClose",CharacterClassHyphen:"CharacterClassHyphen",CharacterClassIntersector:"CharacterClassIntersector",CharacterClassOpen:"CharacterClassOpen",CharacterSet:"CharacterSet",Directive:"Directive",GroupClose:"GroupClose",GroupOpen:"GroupOpen",Subroutine:"Subroutine",Quantifier:"Quantifier",VariableLengthCharacterSet:"VariableLengthCharacterSet",EscapedNumber:"EscapedNumber"},$={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},He={flags:"flags",keep:"keep"},P={absent_repeater:"absent_repeater",atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},on=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),Kn=_`\[\^?`,Yn=`c.? | C(?:-.?)?|${_`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${_`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${_`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${_`o\{[^\}]*\}?`}|${_`\d{1,3}`}`,Jn=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ve=new RegExp(_`
117
+ \\ (?:
118
+ ${Yn}
119
+ | [gk]<[^>]*>?
120
+ | [gk]'[^']*'?
121
+ | .
122
+ )
123
+ | \( (?: \? (?:
124
+ [:=!>(]
125
+ | <[=!]
126
+ | <[^>]*>
127
+ | '[^']*'
128
+ | ~\|?
129
+ | # (?:[^)\\] | \\.?)*
130
+ | [imx\-]+[:)]
131
+ )?)?
132
+ | ${Jn.source}
133
+ | ${Kn}
134
+ | .
135
+ `.replace(/\s+/g,""),"gsu"),at=new RegExp(_`
136
+ \\ (?:
137
+ ${Yn}
138
+ | .
139
+ )
140
+ | \[:[^:]*:\]
141
+ | ${Kn}
142
+ | &&
143
+ | .
144
+ `.replace(/\s+/g,""),"gsu");function er(t,e="",n){if(n={captureGroup:!1,singleline:!1,...n},typeof t!="string")throw new Error("String expected as pattern");if(!/^[imxDSW]*$/.test(e))throw new Error(`Flags "${e}" includes unsupported value`);const r=e.includes("x"),s=[r],a={captureGroup:n.captureGroup,getCurrentModX:()=>s.at(-1),numOpenGroups:0,popModX(){s.pop()},pushModX(h){s.push(h)},replaceCurrentModX(h){s[s.length-1]=h},singleline:n.singleline};let o=[],i;for(ve.lastIndex=0;i=ve.exec(t);){const h=Ja(a,t,i[0],ve.lastIndex);h.tokens?o.push(...h.tokens):h.token&&o.push(h.token),h.lastIndex!==void 0&&(ve.lastIndex=h.lastIndex)}const c=[];let l=0;o.forEach(h=>{h.type===y.GroupOpen&&(h.kind===P.capturing?h.number=++l:h.raw==="("&&c.push(h))}),l||c.forEach((h,d)=>{h.kind=P.capturing,h.number=d+1});const u=l||c.length;return o=o.map(h=>h.type===y.EscapedNumber?co(h,u):h).flat(),{tokens:o,flags:{ignoreCase:e.includes("i"),dotAll:e.includes("m"),extended:r,digitIsAscii:e.includes("D"),spaceIsAscii:e.includes("S"),wordIsAscii:e.includes("W")},rules:n}}function Ja(t,e,n,r){const[s,a,o]=n;if(s==="["){const i=eo(e,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(s==="\\"){if("AbBGzZ".includes(a))return{token:S(y.Assertion,n,{kind:n})};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:S(y.Subroutine,n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:S(y.Backreference,n)}}if(a==="K")return{token:S(y.Directive,n,{kind:He.keep})};if(a==="N")return{token:S(y.CharacterSet,n,{kind:$.non_newline})};if(a==="O")return{token:S(y.CharacterSet,n,{kind:$.any})};if("RX".includes(a))return{token:S(y.VariableLengthCharacterSet,n,{kind:n})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${n}"`);const i=tr(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(s==="("){if(o==="#"){if(e[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if("-imx".includes(o))return{token:ro(n,t)};if(t.pushModX(t.getCurrentModX()),t.numOpenGroups++,n==="("&&!t.captureGroup||n==="(?:")return{token:S(y.GroupOpen,n,{kind:P.group})};if(n==="(?>")return{token:S(y.GroupOpen,n,{kind:P.atomic})};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:S(y.GroupOpen,n,{kind:o==="<"?P.lookbehind:P.lookahead,negate:n.endsWith("!")})};if(o==="<"||o==="'"||n==="("&&t.captureGroup){const i=S(y.GroupOpen,n,{kind:P.capturing});return n!=="("&&(i.name=n.slice(3,-1)),{token:i}}if(o==="~"){if(n==="(?~|")throw new Error(`Unsupported absent function kind "${n}"`);return{token:S(y.GroupOpen,n,{kind:P.absent_repeater})}}throw o==="("?new Error(`Unsupported conditional "${n}"`):n==="(?"?new Error("Invalid group"):new Error(`Unexpected group "${n}"`)}if(n===")"){if(t.popModX(),t.numOpenGroups--,t.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:S(y.GroupClose,n)}}if(n==="#"&&t.getCurrentModX()){const i=e.indexOf(`
145
+ `,r);return{lastIndex:i===-1?e.length:i}}if(/^\s$/.test(n)&&t.getCurrentModX()){const i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(e)?i.lastIndex:r}}if(n===".")return{token:S(y.CharacterSet,n,{kind:$.dot})};if(n==="^"||n==="$"){const i=t.singleline?{"^":_`\A`,$:_`\Z`}[n]:n;return{token:S(y.Assertion,n,{kind:i})}}return n==="|"?{token:S(y.Alternator,n)}:Jn.test(n)?{token:so(n)}:(nr(n),{token:S(y.Character,n,{value:n.codePointAt(0)})})}function eo(t,e,n){const r=[S(y.CharacterClassOpen,e,{negate:e[1]==="^"})];let s=1,a;for(at.lastIndex=n;a=at.exec(t);){const o=a[0];if(o[0]==="["&&o[1]!==":")s++,r.push(S(y.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(r.at(-1).type===y.CharacterClassOpen)r.push(S(y.Character,o,{value:93}));else if(s--,r.push(S(y.CharacterClassClose,o)),!s)break}else{const i=to(o);Array.isArray(i)?r.push(...i):r.push(i)}}return{tokens:r,lastIndex:at.lastIndex||t.length}}function to(t){if(t[0]==="\\")return tr(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!Xn.get(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return S(y.CharacterSet,t,{kind:$.posix,negate:!!e.groups.negate,value:e.groups.name})}return t==="-"?S(y.CharacterClassHyphen,t):t==="&&"?S(y.CharacterClassIntersector,t):(nr(t),S(y.Character,t,{value:t.codePointAt(0)}))}function tr(t,{inCharClass:e}){const n=t[1];if(n==="c"||n==="C")return no(t);if("dDhHsSwW".includes(n))return ao(t);if(t.startsWith(_`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return oo(t)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(t))try{const r=t.split(/\\x/).slice(1).map(o=>parseInt(o,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),a=new TextEncoder;return[...s].map(o=>{const i=[...a.encode(o)].map(c=>`\\x${c.toString(16)}`).join("");return S(y.Character,i,{value:o.codePointAt(0)})})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return S(y.Character,t,{value:io(t)});if(on.has(n))return S(y.Character,t,{value:on.get(n)});if(/\d/.test(n))return S(y.EscapedNumber,t,{inCharClass:e});if(t==="\\")throw new Error(_`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return S(y.Character,t,{value:t.codePointAt(1)});throw new Error(`Unexpected escape "${t}"`)}function S(t,e,n){return{type:t,raw:e,...n}}function no(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return S(y.Character,t,{value:e.toUpperCase().codePointAt(0)-64})}function ro(t,e){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(t).groups;r??="";const s=(e.getCurrentModX()||n.includes("x"))&&!r.includes("x"),a=cn(n),o=cn(r),i={};if(a&&(i.enable=a),o&&(i.disable=o),t.endsWith(")"))return e.replaceCurrentModX(s),S(y.Directive,t,{kind:He.flags,flags:i});if(t.endsWith(":")){e.pushModX(s),e.numOpenGroups++;const c=S(y.GroupOpen,t,{kind:P.group});return(a||o)&&(c.flags=i),c}throw new Error(`Unexpected flag modifier "${t}"`)}function so(t){const e={};if(t[0]==="{"){const{min:n,max:r}=/^\{(?<min>\d*)(?:,(?<max>\d*))?/.exec(t).groups,s=1e5;if(+n>s||+r>s)throw new Error("Quantifier value unsupported in Oniguruma");e.min=+n,e.max=r===void 0?+n:r===""?1/0:+r,e.greedy=!t.endsWith("?"),e.possessive=!1}else e.min=t[0]==="+"?1:0,e.max=t[0]==="?"?1:1/0,e.greedy=t[1]!=="?",e.possessive=t[1]==="+";return S(y.Quantifier,t,e)}function ao(t){const e=t[1].toLowerCase();return S(y.CharacterSet,t,{kind:{d:$.digit,h:$.hex,s:$.space,w:$.word}[e],negate:t[1]!==e})}function oo(t){const{p:e,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups,s=e==="P"&&!n||e==="p"&&!!n;return S(y.CharacterSet,t,{kind:$.property,negate:s,value:r})}function cn(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function io(t){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function co(t,e){const{raw:n,inCharClass:r}=t,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[S(y.Backreference,n)];const a=[],o=s.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){const c=o[i];let l;if(i===0&&c!=="8"&&c!=="9"){if(l=parseInt(c,8),l>127)throw new Error(_`Octal encoded byte above 177 unsupported "${n}"`)}else l=c.codePointAt(0);a.push(S(y.Character,(i===0?"\\":"")+c,{value:l}))}return a}function nr(t){if([...t].length!==1)throw new Error(`Expected "${t}" to be a single code point`)}function $t({alternatives:t},e){return t.length===1&&t[0].elements.length===1&&(!e||e(t[0].elements[0]))}function lo({type:t}){return t===f.Assertion||t===f.Directive}function uo(t){const e=[f.Character,f.CharacterClass,f.CharacterSet];return e.includes(t.type)||t.type===f.Quantifier&&t.min&&e.includes(t.element.type)}function rr({type:t}){return t===f.CapturingGroup||t===f.Group}function Ce({type:t,kind:e}){return t===f.Assertion&&(e===A.lookahead||e===A.lookbehind)}function oe(t,e,n){let r=t.node;for(;r.parent;)r=r.parent;function s(o,i){for(let c=0;c<o.length;c++){const l=a(o[c],i,c,o);c=Math.max(-1,c+l)}}function a(o,i=null,c=null,l=null){let u=0,h=!1;const d={node:o,parent:i,key:c,container:l,ast:r,remove(){Q(l,"Container expected").splice(Math.max(0,c+u),1),u-=1},removeAllNextSiblings(){return Q(l,"Container expected").splice(c+1)},removeAllPrevSiblings(){const C=c+u;return u-=C,Q(l,"Container expected").splice(0,Math.max(0,C))},replaceWith(C){po(C,i),l?l[Math.max(0,c+u)]=C:i[c]=C},skip(){h=!0}},p=ho(o).find(C=>!!n[C]),g=p&&n[p],k=typeof g=="function"?g:g?.enter,m=g?.exit;if(k?.(d,e),!h)switch(o.type){case f.Regex:a(o.pattern,o,"pattern"),a(o.flags,o,"flags");break;case f.Alternative:case f.CharacterClass:s(o.elements,o);break;case f.Assertion:Ce(o)&&s(o.alternatives,o);break;case f.Backreference:case f.Character:case f.CharacterSet:case f.Directive:case f.Flags:case f.Recursion:case f.Subroutine:case f.VariableLengthCharacterSet:break;case f.AbsentFunction:case f.CapturingGroup:case f.Group:case f.Pattern:s(o.alternatives,o);break;case f.CharacterClassIntersection:s(o.classes,o);break;case f.CharacterClassRange:a(o.min,o,"min"),a(o.max,o,"max");break;case f.Quantifier:a(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return m?.(d,e),u}a(t.node,t.parent,t.key,t.container)}var ln={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function ho(t){const e=[ln.AnyNode];return(rr(t)||Ce(t))&&e.push(ln.AnyGroup),e.push(t.type),e}function po(t,e){"parent"in e&&(t.parent=e)}var f={AbsentFunction:"AbsentFunction",Alternative:"Alternative",Assertion:"Assertion",Backreference:"Backreference",CapturingGroup:"CapturingGroup",Character:"Character",CharacterClass:"CharacterClass",CharacterClassIntersection:"CharacterClassIntersection",CharacterClassRange:"CharacterClassRange",CharacterSet:"CharacterSet",Directive:"Directive",Flags:"Flags",Group:"Group",Pattern:"Pattern",Quantifier:"Quantifier",Regex:"Regex",Subroutine:"Subroutine",VariableLengthCharacterSet:"VariableLengthCharacterSet",Recursion:"Recursion"},go={repeater:"repeater"},A={line_end:"line_end",line_start:"line_start",lookahead:"lookahead",lookbehind:"lookbehind",search_start:"search_start",string_end:"string_end",string_end_newline:"string_end_newline",string_start:"string_start",word_boundary:"word_boundary"},x=$,$e=He,Oe={grapheme:"grapheme",newline:"newline"};function sr({tokens:t,flags:e,rules:n},r){const s={skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...r},a={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:s.skipBackrefValidation,skipLookbehindValidation:s.skipLookbehindValidation,skipPropertyNameValidation:s.skipPropertyNameValidation,subroutines:[],token:null,tokens:t,verbose:s.verbose,walk:o};function o(p,g){const k=t[a.current];switch(a.parent=p,a.token=k,a.current++,k.type){case y.Alternator:return K();case y.Assertion:return So(k);case y.Backreference:return fo(a);case y.Character:return ir(k.value,{useLastValid:!!g.isCheckingRangeEnd});case y.CharacterClassHyphen:return mo(a,g);case y.CharacterClassOpen:return bo(a,g);case y.CharacterSet:return yo(a);case y.Directive:return Eo(k);case y.GroupOpen:return _o(a,g);case y.Quantifier:return ko(a);case y.Subroutine:return Co(a);case y.VariableLengthCharacterSet:return Po(k.kind);default:throw new Error(`Unexpected token type "${k.type}"`)}}const i=$o(Io(),No(e));let c=i.pattern.alternatives[0];for(;a.current<t.length;){const p=o(c,{});p.type===f.Alternative?(i.pattern.alternatives.push(p),c=p):c.elements.push(p)}const{capturingGroups:l,hasNumberedRef:u,namedGroupsByName:h,subroutines:d}=a;if(u&&h.size&&!n.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:p}of d)if(typeof p=="number"){if(p>l.length)throw new Error("Subroutine uses a group number that's not defined")}else if(h.has(p)){if(h.get(p).length>1)throw new Error(_`Subroutine uses a duplicate group name "\g<${p}>"`)}else throw new Error(_`Subroutine uses a group name that's not defined "\g<${p}>"`);return oe({node:i},null,{AnyNode({node:p,parent:g}){p.parent=g}}),i}function fo(t){const{raw:e}=t.token,n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(a,o=!1)=>{const i=t.capturingGroups.length;let c=!1;if(a>i)if(t.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Ct(o?i+1-a:a,{orphan:c})};if(n){const a=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(a)return s(+a.groups.num,!!a.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Ct(r)}return s(+r)}function mo(t,e){const{parent:n,tokens:r,walk:s}=t,a=n.elements.at(-1),o=r[t.current];if(!e.isCheckingRangeEnd&&a&&a.type!==f.CharacterClass&&a.type!==f.CharacterClassRange&&o&&o.type!==y.CharacterClassOpen&&o.type!==y.CharacterClassClose&&o.type!==y.CharacterClassIntersector){const i=s(n,{...e,isCheckingRangeEnd:!0});if(a.type===f.Character&&i.type===f.Character)return n.elements.pop(),vo(a,i);throw new Error("Invalid character class range")}return ir(45)}function bo(t,e){const{token:n,tokens:r,verbose:s,walk:a}=t,o=r[t.current];let i=wt({negate:n.negate});const c=i.elements[0];let l=un(o);for(;l.type!==y.CharacterClassClose;){if(l.type===y.CharacterClassIntersector)c.classes.push(wt({negate:!1,baseOnly:!0})),t.current++;else{const u=c.classes.at(-1);u.elements.push(a(u,e))}l=un(r[t.current],o)}if(s||Mo(c),c.classes.length===1){const u=c.classes[0];u.negate=i.negate!==u.negate,i=u}return t.current++,i}function yo({token:t,skipPropertyNameValidation:e}){let{kind:n,negate:r,value:s}=t;if(n===$.property){const a=qe(s);if(Ka.has(a))n=$.posix,s=a;else return re(s,{negate:r,skipPropertyNameValidation:e})}return n===$.posix?{type:f.CharacterSet,kind:x.posix,negate:r,value:s}:St(n,{negate:r})}function _o(t,e){const{token:n,tokens:r,capturingGroups:s,namedGroupsByName:a,skipLookbehindValidation:o,verbose:i,walk:c}=t;let l=Ao(n);const u=l.type===f.AbsentFunction,h=l.kind===A.lookbehind,d=h&&l.negate;if(l.type===f.CapturingGroup&&(s.push(l),l.name&&Be(a,l.name,[]).push(l)),u&&e.isInAbsentFunction)throw new Error("Nested absent function not supported by Oniguruma");let p=hn(r[t.current]);for(;p.type!==y.GroupClose;){if(p.type===y.Alternator)l.alternatives.push(K()),t.current++;else{const g=l.alternatives.at(-1),k=c(g,{...e,isInAbsentFunction:e.isInAbsentFunction||u,isInLookbehind:e.isInLookbehind||h,isInNegLookbehind:e.isInNegLookbehind||d});if(g.elements.push(k),(h||e.isInLookbehind)&&!o){const m="Lookbehind includes a pattern not allowed by Oniguruma";if(d||e.isInNegLookbehind){if(k.kind===A.lookahead||k.type===f.CapturingGroup)throw new Error(m)}else if(k.kind===A.lookahead||k.kind===A.lookbehind&&k.negate)throw new Error(m)}}p=hn(r[t.current])}return i||(l=Lo(l)),t.current++,l}function ko({token:t,parent:e}){const{min:n,max:r,greedy:s,possessive:a}=t,o=e.elements.at(-1);if(!o||o.type===f.Assertion||o.type===f.Directive)throw new Error("Quantifier requires a repeatable token");const i=cr(o,n,r,s,a);return e.elements.pop(),i}function Co(t){const{token:e,capturingGroups:n,subroutines:r}=t;let s=e.raw.slice(3,-1);const a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(a){const i=+a.groups.num,c=n.length;if(t.hasNumberedRef=!0,s={"":i,"+":c+i,"-":c+1-i}[a.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const o=Ro(s);return r.push(o),o}function wo(t){return{type:f.AbsentFunction,kind:t,alternatives:[K()]}}function K(){return{type:f.Alternative,elements:[]}}function ar(t,e){const n=!!e?.negate;return{type:f.Assertion,kind:t,...t===A.word_boundary&&{negate:n}}}function So({kind:t}){return ar(Q({"^":A.line_start,$:A.line_end,"\\A":A.string_start,"\\b":A.word_boundary,"\\B":A.word_boundary,"\\G":A.search_start,"\\z":A.string_end,"\\Z":A.string_end_newline}[t],`Unexpected assertion kind "${t}"`),{negate:t===_`\B`})}function Ct(t,e){const n=!!e?.orphan;return{type:f.Backreference,...n&&{orphan:n},ref:t}}function Ao({flags:t,kind:e,name:n,negate:r,number:s}){switch(e){case P.absent_repeater:return wo(go.repeater);case P.atomic:return W({atomic:!0});case P.capturing:return or(s,n);case P.group:return W({flags:t});case P.lookahead:case P.lookbehind:return pe({behind:e===P.lookbehind,negate:r});default:throw new Error(`Unexpected group kind "${e}"`)}}function or(t,e){const n=e!==void 0;if(n&&!Go(e))throw new Error(`Group name "${e}" invalid in Oniguruma`);return{type:f.CapturingGroup,number:t,...n&&{name:e},alternatives:[K()]}}function ir(t,e){const n={useLastValid:!1,...e};if(t>1114111){const r=t.toString(16);if(n.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:f.Character,value:t}}function wt(t){const e={baseOnly:!1,negate:!1,...t};return{type:f.CharacterClass,negate:e.negate,elements:e.baseOnly?[]:[xo()]}}function xo(){return{type:f.CharacterClassIntersection,classes:[wt({negate:!1,baseOnly:!0})]}}function vo(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:f.CharacterClassRange,min:t,max:e}}function St(t,{negate:e}){const n={type:f.CharacterSet,kind:Q(x[t],`Unexpected character set kind "${t}"`)};return(t===$.digit||t===$.hex||t===$.space||t===$.word)&&(n.negate=e),n}function Eo({kind:t,flags:e}){const n={type:f.Directive,kind:Q($e[t],`Unexpected directive kind "${t}"`)};return t===He.flags&&(n.flags=e),n}function No({ignoreCase:t,dotAll:e,extended:n,digitIsAscii:r,spaceIsAscii:s,wordIsAscii:a}){return{type:f.Flags,ignoreCase:t,dotAll:e,extended:n,digitIsAscii:r,spaceIsAscii:s,wordIsAscii:a}}function W(t){const e=t?.atomic,n=t?.flags;return{type:f.Group,...e&&{atomic:e},...n&&{flags:n},alternatives:[K()]}}function pe(t){const e={behind:!1,negate:!1,...t};return{type:f.Assertion,kind:e.behind?A.lookbehind:A.lookahead,negate:e.negate,alternatives:[K()]}}function Io(){return{type:f.Pattern,alternatives:[K()]}}function cr(t,e,n,r=!0,s=!1){const a={type:f.Quantifier,min:e,max:n,greedy:r,possessive:s,element:t};return n<e?{...a,min:n,max:e,possessive:!0}:a}function $o(t,e){return{type:f.Regex,pattern:t,flags:e}}function Ro(t){return{type:f.Subroutine,ref:t}}function re(t,e){const n={negate:!1,skipPropertyNameValidation:!1,...e};return{type:f.CharacterSet,kind:x.property,value:n.skipPropertyNameValidation?t:To(t),negate:n.negate}}function Po(t){return{type:f.VariableLengthCharacterSet,kind:Q({"\\R":Oe.newline,"\\X":Oe.grapheme}[t],`Unexpected varcharset kind "${t}"`)}}function To(t){const e=qe(t);if(Qn.has(e))throw new Error(_`Unicode property "\p{${t}}" unsupported in Oniguruma`);return Vn.get(e)||t.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 Lo(t){const e=t.alternatives[0].elements[0];return t.type===f.Group&&$t(t,n=>n.type===f.Group)&&!(t.atomic&&e.flags)&&!(t.flags&&(e.atomic||e.flags))?(t.atomic?e.atomic=!0:t.flags&&(e.flags=t.flags),e):t}function Go(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function Mo(t){for(let e=0;e<t.classes.length;e++){const n=t.classes[e],r=n.elements[0];n.elements.length===1&&r.type===f.CharacterClass&&(t.classes[e]=r,r.negate=n.negate!==r.negate)}}function un(t,e){return Q(t,`${e?.value===93?"Empty":"Unclosed"} character class`)}function hn(t){return Q(t,"Unclosed group")}function Bo(t,e){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e},r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:kt(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};oe({node:t},r,lr);const s={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},a={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};oe({node:t},a,ur);const o={groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer};return oe({node:t},o,Oo),t._strategy=r.strategy,t}var lr={AbsentFunction({node:t,replaceWith:e}){const n=H(W(),[me(pe({negate:!0}),t.alternatives),re("Any")]),r=cr(n,0,1/0);n.parent=r,e(H(W(),[r]))},Alternative:{enter({node:t,parent:e,key:n},{flagDirectivesByAlt:r}){const s=t.elements.filter(a=>a.kind===$e.flags);for(let a=n+1;a<e.alternatives.length;a++){const o=e.alternatives[a];Be(r,o,[]).push(...s)}},exit({node:t},{flagDirectivesByAlt:e}){if(e.get(t)?.length){const n=pr(e.get(t));if(n){const r=H(W({flags:n}),t.elements);r.parent=t,t.elements=[r]}}}},Assertion({node:t,key:e,container:n,ast:r,remove:s,replaceWith:a},o){const{kind:i,negate:c}=t,{asciiWordBoundaries:l,avoidSubclass:u,supportedGNodes:h,wordIsAscii:d}=o;if(i===A.line_end)a(O(_`(?=\z|\n)`));else if(i===A.line_start)a(O(_`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}));else if(i===A.lookbehind)o.passedLookbehind=!0;else if(i===A.search_start)if(h.has(t))r.flags.sticky=!0,s();else{const p=n[e-1];if(p&&uo(p))a(H(pe({negate:!0})));else{if(u)throw new Error(_`Uses "\G" in a way that requires a subclass`);a(ar(A.string_start)),o.strategy="search_start_clip"}}else if(i===A.string_end_newline)a(O(_`(?=\n?\z)`));else if(i===A.word_boundary&&!d&&!l){const p=`(?:(?<=${q})(?!${q})|(?<!${q})(?=${q}))`,g=`(?:(?<=${q})(?=${q})|(?<!${q})(?!${q}))`;a(O(c?g:p))}},Backreference({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!it(n)&&(n=ot(n,e),t.ref=n)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:n}){let{name:r}=t;r&&!it(r)&&(r=ot(r,e),t.name=r),n.set(t.number,t),r&&n.set(r,t)},CharacterSet({node:t,replaceWith:e},{accuracy:n,minTargetEs2024:r,digitIsAscii:s,spaceIsAscii:a,wordIsAscii:o}){const{kind:i,negate:c,value:l}=t;if(s&&(i===x.digit||l==="digit")){e(St(x.digit,{negate:c}));return}if(a&&(i===x.space||l==="space")){e(ct(O(Fo),c));return}if(o&&(i===x.word||l==="word")){e(St(x.word,{negate:c}));return}if(i===x.any)e(re("Any"));else if(i===x.digit)e(re("Nd",{negate:c}));else if(i===x.hex)e(re("AHex",{negate:c}));else if(i===x.non_newline)e(O(_`[^\n]`));else if(i===x.space)e(re("space",{negate:c}));else if(i===x.word)e(ct(O(q),c));else if(i===x.property)zn.has(l)||(t.key="sc");else if(i===x.posix)if(!r&&(l==="graph"||l==="print")){if(n==="strict")throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);let u={graph:"!-~",print:" -~"}[l];c&&(u=`\0-${E(u.codePointAt(0)-1)}${E(u.codePointAt(2)+1)}-􏿿`),e(O(`[${u}]`))}else e(ct(O(Xn.get(l)),c))},Directive(t,e){const{node:n,parent:r,ast:s,remove:a,replaceWith:o,removeAllPrevSiblings:i,removeAllNextSiblings:c}=t,{kind:l,flags:u}=n;if(l===$e.flags)if(!u.enable&&!u.disable)a();else{const h=H(W({flags:u}),c());o(h),mr(h,t,e,lr)}else if(l===$e.keep){const h=s.pattern.alternatives[0].elements[0],d=$t(s.pattern,p=>p.type===f.Group)&&h.alternatives.length===1?h:s.pattern;if(r.parent!==d||d.alternatives.length>1)throw new Error(_`Uses "\K" in a way that's unsupported`);o(H(pe({behind:!0}),i()))}},Flags({node:t,parent:e}){["digitIsAscii","extended","spaceIsAscii","wordIsAscii"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},Pattern:{enter({node:t},{supportedGNodes:e}){const n=[];let r=!1,s=!1;for(const a of t.alternatives)if(a.elements.length===1&&a.elements[0].kind===A.search_start)a.elements.pop();else{const o=gr(a.elements);o?(r=!0,Array.isArray(o)?n.push(...o):n.push(o)):s=!0}r&&!s&&n.forEach(a=>e.add(a))},exit(t,{accuracy:e,passedLookbehind:n,strategy:r}){if(e==="strict"&&n&&r)throw new Error(_`Uses "\G" in a way that requires non-strict accuracy`)}},Quantifier({node:t}){if(t.element.type===f.Quantifier){const e=H(W(),[t.element]);e.parent=t,t.element=e}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!it(n)&&(n=ot(n,e),t.ref=n)},VariableLengthCharacterSet({node:t,replaceWith:e},{accuracy:n,minTargetEs2024:r}){const{kind:s}=t;if(s===Oe.newline)e(O(`(?>\r
146
+ ?|[
147
+ \v\f…\u2028\u2029])`));else if(s===Oe.grapheme){if(n==="strict")throw new Error(_`Use of "\X" requires non-strict accuracy`);const a=r?_`\p{RGI_Emoji}`:Ra().source.replace(/\\u\{/g,"\\x{");e(O(_`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${s}"`)}},ur={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=t;r||n.set(t,[...e.get(s).map(({node:a})=>a)])},CapturingGroup:{enter({node:t,replaceWith:e,skip:n},{groupOriginByCopy:r,groupsByName:s,multiplexCapturesToLeftByRef:a,openRefs:o,reffedNodesByReferencer:i}){const c=r.get(t);if(c&&o.has(t.number)){const u=pn(t.number);i.set(u,o.get(t.number)),e(u),n();return}o.set(t.number,t),a.set(t.number,[]),t.name&&Be(a,t.name,[]);const l=a.get(t.name??t.number);for(let u=0;u<l.length;u++){const h=l[u];if(c===h.node||c&&c===h.origin||t===h.origin){l.splice(u,1);break}}if(a.get(t.number).push({node:t,origin:c}),t.name&&a.get(t.name).push({node:t,origin:c}),t.name){const u=Be(s,t.name,new Map);let h=!1;if(c)h=!0;else for(const d of u.values())if(!d.hasDuplicateNameToRemove){h=!0;break}s.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:h})}c&&(t._originNumber=c.number)},exit({node:t},{openRefs:e}){e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Me(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Recursion({node:t,parent:e},{reffedNodesByReferencer:n}){const{ref:r}=t;let s=e;for(;(s=s.parent)&&!(s.type===f.CapturingGroup&&(s.name===r||s.number===r)););n.set(t,s)},Subroutine(t,e){const{node:n,replaceWith:r}=t,{ref:s}=n,a=e.subroutineRefMap.get(s),o=s===0,i=o?pn(0):hr(a,e.groupOriginByCopy,null);let c=i;if(!o){const l=pr(Wo(a,h=>h.type===f.Group&&!!h.flags)),u=l?Me(e.globalFlags,l):e.globalFlags;jo(u,e.currentFlags)||(c=H(W({flags:Uo(u)}),[i]))}r(c),o||mr(c,t,e,ur)}},Oo={Backreference({node:t,replaceWith:e},n){if(t.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,t.ref);return}const r=n.reffedNodesByReferencer.get(t).filter(s=>Do(s,t));if(!r.length)e(H(pe({negate:!0})));else if(r.length>1){const s=r.map(a=>me(K(),[Ct(a.number)]));e(me(W(),s))}else t.ref=r[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Recursion({node:t},e){t.ref!==0&&(t.ref=e.reffedNodesByReferencer.get(t).number)},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=or();t.pattern.alternatives.at(-1).elements.push(s)}}}},Fo="[ -\r ]",q=_`[\p{L}\p{M}\p{N}\p{Pc}]`;function me(t,e){return e.forEach(n=>n.parent=t),t[Rt(t)]=e,t}function jo(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function Do(t,e){let n=e;do{if(n.type===f.Pattern)return!1;if(n.type===f.Alternative)continue;if(n===t)return!1;const r=dr(n.parent);for(const s of r){if(s===n)break;if(s===t||fr(s,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function hr(t,e,n,r){const s=Array.isArray(t)?[]:{};for(const[a,o]of Object.entries(t))a==="parent"?s.parent=Array.isArray(n)?r:n:o&&typeof o=="object"?s[a]=hr(o,e,s,n):(a==="type"&&o===f.CapturingGroup&&e.set(s,e.get(t)??t),s[a]=o);return s}function pn(t){return{type:f.Recursion,ref:t}}function Wo(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function ot(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function Rt(t){for(const e of["alternatives","classes","elements"])if(t[e])return e;return null}function pr(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:r})=>{e.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Uo({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function dr(t){if(!t)throw new Error("Node expected");if(t.type===f.Quantifier)return[t.element];const e=Rt(t);return e&&t[e]}function gr(t){const e=t.find(n=>n.kind===A.search_start||qo(n,{negate:!1})||!lo(n));if(!e)return null;if(e.kind===A.search_start)return e;if(Ce(e))return e.alternatives[0].elements[0];if(rr(e)){const n=[];for(const r of e.alternatives){const s=gr(r.elements);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function fr(t,e){const n=dr(t)??[];for(const r of n)if(r===e||fr(r,e))return!0;return!1}function qo(t,e){const n={negate:null,...e};return Ce(t)&&(n.negate===null||t.negate===n.negate)&&$t(t,r=>r.kind===A.search_start)}function it(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function O(t,e){const n=sr(er(t),e).pattern.alternatives;return n.length>1||n[0].elements.length>1?me(W(),n):n[0].elements[0]}function H(t,e){const n=Rt(t);return t[n][0].parent=t,e&&me(t[n][0],e),t}function ct(t,e){return t.negate=e,t}function mr(t,{parent:e,key:n,container:r},s,a){oe({node:t,parent:e,key:n,container:r},s,a)}function Ho(t,e){const n=qn(e),r=kt(n.target,"ES2024"),s=kt(n.target,"ES2025"),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,i=null;if(!s){const p=[t.flags.ignoreCase];oe({node:t},{getCurrentModI:()=>p.at(-1),popModI(){p.pop()},pushModI(g){p.push(g)},setHasCasedChar(){p.at(-1)?o=!0:i=!0}},zo)}const c={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||o)&&!i)};let l=null;const u={accuracy:n.accuracy,appliedGlobalFlags:c,avoidSubclass:n.avoidSubclass,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:l,recursionLimit:a,useAppliedIgnoreCase:!!(!s&&o&&i),useFlagMods:s,useFlagV:r,verbose:n.verbose};function h(p){switch(u.lastNode=l,l=p,p.type){case f.Regex:return{pattern:h(p.pattern),flags:h(p.flags),options:{...p.options}};case f.Alternative:return p.elements.map(h).join("");case f.Assertion:return Ko(p,u,h);case f.Backreference:return Yo(p,u);case f.CapturingGroup:return Jo(p,u,h);case f.Character:return ei(p,u);case f.CharacterClass:return ti(p,u,h);case f.CharacterClassIntersection:if(!u.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return p.classes.map(h).join("&&");case f.CharacterClassRange:return ni(p,u);case f.CharacterSet:return ri(p,u);case f.Flags:return si(p,u);case f.Group:return ai(p,u,h);case f.Pattern:return p.alternatives.map(h).join("|");case f.Quantifier:return h(p.element)+li(p);case f.Recursion:return oi(p,u);default:throw new Error(`Unexpected node type "${p.type}"`)}}const d=h(t);return r||(delete d.options.force.v,d.options.disable.v=!0,d.options.unicodeSetsPlugin=null),d}var zo={AnyGroup:{enter({node:t},e){const n=e.getCurrentModI();e.pushModI(t.flags?Me({ignoreCase:n},t.flags).ignoreCase:n)},exit(t,e){e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){Pt(E(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),br(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind===x.property&&Zn.has(t.value)&&e.setHasCasedChar()}},Vo=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Qo=new Set(["-","\\","]","^","["]),Xo=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),dn=new Map([[9,_`\t`],[10,_`\n`],[11,_`\v`],[12,_`\f`],[13,_`\r`],[8232,_`\u2028`],[8233,_`\u2029`],[65279,_`\uFEFF`]]),Zo=/^\p{Cased}$/u;function Pt(t){return Zo.test(t)}function Ko(t,e,n){const{kind:r,negate:s,alternatives:a}=t;if(Ce(t))return`(?${`${r===A.lookahead?"":"<"}${s?"!":"="}`}${a.map(n).join("|")})`;if(r===A.string_end)return"$";if(r===A.string_start)return"^";if(r===A.word_boundary)return s?_`\B`:_`\b`;throw new Error(`Unexpected assertion kind "${r}"`)}function Yo({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t}function Jo({name:t,number:e,alternatives:n,_originNumber:r},s,a){return s.captureMap.set(e,{ignoreCase:s.currentFlags.ignoreCase}),`(${t?`?<${t}>`:""}${!s.avoidSubclass&&r?`${r<e?`$${r}`:""}${te}`:""}${n.map(a).join("|")})`}function ei({value:t},e){const n=E(t),r=se(t,{isAfterBackref:e.lastNode.type===f.Backreference,inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(r!==n)return r;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&Pt(n)){const s=Hn(n);return e.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n}function ti({negate:t,parent:e,elements:n},r,s){const a=()=>`[${t?"^":""}${n.map(s).join("")}]`;if(!r.inCharClass){r.inCharClass=!0;const i=a();return r.inCharClass=!1,i}const o=n[0]?.type;if(!t&&o&&((!r.useFlagV||!r.verbose)&&e.type===f.CharacterClass&&o!==f.CharacterClassIntersection||!r.verbose&&e.type===f.CharacterClassIntersection&&n.length===1&&o!==f.CharacterClass&&o!==f.CharacterClassRange))return n.map(s).join("");if(!r.useFlagV&&e.type===f.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");return a()}function ni(t,e){const n=t.min.value,r=t.max.value,s={isAfterBackref:!1,inCharClass:!0,useFlagV:e.useFlagV},a=se(n,s),o=se(r,s),i=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const c=br(t);ii(c).forEach(l=>{i.add(Array.isArray(l)?`${se(l[0],s)}-${se(l[1],s)}`:se(l,s))})}return`${a}-${o}${[...i].join("")}`}function ri({kind:t,negate:e,value:n,key:r},s){if(t===x.dot)return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":_`[^\n]`;if(t===x.digit)return e?_`\D`:_`\d`;if(t===x.property){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Zn.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?_`\P`:_`\p`}{${r?`${r}=`:""}${n}}`}if(t===x.word)return e?_`\W`:_`\w`;throw new Error(`Unexpected character set kind "${t}"`)}function si(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")}function ai({atomic:t,flags:e,parent:n,alternatives:r},s,a){const o=s.currentFlags;e&&(s.currentFlags=Me(o,e));const i=r.map(a).join("|"),c=!s.verbose&&r.length===1&&n.type!==f.Quantifier&&!t&&(!s.useFlagMods||!e)?i:`(?${ci(t,e,s.useFlagMods)}${i})`;return s.currentFlags=o,c}function oi({ref:t},e){const n=e.recursionLimit;return t===0?`(?R=${n})`:_`\g<${t}&R=${n}>`}function br(t,e){const n=!!e?.firstOnly,r=t.min.value,s=t.max.value,a=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return a;for(let o=r;o<=s;o++){const i=E(o);if(!Pt(i))continue;const c=Hn(i).filter(l=>{const u=l.codePointAt(0);return u<r||u>s});if(c.length&&(a.push(...c),n))break}return a}function se(t,{isAfterBackref:e,inCharClass:n,useFlagV:r}){if(dn.has(t))return dn.get(t);if(t<32||t>126&&t<160||t>262143||e&&ui(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?Xo:Qo:Vo,a=E(t);return(s.has(a)?"\\":"")+a}function ii(t){const e=t.map(s=>s.codePointAt(0)).sort((s,a)=>s-a),n=[];let r=null;for(let s=0;s<e.length;s++)e[s+1]===e[s]+1?r??=e[s]:r===null?n.push(e[s]):(n.push([r,e[s]]),r=null);return n}function ci(t,e,n){if(t)return">";let r="";if(e&&n){const{enable:s,disable:a}=e;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(a?"-":"")+(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")}return`${r}:`}function li({min:t,max:e,greedy:n,possessive:r}){let s;return!t&&e===1?s="?":!t&&e===1/0?s="*":t===1&&e===1/0?s="+":t===e?s=`{${t}}`:s=`{${t},${e===1/0?"":e}}`,s+(r?"+":n?"":"?")}function ui(t){return t>47&&t<58}var hi=class yr extends It{#e;rawArgs;constructor(e,n,r){if(e instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");super(e,n),e instanceof yr?(this.#e=e.#e,this.rawArgs=e.rawArgs):(this.#e=null,this.rawArgs={pattern:e.source,flags:e.flags,options:{}}),n!==void 0&&(this.rawArgs.flags=n)}else{const s={strategy:null,useEmulationGroups:!1,...r};super(e,n,{useEmulationGroups:s.useEmulationGroups}),this.#e=s.strategy,this.rawArgs={pattern:e,flags:n??"",options:{...s.strategy&&{strategy:s.strategy},...s.useEmulationGroups&&{useEmulationGroups:!0}}}}}exec(e){const n=super.exec,r=this.global||this.sticky,s=this.lastIndex;if(this.#e==="search_start_clip"&&r&&s){this.lastIndex=0;const a=n.call(this,e.slice(s));return a&&(pi(a,this,e,s),this.lastIndex+=s),a}return n.call(this,e)}};function pi(t,e,n,r){if(t.input=n,t.index+=r,e.hasIndices){const s=t.indices;for(let o=0;o<s.length;o++){const i=s[o];i&&(s[o]=[i[0]+r,i[1]+r])}const a=s.groups;a&&Object.keys(a).forEach(o=>{const i=a[o];i&&(a[o]=[i[0]+r,i[1]+r])})}}function di(t,e){const n=qn(e),r=n.avoidSubclass,s=er(t,n.flags,{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}),a=sr(s,{skipBackrefValidation:n.rules.allowOrphanBackrefs,verbose:n.verbose}),o=Bo(a,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:r,bestEffortTarget:n.target}),i=Ho(o,n),c={useEmulationGroups:!r},l={pattern:Oa(Fa(Da(i.pattern,c)),c),flags:`${n.hasIndices?"d":""}${n.global?"g":""}${i.flags}${i.options.disable.v?"u":"v"}`},u=!r&&l.pattern.includes(te),h=o._strategy;return(u||h)&&(l.options={...h&&{strategy:h},...u&&{useEmulationGroups:u}}),l}function gi(t,e){const n=di(t,e);return n.options?new hi(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}const gn=4294967295;class fi{constructor(e,n={}){this.patterns=e,this.options=n;const{forgiving:r=!1,cache:s,regexConstructor:a}=n;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const i=s?.get(o);if(i){if(i instanceof RegExp)return i;if(r)return null;throw i}try{const c=a(o);return s?.set(o,c),c}catch(c){if(s?.set(o,c),r)return null;throw c}})}regexps;findNextMatchSync(e,n,r){const s=typeof e=="string"?e:e.content,a=[];function o(i,c,l=0){return{index:i,captureIndices:c.indices.map(u=>u==null?{start:gn,end:gn,length:0}:{start:u[0]+l,end:u[1]+l,length:u[1]-u[0]})}}for(let i=0;i<this.regexps.length;i++){const c=this.regexps[i];if(c)try{c.lastIndex=n;const l=c.exec(s);if(!l)continue;if(l.index===n)return o(i,l,0);a.push([i,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(a.length){const i=Math.min(...a.map(c=>c[1].index));for(const[c,l,u]of a)if(l.index===i)return o(c,l,u)}return null}}function _r(t,e){return gi(t,{global:!0,hasIndices:!0,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function mi(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>_r(n,{target:e.target}),{createScanner(n){return new fi(n,e)},createString(n){return{content:n}}}}function bi(t){return F("import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead"),At(t)}function Ki(t){return F("import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead"),At(t)}function Yi(t){return F("import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead"),Mr(t)}function yi(t){return Array.isArray(t)?t:[t]}function ze(t,e=!1){const n=t.split(/(\r?\n)/g);let r=0;const s=[];for(let a=0;a<n.length;a+=2){const o=e?n[a]+(n[a+1]||""):n[a];s.push([o,r]),r+=n[a].length,r+=n[a+1]?.length||0}return s}function Tt(t){return!t||["plaintext","txt","text","plain"].includes(t)}function kr(t){return t==="ansi"||Tt(t)}function Lt(t){return t==="none"}function Cr(t){return Lt(t)}function wr(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function _i(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function ki(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const a=n.filter(o=>s.offset<o&&o<s.offset+s.content.length).map(o=>o-s.offset).sort((o,i)=>o-i);return a.length?_i(s,a):s})):t}async function Sr(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function Fe(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,a]of Object.entries(e?.colorReplacements||{}))typeof a=="string"?n[s]=a:s===r&&Object.assign(n,a);return n}function J(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function Ar(t){const e={};return t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle&&(t.fontStyle&z.Italic&&(e["font-style"]="italic"),t.fontStyle&z.Bold&&(e["font-weight"]="bold"),t.fontStyle&z.Underline&&(e["text-decoration"]="underline")),e}function Ci(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}function wi(t){const e=ze(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let a=s,o=0;for(const i of e){if(a<i.length)break;a-=i.length,o++}return{line:o,character:a}}function r(s,a){let o=0;for(let i=0;i<s;i++)o+=e[i].length;return o+=a,o}return{lines:e,indexToPos:n,posToIndex:r}}class T extends Error{constructor(e){super(e),this.name="ShikiError"}}const xr=new WeakMap;function Ve(t,e){xr.set(t,e)}function be(t){return xr.get(t)}class ce{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new ce(Object.fromEntries(yi(n).map(r=>[r,mt])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}get scopes(){return F("GrammarState.scopes is deprecated, use GrammarState.getScopes() instead"),fn(this._stacks[this.theme])}getScopes(e=this.theme){return fn(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.scopes}}}function fn(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const a=s?.nameScopesList?.scopeName;a&&e.push(a),s.parent&&r(s.parent)}return r(t),e}function Si(t,e){if(!(t instanceof ce))throw new T("Invalid grammar state");return t.getInternalStack(e)}function Ai(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(o){if(typeof o=="number"){if(o<0||o>n.source.length)throw new T(`Invalid decoration offset: ${o}. Code length: ${n.source.length}`);return{...s.indexToPos(o),offset:o}}else{const i=s.lines[o.line];if(i===void 0)throw new T(`Invalid decoration position ${JSON.stringify(o)}. Lines length: ${s.lines.length}`);if(o.character<0||o.character>i.length)throw new T(`Invalid decoration position ${JSON.stringify(o)}. Line ${o.line} length: ${i.length}`);return{...o,offset:s.posToIndex(o.line,o.character)}}};const s=wi(n.source),a=(n.options.decorations||[]).map(o=>({...o,start:r(o.start),end:r(o.end)}));xi(a),t.set(n.meta,{decorations:a,converter:s,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const r=e(this).decorations.flatMap(s=>[s.start.offset,s.end.offset]);return ki(n,r)},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new T(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function a(u,h,d,p){const g=s[u];let k="",m=-1,C=-1;if(h===0&&(m=0),d===0&&(C=0),d===Number.POSITIVE_INFINITY&&(C=g.children.length),m===-1||C===-1)for(let w=0;w<g.children.length;w++)k+=vr(g.children[w]),m===-1&&k.length===h&&(m=w+1),C===-1&&k.length===d&&(C=w+1);if(m===-1)throw new T(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(C===-1)throw new T(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);const b=g.children.slice(m,C);if(!p.alwaysWrap&&b.length===g.children.length)i(g,p,"line");else if(!p.alwaysWrap&&b.length===1&&b[0].type==="element")i(b[0],p,"token");else{const w={type:"element",tagName:"span",properties:{},children:b};i(w,p,"wrapper"),g.children.splice(m,b.length,w)}}function o(u,h){s[u]=i(s[u],h,"line")}function i(u,h,d){const p=h.properties||{},g=h.transform||(k=>k);return u.tagName=h.tagName||"span",u.properties={...u.properties,...p,class:u.properties.class},h.properties?.class&&wr(u,h.properties.class),u=g(u,d)||u,u}const c=[],l=r.decorations.sort((u,h)=>h.start.offset-u.start.offset);for(const u of l){const{start:h,end:d}=u;if(h.line===d.line)a(h.line,h.character,d.character,u);else if(h.line<d.line){a(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let p=h.line+1;p<d.line;p++)c.unshift(()=>o(p,u));a(d.line,0,d.character,u)}}c.forEach(u=>u())}}}function xi(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new T(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],a=n.start.offset<s.start.offset&&s.start.offset<n.end.offset,o=n.start.offset<s.end.offset&&s.end.offset<n.end.offset,i=s.start.offset<n.start.offset&&n.start.offset<s.end.offset,c=s.start.offset<n.end.offset&&n.end.offset<s.end.offset;if(a||o||i||c){if(o&&o||i&&c)continue;throw new T(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function vr(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(vr).join(""):""}const vi=[Ai()];function je(t){return[...t.transformers||[],...vi]}var ee=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],lt={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",9:"strikethrough"};function Ei(t,e){const n=t.indexOf("\x1B[",e);if(n!==-1){const r=t.indexOf("m",n);return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function mn(t,e){let n=1;const r=t[e+n++];let s;if(r==="2"){const a=[t[e+n++],t[e+n++],t[e+n]].map(o=>Number.parseInt(o));a.length===3&&!a.some(o=>Number.isNaN(o))&&(s={type:"rgb",rgb:a})}else if(r==="5"){const a=Number.parseInt(t[e+n]);Number.isNaN(a)||(s={type:"table",index:Number(a)})}return[n,s]}function Ni(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n],s=Number.parseInt(r);if(!Number.isNaN(s))if(s===0)e.push({type:"resetAll"});else if(s<=9)lt[s]&&e.push({type:"setDecoration",value:lt[s]});else if(s<=29){const a=lt[s-20];a&&e.push({type:"resetDecoration",value:a})}else if(s<=37)e.push({type:"setForegroundColor",value:{type:"named",name:ee[s-30]}});else if(s===38){const[a,o]=mn(t,n);o&&e.push({type:"setForegroundColor",value:o}),n+=a}else if(s===39)e.push({type:"resetForegroundColor"});else if(s<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:ee[s-40]}});else if(s===48){const[a,o]=mn(t,n);o&&e.push({type:"setBackgroundColor",value:o}),n+=a}else s===49?e.push({type:"resetBackgroundColor"}):s>=90&&s<=97?e.push({type:"setForegroundColor",value:{type:"named",name:ee[s-90+8]}}):s>=100&&s<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:ee[s-100+8]}})}return e}function Ii(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let a=0;do{const o=Ei(r,a),i=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(i.length>0&&s.push({value:i,foreground:t,background:e,decorations:new Set(n)}),o.sequence){const c=Ni(o.sequence);for(const l of c)l.type==="resetAll"?(t=null,e=null,n.clear()):l.type==="resetForegroundColor"?t=null:l.type==="resetBackgroundColor"?e=null:l.type==="resetDecoration"&&n.delete(l.value);for(const l of c)l.type==="setForegroundColor"?t=l.value:l.type==="setBackgroundColor"?e=l.value:l.type==="setDecoration"&&n.add(l.value)}a=o.position}while(a<r.length);return s}}}var $i={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Ri(t=$i){function e(i){return t[i]}function n(i){return`#${i.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let l=0;l<ee.length;l++)r.push(e(ee[l]));let i=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[l],i[u],i[h]]));let c=8;for(let l=0;l<24;l++,c+=10)r.push(n([c,c,c]));return r}function a(i){return s()[i]}function o(i){switch(i.type){case"named":return e(i.name);case"rgb":return n(i.rgb);case"table":return a(i.index)}}return{value:o}}function Pi(t,e,n){const r=Fe(t,n),s=ze(e),a=Ri(Object.fromEntries(ee.map(i=>[i,t.colors?.[`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`]]))),o=Ii();return s.map(i=>o.parse(i[0]).map(c=>{let l,u;c.decorations.has("reverse")?(l=c.background?a.value(c.background):t.bg,u=c.foreground?a.value(c.foreground):t.fg):(l=c.foreground?a.value(c.foreground):t.fg,u=c.background?a.value(c.background):void 0),l=J(l,r),u=J(u,r),c.decorations.has("dim")&&(l=Ti(l));let h=z.None;return c.decorations.has("bold")&&(h|=z.Bold),c.decorations.has("italic")&&(h|=z.Italic),c.decorations.has("underline")&&(h|=z.Underline),{content:c.value,offset:i[1],color:l,bgColor:u,fontStyle:h}}))}function Ti(t){const e=t.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(e)if(e[3]){const r=Math.round(Number.parseInt(e[3],16)/2).toString(16).padStart(2,"0");return`#${e[1]}${e[2]}${r}`}else return e[2]?`#${e[1]}${e[2]}80`:`#${Array.from(e[1]).map(r=>`${r}${r}`).join("")}80`;const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function Qe(t,e,n={}){const{lang:r="text",theme:s=t.getLoadedThemes()[0]}=n;if(Tt(r)||Lt(s))return ze(e).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:o}=t.setTheme(s);if(r==="ansi")return Pi(a,e,n);const i=t.getLanguage(r);if(n.grammarState){if(n.grammarState.lang!==i.name)throw new V(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(a.name))throw new V(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return Li(e,i,a,o,n)}function Er(...t){if(t.length===2)return be(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:a=e.getLoadedThemes()[0]}=r;if(Tt(s)||Lt(a))throw new V("Plain language does not have grammar state");if(s==="ansi")throw new V("ANSI language does not have grammar state");const{theme:o,colorMap:i}=e.setTheme(a),c=e.getLanguage(s);return new ce(De(n,c,o,i,r).stateStack,c.name,o.name)}function Li(t,e,n,r,s){const a=De(t,e,n,r,s),o=new ce(De(t,e,n,r,s).stateStack,e.name,n.name);return Ve(a.tokens,o),a.tokens}function De(t,e,n,r,s){const a=Fe(n,s),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:i=500}=s,c=ze(t);let l=s.grammarState?Si(s.grammarState,n.name)??mt:s.grammarContextCode!=null?De(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:mt,u=[];const h=[];for(let d=0,p=c.length;d<p;d++){const[g,k]=c[d];if(g===""){u=[],h.push([]);continue}if(o>0&&g.length>=o){u=[],h.push([{content:g,offset:k,color:"",fontStyle:0}]);continue}let m,C,b;s.includeExplanation&&(m=e.tokenizeLine(g,l),C=m.tokens,b=0);const w=e.tokenizeLine2(g,l,i),I=w.tokens.length/2;for(let v=0;v<I;v++){const j=w.tokens[2*v],L=v+1<I?w.tokens[2*v+2]:g.length;if(j===L)continue;const Ot=w.tokens[2*v+1],Tr=J(r[ie.getForeground(Ot)],a),Lr=ie.getFontStyle(Ot),Xe={content:g.substring(j,L),offset:k+j,color:Tr,fontStyle:Lr};if(s.includeExplanation){const Ft=[];if(s.includeExplanation!=="scopeName")for(const U of n.settings){let ne;switch(typeof U.scope){case"string":ne=U.scope.split(/,/).map(Ze=>Ze.trim());break;case"object":ne=U.scope;break;default:continue}Ft.push({settings:U,selectors:ne.map(Ze=>Ze.split(/ /))})}Xe.explanation=[];let jt=0;for(;j+jt<L;){const U=C[b],ne=g.substring(U.startIndex,U.endIndex);jt+=ne.length,Xe.explanation.push({content:ne,scopes:s.includeExplanation==="scopeName"?Gi(U.scopes):Mi(Ft,U.scopes)}),b+=1}}u.push(Xe)}h.push(u),u=[],l=w.ruleStack}return{tokens:h,stateStack:l}}function Gi(t){return t.map(e=>({scopeName:e}))}function Mi(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n[r]={scopeName:a,themeMatches:Oi(t,a,e.slice(0,r))}}return n}function bn(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function Bi(t,e,n){if(!bn(t[t.length-1],e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)bn(t[r],n[s])&&(r-=1),s-=1;return r===-1}function Oi(t,e,n){const r=[];for(const{selectors:s,settings:a}of t)for(const o of s)if(Bi(o,e,n)){r.push(a);break}return r}function Gt(t,e,n){const r=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),s=r.map(c=>{const l=Qe(t,e,{...n,theme:c.theme}),u=be(l),h=typeof c.theme=="string"?c.theme:c.theme.name;return{tokens:l,state:u,theme:h}}),a=Fi(...s.map(c=>c.tokens)),o=a[0].map((c,l)=>c.map((u,h)=>{const d={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(d.explanation=u.explanation),a.forEach((p,g)=>{const{content:k,explanation:m,offset:C,...b}=p[l][h];d.variants[r[g].color]=b}),d})),i=s[0].state?new ce(Object.fromEntries(s.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),s[0].state.lang):void 0;return i&&Ve(o,i),o}function Fi(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(c=>c[r]),a=e.map(()=>[]);e.forEach((c,l)=>c.push(a[l]));const o=s.map(()=>0),i=s.map(c=>c[0]);for(;i.every(c=>c);){const c=Math.min(...i.map(l=>l.content.length));for(let l=0;l<n;l++){const u=i[l];u.content.length===c?(a[l].push(u),o[l]+=1,i[l]=s[l][o[l]]):(a[l].push({...u,content:u.content.slice(0,c)}),i[l]={...u,content:u.content.slice(c),offset:u.offset+c})}}}return e}function ye(t,e,n){let r,s,a,o,i,c;if("themes"in n){const{defaultColor:l="light",cssVariablePrefix:u="--shiki-"}=n,h=Object.entries(n.themes).filter(m=>m[1]).map(m=>({color:m[0],theme:m[1]})).sort((m,C)=>m.color===l?-1:C.color===l?1:0);if(h.length===0)throw new V("`themes` option must not be empty");const d=Gt(t,e,n);if(c=be(d),l&&!h.find(m=>m.color===l))throw new V(`\`themes\` option must contain the defaultColor key \`${l}\``);const p=h.map(m=>t.getTheme(m.theme)),g=h.map(m=>m.color);a=d.map(m=>m.map(C=>ji(C,g,u,l))),c&&Ve(a,c);const k=h.map(m=>Fe(m.theme,n));s=h.map((m,C)=>(C===0&&l?"":`${u+m.color}:`)+(J(p[C].fg,k[C])||"inherit")).join(";"),r=h.map((m,C)=>(C===0&&l?"":`${u+m.color}-bg:`)+(J(p[C].bg,k[C])||"inherit")).join(";"),o=`shiki-themes ${p.map(m=>m.name).join(" ")}`,i=l?void 0:[s,r].join(";")}else if("theme"in n){const l=Fe(n.theme,n);a=Qe(t,e,n);const u=t.getTheme(n.theme);r=J(u.bg,l),s=J(u.fg,l),o=u.name,c=be(a)}else throw new V("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:s,bg:r,themeName:o,rootStyle:i,grammarState:c}}function ji(t,e,n,r){const s={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(c=>Ar(t.variants[c])),o=new Set(a.flatMap(c=>Object.keys(c))),i={};return a.forEach((c,l)=>{for(const u of o){const h=c[u]||"inherit";if(l===0&&r)i[u]=h;else{const d=u==="color"?"":u==="background-color"?"-bg":`-${u}`,p=n+e[l]+(u==="color"?"":d);i[p]=h}}}),s.htmlStyle=i,s}function _e(t,e,n,r={meta:{},options:n,codeToHast:(s,a)=>_e(t,s,a),codeToTokens:(s,a)=>ye(t,s,a)}){let s=e;for(const p of je(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:a,fg:o,bg:i,themeName:c,rootStyle:l,grammarState:u}=ye(t,s,n);const{mergeWhitespaces:h=!0}=n;h===!0?a=Wi(a):h==="never"&&(a=Ui(a));const d={...r,get source(){return s}};for(const p of je(n))a=p.tokens?.call(d,a)||a;return Di(a,{...n,fg:o,bg:i,themeName:c,rootStyle:l},d,u)}function Di(t,e,n,r=be(t)){const s=je(e),a=[],o={type:"root",children:[]},{structure:i="classic",tabindex:c="0"}=e;let l={type:"element",tagName:"pre",properties:{class:`shiki ${e.themeName||""}`,style:e.rootStyle||`background-color:${e.bg};color:${e.fg}`,...c!==!1&&c!=null?{tabindex:c.toString()}:{},...Object.fromEntries(Array.from(Object.entries(e.meta||{})).filter(([g])=>!g.startsWith("_")))},children:[]},u={type:"element",tagName:"code",properties:{},children:a};const h=[],d={...n,structure:i,addClassToHast:wr,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return o},get pre(){return l},get code(){return u},get lines(){return h}};if(t.forEach((g,k)=>{k&&(i==="inline"?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&a.push({type:"text",value:`
148
+ `}));let m={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(const b of g){let w={type:"element",tagName:"span",properties:{...b.htmlAttrs},children:[{type:"text",value:b.content}]};typeof b.htmlStyle=="string"&&F("`htmlStyle` as a string is deprecated. Use an object instead.");const I=Ci(b.htmlStyle||Ar(b));I&&(w.properties.style=I);for(const v of s)w=v?.span?.call(d,w,k+1,C,m,b)||w;i==="inline"?o.children.push(w):i==="classic"&&m.children.push(w),C+=b.content.length}if(i==="classic"){for(const b of s)m=b?.line?.call(d,m,k+1)||m;h.push(m),a.push(m)}}),i==="classic"){for(const g of s)u=g?.code?.call(d,u)||u;l.children.push(u);for(const g of s)l=g?.pre?.call(d,l)||l;o.children.push(l)}let p=o;for(const g of s)p=g?.root?.call(d,p)||p;return r&&Ve(p,r),p}function Wi(t){return t.map(e=>{const n=[];let r="",s=0;return e.forEach((a,o)=>{const i=!(a.fontStyle&&a.fontStyle&z.Underline);i&&a.content.match(/^\s+$/)&&e[o+1]?(s||(s=a.offset),r+=a.content):r?(i?n.push({...a,offset:s,content:r+a.content}):n.push({content:r,offset:s},a),s=0,r=""):n.push(a)}),n})}function Ui(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,s,a,o]=r;if(!s&&!o)return n;const i=[{...n,offset:n.offset+s.length,content:a}];return s&&i.unshift({content:s,offset:n.offset}),o&&i.push({content:o,offset:n.offset+s.length+a.length}),i}))}function Nr(t,e,n){const r={meta:{},options:n,codeToHast:(a,o)=>_e(t,a,o),codeToTokens:(a,o)=>ye(t,a,o)};let s=Na(_e(t,e,n,r));for(const a of je(n))s=a.postprocess?.call(r,s,n)||s;return s}const yn={light:"#333333",dark:"#bbbbbb"},_n={light:"#fffffe",dark:"#1e1e1e"},kn="__shiki_resolved";function Mt(t){if(t?.[kn])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const i=e.settings?e.settings.find(c=>!c.name&&!c.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?yn.light:yn.dark),n||(n=e.type==="light"?_n.light:_n.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const a=new Map;function o(i){if(a.has(i))return a.get(i);s+=1;const c=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${c}`]?o(i):(a.set(i,c),c)}e.settings=e.settings.map(i=>{const c=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),l=i.settings?.background&&!i.settings.background.startsWith("#");if(!c&&!l)return i;const u={...i,settings:{...i.settings}};if(c){const h=o(i.settings.foreground);e.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(l){const h=o(i.settings.background);e.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(const i of Object.keys(e.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!e.colors[i]?.startsWith("#")){const c=o(e.colors[i]);e.colorReplacements[c]=e.colors[i],e.colors[i]=c}return Object.defineProperty(e,kn,{enumerable:!1,writable:!1,value:!0}),e}async function Ir(t){return Array.from(new Set((await Promise.all(t.filter(e=>!kr(e)).map(async e=>await Sr(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function $r(t){return(await Promise.all(t.map(async e=>Cr(e)?null:Mt(await Sr(e))))).filter(e=>!!e)}class qi extends Ns{constructor(e,n,r,s={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=s,this._themes.map(a=>this.loadTheme(a)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=Mt(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=Re.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){if(this._alias[e]){const n=new Set([e]);for(;this._alias[e];){if(e=this._alias[e],n.has(e))throw new T(`Circular alias \`${Array.from(n).join(" -> ")} -> ${e}\``);n.add(e)}}return this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(a=>a.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(a=>{this._alias[a]=e.name}),this._loadedLanguagesCache=null,n.size)for(const a of n)this._resolvedGrammars.delete(a.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(a.scopeName),this._syncRegistry?._grammars?.delete(a.scopeName),this.loadLanguage(this._langMap.get(a.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const n=Array.from(this._langGraph.entries()),r=n.filter(([s,a])=>!a);if(r.length){const s=n.filter(([a,o])=>o&&o.embeddedLangs?.some(i=>r.map(([c])=>c).includes(i))).filter(a=>!r.includes(a));throw new T(`Missing languages ${r.map(([a])=>`\`${a}\``).join(", ")}, required by ${s.map(([a])=>`\`${a}\``).join(", ")}`)}for(const[s,a]of n)this._resolver.addLanguage(a);for(const[s,a]of n)this.loadLanguage(a)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){if(this._langMap.set(e.name,e),this._langGraph.set(e.name,e),e.embeddedLangs)for(const n of e.embeddedLangs)this._langGraph.set(n,this._langMap.get(n))}}class Hi{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let s=1;s<=n.length;s++){const a=n.slice(0,s).join(".");r=[...r,...this._injections.get(a)||[]]}return r}}let le=0;function Rr(t){le+=1,t.warnings!==!1&&le>=10&&le%10===0&&console.warn(`[Shiki] ${le} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new T("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(Mt),s=new Hi(t.engine,n),a=new qi(s,r,n,t.langAlias);let o;function i(b){m();const w=a.getGrammar(typeof b=="string"?b:b.name);if(!w)throw new T(`Language \`${b}\` not found, you may need to load it first`);return w}function c(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};m();const w=a.getTheme(b);if(!w)throw new T(`Theme \`${b}\` not found, you may need to load it first`);return w}function l(b){m();const w=c(b);o!==b&&(a.setTheme(w),o=b);const I=a.getColorMap();return{theme:w,colorMap:I}}function u(){return m(),a.getLoadedThemes()}function h(){return m(),a.getLoadedLanguages()}function d(...b){m(),a.loadLanguages(b.flat(1))}async function p(...b){return d(await Ir(b))}function g(...b){m();for(const w of b.flat(1))a.loadTheme(w)}async function k(...b){return m(),g(await $r(b))}function m(){if(e)throw new T("Shiki instance has been disposed")}function C(){e||(e=!0,a.dispose(),le-=1)}return{setTheme:l,getTheme:c,getLanguage:i,getLoadedThemes:u,getLoadedLanguages:h,loadLanguage:p,loadLanguageSync:d,loadTheme:k,loadThemeSync:g,dispose:C,[Symbol.dispose]:C}}async function Pr(t={}){t.loadWasm&&F("`loadWasm` option is deprecated. Use `engine: createOnigurumaEngine(loadWasm)` instead.");const[e,n,r]=await Promise.all([$r(t.themes||[]),Ir(t.langs||[]),t.engine||At(t.loadWasm||Gr())]);return Rr({...t,themes:e,langs:n,engine:r})}function Ji(t={}){return F("`getShikiInternal` is deprecated. Use `createShikiInternal` instead."),Pr(t)}async function Bt(t={}){const e=await Pr(t);return{getLastGrammarState:(...n)=>Er(e,...n),codeToTokensBase:(n,r)=>Qe(e,n,r),codeToTokensWithThemes:(n,r)=>Gt(e,n,r),codeToTokens:(n,r)=>ye(e,n,r),codeToHast:(n,r)=>_e(e,n,r),codeToHtml:(n,r)=>Nr(e,n,r),...e,getInternalContext:()=>e}}function ec(t={}){const e=Rr(t);return{getLastGrammarState:(...n)=>Er(e,...n),codeToTokensBase:(n,r)=>Qe(e,n,r),codeToTokensWithThemes:(n,r)=>Gt(e,n,r),codeToTokens:(n,r)=>ye(e,n,r),codeToHast:(n,r)=>_e(e,n,r),codeToHtml:(n,r)=>Nr(e,n,r),...e,getInternalContext:()=>e}}function zi(t){let e;async function n(r={}){if(e){const s=await e;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}else return e=t({...r,themes:r.themes||[],langs:r.langs||[]}),e}return n}const tc=zi(Bt);function nc(t={}){return F("`getHighlighterCore` is deprecated. Use `createHighlighterCore` or `getSingletonHighlighterCore` instead."),Bt(t)}function rc(t,e,n){let r,s,a;if(e)F("`createdBundledHighlighter` signature with `bundledLanguages` and `bundledThemes` is deprecated. Use the options object signature instead."),r=t,s=e,a=()=>bi(n);else{const i=t;r=i.langs,s=i.themes,a=i.engine}async function o(i){function c(p){if(typeof p=="string"){if(kr(p))return[];const g=r[p];if(!g)throw new V(`Language \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}function l(p){if(Cr(p))return"none";if(typeof p=="string"){const g=s[p];if(!g)throw new V(`Theme \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}const u=(i.themes??[]).map(p=>l(p)),h=(i.langs??[]).map(p=>c(p)),d=await Bt({engine:i.engine??a(),...i,themes:u,langs:h});return{...d,loadLanguage(...p){return d.loadLanguage(...p.map(c))},loadTheme(...p){return d.loadTheme(...p.map(l))}}}return o}function Vi(t){let e;async function n(r={}){if(e){const s=await e;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}else return e=t({...r,themes:r.themes||[],langs:r.langs||[]}),e}return n}function sc(t){const e=Vi(t);return{getSingletonHighlighter(n){return e(n)},async codeToHtml(n,r){return(await e({langs:[r.lang],themes:"theme"in r?[r.theme]:Object.values(r.themes)})).codeToHtml(n,r)},async codeToHast(n,r){return(await e({langs:[r.lang],themes:"theme"in r?[r.theme]:Object.values(r.themes)})).codeToHast(n,r)},async codeToTokens(n,r){return(await e({langs:[r.lang],themes:"theme"in r?[r.theme]:Object.values(r.themes)})).codeToTokens(n,r)},async codeToTokensBase(n,r){return(await e({langs:[r.lang],themes:[r.theme]})).codeToTokensBase(n,r)},async codeToTokensWithThemes(n,r){return(await e({langs:[r.lang],themes:Object.values(r.themes).filter(Boolean)})).codeToTokensWithThemes(n,r)},async getLastGrammarState(n,r){return(await e({langs:[r.lang],themes:[r.theme]})).getLastGrammarState(n,r)}}}function ac(t){return F("import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead"),mi(t)}function oc(t){return F("import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead"),_r(t)}function ic(t={}){const{name:e="css-variables",variablePrefix:n="--shiki-",fontStyle:r=!0}=t,s=o=>t.variableDefaults?.[o]?`var(${n}${o}, ${t.variableDefaults[o]})`:`var(${n}${o})`,a={name:e,type:"dark",colors:{"editor.foreground":s("foreground"),"editor.background":s("background"),"terminal.ansiBlack":s("ansi-black"),"terminal.ansiRed":s("ansi-red"),"terminal.ansiGreen":s("ansi-green"),"terminal.ansiYellow":s("ansi-yellow"),"terminal.ansiBlue":s("ansi-blue"),"terminal.ansiMagenta":s("ansi-magenta"),"terminal.ansiCyan":s("ansi-cyan"),"terminal.ansiWhite":s("ansi-white"),"terminal.ansiBrightBlack":s("ansi-bright-black"),"terminal.ansiBrightRed":s("ansi-bright-red"),"terminal.ansiBrightGreen":s("ansi-bright-green"),"terminal.ansiBrightYellow":s("ansi-bright-yellow"),"terminal.ansiBrightBlue":s("ansi-bright-blue"),"terminal.ansiBrightMagenta":s("ansi-bright-magenta"),"terminal.ansiBrightCyan":s("ansi-bright-cyan"),"terminal.ansiBrightWhite":s("ansi-bright-white")},tokenColors:[{scope:["keyword.operator.accessor","meta.group.braces.round.function.arguments","meta.template.expression","markup.fenced_code meta.embedded.block"],settings:{foreground:s("foreground")}},{scope:"emphasis",settings:{fontStyle:"italic"}},{scope:["strong","markup.heading.markdown","markup.bold.markdown"],settings:{fontStyle:"bold"}},{scope:["markup.italic.markdown"],settings:{fontStyle:"italic"}},{scope:"meta.link.inline.markdown",settings:{fontStyle:"underline",foreground:s("token-link")}},{scope:["string","markup.fenced_code","markup.inline"],settings:{foreground:s("token-string")}},{scope:["comment","string.quoted.docstring.multi"],settings:{foreground:s("token-comment")}},{scope:["constant.numeric","constant.language","constant.other.placeholder","constant.character.format.placeholder","variable.language.this","variable.other.object","variable.other.class","variable.other.constant","meta.property-name","meta.property-value","support"],settings:{foreground:s("token-constant")}},{scope:["keyword","storage.modifier","storage.type","storage.control.clojure","entity.name.function.clojure","entity.name.tag.yaml","support.function.node","support.type.property-name.json","punctuation.separator.key-value","punctuation.definition.template-expression"],settings:{foreground:s("token-keyword")}},{scope:"variable.parameter.function",settings:{foreground:s("token-parameter")}},{scope:["support.function","entity.name.type","entity.other.inherited-class","meta.function-call","meta.instance.constructor","entity.other.attribute-name","entity.name.function","constant.keyword.clojure"],settings:{foreground:s("token-function")}},{scope:["entity.name.tag","string.quoted","string.regexp","string.interpolated","string.template","string.unquoted.plain.out.yaml","keyword.other.template"],settings:{foreground:s("token-string-expression")}},{scope:["punctuation.definition.arguments","punctuation.definition.dict","punctuation.separator","meta.function-call.arguments"],settings:{foreground:s("token-punctuation")}},{scope:["markup.underline.link","punctuation.definition.metadata.markdown"],settings:{foreground:s("token-link")}},{scope:["beginning.punctuation.definition.list.markdown"],settings:{foreground:s("token-string")}},{scope:["punctuation.definition.string.begin.markdown","punctuation.definition.string.end.markdown","string.other.link.title.markdown","string.other.link.description.markdown"],settings:{foreground:s("token-keyword")}},{scope:["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],settings:{foreground:s("token-inserted")}},{scope:["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],settings:{foreground:s("token-deleted")}},{scope:["markup.changed","punctuation.definition.changed"],settings:{foreground:s("token-changed")}}]};return r||(a.tokenColors=a.tokenColors?.map(o=>(o.settings?.fontStyle&&delete o.settings.fontStyle,o))),a}export{z as FontStyle,V as ShikiError,ie as StackElementMetadata,wr as addClassToHast,J as applyColorReplacements,_e as codeToHast,Nr as codeToHtml,ye as codeToTokens,Qe as codeToTokensBase,Gt as codeToTokensWithThemes,ic as createCssVariablesTheme,Bt as createHighlighterCore,ec as createHighlighterCoreSync,ac as createJavaScriptRegexEngine,bi as createOnigurumaEngine,wi as createPositionConverter,Pr as createShikiInternal,Rr as createShikiInternalSync,sc as createSingletonShorthands,Ki as createWasmOnigEngine,rc as createdBundledHighlighter,oc as defaultJavaScriptRegexConstructor,Zi as enableDeprecationWarnings,nc as getHighlighterCore,Ji as getShikiInternal,tc as getSingletonHighlighterCore,Ar as getTokenStyleObject,Na as hastToHtml,Lt as isNoneTheme,Tt as isPlainLang,kr as isSpecialLang,Cr as isSpecialTheme,Yi as loadWasm,Vi as makeSingletonHighlighter,zi as makeSingletonHighlighterCore,Sr as normalizeGetter,Mt as normalizeTheme,Fe as resolveColorReplacements,ze as splitLines,_i as splitToken,ki as splitTokens,Ci as stringifyTokenStyle,yi as toArray,Pi as tokenizeAnsiWithTheme,Li as tokenizeWithTheme,Di as tokensToHast,Ai as transformerDecorations,F as warnDeprecated};
@@ -0,0 +1 @@
1
+ class B extends Error{constructor(t){super(t),this.name="ShikiError"}}function v(){return 2147483648}function C(){return typeof performance<"u"?performance.now():Date.now()}const M=(n,t)=>n+(t-n%t)%t;async function H(n){let t,r;const e={};function c(i){r=i,e.HEAPU8=new Uint8Array(i),e.HEAPU32=new Uint32Array(i)}function h(i,l,A){e.HEAPU8.copyWithin(i,l,l+A)}function o(i){try{return t.grow(i-r.byteLength+65535>>>16),c(t.buffer),1}catch{}}function f(i){const l=e.HEAPU8.length;i=i>>>0;const A=v();if(i>A)return!1;for(let O=1;O<=4;O*=2){let p=l*(1+.2/O);p=Math.min(p,i+100663296);const _=Math.min(A,M(Math.max(i,p),65536));if(o(_))return!0}return!1}const s=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function a(i,l,A=1024){const O=l+A;let p=l;for(;i[p]&&!(p>=O);)++p;if(p-l>16&&i.buffer&&s)return s.decode(i.subarray(l,p));let _="";for(;l<p;){let y=i[l++];if(!(y&128)){_+=String.fromCharCode(y);continue}const S=i[l++]&63;if((y&224)===192){_+=String.fromCharCode((y&31)<<6|S);continue}const E=i[l++]&63;if((y&240)===224?y=(y&15)<<12|S<<6|E:y=(y&7)<<18|S<<12|E<<6|i[l++]&63,y<65536)_+=String.fromCharCode(y);else{const x=y-65536;_+=String.fromCharCode(55296|x>>10,56320|x&1023)}}return _}function m(i,l){return i?a(e.HEAPU8,i,l):""}const u={emscripten_get_now:C,emscripten_memcpy_big:h,emscripten_resize_heap:f,fd_write:()=>0};async function w(){const i=await n({env:u,wasi_snapshot_preview1:u});t=i.memory,c(t.buffer),Object.assign(e,i),e.UTF8ToString=m}return await w(),e}var D=Object.defineProperty,I=(n,t,r)=>t in n?D(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,g=(n,t,r)=>(I(n,typeof t!="symbol"?t+"":t,r),r);let d=null;function V(n){throw new B(n.UTF8ToString(n.getLastOnigError()))}class b{constructor(t){g(this,"utf16Length"),g(this,"utf8Length"),g(this,"utf16Value"),g(this,"utf8Value"),g(this,"utf16OffsetToUtf8"),g(this,"utf8OffsetToUtf16");const r=t.length,e=b._utf8ByteLength(t),c=e!==r,h=c?new Uint32Array(r+1):null;c&&(h[r]=e);const o=c?new Uint32Array(e+1):null;c&&(o[e]=r);const f=new Uint8Array(e);let s=0;for(let a=0;a<r;a++){const m=t.charCodeAt(a);let u=m,w=!1;if(m>=55296&&m<=56319&&a+1<r){const i=t.charCodeAt(a+1);i>=56320&&i<=57343&&(u=(m-55296<<10)+65536|i-56320,w=!0)}c&&(h[a]=s,w&&(h[a+1]=s),u<=127?o[s+0]=a:u<=2047?(o[s+0]=a,o[s+1]=a):u<=65535?(o[s+0]=a,o[s+1]=a,o[s+2]=a):(o[s+0]=a,o[s+1]=a,o[s+2]=a,o[s+3]=a)),u<=127?f[s++]=u:u<=2047?(f[s++]=192|(u&1984)>>>6,f[s++]=128|(u&63)>>>0):u<=65535?(f[s++]=224|(u&61440)>>>12,f[s++]=128|(u&4032)>>>6,f[s++]=128|(u&63)>>>0):(f[s++]=240|(u&1835008)>>>18,f[s++]=128|(u&258048)>>>12,f[s++]=128|(u&4032)>>>6,f[s++]=128|(u&63)>>>0),w&&a++}this.utf16Length=r,this.utf8Length=e,this.utf16Value=t,this.utf8Value=f,this.utf16OffsetToUtf8=h,this.utf8OffsetToUtf16=o}static _utf8ByteLength(t){let r=0;for(let e=0,c=t.length;e<c;e++){const h=t.charCodeAt(e);let o=h,f=!1;if(h>=55296&&h<=56319&&e+1<c){const s=t.charCodeAt(e+1);s>=56320&&s<=57343&&(o=(h-55296<<10)+65536|s-56320,f=!0)}o<=127?r+=1:o<=2047?r+=2:o<=65535?r+=3:r+=4,f&&e++}return r}createString(t){const r=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,r),r}}const U=class{constructor(n){if(g(this,"id",++U.LAST_ID),g(this,"_onigBinding"),g(this,"content"),g(this,"utf16Length"),g(this,"utf8Length"),g(this,"utf16OffsetToUtf8"),g(this,"utf8OffsetToUtf16"),g(this,"ptr"),!d)throw new B("Must invoke loadWasm first.");this._onigBinding=d,this.content=n;const t=new b(n);this.utf16Length=t.utf16Length,this.utf8Length=t.utf8Length,this.utf16OffsetToUtf8=t.utf16OffsetToUtf8,this.utf8OffsetToUtf16=t.utf8OffsetToUtf16,this.utf8Length<1e4&&!U._sharedPtrInUse?(U._sharedPtr||(U._sharedPtr=d.omalloc(1e4)),U._sharedPtrInUse=!0,d.HEAPU8.set(t.utf8Value,U._sharedPtr),this.ptr=U._sharedPtr):this.ptr=t.createString(d)}convertUtf8OffsetToUtf16(n){return this.utf8OffsetToUtf16?n<0?0:n>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[n]:n}convertUtf16OffsetToUtf8(n){return this.utf16OffsetToUtf8?n<0?0:n>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[n]:n}dispose(){this.ptr===U._sharedPtr?U._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};let L=U;g(L,"LAST_ID",0);g(L,"_sharedPtr",0);g(L,"_sharedPtrInUse",!1);class N{constructor(t){if(g(this,"_onigBinding"),g(this,"_ptr"),!d)throw new B("Must invoke loadWasm first.");const r=[],e=[];for(let f=0,s=t.length;f<s;f++){const a=new b(t[f]);r[f]=a.createString(d),e[f]=a.utf8Length}const c=d.omalloc(4*t.length);d.HEAPU32.set(r,c/4);const h=d.omalloc(4*t.length);d.HEAPU32.set(e,h/4);const o=d.createOnigScanner(c,h,t.length);for(let f=0,s=t.length;f<s;f++)d.ofree(r[f]);d.ofree(h),d.ofree(c),o===0&&V(d),this._onigBinding=d,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,r,e){let c=0;if(typeof e=="number"&&(c=e),typeof t=="string"){t=new L(t);const h=this._findNextMatchSync(t,r,!1,c);return t.dispose(),h}return this._findNextMatchSync(t,r,!1,c)}_findNextMatchSync(t,r,e,c){const h=this._onigBinding,o=h.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(r),c);if(o===0)return null;const f=h.HEAPU32;let s=o/4;const a=f[s++],m=f[s++],u=[];for(let w=0;w<m;w++){const i=t.convertUtf8OffsetToUtf16(f[s++]),l=t.convertUtf8OffsetToUtf16(f[s++]);u[w]={start:i,end:l,length:l-i}}return{index:a,captureIndices:u}}}function k(n){return typeof n.instantiator=="function"}function j(n){return typeof n.default=="function"}function F(n){return typeof n.data<"u"}function R(n){return typeof Response<"u"&&n instanceof Response}function z(n){return typeof ArrayBuffer<"u"&&(n instanceof ArrayBuffer||ArrayBuffer.isView(n))||typeof Buffer<"u"&&Buffer.isBuffer?.(n)||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&n instanceof Uint32Array}let T;function G(n){if(T)return T;async function t(){d=await H(async r=>{let e=n;return e=await e,typeof e=="function"&&(e=await e(r)),typeof e=="function"&&(e=await e(r)),k(e)?e=await e.instantiator(r):j(e)?e=await e.default(r):(F(e)&&(e=e.data),R(e)?typeof WebAssembly.instantiateStreaming=="function"?e=await J(e)(r):e=await K(e)(r):z(e)?e=await P(e)(r):e instanceof WebAssembly.Module?e=await P(e)(r):"default"in e&&e.default instanceof WebAssembly.Module&&(e=await P(e.default)(r))),"instance"in e&&(e=e.instance),"exports"in e&&(e=e.exports),e})}return T=t(),T}function P(n){return t=>WebAssembly.instantiate(n,t)}function J(n){return t=>WebAssembly.instantiateStreaming(n,t)}function K(n){return async t=>{const r=await n.arrayBuffer();return WebAssembly.instantiate(r,t)}}let W;function X(n){W=n}function Y(){return W}async function Q(n){return n&&await G(n),{createScanner(t){return new N(t.map(r=>typeof r=="string"?r:r.source))},createString(t){return new L(t)}}}async function Z(n){return Q(n)}export{Q as createOnigurumaEngine,Z as createWasmOnigEngine,Y as getDefaultWasmLoader,G as loadWasm,X as setDefaultWasmLoader};