import { z as AccountPermission, q as AccountBalance, v as KeyUsageOptions, s as UsageResponse, K as KeyInfo, p as AccountProfile } from '../types-ZIAZIVEM.js'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; interface AuthStateValue { apiKey: string | null; isLoggedIn: boolean; isHydrated: boolean; error: Error | null; } /** * Per-call overrides for the OAuth authorize redirect. Each field maps to a * BYOP (bring-your-own-policy) URL parameter on `enter.pollinations.ai/authorize` * — see `` props for the same fields as provider-level defaults. */ interface AuthorizeRequest { /** Extra OAuth scopes appended to provider defaults. */ permissions?: AccountPermission[]; /** Restrict the minted key to these model slugs. Omit / empty = all models. */ models?: string[]; /** Pollen budget to request for the minted key. */ budget?: number; /** Days until the minted key expires. */ expiry?: number; } interface AuthActionsValue { login: (request?: AuthorizeRequest) => void; logout: () => void; setApiKey: (apiKey: string | null) => void; /** Resolved enter URL, useful for top-up / dashboard links. */ enterUrl: string; /** Resolved account API URL used by opt-in account hooks. */ apiBaseUrl: string; } interface AuthContextValue extends AuthStateValue, AuthActionsValue { } interface AccountResourceValue { data: T | null; isLoading: boolean; error: Error | null; refresh: () => Promise; } interface UseAccountKeyUsageOptions extends KeyUsageOptions { enabled?: boolean; } type UseAccountProfileValue = AccountResourceValue; type UseAccountBalanceValue = AccountResourceValue; type UseAccountKeyValue = AccountResourceValue; type UseAccountKeyUsageValue = AccountResourceValue; /** Current auth session state only. Does not fetch account data. */ declare function useAuthState(): AuthStateValue; /** Stable login/logout refs and provider config. */ declare function useAuthActions(): AuthActionsValue; /** Combined thin auth hook. Account data is available through opt-in hooks. */ declare function useAuth(): AuthContextValue; /** Current account profile for the delegated key. */ declare function useAccountProfile(options?: { enabled?: boolean; }): AccountResourceValue; /** Current visible balance for the delegated key. */ declare function useAccountBalance(options?: { enabled?: boolean; }): AccountResourceValue; /** Current delegated key metadata. */ declare function useAccountKey(options?: { enabled?: boolean; }): AccountResourceValue; /** Usage for the current delegated key only. */ declare function useAccountKeyUsage(options?: UseAccountKeyUsageOptions): UseAccountKeyUsageValue; /** * Synchronous key/value store for the user's session token and OAuth state. * Modeled on `window.localStorage` — implement against any sync backend * (cookies, in-memory, sessionStorage). Async backends (IndexedDB, RN * AsyncStorage) are out of scope. */ interface StorageAdapter { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; } type StorageOption = "localStorage" | "sessionStorage" | StorageAdapter; declare const DEFAULT_ENTER_URL = "https://enter.pollinations.ai"; interface PolliProviderProps { /** Publishable key (`pk_...`): the app identifier, not a user's API key. */ appKey: string; children: ReactNode; /** * Where to persist the user's session token. Defaults to `"localStorage"`. * Accepts `"sessionStorage"` or a custom synchronous `StorageAdapter` * (e.g. cookie-backed or in-memory). Async backends like IndexedDB or * React Native AsyncStorage are not supported — the interface is sync * because hydration runs in a `useEffect`. */ storage?: StorageOption; /** OAuth scopes to request at login. Defaults to no optional account scopes. */ permissions?: AccountPermission[]; /** * Default model slugs to request access to (BYOP). Empty / undefined means * "all models". Per-call `login({ models })` overrides this. */ models?: string[]; /** * Default pollen budget to request for the minted key. Per-call * `login({ budget })` overrides this. */ budget?: number; /** * Default key lifetime in days. Per-call `login({ expiry })` overrides this. */ expiry?: number; /** Auth host. Defaults to `https://enter.pollinations.ai`. */ enterUrl?: string; /** Account API host. Derived from `enterUrl + "/api"` unless explicitly set. */ apiBaseUrl?: string; } /** * Provides Pollinations auth state to descendants. Wrap your app once at the * root. Holds the delegated API key, handles the OAuth callback, and exposes * login/logout. Account data is fetched by opt-in hooks so apps only request * the data they render. */ declare function PolliProvider({ appKey, children, storage: storageOption, permissions, models: defaultModels, budget: defaultBudget, expiry: defaultExpiry, enterUrl, apiBaseUrl, }: PolliProviderProps): react_jsx_runtime.JSX.Element; export { type AccountResourceValue, type AuthActionsValue, type AuthContextValue, type AuthStateValue, DEFAULT_ENTER_URL, PolliProvider, type PolliProviderProps, type StorageAdapter, type StorageOption, type UseAccountBalanceValue, type UseAccountKeyUsageOptions, type UseAccountKeyUsageValue, type UseAccountKeyValue, type UseAccountProfileValue, useAccountBalance, useAccountKey, useAccountKeyUsage, useAccountProfile, useAuth, useAuthActions, useAuthState };