"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var c=(n=>(n.STAGING="STAGING",n.PRODUCTION="PRODUCTION",n))(c||{});var f=(e=>(e.ORDER_CREATED="ORDER_CREATED",e.ORDER_PAYMENT_VERIFYING="ORDER_PAYMENT_VERIFYING",e.ORDER_PROCESSING="ORDER_PROCESSING",e.ORDER_COMPLETED="ORDER_COMPLETED",e.ORDER_FAILED="ORDER_FAILED",e))(f||{});var _react = require('react');var _reactnative = require('react-native');var _reactnativewebview = require('react-native-webview');var _reactnativeinappbrowserreborn = require('react-native-inappbrowser-reborn');var _querystring = require('query-string'); var _querystring2 = _interopRequireDefault(_querystring);var _pako = require('pako'); var _pako2 = _interopRequireDefault(_pako);var d={DEVELOPMENT:"https://:5005/",DEV:"https://global-dev.transak.com",BETA:"https://global-beta.transak.com",STAGING:"https://global-stg.transak.com",PRODUCTION:"https://global.transak.com"};var m={name:"@transak/react-native-sdk",version:"2.0.4",description:"A React Native SDK for decentralised applications to onboard their global user base with fiat currency",type:"module",types:"lib/index.d.ts",main:"lib/index.cjs",exports:{".":{import:{types:"./lib/index.d.ts",default:"./lib/index.js"},require:{types:"./lib/index.d.cts",default:"./lib/index.cjs"}}},engines:{node:">=18.0.0"},packageManager:"pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903",files:["lib/**/*"],scripts:{eslint:"eslint . --ext .ts,.tsx","eslint:fix":"pnpm eslint --fix",build:"tsc && tsup",prepack:"pnpm build",packDev:"pnpm pack"},author:"Transak",license:"ISC",homepage:"https://docs.transak.com/docs/react-native-integration#transak-react-native-sdk",repository:{type:"git",url:"https://github.com/Transak/react-native-sdk"},peerDependencies:{"@react-native-community/netinfo":"*","@types/react":"*",react:"*","react-native":"*","react-native-inappbrowser-reborn":"*","react-native-webview":"*"},dependencies:{pako:"^2.1.0","pusher-js":"^8.3.0","query-string":"^8.2.0"},devDependencies:{"@types/pako":"^2.0.3","@types/react":"^18.2.57",eslint:"^8.56.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-airbnb-typescript":"^17.1.0","eslint-config-prettier":"^9.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-import":"^2.29.1","eslint-plugin-no-relative-import-paths":"^1.5.3","eslint-plugin-prettier":"^5.1.3","eslint-plugin-promise":"^6.1.1",prettier:"^3.2.5",tsup:"^8.0.2",typescript:"^5.3.3"},keywords:["crypto","cryptocurrency","fiat","on","off","ramp","sdk","react-native"]};function u(r){let{name:i,version:n}=m,{environment:s="STAGING"}=r,a={sdkName:i,sdkVersion:n},e="";return Object.keys(r).forEach(t=>{if(!["environment","widgetWidth","widgetHeight"].includes(t)){if(["walletAddressesData","userData"].includes(t)){try{a[t]=JSON.stringify(r[t])}catch (e2){}return}if(["nftData","sourceTokenData","cryptoCurrencyData","tokenData"].includes(t)){try{a[t]=btoa(JSON.stringify(r[t]))}catch (e3){}return}if(["calldata"].includes(t)){try{a[t]=btoa(String.fromCharCode.apply(null,_pako2.default.deflate(r[t])))}catch (e4){}return}a[t]=r[t]}}),e=_querystring2.default.stringify(a,{arrayFormat:"comma"}),`${d[s]}?${e}`}var _reactnative3 = require('pusher-js/react-native'); var _reactnative4 = _interopRequireDefault(_reactnative3);function b({apiKey:r,partnerOrderId:i},n){let s=new (0, _reactnative4.default)("1d9ffac87de599c61283",{cluster:"ap2"}),a=`${r}_${i}`;return s.subscribe(a),s.bind_global((e,t)=>{e!=="pusher:pong"&&n(e,t)}),{unbindListener:()=>{s.unsubscribe(a),s.unbind_global()}}}var _jsxruntime = require('react/jsx-runtime');var D=_react.forwardRef.call(void 0, ({transakConfig:r,onTransakEvent:i,...n},s)=>{let a=u(r),e={...n};delete e.sharedCookiesEnabled,delete e.injectedJavaScript,delete e.injectedJavaScriptBeforeContentLoaded,delete e.onMessage;let t=async o=>{try{await _reactnativeinappbrowserreborn.InAppBrowser.isAvailable()?await _reactnativeinappbrowserreborn.InAppBrowser.open(o,{showTitle:!1,toolbarColor:r.themeColor?`#${r.themeColor}`:"#2575fc",secondaryToolbarColor:"#ffffff",enableUrlBarHiding:!0,enableDefaultShare:!1,forceCloseOnRedirection:!1,hasBackButton:!1,showInRecents:!1,dismissButtonStyle:"done",preferredBarTintColor:r.themeColor?`#${r.themeColor}`:"#2575fc",preferredControlTintColor:"#ffffff",readerMode:!1,animated:!0,modalPresentationStyle:"fullScreen",modalTransitionStyle:"coverVertical",modalEnabled:!0,enableBarCollapsing:!1}):await _reactnative.Linking.openURL(o)}catch(p){p instanceof Error&&_reactnative.Alert.alert(p.message)}},l=o=>{n.onMessage&&n.onMessage(o);let p=o.nativeEvent.data;p.includes("/googlepay")&&t(p.replace("isWebView","useAsExternalPayment"))};return _react.useEffect.call(void 0, ()=>{let{unbindListener:o}=b(r,i);return()=>{o()}},[]),_jsxruntime.jsx.call(void 0, _reactnativewebview.WebView,{ref:s,...e,originWhitelist:["*"],source:{uri:a},enableApplePay:!0,allowsInlineMediaPlayback:!0,onMessage:l})});exports.Environments = c; exports.Events = f; exports.TransakWebView = D; //# sourceMappingURL=index.cjs.map