import { writable } from 'svelte/store'; export interface Confirmation { title: string; message: string; confirmLabel?: string; danger?: boolean; } export const confirmation = writable(null); let resolvePending: ((accepted: boolean) => void) | null = null; /** Resolve only from a deliberate confirm/cancel action; never default to acceptance. */ export function confirmAction(options: Confirmation): Promise { resolvePending?.(false); return new Promise(resolve => { resolvePending = resolve; confirmation.set(options); }); } export function resolveConfirmation(accepted: boolean): void { const resolve = resolvePending; resolvePending = null; confirmation.set(null); resolve?.(accepted); }