starti.app 1.1.2 → 1.1.3

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/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare class StartiappClass extends EventTarget {
11
11
  disableScreenRotation(): void;
12
12
  enableScreenRotation(): void;
13
13
  getInternalDomains(): void;
14
- addInternalDomain(domain: string): void; /** Access to client user functionality. */
14
+ addInternalDomain(domain: string): void;
15
15
  removeInternalDomain(domain: string): void;
16
16
  setSafeAreaBackgroundColor(color: string): void;
17
17
  hideStatusBar(): void;
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ const biometrics_1 = require("./biometrics");
5
5
  const clientUser_1 = require("./clientUser");
6
6
  const device_1 = require("./device");
7
7
  const getIntegration_1 = require("./getIntegration");
8
+ const ViewportMetatag_1 = require("./lib/ViewportMetatag");
8
9
  const nfc_1 = require("./nfc");
9
10
  const pushnotification_1 = require("./pushnotification");
10
11
  const qrscanner_1 = require("./qrscanner");
@@ -80,12 +81,35 @@ function documentBodyExists(observer) {
80
81
  if (!document.body)
81
82
  return;
82
83
  if (startiapp.isRunningInApp()) {
83
- document.body.setAttribute("startiapp", "true");
84
+ document.body.setAttribute("startiapp", "");
84
85
  }
86
+ else {
87
+ document.body.removeAttribute("startiapp");
88
+ }
89
+ if (!document.head)
90
+ return;
85
91
  // Append the utility styles to the document head
86
92
  const style = document.createElement("style");
87
93
  style.innerHTML = `body:not([startiapp]) .startiapp-hide-in-browser,body:not([startiapp]) .startiapp-show-in-app,body[startiapp] .startiapp-hide-in-app,body[startiapp] .startiapp-show-in-browser{display:none!important}`;
88
94
  document.head.appendChild(style);
95
+ // Update the viewport meta tag to use viewport fit cover and device width if the app is running in the starti.app app
96
+ if (startiapp.isRunningInApp()) {
97
+ const startiappViewportContent = {
98
+ "width": "device-width",
99
+ "viewport-fit": "cover",
100
+ };
101
+ const existingViewport = document.querySelector("meta[name=viewport]");
102
+ if (existingViewport) {
103
+ const content = (0, ViewportMetatag_1.parseViewportMeta)(existingViewport.content);
104
+ existingViewport.content = (0, ViewportMetatag_1.serializeViewportMeta)(Object.assign(Object.assign({}, content), startiappViewportContent));
105
+ }
106
+ else {
107
+ const meta = document.createElement("meta");
108
+ meta.name = "viewport";
109
+ meta.content = (0, ViewportMetatag_1.serializeViewportMeta)(startiappViewportContent);
110
+ document.head.appendChild(meta);
111
+ }
112
+ }
89
113
  if (observer)
90
114
  observer.disconnect();
91
115
  }
@@ -0,0 +1,11 @@
1
+ export interface ViewportMeta {
2
+ "width"?: string | "device-width";
3
+ "height"?: string | "device-height";
4
+ "initial-scale"?: string;
5
+ "minimum-scale"?: string;
6
+ "maximum-scale"?: string;
7
+ "user-scalable"?: "yes" | "no" | "0" | "1";
8
+ "viewport-fit"?: "auto" | "contain" | "cover";
9
+ }
10
+ export declare function parseViewportMeta(content: string): ViewportMeta;
11
+ export declare function serializeViewportMeta(viewportMeta: ViewportMeta): string;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeViewportMeta = exports.parseViewportMeta = void 0;
4
+ function parseViewportMeta(content) {
5
+ const viewportMeta = {};
6
+ const properties = content.split(",");
7
+ for (const property of properties) {
8
+ const [key, value] = property.trim().split("=");
9
+ switch (key.trim()) {
10
+ case "width":
11
+ case "height":
12
+ case "initial-scale":
13
+ case "minimum-scale":
14
+ case "maximum-scale":
15
+ case "user-scalable":
16
+ case "viewport-fit":
17
+ viewportMeta[key.trim()] = value.trim();
18
+ break;
19
+ default:
20
+ break;
21
+ }
22
+ }
23
+ return viewportMeta;
24
+ }
25
+ exports.parseViewportMeta = parseViewportMeta;
26
+ function serializeViewportMeta(viewportMeta) {
27
+ const properties = [];
28
+ for (const [key, value] of Object.entries(viewportMeta)) {
29
+ if (value) {
30
+ properties.push(`${key}=${value}`);
31
+ }
32
+ }
33
+ return properties.join(", ");
34
+ }
35
+ exports.serializeViewportMeta = serializeViewportMeta;
@@ -1,9 +1,9 @@
1
1
  declare class UI implements IUI {
2
2
  private options;
3
3
  private styleString;
4
- private initialViewportMetaContent;
5
4
  setOptions(options?: InitializeParams): void;
6
5
  getOptions(): InitializeParams;
6
+ private updateViewportMeta;
7
7
  private updateUI;
8
8
  }
9
9
  interface IUI {
@@ -2,48 +2,61 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppUI = void 0;
4
4
  const config_1 = require("../config");
5
+ const ViewportMetatag_1 = require("../lib/ViewportMetatag");
5
6
  class UI {
6
7
  constructor() {
7
- this.options = { allowDrag: false, allowHighligt: false, allowZoom: false, allowScrollBounce: false };
8
+ this.options = {
9
+ allowDrag: false,
10
+ allowHighligt: false,
11
+ allowZoom: false,
12
+ allowScrollBounce: false,
13
+ };
8
14
  }
9
15
  setOptions(options) {
10
16
  this.options = Object.assign(this.options, options);
11
- if (document.querySelector('meta[name="viewport"]') != null && typeof (this.initialViewportMetaContent) == 'undefined') {
12
- this.initialViewportMetaContent = document.querySelector('meta[name="viewport"]').getAttribute("content");
13
- }
14
- if (!this.initialViewportMetaContent.includes("viewport-fit=cover"))
15
- this.initialViewportMetaContent += ", viewport-fit=cover";
16
17
  this.updateUI();
17
18
  }
18
19
  getOptions() {
19
20
  return this.options;
20
21
  }
22
+ updateViewportMeta(content) {
23
+ const existingViewport = document.querySelector("meta[name=viewport]");
24
+ if (existingViewport) {
25
+ const existingContent = (0, ViewportMetatag_1.parseViewportMeta)(existingViewport.content);
26
+ existingViewport.content = (0, ViewportMetatag_1.serializeViewportMeta)(Object.assign(Object.assign({}, existingContent), content));
27
+ }
28
+ else {
29
+ const metaElement = document.createElement("meta");
30
+ metaElement.setAttribute("name", "viewport");
31
+ metaElement.setAttribute("content", (0, ViewportMetatag_1.serializeViewportMeta)(content));
32
+ document.head.appendChild(metaElement);
33
+ }
34
+ }
21
35
  updateUI() {
22
36
  this.styleString = "";
23
37
  const prevStyleElement = document.getElementById(config_1.styleTagId);
24
38
  if (prevStyleElement) {
25
39
  prevStyleElement.remove();
26
40
  }
27
- const images = document.getElementsByTagName('img');
28
- const links = document.getElementsByTagName('a');
41
+ const images = document.getElementsByTagName("img");
42
+ const links = document.getElementsByTagName("a");
29
43
  if (!this.options.allowDrag) {
30
- [...images, ...links].forEach(element => {
31
- element.setAttribute('draggable', 'false');
44
+ [...images, ...links].forEach((element) => {
45
+ element.setAttribute("draggable", "false");
32
46
  });
33
47
  }
34
48
  else {
35
- [...images, ...links].forEach(element => {
36
- element.removeAttribute('draggable');
49
+ [...images, ...links].forEach((element) => {
50
+ element.removeAttribute("draggable");
37
51
  });
38
52
  }
39
- let viewport = document.querySelector("meta[name=viewport]");
40
53
  if (!this.options.allowHighligt) {
41
54
  this.styleString += `
42
55
  body {
43
- -webkit-user-select: none;
44
- -khtml-user-select: none;
45
- -moz-user-select: none;
46
- -o-user-select: none;
56
+ -webkit-user-select: none;
57
+ -khtml-user-select: none;
58
+ -moz-user-select: none;
59
+ -o-user-select: none;
47
60
  user-select: none;
48
61
  }
49
62
  `;
@@ -61,14 +74,11 @@ class UI {
61
74
  touch-action: pan-x pan-y;
62
75
  }
63
76
  `;
64
- viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover');
65
- }
66
- else {
67
- viewport.setAttribute('content', this.initialViewportMetaContent);
77
+ this.updateViewportMeta({ "user-scalable": "no" });
68
78
  }
69
- const styleElement = document.createElement('style');
79
+ const styleElement = document.createElement("style");
70
80
  styleElement.textContent = this.styleString;
71
- styleElement.setAttribute('id', config_1.styleTagId);
81
+ styleElement.setAttribute("id", config_1.styleTagId);
72
82
  document.body.appendChild(styleElement);
73
83
  }
74
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starti.app",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Use this package for easy communication with the starti.app API.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,10 +14,12 @@
14
14
  "ts-loader": "^9.4.1",
15
15
  "typescript": "^4.8.4",
16
16
  "webpack": "^5.74.0",
17
- "webpack-cli": "^4.10.0"
17
+ "webpack-cli": "^4.10.0",
18
+ "webpack-dev-server": "^4.15.1"
18
19
  },
19
20
  "scripts": {
20
21
  "build": "tsc && webpack --mode=production --node-env=production",
22
+ "dev": "webpack-dev-server --config webpack.config.js",
21
23
  "build:dev": "webpack --mode=development",
22
24
  "build:prod": "webpack --mode=production --node-env=production",
23
25
  "watch": "webpack --watch"
package/umd/main.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see main.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>{return e={466:function(e){e.exports=function(){"use strict";var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)};function n(e){return"function"==typeof e}function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function s(e,t){return null!=e&&"object"==typeof e&&t in e}var i=RegExp.prototype.test;var o=/\S/;function a(e){return!function(e,t){return i.call(e,t)}(o,e)}var c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};var l=/\s*/,u=/\s+/,p=/\s*=/,d=/\s*\}/,h=/#|\^|\/|>|\{|&|=|!/;function v(e){this.string=e,this.tail=e,this.pos=0}function g(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function f(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}v.prototype.eos=function(){return""===this.tail},v.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},v.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},g.prototype.push=function(e){return new g(e,this)},g.prototype.lookup=function(e){var t,r,i,o=this.cache;if(o.hasOwnProperty(e))t=o[e];else{for(var a,c,l,u=this,p=!1;u;){if(e.indexOf(".")>0)for(a=u.view,c=e.split("."),l=0;null!=a&&l<c.length;)l===c.length-1&&(p=s(a,c[l])||(r=a,i=c[l],null!=r&&"object"!=typeof r&&r.hasOwnProperty&&r.hasOwnProperty(i))),a=a[c[l++]];else a=u.view[e],p=s(u.view,e);if(p){t=a;break}u=u.parent}o[e]=t}return n(t)&&(t=t.call(this.view)),t},f.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},f.prototype.parse=function(e,n){var s=this.templateCache,i=e+":"+(n||m.tags).join(":"),o=void 0!==s,c=o?s.get(i):void 0;return null==c&&(c=function(e,n){if(!e)return[];var s,i,o,c=!1,g=[],f=[],w=[],S=!1,I=!1,b="",y=0;function C(){if(S&&!I)for(;w.length;)delete f[w.pop()];else w=[];S=!1,I=!1}function E(e){if("string"==typeof e&&(e=e.split(u,2)),!t(e)||2!==e.length)throw new Error("Invalid tags: "+e);s=new RegExp(r(e[0])+"\\s*"),i=new RegExp("\\s*"+r(e[1])),o=new RegExp("\\s*"+r("}"+e[1]))}E(n||m.tags);for(var T,A,P,N,R,x,_=new v(e);!_.eos();){if(T=_.pos,P=_.scanUntil(s))for(var U=0,O=P.length;U<O;++U)a(N=P.charAt(U))?(w.push(f.length),b+=N):(I=!0,c=!0,b+=" "),f.push(["text",N,T,T+1]),T+=1,"\n"===N&&(C(),b="",y=0,c=!1);if(!_.scan(s))break;if(S=!0,A=_.scan(h)||"name",_.scan(l),"="===A?(P=_.scanUntil(p),_.scan(p),_.scanUntil(i)):"{"===A?(P=_.scanUntil(o),_.scan(d),_.scanUntil(i),A="&"):P=_.scanUntil(i),!_.scan(i))throw new Error("Unclosed tag at "+_.pos);if(R=">"==A?[A,P,T,_.pos,b,y,c]:[A,P,T,_.pos],y++,f.push(R),"#"===A||"^"===A)g.push(R);else if("/"===A){if(!(x=g.pop()))throw new Error('Unopened section "'+P+'" at '+T);if(x[1]!==P)throw new Error('Unclosed section "'+x[1]+'" at '+T)}else"name"===A||"{"===A||"&"===A?I=!0:"="===A&&E(P)}if(C(),x=g.pop())throw new Error('Unclosed section "'+x[1]+'" at '+_.pos);return function(e){for(var t,n=[],r=n,s=[],i=0,o=e.length;i<o;++i)switch((t=e[i])[0]){case"#":case"^":r.push(t),s.push(t),r=t[4]=[];break;case"/":s.pop()[5]=t[2],r=s.length>0?s[s.length-1][4]:n;break;default:r.push(t)}return n}(function(e){for(var t,n,r=[],s=0,i=e.length;s<i;++s)(t=e[s])&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}(f))}(e,n),o&&s.set(i,c)),c},f.prototype.render=function(e,t,n,r){var s=this.getConfigTags(r),i=this.parse(e,s),o=t instanceof g?t:new g(t,void 0);return this.renderTokens(i,o,n,e,r)},f.prototype.renderTokens=function(e,t,n,r,s){for(var i,o,a,c="",l=0,u=e.length;l<u;++l)a=void 0,"#"===(o=(i=e[l])[0])?a=this.renderSection(i,t,n,r,s):"^"===o?a=this.renderInverted(i,t,n,r,s):">"===o?a=this.renderPartial(i,t,n,s):"&"===o?a=this.unescapedValue(i,t):"name"===o?a=this.escapedValue(i,t,s):"text"===o&&(a=this.rawValue(i)),void 0!==a&&(c+=a);return c},f.prototype.renderSection=function(e,r,s,i,o){var a=this,c="",l=r.lookup(e[1]);if(l){if(t(l))for(var u=0,p=l.length;u<p;++u)c+=this.renderTokens(e[4],r.push(l[u]),s,i,o);else if("object"==typeof l||"string"==typeof l||"number"==typeof l)c+=this.renderTokens(e[4],r.push(l),s,i,o);else if(n(l)){if("string"!=typeof i)throw new Error("Cannot use higher-order sections without the original template");null!=(l=l.call(r.view,i.slice(e[3],e[5]),(function(e){return a.render(e,r,s,o)})))&&(c+=l)}else c+=this.renderTokens(e[4],r,s,i,o);return c}},f.prototype.renderInverted=function(e,n,r,s,i){var o=n.lookup(e[1]);if(!o||t(o)&&0===o.length)return this.renderTokens(e[4],n,r,s,i)},f.prototype.indentPartial=function(e,t,n){for(var r=t.replace(/[^ \t]/g,""),s=e.split("\n"),i=0;i<s.length;i++)s[i].length&&(i>0||!n)&&(s[i]=r+s[i]);return s.join("\n")},f.prototype.renderPartial=function(e,t,r,s){if(r){var i=this.getConfigTags(s),o=n(r)?r(e[1]):r[e[1]];if(null!=o){var a=e[6],c=e[5],l=e[4],u=o;0==c&&l&&(u=this.indentPartial(o,l,a));var p=this.parse(u,i);return this.renderTokens(p,t,r,u,s)}}},f.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(null!=n)return n},f.prototype.escapedValue=function(e,t,n){var r=this.getConfigEscape(n)||m.escape,s=t.lookup(e[1]);if(null!=s)return"number"==typeof s&&r===m.escape?String(s):r(s)},f.prototype.rawValue=function(e){return e[1]},f.prototype.getConfigTags=function(e){return t(e)?e:e&&"object"==typeof e?e.tags:void 0},f.prototype.getConfigEscape=function(e){return e&&"object"==typeof e&&!t(e)?e.escape:void 0};var m={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){w.templateCache=e},get templateCache(){return w.templateCache}},w=new f;return m.clearCache=function(){return w.clearCache()},m.parse=function(e,t){return w.parse(e,t)},m.render=function(e,n,r,s){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+((t(i=e)?"array":typeof i)+'" was given as the first argument for mustache#render(template, view, partials)'));var i;return w.render(e,n,r,s)},m.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,(function(e){return c[e]}))},m.Scanner=v,m.Context=g,m.Writer=f,m}()},715:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetWithType=void 0;class n extends EventTarget{addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}t.EventTargetWithType=n},752:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{constructor(){super(...arguments),this.startiappIsLoaded=!1}get appIntegration(){return(0,s.getIntegration)("AppIntegration")}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){this.appIntegration.setAppUrl(e)}resetAppUrl(){this.appIntegration.resetAppUrl()}openExternalBrowser(e){this.appIntegration.openBrowser(e)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,this.appIntegration.brandId()}))}requestReview(){this.appIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,this.appIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,this.appIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,this.appIntegration.getInternalDomains()}))}addInternalDomain(e){this.appIntegration.addInternalDomain(e)}removeInternalDomain(e){this.appIntegration.removeInternalDomain(e)}showStatusBar(){this.appIntegration.showStatusBar()}hideStatusBar(){this.appIntegration.hideStatusBar()}setStatusBar(e){this.appIntegration.setStatusBar(e)}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,this.appIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){this.appIntegration.disableScreenRotation()}enableScreenRotation(){this.appIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,this.appIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e),this.resolveExternalDomains=null}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e),this.resolveBrandId=null}versionResult(e){this.resolveVersion(e),this.resolveVersion=null}deviceIdResult(e){this.resolveDeviceId(e),this.resolveDeviceId=null}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e),this.resolveSetSafeAreaBackgroundColor=null}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e),this.resolveGetInternalDomains=null}}t.App=new i},1:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{constructor(){super(...arguments),this.SECURED_CONTENT_KEY="STARTI_APP_BIOMETRIC_CONTENT",this.SECURED_LOGIN_KEY="STARTI_APP_BIOMETRIC_LOGIN_CONTENT",this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}get biometricIntegration(){return(0,s.getIntegration)("BiometricIntegration")}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveScan=n,this.biometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,this.biometricIntegration.getAuthenticationType()}))}setSecuredContent(e){this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveGetContent=n,this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveGetUsernamePassword=n,this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.result);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}this.resolveGetUsernamePassword=null}hasSecuredContentResult({result:e,key:t}){if(t===this.SECURED_LOGIN_KEY)return this.resolveHasUsernameAndPassword(e),void(this.resolveHasUsernameAndPassword=null);this.resolveHasSecureContent(e),this.resolveHasSecureContent=null}getAuthenticationTypeResult(e){this.resolveAuthType(e),this.resolveAuthType=null}startScanningResult(e){this.resolveScan(e),this.resolveScan=null}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY){try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}this.resolveGetContent=null}else this.handleResolveGetUsernamePassword(e)}}t.Biometrics=new i},495:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const s=n(715),i=n(913),o=n(607);class a extends s.EventTargetWithType{registerId(e){return r(this,void 0,void 0,(function*(){const t=yield o.default.App.brandId(),n=yield o.default.App.deviceId(),r=yield o.default.PushNotification.getToken();if(!r||0===r.length)throw console.warn("Failed to register logged in client user",e,"No FCM token"),new Error(`Failed to register logged in client user ${e}: No FCM token`);const s={brandId:t,clientUserId:e,deviceId:n,fcmToken:r},a=yield fetch(i.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,s),new Error(`Failed to register logged in client user ${e}: Firebase returned statuscode ${a.status}`)}))}}t.ClientUser=new a},913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.styleTagId=t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-1fac2.cloudfunctions.net",t.styleTagId="startiapp-styling"},955:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get deviceIntegration(){return(0,s.getIntegration)("DeviceIntegration")}startAccelerometer(){this.deviceIntegration.startAccelerometer()}stopAccelerometer(){this.deviceIntegration.stopAccelerometer()}isAccelerometerStarted(){return new Promise(((e,t)=>{this.deviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e),this.resolveIsAccelerometerStarted=null}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new i},900:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],r=0;for(;!t&&r<5;)t=window.parent[e],r++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(752),s=n(1),i=n(495),o=n(955),a=n(900),c=n(983),l=n(681),u=n(952),p=n(716),d=n(634),h=window;h.appIntegrationsAreReady=()=>{r.App.setStartiappIsLoaded(),g.dispatchEvent(new CustomEvent("ready"))},h.startiappDevice=o.Device,h.startiappApp=r.App,h.startiappUser=i.ClientUser,h.startiappQrScanner=u.QrScanner,h.startiappPushNotification=l.PushNotification,h.startiappNFC=c.NFC,h.startiappShare=d.Share,h.startiappBiometric=s.Biometrics,h.appErrorEvent=e=>{g.dispatchEvent(new CustomEvent("error",{detail:e}))};class v extends EventTarget{constructor(){super(...arguments),this.App=r.App,this.Device=o.Device,this.Biometrics=s.Biometrics,this.User=i.ClientUser,this.NfcScanner=c.NFC,this.PushNotification=l.PushNotification,this.QrScanner=u.QrScanner,this.Share=d.Share}get appIntegration(){return(0,a.getIntegration)("AppIntegration")}initialize(e){this.isRunningInApp()&&p.AppUI.setOptions(e),this.appIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}const g=new v;if(document.body)f();else{const e=new MutationObserver((()=>f(e)));e.observe(document.documentElement,{childList:!0})}function f(e){if(!document.body)return;g.isRunningInApp()&&document.body.setAttribute("startiapp","true");const t=document.createElement("style");t.innerHTML="body:not([startiapp]) .startiapp-hide-in-browser,body:not([startiapp]) .startiapp-show-in-app,body[startiapp] .startiapp-hide-in-app,body[startiapp] .startiapp-show-in-browser{display:none!important}",document.head.appendChild(t),e&&e.disconnect()}t.default=g,h.startiapp=g},983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get NFCIntegration(){return(0,s.getIntegration)("NFCIntegration")}isNfcSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,this.NFCIntegration.isNFCSupported()}))}startNfcScanner(){return new Promise((e=>{this.resolveStartNFCReader=e,this.NFCIntegration.startListening()}))}stopNfcScanner(){return new Promise((e=>{this.resolveStopNFCReader=e,this.NFCIntegration.stopListening()}))}nfcTagScannedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}stopListeningResult(e){this.resolveStopNFCReader(e),this.resolveStopNFCReader=null}isNFCSupportedResult(e){this.resolveNFCSupported(e),this.resolveNFCSupported=null}startListeningResult(e){this.resolveStartNFCReader(e),this.resolveStartNFCReader=null}}t.NFC=new i},681:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=t.Topic=void 0;const s=n(466),i=n(715),o=n(913),a=n(900),c=n(607);class l extends i.EventTargetWithType{get pushNotificationIntegration(){return(0,a.getIntegration)("PushNotificationIntegration")}requestAccess(){return r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,this.pushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,this.pushNotificationIntegration.getFCMToken()}))}getTopics(){return r(this,void 0,void 0,(function*(){const e={brand:yield c.default.App.brandId()},t=yield fetch(o.baseUrl+"/Newsletter-getTopics?"+new URLSearchParams(Object.assign({},e)));if(!t.ok)throw new Error("Failed to get topics");const n=yield t.json(),r=this.getSubscribedTopics();return n.map((({name:e,topic:t})=>new u(t,e,r.includes(t))))}))}renderTopics(){return r(this,void 0,void 0,(function*(){const e=yield this.getTopics(),t=document.getElementById("startiapp-topics-template");if(!t||"SCRIPT"!==t.tagName)throw new Error("Template element not found");if("x-tmpl-mustache"!==t.type)throw new Error('Template element must have type="x-tmpl-mustache"');const n=document.getElementById("startiapp-topics-target");if(!n||"DIV"!==n.tagName)throw new Error("Template target element not found");const i=t.innerHTML,o=(0,s.render)(i,{topics:e});n.innerHTML=o,n.querySelectorAll('input[type="checkbox"]').forEach((e=>{e.dataset.startiappTopic&&e.addEventListener("change",(t=>r(this,void 0,void 0,(function*(){if(!(yield this.requestAccess()))return t.target.checked=!1,void t.preventDefault();e.checked?this.subscribeToTopics([e.dataset.startiappTopic]):this.unsubscribeFromTopics([e.dataset.startiappTopic])}))))}))}))}subscribeToTopics(e){return r(this,void 0,void 0,(function*(){const[t,n,r]=yield Promise.all([this.getToken(),c.default.App.brandId(),c.default.App.deviceId()]),s=[];e.forEach((e=>{const i={brandId:n,topic:e,fcmToken:t,deviceId:r},a=fetch(o.baseUrl+"/Newsletter-subscribeToTopic",{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json"}});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok?this.updateSubscribedTopics(e[n],!0):console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return r(this,void 0,void 0,(function*(){const[t,n,r]=yield Promise.all([this.getToken(),c.default.App.brandId(),c.default.App.deviceId()]),s=[];e.forEach((e=>{const i={brandId:n,topic:e,fcmToken:t,deviceId:r},a=fetch(o.baseUrl+"/Newsletter-unsubscribeFromTopic",{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json"}});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok?this.updateSubscribedTopics(e[n],!1):console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e),this.resolveRequestAccess=null}getFCMTokenResult(e){this.resolveFCMToken(e),this.resolveFCMToken=null}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}updateSubscribedTopics(e,t){const n=localStorage.getItem("startiapp-subscribed-topics")?JSON.parse(localStorage.getItem("startiapp-subscribed-topics")):[];t?n.includes(e)||n.push(e):n.includes(e)&&n.splice(n.indexOf(e),1),localStorage.setItem("startiapp-subscribed-topics",JSON.stringify(n))}getSubscribedTopics(){return localStorage.getItem("startiapp-subscribed-topics")?JSON.parse(localStorage.getItem("startiapp-subscribed-topics")):[]}}class u{constructor(e,t,n=!1){this.topic=e,this.name=t,this.subscribed=n}toJSON(){return{topic:this.topic,name:this.name,subscribed:this.subscribed}}subscribe(){t.PushNotification.subscribeToTopics([this.topic])}unsubscribe(){t.PushNotification.unsubscribeFromTopics([this.topic])}}t.Topic=u,t.PushNotification=new l},952:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get qrScannerIntegration(){return(0,s.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e),this.resolveRequestCameraAccess=null}startQrCodeScannerResult(e){this.resolveScan(e),this.resolveScan=null}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e),this.resolveCameraAccessGranted=null}}t.QrScanner=new i},716:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const r=n(913);t.AppUI=new class{constructor(){this.options={allowDrag:!1,allowHighligt:!1,allowZoom:!1,allowScrollBounce:!1}}setOptions(e){this.options=Object.assign(this.options,e),null!=document.querySelector('meta[name="viewport"]')&&void 0===this.initialViewportMetaContent&&(this.initialViewportMetaContent=document.querySelector('meta[name="viewport"]').getAttribute("content")),this.initialViewportMetaContent.includes("viewport-fit=cover")||(this.initialViewportMetaContent+=", viewport-fit=cover"),this.updateUI()}getOptions(){return this.options}updateUI(){this.styleString="";const e=document.getElementById(r.styleTagId);e&&e.remove();const t=document.getElementsByTagName("img"),n=document.getElementsByTagName("a");this.options.allowDrag?[...t,...n].forEach((e=>{e.removeAttribute("draggable")})):[...t,...n].forEach((e=>{e.setAttribute("draggable","false")}));let s=document.querySelector("meta[name=viewport]");this.options.allowHighligt||(this.styleString+="\n body {\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -o-user-select: none; \n user-select: none;\n }\n "),this.options.allowScrollBounce||(this.styleString+="\n html {\n overscroll-behavior: none;\n }\n "),this.options.allowZoom?s.setAttribute("content",this.initialViewportMetaContent):(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",s.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, viewport-fit=cover"));const i=document.createElement("style");i.textContent=this.styleString,i.setAttribute("id",r.styleTagId),document.body.appendChild(i)}}},634:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Share=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get shareIntegration(){return(0,s.getIntegration)("ShareIntegration")}shareFile(e,t){return new Promise(((n,r)=>{this.resolveShareFile=n,this.shareIntegration.shareFile(e,t)}))}shareText(e){return new Promise(((t,n)=>{this.resolveShareText=t,this.shareIntegration.shareText(e)}))}downloadFile(e,t){return new Promise(((n,r)=>{this.resolveDownloadText=n,this.shareIntegration.downloadFile(e,t)}))}shareFileResult(e){this.resolveShareFile(e),this.resolveShareFile=null}shareTextResult(e){this.resolveShareText(e),this.resolveShareText=null}downloadFileResult(e){this.resolveDownloadText(e),this.resolveDownloadText=null}}t.Share=new i}},t={},function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(607);var e,t}));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>{return e={466:function(e){e.exports=function(){"use strict";var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)};function n(e){return"function"==typeof e}function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function s(e,t){return null!=e&&"object"==typeof e&&t in e}var i=RegExp.prototype.test;var o=/\S/;function a(e){return!function(e,t){return i.call(e,t)}(o,e)}var c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};var l=/\s*/,u=/\s+/,p=/\s*=/,d=/\s*\}/,h=/#|\^|\/|>|\{|&|=|!/;function v(e){this.string=e,this.tail=e,this.pos=0}function g(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function f(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}v.prototype.eos=function(){return""===this.tail},v.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},v.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},g.prototype.push=function(e){return new g(e,this)},g.prototype.lookup=function(e){var t,r,i,o=this.cache;if(o.hasOwnProperty(e))t=o[e];else{for(var a,c,l,u=this,p=!1;u;){if(e.indexOf(".")>0)for(a=u.view,c=e.split("."),l=0;null!=a&&l<c.length;)l===c.length-1&&(p=s(a,c[l])||(r=a,i=c[l],null!=r&&"object"!=typeof r&&r.hasOwnProperty&&r.hasOwnProperty(i))),a=a[c[l++]];else a=u.view[e],p=s(u.view,e);if(p){t=a;break}u=u.parent}o[e]=t}return n(t)&&(t=t.call(this.view)),t},f.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},f.prototype.parse=function(e,n){var s=this.templateCache,i=e+":"+(n||m.tags).join(":"),o=void 0!==s,c=o?s.get(i):void 0;return null==c&&(c=function(e,n){if(!e)return[];var s,i,o,c=!1,g=[],f=[],w=[],b=!1,S=!1,I="",y=0;function E(){if(b&&!S)for(;w.length;)delete f[w.pop()];else w=[];b=!1,S=!1}function C(e){if("string"==typeof e&&(e=e.split(u,2)),!t(e)||2!==e.length)throw new Error("Invalid tags: "+e);s=new RegExp(r(e[0])+"\\s*"),i=new RegExp("\\s*"+r(e[1])),o=new RegExp("\\s*"+r("}"+e[1]))}C(n||m.tags);for(var T,A,P,N,R,x,_=new v(e);!_.eos();){if(T=_.pos,P=_.scanUntil(s))for(var O=0,U=P.length;O<U;++O)a(N=P.charAt(O))?(w.push(f.length),I+=N):(S=!0,c=!0,I+=" "),f.push(["text",N,T,T+1]),T+=1,"\n"===N&&(E(),I="",y=0,c=!1);if(!_.scan(s))break;if(b=!0,A=_.scan(h)||"name",_.scan(l),"="===A?(P=_.scanUntil(p),_.scan(p),_.scanUntil(i)):"{"===A?(P=_.scanUntil(o),_.scan(d),_.scanUntil(i),A="&"):P=_.scanUntil(i),!_.scan(i))throw new Error("Unclosed tag at "+_.pos);if(R=">"==A?[A,P,T,_.pos,I,y,c]:[A,P,T,_.pos],y++,f.push(R),"#"===A||"^"===A)g.push(R);else if("/"===A){if(!(x=g.pop()))throw new Error('Unopened section "'+P+'" at '+T);if(x[1]!==P)throw new Error('Unclosed section "'+x[1]+'" at '+T)}else"name"===A||"{"===A||"&"===A?S=!0:"="===A&&C(P)}if(E(),x=g.pop())throw new Error('Unclosed section "'+x[1]+'" at '+_.pos);return function(e){for(var t,n=[],r=n,s=[],i=0,o=e.length;i<o;++i)switch((t=e[i])[0]){case"#":case"^":r.push(t),s.push(t),r=t[4]=[];break;case"/":s.pop()[5]=t[2],r=s.length>0?s[s.length-1][4]:n;break;default:r.push(t)}return n}(function(e){for(var t,n,r=[],s=0,i=e.length;s<i;++s)(t=e[s])&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}(f))}(e,n),o&&s.set(i,c)),c},f.prototype.render=function(e,t,n,r){var s=this.getConfigTags(r),i=this.parse(e,s),o=t instanceof g?t:new g(t,void 0);return this.renderTokens(i,o,n,e,r)},f.prototype.renderTokens=function(e,t,n,r,s){for(var i,o,a,c="",l=0,u=e.length;l<u;++l)a=void 0,"#"===(o=(i=e[l])[0])?a=this.renderSection(i,t,n,r,s):"^"===o?a=this.renderInverted(i,t,n,r,s):">"===o?a=this.renderPartial(i,t,n,s):"&"===o?a=this.unescapedValue(i,t):"name"===o?a=this.escapedValue(i,t,s):"text"===o&&(a=this.rawValue(i)),void 0!==a&&(c+=a);return c},f.prototype.renderSection=function(e,r,s,i,o){var a=this,c="",l=r.lookup(e[1]);if(l){if(t(l))for(var u=0,p=l.length;u<p;++u)c+=this.renderTokens(e[4],r.push(l[u]),s,i,o);else if("object"==typeof l||"string"==typeof l||"number"==typeof l)c+=this.renderTokens(e[4],r.push(l),s,i,o);else if(n(l)){if("string"!=typeof i)throw new Error("Cannot use higher-order sections without the original template");null!=(l=l.call(r.view,i.slice(e[3],e[5]),(function(e){return a.render(e,r,s,o)})))&&(c+=l)}else c+=this.renderTokens(e[4],r,s,i,o);return c}},f.prototype.renderInverted=function(e,n,r,s,i){var o=n.lookup(e[1]);if(!o||t(o)&&0===o.length)return this.renderTokens(e[4],n,r,s,i)},f.prototype.indentPartial=function(e,t,n){for(var r=t.replace(/[^ \t]/g,""),s=e.split("\n"),i=0;i<s.length;i++)s[i].length&&(i>0||!n)&&(s[i]=r+s[i]);return s.join("\n")},f.prototype.renderPartial=function(e,t,r,s){if(r){var i=this.getConfigTags(s),o=n(r)?r(e[1]):r[e[1]];if(null!=o){var a=e[6],c=e[5],l=e[4],u=o;0==c&&l&&(u=this.indentPartial(o,l,a));var p=this.parse(u,i);return this.renderTokens(p,t,r,u,s)}}},f.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(null!=n)return n},f.prototype.escapedValue=function(e,t,n){var r=this.getConfigEscape(n)||m.escape,s=t.lookup(e[1]);if(null!=s)return"number"==typeof s&&r===m.escape?String(s):r(s)},f.prototype.rawValue=function(e){return e[1]},f.prototype.getConfigTags=function(e){return t(e)?e:e&&"object"==typeof e?e.tags:void 0},f.prototype.getConfigEscape=function(e){return e&&"object"==typeof e&&!t(e)?e.escape:void 0};var m={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){w.templateCache=e},get templateCache(){return w.templateCache}},w=new f;return m.clearCache=function(){return w.clearCache()},m.parse=function(e,t){return w.parse(e,t)},m.render=function(e,n,r,s){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+((t(i=e)?"array":typeof i)+'" was given as the first argument for mustache#render(template, view, partials)'));var i;return w.render(e,n,r,s)},m.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,(function(e){return c[e]}))},m.Scanner=v,m.Context=g,m.Writer=f,m}()},715:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetWithType=void 0;class n extends EventTarget{addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}t.EventTargetWithType=n},752:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.App=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{constructor(){super(...arguments),this.startiappIsLoaded=!1}get appIntegration(){return(0,s.getIntegration)("AppIntegration")}setStartiappIsLoaded(){this.startiappIsLoaded=!0}isStartiappLoaded(){return this.startiappIsLoaded}setAppUrl(e){this.appIntegration.setAppUrl(e)}resetAppUrl(){this.appIntegration.resetAppUrl()}openExternalBrowser(e){this.appIntegration.openBrowser(e)}brandId(){return new Promise(((e,t)=>{this.resolveBrandId=e,this.appIntegration.brandId()}))}requestReview(){this.appIntegration.requestReview()}deviceId(){return new Promise(((e,t)=>{this.resolveDeviceId=e,this.appIntegration.deviceId()}))}version(){return new Promise(((e,t)=>{this.resolveVersion=e,this.appIntegration.version()}))}getInternalDomains(){return new Promise(((e,t)=>{this.resolveGetInternalDomains=e,this.appIntegration.getInternalDomains()}))}addInternalDomain(e){this.appIntegration.addInternalDomain(e)}removeInternalDomain(e){this.appIntegration.removeInternalDomain(e)}showStatusBar(){this.appIntegration.showStatusBar()}hideStatusBar(){this.appIntegration.hideStatusBar()}setStatusBar(e){this.appIntegration.setStatusBar(e)}setSafeAreaBackgroundColor(e){return new Promise(((t,n)=>{this.resolveSetSafeAreaBackgroundColor=t,this.appIntegration.setSafeAreaBackgroundColor(e)}))}disableScreenRotation(){this.appIntegration.disableScreenRotation()}enableScreenRotation(){this.appIntegration.enableScreenRotation()}addExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.addExternalDomains(t)}removeExternalDomains(...e){let t=e.map((e=>({pattern:e.source,flags:e.flags})));this.appIntegration.removeExternalDomains(t)}getExternalDomains(){return new Promise(((e,t)=>{this.resolveExternalDomains=e,this.appIntegration.getExternalDomains()}))}getExternalDomainsResult(e){this.resolveExternalDomains(e),this.resolveExternalDomains=null}appInForegroundEventRecievedEvent(){this.dispatchEvent(new CustomEvent("appInForeground"))}brandIdResult(e){this.resolveBrandId(e),this.resolveBrandId=null}versionResult(e){this.resolveVersion(e),this.resolveVersion=null}deviceIdResult(e){this.resolveDeviceId(e),this.resolveDeviceId=null}setSafeAreaBackgroundColorResult(e){this.resolveSetSafeAreaBackgroundColor(e),this.resolveSetSafeAreaBackgroundColor=null}navigatingPageEvent(e){this.dispatchEvent(new CustomEvent("navigatingPage",{detail:e}))}getInternalDomainsResult(e){this.resolveGetInternalDomains(e),this.resolveGetInternalDomains=null}}t.App=new i},1:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Biometrics=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{constructor(){super(...arguments),this.SECURED_CONTENT_KEY="STARTI_APP_BIOMETRIC_CONTENT",this.SECURED_LOGIN_KEY="STARTI_APP_BIOMETRIC_LOGIN_CONTENT",this.defaultScanTitle="Prove you have fingers!",this.defaultScanReason="Can't let you in if you don't."}get biometricIntegration(){return(0,s.getIntegration)("BiometricIntegration")}scan(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveScan=n,this.biometricIntegration.startScanning(e,t)}))}getAuthenticationType(){return new Promise(((e,t)=>{this.resolveAuthType=e,this.biometricIntegration.getAuthenticationType()}))}setSecuredContent(e){this.biometricIntegration.setSecuredContent(this.SECURED_CONTENT_KEY,JSON.stringify(e))}getSecuredContent(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveGetContent=n,this.biometricIntegration.getSecuredContent(this.SECURED_CONTENT_KEY,e,t)}))}hasSecuredContent(){return new Promise(((e,t)=>{this.resolveHasSecureContent=e,this.biometricIntegration.hasSecuredContent(this.SECURED_CONTENT_KEY)}))}removeSecuredContent(){this.biometricIntegration.removeSecuredContent(this.SECURED_CONTENT_KEY)}setUsernameAndPassword(e,t){this.biometricIntegration.setSecuredContent(this.SECURED_LOGIN_KEY,JSON.stringify({username:e,password:t}))}removeUsernameAndPassword(){this.biometricIntegration.removeSecuredContent(this.SECURED_LOGIN_KEY)}hasUsernameAndPassword(){return new Promise(((e,t)=>{this.resolveHasUsernameAndPassword=e,this.biometricIntegration.hasSecuredContent(this.SECURED_LOGIN_KEY)}))}getUsernameAndPassword(e=this.defaultScanTitle,t=this.defaultScanReason){return new Promise(((n,r)=>{this.resolveGetUsernamePassword=n,this.biometricIntegration.getSecuredContent(this.SECURED_LOGIN_KEY,e,t)}))}handleResolveGetUsernamePassword(e){try{const t=JSON.parse(e.result);this.resolveGetUsernamePassword(t)}catch(e){this.resolveGetUsernamePassword(null)}this.resolveGetUsernamePassword=null}hasSecuredContentResult({result:e,key:t}){if(t===this.SECURED_LOGIN_KEY)return this.resolveHasUsernameAndPassword(e),void(this.resolveHasUsernameAndPassword=null);this.resolveHasSecureContent(e),this.resolveHasSecureContent=null}getAuthenticationTypeResult(e){this.resolveAuthType(e),this.resolveAuthType=null}startScanningResult(e){this.resolveScan(e),this.resolveScan=null}getSecuredContentResult(e){if(e.key!==this.SECURED_LOGIN_KEY){try{const t=JSON.parse(e.result);this.resolveGetContent(t)}catch(t){this.resolveGetContent(e.result)}this.resolveGetContent=null}else this.handleResolveGetUsernamePassword(e)}}t.Biometrics=new i},495:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientUser=void 0;const s=n(715),i=n(913),o=n(607);class a extends s.EventTargetWithType{registerId(e){return r(this,void 0,void 0,(function*(){const t=yield o.default.App.brandId(),n=yield o.default.App.deviceId(),r=yield o.default.PushNotification.getToken();if(!r||0===r.length)throw console.warn("Failed to register logged in client user",e,"No FCM token"),new Error(`Failed to register logged in client user ${e}: No FCM token`);const s={brandId:t,clientUserId:e,deviceId:n,fcmToken:r},a=yield fetch(i.baseUrl+"/ClientUser-registerId",{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"});if(!a.ok)throw console.warn("Failed to register logged in client user",e,s),new Error(`Failed to register logged in client user ${e}: Firebase returned statuscode ${a.status}`)}))}}t.ClientUser=new a},913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.styleTagId=t.baseUrl=void 0,t.baseUrl="https://europe-west3-startiapp-admin-1fac2.cloudfunctions.net",t.styleTagId="startiapp-styling"},955:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Device=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get deviceIntegration(){return(0,s.getIntegration)("DeviceIntegration")}startAccelerometer(){this.deviceIntegration.startAccelerometer()}stopAccelerometer(){this.deviceIntegration.stopAccelerometer()}isAccelerometerStarted(){return new Promise(((e,t)=>{this.deviceIntegration.isAccelerometerStarted(),this.resolveIsAccelerometerStarted=e}))}isAccelerometerStartedResult(e){this.resolveIsAccelerometerStarted(e),this.resolveIsAccelerometerStarted=null}onShakeEvent(){this.dispatchEvent(new CustomEvent("shake"))}}t.Device=new i},900:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIntegration=void 0;let n={};t.getIntegration=function(e){if(n[e])return n[e];let t=window[e],r=0;for(;!t&&r<5;)t=window.parent[e],r++;if(!t)throw new Error(`Could not find integration ${e}`);return n[e]=t,t}},607:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(752),s=n(1),i=n(495),o=n(955),a=n(900),c=n(240),l=n(983),u=n(681),p=n(952),d=n(716),h=n(634),v=window;v.appIntegrationsAreReady=()=>{r.App.setStartiappIsLoaded(),f.dispatchEvent(new CustomEvent("ready"))},v.startiappDevice=o.Device,v.startiappApp=r.App,v.startiappUser=i.ClientUser,v.startiappQrScanner=p.QrScanner,v.startiappPushNotification=u.PushNotification,v.startiappNFC=l.NFC,v.startiappShare=h.Share,v.startiappBiometric=s.Biometrics,v.appErrorEvent=e=>{f.dispatchEvent(new CustomEvent("error",{detail:e}))};class g extends EventTarget{constructor(){super(...arguments),this.App=r.App,this.Device=o.Device,this.Biometrics=s.Biometrics,this.User=i.ClientUser,this.NfcScanner=l.NFC,this.PushNotification=u.PushNotification,this.QrScanner=p.QrScanner,this.Share=h.Share}get appIntegration(){return(0,a.getIntegration)("AppIntegration")}initialize(e){this.isRunningInApp()&&d.AppUI.setOptions(e),this.appIntegration.webAppIsReady()}isRunningInApp(){return navigator.userAgent.toLowerCase().indexOf("starti.app")>-1}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}}const f=new g;if(document.body)m();else{const e=new MutationObserver((()=>m(e)));e.observe(document.documentElement,{childList:!0})}function m(e){if(!document.body)return;if(f.isRunningInApp()?document.body.setAttribute("startiapp",""):document.body.removeAttribute("startiapp"),!document.head)return;const t=document.createElement("style");if(t.innerHTML="body:not([startiapp]) .startiapp-hide-in-browser,body:not([startiapp]) .startiapp-show-in-app,body[startiapp] .startiapp-hide-in-app,body[startiapp] .startiapp-show-in-browser{display:none!important}",document.head.appendChild(t),f.isRunningInApp()){const e={width:"device-width","viewport-fit":"cover"},t=document.querySelector("meta[name=viewport]");if(t){const n=(0,c.parseViewportMeta)(t.content);t.content=(0,c.serializeViewportMeta)(Object.assign(Object.assign({},n),e))}else{const t=document.createElement("meta");t.name="viewport",t.content=(0,c.serializeViewportMeta)(e),document.head.appendChild(t)}}e&&e.disconnect()}t.default=f,v.startiapp=f},240:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serializeViewportMeta=t.parseViewportMeta=void 0,t.parseViewportMeta=function(e){const t={},n=e.split(",");for(const e of n){const[n,r]=e.trim().split("=");switch(n.trim()){case"width":case"height":case"initial-scale":case"minimum-scale":case"maximum-scale":case"user-scalable":case"viewport-fit":t[n.trim()]=r.trim()}}return t},t.serializeViewportMeta=function(e){const t=[];for(const[n,r]of Object.entries(e))r&&t.push(`${n}=${r}`);return t.join(", ")}},983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NFC=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get NFCIntegration(){return(0,s.getIntegration)("NFCIntegration")}isNfcSupported(){return new Promise(((e,t)=>{this.resolveNFCSupported=e,this.NFCIntegration.isNFCSupported()}))}startNfcScanner(){return new Promise((e=>{this.resolveStartNFCReader=e,this.NFCIntegration.startListening()}))}stopNfcScanner(){return new Promise((e=>{this.resolveStopNFCReader=e,this.NFCIntegration.stopListening()}))}nfcTagScannedEvent(e){const t=new CustomEvent("nfcTagScanned",{detail:e});this.dispatchEvent(t)}stopListeningResult(e){this.resolveStopNFCReader(e),this.resolveStopNFCReader=null}isNFCSupportedResult(e){this.resolveNFCSupported(e),this.resolveNFCSupported=null}startListeningResult(e){this.resolveStartNFCReader(e),this.resolveStartNFCReader=null}}t.NFC=new i},681:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,i){function o(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PushNotification=t.Topic=void 0;const s=n(466),i=n(715),o=n(913),a=n(900),c=n(607);class l extends i.EventTargetWithType{get pushNotificationIntegration(){return(0,a.getIntegration)("PushNotificationIntegration")}requestAccess(){return r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this.resolveRequestAccess=e,this.pushNotificationIntegration.requestAccess()}))}))}getToken(){return new Promise(((e,t)=>{this.resolveFCMToken=e,this.pushNotificationIntegration.getFCMToken()}))}getTopics(){return r(this,void 0,void 0,(function*(){const e={brand:yield c.default.App.brandId()},t=yield fetch(o.baseUrl+"/Newsletter-getTopics?"+new URLSearchParams(Object.assign({},e)));if(!t.ok)throw new Error("Failed to get topics");const n=yield t.json(),r=this.getSubscribedTopics();return n.map((({name:e,topic:t})=>new u(t,e,r.includes(t))))}))}renderTopics(){return r(this,void 0,void 0,(function*(){const e=yield this.getTopics(),t=document.getElementById("startiapp-topics-template");if(!t||"SCRIPT"!==t.tagName)throw new Error("Template element not found");if("x-tmpl-mustache"!==t.type)throw new Error('Template element must have type="x-tmpl-mustache"');const n=document.getElementById("startiapp-topics-target");if(!n||"DIV"!==n.tagName)throw new Error("Template target element not found");const i=t.innerHTML,o=(0,s.render)(i,{topics:e});n.innerHTML=o,n.querySelectorAll('input[type="checkbox"]').forEach((e=>{e.dataset.startiappTopic&&e.addEventListener("change",(t=>r(this,void 0,void 0,(function*(){if(!(yield this.requestAccess()))return t.target.checked=!1,void t.preventDefault();e.checked?this.subscribeToTopics([e.dataset.startiappTopic]):this.unsubscribeFromTopics([e.dataset.startiappTopic])}))))}))}))}subscribeToTopics(e){return r(this,void 0,void 0,(function*(){const[t,n,r]=yield Promise.all([this.getToken(),c.default.App.brandId(),c.default.App.deviceId()]),s=[];e.forEach((e=>{const i={brandId:n,topic:e,fcmToken:t,deviceId:r},a=fetch(o.baseUrl+"/Newsletter-subscribeToTopic",{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json"}});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok?this.updateSubscribedTopics(e[n],!0):console.warn("Failed to sign up to topic",n,e[n])}))}))}unsubscribeFromTopics(e){return r(this,void 0,void 0,(function*(){const[t,n,r]=yield Promise.all([this.getToken(),c.default.App.brandId(),c.default.App.deviceId()]),s=[];e.forEach((e=>{const i={brandId:n,topic:e,fcmToken:t,deviceId:r},a=fetch(o.baseUrl+"/Newsletter-unsubscribeFromTopic",{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json"}});s.push(a)})),(yield Promise.all(s)).forEach(((t,n)=>{t.ok?this.updateSubscribedTopics(e[n],!1):console.warn("Failed to unsubscribe from topic",n,e[n])}))}))}requestAccessResult(e){this.resolveRequestAccess(e),this.resolveRequestAccess=null}getFCMTokenResult(e){this.resolveFCMToken(e),this.resolveFCMToken=null}tokenReceivedEvent(e){this.dispatchEvent(new CustomEvent("tokenRefreshed",{detail:e}))}notificationReceivedEvent(e){this.dispatchEvent(new CustomEvent("notificationReceived",{detail:e}))}firebasePushNotificationTopicsUnsubscribeResult(e){}firebasePushNotificationSubscribeToTopicsResult(e){}updateSubscribedTopics(e,t){const n=localStorage.getItem("startiapp-subscribed-topics")?JSON.parse(localStorage.getItem("startiapp-subscribed-topics")):[];t?n.includes(e)||n.push(e):n.includes(e)&&n.splice(n.indexOf(e),1),localStorage.setItem("startiapp-subscribed-topics",JSON.stringify(n))}getSubscribedTopics(){return localStorage.getItem("startiapp-subscribed-topics")?JSON.parse(localStorage.getItem("startiapp-subscribed-topics")):[]}}class u{constructor(e,t,n=!1){this.topic=e,this.name=t,this.subscribed=n}toJSON(){return{topic:this.topic,name:this.name,subscribed:this.subscribed}}subscribe(){t.PushNotification.subscribeToTopics([this.topic])}unsubscribe(){t.PushNotification.unsubscribeFromTopics([this.topic])}}t.Topic=u,t.PushNotification=new l},952:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QrScanner=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get qrScannerIntegration(){return(0,s.getIntegration)("QrScannerIntegration")}scan(){return new Promise(((e,t)=>{this.resolveScan=e,this.qrScannerIntegration.startQrCodeScanner()}))}isCameraAccessGranted(){return new Promise(((e,t)=>{this.resolveCameraAccessGranted=e,this.qrScannerIntegration.isCameraAccessGranted()}))}requestCameraAccess(){return new Promise(((e,t)=>{this.resolveRequestCameraAccess=e,this.qrScannerIntegration.requestCameraAccess()}))}requestCameraAccessResult(e){this.resolveRequestCameraAccess(e),this.resolveRequestCameraAccess=null}startQrCodeScannerResult(e){this.resolveScan(e),this.resolveScan=null}isCameraAccessGrantedResult(e){this.resolveCameraAccessGranted(e),this.resolveCameraAccessGranted=null}}t.QrScanner=new i},716:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppUI=void 0;const r=n(913),s=n(240);t.AppUI=new class{constructor(){this.options={allowDrag:!1,allowHighligt:!1,allowZoom:!1,allowScrollBounce:!1}}setOptions(e){this.options=Object.assign(this.options,e),this.updateUI()}getOptions(){return this.options}updateViewportMeta(e){const t=document.querySelector("meta[name=viewport]");if(t){const n=(0,s.parseViewportMeta)(t.content);t.content=(0,s.serializeViewportMeta)(Object.assign(Object.assign({},n),e))}else{const t=document.createElement("meta");t.setAttribute("name","viewport"),t.setAttribute("content",(0,s.serializeViewportMeta)(e)),document.head.appendChild(t)}}updateUI(){this.styleString="";const e=document.getElementById(r.styleTagId);e&&e.remove();const t=document.getElementsByTagName("img"),n=document.getElementsByTagName("a");this.options.allowDrag?[...t,...n].forEach((e=>{e.removeAttribute("draggable")})):[...t,...n].forEach((e=>{e.setAttribute("draggable","false")})),this.options.allowHighligt||(this.styleString+="\n body {\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n user-select: none;\n }\n "),this.options.allowScrollBounce||(this.styleString+="\n html {\n overscroll-behavior: none;\n }\n "),this.options.allowZoom||(this.styleString+="\n body {\n touch-action: pan-x pan-y;\n }\n ",this.updateViewportMeta({"user-scalable":"no"}));const s=document.createElement("style");s.textContent=this.styleString,s.setAttribute("id",r.styleTagId),document.body.appendChild(s)}}},634:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Share=void 0;const r=n(715),s=n(900);class i extends r.EventTargetWithType{get shareIntegration(){return(0,s.getIntegration)("ShareIntegration")}shareFile(e,t){return new Promise(((n,r)=>{this.resolveShareFile=n,this.shareIntegration.shareFile(e,t)}))}shareText(e){return new Promise(((t,n)=>{this.resolveShareText=t,this.shareIntegration.shareText(e)}))}downloadFile(e,t){return new Promise(((n,r)=>{this.resolveDownloadText=n,this.shareIntegration.downloadFile(e,t)}))}shareFileResult(e){this.resolveShareFile(e),this.resolveShareFile=null}shareTextResult(e){this.resolveShareText(e),this.resolveShareText=null}downloadFileResult(e){this.resolveDownloadText(e),this.resolveDownloadText=null}}t.Share=new i}},t={},function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(607);var e,t}));