import { resource } from "@assistant-ui/tap";
import type { ClientOutput } from "@assistant-ui/store";
import type { AttachmentRuntime } from "../../runtime/api/attachment-runtime";
import { tapSubscribable } from "./tap-subscribable";

export const AttachmentRuntimeClient = resource(
  ({ runtime }: { runtime: AttachmentRuntime }): ClientOutput<"attachment"> => {
    const state = tapSubscribable(runtime);

    return {
      getState: () => state,
      remove: runtime.remove,
      __internal_getRuntime: () => runtime,
    };
  },
);
