@saasquatch/squatch-js 2.6.0-0 → 2.6.0-2

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see squatch.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.squatch=t():e.squatch=t()}(self,(function(){return function(){var e={264:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t,n=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(e);this.domain=(null==n?void 0:n.domain)||(null===(t=window.squatchConfig)||void 0===t?void 0:t.domain)||o.cE}pushAnalyticsLoadEvent(e){if(e.externalUserId&&e.externalAccountId){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=e.programId?"&programId=".concat(encodeURIComponent(e.programId)):"",s="/a/".concat(t,"/widgets/analytics/loaded?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i).concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}pushAnalyticsShareClickedEvent(e){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=encodeURIComponent(e.shareMedium),s="/a/".concat(t,"/widgets/analytics/shared?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i,"&shareMedium=").concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}},745:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t=e,n=(0,o.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain}track(e,t){var n=t,i=function(e){if(!(0,o.Kn)(e))throw new Error("tracking parameter must be an object");if(null==e||!e.accountId)throw new Error("accountId field is required");if(null==e||!e.events)throw new Error("events field is required");if(null==e||!e.userId)throw new Error("userId field is required");var t=e;if(!Array.isArray(t.events))throw new Error("'events' should be an array");return t}(e),{jwt:a}=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(n),s=encodeURIComponent(this.tenantAlias),c=encodeURIComponent(i.userId),d=encodeURIComponent(i.accountId),u="/api/v1/".concat(s,"/open/account/").concat(d,"/user/").concat(c,"/events"),l=this.domain+u;return(0,r.Mx)(l,JSON.stringify(i),a)}}},139:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(572),o=n(861),i=n(955),a=n(615),s=n(787);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class u{constructor(e){var t=e,n=(0,s.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain,this.npmCdn=n.npmCdn}upsertUser(e){var t=e,n=(0,s.xW)(t),{widgetType:r,engagementMedium:o="POPUP",jwt:c,user:d}=n,u=encodeURIComponent(this.tenantAlias),l=encodeURIComponent(d.accountId),p=encodeURIComponent(d.id),f=function(e){var{widgetType:t,engagementMedium:n}=e;return(t?"?widgetType=".concat(encodeURIComponent(t)):"")+"".concat(t?"&":"?","engagementMedium=").concat(encodeURIComponent(n))}({widgetType:r,engagementMedium:o}),h="/api/v1/".concat(u,"/widget/account/").concat(l,"/user/").concat(p,"/upsert").concat(f),g=this.domain+h,m=(i.Z||window.Cookies).get("_saasquatch");return m&&(d.cookies=m),(0,a.iR)(g,JSON.stringify(d),c)}render(e){var t,n=e,r=(0,s.ZL)(n),{widgetType:i,engagementMedium:c="POPUP",jwt:d,user:u}=r,l=encodeURIComponent(this.tenantAlias),p=u?encodeURIComponent(u.accountId):null,f=u?encodeURIComponent(u.id):null,h=null!==(t=r.locale)&&void 0!==t?t:(0,s.Qb)(navigator.language.replace(/\-/g,"_")),g="/api/v1/".concat(l,"/graphql"),m=this.domain+g;return new Promise(function(){var e=(0,o.Z)((function*(e,t){try{var n,r=yield(0,a.Rf)(m,"\n query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {\n renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {\n template\n user {\n id\n accountId\n }\n jsOptions\n widgetConfig {\n values\n }\n }\n }\n",{user:f&&p?{id:f,accountId:p}:null,engagementMedium:c,widgetType:i,locale:h},d);e(null==r||null===(n=r.data)||void 0===n?void 0:n.renderWidget)}catch(e){t(e)}}));return function(t,n){return e.apply(this,arguments)}}())}squatchReferralCookie(){var e=this;return(0,o.Z)((function*(){var t=encodeURIComponent(e.tenantAlias),n=(i.Z||window.Cookies).get("_saasquatch")||"",r=n?"?cookies=".concat(encodeURIComponent(n)):"",o="".concat(e.domain,"/a/").concat(t,"/widgets/squatchcookiejson").concat(r),s=yield(0,a.gc)(o);return Promise.resolve(d(d({},s),{},{encodedCookie:n}))}))()}}},762:function(e,t,n){"use strict";function r(){var e=window.squatch||null,t=window._squatch||null;if(e&&t){(t.ready||[]).forEach((e=>setTimeout((()=>e()),0))),setTimeout((()=>window.squatch._auto()),0),window._squatch=void 0;try{delete window._squatch}catch(e){throw e}}}n.d(t,{Z:function(){return r}})},510:function(e,t,n){"use strict";function r(){console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.")}n.d(t,{R:function(){return r}})},518:function(){},998:function(e,t,n){"use strict";n.d(t,{F:function(){return l},b:function(){return f}});var r=n(572),o=n(227),i=n(955);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c=(0,o.debug)("squatch-js"),d=e=>"object"==typeof e&&!Array.isArray(e),u=(e,t)=>{var n=n=>d(t[n])&&e.hasOwnProperty(n)&&d(e[n]),r=Object.getOwnPropertyNames(t).map((r=>({[r]:n(r)?u(e[r],t[r]):t[r]}))).reduce(((e,t)=>s(s({},e),t)),{});return s(s({},e),r)};function l(e){return atob(e.replace(/_/g,"/").replace(/-/g,"+"))}function p(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(){var e=window.location.search,t=new URLSearchParams(e).get("_saasquatch")||"";if(t){var n="",r="",o="";try{n=JSON.parse(l(t))}catch(e){return void c("Unable to decode params",e)}try{r=JSON.parse(l(i.Z.get("_saasquatch"))),c("existing cookie",r)}catch(e){c("Unable to retrieve cookie",e)}try{var a=function(){var e,t,n="weird_get_top_level_domain=cookie",r=document.location.hostname.split(".");for(e=r.length-1;e>=0;e--)if(t=r.slice(e).join("."),document.cookie=n+";domain=."+t+";",document.cookie.indexOf(n)>-1)return document.cookie=n.split("=")[0]+"=;domain=."+t+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",t}();if(c("domain retrieved:",a),r){var s=u(r,n);o=p(JSON.stringify(s)),c("cookie to store:",s)}else o=p(JSON.stringify(n)),c("cookie to store:",n);i.Z.set("_saasquatch",o,{expires:365,secure:!1,sameSite:"Lax",domain:a,path:"/"})}catch(e){c("Unable to set cookie",e)}}}},936:function(e,t,n){"use strict";function r(e,t){var n,r=[],o=e,i=o.documentElement.doScroll,a="DOMContentLoaded",s=(i?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);return s||o.addEventListener(a,n=()=>{for(o.removeEventListener(a,n),s=!0;n=r.shift();)n()}),s?setTimeout(t,0):r.push(t)}n.d(t,{V:function(){return r}})},615:function(e,t,n){"use strict";n.d(t,{Mx:function(){return l},Rf:function(){return s},gc:function(){return d},iR:function(){return f}});var r=n(572),o=n(861);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n,r){return c.apply(this,arguments)}function c(){return(c=(0,o.Z)((function*(e,t,n,r){var o=a(a({Accept:"application/json","Content-Type":"application/json"},r?{Authorization:"Bearer ".concat(r)}:{}),{},{"X-SaaSquatch-Referrer":window?window.location.href:""});try{var i=yield fetch(e,{method:"POST",body:JSON.stringify({query:t,variables:n}),headers:o});if(!i.ok)throw new Error(yield i.text());return yield i.json()}catch(e){throw e}}))).apply(this,arguments)}function d(e){return u.apply(this,arguments)}function u(){return u=(0,o.Z)((function*(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n={Accept:"application/json","Content-Type":"application/json"};t&&(n["X-SaaSquatch-User-Token"]=t);try{var r=yield fetch(e,{method:"GET",credentials:"include",headers:n}),o=yield r.text();if(!r.ok)throw new Error(o);return o?JSON.parse(o):o}catch(e){throw e}})),u.apply(this,arguments)}function l(e,t,n){return p.apply(this,arguments)}function p(){return(p=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json"};n&&(r["X-SaaSquatch-User-Token"]=n);try{var o=yield fetch(e,{method:"POST",body:t,headers:r}),i=yield o.text();if(!o.ok)throw new Error(i);return i?JSON.parse(i):i}catch(e){throw e}}))).apply(this,arguments)}function f(e,t,n){return h.apply(this,arguments)}function h(){return(h=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json","X-SaaSquatch-Referrer":window?window.location.href:""};n&&(r["X-SaaSquatch-User-Token"]=n);try{var o=yield fetch(e,{headers:r,method:"PUT",credentials:"include",body:t}),i=yield o.text();if(!o.ok)throw new Error(i);return i?JSON.parse(i):i}catch(e){throw e}}))).apply(this,arguments)}(0,n(227).debug)("squatch-js:io")},8:function(e,t,n){"use strict";n.d(t,{G:function(){return u}});var r=n(572);function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=n(227),a=n(998);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var d=(0,i.debug)("squatch-js");function u(e){var t=window.location.search,n=new URLSearchParams(t).get("_saasquatchExtra")||"";if(n){var r;try{r=JSON.parse((0,a.F)(n))}catch(e){return void d("Unable to decode _saasquatchExtra config")}var{domain:i,tenantAlias:s,widgetConfig:u}=function(e){var t,n=Object.keys(e||{})[0],r=Object.keys((null==e?void 0:e[n])||{})[0],o=null==e||null===(t=e[n])||void 0===t?void 0:t[r];return{domain:n?"https://".concat(n):void 0,tenantAlias:r,widgetConfig:o}}(r);if(i&&s&&u){var{autoPopupWidgetType:l}=u;return{widgetConfig:c({widgetType:l,displayOnLoad:!0},o(u,["autoPopupWidgetType"])),squatchConfig:c(c({},e?{configIn:e}:{}),{},{domain:i,tenantAlias:s})}}d("_saasquatchExtra did not have an expected structure")}else d("No _saasquatchExtra param")}},787:function(e,t,n){"use strict";n.d(t,{Kn:function(){return a},Qb:function(){return s},ZL:function(){return d},cE:function(){return r},eu:function(){return o},ww:function(){return i},xW:function(){return c}});var r="https://app.referralsaasquatch.com",o="https://fast.ssqt.io/npm";function i(e){var t,n,i;if("object"!=typeof e)throw new Error("config must be an object");var a={tenantAlias:(null==e?void 0:e.tenantAlias)||window.squatchTenant,domain:(null==e?void 0:e.domain)||(null===(t=window.squatchConfig)||void 0===t?void 0:t.domain),npmCdn:(null==e?void 0:e.npmCdn)||(null===(n=window.squatchConfig)||void 0===n?void 0:n.npmCdn),debug:(null==e?void 0:e.debug)||(null===(i=window.squatchConfig)||void 0===i?void 0:i.debug)};if("string"!=typeof a.tenantAlias)throw new Error("tenantAlias not provided");return{tenantAlias:a.tenantAlias,domain:"string"==typeof a.domain&&a.domain||r,debug:"boolean"==typeof a.debug&&a.debug||!1,npmCdn:"string"==typeof a.npmCdn&&a.npmCdn||o}}function a(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function s(e){if(e&&/^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(e))return e}function c(e){if(!a(e))throw new Error("Widget properties must be an object");if(null==e||!e.user)throw new Error("Required properties missing.");return e}function d(e){if(!a(e))throw new Error("Widget properties must be an object");return e}},75:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(861),o=n(572),i=n(227),a=n(657),s=n(936),c=(0,i.debug)("squatch-js:EMBEDwidget");class d extends a.Z{constructor(e,t){super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close)}load(e){var t=this;return(0,r.Z)((function*(){var n=t._findElement();t.container?n.shadowRoot?n.shadowRoot.appendChild(e):n.firstChild?n.replaceChild(e,n.firstChild):n.appendChild(e):n.firstChild&&"#text"!==n.firstChild.nodeName||n.appendChild(e);var{contentWindow:o}=e;if(!o)throw new Error("Frame needs a content window");var i=o.document;i.open(),i.write(t.content),i.write('<script src="'.concat(t.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),i.close(),(0,s.V)(i,(0,r.Z)((function*(){var n=o.squatch||o.widgetIdent,r=i.getElementById("cta");if(r){if(!r.parentNode)throw new Error("ctaElement needs a parentNode");r.parentNode.removeChild(r)}e.height=i.body.scrollHeight,new o.ResizeObserver((t=>{for(var n of t){var{height:r}=n.contentRect;e.height=r}})).observe(yield t._findInnerContainer(e)),t.container||(t._loadEvent(n),c("loaded"))})))}))()}open(e){var t,n,r;if(!e)return c("no target element to open");var o=this._findElement();o.style.visibility="unset",o.style.height="auto",o.style["overflow-y"]="auto",null==e||null===(t=e.contentDocument)||void 0===t||t.dispatchEvent(new CustomEvent("sq:refresh"));var i=(null==e||null===(n=e.contentWindow)||void 0===n?void 0:n.squatch)||(null==e||null===(r=e.contentWindow)||void 0===r?void 0:r.widgetIdent);this._loadEvent(i),c("loaded")}close(e){if(!e)return c("no target element to close");var t=this._findElement();t.style.visibility="hidden",t.style.height="0",t.style["overflow-y"]="hidden",c("Embed widget closed")}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"embed",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n)}}},658:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(572),i=n(227),a=n(936),s=n(657),c=(0,i.debug)("squatch-js:POPUPwidget"),d=0;class u extends s.Z{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".squatchpop";super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.trigger=t,this.container?this.id="squatchModal":(this.id=0===d?"squatchModal":"squatchModal__".concat(d),d+=1),document.head.insertAdjacentHTML("beforeend","<style>#".concat(this.id,"::-webkit-scrollbar { display: none; }</style>"))}_initialiseCTA(e){var t;try{t=document.querySelector(this.trigger),this.trigger&&!t&&c("No element found with trigger selector",this.trigger)}catch(e){c("Not a valid selector",this.trigger)}t&&(t.onclick=()=>{this.open(e)});var n=this._findElement().querySelector(".squatchpop");"#cta"===this.trigger&&n&&(n.onclick=()=>{this.open(e)})}_createPopupDialog(){var e=document.createElement("dialog");return e.id=this.id,e.setAttribute("style","width: 100%; max-width: 500px; border: none; padding: 0;"),e.addEventListener("click",(t=>{t.target===e&&e.close()})),e}load(e){this._initialiseCTA(e);var t=this._findElement(),n=t.shadowRoot||t,r=this._createPopupDialog();r.appendChild(e),n.appendChild(r);var{contentWindow:o}=e;if(!o)throw new Error("Frame needs a content window");var i=o.document;i.open(),i.write(this.content),i.write('<script src="'.concat(this.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),i.close(),c("Popup template loaded into iframe"),this._setupResizeHandler(e)}_setupResizeHandler(e){var t=this,{contentWindow:n}=e;if(!n)throw new Error("Frame needs a content window");var o=n.document;(0,a.V)(o,(0,r.Z)((function*(){o.body.style.overflowY="hidden",e.height="".concat(o.body.offsetHeight,"px"),new n.ResizeObserver((t=>{for(var n of t){var{top:r,bottom:o}=n.contentRect,i=o+r;e.height=i+"",n.target.style=""}})).observe(yield t._findInnerContainer(e))})))}open(e){var t=this._findElement(),n=(t.shadowRoot||t).querySelector("#".concat(this.id));if(!n)throw new Error("Could not determine container div");n.showModal();var{contentWindow:r}=e;if(!r)throw new Error("Squatch.js has an empty iframe");var o=r.document;(0,a.V)(o,(()=>{var t,n=r.squatch||r.widgetIdent;null===(t=e.contentDocument)||void 0===t||t.dispatchEvent(new CustomEvent("sq:refresh")),this._loadEvent(n),c("Popup opened")}))}close(){var e=document.getElementById(this.id);if(!e)throw new Error("Could not determine container div");e.close(),c("Popup closed")}_clickedOutside(e){var{target:t}=e}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n||"body { margin: 0; } .modal { box-shadow: none; border: 0; }")}}},657:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(861),o=n(227),i=n(264),a=n(787),s=(0,o.debug)("squatch-js:widget");class c{constructor(e){s("widget initializing ..."),this.content="error"===e.content?this._error(e.rsCode):e.content,this.type=e.type,this.widgetApi=e.api,this.npmCdn=e.npmCdn,this.analyticsApi=new i.Z({domain:e.domain}),this.context=e.context,this.container=e.container}_findElement(){var e;if("string"==typeof this.container?(e=document.querySelector(this.container),s("loading widget with selector",e)):this.container instanceof HTMLElement?(e=this.container,s("loading widget with container",e)):this.container?(e=null,s("container must be an HTMLElement or string",this.container)):(e=document.querySelector("#squatchembed")||document.querySelector(".squatchembed"),s("loading widget with default selector",e)),!(e instanceof HTMLElement))throw new Error("element with selector '".concat(this.container||"#squatchembed or .squatchembed","' not found.'"));return e}_createFrame(){var e=document.createElement("iframe");return e.squatchJsApi=this,e.width="100%",e.src="about:blank",e.scrolling="no",e.setAttribute("style","border: 0; background-color: none; width: 1px; min-width: 100%;"),e}_loadEvent(e){var t;if(e){if(!(0,a.Kn)(e))throw new Error("Widget Load event identity property is not an object");var n;if("programId"in e){if(!(e.tenantAlias&&e.accountId&&e.userId&&e.engagementMedium))throw new Error("Widget Load event missing required properties");n={tenantAlias:e.tenantAlias,externalAccountId:e.accountId,externalUserId:e.userId,engagementMedium:e.engagementMedium,programId:e.programId}}else{var{analytics:r,mode:o}=e;n={tenantAlias:r.attributes.tenant,externalAccountId:r.attributes.accountId,externalUserId:r.attributes.userId,engagementMedium:o.widgetMode}}null===(t=this.analyticsApi.pushAnalyticsLoadEvent(n))||void 0===t||t.then((e=>{s("".concat(n.engagementMedium," loaded event recorded."))})).catch((e=>{s(new Error("pushAnalyticsLoadEvent() ".concat(e)))}))}}_shareEvent(e,t){e&&this.analyticsApi.pushAnalyticsShareClickedEvent({tenantAlias:e.analytics.attributes.tenant,externalAccountId:e.analytics.attributes.accountId,externalUserId:e.analytics.attributes.userId,engagementMedium:e.mode.widgetMode,shareMedium:t}).then((n=>{s("".concat(e.mode.widgetMode," share ").concat(t," event recorded. ").concat(n))})).catch((e=>{s(new Error("pushAnalyticsLoadEvent() ".concat(e)))}))}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal";return'<!DOCTYPE html>\n \x3c!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if gt IE 8]>\x3c!--\x3e<html lang="en">\x3c!--<![endif]--\x3e\n <head>\n <link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">\n <style>\n '.concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",'\n </style>\n </head>\n <body>\n\n <div class="squatch-container ').concat(t,'" style="width:100%">\n <div class="errorheader">\n <button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">&times;</button>\n <p class="errortitle">Error</p>\n </div>\n <div class="errorbody">\n <div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>\n <h4>Our referral program is temporarily unavailable.</h4><br>\n <p>Please reload the page or check back later.</p>\n <p>If the persists please contact our support team.</p>\n <br>\n <br>\n <div class="right-align errtxt">\n Error Code: ').concat(e,"\n </div>\n </div>\n </div>\n </body>\n </html>")}_findInnerContainer(e){return(0,r.Z)((function*(){var{contentWindow:t}=e;if(!t)throw new Error("Squatch.js frame inner frame is empty");for(var n,r,o=t.document,i=null,a=0;a<5&&(void 0,void 0,n=o.getElementsByTagName("sqh-global-container"),r=o.getElementsByClassName("squatch-container"),!(i=n.length>0?n[0]:r.length>0?r[0]:null));a++)yield d(100);return i||o.body}))()}reload(e,t,n){var r,{email:o,firstName:i,lastName:a}=t,c=e.contentWindow,d=this.context.engagementMedium||"POPUP";if(!c)throw new Error("Frame needs a content window");if("upsert"===this.context.type){var u={email:o||null,firstName:i||null,lastName:a||null,id:this.context.user.id,accountId:this.context.user.accountId};r=this.widgetApi.upsertUser({user:u,engagementMedium:d,widgetType:this.type,jwt:n})}else{if("passwordless"!==this.context.type)throw new Error("can't reload an error widget");r=this.widgetApi.render({user:void 0,engagementMedium:d,widgetType:this.type,jwt:void 0})}r.then((t=>{var{template:n}=t;n&&(this.content=n,this.__deprecated__register(e,{email:o,engagementMedium:d},(()=>{this.load(e),"POPUP"===d&&this.open(e)})))})).catch((e=>{var{message:t}=e;s("".concat(t))}))}__deprecated__register(e,t,n){var r=e.contentWindow.document,o=r.createElement("button"),i=r.getElementsByClassName("squatch-register")[0];if(i){o.className="btn btn-primary",o.id="show-stats-btn",o.textContent="REFERRER_WIDGET"===this.type?"Show Stats":"Show Reward";var a="POPUP"===t.engagementMedium?"margin-top: 10px; max-width: 130px; width: 100%;":"margin-top: 10px;";o.setAttribute("style",a),o.onclick=n,i.style.paddingTop="30px",i.innerHTML="<p><strong>".concat(t.email,"</strong><br>Has been successfully registered</p>"),i.appendChild(o)}}}function d(e){return new Promise((function(t,n){setTimeout((function(){t((()=>{}))}),e)}))}},452:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(227),i=n(139),a=n(787),s=n(75),c=n(658),d=(0,o.debug)("squatch-js:widgets");class u{constructor(e){var t=(0,a.ww)(e);this.tenantAlias=t.tenantAlias,this.domain=t.domain,this.npmCdn=t.npmCdn,this.api=new i.Z(t)}upsertUser(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.xW)(n);try{var o=yield t.api.upsertUser(r);return{widget:t._renderWidget(o,r,{type:"upsert",user:r.user||null,engagementMedium:e.engagementMedium,container:e.container,trigger:e.trigger}),user:o.user}}catch(n){throw d(n),n.apiErrorCode&&t._renderErrorWidget(n,e.engagementMedium),n}}))()}render(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.ZL)(n);try{var o=yield t.api.render(r);return{widget:t._renderWidget(o,r,{type:"passwordless",engagementMedium:r.engagementMedium}),user:o.user}}catch(e){throw e.apiErrorCode&&t._renderErrorWidget(e,r.engagementMedium),e}}))()}autofill(e){var t=e;if("function"!=typeof t){if("string"!=typeof t)throw new Error("Autofill accepts a string or function");var n,r=document.querySelectorAll(t);if(!(r.length>0))throw d("Element id/class or function missing"),new Error("Element id/class or function missing");n=r[0],this.api.squatchReferralCookie().then((e=>{var{codes:t}=e;n.value=t[0]})).catch((e=>{throw e}))}else this.api.squatchReferralCookie().then((function(){return t(...arguments)})).catch((e=>{throw d("Autofill error",e),e}))}_renderWidget(e,t,n){if(d("Rendering Widget..."),!e)throw new Error("Unable to get a response");var r,o=!!t.displayOnLoad,i=e.jsOptions||"",a={content:e.template,type:t.widgetType||i.widget.defaultWidgetType,api:this.api,domain:this.domain,npmCdn:this.npmCdn,context:n};return i.widgetUrlMappings&&i.widgetUrlMappings.forEach((t=>{u._matchesUrl(t.url)&&("CONVERSION_WIDGET"!==t.widgetType||e.user.referredBy&&e.user.referredBy.code?(o=t.displayOnLoad,t.showAsCTA,d("Display ".concat(t.widgetType," on ").concat(t.url))):d("Don't display ".concat(t.widgetType," when no referral on widget rule match ").concat(t.url)))})),i.fuelTankAutofillUrls&&(d("We found a fuel tank autofill!"),i.fuelTankAutofillUrls.forEach((t=>{var{url:n,formSelector:r}=t;if(u._matchesUrl(n)&&(d("Fuel Tank URL matches"),e.user.referredBy&&e.user.referredBy.code)){var o=document.querySelector(r);o?o.value=e.user.referredBy.referredReward.fuelTankCode||"":d(new Error("Element with id/class ".concat(r," was not found.")))}}))),"EMBED"===t.engagementMedium?this._renderEmbedWidget(a,a.context.container):"POPUP"===t.engagementMedium?(r=this._renderPopupWidget(a),o&&r.open()):(d("display popup on load"),(r=new c.Z(a)).load(),o&&r.open()),r}_renderPopupWidget(e){var t=new c.Z(e,e.context.trigger),n=t._createFrame();return t.load(n),t}_renderEmbedWidget(e,t){var n=new s.Z(e),r=n._createFrame();n.load(r)}_renderErrorWidget(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POPUP",{apiErrorCode:n,rsCode:r,message:o}=e;d(new Error("".concat(n," (").concat(r,") ").concat(o)));var i,a={content:"error",rsCode:r,api:this.api,domain:this.domain,npmCdn:this.npmCdn,type:"ERROR_WIDGET",context:{type:"error"}};if("EMBED"===t){var u=(i=new s.Z(a))._createFrame();i.load(u)}else if("POPUP"===t){var l=(i=new c.Z(a))._createFrame();i.load(l)}}static _matchesUrl(e){return!!window.location.href.match(new RegExp(e))}static _cb(e,t,n){var r;r="string"==typeof n||n instanceof String?{email:n}:n,t.reload(r)}}},22:function(e,t,n){"use strict";n.d(t,{U:function(){return m},n:function(){return w}});var r=n(861),o=n(572),i=n(227),a=n.n(i),s=n(264),c=n(139),d=n(998),u=(0,i.debug)("squatch-js:decodeJwt"),l=n(8),p=n(787),f=n(75),h=n(658);a()("sqh:DeclarativeWidget");class g extends HTMLElement{constructor(){super(),(0,o.Z)(this,"_setWidget",((e,t)=>{var n;if(!this.widgetType)throw new Error("Widget was no specified");return new("EMBED"===this.type?f.Z:h.Z)({api:this.widgetApi,content:e,context:{type:t.type,engagementMedium:this.type},type:this.widgetType,domain:(null===(n=this.config)||void 0===n?void 0:n.domain)||p.cE,npmCdn:p.eu,container:this.container||this})})),(0,o.Z)(this,"setErrorWidget",(e=>{var t;return new("EMBED"===this.type?f.Z:h.Z)({api:this.widgetApi,content:"error",context:{type:"error"},type:"ERROR_WIDGET",domain:(null===(t=this.config)||void 0===t?void 0:t.domain)||p.cE,npmCdn:p.eu,container:this.container||this})})),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.attachShadow({mode:"open"}).innerHTML="<style>:host { display: contents; }</style><slot></slot>",this.config=window.squatchConfig,this.token=window.squatchToken,this.tenant=window.squatchTenant,this.container=this}_setupApis(e){var t,n;if(!this.tenant)throw new Error("Requires tenantAlias");this.widgetApi=new c.Z({tenantAlias:(null==e?void 0:e.tenantAlias)||this.tenant,domain:(null==e?void 0:e.domain)||(null===(t=this.config)||void 0===t?void 0:t.domain)||p.cE}),this.analyticsApi=new s.Z({domain:(null==e?void 0:e.domain)||(null===(n=this.config)||void 0===n?void 0:n.domain)||p.cE})}renderPasswordlessVariant(){var e,t,n=(0,l.G)();return this._setupApis(null==n?void 0:n.squatchConfig),this.widgetApi.render({engagementMedium:(null==n||null===(e=n.widgetConfig)||void 0===e?void 0:e.engagementMedium)||this.type,widgetType:(null==n||null===(t=n.widgetConfig)||void 0===t?void 0:t.widgetType)||this.widgetType}).then((e=>this._setWidget(e.template,{type:"passwordless"}))).catch(this.setErrorWidget)}renderUserUpsertVariant(){var e=this;return(0,r.Z)((function*(){if(!e.widgetType)throw new Error("Widget must be specified");e._setupApis();var t=function(e){try{var t,n=e.split(".")[1];if(void 0===n)return null;var r=(0,d.F)(n);return null===(t=JSON.parse(r))||void 0===t?void 0:t.user}catch(e){return u(e),null}}(e.token);if(!t)throw new Error("Could not load user information from jwt");return yield e.widgetApi.upsertUser({user:t,engagementMedium:e.type,widgetType:e.widgetType,jwt:e.token}).then((t=>e._setWidget(t.template,{type:"upsert"}))).catch(e.setErrorWidget)}))()}getWidgetInstance(){var e=this;return(0,r.Z)((function*(){var t;if(e.widgetType=e.getAttribute("widget")||void 0,!e.widgetType)throw new Error("No widget has been specified");if(!(t=e.token?yield e.renderUserUpsertVariant():yield e.renderPasswordlessVariant()))throw new Error("Could not create widget.");return e.widgetInstance=t,t}))()}renderWidget(){var e=this;return(0,r.Z)((function*(){yield e.getWidgetInstance(),e.element=e.widgetInstance._findElement(),e.frame=e.widgetInstance._createFrame(),yield e.widgetInstance.load(e.frame)}))()}open(){this.widgetInstance.open(this.frame)}close(){this.widgetInstance.close(this.frame)}}class m extends g{constructor(){super(),this.type="EMBED",this.container=this.getAttribute("container")||this}static get observedAttributes(){return["widget","container"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"widget":this.connectedCallback();break;case"container":this.element&&this.close(),this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){var t,n;yield e.renderWidget();var r=null===(t=e.shadowRoot&&Array.from(e.shadowRoot.children))||void 0===t?void 0:t.find((e=>"SLOT"===e.tagName));null===(n=e.shadowRoot)||void 0===n||n.removeChild(r)}))()}}class w extends g{constructor(){super(),this.type="POPUP",this.addEventListener("click",(e=>{e.stopPropagation(),"SQUATCH-POPUP"!==e.target.tagName&&this.open()}))}static get observedAttributes(){return["widget","id","open"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"open":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){yield e.renderWidget(),null!==e.getAttribute("open")&&e.open()}))()}}window.customElements.define("squatch-embed",m),window.customElements.define("squatch-popup",w)},227:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)}},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(447)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:function(e,t,n){"use strict";e.exports=function(e){function t(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var n;function a(){if(a.enabled){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var i=a,s=Number(new Date),c=s-(n||s);i.diff=c,i.prev=n,i.curr=s,n=s,t[0]=r.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var d=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,n){if("%%"===e)return e;d++;var o=r.formatters[n];if("function"==typeof o){var a=t[d];e=o.call(i,a),t.splice(d,1),d--}return e})),r.formatArgs.call(i,t),(i.log||r.log).apply(i,t)}}return a.namespace=e,a.enabled=r.enabled(e),a.useColors=r.useColors(),a.color=t(e),a.destroy=o,a.extend=i,"function"==typeof r.init&&r.init(a),r.instances.push(a),a}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){return r(this.namespace+(void 0===t?":":t)+e)}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){r.enable("")},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=n(824),Object.keys(e).forEach((function(t){r[t]=e[t]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r}},824:function(e){var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,a){a=a||{};var s,c,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(s=e,(c=Math.abs(s))>=o?i(s,c,o,"day"):c>=r?i(s,c,r,"hour"):c>=n?i(s,c,n,"minute"):c>=t?i(s,c,t,"second"):s+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},861:function(e,t,n){"use strict";function r(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function s(e){r(a,o,i,s,c,"next",e)}function c(e){r(a,o,i,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return o}})},572:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===r(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return o}})},955:function(e,t,n){"use strict";function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}n.d(t,{Z:function(){return o}});var o=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=r({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var s in i)i[s]&&(a+="; "+s,!0!==i[s]&&(a+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+a}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){o(e,"",r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,r({},this.attributes,t))},withConverter:function(t){return e(r({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{DeclarativeEmbedWidget:function(){return p.U},DeclarativePopupWidget:function(){return p.n},EmbedWidget:function(){return o.Z},PopupWidget:function(){return i.Z},WidgetApi:function(){return a.Z},Widgets:function(){return t.Z},_auto:function(){return j},api:function(){return C},autofill:function(){return I},events:function(){return O},help:function(){return m.R},init:function(){return x},pushCookie:function(){return q},ready:function(){return P},submitEmail:function(){return _},widget:function(){return A},widgets:function(){return E}});var e=n(227),t=n(452),o=n(75),i=n(658),a=n(139),s=n(745),c=n(762),d=n(787),u=n(998),l=n(8),p=n(22),f=n(518),h={};for(var g in f)["default","Widgets","EmbedWidget","PopupWidget","DeclarativeEmbedWidget","DeclarativePopupWidget","WidgetApi","api","widgets","events","widget","_auto","init","ready","autofill","submitEmail","pushCookie"].indexOf(g)<0&&(h[g]=function(e){return f[e]}.bind(0,g));n.d(r,h);var m=n(510),w=(0,e.debug)("squatch-js"),v=null,y=null,b=null;function C(){return v||this.init({}),v}function E(){return y||this.init({}),y}function O(){return b||this.init({}),b}function A(e){var t;return null===(t=E())||void 0===t?void 0:t.render(e)}function j(e){var t=(0,l.G)(e);if(t){var n,{squatchConfig:r,widgetConfig:o}=t;return x(r),null===(n=E())||void 0===n?void 0:n.render(o)}}function x(n){var r=n,o=(0,d.ww)(r);(o.tenantAlias.match("^test")||o.debug)&&e.debug.enable("squatch-js*"),w("initializing ..."),v=new a.Z(o),y=new t.Z(o),b=new s.Z(o),w("Widget API instance",v),w("Widgets instance",y),w("Events API instance",b)}function P(e){e()}function I(e){E().autofill(e)}function _(e){E().submitEmail(e)}function q(){(0,u.b)()}"undefined"==typeof document||window.SaaSquatchDoNotAutoDrop||q(),"undefined"!=typeof document&&(0,c.Z)()}(),r}()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.squatch=t():e.squatch=t()}(self,(function(){return function(){var e={264:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t,n=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(e);this.domain=(null==n?void 0:n.domain)||(null===(t=window.squatchConfig)||void 0===t?void 0:t.domain)||o.cE}pushAnalyticsLoadEvent(e){if(e.externalUserId&&e.externalAccountId){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=e.programId?"&programId=".concat(encodeURIComponent(e.programId)):"",s="/a/".concat(t,"/widgets/analytics/loaded?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i).concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}pushAnalyticsShareClickedEvent(e){var t=encodeURIComponent(e.tenantAlias),n=encodeURIComponent(e.externalAccountId),o=encodeURIComponent(e.externalUserId),i=encodeURIComponent(e.engagementMedium),a=encodeURIComponent(e.shareMedium),s="/a/".concat(t,"/widgets/analytics/shared?externalAccountId=").concat(n,"&externalUserId=").concat(o,"&engagementMedium=").concat(i,"&shareMedium=").concat(a),c=this.domain+s;return(0,r.Mx)(c,JSON.stringify({}))}}},745:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(615),o=n(787);class i{constructor(e){var t=e,n=(0,o.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain}track(e,t){var n=t,i=function(e){if(!(0,o.Kn)(e))throw new Error("tracking parameter must be an object");if(null==e||!e.accountId)throw new Error("accountId field is required");if(null==e||!e.events)throw new Error("events field is required");if(null==e||!e.userId)throw new Error("userId field is required");var t=e;if(!Array.isArray(t.events))throw new Error("'events' should be an array");return t}(e),{jwt:a}=function(e){if(!(0,o.Kn)(e))throw new Error("'options' should be an object");return e}(n),s=encodeURIComponent(this.tenantAlias),c=encodeURIComponent(i.userId),d=encodeURIComponent(i.accountId),u="/api/v1/".concat(s,"/open/account/").concat(d,"/user/").concat(c,"/events"),l=this.domain+u;return(0,r.Mx)(l,JSON.stringify(i),a)}}},139:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(572),o=n(861),i=n(955),a=n(615),s=n(787);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class u{constructor(e){var t=e,n=(0,s.ww)(t);this.tenantAlias=n.tenantAlias,this.domain=n.domain,this.npmCdn=n.npmCdn}upsertUser(e){var t=e,n=(0,s.xW)(t),{widgetType:r,engagementMedium:o="POPUP",jwt:c,user:d}=n,u=encodeURIComponent(this.tenantAlias),l=d.accountId?encodeURIComponent(d.accountId):null,p=d.id?encodeURIComponent(d.id):null,f=function(e){var{widgetType:t,engagementMedium:n}=e;return(t?"?widgetType=".concat(encodeURIComponent(t)):"")+"".concat(t?"&":"?","engagementMedium=").concat(encodeURIComponent(n))}({widgetType:r,engagementMedium:o}),h="/api/v1/".concat(u,"/widget/account/").concat(l,"/user/").concat(p,"/upsert").concat(f),g=this.domain+h,m=(i.Z||window.Cookies).get("_saasquatch");return m&&(d.cookies=m),(0,a.iR)(g,JSON.stringify(d),c)}render(e){var t,n=e,r=(0,s.ZL)(n),{widgetType:i,engagementMedium:c="POPUP",jwt:d,user:u}=r,l=encodeURIComponent(this.tenantAlias),p=null!=u&&u.accountId?encodeURIComponent(u.accountId):null,f=null!=u&&u.id?encodeURIComponent(u.id):null,h=null!==(t=r.locale)&&void 0!==t?t:(0,s.Qb)(navigator.language.replace(/\-/g,"_")),g="/api/v1/".concat(l,"/graphql"),m=this.domain+g;return new Promise(function(){var e=(0,o.Z)((function*(e,t){try{var n,r=yield(0,a.Rf)(m,"\n query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {\n renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {\n template\n user {\n id\n accountId\n }\n jsOptions\n widgetConfig {\n values\n }\n }\n }\n",{user:f&&p?{id:f,accountId:p}:null,engagementMedium:c,widgetType:i,locale:h},d);e(null==r||null===(n=r.data)||void 0===n?void 0:n.renderWidget)}catch(e){t(e)}}));return function(t,n){return e.apply(this,arguments)}}())}squatchReferralCookie(){var e=this;return(0,o.Z)((function*(){var t=encodeURIComponent(e.tenantAlias),n=(i.Z||window.Cookies).get("_saasquatch")||"",r=n?"?cookies=".concat(encodeURIComponent(n)):"",o="".concat(e.domain,"/a/").concat(t,"/widgets/squatchcookiejson").concat(r),s=yield(0,a.gc)(o);return Promise.resolve(d(d({},s),{},{encodedCookie:n}))}))()}}},762:function(e,t,n){"use strict";function r(){var e=window.squatch||null,t=window._squatch||null;if(e&&t){(t.ready||[]).forEach((e=>setTimeout((()=>e()),0))),setTimeout((()=>window.squatch._auto()),0),window._squatch=void 0;try{delete window._squatch}catch(e){throw e}}}n.d(t,{Z:function(){return r}})},510:function(e,t,n){"use strict";function r(){console.log("Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes.")}n.d(t,{R:function(){return r}})},518:function(){},998:function(e,t,n){"use strict";n.d(t,{F:function(){return l},b:function(){return f}});var r=n(572),o=n(227),i=n(955);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c=(0,o.debug)("squatch-js"),d=e=>"object"==typeof e&&!Array.isArray(e),u=(e,t)=>{var n=n=>d(t[n])&&e.hasOwnProperty(n)&&d(e[n]),r=Object.getOwnPropertyNames(t).map((r=>({[r]:n(r)?u(e[r],t[r]):t[r]}))).reduce(((e,t)=>s(s({},e),t)),{});return s(s({},e),r)};function l(e){return atob(e.replace(/_/g,"/").replace(/-/g,"+"))}function p(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(){var e=window.location.search,t=new URLSearchParams(e).get("_saasquatch")||"";if(t){var n="",r="",o="";try{n=JSON.parse(l(t))}catch(e){return void c("Unable to decode params",e)}try{r=JSON.parse(l(i.Z.get("_saasquatch"))),c("existing cookie",r)}catch(e){c("Unable to retrieve cookie",e)}try{var a=function(){var e,t,n="weird_get_top_level_domain=cookie",r=document.location.hostname.split(".");for(e=r.length-1;e>=0;e--)if(t=r.slice(e).join("."),document.cookie=n+";domain=."+t+";",document.cookie.indexOf(n)>-1)return document.cookie=n.split("=")[0]+"=;domain=."+t+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",t}();if(c("domain retrieved:",a),r){var s=u(r,n);o=p(JSON.stringify(s)),c("cookie to store:",s)}else o=p(JSON.stringify(n)),c("cookie to store:",n);i.Z.set("_saasquatch",o,{expires:365,secure:!1,sameSite:"Lax",domain:a,path:"/"})}catch(e){c("Unable to set cookie",e)}}}},936:function(e,t,n){"use strict";function r(e,t){var n,r=[],o=e,i=o.documentElement.doScroll,a="DOMContentLoaded",s=(i?/^loaded|^c/:/^loaded|^i|^c/).test(o.readyState);return s||o.addEventListener(a,n=()=>{for(o.removeEventListener(a,n),s=!0;n=r.shift();)n()}),s?setTimeout(t,0):r.push(t)}n.d(t,{V:function(){return r}})},615:function(e,t,n){"use strict";n.d(t,{Mx:function(){return l},Rf:function(){return s},gc:function(){return d},iR:function(){return f}});var r=n(572),o=n(861);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n,r){return c.apply(this,arguments)}function c(){return(c=(0,o.Z)((function*(e,t,n,r){var o=r||window.squatchToken,i=a(a({Accept:"application/json","Content-Type":"application/json"},o?{Authorization:"Bearer ".concat(o)}:{}),{},{"X-SaaSquatch-Referrer":window?window.location.href:""});try{var s=yield fetch(e,{method:"POST",body:JSON.stringify({query:t,variables:n}),headers:i});if(!s.ok)throw new Error(yield s.text());return yield s.json()}catch(e){throw e}}))).apply(this,arguments)}function d(e){return u.apply(this,arguments)}function u(){return u=(0,o.Z)((function*(e){var t={Accept:"application/json","Content-Type":"application/json"},n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||window.squatchToken;n&&(t["X-SaaSquatch-User-Token"]=n);try{var r=yield fetch(e,{method:"GET",credentials:"include",headers:t}),o=yield r.text();if(!r.ok)throw new Error(o);return o?JSON.parse(o):o}catch(e){throw e}})),u.apply(this,arguments)}function l(e,t,n){return p.apply(this,arguments)}function p(){return(p=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json"},o=n||window.squatchToken;o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{method:"POST",body:t,headers:r}),a=yield i.text();if(!i.ok)throw new Error(a);return a?JSON.parse(a):a}catch(e){throw e}}))).apply(this,arguments)}function f(e,t,n){return h.apply(this,arguments)}function h(){return(h=(0,o.Z)((function*(e,t,n){var r={Accept:"application/json","Content-Type":"application/json","X-SaaSquatch-Referrer":window?window.location.href:""},o=n||window.squatchToken;o&&(r["X-SaaSquatch-User-Token"]=o);try{var i=yield fetch(e,{headers:r,method:"PUT",credentials:"include",body:t}),a=yield i.text();if(!i.ok)throw new Error(a);return a?JSON.parse(a):a}catch(e){throw e}}))).apply(this,arguments)}(0,n(227).debug)("squatch-js:io")},8:function(e,t,n){"use strict";n.d(t,{G:function(){return u}});var r=n(572);function o(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=n(227),a=n(998);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var d=(0,i.debug)("squatch-js");function u(e){var t=window.location.search,n=new URLSearchParams(t).get("_saasquatchExtra")||"";if(n){var r;try{r=JSON.parse((0,a.F)(n))}catch(e){return void d("Unable to decode _saasquatchExtra config")}var{domain:i,tenantAlias:s,widgetConfig:u}=function(e){var t,n=Object.keys(e||{})[0],r=Object.keys((null==e?void 0:e[n])||{})[0],o=null==e||null===(t=e[n])||void 0===t?void 0:t[r];return{domain:n?"https://".concat(n):void 0,tenantAlias:r,widgetConfig:o}}(r);if(i&&s&&u){var{autoPopupWidgetType:l}=u;return{widgetConfig:c({widgetType:l,displayOnLoad:!0},o(u,["autoPopupWidgetType"])),squatchConfig:c(c({},e?{configIn:e}:{}),{},{domain:i,tenantAlias:s})}}d("_saasquatchExtra did not have an expected structure")}else d("No _saasquatchExtra param")}},787:function(e,t,n){"use strict";n.d(t,{Kn:function(){return a},Qb:function(){return s},ZL:function(){return d},cE:function(){return r},eu:function(){return o},ww:function(){return i},xW:function(){return c}});var r="https://app.referralsaasquatch.com",o="https://fast.ssqt.io/npm";function i(e){var t,n,i;if("object"!=typeof e)throw new Error("config must be an object");var a={tenantAlias:(null==e?void 0:e.tenantAlias)||window.squatchTenant,domain:(null==e?void 0:e.domain)||(null===(t=window.squatchConfig)||void 0===t?void 0:t.domain),npmCdn:(null==e?void 0:e.npmCdn)||(null===(n=window.squatchConfig)||void 0===n?void 0:n.npmCdn),debug:(null==e?void 0:e.debug)||(null===(i=window.squatchConfig)||void 0===i?void 0:i.debug)};if("string"!=typeof a.tenantAlias)throw new Error("tenantAlias not provided");return{tenantAlias:a.tenantAlias,domain:"string"==typeof a.domain&&a.domain||r,debug:"boolean"==typeof a.debug&&a.debug||!1,npmCdn:"string"==typeof a.npmCdn&&a.npmCdn||o}}function a(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function s(e){if(e&&/^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(e))return e}function c(e){if(!a(e))throw new Error("Widget properties must be an object");if(null==e||!e.user)throw new Error("Required properties missing.");return e}function d(e){if(!a(e))throw new Error("Widget properties must be an object");return e}},75:function(e,t,n){"use strict";n.d(t,{Z:function(){return d}});var r=n(861),o=n(572),i=n(227),a=n(657),s=n(936),c=(0,i.debug)("squatch-js:EMBEDwidget");class d extends a.Z{constructor(e,t){super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close)}load(){var e=this;return(0,r.Z)((function*(){var t,n=e._createFrame(),o=e._findElement();e.container?o.shadowRoot?"IFRAME"===(null===(t=o.shadowRoot.lastChild)||void 0===t?void 0:t.nodeName)?o.shadowRoot.replaceChild(n,o.shadowRoot.lastChild):o.shadowRoot.appendChild(n):o.firstChild?o.replaceChild(n,o.firstChild):o.appendChild(n):o.firstChild&&"#text"!==o.firstChild.nodeName||o.appendChild(n);var{contentWindow:i}=n;if(!i)throw new Error("Frame needs a content window");var a=i.document;a.open(),a.write(e.content),a.write('<script src="'.concat(e.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),a.close(),(0,s.V)(a,(0,r.Z)((function*(){var t=i.squatch||i.widgetIdent;n.height=a.body.scrollHeight,new i.ResizeObserver((e=>{for(var t of e){var{height:r}=t.contentRect;n.height=r}})).observe(yield e._findInnerContainer(n)),e.container||(e._loadEvent(t),c("loaded"))})))}))()}open(){var e,t,n,r=this._findFrame();if(!r)return c("no target element to open");var o=this._findElement();o.style.visibility="unset",o.style.height="auto",o.style["overflow-y"]="auto",null==r||null===(e=r.contentDocument)||void 0===e||e.dispatchEvent(new CustomEvent("sq:refresh"));var i=(null==r||null===(t=r.contentWindow)||void 0===t?void 0:t.squatch)||(null==r||null===(n=r.contentWindow)||void 0===n?void 0:n.widgetIdent);this._loadEvent(i),c("loaded")}close(){if(!this._findFrame())return c("no target element to close");var e=this._findElement();e.style.visibility="hidden",e.style.height="0",e.style["overflow-y"]="hidden",c("Embed widget closed")}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"embed",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n)}}},658:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(572),i=n(227),a=n(936),s=n(657),c=(0,i.debug)("squatch-js:POPUPwidget"),d=0;class u extends s.Z{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".squatchpop";super(e),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.trigger=t,this.container?this.id="squatchModal":(this.id=0===d?"squatchModal":"squatchModal__".concat(d),d+=1),document.head.insertAdjacentHTML("beforeend","<style>#".concat(this.id,"::-webkit-scrollbar { display: none; }</style>"))}_initialiseCTA(e){if(this.trigger){var t;try{t=document.querySelector(this.trigger),this.trigger&&!t&&c("No element found with trigger selector",this.trigger)}catch(e){c("Not a valid selector",this.trigger)}t&&(t.onclick=()=>{this.open()})}}_createPopupDialog(){var e=document.createElement("dialog");return e.id=this.id,e.setAttribute("style","width: 100%; max-width: 500px; border: none; padding: 0;"),e.addEventListener("click",(t=>{t.target===e&&e.close()})),e}load(){var e,t=this._createFrame();this._initialiseCTA(t);var n=this._findElement(),r=n.shadowRoot||n,o=this._createPopupDialog();o.appendChild(t),"DIALOG"===(null===(e=r.lastChild)||void 0===e?void 0:e.nodeName)?r.replaceChild(o,r.lastChild):r.appendChild(o);var{contentWindow:i}=t;if(!i)throw new Error("Frame needs a content window");var a=i.document;a.open(),a.write(this.content),a.write('<script src="'.concat(this.npmCdn,'/resize-observer-polyfill@1.5.x"><\/script>')),a.close(),c("Popup template loaded into iframe"),this._setupResizeHandler(t)}_setupResizeHandler(e){var t=this,{contentWindow:n}=e;if(!n)throw new Error("Frame needs a content window");var o=n.document;(0,a.V)(o,(0,r.Z)((function*(){o.body.style.overflowY="hidden",e.height="".concat(o.body.offsetHeight,"px"),new n.ResizeObserver((t=>{for(var n of t){var{top:r,bottom:o}=n.contentRect,i=o+r;e.height=i+"",n.target.style=""}})).observe(yield t._findInnerContainer(e))})))}open(){var e=this._findElement(),t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.showModal();var n=this._findFrame();if(!n)throw new Error("Could not find iframe");var{contentWindow:r}=n;if(!r)throw new Error("Squatch.js has an empty iframe");var o=r.document;(0,a.V)(o,(()=>{var e,t=r.squatch||r.widgetIdent;null===(e=n.contentDocument)||void 0===e||e.dispatchEvent(new CustomEvent("sq:refresh")),this._loadEvent(t),c("Popup opened")}))}close(){var e=this._findElement(),t=(e.shadowRoot||e).querySelector("#".concat(this.id));if(!t)throw new Error("Could not determine container div");t.close(),c("Popup closed")}_clickedOutside(e){var{target:t}=e}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return super._error(e,t,n||"body { margin: 0; } .modal { box-shadow: none; border: 0; }")}}},657:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(861),o=n(227),i=n(264),a=n(787),s=(0,o.debug)("squatch-js:widget");class c{constructor(e){s("widget initializing ..."),this.content="error"===e.content?this._error(e.rsCode):e.content,this.type=e.type,this.widgetApi=e.api,this.npmCdn=e.npmCdn,this.analyticsApi=new i.Z({domain:e.domain}),this.context=e.context,this.container=e.container}_findElement(){var e;if("string"==typeof this.container?(e=document.querySelector(this.container),s("loading widget with selector",e)):this.container instanceof HTMLElement?(e=this.container,s("loading widget with container",e)):this.container?(e=null,s("container must be an HTMLElement or string",this.container)):(e=document.querySelector("#squatchembed")||document.querySelector(".squatchembed"),s("loading widget with default selector",e)),!(e instanceof HTMLElement))throw new Error("element with selector '".concat(this.container||"#squatchembed or .squatchembed","' not found.'"));return e}_createFrame(){var e=document.createElement("iframe");return e.squatchJsApi=this,e.id="squatchFrame",e.width="100%",e.src="about:blank",e.scrolling="no",e.setAttribute("style","border: 0; background-color: none; width: 1px; min-width: 100%;"),e}_findFrame(){var e=this._findElement();return(e.shadowRoot||e).querySelector("iframe#squatchFrame")}_loadEvent(e){var t;if(e){if(!(0,a.Kn)(e))throw new Error("Widget Load event identity property is not an object");var n;if("programId"in e){if(!(e.tenantAlias&&e.accountId&&e.userId&&e.engagementMedium))throw new Error("Widget Load event missing required properties");n={tenantAlias:e.tenantAlias,externalAccountId:e.accountId,externalUserId:e.userId,engagementMedium:e.engagementMedium,programId:e.programId}}else{var{analytics:r,mode:o}=e;n={tenantAlias:r.attributes.tenant,externalAccountId:r.attributes.accountId,externalUserId:r.attributes.userId,engagementMedium:o.widgetMode}}null===(t=this.analyticsApi.pushAnalyticsLoadEvent(n))||void 0===t||t.then((e=>{s("".concat(n.engagementMedium," loaded event recorded."))})).catch((e=>{s("ERROR: pushAnalyticsLoadEvent() ".concat(e))}))}}_shareEvent(e,t){e&&this.analyticsApi.pushAnalyticsShareClickedEvent({tenantAlias:e.analytics.attributes.tenant,externalAccountId:e.analytics.attributes.accountId,externalUserId:e.analytics.attributes.userId,engagementMedium:e.mode.widgetMode,shareMedium:t}).then((n=>{s("".concat(e.mode.widgetMode," share ").concat(t," event recorded. ").concat(n))})).catch((e=>{s("ERROR: pushAnalyticsShareClickedEvent() ".concat(e))}))}_error(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal";return'<!DOCTYPE html>\n \x3c!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]--\x3e\n \x3c!--[if gt IE 8]>\x3c!--\x3e<html lang="en">\x3c!--<![endif]--\x3e\n <head>\n <link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">\n <style>\n '.concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",'\n </style>\n </head>\n <body>\n\n <div class="squatch-container ').concat(t,'" style="width:100%">\n <div class="errorheader">\n <button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">&times;</button>\n <p class="errortitle">Error</p>\n </div>\n <div class="errorbody">\n <div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>\n <h4>Our referral program is temporarily unavailable.</h4><br>\n <p>Please reload the page or check back later.</p>\n <p>If the persists please contact our support team.</p>\n <br>\n <br>\n <div class="right-align errtxt">\n Error Code: ').concat(e,"\n </div>\n </div>\n </div>\n </body>\n </html>")}_findInnerContainer(e){return(0,r.Z)((function*(){var{contentWindow:t}=e;if(!t)throw new Error("Squatch.js frame inner frame is empty");for(var n,r,o=t.document,i=null,a=0;a<5&&(void 0,void 0,n=o.getElementsByTagName("sqh-global-container"),r=o.getElementsByClassName("squatch-container"),!(i=n.length>0?n[0]:r.length>0?r[0]:null));a++)yield d(100);return i||o.body}))()}reload(e,t){var{email:n,firstName:r,lastName:o}=e,i=this._findFrame();if(!i)throw new Error("Could not find widget iframe");var a,c=i.contentWindow,d=this.context.engagementMedium||"POPUP";if(!c)throw new Error("Frame needs a content window");if("upsert"===this.context.type){if(!this.context.user)throw new Error("Can't reload without user ids");var u={email:n||null,firstName:r||null,lastName:o||null,id:this.context.user.id,accountId:this.context.user.accountId};a=this.widgetApi.upsertUser({user:u,engagementMedium:d,widgetType:this.type,jwt:t})}else{if("passwordless"!==this.context.type)throw new Error("can't reload an error widget");a=this.widgetApi.render({user:void 0,engagementMedium:d,widgetType:this.type,jwt:void 0})}a.then((e=>{var{template:t}=e;t&&(this.content=t,this.__deprecated__register(i,{email:n,engagementMedium:d},(()=>{this.load(),"POPUP"===d&&this.open()})))})).catch((e=>{var{message:t}=e;s("".concat(t))}))}__deprecated__register(e,t,n){var r=e.contentWindow.document,o=r.createElement("button"),i=r.getElementsByClassName("squatch-register")[0];if(i){o.className="btn btn-primary",o.id="show-stats-btn",o.textContent="REFERRER_WIDGET"===this.type?"Show Stats":"Show Reward";var a="POPUP"===t.engagementMedium?"margin-top: 10px; max-width: 130px; width: 100%;":"margin-top: 10px;";o.setAttribute("style",a),o.onclick=n,i.style.paddingTop="30px",i.innerHTML="<p><strong>".concat(t.email,"</strong><br>Has been successfully registered</p>"),i.appendChild(o)}}}function d(e){return new Promise((function(t,n){setTimeout((function(){t((()=>{}))}),e)}))}},452:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(861),o=n(227),i=n(139),a=n(787),s=n(75),c=n(658),d=(0,o.debug)("squatch-js:widgets");class u{constructor(e){var t=(0,a.ww)(e);this.tenantAlias=t.tenantAlias,this.domain=t.domain,this.npmCdn=t.npmCdn,this.api=new i.Z(t)}upsertUser(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.xW)(n);try{var o=yield t.api.upsertUser(r);return{widget:t._renderWidget(o,r,{type:"upsert",user:r.user||null,engagementMedium:e.engagementMedium,container:e.container,trigger:e.trigger}),user:o.user}}catch(n){throw d(n),n.apiErrorCode&&t._renderErrorWidget(n,e.engagementMedium),new Error(n)}}))()}render(e){var t=this;return(0,r.Z)((function*(){var n=e,r=(0,a.ZL)(n);try{var o=yield t.api.render(r);return{widget:t._renderWidget(o,r,{type:"passwordless",engagementMedium:r.engagementMedium}),user:o.user}}catch(e){throw e.apiErrorCode&&t._renderErrorWidget(e,r.engagementMedium),new Error(e)}}))()}autofill(e){var t=this;return(0,r.Z)((function*(){var n=e;if("function"!=typeof n){if("string"!=typeof n)throw new Error("Autofill accepts a string or function");var r,o=document.querySelectorAll(n);if(!(o.length>0))throw d("Element id/class or function missing"),new Error("Element id/class or function missing");r=o[0];try{var i=yield t.api.squatchReferralCookie();r.value=i.codes[0]}catch(e){throw new Error(e)}}else try{n(yield t.api.squatchReferralCookie())}catch(e){throw d("Autofill error",e),new Error(e)}}))()}_renderWidget(e,t,n){var r,o;if(d("Rendering Widget..."),!e)throw new Error("Unable to get a response");var i=!!t.displayOnLoad,a=e.jsOptions||{},s={content:e.template,type:t.widgetType||(null===(r=a.widget)||void 0===r?void 0:r.defaultWidgetType),api:this.api,domain:this.domain,npmCdn:this.npmCdn,context:n};return a.widgetUrlMappings&&a.widgetUrlMappings.forEach((t=>{var n,r,o;u._matchesUrl(t.url)&&("CONVERSION_WIDGET"!==t.widgetType||null!==(n=e.user)&&void 0!==n&&n.referredBy&&null!==(r=e.user)&&void 0!==r&&null!==(o=r.referredBy)&&void 0!==o&&o.code?(i=t.displayOnLoad,t.showAsCTA,d("Display ".concat(t.widgetType," on ").concat(t.url))):d("Don't display ".concat(t.widgetType," when no referral on widget rule match ").concat(t.url)))})),a.fuelTankAutofillUrls&&(d("We found a fuel tank autofill!"),a.fuelTankAutofillUrls.forEach((t=>{var n,r,o,{url:i,formSelector:a}=t;if(u._matchesUrl(i)&&(d("Fuel Tank URL matches"),null!==(n=e.user)&&void 0!==n&&n.referredBy&&null!==(r=e.user)&&void 0!==r&&null!==(o=r.referredBy)&&void 0!==o&&o.code)){var s=document.querySelector(a);s?s.value=e.user.referredBy.referredReward.fuelTankCode||"":d(new Error("Element with id/class ".concat(a," was not found.")))}}))),"EMBED"===t.engagementMedium?o=this._renderEmbedWidget(s,s.context.container):"POPUP"===t.engagementMedium?(o=this._renderPopupWidget(s),i&&o.open()):(d("display popup on load"),(o=new c.Z(s)).load(),i&&o.open()),o}_renderPopupWidget(e){var t=new c.Z(e,e.context.trigger);return t.load(),t}_renderEmbedWidget(e,t){var n=new s.Z(e);return n.load(),n}_renderErrorWidget(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POPUP",{apiErrorCode:n,rsCode:r,message:o}=e;d(new Error("".concat(n," (").concat(r,") ").concat(o)));var i={content:"error",rsCode:r,api:this.api,domain:this.domain,npmCdn:this.npmCdn,type:"ERROR_WIDGET",context:{type:"error"}};"EMBED"===t?new s.Z(i).load():"POPUP"===t&&new c.Z(i).load()}static _matchesUrl(e){return!!window.location.href.match(new RegExp(e))}}},22:function(e,t,n){"use strict";n.d(t,{U:function(){return m},n:function(){return w}});var r=n(861),o=n(572),i=n(227),a=n.n(i),s=n(264),c=n(139),d=n(998),u=(0,i.debug)("squatch-js:decodeJwt"),l=n(8),p=n(787),f=n(75),h=n(658);a()("sqh:DeclarativeWidget");class g extends HTMLElement{constructor(){super(),(0,o.Z)(this,"_setWidget",((e,t)=>{var n,r={api:this.widgetApi,content:e,context:{type:t.type,engagementMedium:this.type},type:this.widgetType,domain:(null===(n=this.config)||void 0===n?void 0:n.domain)||p.cE,npmCdn:p.eu,container:this.container||this};return"EMBED"===this.type?new f.Z(r):new h.Z(r,this.firstChild?null:void 0)})),(0,o.Z)(this,"setErrorWidget",(e=>{var t,n={api:this.widgetApi,content:"error",context:{type:"error"},type:"ERROR_WIDGET",domain:(null===(t=this.config)||void 0===t?void 0:t.domain)||p.cE,npmCdn:p.eu,container:this.container||this};return"EMBED"===this.type?new f.Z(n):new h.Z(n,this.firstChild?null:void 0)})),(0,o.Z)(this,"show",this.open),(0,o.Z)(this,"hide",this.close),this.attachShadow({mode:"open"}).innerHTML="<style>:host { display: contents; }</style><slot></slot>",this.config=window.squatchConfig,this.token=window.squatchToken,this.tenant=window.squatchTenant,this.container=this}_setupApis(e){var t,n;if(!this.tenant)throw new Error("Requires tenantAlias");this.widgetApi=new c.Z({tenantAlias:(null==e?void 0:e.tenantAlias)||this.tenant,domain:(null==e?void 0:e.domain)||(null===(t=this.config)||void 0===t?void 0:t.domain)||p.cE}),this.analyticsApi=new s.Z({domain:(null==e?void 0:e.domain)||(null===(n=this.config)||void 0===n?void 0:n.domain)||p.cE})}renderPasswordlessVariant(){var e=this;return(0,r.Z)((function*(){var t,n,r=(0,l.G)();return e._setupApis(null==r?void 0:r.squatchConfig),yield e.widgetApi.render({engagementMedium:(null==r||null===(t=r.widgetConfig)||void 0===t?void 0:t.engagementMedium)||e.type,widgetType:(null==r||null===(n=r.widgetConfig)||void 0===n?void 0:n.widgetType)||e.widgetType}).then((t=>e._setWidget(t.template,{type:"passwordless"}))).catch(e.setErrorWidget)}))()}renderUserUpsertVariant(){var e=this;return(0,r.Z)((function*(){e._setupApis();var t=function(e){try{var t,n=e.split(".")[1];if(void 0===n)return null;var r=(0,d.F)(n);return null===(t=JSON.parse(r))||void 0===t?void 0:t.user}catch(e){return u(e),null}}(e.token);if(!t)throw new Error("Could not load user information from jwt");return yield e.widgetApi.upsertUser({user:t,engagementMedium:e.type,widgetType:e.widgetType,jwt:e.token}).then((t=>e._setWidget(t.template,{type:"upsert"}))).catch(e.setErrorWidget)}))()}getWidgetInstance(){var e=this;return(0,r.Z)((function*(){var t;if(e.widgetType=e.getAttribute("widget")||void 0,!e.widgetType)throw new Error("No widget has been specified");if(!(t=e.token?yield e.renderUserUpsertVariant():yield e.renderPasswordlessVariant()))throw new Error("Could not create widget.");return e.widgetInstance=t,t}))()}renderWidget(){var e=this;return(0,r.Z)((function*(){yield e.getWidgetInstance(),yield e.widgetInstance.load()}))()}open(){this.widgetInstance.open()}close(){this.widgetInstance.close()}}class m extends g{constructor(){super(),this.type="EMBED"}static get observedAttributes(){return["widget","container"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"widget":this.connectedCallback();break;case"container":this.widgetInstance._findElement()&&this.close(),this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){var t,n;e.container=e.getAttribute("container")||e,yield e.renderWidget();var r=null===(t=e.shadowRoot&&Array.from(e.shadowRoot.children))||void 0===t?void 0:t.find((e=>"SLOT"===e.tagName));r&&(null===(n=e.shadowRoot)||void 0===n||n.removeChild(r))}))()}}class w extends g{constructor(){super(),this.type="POPUP",this.addEventListener("click",(e=>{e.stopPropagation(),"SQUATCH-POPUP"!==e.target.tagName&&this.open()}))}static get observedAttributes(){return["widget","id","open"]}attributeChangedCallback(e,t,n){if(t!==n&&t)switch(e){case"open":case"widget":this.connectedCallback()}}connectedCallback(){var e=this;return(0,r.Z)((function*(){yield e.renderWidget(),null!==e.getAttribute("open")&&e.open()}))()}}window.customElements.define("squatch-embed",m),window.customElements.define("squatch-popup",w)},227:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)}},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(447)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:function(e,t,n){"use strict";e.exports=function(e){function t(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var n;function a(){if(a.enabled){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var i=a,s=Number(new Date),c=s-(n||s);i.diff=c,i.prev=n,i.curr=s,n=s,t[0]=r.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var d=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,n){if("%%"===e)return e;d++;var o=r.formatters[n];if("function"==typeof o){var a=t[d];e=o.call(i,a),t.splice(d,1),d--}return e})),r.formatArgs.call(i,t),(i.log||r.log).apply(i,t)}}return a.namespace=e,a.enabled=r.enabled(e),a.useColors=r.useColors(),a.color=t(e),a.destroy=o,a.extend=i,"function"==typeof r.init&&r.init(a),r.instances.push(a),a}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){return r(this.namespace+(void 0===t?":":t)+e)}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){r.enable("")},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=n(824),Object.keys(e).forEach((function(t){r[t]=e[t]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r}},824:function(e){var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,a){a=a||{};var s,c,d=typeof e;if("string"===d&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===d&&isFinite(e))return a.long?(s=e,(c=Math.abs(s))>=o?i(s,c,o,"day"):c>=r?i(s,c,r,"hour"):c>=n?i(s,c,n,"minute"):c>=t?i(s,c,t,"second"):s+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},861:function(e,t,n){"use strict";function r(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function s(e){r(a,o,i,s,c,"next",e)}function c(e){r(a,o,i,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return o}})},572:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===r(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return o}})},955:function(e,t,n){"use strict";function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}n.d(t,{Z:function(){return o}});var o=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=r({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var s in i)i[s]&&(a+="; "+s,!0!==i[s]&&(a+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+a}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");try{var s=decodeURIComponent(i[0]);if(r[s]=t.read(a,s),e===s)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){o(e,"",r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,r({},this.attributes,t))},withConverter:function(t){return e(r({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";n.r(r),n.d(r,{DeclarativeEmbedWidget:function(){return p.U},DeclarativePopupWidget:function(){return p.n},EmbedWidget:function(){return o.Z},PopupWidget:function(){return i.Z},WidgetApi:function(){return a.Z},Widgets:function(){return t.Z},_auto:function(){return A},api:function(){return C},autofill:function(){return P},events:function(){return O},help:function(){return m.R},init:function(){return j},pushCookie:function(){return q},ready:function(){return I},widget:function(){return x},widgets:function(){return E}});var e=n(227),t=n(452),o=n(75),i=n(658),a=n(139),s=n(745),c=n(762),d=n(787),u=n(998),l=n(8),p=n(22),f=n(518),h={};for(var g in f)["default","Widgets","EmbedWidget","PopupWidget","DeclarativeEmbedWidget","DeclarativePopupWidget","WidgetApi","api","widgets","events","widget","_auto","init","ready","autofill","pushCookie"].indexOf(g)<0&&(h[g]=function(e){return f[e]}.bind(0,g));n.d(r,h);var m=n(510),w=(0,e.debug)("squatch-js"),v=null,y=null,b=null;function C(){return v||exports.init({}),v}function E(){return y||exports.init({}),y}function O(){return b||exports.init({}),b}function x(e){var t;return null===(t=E())||void 0===t?void 0:t.render(e)}function A(e){var t=(0,l.G)(e);if(t){var n,{squatchConfig:r,widgetConfig:o}=t;return j(r),null===(n=E())||void 0===n?void 0:n.render(o)}}function j(n){var r=n,o=(0,d.ww)(r);(o.tenantAlias.match("^test")||o.debug)&&e.debug.enable("squatch-js*"),w("initializing ..."),v=new a.Z(o),y=new t.Z(o),b=new s.Z(o),w("Widget API instance",v),w("Widgets instance",y),w("Events API instance",b)}function I(e){e()}function P(e){E().autofill(e)}function q(){(0,u.b)()}"undefined"==typeof document||window.SaaSquatchDoNotAutoDrop||q(),"undefined"!=typeof document&&(0,c.Z)()}(),r}()}));
@@ -1,5 +1,5 @@
1
1
  import { JWT } from "../types";
2
- export declare function doQuery(url: string, query: string, variables: Record<string, unknown>, token: string | undefined): Promise<any>;
2
+ export declare function doQuery(url: string, query: string, variables: Record<string, unknown>, jwt: string | undefined): Promise<any>;
3
3
  export declare function doGet<T>(url: any, jwt?: string): Promise<T>;
4
4
  export declare function doPost(url: string, data: any, jwt?: JWT): Promise<any>;
5
5
  export declare function doPut(url: string, data: any, jwt?: JWT): Promise<any>;
@@ -7,10 +7,10 @@ import Widget, { Params } from "./Widget";
7
7
  */
8
8
  export default class EmbedWidget extends Widget {
9
9
  constructor(params: Params, container?: HTMLElement | string);
10
- load(frame: HTMLIFrameElement): Promise<void>;
11
- open(frame: HTMLIFrameElement): void;
12
- close(frame: HTMLIFrameElement): void;
10
+ load(): Promise<void>;
11
+ open(): void;
12
+ close(): void;
13
13
  protected _error(rs: any, mode?: string, style?: string): string;
14
- show: (frame: HTMLIFrameElement) => void;
15
- hide: (frame: HTMLIFrameElement) => void;
14
+ show: () => void;
15
+ hide: () => void;
16
16
  }
@@ -7,19 +7,19 @@ import Widget, { Params } from "./Widget";
7
7
  *
8
8
  */
9
9
  export default class PopupWidget extends Widget {
10
- trigger: string;
10
+ trigger: string | null;
11
11
  id: string;
12
- constructor(params: Params, trigger?: string);
12
+ constructor(params: Params, trigger?: string | null);
13
13
  _initialiseCTA(frame: HTMLIFrameElement): void;
14
14
  _createPopupDialog(): HTMLDialogElement;
15
- load(frame: HTMLIFrameElement): void;
15
+ load(): void;
16
16
  protected _setupResizeHandler(frame: HTMLIFrameElement): void;
17
- open(frame: HTMLIFrameElement): void;
17
+ open(): void;
18
18
  close(): void;
19
19
  protected _clickedOutside({ target }: {
20
20
  target: any;
21
21
  }): void;
22
22
  protected _error(rs: any, mode?: string, style?: string): string;
23
- show: (frame: HTMLIFrameElement) => void;
23
+ show: () => void;
24
24
  hide: () => void;
25
25
  }
@@ -33,7 +33,8 @@ export default abstract class Widget {
33
33
  protected constructor(params: Params);
34
34
  _findElement(): HTMLElement;
35
35
  _createFrame(): HTMLIFrameElement;
36
- abstract load(frame: HTMLIFrameElement): void;
36
+ _findFrame(): HTMLIFrameElement | null;
37
+ abstract load(): void;
37
38
  protected _loadEvent(sqh: ProgramLoadEvent | GenericLoadEvent): void;
38
39
  protected _shareEvent(sqh: any, medium: any): void;
39
40
  protected _error(rs: any, mode?: string, style?: string): string;
@@ -44,7 +45,7 @@ export default abstract class Widget {
44
45
  * @param param0 Form field values
45
46
  * @param jwt JWT for API authentication
46
47
  */
47
- reload(frame: HTMLIFrameElement, { email, firstName, lastName }: {
48
+ reload({ email, firstName, lastName }: {
48
49
  email: any;
49
50
  firstName: any;
50
51
  lastName: any;
@@ -71,7 +71,7 @@ export default class Widgets {
71
71
  * @param selector Element class/id selector, or a callback function
72
72
  * @returns
73
73
  */
74
- autofill(selector: string | Function): void;
74
+ autofill(selector: string | Function): Promise<void>;
75
75
  /**
76
76
  * @hidden
77
77
  * @param {Object} response The json object return from the WidgetApi
@@ -96,13 +96,4 @@ export default class Widgets {
96
96
  * @returns {boolean} true if rule matches Url, false otherwise
97
97
  */
98
98
  private static _matchesUrl;
99
- /**
100
- * @hidden
101
- * @param {Object} target Object containing the target DOM element
102
- * @param {Widget} widget A widget (EmbedWidget, PopupWidget)
103
- * @param {Object} params An object with valid parameters
104
- * (e.g) {email:'email', firstName:'firstName'}
105
- * @returns {void}
106
- */
107
- private static _cb;
108
99
  }
@@ -12,16 +12,14 @@ export default abstract class DeclarativeWidget extends HTMLElement {
12
12
  analyticsApi: AnalyticsApi;
13
13
  type: "EMBED" | "POPUP";
14
14
  widgetInstance: EmbedWidget | PopupWidget;
15
- frame: HTMLIFrameElement;
16
15
  container: string | HTMLElement | undefined | null;
17
16
  element: HTMLElement | undefined;
17
+ _hasChildren: boolean;
18
18
  constructor();
19
19
  private _setupApis;
20
- renderPasswordlessVariant(): Promise<EmbedWidget | PopupWidget>;
21
- renderUserUpsertVariant(): Promise<EmbedWidget | PopupWidget>;
22
- _setWidget: (template: any, config: {
23
- type: "upsert" | "passwordless";
24
- }) => EmbedWidget | PopupWidget;
20
+ private renderPasswordlessVariant;
21
+ private renderUserUpsertVariant;
22
+ private _setWidget;
25
23
  getWidgetInstance(): Promise<EmbedWidget | PopupWidget>;
26
24
  renderWidget(): Promise<void>;
27
25
  setErrorWidget: (e: Error) => EmbedWidget | PopupWidget;
package/jest.config.ts CHANGED
@@ -26,9 +26,7 @@ export default {
26
26
  // coverageDirectory: "coverage",
27
27
 
28
28
  // An array of regexp pattern strings used to skip coverage collection
29
- // coveragePathIgnorePatterns: [
30
- // "/node_modules/"
31
- // ],
29
+ coveragePathIgnorePatterns: ["/node_modules/", "/test/"],
32
30
 
33
31
  // Indicates which provider should be used to instrument code for coverage
34
32
  // coverageProvider: "babel",
@@ -110,10 +108,10 @@ export default {
110
108
  // reporters: undefined,
111
109
 
112
110
  // Automatically reset mock state before every test
113
- // resetMocks: false,
111
+ resetMocks: true,
114
112
 
115
113
  // Reset the module registry before running each individual test
116
- // resetModules: false,
114
+ resetModules: true,
117
115
 
118
116
  // A path to a custom resolver
119
117
  // resolver: undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasquatch/squatch-js",
3
- "version": "2.6.0-0",
3
+ "version": "2.6.0-2",
4
4
  "description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
5
5
  "license": "MIT",
6
6
  "author": "ReferralSaaSquatch.com, Inc.",
@@ -37,7 +37,7 @@
37
37
  "test:types": "tsd",
38
38
  "test:features": "jest --verbose --coverage",
39
39
  "test": "run-s test:features test:browser test:webkit test:firefox",
40
- "build:docs": "typedoc --out docs/ src/ ",
40
+ "build:docs": "typedoc",
41
41
  "deploy": "np --no-cleanup",
42
42
  "deploy:docs": "surge ./ -d squathjsv2.surge.sh",
43
43
  "preversion": "run-s build",
@@ -63,12 +63,13 @@
63
63
  "@types/chai": "^4.3.5",
64
64
  "@types/cucumber": "^6.0.1",
65
65
  "@types/debug": "4.1.5",
66
+ "@types/estree": "^1.0.1",
66
67
  "@types/express": "^4.17.6",
68
+ "@types/inquirer": "^9.0.3",
67
69
  "@types/jest": "^29.5.2",
68
70
  "@types/js-cookie": "^2.2.6",
69
71
  "@types/jsdom-global": "^3.0.2",
70
72
  "@types/react": "^16.9.35",
71
- "@types/superagent": "^4.1.7",
72
73
  "@ungap/url-search-params": "^0.2.0",
73
74
  "babel-jest": "^29.5.0",
74
75
  "babel-loader": "^8.2.2",
@@ -92,13 +93,12 @@
92
93
  "react-dom": "^16.13.1",
93
94
  "react-url-query": "^1.5.0",
94
95
  "serve": "^11.3.0",
95
- "shadow-dom-testing-library": "^1.11.0",
96
96
  "size-limit": "^8.2.4",
97
97
  "ts-jest": "^29.1.1",
98
98
  "ts-loader": "^7.0.4",
99
99
  "ts-node": "^8.10.2",
100
100
  "tsd": "^0.13.1",
101
- "typedoc": "^0.17.7",
101
+ "typedoc": "^0.24.8",
102
102
  "typescript": "^5.1.6",
103
103
  "webpack": "^5.88.0",
104
104
  "webpack-bundle-analyzer": "^4.9.0",
package/tsconfig.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "typedocOptions":{
17
17
  "out": "docs",
18
18
  "json": "docs/docs.json",
19
+ "entryPoints": ["src/squatch.ts"],
19
20
  "excludePrivate": true,
20
21
  "excludeProtected": true
21
22
  }