@common.js/formatjs__icu-messageformat-parser 3.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../error.ts","../types.ts","../../../node_modules/.aspect_rules_js/@formatjs_generated+unicode@0.0.0/node_modules/@formatjs_generated/unicode/icu-messageformat-parser-regex.js","../../../node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/time-data.js","../date-time-pattern-generator.ts","../parser.ts","../manipulator.ts","../index.ts"],"sourcesContent":["import {type Location} from '#packages/icu-messageformat-parser/types.js'\n\nexport interface ParserError {\n kind: ErrorKind\n message: string\n location: Location\n}\n\nexport enum ErrorKind {\n /** Argument is unclosed (e.g. `{0`) */\n EXPECT_ARGUMENT_CLOSING_BRACE = 1,\n /** Argument is empty (e.g. `{}`). */\n EMPTY_ARGUMENT = 2,\n /** Argument is malformed (e.g. `{foo!}``) */\n MALFORMED_ARGUMENT = 3,\n /** Expect an argument type (e.g. `{foo,}`) */\n EXPECT_ARGUMENT_TYPE = 4,\n /** Unsupported argument type (e.g. `{foo,foo}`) */\n INVALID_ARGUMENT_TYPE = 5,\n /** Expect an argument style (e.g. `{foo, number, }`) */\n EXPECT_ARGUMENT_STYLE = 6,\n /** The number skeleton is invalid. */\n INVALID_NUMBER_SKELETON = 7,\n /** The date time skeleton is invalid. */\n INVALID_DATE_TIME_SKELETON = 8,\n /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */\n EXPECT_NUMBER_SKELETON = 9,\n /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */\n EXPECT_DATE_TIME_SKELETON = 10,\n /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */\n UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11,\n /** Missing select argument options (e.g. `{foo, select}`) */\n EXPECT_SELECT_ARGUMENT_OPTIONS = 12,\n\n /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */\n EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13,\n /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */\n INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14,\n\n /** Expecting a selector in `select` argument (e.g `{foo, select}`) */\n EXPECT_SELECT_ARGUMENT_SELECTOR = 15,\n /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */\n EXPECT_PLURAL_ARGUMENT_SELECTOR = 16,\n\n /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */\n EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17,\n /**\n * Expecting a message fragment after the `plural` or `selectordinal` selector\n * (e.g. `{foo, plural, one}`)\n */\n EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18,\n\n /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */\n INVALID_PLURAL_ARGUMENT_SELECTOR = 19,\n\n /**\n * Duplicate selectors in `plural` or `selectordinal` argument.\n * (e.g. {foo, plural, one {#} one {#}})\n */\n DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20,\n /** Duplicate selectors in `select` argument.\n * (e.g. {foo, select, apple {apple} apple {apple}})\n */\n DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21,\n\n /** Plural or select argument option must have `other` clause. */\n MISSING_OTHER_CLAUSE = 22,\n\n /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */\n INVALID_TAG = 23,\n /** The tag name is invalid. (e.g. `<123>foo</123>`) */\n INVALID_TAG_NAME = 25,\n /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */\n UNMATCHED_CLOSING_TAG = 26,\n /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */\n UNCLOSED_TAG = 27,\n}\n","import type {NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {type NumberSkeletonToken} from '@formatjs/icu-skeleton-parser'\n\nexport interface ExtendedNumberFormatOptions extends NumberFormatOptions {\n scale?: number\n}\n\nexport enum TYPE {\n /**\n * Raw text\n */\n literal,\n /**\n * Variable w/o any format, e.g `var` in `this is a {var}`\n */\n argument,\n /**\n * Variable w/ number format\n */\n number,\n /**\n * Variable w/ date format\n */\n date,\n /**\n * Variable w/ time format\n */\n time,\n /**\n * Variable w/ select format\n */\n select,\n /**\n * Variable w/ plural format\n */\n plural,\n /**\n * Only possible within plural argument.\n * This is the `#` symbol that will be substituted with the count.\n */\n pound,\n /**\n * XML-like tag\n */\n tag,\n}\n\nexport enum SKELETON_TYPE {\n number,\n dateTime,\n}\n\nexport interface LocationDetails {\n offset: number\n line: number\n column: number\n}\nexport interface Location {\n start: LocationDetails\n end: LocationDetails\n}\n\nexport interface BaseElement<T extends TYPE> {\n type: T\n value: string\n location?: Location\n}\n\nexport type LiteralElement = BaseElement<TYPE.literal>\nexport type ArgumentElement = BaseElement<TYPE.argument>\nexport interface TagElement extends BaseElement<TYPE.tag> {\n children: MessageFormatElement[]\n}\n\nexport interface SimpleFormatElement<\n T extends TYPE,\n S extends Skeleton,\n> extends BaseElement<T> {\n style?: string | S | null\n}\n\nexport type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>\nexport type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>\nexport type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>\n\nexport type ValidPluralRule =\n | 'zero'\n | 'one'\n | 'two'\n | 'few'\n | 'many'\n | 'other'\n | string\n\nexport interface PluralOrSelectOption {\n value: MessageFormatElement[]\n location?: Location\n}\n\nexport interface SelectElement extends BaseElement<TYPE.select> {\n options: Record<string, PluralOrSelectOption>\n}\n\nexport interface PluralElement extends BaseElement<TYPE.plural> {\n options: Record<ValidPluralRule, PluralOrSelectOption>\n offset: number\n pluralType: Intl.PluralRulesOptions['type']\n}\n\nexport interface PoundElement {\n type: TYPE.pound\n location?: Location\n}\n\nexport type MessageFormatElement =\n | ArgumentElement\n | DateElement\n | LiteralElement\n | NumberElement\n | PluralElement\n | PoundElement\n | SelectElement\n | TagElement\n | TimeElement\n\nexport interface NumberSkeleton {\n type: SKELETON_TYPE.number\n tokens: NumberSkeletonToken[]\n location?: Location\n parsedOptions: ExtendedNumberFormatOptions\n}\n\nexport interface DateTimeSkeleton {\n type: SKELETON_TYPE.dateTime\n pattern: string\n location?: Location\n parsedOptions: Intl.DateTimeFormatOptions\n}\n\nexport type Skeleton = NumberSkeleton | DateTimeSkeleton\n\n/**\n * Type Guards\n */\nexport function isLiteralElement(\n el: MessageFormatElement\n): el is LiteralElement {\n return el.type === TYPE.literal\n}\nexport function isArgumentElement(\n el: MessageFormatElement\n): el is ArgumentElement {\n return el.type === TYPE.argument\n}\nexport function isNumberElement(el: MessageFormatElement): el is NumberElement {\n return el.type === TYPE.number\n}\nexport function isDateElement(el: MessageFormatElement): el is DateElement {\n return el.type === TYPE.date\n}\nexport function isTimeElement(el: MessageFormatElement): el is TimeElement {\n return el.type === TYPE.time\n}\nexport function isSelectElement(el: MessageFormatElement): el is SelectElement {\n return el.type === TYPE.select\n}\nexport function isPluralElement(el: MessageFormatElement): el is PluralElement {\n return el.type === TYPE.plural\n}\nexport function isPoundElement(el: MessageFormatElement): el is PoundElement {\n return el.type === TYPE.pound\n}\nexport function isTagElement(el: MessageFormatElement): el is TagElement {\n return el.type === TYPE.tag\n}\nexport function isNumberSkeleton(\n el: NumberElement['style'] | Skeleton\n): el is NumberSkeleton {\n return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number)\n}\nexport function isDateTimeSkeleton(\n el?: DateElement['style'] | TimeElement['style'] | Skeleton\n): el is DateTimeSkeleton {\n return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime)\n}\n\nexport function createLiteralElement(value: string): LiteralElement {\n return {\n type: TYPE.literal,\n value,\n }\n}\n\nexport function createNumberElement(\n value: string,\n style?: string | null\n): NumberElement {\n return {\n type: TYPE.number,\n value,\n style,\n }\n}\n","// @generated from regex-gen.ts\nexport const SPACE_SEPARATOR_REGEX = /[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]/;\nexport const WHITE_SPACE_REGEX = /[\\t-\\r \\x85\\u200E\\u200F\\u2028\\u2029]/;\n","// @generated from time-data-gen.ts\n// prettier-ignore\nexport const timeData = {\n\t\"001\": [\"H\", \"h\"],\n\t\"419\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"AC\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"AD\": [\"H\", \"hB\"],\n\t\"AE\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"AF\": [\n\t\t\"H\",\n\t\t\"hb\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"AG\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"AI\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"AL\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"AM\": [\"H\", \"hB\"],\n\t\"AO\": [\"H\", \"hB\"],\n\t\"AR\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"AS\": [\"h\", \"H\"],\n\t\"AT\": [\"H\", \"hB\"],\n\t\"AU\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"AW\": [\"H\", \"hB\"],\n\t\"AX\": [\"H\"],\n\t\"AZ\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"BA\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"BB\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"BD\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"H\"\n\t],\n\t\"BE\": [\"H\", \"hB\"],\n\t\"BF\": [\"H\", \"hB\"],\n\t\"BG\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"BH\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"BI\": [\"H\", \"h\"],\n\t\"BJ\": [\"H\", \"hB\"],\n\t\"BL\": [\"H\", \"hB\"],\n\t\"BM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"BN\": [\n\t\t\"hb\",\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"BO\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"BQ\": [\"H\"],\n\t\"BR\": [\"H\", \"hB\"],\n\t\"BS\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"BT\": [\"h\", \"H\"],\n\t\"BW\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"BY\": [\"H\", \"h\"],\n\t\"BZ\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"CA\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"CC\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"CD\": [\"hB\", \"H\"],\n\t\"CF\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"CG\": [\"H\", \"hB\"],\n\t\"CH\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"CI\": [\"H\", \"hB\"],\n\t\"CK\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"CL\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"CM\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"CN\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\"\n\t],\n\t\"CO\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"CP\": [\"H\"],\n\t\"CR\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"CU\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"CV\": [\"H\", \"hB\"],\n\t\"CW\": [\"H\", \"hB\"],\n\t\"CX\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"CY\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"CZ\": [\"H\"],\n\t\"DE\": [\"H\", \"hB\"],\n\t\"DG\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"DJ\": [\"h\", \"H\"],\n\t\"DK\": [\"H\"],\n\t\"DM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"DO\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"DZ\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"EA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"EC\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"EE\": [\"H\", \"hB\"],\n\t\"EG\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"EH\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"ER\": [\"h\", \"H\"],\n\t\"ES\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"hb\"\n\t],\n\t\"ET\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"FI\": [\"H\"],\n\t\"FJ\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"FK\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"FM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"FO\": [\"H\", \"h\"],\n\t\"FR\": [\"H\", \"hB\"],\n\t\"GA\": [\"H\", \"hB\"],\n\t\"GB\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"GD\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"GE\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"GF\": [\"H\", \"hB\"],\n\t\"GG\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"GH\": [\"h\", \"H\"],\n\t\"GI\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"GL\": [\"H\", \"h\"],\n\t\"GM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"GN\": [\"H\", \"hB\"],\n\t\"GP\": [\"H\", \"hB\"],\n\t\"GQ\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"hb\"\n\t],\n\t\"GR\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"GS\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"GT\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"GU\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"GW\": [\"H\", \"hB\"],\n\t\"GY\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"HK\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"HN\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"HR\": [\"H\", \"hB\"],\n\t\"HU\": [\"H\", \"h\"],\n\t\"IC\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"ID\": [\"H\"],\n\t\"IE\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"IL\": [\"H\", \"hB\"],\n\t\"IM\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"IN\": [\"h\", \"H\"],\n\t\"IO\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"IQ\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"IR\": [\"hB\", \"H\"],\n\t\"IS\": [\"H\"],\n\t\"IT\": [\"H\", \"hB\"],\n\t\"JE\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"JM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"JO\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"JP\": [\n\t\t\"H\",\n\t\t\"K\",\n\t\t\"h\"\n\t],\n\t\"KE\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"h\"\n\t],\n\t\"KG\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"KH\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hb\"\n\t],\n\t\"KI\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"KM\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"KN\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"KP\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"KR\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"KW\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"KY\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"KZ\": [\"H\", \"hB\"],\n\t\"LA\": [\n\t\t\"H\",\n\t\t\"hb\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"LB\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"LC\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"LI\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"LK\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"LR\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"LS\": [\"h\", \"H\"],\n\t\"LT\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"LU\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"LV\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\"\n\t],\n\t\"LY\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"MA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"MC\": [\"H\", \"hB\"],\n\t\"MD\": [\"H\", \"hB\"],\n\t\"ME\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"MF\": [\"H\", \"hB\"],\n\t\"MG\": [\"H\", \"h\"],\n\t\"MH\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"MK\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"ML\": [\"H\"],\n\t\"MM\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"h\"\n\t],\n\t\"MN\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"MO\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"MP\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"MQ\": [\"H\", \"hB\"],\n\t\"MR\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"MS\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"MT\": [\"H\", \"h\"],\n\t\"MU\": [\"H\", \"h\"],\n\t\"MV\": [\"H\", \"h\"],\n\t\"MW\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"MX\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"MY\": [\n\t\t\"hb\",\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"MZ\": [\"H\", \"hB\"],\n\t\"NA\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"NC\": [\"H\", \"hB\"],\n\t\"NE\": [\"H\"],\n\t\"NF\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"NG\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"NI\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"NL\": [\"H\", \"hB\"],\n\t\"NO\": [\"H\", \"h\"],\n\t\"NP\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"NR\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"NU\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"NZ\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"OM\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"PA\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"PE\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"PF\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"PG\": [\"h\", \"H\"],\n\t\"PH\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"PK\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"H\"\n\t],\n\t\"PL\": [\"H\", \"h\"],\n\t\"PM\": [\"H\", \"hB\"],\n\t\"PN\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"PR\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"PS\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"PT\": [\"H\", \"hB\"],\n\t\"PW\": [\"h\", \"H\"],\n\t\"PY\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"QA\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"RE\": [\"H\", \"hB\"],\n\t\"RO\": [\"H\", \"hB\"],\n\t\"RS\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"RU\": [\"H\"],\n\t\"RW\": [\"H\", \"h\"],\n\t\"SA\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"SB\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"SC\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"SD\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"SE\": [\"H\"],\n\t\"SG\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"SH\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"SI\": [\"H\", \"hB\"],\n\t\"SJ\": [\"H\"],\n\t\"SK\": [\"H\"],\n\t\"SL\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"SM\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"SN\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"SO\": [\"h\", \"H\"],\n\t\"SR\": [\"H\", \"hB\"],\n\t\"SS\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"ST\": [\"H\", \"hB\"],\n\t\"SV\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"SX\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"SY\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"SZ\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"TA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"TC\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"TD\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"TF\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"TG\": [\"H\", \"hB\"],\n\t\"TH\": [\"H\", \"h\"],\n\t\"TJ\": [\"H\", \"h\"],\n\t\"TL\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\"\n\t],\n\t\"TM\": [\"H\", \"h\"],\n\t\"TN\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"TO\": [\"h\", \"H\"],\n\t\"TR\": [\"H\", \"hB\"],\n\t\"TT\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"TW\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"TZ\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"h\"\n\t],\n\t\"UA\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"UG\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"h\"\n\t],\n\t\"UM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"US\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"UY\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"UZ\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"VA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"VC\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"VE\": [\n\t\t\"h\",\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"VG\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"VI\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"VN\": [\"H\", \"h\"],\n\t\"VU\": [\"h\", \"H\"],\n\t\"WF\": [\"H\", \"hB\"],\n\t\"WS\": [\"h\", \"H\"],\n\t\"XK\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"h\"\n\t],\n\t\"YE\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"YT\": [\"H\", \"hB\"],\n\t\"ZA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"ZM\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"ZW\": [\"H\", \"h\"],\n\t\"af-ZA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"ar-001\": [\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"ca-ES\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"en-001\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"en-HK\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"en-IL\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"hB\"\n\t],\n\t\"en-MY\": [\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\",\n\t\t\"hB\"\n\t],\n\t\"es-BR\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"es-ES\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"es-GQ\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\",\n\t\t\"hb\"\n\t],\n\t\"fr-CA\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"gl-ES\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"gu-IN\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"hi-IN\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"it-CH\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"it-IT\": [\n\t\t\"H\",\n\t\t\"h\",\n\t\t\"hB\"\n\t],\n\t\"kn-IN\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"ku-SY\": [\"H\", \"hB\"],\n\t\"ml-IN\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"mr-IN\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"pa-IN\": [\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"ta-IN\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"hb\",\n\t\t\"H\"\n\t],\n\t\"te-IN\": [\n\t\t\"hB\",\n\t\t\"h\",\n\t\t\"H\"\n\t],\n\t\"zu-ZA\": [\n\t\t\"H\",\n\t\t\"hB\",\n\t\t\"hb\",\n\t\t\"h\"\n\t]\n};\n","import {timeData} from '@formatjs_generated/cldr.core/time-data.js'\n\n/**\n * Returns the best matching date time pattern if a date time skeleton\n * pattern is provided with a locale. Follows the Unicode specification:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns\n * @param skeleton date time skeleton pattern that possibly includes j, J or C\n * @param locale\n */\nexport function getBestPattern(skeleton: string, locale: Intl.Locale): string {\n let skeletonCopy = ''\n for (let patternPos = 0; patternPos < skeleton.length; patternPos++) {\n const patternChar = skeleton.charAt(patternPos)\n\n if (patternChar === 'j') {\n let extraLength = 0\n while (\n patternPos + 1 < skeleton.length &&\n skeleton.charAt(patternPos + 1) === patternChar\n ) {\n extraLength++\n patternPos++\n }\n\n let hourLen = 1 + (extraLength & 1)\n let dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1)\n let dayPeriodChar = 'a'\n let hourChar = getDefaultHourSymbolFromLocale(locale)\n\n if (hourChar == 'H' || hourChar == 'k') {\n dayPeriodLen = 0\n }\n\n while (dayPeriodLen-- > 0) {\n skeletonCopy += dayPeriodChar\n }\n while (hourLen-- > 0) {\n skeletonCopy = hourChar + skeletonCopy\n }\n } else if (patternChar === 'J') {\n skeletonCopy += 'H'\n } else {\n skeletonCopy += patternChar\n }\n }\n\n return skeletonCopy\n}\n\n/**\n * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)\n * of the given `locale` to the corresponding time pattern.\n * @param locale\n */\nfunction getDefaultHourSymbolFromLocale(locale: Intl.Locale): string {\n let hourCycle = locale.hourCycle\n\n if (\n hourCycle === undefined &&\n // @ts-ignore hourCycle(s) is not identified yet\n locale.hourCycles &&\n // @ts-ignore\n locale.hourCycles.length\n ) {\n // @ts-ignore\n hourCycle = locale.hourCycles[0]\n }\n\n if (hourCycle) {\n switch (hourCycle) {\n case 'h24':\n return 'k'\n case 'h23':\n return 'H'\n case 'h12':\n return 'h'\n case 'h11':\n return 'K'\n default:\n throw new Error('Invalid hourCycle')\n }\n }\n\n // TODO: Once hourCycle is fully supported remove the following with data generation\n const languageTag = locale.language\n let regionTag: string | undefined\n if (languageTag !== 'root') {\n regionTag = locale.maximize().region\n }\n const hourCycles =\n timeData[regionTag || ''] ||\n timeData[languageTag || ''] ||\n timeData[`${languageTag}-001`] ||\n timeData['001']\n return hourCycles[0]\n}\n","import {\n ErrorKind,\n type ParserError,\n} from '#packages/icu-messageformat-parser/error.js'\nimport {\n type DateTimeSkeleton,\n type LiteralElement,\n type Location,\n type MessageFormatElement,\n type NumberSkeleton,\n type PluralOrSelectOption,\n SKELETON_TYPE,\n type TagElement,\n TYPE,\n} from '#packages/icu-messageformat-parser/types.js'\nimport {SPACE_SEPARATOR_REGEX} from '@formatjs_generated/unicode/icu-messageformat-parser-regex.js'\nimport {\n type NumberSkeletonToken,\n parseNumberSkeleton,\n parseNumberSkeletonFromString,\n parseDateTimeSkeleton,\n} from '@formatjs/icu-skeleton-parser'\nimport {getBestPattern} from '#packages/icu-messageformat-parser/date-time-pattern-generator.js'\n\nconst SPACE_SEPARATOR_START_REGEX = new RegExp(\n `^${SPACE_SEPARATOR_REGEX.source}*`\n)\nconst SPACE_SEPARATOR_END_REGEX = new RegExp(\n `${SPACE_SEPARATOR_REGEX.source}*$`\n)\n\nexport interface Position {\n /** Offset in terms of UTF-16 *code unit*. */\n offset: number\n line: number\n /** Column offset in terms of unicode *code point*. */\n column: number\n}\n\nexport interface ParserOptions {\n /**\n * Whether to treat HTML/XML tags as string literal\n * instead of parsing them as tag token.\n * When this is false we only allow simple tags without\n * any attributes\n */\n ignoreTag?: boolean\n /**\n * Should `select`, `selectordinal`, and `plural` arguments always include\n * the `other` case clause.\n */\n requiresOtherClause?: boolean\n /**\n * Whether to parse number/datetime skeleton\n * into Intl.NumberFormatOptions and Intl.DateTimeFormatOptions, respectively.\n */\n shouldParseSkeletons?: boolean\n /**\n * Capture location info in AST\n * Default is false\n */\n captureLocation?: boolean\n /**\n * Instance of Intl.Locale to resolve locale-dependent skeleton\n */\n locale?: Intl.Locale\n}\n\nexport type Result<T, E> = {val: T; err: null} | {val: null; err: E}\ntype ArgType =\n | 'number'\n | 'date'\n | 'time'\n | 'select'\n | 'plural'\n | 'selectordinal'\n | ''\n\nfunction createLocation(start: Position, end: Position): Location {\n return {start, end}\n}\n\n// #region Ponyfills\n// Consolidate these variables up top for easier toggling during debugging\nconst hasNativeFromEntries = !!(Object as any).fromEntries\nconst hasTrimStart = !!(String.prototype as any).trimStart\nconst hasTrimEnd = !!(String.prototype as any).trimEnd\n\nconst fromEntries: <T = any>(\n entries: readonly (readonly [string, T])[]\n) => {[k: string]: T} =\n // native\n hasNativeFromEntries\n ? (Object as any).fromEntries\n : // Ponyfill\n function fromEntries(entries) {\n const obj: Record<string, any> = {}\n for (const [k, v] of entries) {\n obj[k] = v\n }\n return obj\n }\n\nconst trimStart: (s: string) => string = hasTrimStart\n ? // Native\n function trimStart(s) {\n return (s as any).trimStart()\n }\n : // Ponyfill\n function trimStart(s) {\n return s.replace(SPACE_SEPARATOR_START_REGEX, '')\n }\n\nconst trimEnd: (s: string) => string = hasTrimEnd\n ? // Native\n function trimEnd(s) {\n return (s as any).trimEnd()\n }\n : // Ponyfill\n function trimEnd(s) {\n return s.replace(SPACE_SEPARATOR_END_REGEX, '')\n }\n\n// #endregion\n\nconst IDENTIFIER_PREFIX_RE = new RegExp(\n '([^\\\\p{White_Space}\\\\p{Pattern_Syntax}]*)',\n 'yu'\n)\n\nfunction matchIdentifierAtIndex(s: string, index: number): string {\n IDENTIFIER_PREFIX_RE.lastIndex = index\n const match = IDENTIFIER_PREFIX_RE.exec(s)!\n return match[1] ?? ''\n}\n\nfunction plainTopLevelEndPosition(message: string): Position | null {\n if (message.length === 0) {\n return null\n }\n let line = 1\n let column = 1\n for (let offset = 0; offset < message.length; ) {\n const code = message.charCodeAt(offset)\n switch (code) {\n case 35: // #\n case 39: // '\n case 60: // <\n case 123: // {\n case 125: // }\n return null\n }\n if (code === 10 /* '\\n' */) {\n line++\n column = 1\n offset++\n } else {\n column++\n if (code >= 0xd800 && code <= 0xdbff && offset + 1 < message.length) {\n const next = message.charCodeAt(offset + 1)\n offset += next >= 0xdc00 && next <= 0xdfff ? 2 : 1\n } else {\n offset++\n }\n }\n }\n return {offset: message.length, line, column}\n}\n\nexport class Parser {\n private message: string\n private position: Position\n private locale?: Intl.Locale\n\n private ignoreTag: boolean\n private requiresOtherClause: boolean\n private shouldParseSkeletons?: boolean\n\n constructor(message: string, options: ParserOptions = {}) {\n this.message = message\n this.position = {offset: 0, line: 1, column: 1}\n this.ignoreTag = !!options.ignoreTag\n this.locale = options.locale\n this.requiresOtherClause = !!options.requiresOtherClause\n this.shouldParseSkeletons = !!options.shouldParseSkeletons\n }\n\n parse(): Result<MessageFormatElement[], ParserError> {\n if (this.offset() !== 0) {\n throw Error('parser can only be used once')\n }\n if (this.message.length > 0) {\n const firstCode = this.message.charCodeAt(0)\n if (\n firstCode !== 35 /* # */ &&\n firstCode !== 39 /* ' */ &&\n firstCode !== 60 /* < */ &&\n firstCode !== 123 /* { */ &&\n firstCode !== 125 /* } */\n ) {\n const plainEndPosition = plainTopLevelEndPosition(this.message)\n if (plainEndPosition) {\n const start = this.clonePosition()\n this.position = plainEndPosition\n return {\n val: [\n {\n type: TYPE.literal,\n value: this.message,\n location: createLocation(start, this.clonePosition()),\n },\n ],\n err: null,\n }\n }\n }\n }\n return this.parseMessage(0, '', false)\n }\n\n private parseMessage(\n nestingLevel: number,\n parentArgType: ArgType,\n expectingCloseTag: boolean\n ): Result<MessageFormatElement[], ParserError> {\n let elements: MessageFormatElement[] = []\n\n while (!this.isEOF()) {\n const char = this.char()\n if (char === 123 /* `{` */) {\n const result = this.parseArgument(nestingLevel, expectingCloseTag)\n if (result.err) {\n return result\n }\n elements.push(result.val)\n } else if (char === 125 /* `}` */ && nestingLevel > 0) {\n break\n } else if (\n char === 35 /* `#` */ &&\n (parentArgType === 'plural' || parentArgType === 'selectordinal')\n ) {\n const position = this.clonePosition()\n this.bump()\n elements.push({\n type: TYPE.pound,\n location: createLocation(position, this.clonePosition()),\n })\n } else if (\n char === 60 /* `<` */ &&\n !this.ignoreTag &&\n this.peek() === 47 // char code for '/'\n ) {\n if (expectingCloseTag) {\n break\n } else {\n return this.error(\n ErrorKind.UNMATCHED_CLOSING_TAG,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n } else if (\n char === 60 /* `<` */ &&\n !this.ignoreTag &&\n _isAlpha(this.peek() || 0)\n ) {\n const result = this.parseTag(nestingLevel, parentArgType)\n if (result.err) {\n return result\n }\n elements.push(result.val)\n } else {\n const result = this.parseLiteral(nestingLevel, parentArgType)\n if (result.err) {\n return result\n }\n elements.push(result.val)\n }\n }\n\n return {val: elements, err: null}\n }\n /**\n * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the\n * [custom element name][] except that a dash is NOT always mandatory and uppercase letters\n * are accepted:\n *\n * ```\n * tag ::= \"<\" tagName (whitespace)* \"/>\" | \"<\" tagName (whitespace)* \">\" message \"</\" tagName (whitespace)* \">\"\n * tagName ::= [a-z] (PENChar)*\n * PENChar ::=\n * \"-\" | \".\" | [0-9] | \"_\" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |\n * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |\n * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]\n * ```\n *\n * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name\n * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do\n * since other tag-based engines like React allow it\n */\n private parseTag(\n nestingLevel: number,\n parentArgType: ArgType\n ): Result<TagElement | LiteralElement, ParserError> {\n const startPosition = this.clonePosition()\n this.bump() // `<`\n\n const tagName = this.parseTagName()\n this.bumpSpace()\n\n if (this.bumpIf('/>')) {\n // Self closing tag\n return {\n val: {\n type: TYPE.literal,\n value: `<${tagName}/>`,\n location: createLocation(startPosition, this.clonePosition()),\n } as LiteralElement,\n err: null,\n }\n } else if (this.bumpIf('>')) {\n const childrenResult = this.parseMessage(\n nestingLevel + 1,\n parentArgType,\n true\n )\n if (childrenResult.err) {\n return childrenResult\n }\n const children = childrenResult.val\n\n // Expecting a close tag\n const endTagStartPosition = this.clonePosition()\n\n if (this.bumpIf('</')) {\n if (this.isEOF() || !_isAlpha(this.char())) {\n return this.error(\n ErrorKind.INVALID_TAG,\n createLocation(endTagStartPosition, this.clonePosition())\n )\n }\n\n const closingTagNameStartPosition = this.clonePosition()\n const closingTagName = this.parseTagName()\n if (tagName !== closingTagName) {\n return this.error(\n ErrorKind.UNMATCHED_CLOSING_TAG,\n createLocation(closingTagNameStartPosition, this.clonePosition())\n )\n }\n\n this.bumpSpace()\n if (!this.bumpIf('>')) {\n return this.error(\n ErrorKind.INVALID_TAG,\n createLocation(endTagStartPosition, this.clonePosition())\n )\n }\n\n return {\n val: {\n type: TYPE.tag,\n value: tagName,\n children,\n location: createLocation(startPosition, this.clonePosition()),\n },\n err: null,\n }\n } else {\n return this.error(\n ErrorKind.UNCLOSED_TAG,\n createLocation(startPosition, this.clonePosition())\n )\n }\n } else {\n return this.error(\n ErrorKind.INVALID_TAG,\n createLocation(startPosition, this.clonePosition())\n )\n }\n }\n\n /**\n * This method assumes that the caller has peeked ahead for the first tag character.\n */\n private parseTagName(): string {\n const startOffset = this.offset()\n\n this.bump() // the first tag name character\n while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {\n this.bump()\n }\n return this.message.slice(startOffset, this.offset())\n }\n\n private parseLiteral(\n nestingLevel: number,\n parentArgType: ArgType\n ): Result<LiteralElement, ParserError> {\n const start = this.clonePosition()\n\n let value = ''\n while (true) {\n const parseQuoteResult = this.tryParseQuote(parentArgType)\n if (parseQuoteResult) {\n value += parseQuoteResult\n continue\n }\n\n const parseUnquotedResult = this.tryParseUnquoted(\n nestingLevel,\n parentArgType\n )\n if (parseUnquotedResult) {\n value += parseUnquotedResult\n continue\n }\n\n const parseLeftAngleResult = this.tryParseLeftAngleBracket()\n if (parseLeftAngleResult) {\n value += parseLeftAngleResult\n continue\n }\n\n break\n }\n\n const location = createLocation(start, this.clonePosition())\n return {\n val: {type: TYPE.literal, value, location},\n err: null,\n }\n }\n\n tryParseLeftAngleBracket(): string | null {\n if (\n !this.isEOF() &&\n this.char() === 60 /* `<` */ &&\n (this.ignoreTag ||\n // If at the opening tag or closing tag position, bail.\n !_isAlphaOrSlash(this.peek() || 0))\n ) {\n this.bump() // `<`\n return '<'\n }\n return null\n }\n\n /**\n * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes\n * a character that requires quoting (that is, \"only where needed\"), and works the same in\n * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.\n */\n private tryParseQuote(parentArgType: ArgType): string | null {\n if (this.isEOF() || this.char() !== 39 /* `'` */) {\n return null\n }\n\n // Parse escaped char following the apostrophe, or early return if there is no escaped char.\n // Check if is valid escaped character\n switch (this.peek()) {\n case 39 /* `'` */:\n // double quote, should return as a single quote.\n this.bump()\n this.bump()\n return \"'\"\n // '{', '<', '>', '}'\n case 123:\n case 60:\n case 62:\n case 125:\n break\n case 35: // '#'\n if (parentArgType === 'plural' || parentArgType === 'selectordinal') {\n break\n }\n return null\n default:\n return null\n }\n\n this.bump() // apostrophe\n const codePoints = [this.char()] // escaped char\n this.bump()\n\n // read chars until the optional closing apostrophe is found\n while (!this.isEOF()) {\n const ch = this.char()\n if (ch === 39 /* `'` */) {\n if (this.peek() === 39 /* `'` */) {\n codePoints.push(39)\n // Bump one more time because we need to skip 2 characters.\n this.bump()\n } else {\n // Optional closing apostrophe.\n this.bump()\n break\n }\n } else {\n codePoints.push(ch)\n }\n this.bump()\n }\n\n return String.fromCodePoint(...codePoints)\n }\n\n private tryParseUnquoted(\n nestingLevel: number,\n parentArgType: ArgType\n ): string | null {\n if (this.isEOF()) {\n return null\n }\n const ch = this.char()\n\n if (\n ch === 60 /* `<` */ ||\n ch === 123 /* `{` */ ||\n (ch === 35 /* `#` */ &&\n (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||\n (ch === 125 /* `}` */ && nestingLevel > 0)\n ) {\n return null\n } else {\n this.bump()\n return String.fromCodePoint(ch)\n }\n }\n\n private parseArgument(\n nestingLevel: number,\n expectingCloseTag: boolean\n ): Result<MessageFormatElement, ParserError> {\n const openingBracePosition = this.clonePosition()\n this.bump() // `{`\n\n this.bumpSpace()\n\n if (this.isEOF()) {\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n\n if (this.char() === 125 /* `}` */) {\n this.bump()\n return this.error(\n ErrorKind.EMPTY_ARGUMENT,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n\n // argument name\n let value = this.parseIdentifierIfPossible().value\n if (!value) {\n return this.error(\n ErrorKind.MALFORMED_ARGUMENT,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n\n this.bumpSpace()\n\n if (this.isEOF()) {\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n\n switch (this.char()) {\n // Simple argument: `{name}`\n case 125 /* `}` */: {\n this.bump() // `}`\n return {\n val: {\n type: TYPE.argument,\n // value does not include the opening and closing braces.\n value,\n location: createLocation(\n openingBracePosition,\n this.clonePosition()\n ),\n },\n err: null,\n }\n }\n // Argument with options: `{name, format, ...}`\n case 44 /* `,` */: {\n this.bump() // `,`\n this.bumpSpace()\n\n if (this.isEOF()) {\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n\n return this.parseArgumentOptions(\n nestingLevel,\n expectingCloseTag,\n value,\n openingBracePosition\n )\n }\n default:\n return this.error(\n ErrorKind.MALFORMED_ARGUMENT,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n }\n\n /**\n * Advance the parser until the end of the identifier, if it is currently on\n * an identifier character. Return an empty string otherwise.\n */\n private parseIdentifierIfPossible(): {value: string; location: Location} {\n const startingPosition = this.clonePosition()\n\n const startOffset = this.offset()\n const value = matchIdentifierAtIndex(this.message, startOffset)\n const endOffset = startOffset + value.length\n\n this.bumpTo(endOffset)\n\n const endPosition = this.clonePosition()\n const location = createLocation(startingPosition, endPosition)\n\n return {value, location}\n }\n\n private parseArgumentOptions(\n nestingLevel: number,\n expectingCloseTag: boolean,\n value: string,\n openingBracePosition: Position\n ): Result<MessageFormatElement, ParserError> {\n // Parse this range:\n // {name, type, style}\n // ^---^\n let typeStartPosition = this.clonePosition()\n let argType = this.parseIdentifierIfPossible().value\n let typeEndPosition = this.clonePosition()\n\n switch (argType) {\n case '':\n // Expecting a style string number, date, time, plural, selectordinal, or select.\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_TYPE,\n createLocation(typeStartPosition, typeEndPosition)\n )\n case 'number':\n case 'date':\n case 'time': {\n // Parse this range:\n // {name, number, style}\n // ^-------^\n this.bumpSpace()\n let styleAndLocation: {\n style: string\n styleLocation: Location\n } | null = null\n\n if (this.bumpIf(',')) {\n this.bumpSpace()\n\n const styleStartPosition = this.clonePosition()\n const result = this.parseSimpleArgStyleIfPossible()\n if (result.err) {\n return result\n }\n const style = trimEnd(result.val)\n\n if (style.length === 0) {\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_STYLE,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n\n const styleLocation = createLocation(\n styleStartPosition,\n this.clonePosition()\n )\n styleAndLocation = {style, styleLocation}\n }\n\n const argCloseResult = this.tryParseArgumentClose(openingBracePosition)\n if (argCloseResult.err) {\n return argCloseResult\n }\n\n const location = createLocation(\n openingBracePosition,\n this.clonePosition()\n )\n\n // Extract style or skeleton\n if (styleAndLocation && styleAndLocation.style.startsWith('::')) {\n // Skeleton starts with `::`.\n let skeleton = trimStart(styleAndLocation.style.slice(2))\n\n if (argType === 'number') {\n const result = this.parseNumberSkeletonFromString(\n skeleton,\n styleAndLocation.styleLocation\n )\n if (result.err) {\n return result\n }\n return {\n val: {type: TYPE.number, value, location, style: result.val},\n err: null,\n }\n } else {\n if (skeleton.length === 0) {\n return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location)\n }\n\n let dateTimePattern = skeleton\n\n // Get \"best match\" pattern only if locale is passed, if not, let it\n // pass as-is where `parseDateTimeSkeleton()` will throw an error\n // for unsupported patterns.\n if (this.locale) {\n dateTimePattern = getBestPattern(skeleton, this.locale)\n }\n\n const style: DateTimeSkeleton = {\n type: SKELETON_TYPE.dateTime,\n pattern: dateTimePattern,\n location: styleAndLocation.styleLocation,\n parsedOptions: this.shouldParseSkeletons\n ? parseDateTimeSkeleton(dateTimePattern)\n : {},\n }\n\n const type = argType === 'date' ? TYPE.date : TYPE.time\n return {\n val: {type, value, location, style},\n err: null,\n }\n }\n }\n\n // Regular style or no style.\n return {\n val: {\n type:\n argType === 'number'\n ? TYPE.number\n : argType === 'date'\n ? TYPE.date\n : TYPE.time,\n value,\n location,\n style: styleAndLocation?.style ?? null,\n },\n err: null,\n }\n }\n case 'plural':\n case 'selectordinal':\n case 'select': {\n // Parse this range:\n // {name, plural, options}\n // ^---------^\n const typeEndPosition = this.clonePosition()\n this.bumpSpace()\n\n if (!this.bumpIf(',')) {\n return this.error(\n ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS,\n createLocation(typeEndPosition, {...typeEndPosition})\n )\n }\n this.bumpSpace()\n\n // Parse offset:\n // {name, plural, offset:1, options}\n // ^-----^\n //\n // or the first option:\n //\n // {name, plural, one {...} other {...}}\n // ^--^\n let identifierAndLocation = this.parseIdentifierIfPossible()\n\n let pluralOffset = 0\n if (argType !== 'select' && identifierAndLocation.value === 'offset') {\n if (!this.bumpIf(':')) {\n return this.error(\n ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n this.bumpSpace()\n const result = this.tryParseDecimalInteger(\n ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,\n ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE\n )\n if (result.err) {\n return result\n }\n\n // Parse another identifier for option parsing\n this.bumpSpace()\n identifierAndLocation = this.parseIdentifierIfPossible()\n\n pluralOffset = result.val\n }\n\n const optionsResult = this.tryParsePluralOrSelectOptions(\n nestingLevel,\n argType,\n expectingCloseTag,\n identifierAndLocation\n )\n if (optionsResult.err) {\n return optionsResult\n }\n\n const argCloseResult = this.tryParseArgumentClose(openingBracePosition)\n if (argCloseResult.err) {\n return argCloseResult\n }\n\n const location = createLocation(\n openingBracePosition,\n this.clonePosition()\n )\n\n if (argType === 'select') {\n return {\n val: {\n type: TYPE.select,\n value,\n options: fromEntries(optionsResult.val),\n location,\n },\n err: null,\n }\n } else {\n return {\n val: {\n type: TYPE.plural,\n value,\n options: fromEntries(optionsResult.val),\n offset: pluralOffset,\n pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',\n location,\n },\n err: null,\n }\n }\n }\n default:\n return this.error(\n ErrorKind.INVALID_ARGUMENT_TYPE,\n createLocation(typeStartPosition, typeEndPosition)\n )\n }\n }\n\n private tryParseArgumentClose(\n openingBracePosition: Position\n ): Result<true, ParserError> {\n // Parse: {value, number, ::currency/GBP }\n //\n if (this.isEOF() || this.char() !== 125 /* `}` */) {\n return this.error(\n ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE,\n createLocation(openingBracePosition, this.clonePosition())\n )\n }\n this.bump() // `}`\n return {val: true, err: null}\n }\n\n /**\n * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659\n */\n private parseSimpleArgStyleIfPossible(): Result<string, ParserError> {\n let nestedBraces = 0\n\n const startPosition = this.clonePosition()\n while (!this.isEOF()) {\n const ch = this.char()\n switch (ch) {\n case 39 /* `'` */: {\n // Treat apostrophe as quoting but include it in the style part.\n // Find the end of the quoted literal text.\n this.bump()\n let apostrophePosition = this.clonePosition()\n\n if (!this.bumpUntil(\"'\")) {\n return this.error(\n ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,\n createLocation(apostrophePosition, this.clonePosition())\n )\n }\n this.bump()\n break\n }\n case 123 /* `{` */: {\n nestedBraces += 1\n this.bump()\n break\n }\n case 125 /* `}` */: {\n if (nestedBraces > 0) {\n nestedBraces -= 1\n } else {\n return {\n val: this.message.slice(startPosition.offset, this.offset()),\n err: null,\n }\n }\n break\n }\n default:\n this.bump()\n break\n }\n }\n return {\n val: this.message.slice(startPosition.offset, this.offset()),\n err: null,\n }\n }\n\n private parseNumberSkeletonFromString(\n skeleton: string,\n location: Location\n ): Result<NumberSkeleton, ParserError> {\n let tokens: NumberSkeletonToken[] = []\n try {\n tokens = parseNumberSkeletonFromString(skeleton)\n } catch {\n return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location)\n }\n\n return {\n val: {\n type: SKELETON_TYPE.number,\n tokens,\n location,\n parsedOptions: this.shouldParseSkeletons\n ? parseNumberSkeleton(tokens)\n : {},\n },\n err: null,\n }\n }\n\n /**\n * @param nesting_level The current nesting level of messages.\n * This can be positive when parsing message fragment in select or plural argument options.\n * @param parent_arg_type The parent argument's type.\n * @param parsed_first_identifier If provided, this is the first identifier-like selector of\n * the argument. It is a by-product of a previous parsing attempt.\n * @param expecting_close_tag If true, this message is directly or indirectly nested inside\n * between a pair of opening and closing tags. The nested message will not parse beyond\n * the closing tag boundary.\n */\n private tryParsePluralOrSelectOptions(\n nestingLevel: number,\n parentArgType: ArgType,\n expectCloseTag: boolean,\n parsedFirstIdentifier: {value: string; location: Location}\n ): Result<[string, PluralOrSelectOption][], ParserError> {\n let hasOtherClause = false\n const options: [string, PluralOrSelectOption][] = []\n const parsedSelectors = new Set<string>()\n let {value: selector, location: selectorLocation} = parsedFirstIdentifier\n\n // Parse:\n // one {one apple}\n // ^--^\n while (true) {\n if (selector.length === 0) {\n const startPosition = this.clonePosition()\n if (parentArgType !== 'select' && this.bumpIf('=')) {\n // Try parse `={number}` selector\n const result = this.tryParseDecimalInteger(\n ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR,\n ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR\n )\n if (result.err) {\n return result\n }\n selectorLocation = createLocation(startPosition, this.clonePosition())\n selector = this.message.slice(startPosition.offset, this.offset())\n } else {\n break\n }\n }\n\n // Duplicate selector clauses\n if (parsedSelectors.has(selector)) {\n return this.error(\n parentArgType === 'select'\n ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR\n : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,\n selectorLocation\n )\n }\n\n if (selector === 'other') {\n hasOtherClause = true\n }\n\n // Parse:\n // one {one apple}\n // ^----------^\n this.bumpSpace()\n const openingBracePosition = this.clonePosition()\n if (!this.bumpIf('{')) {\n return this.error(\n parentArgType === 'select'\n ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT\n : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n\n const fragmentResult = this.parseMessage(\n nestingLevel + 1,\n parentArgType,\n expectCloseTag\n )\n if (fragmentResult.err) {\n return fragmentResult\n }\n const argCloseResult = this.tryParseArgumentClose(openingBracePosition)\n if (argCloseResult.err) {\n return argCloseResult\n }\n\n options.push([\n selector,\n {\n value: fragmentResult.val,\n location: createLocation(openingBracePosition, this.clonePosition()),\n },\n ])\n // Keep track of the existing selectors\n parsedSelectors.add(selector)\n\n // Prep next selector clause.\n this.bumpSpace()\n ;({value: selector, location: selectorLocation} =\n this.parseIdentifierIfPossible())\n }\n\n if (options.length === 0) {\n return this.error(\n parentArgType === 'select'\n ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR\n : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n\n if (this.requiresOtherClause && !hasOtherClause) {\n return this.error(\n ErrorKind.MISSING_OTHER_CLAUSE,\n createLocation(this.clonePosition(), this.clonePosition())\n )\n }\n\n return {val: options, err: null}\n }\n\n private tryParseDecimalInteger(\n expectNumberError: ErrorKind,\n invalidNumberError: ErrorKind\n ): Result<number, ParserError> {\n let sign = 1\n const startingPosition = this.clonePosition()\n\n if (this.bumpIf('+')) {\n } else if (this.bumpIf('-')) {\n sign = -1\n }\n\n let hasDigits = false\n let decimal = 0\n while (!this.isEOF()) {\n const ch = this.char()\n if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {\n hasDigits = true\n decimal = decimal * 10 + (ch - 48)\n this.bump()\n } else {\n break\n }\n }\n\n const location = createLocation(startingPosition, this.clonePosition())\n\n if (!hasDigits) {\n return this.error(expectNumberError, location)\n }\n\n decimal *= sign\n if (!Number.isSafeInteger(decimal)) {\n return this.error(invalidNumberError, location)\n }\n\n return {val: decimal, err: null}\n }\n\n private offset(): number {\n return this.position.offset\n }\n\n private isEOF(): boolean {\n return this.offset() === this.message.length\n }\n\n private clonePosition(): Position {\n // This is much faster than `Object.assign` or spread.\n return {\n offset: this.position.offset,\n line: this.position.line,\n column: this.position.column,\n }\n }\n\n /**\n * Return the code point at the current position of the parser.\n * Throws if the index is out of bound.\n */\n private char(): number {\n const offset = this.position.offset\n if (offset >= this.message.length) {\n throw Error('out of bound')\n }\n const code = this.message.codePointAt(offset)\n if (code === undefined) {\n throw Error(`Offset ${offset} is at invalid UTF-16 code unit boundary`)\n }\n return code\n }\n\n private error(\n kind: ErrorKind,\n location: Location\n ): Result<never, ParserError> {\n return {\n val: null,\n err: {\n kind,\n message: this.message,\n location,\n },\n }\n }\n\n /** Bump the parser to the next UTF-16 code unit. */\n private bump(): void {\n if (this.isEOF()) {\n return\n }\n const code = this.char()\n if (code === 10 /* '\\n' */) {\n this.position.line += 1\n this.position.column = 1\n this.position.offset += 1\n } else {\n this.position.column += 1\n // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.\n this.position.offset += code < 0x10000 ? 1 : 2\n }\n }\n\n /**\n * If the substring starting at the current position of the parser has\n * the given prefix, then bump the parser to the character immediately\n * following the prefix and return true. Otherwise, don't bump the parser\n * and return false.\n */\n private bumpIf(prefix: string): boolean {\n if (this.message.startsWith(prefix, this.offset())) {\n for (let i = 0; i < prefix.length; i++) {\n this.bump()\n }\n return true\n }\n return false\n }\n\n /**\n * Bump the parser until the pattern character is found and return `true`.\n * Otherwise bump to the end of the file and return `false`.\n */\n private bumpUntil(pattern: string): boolean {\n const currentOffset = this.offset()\n const index = this.message.indexOf(pattern, currentOffset)\n if (index >= 0) {\n this.bumpTo(index)\n return true\n } else {\n this.bumpTo(this.message.length)\n return false\n }\n }\n\n /**\n * Bump the parser to the target offset.\n * If target offset is beyond the end of the input, bump the parser to the end of the input.\n */\n private bumpTo(targetOffset: number) {\n if (this.offset() > targetOffset) {\n throw Error(\n `targetOffset ${targetOffset} must be greater than or equal to the current offset ${this.offset()}`\n )\n }\n\n targetOffset = Math.min(targetOffset, this.message.length)\n while (true) {\n const offset = this.offset()\n if (offset === targetOffset) {\n break\n }\n if (offset > targetOffset) {\n throw Error(\n `targetOffset ${targetOffset} is at invalid UTF-16 code unit boundary`\n )\n }\n\n this.bump()\n if (this.isEOF()) {\n break\n }\n }\n }\n\n /** advance the parser through all whitespace to the next non-whitespace code unit. */\n private bumpSpace() {\n while (!this.isEOF() && _isWhiteSpace(this.char())) {\n this.bump()\n }\n }\n\n /**\n * Peek at the *next* Unicode codepoint in the input without advancing the parser.\n * If the input has been exhausted, then this returns null.\n */\n private peek(): number | null {\n if (this.isEOF()) {\n return null\n }\n const code = this.char()\n const offset = this.offset()\n const nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1))\n return nextCode ?? null\n }\n}\n\n/**\n * This check if codepoint is alphabet (lower & uppercase)\n * @param codepoint\n * @returns\n */\nfunction _isAlpha(codepoint: number): boolean {\n return (\n (codepoint >= 97 && codepoint <= 122) ||\n (codepoint >= 65 && codepoint <= 90)\n )\n}\n\nfunction _isAlphaOrSlash(codepoint: number): boolean {\n return _isAlpha(codepoint) || codepoint === 47 /* '/' */\n}\n\n/** See `parseTag` function docs. */\nfunction _isPotentialElementNameChar(c: number): boolean {\n return (\n c === 45 /* '-' */ ||\n c === 46 /* '.' */ ||\n (c >= 48 && c <= 57) /* 0..9 */ ||\n c === 95 /* '_' */ ||\n (c >= 97 && c <= 122) /** a..z */ ||\n (c >= 65 && c <= 90) /* A..Z */ ||\n c == 0xb7 ||\n (c >= 0xc0 && c <= 0xd6) ||\n (c >= 0xd8 && c <= 0xf6) ||\n (c >= 0xf8 && c <= 0x37d) ||\n (c >= 0x37f && c <= 0x1fff) ||\n (c >= 0x200c && c <= 0x200d) ||\n (c >= 0x203f && c <= 0x2040) ||\n (c >= 0x2070 && c <= 0x218f) ||\n (c >= 0x2c00 && c <= 0x2fef) ||\n (c >= 0x3001 && c <= 0xd7ff) ||\n (c >= 0xf900 && c <= 0xfdcf) ||\n (c >= 0xfdf0 && c <= 0xfffd) ||\n (c >= 0x10000 && c <= 0xeffff)\n )\n}\n\n/**\n * Code point equivalent of regex `\\p{White_Space}`.\n * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt\n */\nfunction _isWhiteSpace(c: number) {\n return (\n (c >= 0x0009 && c <= 0x000d) ||\n c === 0x0020 ||\n c === 0x0085 ||\n (c >= 0x200e && c <= 0x200f) ||\n c === 0x2028 ||\n c === 0x2029\n )\n}\n","import {\n isArgumentElement,\n isDateElement,\n isNumberElement,\n isPluralElement,\n isPoundElement,\n isSelectElement,\n isTagElement,\n isTimeElement,\n type MessageFormatElement,\n type PluralElement,\n type PluralOrSelectOption,\n type SelectElement,\n TYPE,\n} from '#packages/icu-messageformat-parser/types.js'\n\nfunction cloneDeep<T>(obj: T): T {\n if (Array.isArray(obj)) {\n // @ts-expect-error meh\n return obj.map(cloneDeep)\n }\n if (obj !== null && typeof obj === 'object') {\n // @ts-expect-error meh\n return Object.keys(obj).reduce((cloned, k) => {\n // @ts-expect-error meh\n cloned[k] = cloneDeep(obj[k])\n return cloned\n }, {})\n }\n return obj\n}\n\n/**\n * Replace pound elements with number elements referencing the given variable.\n * This is needed when nesting plurals - the # in the outer plural should become\n * an explicit variable reference when nested inside another plural.\n * GH #4202\n */\nfunction replacePoundWithArgument(\n ast: MessageFormatElement[],\n variableName: string\n): MessageFormatElement[] {\n return ast.map(el => {\n if (isPoundElement(el)) {\n // Replace # with {variableName, number}\n return {\n type: TYPE.number,\n value: variableName,\n style: null,\n location: el.location,\n }\n }\n if (isPluralElement(el) || isSelectElement(el)) {\n // Recursively process options\n const newOptions: Record<string, PluralOrSelectOption> = {}\n for (const key of Object.keys(el.options)) {\n newOptions[key] = {\n value: replacePoundWithArgument(el.options[key].value, variableName),\n }\n }\n return {...el, options: newOptions}\n }\n if (isTagElement(el)) {\n return {\n ...el,\n children: replacePoundWithArgument(el.children, variableName),\n }\n }\n return el\n })\n}\n\nfunction hoistPluralOrSelectElement(\n ast: MessageFormatElement[],\n el: PluralElement | SelectElement,\n positionToInject: number\n) {\n // pull this out of the ast and move it to the top\n const cloned = cloneDeep(el)\n const {options} = cloned\n\n // GH #4202: Check if there are other plural/select elements after this one\n const afterElements = ast.slice(positionToInject + 1)\n const hasSubsequentPluralOrSelect = afterElements.some(\n isPluralOrSelectElement\n )\n\n cloned.options = Object.keys(options).reduce(\n (all: Record<string, PluralOrSelectOption>, k) => {\n let optionValue = options[k].value\n\n // GH #4202: If there are subsequent plurals/selects and this is a plural,\n // replace # with explicit variable reference to avoid ambiguity\n if (hasSubsequentPluralOrSelect && isPluralElement(el)) {\n optionValue = replacePoundWithArgument(optionValue, el.value)\n }\n\n const newValue = hoistSelectors([\n ...ast.slice(0, positionToInject),\n ...optionValue,\n ...afterElements,\n ])\n all[k] = {\n value: newValue,\n }\n return all\n },\n {}\n )\n return cloned\n}\n\nfunction isPluralOrSelectElement(\n el: MessageFormatElement\n): el is PluralElement | SelectElement {\n return isPluralElement(el) || isSelectElement(el)\n}\n\nfunction findPluralOrSelectElement(ast: MessageFormatElement[]): boolean {\n return !!ast.find(el => {\n if (isPluralOrSelectElement(el)) {\n return true\n }\n if (isTagElement(el)) {\n return findPluralOrSelectElement(el.children)\n }\n return false\n })\n}\n\n/**\n * Hoist all selectors to the beginning of the AST & flatten the\n * resulting options. E.g:\n * \"I have {count, plural, one{a dog} other{many dogs}}\"\n * becomes \"{count, plural, one{I have a dog} other{I have many dogs}}\".\n * If there are multiple selectors, the order of which one is hoisted 1st\n * is non-deterministic.\n * The goal is to provide as many full sentences as possible since fragmented\n * sentences are not translator-friendly\n * @param ast AST\n */\nexport function hoistSelectors(\n ast: MessageFormatElement[]\n): MessageFormatElement[] {\n for (let i = 0; i < ast.length; i++) {\n const el = ast[i]\n if (isPluralOrSelectElement(el)) {\n return [hoistPluralOrSelectElement(ast, el, i)]\n }\n if (isTagElement(el) && findPluralOrSelectElement([el])) {\n throw new Error(\n 'Cannot hoist plural/select within a tag element. Please put the tag element inside each plural/select option'\n )\n }\n }\n return ast\n}\n\n/**\n * Collect all variables in an AST to Record<string, TYPE>\n * @param ast AST to collect variables from\n * @param vars Record of variable name to variable type\n */\nfunction collectVariables(\n ast: MessageFormatElement[],\n vars: Map<string, TYPE> = new Map<string, TYPE>()\n): void {\n ast.forEach(el => {\n if (\n isArgumentElement(el) ||\n isDateElement(el) ||\n isTimeElement(el) ||\n isNumberElement(el)\n ) {\n // If the variable was already registered as a plural/select, it's normal\n // for it to also appear inside as number/date/time/argument — not a conflict.\n if (vars.has(el.value)) {\n const existingType = vars.get(el.value)!\n if (\n existingType !== el.type &&\n existingType !== TYPE.plural &&\n existingType !== TYPE.select\n ) {\n throw new Error(`Variable ${el.value} has conflicting types`)\n }\n } else {\n vars.set(el.value, el.type)\n }\n }\n\n if (isPluralElement(el) || isSelectElement(el)) {\n vars.set(el.value, el.type)\n Object.keys(el.options).forEach(k => {\n collectVariables(el.options[k].value, vars)\n })\n }\n\n if (isTagElement(el)) {\n vars.set(el.value, el.type)\n collectVariables(el.children, vars)\n }\n })\n}\n\ninterface IsStructurallySameResult {\n error?: Error\n success: boolean\n}\n\n/**\n * Check if 2 ASTs are structurally the same. This primarily means that\n * they have the same variables with the same type\n * @param a\n * @param b\n * @returns\n */\nexport function isStructurallySame(\n a: MessageFormatElement[],\n b: MessageFormatElement[]\n): IsStructurallySameResult {\n const aVars = new Map<string, TYPE>()\n const bVars = new Map<string, TYPE>()\n collectVariables(a, aVars)\n collectVariables(b, bVars)\n\n if (aVars.size !== bVars.size) {\n return {\n success: false,\n error: new Error(\n `Different number of variables: [${Array.from(aVars.keys()).join(', ')}] vs [${Array.from(bVars.keys()).join(', ')}]`\n ),\n }\n }\n\n return Array.from(aVars.entries()).reduce<IsStructurallySameResult>(\n (result, [key, type]) => {\n if (!result.success) {\n return result\n }\n const bType = bVars.get(key)\n if (bType == null) {\n return {\n success: false,\n error: new Error(`Missing variable ${key} in message`),\n }\n }\n if (bType !== type) {\n return {\n success: false,\n error: new Error(\n `Variable ${key} has conflicting types: ${TYPE[type]} vs ${TYPE[bType]}`\n ),\n }\n }\n return result\n },\n {success: true}\n )\n}\n","import {ErrorKind} from '#packages/icu-messageformat-parser/error.js'\nimport {\n Parser,\n type ParserOptions,\n} from '#packages/icu-messageformat-parser/parser.js'\nimport {\n isDateElement,\n isDateTimeSkeleton,\n isNumberElement,\n isNumberSkeleton,\n isPluralElement,\n isSelectElement,\n isTagElement,\n isTimeElement,\n type MessageFormatElement,\n} from '#packages/icu-messageformat-parser/types.js'\n\nfunction pruneLocation(els: MessageFormatElement[]): void {\n els.forEach(el => {\n delete el.location\n if (isSelectElement(el) || isPluralElement(el)) {\n for (const k in el.options) {\n delete el.options[k].location\n pruneLocation(el.options[k].value)\n }\n } else if (isNumberElement(el) && isNumberSkeleton(el.style)) {\n delete el.style.location\n } else if (\n (isDateElement(el) || isTimeElement(el)) &&\n isDateTimeSkeleton(el.style)\n ) {\n delete el.style.location\n } else if (isTagElement(el)) {\n pruneLocation(el.children)\n }\n })\n}\n\nexport function parse(\n message: string,\n opts: ParserOptions = {}\n): MessageFormatElement[] {\n opts = {\n shouldParseSkeletons: true,\n requiresOtherClause: true,\n ...opts,\n }\n const result = new Parser(message, opts).parse()\n if (result.err) {\n const error = SyntaxError(ErrorKind[result.err.kind])\n // @ts-expect-error Assign to error object\n error.location = result.err.location\n // @ts-expect-error Assign to error object\n error.originalMessage = result.err.message\n throw error\n }\n\n if (!opts?.captureLocation) {\n pruneLocation(result.val)\n }\n return result.val\n}\nexport * from '#packages/icu-messageformat-parser/types.js'\nexport type {ParserOptions}\n// only for testing\nexport const _Parser: typeof Parser = Parser\nexport {isStructurallySame} from '#packages/icu-messageformat-parser/manipulator.js'\n"],"x_google_ignoreList":[2,3],"mappings":";;AAQA,IAAY,YAAL,yBAAA,WAAA;;CAEL,UAAA,UAAA,mCAAA,KAAA;;CAEA,UAAA,UAAA,oBAAA,KAAA;;CAEA,UAAA,UAAA,wBAAA,KAAA;;CAEA,UAAA,UAAA,0BAAA,KAAA;;CAEA,UAAA,UAAA,2BAAA,KAAA;;CAEA,UAAA,UAAA,2BAAA,KAAA;;CAEA,UAAA,UAAA,6BAAA,KAAA;;CAEA,UAAA,UAAA,gCAAA,KAAA;;CAEA,UAAA,UAAA,4BAAA,KAAA;;CAEA,UAAA,UAAA,+BAAA,MAAA;;CAEA,UAAA,UAAA,sCAAA,MAAA;;CAEA,UAAA,UAAA,oCAAA,MAAA;;CAGA,UAAA,UAAA,yCAAA,MAAA;;CAEA,UAAA,UAAA,0CAAA,MAAA;;CAGA,UAAA,UAAA,qCAAA,MAAA;;CAEA,UAAA,UAAA,qCAAA,MAAA;;CAGA,UAAA,UAAA,8CAAA,MAAA;;;;;CAKA,UAAA,UAAA,8CAAA,M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ACA,SAAgB,aAAa,IAA4C;CACvE,OAAO,GAAG,SAAA;AACZ;AACA,SAAgB,iBACd,IACsB;CACtB,OAAO,CAAC,EAAE,MAAM,OAAO,OAAO,YAAY,GAAG,SAAA;AAC/C;AACA,SAAgB,mBACd,IACwB;CACxB,OAAO,CAAC,EAAE,MAAM,OAAO,OAAO,YAAY,GAAG,SAAA;AAC/C;AAEA,SAAgB,qBAAqB,OAA+B;CAClE,OAAO;EACL,MAAA;EACA;CACF;AACF;AAEA,SAAgB,oBACd,OACA,OACe;CACf,OAAO;EACL,MAAA;EACA;EACA;CACF;AACF;;;ACzMA,MAAa,wBAAwB;;;ACCrC,MAAa,WAAW;CACvB,OAAO,CAAC,KAAK,GAAG;CAChB,OAAO;EACN;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,MAAM,GAAG;CAChB,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,MAAM,GAAG;CAChB,MAAM,CAAC,GAAG;CACV,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,GAAG;CACV,MAAM,CAAC,GAAG;CACV,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,GAAG;CACf,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM,CAAC,KAAK,GAAG;CACf,MAAM;EACL;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,IAAI;CAChB,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM;EACL;EACA;EACA;EACA;CACD;CACA,MAAM,CAAC,KAAK,GAAG;CACf,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,UAAU;EACT;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,UAAU;EACT;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS,CAAC,KAAK,IAAI;CACnB,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;CACD;CACA,SAAS;EACR;EACA;EACA;EACA;CACD;AACD;;;;;;;;;;ACnoCA,SAAgB,eAAe,UAAkB,QAA6B;CAC5E,IAAI,eAAe;CACnB,KAAK,IAAI,aAAa,GAAG,aAAa,SAAS,QAAQ,cAAc;EACnE,MAAM,cAAc,SAAS,OAAO,UAAU;EAE9C,IAAI,gBAAgB,KAAK;GACvB,IAAI,cAAc;GAClB,OACE,aAAa,IAAI,SAAS,UAC1B,SAAS,OAAO,aAAa,CAAC,MAAM,aACpC;IACA;IACA;GACF;GAEA,IAAI,UAAU,KAAK,cAAc;GACjC,IAAI,eAAe,cAAc,IAAI,IAAI,KAAK,eAAe;GAC7D,IAAI,gBAAgB;GACpB,IAAI,WAAW,+BAA+B,MAAM;GAEpD,IAAI,YAAY,OAAO,YAAY,KACjC,eAAe;GAGjB,OAAO,iBAAiB,GACtB,gBAAgB;GAElB,OAAO,YAAY,GACjB,eAAe,WAAW;EAE9B,OAAO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AAM;OACX,KACJ,cAAc,EAAE,KAAK,cAAc,EAAE,MACtC,mBAAmB,GAAG,KAAK,GAE3B,OAAO,GAAG,MAAM;OACX,IAAI,aAAa,EAAE,GACxB,cAAc,GAAG,QAAQ;CAE7B,CAAC;AACH;AAEA,SAAgB,MACd,SACA,OAAsB,CAAC,GACC;CACxB,OAAO;EACL,sBAAsB;EACtB,qBAAqB;EACrB,GAAG;CACL;CACA,MAAM,SAAS,IAAI,OAAO,SAAS,IAAI,CAAC,CAAC,MAAM;CAC/C,IAAI,OAAO,KAAK;EACd,MAAM,QAAQ,YAAY,UAAU,OAAO,IAAI,KAAK;EAEpD,MAAM,WAAW,OAAO,IAAI;EAE5B,MAAM,kBAAkB,OAAO,IAAI;EACnC,MAAM;CACR;CAEA,IAAI,CAAC,MAAM,iBACT,cAAc,OAAO,GAAG;CAE1B,OAAO,OAAO;AAChB;AAIA,MAAa,UAAyB"}
@@ -0,0 +1,177 @@
1
+ import { NumberSkeletonToken } from "@formatjs/icu-skeleton-parser";
2
+
3
+ //#region packages/ecma402-abstract/types/number.d.ts
4
+ type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
5
+ type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
6
+ type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
7
+ type UseGroupingType = "min2" | "auto" | "always" | boolean;
8
+ interface NumberFormatDigitOptions {
9
+ minimumIntegerDigits?: number;
10
+ minimumSignificantDigits?: number;
11
+ maximumSignificantDigits?: number;
12
+ minimumFractionDigits?: number;
13
+ maximumFractionDigits?: number;
14
+ roundingPriority?: RoundingPriorityType;
15
+ roundingIncrement?: number;
16
+ roundingMode?: RoundingModeType;
17
+ trailingZeroDisplay?: TrailingZeroDisplay;
18
+ }
19
+ type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit";
20
+ type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit";
21
+ type NumberFormatOptionsCompactDisplay = "short" | "long";
22
+ type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol";
23
+ type NumberFormatOptionsCurrencySign = "standard" | "accounting";
24
+ type NumberFormatOptionsNotation = NumberFormatNotation;
25
+ type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative";
26
+ type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow";
27
+ type TrailingZeroDisplay = "auto" | "stripIfInteger";
28
+ type NumberFormatOptions = Omit<Intl.NumberFormatOptions, "signDisplay" | "useGrouping"> & NumberFormatDigitOptions & {
29
+ localeMatcher?: NumberFormatOptionsLocaleMatcher;
30
+ style?: NumberFormatOptionsStyle;
31
+ compactDisplay?: NumberFormatOptionsCompactDisplay;
32
+ currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
33
+ currencySign?: NumberFormatOptionsCurrencySign;
34
+ notation?: NumberFormatOptionsNotation;
35
+ signDisplay?: NumberFormatOptionsSignDisplay;
36
+ unit?: string;
37
+ unitDisplay?: NumberFormatOptionsUnitDisplay;
38
+ numberingSystem?: string;
39
+ trailingZeroDisplay?: TrailingZeroDisplay;
40
+ roundingPriority?: RoundingPriorityType;
41
+ roundingIncrement?: number;
42
+ roundingMode?: RoundingModeType;
43
+ useGrouping?: UseGroupingType;
44
+ };
45
+ //#endregion
46
+ //#region packages/icu-messageformat-parser/types.d.ts
47
+ interface ExtendedNumberFormatOptions extends NumberFormatOptions {
48
+ scale?: number;
49
+ }
50
+ declare enum TYPE {
51
+ /**
52
+ * Raw text
53
+ */
54
+ literal = 0,
55
+ /**
56
+ * Variable w/o any format, e.g `var` in `this is a {var}`
57
+ */
58
+ argument = 1,
59
+ /**
60
+ * Variable w/ number format
61
+ */
62
+ number = 2,
63
+ /**
64
+ * Variable w/ date format
65
+ */
66
+ date = 3,
67
+ /**
68
+ * Variable w/ time format
69
+ */
70
+ time = 4,
71
+ /**
72
+ * Variable w/ select format
73
+ */
74
+ select = 5,
75
+ /**
76
+ * Variable w/ plural format
77
+ */
78
+ plural = 6,
79
+ /**
80
+ * Only possible within plural argument.
81
+ * This is the `#` symbol that will be substituted with the count.
82
+ */
83
+ pound = 7,
84
+ /**
85
+ * XML-like tag
86
+ */
87
+ tag = 8
88
+ }
89
+ declare enum SKELETON_TYPE {
90
+ number = 0,
91
+ dateTime = 1
92
+ }
93
+ interface LocationDetails {
94
+ offset: number;
95
+ line: number;
96
+ column: number;
97
+ }
98
+ interface Location {
99
+ start: LocationDetails;
100
+ end: LocationDetails;
101
+ }
102
+ interface BaseElement<T extends TYPE> {
103
+ type: T;
104
+ value: string;
105
+ location?: Location;
106
+ }
107
+ type LiteralElement = BaseElement<TYPE.literal>;
108
+ type ArgumentElement = BaseElement<TYPE.argument>;
109
+ interface TagElement extends BaseElement<TYPE.tag> {
110
+ children: MessageFormatElement[];
111
+ }
112
+ interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> {
113
+ style?: string | S | null;
114
+ }
115
+ type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;
116
+ type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>;
117
+ type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>;
118
+ type ValidPluralRule = "zero" | "one" | "two" | "few" | "many" | "other" | string;
119
+ interface PluralOrSelectOption {
120
+ value: MessageFormatElement[];
121
+ location?: Location;
122
+ }
123
+ interface SelectElement extends BaseElement<TYPE.select> {
124
+ options: Record<string, PluralOrSelectOption>;
125
+ }
126
+ interface PluralElement extends BaseElement<TYPE.plural> {
127
+ options: Record<ValidPluralRule, PluralOrSelectOption>;
128
+ offset: number;
129
+ pluralType: Intl.PluralRulesOptions["type"];
130
+ }
131
+ interface PoundElement {
132
+ type: TYPE.pound;
133
+ location?: Location;
134
+ }
135
+ type MessageFormatElement = ArgumentElement | DateElement | LiteralElement | NumberElement | PluralElement | PoundElement | SelectElement | TagElement | TimeElement;
136
+ interface NumberSkeleton {
137
+ type: SKELETON_TYPE.number;
138
+ tokens: NumberSkeletonToken[];
139
+ location?: Location;
140
+ parsedOptions: ExtendedNumberFormatOptions;
141
+ }
142
+ interface DateTimeSkeleton {
143
+ type: SKELETON_TYPE.dateTime;
144
+ pattern: string;
145
+ location?: Location;
146
+ parsedOptions: Intl.DateTimeFormatOptions;
147
+ }
148
+ type Skeleton = NumberSkeleton | DateTimeSkeleton;
149
+ //#endregion
150
+ //#region packages/icu-messageformat-parser/manipulator.d.ts
151
+ /**
152
+ * Hoist all selectors to the beginning of the AST & flatten the
153
+ * resulting options. E.g:
154
+ * "I have {count, plural, one{a dog} other{many dogs}}"
155
+ * becomes "{count, plural, one{I have a dog} other{I have many dogs}}".
156
+ * If there are multiple selectors, the order of which one is hoisted 1st
157
+ * is non-deterministic.
158
+ * The goal is to provide as many full sentences as possible since fragmented
159
+ * sentences are not translator-friendly
160
+ * @param ast AST
161
+ */
162
+ declare function hoistSelectors(ast: MessageFormatElement[]): MessageFormatElement[];
163
+ interface IsStructurallySameResult {
164
+ error?: Error;
165
+ success: boolean;
166
+ }
167
+ /**
168
+ * Check if 2 ASTs are structurally the same. This primarily means that
169
+ * they have the same variables with the same type
170
+ * @param a
171
+ * @param b
172
+ * @returns
173
+ */
174
+ declare function isStructurallySame(a: MessageFormatElement[], b: MessageFormatElement[]): IsStructurallySameResult;
175
+ //#endregion
176
+ export { hoistSelectors, isStructurallySame };
177
+ //# sourceMappingURL=manipulator.d.ts.map