import type { ReactiveController, ReactiveControllerHost } from 'lit'; /** * Host slots the controller drives. {@link RoxyDataElement} satisfies this, so the form mixin can attach a controller without the component wiring state by hand. * * @remarks * Intersected with `HTMLElement` because the controller dispatches events on the host. Lit's `ReactiveControllerHost` is the update-lifecycle contract only (`addController`, `requestUpdate`, `updateComplete`) and carries no DOM surface, even though every real host is a `LitElement` and therefore an `HTMLElement`. Declaring the DOM half is what the controller actually needs; it used to reach it through a `this.host as unknown as EventTarget` double cast instead, which asserted a capability the type never promised. */ type FetchHost = ReactiveControllerHost & HTMLElement & { data: T | null; loading: boolean; error: string | null; }; /** Default RoxyAPI v2 origin. A component overrides it per instance via its `base-url` attribute. */ /** The public API root. Exported so anything else that must reach the API (the field-label * fetch in `endpoint-form`) uses the SAME origin as every data request instead of a second copy. */ export declare const DEFAULT_BASE_URL = "https://roxyapi.com/api/v2"; /** * Turn a failed `Response` into the message to show: the API's own `{ error }` string when the body carries one, else the status line. * * @remarks * Exported so every client-side fetch boundary renders the same words for the same failure, the way {@link keyIsRefused} centralizes the key refusal. A boundary that discards the response body cannot tell a rejected request from an empty result, and renders the two identically. */ export declare function readApiError(res: Response): Promise; /** A single request the controller issues on the component's behalf. */ export interface RoxyRequest { /** Path under the API base, e.g. "/dreams/symbols/water" or "/astrology/natal-chart". */ path: string; method?: 'GET' | 'POST'; /** JSON body for POST endpoints. */ body?: unknown; /** Query string parameters; nullish values are dropped. */ query?: Record; } /** * Client-side fetch for uncontrolled (self-fetching) components: drives `host.data` / `host.loading` / `host.error` and cancels a stale request when a newer one starts or the host disconnects. * * @remarks * Security boundary. The only credential this ever sends is a `pk_` publishable key, which carries a server-side origin allowlist. A secret (`sk_`) or legacy unprefixed key is refused before any network call and surfaced as an error, so a server secret cannot leak into a browser request. This centralizes the guard that originated in `` so every self-fetching component enforces it identically. * * Controlled-mode components never construct this. When a server injects the response as a `