import { ReactNode, ReactElement } from 'react'; import { HallidayPaymentsConfig, DepositConfig, WithdrawalConfig, HallidayPayments, HallidaySnapshot } from '@halliday-sdk/payments'; /** * Public React surface. The Provider accepts the **declarative, serializable** slice of the config * as flat props; the **imperative** wallet roles (functions) flow through `useHallidayPayments().updateWallets` * instead, so they never need to survive a serialize/diff cycle. */ /** * Declarative Provider props: the serializable config minus `owner` (a function bag), the per-flow wallet * roles (`deposit.funders`/`withdrawal.funder`), and `targetElementId` (owned by ``). */ type ProviderConfig = Omit & { deposit?: Omit; withdrawal?: Omit; }; /** Either declarative config props (Provider owns the instance) or a bring-your-own instance — never both. */ type HallidayPaymentsProviderProps = (ProviderConfig & { children: ReactNode; instance?: never; }) | { instance: HallidayPayments; children: ReactNode; }; /** The imperative wallet slice pushed through `updateWallets` (functions live here, not in props). */ type WalletParams = Pick & { deposit?: Pick; withdrawal?: Pick; }; /** The value returned by `useHallidayPayments` — the reactive snapshot plus instance-bound actions. */ interface UseHallidayPaymentsResult extends HallidaySnapshot { openDeposit: HallidayPayments["openDeposit"]; openWithdrawal: HallidayPayments["openWithdrawal"]; openActivity: () => void; openOrder: (paymentId: string) => void; close: () => void; updateWallets: (wallets: WalletParams) => void; instance: HallidayPayments; } /** * Provides a single `HallidayPayments` instance to the subtree. Two mutually-exclusive modes: * * - **Owned (config props):** the Provider constructs the instance once (with `autoPreload:false`), warms it * on mount, pushes reactive prop changes through `diffConfig`→`updateConfig`, and `destroy()`s it on * unmount. The host wallet-connect hook rides a stable proxy (`connectRef`) so it stays current without a * re-wire and without surviving the (function-excluding) diff. * - **BYO (`instance` prop):** the Provider uses the caller's instance and never preloads or destroys it — * the caller owns its lifecycle. * * `` child effects run before this Provider's warm effect, so registering an EMBED target via * `embed()` happens before warming → the iframe is born in EMBED mode with no MODAL→EMBED reload. */ declare const HallidayPaymentsProvider: (props: HallidayPaymentsProviderProps) => ReactElement; /** * Subscribe to the Provider's instance and read its reactive snapshot. Returns the snapshot * fields (`isReady`/`isOpen`/`status`/`error`) plus the instance-bound entry points, `updateWallets`, and the * instance itself. * * The snapshot is read through `useSyncExternalStore(core.subscribe, core.getSnapshot)`; `core.getSnapshot` * returns a referentially-stable object between unchanged reads, so React only re-renders on a real transition. */ declare const useHallidayPayments: () => UseHallidayPaymentsResult; /** * Inline EMBED mount point. Renders a `
` and registers its id with the Provider's instance, so * the widget mounts in place instead of as a MODAL overlay. * * The child effect runs before the Provider's warm effect, so the target is registered before warming → * the iframe is born in EMBED mode with no MODAL→EMBED reload. Singleton per Provider (a second * `` is dev-warned and ignored); unmounting returns the instance to MODAL. */ declare const HallidayEmbed: () => ReactElement; export { HallidayEmbed, HallidayPaymentsProvider, useHallidayPayments }; export type { HallidayPaymentsProviderProps, ProviderConfig, UseHallidayPaymentsResult, WalletParams };