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CAIO,MAAM,mBAAqB,KAChC,MAAM,GAAU,EAAA,mBAAW,iBAC3B,IAAK,EACH,MAAM,IAAI,MACR,8DAGJ,OAAO,CAAO,EAGhB,QAAA,sCAOO,MAAM,eAAgD,EAC3D,UACA,iBACA,UACA,cACG,MAEH,MAAM,EAAU,qBAuBhB,OACE,OAAA,QAAA,cAAC,aAAA,iBAAgB,SAAA,CAAC,QAtBA,UAClB,GAAK,EAML,IACE,MAAM,EAAiB,IAClB,EACH,MAAO,EAAQ,MACf,OAAQ,EAAQ,QAGZ,QAA6B,eAAe,IAAI,GACtD,EAAe,EACjB,CAAE,MAAO,GACP,WAAU,IAAI,MAAM,EAAM,SAC5B,KAjBA,CACE,MAAM,EAAQ,IAAI,MAAM,4CACxB,WAAU,EAEZ,CAaA,GAI4C,GACzC,EACgB,EAIvB,QAAA,8BAUO,MAAM,wBAA0B,MACrC,EACA,EAA8B,QAE9B,UACQ,eAAe,gBAAgB,EAAS,EAChD,CAAE,MAAO,GAEP,MAAM,IAAI,MAAM,yCAAyC,EAAM,UACjE,GACA,QAAA","file":"/npm/react-native-passkit-apple-pay@1.0.0-beta/lib/commonjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-native-passkit-apple-pay@1.0.0-beta/lib/commonjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * React Native PassKit Apple Pay for Conekta\n *\n * A React Native library for integrating Apple Pay with Conekta as payment processor\n * using PassKit framework.\n *\n * @author Conekta <alexis.nahuel@conekta.com>\n * @license MIT\n */\n\nimport React, { createContext, useContext, PropsWithChildren } from 'react';\nimport {\n  NativeModules,\n  TouchableOpacity,\n  TouchableOpacityProps,\n} from 'react-native';\n\nconst { ApplePayModule } = NativeModules;\n\n/**\n * Apple Pay payment method information as returned by PassKit\n */\nexport interface ApplePayPaymentMethod {\n  displayName: string;\n  network: string;\n  type: string;\n}\n\n/**\n * Apple Pay payment data header containing cryptographic information\n * Required for Conekta's Apple Pay token validation\n */\nexport interface ApplePayPaymentDataHeader {\n  publicKeyHash: string;\n  ephemeralPublicKey: string;\n  transactionId: string;\n}\n\n/**\n * Apple Pay payment data containing encrypted payment information\n */\nexport interface ApplePayPaymentData {\n  data: string;\n  signature: string;\n  header: ApplePayPaymentDataHeader;\n  version: string;\n}\n\n/**\n * Complete Apple Pay token structure for Conekta integration\n * This token should be sent directly to Conekta's API for processing\n */\nexport interface ApplePayToken {\n  paymentData: ApplePayPaymentData;\n  paymentMethod: ApplePayPaymentMethod;\n  transactionIdentifier: string;\n}\n\n/**\n * Configuration context for Apple Pay integration with Conekta\n */\ninterface ApplePayContextType {\n  merchantIdentifier: string; // Must be registered with Conekta\n  supportedNetworks: string[]; // Networks supported by Conekta in your region\n  countryCode: string; // LATAM country code (e.g., \"MX\", \"CO\", \"PE\")\n  currencyCode: string; // Local currency code (e.g., \"MXN\", \"COP\", \"PEN\")\n}\n\ninterface ApplePayProviderProps extends ApplePayContextType {\n  // @todo: Add support for Conekta-specific merchant validation,\n  // shipping methods and different merchant capabilities\n}\n\n/**\n * Payment summary for display in Apple Pay sheet\n * Amount should be in the smallest currency unit (e.g., cents for MXN)\n */\ninterface PaymentSummary {\n  label: string;\n  amount: string; // @todo: revisar si es string o integer\n}\n\ninterface ApplePayButtonProps extends TouchableOpacityProps {\n  /**\n   * Payment details for the transaction\n   */\n  payment: PaymentSummary;\n  /**\n   * Callback executed when payment is authorized and token is received\n   * The application is responsible for processing the token with Conekta's API\n   */\n  onPaymentToken: (token: ApplePayToken) => void;\n  /**\n   * Optional callback executed when payment initiation fails or user cancels\n   */\n  onError?: (error: Error) => void;\n  children: React.ReactNode;\n}\n\nconst ApplePayContext = createContext<ApplePayContextType | undefined>(\n  undefined,\n);\n\n/**\n * Provider component that configures global Apple Pay parameters for Conekta integration\n * All ApplePayButton components within this provider will use these settings\n *\n * @param merchantIdentifier - Your merchant ID registered with Conekta\n * @param countryCode - Country code where your business operates\n * @param currencyCode - Local currency code for your market\n * @param supportedNetworks - Payment networks supported by Conekta\n */\nexport const ApplePayProvider: React.FC<\n  PropsWithChildren<ApplePayProviderProps>\n> = ({\n  children,\n  merchantIdentifier,\n  supportedNetworks,\n  countryCode,\n  currencyCode,\n}) => {\n  const contextValue = {\n    merchantIdentifier,\n    supportedNetworks,\n    countryCode,\n    currencyCode,\n  };\n\n  return (\n    <ApplePayContext.Provider value={contextValue}>\n      {children}\n    </ApplePayContext.Provider>\n  );\n};\n\n/**\n * Hook to access Apple Pay configuration context\n * Must be used within an ApplePayProvider\n */\nexport const useApplePayContext = () => {\n  const context = useContext(ApplePayContext);\n  if (!context) {\n    throw new Error(\n      'useApplePayContext must be used within an ApplePayProvider',\n    );\n  }\n  return context;\n};\n\n/**\n * A wrapper component that converts its children into an Apple Pay button\n * Initiates the native payment flow when pressed and returns a token\n *\n * The token returned by this component should be sent directly to your\n * backend for processing with Conekta's charges/orders API\n */\nexport const ApplePayButton: React.FC<ApplePayButtonProps> = ({\n  payment,\n  onPaymentToken,\n  onError,\n  children,\n  ...rest\n}) => {\n  const context = useApplePayContext();\n\n  const handlePress = async () => {\n    if (!payment) {\n      const error = new Error('ApplePayButton: payment prop is required');\n      onError?.(error);\n      return;\n    }\n\n    try {\n      const paymentRequest = {\n        ...context,\n        label: payment.label,\n        amount: payment.amount,\n      };\n\n      const token: ApplePayToken = await ApplePayModule.pay(paymentRequest);\n      onPaymentToken(token);\n    } catch (error: any) {\n      onError?.(new Error(error.message));\n    }\n  };\n\n  return (\n    <TouchableOpacity onPress={handlePress} {...rest}>\n      {children}\n    </TouchableOpacity>\n  );\n};\n\n/**\n * Completes the Apple Pay transaction from the JavaScript side\n * Must be called after Conekta has processed the payment\n *\n * This function signals to the native Apple Pay UI whether the payment\n * succeeded or failed, allowing the user to see the appropriate feedback\n *\n * @param success - true if Conekta payment was successful, false otherwise\n * @param errorMessage - Error message to display if success is false\n */\nexport const completeApplePayPayment = async (\n  success: boolean,\n  errorMessage: string | null = null,\n): Promise<void> => {\n  try {\n    await ApplePayModule.completePayment(success, errorMessage);\n  } catch (error: any) {\n    // @todo: Add integration with Conekta's error tracking\n    throw new Error(`Failed to complete Apple Pay payment: ${error.message}`);\n  }\n};\n"]}