{"version":3,"sources":["../src/index.ts","../src/provider.tsx","../src/use-checkout.ts","../src/checkout-button.tsx","../src/use-customer.ts","../src/use-customer-data.ts","../src/use-query.ts","../src/use-merchant-data.ts","../src/webhook.ts"],"sourcesContent":["export { WaffoPancakeProvider } from \"./provider.js\";\nexport { CheckoutButton } from \"./checkout-button.js\";\nexport { useCheckout } from \"./use-checkout.js\";\nexport { useCustomer, useBuyer } from \"./use-customer.js\";\nexport {\n  useCustomerOrders,\n  useCustomerPayments,\n  useCustomerRefundTickets,\n  useBuyerOrders,\n  useBuyerPayments,\n  useBuyerRefundTickets,\n} from \"./use-customer-data.js\";\nexport { useMerchantOrders, useMerchantSales, useMerchantSubscriptions } from \"./use-merchant-data.js\";\nexport { Webhook } from \"./webhook.js\";\n\n// Re-export types commonly used in client components\nexport { WaffoPancakeError, ChangeTiming, TaxCategory, WebhookEventType } from \"@waffo/pancake-ts\";\n\nexport type {\n  PriceInfo,\n  PriceSnapshot,\n  BillingDetail,\n  RequestedAmount,\n  RefundTicketVersionData,\n  WebhookEvent,\n  WebhookEventData,\n  CashierLanguage,\n  PaymentMethod,\n  RequestOptions,\n} from \"@waffo/pancake-ts\";\n\n// Local types\nexport type {\n  CheckoutMode,\n  CheckoutBaseOptions,\n  LinkCheckoutProps,\n  AnonymousCheckoutProps,\n  AuthenticatedCheckoutProps,\n  CheckoutProps,\n  UseCheckoutReturn,\n} from \"./types.js\";\n\nexport type { CustomerConfig, BuyerConfig, WaffoPancakeProviderProps } from \"./provider.js\";\n\nexport type {\n  CheckoutButtonProps,\n  LinkCheckoutButtonProps,\n  AnonymousCheckoutButtonProps,\n  AuthenticatedCheckoutButtonProps,\n} from \"./checkout-button.js\";\n\nexport type { CustomerActionState, UseCustomerReturn, BuyerActionState, UseBuyerReturn } from \"./use-customer.js\";\n\nexport type { QueryState } from \"./use-query.js\";\n\nexport type {\n  CustomerOnetimeOrder,\n  CustomerSubscriptionOrder,\n  CustomerPayment,\n  CustomerRefundTicket,\n  BuyerOnetimeOrder,\n  BuyerSubscriptionOrder,\n  BuyerPayment,\n  BuyerRefundTicket,\n} from \"./use-customer-data.js\";\n\nexport type {\n  MerchantOrder,\n  MerchantSubscription,\n  SalesOverview,\n  SubscriptionOverview,\n  MerchantOrdersOptions,\n} from \"./use-merchant-data.js\";\n\nexport type { WebhookConfig } from \"./webhook.js\";\n\n// Server action types (for typing the action prop)\nexport type {\n  CheckoutAction,\n  CheckoutActionParams,\n  CheckoutActionResult,\n  CustomerTokenAction,\n  CustomerSessionAction,\n  BuyerTokenAction,\n  BuyerSessionAction,\n  MerchantQueryAction,\n} from \"./server.js\";\n","\"use client\";\n\nimport React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { CustomerTokenAction, CustomerSessionAction } from \"./server.js\";\n\n/** Customer configuration for automatic token management */\nexport interface CustomerConfig {\n  /** Customer identity (email or merchant-provided identifier) */\n  identity: string;\n  /** Store ID (optional when `productId` is provided) */\n  storeId?: string;\n  /** Product ID — used to derive the store when `storeId` is omitted */\n  productId?: string;\n  /** Server action for issuing tokens — from `createCustomerTokenAction()` */\n  issueToken: CustomerTokenAction;\n  /** Server action for customer operations — from `createCustomerSessionAction()` */\n  sessionAction: CustomerSessionAction;\n}\n\n/** @deprecated Use {@link CustomerConfig} instead. */\nexport type BuyerConfig = CustomerConfig;\n\ninterface TokenState {\n  token: string;\n  expiresAt: number;\n}\n\n/** @internal */\nexport interface PancakeContextValue {\n  /** Get a valid customer token (auto-refreshes if expired) */\n  getCustomerToken: () => Promise<string>;\n  /** Execute a customer session operation via server action */\n  customerSessionAction: CustomerSessionAction;\n  /** Whether customer config is provided */\n  hasCustomer: boolean;\n  /** Whether the initial token is ready */\n  isCustomerReady: boolean;\n}\n\n/** @internal Exported for direct useContext access in hooks */\nexport const PancakeContext = createContext<PancakeContextValue | null>(null);\n\n/** Token refresh buffer — refresh 30s before actual expiry */\nconst REFRESH_BUFFER_MS = 30_000;\n\nexport interface WaffoPancakeProviderProps {\n  /** Customer configuration for automatic token management */\n  customer?: CustomerConfig;\n  /** @deprecated Use `customer` instead. */\n  buyer?: CustomerConfig;\n  children: React.ReactNode;\n}\n\n/**\n * Provider that manages customer token lifecycle via server actions.\n *\n * Auto-issues session tokens on mount and refreshes before expiry.\n * All customer hooks (`useCustomer`, `useCustomerOrders`, etc.) read from context.\n *\n * The private key never leaves the server — token issuance and customer\n * operations are delegated to server actions.\n *\n * @param props - Provider configuration\n * @param props.customer - Customer identity and server actions\n * @param props.buyer - Deprecated alias of `customer`\n * @param props.children - React children\n *\n * @example\n * ```tsx\n * // identity must match what you passed as `buyerIdentity` at checkout time —\n * // customer-portal lookups are keyed by merchant_provided_buyer_identity\n * <WaffoPancakeProvider customer={{\n *   identity: user.id,\n *   storeId: \"STO_xxx\",\n *   issueToken,       // from createCustomerTokenAction()\n *   sessionAction,    // from createCustomerSessionAction()\n * }}>\n *   <App />\n * </WaffoPancakeProvider>\n * ```\n */\nexport function WaffoPancakeProvider({ customer, buyer, children }: WaffoPancakeProviderProps) {\n  const config = customer ?? buyer;\n  if (!config) throw new Error(\"WaffoPancakeProvider: the `customer` prop is required\");\n\n  const tokenRef = useRef<TokenState | null>(null);\n  const refreshPromiseRef = useRef<Promise<string> | null>(null);\n  const [isCustomerReady, setIsCustomerReady] = useState(false);\n\n  const refreshToken = useCallback(async (): Promise<string> => {\n    const result = await config.issueToken({\n      buyerIdentity: config.identity,\n      storeId: config.storeId,\n      productId: config.productId,\n    });\n\n    tokenRef.current = {\n      token: result.token,\n      expiresAt: new Date(result.expiresAt).getTime(),\n    };\n\n    return result.token;\n  }, [config]);\n\n  const getCustomerToken = useCallback(async (): Promise<string> => {\n    const current = tokenRef.current;\n    if (current && Date.now() < current.expiresAt - REFRESH_BUFFER_MS) {\n      return current.token;\n    }\n\n    // Deduplicate concurrent refresh calls\n    if (!refreshPromiseRef.current) {\n      refreshPromiseRef.current = refreshToken().finally(() => {\n        refreshPromiseRef.current = null;\n      });\n    }\n\n    return refreshPromiseRef.current;\n  }, [refreshToken]);\n\n  // Issue initial token on mount\n  useEffect(() => {\n    refreshToken()\n      .then(() => setIsCustomerReady(true))\n      .catch(() => setIsCustomerReady(true));\n  }, [refreshToken]);\n\n  const value = useMemo<PancakeContextValue>(\n    () => ({\n      getCustomerToken,\n      customerSessionAction: config.sessionAction,\n      hasCustomer: true,\n      isCustomerReady,\n    }),\n    [getCustomerToken, config.sessionAction, isCustomerReady],\n  );\n\n  return <PancakeContext.Provider value={value}>{children}</PancakeContext.Provider>;\n}\n\n/**\n * Access the Waffo Pancake context. Must be used within `<WaffoPancakeProvider>`.\n */\nexport function usePancakeContext(): PancakeContextValue {\n  const ctx = useContext(PancakeContext);\n  if (!ctx) throw new Error(\"usePancakeContext: must be used within <WaffoPancakeProvider>\");\n  return ctx;\n}\n","\"use client\";\n\nimport { useCallback, useRef, useState } from \"react\";\n\nimport type { CheckoutProps, LinkCheckoutProps, UseCheckoutReturn } from \"./types.js\";\nimport type { CheckoutSessionResult, AuthenticatedCheckoutResult } from \"@waffo/pancake-ts\";\n\n\nconst LOADING_HTML = `<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Loading...</title><style>body{display:flex;align-items:center;justify-content:center;height:100vh;margin:0;font-family:system-ui,sans-serif;background:#f9fafb;color:#6b7280}@media(prefers-color-scheme:dark){body{background:#111827;color:#9ca3af}}</style></head><body><p>Redirecting to checkout...</p></body></html>`;\n\nconst DEFAULT_STOREFRONT_URL = \"https://pancake.waffo.ai\";\n\nconst SDK_FIELDS = new Set([\"action\", \"type\", \"mode\", \"popupLoadingUrl\", \"onSuccess\", \"onError\"]);\n\n/** Extract API checkout params from flattened props, removing SDK-specific fields */\nfunction extractApiParams(args: object): Record<string, unknown> {\n  const params: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(args)) {\n    if (!SDK_FIELDS.has(key)) params[key] = value;\n  }\n  return params;\n}\n\n/**\n * Build a product page URL for link checkout.\n */\nfunction buildLinkUrl(props: LinkCheckoutProps): string {\n  const base = (props.baseUrl ?? DEFAULT_STOREFRONT_URL).replace(/\\/+$/, \"\");\n  const url = new URL(`${base}/store/${props.storeSlug}/product/${props.productId}`);\n\n  if (props.currency) url.searchParams.set(\"currency\", props.currency);\n  if (props.email) url.searchParams.set(\"email\", props.email);\n  if (props.successUrl) url.searchParams.set(\"success_url\", props.successUrl);\n  if (props.test) url.searchParams.set(\"test\", \"true\");\n  if (props.country) url.searchParams.set(\"country\", props.country);\n  if (props.isBusiness) url.searchParams.set(\"is_business\", \"true\");\n\n  return url.toString();\n}\n\n/**\n * React hook for triggering a Waffo Pancake checkout flow.\n *\n * Supports three checkout types:\n * - **link**: Builds a product page URL and navigates directly (no API call, synchronous)\n * - **anonymous**: Calls a server action to create a checkout session, then navigates\n * - **authenticated**: Calls a server action to create a session + token, then navigates\n *\n * The private key never leaves the server — anonymous and authenticated modes\n * use a server action created by `createCheckoutAction()`.\n *\n * @param args - Flattened checkout props\n * @returns `{ checkout, isLoading, error }`\n *\n * @example\n * ```tsx\n * // Link checkout — no server action needed\n * const { checkout } = useCheckout({\n *   type: \"link\",\n *   storeSlug: \"my-store\",\n *   productId: \"PROD_xxx\",\n *   currency: \"USD\",\n * });\n *\n * // Anonymous checkout — via server action\n * const { checkout, isLoading } = useCheckout({\n *   action: checkout, // from createCheckoutAction()\n *   productId: \"PROD_xxx\",\n *   currency: \"USD\",\n * });\n * ```\n */\nexport function useCheckout(args: CheckoutProps): UseCheckoutReturn {\n  const { mode = \"redirect\", popupLoadingUrl, onError } = args;\n  const [isLoading, setIsLoading] = useState(false);\n  const [error, setError] = useState<Error | null>(null);\n  const popupRef = useRef<Window | null>(null);\n\n  const checkout = useCallback(() => {\n    if (isLoading) return;\n\n    // Link checkout — synchronous, no API call\n    if (args.type === \"link\") {\n      const url = buildLinkUrl(args);\n      if (mode === \"popup\") {\n        window.open(url, \"_blank\");\n      } else {\n        window.location.href = url;\n      }\n      return;\n    }\n\n    // Anonymous / Authenticated — server action\n    if (mode === \"popup\") {\n      const loadingUrl = popupLoadingUrl ?? `data:text/html;charset=utf-8,${encodeURIComponent(LOADING_HTML)}`;\n      popupRef.current = window.open(loadingUrl, \"_blank\");\n    }\n\n    setIsLoading(true);\n    setError(null);\n\n    const { action } = args;\n    const params = extractApiParams(args);\n    const actionParams = args.type === \"authenticated\" ? { type: \"authenticated\" as const, ...params } : params;\n\n    action(actionParams as unknown as Parameters<typeof action>[0])\n      .then((result: CheckoutSessionResult | AuthenticatedCheckoutResult) => {\n        if (mode === \"popup\" && popupRef.current) {\n          popupRef.current.location.href = result.checkoutUrl;\n        } else {\n          window.location.href = result.checkoutUrl;\n        }\n        if (\"onSuccess\" in args && args.onSuccess) {\n          (args.onSuccess as (r: CheckoutSessionResult | AuthenticatedCheckoutResult) => void)(result);\n        }\n      })\n      .catch((err: Error) => {\n        if (mode === \"popup\" && popupRef.current) {\n          popupRef.current.close();\n          popupRef.current = null;\n        }\n        setError(err);\n        onError?.(err);\n      })\n      .finally(() => {\n        setIsLoading(false);\n      });\n  }, [args, mode, popupLoadingUrl, onError, isLoading]);\n\n  return { checkout, isLoading, error };\n}\n","\"use client\";\n\nimport React from \"react\";\n\nimport { useCheckout } from \"./use-checkout.js\";\n\nimport type { CheckoutProps, LinkCheckoutProps, AnonymousCheckoutProps, AuthenticatedCheckoutProps } from \"./types.js\";\n\ntype CheckoutButtonBaseProps = {\n  /** Button content */\n  children: React.ReactNode;\n  /** Content shown while checkout session is being created */\n  loadingChildren?: React.ReactNode;\n  /** Additional class name */\n  className?: string;\n  /** Additional inline styles */\n  style?: React.CSSProperties;\n  /** Disabled state (merged with isLoading) */\n  disabled?: boolean;\n} & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"onClick\" | \"disabled\" | \"children\">;\n\n/** Props for CheckoutButton — link mode */\nexport type LinkCheckoutButtonProps = CheckoutButtonBaseProps & LinkCheckoutProps;\n\n/** Props for CheckoutButton — anonymous mode */\nexport type AnonymousCheckoutButtonProps = CheckoutButtonBaseProps & AnonymousCheckoutProps;\n\n/** Props for CheckoutButton — authenticated mode */\nexport type AuthenticatedCheckoutButtonProps = CheckoutButtonBaseProps & AuthenticatedCheckoutProps;\n\nexport type CheckoutButtonProps = LinkCheckoutButtonProps | AnonymousCheckoutButtonProps | AuthenticatedCheckoutButtonProps;\n\n/**\n * A button that triggers a Waffo Pancake checkout flow on click.\n *\n * Three checkout types:\n * - **link**: Instant redirect to product page URL (no server action needed)\n * - **anonymous**: Calls server action to create session, then redirects\n * - **authenticated**: Calls server action to create session + token, then redirects\n *\n * The private key never leaves the server — anonymous and authenticated modes\n * use a server action created by `createCheckoutAction()`.\n *\n * @param props - Flattened checkout props, button content, and optional styling\n *\n * @example\n * ```tsx\n * // Link checkout — no server action needed\n * <CheckoutButton type=\"link\" storeSlug=\"my-store\" productId=\"PROD_xxx\" currency=\"USD\">\n *   Buy Now\n * </CheckoutButton>\n *\n * // Anonymous checkout — via server action\n * <CheckoutButton action={checkout} productId=\"PROD_xxx\" currency=\"USD\">\n *   Buy Now\n * </CheckoutButton>\n *\n * // Authenticated checkout — via server action\n * <CheckoutButton action={checkout} type=\"authenticated\" productId=\"PROD_xxx\" currency=\"USD\" buyerIdentity=\"userIdInYourSystem\" buyerEmail=\"user@example.com\">\n *   Buy Now\n * </CheckoutButton>\n * ```\n */\nexport function CheckoutButton(props: CheckoutButtonProps) {\n  const { children, loadingChildren, className, style, disabled, ...checkoutProps } = props;\n\n  const { checkout, isLoading } = useCheckout(checkoutProps as CheckoutProps);\n\n  return (\n    <button type=\"button\" onClick={checkout} disabled={disabled || isLoading} className={className} style={style}>\n      {isLoading ? (loadingChildren ?? children) : children}\n    </button>\n  );\n}\n","\"use client\";\n\nimport { useCallback, useContext, useMemo, useState } from \"react\";\n\nimport { PancakeContext } from \"./provider.js\";\n\nimport type {\n  CancelSubscriptionParams,\n  CancelSubscriptionResult,\n  CancelOnetimeOrderParams,\n  CancelOnetimeOrderResult,\n  ReactivateSubscriptionParams,\n  ReactivateSubscriptionResult,\n  CreateRefundTicketParams,\n  ResubmitRefundTicketParams,\n  RefundTicket,\n  GraphQLParams,\n  GraphQLResponse,\n} from \"@waffo/pancake-ts\";\n\n/** State of an async customer action */\nexport interface CustomerActionState<T = unknown> {\n  /** Execute the action */\n  execute: (params: T) => Promise<void>;\n  /** Whether the action is in progress */\n  isLoading: boolean;\n  /** Error from the last attempt */\n  error: Error | null;\n}\n\n/** Return type of useCustomer hook */\nexport interface UseCustomerReturn {\n  /** Cancel a subscription order */\n  cancelSubscription: CustomerActionState<CancelSubscriptionParams> & { data: CancelSubscriptionResult | null };\n  /** Cancel a one-time order */\n  cancelOnetimeOrder: CustomerActionState<CancelOnetimeOrderParams> & { data: CancelOnetimeOrderResult | null };\n  /** Reactivate a canceling subscription */\n  reactivateSubscription: CustomerActionState<ReactivateSubscriptionParams> & { data: ReactivateSubscriptionResult | null };\n  /** Create a refund ticket */\n  createRefundTicket: CustomerActionState<CreateRefundTicketParams> & { data: RefundTicket | null };\n  /** Resubmit a rejected refund ticket */\n  resubmitRefundTicket: CustomerActionState<ResubmitRefundTicketParams> & { data: RefundTicket | null };\n  /** Execute a GraphQL query */\n  query: <T = Record<string, unknown>>(params: GraphQLParams) => Promise<GraphQLResponse<T>>;\n}\n\nfunction useCustomerAction<TParams, TResult>(\n  actionFn: (params: TParams) => Promise<TResult>,\n): CustomerActionState<TParams> & { data: TResult | null } {\n  const [isLoading, setIsLoading] = useState(false);\n  const [error, setError] = useState<Error | null>(null);\n  const [data, setData] = useState<TResult | null>(null);\n\n  const execute = useCallback(\n    async (params: TParams) => {\n      setIsLoading(true);\n      setError(null);\n      try {\n        const result = await actionFn(params);\n        setData(result);\n      } catch (err) {\n        setError(err instanceof Error ? err : new Error(String(err)));\n        throw err;\n      } finally {\n        setIsLoading(false);\n      }\n    },\n    [actionFn],\n  );\n\n  return { execute, isLoading, error, data };\n}\n\n/**\n * React hook for customer self-service actions.\n *\n * Must be used within `<WaffoPancakeProvider>`. All operations are executed\n * via server actions — the private key never leaves the server.\n *\n * @returns Customer action handlers with loading/error states\n *\n * @example\n * ```tsx\n * function AccountPage() {\n *   const customer = useCustomer();\n *   return (\n *     <button onClick={() => customer.cancelSubscription.execute({ orderId: \"ORD_xxx\" })}>\n *       Cancel\n *     </button>\n *   );\n * }\n * ```\n */\nexport function useCustomer(): UseCustomerReturn {\n  const ctx = useContext(PancakeContext);\n  if (!ctx) throw new Error(\"useCustomer: must be used within <WaffoPancakeProvider>\");\n\n  const { getCustomerToken, customerSessionAction } = ctx;\n\n  const callAction = useCallback(\n    async (actionType: string, params: unknown) => {\n      const token = await getCustomerToken();\n      return customerSessionAction(token, actionType as never, params);\n    },\n    [getCustomerToken, customerSessionAction],\n  );\n\n  const cancelSubscription = useCustomerAction<CancelSubscriptionParams, CancelSubscriptionResult>(\n    useCallback((params) => callAction(\"cancelSubscription\", params) as Promise<CancelSubscriptionResult>, [callAction]),\n  );\n\n  const cancelOnetimeOrder = useCustomerAction<CancelOnetimeOrderParams, CancelOnetimeOrderResult>(\n    useCallback((params) => callAction(\"cancelOnetimeOrder\", params) as Promise<CancelOnetimeOrderResult>, [callAction]),\n  );\n\n  const reactivateSubscription = useCustomerAction<ReactivateSubscriptionParams, ReactivateSubscriptionResult>(\n    useCallback((params) => callAction(\"reactivateSubscription\", params) as Promise<ReactivateSubscriptionResult>, [callAction]),\n  );\n\n  const createRefundTicket = useCustomerAction<CreateRefundTicketParams, { ticket: RefundTicket }>(\n    useCallback((params) => callAction(\"createRefundTicket\", params) as Promise<{ ticket: RefundTicket }>, [callAction]),\n  );\n  const createRefundTicketMapped = useMemo(\n    () => ({ ...createRefundTicket, data: createRefundTicket.data?.ticket ?? null }),\n    [createRefundTicket],\n  );\n\n  const resubmitRefundTicket = useCustomerAction<ResubmitRefundTicketParams, { ticket: RefundTicket }>(\n    useCallback((params) => callAction(\"resubmitRefundTicket\", params) as Promise<{ ticket: RefundTicket }>, [callAction]),\n  );\n  const resubmitRefundTicketMapped = useMemo(\n    () => ({ ...resubmitRefundTicket, data: resubmitRefundTicket.data?.ticket ?? null }),\n    [resubmitRefundTicket],\n  );\n\n  const query = useCallback(\n    async <T = Record<string, unknown>>(params: GraphQLParams) => {\n      const token = await getCustomerToken();\n      return customerSessionAction(token, \"query\", params) as Promise<GraphQLResponse<T>>;\n    },\n    [getCustomerToken, customerSessionAction],\n  );\n\n  return {\n    cancelSubscription,\n    cancelOnetimeOrder,\n    reactivateSubscription,\n    createRefundTicket: createRefundTicketMapped,\n    resubmitRefundTicket: resubmitRefundTicketMapped,\n    query,\n  };\n}\n\n// ============================================================\n// Deprecated Aliases\n// ============================================================\n\n/** @deprecated Use {@link CustomerActionState} instead. */\nexport type BuyerActionState<T = unknown> = CustomerActionState<T>;\n\n/** @deprecated Use {@link UseCustomerReturn} instead. */\nexport type UseBuyerReturn = UseCustomerReturn;\n\n/** @deprecated Use {@link useCustomer} instead. */\nexport const useBuyer = useCustomer;\n","\"use client\";\n\nimport { useCallback, useContext } from \"react\";\n\nimport { PancakeContext } from \"./provider.js\";\nimport { useQuery } from \"./use-query.js\";\n\nimport type { QueryState } from \"./use-query.js\";\nimport type { GraphQLResponse, RefundTicketVersionData } from \"@waffo/pancake-ts\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/** A customer's one-time order */\nexport interface CustomerOnetimeOrder {\n  id: string;\n  status: string;\n  currency: string;\n  buyerEmail: string;\n  product: { id: string; name: string } | null;\n  payments: Array<{ id: string; status: string; snapshotDisplayAmount: string; snapshotDisplayCurrency: string; createdAt: string }>;\n  createdAt: string;\n}\n\n/** A customer's subscription order */\nexport interface CustomerSubscriptionOrder {\n  id: string;\n  status: string;\n  currency: string;\n  buyerEmail: string;\n  currentPeriodStart: string | null;\n  currentPeriodEnd: string | null;\n  cancelAt: string | null;\n  product: { id: string; name: string; billingPeriod: string } | null;\n  payments: Array<{ id: string; status: string; snapshotDisplayAmount: string; snapshotDisplayCurrency: string; createdAt: string }>;\n  createdAt: string;\n}\n\n/** A customer's payment record */\nexport interface CustomerPayment {\n  id: string;\n  orderId: string;\n  status: string;\n  snapshotDisplayAmount: string;\n  snapshotDisplayCurrency: string;\n  failureReason: string | null;\n  createdAt: string;\n}\n\n/**\n * A customer's refund ticket.\n *\n * Ticket-level fields are flat; per-version fields (`reason`, `requestedAmount`)\n * live under `versionData` because the customer can resubmit a rejected ticket and\n * each submission is a versioned record. `versionData` reflects the current\n * (latest) version. The `versionData` shape is shared with `@waffo/pancake-ts`'s\n * `RefundTicketVersionData`.\n */\nexport interface CustomerRefundTicket {\n  id: string;\n  status: string;\n  versionNumber: number | null;\n  versionData: RefundTicketVersionData | null;\n  createdAt: string;\n}\n\n// ============================================================\n// Queries\n// ============================================================\n\nconst CUSTOMER_ORDERS_QUERY = `query {\n  onetimeOrders(limit: 50) {\n    id status currency buyerEmail createdAt\n    product { id name }\n    payments { id status snapshotDisplayAmount snapshotDisplayCurrency createdAt }\n  }\n  subscriptionOrders(limit: 50) {\n    id status currency buyerEmail currentPeriodStart currentPeriodEnd cancelAt createdAt\n    product { id name billingPeriod }\n    payments { id status snapshotDisplayAmount snapshotDisplayCurrency createdAt }\n  }\n}`;\n\nconst CUSTOMER_PAYMENTS_QUERY = `query {\n  payments(limit: 50) {\n    id orderId status snapshotDisplayAmount snapshotDisplayCurrency failureReason createdAt\n  }\n}`;\n\nconst CUSTOMER_REFUND_TICKETS_QUERY = `query {\n  refundTickets(limit: 50) {\n    id status versionNumber\n    versionData {\n      reason\n      requestedAmount { amount currency }\n    }\n    createdAt\n  }\n}`;\n\n// ============================================================\n// Internal helper\n// ============================================================\n\nfunction useCustomerQuery<T>(query: string): QueryState<T> {\n  const ctx = useContext(PancakeContext);\n  if (!ctx) throw new Error(\"Customer data hook: must be used within <WaffoPancakeProvider>\");\n\n  const { getCustomerToken, customerSessionAction, isCustomerReady } = ctx;\n\n  const queryFn = useCallback(async () => {\n    const token = await getCustomerToken();\n    const result = (await customerSessionAction(token, \"query\", { query })) as unknown as GraphQLResponse<T>;\n    return result.data as T;\n  }, [getCustomerToken, customerSessionAction, query]);\n\n  return useQuery(queryFn, isCustomerReady);\n}\n\n// ============================================================\n// Hooks\n// ============================================================\n\ninterface CustomerOrdersData {\n  onetimeOrders: CustomerOnetimeOrder[];\n  subscriptionOrders: CustomerSubscriptionOrder[];\n}\n\n/**\n * Fetch the customer's order history (one-time + subscription).\n *\n * Must be used within `<WaffoPancakeProvider>`. Token is auto-managed.\n *\n * @returns Orders with product info and payment history\n *\n * @example\n * ```tsx\n * const { data, isLoading, refetch } = useCustomerOrders();\n * // data.onetimeOrders + data.subscriptionOrders\n * ```\n */\nexport function useCustomerOrders(): QueryState<CustomerOrdersData> {\n  return useCustomerQuery<CustomerOrdersData>(CUSTOMER_ORDERS_QUERY);\n}\n\n/**\n * Fetch the customer's payment history.\n *\n * Must be used within `<WaffoPancakeProvider>`. Token is auto-managed.\n *\n * @returns Payment records with amounts and status\n *\n * @example\n * ```tsx\n * const { data: payments, isLoading } = useCustomerPayments();\n * ```\n */\nexport function useCustomerPayments(): QueryState<CustomerPayment[]> {\n  const result = useCustomerQuery<{ payments: CustomerPayment[] }>(CUSTOMER_PAYMENTS_QUERY);\n  return { ...result, data: result.data?.payments ?? null };\n}\n\n/**\n * Fetch the customer's refund tickets.\n *\n * Must be used within `<WaffoPancakeProvider>`. Token is auto-managed.\n *\n * @returns Refund tickets with status and requested amounts\n *\n * @example\n * ```tsx\n * const { data: tickets, isLoading } = useCustomerRefundTickets();\n * ```\n */\nexport function useCustomerRefundTickets(): QueryState<CustomerRefundTicket[]> {\n  const result = useCustomerQuery<{ refundTickets: CustomerRefundTicket[] }>(CUSTOMER_REFUND_TICKETS_QUERY);\n  return { ...result, data: result.data?.refundTickets ?? null };\n}\n\n// ============================================================\n// Deprecated Aliases\n// ============================================================\n\n/** @deprecated Use {@link CustomerOnetimeOrder} instead. */\nexport type BuyerOnetimeOrder = CustomerOnetimeOrder;\n\n/** @deprecated Use {@link CustomerSubscriptionOrder} instead. */\nexport type BuyerSubscriptionOrder = CustomerSubscriptionOrder;\n\n/** @deprecated Use {@link CustomerPayment} instead. */\nexport type BuyerPayment = CustomerPayment;\n\n/** @deprecated Use {@link CustomerRefundTicket} instead. */\nexport type BuyerRefundTicket = CustomerRefundTicket;\n\n/** @deprecated Use {@link useCustomerOrders} instead. */\nexport const useBuyerOrders = useCustomerOrders;\n\n/** @deprecated Use {@link useCustomerPayments} instead. */\nexport const useBuyerPayments = useCustomerPayments;\n\n/** @deprecated Use {@link useCustomerRefundTickets} instead. */\nexport const useBuyerRefundTickets = useCustomerRefundTickets;\n","\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\n/** Query state with typed data */\nexport interface QueryState<T> {\n  data: T | null;\n  isLoading: boolean;\n  error: Error | null;\n  refetch: () => void;\n}\n\n/**\n * Internal hook for async data fetching with loading/error state.\n *\n * @param queryFn - Async function that returns the data\n * @param ready - Whether to start fetching (false = wait)\n * @returns Query state with data, loading, error, and refetch\n */\nexport function useQuery<T>(queryFn: () => Promise<T>, ready: boolean): QueryState<T> {\n  const [data, setData] = useState<T | null>(null);\n  const [isLoading, setIsLoading] = useState(true);\n  const [error, setError] = useState<Error | null>(null);\n\n  const fetch = useCallback(() => {\n    if (!ready) return;\n    setIsLoading(true);\n    setError(null);\n    queryFn()\n      .then(setData)\n      .catch((err) => setError(err instanceof Error ? err : new Error(String(err))))\n      .finally(() => setIsLoading(false));\n  }, [queryFn, ready]);\n\n  useEffect(() => {\n    fetch();\n  }, [fetch]);\n\n  return { data, isLoading, error, refetch: fetch };\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\n\nimport { useQuery } from \"./use-query.js\";\n\nimport type { MerchantQueryAction } from \"./server.js\";\nimport type { QueryState } from \"./use-query.js\";\nimport type { GraphQLResponse } from \"@waffo/pancake-ts\";\n\n// ============================================================\n// Merchant Data Hooks (via server action)\n// ============================================================\n\n/** A merchant's recent order (one-time or subscription) */\nexport interface MerchantOrder {\n  id: string;\n  status: string;\n  currency: string;\n  buyerEmail: string;\n  testMode: boolean;\n  product: { id: string; name: string } | null;\n  payments: Array<{ id: string; status: string; snapshotDisplayAmount: string; snapshotDisplayCurrency: string }>;\n  createdAt: string;\n}\n\n/**\n * Sales overview statistics.\n *\n * Monetary fields (`totalRevenue`, `revenueByPeriod[].amount`) are returned as\n * display-formatted strings (e.g., `\"9.99\"`), not minor-currency-unit integers.\n * The conversion happens server-side via the GraphQL `currencyDisplayLoader`.\n */\nexport interface SalesOverview {\n  totalOrders: number;\n  /** Total succeeded payment revenue as display string (e.g., `\"1234.56\"`) */\n  totalRevenue: string;\n  totalCustomers: number;\n  currency: string;\n  ordersByStatus: Array<{ status: string; count: number }>;\n  /** Revenue by period; `amount` is a display string (e.g., `\"9.99\"`) */\n  revenueByPeriod: Array<{ period: string; amount: string }>;\n}\n\n/** Subscription overview */\nexport interface SubscriptionOverview {\n  activeCount: number;\n  cancelingCount: number;\n  pastDueCount: number;\n  totalCount: number;\n  subscriptions: MerchantSubscription[];\n}\n\n/** A merchant's subscription with status details */\nexport interface MerchantSubscription {\n  id: string;\n  status: string;\n  currency: string;\n  buyerEmail: string;\n  currentPeriodStart: string | null;\n  currentPeriodEnd: string | null;\n  cancelAt: string | null;\n  product: { id: string; name: string; billingPeriod: string } | null;\n  createdAt: string;\n}\n\nexport interface MerchantOrdersOptions {\n  /** Store ID to filter by */\n  storeId: string;\n  /** Max results (default: 20) */\n  limit?: number;\n}\n\nconst MERCHANT_ORDERS_QUERY = `query ($storeId: ID!, $limit: Int) {\n  onetimeOrders(storeId: $storeId, limit: $limit) {\n    id status currency buyerEmail testMode createdAt\n    product { id name }\n    payments { id status snapshotDisplayAmount snapshotDisplayCurrency }\n  }\n  subscriptionOrders(storeId: $storeId, limit: $limit) {\n    id status currency buyerEmail testMode createdAt\n    product { id name }\n    payments { id status snapshotDisplayAmount snapshotDisplayCurrency }\n  }\n}`;\n\n/**\n * Fetch recent orders for a store (one-time + subscription).\n *\n * @param query - Server action from `createMerchantQueryAction()`\n * @param options - Store ID and optional limit\n * @returns Recent orders with product info and payment summary\n *\n * @example\n * ```tsx\n * const { data, isLoading, refetch } = useMerchantOrders(merchantQuery, { storeId: \"STO_xxx\" });\n * ```\n */\nexport function useMerchantOrders(\n  query: MerchantQueryAction,\n  options: MerchantOrdersOptions,\n): QueryState<{ onetimeOrders: MerchantOrder[]; subscriptionOrders: MerchantOrder[] }> {\n  const { storeId, limit = 20 } = options;\n\n  const queryFn = useCallback(async () => {\n    const result = (await query({\n      query: MERCHANT_ORDERS_QUERY,\n      variables: { storeId, limit },\n    })) as unknown as GraphQLResponse<{ onetimeOrders: MerchantOrder[]; subscriptionOrders: MerchantOrder[] }>;\n    return result.data as { onetimeOrders: MerchantOrder[]; subscriptionOrders: MerchantOrder[] };\n  }, [query, storeId, limit]);\n\n  return useQuery(queryFn, true);\n}\n\nconst MERCHANT_SALES_QUERY = `query ($storeId: ID!) {\n  orderStatistics(storeId: $storeId) {\n    totalCount\n    countByStatus { status count }\n  }\n  paymentStatistics(storeId: $storeId) {\n    totalSucceededAmount\n    totalSucceededCurrency\n    totalSucceededCount\n  }\n  customerAnalysis(storeId: $storeId) {\n    totalCustomers\n  }\n  trendAnalysis(storeId: $storeId) {\n    revenueByPeriod { period amount }\n  }\n}`;\n\ninterface SalesQueryData {\n  orderStatistics: { totalCount: number; countByStatus: Array<{ status: string; count: number }> };\n  paymentStatistics: { totalSucceededAmount: string; totalSucceededCurrency: string; totalSucceededCount: number };\n  customerAnalysis: { totalCustomers: number };\n  trendAnalysis: { revenueByPeriod: Array<{ period: string; amount: string }> };\n}\n\n/**\n * Fetch sales overview for a store.\n *\n * @param query - Server action from `createMerchantQueryAction()`\n * @param storeId - Store ID\n * @returns Aggregated sales statistics\n *\n * @example\n * ```tsx\n * const { data: sales } = useMerchantSales(merchantQuery, \"STO_xxx\");\n * ```\n */\nexport function useMerchantSales(query: MerchantQueryAction, storeId: string): QueryState<SalesOverview> {\n  const queryFn = useCallback(async () => {\n    const result = (await query({\n      query: MERCHANT_SALES_QUERY,\n      variables: { storeId },\n    })) as unknown as GraphQLResponse<SalesQueryData>;\n    const d = result.data as SalesQueryData;\n    return {\n      totalOrders: d.orderStatistics.totalCount,\n      totalRevenue: d.paymentStatistics.totalSucceededAmount,\n      totalCustomers: d.customerAnalysis.totalCustomers,\n      currency: d.paymentStatistics.totalSucceededCurrency,\n      ordersByStatus: d.orderStatistics.countByStatus,\n      revenueByPeriod: d.trendAnalysis.revenueByPeriod,\n    };\n  }, [query, storeId]);\n\n  return useQuery(queryFn, true);\n}\n\nconst MERCHANT_SUBSCRIPTIONS_QUERY = `query ($storeId: ID!) {\n  subscriptionOrders(storeId: $storeId, limit: 100) {\n    id status currency buyerEmail currentPeriodStart currentPeriodEnd cancelAt createdAt\n    product { id name billingPeriod }\n  }\n}`;\n\n/**\n * Fetch subscription overview for a store.\n *\n * @param query - Server action from `createMerchantQueryAction()`\n * @param storeId - Store ID\n * @returns Subscription counts and detailed list\n *\n * @example\n * ```tsx\n * const { data: subs } = useMerchantSubscriptions(merchantQuery, \"STO_xxx\");\n * ```\n */\nexport function useMerchantSubscriptions(query: MerchantQueryAction, storeId: string): QueryState<SubscriptionOverview> {\n  const queryFn = useCallback(async () => {\n    const result = (await query({\n      query: MERCHANT_SUBSCRIPTIONS_QUERY,\n      variables: { storeId },\n    })) as unknown as GraphQLResponse<{ subscriptionOrders: MerchantSubscription[] }>;\n    const subs = (result.data as { subscriptionOrders: MerchantSubscription[] }).subscriptionOrders;\n    return {\n      activeCount: subs.filter((s) => s.status === \"active\").length,\n      cancelingCount: subs.filter((s) => s.status === \"canceling\").length,\n      pastDueCount: subs.filter((s) => s.status === \"past_due\").length,\n      totalCount: subs.length,\n      subscriptions: subs,\n    };\n  }, [query, storeId]);\n\n  return useQuery(queryFn, true);\n}\n","import { verifyWebhook } from \"@waffo/pancake-ts\";\n\nimport type { VerifyWebhookOptions, WebhookEvent, WebhookEventData } from \"@waffo/pancake-ts\";\n\n/** Handler function for a specific webhook event */\ntype EventHandler<T = WebhookEventData> = (event: WebhookEvent<T>) => void | Promise<void>;\n\n/** Configuration for the Webhook route handler factory */\nexport interface WebhookConfig {\n  /** Webhook signature verification options (environment, publicKey, tolerance, etc.) */\n  verifyOptions?: VerifyWebhookOptions;\n\n  /** Catch-all handler — called for every event regardless of type */\n  onPayload?: EventHandler;\n\n  /** One-time order first payment succeeded */\n  onOrderCompleted?: EventHandler;\n  /** Subscription first payment succeeded (newly activated) */\n  onSubscriptionActivated?: EventHandler;\n  /** Subscription payment succeeded — a pure payment event, carries no subscription period or status */\n  onSubscriptionPaymentSucceeded?: EventHandler;\n  /** Current billing period rolled forward (renewal) */\n  onSubscriptionRenewed?: EventHandler;\n  /** Subscription recovered from past due (a retried charge succeeded) */\n  onSubscriptionRecovered?: EventHandler;\n  /** Plan change took effect (upgrade/downgrade) */\n  onSubscriptionPlanChanged?: EventHandler;\n  /** Plan change confirmed, takes effect next billing period */\n  onSubscriptionPlanChangeScheduled?: EventHandler;\n  /** Plan change did not complete, the current plan stays in effect */\n  onSubscriptionPlanChangeFailed?: EventHandler;\n  /** Customer initiated cancellation (expires at end of current period) */\n  onSubscriptionCanceling?: EventHandler;\n  /** Customer withdrew cancellation (subscription restored) */\n  onSubscriptionUncanceled?: EventHandler;\n  /** Subscription fully terminated */\n  onSubscriptionCanceled?: EventHandler;\n  /** Renewal payment failed (past due) */\n  onSubscriptionPastDue?: EventHandler;\n  /** Refund succeeded */\n  onRefundSucceeded?: EventHandler;\n  /** Refund failed */\n  onRefundFailed?: EventHandler;\n}\n\n/* eslint-disable @typescript-eslint/naming-convention -- event type keys use dot notation */\nconst EVENT_HANDLER_MAP: Record<string, keyof WebhookConfig> = {\n  \"order.completed\": \"onOrderCompleted\",\n  \"subscription.activated\": \"onSubscriptionActivated\",\n  \"subscription.payment_succeeded\": \"onSubscriptionPaymentSucceeded\",\n  \"subscription.renewed\": \"onSubscriptionRenewed\",\n  \"subscription.recovered\": \"onSubscriptionRecovered\",\n  \"subscription.plan_changed\": \"onSubscriptionPlanChanged\",\n  \"subscription.plan_change_scheduled\": \"onSubscriptionPlanChangeScheduled\",\n  \"subscription.plan_change_failed\": \"onSubscriptionPlanChangeFailed\",\n  \"subscription.canceling\": \"onSubscriptionCanceling\",\n  \"subscription.uncanceled\": \"onSubscriptionUncanceled\",\n  \"subscription.canceled\": \"onSubscriptionCanceled\",\n  \"subscription.past_due\": \"onSubscriptionPastDue\",\n  \"refund.succeeded\": \"onRefundSucceeded\",\n  \"refund.failed\": \"onRefundFailed\",\n};\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/**\n * Create a Next.js POST route handler for Waffo Pancake webhooks.\n *\n * Automatically verifies the webhook signature using `@waffo/pancake-ts`,\n * then dispatches to the matching event handler.\n *\n * @param config - Verification options and event handlers\n * @returns A Next.js POST route handler\n *\n * @example\n * ```ts\n * // app/api/webhooks/waffo/route.ts\n * import { Webhook } from \"@waffo/pancake-nextjs\";\n *\n * export const POST = Webhook({\n *   verifyOptions: { environment: \"prod\" },\n *   onOrderCompleted: async (event) => {\n *     console.log(\"Order completed:\", event.data.orderId);\n *     // Grant access to the product\n *   },\n *   onSubscriptionActivated: async (event) => {\n *     console.log(\"Subscription activated:\", event.data.orderId);\n *   },\n *   onRefundSucceeded: async (event) => {\n *     console.log(\"Refund succeeded:\", event.data.refundId);\n *     // Revoke access\n *   },\n * });\n * ```\n */\nexport function Webhook(config: WebhookConfig) {\n  return async function POST(request: Request): Promise<Response> {\n    const payload = await request.text();\n    const signature = request.headers.get(\"x-waffo-signature\");\n\n    let event: WebhookEvent;\n    try {\n      event = verifyWebhook(payload, signature, config.verifyOptions);\n    } catch (error) {\n      const message = error instanceof Error ? error.message : \"Webhook verification failed\";\n      return new Response(JSON.stringify({ error: message }), {\n        status: 401,\n        headers: { \"Content-Type\": \"application/json\" },\n      });\n    }\n\n    try {\n      // Catch-all handler\n      if (config.onPayload) {\n        await config.onPayload(event);\n      }\n\n      // Event-specific handler\n      const handlerKey = EVENT_HANDLER_MAP[event.eventType];\n      if (handlerKey) {\n        const handler = config[handlerKey] as EventHandler | undefined;\n        if (handler) {\n          await handler(event);\n        }\n      }\n\n      return new Response(JSON.stringify({ received: true }), {\n        status: 200,\n        headers: { \"Content-Type\": \"application/json\" },\n      });\n    } catch (error) {\n      const message = error instanceof Error ? error.message : \"Webhook handler error\";\n      return new Response(JSON.stringify({ error: message }), {\n        status: 500,\n        headers: { \"Content-Type\": \"application/json\" },\n      });\n    }\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAoG;AAwI3F;AAjGF,IAAM,qBAAiB,4BAA0C,IAAI;AAG5E,IAAM,oBAAoB;AAsCnB,SAAS,qBAAqB,EAAE,UAAU,OAAO,SAAS,GAA8B;AAC7F,QAAM,SAAS,YAAY;AAC3B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,uDAAuD;AAEpF,QAAM,eAAW,qBAA0B,IAAI;AAC/C,QAAM,wBAAoB,qBAA+B,IAAI;AAC7D,QAAM,CAAC,iBAAiB,kBAAkB,QAAI,uBAAS,KAAK;AAE5D,QAAM,mBAAe,0BAAY,YAA6B;AAC5D,UAAM,SAAS,MAAM,OAAO,WAAW;AAAA,MACrC,eAAe,OAAO;AAAA,MACtB,SAAS,OAAO;AAAA,MAChB,WAAW,OAAO;AAAA,IACpB,CAAC;AAED,aAAS,UAAU;AAAA,MACjB,OAAO,OAAO;AAAA,MACd,WAAW,IAAI,KAAK,OAAO,SAAS,EAAE,QAAQ;AAAA,IAChD;AAEA,WAAO,OAAO;AAAA,EAChB,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,uBAAmB,0BAAY,YAA6B;AAChE,UAAM,UAAU,SAAS;AACzB,QAAI,WAAW,KA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