{"version":3,"sources":["../src/components/CheckoutButton.tsx","../src/components/PlanDetailsButton.tsx","../src/components/SubscriptionDetailsButton.tsx","../src/experimental.ts"],"sourcesContent":["import type { __experimental_CheckoutButtonProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport { useAuth } from '../hooks';\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\n/**\n * A button component that opens the Clerk Checkout drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when=\"signed-in\">`).\n *\n * @example\n * ```tsx\n * import { Show } from '@clerk/react';\n * import { CheckoutButton } from '@clerk/react/experimental';\n *\n * // Basic usage with default \"Checkout\" text\n * function BasicCheckout() {\n *   return (\n *     <Show when=\"signed-in\">\n *       <CheckoutButton planId=\"plan_123\" />\n *     </Show>\n *   );\n * }\n *\n * // Custom button with organization subscription\n * function OrganizationCheckout() {\n *   return (\n *     <Show when=\"signed-in\">\n *       <CheckoutButton\n *         planId=\"plan_123\"\n *         planPeriod=\"month\"\n *         for=\"organization\"\n *         onSubscriptionComplete={() => console.log('Subscription completed!')}\n *       >\n *         <button className=\"custom-button\">Subscribe Now</button>\n *       </CheckoutButton>\n *     </Show>\n *   );\n * }\n * ```\n *\n * @throws {Error} When rendered while the user is signed out\n * @throws {Error} When `for=\"organization\"` is used without an active organization context\n *\n * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.\n */\nexport const CheckoutButton = withClerk(\n  ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<__experimental_CheckoutButtonProps>>) => {\n    const {\n      planId,\n      planPeriod,\n      for: _for,\n      onSubscriptionComplete,\n      newSubscriptionRedirectUrl,\n      checkoutProps,\n      getContainer,\n      component,\n      ...rest\n    } = props;\n\n    const { userId, orgId } = useAuth();\n\n    if (userId === null) {\n      throw new Error(\n        'Clerk: Ensure that `<CheckoutButton />` is rendered only when the user is signed in (wrap with `<Show when=\"signed-in\">` or guard with `useAuth()`).',\n      );\n    }\n\n    if (orgId === null && _for === 'organization') {\n      throw new Error(\n        'Clerk: Wrap `<CheckoutButton for=\"organization\" />` with a check for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object',\n      );\n    }\n\n    children = normalizeWithDefaultValue(children, 'Checkout');\n    const child = assertSingleChild(children)('CheckoutButton');\n\n    const clickHandler = () => {\n      if (!clerk) {\n        return;\n      }\n\n      return clerk.__internal_openCheckout({\n        planId,\n        planPeriod,\n        for: _for,\n        onSubscriptionComplete,\n        newSubscriptionRedirectUrl,\n        ...checkoutProps,\n      });\n    };\n\n    const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n      if (child && typeof child === 'object' && 'props' in child) {\n        await safeExecute(child.props.onClick)(e);\n      }\n      return clickHandler();\n    };\n\n    const childProps = { ...rest, onClick: wrappedChildClickHandler };\n    return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n  },\n  { component: 'CheckoutButton', renderWhileLoading: true },\n);\n","import type { __experimental_PlanDetailsButtonProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\n/**\n * A button component that opens the Clerk Plan Details drawer when clicked. This component is part of\n * Clerk's Billing feature which is available under a public beta.\n *\n * @example\n * ```tsx\n * import { Show } from '@clerk/react';\n * import { PlanDetailsButton } from '@clerk/react/experimental';\n *\n * // Basic usage with default \"Plan details\" text\n * function BasicPlanDetails() {\n *   return <PlanDetailsButton planId=\"plan_123\" />;\n * }\n *\n * // Custom button with custom text\n * function CustomPlanDetails() {\n *   return (\n *     <Show when=\"signed-in\">\n *       <PlanDetailsButton planId=\"plan_123\">\n *         <button>View Plan Details</button>\n *       </PlanDetailsButton>\n *     </Show>\n *   );\n * }\n * ```\n *\n * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.\n */\nexport const PlanDetailsButton = withClerk(\n  ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<__experimental_PlanDetailsButtonProps>>) => {\n    const { plan, planId, initialPlanPeriod, planDetailsProps, getContainer, component, ...rest } = props;\n\n    children = normalizeWithDefaultValue(children, 'Plan details');\n    const child = assertSingleChild(children)('PlanDetailsButton');\n\n    const clickHandler = () => {\n      if (!clerk) {\n        return;\n      }\n\n      return clerk.__internal_openPlanDetails({\n        plan,\n        planId,\n        initialPlanPeriod,\n        ...planDetailsProps,\n      } as __experimental_PlanDetailsButtonProps);\n    };\n\n    const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n      if (child && typeof child === 'object' && 'props' in child) {\n        await safeExecute(child.props.onClick)(e);\n      }\n      return clickHandler();\n    };\n\n    const childProps = { ...rest, onClick: wrappedChildClickHandler };\n    return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n  },\n  { component: 'PlanDetailsButton', renderWhileLoading: true },\n);\n","import type { __experimental_SubscriptionDetailsButtonProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport { useAuth } from '../hooks';\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\n/**\n * A button component that opens the Clerk Subscription Details drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when=\"signed-in\">`).\n *\n * @example\n * ```tsx\n * import { Show } from '@clerk/react';\n * import { SubscriptionDetailsButton } from '@clerk/react/experimental';\n *\n * // Basic usage with default \"Subscription details\" text\n * function BasicSubscriptionDetails() {\n *   return (\n *     <Show when=\"signed-in\">\n *       <SubscriptionDetailsButton />\n *     </Show>\n *   );\n * }\n *\n * // Custom button with Organization Subscription\n * function OrganizationSubscriptionDetails() {\n *   return (\n *     <Show when=\"signed-in\">\n *       <SubscriptionDetailsButton\n *         for=\"organization\"\n *         onSubscriptionCancel={() => console.log('Subscription canceled')}\n *       >\n *         <button>View Organization Subscription</button>\n *       </SubscriptionDetailsButton>\n *     </Show>\n *   );\n * }\n * ```\n *\n * @throws {Error} When rendered while the user is signed out\n * @throws {Error} When `for=\"organization\"` is used without an Active Organization context\n *\n * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.\n */\nexport const SubscriptionDetailsButton = withClerk(\n  ({\n    clerk,\n    children,\n    ...props\n  }: WithClerkProp<React.PropsWithChildren<__experimental_SubscriptionDetailsButtonProps>>) => {\n    const { for: _for, subscriptionDetailsProps, onSubscriptionCancel, getContainer, component, ...rest } = props;\n    children = normalizeWithDefaultValue(children, 'Subscription details');\n    const child = assertSingleChild(children)('SubscriptionDetailsButton');\n\n    const { userId, orgId } = useAuth();\n\n    if (userId === null) {\n      throw new Error(\n        'Clerk: Ensure that `<SubscriptionDetailsButton />` is rendered only when the user is signed in (wrap with `<Show when=\"signed-in\">` or guard with `useAuth()`).',\n      );\n    }\n\n    if (orgId === null && _for === 'organization') {\n      throw new Error(\n        'Clerk: Wrap `<SubscriptionDetailsButton for=\"organization\" />` with a check for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object',\n      );\n    }\n\n    const clickHandler = () => {\n      if (!clerk) {\n        return;\n      }\n\n      return clerk.__internal_openSubscriptionDetails({\n        for: _for,\n        onSubscriptionCancel,\n        ...subscriptionDetailsProps,\n      });\n    };\n\n    const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n      if (child && typeof child === 'object' && 'props' in child) {\n        await safeExecute(child.props.onClick)(e);\n      }\n      return clickHandler();\n    };\n\n    const childProps = { ...rest, onClick: wrappedChildClickHandler };\n    return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n  },\n  { component: 'SubscriptionDetailsButton', renderWhileLoading: true },\n);\n","export { CheckoutButton } from './components/CheckoutButton';\nexport { PlanDetailsButton } from './components/PlanDetailsButton';\nexport { SubscriptionDetailsButton } from './components/SubscriptionDetailsButton';\n\nexport type {\n  __experimental_CheckoutButtonProps as CheckoutButtonProps,\n  __experimental_SubscriptionDetailsButtonProps as SubscriptionDetailsButtonProps,\n  __experimental_PlanDetailsButtonProps as PlanDetailsButtonProps,\n} from '@clerk/shared/types';\n\nexport {\n  __experimental_useAPIKeys as useAPIKeys,\n  __experimental_PaymentElementProvider as PaymentElementProvider,\n  __experimental_usePaymentElement as usePaymentElement,\n  __experimental_PaymentElement as PaymentElement,\n  __experimental_usePaymentAttempts as usePaymentAttempts,\n  __experimental_useStatements as useStatements,\n  __experimental_usePaymentMethods as usePaymentMethods,\n  __experimental_usePlans as usePlans,\n  __experimental_useSubscription as useSubscription,\n  __experimental_CheckoutProvider as CheckoutProvider,\n  __experimental_useCheckout as useCheckout,\n} from '@clerk/shared/react';\n"],"mappings":";;;;;;;;;;;AACA,OAAO,WAAW;AA8CX,IAAM,iBAAiB;AAAA,EAC5B,CAAC,EAAE,OAAO,UAAU,GAAG,MAAM,MAAkF;AAC7G,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,EAAE,QAAQ,MAAM,IAAI,QAAQ;AAElC,QAAI,WAAW,MAAM;AACnB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,QAAI,UAAU,QAAQ,SAAS,gBAAgB;AAC7C,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,eAAW,0BAA0B,UAAU,UAAU;AACzD,UAAM,QAAQ,kBAAkB,QAAQ,EAAE,gBAAgB;AAE1D,UAAM,eAAe,MAAM;AAC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