import { clearPendingKeepRuleLogin } from "../../../../lib/create/pendingKeepRuleLogin"; import { clearLastPublishedRule } from "../../../../lib/create/lastPublishedRule"; import { clearCreateFlowPersistedDrafts } from "./clearCreateFlowPersistedDrafts"; const LEGACY_LIVE_KEY = "create-flow-state"; const LEGACY_DRAFT_KEY = "create-flow-draft"; /** * Drop every Rule the browser is holding: the anonymous draft, last finished * Rule, keep-this-rule prompt, and leftover pre-anonymous keys. Does not * `DELETE /api/drafts/me`. Call after Log out and Delete account. */ export function clearBrowserRuleData(): void { clearCreateFlowPersistedDrafts(); clearLastPublishedRule(); clearPendingKeepRuleLogin(); if (typeof window === "undefined") return; try { window.localStorage.removeItem(LEGACY_LIVE_KEY); window.localStorage.removeItem(LEGACY_DRAFT_KEY); } catch { // ignore } }