"use client";

import { useState } from "react";
import { getNavState, type NavStateKey } from "@/lib/navigationState";
import { publishIntentFromNav, type PublishIntent } from "@/lib/publishPermissions";

/** Peek once per route visit; the form remains the only consumer of the payload. */
export function usePublishFormIntent(intent: PublishIntent, navStateKey?: NavStateKey): PublishIntent {
  return useState(() => navStateKey ? publishIntentFromNav(getNavState(navStateKey)) : intent)[0];
}
