// System clipboard (docs/app-lifecycle-plan.md). Write is fire-and-forget; read is async because
// web gates it behind a permission prompt (native hosts complete synchronously).

export const clipboard = {
  /** Put `text` on the system clipboard. Silent no-op on hosts without clipboard access. */
  write(text: string): void {
    _creatorUtils.clipboardWrite?.(text)
  },
  /** Read text from the system clipboard. Rejects when the platform has no clipboard access, the
   *  user denied it, or there is nothing readable. */
  read(): Promise<string> {
    return new Promise((resolve, reject) => {
      if (typeof _creatorUtils.clipboardRead !== "function") {
        reject(new Error("Clipboard is not supported on this platform"))
        return
      }
      _creatorUtils.clipboardRead(resolve, (err: string) => reject(new Error(err)))
    })
  },
}
