@tectra-ng/core 0.4.4 → 0.4.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tectra-ng-core-i18n.mjs","names":[],"sources":["../../../../packages/core/i18n/src/locales.ts","../../../../packages/core/i18n/src/format-message.ts","../../../../packages/core/i18n/src/format-bytes.ts","../../../../packages/core/i18n/src/locale.service.ts","../../../../packages/core/i18n/src/translations.ts"],"sourcesContent":["import { TxLocaleDefinition } from '@tectra-ng/core/config';\n\n/** Built-in English (US) locale, the fallback for every other locale. */\nexport const TX_LOCALE_US: TxLocaleDefinition = {\n code: 'us',\n intl: 'en-US',\n firstDayOfWeek: 0,\n dateFormat: 'mm/dd/yy',\n translations: {\n emptyMessage: 'No results found',\n searchPlaceholder: 'Search',\n clear: 'Clear',\n selectAll: 'Select all',\n close: 'Close',\n loading: 'Loading',\n today: 'Today',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n copy: 'Copy',\n copied: 'Copied',\n validationRequired: 'This field is required',\n validationEmail: 'Enter a valid email',\n validationMinlength: 'At least {requiredLength} characters',\n validationMaxlength: 'At most {requiredLength} characters',\n validationMin: 'Must be at least {min}',\n validationMax: 'Must be at most {max}',\n validationPattern: 'Invalid format',\n validationInvalid: 'Invalid value',\n passwordPrompt: 'Enter a password',\n passwordWeak: 'Weak',\n passwordMedium: 'Medium',\n passwordStrong: 'Strong',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n otpCell: 'Character {index} of {length}',\n increment: 'Increase',\n decrement: 'Decrease',\n ratingValue: '{value} of {stars}',\n rangeStart: 'from',\n rangeEnd: 'to',\n remove: 'Remove',\n moreItems: '{count} more',\n avatarChangePhoto: 'Change photo',\n avatarUploadPhoto: 'Upload photo',\n avatarRemovePhoto: 'Remove',\n avatarRemoveTitle: 'Delete photo',\n avatarRemoveMessage: 'Are you sure you want to delete your photo?',\n avatarPhotoActions: 'Photo actions',\n tagListHidden: 'Other tags',\n selectedItems: '{count} items selected',\n selectedOfTotal: '{selected} of {total}',\n showOptions: 'Show options',\n removeItem: 'Remove {item}',\n pickColor: 'Pick a colour',\n noColor: 'No colour',\n colorArea: 'Saturation and brightness',\n colorAreaValue: 'Saturation {saturation}%, brightness {brightness}%',\n colorHue: 'Hue',\n colorHex: 'Hex colour',\n colorPresets: 'Preset colours',\n useEmail: 'Use {email}',\n didYouMean: 'Did you mean {email}?',\n yes: 'Yes',\n no: 'No',\n copyLink: 'Copy link',\n export: 'Export',\n exportFormats: 'Export formats',\n exportCsv: 'Export to CSV',\n exportExcel: 'Export to Excel',\n exportWord: 'Export to Word',\n exportPdf: 'Export to PDF',\n exportJson: 'Export to JSON',\n exportHtml: 'Export to HTML',\n exportMarkdown: 'Export to Markdown',\n exportCopy: 'Copy table',\n exportCopied: 'Table copied',\n exportPrint: 'Print',\n chooseDate: 'Choose date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n previousDecade: 'Previous decade',\n nextDecade: 'Next decade',\n chooseMonth: 'Choose month',\n chooseYear: 'Choose year',\n weekHeader: 'Wk',\n am: 'AM',\n pm: 'PM',\n hour: 'Hour',\n minute: 'Minute',\n second: 'Second',\n nextHour: 'Next hour',\n previousHour: 'Previous hour',\n nextMinute: 'Next minute',\n previousMinute: 'Previous minute',\n nextSecond: 'Next second',\n previousSecond: 'Previous second',\n toggleAmPm: 'Switch AM / PM',\n dateSelected: '{date} selected',\n calendar: 'Calendar',\n moreEvents: '+{count}',\n events: '{count} events',\n copyEmail: 'Copy email',\n copyPhone: 'Copy phone number',\n opensInNewTab: 'opens in a new tab',\n breadcrumb: 'Breadcrumb',\n stepCompleted: 'completed',\n menu: 'Menu',\n resizePanels: 'Resize panels',\n imagePreview: 'Image preview',\n zoomImage: 'Zoom image',\n rotateRight: 'Rotate right',\n rotateLeft: 'Rotate left',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n carousel: 'Carousel',\n slide: 'Slide',\n slideOf: '{index} of {total}',\n previousSlide: 'Previous slide',\n nextSlide: 'Next slide',\n gallery: 'Gallery',\n galleryImage: 'Image {index}',\n previousImage: 'Previous image',\n nextImage: 'Next image',\n thumbnails: 'Thumbnails',\n previousThumbnails: 'Previous thumbnails',\n nextThumbnails: 'Next thumbnails',\n fileUploadPrompt: 'Drop files here or {browse}',\n fileUploadPromptSingle: 'Drop a file here or {browse}',\n fileUploadBrowse: 'browse',\n fileUploadRelease: 'Release to add',\n chooseFile: 'Choose file',\n chooseFiles: 'Choose files',\n upload: 'Upload',\n replace: 'Replace',\n retry: 'Retry',\n editorLabel: 'Text editor',\n editorToolbar: 'Formatting',\n editorUndo: 'Undo',\n editorRedo: 'Redo',\n editorTextStyle: 'Text style',\n editorParagraph: 'Normal text',\n editorHeading: 'Heading {level}',\n editorBold: 'Bold',\n editorItalic: 'Italic',\n editorUnderline: 'Underline',\n editorStrike: 'Strikethrough',\n editorCode: 'Inline code',\n editorSubscript: 'Subscript',\n editorSuperscript: 'Superscript',\n editorTextColor: 'Text colour',\n editorHighlight: 'Highlight',\n editorDefaultColor: 'Default',\n editorFontSize: 'Text size',\n editorSizeSmall: 'Small',\n editorSizeNormal: 'Normal',\n editorSizeLarge: 'Large',\n editorSizeHuge: 'Huge',\n editorBulletList: 'Bulleted list',\n editorOrderedList: 'Numbered list',\n editorTaskList: 'Checklist',\n editorIndent: 'Increase indent',\n editorOutdent: 'Decrease indent',\n editorAlign: 'Alignment',\n editorAlignLeft: 'Align left',\n editorAlignCenter: 'Align center',\n editorAlignRight: 'Align right',\n editorAlignJustify: 'Justify',\n editorLink: 'Link',\n editorLinkUrl: 'Link address',\n editorLinkApply: 'Apply',\n editorLinkRemove: 'Remove link',\n editorLinkEdit: 'Edit link',\n editorImage: 'Image',\n editorVideo: 'Video',\n editorVideoUrl: 'Video address',\n editorVideoHint: 'YouTube, Vimeo or a player link',\n editorInsert: 'Insert',\n editorQuote: 'Quote',\n editorCodeBlock: 'Code block',\n editorRule: 'Divider',\n editorClear: 'Clear formatting',\n editorFullView: 'Full view',\n editorNormalView: 'Exit full view',\n editorAi: 'Improve with AI',\n editorCount: '{count} characters',\n editorCountLimit: '{count} / {limit}',\n editorNoMatches: 'No matches',\n editorImageTooLarge: '{name} is larger than {size}',\n editorColorGray: 'Gray',\n editorColorRed: 'Red',\n editorColorOrange: 'Orange',\n editorColorYellow: 'Yellow',\n editorColorGreen: 'Green',\n editorColorTeal: 'Teal',\n editorColorBlue: 'Blue',\n editorColorPurple: 'Purple',\n editorColorPink: 'Pink',\n editorImagePreview: 'Image preview',\n editorCallout: 'Callout',\n editorCalloutTone: 'Change the callout colour',\n editorTable: 'Table',\n editorRowAbove: 'Add row above',\n editorRowBelow: 'Add row below',\n editorColumnLeft: 'Add column on the left',\n editorColumnRight: 'Add column on the right',\n editorDeleteRow: 'Delete row',\n editorDeleteColumn: 'Delete column',\n editorHeaderRow: 'Header row',\n editorDeleteTable: 'Delete table',\n editorCommands: 'Insert block',\n editorEmoji: 'Emoji',\n editorMentions: 'People',\n editorAiKeep: 'Keep',\n editorAiDiscard: 'Undo',\n codeEditorLabel: 'Code editor',\n codeHighlightLabel: 'Code',\n codeSearchFind: 'Find',\n codeSearchReplace: 'Replace',\n codeSearchReplaceAll: 'Replace all',\n codeSearchNext: 'Next match',\n codeSearchPrevious: 'Previous match',\n codeSearchMatchCase: 'Match case',\n codeSearchWholeWord: 'Match whole word',\n codeSearchRegexp: 'Use regular expression',\n codeSearchToggleReplace: 'Toggle replace',\n codeSearchClose: 'Close',\n codeSearchCount: '{current} of {total}',\n codeSearchNoResults: 'No results',\n codeDiffLabel: 'Changes',\n codeDiffOriginal: 'Original',\n codeDiffModified: 'Modified',\n noFileChosen: 'No file chosen',\n filesChosen: '{count} files',\n fileReady: 'Ready to upload',\n fileUploading: 'Uploading {progress}%',\n fileUploaded: 'Uploaded',\n fileFailed: 'Upload failed',\n invalidFileType: '{name} is not a supported file type ({types})',\n invalidFileSize: '{name} is larger than {size}',\n invalidFileLimit: 'You can add up to {limit} files',\n filesAdded: 'Added: {names}',\n filesUploaded: 'Upload complete',\n filesSummary: 'Files: {count} · {size}',\n notifications: 'Notifications',\n confirm: 'Confirm',\n cancel: 'Cancel',\n delete: 'Delete',\n confirmQuestion: 'Are you sure?',\n maximize: 'Maximize',\n restore: 'Restore',\n moreActions: 'More actions',\n firstPage: 'First page',\n lastPage: 'Last page',\n pageNumber: 'Page {page}',\n rowsPerPage: 'Rows per page',\n jumpToPage: 'Go to page',\n currentPageReport: '{currentPage} of {totalPages}',\n totalCount: 'Total: {count}',\n pagination: 'Pagination',\n tableSettings: 'Table settings',\n tableColumns: 'Columns',\n tableColumnsHint: 'Show or hide table columns',\n tableActions: 'Actions',\n tableActionsHint: 'Choose which row actions are shown inline',\n rowActions: 'Row actions',\n nodeActions: 'Node actions',\n listView: 'List',\n gridView: 'Grid',\n layout: 'Layout',\n selectRow: 'Select row',\n expandRow: 'Expand row',\n collapseRow: 'Collapse row',\n resizeColumn: 'Resize {column}',\n filterColumn: 'Filter {column}',\n filterValue: 'Value',\n filterMatchMode: 'Match mode',\n filterMatchAll: 'Match all',\n filterMatchAny: 'Match any',\n filterAddRule: 'Add rule',\n filterRemoveRule: 'Remove rule',\n filterApply: 'Apply',\n filterAny: 'Any',\n startsWith: 'Starts with',\n contains: 'Contains',\n notContains: 'Not contains',\n endsWith: 'Ends with',\n equals: 'Equals',\n notEquals: 'Not equals',\n in: 'Is one of',\n lt: 'Less than',\n lte: 'Less than or equal to',\n gt: 'Greater than',\n gte: 'Greater than or equal to',\n between: 'Between',\n dateIs: 'Date is',\n dateIsNot: 'Date is not',\n dateBefore: 'Date is before',\n dateAfter: 'Date is after',\n editRow: 'Edit row',\n saveRow: 'Save row',\n cancelEdit: 'Cancel editing',\n moveRow: 'Move row',\n rowGroup: '{count} rows',\n filters: 'Filters',\n clearFilters: 'Clear filters',\n showFilters: 'Show filters',\n filterHasValue: 'Has a value — shown while it is set',\n resetFiltersLayout: 'Reset to default',\n reorderFilter: 'Drag to reorder',\n filtersShown: '{shown} of {total}',\n filtersHidden: '{label}, {count} hidden',\n legal: 'Legal',\n consoleSections: 'Sections',\n pinMenu: 'Keep the menu open',\n unpinMenu: 'Let the menu fold',\n wizardNext: 'Next',\n wizardBack: 'Back',\n wizardProgress: 'Progress',\n customize: 'Customize',\n pinnedTabs: 'Pinned tabs',\n pinnedTabsHint: 'Selected items appear as tabs for quick switching. The choice is saved in this browser.',\n pinnedSelected: 'Selected: {count} of {total}',\n all: 'All',\n save: 'Save',\n search: 'Search',\n searching: 'Searching…',\n nothingFound: 'Nothing found',\n paletteNavigate: 'to navigate',\n paletteOpen: 'to open',\n paletteClose: 'to close',\n board: 'Board',\n moveColumn: 'Drag to move the column',\n noCards: 'No cards',\n showMore: 'Show {count} more',\n kanbanMoveHint: 'Alt and the arrow keys move it',\n kanbanMoved: 'Moved to {column}, position {position}',\n switchToLight: 'Switch to light theme',\n switchToDark: 'Switch to dark theme',\n language: 'Language',\n theme: 'Theme',\n themePrimary: 'Primary',\n themeSurface: 'Surface',\n themeStyle: 'Style',\n themeRipple: 'Ripple',\n openMenu: 'Open menu',\n closeMenu: 'Close menu',\n cookieTitle: 'Only essential cookies',\n cookieText: 'We use a sign-in cookie and browser storage to keep you signed in and remember your settings. No ads, no tracking.',\n cookieLearnMore: 'Learn more',\n cookieAccept: 'Got it',\n cookieLabel: 'Cookie notice',\n offline: 'No internet connection',\n connectionRestored: 'Connection restored',\n qrCode: 'QR code',\n qrCodeError: 'Unable to render QR code',\n addPerson: 'Add a person',\n listInputPlaceholder: 'One item per line, or separated by commas or spaces',\n listInputPlaceholderDomain: 'example.com, another.org or one domain per line',\n listInputPlaceholderEmail: 'name@example.com, another@example.org or one email per line',\n listInputPlaceholderUrl: 'https://example.com/page or one link per line',\n listInputHint: 'Paste a list — duplicates and lines that do not fit are counted.',\n listInputHintDomain: 'Paste domains or URLs — protocols, paths and duplicates are removed automatically.',\n listInputHintEmail: 'Paste emails — duplicates and invalid addresses are counted.',\n listInputHintUrl: 'Paste links — a missing https:// is added, duplicates are counted.',\n listInputItems: '{count, plural, one {# item} other {# items}}',\n listInputDomains: '{count, plural, one {# domain} other {# domains}}',\n listInputEmails: '{count, plural, one {# email} other {# emails}}',\n listInputUrls: '{count, plural, one {# link} other {# links}}',\n listInputDuplicates: '{count, plural, one {# duplicate} other {# duplicates}}',\n listInputInvalidCount: '{count} not recognized',\n listInputInvalid: 'Not recognized',\n listInputMore: '+{count} more',\n listInputCleanUp: 'Clean up',\n listInputCleanUpHint: 'One item per line, without duplicates and invalid lines',\n chartNoData: 'No data',\n chartLoading: 'Loading chart',\n chartLegend: 'Legend',\n chartDataTable: 'Chart data',\n chartCategory: 'Category',\n chartValue: 'Value',\n chartShare: 'Share',\n chartTotal: 'Total',\n chartSummary: '{type}, {series, plural, one {# series} other {# series}}, {points, plural, one {# value} other {# values}}',\n chartRange: 'from {min} to {max}',\n chartPoint: '{series}, {category}: {value}',\n chartNavigateHint: 'Arrow keys move between values',\n chartLine: 'Line chart',\n chartArea: 'Area chart',\n chartColumn: 'Column chart',\n chartBar: 'Bar chart',\n chartCombo: 'Combo chart',\n chartScatter: 'Scatter chart',\n chartBubble: 'Bubble chart',\n chartSize: 'Size',\n chartRadar: 'Radar chart',\n chartAverage: 'Average',\n chartRadialBar: 'Radial bar chart',\n chartGauge: 'Gauge',\n chartWaterfall: 'Waterfall chart',\n chartFunnel: 'Funnel chart',\n chartBullet: 'Bullet chart',\n chartIncrease: 'Increase',\n chartDecrease: 'Decrease',\n chartChange: 'Change',\n chartConversion: 'Conversion',\n chartOfFirst: 'Of first',\n chartTarget: 'Target',\n chartCandlestick: 'Candlestick chart',\n chartBoxplot: 'Box plot',\n chartRangeArea: 'Range area chart',\n chartOpen: 'Open',\n chartHigh: 'High',\n chartLow: 'Low',\n chartClose: 'Close',\n chartVolume: 'Volume',\n chartMin: 'Min',\n chartMax: 'Max',\n chartMedian: 'Median',\n chartQ1: 'First quartile',\n chartQ3: 'Third quartile',\n chartOutliers: 'Outliers',\n chartGantt: 'Gantt chart',\n chartSummaryTasks: '{count, plural, one {# task} other {# tasks}}',\n chartTask: 'Task',\n chartDays: '{count, plural, one {# day} other {# days}}',\n chartProgress: 'Progress',\n chartMilestone: 'Milestone',\n chartZoomDay: 'Days',\n chartZoomWeek: 'Weeks',\n chartZoomMonth: 'Months',\n chartZoomQuarter: 'Quarters',\n chartTimeline: 'Timeline',\n chartSankey: 'Sankey diagram',\n chartSunburst: 'Sunburst chart',\n chartFlow: '{source} → {target}',\n chartIncoming: 'In',\n chartOutgoing: 'Out',\n chartOfParent: 'Of parent',\n chartOfTotal: 'Of total',\n chartFlows: '{count, plural, one {# flow} other {# flows}}',\n chartResetZoom: 'Reset zoom',\n chartZoomHint: 'Ctrl and the wheel or a pinch zoom, drag to move, + and − zoom, 0 resets',\n chartGanttHint: 'Arrow keys move between tasks · + and − zoom · Ctrl and the wheel zoom at the pointer',\n chartDependsOn: 'Depends on',\n chartRequiredBy: 'Required by',\n chartStartToStart: 'start to start',\n chartFinishToFinish: 'finish to finish',\n chartStartToFinish: 'start to finish',\n chartGaugeValue: '{value} of {min} to {max}',\n chartPie: 'Pie chart',\n chartDonut: 'Donut chart',\n chartMenu: 'Chart menu',\n chartDownloadSvg: 'Download SVG',\n chartDownloadPng: 'Download PNG',\n chartDownloadCsv: 'Download CSV',\n chartHeatmap: 'Heatmap',\n chartTreemap: 'Treemap',\n chartRank: 'Rank chart',\n chartRankValue: 'Rank',\n orgChartTitle: 'Org chart',\n orgChartHint: 'Drag to move · scroll or pinch to zoom at the cursor · keys: + − 0 F /',\n orgChartSearch: 'Search',\n orgChartMatches: '{count} found',\n orgChartNoMatches: 'Nothing found',\n orgChartZoomIn: 'Zoom in',\n orgChartZoomOut: 'Zoom out',\n orgChartResetZoom: 'Reset zoom',\n orgChartFit: 'Fit to screen',\n orgChartExpandAll: 'Expand all',\n orgChartCollapseAll: 'Collapse all',\n orgChartFullscreen: 'Full screen',\n orgChartExitFullscreen: 'Exit full screen',\n orgChartExpand: 'Expand',\n orgChartCollapse: 'Collapse',\n orgChartMore: 'Chart actions',\n httpStatusOk: 'OK',\n httpStatusRedirect: 'Redirect',\n httpStatusClientError: 'Client error',\n httpStatusServerError: 'Server error',\n httpStatusWarning: 'Warning',\n httpStatusNoResponse: 'No response',\n httpStatusUnknown: 'Unknown',\n validationCodeFormat: 'Enter the {length}-digit code',\n validationDate: 'Enter a valid date',\n validationPastDate: 'Pick a date in the future',\n validationUrl: 'Enter a valid link',\n validationWeakPassword: 'Use at least {minLength} characters with upper and lower case letters and a symbol',\n validationMismatch: 'The values do not match',\n validationPasswordMismatch: 'Passwords do not match',\n validationDistinct: 'The values must differ',\n validationIp: 'Enter a valid IP address',\n validationDomain: 'Enter a valid domain',\n validationDuplicate: 'This value is already taken',\n validationTime: 'Enter the time as HH:mm',\n validationJson: 'Enter a valid JSON object',\n validationValueMismatch: 'Type “{expected}” to confirm',\n validationSumExceeded: 'The total must not exceed {max}',\n validationPriceFormat: 'Enter a price like 12.50',\n validationPricePositive: 'The price must be above zero',\n copiedToClipboard: 'Copied to clipboard',\n copyToClipboardFailed: 'Could not copy',\n },\n};\n","const PLURAL_START = /\\{(\\w+),\\s*plural,\\s*/g;\nconst FORM_KEY = /^\\s*(=\\d+|\\w+)\\s*\\{/;\n\n/** Values for the `{name}` placeholders of a message. */\nexport type TxMessageParams = Record<string, string | number>;\n\n/** Fills `{name}` placeholders and ICU `{count, plural, one {…} other {…}}` forms of a message, with `#` as the count. */\nexport function formatMessage(template: string, params: TxMessageParams = {}, intl = 'en-US'): string {\n return replacePlurals(template, params, new Intl.PluralRules(intl)).replace(/\\{(\\w+)\\}/g, (match, name: string) => String(params[name] ?? match));\n}\n\nfunction replacePlurals(template: string, params: TxMessageParams, rules: Intl.PluralRules): string {\n let result = '';\n let index = 0;\n PLURAL_START.lastIndex = 0;\n let match = PLURAL_START.exec(template);\n while (match) {\n result += template.slice(index, match.index);\n const forms: Record<string, string> = {};\n let cursor = PLURAL_START.lastIndex;\n let key = FORM_KEY.exec(template.slice(cursor));\n while (key) {\n cursor += key[0].length;\n const start = cursor;\n let depth = 1;\n while (cursor < template.length && depth > 0) {\n depth += template[cursor] === '{' ? 1 : template[cursor] === '}' ? -1 : 0;\n cursor++;\n }\n forms[key[1]] = template.slice(start, cursor - 1);\n key = FORM_KEY.exec(template.slice(cursor));\n }\n const count = Number(params[match[1]] ?? 0);\n result += (forms[`=${count}`] ?? forms[rules.select(count)] ?? forms['other'] ?? '').replace(/#/g, String(count));\n const end = template.indexOf('}', cursor);\n index = end === -1 ? template.length : end + 1;\n PLURAL_START.lastIndex = index;\n match = PLURAL_START.exec(template);\n }\n return result + template.slice(index);\n}\n","/** Options of `formatBytes`. */\nexport interface TxFormatBytesOptions {\n /** Locale of the number and the unit names (default `en-US`). */\n locale?: string;\n /** Maximum digits after the point for sizes of a kilobyte and more (default 1). */\n decimals?: number;\n /** Size of a unit: `1024` (default) or `1000`. */\n base?: 1000 | 1024;\n}\n\nconst BYTE_UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte'] as const;\n\n/**\n * Formats a byte count in the largest unit that fits, with `Intl.NumberFormat` unit names of the locale: `512 bytes`,\n * `1.5 kB`, `5 MB`. Bytes use the full unit name, so the plural form follows the locale (`1 byte`, `124 bytes`).\n */\nexport function formatBytes(bytes: number, options: TxFormatBytesOptions = {}): string {\n const { locale = 'en-US', decimals = 1, base = 1024 } = options;\n const size = Math.max(0, bytes);\n const exponent = size < base ? 0 : Math.min(BYTE_UNITS.length - 1, Math.floor(Math.log(size) / Math.log(base)));\n return new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: BYTE_UNITS[exponent],\n unitDisplay: exponent === 0 ? 'long' : 'short',\n maximumFractionDigits: exponent === 0 ? 0 : decimals,\n }).format(size / base ** exponent);\n}\n","import { Injectable, computed, inject, signal } from '@angular/core';\nimport { TECTRA_CONFIG, TxLocaleCode, TxLocaleDefinition, TxLocaleRegistry, TxTranslations } from '@tectra-ng/core/config';\nimport { TxMessageParams, formatMessage } from './format-message';\nimport { TX_LOCALE_US } from './locales';\n\n/** Holds the current locale and translates, formats numbers and dates for it; the `locale` config option sets the start locale. */\n@Injectable({ providedIn: 'root' })\nexport class TxLocaleService {\n private config = inject(TECTRA_CONFIG, { optional: true });\n private registry = inject(TxLocaleRegistry);\n\n /** The current locale definition. */\n readonly locale = signal<TxLocaleDefinition>(this.resolve(this.config?.locale ?? 'us'));\n /** Translations of the current locale with the `translations` overrides of the config on top. */\n readonly translations = computed<TxTranslations>(() => ({ ...this.locale().translations, ...this.config?.translations }));\n\n constructor() {\n const initial = this.config?.locale;\n if (typeof initial === 'string' && this.locale().code !== initial) {\n void this.setLocale(initial);\n }\n }\n\n private request = 0;\n\n /** Switches the locale by code or definition; a code that is not registered yet is loaded first, and `us` is used if it fails. */\n async setLocale(locale: TxLocaleCode | TxLocaleDefinition): Promise<void> {\n const request = ++this.request;\n if (typeof locale !== 'string' || locale === TX_LOCALE_US.code || this.registry.get(locale)) {\n this.locale.set(this.resolve(locale));\n return;\n }\n const loaded = await this.registry.load(locale);\n if (request === this.request) {\n this.locale.set(loaded ?? TX_LOCALE_US);\n }\n }\n\n /** Returns the text of a translation key with its parameters filled in. */\n translate(key: keyof TxTranslations, params: TxMessageParams = {}): string {\n return this.format(this.translations()[key], params);\n }\n\n /** Fills the placeholders and plural forms of a template for the current locale. */\n format(template: string, params: TxMessageParams = {}): string {\n return formatMessage(template, params, this.locale().intl);\n }\n\n /** Formats a number with `Intl.NumberFormat` for the current locale. */\n formatNumber(value: number, options?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(this.locale().intl, options).format(value);\n }\n\n /** Formats a date or timestamp with `Intl.DateTimeFormat` for the current locale. */\n formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions): string {\n return new Intl.DateTimeFormat(this.locale().intl, options).format(value);\n }\n\n /** The twelve month names, January first, in the current locale. */\n monthNames(style: 'long' | 'short' = 'long'): string[] {\n const format = new Intl.DateTimeFormat(this.locale().intl, { month: style });\n return Array.from({ length: 12 }, (_, month) => format.format(new Date(2024, month, 1)));\n }\n\n /** The seven weekday names in the current locale, starting at its first day of the week. */\n weekdayNames(style: 'long' | 'short' | 'narrow' = 'short'): string[] {\n const format = new Intl.DateTimeFormat(this.locale().intl, { weekday: style });\n const first = this.locale().firstDayOfWeek;\n return Array.from({ length: 7 }, (_, day) => format.format(new Date(2024, 0, 7 + ((day + first) % 7))));\n }\n\n private resolve(locale: TxLocaleCode | TxLocaleDefinition): TxLocaleDefinition {\n return typeof locale === 'string' ? (this.registry.get(locale) ?? TX_LOCALE_US) : locale;\n }\n}\n","import { Signal, inject } from '@angular/core';\nimport { TxTranslations } from '@tectra-ng/core/config';\nimport { TxLocaleService } from './locale.service';\n\n/** Returns the translations of the current locale as a signal; call it in an injection context. */\nexport function injectTranslations(): Signal<TxTranslations> {\n return inject(TxLocaleService).translations;\n}\n"],"mappings":";;;AAGA,MAAa,eAAmC;CAC9C,MAAM;CACN,MAAM;CACN,gBAAgB;CAChB,YAAY;CACZ,cAAc;EACZ,cAAc;EACd,mBAAmB;EACnB,OAAO;EACP,WAAW;EACX,OAAO;EACP,SAAS;EACT,OAAO;EACP,cAAc;EACd,UAAU;EACV,MAAM;EACN,QAAQ;EACR,oBAAoB;EACpB,iBAAiB;EACjB,qBAAqB;EACrB,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,mBAAmB;EACnB,mBAAmB;EACnB,gBAAgB;EAChB,cAAc;EACd,gBAAgB;EAChB,gBAAgB;EAChB,cAAc;EACd,cAAc;EACd,SAAS;EACT,WAAW;EACX,WAAW;EACX,aAAa;EACb,YAAY;EACZ,UAAU;EACV,QAAQ;EACR,WAAW;EACX,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,qBAAqB;EACrB,oBAAoB;EACpB,eAAe;EACf,e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/format-message.ts","../../../../packages/core/i18n/src/format-bytes.ts","../../../../packages/core/i18n/src/locale.service.ts","../../../../packages/core/i18n/src/translations.ts","../../../../packages/core/i18n/src/locale-sync.ts"],"sourcesContent":["import { TxLocaleDefinition } from '@tectra-ng/core/config';\n\n/** Built-in English (US) locale, the fallback for every other locale. */\nexport const TX_LOCALE_US: TxLocaleDefinition = {\n code: 'us',\n intl: 'en-US',\n firstDayOfWeek: 0,\n dateFormat: 'mm/dd/yy',\n translations: {\n emptyMessage: 'No results found',\n searchPlaceholder: 'Search',\n clear: 'Clear',\n selectAll: 'Select all',\n close: 'Close',\n loading: 'Loading',\n today: 'Today',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n copy: 'Copy',\n copied: 'Copied',\n validationRequired: 'This field is required',\n validationEmail: 'Enter a valid email',\n validationMinlength: 'At least {requiredLength} characters',\n validationMaxlength: 'At most {requiredLength} characters',\n validationMin: 'Must be at least {min}',\n validationMax: 'Must be at most {max}',\n validationPattern: 'Invalid format',\n validationInvalid: 'Invalid value',\n passwordPrompt: 'Enter a password',\n passwordWeak: 'Weak',\n passwordMedium: 'Medium',\n passwordStrong: 'Strong',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n generatePassword: 'Generate password',\n otpCell: 'Character {index} of {length}',\n increment: 'Increase',\n decrement: 'Decrease',\n ratingValue: '{value} of {stars}',\n rangeStart: 'from',\n rangeEnd: 'to',\n remove: 'Remove',\n moreItems: '{count} more',\n avatarChangePhoto: 'Change photo',\n avatarUploadPhoto: 'Upload photo',\n avatarRemovePhoto: 'Remove',\n avatarRemoveTitle: 'Delete photo',\n avatarRemoveMessage: 'Are you sure you want to delete your photo?',\n avatarPhotoActions: 'Photo actions',\n tagListHidden: 'Other tags',\n selectedItems: '{count} items selected',\n selectedOfTotal: '{selected} of {total}',\n showOptions: 'Show options',\n removeItem: 'Remove {item}',\n pickColor: 'Pick a colour',\n noColor: 'No colour',\n colorArea: 'Saturation and brightness',\n colorAreaValue: 'Saturation {saturation}%, brightness {brightness}%',\n colorHue: 'Hue',\n colorHex: 'Hex colour',\n colorPresets: 'Preset colours',\n useEmail: 'Use {email}',\n didYouMean: 'Did you mean {email}?',\n yes: 'Yes',\n no: 'No',\n copyLink: 'Copy link',\n export: 'Export',\n exportFormats: 'Export formats',\n exportCsv: 'Export to CSV',\n exportExcel: 'Export to Excel',\n exportWord: 'Export to Word',\n exportPdf: 'Export to PDF',\n exportJson: 'Export to JSON',\n exportHtml: 'Export to HTML',\n exportMarkdown: 'Export to Markdown',\n exportCopy: 'Copy table',\n exportCopied: 'Table copied',\n exportPrint: 'Print',\n chooseDate: 'Choose date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n previousYear: 'Previous year',\n nextYear: 'Next year',\n previousDecade: 'Previous decade',\n nextDecade: 'Next decade',\n chooseMonth: 'Choose month',\n chooseYear: 'Choose year',\n weekHeader: 'Wk',\n am: 'AM',\n pm: 'PM',\n hour: 'Hour',\n minute: 'Minute',\n second: 'Second',\n nextHour: 'Next hour',\n previousHour: 'Previous hour',\n nextMinute: 'Next minute',\n previousMinute: 'Previous minute',\n nextSecond: 'Next second',\n previousSecond: 'Previous second',\n toggleAmPm: 'Switch AM / PM',\n dateSelected: '{date} selected',\n calendar: 'Calendar',\n moreEvents: '+{count}',\n events: '{count} events',\n copyEmail: 'Copy email',\n copyPhone: 'Copy phone number',\n opensInNewTab: 'opens in a new tab',\n breadcrumb: 'Breadcrumb',\n stepCompleted: 'completed',\n menu: 'Menu',\n resizePanels: 'Resize panels',\n imagePreview: 'Image preview',\n zoomImage: 'Zoom image',\n rotateRight: 'Rotate right',\n rotateLeft: 'Rotate left',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n carousel: 'Carousel',\n slide: 'Slide',\n slideOf: '{index} of {total}',\n previousSlide: 'Previous slide',\n nextSlide: 'Next slide',\n gallery: 'Gallery',\n galleryImage: 'Image {index}',\n previousImage: 'Previous image',\n nextImage: 'Next image',\n thumbnails: 'Thumbnails',\n previousThumbnails: 'Previous thumbnails',\n nextThumbnails: 'Next thumbnails',\n fileUploadPrompt: 'Drop files here or {browse}',\n fileUploadPromptSingle: 'Drop a file here or {browse}',\n fileUploadBrowse: 'browse',\n fileUploadRelease: 'Release to add',\n chooseFile: 'Choose file',\n chooseFiles: 'Choose files',\n upload: 'Upload',\n replace: 'Replace',\n retry: 'Retry',\n editorLabel: 'Text editor',\n editorToolbar: 'Formatting',\n editorUndo: 'Undo',\n editorRedo: 'Redo',\n editorTextStyle: 'Text style',\n editorParagraph: 'Normal text',\n editorHeading: 'Heading {level}',\n editorBold: 'Bold',\n editorItalic: 'Italic',\n editorUnderline: 'Underline',\n editorStrike: 'Strikethrough',\n editorCode: 'Inline code',\n editorSubscript: 'Subscript',\n editorSuperscript: 'Superscript',\n editorTextColor: 'Text colour',\n editorHighlight: 'Highlight',\n editorDefaultColor: 'Default',\n editorFontSize: 'Text size',\n editorSizeSmall: 'Small',\n editorSizeNormal: 'Normal',\n editorSizeLarge: 'Large',\n editorSizeHuge: 'Huge',\n editorBulletList: 'Bulleted list',\n editorOrderedList: 'Numbered list',\n editorTaskList: 'Checklist',\n editorIndent: 'Increase indent',\n editorOutdent: 'Decrease indent',\n editorAlign: 'Alignment',\n editorAlignLeft: 'Align left',\n editorAlignCenter: 'Align center',\n editorAlignRight: 'Align right',\n editorAlignJustify: 'Justify',\n editorLink: 'Link',\n editorLinkUrl: 'Link address',\n editorLinkApply: 'Apply',\n editorLinkRemove: 'Remove link',\n editorLinkEdit: 'Edit link',\n editorImage: 'Image',\n editorVideo: 'Video',\n editorVideoUrl: 'Video address',\n editorVideoHint: 'YouTube, Vimeo or a player link',\n editorInsert: 'Insert',\n editorQuote: 'Quote',\n editorCodeBlock: 'Code block',\n editorRule: 'Divider',\n editorClear: 'Clear formatting',\n editorFullView: 'Full view',\n editorNormalView: 'Exit full view',\n editorAi: 'Improve with AI',\n editorCount: '{count} characters',\n editorCountLimit: '{count} / {limit}',\n editorNoMatches: 'No matches',\n editorImageTooLarge: '{name} is larger than {size}',\n editorColorGray: 'Gray',\n editorColorRed: 'Red',\n editorColorOrange: 'Orange',\n editorColorYellow: 'Yellow',\n editorColorGreen: 'Green',\n editorColorTeal: 'Teal',\n editorColorBlue: 'Blue',\n editorColorPurple: 'Purple',\n editorColorPink: 'Pink',\n editorImagePreview: 'Image preview',\n editorCallout: 'Callout',\n editorCalloutTone: 'Change the callout colour',\n editorTable: 'Table',\n editorRowAbove: 'Add row above',\n editorRowBelow: 'Add row below',\n editorColumnLeft: 'Add column on the left',\n editorColumnRight: 'Add column on the right',\n editorDeleteRow: 'Delete row',\n editorDeleteColumn: 'Delete column',\n editorHeaderRow: 'Header row',\n editorDeleteTable: 'Delete table',\n editorCommands: 'Insert block',\n editorEmoji: 'Emoji',\n editorMentions: 'People',\n editorAiKeep: 'Keep',\n editorAiDiscard: 'Undo',\n codeEditorLabel: 'Code editor',\n codeHighlightLabel: 'Code',\n codeSearchFind: 'Find',\n codeSearchReplace: 'Replace',\n codeSearchReplaceAll: 'Replace all',\n codeSearchNext: 'Next match',\n codeSearchPrevious: 'Previous match',\n codeSearchMatchCase: 'Match case',\n codeSearchWholeWord: 'Match whole word',\n codeSearchRegexp: 'Use regular expression',\n codeSearchToggleReplace: 'Toggle replace',\n codeSearchClose: 'Close',\n codeSearchCount: '{current} of {total}',\n codeSearchNoResults: 'No results',\n codeDiffLabel: 'Changes',\n codeDiffOriginal: 'Original',\n codeDiffModified: 'Modified',\n noFileChosen: 'No file chosen',\n filesChosen: '{count} files',\n fileReady: 'Ready to upload',\n fileUploading: 'Uploading {progress}%',\n fileUploaded: 'Uploaded',\n fileFailed: 'Upload failed',\n invalidFileType: '{name} is not a supported file type ({types})',\n invalidFileSize: '{name} is larger than {size}',\n invalidFileLimit: 'You can add up to {limit} files',\n filesAdded: 'Added: {names}',\n filesUploaded: 'Upload complete',\n filesSummary: 'Files: {count} · {size}',\n notifications: 'Notifications',\n confirm: 'Confirm',\n cancel: 'Cancel',\n delete: 'Delete',\n confirmQuestion: 'Are you sure?',\n maximize: 'Maximize',\n restore: 'Restore',\n moreActions: 'More actions',\n firstPage: 'First page',\n lastPage: 'Last page',\n pageNumber: 'Page {page}',\n rowsPerPage: 'Rows per page',\n jumpToPage: 'Go to page',\n currentPageReport: '{currentPage} of {totalPages}',\n totalCount: 'Total: {count}',\n pagination: 'Pagination',\n tableSettings: 'Table settings',\n tableColumns: 'Columns',\n tableColumnsHint: 'Show or hide table columns',\n tableActions: 'Actions',\n tableActionsHint: 'Choose which row actions are shown inline',\n rowActions: 'Row actions',\n nodeActions: 'Node actions',\n listView: 'List',\n gridView: 'Grid',\n layout: 'Layout',\n selectRow: 'Select row',\n expandRow: 'Expand row',\n collapseRow: 'Collapse row',\n resizeColumn: 'Resize {column}',\n filterColumn: 'Filter {column}',\n filterValue: 'Value',\n filterMatchMode: 'Match mode',\n filterMatchAll: 'Match all',\n filterMatchAny: 'Match any',\n filterAddRule: 'Add rule',\n filterRemoveRule: 'Remove rule',\n filterApply: 'Apply',\n filterAny: 'Any',\n startsWith: 'Starts with',\n contains: 'Contains',\n notContains: 'Not contains',\n endsWith: 'Ends with',\n equals: 'Equals',\n notEquals: 'Not equals',\n in: 'Is one of',\n lt: 'Less than',\n lte: 'Less than or equal to',\n gt: 'Greater than',\n gte: 'Greater than or equal to',\n between: 'Between',\n dateIs: 'Date is',\n dateIsNot: 'Date is not',\n dateBefore: 'Date is before',\n dateAfter: 'Date is after',\n editRow: 'Edit row',\n saveRow: 'Save row',\n cancelEdit: 'Cancel editing',\n moveRow: 'Move row',\n rowGroup: '{count} rows',\n filters: 'Filters',\n clearFilters: 'Clear filters',\n showFilters: 'Show filters',\n filterHasValue: 'Has a value — shown while it is set',\n resetFiltersLayout: 'Reset to default',\n reorderFilter: 'Drag to reorder',\n filtersShown: '{shown} of {total}',\n filtersHidden: '{label}, {count} hidden',\n legal: 'Legal',\n consoleSections: 'Sections',\n pinMenu: 'Keep the menu open',\n unpinMenu: 'Let the menu fold',\n wizardNext: 'Next',\n wizardBack: 'Back',\n wizardProgress: 'Progress',\n customize: 'Customize',\n pinnedTabs: 'Pinned tabs',\n pinnedTabsHint: 'Selected items appear as tabs for quick switching. The choice is saved in this browser.',\n pinnedSelected: 'Selected: {count} of {total}',\n all: 'All',\n save: 'Save',\n search: 'Search',\n searching: 'Searching…',\n nothingFound: 'Nothing found',\n paletteNavigate: 'to navigate',\n paletteOpen: 'to open',\n paletteClose: 'to close',\n board: 'Board',\n moveColumn: 'Drag to move the column',\n noCards: 'No cards',\n showMore: 'Show {count} more',\n kanbanMoveHint: 'Alt and the arrow keys move it',\n kanbanMoved: 'Moved to {column}, position {position}',\n switchToLight: 'Switch to light theme',\n switchToDark: 'Switch to dark theme',\n language: 'Language',\n theme: 'Theme',\n themePrimary: 'Primary',\n themeSurface: 'Surface',\n themeStyle: 'Style',\n themeRipple: 'Ripple',\n openMenu: 'Open menu',\n closeMenu: 'Close menu',\n cookieTitle: 'Only essential cookies',\n cookieText: 'We use a sign-in cookie and browser storage to keep you signed in and remember your settings. No ads, no tracking.',\n cookieLearnMore: 'Learn more',\n cookieAccept: 'Got it',\n cookieLabel: 'Cookie notice',\n offline: 'No internet connection',\n connectionRestored: 'Connection restored',\n qrCode: 'QR code',\n qrCodeError: 'Unable to render QR code',\n addPerson: 'Add a person',\n listInputPlaceholder: 'One item per line, or separated by commas or spaces',\n listInputPlaceholderDomain: 'example.com, another.org or one domain per line',\n listInputPlaceholderEmail: 'name@example.com, another@example.org or one email per line',\n listInputPlaceholderUrl: 'https://example.com/page or one link per line',\n listInputHint: 'Paste a list — duplicates and lines that do not fit are counted.',\n listInputHintDomain: 'Paste domains or URLs — protocols, paths and duplicates are removed automatically.',\n listInputHintEmail: 'Paste emails — duplicates and invalid addresses are counted.',\n listInputHintUrl: 'Paste links — a missing https:// is added, duplicates are counted.',\n listInputItems: '{count, plural, one {# item} other {# items}}',\n listInputDomains: '{count, plural, one {# domain} other {# domains}}',\n listInputEmails: '{count, plural, one {# email} other {# emails}}',\n listInputUrls: '{count, plural, one {# link} other {# links}}',\n listInputDuplicates: '{count, plural, one {# duplicate} other {# duplicates}}',\n listInputInvalidCount: '{count} not recognized',\n listInputInvalid: 'Not recognized',\n listInputMore: '+{count} more',\n listInputCleanUp: 'Clean up',\n listInputCleanUpHint: 'One item per line, without duplicates and invalid lines',\n chartNoData: 'No data',\n chartLoading: 'Loading chart',\n chartLegend: 'Legend',\n chartDataTable: 'Chart data',\n chartCategory: 'Category',\n chartValue: 'Value',\n chartShare: 'Share',\n chartTotal: 'Total',\n chartSummary: '{type}, {series, plural, one {# series} other {# series}}, {points, plural, one {# value} other {# values}}',\n chartRange: 'from {min} to {max}',\n chartPoint: '{series}, {category}: {value}',\n chartNavigateHint: 'Arrow keys move between values',\n chartLine: 'Line chart',\n chartArea: 'Area chart',\n chartColumn: 'Column chart',\n chartBar: 'Bar chart',\n chartCombo: 'Combo chart',\n chartScatter: 'Scatter chart',\n chartBubble: 'Bubble chart',\n chartSize: 'Size',\n chartRadar: 'Radar chart',\n chartAverage: 'Average',\n chartRadialBar: 'Radial bar chart',\n chartGauge: 'Gauge',\n chartWaterfall: 'Waterfall chart',\n chartFunnel: 'Funnel chart',\n chartBullet: 'Bullet chart',\n chartIncrease: 'Increase',\n chartDecrease: 'Decrease',\n chartChange: 'Change',\n chartConversion: 'Conversion',\n chartOfFirst: 'Of first',\n chartTarget: 'Target',\n chartCandlestick: 'Candlestick chart',\n chartBoxplot: 'Box plot',\n chartRangeArea: 'Range area chart',\n chartOpen: 'Open',\n chartHigh: 'High',\n chartLow: 'Low',\n chartClose: 'Close',\n chartVolume: 'Volume',\n chartMin: 'Min',\n chartMax: 'Max',\n chartMedian: 'Median',\n chartQ1: 'First quartile',\n chartQ3: 'Third quartile',\n chartOutliers: 'Outliers',\n chartGantt: 'Gantt chart',\n chartSummaryTasks: '{count, plural, one {# task} other {# tasks}}',\n chartTask: 'Task',\n chartDays: '{count, plural, one {# day} other {# days}}',\n chartProgress: 'Progress',\n chartMilestone: 'Milestone',\n chartZoomDay: 'Days',\n chartZoomWeek: 'Weeks',\n chartZoomMonth: 'Months',\n chartZoomQuarter: 'Quarters',\n chartTimeline: 'Timeline',\n chartSankey: 'Sankey diagram',\n chartSunburst: 'Sunburst chart',\n chartFlow: '{source} → {target}',\n chartIncoming: 'In',\n chartOutgoing: 'Out',\n chartOfParent: 'Of parent',\n chartOfTotal: 'Of total',\n chartFlows: '{count, plural, one {# flow} other {# flows}}',\n chartResetZoom: 'Reset zoom',\n chartZoomHint: 'Ctrl and the wheel or a pinch zoom, drag to move, + and − zoom, 0 resets',\n chartGanttHint: 'Arrow keys move between tasks · + and − zoom · Ctrl and the wheel zoom at the pointer',\n chartDependsOn: 'Depends on',\n chartRequiredBy: 'Required by',\n chartStartToStart: 'start to start',\n chartFinishToFinish: 'finish to finish',\n chartStartToFinish: 'start to finish',\n chartGaugeValue: '{value} of {min} to {max}',\n chartPie: 'Pie chart',\n chartDonut: 'Donut chart',\n chartMenu: 'Chart menu',\n chartDownloadSvg: 'Download SVG',\n chartDownloadPng: 'Download PNG',\n chartDownloadCsv: 'Download CSV',\n chartHeatmap: 'Heatmap',\n chartTreemap: 'Treemap',\n chartRank: 'Rank chart',\n chartRankValue: 'Rank',\n orgChartTitle: 'Org chart',\n orgChartHint: 'Drag to move · scroll or pinch to zoom at the cursor · keys: + − 0 F /',\n orgChartSearch: 'Search',\n orgChartMatches: '{count} found',\n orgChartNoMatches: 'Nothing found',\n orgChartZoomIn: 'Zoom in',\n orgChartZoomOut: 'Zoom out',\n orgChartResetZoom: 'Reset zoom',\n orgChartFit: 'Fit to screen',\n orgChartExpandAll: 'Expand all',\n orgChartCollapseAll: 'Collapse all',\n orgChartFullscreen: 'Full screen',\n orgChartExitFullscreen: 'Exit full screen',\n orgChartExpand: 'Expand',\n orgChartCollapse: 'Collapse',\n orgChartMore: 'Chart actions',\n httpStatusOk: 'OK',\n httpStatusRedirect: 'Redirect',\n httpStatusClientError: 'Client error',\n httpStatusServerError: 'Server error',\n httpStatusWarning: 'Warning',\n httpStatusNoResponse: 'No response',\n httpStatusUnknown: 'Unknown',\n validationCodeFormat: 'Enter the {length}-digit code',\n validationDate: 'Enter a valid date',\n validationPastDate: 'Pick a date in the future',\n validationUrl: 'Enter a valid link',\n validationWeakPassword: 'Use at least {minLength} characters with upper and lower case letters and a symbol',\n validationMismatch: 'The values do not match',\n validationPasswordMismatch: 'Passwords do not match',\n validationDistinct: 'The values must differ',\n validationIp: 'Enter a valid IP address',\n validationDomain: 'Enter a valid domain',\n validationDuplicate: 'This value is already taken',\n validationTime: 'Enter the time as HH:mm',\n validationJson: 'Enter a valid JSON object',\n validationValueMismatch: 'Type “{expected}” to confirm',\n validationSumExceeded: 'The total must not exceed {max}',\n validationPriceFormat: 'Enter a price like 12.50',\n validationPricePositive: 'The price must be above zero',\n copiedToClipboard: 'Copied to clipboard',\n copyToClipboardFailed: 'Could not copy',\n },\n};\n","const PLURAL_START = /\\{(\\w+),\\s*plural,\\s*/g;\nconst FORM_KEY = /^\\s*(=\\d+|\\w+)\\s*\\{/;\n\n/** Values for the `{name}` placeholders of a message. */\nexport type TxMessageParams = Record<string, string | number>;\n\n/** Fills `{name}` placeholders and ICU `{count, plural, one {…} other {…}}` forms of a message, with `#` as the count. */\nexport function formatMessage(template: string, params: TxMessageParams = {}, intl = 'en-US'): string {\n return replacePlurals(template, params, new Intl.PluralRules(intl)).replace(/\\{(\\w+)\\}/g, (match, name: string) => String(params[name] ?? match));\n}\n\nfunction replacePlurals(template: string, params: TxMessageParams, rules: Intl.PluralRules): string {\n let result = '';\n let index = 0;\n PLURAL_START.lastIndex = 0;\n let match = PLURAL_START.exec(template);\n while (match) {\n result += template.slice(index, match.index);\n const forms: Record<string, string> = {};\n let cursor = PLURAL_START.lastIndex;\n let key = FORM_KEY.exec(template.slice(cursor));\n while (key) {\n cursor += key[0].length;\n const start = cursor;\n let depth = 1;\n while (cursor < template.length && depth > 0) {\n depth += template[cursor] === '{' ? 1 : template[cursor] === '}' ? -1 : 0;\n cursor++;\n }\n forms[key[1]] = template.slice(start, cursor - 1);\n key = FORM_KEY.exec(template.slice(cursor));\n }\n const count = Number(params[match[1]] ?? 0);\n result += (forms[`=${count}`] ?? forms[rules.select(count)] ?? forms['other'] ?? '').replace(/#/g, String(count));\n const end = template.indexOf('}', cursor);\n index = end === -1 ? template.length : end + 1;\n PLURAL_START.lastIndex = index;\n match = PLURAL_START.exec(template);\n }\n return result + template.slice(index);\n}\n","/** Options of `formatBytes`. */\nexport interface TxFormatBytesOptions {\n /** Locale of the number and the unit names (default `en-US`). */\n locale?: string;\n /** Maximum digits after the point for sizes of a kilobyte and more (default 1). */\n decimals?: number;\n /** Size of a unit: `1024` (default) or `1000`. */\n base?: 1000 | 1024;\n}\n\nconst BYTE_UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte'] as const;\n\n/**\n * Formats a byte count in the largest unit that fits, with `Intl.NumberFormat` unit names of the locale: `512 bytes`,\n * `1.5 kB`, `5 MB`. Bytes use the full unit name, so the plural form follows the locale (`1 byte`, `124 bytes`).\n */\nexport function formatBytes(bytes: number, options: TxFormatBytesOptions = {}): string {\n const { locale = 'en-US', decimals = 1, base = 1024 } = options;\n const size = Math.max(0, bytes);\n const exponent = size < base ? 0 : Math.min(BYTE_UNITS.length - 1, Math.floor(Math.log(size) / Math.log(base)));\n return new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: BYTE_UNITS[exponent],\n unitDisplay: exponent === 0 ? 'long' : 'short',\n maximumFractionDigits: exponent === 0 ? 0 : decimals,\n }).format(size / base ** exponent);\n}\n","import { Injectable, computed, inject, signal } from '@angular/core';\nimport {\n TECTRA_CONFIG,\n TX_LOCALE_LOADERS,\n TxLocaleCode,\n TxLocaleDefinition,\n TxLocaleRegistry,\n TxLocaleStorage,\n TxTranslations,\n} from '@tectra-ng/core/config';\nimport { TxMessageParams, formatMessage } from './format-message';\nimport { TX_LOCALE_US } from './locales';\n\n/**\n * Holds the current locale and translates, formats numbers and dates for it; the `locale` config option sets the start\n * locale, and a locale remembered under `localeStorageKey` takes its place.\n */\n@Injectable({ providedIn: 'root' })\nexport class TxLocaleService {\n private config = inject(TECTRA_CONFIG, { optional: true });\n private registry = inject(TxLocaleRegistry);\n private storage = inject(TxLocaleStorage);\n private readonly start = this.startLocale();\n\n /** The current locale definition. */\n readonly locale = signal<TxLocaleDefinition>(this.resolve(this.start));\n /** Translations of the current locale with the `translations` overrides of the config on top. */\n readonly translations = computed<TxTranslations>(() => ({ ...this.locale().translations, ...this.config?.translations }));\n\n constructor() {\n const initial = this.start;\n if (typeof initial === 'string' && this.locale().code !== initial) {\n void this.apply(initial);\n }\n }\n\n private request = 0;\n\n /**\n * Switches the locale by code or definition; a code that is not registered yet is loaded first, and `us` is used if\n * it fails. The code of the applied locale is remembered under `localeStorageKey`.\n */\n async setLocale(locale: TxLocaleCode | TxLocaleDefinition): Promise<void> {\n const request = await this.apply(locale);\n if (request === this.request) {\n this.storage.write(this.locale().code);\n }\n }\n\n /** Returns the text of a translation key with its parameters filled in. */\n translate(key: keyof TxTranslations, params: TxMessageParams = {}): string {\n return this.format(this.translations()[key], params);\n }\n\n /** Fills the placeholders and plural forms of a template for the current locale. */\n format(template: string, params: TxMessageParams = {}): string {\n return formatMessage(template, params, this.locale().intl);\n }\n\n /** Formats a number with `Intl.NumberFormat` for the current locale. */\n formatNumber(value: number, options?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(this.locale().intl, options).format(value);\n }\n\n /** Formats a date or timestamp with `Intl.DateTimeFormat` for the current locale. */\n formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions): string {\n return new Intl.DateTimeFormat(this.locale().intl, options).format(value);\n }\n\n /** The twelve month names, January first, in the current locale. */\n monthNames(style: 'long' | 'short' = 'long'): string[] {\n const format = new Intl.DateTimeFormat(this.locale().intl, { month: style });\n return Array.from({ length: 12 }, (_, month) => format.format(new Date(2024, month, 1)));\n }\n\n /** The seven weekday names in the current locale, starting at its first day of the week. */\n weekdayNames(style: 'long' | 'short' | 'narrow' = 'short'): string[] {\n const format = new Intl.DateTimeFormat(this.locale().intl, { weekday: style });\n const first = this.locale().firstDayOfWeek;\n return Array.from({ length: 7 }, (_, day) => format.format(new Date(2024, 0, 7 + ((day + first) % 7))));\n }\n\n private async apply(locale: TxLocaleCode | TxLocaleDefinition): Promise<number> {\n const request = ++this.request;\n if (typeof locale !== 'string' || locale === TX_LOCALE_US.code || this.registry.get(locale)) {\n this.locale.set(this.resolve(locale));\n return request;\n }\n const loaded = await this.registry.load(locale);\n if (request === this.request) {\n this.locale.set(loaded ?? TX_LOCALE_US);\n }\n return request;\n }\n\n private startLocale(): TxLocaleCode | TxLocaleDefinition {\n const stored = this.storage.read();\n if (stored && (stored === TX_LOCALE_US.code || this.registry.get(stored) || stored in TX_LOCALE_LOADERS)) {\n return stored;\n }\n return this.config?.locale ?? TX_LOCALE_US.code;\n }\n\n private resolve(locale: TxLocaleCode | TxLocaleDefinition): TxLocaleDefinition {\n return typeof locale === 'string' ? (this.registry.get(locale) ?? TX_LOCALE_US) : locale;\n }\n}\n","import { Signal, inject } from '@angular/core';\nimport { TxTranslations } from '@tectra-ng/core/config';\nimport { TxLocaleService } from './locale.service';\n\n/** Returns the translations of the current locale as a signal; call it in an injection context. */\nexport function injectTranslations(): Signal<TxTranslations> {\n return inject(TxLocaleService).translations;\n}\n","import {\n ApplicationInitStatus,\n EnvironmentInjector,\n EnvironmentProviders,\n effect,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n runInInjectionContext,\n untracked,\n} from '@angular/core';\nimport { TxLocaleDefinition } from '@tectra-ng/core/config';\nimport { TxLocaleService } from './locale.service';\n\n/** Called with the code and the definition of the current locale; runs in an injection context, so it may `inject()`. */\nexport type TxLocaleListener = (code: string, locale: TxLocaleDefinition) => void;\n\n/**\n * Mirrors the tectra locale into the app: calls the listener once the app has started (with the start locale, a\n * remembered one included) and again after every change, e.g. to switch the app's own translation library.\n */\nexport function provideTxLocaleSync(listener: TxLocaleListener): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideEnvironmentInitializer(() => {\n const injector = inject(EnvironmentInjector);\n void inject(ApplicationInitStatus).donePromise.then(() => {\n if (injector.destroyed) {\n return;\n }\n const service = injector.get(TxLocaleService);\n effect(\n () => {\n const locale = service.locale();\n untracked(() => runInInjectionContext(injector, () => listener(locale.code, locale)));\n },\n { injector },\n );\n });\n }),\n ]);\n}\n"],"mappings":";;;AAGA,MAAa,eAAmC;CAC9C,MAAM;CACN,MAAM;CACN,gBAAgB;CAChB,YAAY;CACZ,cAAc;EACZ,cAAc;EACd,mBAAmB;EACnB,OAAO;EACP,WAAW;EACX,OAAO;EACP,SAAS;EACT,OAAO;EACP,cAAc;EACd,UAAU;EACV,MAAM;EACN,QAAQ;EACR,oBAAoB;EACpB,iBAAiB;EACjB,qBAAqB;EACrB,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,mBAAmB;EACnB,mBAAmB;EACnB,gBAAgB;EAChB,cAAc;EACd,gBAAgB;EAChB,gBAAgB;EAChB,cAAc;EACd,cAAc;EACd,kBAAkB;EAClB,SAAS;EACT,WAAW;EACX,WAAW;EACX,aAAa;EACb,YAAY;EACZ,UAAU;EACV,QAAQ;EACR,WAAW;EACX,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,mBAAmB;EACnB,qBAAqB;EACrB,oBAAoB;EACpB,eAAe;EACf,eAAe;EACf,iBAAiB;EACjB,aAAa;EACb,YAAY;EACZ,WAAW;EACX,SAAS;EACT,WAAW;EACX,gBAAgB;EAChB,UAAU;EACV,UAAU;EACV,cAAc;EACd,UAAU;EACV,YAAY;EACZ,KAAK;EACL,IAAI;EACJ,UAAU;EACV,QAAQ;EACR,eAAe;EACf,WAAW;EACX,aAAa;EACb,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,YAAY;EACZ,gBAAgB;EAChB,YAAY;EACZ,cAAc;EAC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O,yBAAyB,CAC9B,oCAAmC;EACjC,MAAM,WAAW,OAAO,mBAAmB;EAC3C,AAAK,OAAO,qBAAqB,CAAC,CAAC,YAAY,WAAU;GACvD,IAAI,SAAS,WACX;GAEF,MAAM,UAAU,SAAS,IAAI,eAAe;GAC5C,aACO;IACH,MAAM,SAAS,QAAQ,OAAM;IAC7B,gBAAgB,sBAAsB,gBAAgB,SAAS,OAAO,MAAM,MAAM,CAAC,CAAC;GACtF,GACA,EAAE,SAAQ,CAAE;EAEhB,CAAC;CACH,CAAC,CACF,CAAA;AACH"}
@@ -1,7 +1,7 @@
1
1
  import { ComponentPortal, TemplatePortal } from "@angular/cdk/portal";
2
2
  import { CdkConnectedOverlay, createBlockScrollStrategy, createCloseScrollStrategy, createFlexibleConnectedPositionStrategy, createNoopScrollStrategy, createOverlayRef, createRepositionScrollStrategy } from "@angular/cdk/overlay";
3
3
  import * as i0 from "@angular/core";
4
- import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, TemplateRef, afterNextRender, inject, signal } from "@angular/core";
4
+ import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, TemplateRef, afterNextRender, computed, inject, signal } from "@angular/core";
5
5
  import { Subject } from "rxjs";
6
6
  import { TECTRA_CONFIG } from "@tectra-ng/core/config";
7
7
  const OPPOSITE = {
@@ -76,6 +76,9 @@ function txPositions(placement = "bottom-start", offset = 4) {
76
76
  const across = side === "left" || side === "right" ? sidesAround("bottom", "center") : [];
77
77
  return [...sidesAround(side, align), ...across].map(([s, a]) => position(s, a, offset));
78
78
  }
79
+ function txFieldPositions(offset = 4) {
80
+ return ["bottom", "top"].flatMap((side) => ["start", "end"].map((align) => position(side, align, offset)));
81
+ }
79
82
  function placementFromPosition(position) {
80
83
  const panelClass = Array.isArray(position.panelClass) ? position.panelClass[0] : position.panelClass;
81
84
  return panelClass?.startsWith("tx-placement-") ? panelClass.replace("tx-placement-", "") : null;
@@ -1003,6 +1006,61 @@ var TxOverlayRoom = class {
1003
1006
  if (!this.fit(origin, panel, overlay, injector)) overlay?.overlayRef?.updatePosition();
1004
1007
  }
1005
1008
  };
1006
- export { TxOverlay, TxOverlayAnchor, TxOverlayInset, TxOverlayInsets, TxOverlayRoom, TxOverlayStack, fitsInBounds, orderByRoom, parsePlacement, placementFromPosition, scrollContainers, scrollTimeline, scrollTracksOf, scrollersOf, toPlacement, txAnchorPane, txAnimateEnter, txAnimateLeave, txArrowInset, txArrowOffset, txArrowPositions, txConnectedMargin, txCrossShift, txFollowsScroll, txHostGap, txLayoutOrigin, txLayoutRect, txLayoutShift, txOverlayBounds, txPopOrigin, txPositions, txScrollStrategy, txViewportMargin, watchOrigin };
1009
+ function px(value) {
1010
+ return `${value}px`;
1011
+ }
1012
+ function measured(value) {
1013
+ return parseFloat(value ?? "");
1014
+ }
1015
+ var TxPanelWidth = class {
1016
+ box = signal(null, ...ngDevMode ? [{ debugName: "box" }] : /* istanbul ignore next */ []);
1017
+ maxWidth;
1018
+ matchOrigin;
1019
+ fitContent;
1020
+ margin;
1021
+ style = computed(() => {
1022
+ const box = this.box();
1023
+ if (!box) return {};
1024
+ const { origin, limit, locked } = box;
1025
+ const reach = this.maxWidth ? this.matchOrigin ? `max(${this.maxWidth}, ${px(origin)})` : this.maxWidth : null;
1026
+ const max = reach && limit !== null ? `min(${reach}, ${px(limit)})` : reach ?? (limit !== null ? px(limit) : null);
1027
+ const style = {};
1028
+ if (this.matchOrigin) style["min-width"] = px(limit !== null ? Math.min(origin, limit) : origin);
1029
+ if (max) style["max-width"] = max;
1030
+ if (this.fitContent) style["width"] = locked !== null ? px(locked) : "max-content";
1031
+ return style;
1032
+ }, ...ngDevMode ? [{ debugName: "style" }] : /* istanbul ignore next */ []);
1033
+ constructor(options = {}) {
1034
+ this.maxWidth = options.maxWidth;
1035
+ this.matchOrigin = options.matchOrigin ?? true;
1036
+ this.fitContent = options.fitContent ?? true;
1037
+ this.margin = options.margin ?? 8;
1038
+ }
1039
+ open(origin) {
1040
+ const viewport = origin.ownerDocument.documentElement.clientWidth;
1041
+ this.box.set({
1042
+ origin: origin instanceof HTMLElement ? origin.offsetWidth : origin.getBoundingClientRect().width,
1043
+ limit: viewport > 0 ? Math.max(0, viewport - this.margin * 2) : null,
1044
+ locked: null
1045
+ });
1046
+ }
1047
+ lock(panel, overflowing) {
1048
+ const box = this.box();
1049
+ if (!panel || !box || box.locked !== null || !this.fitContent) return;
1050
+ const style = panel.ownerDocument.defaultView?.getComputedStyle(panel);
1051
+ const current = measured(style?.width);
1052
+ const width = Number.isNaN(current) ? panel.offsetWidth : current;
1053
+ const hidden = overflowing ? Array.from(panel.querySelectorAll(overflowing), (element) => element.scrollWidth - element.clientWidth) : [];
1054
+ const wanted = Math.ceil(width + Math.max(0, ...hidden));
1055
+ const max = measured(style?.maxWidth);
1056
+ const locked = Number.isNaN(max) ? wanted : Math.min(wanted, Math.floor(max));
1057
+ this.box.set({
1058
+ ...box,
1059
+ locked
1060
+ });
1061
+ panel.style.width = px(locked);
1062
+ }
1063
+ };
1064
+ export { TxOverlay, TxOverlayAnchor, TxOverlayInset, TxOverlayInsets, TxOverlayRoom, TxOverlayStack, TxPanelWidth, fitsInBounds, orderByRoom, parsePlacement, placementFromPosition, scrollContainers, scrollTimeline, scrollTracksOf, scrollersOf, toPlacement, txAnchorPane, txAnimateEnter, txAnimateLeave, txArrowInset, txArrowOffset, txArrowPositions, txConnectedMargin, txCrossShift, txFieldPositions, txFollowsScroll, txHostGap, txLayoutOrigin, txLayoutRect, txLayoutShift, txOverlayBounds, txPopOrigin, txPositions, txScrollStrategy, txViewportMargin, watchOrigin };
1007
1065
 
1008
1066
  //# sourceMappingURL=tectra-ng-core-overlay.mjs.map