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AE,MAAO,SACD,aAAa,2BAA2B,CAC5C,YACA,OAAQ,sBAAsB,MAC9B,MAAO,CAAE,QAAmB,QAAV,EAAA,aAAC,EAAD,EAAG,eAAO,IAAA,IAAI,kBAEpC,OAMN,MAAM,EAAa,OAAA,OAAA,OAAA,OAAA,GACd,GAAO,CACV,qBAAsB,EACtB,mBAAoB,IAMtB,cAHO,EAAc,gBACd,EAAc,oBAER,EAAa,EAC5B,C,QAEE,IAAK,MAAM,KAAU,QACb,EAAO,QAEjB,CACF,CAEA,MAAM,aAAmC,CACvC,oBAAM,CAAe,GACnB,MAAM,EAAW,aAAO,EAAP,EAAS,SACpB,EAAgB,aAAO,EAAP,EAAS,cAE/B,OAAK,GAAa,EAIX,4BACJ,GAAS,aAAa,eAAe,IAAK,OAAA,OAAA,GACtC,GACL,EACA,GAPO,aAAa,eAAe,UAAW,GASlD,EAEA,4BAAM,CAAuB,GAC3B,MAAM,EAAW,aAAO,EAAP,EAAS,SACpB,EAAgB,aAAO,EAAP,EAAS,cAE/B,OAAK,GAAa,EAIX,4BACJ,GAAS,aAAa,uBAAuB,IAAK,OAAA,OAAA,GAC9C,GACL,EACA,GAPO,aAAa,uBAAuB,EAS/C,EAEA,sBAA2B,SAClB,aAAa,wBAGtB,kBAAmB,aAAa,kBAC5B,MAAO,GAEE,aAAa,kBAAmB,QAEzC,EAEJ,YAAW,CAAC,EAAoD,IACvD,aAAa,YAAY,EAAW,GAG7C,mBAAkB,IACT,aAAa,4BAIxB,KAAc,uBACL,mBAAsB,uDACtB","file":"/npm/@revenuecat/purchases-capacitor-ui@12.2.1/dist/esm/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@revenuecat/purchases-capacitor-ui@12.2.1/dist/esm/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","import { registerPlugin } from '@capacitor/core';\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nimport type {\n  PaywallListener,\n  PaywallResult,\n  PresentPaywallIfNeededOptions,\n  PresentPaywallOptions,\n  PurchaseLogic,\n  PurchaseLogicResult,\n  RevenueCatUIPlugin,\n} from './definitions';\nimport { PURCHASE_LOGIC_RESULT } from './definitions';\n\n/**\n * Internal native plugin interface with native-only methods and events.\n * This is not exported to consumers.\n */\ninterface RevenueCatUINativePlugin {\n  presentPaywall(options: {\n    offering?: any;\n    displayCloseButton?: boolean;\n    hasPaywallListener?: boolean;\n    hasPurchaseLogic?: boolean;\n  }): Promise<PaywallResult>;\n  presentPaywallIfNeeded(options: {\n    offering?: any;\n    displayCloseButton?: boolean;\n    requiredEntitlementIdentifier: string;\n    hasPaywallListener?: boolean;\n    hasPurchaseLogic?: boolean;\n  }): Promise<PaywallResult>;\n  presentCustomerCenter(): Promise<void>;\n  setMockWebResults?(options: { shouldMockWebResults: boolean }): Promise<void>;\n\n  resumePurchaseInitiated(options: { requestId: string; shouldProceed: boolean }): Promise<void>;\n  resumePurchaseLogicPurchase(options: {\n    requestId: string;\n    result: string;\n    error?: { code?: string; message?: string };\n  }): Promise<void>;\n  resumePurchaseLogicRestore(options: {\n    requestId: string;\n    result: string;\n    error?: { code?: string; message?: string };\n  }): Promise<void>;\n\n  addListener(eventName: string, listener: (data: any) => void): Promise<PluginListenerHandle>;\n  removeAllListeners(): Promise<void>;\n}\n\nconst nativePlugin = registerPlugin<RevenueCatUINativePlugin>('RevenueCatUI', {\n  web: () => import('./web').then((m) => new m.RevenueCatUIWeb()),\n});\n\nfunction serializeResultForNative(result: PurchaseLogicResult): {\n  result: string;\n  error?: { code?: string; message?: string };\n} {\n  if (result.result === PURCHASE_LOGIC_RESULT.ERROR && 'error' in result && result.error) {\n    return {\n      result: result.result,\n      error: {\n        code: result.error.code,\n        message: result.error.message,\n      },\n    };\n  }\n  return { result: result.result };\n}\n\nasync function presentWithListenerSupport(\n  nativeMethod: (options: any) => Promise<PaywallResult>,\n  options: any,\n  listener?: PaywallListener,\n  purchaseLogic?: PurchaseLogic,\n): Promise<PaywallResult> {\n  const handles: PluginListenerHandle[] = [];\n\n  try {\n    // Register PaywallListener event handlers\n    if (listener) {\n      if (listener.onPurchaseStarted) {\n        const cb = listener.onPurchaseStarted;\n        handles.push(\n          await nativePlugin.addListener('onPurchaseStarted', (data: any) => {\n            cb({ packageBeingPurchased: data.packageBeingPurchased ?? data });\n          }),\n        );\n      }\n      if (listener.onPurchaseCompleted) {\n        const cb = listener.onPurchaseCompleted;\n        handles.push(\n          await nativePlugin.addListener('onPurchaseCompleted', (data: any) => {\n            cb({\n              customerInfo: data.customerInfo,\n              storeTransaction: data.storeTransaction,\n            });\n          }),\n        );\n      }\n      if (listener.onPurchaseError) {\n        const cb = listener.onPurchaseError;\n        handles.push(\n          await nativePlugin.addListener('onPurchaseError', (data: any) => {\n            cb({ error: data.error ?? data });\n          }),\n        );\n      }\n      if (listener.onPurchaseCancelled) {\n        const cb = listener.onPurchaseCancelled;\n        handles.push(\n          await nativePlugin.addListener('onPurchaseCancelled', () => {\n            cb();\n          }),\n        );\n      }\n      if (listener.onRestoreStarted) {\n        const cb = listener.onRestoreStarted;\n        handles.push(\n          await nativePlugin.addListener('onRestoreStarted', () => {\n            cb();\n          }),\n        );\n      }\n      if (listener.onRestoreCompleted) {\n        const cb = listener.onRestoreCompleted;\n        handles.push(\n          await nativePlugin.addListener('onRestoreCompleted', (data: any) => {\n            cb({ customerInfo: data.customerInfo ?? data });\n          }),\n        );\n      }\n      if (listener.onRestoreError) {\n        const cb = listener.onRestoreError;\n        handles.push(\n          await nativePlugin.addListener('onRestoreError', (data: any) => {\n            cb({ error: data.error ?? data });\n          }),\n        );\n      }\n    }\n\n    // Always register onPurchaseInitiated so we auto-resume when the user\n    // doesn't provide an onPurchaseInitiated callback — otherwise the\n    // purchase flow hangs waiting for a resume that never comes.\n    // This must be outside the `if (listener)` block because the native\n    // delegate adapter always fires this event (even with purchaseLogic only).\n    const onPurchaseInitiatedCb = listener?.onPurchaseInitiated;\n    handles.push(\n      await nativePlugin.addListener('onPurchaseInitiated', (data: any) => {\n        const requestId: string = data.requestId;\n        const packageBeingPurchased = data.package ?? data.packageBeingPurchased;\n        if (onPurchaseInitiatedCb) {\n          onPurchaseInitiatedCb({\n            packageBeingPurchased,\n            resumable: {\n              resume(shouldProceed = true) {\n                nativePlugin.resumePurchaseInitiated({ requestId, shouldProceed });\n              },\n            },\n          });\n        } else {\n          // No callback provided — auto-proceed with the purchase.\n          nativePlugin.resumePurchaseInitiated({ requestId, shouldProceed: true });\n        }\n      }),\n    );\n\n    // Register PurchaseLogic event handlers\n    if (purchaseLogic) {\n      handles.push(\n        await nativePlugin.addListener('onPerformPurchaseRequest', async (data: any) => {\n          const requestId: string = data.requestId;\n          const packageToPurchase = data.package ?? data.packageBeingPurchased ?? data.packageToPurchase;\n          try {\n            const result = await purchaseLogic.performPurchase({ packageToPurchase });\n            await nativePlugin.resumePurchaseLogicPurchase({\n              requestId,\n              ...serializeResultForNative(result),\n            });\n          } catch (e: any) {\n            await nativePlugin.resumePurchaseLogicPurchase({\n              requestId,\n              result: PURCHASE_LOGIC_RESULT.ERROR,\n              error: { message: e?.message ?? 'Unknown error' },\n            });\n          }\n        }),\n      );\n      handles.push(\n        await nativePlugin.addListener('onPerformRestoreRequest', async (data: any) => {\n          const requestId: string = data.requestId;\n          try {\n            const result = await purchaseLogic.performRestore();\n            await nativePlugin.resumePurchaseLogicRestore({\n              requestId,\n              ...serializeResultForNative(result),\n            });\n          } catch (e: any) {\n            await nativePlugin.resumePurchaseLogicRestore({\n              requestId,\n              result: PURCHASE_LOGIC_RESULT.ERROR,\n              error: { message: e?.message ?? 'Unknown error' },\n            });\n          }\n        }),\n      );\n    }\n\n    // Call native with serializable-only options\n    const nativeOptions = {\n      ...options,\n      hasPaywallListener: !!listener,\n      hasPurchaseLogic: !!purchaseLogic,\n    };\n    // Remove non-serializable fields\n    delete nativeOptions.listener;\n    delete nativeOptions.purchaseLogic;\n\n    return await nativeMethod(nativeOptions);\n  } finally {\n    // Clean up all registered listeners\n    for (const handle of handles) {\n      await handle.remove();\n    }\n  }\n}\n\nconst RevenueCatUI: RevenueCatUIPlugin = {\n  async presentPaywall(options?: PresentPaywallOptions): Promise<PaywallResult> {\n    const listener = options?.listener;\n    const purchaseLogic = options?.purchaseLogic;\n\n    if (!listener && !purchaseLogic) {\n      return nativePlugin.presentPaywall(options ?? {});\n    }\n\n    return presentWithListenerSupport(\n      (opts) => nativePlugin.presentPaywall(opts),\n      { ...options },\n      listener,\n      purchaseLogic,\n    );\n  },\n\n  async presentPaywallIfNeeded(options: PresentPaywallIfNeededOptions): Promise<PaywallResult> {\n    const listener = options?.listener;\n    const purchaseLogic = options?.purchaseLogic;\n\n    if (!listener && !purchaseLogic) {\n      return nativePlugin.presentPaywallIfNeeded(options);\n    }\n\n    return presentWithListenerSupport(\n      (opts) => nativePlugin.presentPaywallIfNeeded(opts),\n      { ...options },\n      listener,\n      purchaseLogic,\n    );\n  },\n\n  async presentCustomerCenter(): Promise<void> {\n    return nativePlugin.presentCustomerCenter();\n  },\n\n  setMockWebResults: nativePlugin.setMockWebResults\n    ? async (options: { shouldMockWebResults: boolean }): Promise<void> => {\n        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n        return nativePlugin.setMockWebResults!(options);\n      }\n    : undefined,\n\n  addListener(eventName: 'paywallDisplayed' | 'paywallDismissed', listener: () => void): Promise<PluginListenerHandle> {\n    return nativePlugin.addListener(eventName, listener);\n  },\n\n  removeAllListeners(): Promise<void> {\n    return nativePlugin.removeAllListeners();\n  },\n};\n\nexport * from './definitions';\nexport { PAYWALL_RESULT } from '@revenuecat/purchases-typescript-internal-esm';\nexport { RevenueCatUI };\n"]}