@altertable/data-app 0.75.0 → 0.77.0
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/README.md +56 -9
- package/REFERENCE.md +387 -333
- package/dist/chunks/{contract-B3s0ybE2.js → contract-BQsFReRp.js} +314 -237
- package/dist/chunks/contract-BQsFReRp.js.map +1 -0
- package/dist/chunks/{contract-DcPjfm0R.js → contract-VhY9V9wd.js} +184 -91
- package/dist/chunks/contract-VhY9V9wd.js.map +1 -0
- package/dist/chunks/{format-5hMYUWk3.js → date-time-range-value-CnlTr1U1.js} +8 -153
- package/dist/chunks/date-time-range-value-CnlTr1U1.js.map +1 -0
- package/dist/chunks/{diagnostics-DVwQ5PDK.js → diagnostics-Dyj-rUsY.js} +2 -2
- package/dist/chunks/{diagnostics-DVwQ5PDK.js.map → diagnostics-Dyj-rUsY.js.map} +1 -1
- package/dist/chunks/{operation-CGuN7Zcb.js → operation-BVRM-A5Y.js} +3 -3
- package/dist/chunks/{operation-CGuN7Zcb.js.map → operation-BVRM-A5Y.js.map} +1 -1
- package/dist/client/index.js +65 -50
- package/dist/client/index.js.map +1 -1
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.js +4 -4
- package/dist/core/format.js +149 -1
- package/dist/core/format.js.map +1 -0
- package/dist/internal.js +6 -308
- package/dist/internal.js.map +1 -1
- package/dist/server/index.js +3 -3
- package/dist/types/chunks/contract.d.ts +359 -599
- package/dist/types/chunks/contract2.d.ts +221 -0
- package/dist/types/chunks/date-time-range-value.d.ts +2 -28
- package/dist/types/chunks/date-time-range.d.ts +29 -0
- package/dist/types/chunks/index.d.ts +33 -5
- package/dist/types/client/index.d.ts +3 -3
- package/dist/types/core/config.d.ts +8 -4
- package/dist/types/core/contract.d.ts +5 -3
- package/dist/types/core/format.d.ts +2 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/internal.d.ts +7 -5
- package/dist/types/server/index.d.ts +1 -1
- package/docs/app-authoring.md +15 -10
- package/docs/client.md +12 -7
- package/docs/contract.md +33 -50
- package/docs/data-context.md +9 -5
- package/docs/filters.md +295 -0
- package/docs/hosted-apps.md +4 -3
- package/docs/layout.md +24 -18
- package/docs/stories-and-export.md +19 -10
- package/docs/ui.md +7 -6
- package/docs/views.md +62 -26
- package/docs/widgets.md +38 -14
- package/package.json +16 -5
- package/dist/chunks/contract-B3s0ybE2.js.map +0 -1
- package/dist/chunks/contract-DcPjfm0R.js.map +0 -1
- package/dist/chunks/format-5hMYUWk3.js.map +0 -1
- package/docs/variables.md +0 -269
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-VhY9V9wd.js","names":[],"sources":["../../src/core/filters.ts","../../src/core/facets.ts","../../src/core/facet-filter.ts","../../src/core/date-time-range-contract.ts","../../src/core/date-time-filter.ts","../../src/core/navigation.ts","../../src/core/messages.ts","../../src/core/annotations.ts","../../src/core/external-link.ts","../../src/core/contract.ts"],"sourcesContent":["import {\n type AppFilter,\n type HistoryMode,\n type FilterPresentation,\n} from './app-filters.ts';\nimport { invariant } from './invariant.ts';\n\nexport type NumberOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';\nexport type NumberSelection =\n | { kind: 'all' }\n | { kind: 'comparison'; operator: NumberOperator; value: number }\n | { kind: 'range'; min?: number; max?: number };\nexport type BooleanSelection = { kind: 'all' } | { kind: 'is'; value: boolean };\nexport type NumberFilter = AppFilter<NumberSelection, 'numberFilter'> & {\n label: string;\n min?: number;\n max?: number;\n};\nexport type BooleanFilter = AppFilter<BooleanSelection, 'booleanFilter'> & {\n label: string;\n};\n\ntype FilterOptions<Value> = {\n key: string;\n label: string;\n defaultValue?: Value;\n history?: HistoryMode;\n presentation?: FilterPresentation;\n};\nconst all = { kind: 'all' } as const;\nexport const numberOperatorLabels: Record<NumberOperator, string> = {\n eq: 'Equals',\n ne: 'Does not equal',\n gt: 'Greater than',\n gte: 'At least',\n lt: 'Less than',\n lte: 'At most',\n};\n\n/** Exact numeric predicates; range bounds are inclusive and may be open-ended. */\nexport function numberFilter({\n key,\n label,\n min,\n max,\n defaultValue = all,\n history = 'push',\n presentation,\n}: FilterOptions<NumberSelection> & {\n min?: number;\n max?: number;\n}): NumberFilter {\n invariant(!!key.trim(), 'Numeric filter requires a URL key.');\n invariant(\n (min === undefined || Number.isFinite(min)) &&\n (max === undefined || Number.isFinite(max)) &&\n (min === undefined || max === undefined || min <= max),\n 'Invalid numeric filter bounds.'\n );\n function validNumber(value: unknown): value is number {\n return (\n typeof value === 'number' &&\n Number.isFinite(value) &&\n (min === undefined || value >= min) &&\n (max === undefined || value <= max)\n );\n }\n function valid(value: NumberSelection) {\n if (!value || typeof value !== 'object') return false;\n if (value.kind === 'all') return true;\n if (value.kind === 'comparison')\n return (\n typeof value.operator === 'string' &&\n Object.hasOwn(numberOperatorLabels, value.operator) &&\n validNumber(value.value)\n );\n return (\n value.kind === 'range' &&\n (value.min !== undefined || value.max !== undefined) &&\n (value.min === undefined || validNumber(value.min)) &&\n (value.max === undefined || validNumber(value.max)) &&\n (value.min === undefined ||\n value.max === undefined ||\n value.min <= value.max)\n );\n }\n function encode(value: NumberSelection) {\n return value.kind === 'all'\n ? null\n : value.kind === 'range'\n ? JSON.stringify({ kind: 'range', min: value.min, max: value.max })\n : JSON.stringify({\n kind: 'comparison',\n operator: value.operator,\n value: value.value,\n });\n }\n invariant(valid(defaultValue), `Invalid default for ${label}.`);\n return {\n kind: 'numberFilter',\n presentation,\n label,\n min,\n max,\n defaultValue,\n clearValue: all,\n urlKeys: [key],\n history,\n valid,\n same: (left, right) => encode(left) === encode(right),\n describe(value) {\n return value.kind === 'all'\n ? 'Any'\n : value.kind === 'comparison'\n ? `${numberOperatorLabels[value.operator]} ${value.value}`\n : value.min === undefined\n ? `At most ${value.max}`\n : value.max === undefined\n ? `At least ${value.min}`\n : `${value.min}–${value.max}`;\n },\n read(params) {\n const raw = params.get(key);\n if (raw === null) return defaultValue;\n if (raw.length > 512) return defaultValue;\n try {\n const value = raw === 'all' ? all : JSON.parse(raw);\n return valid(value) ? value : defaultValue;\n } catch {\n return defaultValue;\n }\n },\n write(value) {\n return {\n [key]:\n encode(value) === encode(defaultValue)\n ? null\n : value.kind === 'all'\n ? 'all'\n : encode(value),\n };\n },\n };\n}\n\n/** Boolean predicate with a distinct unrestricted state. */\nexport function booleanFilter({\n key,\n label,\n defaultValue = all,\n history = 'push',\n presentation,\n}: FilterOptions<BooleanSelection>): BooleanFilter {\n invariant(!!key.trim(), 'Boolean filter requires a URL key.');\n function valid(value: BooleanSelection) {\n return (\n !!value &&\n typeof value === 'object' &&\n (value.kind === 'all' ||\n (value.kind === 'is' && typeof value.value === 'boolean'))\n );\n }\n function encode(value: BooleanSelection) {\n return value.kind === 'all' ? 'all' : String(value.value);\n }\n invariant(valid(defaultValue), `Invalid default for ${label}.`);\n return {\n kind: 'booleanFilter',\n presentation,\n label,\n defaultValue,\n clearValue: all,\n urlKeys: [key],\n history,\n valid,\n describe: value =>\n value.kind === 'all' ? 'Any' : value.value ? 'Yes' : 'No',\n same: (left, right) => encode(left) === encode(right),\n read(params) {\n const raw = params.get(key);\n return raw === 'all'\n ? all\n : raw === 'true' || raw === 'false'\n ? { kind: 'is', value: raw === 'true' }\n : defaultValue;\n },\n write(value) {\n return {\n [key]: encode(value) === encode(defaultValue) ? null : encode(value),\n };\n },\n };\n}\n\nexport function parseNumberSelection(\n value: unknown,\n filter: NumberFilter\n): NumberSelection {\n invariant(\n filter.valid(value as NumberSelection),\n `Invalid ${filter.label} selection.`\n );\n return value as NumberSelection;\n}\nexport function parseBooleanSelection(\n value: unknown,\n filter: BooleanFilter\n): BooleanSelection {\n invariant(\n filter.valid(value as BooleanSelection),\n `Invalid ${filter.label} selection.`\n );\n return value as BooleanSelection;\n}\n","import type { DimensionSelectionFilter, DimensionValue } from './dimension.ts';\n\nexport const facetSource = Symbol('data-app.facetSource');\n\n/** A dimension whose options come from an operation. The options follow that\n * operation's own filters, so selecting a period narrows the choices. */\nexport type FacetFilter<\n Value extends DimensionValue = DimensionValue,\n Operation extends string = string,\n> = DimensionSelectionFilter<Value> & {\n readonly optionsSource: 'query';\n readonly [facetSource]: { readonly operation: Operation };\n};\n","import {\n createDimensionFilter,\n type DimensionFilterSettings,\n type DimensionValue,\n} from './dimension.ts';\nimport { facetSource, type FacetFilter } from './facets.ts';\n\ntype FacetFilterOptions<\n Value extends DimensionValue,\n Operation extends string,\n> = DimensionFilterSettings<Value> & {\n /** The registered operation that returns this dimension's options. */\n options: Operation;\n};\n\n/** Options load from `options`, an operation returning `DimensionOption[]`; the\n * client checks that it is registered. Validate selections like any dimension. */\nexport function facetFilter<const Operation extends string>(\n config: FacetFilterOptions<string, Operation> & { valueType: 'string' }\n): FacetFilter<string, Operation>;\nexport function facetFilter<const Operation extends string>(\n config: FacetFilterOptions<number, Operation> & { valueType: 'number' }\n): FacetFilter<number, Operation>;\nexport function facetFilter<\n Value extends DimensionValue,\n const Operation extends string,\n>({\n options: operation,\n ...settings\n}: FacetFilterOptions<Value, Operation>): FacetFilter<Value, Operation> {\n return Object.assign(\n createDimensionFilter<Value>({ ...settings, options: [] }, true),\n {\n optionsSource: 'query' as const,\n [facetSource]: Object.freeze({ operation }),\n }\n );\n}\n","import {\n fromDate,\n parseDate,\n toCalendarDateTime,\n today,\n} from '@internationalized/date';\n\nimport {\n parseDateTimeRange,\n resolveDateTimeRange,\n} from './date-time-range-value.ts';\nimport type {\n DateTimeRange,\n ResolvedDateTimeRange,\n} from './date-time-range.ts';\nimport { invariant } from './invariant.ts';\nimport { fixedUnitMilliseconds } from './time-units.ts';\n\n/** What an operation receives for a date filter: resolved bounds, `from` inclusive and\n * `to` exclusive, and the same window one selected length earlier while the comparison is on. */\nexport type DateTimeRangeInput = {\n range: ResolvedDateTimeRange;\n comparison: ResolvedDateTimeRange | null;\n};\n\nexport type DateTimeRangePolicyOptions = {\n minDate?: string;\n maxDate?: string | (() => string);\n maxRangeDays?: number;\n timeZone: string;\n completeDays?: boolean;\n};\n\n/** A date filter's coverage, duration limit, and reporting time zone. Parsing preserves relative values. */\nexport type DateTimeRangePolicy = ReturnType<typeof createDateTimeRangePolicy>;\n\nexport function createDateTimeRangePolicy({\n minDate,\n maxDate: sourceMaxDate,\n maxRangeDays,\n timeZone,\n completeDays = false,\n}: DateTimeRangePolicyOptions) {\n invariant(\n maxRangeDays === undefined ||\n (Number.isInteger(maxRangeDays) && maxRangeDays > 0),\n 'maxRangeDays must be a positive integer.'\n );\n if (minDate) parseDate(minDate);\n if (typeof sourceMaxDate === 'string') parseDate(sourceMaxDate);\n today(timeZone);\n function reference(now: Date) {\n invariant(Number.isFinite(now.getTime()), 'Invalid reference date.');\n // Resolve symbolic anchors using reporting-zone wall-clock fields, not browser-local fields.\n return toCalendarDateTime(fromDate(now, timeZone)).toDate('UTC');\n }\n function bounds(now = new Date()) {\n const date = reference(now).toISOString().slice(0, 10);\n const latest = parseDate(date)\n .subtract({ days: completeDays ? 1 : 0 })\n .toString();\n const sourceMax =\n typeof sourceMaxDate === 'function' ? sourceMaxDate() : sourceMaxDate;\n if (sourceMax) parseDate(sourceMax);\n return {\n minDate,\n maxDate: sourceMax && sourceMax < latest ? sourceMax : latest,\n maxRangeDays,\n timeZone,\n };\n }\n function resolve(value: unknown, now = new Date()): ResolvedDateTimeRange {\n const range = resolveDateTimeRange(\n parseDateTimeRange(value),\n reference(now)\n );\n const limits = bounds(now);\n invariant(range.from, 'Choose a bounded datetime range.');\n invariant(\n maxRangeDays === undefined ||\n range.to.getTime() - range.from.getTime() <=\n maxRangeDays * fixedUnitMilliseconds.DAY,\n `Choose a range of at most ${maxRangeDays} days.`\n );\n invariant(\n !minDate || range.from >= parseDate(minDate).toDate('UTC'),\n 'Range starts before available source coverage.'\n );\n invariant(\n range.to <= parseDate(limits.maxDate).add({ days: 1 }).toDate('UTC'),\n 'Range ends after available source coverage.'\n );\n return { from: range.from, to: range.to };\n }\n function parse(value: unknown, now = new Date()): DateTimeRange {\n const range = parseDateTimeRange(value);\n resolve(range, now);\n return range;\n }\n /** Hours that have not happened yet hold no data; ending there keeps comparisons equal. */\n function endAtNow(\n range: ResolvedDateTimeRange,\n now = new Date()\n ): ResolvedDateTimeRange {\n const current = reference(now);\n if (range.to <= current) return range;\n return {\n from: range.from,\n to: range.from > current ? range.from : current,\n };\n }\n /** The same window one selected length earlier, ending as far before now as the range does. */\n function comparison(\n value: unknown,\n now = new Date()\n ): ResolvedDateTimeRange | null {\n const selected = resolve(value, now);\n const length = selected.to.getTime() - selected.from.getTime();\n const range = endAtNow(selected, now);\n const previous = {\n from: new Date(range.from.getTime() - length),\n to: new Date(range.to.getTime() - length),\n };\n try {\n return resolve(previous, now);\n } catch {\n return null;\n }\n }\n return {\n timeZone,\n bounds,\n /** Validate coverage and duration while preserving symbolic relative bounds. */\n parse,\n /** Resolve to UTC-rebased bounds using reporting-zone wall-clock fields, then validate policy. */\n resolve,\n /** Return the comparison window, or null when source coverage excludes it. */\n comparison,\n /** End a resolved range at the reference time when it runs past it. */\n endAtNow,\n /** Resolve both periods against one reference instant, ending the range at now. */\n request(\n value: unknown,\n compare = false,\n now = new Date()\n ): DateTimeRangeInput {\n const range = endAtNow(resolve(value, now), now);\n const previous = compare ? comparison(value, now) : null;\n invariant(\n !compare || previous,\n 'Comparison is outside available source coverage.'\n );\n return { range, comparison: previous };\n },\n };\n}\n","import type {\n AppFilter,\n FilterPresentation,\n HistoryMode,\n} from './app-filters.ts';\nimport {\n createDateTimeRangePolicy,\n type DateTimeRangeInput,\n type DateTimeRangePolicy,\n} from './date-time-range-contract.ts';\nimport { parseDateTimeRangeInput } from './date-time-range-parser.ts';\nimport {\n parseDateTimeRange,\n serializeDateTimeRange,\n formatDateTimeRange,\n} from './date-time-range-value.ts';\nimport type { DateTimeRange } from './date-time-range.ts';\nimport { invariant } from './invariant.ts';\n\n/** A picker suggestion. Text ranges use the same natural-language parser as typed input. */\nexport type DateTimeRangePreset = {\n /** Menu label, also shown when this preset matches the selected range. */\n label: string;\n range: DateTimeRange | string;\n /** Optional compact badge, for example \"15m\". */\n shortcut?: string;\n};\n\n/** Monitoring offers minute/hour windows; analytics offers longer periods and to-date windows. Spread either menu to add custom presets. */\nexport const dateTimeRangePresets: {\n readonly monitoring: readonly DateTimeRangePreset[];\n readonly analytics: readonly DateTimeRangePreset[];\n} = {\n monitoring: [\n { label: 'Past 5 minutes', range: '5m', shortcut: '5m' },\n { label: 'Past 15 minutes', range: '15m', shortcut: '15m' },\n { label: 'Past hour', range: '1h', shortcut: '1h' },\n { label: 'Past 4 hours', range: '4h', shortcut: '4h' },\n { label: 'Past 24 hours', range: '1d', shortcut: '1d' },\n ],\n analytics: [\n { label: 'Past 7 days', range: '7d', shortcut: '7d' },\n { label: 'Past 30 days', range: '30d', shortcut: '30d' },\n { label: 'Past 90 days', range: '90d', shortcut: '90d' },\n { label: 'Month to date', range: 'MTD', shortcut: 'MTD' },\n { label: 'Year to date', range: 'YTD', shortcut: 'YTD' },\n { label: 'Past year', range: '1y', shortcut: '1y' },\n ],\n};\n\n/** Offer the previous-period comparison, with its toggle starting off or on. */\nexport type DateTimeRangeComparison = 'off' | 'on';\n\nexport type DateTimeRangeFilterOptions<\n Comparison extends DateTimeRangeComparison | undefined = undefined,\n> = {\n key: string;\n label?: string;\n /** Range text such as \"7d\" stays relative; `{ from, to }` is absolute. */\n defaultValue: DateTimeRange | string;\n /** Reporting zone for relative ranges, calendar days, and labels. Defaults to UTC. */\n timeZone?: string;\n /** Longest selectable range. */\n maxRangeDays?: number;\n /** First date with data, as YYYY-MM-DD. */\n minDate?: string;\n /** Last date with data, as YYYY-MM-DD. */\n maxDate?: string | (() => string);\n /** End coverage yesterday, for sources that load whole days. */\n completeDays?: boolean;\n /** Offer the previous-period comparison. Omit for none. */\n comparison?: Comparison;\n /** Suggestions in display order. Omit for defaults; [] retains calendar and text entry.\n * Invalid or over-limit suggestions are omitted; typed input is not restricted to the menu.\n */\n presets?: readonly DateTimeRangePreset[];\n history?: HistoryMode;\n presentation?: FilterPresentation;\n};\n\n/** The picker's URL state: the selected range, relative or absolute, and the comparison toggle. */\nexport type DateTimeRangeSelection = {\n range: DateTimeRange;\n comparison?: 'previous';\n};\n\n/** Sent from the browser: the resolved input plus the selection and reference time it came from. */\nexport type DateTimeRangeRequest = DateTimeRangeInput & {\n selection: DateTimeRangeSelection;\n reference: string;\n};\n\nexport type DateTimeRangeFilter<Comparable extends boolean = boolean> =\n AppFilter<DateTimeRangeSelection, 'dateTimeRange'> & {\n /** Whether readers can turn on the previous-period comparison. */\n comparable: Comparable;\n policy: DateTimeRangePolicy;\n maxRangeDays?: number;\n presets?: readonly DateTimeRangePreset[];\n /** Resolve a selection against one reference time. */\n request: (\n selection: DateTimeRangeSelection,\n now?: Date\n ) => DateTimeRangeRequest;\n /** Validate untrusted input against coverage and return what the operation receives. */\n parseInput: (value: unknown) => DateTimeRangeInput;\n previous: (\n selection: DateTimeRangeSelection\n ) => DateTimeRangeInput['comparison'];\n };\n\n/** One declaration drives the picker, URL state, and the input of operations that list it.\n * Operations receive `{ range, comparison }`: `from` inclusive, `to` exclusive.\n */\nexport function dateTimeRangeFilter<\n Comparison extends DateTimeRangeComparison | undefined = undefined,\n>(\n options: DateTimeRangeFilterOptions<Comparison>\n): DateTimeRangeFilter<undefined extends Comparison ? false : true> {\n const {\n key,\n label = 'Date range',\n defaultValue,\n timeZone = 'UTC',\n maxRangeDays,\n minDate,\n maxDate,\n completeDays,\n comparison,\n presets,\n history = 'push',\n presentation,\n } = options;\n const policy = createDateTimeRangePolicy({\n minDate,\n maxDate,\n maxRangeDays,\n timeZone,\n completeDays,\n });\n const comparable = comparison !== undefined;\n const compareKey = key === 'period' ? 'compare' : `${key}-compare`;\n function parseRange(value: unknown, now?: Date) {\n return policy.parse(parseDateTimeRange(value, { maxRangeDays }), now);\n }\n const parsed =\n typeof defaultValue === 'string'\n ? parseDateTimeRangeInput(defaultValue)\n : null;\n invariant(!parsed || parsed.ok, `Invalid default range for ${key}.`);\n const initial: DateTimeRangeSelection = {\n range: parseRange(parsed?.ok ? parsed.range : defaultValue),\n ...(comparison === 'on' ? { comparison: 'previous' as const } : {}),\n };\n function sameRange(left: DateTimeRange, right: DateTimeRange) {\n return serializeDateTimeRange(left) === serializeDateTimeRange(right);\n }\n function parseSelection(\n value: unknown,\n now = new Date()\n ): DateTimeRangeSelection {\n invariant(\n !!value && typeof value === 'object' && !Array.isArray(value),\n 'Choose a datetime range.'\n );\n const selection = value as Record<string, unknown>;\n invariant(\n Object.keys(selection).every(\n name => name === 'range' || name === 'comparison'\n ) &&\n (selection.comparison === undefined ||\n (comparable && selection.comparison === 'previous')),\n 'Invalid comparison selection.'\n );\n const range = parseRange(selection.range, now);\n invariant(\n !selection.comparison || policy.comparison(range, now),\n 'Comparison is outside available source coverage.'\n );\n return {\n range,\n ...(selection.comparison ? { comparison: 'previous' as const } : {}),\n };\n }\n function request(\n value: DateTimeRangeSelection,\n now = new Date()\n ): DateTimeRangeRequest {\n const selection = parseSelection(value, now);\n return {\n ...policy.request(\n selection.range,\n selection.comparison === 'previous',\n now\n ),\n selection,\n reference: now.toISOString(),\n };\n }\n function same(left: DateTimeRangeSelection, right: DateTimeRangeSelection) {\n return (\n left.comparison === right.comparison && sameRange(left.range, right.range)\n );\n }\n function valid(value: DateTimeRangeSelection) {\n try {\n parseSelection(value);\n return true;\n } catch {\n return false;\n }\n }\n invariant(\n valid(initial),\n `Date filter ${key} has a default outside its source coverage.`\n );\n /** The URL records the comparison only when it differs from the default. */\n function comparisonParam(selection: DateTimeRangeSelection) {\n if (!comparable) return {};\n const state = selection.comparison ?? 'off';\n return {\n [compareKey]: state === (initial.comparison ?? 'off') ? null : state,\n };\n }\n function readRange(params: URLSearchParams) {\n const text = params.get(key);\n if (!text || text.length > 8192) return initial.range;\n try {\n return parseRange(JSON.parse(text));\n } catch {\n return initial.range;\n }\n }\n return {\n kind: 'dateTimeRange',\n label,\n presentation,\n history,\n urlKeys: comparable ? [key, compareKey] : [key],\n defaultValue: initial,\n clearValue: initial,\n comparable: comparable as undefined extends Comparison ? false : true,\n policy,\n maxRangeDays,\n presets,\n request,\n parseInput(value) {\n invariant(\n !!value && typeof value === 'object' && !Array.isArray(value),\n 'Invalid datetime request.'\n );\n const supplied = value as Record<string, unknown>;\n invariant(\n Object.keys(supplied).every(name =>\n ['range', 'comparison', 'selection', 'reference'].includes(name)\n ),\n 'Invalid datetime request.'\n );\n // The server checks the range against current coverage; browser selection fields are ignored.\n const range = policy.endAtNow(policy.resolve(parseRange(supplied.range)));\n if (supplied.comparison === null || supplied.comparison === undefined)\n return { range, comparison: null };\n invariant(comparable, `${label} has no comparison.`);\n // The browser shifts by the selected length, which the server does not see:\n // accept an earlier window of equal length within coverage.\n const comparison = policy.resolve(\n parseDateTimeRange(supplied.comparison)\n );\n invariant(\n comparison.to <= range.from &&\n comparison.to.getTime() - comparison.from.getTime() ===\n range.to.getTime() - range.from.getTime(),\n 'Comparison must be an earlier range of equal length.'\n );\n return { range, comparison };\n },\n previous(selection) {\n return comparable ? policy.comparison(selection.range) : null;\n },\n valid,\n same,\n describe: selection =>\n `${formatDateTimeRange(selection.range)}${selection.comparison ? ' vs previous period' : ''}`,\n read(params) {\n const range = readRange(params);\n if (!comparable) return { range };\n const state = params.get(compareKey);\n const compared: DateTimeRangeSelection = {\n range,\n comparison: 'previous',\n };\n const on =\n state === 'previous' || (state === null && !!initial.comparison);\n return on && valid(compared) ? compared : { range };\n },\n write(value) {\n const selection = parseSelection(value);\n return {\n [key]: sameRange(selection.range, initial.range)\n ? null\n : serializeDateTimeRange(selection.range),\n ...comparisonParam(selection),\n };\n },\n };\n}\n","/** App-owned URL state shared by controls, frame adapters, and host navigation. */\nexport type AppLocation = { search: string; hash: string };\nexport type HistoryMode = 'push' | 'replace';\nexport type NavigationUpdate = AppLocation & {\n mode: HistoryMode;\n title?: string;\n};\n\nexport function validLocation(value: unknown): value is AppLocation {\n if (!value || typeof value !== 'object') return false;\n const message = value as { search?: unknown; hash?: unknown };\n return (\n typeof message.search === 'string' &&\n message.search.length <= 16_384 &&\n (message.search === '' || message.search.startsWith('?')) &&\n typeof message.hash === 'string' &&\n message.hash.length <= 4096 &&\n (message.hash === '' || message.hash.startsWith('#'))\n );\n}\n","import {\n type TransportResponse,\n type QueryResult,\n type OperationContracts,\n type DataQueryInput,\n type DataQueryBody,\n type OutputOf,\n} from './operation-types.ts';\nimport { isQueryParameters, type QueryParameters } from './queries.ts';\nexport {\n type OperationContracts,\n type DataQueryInput,\n type DataQueryBody,\n} from './operation-types.ts';\nimport { validLocation, type NavigationUpdate } from './navigation.ts';\nexport { type NavigationUpdate } from './navigation.ts';\n\nexport type MessageContext = { signal: AbortSignal };\nexport type RoutedMessage = { route: string; payload: unknown };\nexport type MessageDispatcher = (\n message: unknown,\n context: MessageContext\n) => Promise<unknown>;\nexport type MessageTransport = (\n message: RoutedMessage,\n signal?: AbortSignal\n) => Promise<unknown>;\nexport type MessageRoute<Input, Output> = {\n input: (value: unknown) => Input;\n output: (value: unknown, input: Input) => Output;\n};\nexport type MessageRoutes = Record<\n string,\n {\n input: (value: unknown) => unknown;\n output: (value: unknown, input: never) => unknown;\n }\n>;\nexport type MessageInput<Route extends MessageRoutes[string]> = ReturnType<\n Route['input']\n>;\nexport type MessageHandlers<Routes extends MessageRoutes> = {\n [Name in keyof Routes]: (\n payload: MessageInput<Routes[Name]>,\n context: MessageContext\n ) =>\n | ReturnType<Routes[Name]['output']>\n | Promise<ReturnType<Routes[Name]['output']>>;\n};\n\n// A bootstrap and its app may bundle independent copies in the same window.\nconst errorBrand = Symbol.for('@altertable/data-app/MessageRoutingError');\n\n/** Only these deliberate, public failures cross the message boundary. Other errors stay private. */\nexport class MessageRoutingError extends Error {\n readonly [errorBrand] = true;\n\n static override [Symbol.hasInstance](value: unknown): boolean {\n return (\n value instanceof Error &&\n (value as { [errorBrand]?: unknown })[errorBrand] === true\n );\n }\n\n constructor(\n public readonly code: string,\n message: string,\n public readonly requestId?: string,\n /** `cause` stays with the host for logs; the bridge sends only code, message, and request ID. */\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'MessageRoutingError';\n }\n}\n\nexport function defineMessageRoute<Input, Output>(\n route: MessageRoute<Input, Output>\n): MessageRoute<Input, Output> {\n return route;\n}\n\n/** Contracts are shared; handlers are supplied by the host and never belong in the app bundle. */\nexport function createMessageRouter<const Routes extends MessageRoutes>(\n routes: Routes,\n handlers: MessageHandlers<NoInfer<Routes>>\n) {\n const registered = new Map(\n Object.entries(routes).map(([name, contract]) => {\n const handler = handlers[name];\n if (!name || name.length > 256 || typeof handler !== 'function')\n throw new Error(\n 'Each message route requires a handler and a bounded name.'\n );\n\n return [name, { contract, handler }] as const;\n })\n );\n\n async function dispatch(\n value: unknown,\n context: MessageContext\n ): Promise<unknown> {\n if (\n !value ||\n typeof value !== 'object' ||\n typeof (value as RoutedMessage).route !== 'string'\n )\n throw new MessageRoutingError(\n 'invalid_message',\n 'Invalid routed message.'\n );\n const message = value as RoutedMessage;\n const entry = registered.get(message.route);\n if (!entry)\n throw new MessageRoutingError('unknown_route', 'Unknown message route.');\n let payload: unknown;\n try {\n payload = entry.contract.input(message.payload);\n } catch (error) {\n if (error instanceof MessageRoutingError) throw error;\n throw new MessageRoutingError(\n 'invalid_payload',\n 'Invalid message payload.'\n );\n }\n context.signal.throwIfAborted();\n let result: unknown;\n try {\n result = await entry.handler(payload as never, context);\n } catch (error) {\n if (context.signal.aborted) throw context.signal.reason;\n if (error instanceof MessageRoutingError) throw error;\n throw new MessageRoutingError(\n 'request_failed',\n 'The message request failed. Retry the request.'\n );\n }\n context.signal.throwIfAborted();\n try {\n return entry.contract.output(result, payload as never);\n } catch (error) {\n if (error instanceof MessageRoutingError) throw error;\n throw new MessageRoutingError(\n 'invalid_response',\n 'Invalid message response.'\n );\n }\n }\n\n return { dispatch };\n}\n\nexport type DataQueryRoute<Operations extends OperationContracts> =\n MessageRoute<DataQueryInput<Operations>, TransportResponse> & {\n operations: Operations | undefined;\n };\nexport type MessageOutput<Route extends MessageRoutes[string], Input> =\n Route extends DataQueryRoute<infer Operations>\n ? Input extends { operation: infer Name extends keyof Operations }\n ? TransportResponse<DataQueryBody<OutputOf<Operations[Name]>>>\n : never\n : ReturnType<Route['output']>;\n\n/** Omit contracts only in generic hosts such as the CLI shell, where Bun validates operations. */\nexport function defineDataQueryRoute<\n Operations extends OperationContracts = OperationContracts,\n>(operations?: Operations): DataQueryRoute<Operations> {\n return {\n operations,\n input(value) {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid query.');\n const request = value as { operation?: unknown; input?: unknown };\n if (\n typeof request.operation !== 'string' ||\n !request.operation ||\n request.operation.length > 256 ||\n request.operation.includes('/')\n )\n throw new Error('Invalid operation.');\n const operation =\n operations && Object.hasOwn(operations, request.operation)\n ? operations[request.operation]\n : undefined;\n if (operations && !operation) throw new Error('Unknown operation.');\n\n return {\n operation: request.operation,\n input: operation ? operation.input(request.input) : request.input,\n } as DataQueryInput<Operations>;\n },\n output(value) {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid data response.');\n const response = value as TransportResponse;\n if (\n !Number.isInteger(response.status) ||\n response.status < 100 ||\n response.status > 599 ||\n !response.body ||\n typeof response.body !== 'object' ||\n Array.isArray(response.body)\n )\n throw new Error('Invalid data response.');\n const body = response.body as DataQueryBody<unknown> & {\n error?: { code?: unknown; message?: unknown; requestId?: unknown };\n };\n if (response.status < 200 || response.status >= 300) {\n const failure = body.error;\n throw new MessageRoutingError(\n typeof failure?.code === 'string' ? failure.code : 'request_failed',\n typeof failure?.message === 'string'\n ? failure.message\n : 'Could not load data.',\n typeof failure?.requestId === 'string' ? failure.requestId : undefined\n );\n }\n if (\n !('data' in body) ||\n typeof body.requestId !== 'string' ||\n typeof body.queriedAt !== 'string' ||\n !Array.isArray(body.queryIds) ||\n !body.queryIds.every(id => typeof id === 'string')\n )\n throw new Error('Invalid data envelope.');\n if (\n body.queries !== undefined &&\n (!Array.isArray(body.queries) ||\n !body.queries.every(\n query =>\n query &&\n typeof query === 'object' &&\n typeof query.name === 'string' &&\n typeof query.statement === 'string' &&\n (query.params === undefined || isQueryParameters(query.params)) &&\n (query.queryId === undefined || typeof query.queryId === 'string')\n ))\n )\n throw new Error('Invalid query evidence.');\n return { status: response.status, body };\n },\n };\n}\n\nexport const navigationUpdateRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): NavigationUpdate {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid navigation.');\n const input = value as NavigationUpdate;\n if (\n !validLocation(input) ||\n (input.mode !== 'push' && input.mode !== 'replace') ||\n (input.title !== undefined &&\n (typeof input.title !== 'string' || input.title.length > 512))\n )\n throw new Error('Invalid navigation.');\n\n return {\n search: input.search,\n hash: input.hash,\n mode: input.mode,\n ...(input.title === undefined ? {} : { title: input.title }),\n };\n },\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid navigation response.');\n\n return null;\n },\n});\nexport type SqlQueryInput = {\n statement: string;\n limit: number;\n params?: QueryParameters;\n};\n\n/** SQL delivery for browser-owned operations. Hosts must enforce backend access and resource limits. */\nexport const sqlQueryRoute = defineMessageRoute({\n input(value: unknown): SqlQueryInput {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid SQL query.');\n const query = value as {\n statement?: unknown;\n limit?: unknown;\n params?: unknown;\n };\n if (\n typeof query.statement !== 'string' ||\n !query.statement.trim() ||\n typeof query.limit !== 'number' ||\n !Number.isSafeInteger(query.limit) ||\n query.limit < 1 ||\n (query.params !== undefined && !isQueryParameters(query.params))\n )\n throw new Error('Invalid SQL query.');\n\n return {\n statement: query.statement,\n limit: query.limit,\n ...(query.params === undefined\n ? {}\n : { params: query.params as QueryParameters }),\n };\n },\n output(value: unknown, input: SqlQueryInput): QueryResult {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid query result.');\n const result = value as QueryResult;\n if (\n !Array.isArray(result.columns) ||\n !result.columns.every(\n column =>\n column &&\n typeof column.name === 'string' &&\n (column.type === undefined || typeof column.type === 'string')\n ) ||\n !Array.isArray(result.rows) ||\n result.rows.length > input.limit ||\n !result.rows.every(\n row => Array.isArray(row) && row.length === result.columns.length\n ) ||\n (result.queryId !== undefined && typeof result.queryId !== 'string')\n )\n throw new Error('Invalid query result.');\n\n return {\n columns: result.columns,\n rows: result.rows,\n ...(result.queryId === undefined ? {} : { queryId: result.queryId }),\n };\n },\n});\n\nexport const dataAppRoutes = {\n 'data:query': /* @__PURE__ */ defineDataQueryRoute(),\n 'navigation:update': navigationUpdateRoute,\n};\n","import { defineMessageRoute } from './messages.ts';\n\nexport type DataAppAnnotationDraft = {\n id: string;\n target: {\n id: string;\n label: string;\n kind: 'widget' | 'element' | 'app';\n text: string;\n queryNames: string[];\n glossaryIds: string[];\n };\n context: {\n search: string;\n hash: string;\n displayedInput?: unknown;\n /** Normalized position within the selected target, stable across scrolling/resizing. */\n anchor?: { x: number; y: number };\n cursor?: { x: number; y: number };\n /** Normalized custom selection rectangle within the iframe document. */\n region?: { x: number; y: number; width: number; height: number };\n screenshot?: {\n mimeType: 'image/png';\n dataUrl: string;\n width: number;\n height: number;\n };\n view?: string;\n viewport: { width: number; height: number };\n rect: { x: number; y: number; width: number; height: number };\n };\n comment: string;\n};\n\nexport type DataAppAnnotationPresentation = {\n enabled: boolean;\n /** When provided, the host owns the mode and renders the annotation trigger. */\n active?: boolean;\n pinsVisible?: boolean;\n showHint?: boolean;\n readOnly?: boolean;\n targets?: {\n id: string;\n targetId: string;\n number: number;\n comment?: string;\n anchor?: { x: number; y: number };\n region?: { x: number; y: number; width: number; height: number };\n }[];\n selectedAnnotationId?: string;\n selectedTargetId?: string;\n selectionId?: string;\n /** Confirmed host click outside the iframe; occurredAt is epoch milliseconds. */\n dismissal?: { id: string; occurredAt: number };\n};\n\nfunction object(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new Error('Invalid annotation.');\n return value as Record<string, unknown>;\n}\nfunction text(value: unknown, limit: number, required = false): string {\n if (\n typeof value !== 'string' ||\n value.length > limit ||\n (required && !value.trim())\n )\n throw new Error('Invalid annotation text.');\n return value;\n}\nfunction names(value: unknown): string[] {\n if (!Array.isArray(value) || value.length > 20)\n throw new Error('Invalid annotation references.');\n return value.map(name => text(name, 128, true));\n}\nfunction number(value: unknown, positive = false): number {\n if (\n typeof value !== 'number' ||\n !Number.isFinite(value) ||\n Math.abs(value) > 1_000_000 ||\n (positive && value < 0)\n )\n throw new Error('Invalid annotation geometry.');\n return value;\n}\n\n/** Reconstruct at the boundary; discard extra fields and bound the entire JSON payload. */\nexport function parseDataAppAnnotationDraft(\n value: unknown\n): DataAppAnnotationDraft {\n const input = object(value);\n const target = object(input.target);\n const context = object(input.context);\n const viewport = object(context.viewport);\n const rect = object(context.rect);\n if (\n target.kind !== 'widget' &&\n target.kind !== 'element' &&\n target.kind !== 'app'\n )\n throw new Error('Invalid annotation target.');\n let screenshot: DataAppAnnotationDraft['context']['screenshot'];\n if (context.screenshot !== undefined) {\n const image = object(context.screenshot);\n const dataUrl = text(image.dataUrl, 350_000, true);\n if (\n image.mimeType !== 'image/png' ||\n !/^data:image\\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(dataUrl)\n )\n throw new Error('Invalid annotation screenshot.');\n const width = number(image.width, true);\n const height = number(image.height, true);\n if (\n !Number.isInteger(width) ||\n !Number.isInteger(height) ||\n width < 1 ||\n height < 1 ||\n width > 1024 ||\n height > 1024\n )\n throw new Error('Invalid screenshot dimensions.');\n const encoded = dataUrl.slice('data:image/png;base64,'.length);\n if (\n encoded.length % 4 !== 0 ||\n (encoded.length / 4) * 3 -\n (encoded.endsWith('==') ? 2 : encoded.endsWith('=') ? 1 : 0) >\n 262_144\n )\n throw new Error('Screenshot is too large.');\n const header = atob(encoded.slice(0, 44));\n if (header.length < 24 || header.slice(12, 16) !== 'IHDR')\n throw new Error('Invalid PNG header.');\n const bytes = Uint8Array.from(header, character => character.charCodeAt(0));\n const dimensions = new DataView(bytes.buffer);\n if (\n dimensions.getUint32(16) !== width ||\n dimensions.getUint32(20) !== height\n )\n throw new Error('Screenshot dimensions do not match the image.');\n screenshot = { mimeType: 'image/png', dataUrl, width, height };\n }\n let anchor: { x: number; y: number } | undefined;\n if (context.anchor !== undefined) {\n const point = object(context.anchor);\n const x = number(point.x, true);\n const y = number(point.y, true);\n if (x > 1 || y > 1) throw new Error('Invalid annotation anchor.');\n anchor = { x, y };\n }\n let cursor: { x: number; y: number } | undefined;\n if (context.cursor !== undefined) {\n const point = object(context.cursor);\n cursor = { x: number(point.x), y: number(point.y) };\n }\n let region: DataAppAnnotationDraft['context']['region'];\n if (context.region !== undefined) {\n const area = object(context.region);\n region = {\n x: number(area.x, true),\n y: number(area.y, true),\n width: number(area.width, true),\n height: number(area.height, true),\n };\n if (\n target.kind !== 'app' ||\n region.width <= 0 ||\n region.height <= 0 ||\n region.x + region.width > 1.000001 ||\n region.y + region.height > 1.000001\n )\n throw new Error('Invalid annotation selection.');\n }\n const draft: DataAppAnnotationDraft = {\n id: text(input.id, 128, true),\n target: {\n id: text(target.id, 128, true),\n label: text(target.label, 256, true),\n kind: target.kind,\n text: text(target.text, 1024),\n queryNames: names(target.queryNames),\n glossaryIds: names(target.glossaryIds),\n },\n context: {\n ...(anchor ? { anchor } : {}),\n ...(region ? { region } : {}),\n ...(cursor ? { cursor } : {}),\n ...(screenshot ? { screenshot } : {}),\n search: text(context.search, 2048),\n hash: text(context.hash, 1024),\n viewport: {\n width: number(viewport.width, true),\n height: number(viewport.height, true),\n },\n rect: {\n x: number(rect.x),\n y: number(rect.y),\n width: number(rect.width, true),\n height: number(rect.height, true),\n },\n ...(context.view === undefined ? {} : { view: text(context.view, 128) }),\n ...(context.displayedInput === undefined\n ? {}\n : { displayedInput: context.displayedInput }),\n },\n comment: text(input.comment, 2000, true).trim(),\n };\n const json = JSON.stringify({\n ...draft,\n context: { ...draft.context, screenshot: undefined },\n });\n if (new TextEncoder().encode(json).byteLength > 12_000)\n throw new Error('Annotation is too large.');\n return JSON.parse(JSON.stringify(draft)) as DataAppAnnotationDraft;\n}\n\nexport const annotationDraftRoute = /* @__PURE__ */ defineMessageRoute({\n input: parseDataAppAnnotationDraft,\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation response.');\n return null;\n },\n});\n\nexport const annotationEditorStateRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): { hasUnsavedChanges: boolean } {\n const input = object(value);\n if (typeof input.hasUnsavedChanges !== 'boolean')\n throw new Error('Invalid annotation editor state.');\n return { hasUnsavedChanges: input.hasUnsavedChanges };\n },\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation response.');\n return null;\n },\n});\n\n/** Request host-owned batch submission without transferring ownership of drafts. */\nexport const annotationSendRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation send request.');\n return null;\n },\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation response.');\n return null;\n },\n});\n\nexport const annotationUpdateRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): { id: string; comment: string } {\n const input = object(value);\n return {\n id: text(input.id, 128, true),\n comment: text(input.comment, 2000, true).trim(),\n };\n },\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation response.');\n return null;\n },\n});\n\n/** A controlled shell acknowledges local exits (for example Escape). */\nexport const annotationModeRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): { active: boolean } {\n const input = object(value);\n if (typeof input.active !== 'boolean')\n throw new Error('Invalid annotation mode.');\n return { active: input.active };\n },\n output(value: unknown): null {\n if (value !== null) throw new Error('Invalid annotation response.');\n return null;\n },\n});\n\nexport function isAnnotationPresentation(\n value: unknown\n): value is DataAppAnnotationPresentation {\n if (!value || typeof value !== 'object') return false;\n const input = value as DataAppAnnotationPresentation;\n return (\n typeof input.enabled === 'boolean' &&\n (input.active === undefined || typeof input.active === 'boolean') &&\n (input.pinsVisible === undefined ||\n typeof input.pinsVisible === 'boolean') &&\n (input.showHint === undefined || typeof input.showHint === 'boolean') &&\n (input.readOnly === undefined || typeof input.readOnly === 'boolean') &&\n (input.selectedAnnotationId === undefined ||\n (typeof input.selectedAnnotationId === 'string' &&\n input.selectedAnnotationId.length <= 128)) &&\n (input.dismissal === undefined ||\n (input.dismissal !== null &&\n typeof input.dismissal === 'object' &&\n typeof input.dismissal.id === 'string' &&\n input.dismissal.id.length <= 128 &&\n typeof input.dismissal.occurredAt === 'number' &&\n Number.isFinite(input.dismissal.occurredAt))) &&\n (input.selectionId === undefined ||\n (typeof input.selectionId === 'string' &&\n input.selectionId.length <= 128)) &&\n (input.selectedTargetId === undefined ||\n (typeof input.selectedTargetId === 'string' &&\n input.selectedTargetId.length <= 128)) &&\n (input.targets === undefined ||\n (Array.isArray(input.targets) &&\n input.targets.length <= 50 &&\n input.targets.every(\n target =>\n target &&\n typeof target.id === 'string' &&\n target.id.length <= 128 &&\n typeof target.targetId === 'string' &&\n target.targetId.length <= 128 &&\n Number.isSafeInteger(target.number) &&\n target.number > 0 &&\n (target.anchor === undefined ||\n (typeof target.anchor.x === 'number' &&\n Number.isFinite(target.anchor.x) &&\n target.anchor.x >= 0 &&\n target.anchor.x <= 1 &&\n typeof target.anchor.y === 'number' &&\n Number.isFinite(target.anchor.y) &&\n target.anchor.y >= 0 &&\n target.anchor.y <= 1)) &&\n (target.region === undefined ||\n (typeof target.region === 'object' &&\n target.region !== null &&\n ['x', 'y', 'width', 'height'].every(key => {\n const value = (target.region as Record<string, unknown>)[key];\n return (\n typeof value === 'number' &&\n Number.isFinite(value) &&\n value >= 0 &&\n value <= 1\n );\n }) &&\n target.region.width > 0 &&\n target.region.height > 0 &&\n target.region.x + target.region.width <= 1.000001 &&\n target.region.y + target.region.height <= 1.000001)) &&\n (target.comment === undefined ||\n (typeof target.comment === 'string' &&\n target.comment.length <= 2000))\n )))\n );\n}\n","import { defineMessageRoute } from './messages.ts';\n\n/** Absolute HTTPS destinations only; URLs must not contain embedded credentials. */\nexport function parseExternalUrl(value: unknown): string {\n if (\n typeof value !== 'string' ||\n value.length > 8192 ||\n /[\\s\\\\\\p{Cc}\\p{Cf}]/u.test(value)\n )\n throw new Error('Expected an absolute HTTPS URL.');\n const url = new URL(value);\n if (\n !/^https:\\/\\//i.test(value) ||\n url.protocol !== 'https:' ||\n url.username ||\n url.password\n )\n throw new Error('Expected an HTTPS URL without credentials.');\n return url.href;\n}\n\nexport type ExternalLinkTarget = 'tab' | 'window';\nexport type ExternalLinkModifiers = {\n shiftKey: boolean;\n metaKey: boolean;\n ctrlKey: boolean;\n};\nexport type OpenExternalLink = { url: string } & (\n | { target?: ExternalLinkTarget }\n | { target: 'event'; keys: ExternalLinkModifiers }\n);\nexport type ExternalLinkResult = 'opened' | 'cancelled' | 'ignored';\n\n/** Shift takes precedence over Ctrl/Cmd; an unmodified event requests no navigation. */\nexport function resolveExternalLinkTarget(\n input: OpenExternalLink\n): ExternalLinkTarget | null {\n if (input.target !== 'event') return input.target ?? 'tab';\n return input.keys.shiftKey\n ? 'window'\n : input.keys.metaKey || input.keys.ctrlKey\n ? 'tab'\n : null;\n}\n\n/** Opt-in host route. Validation does not replace the host's destination policy. */\nexport const openExternalLinkRoute = /* @__PURE__ */ defineMessageRoute({\n input(value: unknown): OpenExternalLink {\n if (!value || typeof value !== 'object')\n throw new Error('Invalid external link.');\n const input = value as Record<string, unknown>;\n const url = parseExternalUrl(input.url);\n if (input.target === undefined) return { url };\n if (input.target === 'tab' || input.target === 'window')\n return { url, target: input.target };\n if (\n input.target === 'event' &&\n input.keys &&\n typeof input.keys === 'object'\n ) {\n const keys = input.keys as Record<string, unknown>;\n if (\n typeof keys.shiftKey === 'boolean' &&\n typeof keys.metaKey === 'boolean' &&\n typeof keys.ctrlKey === 'boolean'\n )\n return {\n url,\n target: 'event',\n keys: {\n shiftKey: keys.shiftKey,\n metaKey: keys.metaKey,\n ctrlKey: keys.ctrlKey,\n },\n };\n }\n throw new Error('Invalid external navigation target.');\n },\n output(value: unknown): ExternalLinkResult {\n if (value !== 'opened' && value !== 'cancelled' && value !== 'ignored')\n throw new Error('Invalid external link response.');\n return value;\n },\n});\n","/** Operation authoring and delivery contracts; portable across runtimes. */\nexport {\n parseTrue,\n parseCount,\n parseLabel,\n defineQueryNames,\n defineOperation,\n connectionCheck,\n dimensionFilter,\n parseDimensionSelection,\n parseFacetOptions,\n dimensionPredicate,\n numberFilter,\n booleanFilter,\n parseNumberSelection,\n parseBooleanSelection,\n searchFilter,\n choiceFilter,\n displayChoice,\n multiChoiceFilter,\n facetFilter,\n} from '../authoring/contract.ts';\nexport type {\n ReportingPeriod,\n DateTimeRangeInput,\n DateTimeRangePolicy,\n RegisteredQuery,\n ConnectionOperation,\n QueryDefinitions,\n QueryParameters,\n QueryParameterValue,\n QueryParameter,\n QueryValueType,\n QueryField,\n QueryProjections,\n QueryRow,\n QueryResult,\n DisclosedQuery,\n DataOperation,\n DimensionSelection,\n DimensionMember,\n DimensionOption,\n DimensionFilter,\n DimensionFilterOptions,\n NumberSelection,\n NumberOperator,\n NumberFilter,\n BooleanSelection,\n BooleanFilter,\n AppFilter,\n FilterValues,\n SearchFilter,\n ChoiceFilter,\n ChoiceOption,\n MultiChoiceFilter,\n FilterCollection,\n FilterPresentation,\n FacetFilter,\n FilterInput,\n DefinedOperation,\n FilterOperationDefinition,\n InputOperationDefinition,\n WithFilterInput,\n} from '../authoring/contract.ts';\nexport type {\n Lakehouse,\n OperationContext,\n DataOperations,\n} from './operation-types.ts';\n\nconst sourceErrorBrand = Symbol.for('@altertable/data-app/DataSourceError');\n\nexport class DataSourceError extends Error {\n readonly [sourceErrorBrand] = true;\n queryName?: string;\n\n static override [Symbol.hasInstance](value: unknown): boolean {\n return (\n value instanceof Error &&\n (value as { [sourceErrorBrand]?: unknown })[sourceErrorBrand] === true\n );\n }\n\n constructor(\n public readonly reason:\n | 'unauthorized'\n | 'forbidden'\n | 'rate_limited'\n | 'query_rejected'\n | 'unavailable',\n public readonly status?: number,\n /** `cause` stays on the server or host for logs; responses carry only the reason. */\n options?: ErrorOptions\n ) {\n super(`Data source ${reason}${status ? ` (${status})` : ''}.`, options);\n this.name = 'DataSourceError';\n }\n}\n\nexport {\n createMessageRouter,\n defineMessageRoute,\n defineDataQueryRoute,\n MessageRoutingError,\n dataAppRoutes,\n navigationUpdateRoute,\n sqlQueryRoute,\n} from './messages.ts';\nexport type {\n MessageContext,\n RoutedMessage,\n MessageDispatcher,\n MessageTransport,\n MessageRoute,\n MessageRoutes,\n MessageInput,\n MessageHandlers,\n MessageOutput,\n OperationContracts,\n DataQueryInput,\n DataQueryBody,\n DataQueryRoute,\n NavigationUpdate,\n SqlQueryInput,\n} from './messages.ts';\nexport type { TransportResponse } from './bridge.ts';\n\nexport {\n annotationDraftRoute,\n annotationModeRoute,\n annotationEditorStateRoute,\n annotationSendRoute,\n annotationUpdateRoute,\n parseDataAppAnnotationDraft,\n} from './annotations.ts';\nexport type {\n DataAppAnnotationDraft,\n DataAppAnnotationPresentation,\n} from './annotations.ts';\n\nexport {\n parseExternalUrl,\n resolveExternalLinkTarget,\n type ExternalLinkTarget,\n type ExternalLinkModifiers,\n openExternalLinkRoute,\n type OpenExternalLink,\n type ExternalLinkResult,\n} from './external-link.ts';\nexport {\n dateTimeRangeFilter,\n dateTimeRangePresets,\n type DateTimeRangePreset,\n type DateTimeRangeFilter,\n type DateTimeRangeFilterOptions,\n type DateTimeRangeComparison,\n type DateTimeRangeSelection,\n} from '../authoring/contract.ts';\nexport {\n parseDateTimeRange,\n serializeDateTimeRange,\n resolveDateTimeRange,\n formatDateTimeRange,\n formatDateTimeBound,\n parseDateTimeBound,\n} from '../authoring/contract.ts';\nexport type {\n DateTimeRange,\n ResolvedDateTimeRange,\n AbsoluteOrRelativeDateTime,\n RelativeDateTime,\n} from '../authoring/contract.ts';\n\nexport { dateTimeRangeSql } from '../authoring/contract.ts';\n"],"mappings":";;;;AA6BA,MAAM,MAAM,EAAE,MAAM,MAAM;AAC1B,MAAa,u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A;CAjBlB,CAAU,oBAAoB;CAC9B;CAEA,QAAiB,OAAO,aAAa,OAAyB;EAC5D,OACE,iBAAiB,SAChB,MAA2C,sBAAsB;CAEtE;CAEA,YACE,QAMA,QAEA,SACA;EACA,MAAM,eAAe,SAAS,SAAS,KAAK,OAAO,KAAK,GAAG,IAAI,OAAO;EAVtD,KAAA,SAAA;EAMA,KAAA,SAAA;EAKhB,KAAK,OAAO;CACd;AACF"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { CalendarDateTime } from "@internationalized/date";
|
|
2
2
|
import * as chrono from "chrono-node";
|
|
3
|
+
//#region src/core/invariant.ts
|
|
4
|
+
/** Assert an author or data contract while preserving a useful failure message. */
|
|
5
|
+
function invariant(condition, message) {
|
|
6
|
+
if (!condition) throw new Error(`Invariant failed: ${message}`);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
3
9
|
//#region src/core/date-time-range-parser.ts
|
|
4
10
|
const RANGE_SEPARATOR_PATTERN = / ?(?:-|–|—| to ) ?/i;
|
|
5
11
|
const RELATIVE_UNIT_BY_PATTERN = new Map([
|
|
@@ -443,12 +449,6 @@ function parseDateTimeRangeInput(input, options) {
|
|
|
443
449
|
return failure("unrecognized", normalizedInput);
|
|
444
450
|
}
|
|
445
451
|
//#endregion
|
|
446
|
-
//#region src/core/invariant.ts
|
|
447
|
-
/** Assert an author or data contract while preserving a useful failure message. */
|
|
448
|
-
function invariant(condition, message) {
|
|
449
|
-
if (!condition) throw new Error(`Invariant failed: ${message}`);
|
|
450
|
-
}
|
|
451
|
-
//#endregion
|
|
452
452
|
//#region src/core/time-units.ts
|
|
453
453
|
const second = 1e3;
|
|
454
454
|
const minute = 60 * second;
|
|
@@ -643,151 +643,6 @@ function parseDateTimeBound(text) {
|
|
|
643
643
|
return since.range.from;
|
|
644
644
|
}
|
|
645
645
|
//#endregion
|
|
646
|
-
|
|
647
|
-
const calendarDate = /^\d{4}-\d{2}-\d{2}$/;
|
|
648
|
-
const timestamp = /^(\d{4}-\d{2}-\d{2})T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,9})?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
|
|
649
|
-
function missing(options) {
|
|
650
|
-
return options.missing ?? "—";
|
|
651
|
-
}
|
|
652
|
-
function parseCalendarDate(value) {
|
|
653
|
-
if (!calendarDate.test(value)) return null;
|
|
654
|
-
const date = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
|
|
655
|
-
return Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value ? null : date;
|
|
656
|
-
}
|
|
657
|
-
function formatter(locale, options) {
|
|
658
|
-
try {
|
|
659
|
-
return new Intl.DateTimeFormat(locale, options);
|
|
660
|
-
} catch {
|
|
661
|
-
return null;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
/** Format an ISO calendar date as a date, never as a browser-local instant. */
|
|
665
|
-
function formatDate(value, options = {}) {
|
|
666
|
-
if (value === null || value === void 0) return missing(options);
|
|
667
|
-
const date = parseCalendarDate(value);
|
|
668
|
-
const format = formatter(options.locale ?? "en-US", {
|
|
669
|
-
dateStyle: "medium",
|
|
670
|
-
timeZone: "UTC"
|
|
671
|
-
});
|
|
672
|
-
return date && format ? format.format(date) : missing(options);
|
|
673
|
-
}
|
|
674
|
-
/** Parse only unambiguous instants. String values must include `Z` or an explicit offset. */
|
|
675
|
-
function parseDateTime(value) {
|
|
676
|
-
if (value === null || value === void 0) return null;
|
|
677
|
-
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value;
|
|
678
|
-
if (typeof value === "number") {
|
|
679
|
-
const date = new Date(value);
|
|
680
|
-
return Number.isNaN(date.getTime()) ? null : date;
|
|
681
|
-
}
|
|
682
|
-
const match = timestamp.exec(value);
|
|
683
|
-
if (!match || !parseCalendarDate(match[1])) return null;
|
|
684
|
-
const date = new Date(value);
|
|
685
|
-
return Number.isNaN(date.getTime()) ? null : date;
|
|
686
|
-
}
|
|
687
|
-
/** Format an instant in an explicit reporting zone. Defaults use UTC and 24-hour minutes. */
|
|
688
|
-
function formatDateTime(value, options = {}) {
|
|
689
|
-
const date = parseDateTime(value);
|
|
690
|
-
const format = formatter(options.locale ?? "en-US", {
|
|
691
|
-
dateStyle: "medium",
|
|
692
|
-
timeStyle: options.precision === "second" ? "medium" : "short",
|
|
693
|
-
hourCycle: "h23",
|
|
694
|
-
timeZone: options.timeZone ?? "UTC"
|
|
695
|
-
});
|
|
696
|
-
return date && format ? format.format(date) : missing(options);
|
|
697
|
-
}
|
|
698
|
-
/** Format an instant's time for intraday chart axes using the same zone and precision policy. */
|
|
699
|
-
function formatTime(value, options = {}) {
|
|
700
|
-
const date = parseDateTime(value);
|
|
701
|
-
const format = formatter(options.locale ?? "en-US", {
|
|
702
|
-
hour: "2-digit",
|
|
703
|
-
minute: "2-digit",
|
|
704
|
-
...options.precision === "second" ? { second: "2-digit" } : {},
|
|
705
|
-
hourCycle: "h23",
|
|
706
|
-
timeZone: options.timeZone ?? "UTC"
|
|
707
|
-
});
|
|
708
|
-
return date && format ? format.format(date) : missing(options);
|
|
709
|
-
}
|
|
710
|
-
//#endregion
|
|
711
|
-
//#region src/core/format.ts
|
|
712
|
-
/** Compact, unambiguous calendar dates for labels and request status. */
|
|
713
|
-
function formatDateRange({ start, end }, options = {}) {
|
|
714
|
-
const first = parseDateTime(`${start}T00:00:00Z`);
|
|
715
|
-
const last = parseDateTime(`${end}T00:00:00Z`);
|
|
716
|
-
if (!first || !last || start > end) return options.missing ?? "—";
|
|
717
|
-
if (options.locale && options.locale !== "en-US") try {
|
|
718
|
-
return new Intl.DateTimeFormat(options.locale, {
|
|
719
|
-
dateStyle: "medium",
|
|
720
|
-
timeZone: "UTC"
|
|
721
|
-
}).formatRange(first, last);
|
|
722
|
-
} catch {
|
|
723
|
-
return options.missing ?? "—";
|
|
724
|
-
}
|
|
725
|
-
function format(date, options) {
|
|
726
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
727
|
-
...options,
|
|
728
|
-
timeZone: "UTC"
|
|
729
|
-
}).format(date);
|
|
730
|
-
}
|
|
731
|
-
function formatFullDate(date) {
|
|
732
|
-
return format(date, {
|
|
733
|
-
month: "short",
|
|
734
|
-
day: "numeric",
|
|
735
|
-
year: "numeric"
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
if (start === end) return formatFullDate(first);
|
|
739
|
-
if (first.getUTCFullYear() !== last.getUTCFullYear()) return `${formatFullDate(first)}–${formatFullDate(last)}`;
|
|
740
|
-
const firstMonth = format(first, { month: "short" });
|
|
741
|
-
const lastMonth = format(last, { month: "short" });
|
|
742
|
-
const firstDay = first.getUTCDate();
|
|
743
|
-
const lastDay = last.getUTCDate();
|
|
744
|
-
return firstMonth === lastMonth ? `${firstMonth} ${firstDay}–${lastDay}, ${last.getUTCFullYear()}` : `${firstMonth} ${firstDay}–${lastMonth} ${lastDay}, ${last.getUTCFullYear()}`;
|
|
745
|
-
}
|
|
746
|
-
function formatMetric(value, format) {
|
|
747
|
-
if (format.kind === "count") return formatCount(value, format);
|
|
748
|
-
if (format.kind === "ratio") return formatPercent(value, format);
|
|
749
|
-
return formatNumber(value, {
|
|
750
|
-
style: "currency",
|
|
751
|
-
currency: format.currency,
|
|
752
|
-
locale: format.locale
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
/** Missing and non-finite values use the `missing` label; negative zero renders as zero. */
|
|
756
|
-
function formatNumber(value, options = {}) {
|
|
757
|
-
const { locale = "en-US", missing = "—", ...numberOptions } = options;
|
|
758
|
-
return value === null || value === void 0 || !Number.isFinite(value) ? missing : new Intl.NumberFormat(locale, numberOptions).format(Object.is(value, -0) ? 0 : value);
|
|
759
|
-
}
|
|
760
|
-
/** Negative and fractional counts render as missing. Compact notation is opt-in. */
|
|
761
|
-
function formatCount(value, options = {}) {
|
|
762
|
-
const { compact = false, ...common } = options;
|
|
763
|
-
if (value !== null && value !== void 0 && (!Number.isInteger(value) || value < 0)) return common.missing ?? "—";
|
|
764
|
-
return formatNumber(value, {
|
|
765
|
-
...common,
|
|
766
|
-
notation: compact ? "compact" : "standard",
|
|
767
|
-
maximumFractionDigits: compact ? 1 : 0
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
const pluralRules = new Intl.PluralRules();
|
|
771
|
-
function pluralize(count, singular, plural = `${singular}s`) {
|
|
772
|
-
return pluralRules.select(count) === "one" ? singular : plural;
|
|
773
|
-
}
|
|
774
|
-
/** Accepts a ratio (0.116), not a percentage (11.6). */
|
|
775
|
-
function formatPercent(ratio, options = {}) {
|
|
776
|
-
if (ratio === null || ratio === void 0 || !Number.isFinite(ratio)) return options.missing ?? "—";
|
|
777
|
-
const digits = options.maximumFractionDigits ?? (Math.abs(ratio) < .01 ? 2 : 1);
|
|
778
|
-
const percentOptions = {
|
|
779
|
-
locale: options.locale,
|
|
780
|
-
style: "percent",
|
|
781
|
-
maximumFractionDigits: digits
|
|
782
|
-
};
|
|
783
|
-
const smallestVisibleRatio = 10 ** -digits / 100;
|
|
784
|
-
if (ratio !== 0 && Math.round(Math.abs(ratio) / smallestVisibleRatio) === 0) {
|
|
785
|
-
const boundary = formatNumber(smallestVisibleRatio, percentOptions);
|
|
786
|
-
return ratio > 0 ? `<${boundary}` : `>−${boundary}`;
|
|
787
|
-
}
|
|
788
|
-
return formatNumber(ratio, percentOptions);
|
|
789
|
-
}
|
|
790
|
-
//#endregion
|
|
791
|
-
export { fixedUnitMilliseconds as _, formatPercent as a, formatDateTime as c, formatDateTimeBound as d, formatDateTimeRange as f, serializeDateTimeRange as g, resolveDateTimeRange as h, formatNumber as i, formatTime as l, parseDateTimeRange as m, formatDateRange as n, pluralize as o, parseDateTimeBound as p, formatMetric as r, formatDate as s, formatCount as t, parseDateTime as u, invariant as v, parseDateTimeRangeInput as y };
|
|
646
|
+
export { resolveDateTimeRange as a, parseDateTimeRangeInput as c, parseDateTimeRange as i, invariant as l, formatDateTimeRange as n, serializeDateTimeRange as o, parseDateTimeBound as r, fixedUnitMilliseconds as s, formatDateTimeBound as t };
|
|
792
647
|
|
|
793
|
-
//# sourceMappingURL=
|
|
648
|
+
//# sourceMappingURL=date-time-range-value-CnlTr1U1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time-range-value-CnlTr1U1.js","names":[],"sources":["../../src/core/invariant.ts","../../src/core/date-time-range-parser.ts","../../src/core/time-units.ts","../../src/core/date-time-range-value.ts"],"sourcesContent":["/** Assert an author or data contract while preserving a useful failure message. */\nexport function invariant(\n condition: unknown,\n message: string\n): asserts condition {\n if (!condition) throw new Error(`Invariant failed: ${message}`);\n}\n","import * as chrono from 'chrono-node';\n\nimport type {\n DateTimeRange,\n RelativeDateTime,\n RelativeUnit,\n} from './date-time-range.ts';\n\n// Adapted from the frontend parser. Absolute fields are encoded as UTC,\n// while relative anchors remain unevaluated for the backend.\n\nexport type DateTimeRangeParseFailureReason =\n | 'empty'\n | 'unrecognized'\n | 'invalid-range'\n | 'ambiguous';\n\nexport type DateTimeRangeParserOptions = {\n /** UTC-encoded reference fields for omitted dates/years. Defaults to the current UTC date/time. */\n now?: Date;\n};\n\nexport type ParseDateTimeRangeResult =\n | {\n ok: true;\n range: DateTimeRange;\n normalizedInput: string;\n parser:\n | 'relative'\n | 'calendar-preset'\n | 'calendar-range'\n | 'unix'\n | 'chrono';\n }\n | {\n ok: false;\n reason: DateTimeRangeParseFailureReason;\n normalizedInput: string;\n };\n\ntype ParseSuccess = Extract<ParseDateTimeRangeResult, { ok: true }>;\n\n// Input whitespace is normalized to single spaces before matching.\nconst RANGE_SEPARATOR_PATTERN = / ?(?:-|–|—| to ) ?/i;\n\nconst RELATIVE_UNIT_PATTERNS: ReadonlyArray<{\n unit: RelativeUnit;\n patterns: readonly string[];\n}> = [\n {\n unit: 'SECOND',\n patterns: ['seconds', 'second', 'secs', 'sec', 's'],\n },\n {\n unit: 'MINUTE',\n patterns: ['minutes', 'minute', 'mins', 'min', 'mn', 'm'],\n },\n {\n unit: 'HOUR',\n patterns: ['hours', 'hour', 'hrs', 'hr', 'h'],\n },\n {\n unit: 'DAY',\n patterns: ['days', 'day', 'd'],\n },\n {\n unit: 'WEEK',\n patterns: ['weeks', 'week', 'wks', 'wk', 'w'],\n },\n {\n unit: 'MONTH',\n patterns: ['months', 'month', 'mos', 'mo', 'mon'],\n },\n {\n unit: 'YEAR',\n patterns: ['years', 'year', 'yrs', 'yr', 'y'],\n },\n];\n\nconst RELATIVE_UNIT_BY_PATTERN = new Map(\n RELATIVE_UNIT_PATTERNS.flatMap(({ unit, patterns }) =>\n patterns.map(pattern => [pattern, unit] as const)\n )\n);\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nconst RELATIVE_UNIT_PATTERN = [...RELATIVE_UNIT_BY_PATTERN.keys()]\n .sort((left, right) => right.length - left.length)\n .map(escapeRegex)\n .join('|');\n\nconst SLIDING_RELATIVE_PATTERN = new RegExp(\n `^(?:last|past)\\\\s+(?:(\\\\d+)\\\\s*)?(${RELATIVE_UNIT_PATTERN})$`,\n 'i'\n);\n\nconst AGO_RELATIVE_PATTERN = new RegExp(\n `^(\\\\d+)\\\\s*(${RELATIVE_UNIT_PATTERN})\\\\s+ago$`,\n 'i'\n);\n\nconst BARE_RELATIVE_PATTERN = new RegExp(\n `^(\\\\d+)\\\\s*(${RELATIVE_UNIT_PATTERN})$`,\n 'i'\n);\n\nconst SINCE_PREFIX_PATTERN = /^(?:since|from) (.+)$/i;\n\nconst UNIX_TIMESTAMP_PATTERN = /^\\d+$/;\n\nconst NOW_KEYWORDS = new Set(['now', 'today']);\n\nfunction normalizeInput(input: string): string {\n return input.trim().replace(/\\s+/g, ' ');\n}\n\nfunction getParserContext(options?: DateTimeRangeParserOptions) {\n const now = options?.now ?? new Date();\n return { now, reference: { instant: now, timezone: 'UTC' } };\n}\n\n/** Construct wall-clock fields without interpreting the runtime timezone. */\nfunction utcDate(\n year: number,\n month: number,\n day: number,\n hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0\n): Date {\n const date = new Date(0);\n date.setUTCFullYear(year, month, day);\n date.setUTCHours(hour, minute, second, millisecond);\n return date;\n}\n\nfunction parseRelativeUnit(rawUnit: string): RelativeUnit | null {\n return RELATIVE_UNIT_BY_PATTERN.get(rawUnit.toLowerCase()) ?? null;\n}\n\nfunction relativeFromNowOffset(\n amount: number,\n unit: RelativeUnit\n): RelativeDateTime {\n return {\n anchor: 'RELATIVE_ANCHOR_NOW',\n offset: [{ amount: -amount, unit }],\n };\n}\n\nfunction success(\n range: DateTimeRange,\n normalizedInput: string,\n parser: ParseSuccess['parser']\n): ParseSuccess {\n return { ok: true, range, normalizedInput, parser };\n}\n\nfunction failure(\n reason: DateTimeRangeParseFailureReason,\n normalizedInput: string\n): ParseDateTimeRangeResult {\n return { ok: false, reason, normalizedInput };\n}\n\nfunction parseUnixTimestamp(raw: string): Date | null {\n const trimmed = raw.trim();\n if (!UNIX_TIMESTAMP_PATTERN.test(trimmed)) {\n return null;\n }\n\n const value = Number(trimmed);\n if (!Number.isFinite(value)) {\n return null;\n }\n\n const date = trimmed.length <= 10 ? new Date(value * 1_000) : new Date(value);\n return Number.isFinite(date.getTime()) ? date : null;\n}\n\nfunction dateFromChronoComponents(\n components: chrono.ParsedComponents\n): Date | null {\n const year = components.get('year');\n const month = components.get('month');\n const day = components.get('day');\n const hour = components.get('hour');\n const minute = components.get('minute');\n const second = components.get('second');\n const millisecond = components.get('millisecond');\n\n if (year === null || month === null || day === null) {\n return null;\n }\n\n return utcDate(\n year,\n month - 1,\n day,\n hour ?? 0,\n minute ?? 0,\n second ?? 0,\n millisecond ?? 0\n );\n}\n\n// Chrono validates calendar fields using local Date construction, which rejects\n// wall-clock times in the host's DST gap. Validate these parse-local components\n// as UTC fields instead, without changing Chrono's global parser or prototypes.\nconst wallClockParser = chrono.casual.clone();\nwallClockParser.refiners = wallClockParser.refiners.map(refiner => ({\n refine(context, results) {\n for (const result of results) {\n for (const components of [result.start, result.end]) {\n if (!components) continue;\n components.isValidDate = () => {\n const date = dateFromChronoComponents(components);\n return (\n date !== null &&\n Number.isFinite(date.getTime()) &&\n date.getUTCFullYear() === components.get('year') &&\n date.getUTCMonth() + 1 === components.get('month') &&\n date.getUTCDate() === components.get('day') &&\n date.getUTCHours() === (components.get('hour') ?? 0) &&\n date.getUTCMinutes() === (components.get('minute') ?? 0)\n );\n };\n }\n }\n return refiner.refine(context, results);\n },\n}));\n\nfunction parseAbsoluteResult(\n text: string,\n reference: chrono.ParsingReference\n): chrono.ParsedResult | null | 'ambiguous' {\n const trimmed = text.trim();\n if (!trimmed) {\n return null;\n }\n\n const results = wallClockParser.parse(trimmed, reference, {\n forwardDate: false,\n });\n if (results.length === 0) {\n return null;\n }\n\n const parsed = results[0];\n if (!parsed) {\n return null;\n }\n\n if (parsed.index !== 0 || parsed.text.length !== trimmed.length) {\n return null;\n }\n\n if (results.length > 1) {\n const firstStart = parsed.start.date().getTime();\n const hasDistinctInterpretation = results.some(\n result => result.start.date().getTime() !== firstStart\n );\n if (hasDistinctInterpretation) {\n return 'ambiguous';\n }\n }\n\n return parsed;\n}\n\nfunction parseAbsoluteDateTime(\n text: string,\n reference: chrono.ParsingReference,\n end = false\n): Date | null | 'ambiguous' {\n const parsed = parseAbsoluteResult(text, reference);\n if (!parsed || parsed === 'ambiguous') {\n return parsed;\n }\n\n if (parsed.end) return null;\n return absoluteBoundary(parsed.start, end);\n}\n\nfunction absoluteBoundary(\n components: chrono.ParsedComponents,\n end = false\n): Date | null {\n const date = dateFromChronoComponents(components);\n if (date && !components.isCertain('hour')) {\n date.setUTCHours(0, 0, 0, 0);\n if (end) date.setUTCDate(date.getUTCDate() + 1);\n }\n return date;\n}\n\nfunction isNowKeyword(text: string): boolean {\n return NOW_KEYWORDS.has(text.trim().toLowerCase());\n}\n\nconst CALENDAR_MONTH_PATTERN =\n /^(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)(?:\\s+(\\d{4}))?$/i;\n\nconst CALENDAR_MONTHS = [\n 'jan',\n 'feb',\n 'mar',\n 'apr',\n 'may',\n 'jun',\n 'jul',\n 'aug',\n 'sep',\n 'oct',\n 'nov',\n 'dec',\n];\n\nfunction parseCalendarPeriod(text: string) {\n if (/^\\d{4}$/.test(text)) {\n return { year: Number(text), month: 0, months: 12 };\n }\n\n const match = text.match(CALENDAR_MONTH_PATTERN);\n if (!match?.[1]) {\n return null;\n }\n\n return {\n year: match[2] ? Number(match[2]) : null,\n month: CALENDAR_MONTHS.indexOf(match[1].slice(0, 3).toLowerCase()),\n months: 1,\n };\n}\n\nfunction tryParseCalendarRange(\n normalized: string,\n now: Date\n): ParseDateTimeRangeResult | null {\n const parts = normalized.split(RANGE_SEPARATOR_PATTERN);\n if (parts.length > 2) {\n return null;\n }\n\n const first = parseCalendarPeriod(parts[0] ?? '');\n const last = parts.length === 1 ? first : parseCalendarPeriod(parts[1] ?? '');\n if (!first || !last || first.months !== last.months) {\n return null;\n }\n\n const currentYear = now.getUTCFullYear();\n const fromYear = first.year ?? last.year ?? currentYear;\n const toYear = last.year ?? first.year ?? currentYear;\n const from = utcDate(fromYear, first.month, 1);\n const to = utcDate(toYear, last.month + last.months, 1);\n\n if (from.getTime() >= to.getTime()) {\n return failure('invalid-range', normalized);\n }\n\n return success({ from, to }, normalized, 'calendar-range');\n}\n\nfunction tryParseUnixRange(\n normalized: string\n): ParseSuccess | ParseDateTimeRangeResult | null {\n const parts = normalized.split(RANGE_SEPARATOR_PATTERN);\n if (parts.length !== 2) {\n return null;\n }\n\n const fromPart = parts.at(0);\n const toPart = parts.at(1);\n if (!fromPart || !toPart) {\n return null;\n }\n\n const from = parseUnixTimestamp(fromPart);\n if (from && isNowKeyword(toPart)) {\n return success({ from, to: null }, normalized, 'unix');\n }\n\n const to = parseUnixTimestamp(toPart);\n if (!from || !to) {\n return null;\n }\n\n if (from.getTime() > to.getTime()) {\n return failure('invalid-range', normalized);\n }\n\n return success({ from, to }, normalized, 'unix');\n}\n\nfunction tryParseSlidingRelative(normalized: string): ParseSuccess | null {\n const match = normalized.match(SLIDING_RELATIVE_PATTERN);\n if (!match) {\n return null;\n }\n\n const amount = match[1] ? Number(match[1]) : 1;\n const unit = parseRelativeUnit(match[2] ?? '');\n if (!Number.isSafeInteger(amount) || amount <= 0 || !unit) {\n return null;\n }\n\n return success(\n {\n from: relativeFromNowOffset(amount, unit),\n to: null,\n },\n normalized,\n 'relative'\n );\n}\n\nfunction tryParseCalendarPreset(normalized: string): ParseSuccess | null {\n const lower = normalized.toLowerCase();\n\n if (lower === 'today') {\n return success(\n {\n from: {\n anchor: 'RELATIVE_ANCHOR_START_OF_TODAY',\n offset: [],\n },\n to: null,\n },\n normalized,\n 'calendar-preset'\n );\n }\n\n if (lower === 'yesterday') {\n return success(\n {\n from: {\n anchor: 'RELATIVE_ANCHOR_START_OF_YESTERDAY',\n offset: [],\n },\n to: {\n anchor: 'RELATIVE_ANCHOR_START_OF_TODAY',\n offset: [],\n },\n },\n normalized,\n 'calendar-preset'\n );\n }\n\n if (lower === 'week to date' || lower === 'wtd') {\n return success(\n {\n from: {\n anchor: 'RELATIVE_ANCHOR_START_OF_WEEK',\n offset: [],\n },\n to: null,\n },\n normalized,\n 'calendar-preset'\n );\n }\n\n if (lower === 'month to date' || lower === 'mtd') {\n return success(\n {\n from: {\n anchor: 'RELATIVE_ANCHOR_START_OF_MONTH',\n offset: [],\n },\n to: null,\n },\n normalized,\n 'calendar-preset'\n );\n }\n\n if (lower === 'year to date' || lower === 'ytd') {\n return success(\n {\n from: {\n anchor: 'RELATIVE_ANCHOR_START_OF_YEAR',\n offset: [],\n },\n to: null,\n },\n normalized,\n 'calendar-preset'\n );\n }\n\n return null;\n}\n\nfunction tryParseAgoRelative(normalized: string): ParseSuccess | null {\n const match = normalized.match(AGO_RELATIVE_PATTERN);\n if (!match) {\n return null;\n }\n\n const amount = Number(match[1]);\n const unit = parseRelativeUnit(match[2] ?? '');\n if (!Number.isSafeInteger(amount) || amount <= 0 || !unit) {\n return null;\n }\n\n return success(\n {\n from: relativeFromNowOffset(amount, unit),\n to: null,\n },\n normalized,\n 'relative'\n );\n}\n\nfunction tryParseBareRelative(normalized: string): ParseSuccess | null {\n const match = normalized.match(BARE_RELATIVE_PATTERN);\n if (!match) {\n return null;\n }\n\n const amount = Number(match[1]);\n const unit = parseRelativeUnit(match[2] ?? '');\n if (!Number.isSafeInteger(amount) || amount <= 0 || !unit) {\n return null;\n }\n\n return success(\n {\n from: relativeFromNowOffset(amount, unit),\n to: null,\n },\n normalized,\n 'relative'\n );\n}\n\nfunction tryParseSinceRelative(\n normalized: string\n): ParseSuccess | ParseDateTimeRangeResult | null {\n const match = normalized.match(SINCE_PREFIX_PATTERN);\n if (!match) {\n return null;\n }\n\n const remainder = match[1]?.trim();\n if (!remainder) {\n return failure('unrecognized', normalized);\n }\n\n const agoMatch = remainder.match(AGO_RELATIVE_PATTERN);\n if (agoMatch) {\n const amount = Number(agoMatch[1]);\n const unit = parseRelativeUnit(agoMatch[2] ?? '');\n if (!Number.isSafeInteger(amount) || amount <= 0 || !unit) {\n return failure('unrecognized', normalized);\n }\n\n return success(\n {\n from: relativeFromNowOffset(amount, unit),\n to: null,\n },\n normalized,\n 'relative'\n );\n }\n\n return null;\n}\n\nfunction tryParseSinceAbsolute(\n normalized: string,\n reference: chrono.ParsingReference\n): ParseSuccess | ParseDateTimeRangeResult | null {\n const match = normalized.match(SINCE_PREFIX_PATTERN);\n if (!match) {\n return null;\n }\n\n const remainder = match[1]?.trim();\n if (!remainder) {\n return failure('unrecognized', normalized);\n }\n\n const range = tryParseAbsoluteRange(remainder, reference);\n if (range) return { ...range, normalizedInput: normalized };\n const absolute = parseAbsoluteDateTime(remainder, reference);\n if (absolute === 'ambiguous') {\n return failure('ambiguous', normalized);\n }\n if (!absolute) {\n return failure('unrecognized', normalized);\n }\n\n return success({ from: absolute, to: null }, normalized, 'chrono');\n}\n\nfunction tryParseAbsoluteRange(\n normalized: string,\n reference: chrono.ParsingReference\n): ParseSuccess | ParseDateTimeRangeResult | null {\n const parts = normalized.split(RANGE_SEPARATOR_PATTERN);\n if (parts.length !== 2) {\n return null;\n }\n\n const fromPart = parts.at(0)?.trim();\n const toPart = parts.at(1)?.trim();\n if (!fromPart || !toPart) {\n return null;\n }\n\n if (isNowKeyword(toPart)) {\n const from = parseAbsoluteDateTime(fromPart, reference);\n if (from === 'ambiguous') {\n return failure('ambiguous', normalized);\n }\n if (!from) {\n return null;\n }\n\n return success({ from, to: null }, normalized, 'chrono');\n }\n\n // Parse both ends together so an explicit year is shared with the other bound.\n const paired = parseAbsoluteResult(normalized, reference);\n if (paired === 'ambiguous') return failure('ambiguous', normalized);\n if (paired?.end) {\n const from = absoluteBoundary(paired.start);\n const to = absoluteBoundary(paired.end, true);\n if (!from || !to) return null;\n if (from.getTime() >= to.getTime())\n return failure('invalid-range', normalized);\n return success({ from, to }, normalized, 'chrono');\n }\n const from = parseAbsoluteDateTime(fromPart, reference);\n if (from === 'ambiguous') {\n return failure('ambiguous', normalized);\n }\n\n const to = parseAbsoluteDateTime(toPart, reference, true);\n if (to === 'ambiguous') {\n return failure('ambiguous', normalized);\n }\n\n if (!from || !to) {\n return null;\n }\n\n if (from.getTime() > to.getTime()) {\n return failure('invalid-range', normalized);\n }\n\n return success({ from, to }, normalized, 'chrono');\n}\n\nfunction tryParseAbsoluteDay(\n normalized: string,\n reference: chrono.ParsingReference\n): ParseSuccess | ParseDateTimeRangeResult | null {\n const parsed = parseAbsoluteResult(normalized, reference);\n if (parsed === 'ambiguous') {\n return failure('ambiguous', normalized);\n }\n if (\n !parsed ||\n parsed.end ||\n !parsed.start.isCertain('month') ||\n !parsed.start.isCertain('day') ||\n parsed.start.isCertain('hour')\n ) {\n return null;\n }\n\n const year = parsed.start.get('year');\n const month = parsed.start.get('month');\n const day = parsed.start.get('day');\n if (year === null || month === null || day === null) {\n return null;\n }\n\n const from = utcDate(year, month - 1, day);\n const to = utcDate(year, month - 1, day + 1);\n\n return success({ from, to }, normalized, 'chrono');\n}\n\nexport function parseDateTimeRangeInput(\n input: string,\n options?: DateTimeRangeParserOptions\n): ParseDateTimeRangeResult {\n const normalizedInput = normalizeInput(input);\n\n if (!normalizedInput) {\n return failure('empty', normalizedInput);\n }\n\n const { reference, now } = getParserContext(options);\n\n if (!Number.isFinite(now.getTime()))\n return failure('invalid-range', normalizedInput);\n\n const attempts: Array<() => ParseSuccess | ParseDateTimeRangeResult | null> =\n [\n () => tryParseCalendarRange(normalizedInput, now),\n () => tryParseUnixRange(normalizedInput),\n () => tryParseSlidingRelative(normalizedInput),\n () => tryParseCalendarPreset(normalizedInput),\n () => tryParseAgoRelative(normalizedInput),\n () => tryParseBareRelative(normalizedInput),\n () => tryParseSinceRelative(normalizedInput),\n () => tryParseSinceAbsolute(normalizedInput, reference),\n () => tryParseAbsoluteRange(normalizedInput, reference),\n () => tryParseAbsoluteDay(normalizedInput, reference),\n ];\n\n for (const attempt of attempts) {\n const result = attempt();\n if (!result) {\n continue;\n }\n\n if (!result.ok) {\n return result;\n }\n\n return result;\n }\n\n return failure('unrecognized', normalizedInput);\n}\n","import type { RelativeUnit } from './date-time-range.ts';\n\nconst second = 1_000;\nconst minute = 60 * second;\nconst hour = 60 * minute;\nconst day = 24 * hour;\n\n/** Fixed durations in UTC-rebased arithmetic; months and years are calendar-dependent. */\nexport const fixedUnitMilliseconds: Partial<Record<RelativeUnit, number>> &\n Record<'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK', number> = {\n SECOND: second,\n MINUTE: minute,\n HOUR: hour,\n DAY: day,\n WEEK: 7 * day,\n};\n","import { CalendarDateTime } from '@internationalized/date';\n\nimport { parseDateTimeRangeInput } from './date-time-range-parser.ts';\nimport type {\n AbsoluteOrRelativeDateTime,\n DateTimeRange,\n RelativeAnchor,\n RelativeDateTime,\n RelativeUnit,\n} from './date-time-range.ts';\nimport { invariant } from './invariant.ts';\nimport { fixedUnitMilliseconds } from './time-units.ts';\n\nconst anchors: Record<RelativeAnchor, string> = {\n RELATIVE_ANCHOR_NOW: 'Now',\n RELATIVE_ANCHOR_START_OF_TODAY: 'Start of today',\n RELATIVE_ANCHOR_START_OF_YESTERDAY: 'Start of yesterday',\n RELATIVE_ANCHOR_START_OF_TOMORROW: 'Start of tomorrow',\n RELATIVE_ANCHOR_START_OF_WEEK: 'Start of week',\n RELATIVE_ANCHOR_START_OF_MONTH: 'Start of month',\n RELATIVE_ANCHOR_START_OF_YEAR: 'Start of year',\n};\nconst units: Record<RelativeUnit, string> = {\n SECOND: 's',\n MINUTE: 'm',\n HOUR: 'h',\n DAY: 'd',\n WEEK: 'w',\n MONTH: 'mo',\n YEAR: 'y',\n};\n\n/** Validate and restore UTC-rebased dates from JSON, without resolving relative bounds. */\nexport function parseDateTimeRange(\n value: unknown,\n { maxRangeDays }: { maxRangeDays?: number } = {}\n): DateTimeRange {\n invariant(\n !!value && typeof value === 'object' && !Array.isArray(value),\n 'Choose a datetime range.'\n );\n const record = value as Record<string, unknown>;\n invariant(\n Object.keys(record).every(key => key === 'from' || key === 'to'),\n 'Unknown datetime range field.'\n );\n function bound(raw: unknown): AbsoluteOrRelativeDateTime | null {\n if (raw == null) return null;\n if (raw instanceof Date || typeof raw === 'string') {\n const date = new Date(raw);\n invariant(\n Number.isFinite(date.getTime()) &&\n (raw instanceof Date || date.toISOString() === raw),\n 'Absolute bounds must be UTC ISO dates.'\n );\n return date;\n }\n invariant(\n typeof raw === 'object' && !Array.isArray(raw),\n 'Invalid datetime bound.'\n );\n const r = raw as Record<string, unknown>;\n invariant(\n Object.keys(r).every(key => key === 'anchor' || key === 'offset') &&\n typeof r.anchor === 'string' &&\n Object.hasOwn(anchors, r.anchor),\n 'Invalid relative anchor.'\n );\n invariant(\n Array.isArray(r.offset) && r.offset.length <= 16,\n 'Use at most 16 relative offsets.'\n );\n const offset = r.offset.map((o: unknown) => {\n invariant(\n !!o && typeof o === 'object' && !Array.isArray(o),\n 'Invalid relative offset.'\n );\n const v = o as Record<string, unknown>;\n invariant(\n Object.keys(v).every(key => key === 'amount' || key === 'unit') &&\n typeof v.amount === 'number' &&\n Number.isSafeInteger(v.amount) &&\n Math.abs(v.amount) <= 1_000_000 &&\n typeof v.unit === 'string' &&\n Object.hasOwn(units, v.unit),\n 'Invalid relative offset.'\n );\n return { amount: v.amount, unit: v.unit as RelativeUnit };\n });\n return { anchor: r.anchor as RelativeAnchor, offset };\n }\n const range = { from: bound(record.from), to: bound(record.to) };\n if (range.from instanceof Date && range.to instanceof Date)\n invariant(range.from < range.to, 'Start must be before end.');\n invariant(\n maxRangeDays === undefined ||\n (Number.isFinite(maxRangeDays) && maxRangeDays > 0),\n 'Maximum range days must be positive.'\n );\n // Only compare bounds whose separation is independent of reporting time and zone.\n // Calendar offsets and mixed absolute/relative bounds require backend resolution.\n let duration: number | undefined;\n if (range.from instanceof Date && range.to instanceof Date) {\n duration = range.to.getTime() - range.from.getTime();\n } else if (\n range.from &&\n !(range.from instanceof Date) &&\n !(range.to instanceof Date)\n ) {\n const to = range.to ?? { anchor: 'RELATIVE_ANCHOR_NOW', offset: [] };\n if (range.from.anchor === to.anchor) {\n function offset(bound: RelativeDateTime) {\n let total = 0;\n for (const item of bound.offset) {\n const unit = fixedUnitMilliseconds[item.unit];\n if (unit === undefined) return undefined;\n total += item.amount * unit;\n }\n return total;\n }\n const start = offset(range.from);\n const end = offset(to);\n if (start !== undefined && end !== undefined) duration = end - start;\n }\n }\n invariant(\n duration === undefined || duration > 0,\n 'Start must be before end.'\n );\n invariant(\n maxRangeDays === undefined ||\n (!!range.from &&\n (duration === undefined ||\n duration <= maxRangeDays * fixedUnitMilliseconds.DAY)),\n `Choose a range of at most ${maxRangeDays} days.`\n );\n return range;\n}\n\n/** Canonical URL/JSON representation. Dates retain their encoded UTC fields. */\nexport function serializeDateTimeRange(value: DateTimeRange): string {\n return JSON.stringify(parseDateTimeRange(value));\n}\n\n/** UTC preview only. Backend execution owns reporting-timezone interpretation. Null start is unbounded; null end is now. */\nexport function resolveDateTimeRange(\n value: DateTimeRange,\n now = new Date()\n): { from: Date | null; to: Date } {\n const range = parseDateTimeRange(value);\n invariant(Number.isFinite(now.getTime()), 'Invalid reference date.');\n function resolve(bound: AbsoluteOrRelativeDateTime): Date {\n if (bound instanceof Date) return new Date(bound);\n let date = new CalendarDateTime(\n now.getUTCFullYear(),\n now.getUTCMonth() + 1,\n now.getUTCDate(),\n now.getUTCHours(),\n now.getUTCMinutes(),\n now.getUTCSeconds(),\n now.getUTCMilliseconds()\n );\n if (bound.anchor !== 'RELATIVE_ANCHOR_NOW')\n date = date.set({ hour: 0, minute: 0, second: 0, millisecond: 0 });\n switch (bound.anchor) {\n case 'RELATIVE_ANCHOR_START_OF_YESTERDAY':\n date = date.subtract({ days: 1 });\n break;\n case 'RELATIVE_ANCHOR_START_OF_TOMORROW':\n date = date.add({ days: 1 });\n break;\n case 'RELATIVE_ANCHOR_START_OF_WEEK':\n date = date.subtract({ days: (now.getUTCDay() + 6) % 7 });\n break;\n case 'RELATIVE_ANCHOR_START_OF_MONTH':\n date = date.set({ day: 1 });\n break;\n case 'RELATIVE_ANCHOR_START_OF_YEAR':\n date = date.set({ month: 1, day: 1 });\n break;\n }\n const durations = {\n SECOND: 'seconds',\n MINUTE: 'minutes',\n HOUR: 'hours',\n DAY: 'days',\n WEEK: 'weeks',\n MONTH: 'months',\n YEAR: 'years',\n } as const;\n for (const offset of bound.offset)\n date = date.add({ [durations[offset.unit]]: offset.amount });\n return date.toDate('UTC');\n }\n const from = range.from ? resolve(range.from) : null;\n const to = range.to ? resolve(range.to) : new Date(now);\n invariant(!from || from < to, 'Start must be before end.');\n return { from, to };\n}\n\nexport function formatDateTimeBound(\n value: AbsoluteOrRelativeDateTime | null | undefined,\n fallback = 'Now'\n): string {\n if (!value) return fallback;\n if (value instanceof Date)\n return value\n .toISOString()\n .replace('T', ' ')\n .replace(/:00\\.000Z$/, '')\n .replace(/Z$/, '');\n const offsets = value.offset\n .map(\n o => `${o.amount >= 0 ? '+' : '−'} ${Math.abs(o.amount)}${units[o.unit]}`\n )\n .join(' ');\n return `${anchors[value.anchor]}${offsets ? ` ${offsets}` : ''}`;\n}\nexport function formatDateTimeRange(value: DateTimeRange): string {\n const range = parseDateTimeRange(value);\n const from = range.from;\n if (\n from &&\n !(from instanceof Date) &&\n from.anchor === 'RELATIVE_ANCHOR_NOW' &&\n from.offset.length === 1 &&\n from.offset[0]!.amount < 0 &&\n !range.to\n ) {\n const offset = from.offset[0]!;\n return `Last ${Math.abs(offset.amount)}${units[offset.unit]}`;\n }\n return `${formatDateTimeBound(from, 'Any time')} → ${formatDateTimeBound(range.to)}`;\n}\n\n/** Parse one bound without resolving relative anchors or offsets. */\nexport function parseDateTimeBound(\n text: string\n): AbsoluteOrRelativeDateTime | null {\n const input = text.trim();\n invariant(!!input, 'Enter a date, time, or relative expression.');\n for (const [anchor, label] of Object.entries(anchors)) {\n if (!input.toLowerCase().startsWith(label.toLowerCase())) continue;\n const suffix = input.slice(label.length).trim();\n if (!/^(?:[+−-]\\s*\\d+\\s*(?:mo|[smhdwy])\\s*)*$/.test(suffix)) continue;\n const offset = Array.from(\n suffix.matchAll(/([+−-])\\s*(\\d+)\\s*(mo|[smhdwy])/g),\n match => ({\n amount: Number(match[2]) * (match[1] === '+' ? 1 : -1),\n unit: Object.entries(units).find(\n ([, abbreviation]) => abbreviation === match[3]\n )![0] as RelativeUnit,\n })\n );\n // Validate the bound without comparing it to an implicit \"now\" end.\n return parseDateTimeRange({ to: { anchor, offset } }).to!;\n }\n // datetime-local controls encode fields without performing a local-time conversion.\n if (\n /^\\d{4}-\\d{2}-\\d{2}(?:T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{3})?)?)?Z?$/.test(input)\n ) {\n const encoded = input.includes('T')\n ? input.replace(/Z$/, '')\n : `${input}T00:00`;\n const date = new Date(`${encoded}Z`);\n invariant(\n Number.isFinite(date.getTime()) && date.toISOString().startsWith(encoded),\n 'Choose a valid date and time.'\n );\n return date;\n }\n const parsed = parseDateTimeRangeInput(input);\n if (parsed.ok && parsed.range.from) return parsed.range.from;\n const since = parseDateTimeRangeInput(`since ${input}`);\n invariant(\n since.ok && !!since.range.from,\n 'Enter a date, time, or relative expression.'\n );\n return since.range.from;\n}\n"],"mappings":";;;;AACA,SAAgB,UACd,WACA,SACmB;CACnB,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,qBAAqB,SAAS;AAChE;;;ACqCA,MAAM,0BAA0B;AAoChC,MAAM,2BAA2B,IAAI,IACnC;CA/BA;EACE,MAAM;EACN,UAAU;GAAC;GAAW;GAAU;GAAQ;GAAO;EAAG;CACpD;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAW;GAAU;GAAQ;GAAO;GAAM;EAAG;CAC1D;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAS;GAAQ;GAAO;GAAM;EAAG;CAC9C;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAQ;GAAO;EAAG;CAC/B;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAS;GAAQ;GAAO;GAAM;EAAG;CAC9C;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAU;GAAS;GAAO;GAAM;EAAK;CAClD;CACA;EACE,MAAM;EACN,UAAU;GAAC;GAAS;GAAQ;GAAO;GAAM;EAAG;CAC9C;AAIqB,CAAC,CAAC,SAAS,EAAE,MAAM,eACtC,SAAS,KAAI,YAAW,CAAC,SAAS,IAAI,CAAU,CAClD,CACF;AAEA,SAAS,YAAY,OAAuB;CAC1C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AAEA,MAAM,wBAAwB,CAAC,GAAG,yBAAyB,KAAK,CAAC,CAAC,CAC/D,MAAM,MAAM,UAAU,MAAM,SAAS,KAAK,MAAM,CAAC,CACjD,IAAI,WAAW,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AAK,MAAM,OAAO,MAAM,IAAI;IACnD,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,MACzB,GAAG,kBAAkB,iBAAiB,MAAM,EAC/C,CAAC,CAAE;GACL,EAG6C;EAAE,EAAE,CAAC,CAAC,CAAC;CACxD;CAEA,IACE,gEAAgE,KAAK,KAAK,GAC1E;EACA,MAAM,UAAU,MAAM,SAAS,GAAG,IAC9B,MAAM,QAAQ,MAAM,EAAE,IACtB,GAAG,MAAM;EACb,MAAM,uBAAO,IAAI,KAAK,GAAG,QAAQ,EAAE;EACnC,UACE,OAAO,SAAS,KAAK,QAAQ,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,WAAW,OAAO,GACxE,+BACF;EACA,OAAO;CACT;CACA,MAAM,SAAS,wBAAwB,KAAK;CAC5C,IAAI,OAAO,MAAM,OAAO,MAAM,MAAM,OAAO,OAAO,MAAM;CACxD,MAAM,QAAQ,wBAAwB,SAAS,OAAO;CACtD,UACE,MAAM,MAAM,CAAC,CAAC,MAAM,MAAM,MAC1B,6CACF;CACA,OAAO,MAAM,MAAM;AACrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as MessageRoutingError, h as defineDataQueryRoute, u as isAnnotationPresentation, v as sqlQueryRoute } from "./contract-
|
|
1
|
+
import { f as MessageRoutingError, h as defineDataQueryRoute, u as isAnnotationPresentation, v as sqlQueryRoute } from "./contract-VhY9V9wd.js";
|
|
2
2
|
//#region src/core/uuid.ts
|
|
3
3
|
/** Opaque documents can lack randomUUID even when cryptographic randomness is available. */
|
|
4
4
|
function randomUuid() {
|
|
@@ -964,4 +964,4 @@ const appDiagnostics = {
|
|
|
964
964
|
//#endregion
|
|
965
965
|
export { localFrameBridge as a, createMessageClient as c, MAX_PENDING as d, PARENT_PARAM as f, randomUuid as g, parseAppDiagnosticReport as h, installDataAppTransport as i, isDataAppPresentation as l, validId as m, createIframeTransport as n, DataAppError as o, REQUEST_TIMEOUT_MS as p, getDataAppTransport as r, createHttpTransport as s, appDiagnostics as t, createBridgeEndpoint as u };
|
|
966
966
|
|
|
967
|
-
//# sourceMappingURL=diagnostics-
|
|
967
|
+
//# sourceMappingURL=diagnostics-Dyj-rUsY.js.map
|