import { ListenInput, MSG_RESPONSE, Message, Message as Message$1, MessageData, MessageType, ProtocolMessage, ProtocolMessage as ProtocolMessage$1, RequestMachineContext, RequestMachineContext as RequestMachineContext$1, ResponseMessage } from "@sanity/comlink";
import { ClientPerspective, ContentSourceMap, ContentSourceMapDocuments, MutationEvent, QueryParams, ReconnectEvent, SanityDocument, SyncTag, WelcomeEvent } from "@sanity/client";
import { DocumentSchema, InsertMenuOptions, PreviewSnapshot, PreviewSnapshot as PreviewSnapshot$1, ResolvedSchemaTypeMap, ResolvedSchemaTypeMap as ResolvedSchemaTypeMap$1, SanityNode, SanityNode as SanityNode$1, SanityStegaNode, SanityStegaNode as SanityStegaNode$1, SchemaArrayItem, SchemaArrayNode, SchemaBooleanNode, SchemaInlineNode, SchemaNode, SchemaNullNode, SchemaNumberNode, SchemaObjectField, SchemaObjectNode, SchemaStringNode, SchemaType, SchemaType as SchemaType$1, SchemaUnionNode, SchemaUnionNodeOptions, SchemaUnionOption, SchemaUnknownNode, TypeSchema, UnresolvedPath, UnresolvedPath as UnresolvedPath$1 } from "@sanity/visual-editing-types";
import { Path } from "@sanity/client/csm";
declare const createCompatibilityActors: <T extends Message$1>() => {
  listen: import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage$1>;
  }, import("@sanity/comlink").ListenInput, import("xstate").EventObject>;
  requestMachine: import("xstate").StateMachine<RequestMachineContext$1<T>, {
    type: 'message';
    data: ProtocolMessage$1<import("@sanity/comlink").ResponseMessage>;
  } | {
    type: 'abort';
  }, {
    "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage$1<import("@sanity/comlink").ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>> | undefined;
  }, {
    src: "listen";
    logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage$1<import("@sanity/comlink").ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>;
    id: "listen for response";
  }, {
    type: "on abort";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on fail";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on success";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "send message";
    params: {
      message: ProtocolMessage$1;
    };
  }, {
    type: "expectsResponse";
    params: unknown;
  }, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
    channelId: string;
    data?: T["data"] | undefined;
    domain: string;
    expectResponse?: boolean;
    from: string;
    parentRef: import("xstate").AnyActorRef;
    resolvable?: PromiseWithResolvers<T["response"]> | undefined;
    responseTimeout?: number;
    responseTo?: string;
    signal?: AbortSignal;
    sources: Set<MessageEventSource> | MessageEventSource;
    suppressWarnings?: boolean;
    targetOrigin: string;
    to: string;
    type: T["type"];
  }, {
    requestId: string;
    response: T["response"] | null;
    responseTo: string | undefined;
  }, {
    type: 'request.failed';
    requestId: string;
  } | {
    type: 'request.aborted';
    requestId: string;
  } | {
    type: 'request.success';
    requestId: string;
    response: import("@sanity/comlink").MessageData | null;
    responseTo: string | undefined;
  }, import("xstate").MetaObject, {
    states: {
      readonly idle: {};
      readonly sending: {};
      readonly awaiting: {};
      readonly failed: {};
      readonly success: {};
      readonly aborted: {};
    };
  }>;
};
declare function isMaybePreviewIframe(): boolean;
declare function isMaybePreviewWindow(): boolean;
declare function isMaybePresentation(): boolean;
/**
 * Preview frame history update
 * @public
 */
type HistoryUpdate = {
  type: 'push' | 'pop' | 'replace';
  title?: string;
  url: string;
};
/**
 * @deprecated - the new major of Sanity Studio will no longer send this event, as better APIs like `loader/query-listen`, are available
 */
type DeprecatedHistoryRefreshMutation = {
  /**
   * source 'mutation' means a document were mutated and the preview might need to refresh
   */
  source: 'mutation';
  /**
   * If true then there's either preview-kit or a loader connected on the page
   * @deprecated – it's up to the application to know wether loaders are enabled or not, and how best to implement a refresh handler that works optimally,
   *               the next major of Sanity Studio will not set this field
   */
  livePreviewEnabled: boolean;
  /**
   * Select metadata about the document that were mutated
   * If it's prefixed with `drafts.` then it's a draft document, otherwise it's a published document.
   */
  document: {
    /**
     * If it's prefixed with `drafts.` then it's a draft document, otherwise it's a published document.
     */
    _id: string;
    /**
     * The document type is frequently used in `revalidateTag` scenarios with Next.js App Router
     */
    _type: string;
    /**
     * The document revision, can be used to dedupe requests, as we always send two due to debouncing and handling Content Lake eventual consistency
     */
    _rev: string;
    /**
     * If the document has a top level slug field named `slug` with the type `slug`, then it'll be included here
     */
    slug?: {
      current?: string | null;
    };
  };
};
/**
 * Preview frame history refresh event, emitted by Presentation Tool
 * @public
 */
type HistoryRefresh = {
  /**
   * source 'manual' means the refresh button were clicked by the user
   */
  source: 'manual';
  /**
   * If true then there's either preview-kit or a loader connected on the page
   * @deprecated – it's up to the application to know wether loaders are enabled or not, and how best to implement a refresh handler that works optimally,
   *               the next major of Sanity Studio will not set this field
   */
  livePreviewEnabled: boolean;
} | DeprecatedHistoryRefreshMutation;
/**
 * @public
 */
type VisualEditingControllerMsg = {
  type: 'presentation/focus';
  data: {
    id: string;
    path: string;
  };
} | {
  type: 'presentation/blur';
  data: undefined;
} | {
  type: 'presentation/navigate';
  data: HistoryUpdate;
} | {
  type: 'presentation/toggle-overlay';
  data: undefined;
} | {
  type: 'presentation/refresh';
  data: HistoryRefresh;
} | {
  type: 'presentation/perspective';
  data: {
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
  };
} |
/**
 * @deprecated switch to explict schema fetching (using
 * 'visual-editing/schema') at next major
 */
{
  type: 'presentation/schema';
  data: {
    schema: SchemaType$1[];
  };
} | {
  type: 'presentation/preview-snapshots';
  data: {
    snapshots: PreviewSnapshot$1[];
  };
} | {
  type: 'presentation/snapshot-event';
  data: {
    event: ReconnectEvent | WelcomeEvent | MutationEvent;
  };
} | {
  type: 'presentation/shared-state';
  data: {
    key: string;
    value?: Serializable;
  };
} | {
  /**
   * Special event where Presentation Tool is unable to connect to a target iframe or popup window, and is asking for status with `targetOrigin: *` to detect
   * if the URL origin is misconfigured. Presentation doesn't send any data, as any listener can see it.
   */
  type: 'presentation/status';
  data: undefined;
};
/**
 * @public
 */
type VisualEditingNodeMsg = {
  type: 'visual-editing/focus';
  data: SanityNode$1 | SanityStegaNode$1;
} | {
  type: 'overlay/focus';
  data: SanityNode$1 | SanityStegaNode$1;
} | {
  type: 'visual-editing/navigate';
  data: HistoryUpdate;
} | {
  type: 'overlay/navigate';
  data: HistoryUpdate;
} | {
  type: 'visual-editing/toggle';
  data: {
    enabled: boolean;
  };
} | {
  type: 'overlay/toggle';
  data: {
    enabled: boolean;
  };
} | {
  type: 'visual-editing/meta';
  data: {
    title: string;
  };
} | {
  type: 'visual-editing/documents';
  data: {
    projectId?: string;
    dataset?: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
    documents: ContentSourceMapDocuments;
  };
} | {
  type: 'visual-editing/preview-snapshots';
  data: undefined;
  response: {
    snapshots: PreviewSnapshot$1[];
  };
} | {
  type: 'visual-editing/refreshing';
  data: HistoryRefresh;
} | {
  type: 'visual-editing/refreshed';
  data: HistoryRefresh;
} | {
  type: 'visual-editing/schema';
  data: undefined;
  response: {
    schema: SchemaType$1[];
  };
} | {
  type: 'visual-editing/schema-union-types';
  data: {
    paths: UnresolvedPath$1[];
  };
  response: {
    types: ResolvedSchemaTypeMap$1;
  };
} | {
  type: 'visual-editing/observe-documents';
  data: {
    documentIds: string[];
  };
} | {
  type: 'visual-editing/fetch-snapshot';
  data: {
    documentId: string;
  };
  response: {
    snapshot: SanityDocument<Record<string, any>> | undefined | void;
  };
} | {
  type: 'visual-editing/mutate';
  data: {
    transactionId: string | undefined;
    mutations: any[];
  };
  response: any;
} | {
  type: 'visual-editing/snapshot-welcome';
  data: undefined;
  response: {
    event: WelcomeEvent;
  };
} | {
  type: 'visual-editing/fetch-perspective';
  data: undefined | {
    /**
     * Specifies if <VisualEditing> has a `onPerspectiveChange` prop, which signals perspective changes are handled and should not trigger full page reload
     */
    handlesPerspectiveChange: boolean;
    /**
     * Specifies if <VisualEditing> has an `onVariantChange` prop, which signals variant changes are handled and should not trigger a full page reload
     */
    handlesVariantChange?: boolean;
  };
  response: {
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
  };
} | {
  type: 'visual-editing/features';
  data: undefined;
  response: {
    features: Record<string, boolean>;
  };
} | {
  type: 'visual-editing/shared-state';
  data: undefined;
  response: {
    state: SerializableObject;
  };
} | {
  type: 'visual-editing/telemetry-log';
  data: {
    event: any;
    data: any;
  };
} | {
  /**
   * Special event related to the `presentation/status` event, where comlink is unable to connect,
   * and we're asking for some status information to detect if the URL origin is misconfigured.
   */
  type: 'visual-editing/status';
  data: {
    origin: string;
  };
};
/**
 * @public
 */
type LoaderControllerMsg = {
  type: 'loader/perspective';
  data: {
    projectId: string;
    dataset: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
  };
} | {
  type: 'loader/query-change';
  data: {
    projectId: string;
    dataset: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
    query: string;
    params: QueryParams;
    result: any;
    resultSourceMap?: ContentSourceMap;
    tags?: SyncTag[];
  };
};
/**
 * @public
 */
type LoaderNodeMsg = {
  type: 'loader/query-listen';
  data: {
    projectId: string;
    dataset: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
    query: string;
    params: QueryParams;
    /**
     * If above 0, then the loader will fire listen events on a heartbeat interval,
     * allowing Presentation Tool to detect when it's no longer necessary to subscribe to a query.
     */
    heartbeat?: number;
  };
} | {
  /**
   * Sends over the CSM reported documents in use on the page. If there are multiple queries and thus
   * multiple CSM's, they're all deduped and concatenated into a single list.
   */
  type: 'loader/documents';
  data: {
    projectId: string;
    dataset: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
    documents: ContentSourceMapDocuments;
  };
};
/**
 * @public
 */
type PreviewKitNodeMsg = {
  /**
   * Sends over the CSM reported documents in use on the page. If there are multiple queries and thus
   * multiple CSM's, they're all deduped and concatenated into a single list.
   */
  type: 'preview-kit/documents';
  data: {
    projectId: string;
    dataset: string;
    perspective: ClientPerspective;
    /**
     * The selected editing variant (bare variant id). Undefined when no variant is selected.
     */
    variant?: string;
    documents: ContentSourceMapDocuments;
  };
};
/**
 * @public
 */
type SerializablePrimitive = string | number | boolean | null | undefined;
/**
 * @public
 */
type SerializableObject = {
  [key: string]: Serializable;
};
/**
 * @public
 */
type SerializableArray = Serializable[];
/**
 * @public
 */
type Serializable = SerializablePrimitive | SerializableObject | SerializableArray;
export { type DocumentSchema, type HistoryRefresh, type HistoryUpdate, type InsertMenuOptions, type ListenInput, type LoaderControllerMsg, type LoaderNodeMsg, MSG_RESPONSE, type Message, type MessageData, type MessageType, type Path, type PreviewKitNodeMsg, type PreviewSnapshot, type ProtocolMessage, type RequestMachineContext, type ResolvedSchemaTypeMap, type ResponseMessage, type SanityNode, type SanityStegaNode, type SchemaArrayItem, type SchemaArrayNode, type SchemaBooleanNode, type SchemaInlineNode, type SchemaNode, type SchemaNullNode, type SchemaNumberNode, type SchemaObjectField, type SchemaObjectNode, type SchemaStringNode, type SchemaType, type SchemaUnionNode, type SchemaUnionNodeOptions, type SchemaUnionOption, type SchemaUnknownNode, type Serializable, type SerializableArray, type SerializableObject, type SerializablePrimitive, type TypeSchema, type UnresolvedPath, type VisualEditingControllerMsg, type VisualEditingNodeMsg, createCompatibilityActors, isMaybePresentation, isMaybePreviewIframe, isMaybePreviewWindow };
//# sourceMappingURL=index.d.ts.map