@imtbl/sdk 1.6.0-alpha.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/sdk.js +4 -4
  3. package/dist/browser/checkout/widgets.js +51 -50
  4. package/dist/checkout.d.ts +1 -3
  5. package/dist/checkout.js +8 -43
  6. package/dist/config.js +1 -1
  7. package/dist/index.browser.js +13 -13
  8. package/dist/index.browser.js.map +1 -1
  9. package/dist/index.cjs +10 -45
  10. package/dist/index.d.ts +1 -3
  11. package/dist/index.js +10 -45
  12. package/dist/orderbook.js +1 -1
  13. package/dist/passport.js +3 -3
  14. package/dist/x.js +2 -2
  15. package/package.json +1 -1
  16. package/dist/browser/checkout/BridgeWidget-38c8cacb.js +0 -1
  17. package/dist/browser/checkout/OnRampWidget-1c8e54ce.js +0 -1
  18. package/dist/browser/checkout/SaleWidget-cc5aa51c.js +0 -2
  19. package/dist/browser/checkout/SpendingCapHero-fdeb2fc6.js +0 -1
  20. package/dist/browser/checkout/SwapWidget-acbacee2.js +0 -1
  21. package/dist/browser/checkout/TopUpView-a4425aa3.js +0 -1
  22. package/dist/browser/checkout/WalletWidget-4528b0a7.js +0 -1
  23. package/dist/browser/checkout/auto-track-c91d2967.js +0 -1
  24. package/dist/browser/checkout/balance-17fd7166.js +0 -1
  25. package/dist/browser/checkout/index-008f3a1f.js +0 -1
  26. package/dist/browser/checkout/index-1b56d53b.js +0 -1
  27. package/dist/browser/checkout/index-1ba3ec23.js +0 -106
  28. package/dist/browser/checkout/index-21a40c88.js +0 -1
  29. package/dist/browser/checkout/index-5728dc7e.js +0 -1
  30. package/dist/browser/checkout/index-bc18091f.js +0 -773
  31. package/dist/browser/checkout/index-e5599662.js +0 -1
  32. package/dist/browser/checkout/index.umd-fb0326ca.js +0 -1
  33. package/dist/browser/checkout/is-plan-event-enabled-80f76ce6.js +0 -1
  34. package/dist/browser/checkout/retry-2fc63d32.js +0 -1
  35. package/dist/browser/checkout/useTransakEvents-140c22fb.js +0 -2
  36. package/dist/browser/checkout/widgets-esm.js +0 -1
@@ -1 +0,0 @@
1
- import{bM as n}from"./index-1ba3ec23.js";import{i as e}from"./is-plan-event-enabled-80f76ce6.js";function t(t,i){function r(r){var o=t,a=r.event.event;if(o&&a){var s=o[a];if(!e(o,s))return r.updateEvent("integrations",n(n({},r.event.integrations),{All:!1,"Segment.io":!0})),r;var u=function(n,e){var t,i;if(!n||!Object.keys(n))return{};var r=n.integrations?Object.keys(n.integrations).filter((function(e){return!1===n.integrations[e]})):[],o=[];return(null!==(t=e.remotePlugins)&&void 0!==t?t:[]).forEach((function(n){r.forEach((function(e){(n.name.includes(e)||e.includes(n.name))&&o.push(n.name)}))})),(null!==(i=e.remotePlugins)&&void 0!==i?i:[]).reduce((function(n,e){return e.settings.subscriptions&&o.includes(e.name)&&e.settings.subscriptions.forEach((function(t){return n["".concat(e.name," ").concat(t.partnerAction)]=!1})),n}),{})}(s,i);r.updateEvent("integrations",n(n(n({},r.event.integrations),null==s?void 0:s.integrations),u))}return r}return{name:"Schema Filter",version:"0.1.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},type:"before",page:r,alias:r,track:r,identify:r,group:r}}export{t as schemaFilter};
@@ -1 +0,0 @@
1
- import{b$ as e}from"./index-1ba3ec23.js";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(a){if("default"!==a&&!(a in e)){var n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,n.get?n:{enumerable:!0,get:function(){return t[a]}})}}))})),Object.freeze(e)}var a={exports:{}};window;var n=a.exports=function(e){var t={};function a(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)a.d(n,i,function(t){return e[t]}.bind(null,i));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=2)}([function(e,t,a){a.r(t);var n="function"==typeof fetch?fetch.bind():function(e,t){return t=t||{},new Promise((function(a,n){var i=new XMLHttpRequest;for(var r in i.open(t.method||"get",e,!0),t.headers)i.setRequestHeader(r,t.headers[r]);function o(){var e,t=[],a=[],n={};return i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(i,r,o){t.push(r=r.toLowerCase()),a.push([r,o]),e=n[r],n[r]=e?e+","+o:o})),{ok:2==(i.status/100|0),status:i.status,statusText:i.statusText,url:i.responseURL,clone:o,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},headers:{keys:function(){return t},entries:function(){return a},get:function(e){return n[e.toLowerCase()]},has:function(e){return e.toLowerCase()in n}}}}i.withCredentials="include"==t.credentials,i.onload=function(){a(o())},i.onerror=n,i.send(t.body)}))};t.default=n},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}(),i=function(){function e(t,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pluginName=t}return n(e,[{key:"track",value:function(e,t){window.analytics.track(e,t,{integration:{name:this.pluginName}})}}]),e}();t.default=i},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),t.YouTubeAnalytics=t.VimeoAnalytics=void 0;var n=r(a(3)),i=r(a(4));function r(e){return e&&e.__esModule?e:{default:e}}t.VimeoAnalytics=n.default,t.YouTubeAnalytics=i.default},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}(),i=r(a(0));function r(e){return e&&e.__esModule?e:{default:e}}var o=function(e){function t(e,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"VimeoAnalytics"));return n.authToken=a,n.player=e,n.metadata={content:{},playback:{videoPlayer:"Vimeo"}},n.mostRecentHeartbeat=0,n.isPaused=!1,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"initialize",value:function(){var e=this,t={loaded:this.retrieveMetadata,play:this.trackPlay,pause:this.trackPause,ended:this.trackEnded,timeupdate:this.trackHeartbeat};for(var a in t)this.registerHandler(a,t[a]);this.player.getVideoId().then((function(t){e.retrieveMetadata({id:t})})).catch(console.error)}},{key:"registerHandler",value:function(e,t){var a=this;this.player.on(e,(function(e){a.updateMetadata(e),t.call(a,e)}))}},{key:"trackPlay",value:function(){this.isPaused?(this.track("Video Playback Resumed",this.metadata.playback),this.isPaused=!1):(this.track("Video Playback Started",this.metadata.playback),this.track("Video Content Started",this.metadata.content))}},{key:"trackEnded",value:function(){this.track("Video Playback Completed",this.metadata.playback),this.track("Video Content Completed",this.metadata.content)}},{key:"trackHeartbeat",value:function(){var e=this.mostRecentHeartbeat,t=this.metadata.playback.position;t!==e&&t-e>=10&&(this.track("Video Content Playing",this.metadata.content),this.mostRecentHeartbeat=Math.floor(t))}},{key:"trackPause",value:function(){this.isPaused=!0,this.track("Video Playback Paused",this.metadata.playback)}},{key:"retrieveMetadata",value:function(e){var t=this;return new Promise((function(a,n){var r=e.id;(0,i.default)("https://api.vimeo.com/videos/"+r,{headers:{Authorization:"Bearer "+t.authToken}}).then((function(e){return e.ok?e.json():n(e)})).then((function(e){t.metadata.content.title=e.name,t.metadata.content.description=e.description,t.metadata.content.publisher=e.user.name,t.metadata.playback.position=0,t.metadata.playback.totalLength=e.duration})).catch((function(e){return console.error("Request to Vimeo API Failed with: ",e),n(e)}))}))}},{key:"updateMetadata",value:function(e){var t=this;return new Promise((function(a,n){t.player.getVolume().then((function(n){n&&(t.metadata.playback.sound=100*n),t.metadata.playback.position=e.seconds,a()})).catch(n)}))}}]),t}(r(a(1)).default);t.default=o},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}(),i=r(a(0));function r(e){return e&&e.__esModule?e:{default:e}}var o=function(e){function t(e,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"YoutubeAnalytics"));return n.player=e,n.apiKey=a,n.playerLoaded=!1,n.playbackStarted=!1,n.contentStarted=!1,n.isPaused=!1,n.isBuffering=!1,n.isSeeking=!1,n.lastRecordedTime={timeReported:Date.now(),timeElapsed:0},n.metadata=[{playback:{video_player:"youtube"},content:{}}],n.playlistIndex=0,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"initialize",value:function(){window.segmentYoutubeOnStateChange=this.onPlayerStateChange.bind(this),window.segmentYoutubeOnReady=this.onPlayerReady.bind(this),this.player.addEventListener("onReady","segmentYoutubeOnReady"),this.player.addEventListener("onStateChange","segmentYoutubeOnStateChange")}},{key:"onPlayerReady",value:function(e){this.retrieveMetadata()}},{key:"onPlayerStateChange",value:function(e){var t=this.player.getCurrentTime();switch(this.metadata[this.playlistIndex]&&(this.metadata[this.playlistIndex].playback.position=this.metadata[this.playlistIndex].content.position=t,this.metadata[this.playlistIndex].playback.quality=this.player.getPlaybackQuality(),this.metadata[this.playlistIndex].playback.sound=this.player.isMuted()?0:this.player.getVolume()),e.data){case-1:if(this.playerLoaded)break;this.retrieveMetadata(),this.playerLoaded=!0;break;case YT.PlayerState.BUFFERING:this.handleBuffer();break;case YT.PlayerState.PLAYING:this.handlePlay();break;case YT.PlayerState.PAUSED:this.handlePause();break;case YT.PlayerState.ENDED:this.handleEnd()}this.lastRecordedTime={timeReported:Date.now(),timeElapsed:1e3*this.player.getCurrentTime()}}},{key:"retrieveMetadata",value:function(){var e=this;return new Promise((function(t,a){var n=e.player.getVideoData(),r=e.player.getPlaylist()||[n.video_id],o=r.join();(0,i.default)("https://www.googleapis.com/youtube/v3/videos?id="+o+"&part=snippet,contentDetails&key="+e.apiKey).then((function(e){if(!e.ok){var t=new Error("Segment request to Youtube API failed (likely due to a bad API Key. Events will still be sent but will not contain video metadata)");throw t.response=e,t}return e.json()})).then((function(a){e.metadata=[];for(var n=0,i=0;i<r.length;i++){var o=a.items[i];e.metadata.push({content:{title:o.snippet.title,description:o.snippet.description,keywords:o.snippet.tags,channel:o.snippet.channelTitle,airdate:o.snippet.publishedAt}}),n+=s(o.contentDetails.duration)}for(i=0;i<r.length;i++)e.metadata[i].playback={total_length:n,video_player:"youtube"};t()})).catch((function(t){e.metadata=r.map((function(e){return{playback:{video_player:"youtube"},content:{}}})),a(t)}))}))}},{key:"handleBuffer",value:function(){var e=this.determineSeek();this.playbackStarted||(this.playbackStarted=!0,this.track("Video Playback Started",this.metadata[this.playlistIndex].playback)),e&&!this.isSeeking&&(this.isSeeking=!0,this.track("Video Playback Seek Started",this.metadata[this.playlistIndex].playback)),this.isSeeking&&(this.track("Video Playback Seek Completed",this.metadata[this.playlistIndex].playback),this.isSeeking=!1);var t=this.player.getPlaylist();t&&0===this.player.getCurrentTime()&&this.player.getPlaylistIndex()!==this.playlistIndex&&(this.contentStarted=!1,this.playlistIndex===t.length-1&&0===this.player.getPlaylistIndex()&&(this.track("Video Playback Completed",this.metadata[this.player.getPlaylistIndex()].playback),this.track("Video Playback Started",this.metadata[this.player.getPlaylistIndex()].playback))),this.track("Video Playback Buffer Started",this.metadata[this.playlistIndex].playback),this.isBuffering=!0}},{key:"handlePlay",value:function(){this.contentStarted||(this.playlistIndex=this.player.getPlaylistIndex(),-1===this.playlistIndex&&(this.playlistIndex=0),this.track("Video Content Started",this.metadata[this.playlistIndex].content),this.contentStarted=!0),this.isBuffering&&(this.track("Video Playback Buffer Completed",this.metadata[this.playlistIndex].playback),this.isBuffering=!1),this.isPaused&&(this.track("Video Playback Resumed",this.metadata[this.playlistIndex].playback),this.isPaused=!1)}},{key:"handlePause",value:function(){var e=this.determineSeek();this.isBuffering&&(this.track("Video Playback Buffer Completed",this.metadata[this.playlistIndex].playback),this.isBuffering=!1),this.isPaused||(e?(this.track("Video Playback Seek Started",this.metadata[this.playlistIndex].playback),this.isSeeking=!0):(this.track("Video Playback Paused",this.metadata[this.playlistIndex].playback),this.isPaused=!0))}},{key:"handleEnd",value:function(){this.track("Video Content Completed",this.metadata[this.playlistIndex].content),this.contentStarted=!1;var e=this.player.getPlaylistIndex(),t=this.player.getPlaylist();(t&&e===t.length-1||-1===e)&&(this.track("Video Playback Completed",this.metadata[this.playlistIndex].playback),this.playbackStarted=!1)}},{key:"determineSeek",value:function(){var e=this.isPaused||this.isBuffering?0:Date.now()-this.lastRecordedTime.timeReported,t=1e3*this.player.getCurrentTime()-this.lastRecordedTime.timeElapsed;return Math.abs(e-t)>2e3}}]),t}(r(a(1)).default);function s(e){var t=e.match(/PT(\d+H)?(\d+M)?(\d+S)?/);return t=t.slice(1).map((function(e){if(null!=e)return e.replace(/\D/,"")})),3600*(parseInt(t[0])||0)+60*(parseInt(t[1])||0)+(parseInt(t[2])||0)}t.default=o}]),i=t({__proto__:null,default:e(n)},[n]);export{i};
@@ -1 +0,0 @@
1
- function l(l,e){var n,o;return"boolean"==typeof(null==e?void 0:e.enabled)?e.enabled:null===(o=null===(n=null==l?void 0:l.__default)||void 0===n?void 0:n.enabled)||void 0===o||o}export{l as i};
@@ -1 +0,0 @@
1
- import{r,bC as e}from"./index-1ba3ec23.js";function t(t,n){const a=r.useRef(t),s=r.useRef(0);return e((()=>{a.current=t}),[t]),r.useEffect((()=>{if(n||0===n)return s.current=setInterval((()=>a.current()),n),()=>{clearInterval(s.current)}}),[n]),()=>{s.current&&clearInterval(s.current)}}const n=async(r,{retries:e,retryIntervalMs:t,nonRetryable:a,nonRetryableSilently:s})=>{let i=e;try{return await r()}catch(e){if(s&&s(e))return;if(a&&a(e))throw e;if(void 0!==i){if(i<=0)throw e;i-=1}return await((r=0)=>r&&new Promise((e=>setTimeout(e,r))))(t),n(r,{retries:i,retryIntervalMs:t,nonRetryable:a,nonRetryableSilently:s})}};export{n as r,t as u};
@@ -1,2 +0,0 @@
1
- import{a_ as e,a$ as t,b0 as r,b1 as n,b2 as a,a as o,r as s}from"./index-1ba3ec23.js";
2
- /*! https://mths.be/punycode v1.4.1 by @mathias */var h=2147483647,c=36,i=1,l=26,u=38,p=700,f=72,m=128,d="-",v=/[^\x20-\x7E]/,R=/[\x2E\u3002\uFF0E\uFF61]/g,E={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=c-i,g=Math.floor,y=String.fromCharCode;function O(e){throw new RangeError(E[e])}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function S(e,t,r){var n=0;for(e=r?g(e/p):e>>1,e+=g(e/t);e>A*l>>1;n+=c)e=g(e/A);return g(n+(A+1)*e/(e+u))}function I(e){return function(e,t){var r=e.split("@"),n="";r.length>1&&(n=r[0]+"@",e=r[1]);var a=function(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}((e=e.replace(R,".")).split("."),t).join(".");return n+a}(e,(function(e){return v.test(e)?"xn--"+function(e){var t,r,n,a,o,s,u,p,v,R,E,A,I,b,C,_=[];for(e=function(e){for(var t,r,n=[],a=0,o=e.length;a<o;)(t=e.charCodeAt(a++))>=55296&&t<=56319&&a<o?56320==(64512&(r=e.charCodeAt(a++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),a--):n.push(t);return n}(e),A=e.length,t=m,r=0,o=f,s=0;s<A;++s)(E=e[s])<128&&_.push(y(E));for(n=a=_.length,a&&_.push(d);n<A;){for(u=h,s=0;s<A;++s)(E=e[s])>=t&&E<u&&(u=E);for(u-t>g((h-r)/(I=n+1))&&O("overflow"),r+=(u-t)*I,t=u,s=0;s<A;++s)if((E=e[s])<t&&++r>h&&O("overflow"),E==t){for(p=r,v=c;!(p<(R=v<=o?i:v>=o+l?l:v-o));v+=c)C=p-R,b=c-R,_.push(y(T(R+C%b,0))),p=g(C/b);_.push(y(T(p,0))),o=S(r,I,n==a),r=0,++n}++r,++t}return _.join("")}(e):e}))}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function _(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function D(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n<e.length;n++)r.push(t(e[n],n));return r}var L=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t};function N(e,t,r,n){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var o=/\+/g;e=e.split(t);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var h=e.length;s>0&&h>s&&(h=s);for(var c=0;c<h;++c){var i,l,u,p,f=e[c].replace(o,"%20"),m=f.indexOf(r);m>=0?(i=f.substr(0,m),l=f.substr(m+1)):(i=f,l=""),u=decodeURIComponent(i),p=decodeURIComponent(l),b(a,u)?C(a[u])?a[u].push(p):a[u]=[a[u],p]:a[u]=p}return a}var U={parse:B,resolve:function(e,t){return B(e,!1,!0).resolve(t)},resolveObject:function(e,t){return e?B(e,!1,!0).resolveObject(t):t},fileURLToPath:function(e){if("string"==typeof e)e=(new j).parse(e);else if(!(e instanceof j))throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof e+String(e));if("file:"!==e.protocol)throw new TypeError("The URL must be of scheme file");return function(e){const t=e.pathname;for(let e=0;e<t.length;e++)if("%"===t[e]){const r=32|t.codePointAt(e+2);if("2"===t[e+1]&&102===r)throw new TypeError("must not include encoded / characters")}return decodeURIComponent(t)}(e)},format:function(e){r(e)&&(e=Q({},e));return V(e)},Url:j,URL:e.URL,URLSearchParams:e.URLSearchParams};function j(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var w,x,P=/^([a-z0-9.+-]+:)/i,K=/:[0-9]*$/,k=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,q=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),F=["'"].concat(q),G=["%","/","?",";","#"].concat(F),W=["/","?","#"],$=255,M=/^[+a-z0-9A-Z_-]{0,63}$/,z=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,J={javascript:!0,"javascript:":!0},Z={javascript:!0,"javascript:":!0},H={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function B(e,r,n){if(e&&t(e)&&e instanceof j)return e;var a=new j;return a.parse(e,r,n),a}function Q(e,t,n,a){if(!r(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),s=-1!==o&&o<t.indexOf("#")?"?":"#",h=t.split(s);h[0]=h[0].replace(/\\/g,"/");var c=t=h.join(s);if(c=c.trim(),!a&&1===t.split("#").length){var i=k.exec(c);if(i)return e.path=c,e.href=c,e.pathname=i[1],i[2]?(e.search=i[2],e.query=n?N(e.search.substr(1)):e.search.substr(1)):n&&(e.search="",e.query={}),e}var l,u,p,f,m=P.exec(c);if(m){var d=(m=m[0]).toLowerCase();e.protocol=d,c=c.substr(m.length)}if(a||m||c.match(/^\/\/[^@\/]+@[^@\/]+/)){var v="//"===c.substr(0,2);!v||m&&Z[m]||(c=c.substr(2),e.slashes=!0)}if(!Z[m]&&(v||m&&!H[m])){var R,E,A=-1;for(l=0;l<W.length;l++)-1!==(u=c.indexOf(W[l]))&&(-1===A||u<A)&&(A=u);for(-1!==(E=-1===A?c.lastIndexOf("@"):c.lastIndexOf("@",A))&&(R=c.slice(0,E),c=c.slice(E+1),e.auth=decodeURIComponent(R)),A=-1,l=0;l<G.length;l++)-1!==(u=c.indexOf(G[l]))&&(-1===A||u<A)&&(A=u);-1===A&&(A=c.length),e.host=c.slice(0,A),c=c.slice(A),X(e),e.hostname=e.hostname||"";var g="["===e.hostname[0]&&"]"===e.hostname[e.hostname.length-1];if(!g){var y=e.hostname.split(/\./);for(l=0,p=y.length;l<p;l++){var O=y[l];if(O&&!O.match(M)){for(var T="",S=0,b=O.length;S<b;S++)O.charCodeAt(S)>127?T+="x":T+=O[S];if(!T.match(M)){var C=y.slice(0,l),_=y.slice(l+1),D=O.match(z);D&&(C.push(D[1]),_.unshift(D[2])),_.length&&(c="/"+_.join(".")+c),e.hostname=C.join(".");break}}}}e.hostname.length>$?e.hostname="":e.hostname=e.hostname.toLowerCase(),g||(e.hostname=I(e.hostname)),f=e.port?":"+e.port:"";var L=e.hostname||"";e.host=L+f,e.href+=e.host,g&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==c[0]&&(c="/"+c))}if(!J[d])for(l=0,p=F.length;l<p;l++){var U=F[l];if(-1!==c.indexOf(U)){var j=encodeURIComponent(U);j===U&&(j=escape(U)),c=c.split(U).join(j)}}var w=c.indexOf("#");-1!==w&&(e.hash=c.substr(w),c=c.slice(0,w));var x=c.indexOf("?");if(-1!==x?(e.search=c.substr(x),e.query=c.substr(x+1),n&&(e.query=N(e.query)),c=c.slice(0,x)):n&&(e.search="",e.query={}),c&&(e.pathname=c),H[d]&&e.hostname&&!e.pathname&&(e.pathname="/"),e.pathname||e.search){f=e.pathname||"";var K=e.search||"";e.path=f+K}return e.href=V(e),e}function V(e){var r=e.auth||"";r&&(r=(r=encodeURIComponent(r)).replace(/%3A/i,":"),r+="@");var n,a,o,s,h=e.protocol||"",c=e.pathname||"",i=e.hash||"",l=!1,u="";e.host?l=r+e.host:e.hostname&&(l=r+(-1===e.hostname.indexOf(":")?e.hostname:"["+this.hostname+"]"),e.port&&(l+=":"+e.port)),e.query&&t(e.query)&&Object.keys(e.query).length&&(n=e.query,a=a||"&",o=o||"=",null===n&&(n=void 0),u="object"==typeof n?D(L(n),(function(e){var t=encodeURIComponent(_(e))+o;return C(n[e])?D(n[e],(function(e){return t+encodeURIComponent(_(e))})).join(a):t+encodeURIComponent(_(n[e]))})).join(a):s?encodeURIComponent(_(s))+o+encodeURIComponent(_(n)):"");var p=e.search||u&&"?"+u||"";return h&&":"!==h.substr(-1)&&(h+=":"),e.slashes||(!h||H[h])&&!1!==l?(l="//"+(l||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):l||(l=""),i&&"#"!==i.charAt(0)&&(i="#"+i),p&&"?"!==p.charAt(0)&&(p="?"+p),h+l+(c=c.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(p=p.replace("#","%23"))+i}function X(e){var t=e.host,r=K.exec(t);r&&(":"!==(r=r[0])&&(e.port=r.substr(1)),t=t.substr(0,t.length-r.length)),t&&(e.hostname=t)}j.prototype.parse=function(e,t,r){return Q(this,e,t,r)},j.prototype.format=function(){return V(this)},j.prototype.resolve=function(e){return this.resolveObject(B(e,!1,!0)).format()},j.prototype.resolveObject=function(e){if(r(e)){var t=new j;t.parse(e,!1,!0),e=t}for(var o,s=new j,h=Object.keys(this),c=0;c<h.length;c++){var i=h[c];s[i]=this[i]}if(s.hash=e.hash,""===e.href)return s.href=s.format(),s;if(e.slashes&&!e.protocol){for(var l=Object.keys(e),u=0;u<l.length;u++){var p=l[u];"protocol"!==p&&(s[p]=e[p])}return H[s.protocol]&&s.hostname&&!s.pathname&&(s.path=s.pathname="/"),s.href=s.format(),s}if(e.protocol&&e.protocol!==s.protocol){if(!H[e.protocol]){for(var f=Object.keys(e),m=0;m<f.length;m++){var d=f[m];s[d]=e[d]}return s.href=s.format(),s}if(s.protocol=e.protocol,e.host||Z[e.protocol])s.pathname=e.pathname;else{for(o=(e.pathname||"").split("/");o.length&&!(e.host=o.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==o[0]&&o.unshift(""),o.length<2&&o.unshift(""),s.pathname=o.join("/")}if(s.search=e.search,s.query=e.query,s.host=e.host||"",s.auth=e.auth,s.hostname=e.hostname||e.host,s.port=e.port,s.pathname||s.search){var v=s.pathname||"",R=s.search||"";s.path=v+R}return s.slashes=s.slashes||e.slashes,s.href=s.format(),s}var E,A=s.pathname&&"/"===s.pathname.charAt(0),g=e.host||e.pathname&&"/"===e.pathname.charAt(0),y=g||A||s.host&&e.pathname,O=y,T=s.pathname&&s.pathname.split("/")||[],S=s.protocol&&!H[s.protocol];if(o=e.pathname&&e.pathname.split("/")||[],S&&(s.hostname="",s.port=null,s.host&&(""===T[0]?T[0]=s.host:T.unshift(s.host)),s.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===o[0]?o[0]=e.host:o.unshift(e.host)),e.host=null),y=y&&(""===o[0]||""===T[0])),g)s.host=e.host||""===e.host?e.host:s.host,s.hostname=e.hostname||""===e.hostname?e.hostname:s.hostname,s.search=e.search,s.query=e.query,T=o;else if(o.length)T||(T=[]),T.pop(),T=T.concat(o),s.search=e.search,s.query=e.query;else if(!n(e.search))return S&&(s.hostname=s.host=T.shift(),(E=!!(s.host&&s.host.indexOf("@")>0)&&s.host.split("@"))&&(s.auth=E.shift(),s.host=s.hostname=E.shift())),s.search=e.search,s.query=e.query,a(s.pathname)&&a(s.search)||(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.href=s.format(),s;if(!T.length)return s.pathname=null,s.search?s.path="/"+s.search:s.path=null,s.href=s.format(),s;for(var I=T.slice(-1)[0],b=(s.host||e.host||T.length>1)&&("."===I||".."===I)||""===I,C=0,_=T.length;_>=0;_--)"."===(I=T[_])?T.splice(_,1):".."===I?(T.splice(_,1),C++):C&&(T.splice(_,1),C--);if(!y&&!O)for(;C--;C)T.unshift("..");!y||""===T[0]||T[0]&&"/"===T[0].charAt(0)||T.unshift(""),b&&"/"!==T.join("/").substr(-1)&&T.push("");var D=""===T[0]||T[0]&&"/"===T[0].charAt(0);return S&&(s.hostname=s.host=D?"":T.length?T.shift():"",(E=!!(s.host&&s.host.indexOf("@")>0)&&s.host.split("@"))&&(s.auth=E.shift(),s.host=s.hostname=E.shift())),(y=y||s.host&&T.length)&&!D&&T.unshift(""),T.length?s.pathname=T.join("/"):(s.pathname=null,s.path=null),a(s.pathname)&&a(s.search)||(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.auth=e.auth||s.auth,s.slashes=s.slashes||e.slashes,s.href=s.format(),s},j.prototype.parseHost=function(){return X(this)},function(e){e.TRANSAK_WIDGET_INITIALISED="TRANSAK_WIDGET_INITIALISED",e.TRANSAK_WIDGET_OPEN="TRANSAK_WIDGET_OPEN",e.TRANSAK_ORDER_CREATED="TRANSAK_ORDER_CREATED",e.TRANSAK_ORDER_SUCCESSFUL="TRANSAK_ORDER_SUCCESSFUL",e.TRANSAK_ORDER_FAILED="TRANSAK_ORDER_FAILED"}(w||(w={})),function(e){e.PROCESSING="PROCESSING",e.COMPLETED="COMPLETED"}(x||(x={}));const Y=["global.transak.com","global-stg.transak.com"],ee={[w.TRANSAK_WIDGET_OPEN]:{screen:"InputScreen",control:"TransakWidgetOpen",controlType:"IframeEvent"},[w.TRANSAK_ORDER_CREATED]:{screen:"InputScreen",control:"OrderCreated",controlType:"IframeEvent"},[`${w.TRANSAK_ORDER_SUCCESSFUL}${x.PROCESSING}`]:{screen:"OrderInProgress",control:"PaymentProcessing",controlType:"IframeEvent"},[`${w.TRANSAK_ORDER_SUCCESSFUL}${x.COMPLETED}`]:{screen:"Success",control:"PaymentCompleted",controlType:"IframeEvent"},[w.TRANSAK_ORDER_FAILED]:{screen:"Failure",control:"PaymentFailed",controlType:"IframeEvent"}},te=e=>{const{track:t}=o(),{userJourney:r,ref:n,email:a,userId:h,isPassportWallet:c,failedToLoadTimeoutInMs:i,onFailedToLoad:l}=e,[u,p]=s.useState(!1),f=i||1e4,m=s.useRef(void 0),d=s.useCallback((e=>{const n=e.event_id,o=[w.TRANSAK_ORDER_SUCCESSFUL].includes(n)?`${n}${e.data.status}`:n,s=ee?.[o]||{};Object.keys(s).length>=0&&t({...s,userJourney:r,extras:{email:a,userId:h,isPassportWallet:c}})}),[]),v=s.useCallback((t=>{switch(t.event_id){case w.TRANSAK_WIDGET_INITIALISED:r=t.data,p(!0),clearTimeout(m.current),m.current=void 0,e.onInit?.(r);break;case w.TRANSAK_WIDGET_OPEN:e.onOpen?.(t.data);break;case w.TRANSAK_ORDER_CREATED:e.onOrderCreated?.(t.data);break;case w.TRANSAK_ORDER_SUCCESSFUL:t.data.status===x.PROCESSING&&e.onOrderProcessing?.(t.data),t.data.status===x.COMPLETED&&e.onOrderCompleted?.(t.data);break;case w.TRANSAK_ORDER_FAILED:e.onOrderFailed?.(t.data)}var r}),[]),R=s.useCallback((e=>{const t=B(e.origin)?.host?.toLowerCase();e.source===n?.current?.contentWindow&&t&&Y.includes(t)&&(d(e.data),v(e.data),console.log("@@@ Transak event",e))}),[n]);return s.useEffect((()=>(window.addEventListener("message",R),()=>{clearTimeout(m.current),window.removeEventListener("message",R)})),[]),{initialised:u,onLoad:()=>{void 0!==l&&(void 0!==m.current||u||(m.current=setTimeout((()=>{u||l()}),f)))}}};export{Y as T,te as a,U as u};
@@ -1 +0,0 @@
1
- export{c0 as WidgetsFactory}from"./index-1ba3ec23.js";