customerio-gist-web 3.10.2 → 3.11.1
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.
- package/dist/gist.min.js +1 -1
- package/package.json +1 -1
- package/src/gist.js +14 -4
- package/src/managers/locale-manager.js +16 -0
- package/src/managers/message-broadcast-manager.js +78 -0
- package/src/managers/message-manager.js +11 -13
- package/src/managers/message-user-queue-manager.js +54 -0
- package/src/managers/queue-manager.js +17 -46
- package/src/managers/user-manager.js +41 -12
- package/src/services/network.js +8 -7
- package/src/services/queue-service.js +12 -6
- package/src/templates/embed.js +10 -0
- package/src/templates/message.js +1 -1
- package/src/utilities/local-storage.js +39 -13
- package/src/utilities/preview-mode.js +20 -0
package/dist/gist.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,(()=>(()=>{var e={505:(e,t,n)=>{e.exports=n(15)},592:(e,t,n)=>{"use strict";var r=n(516),s=n(522),i=n(948),o=n(106),a=n(615),u=n(631),c=n(202),l=n(896),d=n(845),f=n(563),p=n(656),h=n(721);e.exports=function(e){return new Promise((function(t,n){var g,m=e.data,v=e.headers,y=e.responseType,b=e.withXSRFToken;function w(){e.cancelToken&&e.cancelToken.unsubscribe(g),e.signal&&e.signal.removeEventListener("abort",g)}r.isFormData(m)&&r.isStandardBrowserEnv()&&delete v["Content-Type"];var x=new XMLHttpRequest;if(e.auth){var E=e.auth.username||"",R=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(E+":"+R)}var O=a(e.baseURL,e.url);function S(){if(x){var r="getAllResponseHeaders"in x?u(x.getAllResponseHeaders()):null,i={data:y&&"text"!==y&&"json"!==y?x.response:x.responseText,status:x.status,statusText:x.statusText,headers:r,config:e,request:x};s((function(e){t(e),w()}),(function(e){n(e),w()}),i),x=null}}if(x.open(e.method.toUpperCase(),o(O,e.params,e.paramsSerializer),!0),x.timeout=e.timeout,"onloadend"in x?x.onloadend=S:x.onreadystatechange=function(){x&&4===x.readyState&&(0!==x.status||x.responseURL&&0===x.responseURL.indexOf("file:"))&&setTimeout(S)},x.onabort=function(){x&&(n(new d("Request aborted",d.ECONNABORTED,e,x)),x=null)},x.onerror=function(){n(new d("Network Error",d.ERR_NETWORK,e,x)),x=null},x.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new d(t,r.clarifyTimeoutError?d.ETIMEDOUT:d.ECONNABORTED,e,x)),x=null},r.isStandardBrowserEnv()&&(b&&r.isFunction(b)&&(b=b(e)),b||!1!==b&&c(O))){var I=e.xsrfHeaderName&&e.xsrfCookieName&&i.read(e.xsrfCookieName);I&&(v[e.xsrfHeaderName]=I)}"setRequestHeader"in x&&r.forEach(v,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete v[t]:x.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(x.withCredentials=!!e.withCredentials),y&&"json"!==y&&(x.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&x.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&x.upload&&x.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(g=function(t){x&&(n(!t||t.type?new f(null,e,x):t),x.abort(),x=null)},e.cancelToken&&e.cancelToken.subscribe(g),e.signal&&(e.signal.aborted?g():e.signal.addEventListener("abort",g))),m||!1===m||0===m||""===m||(m=null);var T=p(O);T&&-1===h.protocols.indexOf(T)?n(new d("Unsupported protocol "+T+":",d.ERR_BAD_REQUEST,e)):x.send(m)}))}},15:(e,t,n)=>{"use strict";var r=n(516),s=n(12),i=n(155),o=n(343),a=n(412),u=n(298),c=function e(t){var n=new i(t),a=s(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(o(t,n))},a}(a);c.Axios=i,c.CanceledError=n(563),c.CancelToken=n(191),c.isCancel=n(864),c.VERSION=n(641).version,c.toFormData=n(440),c.AxiosError=n(845),c.Cancel=c.CanceledError,c.all=function(e){return Promise.all(e)},c.spread=n(980),c.isAxiosError=n(19),c.formToJSON=function(e){return u(r.isHTMLForm(e)?new FormData(e):e)},e.exports=c,e.exports.default=c},191:(e,t,n)=>{"use strict";var r=n(563);function s(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){for(var t=n._listeners.length;t-- >0;)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,s,i){n.reason||(n.reason=new r(e,s,i),t(n.reason))}))}s.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},s.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},s.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},s.source=function(){var e;return{token:new s((function(t){e=t})),cancel:e}},e.exports=s},563:(e,t,n)=>{"use strict";var r=n(845);function s(e,t,n){r.call(this,null==e?"canceled":e,r.ERR_CANCELED,t,n),this.name="CanceledError"}n(516).inherits(s,r,{__CANCEL__:!0}),e.exports=s},864:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},155:(e,t,n)=>{"use strict";var r=n(516),s=n(106),i=n(471),o=n(490),a=n(343),u=n(615),c=n(841),l=c.validators;function d(e){this.defaults=e,this.interceptors={request:new i,response:new i}}d.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&c.assertOptions(n,{silentJSONParsing:l.transitional(l.boolean),forcedJSONParsing:l.transitional(l.boolean),clarifyTimeoutError:l.transitional(l.boolean)},!1);var s=t.paramsSerializer;void 0!==s&&c.assertOptions(s,{encode:l.function,serialize:l.function},!0),r.isFunction(s)&&(t.paramsSerializer={serialize:s});var i=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));var d,f=[];if(this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)})),!u){var p=[o,void 0];for(Array.prototype.unshift.apply(p,i),p=p.concat(f),d=Promise.resolve(t);p.length;)d=d.then(p.shift(),p.shift());return d}for(var h=t;i.length;){var g=i.shift(),m=i.shift();try{h=g(h)}catch(e){m(e);break}}try{d=o(h)}catch(e){return Promise.reject(e)}for(;f.length;)d=d.then(f.shift(),f.shift());return d},d.prototype.getUri=function(e){e=a(this.defaults,e);var t=u(e.baseURL,e.url);return s(t,e.params,e.paramsSerializer)},r.forEach(["delete","get","head","options"],(function(e){d.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,s){return this.request(a(s||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}d.prototype[e]=t(),d.prototype[e+"Form"]=t(!0)})),e.exports=d},845:(e,t,n)=>{"use strict";var r=n(516);function s(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}r.inherits(s,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var i=s.prototype,o={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){o[e]={value:e}})),Object.defineProperties(s,o),Object.defineProperty(i,"isAxiosError",{value:!0}),s.from=function(e,t,n,o,a,u){var c=Object.create(i);return r.toFlatObject(e,c,(function(e){return e!==Error.prototype})),s.call(c,e.message,t,n,o,a),c.cause=e,c.name=e.name,u&&Object.assign(c,u),c},e.exports=s},471:(e,t,n)=>{"use strict";var r=n(516);function s(){this.handlers=[]}s.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},s.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},s.prototype.clear=function(){this.handlers&&(this.handlers=[])},s.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=s},615:(e,t,n)=>{"use strict";var r=n(137),s=n(680);e.exports=function(e,t){return e&&!r(t)?s(e,t):t}},490:(e,t,n)=>{"use strict";var r=n(516),s=n(881),i=n(864),o=n(412),a=n(563),u=n(18);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(e){return c(e),e.headers=e.headers||{},e.data=s.call(e,e.data,e.headers,null,e.transformRequest),u(e.headers,"Accept"),u(e.headers,"Content-Type"),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||o.adapter)(e).then((function(t){return c(e),t.data=s.call(e,t.data,t.headers,t.status,e.transformResponse),t}),(function(t){return i(t)||(c(e),t&&t.response&&(t.response.data=s.call(e,t.response.data,t.response.headers,t.response.status,e.transformResponse))),Promise.reject(t)}))}},343:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e,t){t=t||{};var n={};function s(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isEmptyObject(t)?r.merge({},e):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:s(void 0,e[n]):s(e[n],t[n])}function o(e){if(!r.isUndefined(t[e]))return s(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:s(void 0,e[n]):s(void 0,t[n])}function u(n){return n in t?s(e[n],t[n]):n in e?s(void 0,e[n]):void 0}var c={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,s=t(e);r.isUndefined(s)&&t!==u||(n[e]=s)})),n}},522:(e,t,n)=>{"use strict";var r=n(845);e.exports=function(e,t,n){var s=n.config.validateStatus;n.status&&s&&!s(n.status)?t(new r("Request failed with status code "+n.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}},881:(e,t,n)=>{"use strict";var r=n(516),s=n(412);e.exports=function(e,t,n,i){var o=this||s;return r.forEach(i,(function(r){e=r.call(o,e,t,n)})),e}},412:(e,t,n)=>{"use strict";var r=n(516),s=n(18),i=n(845),o=n(896),a=n(440),u=n(69),c=n(721),l=n(298),d={"Content-Type":"application/x-www-form-urlencoded"};function f(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var p,h={transitional:o,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(p=n(592)),p),transformRequest:[function(e,t){s(t,"Accept"),s(t,"Content-Type");var n,i=t&&t["Content-Type"]||"",o=i.indexOf("application/json")>-1,c=r.isObject(e);if(c&&r.isHTMLForm(e)&&(e=new FormData(e)),r.isFormData(e))return o?JSON.stringify(l(e)):e;if(r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e))return e;if(r.isArrayBufferView(e))return e.buffer;if(r.isURLSearchParams(e))return f(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(c){if(-1!==i.indexOf("application/x-www-form-urlencoded"))return u(e,this.formSerializer).toString();if((n=r.isFileList(e))||i.indexOf("multipart/form-data")>-1){var d=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,d&&new d,this.formSerializer)}}return c||o?(f(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(0,JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||h.transitional,n=t&&t.forcedJSONParsing,s="json"===this.responseType;if(e&&r.isString(e)&&(n&&!this.responseType||s)){var o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw i.from(e,i.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:c.classes.FormData,Blob:c.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){h.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){h.headers[e]=r.merge(d)})),e.exports=h},896:e=>{"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},786:(e,t,n)=>{e.exports=n(894)},641:e=>{e.exports={version:"0.28.1"}},170:(e,t,n)=>{"use strict";var r=n(440);function s(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,(function(e){return t[e]}))}function i(e,t){this._pairs=[],e&&r(e,this,t)}var o=i.prototype;o.append=function(e,t){this._pairs.push([e,t])},o.toString=function(e){var t=e?function(t){return e.call(this,t,s)}:s;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")},e.exports=i},12:e=>{"use strict";e.exports=function(e,t){return function(){return e.apply(t,arguments)}}},106:(e,t,n)=>{"use strict";var r=n(516),s=n(170);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o));var a,u=n&&n.encode||i,c=n&&n.serialize;return(a=c?c(t,n):r.isURLSearchParams(t)?t.toString():new s(t,n).toString(u))&&(e+=(-1===e.indexOf("?")?"?":"&")+a),e}},680:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},948:(e,t,n)=>{"use strict";var r=n(516);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,s,i,o){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(s)&&a.push("path="+s),r.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},298:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e){function t(e,n,s,i){var o=e[i++],a=Number.isFinite(+o),u=i>=e.length;return o=!o&&r.isArray(s)?s.length:o,u?(r.hasOwnProperty(s,o)?s[o]=[s[o],n]:s[o]=n,!a):(s[o]&&r.isObject(s[o])||(s[o]=[]),t(e,n,s[o],i)&&r.isArray(s[o])&&(s[o]=function(e){var t,n,r={},s=Object.keys(e),i=s.length;for(t=0;t<i;t++)r[n=s[t]]=e[n];return r}(s[o])),!a)}if(r.isFormData(e)&&r.isFunction(e.entries)){var n={};return r.forEachEntry(e,(function(e,s){t(function(e){return r.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),s,n,0)})),n}return null}},137:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},19:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}},202:(e,t,n)=>{"use strict";var r=n(516);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function s(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=s(window.location.href),function(t){var n=r.isString(t)?s(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},18:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},631:(e,t,n)=>{"use strict";var r=n(516),s=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.slice(0,i)).toLowerCase(),n=r.trim(e.slice(i+1)),t){if(o[t]&&s.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o}},656:e=>{"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},980:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},440:(e,t,n)=>{"use strict";var r=n(516),s=n(845),i=n(786);function o(e){return r.isPlainObject(e)||r.isArray(e)}function a(e){return r.endsWith(e,"[]")?e.slice(0,-2):e}function u(e,t,n){return e?e.concat(t).map((function(e,t){return e=a(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var c=r.toFlatObject(r,{},null,(function(e){return/^is[A-Z]/.test(e)}));e.exports=function(e,t,n){if(!r.isObject(e))throw new TypeError("target must be an object");t=t||new(i||FormData);var l,d=(n=r.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!r.isUndefined(t[e])}))).metaTokens,f=n.visitor||v,p=n.dots,h=n.indexes,g=(n.Blob||"undefined"!=typeof Blob&&Blob)&&(l=t)&&r.isFunction(l.append)&&"FormData"===l[Symbol.toStringTag]&&l[Symbol.iterator];if(!r.isFunction(f))throw new TypeError("visitor must be a function");function m(e){if(null===e)return"";if(r.isDate(e))return e.toISOString();if(!g&&r.isBlob(e))throw new s("Blob is not supported. Use a Buffer instead.");return r.isArrayBuffer(e)||r.isTypedArray(e)?g&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function v(e,n,s){var i=e;if(e&&!s&&"object"==typeof e)if(r.endsWith(n,"{}"))n=d?n:n.slice(0,-2),e=JSON.stringify(e);else if(r.isArray(e)&&function(e){return r.isArray(e)&&!e.some(o)}(e)||r.isFileList(e)||r.endsWith(n,"[]")&&(i=r.toArray(e)))return n=a(n),i.forEach((function(e,s){!r.isUndefined(e)&&t.append(!0===h?u([n],s,p):null===h?n:n+"[]",m(e))})),!1;return!!o(e)||(t.append(u(s,n,p),m(e)),!1)}var y=[],b=Object.assign(c,{defaultVisitor:v,convertValue:m,isVisitable:o});if(!r.isObject(e))throw new TypeError("data must be an object");return function e(n,s){if(!r.isUndefined(n)){if(-1!==y.indexOf(n))throw Error("Circular reference detected in "+s.join("."));y.push(n),r.forEach(n,(function(n,i){!0===(!r.isUndefined(n)&&f.call(t,n,r.isString(i)?i.trim():i,s,b))&&e(n,s?s.concat(i):[i])})),y.pop()}}(e),t}},69:(e,t,n)=>{"use strict";var r=n(516),s=n(440),i=n(721);e.exports=function(e,t){return s(e,new i.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,s){return i.isNode&&r.isBuffer(e)?(this.append(t,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}},841:(e,t,n)=>{"use strict";var r=n(641).version,s=n(845),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,a){if(!1===e)throw new s(i(r," has been removed"+(t?" in "+t:"")),s.ERR_DEPRECATED);return t&&!o[r]&&(o[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,a)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new s("options must be an object",s.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],a=t[o];if(a){var u=e[o],c=void 0===u||a(u,o,e);if(!0!==c)throw new s("option "+o+" must be "+c,s.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new s("Unknown option "+o,s.ERR_BAD_OPTION)}},validators:i}},243:e=>{"use strict";e.exports=FormData},2:(e,t,n)=>{"use strict";var r=n(170);e.exports="undefined"!=typeof URLSearchParams?URLSearchParams:r},109:(e,t,n)=>{"use strict";e.exports={isBrowser:!0,classes:{URLSearchParams:n(2),FormData:n(243),Blob},protocols:["http","https","file","blob","url","data"]}},721:(e,t,n)=>{"use strict";e.exports=n(109)},516:(e,t,n)=>{"use strict";var r,s=n(12),i=Object.prototype.toString,o=(r=Object.create(null),function(e){var t=i.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())});function a(e){return e=e.toLowerCase(),function(t){return o(t)===e}}function u(e){return Array.isArray(e)}function c(e){return void 0===e}var l=a("ArrayBuffer");function d(e){return"number"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==o(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var h=a("Date"),g=a("File"),m=a("Blob"),v=a("FileList");function y(e){return"[object Function]"===i.call(e)}var b=a("URLSearchParams");function w(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),u(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}var x,E,R=(x="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return x&&e instanceof x}),O=a("HTMLFormElement"),S=(E=Object.prototype.hasOwnProperty,function(e,t){return E.call(e,t)});e.exports={isArray:u,isArrayBuffer:l,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||i.call(e)===t||y(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&l(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:d,isObject:f,isPlainObject:p,isEmptyObject:function(e){return e&&0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype},isUndefined:c,isDate:h,isFile:g,isBlob:m,isFunction:y,isStream:function(e){return f(e)&&y(e.pipe)},isURLSearchParams:b,isStandardBrowserEnv:function(){var e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:w,merge:function e(){var t={};function n(n,r){p(t[r])&&p(n)?t[r]=e(t[r],n):p(n)?t[r]=e({},n):u(n)?t[r]=n.slice():t[r]=n}for(var r=0,s=arguments.length;r<s;r++)w(arguments[r],n);return t},extend:function(e,t,n){return w(t,(function(t,r){e[r]=n&&"function"==typeof t?s(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var s,i,o,a={};if(t=t||{},null==e)return t;do{for(i=(s=Object.getOwnPropertyNames(e)).length;i-- >0;)o=s[i],r&&!r(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==n&&Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:a,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(u(e))return e;var t=e.length;if(!d(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:R,isFileList:v,forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var s=n.value;t.call(e,s[0],s[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:O,hasOwnProperty:S}},894:e=>{e.exports="object"==typeof self?self.FormData:window.FormData},520:(e,t,n)=>{"use strict";n.d(t,{A:()=>ae});class r{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function s(e){ae.config.logging&&console.log(`Gist: ${e}`)}function i(e,t,n){const r={value:t,expiry:n};localStorage.setItem(e,JSON.stringify(r))}function o(e){const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t),r=new Date,s=new Date(n.expiry);return r.getTime()>s.getTime()?(localStorage.removeItem(e),null):n.value}function a(e){localStorage.removeItem(e)}var u,c=new Uint8Array(16);function l(){if(!u&&!(u="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(c)}const d=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],p=0;p<256;++p)f.push((p+256).toString(16).substr(1));const h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&d.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},g=function(e,t,n){var r=(e=e||{}).random||(e.rng||l)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=r[s];return t}return h(r)},m="gist.web.userToken",v="gist.web.guestUserToken",y="gist.web.usingGuestUserToken";function b(){return o(m)}function w(){var e=new Date;if(e.setDate(e.getDate()+365),null===b()){var t=o(v);null==t&&(t=g(),i(v,t,e),s(`Set guest user token "${t}" with expiry date set to 1 year from today`)),i(m,t,e),i(y,!0,e)}}var x=n(505),E=n.n(x);const R={ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://gist-queue-consumer-api.cloud.gist.build",dev:"https://gist-queue-consumer-api.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/2.0",dev:"https://renderer.gist.build/2.0",local:"http://app.local.gist.build:8080/web"}};function O(){var e={"X-CIO-Site-Id":ae.config.siteId,"X-CIO-Datacenter":ae.config.dataCenter},t=b();return null!=t&&(e["X-Gist-Encoded-User-Token"]=btoa(t)),E().create({baseURL:R.GIST_QUEUE_API_ENDPOINT[ae.config.env],timeout:2e4,headers:e})}var S=600,I=!1;const T="gist.web.userQueueNextPullCheck";function A(e){var t="",n="",r="",s=!1,i=!1,o=!1,a=!1,u=null,c=!1,l="#00000033",d=414,f=!1;return e.properties&&e.properties.gist&&(e.properties.gist.campaignId&&(u=e.properties.gist.campaignId),e.properties.gist.elementId&&(t=e.properties.gist.elementId,s=!0),e.properties.gist.routeRuleWeb&&(n=e.properties.gist.routeRuleWeb,i=!0),e.properties.gist.position&&(r=e.properties.gist.position,o=!0),e.properties.gist.scale&&(a=e.properties.gist.scale),e.properties.gist.overlayColor&&(l=e.properties.gist.overlayColor),e.properties.gist.messageWidth&&e.properties.gist.messageWidth>0&&(d=e.properties.gist.messageWidth,f=!0),e.properties.gist.persistent&&(c=!0)),{isEmbedded:s,elementId:t,hasRouteRule:i,routeRule:n,position:r,hasPosition:o,shouldScale:a,campaignId:u,messageWidth:d,overlayColor:l,persistent:c,hasCustomWidth:f}}var D=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];const C=e=>new Promise((t=>setTimeout(t,e))),N=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function P(e){var t=U(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function j(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function _(e){return`gist-${e}`}function k(){var e=document.querySelector(".gist-message");e&&e.classList.add("visible")}function U(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}var L=[];async function $(e){if(ae.isDocumentVisible){if(ae.overlayInstanceId)return s(`Message ${ae.overlayInstanceId} already showing.`),null;var t=A(e);return e.instanceId=g(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),ae.overlayInstanceId=e.instanceId,ae.currentMessages.push(e),V(e)}return s("Document hidden, not showing message now."),null}async function B(e,t){return ae.isDocumentVisible?(e.instanceId=g(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!P(t),e.renderStartTime=(new Date).getTime(),ae.currentMessages.push(e),V(e,t)):(s("Document hidden, not showing message now."),null)}async function F(e){e?(ae.messageDismissed(e),e.overlay?await W(!0,e):M(e)):s(`Message with instance id: ${instanceId} not found`)}async function q(e){var t=A(e);e?t.persistent&&(s("Persistent message dismissed, logging view"),await z(e)):s(`Message with instance id: ${instanceId} not found`)}function M(e){var t;G(e.instanceId),(t=U(e.elementId))&&(t.classList.remove("gist-visible"),t.style.removeProperty("height"),t.innerHTML="")}async function W(e,t){G(t.instanceId),ae.overlayInstanceId=null,e?await async function(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("visible"),await C(300)),j()}():j(),0==ae.currentMessages.length&&(window.removeEventListener("message",Q),window.removeEventListener("touchstart",X))}function V(e,t=null){if(t&&function(e){var t=U(e);return!(!t||!t.classList.contains("gist-visible"))}(t))return s(`Message ${e.messageId} already showing in element ${t}.`),null;var n,r,i={endpoint:R.ENGINE_API_ENDPOINT[ae.config.env],siteId:ae.config.siteId,dataCenter:ae.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties},o=`${R.GIST_VIEW_ENDPOINT[ae.config.env]}/index.html?options=${n=JSON.stringify(i),r=btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode("0x"+t)}))),encodeURIComponent(r)}`;return window.addEventListener("message",Q),window.addEventListener("touchstart",X),t?(D.includes(t)&&function(e){const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),s("Top & bottom elements injected into page")}(t),function(e,t,n){var r=U(e);if(r){r.classList.add(_(n.instanceId));var i=A(n),o=i.messageWidth+"px";N.includes(e)&&!i.hasCustomWidth&&(o="100%"),D.includes(e)&&(r.style.width=o),P(e)||(r.style.height="0px"),r.innerHTML=function(e,t,n){var r=function(e,t,n){var r=800;return t.messageWidth>r&&(r=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n @media (max-width: ${r}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(_(t.instanceId),n,e);return r}(t,n,i)}else s(`Message could not be embedded, elementId ${e} not found.`)}(t,o,e)):function(e,t){document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=A(t),r=function(e,t,n){var r=600;return t.messageWidth>r&&(r=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.background.visible {\n visibility: visible;\n }\n #gist-overlay.background.is-blacked-out {\n display: block;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.bottom {\n bottom: 0;\n }\n .gist-message.top {\n top: 0;\n }\n @media (max-width: ${r}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(_(t.instanceId),n,e);return r}(e,t))}(o,e),e}async function z(e){s(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(function(e){L.push(e);var t=oe();null!=t&&t.length>0&&ie(t.filter((t=>t.queueId!==e.queueId)))}(e),t=await async function(e){try{return await O().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}(e.queueId)):t=await async function(e){try{return await O().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?s("Message view logged"):s(`Problem logging message: ${t.status}`)}function H(e){return ae.currentMessages.find((t=>t.instanceId===e))}function G(e){ae.currentMessages=ae.currentMessages.filter((t=>t.instanceId!==e))}function J(e,t){G(e),ae.currentMessages.push(t)}function X(e){}async function Q(e){if(e.data.gist){var t=e.data.gist.instanceId,n=H(t);if(!n)return;var r=A(n);switch(e.data.gist.method){case"routeLoaded":var i=.001*((new Date).getTime()-n.renderStartTime);s(`Engine render for message: ${n.messageId} timer elapsed in ${i.toFixed(3)} seconds`),n.currentRoute=e.data.gist.parameters.route,n.firstLoad&&(n.overlay?function(e){var t=document.querySelector("#gist-overlay");if(t){t.classList.add("visible");var n=document.querySelector(".gist-message");e.position?n.classList.add(e.position):n.classList.add("center"),setTimeout(k,100)}else j()}(n):(d=U(n.elementId))&&d.classList.add("gist-visible"),ae.messageShown(n),r.persistent?s("Persistent message shown, skipping logging view"):await z(n),n.firstLoad=!1),J(t,n);break;case"tap":var o=e.data.gist.parameters.action,a=e.data.gist.parameters.name;if(ae.messageAction(n,o,a),e.data.gist.parameters.system&&!r.persistent){await F(n);break}try{if((l=new URL(o))&&"gist:"===l.protocol)switch(l.href.replace("gist://","").split("?")[0]){case"close":await F(n),await q(n),await re();break;case"showMessage":var u=l.searchParams.get("messageId"),c=l.searchParams.get("properties");u&&(c&&(c=JSON.parse(atob(c))),await ae.showMessage({messageId:u,properties:c}));break;case"loadPage":var l;(l=l.href.substring(l.href.indexOf("?url=")+5))&&(l.startsWith("https://")||l.startsWith("http://")||l.startsWith("/")?window.location.href=l:window.location.href=window.location+l)}}catch(e){}break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),J(t,n),s(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":s(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=U(e.elementId?e.elementId:_(e.instanceId));if(n){var r=n.style;if(t.height>0)if(t.height>window.innerHeight){var s=1-(t.height/window.innerHeight-1);e.shouldScale&&s>=.4?(r.height=`${t.height}px`,r.transform=`translateX(-50%) translateY(-50%) scale(${s})`):r.height=`${window.innerHeight}px`}else r.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":s(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=U(_(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":ae.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":ae.messageError(n),ae.overlayInstanceId?W(!1,n):M(n)}}var d}const K="gist.web.userQueue",Y=36e5;var Z=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Z(e,t)))),ee=!1,te=[];async function ne(){ee?await re():(async function(){var e=`G${g().substring(0,8)}`,t=document.createElement("div");t.setAttribute("id",e),t.style.display="none",document.body.appendChild(t),await C(5e3),B({messageId:""},e)}(),b()?(s("Queue watcher started"),ee=!0,Z((()=>new Promise((()=>async function(){if(b())if(ae.isDocumentVisible)if(null===o(T)){var e=await async function(){var e;try{if(!I){var t=(new Date).getTime();I=!0,e=await O().post(`/api/v1/users?timestamp=${t}`,{})}}catch(t){t.response?e=t.response:s(`Error getting user queue: ${t}`)}finally{return I=!1,function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(S=t)}var n=new Date((new Date).getTime()+1e3*S);i(T,S,n)}(e),e}}(),t=[];e?(200===e.status||204===e.status?(s("200 response, updating local store."),ie(t=e.data)):304===e.status&&(s("304 response, using local store."),t=oe()),t&&t.length>0?(s(`Message queue checked for user ${b()}, ${t.length} messages found.`),te=t,await re()):(te=[],s("No messages for user token."))):s("There was an error while checking message queue.")}else s("Next queue pull scheduled for later");else s("Document not visible, skipping queue check.");else s("User token reset, skipping queue check.")}()))),1e3)):s("User token not setup, queue not started."))}async function re(){s(`Messages in local queue: ${te.length}`);var e=[],t=te.sort(((e,t)=>e.priority-t.priority));for(const i of t)if(!await se(i)){var n=e.find((e=>e.queueId===i.queueId)),r=ae.currentMessages.find((e=>e.queueId===i.queueId));n||r?s(`Message with queueId: ${i.queueId} already in queue, discarding.`):e.push(i)}te=e}async function se(e){if(!function(e){return void 0!==L.find((t=>t.queueId===e.queueId))}(e)){var t=A(e);if(t.hasRouteRule){var n=ae.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var r=t.routeRule;if(s(`Verifying route against rule: ${r}`),!new RegExp(r).test(n))return s(`Route ${n} does not match rule.`),!1}return t.hasPosition&&(e.position=t.position),t.isEmbedded?await B(e,t.elementId):await $(e)}s(`Message with ${e.queueId} has been shown before, skipping.`)}function ie(e){var t=new Date((new Date).getTime()+Y);i(K,e,t)}function oe(){return o(K)}const ae=class{static async setup(e){this.events=new r,this.config={useGuestSession:void 0!==e.useGuestSession&&e.useGuestSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,s(`Setup complete on ${this.config.env} environment.`),this.config.useGuestSession&&w(),await ne(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await re())}),!1)}static async setCurrentRoute(e){this.currentRoute=e,s(`Current route set to: ${e}`),await re()}static async setUserToken(e,t){!function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),i(m,e,t),a(y),s(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),await ne()}static async clearUserToken(){a(m),s("Cleared user token"),this.config.useGuestSession&&w(),await ne()}static async dismissMessage(e){var t=H(e);await F(t),await q(t),await re()}static async embedMessage(e,t){var n=await B(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await $(e);return t?t.instanceId:null}static messageShown(e){s(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(s(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){s(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){s(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}}},44:(e,t,n)=>{const r=n(520).A;e.exports=r}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(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=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(44)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,(()=>(()=>{var e={505:(e,t,n)=>{e.exports=n(15)},592:(e,t,n)=>{"use strict";var r=n(516),s=n(522),i=n(948),o=n(106),a=n(615),u=n(631),c=n(202),l=n(896),f=n(845),d=n(563),p=n(656),g=n(721);e.exports=function(e){return new Promise((function(t,n){var h,m=e.data,v=e.headers,y=e.responseType,w=e.withXSRFToken;function b(){e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener("abort",h)}r.isFormData(m)&&r.isStandardBrowserEnv()&&delete v["Content-Type"];var x=new XMLHttpRequest;if(e.auth){var E=e.auth.username||"",S=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(E+":"+S)}var R=a(e.baseURL,e.url);function O(){if(x){var r="getAllResponseHeaders"in x?u(x.getAllResponseHeaders()):null,i={data:y&&"text"!==y&&"json"!==y?x.response:x.responseText,status:x.status,statusText:x.statusText,headers:r,config:e,request:x};s((function(e){t(e),b()}),(function(e){n(e),b()}),i),x=null}}if(x.open(e.method.toUpperCase(),o(R,e.params,e.paramsSerializer),!0),x.timeout=e.timeout,"onloadend"in x?x.onloadend=O:x.onreadystatechange=function(){x&&4===x.readyState&&(0!==x.status||x.responseURL&&0===x.responseURL.indexOf("file:"))&&setTimeout(O)},x.onabort=function(){x&&(n(new f("Request aborted",f.ECONNABORTED,e,x)),x=null)},x.onerror=function(){n(new f("Network Error",f.ERR_NETWORK,e,x)),x=null},x.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new f(t,r.clarifyTimeoutError?f.ETIMEDOUT:f.ECONNABORTED,e,x)),x=null},r.isStandardBrowserEnv()&&(w&&r.isFunction(w)&&(w=w(e)),w||!1!==w&&c(R))){var I=e.xsrfHeaderName&&e.xsrfCookieName&&i.read(e.xsrfCookieName);I&&(v[e.xsrfHeaderName]=I)}"setRequestHeader"in x&&r.forEach(v,(function(e,t){void 0===m&&"content-type"===t.toLowerCase()?delete v[t]:x.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(x.withCredentials=!!e.withCredentials),y&&"json"!==y&&(x.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&x.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&x.upload&&x.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(h=function(t){x&&(n(!t||t.type?new d(null,e,x):t),x.abort(),x=null)},e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener("abort",h))),m||!1===m||0===m||""===m||(m=null);var T=p(R);T&&-1===g.protocols.indexOf(T)?n(new f("Unsupported protocol "+T+":",f.ERR_BAD_REQUEST,e)):x.send(m)}))}},15:(e,t,n)=>{"use strict";var r=n(516),s=n(12),i=n(155),o=n(343),a=n(412),u=n(298),c=function e(t){var n=new i(t),a=s(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(o(t,n))},a}(a);c.Axios=i,c.CanceledError=n(563),c.CancelToken=n(191),c.isCancel=n(864),c.VERSION=n(641).version,c.toFormData=n(440),c.AxiosError=n(845),c.Cancel=c.CanceledError,c.all=function(e){return Promise.all(e)},c.spread=n(980),c.isAxiosError=n(19),c.formToJSON=function(e){return u(r.isHTMLForm(e)?new FormData(e):e)},e.exports=c,e.exports.default=c},191:(e,t,n)=>{"use strict";var r=n(563);function s(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){for(var t=n._listeners.length;t-- >0;)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,s,i){n.reason||(n.reason=new r(e,s,i),t(n.reason))}))}s.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},s.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},s.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},s.source=function(){var e;return{token:new s((function(t){e=t})),cancel:e}},e.exports=s},563:(e,t,n)=>{"use strict";var r=n(845);function s(e,t,n){r.call(this,null==e?"canceled":e,r.ERR_CANCELED,t,n),this.name="CanceledError"}n(516).inherits(s,r,{__CANCEL__:!0}),e.exports=s},864:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},155:(e,t,n)=>{"use strict";var r=n(516),s=n(106),i=n(471),o=n(490),a=n(343),u=n(615),c=n(841),l=c.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&c.assertOptions(n,{silentJSONParsing:l.transitional(l.boolean),forcedJSONParsing:l.transitional(l.boolean),clarifyTimeoutError:l.transitional(l.boolean)},!1);var s=t.paramsSerializer;void 0!==s&&c.assertOptions(s,{encode:l.function,serialize:l.function},!0),r.isFunction(s)&&(t.paramsSerializer={serialize:s});var i=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));var f,d=[];if(this.interceptors.response.forEach((function(e){d.push(e.fulfilled,e.rejected)})),!u){var p=[o,void 0];for(Array.prototype.unshift.apply(p,i),p=p.concat(d),f=Promise.resolve(t);p.length;)f=f.then(p.shift(),p.shift());return f}for(var g=t;i.length;){var h=i.shift(),m=i.shift();try{g=h(g)}catch(e){m(e);break}}try{f=o(g)}catch(e){return Promise.reject(e)}for(;d.length;)f=f.then(d.shift(),d.shift());return f},f.prototype.getUri=function(e){e=a(this.defaults,e);var t=u(e.baseURL,e.url);return s(t,e.params,e.paramsSerializer)},r.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,s){return this.request(a(s||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}f.prototype[e]=t(),f.prototype[e+"Form"]=t(!0)})),e.exports=f},845:(e,t,n)=>{"use strict";var r=n(516);function s(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}r.inherits(s,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var i=s.prototype,o={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){o[e]={value:e}})),Object.defineProperties(s,o),Object.defineProperty(i,"isAxiosError",{value:!0}),s.from=function(e,t,n,o,a,u){var c=Object.create(i);return r.toFlatObject(e,c,(function(e){return e!==Error.prototype})),s.call(c,e.message,t,n,o,a),c.cause=e,c.name=e.name,u&&Object.assign(c,u),c},e.exports=s},471:(e,t,n)=>{"use strict";var r=n(516);function s(){this.handlers=[]}s.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},s.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},s.prototype.clear=function(){this.handlers&&(this.handlers=[])},s.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=s},615:(e,t,n)=>{"use strict";var r=n(137),s=n(680);e.exports=function(e,t){return e&&!r(t)?s(e,t):t}},490:(e,t,n)=>{"use strict";var r=n(516),s=n(881),i=n(864),o=n(412),a=n(563),u=n(18);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a}e.exports=function(e){return c(e),e.headers=e.headers||{},e.data=s.call(e,e.data,e.headers,null,e.transformRequest),u(e.headers,"Accept"),u(e.headers,"Content-Type"),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||o.adapter)(e).then((function(t){return c(e),t.data=s.call(e,t.data,t.headers,t.status,e.transformResponse),t}),(function(t){return i(t)||(c(e),t&&t.response&&(t.response.data=s.call(e,t.response.data,t.response.headers,t.response.status,e.transformResponse))),Promise.reject(t)}))}},343:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e,t){t=t||{};var n={};function s(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isEmptyObject(t)?r.merge({},e):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:s(void 0,e[n]):s(e[n],t[n])}function o(e){if(!r.isUndefined(t[e]))return s(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:s(void 0,e[n]):s(void 0,t[n])}function u(n){return n in t?s(e[n],t[n]):n in e?s(void 0,e[n]):void 0}var c={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,s=t(e);r.isUndefined(s)&&t!==u||(n[e]=s)})),n}},522:(e,t,n)=>{"use strict";var r=n(845);e.exports=function(e,t,n){var s=n.config.validateStatus;n.status&&s&&!s(n.status)?t(new r("Request failed with status code "+n.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}},881:(e,t,n)=>{"use strict";var r=n(516),s=n(412);e.exports=function(e,t,n,i){var o=this||s;return r.forEach(i,(function(r){e=r.call(o,e,t,n)})),e}},412:(e,t,n)=>{"use strict";var r=n(516),s=n(18),i=n(845),o=n(896),a=n(440),u=n(69),c=n(721),l=n(298),f={"Content-Type":"application/x-www-form-urlencoded"};function d(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var p,g={transitional:o,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(p=n(592)),p),transformRequest:[function(e,t){s(t,"Accept"),s(t,"Content-Type");var n,i=t&&t["Content-Type"]||"",o=i.indexOf("application/json")>-1,c=r.isObject(e);if(c&&r.isHTMLForm(e)&&(e=new FormData(e)),r.isFormData(e))return o?JSON.stringify(l(e)):e;if(r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e))return e;if(r.isArrayBufferView(e))return e.buffer;if(r.isURLSearchParams(e))return d(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(c){if(-1!==i.indexOf("application/x-www-form-urlencoded"))return u(e,this.formSerializer).toString();if((n=r.isFileList(e))||i.indexOf("multipart/form-data")>-1){var f=this.env&&this.env.FormData;return a(n?{"files[]":e}:e,f&&new f,this.formSerializer)}}return c||o?(d(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(0,JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||g.transitional,n=t&&t.forcedJSONParsing,s="json"===this.responseType;if(e&&r.isString(e)&&(n&&!this.responseType||s)){var o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw i.from(e,i.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:c.classes.FormData,Blob:c.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){g.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){g.headers[e]=r.merge(f)})),e.exports=g},896:e=>{"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},786:(e,t,n)=>{e.exports=n(894)},641:e=>{e.exports={version:"0.28.1"}},170:(e,t,n)=>{"use strict";var r=n(440);function s(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,(function(e){return t[e]}))}function i(e,t){this._pairs=[],e&&r(e,this,t)}var o=i.prototype;o.append=function(e,t){this._pairs.push([e,t])},o.toString=function(e){var t=e?function(t){return e.call(this,t,s)}:s;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")},e.exports=i},12:e=>{"use strict";e.exports=function(e,t){return function(){return e.apply(t,arguments)}}},106:(e,t,n)=>{"use strict";var r=n(516),s=n(170);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o));var a,u=n&&n.encode||i,c=n&&n.serialize;return(a=c?c(t,n):r.isURLSearchParams(t)?t.toString():new s(t,n).toString(u))&&(e+=(-1===e.indexOf("?")?"?":"&")+a),e}},680:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},948:(e,t,n)=>{"use strict";var r=n(516);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,s,i,o){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(s)&&a.push("path="+s),r.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},298:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e){function t(e,n,s,i){var o=e[i++],a=Number.isFinite(+o),u=i>=e.length;return o=!o&&r.isArray(s)?s.length:o,u?(r.hasOwnProperty(s,o)?s[o]=[s[o],n]:s[o]=n,!a):(s[o]&&r.isObject(s[o])||(s[o]=[]),t(e,n,s[o],i)&&r.isArray(s[o])&&(s[o]=function(e){var t,n,r={},s=Object.keys(e),i=s.length;for(t=0;t<i;t++)r[n=s[t]]=e[n];return r}(s[o])),!a)}if(r.isFormData(e)&&r.isFunction(e.entries)){var n={};return r.forEachEntry(e,(function(e,s){t(function(e){return r.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),s,n,0)})),n}return null}},137:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},19:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}},202:(e,t,n)=>{"use strict";var r=n(516);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function s(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=s(window.location.href),function(t){var n=r.isString(t)?s(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},18:(e,t,n)=>{"use strict";var r=n(516);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},631:(e,t,n)=>{"use strict";var r=n(516),s=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.slice(0,i)).toLowerCase(),n=r.trim(e.slice(i+1)),t){if(o[t]&&s.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o}},656:e=>{"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},980:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},440:(e,t,n)=>{"use strict";var r=n(516),s=n(845),i=n(786);function o(e){return r.isPlainObject(e)||r.isArray(e)}function a(e){return r.endsWith(e,"[]")?e.slice(0,-2):e}function u(e,t,n){return e?e.concat(t).map((function(e,t){return e=a(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var c=r.toFlatObject(r,{},null,(function(e){return/^is[A-Z]/.test(e)}));e.exports=function(e,t,n){if(!r.isObject(e))throw new TypeError("target must be an object");t=t||new(i||FormData);var l,f=(n=r.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!r.isUndefined(t[e])}))).metaTokens,d=n.visitor||v,p=n.dots,g=n.indexes,h=(n.Blob||"undefined"!=typeof Blob&&Blob)&&(l=t)&&r.isFunction(l.append)&&"FormData"===l[Symbol.toStringTag]&&l[Symbol.iterator];if(!r.isFunction(d))throw new TypeError("visitor must be a function");function m(e){if(null===e)return"";if(r.isDate(e))return e.toISOString();if(!h&&r.isBlob(e))throw new s("Blob is not supported. Use a Buffer instead.");return r.isArrayBuffer(e)||r.isTypedArray(e)?h&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function v(e,n,s){var i=e;if(e&&!s&&"object"==typeof e)if(r.endsWith(n,"{}"))n=f?n:n.slice(0,-2),e=JSON.stringify(e);else if(r.isArray(e)&&function(e){return r.isArray(e)&&!e.some(o)}(e)||r.isFileList(e)||r.endsWith(n,"[]")&&(i=r.toArray(e)))return n=a(n),i.forEach((function(e,s){!r.isUndefined(e)&&t.append(!0===g?u([n],s,p):null===g?n:n+"[]",m(e))})),!1;return!!o(e)||(t.append(u(s,n,p),m(e)),!1)}var y=[],w=Object.assign(c,{defaultVisitor:v,convertValue:m,isVisitable:o});if(!r.isObject(e))throw new TypeError("data must be an object");return function e(n,s){if(!r.isUndefined(n)){if(-1!==y.indexOf(n))throw Error("Circular reference detected in "+s.join("."));y.push(n),r.forEach(n,(function(n,i){!0===(!r.isUndefined(n)&&d.call(t,n,r.isString(i)?i.trim():i,s,w))&&e(n,s?s.concat(i):[i])})),y.pop()}}(e),t}},69:(e,t,n)=>{"use strict";var r=n(516),s=n(440),i=n(721);e.exports=function(e,t){return s(e,new i.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,s){return i.isNode&&r.isBuffer(e)?(this.append(t,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}},841:(e,t,n)=>{"use strict";var r=n(641).version,s=n(845),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,a){if(!1===e)throw new s(i(r," has been removed"+(t?" in "+t:"")),s.ERR_DEPRECATED);return t&&!o[r]&&(o[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,a)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new s("options must be an object",s.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],a=t[o];if(a){var u=e[o],c=void 0===u||a(u,o,e);if(!0!==c)throw new s("option "+o+" must be "+c,s.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new s("Unknown option "+o,s.ERR_BAD_OPTION)}},validators:i}},243:e=>{"use strict";e.exports=FormData},2:(e,t,n)=>{"use strict";var r=n(170);e.exports="undefined"!=typeof URLSearchParams?URLSearchParams:r},109:(e,t,n)=>{"use strict";e.exports={isBrowser:!0,classes:{URLSearchParams:n(2),FormData:n(243),Blob},protocols:["http","https","file","blob","url","data"]}},721:(e,t,n)=>{"use strict";e.exports=n(109)},516:(e,t,n)=>{"use strict";var r,s=n(12),i=Object.prototype.toString,o=(r=Object.create(null),function(e){var t=i.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())});function a(e){return e=e.toLowerCase(),function(t){return o(t)===e}}function u(e){return Array.isArray(e)}function c(e){return void 0===e}var l=a("ArrayBuffer");function f(e){return"number"==typeof e}function d(e){return null!==e&&"object"==typeof e}function p(e){if("object"!==o(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var g=a("Date"),h=a("File"),m=a("Blob"),v=a("FileList");function y(e){return"[object Function]"===i.call(e)}var w=a("URLSearchParams");function b(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),u(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}var x,E,S=(x="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return x&&e instanceof x}),R=a("HTMLFormElement"),O=(E=Object.prototype.hasOwnProperty,function(e,t){return E.call(e,t)});e.exports={isArray:u,isArrayBuffer:l,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||i.call(e)===t||y(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&l(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:f,isObject:d,isPlainObject:p,isEmptyObject:function(e){return e&&0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype},isUndefined:c,isDate:g,isFile:h,isBlob:m,isFunction:y,isStream:function(e){return d(e)&&y(e.pipe)},isURLSearchParams:w,isStandardBrowserEnv:function(){var e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:b,merge:function e(){var t={};function n(n,r){p(t[r])&&p(n)?t[r]=e(t[r],n):p(n)?t[r]=e({},n):u(n)?t[r]=n.slice():t[r]=n}for(var r=0,s=arguments.length;r<s;r++)b(arguments[r],n);return t},extend:function(e,t,n){return b(t,(function(t,r){e[r]=n&&"function"==typeof t?s(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var s,i,o,a={};if(t=t||{},null==e)return t;do{for(i=(s=Object.getOwnPropertyNames(e)).length;i-- >0;)o=s[i],r&&!r(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==n&&Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:a,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(u(e))return e;var t=e.length;if(!f(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:S,isFileList:v,forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var s=n.value;t.call(e,s[0],s[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:R,hasOwnProperty:O}},894:e=>{e.exports="object"==typeof self?self.FormData:window.FormData},548:(e,t,n)=>{"use strict";n.d(t,{A:()=>ve});class r{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function s(e){ve.config.logging&&console.log(`Gist: ${e}`)}var i,o=new Uint8Array(16);function a(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(o)}const u=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var c=[],l=0;l<256;++l)c.push((l+256).toString(16).substr(1));const f=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&u.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},d=function(e,t,n){var r=(e=e||{}).random||(e.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=r[s];return t}return f(r)},p=365,g="gist.web.isPersistingSession";function h(e,t,n=null){var r=n;r||(r=new Date).setDate(r.getDate()+p);const s={value:t,expiry:r};w().setItem(e,JSON.stringify(s))}function m(e){const t=w().getItem(e);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>new Date(n.expiry).getTime()?(v(e),null):n.value}function v(e){w().removeItem(e)}function y(){const e=sessionStorage.getItem(g);return null===e?(sessionStorage.setItem(g,"true"),!0):"true"===e}function w(){return y()?localStorage:sessionStorage}var b=n(505),x=n.n(b);const E={ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://gist-queue-consumer-api.cloud.gist.build",dev:"https://gist-queue-consumer-api.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/2.0",dev:"https://renderer.gist.build/2.0",local:"http://app.local.gist.build:8080/web"}};function S(){var e=x().create({baseURL:E.GIST_QUEUE_API_ENDPOINT[ve.config.env],timeout:2e4});e.defaults.headers.common["X-CIO-Site-Id"]=ve.config.siteId,e.defaults.headers.common["X-CIO-Client-Platform"]="web";var t=C();return null!=t&&(e.defaults.headers.common["X-Gist-Encoded-User-Token"]=btoa(t)),e}const R="gist.web.userLocale";var O=600,I=!1;const T="gist.web.userQueueNextPullCheck";const A="gist.web.userToken",D="gist.web.usingGuestUserToken",P="gist.web.guestUserToken";function $(){return null!==m(D)}function C(){return m(A)}function N(){if(null===C()){var e=m(P);null==e&&(e=d(),h(P,e),s(`Set guest user token "${e}" with expiry date set to 1 year from today`)),h(A,e),h(D,!0),s(`Using anonymous session with token: "${e}"`)}}async function j(){var e=C();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function U(e){var t="",n="",r="",s=!1,i=!1,o=!1,a=!1,u=null,c=!1,l="#00000033",f=414,d=!1;return e.properties&&e.properties.gist&&(e.properties.gist.campaignId&&(u=e.properties.gist.campaignId),e.properties.gist.elementId&&(t=e.properties.gist.elementId,s=!0),e.properties.gist.routeRuleWeb&&(n=e.properties.gist.routeRuleWeb,i=!0),e.properties.gist.position&&(r=e.properties.gist.position,o=!0),e.properties.gist.scale&&(a=e.properties.gist.scale),e.properties.gist.overlayColor&&(l=e.properties.gist.overlayColor),e.properties.gist.messageWidth&&e.properties.gist.messageWidth>0&&(f=e.properties.gist.messageWidth,d=!0),e.properties.gist.persistent&&(c=!0)),{isEmbedded:s,elementId:t,hasRouteRule:i,routeRule:n,position:r,hasPosition:o,shouldScale:a,campaignId:u,messageWidth:f,overlayColor:l,persistent:c,hasCustomWidth:d}}var k=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];const L=e=>new Promise((t=>setTimeout(t,e))),_=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function B(e){var t=W(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function F(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function q(e){return`gist-${e}`}function M(){var e=document.querySelector(".gist-message");e&&e.classList.add("visible")}function W(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const V="gist.web.message.broadcasts";function H(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}async function z(){const e=await j();return e?`${V}.${e}`:null}function J(e,t){return`${e}.${t}.numberOfTimesShown`}function G(e,t){return`${e}.${t}.shouldShow`}const X="gist.web.message.user";async function Q(){const e=await j();return e?`${X}.${e}`:null}async function K(){const e=await j();return e?`${X}.${e}.seen`:null}async function Y(e){if(ve.isDocumentVisible){if(ve.overlayInstanceId)return s(`Message ${ve.overlayInstanceId} already showing.`),null;var t=U(e);return e.instanceId=d(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),ve.overlayInstanceId=e.instanceId,ve.currentMessages.push(e),se(e)}return s("Document hidden, not showing message now."),null}async function Z(e,t){return ve.isDocumentVisible?(e.instanceId=d(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!B(t),e.renderStartTime=(new Date).getTime(),ve.currentMessages.push(e),se(e,t)):(s("Document hidden, not showing message now."),null)}async function ee(e){e?(ve.messageDismissed(e),e.overlay?await re(!0,e):ne(e)):s(`Message with instance id: ${instanceId} not found`)}async function te(e){var t=U(e);e?t.persistent&&(s("Persistent message dismissed, logging view"),await fe(e),await ie(e)):s(`Message with instance id: ${instanceId} not found`)}function ne(e){var t;ae(e.instanceId),(t=W(e.elementId))&&(t.classList.remove("gist-visible"),t.style.removeProperty("height"),t.innerHTML="")}async function re(e,t){ae(t.instanceId),ve.overlayInstanceId=null,e?await async function(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("visible"),await L(300)),F()}():F(),0==ve.currentMessages.length&&(window.removeEventListener("message",le),window.removeEventListener("touchstart",ce))}function se(e,t=null){if(t&&function(e){var t=W(e);return!(!t||!t.classList.contains("gist-visible"))}(t))return s(`Message ${e.messageId} already showing in element ${t}.`),null;var n,r,i={endpoint:E.ENGINE_API_ENDPOINT[ve.config.env],siteId:ve.config.siteId,dataCenter:ve.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties},o=`${E.GIST_VIEW_ENDPOINT[ve.config.env]}/index.html?options=${n=JSON.stringify(i),r=btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode("0x"+t)}))),encodeURIComponent(r)}`;return window.addEventListener("message",le),window.addEventListener("touchstart",ce),t?(k.includes(t)&&function(e){const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),s("Top & bottom elements injected into page")}(t),function(e,t,n){var r=W(e);if(r){r.classList.add(q(n.instanceId));var i=U(n),o=i.messageWidth+"px";_.includes(e)&&!i.hasCustomWidth&&(o="100%"),k.includes(e)&&(r.style.width=o),B(e)||(r.style.height="0px"),r.innerHTML=function(e,t,n){var r=function(e,t,n){var r=800;return t.messageWidth>r&&(r=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${r}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(q(t.instanceId),n,e);return r}(t,n,i)}else s(`Message could not be embedded, elementId ${e} not found.`)}(t,o,e)):function(e,t){document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=U(t),r=function(e,t,n){var r=600;return t.messageWidth>r&&(r=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.background.visible {\n visibility: visible;\n }\n #gist-overlay.background.is-blacked-out {\n display: block;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.bottom {\n bottom: 0;\n }\n .gist-message.top {\n top: 0;\n }\n @media (max-width: ${r}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(q(t.instanceId),n,e);return r}(e,t))}(o,e),e}async function ie(e){s(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await fe(e),t=await async function(e){try{return await S().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}(e.queueId)):t=await async function(e){try{return await S().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?s("Message view logged"):s(`Problem logging message: ${t.status}`)}function oe(e){return ve.currentMessages.find((t=>t.instanceId===e))}function ae(e){ve.currentMessages=ve.currentMessages.filter((t=>t.instanceId!==e))}function ue(e,t){ae(e),ve.currentMessages.push(t)}function ce(e){}async function le(e){if(e.data.gist){var t=e.data.gist.instanceId,n=oe(t);if(!n)return;var r=U(n);switch(e.data.gist.method){case"routeLoaded":var i=.001*((new Date).getTime()-n.renderStartTime);s(`Engine render for message: ${n.messageId} timer elapsed in ${i.toFixed(3)} seconds`),n.currentRoute=e.data.gist.parameters.route,n.firstLoad&&(n.overlay?function(e){var t=document.querySelector("#gist-overlay");if(t){t.classList.add("visible");var n=document.querySelector(".gist-message");e.position?n.classList.add(e.position):n.classList.add("center"),setTimeout(M,100)}else F()}(n):(f=W(n.elementId))&&f.classList.add("gist-visible"),ve.messageShown(n),r.persistent?s("Persistent message shown, skipping logging view"):await ie(n),n.firstLoad=!1),ue(t,n);break;case"tap":var o=e.data.gist.parameters.action,a=e.data.gist.parameters.name;if(ve.messageAction(n,o,a),e.data.gist.parameters.system&&!r.persistent){await ee(n);break}try{if((l=new URL(o))&&"gist:"===l.protocol)switch(l.href.replace("gist://","").split("?")[0]){case"close":await ee(n),await te(n),await he();break;case"showMessage":var u=l.searchParams.get("messageId"),c=l.searchParams.get("properties");u&&(c&&(c=JSON.parse(atob(c))),await ve.showMessage({messageId:u,properties:c}));break;case"loadPage":var l;(l=l.href.substring(l.href.indexOf("?url=")+5))&&(l.startsWith("https://")||l.startsWith("http://")||l.startsWith("/")?window.location.href=l:window.location.href=window.location+l)}}catch(e){}break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),ue(t,n),s(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":s(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=W(e.elementId?e.elementId:q(e.instanceId));if(n){var r=n.style;if(t.height>0)if(t.height>window.innerHeight){var s=1-(t.height/window.innerHeight-1);e.shouldScale&&s>=.4?(r.height=`${t.height}px`,r.transform=`translateX(-50%) translateY(-50%) scale(${s})`):r.height=`${window.innerHeight}px`}else r.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":s(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=W(q(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":ve.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":ve.messageError(n),ve.overlayInstanceId?re(!1,n):ne(n)}}var f}async function fe(e){s(`Logging user message view locally for: ${e.queueId}`),H(e)?await async function(e){s(`Marking broadcast ${e} as seen.`);const t=await z();if(!t)return;const n=await async function(e,t){return m(e).find((e=>e.queueId===t))}(t,e);if(!n)return;const{broadcast:r}=n.properties.gist,i=J(t,e),o=G(t,e);let a=m(i)||0;if(h(i,a+1),1===r.frequency.count)h(o,!1),s(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+r.frequency.delay),h(o,!1,t),s(`Marked broadcast ${e} as seen, broadcast was seen ${a+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await K();if(!t)return;const n=m(t)??[];n.push(e),h(t,n)}(e.queueId)}var de=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>de(e,t)))),pe=!1;async function ge(){pe?he():(async function(){var e=`G${d().substring(0,8)}`,t=document.createElement("div");t.setAttribute("id",e),t.style.display="none",document.body.appendChild(t),await L(5e3),Z({messageId:""},e)}(),C()?(s("Queue watcher started"),pe=!0,de((()=>new Promise((()=>async function(){if(C())if(ve.isDocumentVisible)if(null===m(T)){var e=await async function(){var e;try{if(!I){var t=(new Date).getTime();I=!0;var n={"X-Gist-User-Anonymous":$(),"Content-Language":null!==m(R)?m(R):navigator.language};e=await S().post(`/api/v2/users?timestamp=${t}`,{},{headers:n})}}catch(t){t.response?e=t.response:s(`Error getting user queue: ${t}`)}finally{return I=!1,function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(O=t)}var n=new Date((new Date).getTime()+1e3*O);h(T,O,n)}(e),e}}(),t=[];e?(200===e.status||204===e.status?(s("200 response, updating local store."),async function(e){const t=await Q();t&&h(t,e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),new Date(Date.now()+36e5))}(t=e.data),async function(e){const t=await z();if(!t)return;const n=new Date;n.setDate(n.getDate()+30),h(t,e.filter(H),n)}(t)):304===e.status&&s("304 response, using local store."),await he()):s("There was an error while checking message queue.")}else s("Next queue pull scheduled for later.");else s("Document not visible, skipping queue check.");else s("User token reset, skipping queue check.")}()))),1e3)):s("User token not setup, queue not started."))}async function he(){var e=await async function(){const e=await z();return e?(m(e)??[]).filter((t=>{const{broadcast:n}=t.properties.gist,r=m(G(e,t.queueId))??!0,s=m(J(e,t.queueId))||0;return r&&s<n.frequency.count})):[]}(),t=await async function(){const e=await Q();if(!e)return[];const t=m(e)??[],n=await async function(){const e=await K();return e?m(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId)))}(),n=e.concat(t);s(`Messages in local queue: ${n.length}`);var r=n.sort(((e,t)=>e.priority-t.priority));for(const e of r)await me(e)}async function me(e){var t=U(e);if(t.hasRouteRule){var n=ve.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var r=t.routeRule;if(s(`Verifying route against rule: ${r}`),!new RegExp(r).test(n))return s(`Route ${n} does not match rule.`),!1}return t.hasPosition&&(e.position=t.position),t.isEmbedded?await Z(e,t.elementId):await Y(e)}const ve=class{static async setup(e){this.events=new r,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(g,!1),ve.setUserToken(e),s(`Preview mode enabled with user token: ${e}`)),!y()}(),s(`Setup complete on ${this.config.env} environment.`),!this.config.isPreviewSession&&this.config.useAnonymousSession&&N(),await ge(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await he())}),!1)}static async setCurrentRoute(e){this.currentRoute=e,s(`Current route set to: ${e}`),await he()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),h(A,e,t),$()&&(v(T),v(D)),s(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),await ge())}static setUserLocale(e){var t;h(R,t=e),s(`Set user locate to "${t}"`)}static async clearUserToken(){this.config.isPreviewSession||(v(A),s("Cleared user token"),this.config.useAnonymousSession&&N(),await ge())}static async dismissMessage(e){var t=oe(e);await ee(t),await te(t),await he()}static async embedMessage(e,t){var n=await Z(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await Y(e);return t?t.instanceId:null}static messageShown(e){s(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(s(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){s(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){s(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}}},44:(e,t,n)=>{const r=n(548).A;e.exports=r}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(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=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(44)})()));
|
package/package.json
CHANGED
package/src/gist.js
CHANGED
|
@@ -3,12 +3,14 @@ import { log } from "./utilities/log";
|
|
|
3
3
|
import { startQueueListener, checkMessageQueue } from "./managers/queue-manager";
|
|
4
4
|
import { setUserToken, clearUserToken, useGuestSession } from "./managers/user-manager";
|
|
5
5
|
import { showMessage, embedMessage, hideMessage, removePersistentMessage, fetchMessageByInstanceId } from "./managers/message-manager";
|
|
6
|
+
import { setUserLocale } from "./managers/locale-manager";
|
|
7
|
+
import { setupPreview } from "./utilities/preview-mode";
|
|
6
8
|
|
|
7
9
|
export default class {
|
|
8
10
|
static async setup(config) {
|
|
9
11
|
this.events = new EventEmitter();
|
|
10
12
|
this.config = {
|
|
11
|
-
|
|
13
|
+
useAnonymousSession: config.useAnonymousSession === undefined ? false : config.useAnonymousSession,
|
|
12
14
|
siteId: config.siteId,
|
|
13
15
|
dataCenter: config.dataCenter,
|
|
14
16
|
env: config.env === undefined ? "prod" : config.env,
|
|
@@ -19,12 +21,14 @@ export default class {
|
|
|
19
21
|
this.overlayInstanceId = null;
|
|
20
22
|
this.currentRoute = null;
|
|
21
23
|
this.isDocumentVisible = true;
|
|
24
|
+
this.config.isPreviewSession = setupPreview();
|
|
22
25
|
|
|
23
26
|
log(`Setup complete on ${this.config.env} environment.`);
|
|
24
27
|
|
|
25
|
-
if (this.config.
|
|
28
|
+
if (!this.config.isPreviewSession && this.config.useAnonymousSession) {
|
|
26
29
|
useGuestSession();
|
|
27
30
|
}
|
|
31
|
+
|
|
28
32
|
await startQueueListener();
|
|
29
33
|
|
|
30
34
|
document.addEventListener("visibilitychange", async () => {
|
|
@@ -44,13 +48,19 @@ export default class {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
static async setUserToken(userToken, expiryDate) {
|
|
51
|
+
if (this.config.isPreviewSession) return;
|
|
47
52
|
setUserToken(userToken, expiryDate);
|
|
48
53
|
await startQueueListener();
|
|
49
54
|
}
|
|
50
55
|
|
|
56
|
+
static setUserLocale(userLocale) {
|
|
57
|
+
setUserLocale(userLocale);
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
static async clearUserToken() {
|
|
61
|
+
if (this.config.isPreviewSession) return;
|
|
52
62
|
clearUserToken();
|
|
53
|
-
if (this.config.
|
|
63
|
+
if (this.config.useAnonymousSession) {
|
|
54
64
|
useGuestSession();
|
|
55
65
|
}
|
|
56
66
|
await startQueueListener();
|
|
@@ -97,4 +107,4 @@ export default class {
|
|
|
97
107
|
this.events.dispatch('messageAction', {message: message, action: action, name: name});
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { log } from '../utilities/log';
|
|
2
|
+
import { setKeyToLocalStore, getKeyFromLocalStore } from '../utilities/local-storage';
|
|
3
|
+
const userLocaleLocalStoreName = "gist.web.userLocale";
|
|
4
|
+
|
|
5
|
+
export function getUserLocale() {
|
|
6
|
+
if (getKeyFromLocalStore(userLocaleLocalStoreName) !== null) {
|
|
7
|
+
return getKeyFromLocalStore(userLocaleLocalStoreName);
|
|
8
|
+
} else {
|
|
9
|
+
return navigator.language;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function setUserLocale(locale) {
|
|
14
|
+
setKeyToLocalStore(userLocaleLocalStoreName, locale);
|
|
15
|
+
log(`Set user locate to "${locale}"`);
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { log } from '../utilities/log';
|
|
2
|
+
import { setKeyToLocalStore, getKeyFromLocalStore } from '../utilities/local-storage';
|
|
3
|
+
import { getHashedUserToken } from './user-manager';
|
|
4
|
+
|
|
5
|
+
const broadcastsLocalStoreName = "gist.web.message.broadcasts";
|
|
6
|
+
const broadcastsExpiryInDays = 30;
|
|
7
|
+
|
|
8
|
+
export async function updateBroadcastsLocalStore(messages) {
|
|
9
|
+
const messageBroadcastLocalStoreName = await getMessageBroadcastLocalStoreName();
|
|
10
|
+
if (!messageBroadcastLocalStoreName) return;
|
|
11
|
+
|
|
12
|
+
const expiryDate = new Date();
|
|
13
|
+
expiryDate.setDate(expiryDate.getDate() + broadcastsExpiryInDays);
|
|
14
|
+
|
|
15
|
+
const messagesWithBroadcast = messages.filter(isMessageBroadcast);
|
|
16
|
+
setKeyToLocalStore(messageBroadcastLocalStoreName, messagesWithBroadcast, expiryDate);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function getEligibleBroadcasts() {
|
|
20
|
+
const messageBroadcastLocalStoreName = await getMessageBroadcastLocalStoreName();
|
|
21
|
+
if (!messageBroadcastLocalStoreName) return [];
|
|
22
|
+
|
|
23
|
+
const broadcasts = getKeyFromLocalStore(messageBroadcastLocalStoreName) ?? [];
|
|
24
|
+
return broadcasts.filter(broadcast => {
|
|
25
|
+
const { broadcast: broadcastDetails } = broadcast.properties.gist;
|
|
26
|
+
const shouldShow = getKeyFromLocalStore(getBroadcastShouldShowLocalStoreName(messageBroadcastLocalStoreName, broadcast.queueId)) ?? true;
|
|
27
|
+
const numberOfTimesShown = getKeyFromLocalStore(getNumberOfTimesShownLocalStoreName(messageBroadcastLocalStoreName, broadcast.queueId)) || 0;
|
|
28
|
+
return shouldShow && numberOfTimesShown < broadcastDetails.frequency.count;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function markBroadcastAsSeen(broadcastId) {
|
|
33
|
+
log(`Marking broadcast ${broadcastId} as seen.`);
|
|
34
|
+
const messageBroadcastLocalStoreName = await getMessageBroadcastLocalStoreName();
|
|
35
|
+
if (!messageBroadcastLocalStoreName) return;
|
|
36
|
+
|
|
37
|
+
const broadcast = await fetchMessageBroadcast(messageBroadcastLocalStoreName, broadcastId);
|
|
38
|
+
if (!broadcast) return;
|
|
39
|
+
|
|
40
|
+
const { broadcast: broadcastDetails } = broadcast.properties.gist;
|
|
41
|
+
const numberOfTimesShownLocalStoreName = getNumberOfTimesShownLocalStoreName(messageBroadcastLocalStoreName, broadcastId);
|
|
42
|
+
const broadcastShouldShowLocalStoreName = getBroadcastShouldShowLocalStoreName(messageBroadcastLocalStoreName, broadcastId);
|
|
43
|
+
let numberOfTimesShown = getKeyFromLocalStore(numberOfTimesShownLocalStoreName) || 0;
|
|
44
|
+
setKeyToLocalStore(numberOfTimesShownLocalStoreName, numberOfTimesShown + 1);
|
|
45
|
+
|
|
46
|
+
if (broadcastDetails.frequency.count === 1) {
|
|
47
|
+
setKeyToLocalStore(broadcastShouldShowLocalStoreName, false);
|
|
48
|
+
log(`Marked broadcast ${broadcastId} as seen.`);
|
|
49
|
+
} else {
|
|
50
|
+
let showShowDate = new Date();
|
|
51
|
+
showShowDate.setSeconds(showShowDate.getSeconds() + broadcastDetails.frequency.delay);
|
|
52
|
+
setKeyToLocalStore(broadcastShouldShowLocalStoreName, false, showShowDate);
|
|
53
|
+
log(`Marked broadcast ${broadcastId} as seen, broadcast was seen ${numberOfTimesShown + 1} times, next show date is ${showShowDate}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function fetchMessageBroadcast(messageBroadcastLocalStoreName, broadcastId) {
|
|
58
|
+
const broadcasts = getKeyFromLocalStore(messageBroadcastLocalStoreName);
|
|
59
|
+
return broadcasts.find(message => message.queueId === broadcastId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isMessageBroadcast(message) {
|
|
63
|
+
return message.properties && message.properties.gist && message.properties.gist.broadcast;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function getMessageBroadcastLocalStoreName() {
|
|
67
|
+
const userToken = await getHashedUserToken();
|
|
68
|
+
if (!userToken) return null;
|
|
69
|
+
return `${broadcastsLocalStoreName}.${userToken}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getNumberOfTimesShownLocalStoreName(messageBroadcastLocalStoreName, broadcastId) {
|
|
73
|
+
return `${messageBroadcastLocalStoreName}.${broadcastId}.numberOfTimesShown`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getBroadcastShouldShowLocalStoreName(messageBroadcastLocalStoreName, broadcastId) {
|
|
77
|
+
return `${messageBroadcastLocalStoreName}.${broadcastId}.shouldShow`;
|
|
78
|
+
}
|
|
@@ -18,9 +18,9 @@ import {
|
|
|
18
18
|
} from "./message-component-manager";
|
|
19
19
|
import { resolveMessageProperties } from "./gist-properties-manager";
|
|
20
20
|
import { positions, addPageElement } from "./page-component-manager";
|
|
21
|
-
import { checkMessageQueue
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
import { checkMessageQueue } from "./queue-manager";
|
|
22
|
+
import { isMessageBroadcast, markBroadcastAsSeen } from './message-broadcast-manager';
|
|
23
|
+
import { markUserQueueMessageAsSeen } from './message-user-queue-manager';
|
|
24
24
|
|
|
25
25
|
export async function showMessage(message) {
|
|
26
26
|
if (Gist.isDocumentVisible) {
|
|
@@ -83,6 +83,7 @@ export async function removePersistentMessage(message) {
|
|
|
83
83
|
if (message) {
|
|
84
84
|
if (messageProperties.persistent) {
|
|
85
85
|
log(`Persistent message dismissed, logging view`);
|
|
86
|
+
await logUserMessageViewLocally(message);
|
|
86
87
|
await reportMessageView(message);
|
|
87
88
|
}
|
|
88
89
|
} else {
|
|
@@ -152,7 +153,7 @@ async function reportMessageView(message) {
|
|
|
152
153
|
log(`Message shown, logging view for: ${message.messageId}`);
|
|
153
154
|
var response = {};
|
|
154
155
|
if (message.queueId != null) {
|
|
155
|
-
logUserMessageViewLocally(message);
|
|
156
|
+
await logUserMessageViewLocally(message);
|
|
156
157
|
response = await logUserMessageView(message.queueId);
|
|
157
158
|
} else {
|
|
158
159
|
response = await logMessageView(message.messageId);
|
|
@@ -294,14 +295,11 @@ async function handleGistEvents(e) {
|
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
|
|
297
|
-
function logUserMessageViewLocally(message) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
async function logUserMessageViewLocally(message) {
|
|
299
|
+
log(`Logging user message view locally for: ${message.queueId}`);
|
|
300
|
+
if (isMessageBroadcast(message)) {
|
|
301
|
+
await markBroadcastAsSeen(message.queueId);
|
|
302
|
+
} else {
|
|
303
|
+
await markUserQueueMessageAsSeen(message.queueId);
|
|
302
304
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export function hasMessageBeenShownBefore(message) {
|
|
306
|
-
return shownMessages.find(msg => msg.queueId === message.queueId) !== undefined;
|
|
307
305
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getKeyFromLocalStore, setKeyToLocalStore } from '../utilities/local-storage';
|
|
2
|
+
import { getHashedUserToken } from './user-manager';
|
|
3
|
+
|
|
4
|
+
const messageQueueLocalStoreName = "gist.web.message.user";
|
|
5
|
+
const messagesLocalStoreCacheInMinutes = 60000 * 60;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export async function updateQueueLocalStore(messages) {
|
|
9
|
+
const userQueueLocalStoreName = await getUserQueueLocalStoreName();
|
|
10
|
+
if (!userQueueLocalStoreName) return;
|
|
11
|
+
|
|
12
|
+
const nonBroadcasts = messages.filter(message =>
|
|
13
|
+
!(message.properties && message.properties.gist && message.properties.gist.broadcast)
|
|
14
|
+
);
|
|
15
|
+
const expiryDate = new Date(Date.now() + messagesLocalStoreCacheInMinutes);
|
|
16
|
+
setKeyToLocalStore(userQueueLocalStoreName, nonBroadcasts, expiryDate);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function getMessagesFromLocalStore() {
|
|
20
|
+
const userQueueLocalStoreName = await getUserQueueLocalStoreName();
|
|
21
|
+
if (!userQueueLocalStoreName) return [];
|
|
22
|
+
|
|
23
|
+
const storedMessages = getKeyFromLocalStore(userQueueLocalStoreName) ?? [];
|
|
24
|
+
const seenMessages = await getSeenMessagesFromLocalStore();
|
|
25
|
+
return storedMessages.filter(message => !seenMessages.includes(message.queueId));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function markUserQueueMessageAsSeen(queueId) {
|
|
29
|
+
const userSeenQueueLocalStoreName = await getUserSeenQueueLocalStoreName();
|
|
30
|
+
if (!userSeenQueueLocalStoreName) return;
|
|
31
|
+
|
|
32
|
+
const seenMessages = getKeyFromLocalStore(userSeenQueueLocalStoreName) ?? [];
|
|
33
|
+
seenMessages.push(queueId);
|
|
34
|
+
setKeyToLocalStore(userSeenQueueLocalStoreName, seenMessages);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function getSeenMessagesFromLocalStore() {
|
|
38
|
+
const userSeenQueueLocalStoreName = await getUserSeenQueueLocalStoreName();
|
|
39
|
+
if (!userSeenQueueLocalStoreName) return [];
|
|
40
|
+
|
|
41
|
+
return getKeyFromLocalStore(userSeenQueueLocalStoreName) ?? [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function getUserQueueLocalStoreName() {
|
|
45
|
+
const userToken = await getHashedUserToken();
|
|
46
|
+
if (!userToken) return null;
|
|
47
|
+
return `${messageQueueLocalStoreName}.${userToken}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function getUserSeenQueueLocalStoreName() {
|
|
51
|
+
const userToken = await getHashedUserToken();
|
|
52
|
+
if (!userToken) return null;
|
|
53
|
+
return `${messageQueueLocalStoreName}.${userToken}.seen`;
|
|
54
|
+
}
|
|
@@ -2,18 +2,16 @@ import Gist from '../gist';
|
|
|
2
2
|
import { log } from "../utilities/log";
|
|
3
3
|
import { getUserToken } from "./user-manager";
|
|
4
4
|
import { getUserQueue, userQueueNextPullCheckLocalStoreName } from "../services/queue-service";
|
|
5
|
-
import { showMessage, embedMessage
|
|
5
|
+
import { showMessage, embedMessage } from "./message-manager";
|
|
6
6
|
import { resolveMessageProperties } from "./gist-properties-manager";
|
|
7
7
|
import { preloadRenderer } from "./message-component-manager";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const MESSAGES_LOCAL_STORE_CACHE_IN_MINUTES = 60000 * 60;
|
|
8
|
+
import { getKeyFromLocalStore } from '../utilities/local-storage';
|
|
9
|
+
import { updateBroadcastsLocalStore, getEligibleBroadcasts } from './message-broadcast-manager';
|
|
10
|
+
import { updateQueueLocalStore, getMessagesFromLocalStore } from './message-user-queue-manager';
|
|
12
11
|
|
|
13
12
|
var sleep = time => new Promise(resolve => setTimeout(resolve, time))
|
|
14
13
|
var poll = (promiseFn, time) => promiseFn().then(sleep(time).then(() => poll(promiseFn, time)));
|
|
15
14
|
var pollingSetup = false;
|
|
16
|
-
var messages = [];
|
|
17
15
|
|
|
18
16
|
export async function startQueueListener() {
|
|
19
17
|
if (!pollingSetup) {
|
|
@@ -23,38 +21,27 @@ export async function startQueueListener() {
|
|
|
23
21
|
pollingSetup = true;
|
|
24
22
|
poll(() => new Promise(() => pullMessagesFromQueue()), 1000);
|
|
25
23
|
} else {
|
|
26
|
-
log(
|
|
24
|
+
log("User token not setup, queue not started.");
|
|
27
25
|
}
|
|
28
26
|
} else {
|
|
29
|
-
|
|
27
|
+
checkMessageQueue();
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
export async function checkMessageQueue() {
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
32
|
+
var broadcastMessages = await getEligibleBroadcasts();
|
|
33
|
+
var userMessages = await getMessagesFromLocalStore();
|
|
34
|
+
var allMessages = broadcastMessages.concat(userMessages);
|
|
35
|
+
|
|
36
|
+
log(`Messages in local queue: ${allMessages.length}`);
|
|
37
|
+
var orderedMessages = allMessages.sort((a, b) => a.priority - b.priority);
|
|
37
38
|
for (const message of orderedMessages) {
|
|
38
|
-
|
|
39
|
-
if (!handledMessage) {
|
|
40
|
-
var duplicateMessage = keptMessages.find(queueMessages => queueMessages.queueId === message.queueId);
|
|
41
|
-
var showingMessage = Gist.currentMessages.find(currentMessage => currentMessage.queueId === message.queueId);
|
|
42
|
-
if (duplicateMessage || showingMessage) {
|
|
43
|
-
log(`Message with queueId: ${message.queueId} already in queue, discarding.`);
|
|
44
|
-
} else {
|
|
45
|
-
keptMessages.push(message);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
39
|
+
await handleMessage(message);
|
|
48
40
|
}
|
|
49
|
-
messages = keptMessages;
|
|
50
41
|
}
|
|
51
42
|
|
|
43
|
+
//TODO: Move this to a utility and only return valid messages (from: getEligibleBroadcasts getMessagesFromLocalStore) & to handleMessage
|
|
52
44
|
async function handleMessage(message) {
|
|
53
|
-
if (hasMessageBeenShownBefore(message)) {
|
|
54
|
-
log(`Message with ${message.queueId} has been shown before, skipping.`);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
45
|
var messageProperties = resolveMessageProperties(message);
|
|
59
46
|
if (messageProperties.hasRouteRule) {
|
|
60
47
|
var currentUrl = Gist.currentRoute
|
|
@@ -91,24 +78,17 @@ export async function pullMessagesFromQueue() {
|
|
|
91
78
|
log("200 response, updating local store.");
|
|
92
79
|
responseData = response.data;
|
|
93
80
|
updateQueueLocalStore(responseData);
|
|
81
|
+
updateBroadcastsLocalStore(responseData);
|
|
94
82
|
}
|
|
95
83
|
else if (response.status === 304) {
|
|
96
84
|
log("304 response, using local store.");
|
|
97
|
-
responseData = getMessagesFromLocalStore();
|
|
98
|
-
}
|
|
99
|
-
if (responseData && responseData.length > 0) {
|
|
100
|
-
log(`Message queue checked for user ${getUserToken()}, ${responseData.length} messages found.`);
|
|
101
|
-
messages = responseData;
|
|
102
|
-
await checkMessageQueue();
|
|
103
|
-
} else {
|
|
104
|
-
messages = [];
|
|
105
|
-
log(`No messages for user token.`);
|
|
106
85
|
}
|
|
86
|
+
await checkMessageQueue();
|
|
107
87
|
} else {
|
|
108
88
|
log(`There was an error while checking message queue.`);
|
|
109
89
|
}
|
|
110
90
|
} else {
|
|
111
|
-
log(`Next queue pull scheduled for later
|
|
91
|
+
log(`Next queue pull scheduled for later.`);
|
|
112
92
|
}
|
|
113
93
|
} else {
|
|
114
94
|
log(`Document not visible, skipping queue check.`);
|
|
@@ -116,13 +96,4 @@ export async function pullMessagesFromQueue() {
|
|
|
116
96
|
} else {
|
|
117
97
|
log(`User token reset, skipping queue check.`);
|
|
118
98
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function updateQueueLocalStore(messages) {
|
|
122
|
-
var expiryDate = new Date(new Date().getTime() + MESSAGES_LOCAL_STORE_CACHE_IN_MINUTES);
|
|
123
|
-
setKeyWithExpiryToLocalStore(userQueueLocalStoreName, messages, expiryDate);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function getMessagesFromLocalStore() {
|
|
127
|
-
return getKeyFromLocalStore(userQueueLocalStoreName);
|
|
128
99
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { log } from '../utilities/log';
|
|
2
|
-
import { setKeyWithExpiryToLocalStore, getKeyFromLocalStore, clearKeyFromLocalStore } from '../utilities/local-storage';
|
|
3
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { log } from '../utilities/log';
|
|
3
|
+
import { setKeyToLocalStore, getKeyFromLocalStore, clearKeyFromLocalStore } from '../utilities/local-storage';
|
|
4
|
+
import { userQueueNextPullCheckLocalStoreName } from '../services/queue-service';
|
|
5
|
+
|
|
4
6
|
const userTokenLocalStoreName = "gist.web.userToken";
|
|
5
|
-
const guestUserTokenLocalStoreName = "gist.web.guestUserToken";
|
|
6
7
|
const usingGuestUserTokenLocalStoreName = "gist.web.usingGuestUserToken";
|
|
8
|
+
const guestUserTokenLocalStoreName = "gist.web.guestUserToken";
|
|
9
|
+
const defaultExpiryInDays = 30;
|
|
7
10
|
|
|
8
11
|
export function isUsingGuestUserToken() {
|
|
9
12
|
return (getKeyFromLocalStore(usingGuestUserTokenLocalStoreName) !== null);
|
|
@@ -16,32 +19,58 @@ export function getUserToken() {
|
|
|
16
19
|
export function setUserToken(userToken, expiryDate) {
|
|
17
20
|
if (expiryDate === undefined) {
|
|
18
21
|
expiryDate = new Date();
|
|
19
|
-
expiryDate.setDate(expiryDate.getDate() +
|
|
22
|
+
expiryDate.setDate(expiryDate.getDate() + defaultExpiryInDays);
|
|
23
|
+
}
|
|
24
|
+
setKeyToLocalStore(userTokenLocalStoreName, userToken, expiryDate);
|
|
25
|
+
|
|
26
|
+
if (isUsingGuestUserToken()) {
|
|
27
|
+
// Removing pull check time key so that we check the queue immediately after the userToken is set.
|
|
28
|
+
clearKeyFromLocalStore(userQueueNextPullCheckLocalStoreName);
|
|
29
|
+
clearKeyFromLocalStore(usingGuestUserTokenLocalStoreName);
|
|
20
30
|
}
|
|
21
|
-
setKeyWithExpiryToLocalStore(userTokenLocalStoreName, userToken, expiryDate);
|
|
22
|
-
clearKeyFromLocalStore(usingGuestUserTokenLocalStoreName);
|
|
23
31
|
log(`Set user token "${userToken}" with expiry date set to ${expiryDate}`);
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export function useGuestSession() {
|
|
27
|
-
var expiryDate = new Date();
|
|
28
|
-
expiryDate.setDate(expiryDate.getDate() + 365);
|
|
29
|
-
|
|
30
35
|
// Guest sessions should never override existing sessions
|
|
31
36
|
if (getUserToken() === null) {
|
|
32
37
|
var guestUserToken = getKeyFromLocalStore(guestUserTokenLocalStoreName);
|
|
33
38
|
if (guestUserToken == null) {
|
|
34
39
|
guestUserToken = uuidv4();
|
|
35
|
-
|
|
40
|
+
setKeyToLocalStore(guestUserTokenLocalStoreName, guestUserToken);
|
|
36
41
|
log(`Set guest user token "${guestUserToken}" with expiry date set to 1 year from today`);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
setKeyToLocalStore(userTokenLocalStoreName, guestUserToken);
|
|
45
|
+
setKeyToLocalStore(usingGuestUserTokenLocalStoreName, true);
|
|
46
|
+
log(`Using anonymous session with token: "${guestUserToken}"`);
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
export async function getHashedUserToken() {
|
|
51
|
+
var userToken = getUserToken();
|
|
52
|
+
if (userToken === null) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return await hashString(userToken);
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
export function clearUserToken() {
|
|
45
59
|
clearKeyFromLocalStore(userTokenLocalStoreName);
|
|
46
60
|
log(`Cleared user token`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function hashString(message) {
|
|
64
|
+
// Encode the message as a Uint8Array
|
|
65
|
+
const encoder = new TextEncoder();
|
|
66
|
+
const data = encoder.encode(message);
|
|
67
|
+
|
|
68
|
+
// Hash the message using the SHA-256 algorithm
|
|
69
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
70
|
+
|
|
71
|
+
// Convert the hash to a hexadecimal string
|
|
72
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
73
|
+
const hashHex = hashArray.map(byte => byte.toString(16).padStart(2, '0')).join('');
|
|
74
|
+
|
|
75
|
+
return hashHex;
|
|
47
76
|
}
|
package/src/services/network.js
CHANGED
|
@@ -4,14 +4,15 @@ import { settings } from './settings';
|
|
|
4
4
|
import { getUserToken } from "../managers/user-manager";
|
|
5
5
|
|
|
6
6
|
export function UserNetworkInstance() {
|
|
7
|
-
var
|
|
7
|
+
var instance = axios.create({
|
|
8
|
+
baseURL: settings.GIST_QUEUE_API_ENDPOINT[Gist.config.env],
|
|
9
|
+
timeout: 20000 // 20 seconds, TODO: should we reconsider?
|
|
10
|
+
})
|
|
11
|
+
instance.defaults.headers.common['X-CIO-Site-Id'] = Gist.config.siteId;
|
|
12
|
+
instance.defaults.headers.common['X-CIO-Client-Platform'] = 'web';
|
|
8
13
|
var userToken = getUserToken();
|
|
9
14
|
if (userToken != null) {
|
|
10
|
-
headers['X-Gist-Encoded-User-Token'] = btoa(userToken);
|
|
15
|
+
instance.defaults.headers.common['X-Gist-Encoded-User-Token'] = btoa(userToken);
|
|
11
16
|
}
|
|
12
|
-
return
|
|
13
|
-
baseURL: settings.GIST_QUEUE_API_ENDPOINT[Gist.config.env],
|
|
14
|
-
timeout: 20000,
|
|
15
|
-
headers: headers
|
|
16
|
-
});
|
|
17
|
+
return instance;
|
|
17
18
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { UserNetworkInstance } from './network';
|
|
2
|
-
import {
|
|
2
|
+
import { setKeyToLocalStore } from '../utilities/local-storage';
|
|
3
3
|
import { log } from "../utilities/log";
|
|
4
|
+
import { isUsingGuestUserToken } from '../managers/user-manager';
|
|
5
|
+
import { getUserLocale } from '../managers/locale-manager';
|
|
4
6
|
|
|
5
|
-
const
|
|
6
|
-
var currentPollingDelayInSeconds =
|
|
7
|
+
const defaultPollingDelayInSeconds = 600;
|
|
8
|
+
var currentPollingDelayInSeconds = defaultPollingDelayInSeconds;
|
|
7
9
|
var checkInProgress = false;
|
|
8
10
|
|
|
9
11
|
export const userQueueNextPullCheckLocalStoreName = "gist.web.userQueueNextPullCheck";
|
|
@@ -13,7 +15,11 @@ export async function getUserQueue() {
|
|
|
13
15
|
if (!checkInProgress) {
|
|
14
16
|
var timestamp = new Date().getTime();
|
|
15
17
|
checkInProgress = true;
|
|
16
|
-
|
|
18
|
+
var headers = {
|
|
19
|
+
"X-Gist-User-Anonymous": isUsingGuestUserToken(),
|
|
20
|
+
"Content-Language": getUserLocale()
|
|
21
|
+
}
|
|
22
|
+
response = await UserNetworkInstance().post(`/api/v2/users?timestamp=${timestamp}`, {}, { headers: headers });
|
|
17
23
|
}
|
|
18
24
|
} catch (error) {
|
|
19
25
|
if (error.response) {
|
|
@@ -36,5 +42,5 @@ function scheduleNextQueuePull(response) {
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
var expiryDate = new Date(new Date().getTime() + currentPollingDelayInSeconds * 1000);
|
|
39
|
-
|
|
40
|
-
}
|
|
45
|
+
setKeyToLocalStore(userQueueNextPullCheckLocalStoreName, currentPollingDelayInSeconds, expiryDate);
|
|
46
|
+
}
|
package/src/templates/embed.js
CHANGED
|
@@ -38,6 +38,16 @@ export function embedHTMLTemplate(elementId, messageProperties, url) {
|
|
|
38
38
|
width: 100%;
|
|
39
39
|
border: none;
|
|
40
40
|
}
|
|
41
|
+
#x-gist-top.${elementId},
|
|
42
|
+
#x-gist-bottom.${elementId},
|
|
43
|
+
#x-gist-floating-top.${elementId},
|
|
44
|
+
#x-gist-floating-bottom.${elementId},
|
|
45
|
+
#x-gist-floating-top-left.${elementId},
|
|
46
|
+
#x-gist-floating-top-right.${elementId},
|
|
47
|
+
#x-gist-floating-bottom-left.${elementId},
|
|
48
|
+
#x-gist-floating-bottom-right.${elementId} {
|
|
49
|
+
transition: height 0.1s ease-in-out;
|
|
50
|
+
}
|
|
41
51
|
@media (max-width: ${maxWidthBreakpoint}px) {
|
|
42
52
|
#x-gist-top.${elementId},
|
|
43
53
|
#x-gist-bottom.${elementId},
|
package/src/templates/message.js
CHANGED
|
@@ -27,7 +27,7 @@ export function messageHTMLTemplate(elementId, messageProperties, url) {
|
|
|
27
27
|
position: absolute;
|
|
28
28
|
border: none;
|
|
29
29
|
opacity: 0;
|
|
30
|
-
transition: opacity 0.3s ease-in-out;
|
|
30
|
+
transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;
|
|
31
31
|
z-index: 9999999999;
|
|
32
32
|
left: 50%;
|
|
33
33
|
transform: translateX(-50%);
|
|
@@ -1,26 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
const maxExpiryDays = 365;
|
|
2
|
+
|
|
3
|
+
const isPersistingSessionLocalStoreName = "gist.web.isPersistingSession";
|
|
4
|
+
|
|
5
|
+
// Switches between local and session storage
|
|
6
|
+
export function shouldPersistSession(presisted) {
|
|
7
|
+
sessionStorage.setItem(isPersistingSessionLocalStoreName, presisted);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function setKeyToLocalStore(key, value, ttl = null) {
|
|
11
|
+
var expiryDate = ttl;
|
|
12
|
+
if (!expiryDate) {
|
|
13
|
+
expiryDate = new Date();
|
|
14
|
+
expiryDate.setDate(expiryDate.getDate() + maxExpiryDays);
|
|
15
|
+
}
|
|
2
16
|
const item = {
|
|
3
17
|
value: value,
|
|
4
|
-
expiry:
|
|
18
|
+
expiry: expiryDate,
|
|
5
19
|
};
|
|
6
|
-
|
|
20
|
+
getStorage().setItem(key, JSON.stringify(item));
|
|
7
21
|
}
|
|
8
|
-
|
|
22
|
+
|
|
9
23
|
export function getKeyFromLocalStore(key) {
|
|
10
|
-
const itemStr =
|
|
11
|
-
if (!itemStr)
|
|
12
|
-
|
|
13
|
-
}
|
|
24
|
+
const itemStr = getStorage().getItem(key);
|
|
25
|
+
if (!itemStr) return null;
|
|
26
|
+
|
|
14
27
|
const item = JSON.parse(itemStr);
|
|
15
28
|
const now = new Date();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
localStorage.removeItem(key);
|
|
29
|
+
if (now.getTime() > new Date(item.expiry).getTime()) {
|
|
30
|
+
clearKeyFromLocalStore(key);
|
|
19
31
|
return null;
|
|
20
32
|
}
|
|
21
33
|
return item.value;
|
|
22
34
|
}
|
|
23
|
-
|
|
35
|
+
|
|
24
36
|
export function clearKeyFromLocalStore(key) {
|
|
25
|
-
|
|
37
|
+
getStorage().removeItem(key);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isSessionBeingPersisted() {
|
|
41
|
+
const currentValue = sessionStorage.getItem(isPersistingSessionLocalStoreName);
|
|
42
|
+
if (currentValue === null) {
|
|
43
|
+
sessionStorage.setItem(isPersistingSessionLocalStoreName, "true");
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return currentValue === "true";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Helper function to select the correct storage based on the session flag
|
|
50
|
+
function getStorage() {
|
|
51
|
+
return isSessionBeingPersisted() ? localStorage : sessionStorage;
|
|
26
52
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Gist from '../gist';
|
|
2
|
+
import { log } from './log';
|
|
3
|
+
import { shouldPersistSession, isSessionBeingPersisted } from './local-storage';
|
|
4
|
+
|
|
5
|
+
const previewParamId = "cioPreviewId";
|
|
6
|
+
|
|
7
|
+
export function setupPreview() {
|
|
8
|
+
const cioPreviewId = fetchPreviewId();
|
|
9
|
+
if (cioPreviewId) {
|
|
10
|
+
shouldPersistSession(false);
|
|
11
|
+
Gist.setUserToken(cioPreviewId);
|
|
12
|
+
log(`Preview mode enabled with user token: ${cioPreviewId}`);
|
|
13
|
+
}
|
|
14
|
+
return !isSessionBeingPersisted();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fetchPreviewId() {
|
|
18
|
+
const params = new URLSearchParams(window.location.search);
|
|
19
|
+
return params.get(previewParamId);
|
|
20
|
+
}
|