@sheerid/jslib-nightly
Version:
SheerID JavaScript Library
1,167 lines (1,166 loc) • 1.32 MB
JavaScript
/**
* WARNING: This file is intended to be used within MySheerID.
* This file is not intended for use in other contexts and there are no guarantees about its behavior outside of MySheerID.
*/
/**
* VERSION: 2.130.0-alpha.4
* BUILD_TIMESTAMP: 1759000347595
* BUILD_DATE: Sat Sep 27 2025 19:12:27 GMT+0000 (Coordinated Universal Time)
* BUILD_COMMIT: be6ef87ab40e8747994d32363389cf39e36a4326
*/
var bA = Object.defineProperty;
var SA = (e, t, r) => t in e ? bA(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var or = (e, t, r) => SA(e, typeof t != "symbol" ? t + "" : t, r);
function wA(e, t) {
for (var r = 0; r < t.length; r++) {
const n = t[r];
if (typeof n != "string" && !Array.isArray(n)) {
for (const o in n)
if (o !== "default" && !(o in e)) {
const a = Object.getOwnPropertyDescriptor(n, o);
a && Object.defineProperty(e, o, a.get ? a : {
enumerable: !0,
get: () => n[o]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
var Ja = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Er(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var hi = Ql;
Ql.flatten = Ql;
Ql.unflatten = GE;
function HE(e) {
return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
}
function zE(e) {
return e;
}
function Ql(e, t) {
t = t || {};
const r = t.delimiter || ".", n = t.maxDepth, o = t.transformKey || zE, a = {};
function s(i, l, u) {
u = u || 1, Object.keys(i).forEach(function(c) {
const d = i[c], p = t.safe && Array.isArray(d), m = Object.prototype.toString.call(d), h = HE(d), g = m === "[object Object]" || m === "[object Array]", w = l ? l + r + o(c) : o(c);
if (!p && !h && g && Object.keys(d).length && (!t.maxDepth || u < n))
return s(d, w, u + 1);
a[w] = d;
});
}
return s(e), a;
}
function GE(e, t) {
t = t || {};
const r = t.delimiter || ".", n = t.overwrite || !1, o = t.transformKey || zE, a = {};
if (HE(e) || Object.prototype.toString.call(e) !== "[object Object]")
return e;
function i(c) {
const d = Number(c);
return isNaN(d) || c.indexOf(".") !== -1 || t.object ? c : d;
}
function l(c, d, p) {
return Object.keys(p).reduce(function(m, h) {
return m[c + r + h] = p[h], m;
}, d);
}
function u(c) {
const d = Object.prototype.toString.call(c), p = d === "[object Array]", m = d === "[object Object]";
if (c) {
if (p)
return !c.length;
if (m)
return !Object.keys(c).length;
} else return !0;
}
return e = Object.keys(e).reduce(function(c, d) {
const p = Object.prototype.toString.call(e[d]);
return !(p === "[object Object]" || p === "[object Array]") || u(e[d]) ? (c[d] = e[d], c) : l(
d,
c,
Ql(e[d], t)
);
}, {}), Object.keys(e).forEach(function(c) {
const d = c.split(r).map(o);
let p = i(d.shift()), m = i(d[0]), h = a;
for (; m !== void 0; ) {
if (p === "__proto__")
return;
const g = Object.prototype.toString.call(h[p]), w = g === "[object Object]" || g === "[object Array]";
if (!n && !w && typeof h[p] < "u")
return;
(n && !w || !n && h[p] == null) && (h[p] = typeof m == "number" && !t.object ? [] : {}), h = h[p], d.length > 0 && (p = i(d.shift()), m = i(d[0]));
}
h[p] = GE(e[c], t);
}), a;
}
const WE = /* @__PURE__ */ Er(hi), KE = {}, qE = (e) => Object.entries(e).forEach(([t, r]) => {
KE[t] = r;
}), YE = async () => KE, Gy = () => window.navigator.globalPrivacyControl, gi = () => window.NREUM && !Gy();
function Fe(e, t) {
try {
return e();
} catch {
return t;
}
}
let _u = 4, Ri = "";
const A0 = {
info: 1,
log: 2,
warn: 3,
error: 4
}, Lu = {
info: "#26c1db",
log: "#09f979",
warn: "#f6b13f",
error: "#e12046"
}, Du = "color: white; font-weight: bold; padding: 2px 10px;";
let id;
const IA = (e) => e && e.stack && e.message, Vd = (...e) => {
_u <= 3 && console.warn(`%c${Ri} warn`, `background: ${Lu.warn};${Du}`, ...e);
}, xA = (...e) => {
_u <= 2 && console.log(`%c${Ri} log`, `background: ${Lu.log};${Du}`, ...e);
}, EA = (...e) => {
_u <= 1 && console.log(`%c${Ri} info`, `background: ${Lu.info};${Du}`, ...e);
}, MA = async (e, t = "unknown group", r = {}) => {
if (_u <= 4) {
if (!e) {
console.error(new Error("An error must be supplied"));
return;
}
let n;
typeof e == "string" && (n = new Error(e)), IA(e) && (n = e), n || (n = new Error("Unknown error"));
let o = { errorMessageGroup: t };
try {
o = {
...await YE(),
...o
}, delete o.jslibVersionActual;
} catch (a) {
gi() ? window.NREUM.noticeError(n, o) : Vd("Unable to assemble GA error attributes", a);
}
try {
if (id && id.getState) {
const a = id.getState(), s = Fe(() => a.verificationResponse.errorIds);
o = {
...o,
programId: Fe(() => a.programId),
isLoading: Fe(() => a.isLoading),
isErrored: Fe(() => a.isErrored),
errorIdsFromVerRsp: Array.isArray(s) ? s.join(", ") : void 0,
verificationId: Fe(() => a.verificationResponse.verificationId),
currentStep: Fe(() => a.verificationResponse.currentStep),
locale: Fe(() => a.programTheme.intl.locale),
isTestMode: Fe(() => a.programTheme.isTestMode),
openOrgSearchEnabled: Fe(() => a.programTheme.openOrgSearchEnabled),
jslibVerActual: Fe(() => "2.130.0-alpha.4", "?"),
...r
};
}
} catch (a) {
gi() ? window.NREUM.noticeError(n, o) : Vd("Unable to assemble useful error attributes", a);
}
gi() && window.NREUM.noticeError(n, o), console.error(
`%c${Ri} error`,
`background: ${Lu.error};${Du}`,
n,
o
);
}
}, CA = (e, t = {}) => {
gi() && window.NREUM.addPageAction(e, t);
}, TA = (e, t) => {
CA("API-calls-timing", {
api_call: e,
api_response_time: t
});
}, L = {
error: MA,
warn: Vd,
log: xA,
info: EA,
/** @deprecated use newRelicPageAction() instead */
logAPIResponseTime: TA,
setLogLevel: (e) => {
if (!A0.hasOwnProperty(e))
throw new Error(`Unknown logLevel '${e}'`);
_u = A0[e], console.log(
`%c${Ri} log level set to ${e}`,
`background: ${Lu[e]};${Du}`
), gi() || Vd("Offsite logging not enabled");
},
setPrefix: (e) => {
Ri = e;
},
init: (e) => {
id = e;
}
}, PA = [
"ar",
"bg",
"bn-IN",
"cs",
"da",
"de",
"el",
"en-GB",
"en-US",
"es-ES",
"es",
"fi",
"fr-CA",
"fr",
"ga",
"hi-IN",
"hr",
"hu",
"id",
"is",
"it",
"iw",
"ja",
"ko",
"lo",
"lt",
"ms",
"nl",
"nl-BE",
"no",
"pl",
"pt-BR",
"pt",
"ro",
"ru",
"sk",
"sl",
"sr",
"sv",
"sw",
"uk",
"ur",
"vi",
"th",
"tr",
"zh-HK",
"zh",
"zu"
], Wy = [...PA];
var Xe = /* @__PURE__ */ ((e) => (e.collectStudentPersonalInfo = "collectStudentPersonalInfo", e.collectTeacherPersonalInfo = "collectTeacherPersonalInfo", e.collectMemberPersonalInfo = "collectMemberPersonalInfo", e.collectMilitaryStatus = "collectMilitaryStatus", e.collectActiveMilitaryPersonalInfo = "collectActiveMilitaryPersonalInfo", e.collectInactiveMilitaryPersonalInfo = "collectInactiveMilitaryPersonalInfo", e.collectSeniorPersonalInfo = "collectSeniorPersonalInfo", e.collectAgePersonalInfo = "collectAgePersonalInfo", e.collectFirstResponderPersonalInfo = "collectFirstResponderPersonalInfo", e.collectMedicalProfessionalPersonalInfo = "collectMedicalProfessionalPersonalInfo", e.collectEmployeePersonalInfo = "collectEmployeePersonalInfo", e.collectSocialSecurityNumber = "collectSocialSecurityNumber", e.cancelSocialSecurityNumber = "cancelSocialSecurityNumber", e.collectDriverLicensePersonalInfo = "collectDriverLicensePersonalInfo", e.collectGeneralIdentityPersonalInfo = "collectGeneralIdentityPersonalInfo", e.collectHybridIdentityPersonalInfo = "collectHybridIdentityPersonalInfo", e.collectLicensedProfessionalPersonalInfo = "collectLicensedProfessionalPersonalInfo", e.collectMoverPersonalInfo = "collectMoverPersonalInfo", e.collectLowIncomePersonalInfo = "collectLowIncomePersonalInfo", e.collectIdentifier = "collectIdentifier", e.collectPersonalInfo = "collectPersonalInfo", e.docUpload = "docUpload", e.pending = "pending", e.docReviewLimitExceeded = "docReviewLimitExceeded", e.success = "success", e.error = "error", e.sso = "sso", e.smsLoop = "smsLoop", e.emailLoop = "emailLoop", e.emailLoopCollectOrganizationEmail = "emailLoopCollectOrganizationEmail", e.completeAuthentication = "completeAuthentication", e.cancelEmailLoop = "cancelEmailLoop", e.idCheckLoop = "idCheckLoop", e.consolation = "consolation", e.override = "override", e.cancelDocUpload = "cancelDocUpload", e.missingRequiredMetadata = "missingRequiredMetadata", e.missingRequiredExternalId = "missingRequiredExternalId", e.thirdPartyLoop = "thirdPartyLoop", e))(Xe || {});
const RA = Object.values(Xe), NA = [
"collectStudentPersonalInfo",
"collectTeacherPersonalInfo",
"collectMemberPersonalInfo",
"collectMilitaryStatus",
"collectActiveMilitaryPersonalInfo",
"collectInactiveMilitaryPersonalInfo",
"collectSeniorPersonalInfo",
"collectAgePersonalInfo",
"collectFirstResponderPersonalInfo",
"collectMedicalProfessionalPersonalInfo",
"collectEmployeePersonalInfo",
"collectDriverLicensePersonalInfo",
"collectGeneralIdentityPersonalInfo",
"collectHybridIdentityPersonalInfo",
"collectLicensedProfessionalPersonalInfo",
"collectMoverPersonalInfo",
"collectLowIncomePersonalInfo",
"collectIdentifier",
"collectPersonalInfo"
/* collectPersonalInfo */
];
function Wf(e) {
return NA.includes(e);
}
function kA(e) {
return e.currentStep === "success";
}
var ZE = /* @__PURE__ */ ((e) => (e.docUpload = "docUpload", e.pending = "pending", e.error = "error", e))(ZE || {});
Object.values(ZE);
var eu = /* @__PURE__ */ ((e) => (e.loading = "loading", e.collect = "collect", e))(eu || {});
const AA = [
"cancelDocUpload",
"cancelEmailLoop",
"cancelSocialSecurityNumber",
"collectMilitaryStatus"
// currently not a useful step to mock
], OA = [
...Object.values(Xe).filter(
(e) => !AA.includes(e)
),
...Object.values(eu)
];
var XE = /* @__PURE__ */ ((e) => (e.TEXT = "TEXT", e.QR = "QR", e.PDF417 = "PDF417", e.UPC_A = "UPC_A", e.ITF = "ITF", e.CODE_128 = "CODE_128", e))(XE || {}), JE = /* @__PURE__ */ ((e) => (e.student = "collectStudentPersonalInfo", e.military = "collectMilitaryStatus", e.teacher = "collectTeacherPersonalInfo", e.firstResponder = "collectFirstResponderPersonalInfo", e.senior = "collectSeniorPersonalInfo", e.age = "collectAgePersonalInfo", e.medical = "collectMedicalProfessionalPersonalInfo", e.recentMover = "collectMoverPersonalInfo", e.licensedProfessional = "collectLicensedProfessionalPersonalInfo", e.identity = "collectGeneralIdentityPersonalInfo", e.member = "collectMemberPersonalInfo", e))(JE || {}), Tr = /* @__PURE__ */ ((e) => (e.STUDENT = "student", e.MILITARY = "military", e.TEACHER = "teacher", e.MEMBER = "member", e.SENIOR = "senior", e.AGE = "age", e.FIRST_RESPONDER = "firstResponder", e.MEDICAL = "medical", e.EMPLOYMENT = "employment", e.IDENTITY = "identity", e.LICENSED_PROFESSIONAL = "licensedProfessional", e.RECENT_MOVER = "recentMover", e.LOW_INCOME = "lowIncome", e))(Tr || {});
const _A = Object.values(Tr);
var mt = /* @__PURE__ */ ((e) => (e.ACTIVE_DUTY = "activeDuty", e.VETERAN = "veteran", e.RESERVIST = "reservist", e.MILITARY_RETIREE = "retiree", e.MILITARY_FAMILY = "militaryFamily", e.GOLD_STAR_FAMILY = "goldStarFamily", e.FIREFIGHTER = "fireFighter", e.POLICE = "police", e.EMT = "emt", e.NURSE = "nurse", e.DRIVER_LICENSE = "driverLicense", e.GENERAL_IDENTITY = "generalIdentity", e.HYBRID_IDENTITY = "hybridIdentity", e.HOME_BUYER = "homeBuyer", e.OTHER_MOVER = "otherMover", e.LICENSED_COSMETOLOGIST = "licensedCosmetologist", e.LICENSED_REAL_ESTATE_AGENT = "licensedRealEstateAgent", e.VETERINARIAN = "veterinarian", e.SNAP_BENEFITS = "snapBenefits", e.OTHER_GOVERNMENT_ASSISTANCE = "otherGovernmentAssistance", e.CHILD_CARE_WORKER = "childCareWorker", e.LIBRARIAN = "librarian", e.INTERIOR_DESIGNER = "interiorDesigner", e.ARCHITECT = "architect", e.GENERAL_CONTRACTOR = "generalContractor", e.NUTRITION_PROFESSIONAL = "nutritionProfessional", e))(mt || {});
Object.values(mt);
const QE = {
ACTIVE_DUTY: "Active Duty",
MILITARY_RETIREE: "Military Retiree",
RESERVIST: "Reservist or National Guard",
VETERAN: "Military Veteran or Retiree",
MILITARY_FAMILY: "Military Family",
GOLD_STAR_FAMILY: "Gold Star Family"
}, LA = {
FIREFIGHTER: "Firefighter",
POLICE: "Police",
EMT: "EMT",
SEARCH_AND_RESCUE: "Search and Rescue"
}, DA = {
NURSE: "Nurse",
DOCTOR: "Doctor",
OTHER_HEALTH_WORKER: "Other Health Worker",
DENTIST: "Dentist",
PHARMACIST: "Pharmacist"
}, eM = {
SNAP_BENEFITS: "Snap Benefits Recipient",
OTHER_GOVERNMENT_ASSISTANCE: "Other Government Assistance Recipient",
COMMUNITY_ELIGIBILITY_PROVISION: "CEP (Community Eligibility Provision, Title 1/LAP)"
};
var St = /* @__PURE__ */ ((e) => (e.firstName = "firstName", e.lastName = "lastName", e.memberId = "memberId", e.organization = "organization", e.birthDate = "birthDate", e.email = "email", e.phoneNumber = "phoneNumber", e.postalCode = "postalCode", e.address1 = "address1", e.city = "city", e.country = "country", e.state = "state", e.dischargeDate = "dischargeDate", e.activeDutyStartDate = "activeDutyStartDate", e.docUpload = "docUpload", e.status = "status", e.statuses = "statuses", e.marketConsentValue = "marketConsentValue", e.socialSecurityNumber = "socialSecurityNumber", e.carrierConsentValue = "carrierConsentValue", e.driverLicenseNumber = "driverLicenseNumber", e.ebtCardNumber = "ebtCardNumber", e.overrideCode = "overrideCode", e.organizationEmail = "organizationEmail", e.authenticationCode = "authenticationCode", e.cvecNumber = "cvecNumber", e))(St || {});
const O0 = Object.values(St);
var tM = /* @__PURE__ */ ((e) => (e.ON_VERIFICATION_READY = "ON_VERIFICATION_READY", e.ON_VERIFICATION_SUCCESS = "ON_VERIFICATION_SUCCESS", e.ON_VERIFICATION_STEP_CHANGE = "ON_VERIFICATION_STEP_CHANGE", e.ON_FORM_LOCALE_CHANGE = "ON_FORM_LOCALE_CHANGE", e))(tM || {});
const rM = Object.values(tM), FA = (e) => {
L.info(`Registering additional locales ${e.join(", ")}`), Wy.push(...e);
};
var Ky = /* @__PURE__ */ ((e) => (e.AK = "AK", e.AL = "AL", e.AR = "AR", e.AZ = "AZ", e.AS = "AS", e.CA = "CA", e.CO = "CO", e.CT = "CT", e.DC = "DC", e.DE = "DE", e.FL = "FL", e.GA = "GA", e.GU = "GU", e.HI = "HI", e.IA = "IA", e.ID = "ID", e.IL = "IL", e.IN = "IN", e.KS = "KS", e.KY = "KY", e.LA = "LA", e.MA = "MA", e.MD = "MD", e.ME = "ME", e.MI = "MI", e.MN = "MN", e.MO = "MO", e.MS = "MS", e.MT = "MT", e.NC = "NC", e.ND = "ND", e.NE = "NE", e.NH = "NH", e.NJ = "NJ", e.NM = "NM", e.NV = "NV", e.NY = "NY", e.OH = "OH", e.OK = "OK", e.OR = "OR", e.PA = "PA", e.PR = "PR", e.RI = "RI", e.SC = "SC", e.SD = "SD", e.TN = "TN", e.TX = "TX", e.UT = "UT", e.VA = "VA", e.VI = "VI", e.VT = "VT", e.WA = "WA", e.WI = "WI", e.WV = "WV", e.WY = "WY", e))(Ky || {}), El = /* @__PURE__ */ ((e) => (e.DOCUMENT = "document", e.FACIAL_SIMILARITY_MOTION = "facial_similarity_motion", e))(El || {}), Ml = /* @__PURE__ */ ((e) => (e.PASSPORT = "passport", e.NATIONAL_IDENTITY_CARD = "national_identity_card", e.DRIVING_LICENCE = "driving_licence", e.RESIDENCE_PERMIT = "residence_permit", e))(Ml || {}), nM = /* @__PURE__ */ ((e) => (e.ID_CHECK = "ID_CHECK", e.ID_CHECK_LIVENESS = "ID_CHECK_LIVENESS", e))(nM || {}), qy = /* @__PURE__ */ ((e) => (e.SIGNZY = "signzy", e))(qy || {});
let lg = {}, oM = [];
const _0 = (e, t) => {
L.log(
`customValidator registering
${t}
for custom field '${e}'`
), lg[e] = t, oM.push(e);
}, aM = (e) => lg[e] ? (L.log(`getCustomValidator returning '${e}'`), lg[e]) : (L.error(
`Custom validator for field '${e}' does not exist.
Has a custom validator been registered using the setCustomValidator method?`,
"getCustomValidator"
), null), Kf = () => oM, sM = (e) => {
if (RA.indexOf(e) < 0)
throw new Error(`Expected valid verification step name but received "${e}".`);
}, Mm = (e) => {
if (OA.indexOf(e) < 0)
throw new Error(`Expected valid verification step name but received "${e}".`);
}, $A = (e) => {
if (_A.indexOf(e) < 0)
throw new Error(`Expected valid segment name but received "${e}".`);
}, iM = (e) => {
if (!Bd(e))
throw new Error(`Invalid locale ${e}, expected one of ${Wy.join(", ")}`);
}, Bd = (e) => Wy.indexOf(e) > -1, UA = (e) => {
if (!(e && e.nodeType === Node.ELEMENT_NODE))
throw new Error(
`Expected argument of type Node.ELEMENT_NODE but received "${typeof e} ${e.nodeType}"`
);
}, lM = (e) => {
GA(e);
}, jA = (e) => {
const t = Kf();
if (O0.indexOf(e) < 0 && t.indexOf(e) < 0)
throw new Error(`Expected valid field ID but received ${e}.
Valid FieldIds are [${O0.join(", ")}, ${t.join(", ")}]`);
}, VA = (e) => {
HA(e.name), Yy(e.callback);
}, BA = (e) => rM.includes(e);
function HA(e) {
if (!BA(e))
throw new Error(
`Expected valid hook name but received ${e}. Valid HookNames are [${rM.join(
", "
)}]`
);
}
const Yy = (e) => {
if (typeof e != "function")
throw new Error(`Expected type "function", but received ${typeof e}`);
}, zA = (e) => {
if (typeof e != "string")
throw new Error(
`Expected trackingId to be a string, but received ${typeof e} instead.`
);
if (e.length < 1)
throw new Error("Expected trackingId string length greater than 0.");
}, GA = (e) => {
if (!/^[0-9a-fA-F]{24}$/.test(e))
throw new Error(`Invalid databaseId "${e}". Expected a 24-digit hexadecimal string.`);
}, Ze = (e) => typeof e == "string", ol = () => {
let e, t;
const r = new Promise((n, o) => {
e = n, t = o;
});
return r.resolve = e, r.reject = t, r;
}, L0 = (e) => e == null ? "" : "" + e, WA = (e, t, r) => {
e.forEach((n) => {
t[n] && (r[n] = t[n]);
});
}, KA = /###/g, D0 = (e) => e && e.indexOf("###") > -1 ? e.replace(KA, ".") : e, F0 = (e) => !e || Ze(e), Dl = (e, t, r) => {
const n = Ze(t) ? t.split(".") : t;
let o = 0;
for (; o < n.length - 1; ) {
if (F0(e)) return {};
const a = D0(n[o]);
!e[a] && r && (e[a] = new r()), Object.prototype.hasOwnProperty.call(e, a) ? e = e[a] : e = {}, ++o;
}
return F0(e) ? {} : {
obj: e,
k: D0(n[o])
};
}, $0 = (e, t, r) => {
const {
obj: n,
k: o
} = Dl(e, t, Object);
if (n !== void 0 || t.length === 1) {
n[o] = r;
return;
}
let a = t[t.length - 1], s = t.slice(0, t.length - 1), i = Dl(e, s, Object);
for (; i.obj === void 0 && s.length; )
a = `${s[s.length - 1]}.${a}`, s = s.slice(0, s.length - 1), i = Dl(e, s, Object), i != null && i.obj && typeof i.obj[`${i.k}.${a}`] < "u" && (i.obj = void 0);
i.obj[`${i.k}.${a}`] = r;
}, qA = (e, t, r, n) => {
const {
obj: o,
k: a
} = Dl(e, t, Object);
o[a] = o[a] || [], o[a].push(r);
}, Hd = (e, t) => {
const {
obj: r,
k: n
} = Dl(e, t);
if (r && Object.prototype.hasOwnProperty.call(r, n))
return r[n];
}, YA = (e, t, r) => {
const n = Hd(e, r);
return n !== void 0 ? n : Hd(t, r);
}, uM = (e, t, r) => {
for (const n in t)
n !== "__proto__" && n !== "constructor" && (n in e ? Ze(e[n]) || e[n] instanceof String || Ze(t[n]) || t[n] instanceof String ? r && (e[n] = t[n]) : uM(e[n], t[n], r) : e[n] = t[n]);
return e;
}, Ls = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var ZA = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
"/": "/"
};
const XA = (e) => Ze(e) ? e.replace(/[&<>"'\/]/g, (t) => ZA[t]) : e;
class JA {
constructor(t) {
this.capacity = t, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
}
getRegExp(t) {
const r = this.regExpMap.get(t);
if (r !== void 0)
return r;
const n = new RegExp(t);
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(t, n), this.regExpQueue.push(t), n;
}
}
const QA = [" ", ",", "?", "!", ";"], eO = new JA(20), tO = (e, t, r) => {
t = t || "", r = r || "";
const n = QA.filter((s) => t.indexOf(s) < 0 && r.indexOf(s) < 0);
if (n.length === 0) return !0;
const o = eO.getRegExp(`(${n.map((s) => s === "?" ? "\\?" : s).join("|")})`);
let a = !o.test(e);
if (!a) {
const s = e.indexOf(r);
s > 0 && !o.test(e.substring(0, s)) && (a = !0);
}
return a;
}, ug = (e, t, r = ".") => {
if (!e) return;
if (e[t])
return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
const n = t.split(r);
let o = e;
for (let a = 0; a < n.length; ) {
if (!o || typeof o != "object")
return;
let s, i = "";
for (let l = a; l < n.length; ++l)
if (l !== a && (i += r), i += n[l], s = o[i], s !== void 0) {
if (["string", "number", "boolean"].indexOf(typeof s) > -1 && l < n.length - 1)
continue;
a += l - a + 1;
break;
}
o = s;
}
return o;
}, tu = (e) => e == null ? void 0 : e.replace("_", "-"), rO = {
type: "logger",
log(e) {
this.output("log", e);
},
warn(e) {
this.output("warn", e);
},
error(e) {
this.output("error", e);
},
output(e, t) {
var r, n;
(n = (r = console == null ? void 0 : console[e]) == null ? void 0 : r.apply) == null || n.call(r, console, t);
}
};
class zd {
constructor(t, r = {}) {
this.init(t, r);
}
init(t, r = {}) {
this.prefix = r.prefix || "i18next:", this.logger = t || rO, this.options = r, this.debug = r.debug;
}
log(...t) {
return this.forward(t, "log", "", !0);
}
warn(...t) {
return this.forward(t, "warn", "", !0);
}
error(...t) {
return this.forward(t, "error", "");
}
deprecate(...t) {
return this.forward(t, "warn", "WARNING DEPRECATED: ", !0);
}
forward(t, r, n, o) {
return o && !this.debug ? null : (Ze(t[0]) && (t[0] = `${n}${this.prefix} ${t[0]}`), this.logger[r](t));
}
create(t) {
return new zd(this.logger, {
prefix: `${this.prefix}:${t}:`,
...this.options
});
}
clone(t) {
return t = t || this.options, t.prefix = t.prefix || this.prefix, new zd(this.logger, t);
}
}
var lo = new zd();
let qf = class {
constructor() {
this.observers = {};
}
on(t, r) {
return t.split(" ").forEach((n) => {
this.observers[n] || (this.observers[n] = /* @__PURE__ */ new Map());
const o = this.observers[n].get(r) || 0;
this.observers[n].set(r, o + 1);
}), this;
}
off(t, r) {
if (this.observers[t]) {
if (!r) {
delete this.observers[t];
return;
}
this.observers[t].delete(r);
}
}
emit(t, ...r) {
this.observers[t] && Array.from(this.observers[t].entries()).forEach(([o, a]) => {
for (let s = 0; s < a; s++)
o(...r);
}), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([o, a]) => {
for (let s = 0; s < a; s++)
o.apply(o, [t, ...r]);
});
}
};
class U0 extends qf {
constructor(t, r = {
ns: ["translation"],
defaultNS: "translation"
}) {
super(), this.data = t || {}, this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
}
addNamespaces(t) {
this.options.ns.indexOf(t) < 0 && this.options.ns.push(t);
}
removeNamespaces(t) {
const r = this.options.ns.indexOf(t);
r > -1 && this.options.ns.splice(r, 1);
}
getResource(t, r, n, o = {}) {
var u, c;
const a = o.keySeparator !== void 0 ? o.keySeparator : this.options.keySeparator, s = o.ignoreJSONStructure !== void 0 ? o.ignoreJSONStructure : this.options.ignoreJSONStructure;
let i;
t.indexOf(".") > -1 ? i = t.split(".") : (i = [t, r], n && (Array.isArray(n) ? i.push(...n) : Ze(n) && a ? i.push(...n.split(a)) : i.push(n)));
const l = Hd(this.data, i);
return !l && !r && !n && t.indexOf(".") > -1 && (t = i[0], r = i[1], n = i.slice(2).join(".")), l || !s || !Ze(n) ? l : ug((c = (u = this.data) == null ? void 0 : u[t]) == null ? void 0 : c[r], n, a);
}
addResource(t, r, n, o, a = {
silent: !1
}) {
const s = a.keySeparator !== void 0 ? a.keySeparator : this.options.keySeparator;
let i = [t, r];
n && (i = i.concat(s ? n.split(s) : n)), t.indexOf(".") > -1 && (i = t.split("."), o = r, r = i[1]), this.addNamespaces(r), $0(this.data, i, o), a.silent || this.emit("added", t, r, n, o);
}
addResources(t, r, n, o = {
silent: !1
}) {
for (const a in n)
(Ze(n[a]) || Array.isArray(n[a])) && this.addResource(t, r, a, n[a], {
silent: !0
});
o.silent || this.emit("added", t, r, n);
}
addResourceBundle(t, r, n, o, a, s = {
silent: !1,
skipCopy: !1
}) {
let i = [t, r];
t.indexOf(".") > -1 && (i = t.split("."), o = n, n = r, r = i[1]), this.addNamespaces(r);
let l = Hd(this.data, i) || {};
s.skipCopy || (n = JSON.parse(JSON.stringify(n))), o ? uM(l, n, a) : l = {
...l,
...n
}, $0(this.data, i, l), s.silent || this.emit("added", t, r, n);
}
removeResourceBundle(t, r) {
this.hasResourceBundle(t, r) && delete this.data[t][r], this.removeNamespaces(r), this.emit("removed", t, r);
}
hasResourceBundle(t, r) {
return this.getResource(t, r) !== void 0;
}
getResourceBundle(t, r) {
return r || (r = this.options.defaultNS), this.getResource(t, r);
}
getDataByLanguage(t) {
return this.data[t];
}
hasLanguageSomeTranslations(t) {
const r = this.getDataByLanguage(t);
return !!(r && Object.keys(r) || []).find((o) => r[o] && Object.keys(r[o]).length > 0);
}
toJSON() {
return this.data;
}
}
var cM = {
processors: {},
addPostProcessor(e) {
this.processors[e.name] = e;
},
handle(e, t, r, n, o) {
return e.forEach((a) => {
var s;
t = ((s = this.processors[a]) == null ? void 0 : s.process(t, r, n, o)) ?? t;
}), t;
}
};
const dM = Symbol("i18next/PATH_KEY");
function nO() {
const e = [], t = /* @__PURE__ */ Object.create(null);
let r;
return t.get = (n, o) => {
var a;
return (a = r == null ? void 0 : r.revoke) == null || a.call(r), o === dM ? e : (e.push(o), r = Proxy.revocable(n, t), r.proxy);
}, Proxy.revocable(/* @__PURE__ */ Object.create(null), t).proxy;
}
function cg(e, t) {
const {
[dM]: r
} = e(nO());
return r.join((t == null ? void 0 : t.keySeparator) ?? ".");
}
const j0 = {}, V0 = (e) => !Ze(e) && typeof e != "boolean" && typeof e != "number";
class Gd extends qf {
constructor(t, r = {}) {
super(), WA(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], t, this), this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = lo.create("translator");
}
changeLanguage(t) {
t && (this.language = t);
}
exists(t, r = {
interpolation: {}
}) {
const n = {
...r
};
if (t == null) return !1;
const o = this.resolve(t, n);
return (o == null ? void 0 : o.res) !== void 0;
}
extractFromKey(t, r) {
let n = r.nsSeparator !== void 0 ? r.nsSeparator : this.options.nsSeparator;
n === void 0 && (n = ":");
const o = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
let a = r.ns || this.options.defaultNS || [];
const s = n && t.indexOf(n) > -1, i = !this.options.userDefinedKeySeparator && !r.keySeparator && !this.options.userDefinedNsSeparator && !r.nsSeparator && !tO(t, n, o);
if (s && !i) {
const l = t.match(this.interpolator.nestingRegexp);
if (l && l.length > 0)
return {
key: t,
namespaces: Ze(a) ? [a] : a
};
const u = t.split(n);
(n !== o || n === o && this.options.ns.indexOf(u[0]) > -1) && (a = u.shift()), t = u.join(o);
}
return {
key: t,
namespaces: Ze(a) ? [a] : a
};
}
translate(t, r, n) {
let o = typeof r == "object" ? {
...r
} : r;
if (typeof o != "object" && this.options.overloadTranslationOptionHandler && (o = this.options.overloadTranslationOptionHandler(arguments)), typeof o == "object" && (o = {
...o
}), o || (o = {}), t == null) return "";
typeof t == "function" && (t = cg(t, {
...this.options,
...o
})), Array.isArray(t) || (t = [String(t)]);
const a = o.returnDetails !== void 0 ? o.returnDetails : this.options.returnDetails, s = o.keySeparator !== void 0 ? o.keySeparator : this.options.keySeparator, {
key: i,
namespaces: l
} = this.extractFromKey(t[t.length - 1], o), u = l[l.length - 1];
let c = o.nsSeparator !== void 0 ? o.nsSeparator : this.options.nsSeparator;
c === void 0 && (c = ":");
const d = o.lng || this.language, p = o.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
if ((d == null ? void 0 : d.toLowerCase()) === "cimode")
return p ? a ? {
res: `${u}${c}${i}`,
usedKey: i,
exactUsedKey: i,
usedLng: d,
usedNS: u,
usedParams: this.getUsedParamsDetails(o)
} : `${u}${c}${i}` : a ? {
res: i,
usedKey: i,
exactUsedKey: i,
usedLng: d,
usedNS: u,
usedParams: this.getUsedParamsDetails(o)
} : i;
const m = this.resolve(t, o);
let h = m == null ? void 0 : m.res;
const g = (m == null ? void 0 : m.usedKey) || i, w = (m == null ? void 0 : m.exactUsedKey) || i, v = ["[object Number]", "[object Function]", "[object RegExp]"], y = o.joinArrays !== void 0 ? o.joinArrays : this.options.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, I = o.count !== void 0 && !Ze(o.count), x = Gd.hasDefaultValue(o), R = I ? this.pluralResolver.getSuffix(d, o.count, o) : "", E = o.ordinal && I ? this.pluralResolver.getSuffix(d, o.count, {
ordinal: !1
}) : "", N = I && !o.ordinal && o.count === 0, O = N && o[`defaultValue${this.options.pluralSeparator}zero`] || o[`defaultValue${R}`] || o[`defaultValue${E}`] || o.defaultValue;
let k = h;
b && !h && x && (k = O);
const X = V0(k), ie = Object.prototype.toString.apply(k);
if (b && k && X && v.indexOf(ie) < 0 && !(Ze(y) && Array.isArray(k))) {
if (!o.returnObjects && !this.options.returnObjects) {
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
const ce = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(g, k, {
...o,
ns: l
}) : `key '${i} (${this.language})' returned an object instead of string.`;
return a ? (m.res = ce, m.usedParams = this.getUsedParamsDetails(o), m) : ce;
}
if (s) {
const ce = Array.isArray(k), V = ce ? [] : {}, le = ce ? w : g;
for (const Y in k)
if (Object.prototype.hasOwnProperty.call(k, Y)) {
const ne = `${le}${s}${Y}`;
x && !h ? V[Y] = this.translate(ne, {
...o,
defaultValue: V0(O) ? O[Y] : void 0,
joinArrays: !1,
ns: l
}) : V[Y] = this.translate(ne, {
...o,
joinArrays: !1,
ns: l
}), V[Y] === ne && (V[Y] = k[Y]);
}
h = V;
}
} else if (b && Ze(y) && Array.isArray(h))
h = h.join(y), h && (h = this.extendTranslation(h, t, o, n));
else {
let ce = !1, V = !1;
!this.isValidLookup(h) && x && (ce = !0, h = O), this.isValidLookup(h) || (V = !0, h = i);
const Y = (o.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && V ? void 0 : h, ne = x && O !== h && this.options.updateMissing;
if (V || ce || ne) {
if (this.logger.log(ne ? "updateKey" : "missingKey", d, u, i, ne ? O : h), s) {
const Z = this.resolve(i, {
...o,
keySeparator: !1
});
Z && Z.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
}
let $ = [];
const ae = this.languageUtils.getFallbackCodes(this.options.fallbackLng, o.lng || this.language);
if (this.options.saveMissingTo === "fallback" && ae && ae[0])
for (let Z = 0; Z < ae.length; Z++)
$.push(ae[Z]);
else this.options.saveMissingTo === "all" ? $ = this.languageUtils.toResolveHierarchy(o.lng || this.language) : $.push(o.lng || this.language);
const ee = (Z, te, J) => {
var P;
const q = x && J !== h ? J : Y;
this.options.missingKeyHandler ? this.options.missingKeyHandler(Z, u, te, q, ne, o) : (P = this.backendConnector) != null && P.saveMissing && this.backendConnector.saveMissing(Z, u, te, q, ne, o), this.emit("missingKey", Z, u, te, h);
};
this.options.saveMissing && (this.options.saveMissingPlurals && I ? $.forEach((Z) => {
const te = this.pluralResolver.getSuffixes(Z, o);
N && o[`defaultValue${this.options.pluralSeparator}zero`] && te.indexOf(`${this.options.pluralSeparator}zero`) < 0 && te.push(`${this.options.pluralSeparator}zero`), te.forEach((J) => {
ee([Z], i + J, o[`defaultValue${J}`] || O);
});
}) : ee($, i, O));
}
h = this.extendTranslation(h, t, o, m, n), V && h === i && this.options.appendNamespaceToMissingKey && (h = `${u}${c}${i}`), (V || ce) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${c}${i}` : i, ce ? h : void 0, o));
}
return a ? (m.res = h, m.usedParams = this.getUsedParamsDetails(o), m) : h;
}
extendTranslation(t, r, n, o, a) {
var l, u;
if ((l = this.i18nFormat) != null && l.parse)
t = this.i18nFormat.parse(t, {
...this.options.interpolation.defaultVariables,
...n
}, n.lng || this.language || o.usedLng, o.usedNS, o.usedKey, {
resolved: o
});
else if (!n.skipInterpolation) {
n.interpolation && this.interpolator.init({
...n,
interpolation: {
...this.options.interpolation,
...n.interpolation
}
});
const c = Ze(t) && (((u = n == null ? void 0 : n.interpolation) == null ? void 0 : u.skipOnVariables) !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
let d;
if (c) {
const m = t.match(this.interpolator.nestingRegexp);
d = m && m.length;
}
let p = n.replace && !Ze(n.replace) ? n.replace : n;
if (this.options.interpolation.defaultVariables && (p = {
...this.options.interpolation.defaultVariables,
...p
}), t = this.interpolator.interpolate(t, p, n.lng || this.language || o.usedLng, n), c) {
const m = t.match(this.interpolator.nestingRegexp), h = m && m.length;
d < h && (n.nest = !1);
}
!n.lng && o && o.res && (n.lng = this.language || o.usedLng), n.nest !== !1 && (t = this.interpolator.nest(t, (...m) => (a == null ? void 0 : a[0]) === m[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${r[0]}`), null) : this.translate(...m, r), n)), n.interpolation && this.interpolator.reset();
}
const s = n.postProcess || this.options.postProcess, i = Ze(s) ? [s] : s;
return t != null && (i != null && i.length) && n.applyPostProcessor !== !1 && (t = cM.handle(i, t, r, this.options && this.options.postProcessPassResolved ? {
i18nResolved: {
...o,
usedParams: this.getUsedParamsDetails(n)
},
...n
} : n, this)), t;
}
resolve(t, r = {}) {
let n, o, a, s, i;
return Ze(t) && (t = [t]), t.forEach((l) => {
if (this.isValidLookup(n)) return;
const u = this.extractFromKey(l, r), c = u.key;
o = c;
let d = u.namespaces;
this.options.fallbackNS && (d = d.concat(this.options.fallbackNS));
const p = r.count !== void 0 && !Ze(r.count), m = p && !r.ordinal && r.count === 0, h = r.context !== void 0 && (Ze(r.context) || typeof r.context == "number") && r.context !== "", g = r.lngs ? r.lngs : this.languageUtils.toResolveHierarchy(r.lng || this.language, r.fallbackLng);
d.forEach((w) => {
var v, y;
this.isValidLookup(n) || (i = w, !j0[`${g[0]}-${w}`] && ((v = this.utils) != null && v.hasLoadedNamespace) && !((y = this.utils) != null && y.hasLoadedNamespace(i)) && (j0[`${g[0]}-${w}`] = !0, this.logger.warn(`key "${o}" for languages "${g.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), g.forEach((b) => {
var R;
if (this.isValidLookup(n)) return;
s = b;
const I = [c];
if ((R = this.i18nFormat) != null && R.addLookupKeys)
this.i18nFormat.addLookupKeys(I, c, b, w, r);
else {
let E;
p && (E = this.pluralResolver.getSuffix(b, r.count, r));
const N = `${this.options.pluralSeparator}zero`, O = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
if (p && (r.ordinal && E.indexOf(O) === 0 && I.push(c + E.replace(O, this.options.pluralSeparator)), I.push(c + E), m && I.push(c + N)), h) {
const k = `${c}${this.options.contextSeparator || "_"}${r.context}`;
I.push(k), p && (r.ordinal && E.indexOf(O) === 0 && I.push(k + E.replace(O, this.options.pluralSeparator)), I.push(k + E), m && I.push(k + N));
}
}
let x;
for (; x = I.pop(); )
this.isValidLookup(n) || (a = x, n = this.getResource(b, w, x, r));
}));
});
}), {
res: n,
usedKey: o,
exactUsedKey: a,
usedLng: s,
usedNS: i
};
}
isValidLookup(t) {
return t !== void 0 && !(!this.options.returnNull && t === null) && !(!this.options.returnEmptyString && t === "");
}
getResource(t, r, n, o = {}) {
var a;
return (a = this.i18nFormat) != null && a.getResource ? this.i18nFormat.getResource(t, r, n, o) : this.resourceStore.getResource(t, r, n, o);
}
getUsedParamsDetails(t = {}) {
const r = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = t.replace && !Ze(t.replace);
let o = n ? t.replace : t;
if (n && typeof t.count < "u" && (o.count = t.count), this.options.interpolation.defaultVariables && (o = {
...this.options.interpolation.defaultVariables,
...o
}), !n) {
o = {
...o
};
for (const a of r)
delete o[a];
}
return o;
}
static hasDefaultValue(t) {
const r = "defaultValue";
for (const n in t)
if (Object.prototype.hasOwnProperty.call(t, n) && r === n.substring(0, r.length) && t[n] !== void 0)
return !0;
return !1;
}
}
class B0 {
constructor(t) {
this.options = t, this.supportedLngs = this.options.supportedLngs || !1, this.logger = lo.create("languageUtils");
}
getScriptPartFromCode(t) {
if (t = tu(t), !t || t.indexOf("-") < 0) return null;
const r = t.split("-");
return r.length === 2 || (r.pop(), r[r.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(r.join("-"));
}
getLanguagePartFromCode(t) {
if (t = tu(t), !t || t.indexOf("-") < 0) return t;
const r = t.split("-");
return this.formatLanguageCode(r[0]);
}
formatLanguageCode(t) {
if (Ze(t) && t.indexOf("-") > -1) {
let r;
try {
r = Intl.getCanonicalLocales(t)[0];
} catch {
}
return r && this.options.lowerCaseLng && (r = r.toLowerCase()), r || (this.options.lowerCaseLng ? t.toLowerCase() : t);
}
return this.options.cleanCode || this.options.lowerCaseLng ? t.toLowerCase() : t;
}
isSupportedCode(t) {
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (t = this.getLanguagePartFromCode(t)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(t) > -1;
}
getBestMatchFromCodes(t) {
if (!t) return null;
let r;
return t.forEach((n) => {
if (r) return;
const o = this.formatLanguageCode(n);
(!this.options.supportedLngs || this.isSupportedCode(o)) && (r = o);
}), !r && this.options.supportedLngs && t.forEach((n) => {
if (r) return;
const o = this.getScriptPartFromCode(n);
if (this.isSupportedCode(o)) return r = o;
const a = this.getLanguagePartFromCode(n);
if (this.isSupportedCode(a)) return r = a;
r = this.options.supportedLngs.find((s) => {
if (s === a) return s;
if (!(s.indexOf("-") < 0 && a.indexOf("-") < 0) && (s.indexOf("-") > 0 && a.indexOf("-") < 0 && s.substring(0, s.indexOf("-")) === a || s.indexOf(a) === 0 && a.length > 1))
return s;
});
}), r || (r = this.getFallbackCodes(this.options.fallbackLng)[0]), r;
}
getFallbackCodes(t, r) {
if (!t) return [];
if (typeof t == "function" && (t = t(r)), Ze(t) && (t = [t]), Array.isArray(t)) return t;
if (!r) return t.default || [];
let n = t[r];
return n || (n = t[this.getScriptPartFromCode(r)]), n || (n = t[this.formatLanguageCode(r)]), n || (n = t[this.getLanguagePartFromCode(r)]), n || (n = t.default), n || [];
}
toResolveHierarchy(t, r) {
const n = this.getFallbackCodes((r === !1 ? [] : r) || this.options.fallbackLng || [], t), o = [], a = (s) => {
s && (this.isSupportedCode(s) ? o.push(s) : this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`));
};
return Ze(t) && (t.indexOf("-") > -1 || t.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && a(this.formatLanguageCode(t)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && a(this.getScriptPartFromCode(t)), this.options.load !== "currentOnly" && a(this.getLanguagePartFromCode(t))) : Ze(t) && a(this.formatLanguageCode(t)), n.forEach((s) => {
o.indexOf(s) < 0 && a(this.formatLanguageCode(s));
}), o;
}
}
const H0 = {
zero: 0,
one: 1,
two: 2,
few: 3,
many: 4,
other: 5
}, z0 = {
select: (e) => e === 1 ? "one" : "other",
resolvedOptions: () => ({
pluralCategories: ["one", "other"]
})
};
class oO {
constructor(t, r = {}) {
this.languageUtils = t, this.options = r, this.logger = lo.create("pluralResolver"), this.pluralRulesCache = {};
}
addRule(t, r) {
this.rules[t] = r;
}
clearCache() {
this.pluralRulesCache = {};
}
getRule(t, r = {}) {
const n = tu(t === "dev" ? "en" : t), o = r.ordinal ? "ordinal" : "cardinal", a = JSON.stringify({
cleanedCode: n,
type: o
});
if (a in this.pluralRulesCache)
return this.pluralRulesCache[a];
let s;
try {
s = new Intl.PluralRules(n, {
type: o
});
} catch {
if (!Intl)
return this.logger.error("No Intl support, please use an Intl polyfill!"), z0;
if (!t.match(/-|_/)) return z0;
const l = this.languageUtils.getLanguagePartFromCode(t);
s = this.getRule(l, r);
}
return this.pluralRulesCache[a] = s, s;
}
needsPlural(t, r = {}) {
let n = this.getRule(t, r);
return n || (n = this.getRule("dev", r)), (n == null ? void 0 : n.resolvedOptions().pluralCategories.length) > 1;
}
getPluralFormsOfKey(t, r, n = {}) {
return this.getSuffixes(t, n).map((o) => `${r}${o}`);
}
getSuffixes(t, r = {}) {
let n = this.getRule(t, r);
return n || (n = this.getRule("dev", r)), n ? n.resolvedOptions().pluralCategories.sort((o, a) => H0[o] - H0[a]).map((o) => `${this.options.prepend}${r.ordinal ? `ordinal${this.options.prepend}` : ""}${o}`) : [];
}
getSuffix(t, r, n = {}) {
const o = this.getRule(t, n);
return o ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${o.select(r)}` : (this.logger.warn(`no plural rule found for: ${t}`), this.getSuffix("dev", r, n));
}
}
const G0 = (e, t, r, n = ".", o = !0) => {
let a = YA(e, t, r);
return !a && o && Ze(r) && (a = ug(e, r, n), a === void 0 && (a = ug(t, r, n))), a;
}, Cm = (e) => e.replace(/\$/g, "$$$$");
class aO {
constructor(t = {}) {
var r;
this.logger = lo.create("interpolator"), this.options = t, this.format = ((r = t == null ? void 0 : t.interpolation) == null ? void 0 : r.format) || ((n) => n), this.init(t);
}
init(t = {}) {
t.interpolation || (t.interpolation = {
escapeValue: !0
});
const {
escape: r,
escapeValue: n,
useRawValueToEscape: o,
prefix: a,
prefixEscaped: s,
suffix: i,
suffixEscaped: l,
formatSeparator: u,
unescapeSuffix: c,
unescapePrefix: d,
nestingPrefix: p,
nestingPrefixEscaped: m,
nestingSuffix: h,
nestingSuffixEscaped: g,
nestingOptionsSeparator: w,
maxReplaces: v,
alwaysFormat: y
} = t.interpolation;
this.escape = r !== void 0 ? r : XA, this.escapeValue = n !== void 0 ? n : !0, this.useRawValueToEscape = o !== void 0 ? o : !1, this.prefix = a ? Ls(a) : s || "{{", this.suffix = i ? Ls(i) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = c ? "" : d || "-", this.unescapeSuffix = this.unescapePrefix ? "" : c || "", this.nestingPrefix = p ? Ls(p) : m || Ls("$t("), this.nestingSuffix = h ? Ls(h) : g || Ls(")"), this.nestingOptionsSeparator = w || ",", this.maxReplaces = v || 1e3, this.alwaysFormat = y !== void 0 ? y : !1, this.resetRegExp();
}
reset() {
this.options && this.init(this.options);
}
resetRegExp() {
const t = (r, n) => (r == null ? void 0 : r.source) === n ? (r.lastIndex = 0, r) : new RegExp(n, "g");
this.regexp = t(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = t(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = t(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
}
interpolate(t, r, n, o) {
var m;
let a, s, i;
const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (h) => {
if (h.indexOf(this.formatSeparator) < 0) {
const y = G0(r, l, h, this.options.keySeparator, this.options.ignoreJSONStructure);
return this.alwaysFormat ? this.format(y, void 0, n, {
...o,
...r,
interpolationkey: h
}) : y;
}
const g = h.split(this.formatSeparator), w = g.shift().trim(), v = g.join(this.formatSeparator).trim();
return this.format(G0(r, l, w, this.options.keySeparator, this.options.ignoreJSONStructure), v, n, {
...o,
...r,
interpolationkey: w
});
};
this.resetRegExp();
const c = (o == null ? void 0 : o.missingInterpolationHandler) || this.options.missingInterpolationHandler, d = ((m = o == null ? void 0 : o.interpolation) == null ? void 0 : m.skipOnVariables) !== void 0 ? o.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
return [{
regex: this.regexpUnescape,
safeValue: (h) => Cm(h)
}, {
regex: this.regexp,
safeValue: (h) => this.escapeValue ? Cm(this.escape(h)) : Cm(h)
}].forEach((h) => {
for (i = 0; a = h.regex.exec(t); ) {
const g = a[1].trim();
if (s = u(g), s === void 0)
if (typeof c == "function") {
const v = c(t, a, o);
s = Ze(v) ? v : "";
} else if (o && Object.prototype.hasOwnProperty.call(o, g))
s = "";
else if (d) {
s = a[0];
continue;
} else
this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`), s = "";
else !Ze(s) && !this.useRawValueToEscape && (s = L0(s));
const w = h.safeValue(s);
if (t = t.replace(a[0], w), d ? (h.regex.lastIndex += s.length, h.regex.lastIndex -= a[0].length) : h.regex.lastIndex = 0, i++, i >= this.maxReplaces)
break;
}
}), t;
}
nest(t, r, n = {}) {
let o, a, s;
const i = (l, u) => {
const c = this.nestingOptionsSeparator;
if (l.indexOf(c) < 0) return l;
const d = l.split(new RegExp(`${c}[ ]*{`));
let p = `{${d[1]}`;
l = d[0], p = this.interpolate(p, s);
const m = p.match(/'/g), h = p.match(/"/g);
(((m == null ? void 0 : m.length) ?? 0) % 2 === 0 && !h || h.length % 2 !== 0) && (p = p.replace(/'/g, '"'));
try {
s = JSON.parse(p), u && (s = {
...u,
...s
});
} catch (g) {
return this.logger.warn(`failed parsing options string in nesting for key ${l}`, g), `${l}${c}${p}`;
}
return s.defaultValue && s.defaultValue.indexOf(this.prefix) > -1 && delete s.defaultValue, l;
};
for (; o = this.nestingRegexp.exec(t); ) {
let l = [];
s = {
...n
}, s = s.replace &