66 lines
91 KiB
JavaScript
66 lines
91 KiB
JavaScript
import{i as B,m as N,j as d,g as p,h as Se}from"./krC2xWPP.js";function Xt(){if(typeof window>"u")return"";const t=window.__GRAV_CONFIG__;return t?.basePath||t?.serverUrl||""}function Ce(t){const e=Xt();return e?`${t}::${e}`:t}const pt=Ce("grav_admin_auth");function Vt(){try{const t=localStorage.getItem(pt);return t?JSON.parse(t):null}catch{return null}}function fe(t){try{const e=t.split(".");if(e.length<2)return null;const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),n=r+"=".repeat((4-r.length%4)%4),s=JSON.parse(atob(n));return typeof s.exp!="number"?null:s.exp*1e3}catch{return null}}function qt(){return typeof window<"u"&&window.__GRAV_CONFIG__?window.__GRAV_CONFIG__:null}function jt(){const t=Vt(),e=qt();let r=B(N(e?.serverUrl??t?.serverUrl??"")),n=B(N(t?.environment??e?.environment??"")),s=B(N(e?.apiPrefix??t?.apiPrefix??"/api/v1")),i=B(N(t?.accessToken??"")),a=B(N(t?.refreshToken??"")),l=B(N(t?.expiresAt??0)),o=B(N(t?.username??"")),c=B(N(t?.fullname??"")),h=B(N(t?.email??"")),u=B(N(t?.avatarUrl??"")),f=B(""),m=B(N(t?.superAdmin??!1)),b=B(N(t?.access??{})),T=B(N(t?.gravVersion??"")),$=B(N(t?.adminVersion??""));const V=Se(()=>!!p(i)&&Date.now()<p(l)),_=Se(()=>!!p(i)&&p(l)-Date.now()<300*1e3),v=Se(()=>p(m)),H=e!==null;function S(){const x={serverUrl:p(r),environment:p(n),apiPrefix:p(s),accessToken:p(i),refreshToken:p(a),expiresAt:p(l),username:p(o),fullname:p(c),email:p(h),avatarUrl:p(u),superAdmin:p(m),access:p(b),gravVersion:p(T),adminVersion:p($)};localStorage.setItem(pt,JSON.stringify(x))}return{get serverUrl(){return p(r)},set serverUrl(x){d(r,x,!0),S()},get environment(){return p(n)},set environment(x){d(n,x,!0),S()},get gravEnvironment(){return p(n)||"default"},get apiPrefix(){return p(s)},set apiPrefix(x){d(s,x,!0),S()},get accessToken(){return p(i)},get refreshToken(){return p(a)},get expiresAt(){return p(l)},get username(){return p(o)},get fullname(){return p(c)},get email(){return p(h)},get avatarUrl(){return p(u)},get contentEditor(){return p(f)},get isAuthenticated(){return p(V)},get isExpiringSoon(){return p(_)},get isSuperAdmin(){return p(v)},get access(){return p(b)},get hasGravConfig(){return H},get gravVersion(){return p(T)},get adminVersion(){return p($)},setTokens(x,M,j){d(i,x,!0),d(a,M,!0),d(l,Date.now()+j*1e3),S()},setUser(x,M,j="",ne,K){d(o,x,!0),d(c,M,!0),d(h,j,!0),ne!==void 0&&ne!==""&&d(u,ne,!0),K!==void 0&&d(f,K,!0),S()},setPermissions(x,M){d(m,x,!0),d(b,M,!0),S()},setVersions(x,M){x&&d(T,x,!0),M&&d($,M,!0),S()},setServer(x,M,j="/api/v1"){d(r,x.replace(/\/+$/,""),!0),d(n,M,!0),d(s,j,!0),S()},logout(){d(i,""),d(a,""),d(l,0),d(o,""),d(c,""),d(h,""),d(u,""),d(m,!1),d(b,{},!0),S()}}}const R=jt(),Zt=6e4,Wt=5e3,Qt=3e4;function Jt(){let t=null,e=B(!1),r=[],n=!1;function s(){t&&(clearTimeout(t),t=null)}function i(){const _=R.accessToken;if(!_)return null;const H=fe(_)??R.expiresAt;if(!H)return null;const S=H-Date.now()-Zt;return Math.max(Wt,S)}async function a(){if(!R.refreshToken)return!1;try{const _=`${R.serverUrl}${R.apiPrefix||"/api/v1"}`,v=await fetch(`${_}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({refresh_token:R.refreshToken})});if(!v.ok)return!1;const H=await v.json(),S=H.data??H;return R.setTokens(S.access_token,S.refresh_token,S.expires_in),!0}catch{return!1}}function l(){s();const _=i();_!==null&&(t=setTimeout(async()=>{if(await a())l();else if(R.refreshToken){const H=fe(R.accessToken)??R.expiresAt;H&&H<Date.now()?u():t=setTimeout(l,Qt)}else u()},_))}function o(){const _=fe(R.accessToken)??R.expiresAt;!R.accessToken||!_||(_<=Date.now()?u():l())}function c(){n||typeof window>"u"||(window.addEventListener("focus",o),n=!0)}function h(){!n||typeof window>"u"||(window.removeEventListener("focus",o),n=!1)}function u(){s(),d(e,!0)}function f(){d(e,!1)}function m(_){r.push(_),u()}async function b(_){const v=r;r=[];for(const H of v)try{const S=await _(H);H.resolve(S)}catch(S){H.reject(S)}}function T(_){const v=r;r=[];for(const H of v)H.reject(_)}function $(){c(),l()}function V(){s(),h(),T(new Error("Session stopped")),f()}return{get reauthOpen(){return p(e)},get pendingCount(){return r.length},start:$,stop:V,schedule:l,openReauth:u,closeReauth:f,enqueuePendingRequest:m,retryPending:b,rejectPending:T,performRefresh:a}}const Z=Jt();function je(t){const e=t.split(":");return{tag:t,resource:e[0]??"",action:e[1]??"",id:e.length>2?e.slice(2).join(":"):void 0}}function Yt(t,e){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++){const n=e[r],s=t[r];if(n!=="*"&&n!==s)return!1}return!0}function Kt(){const t=new Set;return{emit(e){const r=Array.isArray(e)?e:[e];for(const n of r){const s=typeof n=="string"?je(n):n,i=s.tag.split(":");for(const a of t)if(Yt(i,a.segments)&&!a.dirtyGuard?.())try{a.handler(s)}catch(l){console.error("[invalidation] subscriber error for",s.tag,l)}}},subscribe(e,r,n={}){const s={pattern:e,segments:e.split(":"),handler:r,dirtyGuard:n.dirtyGuard};return t.add(s),()=>{t.delete(s)}},subscribeResource(e,r,n={}){return this.subscribe(`${e}:*`,r,n)},parseTag:je,get subscriberCount(){return t.size}}}const er=Kt();class q extends Error{constructor(e,r){super(e.detail||e.title),this.error=e,this.response=r,this.name="ApiRequestError"}get status(){return this.error.status}}const tr=6e4,Ze=new Set(["DELETE","PATCH","PUT"]),ft="grav_admin_method_override";function rr(){try{return sessionStorage.getItem(ft)==="1"}catch{return!1}}function nr(){try{sessionStorage.setItem(ft,"1")}catch{}}class sr{refreshPromise=null;get baseUrl(){const e=R.serverUrl,r=R.apiPrefix||"/api/v1";return`${e}${r}`}get headers(){const e={"Content-Type":"application/json",Accept:"application/json"},r=R.accessToken;return r&&(e["X-API-Token"]=r),this.applyEnvironmentHeaders(e),e}get authHeaders(){const e={Accept:"application/json"},r=R.accessToken;return r&&(e["X-API-Token"]=r),this.applyEnvironmentHeaders(e),e}applyEnvironmentHeaders(e){const r=R.gravEnvironment;e["X-Grav-Environment"]=r,e["X-Config-Environment"]=r}parseInvalidates(e){const r=e.headers.get("X-Invalidates");if(!r)return;const n=r.split(",").map(s=>s.trim()).filter(Boolean);n.length>0&&er.emit(n)}async ensureFreshToken(e){if(e.startsWith("/auth/"))return;const r=R.accessToken;if(!r)return;const n=fe(r)??R.expiresAt;!n||n-Date.now()>tr||await this.tryRefresh()}async handleResponse(e){if(e.ok&&this.parseInvalidates(e),e.status===204)return;const r=await e.json().catch(()=>null);if(!e.ok){const n=r??{status:e.status,title:e.statusText,detail:`Request failed with status ${e.status}`};throw new q(n,e)}return r?.data!==void 0?r.data:r}async request(e,r,n={}){await this.ensureFreshToken(r);let s=`${this.baseUrl}${r}`;if(n.params){const h=new URLSearchParams(n.params);s+=`?${h.toString()}`}const i=e.toUpperCase(),a=Ze.has(i)&&rr(),l={...this.headers,...n.headers};a&&(l["X-HTTP-Method-Override"]=i);const o={method:a?"POST":e,headers:l};n.body!==void 0&&(o.body=JSON.stringify(n.body));let c;try{c=await fetch(s,o)}catch{throw new q({status:0,title:"Network Error",detail:"Unable to connect to the server. Check your connection and server URL."},new Response(null,{status:0}))}return c.status===401&&!r.startsWith("/auth/")&&n.retry!==!1?await this.tryRefresh()?this.request(e,r,{...n,retry:!1}):this.enqueueForReauth(e,r,n):c.status===405&&!a&&Ze.has(i)&&n.overrideRetry!==!1?(nr(),this.request(e,r,{...n,overrideRetry:!1})):this.handleResponse(c)}enqueueForReauth(e,r,n){return new Promise((s,i)=>{const a={method:e,path:r,body:n.body,params:n.params,headers:n.headers,resolve:s,reject:i};Z.enqueuePendingRequest(a)})}async retryPending(e){return this.request(e.method,e.path,{body:e.body,params:e.params,headers:e.headers,retry:!1})}async tryRefresh(){if(!R.refreshToken)return!1;this.refreshPromise||(this.refreshPromise=Z.performRefresh());try{return await this.refreshPromise}finally{this.refreshPromise=null}}async requestRaw(e,r,n={}){await this.ensureFreshToken(r);let s=`${this.baseUrl}${r}`;if(n.params){const c=new URLSearchParams(n.params);s+=`?${c.toString()}`}const i={method:e,headers:{...this.headers,...n.headers}};n.body!==void 0&&(i.body=JSON.stringify(n.body));const a=await fetch(s,i);if(a.status===401&&!r.startsWith("/auth/")&&n.retry!==!1)return await this.tryRefresh()?this.requestRaw(e,r,{...n,retry:!1}):new Promise((h,u)=>{Z.enqueuePendingRequest({method:e,path:r,body:n.body,params:n.params,headers:n.headers,resolve:f=>h(f),reject:u})});if(a.ok&&this.parseInvalidates(a),a.status===204)return{data:void 0,headers:a.headers};const l=await a.json().catch(()=>null);if(!a.ok){const c=l??{status:a.status,title:a.statusText,detail:`Request failed with status ${a.status}`};throw new q(c,a)}return{data:l?.data!==void 0?l.data:l,meta:l?.meta,headers:a.headers}}async getFullBody(e,r,n={}){await this.ensureFreshToken(e);let s=`${this.baseUrl}${e}`;if(r){const l=new URLSearchParams(r);s+=`?${l.toString()}`}const i=await fetch(s,{method:"GET",headers:this.headers});if(i.status===401&&!e.startsWith("/auth/")&&n.retry!==!1)return await this.tryRefresh()?this.getFullBody(e,r,{retry:!1}):new Promise((o,c)=>{Z.enqueuePendingRequest({method:"GET_FULL",path:e,params:r,resolve:h=>o(h),reject:c})});i.ok&&this.parseInvalidates(i);const a=await i.json().catch(()=>null);if(!i.ok){const l=a??{status:i.status,title:i.statusText,detail:`Request failed with status ${i.status}`};throw new q(l,i)}return a}async ensureAuth(){return R.accessToken?(await this.ensureFreshToken("/ensure-auth"),!!R.accessToken):!1}async get(e,r){return this.request("GET",e,{params:r})}async post(e,r){return this.request("POST",e,{body:r})}async patch(e,r){return this.request("PATCH",e,{body:r})}async delete(e,r){return this.request("DELETE",e,{body:r})}async uploadFile(e,r,n={}){await this.ensureFreshToken(e);const s=`${this.baseUrl}${e}`,i=n.method??"POST";let a;if(r instanceof FormData)a=r;else if(a=new FormData,a.append(n.fieldName??"file",r),n.fields)for(const[o,c]of Object.entries(n.fields))a.append(o,c);let l;try{l=await fetch(s,{method:i,headers:this.authHeaders,body:a})}catch{throw new q({status:0,title:"Network Error",detail:"Unable to connect to the server. Check your connection and server URL."},new Response(null,{status:0}))}return l.status===401&&!e.startsWith("/auth/")&&n.retry!==!1?await this.tryRefresh()?this.uploadFile(e,r,{...n,retry:!1}):new Promise((c,h)=>{Z.enqueuePendingRequest({method:"UPLOAD",path:e,body:r,headers:n,resolve:u=>c(u),reject:h})}):this.handleResponse(l)}async fetchBlob(e,r={}){const n=/^https?:\/\//i.test(e),s=n?e:`${this.baseUrl}${e}`;n||await this.ensureFreshToken(e);const i=await fetch(s,{method:"GET",headers:this.authHeaders});if(i.status===401&&r.retry!==!1)return await this.tryRefresh()?this.fetchBlob(e,{retry:!1}):new Promise((o,c)=>{Z.enqueuePendingRequest({method:"BLOB",path:e,resolve:h=>o(h),reject:c})});if(!i.ok)throw new q({status:i.status,title:i.statusText,detail:`Download failed (status ${i.status})`},i);return{blob:await i.blob(),headers:i.headers}}async fetchScript(e,r={}){const n=/^https?:\/\//i.test(e),s=n?e:`${this.baseUrl}${e}`;n||await this.ensureFreshToken(e);const i=await fetch(s,{method:"GET",headers:this.authHeaders});if(i.status===401&&r.retry!==!1)return await this.tryRefresh()?this.fetchScript(e,{retry:!1}):new Promise((l,o)=>{Z.enqueuePendingRequest({method:"SCRIPT",path:e,resolve:c=>l(c),reject:o})});if(!i.ok)throw new q({status:i.status,title:i.statusText,detail:`Failed to fetch script (status ${i.status})`},i);return i.text()}beaconPost(e,r){try{const n=`${this.baseUrl}${e}`;fetch(n,{method:"POST",headers:this.headers,body:JSON.stringify(r),keepalive:!0})}catch{}}}const W=new sr;typeof window<"u"&&(window.__apiClientRetry__=t=>t.method==="UPLOAD"?W.uploadFile(t.path,t.body,t.headers):t.method==="SCRIPT"?W.fetchScript(t.path):t.method==="BLOB"?W.fetchBlob(t.path):t.method==="GET_FULL"?W.getFullBody(t.path,t.params):W.retryPending(t));const Mn=Object.freeze(Object.defineProperty({__proto__:null,ApiRequestError:q,api:W},Symbol.toStringTag,{value:"Module"}));function _e(t,e){const r=e&&e.cache?e.cache:ur,n=e&&e.serializer?e.serializer:hr;return(e&&e.strategy?e.strategy:or)(t,{cache:r,serializer:n})}function ir(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ar(t,e,r,n){const s=ir(n)?n:r(n);let i=e.get(s);return typeof i>"u"&&(i=t.call(this,n),e.set(s,i)),i}function gt(t,e,r){const n=Array.prototype.slice.call(arguments,3),s=r(n);let i=e.get(s);return typeof i>"u"&&(i=t.apply(this,n),e.set(s,i)),i}function dt(t,e,r,n,s){return r.bind(e,t,n,s)}function or(t,e){const r=t.length===1?ar:gt;return dt(t,this,r,e.cache.create(),e.serializer)}function lr(t,e){return dt(t,this,gt,e.cache.create(),e.serializer)}const hr=function(){return JSON.stringify(arguments)};var cr=class{constructor(){this.cache=Object.create(null)}get(t){return this.cache[t]}set(t,e){this.cache[t]=e}};const ur={create:function(){return new cr}},Ae={variadic:lr},pr=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function fr(t){const e={};return t.replace(pr,r=>{const n=r.length;switch(r[0]){case"G":e.era=n===4?"long":n===5?"narrow":"short";break;case"y":e.year=n===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":e.month=["numeric","2-digit","short","long","narrow"][n-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":e.day=["numeric","2-digit"][n-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":e.weekday=n===4?"long":n===5?"narrow":"short";break;case"e":if(n<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][n-4];break;case"c":if(n<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][n-4];break;case"a":e.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":e.hourCycle="h12",e.hour=["numeric","2-digit"][n-1];break;case"H":e.hourCycle="h23",e.hour=["numeric","2-digit"][n-1];break;case"K":e.hourCycle="h11",e.hour=["numeric","2-digit"][n-1];break;case"k":e.hourCycle="h24",e.hour=["numeric","2-digit"][n-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":e.minute=["numeric","2-digit"][n-1];break;case"s":e.second=["numeric","2-digit"][n-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":e.timeZoneName=n<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),e}const gr=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function dr(t){if(t.length===0)throw new Error("Number skeleton cannot be empty");const e=t.split(gr).filter(n=>n.length>0),r=[];for(const n of e){let s=n.split("/");if(s.length===0)throw new Error("Invalid number skeleton");const[i,...a]=s;for(const l of a)if(l.length===0)throw new Error("Invalid number skeleton");r.push({stem:i,options:a})}return r}function mr(t){return t.replace(/^(.*?)-/,"")}const We=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,mt=/^(@+)?(\+|#+)?[rs]?$/g,br=/(\*)(0+)|(#+)(0+)|(0+)/g,bt=/^(0+)$/;function Qe(t){const e={};return t[t.length-1]==="r"?e.roundingPriority="morePrecision":t[t.length-1]==="s"&&(e.roundingPriority="lessPrecision"),t.replace(mt,function(r,n,s){return typeof s!="string"?(e.minimumSignificantDigits=n.length,e.maximumSignificantDigits=n.length):s==="+"?e.minimumSignificantDigits=n.length:n[0]==="#"?e.maximumSignificantDigits=n.length:(e.minimumSignificantDigits=n.length,e.maximumSignificantDigits=n.length+(typeof s=="string"?s.length:0)),""}),e}function kt(t){switch(t){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function kr(t){let e;if(t[0]==="E"&&t[1]==="E"?(e={notation:"engineering"},t=t.slice(2)):t[0]==="E"&&(e={notation:"scientific"},t=t.slice(1)),e){const r=t.slice(0,2);if(r==="+!"?(e.signDisplay="always",t=t.slice(2)):r==="+?"&&(e.signDisplay="exceptZero",t=t.slice(2)),!bt.test(t))throw new Error("Malformed concise eng/scientific notation");e.minimumIntegerDigits=t.length}return e}function Je(t){const e={},r=kt(t);return r||e}function yr(t){let e={};for(const r of t){switch(r.stem){case"percent":case"%":e.style="percent";continue;case"%x100":e.style="percent",e.scale=100;continue;case"currency":e.style="currency",e.currency=r.options[0];continue;case"group-off":case",_":e.useGrouping=!1;continue;case"precision-integer":case".":e.maximumFractionDigits=0;continue;case"measure-unit":case"unit":e.style="unit",e.unit=mr(r.options[0]);continue;case"compact-short":case"K":e.notation="compact",e.compactDisplay="short";continue;case"compact-long":case"KK":e.notation="compact",e.compactDisplay="long";continue;case"scientific":e={...e,notation:"scientific",...r.options.reduce((i,a)=>({...i,...Je(a)}),{})};continue;case"engineering":e={...e,notation:"engineering",...r.options.reduce((i,a)=>({...i,...Je(a)}),{})};continue;case"notation-simple":e.notation="standard";continue;case"unit-width-narrow":e.currencyDisplay="narrowSymbol",e.unitDisplay="narrow";continue;case"unit-width-short":e.currencyDisplay="code",e.unitDisplay="short";continue;case"unit-width-full-name":e.currencyDisplay="name",e.unitDisplay="long";continue;case"unit-width-iso-code":e.currencyDisplay="symbol";continue;case"scale":e.scale=parseFloat(r.options[0]);continue;case"rounding-mode-floor":e.roundingMode="floor";continue;case"rounding-mode-ceiling":e.roundingMode="ceil";continue;case"rounding-mode-down":e.roundingMode="trunc";continue;case"rounding-mode-up":e.roundingMode="expand";continue;case"rounding-mode-half-even":e.roundingMode="halfEven";continue;case"rounding-mode-half-down":e.roundingMode="halfTrunc";continue;case"rounding-mode-half-up":e.roundingMode="halfExpand";continue;case"integer-width":if(r.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");r.options[0].replace(br,function(i,a,l,o,c,h){if(a)e.minimumIntegerDigits=l.length;else{if(o&&c)throw new Error("We currently do not support maximum integer digits");if(h)throw new Error("We currently do not support exact integer digits")}return""});continue}if(bt.test(r.stem)){e.minimumIntegerDigits=r.stem.length;continue}if(We.test(r.stem)){if(r.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");r.stem.replace(We,function(a,l,o,c,h,u){return o==="*"?e.minimumFractionDigits=l.length:c&&c[0]==="#"?e.maximumFractionDigits=c.length:h&&u?(e.minimumFractionDigits=h.length,e.maximumFractionDigits=h.length+u.length):(e.minimumFractionDigits=l.length,e.maximumFractionDigits=l.length),""});const i=r.options[0];i==="w"?e={...e,trailingZeroDisplay:"stripIfInteger"}:i&&(e={...e,...Qe(i)});continue}if(mt.test(r.stem)){e={...e,...Qe(r.stem)};continue}const n=kt(r.stem);n&&(e={...e,...n});const s=kr(r.stem);s&&(e={...e,...s})}return e}let w=(function(t){return t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG",t})({}),I=(function(t){return t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag",t})({}),de=(function(t){return t[t.number=0]="number",t[t.dateTime=1]="dateTime",t})({});function Ye(t){return t.type===I.literal}function wr(t){return t.type===I.argument}function yt(t){return t.type===I.number}function wt(t){return t.type===I.date}function Et(t){return t.type===I.time}function Tt(t){return t.type===I.select}function xt(t){return t.type===I.plural}function Er(t){return t.type===I.pound}function St(t){return t.type===I.tag}function _t(t){return!!(t&&typeof t=="object"&&t.type===de.number)}function He(t){return!!(t&&typeof t=="object"&&t.type===de.dateTime)}const At=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,ce={"001":["H","h"],419:["h","H","hB","hb"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["h","H","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["h","H","hB","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["h","H","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["h","H","hB","hb"],CU:["h","H","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["h","H","hB","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GS:["H","h","hb","hB"],GT:["h","H","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["h","H","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["h","H","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["h","H","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["h","H","hB","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["h","H","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["h","H","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["h","H","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"en-HK":["h","hb","H","hB"],"en-IL":["H","h","hb","hB"],"en-MY":["h","hb","H","hB"],"es-BR":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ku-SY":["H","hB"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function Tr(t,e){let r="";for(let n=0;n<t.length;n++){const s=t.charAt(n);if(s==="j"){let i=0;for(;n+1<t.length&&t.charAt(n+1)===s;)i++,n++;let a=1+(i&1),l=i<2?1:3+(i>>1),o="a",c=xr(e);for((c=="H"||c=="k")&&(l=0);l-- >0;)r+=o;for(;a-- >0;)r=c+r}else s==="J"?r+="H":r+=s}return r}function xr(t){let e=t.hourCycle;if(e===void 0&&t.hourCycles&&t.hourCycles.length&&(e=t.hourCycles[0]),e)switch(e){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}const r=t.language;let n;return r!=="root"&&(n=t.maximize().region),(ce[n||""]||ce[r||""]||ce[`${r}-001`]||ce["001"])[0]}const Sr=new RegExp(`^${At.source}*`),_r=new RegExp(`${At.source}*$`);function k(t,e){return{start:t,end:e}}const Ar=!!Object.fromEntries,Rr=!!String.prototype.trimStart,Hr=!!String.prototype.trimEnd,Ke=Ar?Object.fromEntries:function(e){const r={};for(const[n,s]of e)r[n]=s;return r},Br=Rr?function(e){return e.trimStart()}:function(e){return e.replace(Sr,"")},Ir=Hr?function(e){return e.trimEnd()}:function(e){return e.replace(_r,"")},et=new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");function Pr(t,e){return et.lastIndex=e,et.exec(t)[1]??""}var Lr=class{constructor(t,e={}){this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!e.ignoreTag,this.locale=e.locale,this.requiresOtherClause=!!e.requiresOtherClause,this.shouldParseSkeletons=!!e.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)}parseMessage(t,e,r){let n=[];for(;!this.isEOF();){const s=this.char();if(s===123){const i=this.parseArgument(t,r);if(i.err)return i;n.push(i.val)}else{if(s===125&&t>0)break;if(s===35&&(e==="plural"||e==="selectordinal")){const i=this.clonePosition();this.bump(),n.push({type:I.pound,location:k(i,this.clonePosition())})}else if(s===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(w.UNMATCHED_CLOSING_TAG,k(this.clonePosition(),this.clonePosition()))}else if(s===60&&!this.ignoreTag&&Be(this.peek()||0)){const i=this.parseTag(t,e);if(i.err)return i;n.push(i.val)}else{const i=this.parseLiteral(t,e);if(i.err)return i;n.push(i.val)}}}return{val:n,err:null}}parseTag(t,e){const r=this.clonePosition();this.bump();const n=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:I.literal,value:`<${n}/>`,location:k(r,this.clonePosition())},err:null};if(this.bumpIf(">")){const s=this.parseMessage(t+1,e,!0);if(s.err)return s;const i=s.val,a=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!Be(this.char()))return this.error(w.INVALID_TAG,k(a,this.clonePosition()));const l=this.clonePosition();return n!==this.parseTagName()?this.error(w.UNMATCHED_CLOSING_TAG,k(l,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:I.tag,value:n,children:i,location:k(r,this.clonePosition())},err:null}:this.error(w.INVALID_TAG,k(a,this.clonePosition())))}else return this.error(w.UNCLOSED_TAG,k(r,this.clonePosition()))}else return this.error(w.INVALID_TAG,k(r,this.clonePosition()))}parseTagName(){const t=this.offset();for(this.bump();!this.isEOF()&&Cr(this.char());)this.bump();return this.message.slice(t,this.offset())}parseLiteral(t,e){const r=this.clonePosition();let n="";for(;;){const i=this.tryParseQuote(e);if(i){n+=i;continue}const a=this.tryParseUnquoted(t,e);if(a){n+=a;continue}const l=this.tryParseLeftAngleBracket();if(l){n+=l;continue}break}const s=k(r,this.clonePosition());return{val:{type:I.literal,value:n,location:s},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Nr(this.peek()||0))?(this.bump(),"<"):null}tryParseQuote(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();const e=[this.char()];for(this.bump();!this.isEOF();){const r=this.char();if(r===39)if(this.peek()===39)e.push(39),this.bump();else{this.bump();break}else e.push(r);this.bump()}return String.fromCodePoint(...e)}tryParseUnquoted(t,e){if(this.isEOF())return null;const r=this.char();return r===60||r===123||r===35&&(e==="plural"||e==="selectordinal")||r===125&&t>0?null:(this.bump(),String.fromCodePoint(r))}parseArgument(t,e){const r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(w.EXPECT_ARGUMENT_CLOSING_BRACE,k(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(w.EMPTY_ARGUMENT,k(r,this.clonePosition()));let n=this.parseIdentifierIfPossible().value;if(!n)return this.error(w.MALFORMED_ARGUMENT,k(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(w.EXPECT_ARGUMENT_CLOSING_BRACE,k(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:I.argument,value:n,location:k(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(w.EXPECT_ARGUMENT_CLOSING_BRACE,k(r,this.clonePosition())):this.parseArgumentOptions(t,e,n,r);default:return this.error(w.MALFORMED_ARGUMENT,k(r,this.clonePosition()))}}parseIdentifierIfPossible(){const t=this.clonePosition(),e=this.offset(),r=Pr(this.message,e),n=e+r.length;return this.bumpTo(n),{value:r,location:k(t,this.clonePosition())}}parseArgumentOptions(t,e,r,n){let s=this.clonePosition(),i=this.parseIdentifierIfPossible().value,a=this.clonePosition();switch(i){case"":return this.error(w.EXPECT_ARGUMENT_TYPE,k(s,a));case"number":case"date":case"time":{this.bumpSpace();let l=null;if(this.bumpIf(",")){this.bumpSpace();const h=this.clonePosition(),u=this.parseSimpleArgStyleIfPossible();if(u.err)return u;const f=Ir(u.val);if(f.length===0)return this.error(w.EXPECT_ARGUMENT_STYLE,k(this.clonePosition(),this.clonePosition()));l={style:f,styleLocation:k(h,this.clonePosition())}}const o=this.tryParseArgumentClose(n);if(o.err)return o;const c=k(n,this.clonePosition());if(l&&l.style.startsWith("::")){let h=Br(l.style.slice(2));if(i==="number"){const u=this.parseNumberSkeletonFromString(h,l.styleLocation);return u.err?u:{val:{type:I.number,value:r,location:c,style:u.val},err:null}}else{if(h.length===0)return this.error(w.EXPECT_DATE_TIME_SKELETON,c);let u=h;this.locale&&(u=Tr(h,this.locale));const f={type:de.dateTime,pattern:u,location:l.styleLocation,parsedOptions:this.shouldParseSkeletons?fr(u):{}};return{val:{type:i==="date"?I.date:I.time,value:r,location:c,style:f},err:null}}}return{val:{type:i==="number"?I.number:i==="date"?I.date:I.time,value:r,location:c,style:l?.style??null},err:null}}case"plural":case"selectordinal":case"select":{const l=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(w.EXPECT_SELECT_ARGUMENT_OPTIONS,k(l,{...l}));this.bumpSpace();let o=this.parseIdentifierIfPossible(),c=0;if(i!=="select"&&o.value==="offset"){if(!this.bumpIf(":"))return this.error(w.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,k(this.clonePosition(),this.clonePosition()));this.bumpSpace();const m=this.tryParseDecimalInteger(w.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,w.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(m.err)return m;this.bumpSpace(),o=this.parseIdentifierIfPossible(),c=m.val}const h=this.tryParsePluralOrSelectOptions(t,i,e,o);if(h.err)return h;const u=this.tryParseArgumentClose(n);if(u.err)return u;const f=k(n,this.clonePosition());return i==="select"?{val:{type:I.select,value:r,options:Ke(h.val),location:f},err:null}:{val:{type:I.plural,value:r,options:Ke(h.val),offset:c,pluralType:i==="plural"?"cardinal":"ordinal",location:f},err:null}}default:return this.error(w.INVALID_ARGUMENT_TYPE,k(s,a))}}tryParseArgumentClose(t){return this.isEOF()||this.char()!==125?this.error(w.EXPECT_ARGUMENT_CLOSING_BRACE,k(t,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let t=0;const e=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let r=this.clonePosition();if(!this.bumpUntil("'"))return this.error(w.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,k(r,this.clonePosition()));this.bump();break}case 123:t+=1,this.bump();break;case 125:if(t>0)t-=1;else return{val:this.message.slice(e.offset,this.offset()),err:null};break;default:this.bump();break}return{val:this.message.slice(e.offset,this.offset()),err:null}}parseNumberSkeletonFromString(t,e){let r=[];try{r=dr(t)}catch{return this.error(w.INVALID_NUMBER_SKELETON,e)}return{val:{type:de.number,tokens:r,location:e,parsedOptions:this.shouldParseSkeletons?yr(r):{}},err:null}}tryParsePluralOrSelectOptions(t,e,r,n){let s=!1;const i=[],a=new Set;let{value:l,location:o}=n;for(;;){if(l.length===0){const f=this.clonePosition();if(e!=="select"&&this.bumpIf("=")){const m=this.tryParseDecimalInteger(w.EXPECT_PLURAL_ARGUMENT_SELECTOR,w.INVALID_PLURAL_ARGUMENT_SELECTOR);if(m.err)return m;o=k(f,this.clonePosition()),l=this.message.slice(f.offset,this.offset())}else break}if(a.has(l))return this.error(e==="select"?w.DUPLICATE_SELECT_ARGUMENT_SELECTOR:w.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,o);l==="other"&&(s=!0),this.bumpSpace();const c=this.clonePosition();if(!this.bumpIf("{"))return this.error(e==="select"?w.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:w.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,k(this.clonePosition(),this.clonePosition()));const h=this.parseMessage(t+1,e,r);if(h.err)return h;const u=this.tryParseArgumentClose(c);if(u.err)return u;i.push([l,{value:h.val,location:k(c,this.clonePosition())}]),a.add(l),this.bumpSpace(),{value:l,location:o}=this.parseIdentifierIfPossible()}return i.length===0?this.error(e==="select"?w.EXPECT_SELECT_ARGUMENT_SELECTOR:w.EXPECT_PLURAL_ARGUMENT_SELECTOR,k(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!s?this.error(w.MISSING_OTHER_CLAUSE,k(this.clonePosition(),this.clonePosition())):{val:i,err:null}}tryParseDecimalInteger(t,e){let r=1;const n=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);let s=!1,i=0;for(;!this.isEOF();){const l=this.char();if(l>=48&&l<=57)s=!0,i=i*10+(l-48),this.bump();else break}const a=k(n,this.clonePosition());return s?(i*=r,Number.isSafeInteger(i)?{val:i,err:null}:this.error(e,a)):this.error(t,a)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){const t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");const e=this.message.codePointAt(t);if(e===void 0)throw Error(`Offset ${t} is at invalid UTF-16 code unit boundary`);return e}error(t,e){return{val:null,err:{kind:t,message:this.message,location:e}}}bump(){if(this.isEOF())return;const t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}bumpIf(t){if(this.message.startsWith(t,this.offset())){for(let e=0;e<t.length;e++)this.bump();return!0}return!1}bumpUntil(t){const e=this.offset(),r=this.message.indexOf(t,e);return r>=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)}bumpTo(t){if(this.offset()>t)throw Error(`targetOffset ${t} must be greater than or equal to the current offset ${this.offset()}`);for(t=Math.min(t,this.message.length);;){const e=this.offset();if(e===t)break;if(e>t)throw Error(`targetOffset ${t} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&vr(this.char());)this.bump()}peek(){if(this.isEOF())return null;const t=this.char(),e=this.offset();return this.message.charCodeAt(e+(t>=65536?2:1))??null}};function Be(t){return t>=97&&t<=122||t>=65&&t<=90}function Nr(t){return Be(t)||t===47}function Cr(t){return t===45||t===46||t>=48&&t<=57||t===95||t>=97&&t<=122||t>=65&&t<=90||t==183||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8255&&t<=8256||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}function vr(t){return t>=9&&t<=13||t===32||t===133||t>=8206&&t<=8207||t===8232||t===8233}function Ie(t){t.forEach(e=>{if(delete e.location,Tt(e)||xt(e))for(const r in e.options)delete e.options[r].location,Ie(e.options[r].value);else yt(e)&&_t(e.style)||(wt(e)||Et(e))&&He(e.style)?delete e.style.location:St(e)&&Ie(e.children)})}function Ur(t,e={}){e={shouldParseSkeletons:!0,requiresOtherClause:!0,...e};const r=new Lr(t,e).parse();if(r.err){const n=SyntaxError(w[r.err.kind]);throw n.location=r.err.location,n.originalMessage=r.err.message,n}return e?.captureLocation||Ie(r.val),r.val}let ye=(function(t){return t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API",t})({});var we=class extends Error{constructor(t,e,r){super(t),this.code=e,this.originalMessage=r}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},tt=class extends we{constructor(t,e,r,n){super(`Invalid values for "${t}": "${e}". Options are "${Object.keys(r).join('", "')}"`,ye.INVALID_VALUE,n)}},Mr=class extends we{constructor(t,e,r){super(`Value for "${t}" must be of type ${e}`,ye.INVALID_VALUE,r)}},Or=class extends we{constructor(t,e){super(`The intl string context variable "${t}" was not provided to the string "${e}"`,ye.MISSING_VALUE,e)}};let D=(function(t){return t[t.literal=0]="literal",t[t.object=1]="object",t})({});function Dr(t){return t.length<2?t:t.reduce((e,r)=>{const n=e[e.length-1];return!n||n.type!==D.literal||r.type!==D.literal?e.push(r):n.value+=r.value,e},[])}function $r(t){return typeof t=="function"}function ge(t,e,r,n,s,i,a){if(t.length===1&&Ye(t[0]))return[{type:D.literal,value:t[0].value}];const l=[];for(const o of t){if(Ye(o)){l.push({type:D.literal,value:o.value});continue}if(Er(o)){typeof i=="number"&&l.push({type:D.literal,value:r.getNumberFormat(e).format(i)});continue}const{value:c}=o;if(!(s&&c in s))throw new Or(c,a);let h=s[c];if(wr(o)){(!h||typeof h=="string"||typeof h=="number"||typeof h=="bigint")&&(h=typeof h=="string"||typeof h=="number"||typeof h=="bigint"?String(h):""),l.push({type:typeof h=="string"?D.literal:D.object,value:h});continue}if(wt(o)){const u=typeof o.style=="string"?n.date[o.style]:He(o.style)?o.style.parsedOptions:void 0;l.push({type:D.literal,value:r.getDateTimeFormat(e,u).format(h)});continue}if(Et(o)){const u=typeof o.style=="string"?n.time[o.style]:He(o.style)?o.style.parsedOptions:n.time.medium;l.push({type:D.literal,value:r.getDateTimeFormat(e,u).format(h)});continue}if(yt(o)){const u=typeof o.style=="string"?n.number[o.style]:_t(o.style)?o.style.parsedOptions:void 0;if(u&&u.scale){const f=u.scale||1;if(typeof h=="bigint"){if(!Number.isInteger(f))throw new TypeError(`Cannot apply fractional scale ${f} to bigint value. Scale must be an integer when formatting bigint.`);h=h*BigInt(f)}else h=h*f}l.push({type:D.literal,value:r.getNumberFormat(e,u).format(h)});continue}if(St(o)){const{children:u,value:f}=o,m=s[f];if(!$r(m))throw new Mr(f,"function",a);let b=m(ge(u,e,r,n,s,i).map(T=>T.value));Array.isArray(b)||(b=[b]),l.push(...b.map(T=>({type:typeof T=="string"?D.literal:D.object,value:T})))}if(Tt(o)){const u=h,f=(Object.prototype.hasOwnProperty.call(o.options,u)?o.options[u]:void 0)||o.options.other;if(!f)throw new tt(o.value,h,Object.keys(o.options),a);l.push(...ge(f.value,e,r,n,s));continue}if(xt(o)){const u=`=${h}`;let f=Object.prototype.hasOwnProperty.call(o.options,u)?o.options[u]:void 0;if(!f){if(!Intl.PluralRules)throw new we(`Intl.PluralRules is not available in this environment.
|
||
Try polyfilling it using "@formatjs/intl-pluralrules"
|
||
`,ye.MISSING_INTL_API,a);const b=typeof h=="bigint"?Number(h):h,T=r.getPluralRules(e,{type:o.pluralType}).select(b-(o.offset||0));f=(Object.prototype.hasOwnProperty.call(o.options,T)?o.options[T]:void 0)||o.options.other}if(!f)throw new tt(o.value,h,Object.keys(o.options),a);const m=typeof h=="bigint"?Number(h):h;l.push(...ge(f.value,e,r,n,s,m-(o.offset||0)));continue}}return Dr(l)}function Gr(t,e){return e?{...t,...e,...Object.keys(t).reduce((r,n)=>(r[n]={...t[n],...e[n]},r),{})}:t}function Fr(t,e){return e?Object.keys(t).reduce((r,n)=>(r[n]=Gr(t[n],e[n]),r),{...t}):t}function Re(t){return{create(){return{get(e){return t[e]},set(e,r){t[e]=r}}}}}function zr(t={number:{},dateTime:{},pluralRules:{}}){return{getNumberFormat:_e((...e)=>new Intl.NumberFormat(...e),{cache:Re(t.number),strategy:Ae.variadic}),getDateTimeFormat:_e((...e)=>new Intl.DateTimeFormat(...e),{cache:Re(t.dateTime),strategy:Ae.variadic}),getPluralRules:_e((...e)=>new Intl.PluralRules(...e),{cache:Re(t.pluralRules),strategy:Ae.variadic})}}var C,Xr=(C=class{constructor(e,r=C.defaultLocale,n,s){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=i=>{const a=this.formatToParts(i);if(a.length===1)return a[0].value;const l=a.reduce((o,c)=>(!o.length||c.type!==D.literal||typeof o[o.length-1]!="string"?o.push(c.value):o[o.length-1]+=c.value,o),[]);return l.length<=1?l[0]||"":l},this.formatToParts=i=>ge(this.ast,this.locales,this.formatters,this.formats,i,void 0,this.message),this.resolvedOptions=()=>({locale:this.resolvedLocale?.toString()||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}),this.getAst=()=>this.ast,this.locales=r,this.resolvedLocale=C.resolveLocale(r),typeof e=="string"){if(this.message=e,!C.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");const{...i}=s||{};this.ast=C.__parse(e,{...i,locale:this.resolvedLocale})}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Fr(C.formats,n),this.formatters=s&&s.formatters||zr(this.formatterCache)}static get defaultLocale(){return C.memoizedDefaultLocale||(C.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),C.memoizedDefaultLocale}},C.memoizedDefaultLocale=null,C.resolveLocale=e=>{if(typeof Intl.Locale>"u")return;const r=Intl.NumberFormat.supportedLocalesOf(e);return r.length>0?new Intl.Locale(r[0]):new Intl.Locale(typeof e=="string"?e:e[0])},C.__parse=Ur,C.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},C);function ve(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Y=ve();function Rt(t){Y=t}var Q={exec:()=>null};function y(t,e=""){let r=typeof t=="string"?t:t.source,n={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(U.caret,"$1"),r=r.replace(s,a),n},getRegex:()=>new RegExp(r,e)};return n}var Vr=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),U={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},qr=/^(?:[ \t]*(?:\n|$))+/,jr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Zr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,he=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Wr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Bt=y(Ht).replace(/bull/g,Ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Qr=y(Ht).replace(/bull/g,Ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jr=/^[^\n]+/,Oe=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yr=y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Oe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Kr=y(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ue).getRegex(),Ee="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",De=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,en=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",De).replace("tag",Ee).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),It=y(Me).replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ee).getRegex(),tn=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",It).getRegex(),$e={blockquote:tn,code:jr,def:Yr,fences:Zr,heading:Wr,hr:he,html:en,lheading:Bt,list:Kr,newline:qr,paragraph:It,table:Q,text:Jr},rt=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ee).getRegex(),rn={...$e,lheading:Qr,table:rt,paragraph:y(Me).replace("hr",he).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ee).getRegex()},nn={...$e,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",De).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Q,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(Me).replace("hr",he).replace("heading",` *#{1,6} *[^
|
||
]`).replace("lheading",Bt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},sn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,an=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Pt=/^( {2,}|\\)\n(?!\s*$)/,on=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,re=/[\p{P}\p{S}]/u,Te=/[\s\p{P}\p{S}]/u,Ge=/[^\s\p{P}\p{S}]/u,ln=y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Te).getRegex(),Lt=/(?!~)[\p{P}\p{S}]/u,hn=/(?!~)[\s\p{P}\p{S}]/u,cn=/(?:[^\s\p{P}\p{S}]|~)/u,un=y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vr?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nt=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,pn=y(Nt,"u").replace(/punct/g,re).getRegex(),fn=y(Nt,"u").replace(/punct/g,Lt).getRegex(),Ct="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gn=y(Ct,"gu").replace(/notPunctSpace/g,Ge).replace(/punctSpace/g,Te).replace(/punct/g,re).getRegex(),dn=y(Ct,"gu").replace(/notPunctSpace/g,cn).replace(/punctSpace/g,hn).replace(/punct/g,Lt).getRegex(),mn=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ge).replace(/punctSpace/g,Te).replace(/punct/g,re).getRegex(),bn=y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,re).getRegex(),kn="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",yn=y(kn,"gu").replace(/notPunctSpace/g,Ge).replace(/punctSpace/g,Te).replace(/punct/g,re).getRegex(),wn=y(/\\(punct)/,"gu").replace(/punct/g,re).getRegex(),En=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Tn=y(De).replace("(?:-->|$)","-->").getRegex(),xn=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Tn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),me=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Sn=y(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",me).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),vt=y(/^!?\[(label)\]\[(ref)\]/).replace("label",me).replace("ref",Oe).getRegex(),Ut=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",Oe).getRegex(),_n=y("reflink|nolink(?!\\()","g").replace("reflink",vt).replace("nolink",Ut).getRegex(),nt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Fe={_backpedal:Q,anyPunctuation:wn,autolink:En,blockSkip:un,br:Pt,code:an,del:Q,delLDelim:Q,delRDelim:Q,emStrongLDelim:pn,emStrongRDelimAst:gn,emStrongRDelimUnd:mn,escape:sn,link:Sn,nolink:Ut,punctuation:ln,reflink:vt,reflinkSearch:_n,tag:xn,text:on,url:Q},An={...Fe,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",me).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me).getRegex()},Pe={...Fe,emStrongRDelimAst:dn,emStrongLDelim:fn,delLDelim:bn,delRDelim:yn,url:y(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:y(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",nt).getRegex()},Rn={...Pe,br:y(Pt).replace("{2,}","*").getRegex(),text:y(Pe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ue={normal:$e,gfm:rn,pedantic:nn},ie={normal:Fe,gfm:Pe,breaks:Rn,pedantic:An},Hn={"&":"&","<":"<",">":">",'"':""","'":"'"},st=t=>Hn[t];function X(t,e){if(e){if(U.escapeTest.test(t))return t.replace(U.escapeReplace,st)}else if(U.escapeTestNoEncode.test(t))return t.replace(U.escapeReplaceNoEncode,st);return t}function it(t){try{t=encodeURI(t).replace(U.percentDecode,"%")}catch{return null}return t}function at(t,e){let r=t.replace(U.findPipe,(i,a,l)=>{let o=!1,c=a;for(;--c>=0&&l[c]==="\\";)o=!o;return o?"|":" |"}),n=r.split(U.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(U.slashPipe,"|");return n}function ae(t,e,r){let n=t.length;if(n===0)return"";let s=0;for(;s<n&&t.charAt(n-s-1)===e;)s++;return t.slice(0,n-s)}function Bn(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function In(t,e=0){let r=e,n="";for(let s of t)if(s===" "){let i=4-r%4;n+=" ".repeat(i),r+=i}else n+=s,r++;return n}function ot(t,e,r,n,s){let i=e.href,a=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let o={type:t[0].charAt(0)==="!"?"image":"link",raw:r,href:i,title:a,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,o}function Pn(t,e,r){let n=t.match(r.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(`
|
||
`).map(i=>{let a=i.match(r.other.beginningSpace);if(a===null)return i;let[l]=a;return l.length>=s.length?i.slice(s.length):i}).join(`
|
||
`)}var be=class{options;rules;lexer;constructor(t){this.options=t||Y}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:ae(r,`
|
||
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],n=Pn(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let n=ae(r,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(r=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:ae(e[0],`
|
||
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=ae(e[0],`
|
||
`).split(`
|
||
`),n="",s="",i=[];for(;r.length>0;){let a=!1,l=[],o;for(o=0;o<r.length;o++)if(this.rules.other.blockquoteStart.test(r[o]))l.push(r[o]),a=!0;else if(!a)l.push(r[o]);else break;r=r.slice(o);let c=l.join(`
|
||
`),h=c.replace(this.rules.other.blockquoteSetextReplace,`
|
||
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
||
${c}`:c,s=s?`${s}
|
||
${h}`:h;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=u,r.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let m=f,b=m.raw+`
|
||
`+r.join(`
|
||
`),T=this.blockquote(b);i[i.length-1]=T,n=n.substring(0,n.length-m.raw.length)+T.raw,s=s.substring(0,s.length-m.text.length)+T.text;break}else if(f?.type==="list"){let m=f,b=m.raw+`
|
||
`+r.join(`
|
||
`),T=this.list(b);i[i.length-1]=T,n=n.substring(0,n.length-f.raw.length)+T.raw,s=s.substring(0,s.length-m.raw.length)+T.raw,r=b.substring(i.at(-1).raw.length).split(`
|
||
`);continue}}return{type:"blockquote",raw:n,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),n=r.length>1,s={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let i=this.rules.other.listItemRegex(r),a=!1;for(;t;){let o=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let u=In(e[2].split(`
|
||
`,1)[0],e[1].length),f=t.split(`
|
||
`,1)[0],m=!u.trim(),b=0;if(this.options.pedantic?(b=2,h=u.trimStart()):m?b=e[1].length+1:(b=u.search(this.rules.other.nonSpaceChar),b=b>4?1:b,h=u.slice(b),b+=e[1].length),m&&this.rules.other.blankLine.test(f)&&(c+=f+`
|
||
`,t=t.substring(f.length+1),o=!0),!o){let T=this.rules.other.nextBulletRegex(b),$=this.rules.other.hrRegex(b),V=this.rules.other.fencesBeginRegex(b),_=this.rules.other.headingBeginRegex(b),v=this.rules.other.htmlBeginRegex(b),H=this.rules.other.blockquoteBeginRegex(b);for(;t;){let S=t.split(`
|
||
`,1)[0],x;if(f=S,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),x=f):x=f.replace(this.rules.other.tabCharGlobal," "),V.test(f)||_.test(f)||v.test(f)||H.test(f)||T.test(f)||$.test(f))break;if(x.search(this.rules.other.nonSpaceChar)>=b||!f.trim())h+=`
|
||
`+x.slice(b);else{if(m||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(u)||_.test(u)||$.test(u))break;h+=`
|
||
`+f}m=!f.trim(),c+=S+`
|
||
`,t=t.substring(S.length+1),u=x.slice(b)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),s.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),s.raw+=c}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let o of s.items){if(this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]),o.task){if(o.text=o.text.replace(this.rules.other.listReplaceTask,""),o.tokens[0]?.type==="text"||o.tokens[0]?.type==="paragraph"){o.tokens[0].raw=o.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),o.tokens[0].text=o.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(o.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};o.checked=h.checked,s.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=h.raw+o.tokens[0].raw,o.tokens[0].text=h.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(h)):o.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):o.tokens.unshift(h)}}if(!s.loose){let c=o.tokens.filter(u=>u.type==="space"),h=c.length>0&&c.some(u=>this.rules.other.anyLine.test(u.raw));s.loose=h}}if(s.loose)for(let o of s.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:n,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=at(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
||
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===n.length){for(let a of n)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<r.length;a++)i.header.push({text:r[a],tokens:this.lexer.inline(r[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(at(a,i.header.length).map((l,o)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[o]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let r=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let r=e[1].charAt(e[1].length-1)===`
|
||
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let i=ae(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{let i=Bn(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let n=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?n=n.slice(1):n=n.slice(1,-1)),ot(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let n=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[n.toLowerCase()];if(!s){let i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return ot(r,s,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(t);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!r||this.rules.inline.punctuation.exec(r))){let s=[...n[0]].length-1,i,a,l=s,o=0,c=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(n=c.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(a=[...i].length,n[3]||n[4]){l+=a;continue}else if((n[5]||n[6])&&s%3&&!((s+a)%3)){o+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+o);let h=[...n[0]][0].length,u=t.slice(0,s+n.index+h+a);if(Math.min(s,a)%2){let m=u.slice(1,-1);return{type:"em",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}let f=u.slice(2,-2);return{type:"strong",raw:u,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(r),s=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return n&&s&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,r=""){let n=this.rules.inline.delLDelim.exec(t);if(n&&(!n[1]||!r||this.rules.inline.punctuation.exec(r))){let s=[...n[0]].length-1,i,a,l=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,e=e.slice(-1*t.length+s);(n=o.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i||(a=[...i].length,a!==s))continue;if(n[3]||n[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...n[0]][0].length,h=t.slice(0,s+n.index+c+a),u=h.slice(s,-s);return{type:"del",raw:h,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,n;return e[2]==="@"?(r=e[1],n="mailto:"+r):(r=e[1],n=r),{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let r,n;if(e[2]==="@")r=e[0],n="mailto:"+r;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);r=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},G=class Le{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Y,this.options.tokenizer=this.options.tokenizer||new be,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let r={other:U,block:ue.normal,inline:ie.normal};this.options.pedantic?(r.block=ue.pedantic,r.inline=ie.pedantic):this.options.gfm&&(r.block=ue.gfm,this.options.breaks?r.inline=ie.breaks:r.inline=ie.gfm),this.tokenizer.rules=r}static get rules(){return{block:ue,inline:ie}}static lex(e,r){return new Le(r).lex(e)}static lexInline(e,r){return new Le(r).inlineTokens(e)}lex(e){e=e.replace(U.carriageReturn,`
|
||
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(U.tabCharGlobal," ").replace(U.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(a=>(s=a.call({lexer:this},e,r))?(e=e.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let a=r.at(-1);s.raw.length===1&&a!==void 0?a.raw+=`
|
||
`:r.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let a=r.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
||
`)?"":`
|
||
`)+s.raw,a.text+=`
|
||
`+s.text,this.inlineQueue.at(-1).src=a.text):r.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let a=r.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
||
`)?"":`
|
||
`)+s.raw,a.text+=`
|
||
`+s.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},r.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),r.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let a=1/0,l=e.slice(1),o;this.options.extensions.startBlock.forEach(c=>{o=c.call({lexer:this},l),typeof o=="number"&&o>=0&&(a=Math.min(a,o))}),a<1/0&&a>=0&&(i=e.substring(0,a+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let a=r.at(-1);n&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
||
`)?"":`
|
||
`)+s.raw,a.text+=`
|
||
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):r.push(s),n=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let a=r.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
||
`)?"":`
|
||
`)+s.raw,a.text+=`
|
||
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):r.push(s);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){this.tokenizer.lexer=this;let n=e,s=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=s[2]?s[2].length:0,n=n.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,l="";for(;e;){a||(l=""),a=!1;let o;if(this.options.extensions?.inline?.some(h=>(o=h.call({lexer:this},e,r))?(e=e.substring(o.raw.length),r.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let h=r.at(-1);o.type==="text"&&h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):r.push(o);continue}if(o=this.tokenizer.emStrong(e,n,l)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.del(e,n,l)){e=e.substring(o.raw.length),r.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),r.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),r.push(o);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0,u=e.slice(1),f;this.options.extensions.startInline.forEach(m=>{f=m.call({lexer:this},u),typeof f=="number"&&f>=0&&(h=Math.min(h,f))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(l=o.raw.slice(-1)),a=!0;let h=r.at(-1);h?.type==="text"?(h.raw+=o.raw,h.text+=o.text):r.push(o);continue}if(e){let h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return r}},ke=class{options;parser;constructor(t){this.options=t||Y}space(t){return""}code({text:t,lang:e,escaped:r}){let n=(e||"").match(U.notSpaceStart)?.[0],s=t.replace(U.endingNewline,"")+`
|
||
`;return n?'<pre><code class="language-'+X(n)+'">'+(r?s:X(s,!0))+`</code></pre>
|
||
`:"<pre><code>"+(r?s:X(s,!0))+`</code></pre>
|
||
`}blockquote({tokens:t}){return`<blockquote>
|
||
${this.parser.parse(t)}</blockquote>
|
||
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
||
`}hr(t){return`<hr>
|
||
`}list(t){let e=t.ordered,r=t.start,n="";for(let a=0;a<t.items.length;a++){let l=t.items[a];n+=this.listitem(l)}let s=e?"ol":"ul",i=e&&r!==1?' start="'+r+'"':"";return"<"+s+i+`>
|
||
`+n+"</"+s+`>
|
||
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
||
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
||
`}table(t){let e="",r="";for(let s=0;s<t.header.length;s++)r+=this.tablecell(t.header[s]);e+=this.tablerow({text:r});let n="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];r="";for(let a=0;a<i.length;a++)r+=this.tablecell(i[a]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
||
<thead>
|
||
`+e+`</thead>
|
||
`+n+`</table>
|
||
`}tablerow({text:t}){return`<tr>
|
||
${t}</tr>
|
||
`}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
|
||
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${X(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let n=this.parser.parseInline(r),s=it(t);if(s===null)return n;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+X(e)+'"'),i+=">"+n+"</a>",i}image({href:t,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let s=it(t);if(s===null)return X(r);t=s;let i=`<img src="${t}" alt="${X(r)}"`;return e&&(i+=` title="${X(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:X(t.text)}},ze=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},F=class Ne{options;renderer;textRenderer;constructor(e){this.options=e||Y,this.options.renderer=this.options.renderer||new ke,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ze}static parse(e,r){return new Ne(r).parse(e)}static parseInline(e,r){return new Ne(r).parseInline(e)}parse(e){this.renderer.parser=this;let r="";for(let n=0;n<e.length;n++){let s=e[n];if(this.options.extensions?.renderers?.[s.type]){let a=s,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){r+=l||"";continue}}let i=s;switch(i.type){case"space":{r+=this.renderer.space(i);break}case"hr":{r+=this.renderer.hr(i);break}case"heading":{r+=this.renderer.heading(i);break}case"code":{r+=this.renderer.code(i);break}case"table":{r+=this.renderer.table(i);break}case"blockquote":{r+=this.renderer.blockquote(i);break}case"list":{r+=this.renderer.list(i);break}case"checkbox":{r+=this.renderer.checkbox(i);break}case"html":{r+=this.renderer.html(i);break}case"def":{r+=this.renderer.def(i);break}case"paragraph":{r+=this.renderer.paragraph(i);break}case"text":{r+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}parseInline(e,r=this.renderer){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=l||"";continue}}let a=i;switch(a.type){case"escape":{n+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"checkbox":{n+=r.checkbox(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}},oe=class{options;block;constructor(t){this.options=t||Y}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?G.lex:G.lexInline}provideParser(){return this.block?F.parse:F.parseInline}},Ln=class{defaults=ve();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=F;Renderer=ke;TextRenderer=ze;Lexer=G;Tokenizer=be;Hooks=oe;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let n of t)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let s=n;for(let i of s.header)r=r.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let a of i)r=r.concat(this.walkTokens(a.tokens,e));break}case"list":{let s=n;r=r.concat(this.walkTokens(s.items,e));break}default:{let s=n;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let a=s[i].flat(1/0);r=r.concat(this.walkTokens(a,e))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...a){let l=s.renderer.apply(this,a);return l===!1&&(l=i.apply(this,a)),l}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),n.extensions=e),r.renderer){let s=this.defaults.renderer||new ke(this.defaults);for(let i in r.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,l=r.renderer[a],o=s[a];s[a]=(...c)=>{let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h||""}}n.renderer=s}if(r.tokenizer){let s=this.defaults.tokenizer||new be(this.defaults);for(let i in r.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,l=r.tokenizer[a],o=s[a];s[a]=(...c)=>{let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h}}n.tokenizer=s}if(r.hooks){let s=this.defaults.hooks||new oe;for(let i in r.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,l=r.hooks[a],o=s[a];oe.passThroughHooks.has(i)?s[a]=c=>{if(this.defaults.async&&oe.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await l.call(s,c);return o.call(s,u)})();let h=l.call(s,c);return o.call(s,h)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(s,c);return u===!1&&(u=await o.apply(s,c)),u})();let h=l.apply(s,c);return h===!1&&(h=o.apply(s,c)),h}}n.hooks=s}if(r.walkTokens){let s=this.defaults.walkTokens,i=r.walkTokens;n.walkTokens=function(a){let l=[];return l.push(i.call(this,a)),s&&(l=l.concat(s.call(this,a))),l}}this.defaults={...this.defaults,...n}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return G.lex(t,e??this.defaults)}parser(t,e){return F.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let n={...r},s={...this.defaults,...n},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&n.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(e):e,l=await(s.hooks?await s.hooks.provideLexer():t?G.lex:G.lexInline)(a,s),o=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(o,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?F.parse:F.parseInline)(o,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let a=(s.hooks?s.hooks.provideLexer():t?G.lex:G.lexInline)(e,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let l=(s.hooks?s.hooks.provideParser():t?F.parse:F.parseInline)(a,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(a){return i(a)}}}onError(t,e){return r=>{if(r.message+=`
|
||
Please report this to https://github.com/markedjs/marked.`,t){let n="<p>An error occurred:</p><pre>"+X(r.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(r);throw r}}},J=new Ln;function E(t,e){return J.parse(t,e)}E.options=E.setOptions=function(t){return J.setOptions(t),E.defaults=J.defaults,Rt(E.defaults),E};E.getDefaults=ve;E.defaults=Y;E.use=function(...t){return J.use(...t),E.defaults=J.defaults,Rt(E.defaults),E};E.walkTokens=function(t,e){return J.walkTokens(t,e)};E.parseInline=J.parseInline;E.Parser=F;E.parser=F.parse;E.Renderer=ke;E.TextRenderer=ze;E.Lexer=G;E.lexer=G.lex;E.Tokenizer=be;E.Hooks=oe;E.parse=E;E.options;E.setOptions;E.use;E.walkTokens;E.parseInline;F.parse;G.lex;async function lt(t,e){const r={};return e&&(r.prefix=e),W.get(`/translations/${t}`,r)}const Nn={"ICU.ADMIN_NEXT.LOADING":"Loading...","ICU.ADMIN_NEXT.SIGN_OUT":"Sign out","ICU.ADMIN_NEXT.BOOT.TRANSLATIONS_FAILED":"Translations could not be loaded. Some labels may show as keys.","ICU.ADMIN_NEXT.BOOT.OFFLINE":"Cannot reach the server."},Xe="en-US",ht={en:"en-US",ar:"ar-SA",cs:"cs-CZ",de:"de-DE",es:"es-ES","es-mx":"es-MX",fi:"fi-FI",fr:"fr-FR","fr-ca":"fr-CA",he:"he-IL",it:"it-IT",nl:"nl-NL",pt:"pt-PT",ru:"ru-RU",sv:"sv-SE",uk:"uk-UA","zh-hans":"zh-Hans","zh-hant":"zh-Hant"};function le(t){if(!t)return Xe;const e=t.trim().replace(/_/g,"-").toLowerCase();if(e in ht)return ht[e];const r=t.match(/^([a-z]{2,3})-([a-z0-9]{2,4})$/i);if(r){const n=r[1].toLowerCase(),s=r[2],i=s.length===4?s.charAt(0).toUpperCase()+s.slice(1).toLowerCase():s.toUpperCase();return`${n}-${i}`}return t}const ct={"en-US":Nn};function ut(t){const e=le(t);return ct[e]??ct[Xe]??{}}const Mt=Ce("grav_admin_i18n_v2");Ce("grav_admin_i18n_checksum");const pe="ICU.";function Cn(){try{const t=localStorage.getItem(Mt);return t?JSON.parse(t):null}catch{return null}}function vn(){const t=Cn(),e=le(t?.lang??Xe);let r=B(N(e)),n=B(N(t?.dir??"ltr")),s=B(N({...ut(e),...t?.strings??{}})),i=B(N(t?.checksum??"")),a=B(!1),l=B(!!t),o=!1;const c=new Map,h=new Set,u=new Map;let f=!1,m=!1;function b(){if(f)return m;if(f=!0,typeof window>"u")return!1;try{const g=window.localStorage?.getItem("i18n-debug"),A=new URLSearchParams(window.location.search);m=g==="1"||g==="true"||A.has("i18n-debug")}catch{m=!1}return m}function T(){for(const g of h)try{g(p(r))}catch{}}function $(){c.clear()}function V(g,A){const L=`${p(r)}::${g}`;let P=c.get(L);if(P)return P;try{return P=new Xr(A,p(r)),c.set(L,P),P}catch(O){return console.warn(`[i18n] Failed to compile ICU message for "${g}":`,O),null}}function _(){const g=ut(p(r));d(s,{...g,...p(s)},!0),$()}function v(){try{localStorage.setItem(Mt,JSON.stringify({lang:p(r),dir:p(n),checksum:p(i),strings:p(s)}))}catch{}}function H(g,A){if(!g)return"";const L=(te,xe)=>{const qe=V(te,xe);if(qe)try{const se=qe.format(A);return typeof se=="string"?se:String(se??"")}catch(se){return console.warn(`[i18n] Format error for "${te}":`,se),xe}return xe},P=pe+g;if(p(s)[P]!==void 0)return L(P,p(s)[P]);if(g.startsWith("PLUGIN_ADMIN.")){const te=pe+"ADMIN_NEXT."+g.slice(13);if(p(s)[te]!==void 0)return L(te,p(s)[te])}const O=p(s)[g];if(O!==void 0)return O;const ee=g.toUpperCase(),Ve=p(s)[ee];return Ve!==void 0?Ve:ne(g)}function S(g,A){const L=H(g,A);try{return E.parseInline(L,{async:!1})}catch(P){return console.warn(`[i18n] tHtml render failed for "${g}":`,P),L}}function x(g){return g?pe+g in p(s)||g in p(s)||g.toUpperCase()in p(s)?!0:g.startsWith("PLUGIN_ADMIN.")?pe+"ADMIN_NEXT."+g.slice(13)in p(s):!1:!1}function M(g){return/^[A-Z][A-Z0-9_]*\.[A-Z][A-Z0-9_.]*$/.test(g)}function j(g,A){return g?M(g)?H(g,A):g:""}function ne(g){const A=g.split("."),P=A[A.length-1].replace(/^PLUGIN_\w+_/,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,O=>O.toUpperCase());if(b()){const O=u.get(g);if(O)O.count++;else{let ee;try{ee=new Error().stack?.split(`
|
||
`).slice(2,6).join(`
|
||
`)}catch{}u.set(g,{count:1,firstStack:ee}),console.warn(`[i18n] Humanize fallback: ${g}`,ee?`
|
||
at ${ee}`:"")}return`⟦${P}⟧`}return P}async function K(g){const A=le(g??p(r));d(a,!0);try{const L=await lt(A),P=L.checksum===p(i)&&L.lang===p(r)&&L.dir===p(n);if(!o||!P){const O=L.lang!==p(r);d(r,L.lang,!0),d(n,L.dir??"ltr",!0),d(s,L.strings,!0),d(i,L.checksum,!0),$(),_(),v(),O&&T()}o=!0,d(l,!0)}catch{!p(l)&&t&&d(l,!0)}finally{d(a,!1)}}async function Ot(g,A){const L=le(A??p(r));try{const P=await lt(L,g),O=P.lang!==p(r);d(r,P.lang,!0),d(n,P.dir??"ltr",!0),d(s,{...p(s),...P.strings},!0),$(),_(),v(),O&&T()}catch{}}function Dt(g){K(g)}async function $t(g){const A=le(g);A===p(r)&&p(l)||await K(A)}function Gt(g){return h.add(g),()=>h.delete(g)}function Ft(){return[...u.entries()].map(([g,A])=>({key:g,count:A.count,firstStack:A.firstStack})).sort((g,A)=>A.count-g.count)}function zt(){u.clear()}return{get lang(){return p(r)},get dir(){return p(n)},get loading(){return p(a)},get loaded(){return p(l)},get count(){return Object.keys(p(s)).length},t:H,tHtml:S,tMaybe:j,has:x,isTranslationKey:M,load:K,loadPrefix:Ot,loadAllInBackground:Dt,setLanguage:$t,subscribeLocale:Gt,getHumanizeMisses:Ft,clearHumanizeMisses:zt}}const z=vn();typeof window<"u"&&(Object.defineProperty(window,"__GRAV_I18N",{value:{t:(e,r)=>z.t(e,r),tHtml:(e,r)=>z.tHtml(e,r),has:e=>z.has(e),get locale(){return z.lang},get dir(){return z.dir},subscribe:e=>z.subscribeLocale(e)},writable:!1,configurable:!1}),window.__GRAV_I18N_DEBUG={enable(){try{localStorage.setItem("i18n-debug","1")}catch{}console.info("[i18n-debug] Enabled. Reload the page so all components pick it up.")},disable(){try{localStorage.removeItem("i18n-debug")}catch{}console.info("[i18n-debug] Disabled. Reload the page.")},misses(){return z.getHumanizeMisses()},clear(){z.clearHumanizeMisses()},report(){const e=z.getHumanizeMisses();console.group(`[i18n] ${e.length} unique humanize fallbacks this session`);for(const r of e)console.log(`${String(r.count).padStart(4)} × ${r.key}`);return console.groupEnd(),e},yaml(){const e=z.getHumanizeMisses(),r=["# Drop these into the appropriate languages/en.yaml under ICU:"];for(const n of e)r.push(`# (${n.count}×) ${n.key}: "@@TODO ${n.key}"`);return r.join(`
|
||
`)}});export{q as A,er as a,W as b,R as c,Z as d,Mn as e,E as g,z as i,le as n,Ce as s};
|