Rocky_Mountain_Vending/.pnpm-store/v10/files/d5/53f897db2cce802fefb58e486223840f86b32cdc81d0138395ee0553f46acaab5e3a0bdd9ebeb0ccd24b8c1a9e3c61b866d44ffb066261f68e7852a3fdabf5
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

86 lines
3.1 KiB
Text

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBestPattern = getBestPattern;
var time_data_generated_1 = require("./time-data.generated");
/**
* Returns the best matching date time pattern if a date time skeleton
* pattern is provided with a locale. Follows the Unicode specification:
* https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
* @param skeleton date time skeleton pattern that possibly includes j, J or C
* @param locale
*/
function getBestPattern(skeleton, locale) {
var skeletonCopy = '';
for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
var patternChar = skeleton.charAt(patternPos);
if (patternChar === 'j') {
var extraLength = 0;
while (patternPos + 1 < skeleton.length &&
skeleton.charAt(patternPos + 1) === patternChar) {
extraLength++;
patternPos++;
}
var hourLen = 1 + (extraLength & 1);
var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
var dayPeriodChar = 'a';
var hourChar = getDefaultHourSymbolFromLocale(locale);
if (hourChar == 'H' || hourChar == 'k') {
dayPeriodLen = 0;
}
while (dayPeriodLen-- > 0) {
skeletonCopy += dayPeriodChar;
}
while (hourLen-- > 0) {
skeletonCopy = hourChar + skeletonCopy;
}
}
else if (patternChar === 'J') {
skeletonCopy += 'H';
}
else {
skeletonCopy += patternChar;
}
}
return skeletonCopy;
}
/**
* Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
* of the given `locale` to the corresponding time pattern.
* @param locale
*/
function getDefaultHourSymbolFromLocale(locale) {
var hourCycle = locale.hourCycle;
if (hourCycle === undefined &&
// @ts-ignore hourCycle(s) is not identified yet
locale.hourCycles &&
// @ts-ignore
locale.hourCycles.length) {
// @ts-ignore
hourCycle = locale.hourCycles[0];
}
if (hourCycle) {
switch (hourCycle) {
case 'h24':
return 'k';
case 'h23':
return 'H';
case 'h12':
return 'h';
case 'h11':
return 'K';
default:
throw new Error('Invalid hourCycle');
}
}
// TODO: Once hourCycle is fully supported remove the following with data generation
var languageTag = locale.language;
var regionTag;
if (languageTag !== 'root') {
regionTag = locale.maximize().region;
}
var hourCycles = time_data_generated_1.timeData[regionTag || ''] ||
time_data_generated_1.timeData[languageTag || ''] ||
time_data_generated_1.timeData["".concat(languageTag, "-001")] ||
time_data_generated_1.timeData['001'];
return hourCycles[0];
}