import type { ShareVisibility } from "./useShareDialogController.js"; /** * Whether moving to `to` shows more of the resource to more people than `from` * does and so needs an explicit confirmation. Public -> organization narrows * access and Public stays confirmation-free, so only private -> organization * asks. */ export declare function visibilityNeedsConfirmation(from: ShareVisibility, to: ShareVisibility): boolean; /** * Why a requested visibility change was never saved: `ignored` when the * request was refused up front (closed surface, no manage rights, a save * already running) and `dropped` when it was held for confirmation and then * cancelled or invalidated. */ export declare class ShareVisibilityNotSavedError extends Error { readonly reason: "ignored" | "dropped"; constructor(reason: "ignored" | "dropped"); } export interface ShareVisibilityTransitionOptions { resourceType: string; resourceId: string; /** The visibility shown right now, including an in-flight optimistic one. */ current: ShareVisibility; /** The organization the resource belongs to, from the share listing. */ orgId: string | null; canManage: boolean; /** False while the share surface is closed; a pending request is dropped. */ active: boolean; /** Saves the visibility. Rejects on failure so the caller can show it. */ apply: (next: ShareVisibility) => Promise; /** * Receives a failure of a change that needed no confirmation. Required so a * failed save is never left looking like a successful one. */ onDirectError: (error: unknown) => void; } export interface ShareVisibilityTransitionRequest { from: ShareVisibility; to: ShareVisibility; } export interface ShareVisibilityTransition { /** The change waiting for confirmation, or null. Nothing is saved yet. */ pending: ShareVisibilityTransitionRequest | null; /** * The resource's organization name, only when it was read for that exact * organization. Null means "say your organization" instead of a name. */ organizationName: string | null; submitting: boolean; /** Why the last confirmation failed; the request stays pending to retry. */ error: string | null; /** * Saves `next` at once, or holds it for confirmation when it broadens. * The promise resolves only once the change is persisted. A change that * needs no confirmation rejects with the save's failure. A held change that * fails when confirmed keeps its `error` and stays pending so the user can * retry, and its promise stays pending too: it resolves after a successful * retry and rejects with `ShareVisibilityNotSavedError` once the change is * cancelled or invalidated (resource change, closed surface, lost manage * rights). A request that is refused up front rejects the same way. * While a save runs, the same target joins it and a different target is * refused with reason `ignored` until the write settles. */ request: (next: ShareVisibility) => Promise; confirm: () => Promise; cancel: () => void; } export declare function useShareVisibilityTransition(options: ShareVisibilityTransitionOptions): ShareVisibilityTransition;