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AA,EAAM,EAAM,EAAE,EAEjF,AAAA,EAAmB,CACf,WAAY,OACZ,eAAgB,EAAI,WAAW,EACnC,GACK,KAAK,CAAC,AAAA,IACH,QAAQ,KAAK,CAAC,EAClB,EACR,EAAG,IACP,CACJ,GACC,KAAK,CAAC,AAAA,IACH,QAAQ,KAAK,CAAC,EAClB,EAEZ,CACJ,C,C","sources":["","src/integration.ts","../../../../../node_modules/.aspect_rules_js/@repo+cookies@0.0.0/node_modules/@repo/cookies/src/cookies.ts","../../../../../node_modules/.aspect_rules_js/@repo+urlhelper@0.0.0/node_modules/@repo/urlhelper/src/main.ts","../../../../../node_modules/.aspect_rules_js/@repo+urlhelper@0.0.0/node_modules/@repo/urlhelper/src/absoluteurl/getAbsoluteURL.ts","src/csat/csat.ts"],"sourcesContent":["(() => {\nfunction $2fba7cc17b35f244$export$4be65e66cfa2648a(cname) {\n const name = cname + \"=\";\n const decodedCookie = decodeURIComponent(document.cookie);\n const ca = decodedCookie.split(\";\");\n for(let i = 0; i < ca.length; i++){\n let c = ca[i];\n while(c.charAt(0) == \" \")c = c.substring(1);\n if (c.indexOf(name) == 0) return c.substring(name.length, c.length);\n }\n return \"\";\n}\nfunction $2fba7cc17b35f244$export$110700823644f4a6(name, value, path = \"/\") {\n const expires = new Date();\n expires.setTime(expires.getTime() + 31536000000);\n document.cookie = `${name}=${value};Path=${path};Expires=${expires.toUTCString()};SameSite=None;Secure;`;\n}\nfunction $2fba7cc17b35f244$export$6a874b7a74007875(name, path = \"/\") {\n document.cookie = `${name}=;Path=${path};Expires=Thu, 01 Jan 1970 00:00:01 GMT};SameSite=None;Secure;`;\n}\n\n\nfunction $acd838a2cd54fa85$export$2e2bcd8739ae039(url) {\n const anchorElement = document.createElement(\"a\");\n anchorElement.href = url; // now href is an absolute uri.\n return anchorElement.href;\n}\n\n\nconst $0adb5bcfe0bdd84b$export$3e2c416251316c0d = (0, $acd838a2cd54fa85$export$2e2bcd8739ae039);\n\n\nasync function $90b3f8835f10c8aa$export$a29223f6da1220a5(messageID) {\n const response = await fetch(\"/contact/csat/\" + messageID, {\n method: \"GET\",\n headers: {\n \"Accept\": \"application/json\"\n }\n });\n if (!response.ok) {\n if (response.status == 404) return {\n message_id: messageID,\n last_submitted: \"1900-01-01\"\n };\n throw new Error(`get customer satisfaction score failed. Status ${response.status}: ${response.statusText}`);\n }\n return await response.json();\n}\nasync function $90b3f8835f10c8aa$export$f3cc014844de0a6b(score) {\n const response = await fetch(\"/contact/csat/\" + score.message_id, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(score)\n });\n if (!response.ok) throw new Error(`create or update customer satisfaction score failed. Status ${response.status}: ${response.statusText}`);\n}\n\n\n// The Placeholder string will be replaced by the go package which serves this file\n// with an object containing all feature flags and whether they are activated or not\nconst $1862df4f746c1637$var$FEATURE_FLAGS = \"__FEATURE_FLAGS_PLACEHOLDER__\";\nclass $1862df4f746c1637$export$3cef061fc5dfa2be {\n constructor(){\n this.onLoad = this.onLoad.bind(this);\n if (window.document.readyState === \"complete\") this.onLoad();\n else window.addEventListener(\"load\", this.onLoad);\n }\n onLoad() {\n if ($1862df4f746c1637$var$FEATURE_FLAGS instanceof Object && $1862df4f746c1637$var$FEATURE_FLAGS[\"ENABLE_CUSTOMER_SATISFACTION_SCORE_UI_HANDLER\"]) this.initCsat();\n }\n isHomePage() {\n const path = window.location.pathname;\n const hash = decodeURIComponent(window.location.hash);\n if (path === \"/dash/\" || path === \"/home/features\") return true;\n if (path === \"/shell/ng/\" && hash === \"#/dash/\") return true;\n if (path === \"/shell/\" && hash === \"#/home/features\") return true;\n return false;\n }\n isLanguageAdded() {\n const browserLang = navigator.language;\n const notAddedLanguages = [\n \"cs\",\n \"da\",\n \"es\",\n \"fr\",\n \"hr\",\n \"it\",\n \"nl\",\n \"pl\",\n \"sk\",\n \"sr\",\n \"zh-CN\"\n ];\n for (const l of notAddedLanguages){\n if (browserLang.startsWith(l)) return false;\n }\n return true;\n }\n initCsat() {\n const now = new Date();\n if ((0, $2fba7cc17b35f244$export$4be65e66cfa2648a)(\"IsQAEnvironment\") === \"true\" && (0, $2fba7cc17b35f244$export$4be65e66cfa2648a)(\"EnableCSAT\") !== \"true\") {\n console.info(`Did not show CSAT dialog, because \"IsQAEnvironment\" is set to true.`);\n return;\n }\n if (this.isLanguageAdded() && this.isHomePage() && now.getHours() >= 13) (0, $90b3f8835f10c8aa$export$a29223f6da1220a5)(\"CSAT\").then((score)=>{\n const lastSubmitted = new Date(score.last_submitted);\n const diff = now.getTime() - lastSubmitted.getTime();\n if (diff >= 7776000000) {\n const shell = window.shell;\n setTimeout(()=>{\n shell.openDialog((0, $0adb5bcfe0bdd84b$export$3e2c416251316c0d)(\"/contact/csat/dialog\"), 534, 900, true, shell.id);\n (0, $90b3f8835f10c8aa$export$f3cc014844de0a6b)({\n message_id: \"CSAT\",\n last_submitted: now.toISOString()\n }).catch((reason)=>{\n console.error(reason);\n });\n }, 2000);\n }\n }).catch((reason)=>{\n console.error(reason);\n });\n }\n}\nnew $1862df4f746c1637$export$3cef061fc5dfa2be();\n\n})();\n//# sourceMappingURL=integration.js.map\n","import { getCookie } from \"@repo/cookies\";\nimport { GetAbsoluteUrl } from \"@repo/urlhelper\";\nimport { createOrUpdateCsat, getCsat } from \"./csat/csat\";\n\n// The Placeholder string will be replaced by the go package which serves this file\n// with an object containing all feature flags and whether they are activated or not\nconst FEATURE_FLAGS: string|Record = \"__FEATURE_FLAGS_PLACEHOLDER__\";\n\nexport class FiveStarShellPlugin {\n\n constructor() {\n this.onLoad = this.onLoad.bind(this);\n if (window.document.readyState === \"complete\") {\n this.onLoad();\n } else {\n window.addEventListener(\"load\", this.onLoad);\n }\n }\n\n private onLoad() {\n if (FEATURE_FLAGS instanceof Object && FEATURE_FLAGS[\"ENABLE_CUSTOMER_SATISFACTION_SCORE_UI_HANDLER\"]) {\n this.initCsat();\n }\n }\n\n private isHomePage(): boolean {\n const path = window.location.pathname;\n const hash = decodeURIComponent(window.location.hash);\n\n if (path === \"/dash/\" || path === \"/home/features\") {\n return true;\n }\n\n if (path === \"/shell/ng/\" && hash === \"#/dash/\") {\n return true;\n }\n\n if (path === \"/shell/\" && hash === \"#/home/features\") {\n return true;\n }\n\n return false;\n }\n\n private isLanguageAdded(): boolean {\n const browserLang = navigator.language;\n const notAddedLanguages = [ \"cs\", \"da\", \"es\", \"fr\", \"hr\", \"it\", \"nl\", \"pl\", \"sk\", \"sr\", \"zh-CN\" ];\n for (const l of notAddedLanguages) {\n if (browserLang.startsWith(l)) {\n return false;\n }\n }\n\n return true;\n }\n\n private initCsat() {\n const now = new Date();\n\n if (getCookie(\"IsQAEnvironment\") === \"true\" && getCookie(\"EnableCSAT\") !== \"true\") {\n console.info(`Did not show CSAT dialog, because \"IsQAEnvironment\" is set to true.`);\n return;\n }\n\n if (this.isLanguageAdded() && this.isHomePage() && now.getHours() >= 13) {\n getCsat(\"CSAT\")\n .then(score => {\n const lastSubmitted = new Date(score.last_submitted);\n const diff = now.getTime() - lastSubmitted.getTime();\n\n if (diff >= 1000 * 60 * 60 * 24 * 30 * 3) {\n const shell = (window as any).shell;\n setTimeout(() => {\n shell.openDialog(GetAbsoluteUrl(\"/contact/csat/dialog\"), 534, 900, true, shell.id);\n\n createOrUpdateCsat({\n message_id: \"CSAT\",\n last_submitted: now.toISOString(),\n })\n .catch(reason => {\n console.error(reason);\n });\n }, 2000);\n }\n })\n .catch(reason => {\n console.error(reason);\n });\n }\n }\n}\n\nnew FiveStarShellPlugin();\n","export function getCookie(cname: string) {\n const name = cname + \"=\";\n const decodedCookie = decodeURIComponent(document.cookie);\n const ca = decodedCookie.split(\";\");\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == \" \") {\n c = c.substring(1);\n }\n if (c.indexOf(name) == 0) {\n return c.substring(name.length, c.length);\n }\n }\n return \"\";\n}\n\nexport function setCookie(name: string, value: string, path: string = \"/\"): void {\n const expires = new Date();\n expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000));\n document.cookie = `${name}=${value};Path=${path};Expires=${expires.toUTCString()};SameSite=None;Secure;`;\n}\n\nexport function removeCookie(name: string, path: string = \"/\"): void {\n document.cookie = `${name}=;Path=${path};Expires=Thu, 01 Jan 1970 00:00:01 GMT};SameSite=None;Secure;`;\n}\n","import getAbsoluteURL from \"./absoluteurl/getAbsoluteURL\";\n\nexport const GetAbsoluteUrl = getAbsoluteURL;\n","\nexport default function getAbsoluteURL(url: string): string {\n const anchorElement = document.createElement(\"a\");\n anchorElement.href = url; // now href is an absolute uri.\n return anchorElement.href;\n}\n","export async function getCsat(messageID: string): Promise {\n const response = await fetch(\"/contact/csat/\" + messageID, {\n method: \"GET\",\n headers: {\n \"Accept\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n if (response.status == 404) {\n return {\n message_id: messageID,\n last_submitted: \"1900-01-01\",\n };\n }\n throw new Error(`get customer satisfaction score failed. Status ${response.status}: ${response.statusText}`);\n }\n\n return await response.json();\n}\n\nexport async function createOrUpdateCsat(score: CustomerSatisfactionScore): Promise {\n const response = await fetch(\"/contact/csat/\" + score.message_id, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(score)\n });\n\n if (!response.ok) {\n throw new Error(`create or update customer satisfaction score failed. Status ${response.status}: ${response.statusText}`);\n }\n}\n"],"names":["$2fba7cc17b35f244$export$4be65e66cfa2648a","cname","name","ca","decodedCookie","decodeURIComponent","document","cookie","split","i","length","c","charAt","substring","indexOf","$0adb5bcfe0bdd84b$export$3e2c416251316c0d","url","anchorElement","createElement","href","$90b3f8835f10c8aa$export$a29223f6da1220a5","messageID","response","fetch","method","headers","ok","status","message_id","last_submitted","Error","statusText","json","$90b3f8835f10c8aa$export$f3cc014844de0a6b","score","body","JSON","stringify","$1862df4f746c1637$var$FEATURE_FLAGS","constructor","onLoad","bind","window","readyState","addEventListener","Object","initCsat","isHomePage","path","location","pathname","hash","isLanguageAdded","browserLang","navigator","language","l","startsWith","now","Date","console","info","getHours","then","lastSubmitted","diff","getTime","shell","setTimeout","openDialog","id","toISOString","catch","reason","error"],"version":3,"file":"integration.js.map"}