{"version":3,"file":"MeProxy.min.js","sources":["../../../../../../node_modules/tslib/tslib.es6.js","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/correlationVector.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/options.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/globals.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/time.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/dom.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/error.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/events.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/guid.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/object.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/url.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/utilities/string.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/telemetry/eventWriter.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/telemetry/utilities.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/telemetry/eventQueue.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/telemetry/eventGenerator.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/telemetry/src/telemetry/creators/clientError.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/telemetry/src/telemetry/creators/outgoingRequest.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/telemetry/src/telemetry/creators/trackedScenario.ts","../../../../../../node_modules/promise-polyfill/src/index.js","../../../../../../node_modules/promise-polyfill/src/finally.js","../../../../../../node_modules/@mecontrol/web-inline/lib/src/telemetry/src/telemetry/IdentityUX.Shared.Telemetry/OneDSTelemetryInitializer.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/logger.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/telemetry/index.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/promise.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/amd/queue.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/amd/cache.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/amd/define.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/src/amd/import.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/publicProxy.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/createProxy.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/loader.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/windowApi.ts","../../../../../../node_modules/@mecontrol/web-inline/lib/src/index.ts","../../../../../../node_modules/@mecontrol/web-boot/lib/src/src/utilities/url.polyfill.ts","../../lib/src/MeProxy.ts","../../../../../../node_modules/@mecontrol/web-boot/lib/src/src/utilities/url.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","export interface ICorrelationVector {\r\n /**\r\n * Get the value of the CV\r\n * @returns The string representation of the CV. If it exceeds the max allowed\r\n * length, the value will be truncated and have an ending '!'\r\n */\r\n getValue(): string;\r\n\r\n /**\r\n * Extends the CV to add a new term in the chain.\r\n */\r\n extend(): void;\r\n\r\n /**\r\n * Increments the CV's current chain value by one.\r\n */\r\n increment(): void;\r\n}\r\n\r\nconst base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r\nconst baseLength = 16;\r\nconst maxLength = 63;\r\n\r\n// MeControl CV. Intended to be used throughout the control\r\n// for telemetry and any other similar uses\r\nlet cv = createCV();\r\n\r\n/** Gets the correlation vector for MeControl */\r\nexport function getCv(): ICorrelationVector {\r\n return cv;\r\n}\r\n\r\n/**\r\n * Sets the correlation vector used throughout MeControl\r\n * @param newCv Value to use as the new base\r\n */\r\nexport function setCv(newCv: string): void {\r\n cv = createCV(newCv);\r\n}\r\n\r\n/**\r\n * Define a simple Correlation Vector class for telemetry\r\n * @param value An optional string to initialize the CV too. Intended use is to\r\n * have the value be the result of an other instance's getValue(), so as to allow to\r\n * create a new CV from the string represenation of another.\r\n */\r\nexport function createCV(value?: string): ICorrelationVector {\r\n\r\n // Initialize the CV. If a string value was provided, this\r\n // becomes the new base value. Otherwise, use a random string\r\n let _currentValue = 0;\r\n let _baseValue = value || getRandomBase();\r\n\r\n return {\r\n getValue(): string {\r\n let val = _baseValue + '.' + _currentValue;\r\n if (val.length > maxLength) {\r\n val = val.substring(0, maxLength) + '!';\r\n }\r\n return val;\r\n },\r\n\r\n extend(): void {\r\n _baseValue = this.getValue();\r\n _currentValue = 0;\r\n },\r\n\r\n increment(): void {\r\n _currentValue++;\r\n }\r\n };\r\n}\r\n\r\n/** Create a random base string for CV of the initial base length */\r\nfunction getRandomBase(): string {\r\n let str = '';\r\n while (str.length < baseLength) {\r\n // Append a random char\r\n str += base64Chars[Math.floor(Math.random() * base64Chars.length)];\r\n }\r\n return str;\r\n}\r\n","import { IValidatedMeControlConfiguration } from '@mecontrol/common';\r\n\r\nlet _options: IValidatedMeControlConfiguration | undefined;\r\n\r\n/** Gets the MeControl options */\r\nexport function getOptions(): IValidatedMeControlConfiguration | undefined {\r\n return _options;\r\n}\r\n\r\nexport function setOptions(opts: IValidatedMeControlConfiguration | undefined): void {\r\n _options = opts;\r\n}\r\n","import { MeControlNamespace } from '@mecontrol/common';\r\n\r\nexport const w = window;\r\n\r\n// Setup shared global objects;\r\nexport const ME: MeControlNamespace = (w.MeControl = w.MeControl || {}) as any;\r\n","import { w } from './globals';\r\n\r\nexport const getTime: () => number = Date.now ? () => Date.now() : () => +new Date();\r\n\r\n// NOTE: Because we are using the result of now to measure elapsed time, we want the higest resolution\r\n// time available to use that is not subject to the user changing their clock. The function that meets\r\n// those requirements is `performance.now`. However in older browsers we fallback to `Date.now`.\r\n// Do not use perfNow to get the current system time as in will not return it to you in most browsers.\r\n// `performance.now` is generally the number of milliseconds since the browser tab was opened.\r\n// See https://mythbusters.js.org/#/date/timestamp\r\n\r\n/**\r\n * Get a number to use in performance timings\r\n * @returns A number measured in milliseconds, accurate to five thousandths of a millisecond (5 microseconds).\r\n * The returned value represents the time elapsed since the time origin (approximately performance.timing.navigationStart).\r\n */\r\nexport const perfNow = () => w.performance.now();\r\n\r\n/**\r\n * Get an array of PerformanceEntries. Presumably those from the Performance API. If\r\n * said API is not available, then an empty array is returned.\r\n */\r\nexport const getPerfEntries = () => {\r\n if (w.performance && w.performance.getEntries) {\r\n return window.performance.getEntries();\r\n }\r\n\r\n return [];\r\n};\r\n","import { getOptions } from './options';\r\nimport { perfNow } from './time';\r\nimport { w } from './globals';\r\n\r\nexport const getPageLocation = () => w.location;\r\n\r\n/**\r\n * Loads CSS based on the given content.\r\n *\r\n * @param {string} cssText The text content for the CSS to be loaded.\r\n */\r\nexport function loadCss(cssText: string): void {\r\n let doc = document;\r\n let style = doc.createElement('style');\r\n style.type = 'text/css';\r\n\r\n // TODO: trevori - bring over the isIE8 stuff.\r\n // First check for IE8-10 stylesheet property but only use it for IE8\r\n //if (isIE8 && style.styleSheet) {\r\n // style.styleSheet.cssText = cssText;\r\n //}\r\n //else {\r\n // style.appendChild(document.createTextNode(cssText));\r\n //}\r\n style.appendChild(document.createTextNode(cssText));\r\n\r\n const options = getOptions();\r\n\r\n // When used in web components, append style element to the shadowDOM container element instead of head.\r\n if (options && options.shadowDOMContainerElement && options.shadowDOMContainerElement.appendChild) {\r\n options.shadowDOMContainerElement.appendChild(style);\r\n return;\r\n }\r\n\r\n let head = doc.head || doc.getElementsByTagName('head')[0];\r\n head.appendChild(style);\r\n}\r\n\r\nexport const requestAnimationFrame: Window[\"requestAnimationFrame\"] =\r\n w.requestAnimationFrame\r\n ? cb => w.requestAnimationFrame(cb)\r\n : cb => setTimeout(() => cb(perfNow()));\r\n\r\n// Constants used for createId() below\r\nconst idPrefix = 'mectrl';\r\nconst idSeparator = '_';\r\nconst prefixTester = new RegExp(`^${idPrefix}`, 'i'); // Regex to test if the string starts with the prefix\r\n\r\n/**\r\n * Create a Me Control ID for html elements. Has a unique Me Control prefix\r\n * @param idParts Parts of the ID that will be concatenated as part of the ID\r\n */\r\nexport function createId(...idParts: (number | string)[]): string {\r\n let joinedParts = idParts.join(idSeparator);\r\n if (!prefixTester.test(joinedParts)) {\r\n joinedParts = idPrefix + idSeparator + joinedParts;\r\n }\r\n return joinedParts;\r\n}\r\n","import { AnyObject } from '@mecontrol/common';\r\n\r\nexport interface MeControlError extends Error {\r\n mcIsTimeout?: boolean;\r\n}\r\n\r\nconst meControlErrorPrefix = 'MeControlError::';\r\n\r\n/**\r\n * Create a Me Control error object with a given message\r\n * @param message Error message\r\n * @param isTimeout Flag to indicate whether the error is because of a timeout\r\n */\r\nexport function createError(message: string, isTimeout: boolean = false): MeControlError {\r\n const error: MeControlError = new Error(`${meControlErrorPrefix}${message}`);\r\n error.mcIsTimeout = isTimeout;\r\n return error;\r\n}\r\n\r\n/**\r\n * Convert an error object into a similar object that can be converted\r\n * to a JSON string\r\n * @param err Error to convert\r\n */\r\nexport function toJsonable(err: Error): any {\r\n let newObj: AnyObject = {};\r\n let oldObj: AnyObject = err;\r\n Object.getOwnPropertyNames(err).forEach(propName => newObj[propName] = oldObj[propName]);\r\n return newObj;\r\n}\r\n","import { ISyntheticEvent } from '@mecontrol/public-api';\r\nimport {\r\n ISyntheticEventTarget,\r\n MeControlEventType,\r\n EventDetailsMap,\r\n MeControlEventHandler,\r\n IMeControlEvent\r\n} from '@mecontrol/common';\r\n\r\nexport class SyntheticEvent implements ISyntheticEvent {\r\n private _defaultPrevented: boolean;\r\n\r\n get defaultPrevented(): boolean {\r\n return this._defaultPrevented;\r\n }\r\n\r\n constructor(public type: Type, public detail: EventDetailsMap[Type]) {\r\n this._defaultPrevented = false;\r\n }\r\n\r\n /**\r\n * preventDefault - when called by a registered event listener (see {@link addEventListener}) this effectively\r\n * tells the system that the event was \"cancelled\". If this is called by any listener while handling an event\r\n * that was dispatched by {@link dispatchEvent} it will cause a return value of false from that call to {@link dispatchEvent}\r\n * @returns void\r\n */\r\n public preventDefault(): void {\r\n this._defaultPrevented = true;\r\n }\r\n}\r\n\r\ntype ListenersArray = Array>;\r\ntype IEventListeners = { [key in MeControlEventType]?: ListenersArray };\r\n\r\nexport class SyntheticEventTarget implements ISyntheticEventTarget {\r\n private _listeners: IEventListeners = {};\r\n\r\n /**\r\n * addEventListener - registers a listener for a particular named event\r\n * @param type The string name of the event that the listener will be listening for. All calls to dispatchEvent with this same name will result in a call to this listener with the event data presented.\r\n * @param callback The callback function to register. NOTE: if you want to remove later, create a real function and send a reference to it here - the remove uses simple equality to locate callbacks to remove.\r\n * @returns void\r\n */\r\n public addEventListener(type: Type, callback: MeControlEventHandler): void {\r\n if (!(type in this._listeners)) {\r\n this._listeners[type] = [];\r\n }\r\n\r\n // TODO: Explore ways to remove this cast\r\n (this._listeners[type] as ListenersArray).push(callback);\r\n }\r\n\r\n /**\r\n * removeEventListener - removes a registered listener for a particular named event\r\n * @param type The string name of the event that the listener was listening for\r\n * @param callback The callback function that was previously registered (which will be removed). NOTE: the function uses simple reference equality to find the handler to remove.\r\n * @returns void\r\n */\r\n public removeEventListener(type: Type, callback: MeControlEventHandler): void {\r\n if (!(type in this._listeners)) {\r\n return;\r\n }\r\n\r\n // TODO: Explore ways to remove this cast\r\n const listeners = this._listeners[type] as ListenersArray;\r\n const index = listeners.indexOf(callback);\r\n if (index !== -1) {\r\n listeners.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * dispatchEvent - raises an event to all registered event listeners (see addEventListener for registering).\r\n * @param event The event to dispatch. The event should contain a 'type', and optionally can pass additional data in the 'detail' object.\r\n * @returns true if none of the registered listeners \"cancelled\" the event by calling event.preventDefault, false if any listener DID cancel the event by calling event.preventDefault\r\n */\r\n public dispatchEvent(event: IMeControlEvent): boolean {\r\n\r\n if (!(event.type in this._listeners)) {\r\n return true;\r\n }\r\n\r\n // TODO Explore ways to remove this cast\r\n let stack = this._listeners[event.type] as ListenersArray;\r\n\r\n // build up a full event with the input...\r\n let dispatchedEvent = new SyntheticEvent(event.type, event.detail);\r\n\r\n for (let i = 0, l = stack.length; i < l; i++) {\r\n stack[i].call(this, dispatchedEvent);\r\n }\r\n\r\n return !dispatchedEvent.defaultPrevented;\r\n }\r\n}\r\n","import { w } from './globals';\r\n\r\nconst SessionStorageIdKey = 'msameid';\r\n\r\nexport let id = guid();\r\ntry {\r\n const storage = w.sessionStorage;\r\n if (storage) {\r\n id = storage.getItem(SessionStorageIdKey) || guid();\r\n storage.setItem(SessionStorageIdKey, id);\r\n }\r\n}\r\ncatch (e) {\r\n // setItem will throw a QuotaExceededError when iPad Safari is in private browsing.\r\n // We will ignore this and just always create a new ID in this case.\r\n}\r\n\r\n/**\r\n * Generate a new random GUID compliant with RFC4122 version 4\r\n */\r\nexport function guid(): string {\r\n // Stitch in '4' in the third group to comply with RFC4122 version 4\r\n return (term4() + term4() + '-' + term4() + '-4' + term4().substr(0, 3) + '-' + term4() + '-' + term4() + term4() + term4()).toLowerCase();\r\n\r\n function term4(): string {\r\n // tslint:disable-next-line:no-bitwise\r\n return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);\r\n }\r\n}\r\n","import { __assign } from 'tslib';\r\nimport { createError } from './error';\r\n\r\nexport function assertNever(obj: never, errorMessage: string): never {\r\n throw createError('Never assertion failed: ' + errorMessage);\r\n}\r\n\r\nexport function hasOwn(object: any, propertyName: string): boolean {\r\n // Don't do {}.hasOwnProperty because the {} may have overwritten\r\n // hasOwnProperty with it's own implementation that doesn't behave\r\n // as we expect. Instead we always reference the true hasOwnProperty\r\n // which exists on the Object.prototype (unless someone overrides that\r\n // which they just shouldn't ever do...)\r\n return Object.prototype.hasOwnProperty.call(object, propertyName);\r\n}\r\n\r\nexport const assign: ObjectAssign = (Object as any).assign || __assign;\r\n\r\nexport interface ObjectAssign {\r\n /**\r\n * Copy the values of all of the enumerable own properties from one or more source objects to a\r\n * target object. Returns the target object.\r\n * @param target The target object to copy to.\r\n * @param source The source object from which to copy properties.\r\n */\r\n (target: T, source: U): T & U;\r\n\r\n /**\r\n * Copy the values of all of the enumerable own properties from one or more source objects to a\r\n * target object. Returns the target object.\r\n * @param target The target object to copy to.\r\n * @param source1 The first source object from which to copy properties.\r\n * @param source2 The second source object from which to copy properties.\r\n */\r\n (target: T, source1: U, source2: V): T & U & V;\r\n\r\n /**\r\n * Copy the values of all of the enumerable own properties from one or more source objects to a\r\n * target object. Returns the target object.\r\n * @param target The target object to copy to.\r\n * @param source1 The first source object from which to copy properties.\r\n * @param source2 The second source object from which to copy properties.\r\n * @param source3 The third source object from which to copy properties.\r\n */\r\n (target: T, source1: U, source2: V, source3: W): T & U & V & W;\r\n\r\n /**\r\n * Copy the values of all of the enumerable own properties from one or more source objects to a\r\n * target object. Returns the target object.\r\n * @param target The target object to copy to.\r\n * @param sources One or more source objects from which to copy properties\r\n */\r\n (target: object, ...sources: any[]): any;\r\n}\r\n","import { ME } from './globals';\r\n\r\n\r\n/**\r\n * Regular expression for the CDN string obtained from MeConfig.\r\n */\r\nlet CDN_REGEX: RegExp;\r\n\r\n/**\r\n * Default value for the CDN Domain.\r\n */\r\nlet DOMAIN_RESULT: string | undefined | null = null;\r\n\r\n/**\r\n * Get the url root host where MeControl javascript is being pulled from.\r\n */\r\nexport function getRootDomainUrl(): string {\r\n const config = ME.Config;\r\n if (DOMAIN_RESULT == null && ME.Config.cdnRegex != \"\") {\r\n CDN_REGEX = new RegExp(ME.Config.cdnRegex);\r\n DOMAIN_RESULT = checkIfCDNDomainExists(CDN_REGEX);\r\n }\r\n return DOMAIN_RESULT ? DOMAIN_RESULT : config.gfx;\r\n}\r\n\r\n/**\r\n * Iterates through each script file and compares it to the regex\r\n * @param scripts The array of scripts in the HTML document\r\n * @returns A CDN Domain\r\n */\r\nexport function checkIfCDNDomainExists(cdnRegex: RegExp): string | undefined {\r\n const scripts = document.getElementsByTagName('script');\r\n if (scripts) {\r\n const scriptsArray: HTMLScriptElement[] = Array.prototype.slice.call(scripts);\r\n for (let i = 0; i < scriptsArray.length; i++) {\r\n const result = cdnRegex.exec(scriptsArray[i].src);\r\n if (result) {\r\n return result[0];\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\n/**\r\n * checks if the string is a valid URL\r\n * @param str The string to check\r\n */\r\nexport function isValidURL(str: string): boolean {\r\n try {\r\n new URL(str);\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n}","import { StringMap } from '@mecontrol/common';\r\nimport { ME } from './globals';\r\nimport { assign } from './object';\r\n\r\nlet _strings: Record = {};\r\nlet _currentLang: string;\r\n\r\n/**\r\n * Gets the language to be used for getString.\r\n */\r\nfunction getCurrentLang(): string {\r\n // return Config.mkt by default if the internal market has not been set externally\r\n // defaults to 'en-US' if neither of them is defined.\r\n return (_currentLang || ME.Config.mkt || \"en-US\").toLowerCase();\r\n}\r\n\r\n/**\r\n * Sets the language to be used for getString.\r\n * @param newCurrentLang The new language to set to\r\n */\r\nexport function setCurrentLang(newCurrentLang: string): void {\r\n _currentLang = newCurrentLang.toLowerCase();\r\n}\r\n\r\n/**\r\n * Adds new string resources\r\n * @param curLang The culture paired with the strings\r\n * @param newStrings The new strings to be added\r\n */\r\nexport function addStrings(curLang: string, newStrings: StringMap): void {\r\n curLang = curLang.toLowerCase();\r\n _strings[curLang] = _strings[curLang] || {};\r\n assign(_strings[curLang], newStrings);\r\n}\r\n\r\n/**\r\n * Gets an unencoded string resource\r\n * @param stringId The string value for the given string id\r\n * @returns The string resource\r\n */\r\nexport function getString(stringId: string): string {\r\n let lang = getCurrentLang();\r\n\r\n // always fetch the current language in case the app sets it to something else after page loading\r\n return _strings[lang] && _strings[lang][stringId] || `ERROR: ${stringId}`;\r\n}\r\n","import { ITelemetryEvent } from '@mecontrol/common';\r\nimport { ME } from '../utilities';\r\n\r\ntype EventWriter = (event: ITelemetryEvent[]) => void;\r\ntype EventWriterCondition = () => boolean;\r\ntype EventWriterContext = [EventWriter, EventWriterCondition, number];\r\ntype EventWriterCollection = Array;\r\n\r\nconst writerCollection: EventWriterCollection = [];\r\nconst criticalEventsRegex = /ContentUpdate|PageAction|TrackedScenario/;\r\n\r\n/* Direct refernce to the oneDSWriter. This is to be used in conjunction with the old writerCollection so that\r\n * both sources are logged to. oneDS goes into Geneva while the original collection will log through Vortex\r\n * into the old Cosmos. This will be removed in the future and oneDS will be the final location.\r\n*/\r\nlet oneDSWriter: EventWriter;\r\n\r\nlet shouldBatch = true;\r\nlet flusherAttached = false;\r\nlet windowHasLoaded = document.readyState === \"complete\";\r\nlet queuedEvents: ITelemetryEvent[] = [];\r\n\r\n!windowHasLoaded && window.addEventListener('load', () => {\r\n windowHasLoaded = true;\r\n flushEvents();\r\n});\r\n\r\n/** Control whether events should be batched or not */\r\nexport function batchEvents(batch: boolean): void {\r\n shouldBatch = batch;\r\n\r\n // If there are any events pending and we are no\r\n // longer batching, we flush the queue\r\n if (!shouldBatch && queuedEvents.length > 0) {\r\n flushEvents();\r\n }\r\n}\r\n\r\n/**\r\n * Add a new method to write/send events\r\n * @param context Context for event writer being added:\r\n * - First element: the actual event writer\r\n * - Second element: a condition, which will be tested agains to determine\r\n * whether the writer should be used or not\r\n * - Third element: a priority number used to determine the order in which\r\n * to test all of the available writers' conditions. Lower values mean testing\r\n * the writer first\r\n */\r\nexport function addEventWriter(...context: EventWriterContext): void {\r\n writerCollection.push(context);\r\n writerCollection.sort((contextA, contextB) => {\r\n // Sort by ascending priority\r\n return contextA[2] - contextB[2];\r\n });\r\n}\r\n\r\n/**\r\n * Sets the OneDS writer to be used in conjunction with the writer collection.\r\n */\r\nexport function setOneDSWriter(writer: EventWriter): void {\r\n oneDSWriter = writer;\r\n}\r\n\r\n/**\r\n * Write the given event to Vortex\r\n * @param event The telemetry event that will be sent to Vortex\r\n * @param isCritical Indicates whether the event being written should be treated as critical\r\n */\r\nexport function writeEvent(event: ITelemetryEvent, isCritical?: boolean): void {\r\n\r\n let evName = event.partA.name.split('.').pop() as string;\r\n if (ME.Config.telEvs && ME.Config.telEvs.indexOf(evName) !== -1) {\r\n\r\n queuedEvents.push(event);\r\n\r\n if (shouldBatch) {\r\n // Ensure that, as long as we are batching, we have\r\n // the chance to flush on unload\r\n addFlusher();\r\n\r\n // Flush all batched events if the current event is critical.\r\n // We hold off until the window has loaded to do this though\r\n // Also, when 'isCritical' is set to false, we hold off from flushing\r\n if (windowHasLoaded && isCritical !== false && (isCritical === true || criticalEventsRegex.test(evName))) {\r\n // Flushing always involve an extra delay to catch any additional immediate events\r\n setTimeout(flushEvents, 0);\r\n }\r\n }\r\n else {\r\n flushEvents();\r\n }\r\n }\r\n}\r\n\r\n/** Flush the queue of events and send them to Vortex */\r\nexport function flushEvents(): void {\r\n // Remove event listener, since there is no longer a need to flush on unload\r\n window.removeEventListener('beforeunload', flushEvents, true);\r\n flusherAttached = false;\r\n\r\n if (queuedEvents.length > 0) {\r\n // Only write events when not in unit tests\r\n if (!ME.Config.isUT) {\r\n // Write to 1DS as the new standard.\r\n oneDSWriter(queuedEvents);\r\n\r\n // Additionally write to the old writer to ensure all Vortex data continues to flow to Cosmos until removed.\r\n let writer = selectWriter();\r\n writer(queuedEvents);\r\n }\r\n queuedEvents = [];\r\n }\r\n}\r\n\r\n/** FOR TESTING ONLY. Clears all event writers */\r\nexport const clearWriters = () => { writerCollection.splice(0); };\r\n\r\n/**\r\n * Determine which event writer to use when flushing events to Vortex\r\n */\r\nfunction selectWriter(): EventWriter {\r\n // To select an event writer, test the condition of each\r\n // one in order of priority until one returns true\r\n for (let i = 0; i < writerCollection.length; i++) {\r\n // Test writer condition\r\n if (writerCollection[i][1]()) {\r\n // Return the actual writer\r\n return writerCollection[i][0];\r\n }\r\n }\r\n\r\n // If no conditions return true, we return a dummy writer\r\n return () => { /* NOOP */ };\r\n}\r\n\r\n/**\r\n * Add event listener in case we navigate away from the page before flushing\r\n * NOTE: Per this document, 'beforeunload' is the better event to handle when navigating away\r\n * (and only when strictly needed):\r\n * - https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-beforeunload-event\r\n */\r\nfunction addFlusher(): void {\r\n if (!flusherAttached) {\r\n flusherAttached = true;\r\n window.addEventListener('beforeunload', flushEvents, true);\r\n }\r\n}\r\n","import { ContentInfo, ContentBlob } from '@mecontrol/common';\r\n\r\n/**\r\n * Filters out the value of query parameters included in a URL (for privacy purposes) and\r\n * removes the fragment from a passed in URL\r\n * @param url The URL to filter\r\n */\r\nexport function scrubUrl(url: string): string {\r\n if (!url) {\r\n return url;\r\n }\r\n\r\n // Filter out the values of the passed in query parameters or all of them\r\n let filteredUrl = url.replace(/([^?&]*)=([^&#]*)/g, '$1=**');\r\n\r\n // Remove the fragment completely\r\n let parsedUrl = filteredUrl.replace(/#.*/, '');\r\n return parsedUrl;\r\n}\r\n\r\n/**\r\n * Creates a string content blob from the content information provided for events\r\n * @param content Information on the item that was involved in the event\r\n * @returns String representation of the content blob\r\n */\r\nexport function getContentJson(content: ContentInfo): string {\r\n let blob: ContentBlob = {\r\n id: content.id,\r\n cT: content.type,\r\n sN: content.slot,\r\n cS: content.source\r\n };\r\n\r\n return JSON.stringify(blob, (key: string, value: any) => value == null ? undefined : value);\r\n}\r\n","import { AccountType } from '@mecontrol/public-api';\r\nimport { EventParams, PageName, ContentSource } from \"@mecontrol/common\";\r\nimport { getCv, perfNow, guid } from '../utilities';\r\n\r\nexport interface EventMoment {\r\n cv: string;\r\n impressionGuid: string;\r\n pageName: PageName;\r\n date: Date;\r\n timestamp: number;\r\n accounts: {\r\n counts: string;\r\n current?: AccountType;\r\n };\r\n}\r\nexport type QueuedEvent = [EventParams, EventMoment];\r\n\r\n// Queue state\r\nconst impressionGuid = guid();\r\nlet eventsQueue: QueuedEvent[] = [];\r\nlet pageName = PageName.null;\r\nlet accounts: EventMoment['accounts'] = {\r\n counts: '0-0'\r\n};\r\n\r\n/** Queue an event for processing later */\r\nexport function queueEvent(params: EventParams): void {\r\n eventsQueue.push([params, captureMoment(params)]);\r\n}\r\n\r\nexport function popEvents(type: string): QueuedEvent[] {\r\n let newQueue: QueuedEvent[] = [];\r\n let poppedEvents: QueuedEvent[] = [];\r\n for (let i = 0; i < eventsQueue.length; i++) {\r\n if (eventsQueue[i][0].eventType === type) {\r\n poppedEvents.push(eventsQueue[i]);\r\n }\r\n else {\r\n newQueue.push(eventsQueue[i]);\r\n }\r\n }\r\n eventsQueue = newQueue;\r\n return poppedEvents;\r\n}\r\n\r\n/** Create an EventMoment to capture information about when the event happened */\r\nexport function captureMoment(params: EventParams): EventMoment {\r\n // All events increment the CV\r\n let cv = getCv();\r\n cv.increment();\r\n\r\n // Some events may update the page name\r\n // Specifically: ContentUpdate\r\n if (params.eventType === 'ContentUpdate' && params.content && params.content.source === ContentSource.UX) {\r\n pageName = params.content.id as PageName;\r\n }\r\n\r\n return {\r\n cv: cv.getValue(),\r\n impressionGuid,\r\n pageName,\r\n date: new Date(),\r\n timestamp: perfNow(),\r\n accounts\r\n };\r\n}\r\n\r\n/**\r\n * Set the current template of active and remembered accounts currently\r\n * on display in the control\r\n * @param activeAccountType Type of the currently active account (if any)\r\n * @param totalAccounts Number of accounts the control is aware of\r\n */\r\nexport function updateMoment(activeAccountType: AccountType | undefined, totalAccounts: number): void {\r\n const activeAccounts = activeAccountType ? 1 : 0;\r\n const otherAccounts = totalAccounts - activeAccounts;\r\n accounts.counts = `${activeAccounts}-${otherAccounts}`;\r\n accounts.current = activeAccountType;\r\n}\r\n\r\n/**\r\n * returns the type of the current account\r\n */\r\n export function getCurrentAccountType(): AccountType | undefined{\r\n return accounts.current;\r\n}\r\n\r\n/** FOR TESTING ONLY. Empties the queue of events */\r\nexport const clearQueue = () => { eventsQueue = []; };\r\n","import { AccountType } from '@mecontrol/public-api';\r\nimport { IPartA, ITelemetryEvent, EventDefinitions, EventParams, PageTags, Flags } from '@mecontrol/common';\r\nimport { perfNow, getPageLocation, ME } from '../utilities';\r\nimport { scrubUrl } from './utilities';\r\nimport { EventMoment, queueEvent, popEvents, captureMoment } from './eventQueue';\r\nimport { writeEvent } from './eventWriter';\r\n\r\nexport type TypedEventCreator =\r\n (params: EventDefinitions[T][\"params\"], moment: EventMoment) => EventDefinitions[T]['event'];\r\n\r\ntype EventCreator = (params: EventParams, moment: EventMoment) => ITelemetryEvent;\r\ntype EventCreatorsMap = Record;\r\n\r\n// Event generator state\r\nconst startTime = perfNow();\r\nconst eventCreators: EventCreatorsMap = {};\r\n\r\n/**\r\n * Gets the time that has passed since the MeControl code started running and a\r\n * passed in moment\r\n * @param moment Point in time to use measure against start time\r\n */\r\nexport function getTimeSince(moment: number): number {\r\n return moment - startTime;\r\n}\r\n\r\n/**\r\n * Builds the PageTags to send with an event\r\n * @param accounts Information on the current accounts template\r\n * @param accountType Type of the currently signed in Account\r\n * @returns PageTags object to send in an event\r\n */\r\nexport function getPageTags(accounts: string, accountType?: AccountType): PageTags {\r\n // Scrub all query parameters\r\n const url = scrubUrl(getPageLocation().href);\r\n\r\n return {\r\n metaTags: {\r\n authtype: accountType && accountType.toString(),\r\n pgpart: ME.Config.ptn\r\n },\r\n config: ME.Config,\r\n url,\r\n accts: accounts\r\n };\r\n}\r\n\r\n/**\r\n * Creates an object containing the part A data for a telemetry event\r\n * @param name The type of the event to create a Part A for\r\n * @param eventDate Date when the event took place\r\n * @param cv Correlation Vector string for the event\r\n */\r\nexport function createPartA(name: string, eventDate: Date, eventCv: string): IPartA {\r\n return {\r\n ver: '2.1',\r\n name,\r\n time: eventDate.toISOString(), // IE 9+\r\n appId: 'JS:MeControl',\r\n cV: eventCv,\r\n flags: Flags.DropIdentifiers,\r\n ext: {\r\n javascript: {\r\n ver: '1.1',\r\n libVer: '4.2.3',\r\n domain: getPageLocation().hostname,\r\n userConsent: false\r\n },\r\n app: {\r\n env: ME.Config.int ? 'Test' : 'Prod'\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Sets the function that will handle creation of a certain type of Telemetry Event\r\n * @param type A string containing the type of event we are registering a creation function for\r\n * @param eventCreator A function that produces events of type 'type'.\r\n * Takes in the type's parameter object\r\n */\r\nexport function setEventCreator(type: T, eventCreator: TypedEventCreator): void {\r\n eventCreators[type] = eventCreator;\r\n\r\n // Process any events of this type that may be queued\r\n let queuedEvents = popEvents(type);\r\n queuedEvents.forEach(eventData => {\r\n let event = eventCreator(eventData[0], eventData[1]);\r\n writeEvent(event, eventData[0].isCritical);\r\n });\r\n}\r\n\r\n/**\r\n * Creates an event of a given type.\r\n * @param eventParams An object that contains all the information needed to create the event and that\r\n * will be passed to the creator function\r\n * @returns The created event or NULL if no creator for the type of event is found\r\n */\r\nexport function createEvent(eventParams: EventParams): ITelemetryEvent | null {\r\n let eventCreator = eventCreators[eventParams.eventType];\r\n if (eventCreator) {\r\n return eventCreator(eventParams, captureMoment(eventParams));\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Create and send an event\r\n * @param eventParams An object that contains all the information needed to create the event and that\r\n * will be passed to the creator function\r\n */\r\nexport function fireEvent(eventParams: EventParams): void {\r\n let event = createEvent(eventParams);\r\n if (event) {\r\n writeEvent(event, eventParams.isCritical);\r\n }\r\n else {\r\n queueEvent(eventParams);\r\n }\r\n}\r\n","import { IClientErrorEvent, IClientErrorParams, IClientErrorPartC, ErrorSeverity } from '@mecontrol/common';\r\nimport { ME } from '../../utilities';\r\nimport { EventMoment } from '../eventQueue';\r\nimport { createPartA, getPageTags } from '../eventGenerator';\r\n\r\nconst eventName = 'Ms.Webi.ClientError';\r\n\r\n/**\r\n * Creates a ClientError event to log error details on Me Control\r\n * @param errorParams The object containig details of the error that occurred\r\n * @returns The ClientError event that was created\r\n */\r\nexport function createClientError(errorParams: IClientErrorParams, moment: EventMoment): IClientErrorEvent {\r\n let partA = createPartA(eventName, moment.date, moment.cv);\r\n\r\n const cleanString = (str: string) => str.replace(/\\n/g, '\\\\n');\r\n\r\n let partC: IClientErrorPartC = {\r\n baseType: undefined,\r\n errorName: errorParams.name,\r\n errorMessage: cleanString(errorParams.details),\r\n errorType: errorParams.type,\r\n errorInfo: JSON.stringify(getPageTags(moment.accounts.counts, moment.accounts.current)),\r\n severity: errorParams.severity || ErrorSeverity.Error,\r\n wasDisplayed: errorParams.displayed,\r\n pageName: moment.pageName,\r\n impressionGuid: moment.impressionGuid,\r\n market: ME.Config.mkt\r\n };\r\n\r\n return {\r\n partA,\r\n partB: undefined,\r\n partC\r\n };\r\n}\r\n","import {\r\n IOutgoingRequestEvent, IOutgoingRequestParams,\r\n IOutgoingRequestPartB, IOutgoingRequestPartC\r\n} from '@mecontrol/common';\r\nimport { ME, getPerfEntries, assign } from '../../utilities';\r\nimport { EventMoment } from '../eventQueue';\r\nimport { createPartA, getPageTags } from '../eventGenerator';\r\nimport { scrubUrl } from '../utilities';\r\n\r\nconst eventName = 'Ms.Webi.OutgoingRequest';\r\nconst eventBaseType = 'Ms.Qos.OutgoingServiceRequest';\r\n// Filter all query parameters to be safe\r\n// const c_queryFilters = ['login_hint', 'username'];\r\n\r\n/**\r\n * Creates an OutgoingRequest event to capture information on calls to external services/servers\r\n * @param requestParams The outgoing request event's parameters\r\n * @returns The created OutgoingRequest event\r\n */\r\nexport function createOutgoingRequest(requestParams: IOutgoingRequestParams, moment: EventMoment): IOutgoingRequestEvent {\r\n\r\n // Try to retrieve performance API entry for the URL\r\n let entry = getEntry(requestParams.url);\r\n\r\n // Compute latency to report on the event\r\n // We will always prefer the performance API measurements and only\r\n // resort to our own measurements in their absence\r\n let latencyMs = Math.round(getEntryDuration(entry) || requestParams.duration);\r\n\r\n // Determine the operation name by extracting the last part of the path in the\r\n // requests URL. If there is a performance entry for the request, we get the URL\r\n // from there. Otherwise, we use the URL from the params.\r\n // Finally, if we can't find a good path part, we just reuse the service operation\r\n let operationName = getLastPathPart(entry ? entry.name : requestParams.url) ||\r\n requestParams.serviceOperation;\r\n\r\n let partA = createPartA(eventName, moment.date, moment.cv);\r\n\r\n let partB: IOutgoingRequestPartB = {\r\n operationName,\r\n dependencyOperationName: requestParams.serviceOperation,\r\n dependencyName: requestParams.service,\r\n latencyMs,\r\n succeeded: requestParams.success,\r\n targetUri: scrubUrl(requestParams.url)\r\n };\r\n\r\n let partC: IOutgoingRequestPartC = {\r\n baseType: eventBaseType,\r\n message: requestParams.message,\r\n pageName: moment.pageName,\r\n impressionGuid: moment.impressionGuid,\r\n market: ME.Config.mkt,\r\n customData: JSON.stringify(assign(\r\n {},\r\n {\r\n computedDuration: requestParams.duration || -1,\r\n perfDuration: getEntryDuration(entry) || -1\r\n },\r\n getPageTags(moment.accounts.counts, moment.accounts.current)\r\n ))\r\n };\r\n\r\n return {\r\n partA,\r\n partB,\r\n partC\r\n };\r\n}\r\n\r\n/**\r\n * Get a performance entry by looking for a particular name\r\n * @param name Entry name or partial name (URL)\r\n */\r\nfunction getEntry(name: string): PerformanceEntry | undefined {\r\n const entries = getPerfEntries();\r\n for (let entry of entries) {\r\n if (entry.name === name || entry.name.indexOf(name) !== -1) {\r\n return entry;\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Retrieve a possible performance entry duration value or (if not available)\r\n * compute one\r\n * @param entry PerformanceEntry to get the duration information from\r\n */\r\nfunction getEntryDuration(entry: PerformanceEntry | undefined): number | undefined {\r\n if (entry) {\r\n switch (entry.entryType) {\r\n // Special case navigation entries (like our Webview html) that won't\r\n // have a complete entry until EVERYTHING completes loading.\r\n // We care about the network time here\r\n case 'navigation':\r\n return (entry as PerformanceNavigationTiming).responseEnd - entry.startTime;\r\n\r\n case 'resource':\r\n default:\r\n return entry.duration;\r\n\r\n }\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Get the last part of the path of URL\r\n * @param url URL to extract the last part of the path from\r\n */\r\nfunction getLastPathPart(url?: string): string | undefined {\r\n if (url) {\r\n // Create an anchor tag to have it parse the URL\r\n let anchor = document.createElement('a');\r\n anchor.href = url;\r\n\r\n let path = anchor.pathname;\r\n let segments = path.split('/');\r\n for (let i = segments.length - 1; i >= 0; i--) {\r\n if (segments[i]) {\r\n return segments[i];\r\n }\r\n }\r\n }\r\n\r\n return;\r\n}\r\n","import { ITrackedScenarioEvent, ITrackedScenarioParams, ITrackedScenarioPartC } from '@mecontrol/common';\r\nimport { ME } from '../../utilities';\r\nimport { EventMoment } from '../eventQueue';\r\nimport { createPartA } from '../eventGenerator';\r\n\r\nconst eventName = 'Ms.Webi.MeControl.TrackedScenario';\r\n\r\n/**\r\n * Creates a TrackedScenario event to capture information on some process in MeControl\r\n * @param requestParams The tracked scenario event's parameters\r\n * @returns The created TrackedScenario event\r\n */\r\nexport function createTrackedScenario(scenarioParams: ITrackedScenarioParams, moment: EventMoment): ITrackedScenarioEvent {\r\n const partA = createPartA(eventName, moment.date, moment.cv);\r\n\r\n const partC: ITrackedScenarioPartC = {\r\n baseType: undefined,\r\n partner: ME.Config.ptn,\r\n controlVersion: ME.Config.ver,\r\n market: ME.Config.mkt,\r\n scenario: scenarioParams.scenario,\r\n action: scenarioParams.action,\r\n previousAction: scenarioParams.previousAction,\r\n success: scenarioParams.success,\r\n durationMs: scenarioParams.durationMs,\r\n details: scenarioParams.details\r\n };\r\n\r\n return {\r\n partA,\r\n partB: undefined,\r\n partC\r\n };\r\n}\r\n","import promiseFinally from './finally';\n\n// Store setTimeout reference so promise-polyfill will be unaffected by\n// other code modifying setTimeout (like sinon.useFakeTimers())\nvar setTimeoutFunc = setTimeout;\n\nfunction isArray(x) {\n return Boolean(x && typeof x.length !== 'undefined');\n}\n\nfunction noop() {}\n\n// Polyfill for Function.prototype.bind\nfunction bind(fn, thisArg) {\n return function() {\n fn.apply(thisArg, arguments);\n };\n}\n\n/**\n * @constructor\n * @param {Function} fn\n */\nfunction Promise(fn) {\n if (!(this instanceof Promise))\n throw new TypeError('Promises must be constructed via new');\n if (typeof fn !== 'function') throw new TypeError('not a function');\n /** @type {!number} */\n this._state = 0;\n /** @type {!boolean} */\n this._handled = false;\n /** @type {Promise|undefined} */\n this._value = undefined;\n /** @type {!Array} */\n this._deferreds = [];\n\n doResolve(fn, this);\n}\n\nfunction handle(self, deferred) {\n while (self._state === 3) {\n self = self._value;\n }\n if (self._state === 0) {\n self._deferreds.push(deferred);\n return;\n }\n self._handled = true;\n Promise._immediateFn(function() {\n var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;\n if (cb === null) {\n (self._state === 1 ? resolve : reject)(deferred.promise, self._value);\n return;\n }\n var ret;\n try {\n ret = cb(self._value);\n } catch (e) {\n reject(deferred.promise, e);\n return;\n }\n resolve(deferred.promise, ret);\n });\n}\n\nfunction resolve(self, newValue) {\n try {\n // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure\n if (newValue === self)\n throw new TypeError('A promise cannot be resolved with itself.');\n if (\n newValue &&\n (typeof newValue === 'object' || typeof newValue === 'function')\n ) {\n var then = newValue.then;\n if (newValue instanceof Promise) {\n self._state = 3;\n self._value = newValue;\n finale(self);\n return;\n } else if (typeof then === 'function') {\n doResolve(bind(then, newValue), self);\n return;\n }\n }\n self._state = 1;\n self._value = newValue;\n finale(self);\n } catch (e) {\n reject(self, e);\n }\n}\n\nfunction reject(self, newValue) {\n self._state = 2;\n self._value = newValue;\n finale(self);\n}\n\nfunction finale(self) {\n if (self._state === 2 && self._deferreds.length === 0) {\n Promise._immediateFn(function() {\n if (!self._handled) {\n Promise._unhandledRejectionFn(self._value);\n }\n });\n }\n\n for (var i = 0, len = self._deferreds.length; i < len; i++) {\n handle(self, self._deferreds[i]);\n }\n self._deferreds = null;\n}\n\n/**\n * @constructor\n */\nfunction Handler(onFulfilled, onRejected, promise) {\n this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;\n this.onRejected = typeof onRejected === 'function' ? onRejected : null;\n this.promise = promise;\n}\n\n/**\n * Take a potentially misbehaving resolver function and make sure\n * onFulfilled and onRejected are only called once.\n *\n * Makes no guarantees about asynchrony.\n */\nfunction doResolve(fn, self) {\n var done = false;\n try {\n fn(\n function(value) {\n if (done) return;\n done = true;\n resolve(self, value);\n },\n function(reason) {\n if (done) return;\n done = true;\n reject(self, reason);\n }\n );\n } catch (ex) {\n if (done) return;\n done = true;\n reject(self, ex);\n }\n}\n\nPromise.prototype['catch'] = function(onRejected) {\n return this.then(null, onRejected);\n};\n\nPromise.prototype.then = function(onFulfilled, onRejected) {\n // @ts-ignore\n var prom = new this.constructor(noop);\n\n handle(this, new Handler(onFulfilled, onRejected, prom));\n return prom;\n};\n\nPromise.prototype['finally'] = promiseFinally;\n\nPromise.all = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.all accepts an array'));\n }\n\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n try {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n var then = val.then;\n if (typeof then === 'function') {\n then.call(\n val,\n function(val) {\n res(i, val);\n },\n reject\n );\n return;\n }\n }\n args[i] = val;\n if (--remaining === 0) {\n resolve(args);\n }\n } catch (ex) {\n reject(ex);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n};\n\nPromise.resolve = function(value) {\n if (value && typeof value === 'object' && value.constructor === Promise) {\n return value;\n }\n\n return new Promise(function(resolve) {\n resolve(value);\n });\n};\n\nPromise.reject = function(value) {\n return new Promise(function(resolve, reject) {\n reject(value);\n });\n};\n\nPromise.race = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.race accepts an array'));\n }\n\n for (var i = 0, len = arr.length; i < len; i++) {\n Promise.resolve(arr[i]).then(resolve, reject);\n }\n });\n};\n\n// Use polyfill for setImmediate for performance gains\nPromise._immediateFn =\n // @ts-ignore\n (typeof setImmediate === 'function' &&\n function(fn) {\n // @ts-ignore\n setImmediate(fn);\n }) ||\n function(fn) {\n setTimeoutFunc(fn, 0);\n };\n\nPromise._unhandledRejectionFn = function _unhandledRejectionFn(err) {\n if (typeof console !== 'undefined' && console) {\n console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console\n }\n};\n\nexport default Promise;\n","/**\n * @this {Promise}\n */\nfunction finallyConstructor(callback) {\n var constructor = this.constructor;\n return this.then(\n function(value) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n return value;\n });\n },\n function(reason) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n // @ts-ignore\n return constructor.reject(reason);\n });\n }\n );\n}\n\nexport default finallyConstructor;\n","import { ITelemetryEvent } from '@mecontrol/common';\r\nimport { ME, createError } from '../../utilities';\r\nimport Promise from 'promise-polyfill';\r\nimport { TrustedTypesWindow } from 'trusted-types/lib';\r\n\r\nlet _w: any = window;\r\nlet _appInsights: any;\r\n/**\r\n * Maximum retries to execute the downloaded 1ds minified library\r\n */\r\nconst MAX_RETRIES = 3;\r\n\r\n// Performance.now() and Date.now() Polyfills\r\nif ('performance' in window == false) {\r\n _w.performance = {};\r\n}\r\n\r\nDate.now =\r\n Date.now ||\r\n function (): number {\r\n return new Date().getTime();\r\n };\r\n\r\nif ('now' in window.performance === false) {\r\n let nowOffset = Date.now();\r\n\r\n if (\r\n window.performance.timing &&\r\n window.performance.timing.navigationStart\r\n ) {\r\n nowOffset = window.performance.timing.navigationStart;\r\n }\r\n\r\n window.performance.now = function (): number {\r\n return Date.now() - nowOffset;\r\n };\r\n}\r\n\r\nlet eventsQueue: ITelemetryEvent[] = [];\r\n\r\n/**\r\n * Send events to 1DS\r\n * @param events Array of events to send\r\n */\r\nexport function writeEvent(events: ITelemetryEvent[]): void {\r\n eventsQueue = eventsQueue.concat(events);\r\n flushEvents();\r\n}\r\n\r\nexport function flushEvents(): void {\r\n if (_appInsights) {\r\n eventsQueue.forEach(e => {\r\n _appInsights.track(getEventData(e));\r\n });\r\n\r\n eventsQueue = [];\r\n }\r\n}\r\n\r\n/**\r\n * Take in a telemetry event for Vortex and convert it into the final shape that\r\n * Vortex events have, so that JSLL can process it\r\n * @param event Event to convert\r\n */\r\nfunction getEventData(event: ITelemetryEvent): any {\r\n return {\r\n name: event.partA.name,\r\n data: {\r\n ...event.partA,\r\n data: {\r\n baseData: event.partB && { ...event.partB },\r\n ...event.partC\r\n }\r\n }\r\n };\r\n}\r\n\r\nconst ttWindow = window as unknown as TrustedTypesWindow;\r\nconst trustedTypesLibrary = typeof ttWindow.trustedTypes !== \"undefined\" &&\r\n typeof ttWindow.trustedTypes.createPolicy !== \"undefined\"\r\n ? ttWindow.trustedTypes\r\n : { createPolicy: (_name: string, rules: any) => rules }; // Tinyfill for unsupported browsers\r\n\r\nconst ScriptURLPolicy1DS = trustedTypesLibrary.createPolicy('1DSScriptURL', {\r\n createScriptURL: (url: string): string => {\r\n if (url) {\r\n if (new URL(url).origin === \"https://js.monitor.azure.com\") {\r\n return url;\r\n } else {\r\n throw createError(\"1DS Script url is not trusted. Does not match the expected origin.\");\r\n }\r\n } else {\r\n throw createError(\"1DS Script url is not trusted. Expected url is not defined.\");\r\n }\r\n }\r\n});\r\n\r\nexport function initialize1DS(): Promise {\r\n return new Promise((resolve, reject) => {\r\n if (_appInsights) {\r\n resolve();\r\n return;\r\n }\r\n\r\n /** Iterations to instantiate AppInsights */\r\n let i = 0;\r\n const url = ME.Config.oneDSUrl;\r\n const head = document.getElementsByTagName('head')[0];\r\n let script: HTMLScriptElement | undefined =\r\n document.createElement('script');\r\n script.async = true;\r\n script.type = 'text/javascript';\r\n script.charset = 'UTF-8';\r\n try {\r\n script.src = ScriptURLPolicy1DS.createScriptURL(url) as unknown as string;\r\n } catch(error) {\r\n cleanup();\r\n reject(error);\r\n }\r\n\r\n const timeoutId = setTimeout(onScriptTimeout, ME.Config.timeoutMs);\r\n\r\n // IE9 - IE8 and below require using 'onreadystatechange'\r\n script.onload = onScriptComplete;\r\n script.onerror = onScriptError;\r\n\r\n script.crossOrigin = 'anonymous';\r\n head.appendChild(script);\r\n\r\n function cleanup(): void {\r\n clearTimeout(timeoutId);\r\n if (script) {\r\n // Avoid memory leaks in IE\r\n script.onerror = script.onload = undefined as any;\r\n script = undefined;\r\n }\r\n }\r\n\r\n function onScriptError(event: Event | string): void {\r\n cleanup();\r\n const errorMessage = 'oneDsMeControl failed to download/parse/compile';\r\n reject(createError(`${errorMessage}: ${url}`, true));\r\n }\r\n\r\n function onScriptTimeout(): void {\r\n cleanup();\r\n const errorMessage = 'oneDsMeControl download timed out';\r\n reject(createError(`${errorMessage}: ${url}`, true));\r\n }\r\n\r\n function onScriptComplete(event: Event | string): void {\r\n if (i < MAX_RETRIES) {\r\n /**\r\n * To queue onto the event loop\r\n */\r\n setTimeout(initializeAppInsightsCore, 0);\r\n } else {\r\n reject('oneDsMeControl did not instantiate');\r\n }\r\n }\r\n function initializeAppInsightsCore() {\r\n i++;\r\n try {\r\n if (!_w.oneDsMeControl) throw 'oneDsMeControl variable is undefined';\r\n const appInsightsCore = new _w.oneDsMeControl.AppInsightsCore();\r\n const postChannel = new _w.oneDsMeControl.PostChannel();\r\n const propertiesPlugin = new _w.oneDsMeControl.PropertiesPlugin();\r\n\r\n const postChannelConfig = {\r\n eventsLimitInMem: 50\r\n };\r\n const propertiesPluginConfig = {\r\n gpcDataSharingOptIn: false,\r\n hashIdentifiers: true\r\n };\r\n let coreConfig: any = {\r\n instrumentationKey: ME.Config.instKey,\r\n extensions: [ postChannel, propertiesPlugin],\r\n extensionConfig: [],\r\n cookieCfg: {\r\n ignoreCookies: [ \"ANON\" ]\r\n }\r\n };\r\n coreConfig.extensionConfig[postChannel.identifier] = postChannelConfig;\r\n coreConfig.extensionConfig[propertiesPlugin.identifier] = propertiesPluginConfig;\r\n\r\n //Initialize SDK\r\n appInsightsCore.initialize(coreConfig, []);\r\n _appInsights = appInsightsCore;\r\n\r\n cleanup();\r\n resolve();\r\n } catch {\r\n onScriptComplete('');\r\n }\r\n }\r\n });\r\n}\r\n","import { PageAction, PageName, EventParams, ContentSource } from '@mecontrol/common';\r\nimport { SyntheticEvent, getPerfEntries, perfNow, getOptions, ME } from './utilities';\r\nimport { setUpTelemetry, fireEvent, getCurrentAccountType } from './telemetry';\r\nimport { AccountType } from '@mecontrol/public-api';\r\n\r\nsetUpTelemetry(!!(ME.Config && ME.Config.main !== \"iframeBootCore\"));\r\n\r\n/**\r\n * Logs a telemetry event. Uses a proxy to allow queueing of events until the Event Generator is ready\r\n * @param type A string containing the type of event we are logging\r\n * @param eventParams An object that contains all the information needed to create the event\r\n */\r\nexport function logTelemetryEvent(eventParams: EventParams): void {\r\n if (!ME?.Config?.enableTelemetry || \r\n (!ME?.Config?.enableAADTelemetry && (getCurrentAccountType() === AccountType.AAD || getCurrentAccountType() === undefined))) {\r\n return;\r\n }\r\n\r\n const isInitialView = (params: EventParams) =>\r\n params.eventType === 'ContentUpdate' &&\r\n params.content.source === ContentSource.UX &&\r\n params.content.id === PageName.initial;\r\n const isInitialPageAction = (params: EventParams) =>\r\n params.eventType === 'PageAction' &&\r\n params.content &&\r\n (params.content.id == PageAction.signOut || params.content.id == PageAction.viewAccount);\r\n\r\n if (isInitialView(eventParams) || isInitialPageAction(eventParams)) {\r\n const options = getOptions();\r\n if (options) {\r\n let syntheticEvent = new SyntheticEvent(\"telemetry\", {\r\n data: {\r\n event: eventParams\r\n }\r\n });\r\n options.syntheticEventTarget.dispatchEvent(syntheticEvent); // no need to catch the return since it's not cancellable\r\n }\r\n }\r\n\r\n fireEvent(eventParams);\r\n}\r\n\r\n/**\r\n * Use the performance API to fire OutgoingRequest telemetry events for resources that\r\n * belong to us but whose download was not initiated by us (thus making us incapable of\r\n * tracking them)\r\n */\r\nexport function logResourcesDownloaded(): void {\r\n let now = perfNow();\r\n\r\n // Gather all performance entries and filter them out\r\n // using the regex above\r\n getPerfEntries()\r\n .filter((entry: PerformanceEntry) => isMeControlUrl(entry.name))\r\n\r\n // Queue up telemetry for entries that may belong to us.\r\n .forEach((entry: PerformanceEntry) => logTelemetryEvent({\r\n eventType: 'OutgoingRequest',\r\n serviceOperation: 'LoadResource',\r\n service: 'MeControl',\r\n url: entry.name,\r\n success: true,\r\n duration: now - entry.startTime\r\n }));\r\n}\r\n\r\n// Regex used for testing against URL domains for our possible MeControl domains:\r\n// - mem.gfx.ms\r\n// - controls.account.microsoft.com\r\n// - controls.account.microsoft-int.com\r\n// - controls.account.microsoft-dev.com\r\n// - amcdn.msauth.net\r\n// - amcdn.msftauth.net\r\nconst domainRegex = /^(?:mem\\.gfx\\.ms|controls\\.account\\.microsoft|amcdn\\.ms(?:ft)?auth\\.net)/i;\r\n\r\n/**\r\n * Determine whether a given URL is for a MeControl resource/endpoint\r\n * @param url URL to check\r\n */\r\nfunction isMeControlUrl(url: string): boolean {\r\n const a = document.createElement('a');\r\n a.href = url;\r\n const domain = a.hostname;\r\n\r\n return domainRegex.test(domain);\r\n}\r\n","import { batchEvents, setOneDSWriter } from './eventWriter';\r\nimport { setEventCreator } from './eventGenerator';\r\n\r\n\r\nimport { createClientError } from './creators/clientError';\r\nimport { createOutgoingRequest } from './creators/outgoingRequest';\r\nimport { createTrackedScenario } from './creators/trackedScenario';\r\nimport { flushEvents, initialize1DS, writeEvent as writeEvent1DS } from './IdentityUX.Shared.Telemetry/OneDSTelemetryInitializer';\r\nimport { ME } from '../utilities';\r\n\r\nexport {\r\n getPageTags,\r\n getTimeSince,\r\n createPartA,\r\n setEventCreator,\r\n fireEvent\r\n} from './eventGenerator';\r\nexport { EventMoment, updateMoment, getCurrentAccountType } from './eventQueue';\r\nexport {\r\n addEventWriter,\r\n writeEvent,\r\n batchEvents,\r\n} from './eventWriter';\r\nexport {\r\n flushEvents,\r\n initialize1DS\r\n} from './IdentityUX.Shared.Telemetry/OneDSTelemetryInitializer';\r\nexport * from './utilities';\r\n\r\n/** Set up initial event creators and writers */\r\nexport function setUpTelemetry(shouldBatch: boolean): void {\r\n // Setup the one DS writer to go along with the collection of writers so that both locations are have\r\n // all events written until it is decided to remove the old writers to Vortex.\r\n setOneDSWriter(writeEvent1DS);\r\n\r\n // Removed batching of events as the EventsAPI shared library has its own queing system.\r\n batchEvents(false);\r\n\r\n // Set initial event creators\r\n setEventCreator('ClientError', createClientError);\r\n setEventCreator('OutgoingRequest', createOutgoingRequest);\r\n setEventCreator('TrackedScenario', createTrackedScenario);\r\n \r\n if (ME?.Config?.enableTelemetry) {\r\n initialize1DS().then(() => {\r\n flushEvents();\r\n }).catch(()=>{\r\n // One retry to download script\r\n initialize1DS().then(()=>{\r\n flushEvents();\r\n });\r\n });\r\n }\r\n}\r\n","import Promise from \"promise-polyfill\";\r\nimport { createError, w } from './utilities';\r\nimport { logTelemetryEvent } from './logger';\r\nimport { ErrorSeverity } from '@mecontrol/common';\r\n\r\ndeclare global {\r\n interface Window {\r\n Promise?: PromiseConstructorLike;\r\n }\r\n}\r\n\r\n/*\r\n * If native Promise is supported, use that to queue our promise polyfill's deferred fns.\r\n * This hook implementation improves the performance of our promises by running deferred\r\n * functions as microtasks instead of whenever the browser fires a timer\r\n *\r\n * [Learn more about microtask and browser queues]: https://youtu.be/cCOL7MC4Pl0\r\n */\r\nif (typeof w.Promise !== \"undefined\" && w.Promise.toString().indexOf('[native code]') !== -1) {\r\n Promise._immediateFn = callback => {\r\n return (w.Promise as any).resolve().then(callback);\r\n };\r\n}\r\n\r\nconst originalUnhandledFn = Promise._unhandledRejectionFn;\r\nPromise._unhandledRejectionFn = function (error: any): void {\r\n if (process.env.NODE_ENV === \"development\") {\r\n originalUnhandledFn(error);\r\n }\r\n\r\n logTelemetryEvent({\r\n eventType: \"ClientError\",\r\n isCritical: true,\r\n name: error.message || '(falsey message property on error)', // Just to be safe...\r\n type: \"UnhandledPromiseRejection\",\r\n details: error.stack || '', // IE11 Error objects don't have stack property\r\n displayed: false,\r\n severity: error.mcIsTimeout ? ErrorSeverity.Warning : ErrorSeverity.Error\r\n });\r\n};\r\n\r\nfunction timeout(promise: Promise, ms: number): Promise {\r\n return new Promise((resolve, reject) => {\r\n const timeoutId = setTimeout(() => {\r\n reject(createError(`Promise timed out after ${ms}ms.`, true));\r\n }, ms);\r\n\r\n promise\r\n .then(resolve, reject)\r\n .finally(() => { clearTimeout(timeoutId); });\r\n });\r\n}\r\n\r\nexport {\r\n Promise,\r\n timeout,\r\n};\r\n","import { BundleId, AnyFunction } from '@mecontrol/common';\r\n\r\nexport interface BundleQueueItem {\r\n id: BundleId;\r\n deps: string[];\r\n factory: AnyFunction;\r\n}\r\n\r\nconst bundleQueue: BundleQueueItem[] = [];\r\n\r\nexport function popBundle(): BundleQueueItem | undefined {\r\n return bundleQueue.pop();\r\n}\r\n\r\nexport function queueBundle(id: BundleId, deps: string[], factory: AnyFunction): void {\r\n bundleQueue.push({ id, deps, factory });\r\n}\r\n\r\nexport function queueLength(): number {\r\n return bundleQueue.length;\r\n}\r\n","import { BundleId } from '@mecontrol/common';\r\nimport { Promise } from '../promise';\r\n\r\nexport interface BundleMetadata {\r\n /** The bundle id for this metadata object */\r\n id: BundleId;\r\n\r\n /**\r\n * The cached promise created when the bundle script begins downloading.\r\n * Resolves to the result of the exports promise.\r\n */\r\n bundlePromise: Promise;\r\n\r\n /**\r\n * The cached promise created when the bundle dependencies are downloading.\r\n * Resolves to the exports of the bundle.\r\n */\r\n exports?: Promise;\r\n}\r\n\r\nexport type BundleCache = { [bundleId in BundleId]?: BundleMetadata | undefined; };\r\n\r\nconst bundleCache: BundleCache = {};\r\n\r\nexport function getBundleCache(id: BundleId): BundleMetadata {\r\n return bundleCache[id] as any;\r\n}\r\n\r\nexport function setBundleCache(id: BundleId, bundlePromise: Promise, exports?: Promise): void {\r\n bundleCache[id] = {\r\n id,\r\n bundlePromise,\r\n exports,\r\n };\r\n}\r\n","import { BundleId, AmdDependencies, AnyFunction } from '@mecontrol/common';\r\nimport { queueBundle } from './queue';\r\n\r\nexport function meDefine(id: BundleId, factory: AnyFunction): void;\r\nexport function meDefine(id: BundleId, deps: AmdDependencies[], factory: AnyFunction): void;\r\nexport function meDefine(id: BundleId, depsOrFactory: AmdDependencies[] | AnyFunction, possibleFactory?: AnyFunction): void {\r\n let deps: AmdDependencies[];\r\n let factory: AnyFunction;\r\n if (typeof depsOrFactory === 'function') {\r\n deps = [];\r\n factory = depsOrFactory;\r\n }\r\n else {\r\n deps = depsOrFactory;\r\n factory = possibleFactory as AnyFunction;\r\n }\r\n\r\n queueBundle(id, deps, factory);\r\n}\r\n","import { BundleId } from \"@mecontrol/common\";\r\nimport { ME, perfNow, MeControlError, createError, w, getRootDomainUrl, isValidURL } from \"../utilities\";\r\nimport { logTelemetryEvent } from \"../logger\";\r\nimport { Promise, timeout } from \"../promise\";\r\nimport { queueLength, popBundle } from './queue';\r\nimport { getBundleCache, setBundleCache } from './cache';\r\nimport { meDefine } from './define';\r\nimport { TrustedTypesWindow } from \"trusted-types/lib\";\r\n\r\nconst bundleIdMap: { [key: string]: BundleId } = {\r\n \"@mecontrol/web-inline\": \"meInline\",\r\n \"@mecontrol/web-boot\": \"meBoot\",\r\n \"@mecontrol/web-core\": \"meCore\"\r\n};\r\n\r\nconst ttWindow = window as unknown as TrustedTypesWindow;\r\nconst trustedTypesLibrary = typeof ttWindow.trustedTypes !== \"undefined\" &&\r\n typeof ttWindow.trustedTypes.createPolicy !== \"undefined\"\r\n ? ttWindow.trustedTypes\r\n : { createPolicy: (_name: string, rules: any) => rules }; // Tinyfill for unsupported browsers\r\n\r\nconst ScriptURLPolicyMeControl = trustedTypesLibrary.createPolicy('MeControlScriptURL', {\r\n createScriptURL: (url: string): string => {\r\n if ((isValidURL(url) && new URL(url).origin === getRootDomainUrl()) || \r\n (!isValidURL(url) && url.indexOf(getRootDomainUrl()) === 0)) {\r\n return url;\r\n }\r\n throw createError(\"MeControl Script url is not trusted. Does not match the expected origin.\");\r\n }\r\n});\r\n\r\n/**\r\n * Download a Me Control bundle and return a Promise of its exports\r\n * @param bundleId The id of the bundle to download\r\n */\r\nexport function meImport(bundleId: Bundle): Promise {\r\n try {\r\n if (bundleId in bundleIdMap) {\r\n bundleId = bundleIdMap[bundleId] as any;\r\n }\r\n\r\n updateBundleCache();\r\n let bundleMetadata = getBundleCache(bundleId);\r\n if (bundleMetadata) {\r\n return bundleMetadata.bundlePromise;\r\n }\r\n\r\n const bundlePromise = downloadScript(bundleId);\r\n setBundleCache(bundleId, bundlePromise);\r\n\r\n return bundlePromise;\r\n }\r\n catch (err) {\r\n return Promise.reject(err);\r\n }\r\n}\r\n\r\nfunction downloadScript(bundleId: BundleId): Promise {\r\n return new Promise((resolve, reject) => {\r\n const start = perfNow();\r\n const url = getJsUrl(bundleId);\r\n\r\n const head = document.getElementsByTagName('head')[0];\r\n let script: HTMLScriptElement | undefined = document.createElement('script');\r\n script.async = true;\r\n script.type = 'text/javascript';\r\n script.charset = 'UTF-8';\r\n try {\r\n script.src = ScriptURLPolicyMeControl.createScriptURL(url) as string;\r\n } catch(error) {\r\n cleanup();\r\n reject(error);\r\n }\r\n\r\n const timeoutId = setTimeout(onScriptTimeout, ME.Config.timeoutMs);\r\n\r\n // IE9 - IE8 and below require using 'onreadystatechange'\r\n script.onload = onScriptComplete;\r\n script.onerror = onScriptError;\r\n\r\n script.crossOrigin = \"anonymous\";\r\n head.appendChild(script);\r\n\r\n function cleanup(): number {\r\n clearTimeout(timeoutId);\r\n if (script) {\r\n // Avoid memory leaks in IE\r\n script.onerror = script.onload = undefined as any;\r\n script = undefined;\r\n }\r\n\r\n return perfNow() - start;\r\n }\r\n\r\n function onScriptError(event: Event | string): void {\r\n const duration = cleanup();\r\n const errorMessage = 'Bundle failed to download/parse/compile';\r\n reportBundleLoadQos(bundleId, duration, url, true, errorMessage);\r\n reject(createError(`${errorMessage}: ${bundleId} (${url})`, false));\r\n }\r\n\r\n function onScriptTimeout(): void {\r\n const duration = cleanup();\r\n const errorMessage = 'Bundle download timed out';\r\n reportBundleLoadQos(bundleId, duration, url, true, errorMessage);\r\n reject(createError(`${errorMessage}: ${bundleId} (${url})`, true));\r\n }\r\n\r\n function onScriptComplete(event: Event | string): void {\r\n const duration = cleanup();\r\n\r\n // The bundle successfully loaded if the promise for its exports was processed by the define queue\r\n updateBundleCache();\r\n const metadata = getBundleCache(bundleId);\r\n const bundleExports = metadata && metadata.exports;\r\n if (bundleExports) {\r\n timeout(bundleExports, ME.Config.timeoutMs)\r\n .then(exports => {\r\n reportBundleLoadQos(bundleId, duration, url, false);\r\n resolve(exports);\r\n })\r\n .catch((error: MeControlError) => {\r\n const errorMessage = error.mcIsTimeout ?\r\n 'Resolving deps and exports timed out' :\r\n 'Resolving deps and exports failed';\r\n reportBundleLoadQos(bundleId, duration, url, true, errorMessage);\r\n reject(createError(`${errorMessage}: ${bundleId} (${url}). Inner error: ${error.message}`, error.mcIsTimeout));\r\n });\r\n }\r\n else {\r\n let errorMessage: string;\r\n if (w.MeControlDefine != meDefine) {\r\n errorMessage = 'window.MeControlDefine does not equal this bundle\\'s meDefine function. Did you load Me Control twice?';\r\n }\r\n else {\r\n errorMessage = 'Bundle failed to load exports';\r\n }\r\n\r\n reportBundleLoadQos(bundleId, duration, url, true, errorMessage);\r\n reject(createError(`${errorMessage}: ${bundleId} (${url})`, false));\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Go through all currently queued bundles and import their dependencies so that\r\n * they can now be found in the bundle cache.\r\n */\r\nfunction updateBundleCache(): void {\r\n while (queueLength()) {\r\n const queuedBundle = popBundle();\r\n if (queuedBundle) {\r\n\r\n // IE9 - Array.prototype.map is IE9 and above\r\n const bundleExports: any = {};\r\n const exports = Promise.all(queuedBundle.deps\r\n .map(depId => depId === 'exports' ? bundleExports : meImport(depId as any)))\r\n .then(deps => { queuedBundle.factory(...deps); })\r\n .then(() => bundleExports);\r\n\r\n const metadata = getBundleCache(queuedBundle.id);\r\n if (!metadata) {\r\n // Possible for bundles that call MeControlDefine but aren't downloaded using meImport (e.g. web-inline)\r\n setBundleCache(queuedBundle.id, exports, exports);\r\n }\r\n else {\r\n metadata.exports = exports;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Get the full url for a javascript file\r\n * @param fileName The filename to get the full url of\r\n * @internal\r\n */\r\nfunction getJsUrl(fileName: string): string {\r\n // EX: {GFX}/MeControl/Version/Market/meBoot[.min].js\r\n const config = ME.Config;\r\n return `${getRootDomainUrl()}/scripts/me/MeControl/${config.ver}/${config.mkt}/${fileName}${config.dbg ? '' : '.min'}.js`;\r\n}\r\n\r\n/**\r\n * Reports QoS related to a script load operation\r\n * @param bundleId The script id\r\n * @param duration The load duration\r\n * @param url The script url\r\n * @param failed True if it failed to load, false otherwise\r\n * @param message The message to include in telemetry\r\n */\r\nfunction reportBundleLoadQos(bundleId: string, duration: number, url: string, failed: boolean, message?: string): void {\r\n logTelemetryEvent({\r\n eventType: 'OutgoingRequest',\r\n serviceOperation: 'DownloadScript',\r\n service: 'MeControl',\r\n url,\r\n success: !failed,\r\n duration,\r\n message\r\n });\r\n}\r\n","/// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport { IPublicApiProxy } from '@mecontrol/public-api';\r\nimport { createProxy } from './createProxy';\r\nimport { logTelemetryEvent } from './logger';\r\n\r\nlet _proxy = createProxy();\r\n\r\nexport type SetController = typeof _proxy.setComponent;\r\n\r\n// controllerSetter will default to V2 public proxy setter, but the method below\r\n// allow us to override what controllerSetter is for backCompat purposes\r\nlet controllerSetter: SetController = _proxy.setComponent;\r\n\r\nexport const getControllerSetter = () => controllerSetter;\r\nexport const setControllerSetter = (setter: SetController) => controllerSetter = setter;\r\n\r\n// See the definition of IPublicApiProxy for documentation on each of these methods and their call signatures\r\nexport const publicProxy: IPublicApiProxy = {\r\n setActiveAccount: handleCall('setActiveAccount'),\r\n setCommands: handleCall('setCommands'),\r\n setAccountPicture: handleCall('setAccountPicture'),\r\n setProfilePicture: handleCall('setProfilePicture'),\r\n refreshProfilePicture: handleCall('refreshProfilePicture'),\r\n refreshAccountPicture: handleCall('refreshAccountPicture'),\r\n setTheme: handleCall('setTheme'),\r\n setHeaderTheme: handleCall('setHeaderTheme'),\r\n setDisplayMode: handleCall('setDisplayMode'),\r\n loadPresenceConfig: handleCall('loadPresenceConfig'),\r\n setPresence: handleCall('setPresence'),\r\n addEventListener: handleCall('addEventListener'),\r\n removeEventListener: handleCall('removeEventListener')\r\n};\r\n\r\n/**\r\n * Wrapper around the Component Proxy handleComponentCall method to log PartnerApiCall events\r\n * @param method The event being called\r\n * @returns A function that both logs a telemetry event and uses the proxy to call the supplied method\r\n */\r\n\r\nfunction handleCall(method: keyof IPublicApiProxy): (...params: any[]) => void {\r\n let func = _proxy.handleCall(method);\r\n\r\n return (...params: any[]) => {\r\n logTelemetryEvent({\r\n eventType: 'PartnerApiCall',\r\n method,\r\n params: [...params]\r\n });\r\n\r\n func(...params);\r\n };\r\n}\r\n","/// Copyright (C) Microsoft Corporation. All rights reserved.\r\nimport { AnyObject } from '@mecontrol/common';\r\nimport { hasOwn } from './utilities';\r\n\r\nexport interface IComponentProxy {\r\n /**\r\n * Sets the component instance at which point we trigger any queued requests,\r\n * and stop queuing them for future requests. Subsequent requests are delegated\r\n * directly to the component\r\n *\r\n * @param {T} component The controller instance that will receive delegated requests\r\n */\r\n setComponent(component: T): void;\r\n\r\n /**\r\n * Handles a single request by delegating or queuing it depending on the component being ready.\r\n *\r\n * @param {keyof T} name The name of the function to be called on the component\r\n * @param {boolean} priority Optional flag to indicate this method's calls should be prioritized\r\n * @param {any[]} params The parameters to be passed into the delegated function\r\n */\r\n handleCall: (name: keyof T, priority?: boolean) => (...params: any[]) => void;\r\n}\r\n\r\ninterface IQueuedCall {\r\n name: keyof M;\r\n params: any[];\r\n}\r\n\r\n/**\r\n * Creates a class to delegate calls to an object that will be delay-loaded.\r\n * The type of the object being proxied is the generic parameter.\r\n */\r\nexport function createProxy(): IComponentProxy {\r\n let _component: T;\r\n let _queuedCalls: IQueuedCall[] = [];\r\n let _priorityPos = 0;\r\n\r\n function setComponent(component: T): void {\r\n _component = component;\r\n\r\n let queuedCalls = _queuedCalls;\r\n _queuedCalls = [];\r\n for (let i = 0; i < queuedCalls.length; i++) {\r\n triggerCall(queuedCalls[i]);\r\n }\r\n }\r\n\r\n const handleCall = (name: keyof T, priority: boolean = false) => (...params: any[]) => {\r\n let qCall: IQueuedCall = { name, params };\r\n if (_component) {\r\n triggerCall(qCall);\r\n }\r\n else {\r\n // Queue up a component call for the proxy. Handles prioritizing important calls by inserting them\r\n // before the first non-priority calls in the queue.\r\n _queuedCalls.splice(priority ? _priorityPos++ : _queuedCalls.length, 0, qCall);\r\n }\r\n };\r\n\r\n function triggerCall(queuedCall: IQueuedCall): void {\r\n let apiName = queuedCall.name as string;\r\n if (_component && hasOwn(_component, apiName)) {\r\n _component[apiName].apply(_component, queuedCall.params);\r\n }\r\n }\r\n\r\n return {\r\n setComponent,\r\n handleCall,\r\n };\r\n}\r\n","import {\r\n IMeControlConfiguration, AuthenticatedState, AuthProviderConfigType, IConfigurationEvents,\r\n DisplayModeType, SignInExperienceType, IDP, IPresenceConfig, IPresenceState, MeControlEventType, MeControlEventHandler\r\n} from \"@mecontrol/public-api\";\r\nimport { IValidatedMeControlConfiguration, Scenario, ScenarioStage } from '@mecontrol/common';\r\nimport { logResourcesDownloaded, logTelemetryEvent } from './logger';\r\nimport { ME, perfNow, hasOwn, createError, setOptions } from './utilities';\r\nimport { Promise } from './promise';\r\nimport { meImport } from './amd/import';\r\nimport { getControllerSetter } from './publicProxy';\r\nimport { MainModule } from '.';\r\nimport { SyntheticEventTarget } from './utilities/events';\r\n\r\nconst NO_JS_STYLES = \"white-space: nowrap; text-overflow: ellipsis; overflow: hidden; max-width: 160px; display: inline-block; line-height: 48px; font-family: \\'Segoe UI\\'; font-size: 12.4px; color: rgb(80,80,80); padding: 0 10px;\";\r\n\r\nlet startTime = 0;\r\n\r\n/**\r\n * Initiates the main module of MeControl and returns a promise wrapped around that\r\n * @param options Validated MeControl options\r\n */\r\nexport function initiateMain(options: IValidatedMeControlConfiguration, callingMethod: string): Promise {\r\n startTime = perfNow();\r\n\r\n const loadSuccessTelemetry = (success: boolean) => {\r\n logTelemetryEvent({\r\n eventType: 'TrackedScenario',\r\n scenario: Scenario.Load,\r\n previousAction: ScenarioStage.Start,\r\n action: ScenarioStage.End,\r\n success,\r\n durationMs: getTimeSinceStart(),\r\n details: callingMethod\r\n });\r\n };\r\n\r\n return meImport(ME.Config.main)\r\n .then((main: MainModule) => main.init(options, getControllerSetter()))\r\n .then(() => {\r\n loadSuccessTelemetry(true);\r\n }, error => {\r\n // Bubble up error so partners can react, but also render fallback\r\n // links for partners who don't handle errors. We know suiteshell\r\n // will render it's fallback in this error case so we shouldn't\r\n // render ours.\r\n if (ME.Config.wrapperId !== 'suiteshell') {\r\n showHeaderNoJs(options);\r\n }\r\n\r\n loadSuccessTelemetry(false);\r\n throw error;\r\n });\r\n}\r\n\r\n/**\r\n * Validates and starts the MeControl. If successful, it will trigger the download of meBoot.js\r\n * @param options The options to initialize the Me Control\r\n * @returns True if validation succeeded, false otherwise\r\n */\r\nexport function loadAsync(options: IMeControlConfiguration | undefined): Promise {\r\n return new Promise((resolve, reject) => {\r\n // Log downloading resources and use of load function before anything else\r\n logResourcesDownloaded();\r\n logTelemetryEvent({ eventType: 'PartnerApiCall', method: 'loadAsync', params: options! });\r\n resolve(initiateMain(validateConfiguration(options), 'loadAsync'));\r\n });\r\n}\r\n\r\nexport function load(options: IMeControlConfiguration | undefined): boolean {\r\n // Log downloading resources and use of load function before anything else\r\n logResourcesDownloaded();\r\n logTelemetryEvent({ eventType: 'PartnerApiCall', method: 'load', params: options! });\r\n\r\n try {\r\n initiateMain(validateConfiguration(options), 'load');\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport function getStartTime(): number {\r\n return startTime;\r\n}\r\n\r\nexport function getTimeSinceStart(): number {\r\n return perfNow() - startTime;\r\n}\r\n\r\n/** Renders the me control in case of failure downloading the JS files */\r\nexport function showHeaderNoJs(options?: IValidatedMeControlConfiguration): void {\r\n if (!options) {\r\n throw createError('No options object given before showHeaderNoJs was called');\r\n }\r\n\r\n const props = getFallbackHeaderProps(options);\r\n\r\n const text = document.createTextNode(props.str || \"\");\r\n\r\n const a = document.createElement('a');\r\n a.href = props.href || \"#\";\r\n a.style.cssText = NO_JS_STYLES;\r\n a.onclick = props.onClick;\r\n a.appendChild(text);\r\n\r\n const wrapper1 = document.createElement('div');\r\n wrapper1.className = \"msame_Header\";\r\n wrapper1.appendChild(a);\r\n\r\n const wrapper2 = document.createElement('div');\r\n wrapper2.appendChild(wrapper1);\r\n\r\n const container = options.shadowDOMContainerElement || document.getElementById(options.containerId);\r\n if (container) {\r\n container.innerHTML = '';\r\n container.appendChild(wrapper2);\r\n }\r\n}\r\n\r\ninterface FallbackHeaderProps {\r\n href?: string;\r\n str?: string;\r\n onClick: ((e: MouseEvent) => void) | null;\r\n}\r\n\r\nfunction getFallbackHeaderProps(options: IValidatedMeControlConfiguration): FallbackHeaderProps {\r\n const isAuthenticated = options.currentAccount && options.currentAccount.authenticatedState == AuthenticatedState.SignedIn;\r\n const str = isAuthenticated ? options.primaryUXConfig!.signOutStr : options.primaryUXConfig!.signInStr;\r\n\r\n let href: string | undefined;\r\n let onClick: (() => void) | null = null;\r\n\r\n // The partner defines the priority of which IDP config is preferred\r\n const authConfig = options.authProviderConfig;\r\n switch (authConfig.type) {\r\n case AuthProviderConfigType.PartnerManaged:\r\n onClick = isAuthenticated ?\r\n () => authConfig.signOutFromApp({ currentAccount: options.currentAccount! }) :\r\n () => authConfig.signIn({ signInType: authConfig.signInExperienceTypes });\r\n break;\r\n case AuthProviderConfigType.AdalJsWithMsaFed:\r\n case AuthProviderConfigType.AdalJsAadOnly:\r\n onClick = isAuthenticated ?\r\n () => authConfig.signOutFromApp({ currentAccount: options.currentAccount! }) :\r\n () => authConfig.signIn({ signInType: SignInExperienceType.Aad });\r\n break;\r\n case AuthProviderConfigType.MsalJsAadOnly:\r\n case AuthProviderConfigType.MsalJsWithMsa:\r\n // not sure what the default sign in experience should be so I am defaulting to AAD.\r\n onClick = isAuthenticated ?\r\n () => authConfig.signOutFromApp({ currentAccount: options.currentAccount! }) :\r\n () => authConfig.signIn({ signInType: SignInExperienceType.Aad });\r\n break;\r\n case AuthProviderConfigType.V1BackCompat:\r\n const rpData = authConfig.rpData;\r\n const urlPropName = isAuthenticated ? \"signOutUrl\" : \"signInUrl\";\r\n const aadUrlValue = rpData.aadInfo && rpData.aadInfo[urlPropName];\r\n const msaUrlValue = rpData.msaInfo && rpData.msaInfo[urlPropName];\r\n if (rpData.preferredIdp === IDP.AAD && aadUrlValue) {\r\n href = aadUrlValue;\r\n }\r\n else if (rpData.preferredIdp === IDP.MSA && msaUrlValue) {\r\n href = msaUrlValue;\r\n }\r\n else if (aadUrlValue) {\r\n href = aadUrlValue;\r\n }\r\n else if (msaUrlValue) {\r\n href = msaUrlValue;\r\n }\r\n break;\r\n default:\r\n const handler = isAuthenticated ? authConfig.appSignOutUrl : authConfig.appSignInUrl;\r\n href = typeof handler === \"function\" ? handler({ currentAccount: options.currentAccount! }) : handler;\r\n break;\r\n }\r\n\r\n return {\r\n str,\r\n href,\r\n onClick\r\n };\r\n}\r\n\r\nfunction validatePresenceConfiguration(presenceConfig: IPresenceConfig): boolean {\r\n return validatePresenceState(presenceConfig.currentPresence) && validatePresenceList(presenceConfig.presenceList);\r\n}\r\n\r\nfunction validatePresenceList(presenceList: IPresenceState[] | undefined): boolean {\r\n if (presenceList) {\r\n for (let i = 0; i < presenceList.length; i++) {\r\n if (!validatePresenceState(presenceList[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\nfunction validatePresenceState(state: IPresenceState | undefined): boolean {\r\n return state ? state.key.length > 0 && state.key != undefined && state.key != null &&\r\n state.presenceString.length > 0 && state.presenceString != undefined && state.presenceString != null &&\r\n state.imageUrl.length > 0 && state.imageUrl != undefined && state.imageUrl != null : false;\r\n}\r\n\r\nfunction unwindEventsSpecifiedAsProperties(options: IValidatedMeControlConfiguration): void {\r\n if (!options || !options.events) {\r\n return;\r\n }\r\n\r\n let eventName: keyof IConfigurationEvents;\r\n for (eventName in options.events) {\r\n if (!hasOwn(options.events, eventName)) {\r\n continue;\r\n }\r\n\r\n let handler = options.events[eventName];\r\n if (handler) {\r\n // Must lowercase the event name to appropriately match expected value\r\n options.syntheticEventTarget.addEventListener(\r\n eventName.toLowerCase() as MeControlEventType,\r\n handler as MeControlEventHandler\r\n );\r\n }\r\n }\r\n}\r\n\r\nexport function validateConfiguration(options: IMeControlConfiguration | undefined): IValidatedMeControlConfiguration {\r\n // TODO:\r\n // * Validate idpconfig, if the partner give us a PartnerManagedConfig, the partner doesn't define any other idpconfigs\r\n\r\n if (!options) {\r\n throw createError(`Options must be an object. Received ${typeof options}.`);\r\n }\r\n\r\n // Create a copy of the options object to not modify an object we didn't create\r\n options = { ...options };\r\n\r\n if (!options.authProviderConfig) {\r\n throw createError(`options.authProviderConfig not correctly defined. Received ${options.authProviderConfig}.`);\r\n }\r\n\r\n // Presence config validation\r\n if (options.presenceConfig) {\r\n validatePresenceConfiguration(options.presenceConfig);\r\n }\r\n\r\n const uxConfig = options.primaryUXConfig = options.primaryUXConfig || {};\r\n options.events = options.events || {};\r\n\r\n // TODO: replace with localized fallbacks from ME.Config\r\n options.primaryUXConfig.signInStr = uxConfig.signInStr || 'Sign in';\r\n options.primaryUXConfig.signOutStr = uxConfig.signOutStr || 'Sign out';\r\n\r\n // Validate and filter the passed in breakpoints\r\n const validDisplayModeTypes = [DisplayModeType.Compressed];\r\n options.primaryUXConfig.displayModes = (\r\n uxConfig.displayModes &&\r\n uxConfig.displayModes.filter(dm => validDisplayModeTypes.indexOf(dm.type) != -1)\r\n ) || [];\r\n\r\n // Clean up and limit the extensibile links to a max of 5 (1 on body, 4 in dropdown)\r\n if (options.appContextConfig && options.appContextConfig.commands) {\r\n options.appContextConfig.commands = options.appContextConfig.commands.slice(0, 5);\r\n }\r\n\r\n // TODO: Try to remove side-effects from this method\r\n let _options = options as IValidatedMeControlConfiguration;\r\n\r\n // tack the runtime event target onto the _options block to make it universally available\r\n _options.syntheticEventTarget = new SyntheticEventTarget();\r\n\r\n // unwind event callbacks specified on properties and hook them to our new framework\r\n unwindEventsSpecifiedAsProperties(_options);\r\n setOptions(_options);\r\n\r\n return _options;\r\n}\r\n","/// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport {\r\n MeControlNamespace as PublicMeControlNamespace,\r\n IMeControlLoader,\r\n IPublicApiProxy,\r\n} from '@mecontrol/public-api';\r\nimport { w, ME, assign, addStrings } from './utilities';\r\nimport { meDefine, meImport } from './amd/index';\r\nimport { MeControlNamespace as InternalMeControlNamespace } from '@mecontrol/common';\r\n\r\nexport function extendMe(...args: any[]): void {\r\n return assign(ME, ...args);\r\n}\r\n\r\nexport function setPublicWindowApi(\r\n apiProxy: IPublicApiProxy,\r\n load: IMeControlLoader[\"load\"],\r\n loadAsync: IMeControlLoader[\"loadAsync\"]\r\n): void {\r\n // Internal functions used by our custom AMD loader\r\n w.MeControlDefine = meDefine;\r\n w.MeControlImport = meImport;\r\n\r\n const MePublic: PublicMeControlNamespace = {\r\n API: apiProxy,\r\n Loader: {\r\n load,\r\n loadAsync\r\n },\r\n Config: ME.Config || {} as any\r\n };\r\n\r\n // Expose some internals on ME for backwards compat\r\n const MeInternal: Partial = {\r\n Strings: {\r\n addStrings\r\n }\r\n };\r\n\r\n return extendMe(MePublic, MeInternal);\r\n}\r\n","/// Copyright (C) Microsoft Corporation. All rights reserved.\r\n\r\nimport { IValidatedMeControlConfiguration } from '@mecontrol/common';\r\nimport { load, loadAsync } from './loader';\r\nimport { SetController, publicProxy } from './publicProxy';\r\nimport { setPublicWindowApi } from './windowApi';\r\nimport { w } from './utilities';\r\n\r\nexport { meImport } from './amd';\r\nexport * from './promise';\r\nexport { getStartTime, getTimeSinceStart } from './loader';\r\nexport { logTelemetryEvent } from './logger';\r\nexport * from './utilities';\r\nexport * from './telemetry';\r\nexport { extendMe } from './windowApi';\r\n\r\nexport interface MainModule {\r\n init: MainInit;\r\n}\r\nexport type MainInit = (\r\n options: IValidatedMeControlConfiguration | undefined,\r\n setController: SetController\r\n) => void | Promise;\r\n\r\nsetPublicWindowApi(publicProxy, load, loadAsync);\r\n\r\n// Notify consumers that the Load API is ready to be called\r\nlet onLoad = w.onMeControlReadyToLoad;\r\n// Call onLoad asynchronously\r\nsetTimeout(() => onLoad && onLoad(), 0);\r\n","import { createError } from '@mecontrol/web-inline';\r\n\r\n// Consider: Using [url-parse](https://npm.im/url-parse) if our url parsing needs grow more complex\r\n// or we need a cross platform (i.e. non-browser) parser\r\n\r\n/*\r\n * Our ParsedUrl does not implement every method of the [URL standard](https://developer.mozilla.org/en-US/docs/Web/API/URL).\r\n * The following properties are left out because they contain duplicate information\r\n * that is represented in other property, and we have not implemented the logic\r\n * to keep them up to date with each other (mostly for size reasons and because\r\n * we don't need them at this time).\r\n *\r\n * - host (duplicates hostname & port)\r\n * - href (duplicates every other property)\r\n * - origin (duplicates protocol, host, and port)\r\n * - search (duplicates searchParams)\r\n *\r\n * The following properties are not included because the tag does not parse\r\n * and return them in IE. In other words, they are not supported in IE:\r\n *\r\n * - origin\r\n * - password\r\n * - username\r\n *\r\n */\r\n\r\n/**\r\n * A mutable object representing the parts of a URL, inspired by the [URL standard](https://developer.mozilla.org/en-US/docs/Web/API/URL).\r\n */\r\nexport interface ParsedUrl {\r\n /** The protocol scheme of the URL, including the final ':'. */\r\n protocol: string;\r\n\r\n /** The domain of the URL */\r\n hostname: string;\r\n\r\n /** The port of the URL */\r\n port: string;\r\n\r\n /** An initial '/' followed by the path of the URL. */\r\n pathname: string;\r\n\r\n /** An object containing the GET query arguments contained in the URL. */\r\n searchParams: SearchParams;\r\n\r\n /** The URL fragment, including the leading '#' */\r\n hash: string;\r\n\r\n /**\r\n * Serialize the given url to a string. This method will not add the port\r\n * number for http and https protocols if the port is the well-known port\r\n * for those protocols.\r\n * @param url The ParsedUrl to serialize\r\n */\r\n toString(): string;\r\n}\r\n\r\n// Inspired by [URLSearchParams standard](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)\r\n/** The SearchParams interface defines utility methods to work with the query string of a URL. */\r\nexport interface SearchParams {\r\n /**\r\n * Appends a specified key/value pair as a new search parameter.\r\n * @param name The key of the search parameter to append\r\n * @param value The value of the search parameter to append\r\n */\r\n append(name: string, value: string): void;\r\n\r\n /**\r\n * Deletes the given search parameter, and its associated value, from the list of all search parameters.\r\n * @param name The key to delete\r\n */\r\n delete(name: string): void;\r\n\r\n /**\r\n * Returns the first value associated to the given search parameter.\r\n * @param name The key of the search param to get\r\n * @returns The string value of the search param or null if the key does not exist\r\n */\r\n get(name: string): string | null;\r\n\r\n /**\r\n * Returns all the values association with a given search parameter.\r\n * @param name The key to retreive\r\n * @returns The array of all values associated with the given key, or an empty array if the key does not exist\r\n */\r\n getAll(name: string): string[];\r\n\r\n /**\r\n * Returns a Boolean indicating if such a search parameter exists.\r\n * @param name The key to check\r\n */\r\n has(name: string): boolean;\r\n\r\n /**\r\n * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.\r\n * @param name The key to set\r\n * @param value The value to set the search parameter to\r\n */\r\n set(name: string, value: string): void;\r\n\r\n /**\r\n * Returns a string containing a query string suitable for use in a URL.\r\n */\r\n toString(): string;\r\n}\r\n\r\n/**\r\n * Parse a URL into its parts. This method also parses the queryString into an object\r\n * @param url The URL to parse\r\n */\r\nexport function parseUrl(url: string): ParsedUrl {\r\n if (!url) {\r\n throw createError(`Invalid string given to parseUrl: \"${url}\"`);\r\n }\r\n\r\n return new Url(url);\r\n}\r\n\r\nexport function isJavaScriptScheme(parsedUrl: ParsedUrl): boolean {\r\n return parsedUrl.protocol == \"javascript:\";\r\n}\r\n\r\nclass Url implements ParsedUrl {\r\n\r\n private originalUrl: string;\r\n\r\n public protocol: string;\r\n\r\n public hostname: string;\r\n\r\n public port: string;\r\n\r\n public pathname: string;\r\n\r\n public searchParams: SearchParams;\r\n\r\n public hash: string;\r\n\r\n constructor(url: string) {\r\n this.originalUrl = url;\r\n\r\n const a = document.createElement('a');\r\n a.href = url;\r\n\r\n // IE workaround - IE doesn't fill in the page's protocol, hostname or port properties for relative URLs.\r\n // However it does construct an absolute URL when accessing the .href property for relative URLs. So this\r\n // line reads the href property of the A tag which will always be absolute in all browsers tested and\r\n // re-assigns it to the A tag so that the absolute URL is parsed.\r\n a.href = a.href;\r\n\r\n this.protocol = a.protocol;\r\n this.hostname = a.hostname;\r\n this.port = a.port;\r\n this.pathname = a.pathname;\r\n this.searchParams = new UrlSearchParams(a.search);\r\n this.hash = a.hash;\r\n }\r\n\r\n public toString(): string {\r\n if (this.protocol == 'javascript:') {\r\n return this.originalUrl;\r\n }\r\n\r\n // IE workaround - IE always specifies the port for known protocols\r\n // even if it is not specified in the original URL\r\n let port = \"\";\r\n if (\r\n this.port &&\r\n !(this.port === '443' && this.protocol === 'https:') &&\r\n !(this.port === '80' && this.protocol === 'http:')\r\n ) {\r\n port = \":\" + this.port;\r\n }\r\n\r\n // IE workaround - IE doesn't begin `pathname` with a '/' for absolute http(s) URLs\r\n const path = !isJavaScriptScheme(this) && this.pathname[0] !== '/' ? '/' + this.pathname : this.pathname;\r\n const search = this.searchParams ? this.searchParams.toString() : \"\";\r\n const protocolSeparator = !isJavaScriptScheme(this) ? \"//\" : \"\";\r\n\r\n return `${this.protocol}${protocolSeparator}${this.hostname}${port}${path}${search}${this.hash}`;\r\n }\r\n}\r\n\r\n/**\r\n * Replace '+' characters with a space and decode a string using decodeURIComponent\r\n * @param s The string to decode\r\n */\r\nfunction decode(s: string): string {\r\n return decodeURIComponent(s.replace(/\\+/g, ' '));\r\n}\r\n\r\nconst queryStringParser = /([^=?&]+)=?([^&]*)/g;\r\n\r\nclass UrlSearchParams implements SearchParams {\r\n\r\n // IE9 - Object.create is only available in IE9+\r\n // Using Object.create(null):\r\n // - https://stackoverflow.com/a/32263086\r\n // - https://davidwalsh.name/object-create-null\r\n private queryParams: Record = Object.create(null);\r\n\r\n constructor(queryString: string) {\r\n let match;\r\n // tslint:disable-next-line:no-conditional-assignment\r\n while (match = queryStringParser.exec(queryString)) {\r\n // match[0] is the entire matched string. match[1] is first group, match[2] is second, ...\r\n const key = decode(match[1]);\r\n const value = decode(match[2]);\r\n\r\n this.append(key, value);\r\n }\r\n }\r\n\r\n public append(key: string, value: string): void {\r\n if (key in this.queryParams) {\r\n this.queryParams[key].push(value);\r\n }\r\n else {\r\n this.queryParams[key] = [value];\r\n }\r\n }\r\n\r\n public delete(key: string): void {\r\n delete this.queryParams[key];\r\n }\r\n\r\n public get(key: string): string | null {\r\n return key in this.queryParams ? this.queryParams[key][0] : null;\r\n }\r\n\r\n public getAll(key: string): string[] {\r\n return key in this.queryParams ? [...this.queryParams[key]] : [];\r\n }\r\n\r\n public has(key: string): boolean {\r\n return key in this.queryParams;\r\n }\r\n\r\n public set(key: string, value: string): void {\r\n this.queryParams[key] = [value];\r\n }\r\n\r\n public toString(): string {\r\n const serializedPairs = [];\r\n\r\n // tslint:disable-next-line:forin // We are creating queryParams as an object with no prototype so hasOwn check is unnecessary\r\n for (let key in this.queryParams) {\r\n const values = this.queryParams[key];\r\n for (let i = 0; i < values.length; i++) {\r\n serializedPairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(values[i]));\r\n }\r\n }\r\n\r\n return serializedPairs.length ? '?' + serializedPairs.join('&') : '';\r\n }\r\n}\r\n","import { RememberedAccountErrors } from '@mecontrol/common';\r\nimport { setQueryParams } from '@mecontrol/web-boot/lib/src/utilities/url';\r\n\r\ndeclare global {\r\n interface Window {\r\n attachEvent?: (type: string, handler: (e: any) => void) => void;\r\n }\r\n}\r\n\r\nlet proxiedHostname: string;\r\nlet destinationWreply: string;\r\n\r\nfunction handleIdpResponse(e: any): void {\r\n // remove any trailing '/' from origin before checking. just to keep things clean.\r\n if ((e.origin || '').replace(/\\/$/, '') === proxiedHostname) {\r\n postResponse(e.data);\r\n }\r\n}\r\n\r\nfunction postResponse(message: string): void {\r\n if (window === window.parent) {\r\n return;\r\n }\r\n\r\n window.parent.postMessage(message, destinationWreply);\r\n}\r\n\r\n/**\r\n * Given the iFrame control ID, source URL for saved users and allowed hosts, this method will validate the wreply of the source url\r\n * to match that of the window navication and set its value into the iframe source attribute.\r\n *\r\n * @param iFrameId The ID of the iFrame element to set the src value.\r\n * @param sourceUrl The original saved users endpoint URL to update and set as source after validation.\r\n * @param allowedHosts A list of hosts that the iframe is allowed to be run in.\r\n */\r\nexport function setFrameSource(iFrameId: string, sourceUrl: string, allowedHosts: string[]): void {\r\n let frame = document.getElementById(iFrameId) as HTMLIFrameElement;\r\n\r\n // Get current window.location host (with port, if applicable) for validation:\r\n let host = window.location.hostname.toLowerCase();\r\n if (window.location.port &&\r\n !(window.location.port === '443' && window.location.protocol === 'https:') &&\r\n !(window.location.port === '80' && window.location.protocol === 'http:')\r\n ) {\r\n host = `${host}:${window.location.port}`;\r\n }\r\n\r\n for (let allowedHost of allowedHosts) {\r\n if (allowedHost.toLowerCase() === host) {\r\n frame.src = setQueryParams(sourceUrl, { wreply: `https://${host}` });\r\n return;\r\n }\r\n }\r\n\r\n postResponse(JSON.stringify({error: RememberedAccountErrors.InvalidProxiedDomain}));\r\n}\r\n\r\nexport function attachListeners(hostname: string, wreply: string): void {\r\n proxiedHostname = hostname;\r\n destinationWreply = wreply;\r\n\r\n if (window.attachEvent) {\r\n window.attachEvent('onmessage', handleIdpResponse);\r\n }\r\n else {\r\n window.addEventListener('message', handleIdpResponse, false);\r\n }\r\n}\r\n","import { StringMap } from \"@mecontrol/common/\";\r\nimport { hasOwn } from '@mecontrol/web-inline';\r\nimport { parseUrl, isJavaScriptScheme } from './url.polyfill';\r\n\r\n/**\r\n * Sets a dictionary of query string parameters to a given url. It overrides any existing\r\n * query parameters on the URL with the same name\r\n * @param url The url to set the parameters to.\r\n * @param queryParams The query parameters to set on the url.\r\n * @param includeEmptys Default true; determines whether to include query param if string value is empty or null\r\n * @returns The url with the given queryParameters set\r\n */\r\nexport function setQueryParams(url: string, queryParams: Partial, includeEmptys: boolean = true): string {\r\n const parsedUrl = parseUrl(url);\r\n\r\n // Technically, the URL spec allows javascript schemes to have query params\r\n // but in actuality, query params can break javascript schemes,\r\n // so we don't set query params for javascript schemes\r\n if (!isJavaScriptScheme(parsedUrl)) {\r\n for (let key in queryParams) {\r\n let qvalue = queryParams[key];\r\n if (hasOwn(queryParams, key) && (includeEmptys || !!qvalue)) {\r\n parsedUrl.searchParams.set(key, qvalue || '');\r\n }\r\n }\r\n }\r\n\r\n return parsedUrl.toString();\r\n}\r\n\r\n/**\r\n * Checks to see if the given URL has the given queryParam.\r\n *\r\n * @param url {string} The url to check\r\n * @param queryParam {string} The query param key name to check for in the given url\r\n */\r\nexport function hasQueryParam(url: string, queryParam: string): boolean {\r\n if (!url) {\r\n return false;\r\n }\r\n\r\n const parsedUrl = parseUrl(url);\r\n\r\n // Technically, the URL spec allows javascript schemes to have query params\r\n // but in actuality, query params can break javascript schemes,\r\n // so we don't set query params for javascript schemes\r\n if (isJavaScriptScheme(parsedUrl)) {\r\n return false;\r\n }\r\n\r\n return parsedUrl.searchParams.has(queryParam);\r\n}\r\n\r\n/**\r\n * Get the hostname of a URL\r\n * @param url The URL to get the hostname of\r\n */\r\nexport function getHostname(url: string): string {\r\n return parseUrl(url).hostname;\r\n}\r\n\r\n\r\nexport function urlEncodeArr(inputArr: Uint8Array) {\r\n return base64EncArr(inputArr)\r\n .replace(/=/g, \"\")\r\n .replace(/\\+/g, \"-\")\r\n .replace(/\\//g, \"_\");\r\n}\r\n\r\nfunction base64EncArr(aBytes: Uint8Array) {\r\n const eqLen = (3 - (aBytes.length % 3)) % 3;\r\n let sB64Enc = \"\";\r\n\r\n for (var nMod3, nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {\r\n nMod3 = nIdx % 3;\r\n /* Uncomment the following line in order to split the output in lines 76-character long: */\r\n /*\r\n if (nIdx > 0 && (nIdx * 4 / 3) % 76 === 0) { sB64Enc += \"\\r\\n\"; }\r\n */\r\n nUint24 |= aBytes[nIdx] << (16 >>> nMod3 & 24);\r\n if (nMod3 === 2 || aBytes.length - nIdx === 1) {\r\n sB64Enc += String.fromCharCode(\r\n uint6ToB64(nUint24 >>> 18 & 63),\r\n uint6ToB64(nUint24 >>> 12 & 63),\r\n uint6ToB64(nUint24 >>> 6 & 63),\r\n uint6ToB64(nUint24 & 63)\r\n );\r\n nUint24 = 0;\r\n }\r\n }\r\n if (eqLen === 0) { return sB64Enc; }\r\n var sb64Val = sB64Enc.substring(0, sB64Enc.length - eqLen)\r\n if (eqLen === 1) {\r\n return sb64Val + \"=\"\r\n }\r\n else {\r\n return sb64Val + \"==\"\r\n }\r\n}\r\n\r\nfunction uint6ToB64 (nUint6: number) {\r\n if (nUint6 < 26) { return nUint6 + 65; }\r\n else if (nUint6 < 52) { return nUint6 + 71; }\r\n else if (nUint6 < 62) { return nUint6 - 4; }\r\n else if (nUint6 === 62) { return 43; }\r\n else if (nUint6 === 63) { return 47; }\r\n else { return 65; }\r\n}"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__spreadArrays","il","r","Array","k","a","j","jl","value","_currentValue","_baseValue","_options","base64Chars","baseLength","cv","str","Math","floor","random","getRandomBase","getValue","val","substring","extend","increment","w","window","ME","MeControl","perfNow","performance","now","getPerfEntries","getEntries","getPageLocation","location","meControlErrorPrefix","createError","message","isTimeout","error","Error","mcIsTimeout","SyntheticEvent","_defaultPrevented","type","detail","SyntheticEventTarget","callback","_listeners","push","listeners","index","indexOf","splice","event","stack","dispatchedEvent","l","defaultPrevented","SessionStorageIdKey","id","guid","storage","sessionStorage","getItem","setItem","e","term4","substr","toLowerCase","toString","hasOwn","object","propertyName","CDN_REGEX","_strings","addStrings","curLang","newStrings","DOMAIN_RESULT","getRootDomainUrl","config","Config","cdnRegex","RegExp","scripts","document","getElementsByTagName","scriptsArray","slice","result","exec","src","checkIfCDNDomainExists","gfx","isValidURL","URL","oneDSWriter","writerCollection","criticalEventsRegex","shouldBatch","flusherAttached","windowHasLoaded","readyState","queuedEvents","writeEvent","isCritical","evName","partA","name","split","pop","telEvs","addEventListener","flushEvents","test","setTimeout","removeEventListener","isUT","selectWriter","writer","scrubUrl","url","replace","impressionGuid","eventsQueue","pageName","accounts","counts","captureMoment","params","eventType","content","source","date","Date","timestamp","getCurrentAccountType","current","eventCreators","getPageTags","accountType","href","metaTags","authtype","pgpart","ptn","accts","createPartA","eventDate","eventCv","ver","time","toISOString","appId","cV","flags","ext","javascript","libVer","domain","hostname","userConsent","app","env","int","setEventCreator","eventCreator","newQueue","poppedEvents","popEvents","forEach","eventData","fireEvent","eventParams","createEvent","queueEvent","eventName","createClientError","errorParams","moment","partB","undefined","partC","baseType","errorName","errorMessage","details","errorType","errorInfo","JSON","stringify","severity","wasDisplayed","displayed","market","mkt","eventBaseType","createOutgoingRequest","requestParams","entry","entries","entries_1","_i","getEntry","latencyMs","round","getEntryDuration","duration","operationName","anchor","createElement","segments","pathname","getLastPathPart","serviceOperation","dependencyOperationName","dependencyName","service","succeeded","success","targetUri","customData","computedDuration","perfDuration","entryType","responseEnd","startTime","createTrackedScenario","scenarioParams","partner","controlVersion","scenario","action","previousAction","durationMs","setTimeoutFunc","isArray","x","Boolean","noop","Promise","fn","TypeError","_state","_handled","_value","_deferreds","doResolve","handle","self","deferred","_immediateFn","cb","onFulfilled","onRejected","ret","reject","promise","resolve","newValue","then","finale","thisArg","bind","_unhandledRejectionFn","len","Handler","done","reason","ex","prom","constructor","all","arr","args","remaining","res","race","setImmediate","err","console","warn","_appInsights","_w","MAX_RETRIES","getTime","nowOffset_1","timing","navigationStart","events","concat","track","data","baseData","getEventData","ttWindow","ScriptURLPolicy1DS","trustedTypes","createPolicy","_name","rules","createScriptURL","origin","initialize1DS","oneDSUrl","head","script","async","charset","cleanup","timeoutId","timeoutMs","onload","onScriptComplete","onerror","crossOrigin","appendChild","clearTimeout","initializeAppInsightsCore","oneDsMeControl","appInsightsCore","AppInsightsCore","postChannel","PostChannel","propertiesPlugin","PropertiesPlugin","coreConfig","instrumentationKey","instKey","extensions","extensionConfig","cookieCfg","ignoreCookies","identifier","eventsLimitInMem","gpcDataSharingOptIn","hashIdentifiers","initialize","logTelemetryEvent","enableTelemetry","enableAADTelemetry","options","syntheticEvent","syntheticEventTarget","dispatchEvent","logResourcesDownloaded","filter","domainRegex","isMeControlUrl","main","writeEvent1DS","catch","bundleQueue","bundleCache","getBundleCache","setBundleCache","bundlePromise","exports","meDefine","depsOrFactory","possibleFactory","deps","factory","queueBundle","bundleIdMap","@mecontrol/web-inline","@mecontrol/web-boot","@mecontrol/web-core","ScriptURLPolicyMeControl","meImport","bundleId","updateBundleCache","bundleMetadata","start","fileName","dbg","getJsUrl","reportBundleLoadQos","metadata","bundleExports","ms","finally","timeout","MeControlDefine","downloadScript","queuedBundle","bundleExports_1","map","depId","failed","_component","_queuedCalls","_priorityPos","_proxy","setComponent","component","queuedCalls","triggerCall","handleCall","priority","qCall","queuedCall","apiName","controllerSetter","getControllerSetter","publicProxy","setActiveAccount","setCommands","setAccountPicture","setProfilePicture","refreshProfilePicture","refreshAccountPicture","setTheme","setHeaderTheme","setDisplayMode","loadPresenceConfig","setPresence","method","func","apiProxy","load","loadAsync","NO_JS_STYLES","initiateMain","callingMethod","loadSuccessTelemetry","init","wrapperId","props","isAuthenticated","currentAccount","authenticatedState","primaryUXConfig","signOutStr","signInStr","onClick","authConfig","authProviderConfig","signOutFromApp","signIn","signInType","signInExperienceTypes","rpData","urlPropName","aadUrlValue","aadInfo","msaUrlValue","msaInfo","preferredIdp","handler","appSignOutUrl","appSignInUrl","getFallbackHeaderProps","text","createTextNode","style","cssText","onclick","wrapper1","className","wrapper2","container","shadowDOMContainerElement","getElementById","containerId","innerHTML","showHeaderNoJs","validatePresenceConfiguration","presenceConfig","validatePresenceState","currentPresence","presenceList","validatePresenceList","state","key","presenceString","imageUrl","validateConfiguration","uxConfig","validDisplayModeTypes","displayModes","dm","appContextConfig","commands","unwindEventsSpecifiedAsProperties","opts","setOptions","MeControlImport","extendMe","API","Loader","Strings","onLoad","onMeControlReadyToLoad","isJavaScriptScheme","parsedUrl","protocol","Url","originalUrl","port","path","search","searchParams","protocolSeparator","hash","UrlSearchParams","decode","decodeURIComponent","proxiedHostname","destinationWreply","queryStringParser","queryParams","serializedPairs","values","encodeURIComponent","join","queryString","match","create","append","setQueryParams","includeEmptys","parseUrl","qvalue","set","handleIdpResponse","postResponse","parent","postMessage","wreply","attachEvent","iFrameId","sourceUrl","allowedHosts","frame","host","allowedHosts_1"],"mappings":"qCA6BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YAyGzB,SAASQ,IACZ,IAAK,IAAIX,EAAI,EAAGC,EAAI,EAAGW,EAAKT,UAAUC,OAAQH,EAAIW,EAAIX,IAAKD,GAAKG,UAAUF,GAAGG,OACxE,IAAIS,EAAIC,MAAMd,GAAIe,EAAI,EAA3B,IAA8Bd,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