-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnatively-frontend.min.js
1 lines (1 loc) · 17.7 KB
/
natively-frontend.min.js
1
(()=>{"use strict";var i={d:(e,t)=>{for(var l in t)i.o(t,l)&&!i.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})}};i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(i){if("object"==typeof window)return window}}(),i.o=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),i.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var e={};i.r(e),i.d(e,{Natively:()=>l,NativelyAdmobBanner:()=>A,NativelyAdmobInterstitial:()=>w,NativelyAppleSignInService:()=>n,NativelyAudioRecorder:()=>N,NativelyBiometrics:()=>c,NativelyCamera:()=>p,NativelyClipboard:()=>r,NativelyContacts:()=>m,NativelyDatePicker:()=>y,NativelyFirebaseNotifications:()=>k,NativelyGeolocation:()=>d,NativelyHealth:()=>h,NativelyInfo:()=>s,NativelyKlaviyoNotifications:()=>I,NativelyLocation:()=>g,NativelyMediaPicker:()=>f,NativelyMessage:()=>v,NativelyNFCService:()=>S,NativelyNotifications:()=>o,NativelyPurchases:()=>b,NativelyScanner:()=>_,NativelyStorage:()=>u,NativelyTabBar:()=>P,NativelyWakelock:()=>T,generateID:()=>a,useNatively:()=>D});const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==i.g?i.g:null;class l{constructor(){var i,e,l,a;this.isDebug=!1,this.min_app_version=0,this.app_version=0,this.injected=!1,this.observers=[],this.isIOSApp=(null===(e=null===(i=null==t?void 0:t.navigator)||void 0===i?void 0:i.userAgent)||void 0===e?void 0:e.includes("Natively/iOS"))||!1,this.isAndroidApp=(null===(a=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}setDebug(i){t&&(t.natively.isDebug=i)}notify(i,e){t&&(t.natively.injected=!0,i&&(t.natively.min_app_version=i),e&&(t.natively.app_version=e));const l=null==t?void 0:t.natively.observers;for((null==t?void 0:t.natively.isDebug)&&console.log("[INFO] Notify observers: ",l.length);l.length>0;){const i=l.shift();null==i||i()}}addObserver(i){(null==t?void 0:t.natively.injected)?i():((null==t?void 0:t.natively.isDebug)&&console.log(`[DEBUG] addObserver: ${i}`),null==t||t.natively.observers.push(i))}trigger(i,e,l,a,n){const r=null==t?void 0:t.natively.isDebug;if(null==t?void 0:t.natively.injected)if(e>(null==t?void 0:t.natively.app_version))r&&alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${null==t?void 0:t.natively.app_version}, feature version: ${e}`);else{if(l){let e;e=i?a+"_response_"+i:a+"_response",t&&(t[e]=function(a,n){null==t||t.$agent.response(),n.message&&r?alert(`[ERROR] Error message: ${n.message}`):(r&&console.log(`[DEBUG] Callback method: ${e}, body: ${JSON.stringify(a)}, respId: ${i}`),l(a))}),n?n.response_id=i:n={response_id:i}}r&&console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(n)}`),null==t||t.$agent.trigger(a,n)}else null==t||t.natively.addObserver((()=>{null==t||t.natively.trigger(i,e,l,a,n)}))}openLogger(){null==t||t.$agent.natively_logger()}openConsole(){null==t||t.natively.trigger(void 0,22,void 0,"app_console")}closeApp(){null==t||t.natively.trigger(void 0,11,void 0,"app_close")}showProgress(i){null==t||t.natively.trigger(void 0,11,void 0,"app_show_progress",{toggle:i})}shareImage(i){null==t||t.natively.trigger(void 0,0,void 0,"share_image",{url:i})}shareText(i){null==t||t.natively.trigger(void 0,0,void 0,"share_text",{text:i})}shareTextAndImage(i,e){null==t||t.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:e,text:i})}shareFile(i){null==t||t.natively.trigger(void 0,2,void 0,"share_file",{url:i})}openExternalURL(i,e){const l={url:void 0===i?"https://buildnatively.com":i,view:void 0!==e&&e?"external":"web"};null==t||t.natively.trigger(void 0,18,void 0,"open_link",l)}openExternalApp(i){null==t||t.natively.trigger(void 0,22,void 0,"open_app",{url:i})}showAppToast(i,e){null==t||t.natively.trigger(void 0,0,void 0,"show_toast",{text:e||"",type:i||"DEFAULT"})}showAppBanner(i,e,l){null==t||t.natively.trigger(void 0,0,void 0,"show_banner",{type:i||"INFO",title:e||"",description:l||""})}requestAppReview(){null==t||t.natively.trigger(void 0,0,void 0,"request_review")}setAppBackgroundColor(i){null==t||t.natively.trigger(void 0,1,void 0,"app_background",{color:i})}setAppProgressColor(i){null==t||t.natively.trigger(void 0,1,void 0,"app_progress",{color:i})}setAppSwipeNavigation(i){null==t||t.natively.trigger(void 0,22,void 0,"app_navigation",{toggle:i})}setAppPullToRefresh(i){null==t||t.natively.trigger(void 0,1,void 0,"app_pull",{toggle:i})}setAppOrientation(i){null==t||t.natively.trigger(void 0,3,void 0,"app_orientation",{orientation:i})}setAppStatusBarStyle(i){null==t||t.natively.trigger(void 0,22,void 0,"status_bar_style",{style:i})}hideLoadingScreen(){null==t||t.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!1,auto_hide:!0})}showLoadingScreen(i){null==t||t.natively.trigger(void 0,17,void 0,"loading_screen",{show_loader:!0,auto_hide:i||!1})}openAppSettings(){null==t||t.natively.trigger(void 0,0,void 0,"open_appsettings")}hapticPattern(i,e){null==t||t.natively.trigger(void 0,22,void 0,"haptic_pattern",{pattern:i,delay:e})}hapticImpact(i){null==t||t.natively.trigger(void 0,22,void 0,"haptic_impact",{type:i})}hapticNotification(i){null==t||t.natively.trigger(void 0,22,void 0,"haptic_notification",{type:i})}sendPushNotification(i,e,t,l){return a=this,n=void 0,s=function*(){const a=t.filter((i=>i.length>0)),n=[...new Set(a)],r={app_id:l?"be83022a-1d08-45d0-a07a-0c3655666e17":i,include_player_ids:n};e.template_id?r.template_id=e.template_id:(r.headings={en:e.title||"Empty Title"},r.contents={en:e.message||"Empty Message"},e.subtitle&&(r.subtitle={en:e.subtitle}),e.redirect_url&&(r.url=e.redirect_url));const s={method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify(r)};return yield fetch("https://onesignal.com/api/v1/notifications",s)},new((r=void 0)||(r=Promise))((function(i,e){function t(i){try{o(s.next(i))}catch(i){e(i)}}function l(i){try{o(s.throw(i))}catch(i){e(i)}}function o(e){var a;e.done?i(e.value):(a=e.value,a instanceof r?a:new r((function(i){i(a)}))).then(t,l)}o((s=s.apply(a,n||[])).next())}));var a,n,r,s}}const a=()=>Date.now().toString(36)+Math.random().toString(36).substring(2);class n{constructor(){this.id=a()}signin(i){null==t||t.natively.trigger(this.id,16,i,"apple_signin",{})}}class r{constructor(){this.id=a()}copy(i){null==t||t.natively.trigger(void 0,11,void 0,"clipboard_copy",{text:i})}paste(i){null==t||t.natively.trigger(this.id,11,i,"clipboard_paste")}}class s{constructor(){this.id=a()}browserInfo(){var i,e,l,a;return{isNativeApp:void 0!==(null==t?void 0:t.$agent),isIOSApp:(null===(e=null===(i=null==t?void 0:t.navigator)||void 0===i?void 0:i.userAgent)||void 0===e?void 0:e.includes("Natively/iOS"))||!1,isAndroidApp:(null===(a=null===(l=null==t?void 0:t.navigator)||void 0===l?void 0:l.userAgent)||void 0===a?void 0:a.includes("Natively/Android"))||!1}}getAppInfo(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(this.id,0,i,"app_info"))}connectivity(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,0,i,"connectivity"))}app_state(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,19,i,"app_state"))}keyboard_visibility(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(void 0,0,i,"keyboard_visibility"))}}class o{constructor(){this.id=a()}getOneSignalId(i){null==t||t.natively.trigger(this.id,0,i,"onesignal_playerid")}requestPermission(i,e){null==t||t.natively.trigger(this.id,0,e,"push_register",{fallbackToSettings:i})}getPermissionStatus(i){null==t||t.natively.trigger(this.id,0,i,"push_permission")}}class d{constructor(){this.id=a()}getUserGeolocation(i,e){null==t||t.natively.trigger(this.id,0,e,"geolocation",{distance:i})}requestPermission(i){null==t||t.natively.trigger(this.id,0,i,"geo_register")}getPermissionStatus(i){null==t||t.natively.trigger(this.id,0,i,"geo_permission")}}class g{constructor(){this.id=a()}current(i,e,l,a){null==t||t.natively.trigger(this.id,12,a,"location_current",{minAccuracy:i,accuracyType:e,priority:l})}permission(i){null==t||t.natively.trigger(this.id,6,i,"location_permission")}start(i,e,l,a,n){null==t||t.natively.trigger(this.id,12,n,"location_start",{minAccuracy:e,accuracyType:l,priority:a,interval:i})}stop(){null==t||t.natively.trigger(this.id,3,void 0,"location_stop",{})}startBackground(i,e,l,a,n,r){const s={identifier:null!=n?n:"empty",interval:null!=i?i:6e4,minAccuracy:null!=e?e:50,accuracyType:null!=l?l:"Best",priority:null!=a?a:"BALANCED"};null==t||t.natively.trigger(this.id,12,r,"location_start_bg",s)}statusBackground(i){null==t||t.natively.trigger(this.id,20,i,"location_status_bg",{})}stopBackground(i){null==t||t.natively.trigger(this.id,4,i,"location_stop_bg",{})}}class v{constructor(){this.id=a()}sendSMS(i,e,l){const a={body:null!=i?i:"",recipient:null!=e?e:""};null==t||t.natively.trigger(this.id,0,l,"send_sms",a)}sendEmail(i,e,l,a){const n={subject:null!=i?i:"",body:null!=e?e:"",recipient:null!=l?l:""};null==t||t.natively.trigger(this.id,0,a,"send_email",n)}}class u{constructor(){this.id=a()}setStorageValue(i,e){null==t||t.natively.trigger(this.id,0,void 0,"set_storage_value",{key:i,value:e})}getStorageValue(i,e){null==t||t.natively.trigger(this.id,0,e,"get_storage_value",{key:i})}removeStorageValue(i){null==t||t.natively.trigger(this.id,0,void 0,"remove_storage_value",{key:i})}resetStorage(){null==t||t.natively.trigger(this.id,0,void 0,"reset_storage")}}class c{constructor(i){this.id=a(),this.allowPass=i}checkBiometricsSupport(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_support",{allowPass:this.allowPass})}checkCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_has_credentials")}verifyUserIdentify(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_verify",{allowPass:this.allowPass})}getUserCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_auth",{allowPass:this.allowPass})}removeUserCredentials(i){null==t||t.natively.trigger(this.id,0,i,"biometrics_remove_credentials")}saveUserCredentials(i,e,l){null==t||t.natively.trigger(this.id,0,l,"biometrics_auth",{allowPass:this.allowPass,login:i,password:e})}}class y{constructor(){this.id=a()}showDatePicker(i,e,l,a,n){const r={type:null!=l?l:"DATE",style:null!=a?a:"LIGHT",title:null!=i?i:"",description:null!=e?e:""};null==t||t.natively.trigger(this.id,0,n,"datepicker",r)}}class p{constructor(){this.id=a()}showCamera(i,e,l,a){const n={type:null!=i?i:"photo",quality:null!=e?e:"high",camera:null!=l?l:"BACK"};null==t||t.natively.trigger(this.id,2,a,"open_camera",n)}}class h{constructor(){this.id=a()}available(i){null==t||t.natively.trigger(this.id,10,i,"health_available",{})}requestAuthorization(i,e,l){null==t||t.natively.trigger(this.id,10,l,"health_register",{write_data_types:i,read_data_types:e})}permissionStatus(i,e){null==t||t.natively.trigger(this.id,10,e,"health_permission",{data_type:i})}getAllCharacteristics(i){null==t||t.natively.trigger(this.id,10,i,"health_get_all_characteristics",{})}getStatisticQuantity(i,e,l,a,n){const r={data_type:i,interval:e};l&&(r.start_date=l.getTime()),a&&(r.end_date=a.getTime()),null==t||t.natively.trigger(this.id,10,n,"health_get_statistic_quantity",r)}getDailySleepAnalysis(i,e,l,a){const n={limit:l||100};i&&(n.start_date=i.getTime()),e&&(n.end_date=e.getTime()),null==t||t.natively.trigger(this.id,10,a,"health_get_daily_sleep_analysis",n)}getWorkouts(i,e,l,a){const n={limit:l||100};i&&(n.start_date=i.getTime()),e&&(n.end_date=e.getTime()),null==t||t.natively.trigger(this.id,21,a,"health_get_workouts",n)}getActivitySummary(i,e,l){const a={};i&&(a.start_date=i.getTime()),e&&(a.end_date=e.getTime()),null==t||t.natively.trigger(this.id,10,l,"health_get_activity_summary",a)}}class _{constructor(){this.id=a()}showScanner(i){null==t||t.natively.trigger(this.id,2,i,"open_scanner",{})}}class b{constructor(){this.id=a()}login(i,e,l){const a=null!=e?e:"";null==t||t.natively.trigger(this.id,3,l,"purchases_login",{login:i,email:a})}logout(i){null==t||t.natively.trigger(this.id,3,i,"purchases_logout",{})}customerId(i){null==t||t.natively.trigger(this.id,3,i,"purchases_customerid",{})}restore(i){null==t||t.natively.trigger(this.id,10,i,"purchases_restore",{})}purchasePackage(i,e,l){null==t||t.natively.trigger(this.id,3,e,"purchases_package",{packageId:i,oldProductId:null!=l?l:null})}packagePrice(i,e){null==t||t.natively.trigger(this.id,8,e,"purchases_price",{packageId:i})}}class m{constructor(){this.id=a()}getAllContacts(i){null==t||t.natively.trigger(this.id,3,i,"contacts_all",{})}createContact(i,e,l,a,n){const r={firstName:i,lastName:null!=e?e:"",email:null!=l?l:"",phone:null!=a?a:""};null==t||t.natively.trigger(this.id,3,n,"contacts_save",r)}}class f{constructor(){this.id=a()}showMediaPicker(i){null==t||t.natively.trigger(this.id,8,i,"mediapicker",{})}}class N{constructor(){this.id=a()}showRecorder(i,e){const l={max_duration:null!=i?i:0};null==t||t.natively.trigger(this.id,13,e,"record_start",l)}}class A{constructor(i,e,l=!1,n,r=!1,s){var o,d,g,v,u,c;this.id=a();const y={};(null==t?void 0:t.natively.isAndroidApp)?y.unitId=null!==(o=i.androidUnitId)&&void 0!==o?o:"ca-app-pub-3940256099942544/6300978111":(null==t?void 0:t.natively.isIOSApp)&&(y.unitId=null!==(d=i.iOSUnitId)&&void 0!==d?d:"ca-app-pub-3940256099942544/2934735716"),y.position=null!==(g=i.position)&&void 0!==g?g:"BOTTOM",y.sizeType=null!==(v=i.sizeType)&&void 0!==v?v:"AUTO",y.width=null!==(u=i.custom_width)&&void 0!==u?u:320,y.height=null!==(c=i.custom_height)&&void 0!==c?c:50,null==t||t.natively.trigger(this.id,14,(i=>{null==e||e(i),l&&(null==t||t.natively.trigger(this.id,14,(i=>{null==n||n(i),r&&(null==t||t.natively.trigger(this.id,14,s,"bannerad_show",{}))}),"bannerad_load",{}))}),"bannerad_setup",y)}loadAd(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_load",{})}showBanner(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_show",{})}hideBanner(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_hide",{})}bannerIsReady(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_ready",{})}bannerIsVisible(i){null==t||t.natively.trigger(this.id,14,i,"bannerad_visible",{})}}class w{constructor(i="ca-app-pub-3940256099942544/4411468910",e="ca-app-pub-3940256099942544/1033173712",l,n=!1,r){this.id=a(),(null==t?void 0:t.natively.isAndroidApp)?this.unitId=e:(null==t?void 0:t.natively.isIOSApp)&&(this.unitId=i),this.auto_ad_reload=n,this.auto_ad_reload_callback=r,this.loadAd(l)}loadAd(i){var e;const l={unitId:null!==(e=this.unitId)&&void 0!==e?e:"ca-app-pub-3940256099942544/4411468910"};null==t||t.natively.trigger(this.id,14,i,"interstitialad_setup",l)}showInterstitialAd(i){null==t||t.natively.trigger(this.id,14,(e=>{i(e),"DID_DISMISS_AD"===e.event&&this.auto_ad_reload&&setTimeout((()=>{this.loadAd(this.auto_ad_reload_callback)}),500)}),"interstitialad_show",{})}interstitialIsReady(i){null==t||t.natively.trigger(this.id,14,i,"interstitialad_ready",{})}}class S{constructor(i,e,t,l){this.id=a(),this.readAlertMessage=i,this.writeAlertMessage=e,this.readDetectedMessage=t,this.writeDetectedMessage=l}read(i){var e,l;const a={alertMessage:null!==(e=this.readAlertMessage)&&void 0!==e?e:"please set readAlertMessage",detectedMessage:null!==(l=this.readDetectedMessage)&&void 0!==l?l:"readDetectedMessage"};null==t||t.natively.trigger(this.id,15,i,"nfc_read",a)}write(i,e,l){var a,n;const r={alertMessage:null!==(a=this.writeAlertMessage)&&void 0!==a?a:"please set writeAlertMessage",detectedMessage:null!==(n=this.writeDetectedMessage)&&void 0!==n?n:"please set writeDetectedMessage",recordData:null!=e?e:"please set recordData",recordId:null!=i?i:"please set recordId"};null==t||t.natively.trigger(this.id,15,l,"nfc_write",r)}available(i){null==t||t.natively.trigger(this.id,15,i,"nfc_available",{})}}class k{constructor(){this.id=a()}firebase_get_token(i){null==t||t.natively.trigger(this.id,31,i,"firebase_get_token")}firebase_get_apns_token(i){null==t||t.natively.trigger(this.id,31,i,"firebase_get_apns_token")}firebase_request_permission(i){null==t||t.natively.trigger(this.id,31,i,"firebase_request_permission")}firebase_has_permission(i){null==t||t.natively.trigger(this.id,31,i,"firebase_has_permission")}firebase_subscribe_to_topic(i,e){null==t||t.natively.trigger(this.id,31,e,"firebase_subscribe_to_topic",{topic:i})}firebase_unsubscribe_from_topic(i,e){null==t||t.natively.trigger(this.id,31,e,"firebase_unsubscribe_from_topic",{topic:i})}}class I{constructor(){this.id=a()}setProfile(i,e){null==t||t.natively.trigger(this.id,32,e,"klaviyo_set_profile",i)}getExternalId(i){null==t||t.natively.trigger(this.id,32,i,"klaviyo_external_id")}resetProfile(i){null==t||t.natively.trigger(this.id,32,i,"klaviyo_reset_profile")}pushPermission(i){null==t||t.natively.trigger(this.id,32,i,"klaviyo_push_permission")}pushRegister(i){null==t||t.natively.trigger(this.id,32,i,"klaviyo_push_register")}}class P{constructor(){this.id=a()}showTabBar(){null==t||t.natively.trigger(this.id,33,void 0,"show_tab_bar")}hideTabBar(){null==t||t.natively.trigger(this.id,33,void 0,"hide_tab_bar")}}class T{constructor(){this.id=a()}getAppInfo(i){(null==t?void 0:t.natively)&&(null==t||t.natively.trigger(this.id,0,i,"app_info"))}}const D=()=>null==t?void 0:t.natively;t&&(t.natively=new l,t.NativelyAdmobBanner=A,t.NativelyAdmobInterstitial=w,t.NativelyAppleSignInService=n,t.NativelyAudioRecorder=N,t.NativelyBiometrics=c,t.NativelyCamera=p,t.NativelyClipboard=r,t.NativelyContacts=m,t.NativelyDatePicker=y,t.NativelyGeolocation=d,t.NativelyHealth=h,t.NativelyInfo=s,t.NativelyLocation=g,t.NativelyMediaPicker=f,t.NativelyMessage=v,t.NativelyNFCService=S,t.NativelyNotifications=o,t.NativelyPurchases=b,t.NativelyScanner=_,t.NativelyStorage=u,t.NativelyFirebaseNotifications=k,t.NativelyKlaviyoNotifications=I,t.NativelyTabBar=P,t.NativelyWakelock=T),null==t||t.natively.addObserver((()=>null==t?void 0:t.natively.trigger(void 0,0,(i=>{t&&(t.natively.min_app_version=i.minSDKVersion,t.natively.app_version=i.sdkVersion)}),"app_info",{})))})();