var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; /** * SSR Attribute Names */ var SSR_VNODE_ID = 'ssrv'; var SSR_CHILD_ID = 'ssrc'; /** * Default style mode id */ var DEFAULT_STYLE_MODE = '$'; /** * Reusable empty obj/array * Don't add values to these!! */ var EMPTY_OBJ = {}; /** * Key Name to Key Code Map */ var KEY_CODE_MAP = { 'enter': 13, 'escape': 27, 'space': 32, 'tab': 9, 'left': 37, 'up': 38, 'right': 39, 'down': 40 }; function getScopeId(cmpMeta, mode) { return ('sc-' + cmpMeta.tagNameMeta) + ((mode && mode !== DEFAULT_STYLE_MODE) ? '-' + mode : ''); } function getElementScopeId(scopeId, isHostElement) { return scopeId + (isHostElement ? '-h' : '-s'); } function initStyleTemplate(domApi, cmpMeta, encapsulation, style, styleMode, perf) { if (style) { if (false) { perf.mark("init_style_template_start:" + cmpMeta.tagNameMeta); } // we got a style mode for this component, let's create an id for this style var styleModeId = cmpMeta.tagNameMeta + (styleMode || DEFAULT_STYLE_MODE); if (!cmpMeta[styleModeId]) { // we don't have this style mode id initialized yet if (true) { // ie11's template polyfill doesn't fully do the trick and there's still issues // so instead of trying to clone templates with styles in them, we'll just // keep a map of the style text as a string to create "); templateElm.innerHTML = styleContent.join(''); } else { // prod mode, no style id data attributes templateElm.innerHTML = ""; } // add our new template element to the head // so it can be cloned later domApi.$appendChild(domApi.$doc.head, templateElm); } } if (false) { perf.mark("init_style_template_end:" + cmpMeta.tagNameMeta); perf.measure("init_style_template:" + cmpMeta.tagNameMeta, "init_style_template_start:" + cmpMeta.tagNameMeta, "init_style_template_end:" + cmpMeta.tagNameMeta); } } } function attachStyles(plt, domApi, cmpMeta, hostElm) { // first see if we've got a style for a specific mode // either this host element should use scoped css // or it wants to use shadow dom but the browser doesn't support it // create a scope id which is useful for scoped css // and add the scope attribute to the host // create the style id w/ the host element's mode var styleId = cmpMeta.tagNameMeta + hostElm.mode; var styleTemplate = cmpMeta[styleId]; var shouldScopeCss = (cmpMeta.encapsulationMeta === 2 /* ScopedCss */ || (cmpMeta.encapsulationMeta === 1 /* ShadowDom */ && !plt.domApi.$supportsShadowDom)); if (shouldScopeCss) { hostElm['s-sc'] = styleTemplate ? getScopeId(cmpMeta, hostElm.mode) : getScopeId(cmpMeta); } if (!styleTemplate) { // doesn't look like there's a style template with the mode // create the style id using the default style mode and try again styleId = cmpMeta.tagNameMeta + DEFAULT_STYLE_MODE; styleTemplate = cmpMeta[styleId]; } if (styleTemplate) { // cool, we found a style template element for this component var styleContainerNode = domApi.$doc.head; // if this browser supports shadow dom, then let's climb up // the dom and see if we're within a shadow dom if (true && domApi.$supportsShadowDom) { if (cmpMeta.encapsulationMeta === 1 /* ShadowDom */) { // we already know we're in a shadow dom // so shadow root is the container for these styles styleContainerNode = hostElm.shadowRoot; } else { // climb up the dom and see if we're in a shadow dom var root = hostElm; while (root = domApi.$parentNode(root)) { if (root.host && root.host.shadowRoot) { // looks like we are in shadow dom, let's use // this shadow root as the container for these styles styleContainerNode = (root.host.shadowRoot); break; } } } } // if this container element already has these styles // then there's no need to apply them again // create an object to keep track if we'ready applied this component style var appliedStyles = plt.componentAppliedStyles.get(styleContainerNode); if (!appliedStyles) { plt.componentAppliedStyles.set(styleContainerNode, appliedStyles = {}); } // check if we haven't applied these styles to this container yet if (!appliedStyles[styleId]) { var styleElm = void 0; if (true) { // es5 builds are not usig