@cloudlet/toast 1.0.0-rc.3 → 1.1.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/CHANGELOG.md +84 -16
- package/README.md +7 -5
- package/dist/contracts/controller.d.ts +7 -2
- package/dist/contracts/controller.d.ts.map +1 -1
- package/dist/contracts/events.d.ts +1 -1
- package/dist/contracts/events.d.ts.map +1 -1
- package/dist/contracts/internal.d.ts +23 -0
- package/dist/contracts/internal.d.ts.map +1 -1
- package/dist/contracts/notifications.d.ts +38 -6
- package/dist/contracts/notifications.d.ts.map +1 -1
- package/dist/contracts/snapshots.d.ts +3 -1
- package/dist/contracts/snapshots.d.ts.map +1 -1
- package/dist/core/bridge.d.ts +5 -0
- package/dist/core/bridge.d.ts.map +1 -0
- package/dist/core/bridge.js +345 -0
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/controller.d.ts +122 -3
- package/dist/core/controller.d.ts.map +1 -1
- package/dist/core/controller.js +400 -541
- package/dist/core/controller.js.map +1 -1
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +181 -89
- package/dist/core/validation.js.map +1 -1
- package/dist/react/announcer.d.ts.map +1 -1
- package/dist/react/announcer.js +29 -23
- package/dist/react/announcer.js.map +1 -1
- package/dist/react/bindings.d.ts +9 -0
- package/dist/react/bindings.d.ts.map +1 -1
- package/dist/react/bindings.js +32 -69
- package/dist/react/bindings.js.map +1 -1
- package/dist/react/card.d.ts +5 -3
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +146 -34
- package/dist/react/card.js.map +1 -1
- package/dist/react/generators.d.ts +2 -2
- package/dist/react/generators.js.map +1 -1
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +9 -5
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +3 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/plan.d.ts +1 -1
- package/dist/react/plan.d.ts.map +1 -1
- package/dist/react/plan.js +1 -0
- package/dist/react/plan.js.map +1 -1
- package/dist/react/renderer.d.ts +7 -0
- package/dist/react/renderer.d.ts.map +1 -0
- package/dist/react/renderer.js +62 -0
- package/dist/react/renderer.js.map +1 -0
- package/dist/react.d.ts +7 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -2
- package/src/contracts/controller.ts +7 -2
- package/src/contracts/events.ts +2 -1
- package/src/contracts/internal.ts +20 -0
- package/src/contracts/notifications.ts +45 -6
- package/src/contracts/snapshots.ts +3 -0
- package/src/core/bridge.ts +336 -0
- package/src/core/controller.ts +118 -271
- package/src/core/validation.ts +49 -4
- package/src/react/announcer.ts +9 -0
- package/src/react/bindings.tsx +28 -72
- package/src/react/card.tsx +92 -9
- package/src/react/generators.ts +2 -2
- package/src/react/gestures.ts +1 -1
- package/src/react/host.tsx +22 -7
- package/src/react/motion.ts +4 -4
- package/src/react/plan.ts +4 -3
- package/src/react/renderer.tsx +77 -0
- package/src/react.ts +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","names":["ATTENTION_DELAY","freeze","handles","bridges","nextController","EMPTY","COLLAPSED","SERVER","RENDERER_SERVER","IDLE","APPLIED","UNCHANGED","reject","getRendererBridge","bridge","controller","createCloudletCore","options","validateOptions","inputOptions","dependencies","clock","identity","records","listeners","eventListeners","operationSubscriptions","globalPauses","batches","focused","focusRequest","lease","lastLease","serial","autoId","revision","eventSequence","island","presented","hostDelay","hostAutoDismiss","attention","cancelAttention","attentionEpoch","overflow","overflowAnnounced","disposed","delivering","cancelTimer","timerEpoch","snapshot","rendererSnapshot","token","stackOrder","newest","retryable","operation","record","requiresAction","wantsAttention","rule","interacting","pauses","current","handleError","handle","leaseError","value","currentError","withRecord","args","error","action","withCurrent","withOperation","expected","diagnostic","diagnosticValue","failure","source","notifyListeners","listener","set","enqueue","notify","delivery","deliveries","event","release","at","final","batch","settle","now","stopTimer","schedule","deadline","active","epoch","due","commit","publish","notifications","present","armAttention","mutate","apply","assign","retire","next","stopAttention","nominate","candidate","autoDismissing","host","setHostAutoDismiss","changed","budget","remove","order","index","onClose","notice","dismiss","reason","acknowledgeOverflow","subscribe","admit","issues","validateSpec","spec","insert","existing","occurrences","overflowValue","id","copyContent","initialize","emit","replaceContent","content","kind","track","factory","sourceThen","validateTrackOptions","input","field","key","cancelValue","cancelCallback","classifierValue","classifier","config","subscribers","notification","attached","snapshotValue","attemptNumber","createAttempt","cancellation","context","resolve","fail","result","fulfill","rejectResult","attempt","finish","first","getSnapshot","live","binding","run","deliver","initialStatus","status","fallback","mapper","mapped","validateContent","uiApplied","requestCancellation","patchContent","cancellationReason","cancel","start","restart","previous","admission","admitted","unsubscribe","validatePatch","patch","priority","durationChanged","previousBudget","nextBudget","count","target","copied","validHostOptions","validDelay","withLease","hostOptions","nextLease","change","presentation","focusToken","outcome","acknowledgeAnnouncements","acknowledgements","actionToken","failed","message","report","acks","changes","validCount","maximum","ack"],"sources":["../../src/core/controller.ts"],"sourcesContent":["import type { CloudletController, ControllerOptions, FocusTarget } from '../contracts/controller.js';\nimport type { Diagnostic, EventBase, SemanticEvent } from '../contracts/events.js';\nimport type { ActionAttemptToken, ControllerIdentity, Generation, HandleRejection, NotificationHandle, OperationAttemptToken, Unsubscribe } from '../contracts/identity.js';\nimport type {\n AnnouncementAcknowledgement, BridgeRejection, BridgeResult, FocusRequest, FocusRequestToken,\n ControllerDependencies, HostLease, HostOptions, OperationAnnouncementPhase, PauseChange, PresentationToken, RendererBridge,\n RendererSnapshot,\n} from '../contracts/internal.js';\nimport type { AdmissionResult, CloseReason, NotificationContent, NotificationKind, NotificationPatch, NotificationSpec, OperationAdmissionResult, Priority } from '../contracts/notifications.js';\nimport type { AttemptStartResult, CancellationSignal, CancelResult, OperationAttempt, OperationContext, OperationHandle, OperationSnapshot, OperationSource, OperationStatus, TrackOptions } from '../contracts/operations.js';\nimport type { ActionSnapshot, ControllerSnapshot, IslandReason, IslandSnapshot, PauseReason } from '../contracts/snapshots.js';\nimport { copyContent, patchContent, validDelay, validateContent, validateOptions, validatePatch, validateSpec, validateTrackOptions } from './validation.js';\n\ninterface OperationBinding {\n readonly getSnapshot: () => OperationSnapshot;\n readonly retry: () => AttemptStartResult<unknown>;\n readonly cancel: (reason?: unknown) => CancelResult;\n readonly detach: () => Delivery;\n}\n\ntype EventPayload = SemanticEvent extends infer E ? E extends SemanticEvent ? Omit<E, keyof EventBase> : never : never;\ntype Delivery = EventPayload | { readonly callback: () => void; readonly source: string; readonly handle?: NotificationHandle };\n\ninterface RecordState<Slot> {\n readonly handle: NotificationHandle;\n readonly dedupeKey: string | undefined;\n readonly onClose: NotificationSpec<Slot>['onClose'];\n content: Readonly<NotificationContent<Slot>>;\n kind: NotificationKind;\n priority: Priority;\n occurrences: number;\n remaining: number | null;\n activeSince: number | null;\n presentation: PresentationToken | null;\n readable: boolean;\n everPresented: boolean;\n readonly pauses: Set<PauseReason>;\n queuedAnnounced: boolean;\n firstAnnounced: boolean;\n occurrencesAnnounced: number;\n operation: OperationBinding | null;\n readonly operationAnnounced: Set<OperationAnnouncementPhase>;\n action: ActionSnapshot;\n actionAnnounced?: { readonly token: ActionAttemptToken; readonly status: 'pending' | 'failed' };\n}\n\n/** Open Island state; `null` is the collapsed stack. */\ninterface IslandState<Slot> {\n readonly reason: IslandReason;\n current: RecordState<Slot>;\n}\n\ninterface AttentionCandidate<Slot> {\n readonly record: RecordState<Slot>;\n due: number;\n /** Expired during user interaction or without a host; restarts the delay afterwards. */\n waiting: boolean;\n}\n\nconst ATTENTION_DELAY = 600;\n\nconst freeze = Object.freeze;\n\n// Weak registries authenticate capabilities without retaining disposed controllers.\nconst handles = new WeakSet<object>();\nconst bridges = new WeakMap<object, RendererBridge<unknown>>();\nlet nextController = 0;\nconst EMPTY: readonly never[] = freeze([]);\nconst COLLAPSED: IslandSnapshot = freeze({ open: false, reason: null, current: null });\nconst SERVER: ControllerSnapshot<never> = freeze({\n controller: null, revision: 0, disposed: false, notifications: EMPTY, stack: EMPTY,\n island: COLLAPSED, overflow: freeze({ count: 0, pending: false }),\n});\nconst RENDERER_SERVER: RendererSnapshot<never> = freeze({\n ...SERVER, presentation: null, focusRequest: null,\n announcements: freeze({ notifications: EMPTY, overflowCount: 0 }),\n});\nconst IDLE = freeze({ status: 'idle' as const });\nconst APPLIED = freeze({ status: 'applied' as const });\nconst UNCHANGED = freeze({ status: 'unchanged' as const });\nconst reject = <Reason extends string>(reason: Reason) => ({ status: 'rejected' as const, reason });\n\nexport function getRendererBridge<Slot, Signal extends CancellationSignal>(controller: CloudletController<Slot, Signal>): RendererBridge<Slot> {\n const bridge = bridges.get(controller);\n if (!bridge) throw new TypeError('Controller was not created by this Cloudlet package instance');\n // The registry stores the bridge together with its controller's opaque Slot type.\n return bridge as RendererBridge<Slot>;\n}\n\n/** The sole owner of notification state, the stack/Island, budgets, attention and host leases. */\nexport function createCloudletCore<Slot = never, Signal extends CancellationSignal = CancellationSignal>(\n inputOptions: ControllerOptions | undefined,\n dependencies: ControllerDependencies<Signal>,\n): CloudletController<Slot, Signal> {\n const options = validateOptions(inputOptions);\n if (!dependencies?.clock || typeof dependencies.clock.now !== 'function' || typeof dependencies.clock.schedule !== 'function') {\n throw new TypeError('Cloudlet requires a monotonic clock');\n }\n const clock = dependencies.clock;\n if (typeof dependencies.createCancellation !== 'function') throw new TypeError('Cloudlet requires a cancellation source factory');\n const identity = `cloudlet-${++nextController}` as ControllerIdentity;\n const records = new Map<string, RecordState<Slot>>();\n const listeners = new Set<() => void>();\n const eventListeners = new Set<(event: SemanticEvent) => void>();\n const operationSubscriptions = new Map<Set<() => void>, Delivery>();\n const globalPauses = new Set<PauseReason>();\n const batches: (() => void)[] = [];\n let focused: NotificationHandle | null = null;\n let focusRequest: FocusRequest | null = null;\n let lease: HostLease | null = null;\n let lastLease: HostLease | null = null;\n let serial = 0;\n let autoId = 0;\n let revision = 0;\n let eventSequence = 0;\n let island: IslandState<Slot> | null = null;\n // The presented record: Island current when open, otherwise the newest record.\n let presented: RecordState<Slot> | null = null;\n let hostDelay: number | undefined;\n /** `Toaster autoDismiss`: overrides ControllerOptions.autoDismiss while defined and attached. */\n let hostAutoDismiss: boolean | undefined;\n let attention: AttentionCandidate<Slot> | null = null;\n let cancelAttention: Unsubscribe | null = null;\n let attentionEpoch = 0;\n let overflow = 0;\n let overflowAnnounced = 0;\n let disposed = false;\n let delivering = false;\n let cancelTimer: Unsubscribe | null = null;\n let timerEpoch = 0;\n let snapshot: ControllerSnapshot<Slot>;\n let rendererSnapshot: RendererSnapshot<Slot>;\n\n const token = () => `${identity}:${++serial}`;\n // Map insertion order is admission order; the stack shows newest first.\n const stackOrder = () => [...records.values()].reverse();\n const newest = (): RecordState<Slot> | null => stackOrder()[0] ?? null;\n // A settled factory can always retry; only an unsuccessful attempt offers retry as an action.\n const retryable = (record: RecordState<Slot>) => {\n const operation = record.operation?.getSnapshot();\n return !!operation?.canRetry && operation.status !== 'fulfilled';\n };\n const requiresAction = (record: RecordState<Slot>) => !!record.content.action\n || retryable(record) || record.content.attention === 'open';\n const wantsAttention = (record: RecordState<Slot>) => {\n const rule = record.content.attention ?? 'auto';\n return rule === 'open' || (rule === 'auto' && (requiresAction(record) || !!record.content.description));\n };\n const interacting = () => globalPauses.has('hover') || globalPauses.has('focus')\n || [...records.values()].some((record) => record.pauses.has('gesture'));\n const pauses = (record: RecordState<Slot>): PauseReason[] => {\n const current = record === presented;\n return [\n ...(!current ? ['inactive' as const] : []),\n ...(lease === null ? ['no-host' as const] : []),\n ...(current && !record.readable ? ['presentation-pending' as const] : []),\n // An Island opened by the user, or a slide that asks for action, keeps its time.\n ...(current && island && (island.reason === 'user' || requiresAction(record)) ? ['island' as const] : []),\n ...(record.action.status === 'pending' ? ['action-pending' as const] : []),\n ...globalPauses, ...record.pauses,\n ];\n };\n const handleError = (handle: NotificationHandle): HandleRejection | 'disposed' | undefined => {\n if (disposed) return 'disposed';\n if (typeof handle !== 'object' || handle === null || !handles.has(handle)) return 'invalid-handle';\n if (handle.controller !== identity) return 'foreign-controller';\n if (records.get(handle.id)?.handle !== handle) return 'stale-handle';\n return undefined;\n };\n const leaseError = (value: HostLease): 'disposed' | 'stale-lease' | undefined =>\n disposed ? 'disposed' : lease === null || value !== lease ? 'stale-lease' : undefined;\n const currentError = (handle: NotificationHandle): BridgeRejection | undefined =>\n handleError(handle) ?? (records.get(handle.id) !== presented ? 'not-current' : undefined);\n\n // Capability validation always precedes method-specific validation/mutation.\n function withRecord<Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result) {\n return (handle: NotificationHandle, ...args: Args) => {\n const error = handleError(handle);\n return error ? reject(error) : action(records.get(handle.id)!, ...args);\n };\n }\n function withCurrent<Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result) {\n return withRecord((record, ...args: Args) => record !== presented ? reject('not-current') : action(record, ...args));\n }\n function withOperation<Args extends unknown[], Result>(action: (operation: OperationBinding, ...args: Args) => Result) {\n return withRecord((record, expected: OperationAttemptToken, ...args: Args) => {\n const operation = record.operation;\n return !operation ? reject('no-operation') : operation.getSnapshot().token !== expected\n ? reject('stale-operation-token') : action(operation, ...args);\n });\n }\n\n function diagnostic(diagnosticValue: Diagnostic): void {\n const value = freeze({ ...diagnosticValue });\n enqueue([{ type: 'diagnostic', diagnostic: value }]);\n }\n function failure(code: Diagnostic['code'], source: string, error: unknown, handle?: NotificationHandle): void {\n diagnostic({ code, source, message: `${source} failed`, error, ...(handle ? { handle } : {}) });\n }\n function notifyListeners(set: Set<() => void>, source: string): void {\n for (const listener of [...set]) {\n if (!set.has(listener)) continue;\n try { listener(); } catch (error) {\n failure('listener-error', source, error);\n }\n }\n }\n function enqueue(deliveries: readonly Delivery[], notify = false, at = clock.now(), final = false, release = false): void {\n batches.push(() => {\n if (notify) notifyListeners(listeners, 'subscribe');\n for (const delivery of deliveries) {\n if ('callback' in delivery) {\n try { delivery.callback(); } catch (error) {\n failure('callback-error', delivery.source, error, delivery.handle);\n }\n continue;\n }\n const event: SemanticEvent = freeze({ ...delivery, controller: identity, sequence: ++eventSequence,\n at: release ? clock.now() : at });\n for (const listener of [...eventListeners]) {\n if (!eventListeners.has(listener)) continue;\n try { listener(event); } catch (error) {\n if (event.type !== 'diagnostic') failure('listener-error', 'onEvent', error);\n }\n }\n if (event.type === 'diagnostic') {\n try { options.onDiagnostic?.(event.diagnostic); } catch { /* No recursive diagnostics. */ }\n }\n }\n // Close-callback diagnostics are queued before disposal releases observers.\n if (final) enqueue([{ type: 'disposed' }], false, at, false, true);\n if (release) {\n listeners.clear(); eventListeners.clear();\n for (const set of operationSubscriptions.keys()) set.clear();\n operationSubscriptions.clear();\n }\n });\n if (delivering) return;\n delivering = true;\n try {\n let batch: (() => void) | undefined;\n while ((batch = batches.shift())) batch();\n } finally { delivering = false; }\n }\n function settle(): number {\n const now = clock.now();\n for (const record of records.values()) {\n if (record.activeSince !== null && record.remaining !== null) {\n record.remaining = Math.max(0, record.remaining - Math.max(0, now - record.activeSince));\n record.activeSince = now;\n }\n }\n return now;\n }\n function stopTimer(): void {\n ++timerEpoch;\n cancelTimer?.();\n cancelTimer = null;\n }\n function schedule(now: number): void {\n stopTimer();\n let deadline = Infinity;\n for (const record of records.values()) {\n const active = record.remaining !== null && pauses(record).length === 0 && !disposed;\n record.activeSince = active ? now : null;\n if (active) deadline = Math.min(deadline, now + record.remaining!);\n }\n if (!Number.isFinite(deadline)) return;\n const epoch = timerEpoch;\n cancelTimer = clock.schedule(deadline, () => {\n if (disposed || epoch !== timerEpoch) return;\n const at = settle();\n const due = [...records.values()].filter((record) => record.activeSince !== null && record.remaining === 0);\n const deliveries: Delivery[] = [];\n for (const record of due) remove(record, 'timeout', deliveries);\n // An early delivery only rearms; a late delivery closes exactly the due generations.\n if (due.length) commit(deliveries, at);\n else schedule(at);\n });\n }\n function publish(): void {\n const current = [...records.values()];\n const notifications = freeze(current.map((record) => freeze({\n handle: record.handle, kind: record.kind, content: record.content, priority: record.priority,\n occurrences: record.occurrences, location: record === presented ? 'current' as const : 'stack' as const,\n remainingMs: record.remaining, pauseReasons: freeze(pauses(record)), operation: record.operation?.getSnapshot() ?? null, action: record.action,\n })));\n snapshot = freeze({ controller: identity, revision, disposed, notifications,\n stack: freeze(stackOrder().map((record) => record.handle)),\n island: island ? freeze({ open: true, reason: island.reason, current: island.current.handle }) : COLLAPSED,\n overflow: freeze({ count: overflow, pending: overflow > 0 }),\n });\n rendererSnapshot = freeze({ ...snapshot,\n presentation: presented ? freeze({ handle: presented.handle, token: presented.presentation, readable: presented.readable }) : null,\n focusRequest,\n announcements: freeze({ overflowCount: overflowAnnounced,\n notifications: freeze(current.map((record) => freeze({\n handle: record.handle, queued: record.queuedAnnounced, firstPresentation: record.firstAnnounced,\n occurrences: record.occurrencesAnnounced, action: record.actionAnnounced ?? null, operation: record.operation ? freeze({\n token: record.operation.getSnapshot().token, phases: freeze([...record.operationAnnounced]),\n }) : null,\n }))),\n }),\n });\n }\n function commit(deliveries: readonly Delivery[] = [], now = clock.now(), final = false): void {\n present();\n schedule(now);\n armAttention(now);\n ++revision;\n publish();\n enqueue(deliveries, true, now, final);\n }\n // Every state mutation settles the old budget, publishes once, then delivers.\n // The presented record is derived inside that transaction, before subscribers can reenter.\n function mutate(apply: (deliveries: Delivery[]) => void, final = false) {\n const now = settle();\n const deliveries: Delivery[] = [];\n apply(deliveries);\n commit(deliveries, now, final);\n return APPLIED;\n }\n function assign(record: RecordState<Slot>): void {\n record.readable = false;\n record.presentation = lease === null ? null : token() as PresentationToken;\n }\n function retire(record: RecordState<Slot>): void {\n record.presentation = null;\n record.readable = false;\n record.pauses.clear();\n if (focused === record.handle) focused = null;\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === record.handle) focusRequest = null;\n }\n /** A change of the presented record mints a new presentation token; its predecessor keeps its budget. */\n function present(): void {\n const next = island ? island.current : newest();\n if (next === presented) return;\n if (presented) retire(presented);\n presented = next;\n if (next) assign(next);\n }\n function stopAttention(): void {\n ++attentionEpoch;\n cancelAttention?.();\n cancelAttention = null;\n }\n /** Newest candidate wins: a new nomination replaces the pending one. */\n function nominate(record: RecordState<Slot>, now: number): void {\n if (wantsAttention(record)) attention = { record, due: now + (hostDelay ?? options.attentionDelay ?? ATTENTION_DELAY), waiting: false };\n }\n function armAttention(now: number): void {\n stopAttention();\n const candidate = attention;\n if (!candidate || disposed) return;\n // Without a host nothing has landed yet: wait without allocating a timer.\n if (lease === null) { candidate.waiting = true; return; }\n if (candidate.waiting) {\n if (interacting()) return;\n candidate.waiting = false;\n candidate.due = now + (hostDelay ?? options.attentionDelay ?? ATTENTION_DELAY);\n }\n const epoch = attentionEpoch;\n cancelAttention = clock.schedule(candidate.due, () => {\n if (disposed || epoch !== attentionEpoch || attention !== candidate) return;\n const at = clock.now();\n if (at < candidate.due) { armAttention(at); return; }\n cancelAttention = null;\n // Expiry during hover/focus/gesture waits; the next release restarts the delay.\n if (interacting()) { candidate.waiting = true; return; }\n attention = null;\n const record = candidate.record;\n if (!wantsAttention(record) || island?.current === record) return;\n mutate(() => {\n if (island) island.current = record;\n else island = { reason: 'attention', current: record };\n });\n });\n }\n const autoDismissing = (host: boolean | undefined) => (host ?? options.autoDismiss) !== false;\n /** Off stops every budget; on starts each one in full. */\n function setHostAutoDismiss(value: boolean | undefined): void {\n const changed = autoDismissing(value) !== autoDismissing(hostAutoDismiss);\n hostAutoDismiss = value;\n if (!changed) return;\n for (const record of records.values()) record.remaining = budget(record);\n }\n function budget(record: RecordState<Slot>): number | null {\n if (!autoDismissing(hostAutoDismiss)) return null;\n if (record.content.duration !== undefined) return record.content.duration;\n return (record.kind === 'info' || record.kind === 'success') && !record.content.action ? 6000 : null;\n }\n function remove(record: RecordState<Slot>, reason: CloseReason, deliveries: Delivery[]): void {\n if (island?.current === record) {\n // The next older slide, else the next newer one, else the Island closes.\n const order = stackOrder();\n const index = order.indexOf(record);\n const next = order[index + 1] ?? order[index - 1];\n if (next) island.current = next; else island = null;\n }\n if (attention?.record === record) attention = null;\n records.delete(record.handle.id);\n if (record.operation) deliveries.push(record.operation.detach());\n deliveries.push({ type: 'closed', handle: record.handle, reason });\n if (record.onClose) {\n const onClose = record.onClose;\n const notice = freeze({ handle: record.handle, reason });\n deliveries.push({ callback: () => onClose(notice), source: 'onClose', handle: record.handle });\n }\n }\n const dismiss = withRecord((record, reason: CloseReason) =>\n mutate((deliveries) => remove(record, reason, deliveries)));\n function acknowledgeOverflow() {\n if (disposed) return reject('disposed');\n if (!overflow) return UNCHANGED;\n return mutate((deliveries) => {\n deliveries.push({ type: 'overflow-acknowledged', count: overflow });\n overflow = overflowAnnounced = 0;\n if (focusRequest?.target.kind === 'overflow') focusRequest = null;\n });\n }\n function subscribe<T>(set: Set<T>, listener: T): Unsubscribe {\n if (typeof listener !== 'function') throw new TypeError('Listener must be a function');\n if (disposed) return () => {};\n set.add(listener);\n return () => { set.delete(listener); };\n }\n function admit(spec: NotificationSpec<Slot>): AdmissionResult {\n if (disposed) return reject('disposed');\n const issues = validateSpec(spec);\n if (issues.length) {\n diagnostic({ code: 'invalid-input', source: 'show', message: 'Invalid notification specification' });\n return { ...reject('invalid-input'), issues };\n }\n return insert(spec);\n }\n function insert(spec: NotificationSpec<Slot>, initialize?: (record: RecordState<Slot>) => void): AdmissionResult {\n if (spec.id !== undefined && records.has(spec.id)) return reject('id-conflict');\n const existing = spec.dedupeKey === undefined ? undefined : [...records.values()].find((record) => record.dedupeKey === spec.dedupeKey);\n if (existing) {\n let occurrences = existing.occurrences;\n mutate((deliveries) => {\n occurrences = existing.occurrences = Math.min(Number.MAX_SAFE_INTEGER, occurrences + 1);\n deliveries.push({ type: 'deduplicated', handle: existing.handle, occurrences });\n });\n return { status: 'deduplicated', handle: existing.handle, occurrences };\n }\n if (records.size >= 100) {\n mutate((deliveries) => {\n overflow = Math.min(Number.MAX_SAFE_INTEGER, overflow + 1);\n const overflowValue = freeze({ count: overflow, pending: true });\n deliveries.push({ type: 'overflow', count: overflow });\n if (options.onOverflow) deliveries.push({ callback: () => options.onOverflow!(overflowValue), source: 'onOverflow' });\n });\n return reject('capacity');\n }\n const now = settle();\n let id = spec.id;\n if (id === undefined) { do { id = `${identity}:notification-${++autoId}`; } while (records.has(id)); }\n const handle = freeze({ id, controller: identity, generation: token() as Generation }) as NotificationHandle;\n handles.add(handle);\n const record: RecordState<Slot> = {\n handle: handle,\n dedupeKey: spec.dedupeKey,\n onClose: spec.onClose,\n content: copyContent(spec),\n kind: spec.kind ?? 'info',\n priority: spec.priority ?? 'normal',\n occurrences: 1,\n remaining: null,\n activeSince: null,\n presentation: null,\n readable: false,\n everPresented: false,\n pauses: new Set(),\n queuedAnnounced: false,\n firstAnnounced: false,\n occurrencesAnnounced: 0,\n operation: null,\n operationAnnounced: new Set(),\n action: IDLE,\n };\n record.remaining = budget(record);\n records.set(id, record);\n initialize?.(record);\n nominate(record, now);\n const deliveries: Delivery[] = [{ type: 'admitted', handle }];\n if (record.operation) {\n const operation = record.operation.getSnapshot();\n deliveries.push({ type: 'operation-started', handle, token: operation.token, attempt: operation.attempt });\n }\n commit(deliveries, now);\n return { status: 'created', handle };\n }\n function emit(deliveries: readonly Delivery[]): void {\n if (disposed) return;\n enqueue(deliveries);\n }\n function replaceContent(record: RecordState<Slot>, content: Readonly<NotificationContent<Slot>>, kind: NotificationKind): void {\n record.content = content;\n record.kind = kind;\n record.remaining = kind === 'loading' ? null : budget(record);\n // A replacement owns a new action context; old completions cannot close it.\n record.action = IDLE;\n if (record === presented) assign(record);\n // A runner phase (terminal result or new attempt) is evaluated like an admission.\n nominate(record, clock.now());\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === record.handle &&\n focusRequest.target.control === 'action' && !content.action) focusRequest = null;\n }\n function track<T>(source: OperationSource<T, Signal>, input: TrackOptions<T, Slot, Signal>): OperationHandle<T> {\n const factory = typeof source === 'function' ? source : null;\n let sourceThen: PromiseLike<T>['then'] | undefined;\n if (!factory && (source === null || typeof source !== 'object' || typeof (sourceThen = source.then) !== 'function')) {\n throw new TypeError('Operation source must be a factory or thenable');\n }\n const issues = validateTrackOptions(input, factory !== null);\n // Invalid presentation options cannot suppress a valid business source. Read\n // only data properties here; validation never executes option accessors.\n const field = (key: keyof TrackOptions<T, Slot, Signal>): unknown => input && typeof input === 'object'\n ? Object.getOwnPropertyDescriptor(input, key)?.value : undefined;\n const cancelValue = field('cancel');\n const cancelCallback = !factory && typeof cancelValue === 'function' ? cancelValue as (reason: unknown) => void : null;\n const classifierValue = field('isCancellation');\n const classifier = typeof classifierValue === 'function' ? classifierValue as NonNullable<TrackOptions<T, Slot, Signal>['isCancellation']> : null;\n const config = issues.length ? null : freeze({ ...input,\n pending: copyContent(input.pending),\n success: typeof input.success === 'function' ? input.success : copyContent(input.success),\n error: typeof input.error === 'function' ? input.error : copyContent(input.error),\n ...(input.cancelled === undefined ? {} : { cancelled: typeof input.cancelled === 'function' ? input.cancelled : copyContent(input.cancelled) }),\n });\n const subscribers = new Set<() => void>();\n let notification: NotificationHandle | null = null;\n let attached = false;\n let snapshotValue: OperationSnapshot;\n let attemptNumber = 0;\n type Attempt = {\n readonly public: OperationAttempt<T>;\n readonly context: OperationContext<Signal>;\n readonly abort: (reason?: unknown) => void;\n readonly resolve: (value: T | PromiseLike<T>) => void;\n readonly reject: (reason: unknown) => void;\n status: OperationStatus;\n cancelRequested: boolean;\n };\n function createAttempt(): Attempt {\n const cancellation = dependencies.createCancellation();\n const context = freeze({ signal: cancellation.signal, token: token() as OperationAttemptToken, attempt: ++attemptNumber });\n let resolve!: Attempt['resolve'];\n let fail!: Attempt['reject'];\n const result = new Promise<T>((fulfill, rejectResult) => { resolve = fulfill; fail = rejectResult; });\n const attempt: Attempt = {\n public: freeze({ token: context.token, attempt: context.attempt, result }), context,\n abort: cancellation.abort, resolve, reject: fail, status: 'pending', cancelRequested: false,\n };\n // Observe both branches without altering the public promise's value/reason.\n // The derived internal chain is handled as well, even if a platform port fails.\n void result.then((value) => finish(attempt, 'fulfilled', value), (error: unknown) => finish(attempt, 'rejected', error))\n .catch((error: unknown) => {\n if (!disposed) failure('callback-error', 'operation-settlement', error);\n });\n return attempt;\n }\n const first = createAttempt();\n let current = first;\n function getSnapshot(): OperationSnapshot {\n const next = {\n token: current.context.token, attempt: current.context.attempt, status: current.status,\n cancelRequested: current.cancelRequested,\n canCancel: !disposed && current.status === 'pending' && !current.cancelRequested && (!!factory || !!cancelCallback),\n canRetry: !disposed && !!factory && current.status !== 'pending',\n notification: attached && !disposed ? notification : null,\n };\n if (!snapshotValue || Object.keys(next).some((key) => next[key as keyof OperationSnapshot] !== snapshotValue[key as keyof OperationSnapshot])) {\n snapshotValue = freeze(next);\n }\n return snapshotValue;\n }\n const notify: Delivery = { source: 'operation.subscribe',\n callback: () => notifyListeners(subscribers, 'operation.subscribe') };\n function live(attempt: Attempt): RecordState<Slot> | undefined {\n if (disposed || current !== attempt || !attached || !notification) return undefined;\n const record = records.get(notification.id);\n return record?.handle === notification && record.operation === binding ? record : undefined;\n }\n function run(attempt: Attempt): void {\n // Validate and assimilate the same then method once, preserving its receiver.\n // Reading a user accessor again could replace the business outcome.\n try { attempt.resolve(factory ? factory(attempt.context) : { then: sourceThen!.bind(source) }); }\n catch (error) { attempt.reject(error); }\n }\n function deliver(deliveries: Delivery[], apply?: () => void): void {\n if (apply) {\n const now = settle();\n apply();\n commit(deliveries, now);\n } else emit(deliveries);\n }\n function finish(attempt: Attempt, initialStatus: 'fulfilled' | 'rejected', value: unknown): void {\n attempt.status = initialStatus;\n if (initialStatus === 'rejected') {\n try {\n const cancelled = classifier ? classifier(value, attempt.context) === true\n : attempt.cancelRequested && value !== null && typeof value === 'object' && 'name' in value && value.name === 'AbortError';\n if (cancelled) attempt.status = 'cancelled';\n } catch (error) {\n if (!disposed) failure('cancellation-error', 'isCancellation', error);\n }\n }\n let content: Readonly<NotificationContent<Slot>> | undefined;\n if (live(attempt) && config) {\n const status = attempt.status;\n const fallback = status === 'fulfilled' ? options.messages?.operationSuccess ?? 'Completed'\n : status === 'cancelled' ? options.messages?.operationCancelled ?? 'Cancelled'\n : options.messages?.operationError ?? 'Something went wrong';\n try {\n const mapper = status === 'fulfilled' ? config.success : status === 'cancelled' ? config.cancelled : config.error;\n const mapped = typeof mapper === 'function' ? mapper(value as T) : mapper ?? { title: fallback };\n if (validateContent(mapped).length) throw new TypeError('Invalid terminal notification content');\n content = copyContent(mapped);\n } catch (error) {\n content = freeze({ title: fallback, announcementPriority: 'polite' });\n if (!disposed) failure('mapper-error', `track.${status}`, error, notification ?? undefined);\n }\n }\n // User mappers, classifiers and diagnostic listeners are reentrant.\n const record = live(attempt);\n const uiApplied = !!record && !!content;\n const deliveries: Delivery[] = [\n ...(current === attempt ? [notify] : []),\n { type: 'operation-settled', handle: notification, token: attempt.context.token, status: attempt.status, uiApplied },\n ];\n deliver(deliveries, record && content ? () => replaceContent(record, content,\n attempt.status === 'fulfilled' ? 'success' : attempt.status === 'cancelled' ? 'warning' : 'error') : undefined);\n }\n function requestCancellation(attempt: Attempt, reason: unknown): void {\n attempt.cancelRequested = true;\n const record = live(attempt);\n const deliveries: Delivery[] = [notify, { type: 'cancellation-requested', handle: notification, token: attempt.context.token }];\n deliver(deliveries, record ? () => {\n record.content = patchContent(record.content, { title: options.messages?.cancellationRequested ?? 'Cancellation requested' });\n } : undefined);\n try {\n attempt.abort(reason);\n cancelCallback?.(reason);\n } catch (error) {\n if (!disposed) failure('cancellation-error', 'cancel', error, notification ?? undefined);\n }\n }\n function cancellationReason(): Error {\n const error = new Error('Cancellation requested');\n error.name = 'AbortError';\n return error;\n }\n function cancel(reason: unknown = cancellationReason()): CancelResult {\n if (disposed) return reject('disposed');\n if (current.status !== 'pending') return { status: 'unchanged', reason: 'settled' };\n if (!factory && !cancelCallback) return reject('not-cancellable');\n if (current.cancelRequested) return { status: 'unchanged', reason: 'already-requested' };\n requestCancellation(current, reason);\n return { status: 'requested' };\n }\n function start(restart: boolean): AttemptStartResult<T> {\n if (disposed) return reject('disposed');\n if (!factory) return reject('not-retryable');\n if (current.status === 'pending' && !restart) return reject('already-pending');\n const previous = current;\n const next = createAttempt();\n current = next; // Invalidate old ownership before any observer or abort callback.\n const record = live(next);\n const deliveries: Delivery[] = [notify, { type: 'operation-started', handle: notification, token: next.context.token, attempt: next.context.attempt }];\n deliver(deliveries, record && config ? () => {\n record.operationAnnounced.clear();\n replaceContent(record, config.pending, 'loading');\n } : undefined);\n if (previous.status === 'pending' && !previous.cancelRequested) requestCancellation(previous, cancellationReason());\n run(next);\n return { status: 'started', attempt: next.public };\n }\n const binding: OperationBinding = {\n getSnapshot, retry: () => start(false), cancel,\n detach: () => { attached = false; return notify; },\n };\n let admission: OperationAdmissionResult;\n if (disposed) admission = reject('disposed');\n else if (!config) {\n admission = { ...reject('invalid-input'), issues };\n diagnostic({ code: 'invalid-input', source: 'track', message: 'Invalid operation options' });\n } else {\n const admitted = insert({ ...config.pending, ...config, kind: 'loading' }, (record) => {\n notification = record.handle;\n attached = true;\n record.operation = binding;\n });\n // No dedupe key can reach this path (validated TrackOptions).\n if (admitted.status === 'deduplicated') throw new Error('Tracked operation cannot be deduplicated');\n admission = admitted;\n }\n if (admission.status === 'rejected') emit([{ type: 'operation-started', handle: null, token: first.context.token, attempt: 1 }]);\n run(first);\n return freeze({ ...first.public, admission: freeze(admission), getSnapshot,\n subscribe(listener: () => void) {\n const unsubscribe = subscribe(subscribers, listener);\n if (subscribers.size) operationSubscriptions.set(subscribers, notify);\n return () => { unsubscribe(); if (!subscribers.size) operationSubscriptions.delete(subscribers); };\n },\n cancel, retry: () => start(false), restart: () => start(true),\n });\n }\n\n const controller = freeze<CloudletController<Slot, Signal>>({\n show: (spec) => admit(spec),\n track,\n update: withRecord((record, patch: NotificationPatch<Slot>) => {\n const handle = record.handle;\n const issues = validatePatch(patch);\n if (issues.length) {\n diagnostic({ code: 'invalid-input', source: 'update', message: 'Invalid notification patch', handle });\n return { ...reject('invalid-input'), issues };\n }\n if (record.action.status === 'pending' && Object.prototype.hasOwnProperty.call(patch, 'action')) return reject('action-pending');\n if (record.operation && (Object.prototype.hasOwnProperty.call(patch, 'kind') ||\n (record.operation.getSnapshot().status === 'pending' && Object.prototype.hasOwnProperty.call(patch, 'duration')))) return reject('operation-owned');\n const content = patchContent(record.content, patch);\n const kind = patch.kind ?? record.kind;\n const priority = patch.priority ?? record.priority;\n const durationChanged = Object.prototype.hasOwnProperty.call(patch, 'duration');\n if (content === record.content && kind === record.kind && priority === record.priority && !durationChanged &&\n !(Object.prototype.hasOwnProperty.call(patch, 'action') && record.action.status === 'failed')) return UNCHANGED;\n return mutate((deliveries) => {\n const previousBudget = budget(record);\n record.content = content;\n if (Object.prototype.hasOwnProperty.call(patch, 'action')) record.action = IDLE;\n record.kind = kind;\n record.priority = priority;\n const nextBudget = budget(record);\n if (durationChanged || previousBudget !== nextBudget) record.remaining = nextBudget;\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === handle && focusRequest.target.control === 'action' && !content.action) focusRequest = null;\n if (attention?.record === record && !wantsAttention(record)) attention = null;\n deliveries.push({ type: 'updated', handle });\n });\n }),\n getHandle: (id) => !disposed && typeof id === 'string' ? records.get(id)?.handle : undefined,\n dismiss: (handle) => dismiss(handle, 'programmatic'),\n clear() {\n if (disposed) return reject('disposed');\n const count = records.size;\n if (!count) return { status: 'cleared', count };\n mutate((deliveries) => {\n for (const record of records.values()) remove(record, 'clear', deliveries);\n });\n return { status: 'cleared', count };\n },\n requestFocus(target: FocusTarget = { kind: 'anchor' }) {\n if (disposed) return reject('disposed');\n if (target?.kind === 'notification') {\n const error = handleError(target.handle);\n if (error) return reject(error);\n }\n if (!lease) return reject('no-host');\n if (!target || !['anchor', 'notification', 'overflow'].includes(target.kind)) return reject('unavailable');\n if (target.kind === 'notification') {\n const record = records.get(target.handle.id)!;\n if (record !== presented) return reject('not-visible');\n if (target.control !== undefined && !['action', 'close'].includes(target.control)) return reject('unavailable');\n if (target.control === 'action' && !record.content.action) return reject('unavailable');\n // Card controls exist only inside the open Island; the collapsed pill has none.\n if (target.control !== undefined && !island) return reject('not-visible');\n }\n if (target.kind === 'overflow' && !overflow) return reject('unavailable');\n mutate(() => {\n const copied: FocusTarget = target.kind === 'notification'\n ? freeze({ kind: target.kind, handle: target.handle, ...(target.control ? { control: target.control } : {}) })\n : freeze({ kind: target.kind });\n focusRequest = freeze({ token: token() as FocusRequestToken, target: copied });\n });\n return { status: 'requested' };\n },\n acknowledgeOverflow,\n getSnapshot: () => snapshot,\n getServerSnapshot: () => SERVER,\n subscribe: (listener) => subscribe(listeners, listener),\n onEvent: (listener) => subscribe(eventListeners, listener),\n dispose() {\n if (disposed) return;\n mutate((deliveries) => {\n disposed = true;\n for (const record of records.values()) remove(record, 'dispose', deliveries);\n // Detached/admission-rejected handles also lose their capabilities.\n for (const notify of operationSubscriptions.values()) if (!deliveries.includes(notify)) deliveries.push(notify);\n lease = lastLease = null;\n island = null;\n attention = null;\n stopAttention();\n focusRequest = null;\n globalPauses.clear();\n overflow = overflowAnnounced = 0;\n }, true);\n },\n });\n\n function validHostOptions(value: HostOptions | undefined): boolean {\n if (value === undefined) return true;\n return value !== null && typeof value === 'object' && Object.keys(value).every((key) => key === 'attentionDelay')\n && (value.attentionDelay === undefined || validDelay(value.attentionDelay));\n }\n // Preserve the bridge's lease-first validation order in one entry guard.\n function withLease<Args extends unknown[], Result>(action: (...args: Args) => Result) {\n return (value: HostLease, ...args: Args) => {\n const error = leaseError(value);\n return error ? reject(error) : action(...args);\n };\n }\n const bridge = freeze<RendererBridge<Slot>>({\n renderError: options.messages?.renderError ?? 'Content unavailable',\n reportInvalidContainer(message, error) {\n if (!disposed) diagnostic({ code: 'invalid-container', source: 'Toaster.container', message, ...(error === undefined ? {} : { error }) });\n },\n attach(hostOptions) {\n if (disposed) return reject('disposed');\n if (lease !== null) {\n diagnostic({ code: 'second-host', source: 'attach', message: 'A renderer is already attached' });\n return reject('host-exists');\n }\n if (!validHostOptions(hostOptions)) return reject('invalid-input');\n const nextLease = token() as HostLease;\n mutate(() => {\n lease = lastLease = nextLease;\n hostDelay = hostOptions?.attentionDelay;\n if (presented) assign(presented);\n });\n return { status: 'attached', lease: nextLease };\n },\n detach(value) {\n if (disposed) return reject('disposed');\n if (lease === null && lastLease !== null && value === lastLease) return UNCHANGED;\n const error = leaseError(value);\n if (error) return reject(error);\n return mutate(() => {\n lease = null;\n hostDelay = undefined;\n setHostAutoDismiss(undefined);\n focusRequest = null;\n focused = null;\n globalPauses.clear();\n for (const record of records.values()) { record.pauses.clear(); record.readable = false; record.presentation = null; }\n });\n },\n getSnapshot: () => rendererSnapshot,\n getServerSnapshot: () => RENDERER_SERVER,\n subscribe: controller.subscribe,\n onEvent: controller.onEvent,\n openIsland: withLease((reason: IslandReason, handle?: NotificationHandle) => {\n if (reason !== 'user' && reason !== 'attention') return reject('invalid-input');\n let record: RecordState<Slot> | null;\n if (handle === undefined) record = newest();\n else {\n const error = handleError(handle);\n if (error) return reject(error);\n record = records.get(handle.id)!;\n }\n if (!record) return reject('empty');\n const target = record;\n if (island?.current === target) return UNCHANGED;\n // An open Island only moves its slider; the opening reason is kept.\n return mutate(() => {\n if (island) island.current = target;\n else island = { reason, current: target };\n });\n }),\n collapseIsland: withLease(() => island ? mutate(() => { island = null; }) : UNCHANGED),\n setAutoDismiss: withLease((value?: boolean) => {\n if (value !== undefined && typeof value !== 'boolean') return reject('invalid-input');\n if (autoDismissing(value) === autoDismissing(hostAutoDismiss)) { hostAutoDismiss = value; return UNCHANGED; }\n return mutate(() => setHostAutoDismiss(value));\n }),\n navigate: withLease(withRecord((record) => {\n if (!island) return reject('island-closed');\n if (island.current === record) return UNCHANGED;\n return mutate(() => {\n island!.current = record;\n // Navigation is interaction (DESIGN §5): a pending auto-open restarts its delay,\n // and reaching the initiator by hand fulfils it.\n if (attention?.record === record) attention = null;\n else if (attention) { attention.waiting = false; attention.due = clock.now() + (hostDelay ?? options.attentionDelay ?? ATTENTION_DELAY); }\n });\n })),\n setPause: withLease((change: PauseChange) => {\n if (!change || typeof change.active !== 'boolean') return reject('invalid-input');\n let set: Set<PauseReason>;\n if (change.scope === 'host') {\n if (!['hover', 'focus', 'document-hidden', 'window-blur'].includes(change.reason)) return reject('invalid-input');\n set = globalPauses;\n } else if (change.scope === 'notification') {\n const error = currentError(change.handle);\n if (error) return reject(error);\n if (!['gesture', 'content-transition'].includes(change.reason)) return reject('invalid-input');\n set = records.get(change.handle.id)!.pauses;\n } else return reject('invalid-input');\n if (set.has(change.reason) === change.active) return UNCHANGED;\n return mutate(() => {\n if (change.active) set.add(change.reason); else set.delete(change.reason);\n });\n }),\n // Informational since the stack has no slots to protect; it has no observable effect.\n setFocused: withLease((handle: NotificationHandle | null) => {\n const error = (handle === null ? undefined : currentError(handle));\n if (error) return reject(error);\n if (focused === handle) return UNCHANGED;\n focused = handle;\n return APPLIED;\n }),\n beginPresentation: withLease(withCurrent((record, previous: PresentationToken) => {\n if (record.presentation !== previous) return reject('stale-presentation');\n const presentation = token() as PresentationToken;\n mutate(() => { record.presentation = presentation; record.readable = false; });\n return { status: 'started' as const, token: presentation };\n })),\n acknowledgePresentation: withLease(withCurrent((record, presentation: PresentationToken) => {\n if (record.presentation !== presentation) return reject('stale-presentation');\n if (record.readable) return UNCHANGED;\n return mutate((deliveries) => {\n deliveries.push({ type: 'presented', handle: record.handle, firstPresentation: !record.everPresented });\n record.readable = record.everPresented = true;\n });\n })),\n acknowledgeFocus: withLease((focusToken: FocusRequestToken, outcome: 'focused' | 'unavailable') => {\n if (focusRequest?.token !== focusToken) return reject('stale-focus-request');\n if (outcome !== 'focused' && outcome !== 'unavailable') return reject('invalid-input');\n return mutate(() => { focusRequest = null; });\n }),\n acknowledgeOverflow: withLease(() => {\n return acknowledgeOverflow();\n }),\n acknowledgeAnnouncements: withLease((acknowledgements: readonly AnnouncementAcknowledgement[]) => {\n return acknowledgeAnnouncements(acknowledgements);\n }),\n dismiss: withLease((handle: NotificationHandle, reason: 'close-button' | 'swipe' | 'navigation') => {\n const error = handleError(handle);\n if (error) return reject(error);\n // Renderer close reasons are a closed protocol, never an exit callback.\n if (!['close-button', 'swipe', 'navigation'].includes(reason)) return reject('invalid-input');\n return dismiss(handle, reason);\n }),\n invokeAction: withLease(withRecord((record) => {\n const handle = record.handle;\n const action = record.content.action;\n if (!action || action.kind !== 'command') return reject('no-command');\n if (record.action.status === 'pending') return reject('already-pending');\n const actionToken = token() as ActionAttemptToken;\n const live = () => !disposed && records.get(handle.id) === record &&\n record.action.status === 'pending' && record.action.token === actionToken;\n const now = settle();\n record.action = freeze({ status: 'pending', token: actionToken });\n commit([{ type: 'action-started', handle, token: actionToken }], now);\n function failed(reason: unknown): void {\n if (!live()) return;\n let message = options.messages?.actionError ?? 'Action failed';\n if (action?.kind === 'command' && action.errorMessage) {\n try {\n const mapped = action.errorMessage(reason);\n if (typeof mapped !== 'string' || !mapped.trim()) throw new TypeError('Invalid action error message');\n message = mapped;\n } catch (error) {\n if (!disposed) failure('mapper-error', 'action.errorMessage', error, handle);\n }\n }\n if (!live()) return;\n const now = settle();\n record.action = freeze({ status: 'failed', token: actionToken, message });\n commit([{ type: 'action-failed', handle, token: actionToken, message }], now);\n }\n let result: Promise<unknown>;\n try { result = Promise.resolve(action.run(freeze({ handle, token: actionToken }))); }\n catch (error) { result = Promise.reject(error); }\n void result.then(() => {\n if (live()) dismiss(handle, 'action-success');\n }, failed).catch((error: unknown) => {\n if (!disposed) failure('callback-error', 'action-settlement', error, handle);\n });\n return { status: 'started' as const };\n })),\n retryOperation: withLease(withOperation((operation) => {\n const result = operation.retry();\n return result.status === 'started' ? { status: 'started' as const, token: result.attempt.token } : result;\n })),\n cancelOperation: withLease(withOperation((operation, reason?: unknown) => operation.cancel(reason))),\n reportDiagnostic: withLease((report: Diagnostic) => {\n if (!report || typeof report.source !== 'string' || typeof report.message !== 'string'\n || !['invalid-input', 'second-host', 'stale-host', 'mapper-error', 'callback-error', 'listener-error', 'cancellation-error', 'slot-error', 'formatter-error', 'invalid-container'].includes(report.code)) return reject('invalid-input');\n diagnostic(report);\n return APPLIED;\n }),\n });\n\n function acknowledgeAnnouncements(acks: readonly AnnouncementAcknowledgement[]): BridgeResult {\n if (!Array.isArray(acks)) return reject('invalid-input');\n // Stage only effective changes; no ledger mutation occurs until every\n // acknowledgement has passed validation. Repeated counts remain monotonic.\n const changes: (() => void)[] = [];\n const validCount = (count: number, maximum: number) => Number.isSafeInteger(count) && count >= 0 && count <= maximum;\n for (const ack of acks) {\n if (!ack || typeof ack !== 'object') return reject('invalid-input');\n if (ack.kind === 'overflow') {\n if (!validCount(ack.count, overflow)) return reject('invalid-input');\n if (ack.count > overflowAnnounced) changes.push(() => { overflowAnnounced = Math.max(overflowAnnounced, ack.count); });\n continue;\n }\n const error = handleError(ack.handle);\n if (error) return reject(error);\n const record = records.get(ack.handle.id)!;\n if (ack.kind === 'operation') {\n const operation = record.operation?.getSnapshot();\n if (!operation || operation.token !== ack.token) return reject('stale-operation-token');\n if (!['started', 'fulfilled', 'rejected', 'cancelled', 'cancel-requested'].includes(ack.phase)) return reject('invalid-input');\n if (ack.phase === 'cancel-requested' ? !operation.cancelRequested\n : ack.phase !== 'started' && ack.phase !== operation.status) return reject('invalid-input');\n if (!record.operationAnnounced.has(ack.phase)) changes.push(() => { record.operationAnnounced.add(ack.phase); });\n } else if (ack.kind === 'action') {\n if (record.action.status === 'idle' || record.action.token !== ack.token || record.action.status !== ack.status) return reject('invalid-input');\n if (record.actionAnnounced?.token !== ack.token || record.actionAnnounced?.status !== ack.status) {\n changes.push(() => { record.actionAnnounced = freeze({ token: ack.token, status: ack.status }); });\n }\n } else if (ack.kind === 'occurrences') {\n if (!validCount(ack.count, record.occurrences)) return reject('invalid-input');\n if (ack.count > record.occurrencesAnnounced) changes.push(() => { record.occurrencesAnnounced = Math.max(record.occurrencesAnnounced, ack.count); });\n } else if (ack.kind === 'queued' || ack.kind === 'first-presentation') {\n const key = ack.kind === 'queued' ? 'queuedAnnounced' : 'firstAnnounced';\n if (!record[key]) changes.push(() => { record[key] = true; });\n } else return reject('invalid-input');\n }\n if (!changes.length) return UNCHANGED;\n return mutate(() => { for (const apply of changes) apply(); });\n }\n\n publish();\n bridges.set(controller, bridge as RendererBridge<unknown>);\n return controller;\n}\n"],"mappings":";;AA2DA,IAAMA,IAAkB,KAElBC,IAAS,OAAO,QAGhBC,oBAAU,IAAI,QAAgB,GAC9BC,qBAAU,IAAI,QAAyC,GACzDC,IAAiB,GACfC,IAA0BJ,EAAO,CAAC,CAAC,GACnCK,KAA4BL,EAAO;CAAE,MAAM;CAAO,QAAQ;CAAM,SAAS;AAAK,CAAC,GAC/EM,IAAoCN,EAAO;CAC/C,YAAY;CAAM,UAAU;CAAG,UAAU;CAAO,eAAeI;CAAO,OAAOA;CAC7E,QAAQC;CAAW,UAAUL,EAAO;EAAE,OAAO;EAAG,SAAS;CAAM,CAAC;AAClE,CAAC,GACKO,IAA2CP,EAAO;CACtD,GAAGM;CAAQ,cAAc;CAAM,cAAc;CAC7C,eAAeN,EAAO;EAAE,eAAeI;EAAO,eAAe;CAAE,CAAC;AAClE,CAAC,GACKI,IAAOR,EAAO,EAAE,QAAQ,OAAgB,CAAC,GACzCS,IAAUT,EAAO,EAAE,QAAQ,UAAmB,CAAC,GAC/CU,IAAYV,EAAO,EAAE,QAAQ,YAAqB,CAAC,GACnDW,KAAiC,OAAoB;CAAE,QAAQ;CAAqB;AAAO;AAEjG,SAAgBC,EAA2D,GAAoE;CAC7I,IAAMC,IAASX,GAAQ,IAAIY,CAAU;CACrC,IAAI,CAACD,GAAQ,MAAU,UAAU,8DAA8D;CAE/F,OAAOA;AACT;AAGA,SAAgBE,EACd,GACA,GACkC;CAClC,IAAMC,IAAUC,EAAgBC,CAAY;CAC5C,IAAI,CAACC,GAAc,SAAS,OAAOA,EAAa,MAAM,OAAQ,cAAc,OAAOA,EAAa,MAAM,YAAa,YACjH,MAAU,UAAU,qCAAqC;CAE3D,IAAMC,IAAQD,EAAa;CAC3B,IAAI,OA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"controller.js","names":["freeze","handles","kernels","nextController","EMPTY","COLLAPSED","SERVER","RENDERER_SERVER","IDLE","NO_FORM_ERRORS","APPLIED","UNCHANGED","reject","getControllerKernel","kernel","controller","createCloudletCore","options","validateOptions","inputOptions","dependencies","clock","identity","records","listeners","eventListeners","operationSubscriptions","globalPauses","batches","focused","focusRequest","lease","lastLease","serial","autoId","revision","eventSequence","island","presented","hostDelay","hostAutoDismiss","attention","cancelAttention","attentionEpoch","overflow","overflowAnnounced","disposed","delivering","cancelTimer","timerEpoch","snapshot","rendererSnapshot","token","stackOrder","newest","retryable","operation","record","requiresAction","wantsAttention","rule","formOf","action","field","dirty","form","interacting","pauses","current","handleError","handle","withRecord","args","error","diagnostic","diagnosticValue","failure","source","notifyListeners","listener","set","enqueue","notify","delivery","deliveries","event","release","at","final","batch","settle","now","stopTimer","schedule","deadline","active","epoch","due","commit","publish","notifications","present","armAttention","mutate","apply","assign","retire","next","stopAttention","nominate","candidate","autoDismissing","host","setHostAutoDismiss","changed","value","budget","remove","order","index","onClose","notice","dismiss","reason","acknowledgeOverflow","subscribe","admit","issues","validateSpec","spec","insert","existing","occurrences","overflowValue","id","copyContent","initialize","emit","replaceContent","content","kind","track","factory","sourceThen","validateTrackOptions","input","key","cancelValue","cancelCallback","classifierValue","classifier","config","subscribers","notification","attached","snapshotValue","attemptNumber","createAttempt","cancellation","context","resolve","fail","result","fulfill","rejectResult","attempt","finish","first","getSnapshot","live","binding","run","deliver","initialStatus","status","fallback","mapper","mapped","validateContent","uiApplied","requestCancellation","patchContent","cancellationReason","cancel","start","restart","previous","admission","admitted","unsubscribe","validatePatch","patch","priority","durationChanged","previousBudget","nextBudget","count","target","copied"],"sources":["../../src/core/controller.ts"],"sourcesContent":["import type { CloudletController, ControllerOptions, FocusTarget } from '../contracts/controller.js';\nimport type { Diagnostic, EventBase, SemanticEvent } from '../contracts/events.js';\nimport type { ActionAttemptToken, ControllerIdentity, Generation, HandleRejection, NotificationHandle, OperationAttemptToken, Unsubscribe } from '../contracts/identity.js';\nimport type {\n FocusRequest, FocusRequestToken, ControllerDependencies, FormErrors, HostLease, OperationAnnouncementPhase, PresentationToken,\n RendererSnapshot,\n} from '../contracts/internal.js';\nimport type { AdmissionResult, CloseReason, FormAction, NotificationContent, NotificationKind, NotificationPatch, NotificationSpec, OperationAdmissionResult, Priority } from '../contracts/notifications.js';\nimport type { AttemptStartResult, CancellationSignal, CancelResult, OperationAttempt, OperationContext, OperationHandle, OperationSnapshot, OperationSource, OperationStatus, TrackOptions } from '../contracts/operations.js';\nimport type { ActionSnapshot, ControllerSnapshot, IslandReason, IslandSnapshot, PauseReason } from '../contracts/snapshots.js';\nimport { copyContent, patchContent, validateContent, validateOptions, validatePatch, validateSpec, validateTrackOptions } from './validation.js';\n\nexport interface OperationBinding {\n readonly getSnapshot: () => OperationSnapshot;\n readonly retry: () => AttemptStartResult<unknown>;\n readonly cancel: (reason?: unknown) => CancelResult;\n readonly detach: () => Delivery;\n}\n\ntype EventPayload = SemanticEvent extends infer E ? E extends SemanticEvent ? Omit<E, keyof EventBase> : never : never;\nexport type Delivery = EventPayload | { readonly callback: () => void; readonly source: string; readonly handle?: NotificationHandle };\n\nexport interface RecordState<Slot> {\n readonly handle: NotificationHandle;\n readonly dedupeKey: string | undefined;\n readonly onClose: NotificationSpec<Slot>['onClose'];\n content: Readonly<NotificationContent<Slot>>;\n kind: NotificationKind;\n priority: Priority;\n occurrences: number;\n remaining: number | null;\n activeSince: number | null;\n presentation: PresentationToken | null;\n readable: boolean;\n everPresented: boolean;\n readonly pauses: Set<PauseReason>;\n queuedAnnounced: boolean;\n firstAnnounced: boolean;\n occurrencesAnnounced: number;\n operation: OperationBinding | null;\n readonly operationAnnounced: Set<OperationAnnouncementPhase>;\n action: ActionSnapshot;\n actionAnnounced?: { readonly token: ActionAttemptToken; readonly status: 'pending' | 'failed' };\n /** Values of the form action the record holds; a new action object starts from its defaults. */\n form: FormState | null;\n}\n\nexport interface FormState {\n readonly action: FormAction;\n values: Readonly<Record<string, string>>;\n errors: FormErrors;\n}\n\n/** Open Island state; `null` is the collapsed stack. */\nexport interface IslandState<Slot> {\n readonly reason: IslandReason;\n current: RecordState<Slot>;\n}\n\nexport interface AttentionCandidate<Slot> {\n readonly record: RecordState<Slot>;\n due: number;\n /** Expired during user interaction or without a host; restarts the delay afterwards. */\n waiting: boolean;\n}\n\nexport const ATTENTION_DELAY = 600;\n\nconst freeze = Object.freeze;\n\n// Weak registries authenticate capabilities without retaining disposed controllers.\nconst handles = new WeakSet<object>();\nconst kernels = new WeakMap<object, ControllerKernel<unknown>>();\nlet nextController = 0;\nconst EMPTY: readonly never[] = freeze([]);\nconst COLLAPSED: IslandSnapshot = freeze({ open: false, reason: null, current: null });\nconst SERVER: ControllerSnapshot<never> = freeze({\n controller: null, revision: 0, disposed: false, notifications: EMPTY, stack: EMPTY,\n island: COLLAPSED, overflow: freeze({ count: 0, pending: false }),\n});\nexport const RENDERER_SERVER: RendererSnapshot<never> = freeze({\n ...SERVER, presentation: null, focusRequest: null, forms: EMPTY,\n announcements: freeze({ notifications: EMPTY, overflowCount: 0 }),\n});\nconst IDLE = freeze({ status: 'idle' as const });\nexport const NO_FORM_ERRORS: FormErrors = freeze({ form: null, fields: freeze({}) });\nexport const APPLIED = freeze({ status: 'applied' as const });\nexport const UNCHANGED = freeze({ status: 'unchanged' as const });\nexport const reject = <Reason extends string>(reason: Reason) => ({ status: 'rejected' as const, reason });\n\ntype Rejected<Reason extends string> = { status: 'rejected'; reason: Reason };\n\n/**\n * Controller state and transactions the renderer bridge needs (core/bridge.ts). The bridge travels\n * in the lazily loaded renderer chunk, so the start bundle carries only this accessor object.\n */\nexport interface ControllerKernel<Slot> {\n readonly options: ReturnType<typeof validateOptions>;\n readonly clock: ControllerDependencies<CancellationSignal>['clock'];\n readonly records: Map<string, RecordState<Slot>>;\n readonly globalPauses: Set<PauseReason>;\n readonly subscribe: CloudletController<Slot, CancellationSignal>['subscribe'];\n readonly onEvent: CloudletController<Slot, CancellationSignal>['onEvent'];\n readonly disposed: boolean;\n readonly presented: RecordState<Slot> | null;\n readonly rendererSnapshot: RendererSnapshot<Slot>;\n readonly overflow: number;\n lease: HostLease | null;\n lastLease: HostLease | null;\n hostDelay: number | undefined;\n hostAutoDismiss: boolean | undefined;\n island: IslandState<Slot> | null;\n attention: AttentionCandidate<Slot> | null;\n focusRequest: FocusRequest | null;\n focused: NotificationHandle | null;\n overflowAnnounced: number;\n readonly token: () => string;\n readonly diagnostic: (diagnostic: Diagnostic) => void;\n readonly failure: (code: Diagnostic['code'], source: string, error: unknown, handle?: NotificationHandle) => void;\n readonly mutate: (apply: (deliveries: Delivery[]) => void, final?: boolean) => typeof APPLIED;\n readonly commit: (deliveries?: readonly Delivery[], now?: number, final?: boolean) => void;\n readonly settle: () => number;\n readonly assign: (record: RecordState<Slot>) => void;\n readonly newest: () => RecordState<Slot> | null;\n readonly formOf: (record: RecordState<Slot>) => FormState | null;\n readonly handleError: (handle: NotificationHandle) => HandleRejection | 'disposed' | undefined;\n readonly withRecord: <Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result)\n => (handle: NotificationHandle, ...args: Args) => Result | Rejected<HandleRejection | 'disposed'>;\n readonly autoDismissing: (host: boolean | undefined) => boolean;\n readonly setHostAutoDismiss: (value: boolean | undefined) => void;\n readonly dismiss: (handle: NotificationHandle, reason: CloseReason) => typeof APPLIED | Rejected<HandleRejection | 'disposed'>;\n readonly acknowledgeOverflow: () => typeof APPLIED | typeof UNCHANGED | Rejected<'disposed'>;\n readonly reportRendererLoadError: (error: unknown) => void;\n}\n\nexport function getControllerKernel<Slot>(controller: object): ControllerKernel<Slot> {\n const kernel = kernels.get(controller);\n if (!kernel) throw new TypeError('Controller was not created by this Cloudlet package instance');\n // The registry stores the kernel together with its controller's opaque Slot type.\n return kernel as ControllerKernel<Slot>;\n}\n\n/** The sole owner of notification state, the stack/Island, budgets, attention and host leases. */\nexport function createCloudletCore<Slot = never, Signal extends CancellationSignal = CancellationSignal>(\n inputOptions: ControllerOptions | undefined,\n dependencies: ControllerDependencies<Signal>,\n): CloudletController<Slot, Signal> {\n const options = validateOptions(inputOptions);\n if (!dependencies?.clock || typeof dependencies.clock.now !== 'function' || typeof dependencies.clock.schedule !== 'function') {\n throw new TypeError('Cloudlet requires a monotonic clock');\n }\n const clock = dependencies.clock;\n if (typeof dependencies.createCancellation !== 'function') throw new TypeError('Cloudlet requires a cancellation source factory');\n const identity = `cloudlet-${++nextController}` as ControllerIdentity;\n const records = new Map<string, RecordState<Slot>>();\n const listeners = new Set<() => void>();\n const eventListeners = new Set<(event: SemanticEvent) => void>();\n const operationSubscriptions = new Map<Set<() => void>, Delivery>();\n const globalPauses = new Set<PauseReason>();\n const batches: (() => void)[] = [];\n let focused: NotificationHandle | null = null;\n let focusRequest: FocusRequest | null = null;\n let lease: HostLease | null = null;\n let lastLease: HostLease | null = null;\n let serial = 0;\n let autoId = 0;\n let revision = 0;\n let eventSequence = 0;\n let island: IslandState<Slot> | null = null;\n // The presented record: Island current when open, otherwise the newest record.\n let presented: RecordState<Slot> | null = null;\n let hostDelay: number | undefined;\n /** `Toaster autoDismiss`: overrides ControllerOptions.autoDismiss while defined and attached. */\n let hostAutoDismiss: boolean | undefined;\n let attention: AttentionCandidate<Slot> | null = null;\n let cancelAttention: Unsubscribe | null = null;\n let attentionEpoch = 0;\n let overflow = 0;\n let overflowAnnounced = 0;\n let disposed = false;\n let delivering = false;\n let cancelTimer: Unsubscribe | null = null;\n let timerEpoch = 0;\n let snapshot: ControllerSnapshot<Slot>;\n let rendererSnapshot: RendererSnapshot<Slot>;\n\n const token = () => `${identity}:${++serial}`;\n // Map insertion order is admission order; the stack shows newest first.\n const stackOrder = () => [...records.values()].reverse();\n const newest = (): RecordState<Slot> | null => stackOrder()[0] ?? null;\n // A settled factory can always retry; only an unsuccessful attempt offers retry as an action.\n const retryable = (record: RecordState<Slot>) => {\n const operation = record.operation?.getSnapshot();\n return !!operation?.canRetry && operation.status !== 'fulfilled';\n };\n const requiresAction = (record: RecordState<Slot>) => !!record.content.action\n || retryable(record) || record.content.attention === 'open';\n const wantsAttention = (record: RecordState<Slot>) => {\n const rule = record.content.attention ?? 'auto';\n return rule === 'open' || (rule === 'auto' && (requiresAction(record) || !!record.content.description));\n };\n /** The record's form state, started from the field defaults whenever its form action object changes. */\n const formOf = (record: RecordState<Slot>): FormState | null => {\n const action = record.content.action;\n if (action?.kind !== 'form') return record.form = null;\n if (record.form?.action !== action) {\n record.form = { action, errors: NO_FORM_ERRORS,\n values: freeze(Object.fromEntries(action.fields.map((field) => [field.name, field.defaultValue ?? '']))) };\n }\n return record.form;\n };\n const dirty = (record: RecordState<Slot>) => {\n const form = formOf(record);\n return !!form && form.action.fields.some((field) => form.values[field.name] !== (field.defaultValue ?? ''));\n };\n // A draft in the open Island holds it like a hand on it: attention never switches it away.\n const interacting = () => globalPauses.has('hover') || globalPauses.has('focus')\n || [...records.values()].some((record) => record.pauses.has('gesture')) || (!!island && dirty(island.current));\n const pauses = (record: RecordState<Slot>): PauseReason[] => {\n const current = record === presented;\n return [\n ...(!current ? ['inactive' as const] : []),\n ...(lease === null ? ['no-host' as const] : []),\n ...(current && !record.readable ? ['presentation-pending' as const] : []),\n // An Island opened by the user, or a slide that asks for action, keeps its time.\n ...(current && island && (island.reason === 'user' || requiresAction(record)) ? ['island' as const] : []),\n ...(record.action.status === 'pending' ? ['action-pending' as const] : []),\n ...(dirty(record) ? ['draft' as const] : []),\n ...globalPauses, ...record.pauses,\n ];\n };\n const handleError = (handle: NotificationHandle): HandleRejection | 'disposed' | undefined => {\n if (disposed) return 'disposed';\n if (typeof handle !== 'object' || handle === null || !handles.has(handle)) return 'invalid-handle';\n if (handle.controller !== identity) return 'foreign-controller';\n if (records.get(handle.id)?.handle !== handle) return 'stale-handle';\n return undefined;\n };\n\n // Capability validation always precedes method-specific validation/mutation.\n function withRecord<Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result) {\n return (handle: NotificationHandle, ...args: Args) => {\n const error = handleError(handle);\n return error ? reject(error) : action(records.get(handle.id)!, ...args);\n };\n }\n\n function diagnostic(diagnosticValue: Diagnostic): void {\n const value = freeze({ ...diagnosticValue });\n enqueue([{ type: 'diagnostic', diagnostic: value }]);\n }\n function failure(code: Diagnostic['code'], source: string, error: unknown, handle?: NotificationHandle): void {\n diagnostic({ code, source, message: `${source} failed`, error, ...(handle ? { handle } : {}) });\n }\n function notifyListeners(set: Set<() => void>, source: string): void {\n for (const listener of [...set]) {\n if (!set.has(listener)) continue;\n try { listener(); } catch (error) {\n failure('listener-error', source, error);\n }\n }\n }\n function enqueue(deliveries: readonly Delivery[], notify = false, at = clock.now(), final = false, release = false): void {\n batches.push(() => {\n if (notify) notifyListeners(listeners, 'subscribe');\n for (const delivery of deliveries) {\n if ('callback' in delivery) {\n try { delivery.callback(); } catch (error) {\n failure('callback-error', delivery.source, error, delivery.handle);\n }\n continue;\n }\n const event: SemanticEvent = freeze({ ...delivery, controller: identity, sequence: ++eventSequence,\n at: release ? clock.now() : at });\n for (const listener of [...eventListeners]) {\n if (!eventListeners.has(listener)) continue;\n try { listener(event); } catch (error) {\n if (event.type !== 'diagnostic') failure('listener-error', 'onEvent', error);\n }\n }\n if (event.type === 'diagnostic') {\n try { options.onDiagnostic?.(event.diagnostic); } catch { /* No recursive diagnostics. */ }\n }\n }\n // Close-callback diagnostics are queued before disposal releases observers.\n if (final) enqueue([{ type: 'disposed' }], false, at, false, true);\n if (release) {\n listeners.clear(); eventListeners.clear();\n for (const set of operationSubscriptions.keys()) set.clear();\n operationSubscriptions.clear();\n }\n });\n if (delivering) return;\n delivering = true;\n try {\n let batch: (() => void) | undefined;\n while ((batch = batches.shift())) batch();\n } finally { delivering = false; }\n }\n function settle(): number {\n const now = clock.now();\n for (const record of records.values()) {\n if (record.activeSince !== null && record.remaining !== null) {\n record.remaining = Math.max(0, record.remaining - Math.max(0, now - record.activeSince));\n record.activeSince = now;\n }\n }\n return now;\n }\n function stopTimer(): void {\n ++timerEpoch;\n cancelTimer?.();\n cancelTimer = null;\n }\n function schedule(now: number): void {\n stopTimer();\n let deadline = Infinity;\n for (const record of records.values()) {\n const active = record.remaining !== null && pauses(record).length === 0 && !disposed;\n record.activeSince = active ? now : null;\n if (active) deadline = Math.min(deadline, now + record.remaining!);\n }\n if (!Number.isFinite(deadline)) return;\n const epoch = timerEpoch;\n cancelTimer = clock.schedule(deadline, () => {\n if (disposed || epoch !== timerEpoch) return;\n const at = settle();\n const due = [...records.values()].filter((record) => record.activeSince !== null && record.remaining === 0);\n const deliveries: Delivery[] = [];\n for (const record of due) remove(record, 'timeout', deliveries);\n // An early delivery only rearms; a late delivery closes exactly the due generations.\n if (due.length) commit(deliveries, at);\n else schedule(at);\n });\n }\n function publish(): void {\n const current = [...records.values()];\n const notifications = freeze(current.map((record) => freeze({\n handle: record.handle, kind: record.kind, content: record.content, priority: record.priority,\n occurrences: record.occurrences, location: record === presented ? 'current' as const : 'stack' as const,\n remainingMs: record.remaining, pauseReasons: freeze(pauses(record)), operation: record.operation?.getSnapshot() ?? null, action: record.action,\n draft: dirty(record),\n })));\n snapshot = freeze({ controller: identity, revision, disposed, notifications,\n stack: freeze(stackOrder().map((record) => record.handle)),\n island: island ? freeze({ open: true, reason: island.reason, current: island.current.handle }) : COLLAPSED,\n overflow: freeze({ count: overflow, pending: overflow > 0 }),\n });\n rendererSnapshot = freeze({ ...snapshot,\n presentation: presented ? freeze({ handle: presented.handle, token: presented.presentation, readable: presented.readable }) : null,\n focusRequest,\n forms: freeze(current.flatMap((record) => {\n const form = formOf(record);\n return form ? [freeze({ handle: record.handle, values: form.values, errors: form.errors })] : [];\n })),\n announcements: freeze({ overflowCount: overflowAnnounced,\n notifications: freeze(current.map((record) => freeze({\n handle: record.handle, queued: record.queuedAnnounced, firstPresentation: record.firstAnnounced,\n occurrences: record.occurrencesAnnounced, action: record.actionAnnounced ?? null, operation: record.operation ? freeze({\n token: record.operation.getSnapshot().token, phases: freeze([...record.operationAnnounced]),\n }) : null,\n }))),\n }),\n });\n }\n function commit(deliveries: readonly Delivery[] = [], now = clock.now(), final = false): void {\n present();\n schedule(now);\n armAttention(now);\n ++revision;\n publish();\n enqueue(deliveries, true, now, final);\n }\n // Every state mutation settles the old budget, publishes once, then delivers.\n // The presented record is derived inside that transaction, before subscribers can reenter.\n function mutate(apply: (deliveries: Delivery[]) => void, final = false) {\n const now = settle();\n const deliveries: Delivery[] = [];\n apply(deliveries);\n commit(deliveries, now, final);\n return APPLIED;\n }\n function assign(record: RecordState<Slot>): void {\n record.readable = false;\n record.presentation = lease === null ? null : token() as PresentationToken;\n }\n function retire(record: RecordState<Slot>): void {\n record.presentation = null;\n record.readable = false;\n record.pauses.clear();\n if (focused === record.handle) focused = null;\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === record.handle) focusRequest = null;\n }\n /** A change of the presented record mints a new presentation token; its predecessor keeps its budget. */\n function present(): void {\n const next = island ? island.current : newest();\n if (next === presented) return;\n if (presented) retire(presented);\n presented = next;\n if (next) assign(next);\n }\n function stopAttention(): void {\n ++attentionEpoch;\n cancelAttention?.();\n cancelAttention = null;\n }\n /** Newest candidate wins: a new nomination replaces the pending one. */\n function nominate(record: RecordState<Slot>, now: number): void {\n if (wantsAttention(record)) attention = { record, due: now + (hostDelay ?? options.attentionDelay ?? ATTENTION_DELAY), waiting: false };\n }\n function armAttention(now: number): void {\n stopAttention();\n const candidate = attention;\n if (!candidate || disposed) return;\n // Without a host nothing has landed yet: wait without allocating a timer.\n if (lease === null) { candidate.waiting = true; return; }\n if (candidate.waiting) {\n if (interacting()) return;\n candidate.waiting = false;\n candidate.due = now + (hostDelay ?? options.attentionDelay ?? ATTENTION_DELAY);\n }\n const epoch = attentionEpoch;\n cancelAttention = clock.schedule(candidate.due, () => {\n if (disposed || epoch !== attentionEpoch || attention !== candidate) return;\n const at = clock.now();\n if (at < candidate.due) { armAttention(at); return; }\n cancelAttention = null;\n // Expiry during hover/focus/gesture waits; the next release restarts the delay.\n if (interacting()) { candidate.waiting = true; return; }\n attention = null;\n const record = candidate.record;\n if (!wantsAttention(record) || island?.current === record) return;\n mutate(() => {\n if (island) island.current = record;\n else island = { reason: 'attention', current: record };\n });\n });\n }\n const autoDismissing = (host: boolean | undefined) => (host ?? options.autoDismiss) !== false;\n /** Off stops every budget; on starts each one in full. */\n function setHostAutoDismiss(value: boolean | undefined): void {\n const changed = autoDismissing(value) !== autoDismissing(hostAutoDismiss);\n hostAutoDismiss = value;\n if (!changed) return;\n for (const record of records.values()) record.remaining = budget(record);\n }\n function budget(record: RecordState<Slot>): number | null {\n if (!autoDismissing(hostAutoDismiss)) return null;\n if (record.content.duration !== undefined) return record.content.duration;\n return (record.kind === 'info' || record.kind === 'success') && !record.content.action ? 6000 : null;\n }\n function remove(record: RecordState<Slot>, reason: CloseReason, deliveries: Delivery[]): void {\n if (island?.current === record) {\n // The next older slide, else the next newer one, else the Island closes.\n const order = stackOrder();\n const index = order.indexOf(record);\n const next = order[index + 1] ?? order[index - 1];\n if (next) island.current = next; else island = null;\n }\n if (attention?.record === record) attention = null;\n records.delete(record.handle.id);\n if (record.operation) deliveries.push(record.operation.detach());\n deliveries.push({ type: 'closed', handle: record.handle, reason });\n if (record.onClose) {\n const onClose = record.onClose;\n const notice = freeze({ handle: record.handle, reason });\n deliveries.push({ callback: () => onClose(notice), source: 'onClose', handle: record.handle });\n }\n }\n const dismiss = withRecord((record, reason: CloseReason) =>\n mutate((deliveries) => remove(record, reason, deliveries)));\n function acknowledgeOverflow() {\n if (disposed) return reject('disposed');\n if (!overflow) return UNCHANGED;\n return mutate((deliveries) => {\n deliveries.push({ type: 'overflow-acknowledged', count: overflow });\n overflow = overflowAnnounced = 0;\n if (focusRequest?.target.kind === 'overflow') focusRequest = null;\n });\n }\n function subscribe<T>(set: Set<T>, listener: T): Unsubscribe {\n if (typeof listener !== 'function') throw new TypeError('Listener must be a function');\n if (disposed) return () => {};\n set.add(listener);\n return () => { set.delete(listener); };\n }\n function admit(spec: NotificationSpec<Slot>): AdmissionResult {\n if (disposed) return reject('disposed');\n const issues = validateSpec(spec);\n if (issues.length) {\n diagnostic({ code: 'invalid-input', source: 'show', message: 'Invalid notification specification' });\n return { ...reject('invalid-input'), issues };\n }\n return insert(spec);\n }\n function insert(spec: NotificationSpec<Slot>, initialize?: (record: RecordState<Slot>) => void): AdmissionResult {\n if (spec.id !== undefined && records.has(spec.id)) return reject('id-conflict');\n const existing = spec.dedupeKey === undefined ? undefined : [...records.values()].find((record) => record.dedupeKey === spec.dedupeKey);\n if (existing) {\n let occurrences = existing.occurrences;\n mutate((deliveries) => {\n occurrences = existing.occurrences = Math.min(Number.MAX_SAFE_INTEGER, occurrences + 1);\n deliveries.push({ type: 'deduplicated', handle: existing.handle, occurrences });\n });\n return { status: 'deduplicated', handle: existing.handle, occurrences };\n }\n if (records.size >= 100) {\n mutate((deliveries) => {\n overflow = Math.min(Number.MAX_SAFE_INTEGER, overflow + 1);\n const overflowValue = freeze({ count: overflow, pending: true });\n deliveries.push({ type: 'overflow', count: overflow });\n if (options.onOverflow) deliveries.push({ callback: () => options.onOverflow!(overflowValue), source: 'onOverflow' });\n });\n return reject('capacity');\n }\n const now = settle();\n let id = spec.id;\n if (id === undefined) { do { id = `${identity}:notification-${++autoId}`; } while (records.has(id)); }\n const handle = freeze({ id, controller: identity, generation: token() as Generation }) as NotificationHandle;\n handles.add(handle);\n const record: RecordState<Slot> = {\n handle: handle,\n dedupeKey: spec.dedupeKey,\n onClose: spec.onClose,\n content: copyContent(spec),\n kind: spec.kind ?? 'info',\n priority: spec.priority ?? 'normal',\n occurrences: 1,\n remaining: null,\n activeSince: null,\n presentation: null,\n readable: false,\n everPresented: false,\n pauses: new Set(),\n queuedAnnounced: false,\n firstAnnounced: false,\n occurrencesAnnounced: 0,\n operation: null,\n operationAnnounced: new Set(),\n action: IDLE,\n form: null,\n };\n record.remaining = budget(record);\n records.set(id, record);\n initialize?.(record);\n nominate(record, now);\n const deliveries: Delivery[] = [{ type: 'admitted', handle }];\n if (record.operation) {\n const operation = record.operation.getSnapshot();\n deliveries.push({ type: 'operation-started', handle, token: operation.token, attempt: operation.attempt });\n }\n commit(deliveries, now);\n return { status: 'created', handle };\n }\n function emit(deliveries: readonly Delivery[]): void {\n if (disposed) return;\n enqueue(deliveries);\n }\n function replaceContent(record: RecordState<Slot>, content: Readonly<NotificationContent<Slot>>, kind: NotificationKind): void {\n record.content = content;\n record.kind = kind;\n record.remaining = kind === 'loading' ? null : budget(record);\n // A replacement owns a new action context; old completions cannot close it.\n record.action = IDLE;\n if (record === presented) assign(record);\n // A runner phase (terminal result or new attempt) is evaluated like an admission.\n nominate(record, clock.now());\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === record.handle &&\n focusRequest.target.control === 'action' && !content.action) focusRequest = null;\n }\n function track<T>(source: OperationSource<T, Signal>, input: TrackOptions<T, Slot, Signal>): OperationHandle<T> {\n const factory = typeof source === 'function' ? source : null;\n let sourceThen: PromiseLike<T>['then'] | undefined;\n if (!factory && (source === null || typeof source !== 'object' || typeof (sourceThen = source.then) !== 'function')) {\n throw new TypeError('Operation source must be a factory or thenable');\n }\n const issues = validateTrackOptions(input, factory !== null);\n // Invalid presentation options cannot suppress a valid business source. Read\n // only data properties here; validation never executes option accessors.\n const field = (key: keyof TrackOptions<T, Slot, Signal>): unknown => input && typeof input === 'object'\n ? Object.getOwnPropertyDescriptor(input, key)?.value : undefined;\n const cancelValue = field('cancel');\n const cancelCallback = !factory && typeof cancelValue === 'function' ? cancelValue as (reason: unknown) => void : null;\n const classifierValue = field('isCancellation');\n const classifier = typeof classifierValue === 'function' ? classifierValue as NonNullable<TrackOptions<T, Slot, Signal>['isCancellation']> : null;\n const config = issues.length ? null : freeze({ ...input,\n pending: copyContent(input.pending),\n success: typeof input.success === 'function' ? input.success : copyContent(input.success),\n error: typeof input.error === 'function' ? input.error : copyContent(input.error),\n ...(input.cancelled === undefined ? {} : { cancelled: typeof input.cancelled === 'function' ? input.cancelled : copyContent(input.cancelled) }),\n });\n const subscribers = new Set<() => void>();\n let notification: NotificationHandle | null = null;\n let attached = false;\n let snapshotValue: OperationSnapshot;\n let attemptNumber = 0;\n type Attempt = {\n readonly public: OperationAttempt<T>;\n readonly context: OperationContext<Signal>;\n readonly abort: (reason?: unknown) => void;\n readonly resolve: (value: T | PromiseLike<T>) => void;\n readonly reject: (reason: unknown) => void;\n status: OperationStatus;\n cancelRequested: boolean;\n };\n function createAttempt(): Attempt {\n const cancellation = dependencies.createCancellation();\n const context = freeze({ signal: cancellation.signal, token: token() as OperationAttemptToken, attempt: ++attemptNumber });\n let resolve!: Attempt['resolve'];\n let fail!: Attempt['reject'];\n const result = new Promise<T>((fulfill, rejectResult) => { resolve = fulfill; fail = rejectResult; });\n const attempt: Attempt = {\n public: freeze({ token: context.token, attempt: context.attempt, result }), context,\n abort: cancellation.abort, resolve, reject: fail, status: 'pending', cancelRequested: false,\n };\n // Observe both branches without altering the public promise's value/reason.\n // The derived internal chain is handled as well, even if a platform port fails.\n void result.then((value) => finish(attempt, 'fulfilled', value), (error: unknown) => finish(attempt, 'rejected', error))\n .catch((error: unknown) => {\n if (!disposed) failure('callback-error', 'operation-settlement', error);\n });\n return attempt;\n }\n const first = createAttempt();\n let current = first;\n function getSnapshot(): OperationSnapshot {\n const next = {\n token: current.context.token, attempt: current.context.attempt, status: current.status,\n cancelRequested: current.cancelRequested,\n canCancel: !disposed && current.status === 'pending' && !current.cancelRequested && (!!factory || !!cancelCallback),\n canRetry: !disposed && !!factory && current.status !== 'pending',\n notification: attached && !disposed ? notification : null,\n };\n if (!snapshotValue || Object.keys(next).some((key) => next[key as keyof OperationSnapshot] !== snapshotValue[key as keyof OperationSnapshot])) {\n snapshotValue = freeze(next);\n }\n return snapshotValue;\n }\n const notify: Delivery = { source: 'operation.subscribe',\n callback: () => notifyListeners(subscribers, 'operation.subscribe') };\n function live(attempt: Attempt): RecordState<Slot> | undefined {\n if (disposed || current !== attempt || !attached || !notification) return undefined;\n const record = records.get(notification.id);\n return record?.handle === notification && record.operation === binding ? record : undefined;\n }\n function run(attempt: Attempt): void {\n // Validate and assimilate the same then method once, preserving its receiver.\n // Reading a user accessor again could replace the business outcome.\n try { attempt.resolve(factory ? factory(attempt.context) : { then: sourceThen!.bind(source) }); }\n catch (error) { attempt.reject(error); }\n }\n function deliver(deliveries: Delivery[], apply?: () => void): void {\n if (apply) {\n const now = settle();\n apply();\n commit(deliveries, now);\n } else emit(deliveries);\n }\n function finish(attempt: Attempt, initialStatus: 'fulfilled' | 'rejected', value: unknown): void {\n attempt.status = initialStatus;\n if (initialStatus === 'rejected') {\n try {\n const cancelled = classifier ? classifier(value, attempt.context) === true\n : attempt.cancelRequested && value !== null && typeof value === 'object' && 'name' in value && value.name === 'AbortError';\n if (cancelled) attempt.status = 'cancelled';\n } catch (error) {\n if (!disposed) failure('cancellation-error', 'isCancellation', error);\n }\n }\n let content: Readonly<NotificationContent<Slot>> | undefined;\n if (live(attempt) && config) {\n const status = attempt.status;\n const fallback = status === 'fulfilled' ? options.messages?.operationSuccess ?? 'Completed'\n : status === 'cancelled' ? options.messages?.operationCancelled ?? 'Cancelled'\n : options.messages?.operationError ?? 'Something went wrong';\n try {\n const mapper = status === 'fulfilled' ? config.success : status === 'cancelled' ? config.cancelled : config.error;\n const mapped = typeof mapper === 'function' ? mapper(value as T) : mapper ?? { title: fallback };\n if (validateContent(mapped).length) throw new TypeError('Invalid terminal notification content');\n content = copyContent(mapped);\n } catch (error) {\n content = freeze({ title: fallback, announcementPriority: 'polite' });\n if (!disposed) failure('mapper-error', `track.${status}`, error, notification ?? undefined);\n }\n }\n // User mappers, classifiers and diagnostic listeners are reentrant.\n const record = live(attempt);\n const uiApplied = !!record && !!content;\n const deliveries: Delivery[] = [\n ...(current === attempt ? [notify] : []),\n { type: 'operation-settled', handle: notification, token: attempt.context.token, status: attempt.status, uiApplied },\n ];\n deliver(deliveries, record && content ? () => replaceContent(record, content,\n attempt.status === 'fulfilled' ? 'success' : attempt.status === 'cancelled' ? 'warning' : 'error') : undefined);\n }\n function requestCancellation(attempt: Attempt, reason: unknown): void {\n attempt.cancelRequested = true;\n const record = live(attempt);\n const deliveries: Delivery[] = [notify, { type: 'cancellation-requested', handle: notification, token: attempt.context.token }];\n deliver(deliveries, record ? () => {\n record.content = patchContent(record.content, { title: options.messages?.cancellationRequested ?? 'Cancellation requested' });\n } : undefined);\n try {\n attempt.abort(reason);\n cancelCallback?.(reason);\n } catch (error) {\n if (!disposed) failure('cancellation-error', 'cancel', error, notification ?? undefined);\n }\n }\n function cancellationReason(): Error {\n const error = new Error('Cancellation requested');\n error.name = 'AbortError';\n return error;\n }\n function cancel(reason: unknown = cancellationReason()): CancelResult {\n if (disposed) return reject('disposed');\n if (current.status !== 'pending') return { status: 'unchanged', reason: 'settled' };\n if (!factory && !cancelCallback) return reject('not-cancellable');\n if (current.cancelRequested) return { status: 'unchanged', reason: 'already-requested' };\n requestCancellation(current, reason);\n return { status: 'requested' };\n }\n function start(restart: boolean): AttemptStartResult<T> {\n if (disposed) return reject('disposed');\n if (!factory) return reject('not-retryable');\n if (current.status === 'pending' && !restart) return reject('already-pending');\n const previous = current;\n const next = createAttempt();\n current = next; // Invalidate old ownership before any observer or abort callback.\n const record = live(next);\n const deliveries: Delivery[] = [notify, { type: 'operation-started', handle: notification, token: next.context.token, attempt: next.context.attempt }];\n deliver(deliveries, record && config ? () => {\n record.operationAnnounced.clear();\n replaceContent(record, config.pending, 'loading');\n } : undefined);\n if (previous.status === 'pending' && !previous.cancelRequested) requestCancellation(previous, cancellationReason());\n run(next);\n return { status: 'started', attempt: next.public };\n }\n const binding: OperationBinding = {\n getSnapshot, retry: () => start(false), cancel,\n detach: () => { attached = false; return notify; },\n };\n let admission: OperationAdmissionResult;\n if (disposed) admission = reject('disposed');\n else if (!config) {\n admission = { ...reject('invalid-input'), issues };\n diagnostic({ code: 'invalid-input', source: 'track', message: 'Invalid operation options' });\n } else {\n const admitted = insert({ ...config.pending, ...config, kind: 'loading' }, (record) => {\n notification = record.handle;\n attached = true;\n record.operation = binding;\n });\n // No dedupe key can reach this path (validated TrackOptions).\n if (admitted.status === 'deduplicated') throw new Error('Tracked operation cannot be deduplicated');\n admission = admitted;\n }\n if (admission.status === 'rejected') emit([{ type: 'operation-started', handle: null, token: first.context.token, attempt: 1 }]);\n run(first);\n return freeze({ ...first.public, admission: freeze(admission), getSnapshot,\n subscribe(listener: () => void) {\n const unsubscribe = subscribe(subscribers, listener);\n if (subscribers.size) operationSubscriptions.set(subscribers, notify);\n return () => { unsubscribe(); if (!subscribers.size) operationSubscriptions.delete(subscribers); };\n },\n cancel, retry: () => start(false), restart: () => start(true),\n });\n }\n\n const controller = freeze<CloudletController<Slot, Signal>>({\n show: (spec) => admit(spec),\n track,\n update: withRecord((record, patch: NotificationPatch<Slot>) => {\n const handle = record.handle;\n const issues = validatePatch(patch);\n if (issues.length) {\n diagnostic({ code: 'invalid-input', source: 'update', message: 'Invalid notification patch', handle });\n return { ...reject('invalid-input'), issues };\n }\n if (record.action.status === 'pending' && Object.prototype.hasOwnProperty.call(patch, 'action')) return reject('action-pending');\n if (record.operation && (Object.prototype.hasOwnProperty.call(patch, 'kind') ||\n (record.operation.getSnapshot().status === 'pending' && Object.prototype.hasOwnProperty.call(patch, 'duration')))) return reject('operation-owned');\n const content = patchContent(record.content, patch);\n const kind = patch.kind ?? record.kind;\n const priority = patch.priority ?? record.priority;\n const durationChanged = Object.prototype.hasOwnProperty.call(patch, 'duration');\n if (content === record.content && kind === record.kind && priority === record.priority && !durationChanged &&\n !(Object.prototype.hasOwnProperty.call(patch, 'action') && record.action.status === 'failed')) return UNCHANGED;\n return mutate((deliveries) => {\n const previousBudget = budget(record);\n record.content = content;\n if (Object.prototype.hasOwnProperty.call(patch, 'action')) record.action = IDLE;\n record.kind = kind;\n record.priority = priority;\n const nextBudget = budget(record);\n if (durationChanged || previousBudget !== nextBudget) record.remaining = nextBudget;\n if (focusRequest?.target.kind === 'notification' && focusRequest.target.handle === handle && focusRequest.target.control === 'action' && !content.action) focusRequest = null;\n if (attention?.record === record && !wantsAttention(record)) attention = null;\n deliveries.push({ type: 'updated', handle });\n });\n }),\n getHandle: (id) => !disposed && typeof id === 'string' ? records.get(id)?.handle : undefined,\n dismiss: (handle) => dismiss(handle, 'programmatic'),\n clear() {\n if (disposed) return reject('disposed');\n const count = records.size;\n if (!count) return { status: 'cleared', count };\n mutate((deliveries) => {\n for (const record of records.values()) remove(record, 'clear', deliveries);\n });\n return { status: 'cleared', count };\n },\n requestFocus(target: FocusTarget = { kind: 'anchor' }) {\n if (disposed) return reject('disposed');\n if (target?.kind === 'notification') {\n const error = handleError(target.handle);\n if (error) return reject(error);\n }\n if (!lease) return reject('no-host');\n if (!target || !['anchor', 'notification', 'overflow'].includes(target.kind)) return reject('unavailable');\n if (target.kind === 'notification') {\n const record = records.get(target.handle.id)!;\n if (record !== presented) return reject('not-visible');\n if (target.control !== undefined && !['action', 'close'].includes(target.control)) return reject('unavailable');\n if (target.control === 'action' && !record.content.action) return reject('unavailable');\n // Card controls exist only inside the open Island; the collapsed pill has none.\n if (target.control !== undefined && !island) return reject('not-visible');\n }\n if (target.kind === 'overflow' && !overflow) return reject('unavailable');\n mutate(() => {\n const copied: FocusTarget = target.kind === 'notification'\n ? freeze({ kind: target.kind, handle: target.handle, ...(target.control ? { control: target.control } : {}) })\n : freeze({ kind: target.kind });\n focusRequest = freeze({ token: token() as FocusRequestToken, target: copied });\n });\n return { status: 'requested' };\n },\n acknowledgeOverflow,\n getSnapshot: () => snapshot,\n getServerSnapshot: () => SERVER,\n subscribe: (listener) => subscribe(listeners, listener),\n onEvent: (listener) => subscribe(eventListeners, listener),\n dispose() {\n if (disposed) return;\n mutate((deliveries) => {\n disposed = true;\n for (const record of records.values()) remove(record, 'dispose', deliveries);\n // Detached/admission-rejected handles also lose their capabilities.\n for (const notify of operationSubscriptions.values()) if (!deliveries.includes(notify)) deliveries.push(notify);\n lease = lastLease = null;\n island = null;\n attention = null;\n stopAttention();\n focusRequest = null;\n globalPauses.clear();\n overflow = overflowAnnounced = 0;\n }, true);\n },\n });\n\n publish();\n kernels.set(controller, freeze<ControllerKernel<Slot>>({\n options, clock, records, globalPauses, subscribe: controller.subscribe, onEvent: controller.onEvent,\n get disposed() { return disposed; },\n get presented() { return presented; },\n get rendererSnapshot() { return rendererSnapshot; },\n get overflow() { return overflow; },\n get lease() { return lease; }, set lease(value) { lease = value; },\n get lastLease() { return lastLease; }, set lastLease(value) { lastLease = value; },\n get hostDelay() { return hostDelay; }, set hostDelay(value) { hostDelay = value; },\n get hostAutoDismiss() { return hostAutoDismiss; }, set hostAutoDismiss(value) { hostAutoDismiss = value; },\n get island() { return island; }, set island(value) { island = value; },\n get attention() { return attention; }, set attention(value) { attention = value; },\n get focusRequest() { return focusRequest; }, set focusRequest(value) { focusRequest = value; },\n get focused() { return focused; }, set focused(value) { focused = value; },\n get overflowAnnounced() { return overflowAnnounced; }, set overflowAnnounced(value) { overflowAnnounced = value; },\n token, diagnostic, failure, mutate, commit, settle, assign, newest, formOf, handleError, withRecord,\n autoDismissing, setHostAutoDismiss, dismiss, acknowledgeOverflow,\n reportRendererLoadError(error) {\n if (!disposed) diagnostic({ code: 'renderer-load-error', source: 'Toaster', message: 'Toaster renderer failed to load', error });\n },\n }) as ControllerKernel<unknown>);\n return controller;\n}\n"],"mappings":";AAoEA,IAAMA,IAAS,OAAO,QAGhBC,oBAAU,IAAI,QAAgB,GAC9BC,oBAAU,IAAI,QAA2C,GAC3DC,IAAiB,GACfC,IAA0BJ,EAAO,CAAC,CAAC,GACnCK,IAA4BL,EAAO;CAAE,MAAM;CAAO,QAAQ;CAAM,SAAS;AAAK,CAAC,GAC/EM,IAAoCN,EAAO;CAC/C,YAAY;CAAM,UAAU;CAAG,UAAU;CAAO,eAAeI;CAAO,OAAOA;CAC7E,QAAQC;CAAW,UAAUL,EAAO;EAAE,OAAO;EAAG,SAAS;CAAM,CAAC;AAClE,CAAC,GACYO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ACjF,IAAI,YAAY;GAAE,OAAO5E;EAAW;EAAG,IAAI,UAAU,GAAO;GAAE,IAAY4E;EAAO;EACjF,IAAI,kBAAkB;GAAE,OAAO3E;EAAiB;EAAG,IAAI,gBAAgB,GAAO;GAAE,IAAkB2E;EAAO;EACzG,IAAI,SAAS;GAAE,OAAO9E;EAAQ;EAAG,IAAI,OAAO,GAAO;GAAE,IAAS8E;EAAO;EACrE,IAAI,YAAY;GAAE,OAAO1E;EAAW;EAAG,IAAI,UAAU,GAAO;GAAE,IAAY0E;EAAO;EACjF,IAAI,eAAe;GAAE,OAAOrF;EAAc;EAAG,IAAI,aAAa,GAAO;GAAE,IAAeqF;EAAO;EAC7F,IAAI,UAAU;GAAE,OAAOtF;EAAS;EAAG,IAAI,QAAQ,GAAO;GAAE,IAAUsF;EAAO;EACzE,IAAI,oBAAoB;GAAE,OAAOtE;EAAmB;EAAG,IAAI,kBAAkB,GAAO;GAAE,IAAoBsE;EAAO;EACjH;EAAO;EAAY;EAAS;EAAQ;EAAQ;EAAQ;EAAQ;EAAQ;EAAQ;EAAa;EACzF;EAAgB;EAAoB;EAAS;EAC7C,wBAAwB,GAAO;GAC7B,AAAKrE,KAAU4B,EAAW;IAAE,MAAM;IAAuB,QAAQ;IAAW,SAAS;IAAmC;GAAM,CAAC;EACjI;CACF,CAAC,CAA8B,GACxB3D;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAEV,mBAAmB,EACnB,iBAAiB,EAGlB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KA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