1/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */ 2 3// ../../node_modules/@shoelace-style/localize/dist/index.js 4var connectedElements = /* @__PURE__ */ new Set(); 5var translations = /* @__PURE__ */ new Map(); 6var fallback; 7var documentDirection = "ltr"; 8var documentLanguage = "en"; 9var isClient = typeof MutationObserver !== "undefined" && typeof document !== "undefined" && typeof document.documentElement !== "undefined"; 10if (isClient) { 11 const documentElementObserver = new MutationObserver(update); 12 documentDirection = document.documentElement.dir || "ltr"; 13 documentLanguage = document.documentElement.lang || navigator.language; 14 documentElementObserver.observe(document.documentElement, { 15 attributes: true, 16 attributeFilter: ["dir", "lang"] 17 }); 18} 19function registerTranslation(...translation) { 20 translation.map((t) => { 21 const code = t.$code.toLowerCase(); 22 if (translations.has(code)) { 23 translations.set(code, Object.assign(Object.assign({}, translations.get(code)), t)); 24 } else { 25 translations.set(code, t); 26 } 27 if (!fallback) { 28 fallback = t; 29 } 30 }); 31 update(); 32} 33function update() { 34 if (isClient) { 35 documentDirection = document.documentElement.dir || "ltr"; 36 documentLanguage = document.documentElement.lang || navigator.language; 37 } 38 [...connectedElements.keys()].map((el) => { 39 if (typeof el.requestUpdate === "function") { 40 el.requestUpdate(); 41 } 42 }); 43} 44var LocalizeController = class { 45 constructor(host) { 46 this.host = host; 47 this.host.addController(this); 48 } 49 hostConnected() { 50 connectedElements.add(this.host); 51 } 52 hostDisconnected() { 53 connectedElements.delete(this.host); 54 } 55 dir() { 56 return `${this.host.dir || documentDirection}`.toLowerCase(); 57 } 58 lang() { 59 return `${this.host.lang || documentLanguage}`.toLowerCase(); 60 } 61 getTranslationData(lang) { 62 var _a, _b; 63 let locale; 64 try { 65 locale = new Intl.Locale(lang.replace(/_/g, "-")); 66 } catch (_c) { 67 return { locale: void 0, language: "", region: "", primary: void 0, secondary: void 0 }; 68 } 69 const language = locale.language.toLowerCase(); 70 const region = (_b = (_a = locale.region) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : ""; 71 const primary = translations.get(`${language}-${region}`); 72 const secondary = translations.get(language); 73 return { locale, language, region, primary, secondary }; 74 } 75 exists(key, options) { 76 var _a; 77 const { primary, secondary } = this.getTranslationData((_a = options.lang) !== null && _a !== void 0 ? _a : this.lang()); 78 options = Object.assign({ includeFallback: false }, options); 79 if (primary && primary[key] || secondary && secondary[key] || options.includeFallback && fallback && fallback[key]) { 80 return true; 81 } 82 return false; 83 } 84 term(key, ...args) { 85 const { primary, secondary } = this.getTranslationData(this.lang()); 86 let term; 87 if (primary && primary[key]) { 88 term = primary[key]; 89 } else if (secondary && secondary[key]) { 90 term = secondary[key]; 91 } else if (fallback && fallback[key]) { 92 term = fallback[key]; 93 } else { 94 console.error(`No translation found for: ${String(key)}`); 95 return String(key); 96 } 97 if (typeof term === "function") { 98 return term(...args); 99 } 100 return term; 101 } 102 date(dateToFormat, options) { 103 dateToFormat = new Date(dateToFormat); 104 return new Intl.DateTimeFormat(this.lang(), options).format(dateToFormat); 105 } 106 number(numberToFormat, options) { 107 numberToFormat = Number(numberToFormat); 108 return isNaN(numberToFormat) ? "" : new Intl.NumberFormat(this.lang(), options).format(numberToFormat); 109 } 110 relativeTime(value, unit, options) { 111 return new Intl.RelativeTimeFormat(this.lang(), options).format(value, unit); 112 } 113}; 114 115export { 116 registerTranslation, 117 LocalizeController 118};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.