diff --git a/.travis.yml b/.travis.yml
index 872d303..cec4724 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,8 @@ addons:
script:
- npm install -g bower
- bower install
-- xvfb-run wct
+- xvfb-run wct -l chrome
+- xvfb-run wct -l firefox
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'windows 10/microsoftedge@14' -s 'windows 8.1/internet explorer@11' -s 'os x 10.11/safari@10' -s 'os x 10.11/safari@9'; fi
env:
global:
diff --git a/README.md b/README.md
index 3a9255b..3987b99 100644
--- a/README.md
+++ b/README.md
@@ -3,40 +3,36 @@ webcomponents.js
[](https://travis-ci.org/webcomponents/webcomponentsjs)
-A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs:
+A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs.
-**Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
-
-**HTML Imports**: a way to include and reuse HTML documents via other HTML documents ([spec](https://w3c.github.io/webcomponents/spec/imports/)).
-
-**Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)).
+- **Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
+- **HTML Imports**: a way to include and reuse HTML documents via other HTML documents ([spec](https://w3c.github.io/webcomponents/spec/imports/)).
+- **Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)).
## Releases
-Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are two variants:
-
-`webcomponents.js` includes all of the polyfills.
-
-`webcomponents-lite.js` includes all polyfills except for shadow DOM.
+Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are several variants:
+- `webcomponents-lite.js` includes all of the polyfills.
+- `webcomponents-loader.js` is a custom loader that dynamically load a minified polyfill
+bundle, using feature detection. The bundles that can be loaded are:
+ - `webcomponents-hi` -- HTML Imports (needed by Safari Tech Preview)
+ - `webcomponents-hi-ce` -- HTML Imports and Custom Elements (needed by Safari 10)
+ - `webcomponents-hi-ce-sd` -- HTML Imports, Custom Elements and Shady DOM/CSS (needed by Safari 9, Firefox, Edge)
+ - `webcomponents-lite` -- HTML Imports, Custom Elements, Shady DOM/CSS and generic platform polyfills (such as URL, Template, ES6 Promise, Constructable events, etc.) (needed by Internet Explorer 11)
## Browser Support
Our polyfills are intended to work in the latest versions of evergreen browsers. See below
for our complete browser support matrix:
-| Polyfill | IE10 | IE11+ | Chrome* | Firefox* | Safari 7+* | Chrome Android* | Mobile Safari* |
-| ---------- |:----:|:-----:|:-------:|:--------:|:----------:|:---------------:|:--------------:|
-| Custom Elements | ~ | ✓ | ✓ | ✓ | ✓ | ✓| ✓ |
-| HTML Imports | ~ | ✓ | ✓ | ✓ | ✓| ✓| ✓ |
-| Shadow DOM | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
-| Templates | ✓ | ✓ | ✓ | ✓| ✓ | ✓ | ✓ |
+| Polyfill | IE11+ | Chrome* | Firefox* | Safari 9+* | Chrome Android* | Mobile Safari* |
+| ---------- |:-----:|:-------:|:--------:|:----------:|:---------------:|:--------------:|
+| Custom Elements | ✓ | ✓ | ✓ | ✓ | ✓| ✓ |
+| HTML Imports | ✓ | ✓ | ✓ | ✓| ✓| ✓ |
+| Shady CSS/DOM | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
-
-*Indicates the current version of the browser
-
-~Indicates support may be flaky. If using Custom Elements or HTML Imports with Shadow DOM,
-you will get the non-flaky Mutation Observer polyfill that Shadow DOM includes.
+\*Indicates the current version of the browser
The polyfills may work in older browsers, however require additional polyfills (such as classList)
to be used. We cannot guarantee support for browsers outside of our compatibility matrix.
@@ -44,7 +40,7 @@ to be used. We cannot guarantee support for browsers outside of our compatibilit
### Manually Building
-If you wish to build the polyfills yourself, you'll need `node` and `gulp` on your system:
+If you wish to build the polyfills yourself, you'll need `node` and `npm` on your system:
* install [node.js](http://nodejs.org/) using the instructions on their website
* use `npm` to install [gulp.js](http://gulpjs.com/): `npm install -g gulp`
@@ -53,10 +49,11 @@ Now you are ready to build the polyfills with:
# install dependencies
npm install
+ bower install
# build
gulp build
-The builds will be placed into the `dist/` directory.
+The builds will be placed into the root directory.
## Contribute
@@ -74,9 +71,9 @@ Copyright (c) 2015 The Polymer Authors. All rights reserved.
Under native HTML Imports, `
-
+
-
+
diff --git a/tests/ce-import.html b/tests/ce-import.html
index 5200d32..4324af1 100644
--- a/tests/ce-import.html
+++ b/tests/ce-import.html
@@ -13,7 +13,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-
+
diff --git a/tests/ce-upgrade-order.html b/tests/ce-upgrade-order.html
index 9777940..6a28c3b 100644
--- a/tests/ce-upgrade-order.html
+++ b/tests/ce-upgrade-order.html
@@ -12,22 +12,24 @@
Custom Element Upgrade Order
+
-
diff --git a/tests/ce-upgradedocumenttree.html b/tests/ce-upgradedocumenttree.html
index d0429d5..fd3b1d5 100644
--- a/tests/ce-upgradedocumenttree.html
+++ b/tests/ce-upgradedocumenttree.html
@@ -20,7 +20,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
-
+
diff --git a/tests/dev-loader-swizzled.html b/tests/dev-loader-swizzled.html
index c6da9cf..5edb485 100644
--- a/tests/dev-loader-swizzled.html
+++ b/tests/dev-loader-swizzled.html
@@ -12,18 +12,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-
+
diff --git a/tests/dev-loader.html b/tests/dev-loader.html
index 0c02c8c..19564d4 100644
--- a/tests/dev-loader.html
+++ b/tests/dev-loader.html
@@ -12,18 +12,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-
+
diff --git a/tests/integration.html b/tests/integration.html
index 36827b8..ad52963 100644
--- a/tests/integration.html
+++ b/tests/integration.html
@@ -10,8 +10,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-->
- Template with HTMLImports Test
-
+ Integration Test
+
diff --git a/tests/load.html b/tests/load.html
index 67dcb1e..f498d86 100644
--- a/tests/load.html
+++ b/tests/load.html
@@ -12,18 +12,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-
-
-
-
-
+
+
+
+
+
+
diff --git a/tests/smoke.html b/tests/smoke.html
index 465f6ca..b913eeb 100644
--- a/tests/smoke.html
+++ b/tests/smoke.html
@@ -13,7 +13,7 @@
-
+
plain
diff --git a/tests/template-and-CE.html b/tests/template-and-CE.html
index 5613919..45f9588 100644
--- a/tests/template-and-CE.html
+++ b/tests/template-and-CE.html
@@ -58,12 +58,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
window.customElements.define('x-after', XAfter);
});
- test('elements within templates not upgraded', function() {
- assert(!childCreated);
- });
+ suite('template and custom elements', function() {
+ test('elements within templates not upgraded', function() {
+ assert(!childCreated);
+ });
- test('templates before elements are bootstrapped before createdCallback', function() {
- assert(foundTemplate);
+ test('templates before elements are bootstrapped before createdCallback', function() {
+ assert(foundTemplate);
+ });
});
diff --git a/src/boot-lite.js b/webcomponents-debug.js
similarity index 68%
rename from src/boot-lite.js
rename to webcomponents-debug.js
index b039e47..8127393 100644
--- a/src/boot-lite.js
+++ b/webcomponents-debug.js
@@ -14,7 +14,7 @@
window.WebComponents = window.WebComponents || {flags:{}};
// loading script
- var file = 'webcomponents-lite.js';
+ var file = 'webcomponents-debug.js';
var script = document.querySelector('script[src*="' + file + '"]');
// Flags. Convert url arguments to flags
@@ -48,6 +48,28 @@
}
}
+ // construct full dependency list
+ var modules = [
+ '../../webcomponents-platform/webcomponents-platform.js',
+ '../../URL/url.js',
+ '../../template/template.js',
+ '../../es6-promise/dist/es6-promise.auto.min.js',
+ '../../html-imports/src/html-imports.js',
+ 'pre-polyfill.js',
+ '../../shadydom/shadydom.min.js',
+ '../../custom-elements/custom-elements.min.js',
+ '../../shadycss/shadycss.min.js',
+ 'post-polyfill.js',
+ 'unresolved.js'
+ ];
+
+ var src = script.getAttribute('src');
+ var path = src.slice(0, src.lastIndexOf(file));
+
+ modules.forEach(function(f) {
+ document.write('');
+ });
+
// exports
WebComponents.flags = flags;
diff --git a/webcomponents-hi-ce.js b/webcomponents-hi-ce.js
new file mode 100644
index 0000000..ba05716
--- /dev/null
+++ b/webcomponents-hi-ce.js
@@ -0,0 +1,6 @@
+(function(){'use strict';function _(Ot){return Ot=$(Ot),te(ee(Ot),Ot)}function $(Ot){return Ot.replace(Re.comments,'').replace(Re.port,'')}function ee(Ot){let Pt={start:0,end:Ot.length},Lt=Pt;for(let wt=0,kt=Ot.length;wt{'complete'===document.readyState&&Ae()}))}function Ae(){requestAnimationFrame(()=>{(Tt||xt._elementsHaveApplied)&&xt.updateStyles(),Tt=!1})}(Ot=>{const Pt=!!('import'in document.createElement('link'));let Lt=null;!1=='currentScript'in document&&Object.defineProperty(document,'currentScript',{get(){return Lt||('complete'===document.readyState?null:document.scripts[document.scripts.length-1])},configurable:!0});const wt=/(^\/)|(^#)|(^[\w-\d]*:)/,kt=/(url\()([^)]*)(\))/g,Dt=/(@import[\s]+(?!url\())([^;]*)(;)/g,Ht=/(]*)(rel=['|"]?stylesheet['|"]?[^>]*>)/g,Ut={fixUrls(or,nr){or.href&&or.setAttribute('href',Ut.replaceAttrUrl(or.getAttribute('href'),nr)),or.src&&or.setAttribute('src',Ut.replaceAttrUrl(or.getAttribute('src'),nr)),'style'===or.localName&&Ut.resolveUrlsInStyle(or,nr)},fixUrlAttributes(or,nr){const lr=['action','src','href','url','style'];for(let ar,sr=0;srpr.search(/({{|\[\[)/)&&(ir.value='style'===ar?Ut.resolveUrlsInCssText(pr,nr):Ut.replaceAttrUrl(pr,nr))}},fixUrlsInTemplates(or,nr){const lr=or.querySelectorAll('template');for(let sr=0;sr{let dr=ir.replace(/["']/g,'');return nr&&(dr=Ut.resolveUrl(dr,nr)),ar+'\''+dr+'\''+pr})},replaceAttrUrl(or,nr){return or&&wt.test(or)?or:Ut.resolveUrl(or,nr)},resolveUrl(or,nr){if(void 0===Ut.__workingURL){Ut.__workingURL=!1;try{const sr=new URL('b','http://a');sr.pathname='c%20d',Ut.__workingURL='http://a/c%20d'===sr.href}catch(sr){}}if(Ut.__workingURL)return new URL(or,nr).href;let lr=Ut.__tempDoc;return lr||(lr=document.implementation.createHTMLDocument('temp'),Ut.__tempDoc=lr,lr.__base=lr.createElement('base'),lr.head.appendChild(lr.__base),lr.__anchor=lr.createElement('a')),lr.__base.href=nr,lr.__anchor.href=or,lr.__anchor.href||or}},Ft={async:!0,load(or,nr,lr){if(!or)lr('error: href must be specified');else if(or.match(/^data:/)){const sr=or.split(','),ar=sr[0];let ir=sr[1];ir=-1{let ar=sr.getResponseHeader('Location');if(ar&&0===ar.indexOf('/')){const pr=location.origin||location.protocol+'//'+location.host;ar=pr+ar}const ir=sr.response||sr.responseText;304===sr.status||0===sr.status||200<=sr.status&&300>sr.status?nr(ir,ar):lr(ir)},sr.send()}}},jt=/Trident/.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent),qt='link[rel=import]',Bt='import-disable',Kt=`link[rel=stylesheet][href][type=${Bt}]`,Xt=`${qt}, ${Kt},
+ style:not([type]), link[rel=stylesheet][href]:not([type]),
+ script:not([type]), script[type="application/javascript"],
+ script[type="text/javascript"]`,Wt='import-dependency',Vt=`${qt}:not(${Wt})`,Gt=`script[${Wt}]`,Yt=`style[${Wt}],
+ link[rel=stylesheet][${Wt}]`;const $t=or=>{return or.nodeType===Node.ELEMENT_NODE&&'link'===or.localName&&'import'===or.rel},Jt=(or,nr)=>{if(or.__loaded)nr&&nr();else if('script'===or.localName&&!or.src)or.__loaded=!0,nr&&nr();else{const lr=sr=>{or.removeEventListener(sr.type,lr),or.__loaded=!0,nr&&nr()};or.addEventListener('load',lr),jt&&'style'===or.localName||or.addEventListener('error',lr)}},Zt=or=>{Qt(()=>er(()=>or&&or()))},Qt=or=>{if('loading'!==document.readyState)or();else{const nr=()=>{'loading'!==document.readyState&&(document.removeEventListener('readystatechange',nr),or())};document.addEventListener('readystatechange',nr)}},er=or=>{let nr=document.querySelectorAll(Vt),lr=nr.length;if(!lr)return void or();for(let ir,sr=0,ar=nr.length;sr{0==--lr&&or()})},tr=or=>{if(Pt)return or.ownerDocument;let nr=or.__ownerImport;if(!nr){for(nr=or;(nr=nr.parentNode||nr.host)&&!$t(nr););or.__ownerImport=nr}return nr},rr=(or,nr)=>{if('function'==typeof window.CustomEvent)return new CustomEvent(or,nr);const lr=document.createEvent('CustomEvent');return lr.initCustomEvent(or,!!nr.bubbles,!!nr.cancelable,nr.detail),lr};if(Pt){const or=document.querySelectorAll(qt);for(let ar,lr=0,sr=or.length;lr{const sr=lr.target;$t(sr)&&(sr.__loaded=!0)};document.addEventListener('load',nr,!0),document.addEventListener('error',nr,!0)}else new class{constructor(){this.documents={},this.inflight=0,this.dynamicImportsMO=new MutationObserver(or=>this.handleMutations(or)),Qt(()=>{this.dynamicImportsMO.observe(document.head,{childList:!0,subtree:!0}),this.loadImports(document)})}loadImports(or){const nr=or.querySelectorAll(qt);for(let lr=0,sr=nr.length;lr{const ar=this.makeDocument(lr,sr||nr);this.documents[nr]=ar,this.inflight--,this.loadImports(ar)},()=>{this.documents[nr]=null,this.inflight--,this.processImportsIfLoadingDone()})}makeDocument(or,nr){if(!or)return document.createDocumentFragment();jt&&(or=or.replace(Ht,(cr,mr,ur)=>{return-1===cr.indexOf('type=')?`${mr} type=${Bt} ${ur}`:cr}));let lr;const sr=document.createElement('template');if(sr.innerHTML=or,sr.content)lr=sr.content;else for(lr=document.createDocumentFragment();sr.firstChild;)lr.appendChild(sr.firstChild);const ar=lr.querySelector('base');ar&&(nr=Ut.replaceAttrUrl(ar.getAttribute('href'),nr),ar.removeAttribute('href'));const ir=lr.querySelectorAll('dom-module');for(let mr,cr=0;cr{nr&&or&&(this.dynamicImportsMO.observe(document.head,{childList:!0,subtree:!0}),this.fireEvents())};this.waitForStyles(()=>{nr=!0,lr()}),this.runScripts(()=>{or=!0,lr()})}}flatten(or){const nr=or.querySelectorAll(qt);for(let ar,lr=0,sr=nr.length;lr{if(ar{Lt=null,sr(ar+1)})}else or()};sr(0)}waitForStyles(or){const nr=document.querySelectorAll(Yt);let lr=nr.length;if(!lr)return void or();const sr=jt&&!!document.querySelector(Kt);for(let pr,ar=0,ir=nr.length;ar{pr.removeAttribute(Wt),0==--lr&&or()}),sr&&pr.parentNode!==document.head){let dr=tr(pr);for(;dr&&tr(dr);)dr=tr(dr);const cr=pr.parentNode,mr=pr.nextSibling,ur=document.createElement(pr.localName);ur.__appliedElement=pr,ur.setAttribute('type','import-placeholder'),dr.parentNode===document.head?document.head.insertBefore(pr,dr):document.head.appendChild(pr),cr.insertBefore(ur,mr),pr.removeAttribute('type')}}fireEvents(){const or=document.querySelectorAll(qt);for(let lr,nr=or.length-1;0<=nr&&(lr=or[nr]);nr--)this.fireEventIfNeeded(lr)}fireEventIfNeeded(or){if(!or.__loaded){or.__loaded=!0,or.import&&(or.import.readyState='complete');const nr=or.import?'load':'error';or.dispatchEvent(rr(nr,{bubbles:!1,cancelable:!1,detail:void 0}))}}handleMutations(or){for(let nr=0;nrdocument.dispatchEvent(rr('HTMLImportsLoaded',{cancelable:!0,bubbles:!0,detail:void 0}))),Ot.useNative=Pt,Ot.whenReady=Zt,Ot.importForElement=tr})(window.HTMLImports=window.HTMLImports||{}),function(){'use strict';function Ot(Dr){var Hr=or.has(Dr);return Dr=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(Dr),!Hr&&Dr}function Pt(Dr){var Hr=Dr.isConnected;if(void 0!==Hr)return Hr;for(;Dr&&!(Dr.__CE_isImportDocument||Dr instanceof Document);)Dr=Dr.parentNode||(window.ShadowRoot&&Dr instanceof ShadowRoot?Dr.host:void 0);return Dr&&(Dr.__CE_isImportDocument||Dr instanceof Document)}function Lt(Dr,Hr){for(;Hr&&Hr!==Dr&&!Hr.nextSibling;)Hr=Hr.parentNode;return Hr&&Hr!==Dr?Hr.nextSibling:null}function wt(Dr,Hr,Ur){Ur=Ur?Ur:new Set;for(var Fr=Dr;Fr;){if(Fr.nodeType===Node.ELEMENT_NODE){var jr=Fr;Hr(jr);var qr=jr.localName;if('link'===qr&&'import'===jr.getAttribute('rel')){if(Fr=jr.import,Fr instanceof Node&&!Ur.has(Fr))for(Ur.add(Fr),Fr=Fr.firstChild;Fr;Fr=Fr.nextSibling)wt(Fr,Hr,Ur);Fr=Lt(Dr,jr);continue}else if('template'===qr){Fr=Lt(Dr,jr);continue}if(jr=jr.__CE_shadowRoot)for(jr=jr.firstChild;jr;jr=jr.nextSibling)wt(jr,Hr,Ur)}Fr=Fr.firstChild?Fr.firstChild:Lt(Dr,Fr)}}function kt(Dr,Hr,Ur){Dr[Hr]=Ur}function Dt(){this.a=new Map,this.f=new Map,this.c=[],this.b=!1}function Ht(Dr,Hr,Ur){Dr.a.set(Hr,Ur),Dr.f.set(Ur.constructor,Ur)}function Ut(Dr,Hr){Dr.b=!0,Dr.c.push(Hr)}function Ft(Dr,Hr){Dr.b&&wt(Hr,function(Ur){return jt(Dr,Ur)})}function jt(Dr,Hr){if(Dr.b&&!Hr.__CE_patched){Hr.__CE_patched=!0;for(var Ur=0;Ur+~])'};const He='style-scope';class Ue{get SCOPE_NAME(){return He}dom(Ot,Pt,Lt){Ot.__styleScoped?Ot.__styleScoped=null:this._transformDom(Ot,Pt||'',Lt)}_transformDom(Ot,Pt,Lt){Ot.nodeType===Node.ELEMENT_NODE&&this.element(Ot,Pt,Lt);let wt='template'===Ot.localName?(Ot.content||Ot._content).childNodes:Ot.children||Ot.childNodes;if(wt)for(let kt=0;kt`:${Dt}(${Ht.replace(/\s/g,'')})`),Ot=Ot.replace(Ge,`${Xe} $1`),Ot=Ot.replace(Be,(kt,Dt,Ht)=>{if(!wt){let Ut=this._transformCompoundSelector(Ht,Dt,Pt,Lt);wt=wt||Ut.stop,Dt=Ut.combinator,Ht=Ut.value}return Dt+Ht}),Ot}_transformCompoundSelector(Ot,Pt,Lt,wt){let kt=Ot.indexOf(Ve);0<=Ot.indexOf(Xe)?Ot=this._transformHostSelector(Ot,wt):0!==kt&&(Ot=Lt?this._transformSimpleSelector(Ot,Lt):Ot);let Dt=!1;0<=kt&&(Pt='',Dt=!0);let Ht;return Dt&&(Ht=!0,Dt&&(Ot=Ot.replace(ze,(Ut,Ft)=>` > ${Ft}`))),Ot=Ot.replace($e,(Ut,Ft,jt)=>`[dir="${jt}"] ${Ft}, ${Ft}[dir="${jt}"]`),{value:Ot,combinator:Pt,stop:Ht}}_transformSimpleSelector(Ot,Pt){let Lt=Ot.split(Ze);return Lt[0]+=Pt,Lt.join(Ze)}_transformHostSelector(Ot,Pt){let Lt=Ot.match(Ye),wt=Lt&&Lt[2].trim()||'';if(wt){if(!wt[0].match(Ke)){let kt=wt.split(Ke)[0];return kt===Pt?wt:'should_not_match'}return Ot.replace(Ye,function(kt,Dt,Ht){return Pt+Ht})}return Ot.replace(Xe,Pt)}documentRule(Ot){Ot.selector=Ot.parsedSelector,this.normalizeRootSelector(Ot),this._transformRule(Ot,this._transformDocumentSelector)}normalizeRootSelector(Ot){Ot.selector===':root'&&(Ot.selector='html')}_transformDocumentSelector(Ot){return Ot.match(Ve)?this._transformComplexSelector(Ot,je):this._transformSimpleSelector(Ot.trim(),je)}}let Fe=/:(nth[-\w]+)\(([^)]+)\)/,je=`:not(.${He})`,qe=',',Be=/(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g,Ke=/[[.:#*]/,Xe=':host',Ve='::slotted',Ge=/^(::slotted)/,Ye=/(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,ze=/(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,$e=/(.*):dir\((?:(ltr|rtl))\)/,Ze=':';var tt=new Ue,rt={};const ot=Promise.resolve();class nt{static get(Ot){return Ot.__styleInfo}static set(Ot,Pt){return Ot.__styleInfo=Pt,Pt}static invalidate(Ot){rt[Ot]&&(rt[Ot]._applyShimInvalid=!0)}static startValidating(Ot){const Pt=rt[Ot];Pt._validating||(Pt._validating=!0,ot.then(()=>{Pt._applyShimInvalid=!1,Pt._validating=!1}))}constructor(Ot,Pt,Lt,wt,kt,Dt){this.styleRules=Ot||null,this.placeholder=Pt||null,this.ownStylePropertyNames=Lt||[],this.overrideStyleProperties=null,this.elementName=wt||'',this.cssBuild=Dt||'',this.typeExtension=kt||'',this.styleProperties=null,this.scopeSelector=null,this.customStyle=null}}const lt=window.Element.prototype,st=lt.matches||lt.matchesSelector||lt.mozMatchesSelector||lt.msMatchesSelector||lt.oMatchesSelector||lt.webkitMatchesSelector,it=navigator.userAgent.match('Trident'),pt='x-scope';class dt{get XSCOPE_NAME(){return pt}decorateStyles(Ot){let Pt=this,Lt={},wt=[],kt=0;ye(Ot,function(Ht){Pt.decorateRule(Ht),Ht.index=kt++,Pt.collectPropertiesInCssText(Ht.propertyInfo.cssText,Lt)},function(Ut){wt.push(Ut)}),Ot._keyframes=wt;let Dt=[];for(let Ht in Lt)Dt.push(Ht);return Dt}decorateRule(Ot){if(Ot.propertyInfo)return Ot.propertyInfo;let Pt={},Lt={},wt=this.collectProperties(Ot,Lt);return wt&&(Pt.properties=Lt,Ot.rules=null),Pt.cssText=this.collectCssText(Ot),Ot.propertyInfo=Pt,Pt}collectProperties(Ot,Pt){let Lt=Ot.propertyInfo;if(!Lt){let wt,kt=De.VAR_ASSIGN,Dt=Ot.parsedCssText,Ht,Ut;for(;wt=kt.exec(Dt);)Ht=(wt[2]||wt[3]).trim(),('inherit'!==Ht||'unset'!==Ht)&&(Pt[wt[1].trim()]=Ht),Ut=!0;return Ut}else if(Lt.properties)return Object.assign(Pt,Lt.properties),!0}collectCssText(Ot){return this.collectConsumingCssText(Ot.parsedCssText)}collectConsumingCssText(Ot){return Ot.replace(De.BRACKETED,'').replace(De.VAR_ASSIGN,'')}collectPropertiesInCssText(Ot,Pt){for(let Lt,wt;Lt=De.VAR_CONSUMED.exec(Ot);)wt=Lt[1],':'!==Lt[2]&&(Pt[wt]=!0)}reify(Ot){let Pt=Object.getOwnPropertyNames(Ot);for(let wt,Lt=0;Lt *'===Dt||'html'===Dt,Ut=0===Dt.indexOf(':host')&&!Ht;if('shady'===Lt&&(Ht=Dt===kt+' > *.'+kt||-1!==Dt.indexOf('html'),Ut=!Ht&&0===Dt.indexOf(kt)),'shadow'===Lt&&(Ht=':host > *'===Dt||'html'===Dt,Ut=Ut&&!Ht),Ht||Ut){let Ft=kt;Ut&&(Pe&&!Pt.transformedSelector&&(Pt.transformedSelector=tt._transformRuleCss(Pt,tt._transformComplexSelector,tt._calcElementScope(Ot.is),kt)),Ft=Pt.transformedSelector||kt),wt({selector:Ft,isHost:Ut,isRoot:Ht})}}}hostAndRootPropertiesForScope(Ot,Pt){let Lt={},wt={},kt=this,Dt=Pt&&Pt.__cssBuild;return ye(Pt,function(Ht){kt.whenHostOrRootRule(Ot,Ht,Dt,function(Ut){let Ft=Ot._element||Ot;st.call(Ft,Ut.selector)&&(Ut.isHost?kt.collectProperties(Ht,Lt):kt.collectProperties(Ht,wt))})},null,!0),{rootProps:wt,hostProps:Lt}}transformStyles(Ot,Pt,Lt){let wt=this,kt=tt._calcHostScope(Ot.is,Ot.extends),Dt=Ot.extends?'\\'+kt.slice(0,-1)+'\\]':kt,Ht=new RegExp(De.HOST_PREFIX+Dt+De.HOST_SUFFIX),Ut=nt.get(Ot).styleRules,Ft=this._elementKeyframeTransforms(Ot,Ut,Lt);return tt.elementStyles(Ot,Ut,function(jt){wt.applyProperties(jt,Pt),Pe||ue(jt)||!jt.cssText||(wt.applyKeyframeTransforms(jt,Ft),wt._scopeSelector(jt,Ht,kt,Lt))})}_elementKeyframeTransforms(Ot,Pt,Lt){let wt=Pt._keyframes,kt={};if(!Pe&&wt)for(let Dt=0,Ht=wt[Dt];Dt=Ht._useCount&&Ht.parentNode&&Ht.parentNode.removeChild(Ht)),Pe?Dt.customStyle?(Dt.customStyle.textContent=kt,wt=Dt.customStyle):kt&&(wt=he(kt,Lt,Ot.shadowRoot,Dt.placeholder)):wt?!wt.parentNode&&fe(wt,null,Dt.placeholder):kt&&(wt=he(kt,Lt,null,Dt.placeholder)),wt&&(wt._useCount=wt._useCount||0,Dt.customStyle!=wt&&wt._useCount++,Dt.customStyle=wt),it&&(wt.textContent=wt.textContent),wt}applyCustomStyle(Ot,Pt){let Lt=me(Ot),wt=this;Ot.textContent=de(Lt,function(kt){let Dt=kt.cssText=kt.parsedCssText;kt.propertyInfo&&kt.propertyInfo.cssText&&(Dt=se(Dt),kt.cssText=wt.valueForProperties(Dt,Pt))})}}var ct=new dt;let mt={};const ut=window.customElements;if(ut&&!Pe){const Ot=ut.define;ut.define=function(Pt,Lt,wt){return mt[Pt]=ge(Pt),Ot.call(ut,Pt,Lt,wt)}}let ht=De.MIXIN_MATCH,ft=De.VAR_ASSIGN,_t=/;\s*/m,gt=/^\s*(initial)|(inherit)\s*$/,St='_-_';class Ct{constructor(){this._map={}}set(Ot,Pt){Ot=Ot.trim(),this._map[Ot]={properties:Pt,dependants:{}}}get(Ot){return Ot=Ot.trim(),this._map[Ot]}}class bt{constructor(){this._currentTemplate=null,this._measureElement=null,this._map=new Ct,this._separator=St,this._boundProduceCssProperties=(Ot,Pt,Lt,wt)=>this._produceCssProperties(Ot,Pt,Lt,wt)}detectMixin(Ot){const Pt=ht.test(Ot)||ft.test(Ot);return ht.lastIndex=0,ft.lastIndex=0,Pt}transformStyle(Ot,Pt){let Lt=me(Ot);return this.transformRules(Lt,Pt),Lt}transformRules(Ot,Pt){this._currentTemplate=rt[Pt],ye(Ot,Lt=>{this.transformRule(Lt)}),this._currentTemplate=null}transformRule(Ot){Ot.cssText=this.transformCssText(Ot.parsedCssText),':root'===Ot.selector&&(Ot.selector=':host > *')}transformCssText(Ot){return Ot=Ot.replace(ft,this._boundProduceCssProperties),this._consumeCssProperties(Ot)}_getInitialValueForProperty(Ot){return this._measureElement||(this._measureElement=document.createElement('meta'),this._measureElement.style.all='initial',document.head.appendChild(this._measureElement)),window.getComputedStyle(this._measureElement).getPropertyValue(Ot)}_consumeCssProperties(Ot){for(let Pt;Pt=ht.exec(Ot);){let Lt=Pt[0],wt=Pt[1],kt=Pt.index,Dt=kt+Lt.indexOf('@apply'),Ht=kt+Lt.length,Ut=Ot.slice(0,Dt),Ft=Ot.slice(Ht),jt=this._cssTextToMap(Ut),qt=this._atApplyToCssProperties(wt,jt);Ot=[Ut,qt,Ft].join(''),ht.lastIndex=kt+qt.length}return Ot}_atApplyToCssProperties(Ot,Pt){Ot=Ot.replace(_t,'');let Lt=[],wt=this._map.get(Ot);if(wt||(this._map.set(Ot,{}),wt=this._map.get(Ot)),wt){this._currentTemplate&&(wt.dependants[this._currentTemplate.name]=this._currentTemplate);let kt,Dt,Ht;for(kt in wt.properties)Ht=Pt&&Pt[kt],Dt=[kt,': var(',Ot,St,kt],Ht&&Dt.push(',',Ht),Dt.push(')'),Lt.push(Dt.join(''))}return Lt.join('; ')}_replaceInitialOrInherit(Ot,Pt){let Lt=gt.exec(Pt);return Lt&&(Lt[1]?Pt=bt._getInitialValueForProperty(Ot):Pt='apply-shim-inherit'),Pt}_cssTextToMap(Ot){let Pt=Ot.split(';'),Lt,wt,kt={};for(let Ht,Ut,Dt=0;Dt{Vt&&this._map.get(Vt)&&(wt='@apply '+Vt+';')}),!wt)return Ot;let kt=this._consumeCssProperties(wt),Dt=Ot.slice(0,Ot.indexOf('--')),Ht=this._cssTextToMap(kt),Ut=Ht,Ft=this._map.get(Pt),jt=Ft&&Ft.properties;jt?Ut=Object.assign(Object.create(jt),Ht):this._map.set(Pt,Ut);let Bt,Kt,qt=[],Xt=!1;for(Bt in Ut)Kt=Ht[Bt],void 0==Kt&&(Kt='initial'),jt&&!(Bt in jt)&&(Xt=!0),qt.push(Pt+St+Bt+': '+Kt);return Xt&&this._invalidateMixinEntry(Ft),Ft&&(Ft.properties=Ut),Lt&&(Dt=Ot+';'+Dt),Dt+qt.join('; ')+';'}}let Et=new bt;window.ApplyShim=Et;let Nt=function(){};if(!Pe){let Ot=Dt=>{return Dt.classList&&!Dt.classList.contains(tt.SCOPE_NAME)||Dt instanceof SVGElement&&(!Dt.hasAttribute('class')||0>Dt.getAttribute('class').indexOf(tt.SCOPE_NAME))},Pt=Dt=>{for(let Ut,Ht=0;Ht{Lt.observe(Dt,{childList:!0,subtree:!0})},kt=window.customElements&&!window.customElements.flush;if(kt)wt(document);else{let Dt=()=>{wt(document.body)};window.HTMLImports?window.HTMLImports.whenReady(Dt):requestAnimationFrame(function(){if('loading'===document.readyState){let Ht=function(){Dt(),document.removeEventListener('readystatechange',Ht)};document.addEventListener('readystatechange',Ht)}else Dt()})}Nt=function(){Pt(Lt.takeRecords())}}let At=new class{constructor(Ot=100){this.cache={},this.typeMax=Ot}_validate(Ot,Pt,Lt){for(let kt,wt=0;wtthis.typeMax&&kt.shift(),this.cache[Ot]=kt}fetch(Ot,Pt,Lt){let wt=this.cache[Ot];if(wt)for(let Dt,kt=wt.length-1;0<=kt;kt--)if(Dt=wt[kt],this._validate(Dt,Pt,Lt))return Dt}};class vt{constructor(){this._scopeCounter={},this._documentOwner=document.documentElement,this._documentOwnerStyleInfo=nt.set(document.documentElement,new nt({rules:[]})),this._elementsHaveApplied=!1}get nativeShadow(){return Pe}get nativeCss(){return Le}get nativeCssApply(){return!1}flush(){Nt()}_generateScopeSelector(Ot){let Pt=this._scopeCounter[Ot]=(this._scopeCounter[Ot]||0)+1;return`${Ot}-${Pt}`}getStyleAst(Ot){return me(Ot)}styleAstToString(Ot){return de(Ot)}_gatherStyles(Ot){let Pt=Ot.content.querySelectorAll('style'),Lt=[];for(let kt,wt=0;wt{Pe?tt.normalizeRootSelector(Lt):tt.documentRule(Lt),this.nativeCss&&!this.nativeCssApply&&Et.transformRule(Lt)}),this.nativeCss?Ot.textContent=de(Pt):this._documentOwnerStyleInfo.styleRules.rules.push(Pt)}_revalidateApplyShim(Ot){if(this.nativeCss&&!this.nativeCssApply){let Pt=me(Ot);Et.transformRules(Pt),Ot.textContent=de(Pt)}}_applyCustomStyleToDocument(Ot){this.nativeCss||ct.applyCustomStyle(Ot,this._documentOwnerStyleInfo.styleProperties)}getComputedStyleValue(Ot,Pt){let Lt;if(!this.nativeCss){let wt=nt.get(Ot)||nt.get(this._styleOwnerForNode(Ot));Lt=wt.styleProperties[Pt]}return Lt=Lt||window.getComputedStyle(Ot).getPropertyValue(Pt),Lt.trim()}setElementClass(Ot,Pt){let Lt=Ot.getRootNode(),wt=Pt?Pt.split(/\s/):[],kt=Lt.host&&Lt.host.localName;if(!kt){var Dt=Ot.getAttribute('class');if(Dt){let Ht=Dt.split(/\s/);for(let Ut=0;Ut {\n\n /********************* base setup *********************/\n const useNative = Boolean('import' in document.createElement('link'));\n\n // Polyfill `currentScript` for browsers without it.\n let currentScript = null;\n if ('currentScript' in document === false) {\n Object.defineProperty(document, 'currentScript', {\n get() {\n return currentScript ||\n // NOTE: only works when called in synchronously executing code.\n // readyState should check if `loading` but IE10 is\n // interactive when scripts run so we cheat. This is not needed by\n // html-imports polyfill but helps generally polyfill `currentScript`.\n (document.readyState !== 'complete' ?\n document.scripts[document.scripts.length - 1] : null);\n },\n configurable: true\n });\n }\n\n /********************* path fixup *********************/\n const ABS_URL_TEST = /(^\\/)|(^#)|(^[\\w-\\d]*:)/;\n const CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\n const CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\n const STYLESHEET_REGEXP = /(]*)(rel=['|\"]?stylesheet['|\"]?[^>]*>)/g;\n\n // path fixup: style elements in imports must be made relative to the main\n // document. We fixup url's in url() and @import.\n const Path = {\n\n fixUrls(element, base) {\n if (element.href) {\n element.setAttribute('href',\n Path.replaceAttrUrl(element.getAttribute('href'), base));\n }\n if (element.src) {\n element.setAttribute('src',\n Path.replaceAttrUrl(element.getAttribute('src'), base));\n }\n if (element.localName === 'style') {\n Path.resolveUrlsInStyle(element, base);\n }\n },\n\n fixUrlAttributes(element, base) {\n const attrs = ['action', 'src', 'href', 'url', 'style'];\n for (let i = 0, a; i < attrs.length && (a = attrs[i]); i++) {\n const at = element.attributes[a];\n const v = at && at.value;\n // Skip bound attribute values (assume binding is done via {} and []).\n // TODO(valdrin) consider exposing a library-implementable hook.\n if (v && (v.search(/({{|\\[\\[)/) < 0)) {\n at.value = (a === 'style') ?\n Path.resolveUrlsInCssText(v, base) :\n Path.replaceAttrUrl(v, base);\n }\n }\n },\n\n fixUrlsInTemplates(element, base) {\n const t$ = element.querySelectorAll('template');\n for (let i = 0; i < t$.length; i++) {\n Path.fixUrlsInTemplate(t$[i], base);\n }\n },\n\n fixUrlsInTemplate(template, base) {\n // If template is not supported, still resolve urls within it.\n const content = template.content || template;\n const n$ = content.querySelectorAll(\n 'style, form[action], [src], [href], [url], [style]');\n for (let i = 0; i < n$.length; i++) {\n const n = n$[i];\n if (n.localName == 'style') {\n Path.resolveUrlsInStyle(n, base);\n } else {\n Path.fixUrlAttributes(n, base);\n }\n }\n Path.fixUrlsInTemplates(content, base);\n },\n\n resolveUrlsInStyle(style, linkUrl) {\n style.textContent = Path.resolveUrlsInCssText(style.textContent, linkUrl);\n },\n\n resolveUrlsInCssText(cssText, linkUrl) {\n let r = Path.replaceUrls(cssText, linkUrl, CSS_URL_REGEXP);\n r = Path.replaceUrls(r, linkUrl, CSS_IMPORT_REGEXP);\n return r;\n },\n\n replaceUrls(text, linkUrl, regexp) {\n return text.replace(regexp, (m, pre, url, post) => {\n let urlPath = url.replace(/[\"']/g, '');\n if (linkUrl) {\n urlPath = Path.resolveUrl(urlPath, linkUrl);\n }\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n },\n\n replaceAttrUrl(text, linkUrl) {\n if (text && ABS_URL_TEST.test(text)) {\n return text;\n } else {\n return Path.resolveUrl(text, linkUrl);\n }\n },\n\n resolveUrl(url, base) {\n // Lazy feature detection.\n if (Path.__workingURL === undefined) {\n Path.__workingURL = false;\n try {\n const u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n Path.__workingURL = (u.href === 'http://a/c%20d');\n } catch (e) {}\n }\n\n if (Path.__workingURL) {\n return (new URL(url, base)).href;\n }\n\n // Fallback to creating an anchor into a disconnected document.\n let doc = Path.__tempDoc;\n if (!doc) {\n doc = document.implementation.createHTMLDocument('temp');\n Path.__tempDoc = doc;\n doc.__base = doc.createElement('base');\n doc.head.appendChild(doc.__base);\n doc.__anchor = doc.createElement('a');\n }\n doc.__base.href = base;\n doc.__anchor.href = url;\n return doc.__anchor.href || url;\n }\n };\n\n /********************* Xhr processor *********************/\n const Xhr = {\n\n async: true,\n\n /**\n * @param {!string} url\n * @param {!function(!string, string=)} success\n * @param {!function(!string)} fail\n */\n load(url, success, fail) {\n if (!url) {\n fail('error: href must be specified');\n } else if (url.match(/^data:/)) {\n // Handle Data URI Scheme\n const pieces = url.split(',');\n const header = pieces[0];\n let resource = pieces[1];\n if (header.indexOf(';base64') > -1) {\n resource = atob(resource);\n } else {\n resource = decodeURIComponent(resource);\n }\n success(resource);\n } else {\n const request = new XMLHttpRequest();\n request.open('GET', url, Xhr.async);\n request.onload = () => {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly. Handle relative and full paths.\n let redirectedUrl = request.getResponseHeader('Location');\n if (redirectedUrl && redirectedUrl.indexOf('/') === 0) {\n // In IE location.origin might not work\n // https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7\n const origin = (location.origin || location.protocol + '//' + location.host);\n redirectedUrl = origin + redirectedUrl;\n }\n const resource = /** @type {string} */ (request.response || request.responseText);\n if (request.status === 304 || request.status === 0 ||\n request.status >= 200 && request.status < 300) {\n success(resource, redirectedUrl);\n } else {\n fail(resource);\n }\n };\n request.send();\n }\n }\n };\n\n /********************* importer *********************/\n\n const isIE = /Trident/.test(navigator.userAgent) ||\n /Edge\\/\\d./i.test(navigator.userAgent);\n\n const importSelector = 'link[rel=import]';\n\n // Used to disable loading of resources.\n const importDisableType = 'import-disable';\n\n const disabledLinkSelector = `link[rel=stylesheet][href][type=${importDisableType}]`;\n\n const importDependenciesSelector = `${importSelector}, ${disabledLinkSelector},\n style:not([type]), link[rel=stylesheet][href]:not([type]),\n script:not([type]), script[type=\"application/javascript\"],\n script[type=\"text/javascript\"]`;\n\n const importDependencyAttr = 'import-dependency';\n\n const rootImportSelector = `${importSelector}:not(${importDependencyAttr})`;\n\n const pendingScriptsSelector = `script[${importDependencyAttr}]`;\n\n const pendingStylesSelector = `style[${importDependencyAttr}],\n link[rel=stylesheet][${importDependencyAttr}]`;\n\n /**\n * Importer will:\n * - load any linked import documents (with deduping)\n * - whenever an import is loaded, prompt the parser to try to parse\n * - observe imported documents for new elements (these are handled via the\n * dynamic importer)\n */\n class Importer {\n constructor() {\n this.documents = {};\n // Used to keep track of pending loads, so that flattening and firing of\n // events can be done when all resources are ready.\n this.inflight = 0;\n this.dynamicImportsMO = new MutationObserver(m => this.handleMutations(m));\n // 1. Load imports contents\n // 2. Assign them to first import links on the document\n // 3. Wait for import styles & scripts to be done loading/running\n // 4. Fire load/error events\n whenDocumentReady(() => {\n // Observe changes on .\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.loadImports(document);\n });\n }\n\n /**\n * @param {!(HTMLDocument|DocumentFragment|Element)} doc\n */\n loadImports(doc) {\n const links = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = links.length; i < l; i++) {\n this.loadImport(links[i]);\n }\n this.processImportsIfLoadingDone();\n }\n\n /**\n * @param {!HTMLLinkElement} link\n */\n loadImport(link) {\n const url = link.href;\n // This resource is already being handled by another import.\n if (this.documents[url] !== undefined) {\n // If import is already loaded, we can safely associate it to the link\n // and fire the load/error event.\n const imp = this.documents[url];\n if (imp && imp['__loaded']) {\n link.import = imp;\n this.fireEventIfNeeded(link);\n }\n return;\n }\n this.inflight++;\n // Mark it as pending to notify others this url is being loaded.\n this.documents[url] = 'pending';\n Xhr.load(url, (resource, redirectedUrl) => {\n const doc = this.makeDocument(resource, redirectedUrl || url);\n this.documents[url] = doc;\n this.inflight--;\n // Load subtree.\n this.loadImports(doc);\n }, () => {\n // If load fails, handle error.\n this.documents[url] = null;\n this.inflight--;\n this.processImportsIfLoadingDone();\n });\n }\n\n /**\n * Creates a new document containing resource and normalizes urls accordingly.\n * @param {string=} resource\n * @param {string=} url\n * @return {!DocumentFragment}\n */\n makeDocument(resource, url) {\n if (!resource) {\n return document.createDocumentFragment();\n }\n\n if (isIE) {\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order. We disable the loading by\n // setting the type before setting innerHTML to avoid loading\n // resources twice.\n resource = resource.replace(STYLESHEET_REGEXP, (match, p1, p2) => {\n if (match.indexOf('type=') === -1) {\n return `${p1} type=${importDisableType} ${p2}`;\n }\n return match;\n });\n }\n\n let content;\n const template = /** @type {!HTMLTemplateElement} */\n (document.createElement('template'));\n template.innerHTML = resource;\n if (template.content) {\n // This creates issues in Safari10 when used with shadydom (see #12).\n content = template.content;\n } else {\n // not supported, create fragment and move content into it.\n content = document.createDocumentFragment();\n while (template.firstChild) {\n content.appendChild(template.firstChild);\n }\n }\n\n // Support in imported docs. Resolve url and remove its href.\n const baseEl = content.querySelector('base');\n if (baseEl) {\n url = Path.replaceAttrUrl(baseEl.getAttribute('href'), url);\n baseEl.removeAttribute('href');\n }\n\n // This is specific to users of (Polymer).\n // TODO(valdrin) remove this when Polymer uses importForElement.\n const s$ = content.querySelectorAll('dom-module');\n for (let i = 0, s; i < s$.length && (s = s$[i]); i++) {\n s.setAttribute('assetpath',\n Path.replaceAttrUrl(s.getAttribute('assetpath') || '', url));\n }\n\n const n$ = /** @type {!NodeList} */\n (content.querySelectorAll(importDependenciesSelector));\n // For source map hints.\n let inlineScriptIndex = 0;\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n // Listen for load/error events, then fix urls.\n whenElementLoaded(n);\n Path.fixUrls(n, url);\n // Mark for easier selectors.\n n.setAttribute(importDependencyAttr, '');\n // Generate source map hints for inline scripts.\n if (n.localName === 'script' && !n.src && n.textContent) {\n const num = inlineScriptIndex ? `-${inlineScriptIndex}` : '';\n const content = n.textContent + `\\n//# sourceURL=${url}${num}.js\\n`;\n // We use the src attribute so it triggers load/error events, and it's\n // easier to capture errors (e.g. parsing) like this.\n n.setAttribute('src', 'data:text/javascript;charset=utf-8,' + encodeURIComponent(content));\n n.textContent = '';\n inlineScriptIndex++;\n }\n }\n Path.fixUrlsInTemplates(content, url);\n return content;\n }\n\n /**\n * Waits for loaded imports to finish loading scripts and styles, then fires\n * the load/error events.\n */\n processImportsIfLoadingDone() {\n // Wait until all resources are ready, then load import resources.\n if (this.inflight) {\n return;\n }\n\n // Stop observing, flatten & load resource, then restart observing .\n this.dynamicImportsMO.disconnect();\n this.flatten(document);\n // We wait for styles to load, and at the same time we execute the scripts,\n // then fire the load/error events for imports to have faster whenReady\n // callback execution.\n // NOTE: This is different for native behavior where scripts would be\n // executed after the styles before them are loaded.\n // To achieve that, we could select pending styles and scripts in the\n // document and execute them sequentially in their dom order.\n let scriptsOk = false,\n stylesOk = false;\n const onLoadingDone = () => {\n if (stylesOk && scriptsOk) {\n // Restart observing.\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.fireEvents();\n }\n };\n this.waitForStyles(() => {\n stylesOk = true;\n onLoadingDone();\n });\n this.runScripts(() => {\n scriptsOk = true;\n onLoadingDone();\n });\n }\n\n /**\n * @param {!HTMLDocument} doc\n */\n flatten(doc) {\n const n$ = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n const imp = this.documents[n.href];\n n.import = /** @type {!Document} */ (imp);\n if (imp && imp.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // We set the .import to be the link itself, and update its readyState.\n // Other links with the same href will point to this link.\n this.documents[n.href] = n;\n n.readyState = 'loading';\n // Suppress Closure warning about incompatible subtype assignment.\n ( /** @type {!HTMLElement} */ (n).import = n);\n this.flatten(imp);\n n.appendChild(imp);\n }\n }\n }\n\n /**\n * Replaces all the imported scripts with a clone in order to execute them.\n * Updates the `currentScript`.\n * @param {!function()} callback\n */\n runScripts(callback) {\n const s$ = document.querySelectorAll(pendingScriptsSelector);\n const l = s$.length;\n const cloneScript = i => {\n if (i < l) {\n // The pending scripts have been generated through innerHTML and\n // browsers won't execute them for security reasons. We cannot use\n // s.cloneNode(true) either, the only way to run the script is manually\n // creating a new element and copying its attributes.\n const s = s$[i];\n const clone = /** @type {!HTMLScriptElement} */\n (document.createElement('script'));\n // Remove import-dependency attribute to avoid double cloning.\n s.removeAttribute(importDependencyAttr);\n for (let j = 0, ll = s.attributes.length; j < ll; j++) {\n clone.setAttribute(s.attributes[j].name, s.attributes[j].value);\n }\n // Update currentScript and replace original with clone script.\n currentScript = clone;\n s.parentNode.replaceChild(clone, s);\n whenElementLoaded(clone, () => {\n currentScript = null;\n cloneScript(i + 1);\n });\n } else {\n callback();\n }\n };\n cloneScript(0);\n }\n\n /**\n * Waits for all the imported stylesheets/styles to be loaded.\n * @param {!function()} callback\n */\n waitForStyles(callback) {\n const s$ = /** @type {!NodeList} */\n (document.querySelectorAll(pendingStylesSelector));\n let pending = s$.length;\n if (!pending) {\n callback();\n return;\n }\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10472273/\n // If there is one imported, we must move all imported\n // links and styles to .\n const needsMove = isIE && !!document.querySelector(disabledLinkSelector);\n for (let i = 0, l = s$.length, s; i < l && (s = s$[i]); i++) {\n // Listen for load/error events, remove selector once is done loading.\n whenElementLoaded(s, () => {\n s.removeAttribute(importDependencyAttr);\n if (--pending === 0) {\n callback();\n }\n });\n // Check if was already moved to head, to handle the case where the element\n // has already been moved but it is still loading.\n if (needsMove && s.parentNode !== document.head) {\n let rootImport = importForElement(s);\n while (rootImport && importForElement(rootImport)) {\n rootImport = importForElement(rootImport);\n }\n // Replace the element we're about to move with a placeholder.\n // NOTE: we first have to append the element to the new parent, then\n // we can put the placeholder at its place, otherwise load/error events\n // seem to be fired too early.\n const parent = s.parentNode,\n next = s.nextSibling,\n placeholder = document.createElement(s.localName);\n // Add reference of the moved element.\n placeholder['__appliedElement'] = s;\n // Disable this from appearing in document.styleSheets.\n placeholder.setAttribute('type', 'import-placeholder');\n // First, re-parent the element...\n if (rootImport.parentNode === document.head) {\n document.head.insertBefore(s, rootImport);\n } else {\n document.head.appendChild(s);\n }\n // ...and then, insert the placeholder at the right place.\n parent.insertBefore(placeholder, next);\n // Enable the loading of .\n s.removeAttribute('type');\n }\n }\n }\n\n /**\n * Fires load/error events for imports in the right order .\n */\n fireEvents() {\n const n$ = /** @type {!NodeList} */\n (document.querySelectorAll(importSelector));\n // Inverse order to have events firing bottom-up.\n for (let i = n$.length - 1, n; i >= 0 && (n = n$[i]); i--) {\n this.fireEventIfNeeded(n);\n }\n }\n\n /**\n * Fires load/error event for the import if this wasn't done already.\n * @param {!HTMLLinkElement} link\n */\n fireEventIfNeeded(link) {\n // Don't fire twice same event.\n if (!link['__loaded']) {\n link['__loaded'] = true;\n // Update link's import readyState.\n link.import && (link.import.readyState = 'complete');\n const eventType = link.import ? 'load' : 'error';\n link.dispatchEvent(newCustomEvent(eventType, {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }));\n }\n }\n\n /**\n * @param {Array} mutations\n */\n handleMutations(mutations) {\n for (let i = 0; i < mutations.length; i++) {\n const m = mutations[i];\n if (!m.addedNodes) {\n continue;\n }\n for (let ii = 0; ii < m.addedNodes.length; ii++) {\n const link = m.addedNodes[ii];\n if (!link || link.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n // NOTE: added scripts are not updating currentScript in IE.\n // TODO add test w/ script & stylesheet maybe\n if (isImportLink(link)) {\n this.loadImport( /** @type {!HTMLLinkElement} */ (link));\n } else {\n this.loadImports( /** @type {!Element} */ (link));\n }\n }\n }\n }\n }\n\n /**\n * @param {!Node} node\n * @return {boolean}\n */\n const isImportLink = node => {\n return node.nodeType === Node.ELEMENT_NODE && node.localName === 'link' &&\n ( /** @type {!HTMLLinkElement} */ (node).rel === 'import');\n };\n\n /**\n * Waits for an element to finish loading. If already done loading, it will\n * mark the element accordingly.\n * @param {!(HTMLLinkElement|HTMLScriptElement|HTMLStyleElement)} element\n * @param {function()=} callback\n */\n const whenElementLoaded = (element, callback) => {\n if (element['__loaded']) {\n callback && callback();\n } else if (element.localName === 'script' && !element.src) {\n // Inline scripts don't trigger load/error events, consider them already loaded.\n element['__loaded'] = true;\n callback && callback();\n } else {\n const onLoadingDone = event => {\n element.removeEventListener(event.type, onLoadingDone);\n element['__loaded'] = true;\n callback && callback();\n };\n element.addEventListener('load', onLoadingDone);\n // NOTE: We listen only for load events in IE/Edge, because in IE/Edge\n // \n\n*/\n\nlet ShadyCSS$1 = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS$1._elementsHaveApplied) {\n ShadyCSS$1.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS$1._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n 'use strict';\n\n if (customElements && customElements.polyfillWrapFlushCallback) {\n // Here we ensure that the public `HTMLImports.whenReady`\n // always comes *after* custom elements have upgraded.\n let flushCallback;\n function runAndClearCallback() {\n if (flushCallback) {\n let cb = flushCallback;\n flushCallback = null;\n cb();\n }\n }\n let origWhenReady = HTMLImports.whenReady;\n customElements.polyfillWrapFlushCallback(function(cb) {\n flushCallback = cb;\n origWhenReady(runAndClearCallback);\n });\n\n HTMLImports.whenReady = function(cb) {\n origWhenReady(function() {\n runAndClearCallback();\n cb();\n });\n };\n\n }\n\n HTMLImports.whenReady(function() {\n requestAnimationFrame(function() {\n window.dispatchEvent(new CustomEvent('WebComponentsReady'));\n });\n });\n\n})(window.WebComponents);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n // It's desireable to provide a default stylesheet\n // that's convenient for styling unresolved elements, but\n // it's cumbersome to have to include this manually in every page.\n // It would make sense to put inside some HTMLImport but\n // the HTMLImports polyfill does not allow loading of stylesheets\n // that block rendering. Therefore this injection is tolerated here.\n //\n // NOTE: position: relative fixes IE's failure to inherit opacity\n // when a child is not statically positioned.\n var style = document.createElement('style');\n style.textContent = ''\n + 'body {'\n + 'transition: opacity ease-in 0.2s;'\n + ' } \\n'\n + 'body[unresolved] {'\n + 'opacity: 0; display: block; overflow: hidden; position: relative;'\n + ' } \\n'\n ;\n var head = document.querySelector('head');\n head.insertBefore(style, head.firstChild);\n\n})(window.WebComponents);\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/*\n * Polyfills loaded: HTML Imports, Custom Elements\n * Used in: Safari 10, Firefox once SD is shipped\n */\n\n// TODO(notwaldorf): Remove after this is addressed:\n// https://github.com/webcomponents/shadycss/issues/46\n\n}());\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n// given a string of css, return a simple rule tree\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\nfunction lex(text) {\n let root = {\n start: 0,\n end: text.length\n };\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n.rules) {\n n.rules = [];\n }\n let p = n;\n let previous = p.rules[p.rules.length - 1];\n n = {\n start: i + 1,\n parent: p,\n previous: previous\n };\n p.rules.push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n.end = i + 1;\n n = n.parent || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\nfunction parseCss(node, text) {\n let t = text.substring(node.start, node.end - 1);\n node.parsedCssText = node.cssText = t.trim();\n if (node.parent) {\n let ss = node.previous ? node.previous.end : node.parent.start;\n t = text.substring(ss, node.start - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node.parsedSelector = node.selector = t.trim();\n node.atRule = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node.atRule) {\n if (s.indexOf(MEDIA_START) === 0) {\n node.type = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node.type = types.KEYFRAMES_RULE;\n node.keyframesName =\n node.selector.split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node.type = types.MIXIN_RULE;\n } else {\n node.type = types.STYLE_RULE;\n }\n }\n }\n let r$ = node.rules;\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n// conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n// expanded form that doesn't require trailing space `\\000033`\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n// stringify parsed css.\nexport function stringify(node, preserveProperties, text) {\n text = text || '';\n // calc rule cssText\n let cssText = '';\n if (node.cssText || node.rules) {\n let r$ = node.rules;\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node.cssText :\n removeCustomProps(node.cssText);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node.selector) {\n text += node.selector + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node.selector) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\nfunction _hasMixinRules(rules) {\n return rules[0].selector.indexOf(VAR_START) === 0;\n}\n\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\nexport let types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nlet OPEN_BRACE = '{';\nlet CLOSE_BRACE = '}';\n\n// helper regexp's\nlet RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nlet VAR_START = '--';\nlet MEDIA_START = '@media';\nlet AT_START = '@';\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let nativeShadow = !(window.ShadyDOM && window.ShadyDOM.inUse);\n// chrome 49 has semi-working css vars, check if box-shadow works\n// safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\nexport let nativeCssVariables = (!navigator.userAgent.match('AppleWebKit/601') &&\nwindow.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n\n// experimental support for native @apply\nfunction detectNativeApply() {\n let style = document.createElement('style');\n style.textContent = '.foo { @apply --foo }';\n document.head.appendChild(style);\n let nativeCssApply = (style.sheet.cssRules[0].cssText.indexOf('apply') >= 0);\n document.head.removeChild(style);\n return nativeCssApply;\n}\n\nexport let nativeCssApply = false && detectNativeApply();\n\nfunction parseSettings(settings) {\n if (settings) {\n nativeCssVariables = nativeCssVariables && !settings.shimcssproperties;\n nativeShadow = nativeShadow && !settings.shimshadow;\n }\n}\n\nif (window.ShadyCSS) {\n parseSettings(window.ShadyCSS);\n} else if (window.WebComponents) {\n parseSettings(window.WebComponents.flags);\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow, nativeCssVariables} from './style-settings'\nimport {parse, stringify, types} from './css-parse'\n\nexport function toCssText (rules, callback) {\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\nexport function rulesForStyle(style) {\n if (!style.__cssRules && style.textContent) {\n style.__cssRules = parse(style.textContent);\n }\n return style.__cssRules;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\nexport function isKeyframesSelector(rule) {\n return rule.parent &&\n rule.parent.type === types.KEYFRAMES_RULE;\n}\n\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n if (onlyActiveRules) {\n if (node.type === types.MEDIA_RULE) {\n let matchMedia = node.selector.match(rx.MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (node.type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n node.type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (node.type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node.rules;\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i+~])'\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {removeCustomPropAssignment} from './css-parse'\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleInfo from './style-info'\n\n// TODO: dedupe with shady\nconst p = window.Element.prototype;\nconst matchesSelector = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n // decorates styles with rule info and returns an array of used style\n // property names\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule.rules = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = StyleUtil.rx.VAR_ASSIGN;\n let cssText = rule.parsedCssText;\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule.parsedCssText);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(StyleUtil.rx.BRACKETED, '')\n .replace(StyleUtil.rx.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = StyleUtil.rx.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(scope.is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules.__cssBuild;\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let hostSelector = StyleTransformer\n ._calcHostScope(element.is, element.extends);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(StyleUtil.rx.HOST_PREFIX + rxHostSelector +\n StyleUtil.rx.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule.cssText) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule.keyframesName] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n // Transforms `@keyframes` names to be unique for the current host.\n // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');\n rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n rule.selector = rule.transformedSelector.replace(\n rule.keyframesName, rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i elements to co-operate with ShadyCSS\n\nExample:\n\n \n\n*/\n\n'use strict';\n\nlet ShadyCSS = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS._elementsHaveApplied) {\n ShadyCSS.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n(scope => {\n\n /********************* base setup *********************/\n const useNative = Boolean('import' in document.createElement('link'));\n\n // Polyfill `currentScript` for browsers without it.\n let currentScript = null;\n if ('currentScript' in document === false) {\n Object.defineProperty(document, 'currentScript', {\n get() {\n return currentScript ||\n // NOTE: only works when called in synchronously executing code.\n // readyState should check if `loading` but IE10 is\n // interactive when scripts run so we cheat. This is not needed by\n // html-imports polyfill but helps generally polyfill `currentScript`.\n (document.readyState !== 'complete' ?\n document.scripts[document.scripts.length - 1] : null);\n },\n configurable: true\n });\n }\n\n /********************* path fixup *********************/\n const ABS_URL_TEST = /(^\\/)|(^#)|(^[\\w-\\d]*:)/;\n const CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\n const CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\n const STYLESHEET_REGEXP = /(]*)(rel=['|\"]?stylesheet['|\"]?[^>]*>)/g;\n\n // path fixup: style elements in imports must be made relative to the main\n // document. We fixup url's in url() and @import.\n const Path = {\n\n fixUrls(element, base) {\n if (element.href) {\n element.setAttribute('href',\n Path.replaceAttrUrl(element.getAttribute('href'), base));\n }\n if (element.src) {\n element.setAttribute('src',\n Path.replaceAttrUrl(element.getAttribute('src'), base));\n }\n if (element.localName === 'style') {\n Path.resolveUrlsInStyle(element, base);\n }\n },\n\n fixUrlAttributes(element, base) {\n const attrs = ['action', 'src', 'href', 'url', 'style'];\n for (let i = 0, a; i < attrs.length && (a = attrs[i]); i++) {\n const at = element.attributes[a];\n const v = at && at.value;\n // Skip bound attribute values (assume binding is done via {} and []).\n // TODO(valdrin) consider exposing a library-implementable hook.\n if (v && (v.search(/({{|\\[\\[)/) < 0)) {\n at.value = (a === 'style') ?\n Path.resolveUrlsInCssText(v, base) :\n Path.replaceAttrUrl(v, base);\n }\n }\n },\n\n fixUrlsInTemplates(element, base) {\n const t$ = element.querySelectorAll('template');\n for (let i = 0; i < t$.length; i++) {\n Path.fixUrlsInTemplate(t$[i], base);\n }\n },\n\n fixUrlsInTemplate(template, base) {\n // If template is not supported, still resolve urls within it.\n const content = template.content || template;\n const n$ = content.querySelectorAll(\n 'style, form[action], [src], [href], [url], [style]');\n for (let i = 0; i < n$.length; i++) {\n const n = n$[i];\n if (n.localName == 'style') {\n Path.resolveUrlsInStyle(n, base);\n } else {\n Path.fixUrlAttributes(n, base);\n }\n }\n Path.fixUrlsInTemplates(content, base);\n },\n\n resolveUrlsInStyle(style, linkUrl) {\n style.textContent = Path.resolveUrlsInCssText(style.textContent, linkUrl);\n },\n\n resolveUrlsInCssText(cssText, linkUrl) {\n let r = Path.replaceUrls(cssText, linkUrl, CSS_URL_REGEXP);\n r = Path.replaceUrls(r, linkUrl, CSS_IMPORT_REGEXP);\n return r;\n },\n\n replaceUrls(text, linkUrl, regexp) {\n return text.replace(regexp, (m, pre, url, post) => {\n let urlPath = url.replace(/[\"']/g, '');\n if (linkUrl) {\n urlPath = Path.resolveUrl(urlPath, linkUrl);\n }\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n },\n\n replaceAttrUrl(text, linkUrl) {\n if (text && ABS_URL_TEST.test(text)) {\n return text;\n } else {\n return Path.resolveUrl(text, linkUrl);\n }\n },\n\n resolveUrl(url, base) {\n // Lazy feature detection.\n if (Path.__workingURL === undefined) {\n Path.__workingURL = false;\n try {\n const u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n Path.__workingURL = (u.href === 'http://a/c%20d');\n } catch (e) {}\n }\n\n if (Path.__workingURL) {\n return (new URL(url, base)).href;\n }\n\n // Fallback to creating an anchor into a disconnected document.\n let doc = Path.__tempDoc;\n if (!doc) {\n doc = document.implementation.createHTMLDocument('temp');\n Path.__tempDoc = doc;\n doc.__base = doc.createElement('base');\n doc.head.appendChild(doc.__base);\n doc.__anchor = doc.createElement('a');\n }\n doc.__base.href = base;\n doc.__anchor.href = url;\n return doc.__anchor.href || url;\n }\n };\n\n /********************* Xhr processor *********************/\n const Xhr = {\n\n async: true,\n\n /**\n * @param {!string} url\n * @param {!function(!string, string=)} success\n * @param {!function(!string)} fail\n */\n load(url, success, fail) {\n if (!url) {\n fail('error: href must be specified');\n } else if (url.match(/^data:/)) {\n // Handle Data URI Scheme\n const pieces = url.split(',');\n const header = pieces[0];\n let resource = pieces[1];\n if (header.indexOf(';base64') > -1) {\n resource = atob(resource);\n } else {\n resource = decodeURIComponent(resource);\n }\n success(resource);\n } else {\n const request = new XMLHttpRequest();\n request.open('GET', url, Xhr.async);\n request.onload = () => {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly. Handle relative and full paths.\n let redirectedUrl = request.getResponseHeader('Location');\n if (redirectedUrl && redirectedUrl.indexOf('/') === 0) {\n // In IE location.origin might not work\n // https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7\n const origin = (location.origin || location.protocol + '//' + location.host);\n redirectedUrl = origin + redirectedUrl;\n }\n const resource = /** @type {string} */ (request.response || request.responseText);\n if (request.status === 304 || request.status === 0 ||\n request.status >= 200 && request.status < 300) {\n success(resource, redirectedUrl);\n } else {\n fail(resource);\n }\n };\n request.send();\n }\n }\n };\n\n /********************* importer *********************/\n\n const isIE = /Trident/.test(navigator.userAgent) ||\n /Edge\\/\\d./i.test(navigator.userAgent);\n\n const importSelector = 'link[rel=import]';\n\n // Used to disable loading of resources.\n const importDisableType = 'import-disable';\n\n const disabledLinkSelector = `link[rel=stylesheet][href][type=${importDisableType}]`;\n\n const importDependenciesSelector = `${importSelector}, ${disabledLinkSelector},\n style:not([type]), link[rel=stylesheet][href]:not([type]),\n script:not([type]), script[type=\"application/javascript\"],\n script[type=\"text/javascript\"]`;\n\n const importDependencyAttr = 'import-dependency';\n\n const rootImportSelector = `${importSelector}:not(${importDependencyAttr})`;\n\n const pendingScriptsSelector = `script[${importDependencyAttr}]`;\n\n const pendingStylesSelector = `style[${importDependencyAttr}],\n link[rel=stylesheet][${importDependencyAttr}]`;\n\n /**\n * Importer will:\n * - load any linked import documents (with deduping)\n * - whenever an import is loaded, prompt the parser to try to parse\n * - observe imported documents for new elements (these are handled via the\n * dynamic importer)\n */\n class Importer {\n constructor() {\n this.documents = {};\n // Used to keep track of pending loads, so that flattening and firing of\n // events can be done when all resources are ready.\n this.inflight = 0;\n this.dynamicImportsMO = new MutationObserver(m => this.handleMutations(m));\n // 1. Load imports contents\n // 2. Assign them to first import links on the document\n // 3. Wait for import styles & scripts to be done loading/running\n // 4. Fire load/error events\n whenDocumentReady(() => {\n // Observe changes on .\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.loadImports(document);\n });\n }\n\n /**\n * @param {!(HTMLDocument|DocumentFragment|Element)} doc\n */\n loadImports(doc) {\n const links = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = links.length; i < l; i++) {\n this.loadImport(links[i]);\n }\n this.processImportsIfLoadingDone();\n }\n\n /**\n * @param {!HTMLLinkElement} link\n */\n loadImport(link) {\n const url = link.href;\n // This resource is already being handled by another import.\n if (this.documents[url] !== undefined) {\n // If import is already loaded, we can safely associate it to the link\n // and fire the load/error event.\n const imp = this.documents[url];\n if (imp && imp['__loaded']) {\n link.import = imp;\n this.fireEventIfNeeded(link);\n }\n return;\n }\n this.inflight++;\n // Mark it as pending to notify others this url is being loaded.\n this.documents[url] = 'pending';\n Xhr.load(url, (resource, redirectedUrl) => {\n const doc = this.makeDocument(resource, redirectedUrl || url);\n this.documents[url] = doc;\n this.inflight--;\n // Load subtree.\n this.loadImports(doc);\n }, () => {\n // If load fails, handle error.\n this.documents[url] = null;\n this.inflight--;\n this.processImportsIfLoadingDone();\n });\n }\n\n /**\n * Creates a new document containing resource and normalizes urls accordingly.\n * @param {string=} resource\n * @param {string=} url\n * @return {!DocumentFragment}\n */\n makeDocument(resource, url) {\n if (!resource) {\n return document.createDocumentFragment();\n }\n\n if (isIE) {\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order. We disable the loading by\n // setting the type before setting innerHTML to avoid loading\n // resources twice.\n resource = resource.replace(STYLESHEET_REGEXP, (match, p1, p2) => {\n if (match.indexOf('type=') === -1) {\n return `${p1} type=${importDisableType} ${p2}`;\n }\n return match;\n });\n }\n\n let content;\n const template = /** @type {!HTMLTemplateElement} */\n (document.createElement('template'));\n template.innerHTML = resource;\n if (template.content) {\n // This creates issues in Safari10 when used with shadydom (see #12).\n content = template.content;\n } else {\n // not supported, create fragment and move content into it.\n content = document.createDocumentFragment();\n while (template.firstChild) {\n content.appendChild(template.firstChild);\n }\n }\n\n // Support in imported docs. Resolve url and remove its href.\n const baseEl = content.querySelector('base');\n if (baseEl) {\n url = Path.replaceAttrUrl(baseEl.getAttribute('href'), url);\n baseEl.removeAttribute('href');\n }\n\n // This is specific to users of (Polymer).\n // TODO(valdrin) remove this when Polymer uses importForElement.\n const s$ = content.querySelectorAll('dom-module');\n for (let i = 0, s; i < s$.length && (s = s$[i]); i++) {\n s.setAttribute('assetpath',\n Path.replaceAttrUrl(s.getAttribute('assetpath') || '', url));\n }\n\n const n$ = /** @type {!NodeList} */\n (content.querySelectorAll(importDependenciesSelector));\n // For source map hints.\n let inlineScriptIndex = 0;\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n // Listen for load/error events, then fix urls.\n whenElementLoaded(n);\n Path.fixUrls(n, url);\n // Mark for easier selectors.\n n.setAttribute(importDependencyAttr, '');\n // Generate source map hints for inline scripts.\n if (n.localName === 'script' && !n.src && n.textContent) {\n const num = inlineScriptIndex ? `-${inlineScriptIndex}` : '';\n const content = n.textContent + `\\n//# sourceURL=${url}${num}.js\\n`;\n // We use the src attribute so it triggers load/error events, and it's\n // easier to capture errors (e.g. parsing) like this.\n n.setAttribute('src', 'data:text/javascript;charset=utf-8,' + encodeURIComponent(content));\n n.textContent = '';\n inlineScriptIndex++;\n }\n }\n Path.fixUrlsInTemplates(content, url);\n return content;\n }\n\n /**\n * Waits for loaded imports to finish loading scripts and styles, then fires\n * the load/error events.\n */\n processImportsIfLoadingDone() {\n // Wait until all resources are ready, then load import resources.\n if (this.inflight) {\n return;\n }\n\n // Stop observing, flatten & load resource, then restart observing .\n this.dynamicImportsMO.disconnect();\n this.flatten(document);\n // We wait for styles to load, and at the same time we execute the scripts,\n // then fire the load/error events for imports to have faster whenReady\n // callback execution.\n // NOTE: This is different for native behavior where scripts would be\n // executed after the styles before them are loaded.\n // To achieve that, we could select pending styles and scripts in the\n // document and execute them sequentially in their dom order.\n let scriptsOk = false,\n stylesOk = false;\n const onLoadingDone = () => {\n if (stylesOk && scriptsOk) {\n // Restart observing.\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.fireEvents();\n }\n }\n this.waitForStyles(() => {\n stylesOk = true;\n onLoadingDone();\n });\n this.runScripts(() => {\n scriptsOk = true;\n onLoadingDone();\n });\n }\n\n /**\n * @param {!HTMLDocument} doc\n */\n flatten(doc) {\n const n$ = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n const imp = this.documents[n.href];\n n.import = /** @type {!Document} */ (imp);\n if (imp && imp.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // We set the .import to be the link itself, and update its readyState.\n // Other links with the same href will point to this link.\n this.documents[n.href] = n;\n n.readyState = 'loading';\n // Suppress Closure warning about incompatible subtype assignment.\n ( /** @type {!HTMLElement} */ (n).import = n);\n this.flatten(imp);\n n.appendChild(imp);\n }\n }\n }\n\n /**\n * Replaces all the imported scripts with a clone in order to execute them.\n * Updates the `currentScript`.\n * @param {!function()} callback\n */\n runScripts(callback) {\n const s$ = document.querySelectorAll(pendingScriptsSelector);\n const l = s$.length;\n const cloneScript = i => {\n if (i < l) {\n // The pending scripts have been generated through innerHTML and\n // browsers won't execute them for security reasons. We cannot use\n // s.cloneNode(true) either, the only way to run the script is manually\n // creating a new element and copying its attributes.\n const s = s$[i];\n const clone = /** @type {!HTMLScriptElement} */\n (document.createElement('script'));\n // Remove import-dependency attribute to avoid double cloning.\n s.removeAttribute(importDependencyAttr);\n for (let j = 0, ll = s.attributes.length; j < ll; j++) {\n clone.setAttribute(s.attributes[j].name, s.attributes[j].value);\n }\n // Update currentScript and replace original with clone script.\n currentScript = clone;\n s.parentNode.replaceChild(clone, s);\n whenElementLoaded(clone, () => {\n currentScript = null;\n cloneScript(i + 1);\n });\n } else {\n callback();\n }\n };\n cloneScript(0);\n }\n\n /**\n * Waits for all the imported stylesheets/styles to be loaded.\n * @param {!function()} callback\n */\n waitForStyles(callback) {\n const s$ = /** @type {!NodeList} */\n (document.querySelectorAll(pendingStylesSelector));\n let pending = s$.length;\n if (!pending) {\n callback();\n return;\n }\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10472273/\n // If there is one imported, we must move all imported\n // links and styles to .\n const needsMove = isIE && !!document.querySelector(disabledLinkSelector);\n for (let i = 0, l = s$.length, s; i < l && (s = s$[i]); i++) {\n // Listen for load/error events, remove selector once is done loading.\n whenElementLoaded(s, () => {\n s.removeAttribute(importDependencyAttr);\n if (--pending === 0) {\n callback();\n }\n });\n // Check if was already moved to head, to handle the case where the element\n // has already been moved but it is still loading.\n if (needsMove && s.parentNode !== document.head) {\n let rootImport = importForElement(s);\n while (rootImport && importForElement(rootImport)) {\n rootImport = importForElement(rootImport);\n }\n // Replace the element we're about to move with a placeholder.\n // NOTE: we first have to append the element to the new parent, then\n // we can put the placeholder at its place, otherwise load/error events\n // seem to be fired too early.\n const parent = s.parentNode,\n next = s.nextSibling,\n placeholder = document.createElement(s.localName);\n // Add reference of the moved element.\n placeholder['__appliedElement'] = s;\n // Disable this from appearing in document.styleSheets.\n placeholder.setAttribute('type', 'import-placeholder');\n // First, re-parent the element...\n if (rootImport.parentNode === document.head) {\n document.head.insertBefore(s, rootImport);\n } else {\n document.head.appendChild(s);\n }\n // ...and then, insert the placeholder at the right place.\n parent.insertBefore(placeholder, next);\n // Enable the loading of .\n s.removeAttribute('type');\n }\n }\n }\n\n /**\n * Fires load/error events for imports in the right order .\n */\n fireEvents() {\n const n$ = /** @type {!NodeList} */\n (document.querySelectorAll(importSelector));\n // Inverse order to have events firing bottom-up.\n for (let i = n$.length - 1, n; i >= 0 && (n = n$[i]); i--) {\n this.fireEventIfNeeded(n);\n }\n }\n\n /**\n * Fires load/error event for the import if this wasn't done already.\n * @param {!HTMLLinkElement} link\n */\n fireEventIfNeeded(link) {\n // Don't fire twice same event.\n if (!link['__loaded']) {\n link['__loaded'] = true;\n // Update link's import readyState.\n link.import && (link.import.readyState = 'complete');\n const eventType = link.import ? 'load' : 'error';\n link.dispatchEvent(newCustomEvent(eventType, {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }));\n }\n }\n\n /**\n * @param {Array} mutations\n */\n handleMutations(mutations) {\n for (let i = 0; i < mutations.length; i++) {\n const m = mutations[i];\n if (!m.addedNodes) {\n continue;\n }\n for (let ii = 0; ii < m.addedNodes.length; ii++) {\n const link = m.addedNodes[ii];\n if (!link || link.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n // NOTE: added scripts are not updating currentScript in IE.\n // TODO add test w/ script & stylesheet maybe\n if (isImportLink(link)) {\n this.loadImport( /** @type {!HTMLLinkElement} */ (link));\n } else {\n this.loadImports( /** @type {!Element} */ (link));\n }\n }\n }\n }\n }\n\n /**\n * @param {!Node} node\n * @return {boolean}\n */\n const isImportLink = node => {\n return node.nodeType === Node.ELEMENT_NODE && node.localName === 'link' &&\n ( /** @type {!HTMLLinkElement} */ (node).rel === 'import');\n };\n\n /**\n * Waits for an element to finish loading. If already done loading, it will\n * mark the element accordingly.\n * @param {!(HTMLLinkElement|HTMLScriptElement|HTMLStyleElement)} element\n * @param {function()=} callback\n */\n const whenElementLoaded = (element, callback) => {\n if (element['__loaded']) {\n callback && callback();\n } else if (element.localName === 'script' && !element.src) {\n // Inline scripts don't trigger load/error events, consider them already loaded.\n element['__loaded'] = true;\n callback && callback();\n } else {\n const onLoadingDone = event => {\n element.removeEventListener(event.type, onLoadingDone);\n element['__loaded'] = true;\n callback && callback();\n };\n element.addEventListener('load', onLoadingDone);\n // NOTE: We listen only for load events in IE/Edge, because in IE/Edge\n // \n\n*/\n\nlet ShadyCSS$1 = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS$1._elementsHaveApplied) {\n ShadyCSS$1.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS$1._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n 'use strict';\n\n if (customElements && customElements.polyfillWrapFlushCallback) {\n // Here we ensure that the public `HTMLImports.whenReady`\n // always comes *after* custom elements have upgraded.\n let flushCallback;\n function runAndClearCallback() {\n if (flushCallback) {\n let cb = flushCallback;\n flushCallback = null;\n cb();\n }\n }\n let origWhenReady = HTMLImports.whenReady;\n customElements.polyfillWrapFlushCallback(function(cb) {\n flushCallback = cb;\n origWhenReady(runAndClearCallback);\n });\n\n HTMLImports.whenReady = function(cb) {\n origWhenReady(function() {\n runAndClearCallback();\n cb();\n });\n };\n\n }\n\n HTMLImports.whenReady(function() {\n requestAnimationFrame(function() {\n window.dispatchEvent(new CustomEvent('WebComponentsReady'));\n });\n });\n\n})(window.WebComponents);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n // It's desireable to provide a default stylesheet\n // that's convenient for styling unresolved elements, but\n // it's cumbersome to have to include this manually in every page.\n // It would make sense to put inside some HTMLImport but\n // the HTMLImports polyfill does not allow loading of stylesheets\n // that block rendering. Therefore this injection is tolerated here.\n //\n // NOTE: position: relative fixes IE's failure to inherit opacity\n // when a child is not statically positioned.\n var style = document.createElement('style');\n style.textContent = ''\n + 'body {'\n + 'transition: opacity ease-in 0.2s;'\n + ' } \\n'\n + 'body[unresolved] {'\n + 'opacity: 0; display: block; overflow: hidden; position: relative;'\n + ' } \\n'\n ;\n var head = document.querySelector('head');\n head.insertBefore(style, head.firstChild);\n\n})(window.WebComponents);\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/*\n * Polyfills loaded: HTML Imports, Custom Elements, Shady DOM/Shady CSS\n * Used in: Safari 9, Firefox, Edge\n */\n\n}());\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n// given a string of css, return a simple rule tree\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\nfunction lex(text) {\n let root = {\n start: 0,\n end: text.length\n };\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n.rules) {\n n.rules = [];\n }\n let p = n;\n let previous = p.rules[p.rules.length - 1];\n n = {\n start: i + 1,\n parent: p,\n previous: previous\n };\n p.rules.push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n.end = i + 1;\n n = n.parent || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\nfunction parseCss(node, text) {\n let t = text.substring(node.start, node.end - 1);\n node.parsedCssText = node.cssText = t.trim();\n if (node.parent) {\n let ss = node.previous ? node.previous.end : node.parent.start;\n t = text.substring(ss, node.start - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node.parsedSelector = node.selector = t.trim();\n node.atRule = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node.atRule) {\n if (s.indexOf(MEDIA_START) === 0) {\n node.type = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node.type = types.KEYFRAMES_RULE;\n node.keyframesName =\n node.selector.split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node.type = types.MIXIN_RULE;\n } else {\n node.type = types.STYLE_RULE;\n }\n }\n }\n let r$ = node.rules;\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n// conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n// expanded form that doesn't require trailing space `\\000033`\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n// stringify parsed css.\nexport function stringify(node, preserveProperties, text) {\n text = text || '';\n // calc rule cssText\n let cssText = '';\n if (node.cssText || node.rules) {\n let r$ = node.rules;\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node.cssText :\n removeCustomProps(node.cssText);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node.selector) {\n text += node.selector + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node.selector) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\nfunction _hasMixinRules(rules) {\n return rules[0].selector.indexOf(VAR_START) === 0;\n}\n\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\nexport let types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nlet OPEN_BRACE = '{';\nlet CLOSE_BRACE = '}';\n\n// helper regexp's\nlet RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nlet VAR_START = '--';\nlet MEDIA_START = '@media';\nlet AT_START = '@';\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let nativeShadow = !(window.ShadyDOM && window.ShadyDOM.inUse);\n// chrome 49 has semi-working css vars, check if box-shadow works\n// safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\nexport let nativeCssVariables = (!navigator.userAgent.match('AppleWebKit/601') &&\nwindow.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n\n// experimental support for native @apply\nfunction detectNativeApply() {\n let style = document.createElement('style');\n style.textContent = '.foo { @apply --foo }';\n document.head.appendChild(style);\n let nativeCssApply = (style.sheet.cssRules[0].cssText.indexOf('apply') >= 0);\n document.head.removeChild(style);\n return nativeCssApply;\n}\n\nexport let nativeCssApply = false && detectNativeApply();\n\nfunction parseSettings(settings) {\n if (settings) {\n nativeCssVariables = nativeCssVariables && !settings.shimcssproperties;\n nativeShadow = nativeShadow && !settings.shimshadow;\n }\n}\n\nif (window.ShadyCSS) {\n parseSettings(window.ShadyCSS);\n} else if (window.WebComponents) {\n parseSettings(window.WebComponents.flags);\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow, nativeCssVariables} from './style-settings'\nimport {parse, stringify, types} from './css-parse'\n\nexport function toCssText (rules, callback) {\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\nexport function rulesForStyle(style) {\n if (!style.__cssRules && style.textContent) {\n style.__cssRules = parse(style.textContent);\n }\n return style.__cssRules;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\nexport function isKeyframesSelector(rule) {\n return rule.parent &&\n rule.parent.type === types.KEYFRAMES_RULE;\n}\n\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n if (onlyActiveRules) {\n if (node.type === types.MEDIA_RULE) {\n let matchMedia = node.selector.match(rx.MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (node.type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n node.type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (node.type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node.rules;\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i+~])'\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {removeCustomPropAssignment} from './css-parse'\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleInfo from './style-info'\n\n// TODO: dedupe with shady\nconst p = window.Element.prototype;\nconst matchesSelector = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n // decorates styles with rule info and returns an array of used style\n // property names\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule.rules = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = StyleUtil.rx.VAR_ASSIGN;\n let cssText = rule.parsedCssText;\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule.parsedCssText);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(StyleUtil.rx.BRACKETED, '')\n .replace(StyleUtil.rx.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = StyleUtil.rx.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(scope.is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules.__cssBuild;\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let hostSelector = StyleTransformer\n ._calcHostScope(element.is, element.extends);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(StyleUtil.rx.HOST_PREFIX + rxHostSelector +\n StyleUtil.rx.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule.cssText) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule.keyframesName] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n // Transforms `@keyframes` names to be unique for the current host.\n // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');\n rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n rule.selector = rule.transformedSelector.replace(\n rule.keyframesName, rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i elements to co-operate with ShadyCSS\n\nExample:\n\n \n\n*/\n\n'use strict';\n\nlet ShadyCSS = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS._elementsHaveApplied) {\n ShadyCSS.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n(scope => {\n\n /********************* base setup *********************/\n const useNative = Boolean('import' in document.createElement('link'));\n\n // Polyfill `currentScript` for browsers without it.\n let currentScript = null;\n if ('currentScript' in document === false) {\n Object.defineProperty(document, 'currentScript', {\n get() {\n return currentScript ||\n // NOTE: only works when called in synchronously executing code.\n // readyState should check if `loading` but IE10 is\n // interactive when scripts run so we cheat. This is not needed by\n // html-imports polyfill but helps generally polyfill `currentScript`.\n (document.readyState !== 'complete' ?\n document.scripts[document.scripts.length - 1] : null);\n },\n configurable: true\n });\n }\n\n /********************* path fixup *********************/\n const ABS_URL_TEST = /(^\\/)|(^#)|(^[\\w-\\d]*:)/;\n const CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\n const CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\n const STYLESHEET_REGEXP = /(]*)(rel=['|\"]?stylesheet['|\"]?[^>]*>)/g;\n\n // path fixup: style elements in imports must be made relative to the main\n // document. We fixup url's in url() and @import.\n const Path = {\n\n fixUrls(element, base) {\n if (element.href) {\n element.setAttribute('href',\n Path.replaceAttrUrl(element.getAttribute('href'), base));\n }\n if (element.src) {\n element.setAttribute('src',\n Path.replaceAttrUrl(element.getAttribute('src'), base));\n }\n if (element.localName === 'style') {\n Path.resolveUrlsInStyle(element, base);\n }\n },\n\n fixUrlAttributes(element, base) {\n const attrs = ['action', 'src', 'href', 'url', 'style'];\n for (let i = 0, a; i < attrs.length && (a = attrs[i]); i++) {\n const at = element.attributes[a];\n const v = at && at.value;\n // Skip bound attribute values (assume binding is done via {} and []).\n // TODO(valdrin) consider exposing a library-implementable hook.\n if (v && (v.search(/({{|\\[\\[)/) < 0)) {\n at.value = (a === 'style') ?\n Path.resolveUrlsInCssText(v, base) :\n Path.replaceAttrUrl(v, base);\n }\n }\n },\n\n fixUrlsInTemplates(element, base) {\n const t$ = element.querySelectorAll('template');\n for (let i = 0; i < t$.length; i++) {\n Path.fixUrlsInTemplate(t$[i], base);\n }\n },\n\n fixUrlsInTemplate(template, base) {\n // If template is not supported, still resolve urls within it.\n const content = template.content || template;\n const n$ = content.querySelectorAll(\n 'style, form[action], [src], [href], [url], [style]');\n for (let i = 0; i < n$.length; i++) {\n const n = n$[i];\n if (n.localName == 'style') {\n Path.resolveUrlsInStyle(n, base);\n } else {\n Path.fixUrlAttributes(n, base);\n }\n }\n Path.fixUrlsInTemplates(content, base);\n },\n\n resolveUrlsInStyle(style, linkUrl) {\n style.textContent = Path.resolveUrlsInCssText(style.textContent, linkUrl);\n },\n\n resolveUrlsInCssText(cssText, linkUrl) {\n let r = Path.replaceUrls(cssText, linkUrl, CSS_URL_REGEXP);\n r = Path.replaceUrls(r, linkUrl, CSS_IMPORT_REGEXP);\n return r;\n },\n\n replaceUrls(text, linkUrl, regexp) {\n return text.replace(regexp, (m, pre, url, post) => {\n let urlPath = url.replace(/[\"']/g, '');\n if (linkUrl) {\n urlPath = Path.resolveUrl(urlPath, linkUrl);\n }\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n },\n\n replaceAttrUrl(text, linkUrl) {\n if (text && ABS_URL_TEST.test(text)) {\n return text;\n } else {\n return Path.resolveUrl(text, linkUrl);\n }\n },\n\n resolveUrl(url, base) {\n // Lazy feature detection.\n if (Path.__workingURL === undefined) {\n Path.__workingURL = false;\n try {\n const u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n Path.__workingURL = (u.href === 'http://a/c%20d');\n } catch (e) {}\n }\n\n if (Path.__workingURL) {\n return (new URL(url, base)).href;\n }\n\n // Fallback to creating an anchor into a disconnected document.\n let doc = Path.__tempDoc;\n if (!doc) {\n doc = document.implementation.createHTMLDocument('temp');\n Path.__tempDoc = doc;\n doc.__base = doc.createElement('base');\n doc.head.appendChild(doc.__base);\n doc.__anchor = doc.createElement('a');\n }\n doc.__base.href = base;\n doc.__anchor.href = url;\n return doc.__anchor.href || url;\n }\n };\n\n /********************* Xhr processor *********************/\n const Xhr = {\n\n async: true,\n\n /**\n * @param {!string} url\n * @param {!function(!string, string=)} success\n * @param {!function(!string)} fail\n */\n load(url, success, fail) {\n if (!url) {\n fail('error: href must be specified');\n } else if (url.match(/^data:/)) {\n // Handle Data URI Scheme\n const pieces = url.split(',');\n const header = pieces[0];\n let resource = pieces[1];\n if (header.indexOf(';base64') > -1) {\n resource = atob(resource);\n } else {\n resource = decodeURIComponent(resource);\n }\n success(resource);\n } else {\n const request = new XMLHttpRequest();\n request.open('GET', url, Xhr.async);\n request.onload = () => {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly. Handle relative and full paths.\n let redirectedUrl = request.getResponseHeader('Location');\n if (redirectedUrl && redirectedUrl.indexOf('/') === 0) {\n // In IE location.origin might not work\n // https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7\n const origin = (location.origin || location.protocol + '//' + location.host);\n redirectedUrl = origin + redirectedUrl;\n }\n const resource = /** @type {string} */ (request.response || request.responseText);\n if (request.status === 304 || request.status === 0 ||\n request.status >= 200 && request.status < 300) {\n success(resource, redirectedUrl);\n } else {\n fail(resource);\n }\n };\n request.send();\n }\n }\n };\n\n /********************* importer *********************/\n\n const isIE = /Trident/.test(navigator.userAgent) ||\n /Edge\\/\\d./i.test(navigator.userAgent);\n\n const importSelector = 'link[rel=import]';\n\n // Used to disable loading of resources.\n const importDisableType = 'import-disable';\n\n const disabledLinkSelector = `link[rel=stylesheet][href][type=${importDisableType}]`;\n\n const importDependenciesSelector = `${importSelector}, ${disabledLinkSelector},\n style:not([type]), link[rel=stylesheet][href]:not([type]),\n script:not([type]), script[type=\"application/javascript\"],\n script[type=\"text/javascript\"]`;\n\n const importDependencyAttr = 'import-dependency';\n\n const rootImportSelector = `${importSelector}:not(${importDependencyAttr})`;\n\n const pendingScriptsSelector = `script[${importDependencyAttr}]`;\n\n const pendingStylesSelector = `style[${importDependencyAttr}],\n link[rel=stylesheet][${importDependencyAttr}]`;\n\n /**\n * Importer will:\n * - load any linked import documents (with deduping)\n * - whenever an import is loaded, prompt the parser to try to parse\n * - observe imported documents for new elements (these are handled via the\n * dynamic importer)\n */\n class Importer {\n constructor() {\n this.documents = {};\n // Used to keep track of pending loads, so that flattening and firing of\n // events can be done when all resources are ready.\n this.inflight = 0;\n this.dynamicImportsMO = new MutationObserver(m => this.handleMutations(m));\n // 1. Load imports contents\n // 2. Assign them to first import links on the document\n // 3. Wait for import styles & scripts to be done loading/running\n // 4. Fire load/error events\n whenDocumentReady(() => {\n // Observe changes on .\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.loadImports(document);\n });\n }\n\n /**\n * @param {!(HTMLDocument|DocumentFragment|Element)} doc\n */\n loadImports(doc) {\n const links = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = links.length; i < l; i++) {\n this.loadImport(links[i]);\n }\n this.processImportsIfLoadingDone();\n }\n\n /**\n * @param {!HTMLLinkElement} link\n */\n loadImport(link) {\n const url = link.href;\n // This resource is already being handled by another import.\n if (this.documents[url] !== undefined) {\n // If import is already loaded, we can safely associate it to the link\n // and fire the load/error event.\n const imp = this.documents[url];\n if (imp && imp['__loaded']) {\n link.import = imp;\n this.fireEventIfNeeded(link);\n }\n return;\n }\n this.inflight++;\n // Mark it as pending to notify others this url is being loaded.\n this.documents[url] = 'pending';\n Xhr.load(url, (resource, redirectedUrl) => {\n const doc = this.makeDocument(resource, redirectedUrl || url);\n this.documents[url] = doc;\n this.inflight--;\n // Load subtree.\n this.loadImports(doc);\n }, () => {\n // If load fails, handle error.\n this.documents[url] = null;\n this.inflight--;\n this.processImportsIfLoadingDone();\n });\n }\n\n /**\n * Creates a new document containing resource and normalizes urls accordingly.\n * @param {string=} resource\n * @param {string=} url\n * @return {!DocumentFragment}\n */\n makeDocument(resource, url) {\n if (!resource) {\n return document.createDocumentFragment();\n }\n\n if (isIE) {\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order. We disable the loading by\n // setting the type before setting innerHTML to avoid loading\n // resources twice.\n resource = resource.replace(STYLESHEET_REGEXP, (match, p1, p2) => {\n if (match.indexOf('type=') === -1) {\n return `${p1} type=${importDisableType} ${p2}`;\n }\n return match;\n });\n }\n\n let content;\n const template = /** @type {!HTMLTemplateElement} */\n (document.createElement('template'));\n template.innerHTML = resource;\n if (template.content) {\n // This creates issues in Safari10 when used with shadydom (see #12).\n content = template.content;\n } else {\n // not supported, create fragment and move content into it.\n content = document.createDocumentFragment();\n while (template.firstChild) {\n content.appendChild(template.firstChild);\n }\n }\n\n // Support in imported docs. Resolve url and remove its href.\n const baseEl = content.querySelector('base');\n if (baseEl) {\n url = Path.replaceAttrUrl(baseEl.getAttribute('href'), url);\n baseEl.removeAttribute('href');\n }\n\n // This is specific to users of (Polymer).\n // TODO(valdrin) remove this when Polymer uses importForElement.\n const s$ = content.querySelectorAll('dom-module');\n for (let i = 0, s; i < s$.length && (s = s$[i]); i++) {\n s.setAttribute('assetpath',\n Path.replaceAttrUrl(s.getAttribute('assetpath') || '', url));\n }\n\n const n$ = /** @type {!NodeList} */\n (content.querySelectorAll(importDependenciesSelector));\n // For source map hints.\n let inlineScriptIndex = 0;\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n // Listen for load/error events, then fix urls.\n whenElementLoaded(n);\n Path.fixUrls(n, url);\n // Mark for easier selectors.\n n.setAttribute(importDependencyAttr, '');\n // Generate source map hints for inline scripts.\n if (n.localName === 'script' && !n.src && n.textContent) {\n const num = inlineScriptIndex ? `-${inlineScriptIndex}` : '';\n const content = n.textContent + `\\n//# sourceURL=${url}${num}.js\\n`;\n // We use the src attribute so it triggers load/error events, and it's\n // easier to capture errors (e.g. parsing) like this.\n n.setAttribute('src', 'data:text/javascript;charset=utf-8,' + encodeURIComponent(content));\n n.textContent = '';\n inlineScriptIndex++;\n }\n }\n Path.fixUrlsInTemplates(content, url);\n return content;\n }\n\n /**\n * Waits for loaded imports to finish loading scripts and styles, then fires\n * the load/error events.\n */\n processImportsIfLoadingDone() {\n // Wait until all resources are ready, then load import resources.\n if (this.inflight) {\n return;\n }\n\n // Stop observing, flatten & load resource, then restart observing .\n this.dynamicImportsMO.disconnect();\n this.flatten(document);\n // We wait for styles to load, and at the same time we execute the scripts,\n // then fire the load/error events for imports to have faster whenReady\n // callback execution.\n // NOTE: This is different for native behavior where scripts would be\n // executed after the styles before them are loaded.\n // To achieve that, we could select pending styles and scripts in the\n // document and execute them sequentially in their dom order.\n let scriptsOk = false,\n stylesOk = false;\n const onLoadingDone = () => {\n if (stylesOk && scriptsOk) {\n // Restart observing.\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.fireEvents();\n }\n }\n this.waitForStyles(() => {\n stylesOk = true;\n onLoadingDone();\n });\n this.runScripts(() => {\n scriptsOk = true;\n onLoadingDone();\n });\n }\n\n /**\n * @param {!HTMLDocument} doc\n */\n flatten(doc) {\n const n$ = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n const imp = this.documents[n.href];\n n.import = /** @type {!Document} */ (imp);\n if (imp && imp.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // We set the .import to be the link itself, and update its readyState.\n // Other links with the same href will point to this link.\n this.documents[n.href] = n;\n n.readyState = 'loading';\n // Suppress Closure warning about incompatible subtype assignment.\n ( /** @type {!HTMLElement} */ (n).import = n);\n this.flatten(imp);\n n.appendChild(imp);\n }\n }\n }\n\n /**\n * Replaces all the imported scripts with a clone in order to execute them.\n * Updates the `currentScript`.\n * @param {!function()} callback\n */\n runScripts(callback) {\n const s$ = document.querySelectorAll(pendingScriptsSelector);\n const l = s$.length;\n const cloneScript = i => {\n if (i < l) {\n // The pending scripts have been generated through innerHTML and\n // browsers won't execute them for security reasons. We cannot use\n // s.cloneNode(true) either, the only way to run the script is manually\n // creating a new element and copying its attributes.\n const s = s$[i];\n const clone = /** @type {!HTMLScriptElement} */\n (document.createElement('script'));\n // Remove import-dependency attribute to avoid double cloning.\n s.removeAttribute(importDependencyAttr);\n for (let j = 0, ll = s.attributes.length; j < ll; j++) {\n clone.setAttribute(s.attributes[j].name, s.attributes[j].value);\n }\n // Update currentScript and replace original with clone script.\n currentScript = clone;\n s.parentNode.replaceChild(clone, s);\n whenElementLoaded(clone, () => {\n currentScript = null;\n cloneScript(i + 1);\n });\n } else {\n callback();\n }\n };\n cloneScript(0);\n }\n\n /**\n * Waits for all the imported stylesheets/styles to be loaded.\n * @param {!function()} callback\n */\n waitForStyles(callback) {\n const s$ = /** @type {!NodeList} */\n (document.querySelectorAll(pendingStylesSelector));\n let pending = s$.length;\n if (!pending) {\n callback();\n return;\n }\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10472273/\n // If there is one imported, we must move all imported\n // links and styles to .\n const needsMove = isIE && !!document.querySelector(disabledLinkSelector);\n for (let i = 0, l = s$.length, s; i < l && (s = s$[i]); i++) {\n // Listen for load/error events, remove selector once is done loading.\n whenElementLoaded(s, () => {\n s.removeAttribute(importDependencyAttr);\n if (--pending === 0) {\n callback();\n }\n });\n // Check if was already moved to head, to handle the case where the element\n // has already been moved but it is still loading.\n if (needsMove && s.parentNode !== document.head) {\n let rootImport = importForElement(s);\n while (rootImport && importForElement(rootImport)) {\n rootImport = importForElement(rootImport);\n }\n // Replace the element we're about to move with a placeholder.\n // NOTE: we first have to append the element to the new parent, then\n // we can put the placeholder at its place, otherwise load/error events\n // seem to be fired too early.\n const parent = s.parentNode,\n next = s.nextSibling,\n placeholder = document.createElement(s.localName);\n // Add reference of the moved element.\n placeholder['__appliedElement'] = s;\n // Disable this from appearing in document.styleSheets.\n placeholder.setAttribute('type', 'import-placeholder');\n // First, re-parent the element...\n if (rootImport.parentNode === document.head) {\n document.head.insertBefore(s, rootImport);\n } else {\n document.head.appendChild(s);\n }\n // ...and then, insert the placeholder at the right place.\n parent.insertBefore(placeholder, next);\n // Enable the loading of .\n s.removeAttribute('type');\n }\n }\n }\n\n /**\n * Fires load/error events for imports in the right order .\n */\n fireEvents() {\n const n$ = /** @type {!NodeList} */\n (document.querySelectorAll(importSelector));\n // Inverse order to have events firing bottom-up.\n for (let i = n$.length - 1, n; i >= 0 && (n = n$[i]); i--) {\n this.fireEventIfNeeded(n);\n }\n }\n\n /**\n * Fires load/error event for the import if this wasn't done already.\n * @param {!HTMLLinkElement} link\n */\n fireEventIfNeeded(link) {\n // Don't fire twice same event.\n if (!link['__loaded']) {\n link['__loaded'] = true;\n // Update link's import readyState.\n link.import && (link.import.readyState = 'complete');\n const eventType = link.import ? 'load' : 'error';\n link.dispatchEvent(newCustomEvent(eventType, {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }));\n }\n }\n\n /**\n * @param {Array} mutations\n */\n handleMutations(mutations) {\n for (let i = 0; i < mutations.length; i++) {\n const m = mutations[i];\n if (!m.addedNodes) {\n continue;\n }\n for (let ii = 0; ii < m.addedNodes.length; ii++) {\n const link = m.addedNodes[ii];\n if (!link || link.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n // NOTE: added scripts are not updating currentScript in IE.\n // TODO add test w/ script & stylesheet maybe\n if (isImportLink(link)) {\n this.loadImport( /** @type {!HTMLLinkElement} */ (link));\n } else {\n this.loadImports( /** @type {!Element} */ (link));\n }\n }\n }\n }\n }\n\n /**\n * @param {!Node} node\n * @return {boolean}\n */\n const isImportLink = node => {\n return node.nodeType === Node.ELEMENT_NODE && node.localName === 'link' &&\n ( /** @type {!HTMLLinkElement} */ (node).rel === 'import');\n };\n\n /**\n * Waits for an element to finish loading. If already done loading, it will\n * mark the element accordingly.\n * @param {!(HTMLLinkElement|HTMLScriptElement|HTMLStyleElement)} element\n * @param {function()=} callback\n */\n const whenElementLoaded = (element, callback) => {\n if (element['__loaded']) {\n callback && callback();\n } else if (element.localName === 'script' && !element.src) {\n // Inline scripts don't trigger load/error events, consider them already loaded.\n element['__loaded'] = true;\n callback && callback();\n } else {\n const onLoadingDone = event => {\n element.removeEventListener(event.type, onLoadingDone);\n element['__loaded'] = true;\n callback && callback();\n };\n element.addEventListener('load', onLoadingDone);\n // NOTE: We listen only for load events in IE/Edge, because in IE/Edge\n // \n\n*/\n\nlet ShadyCSS$1 = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS$1._elementsHaveApplied) {\n ShadyCSS$1.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS$1._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n 'use strict';\n\n if (customElements && customElements.polyfillWrapFlushCallback) {\n // Here we ensure that the public `HTMLImports.whenReady`\n // always comes *after* custom elements have upgraded.\n let flushCallback;\n function runAndClearCallback() {\n if (flushCallback) {\n let cb = flushCallback;\n flushCallback = null;\n cb();\n }\n }\n let origWhenReady = HTMLImports.whenReady;\n customElements.polyfillWrapFlushCallback(function(cb) {\n flushCallback = cb;\n origWhenReady(runAndClearCallback);\n });\n\n HTMLImports.whenReady = function(cb) {\n origWhenReady(function() {\n runAndClearCallback();\n cb();\n });\n };\n\n }\n\n HTMLImports.whenReady(function() {\n requestAnimationFrame(function() {\n window.dispatchEvent(new CustomEvent('WebComponentsReady'));\n });\n });\n\n})(window.WebComponents);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n // It's desireable to provide a default stylesheet\n // that's convenient for styling unresolved elements, but\n // it's cumbersome to have to include this manually in every page.\n // It would make sense to put inside some HTMLImport but\n // the HTMLImports polyfill does not allow loading of stylesheets\n // that block rendering. Therefore this injection is tolerated here.\n //\n // NOTE: position: relative fixes IE's failure to inherit opacity\n // when a child is not statically positioned.\n var style = document.createElement('style');\n style.textContent = ''\n + 'body {'\n + 'transition: opacity ease-in 0.2s;'\n + ' } \\n'\n + 'body[unresolved] {'\n + 'opacity: 0; display: block; overflow: hidden; position: relative;'\n + ' } \\n'\n ;\n var head = document.querySelector('head');\n head.insertBefore(style, head.firstChild);\n\n})(window.WebComponents);\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/*\n * Polyfills loaded: HTML Imports\n * Used in: Safari Tech Preview\n */\n\n// TODO(notwaldorf): Remove after this is addressed:\n// https://github.com/webcomponents/shadycss/issues/46\n\n}());\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n// given a string of css, return a simple rule tree\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\nfunction lex(text) {\n let root = {\n start: 0,\n end: text.length\n };\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n.rules) {\n n.rules = [];\n }\n let p = n;\n let previous = p.rules[p.rules.length - 1];\n n = {\n start: i + 1,\n parent: p,\n previous: previous\n };\n p.rules.push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n.end = i + 1;\n n = n.parent || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\nfunction parseCss(node, text) {\n let t = text.substring(node.start, node.end - 1);\n node.parsedCssText = node.cssText = t.trim();\n if (node.parent) {\n let ss = node.previous ? node.previous.end : node.parent.start;\n t = text.substring(ss, node.start - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node.parsedSelector = node.selector = t.trim();\n node.atRule = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node.atRule) {\n if (s.indexOf(MEDIA_START) === 0) {\n node.type = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node.type = types.KEYFRAMES_RULE;\n node.keyframesName =\n node.selector.split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node.type = types.MIXIN_RULE;\n } else {\n node.type = types.STYLE_RULE;\n }\n }\n }\n let r$ = node.rules;\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n// conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n// expanded form that doesn't require trailing space `\\000033`\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n// stringify parsed css.\nexport function stringify(node, preserveProperties, text) {\n text = text || '';\n // calc rule cssText\n let cssText = '';\n if (node.cssText || node.rules) {\n let r$ = node.rules;\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node.cssText :\n removeCustomProps(node.cssText);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node.selector) {\n text += node.selector + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node.selector) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\nfunction _hasMixinRules(rules) {\n return rules[0].selector.indexOf(VAR_START) === 0;\n}\n\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\nexport let types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nlet OPEN_BRACE = '{';\nlet CLOSE_BRACE = '}';\n\n// helper regexp's\nlet RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nlet VAR_START = '--';\nlet MEDIA_START = '@media';\nlet AT_START = '@';\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let nativeShadow = !(window.ShadyDOM && window.ShadyDOM.inUse);\n// chrome 49 has semi-working css vars, check if box-shadow works\n// safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\nexport let nativeCssVariables = (!navigator.userAgent.match('AppleWebKit/601') &&\nwindow.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n\n// experimental support for native @apply\nfunction detectNativeApply() {\n let style = document.createElement('style');\n style.textContent = '.foo { @apply --foo }';\n document.head.appendChild(style);\n let nativeCssApply = (style.sheet.cssRules[0].cssText.indexOf('apply') >= 0);\n document.head.removeChild(style);\n return nativeCssApply;\n}\n\nexport let nativeCssApply = false && detectNativeApply();\n\nfunction parseSettings(settings) {\n if (settings) {\n nativeCssVariables = nativeCssVariables && !settings.shimcssproperties;\n nativeShadow = nativeShadow && !settings.shimshadow;\n }\n}\n\nif (window.ShadyCSS) {\n parseSettings(window.ShadyCSS);\n} else if (window.WebComponents) {\n parseSettings(window.WebComponents.flags);\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow, nativeCssVariables} from './style-settings'\nimport {parse, stringify, types} from './css-parse'\n\nexport function toCssText (rules, callback) {\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\nexport function rulesForStyle(style) {\n if (!style.__cssRules && style.textContent) {\n style.__cssRules = parse(style.textContent);\n }\n return style.__cssRules;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\nexport function isKeyframesSelector(rule) {\n return rule.parent &&\n rule.parent.type === types.KEYFRAMES_RULE;\n}\n\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n if (onlyActiveRules) {\n if (node.type === types.MEDIA_RULE) {\n let matchMedia = node.selector.match(rx.MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (node.type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n node.type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (node.type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node.rules;\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i+~])'\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {removeCustomPropAssignment} from './css-parse'\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleInfo from './style-info'\n\n// TODO: dedupe with shady\nconst p = window.Element.prototype;\nconst matchesSelector = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n // decorates styles with rule info and returns an array of used style\n // property names\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule.rules = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = StyleUtil.rx.VAR_ASSIGN;\n let cssText = rule.parsedCssText;\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule.parsedCssText);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(StyleUtil.rx.BRACKETED, '')\n .replace(StyleUtil.rx.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = StyleUtil.rx.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(scope.is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules.__cssBuild;\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let hostSelector = StyleTransformer\n ._calcHostScope(element.is, element.extends);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(StyleUtil.rx.HOST_PREFIX + rxHostSelector +\n StyleUtil.rx.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule.cssText) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule.keyframesName] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n // Transforms `@keyframes` names to be unique for the current host.\n // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');\n rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n rule.selector = rule.transformedSelector.replace(\n rule.keyframesName, rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i elements to co-operate with ShadyCSS\n\nExample:\n\n \n\n*/\n\n'use strict';\n\nlet ShadyCSS = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS._elementsHaveApplied) {\n ShadyCSS.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n(scope => {\n\n /********************* base setup *********************/\n const useNative = Boolean('import' in document.createElement('link'));\n\n // Polyfill `currentScript` for browsers without it.\n let currentScript = null;\n if ('currentScript' in document === false) {\n Object.defineProperty(document, 'currentScript', {\n get() {\n return currentScript ||\n // NOTE: only works when called in synchronously executing code.\n // readyState should check if `loading` but IE10 is\n // interactive when scripts run so we cheat. This is not needed by\n // html-imports polyfill but helps generally polyfill `currentScript`.\n (document.readyState !== 'complete' ?\n document.scripts[document.scripts.length - 1] : null);\n },\n configurable: true\n });\n }\n\n /********************* path fixup *********************/\n const ABS_URL_TEST = /(^\\/)|(^#)|(^[\\w-\\d]*:)/;\n const CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\n const CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\n const STYLESHEET_REGEXP = /(]*)(rel=['|\"]?stylesheet['|\"]?[^>]*>)/g;\n\n // path fixup: style elements in imports must be made relative to the main\n // document. We fixup url's in url() and @import.\n const Path = {\n\n fixUrls(element, base) {\n if (element.href) {\n element.setAttribute('href',\n Path.replaceAttrUrl(element.getAttribute('href'), base));\n }\n if (element.src) {\n element.setAttribute('src',\n Path.replaceAttrUrl(element.getAttribute('src'), base));\n }\n if (element.localName === 'style') {\n Path.resolveUrlsInStyle(element, base);\n }\n },\n\n fixUrlAttributes(element, base) {\n const attrs = ['action', 'src', 'href', 'url', 'style'];\n for (let i = 0, a; i < attrs.length && (a = attrs[i]); i++) {\n const at = element.attributes[a];\n const v = at && at.value;\n // Skip bound attribute values (assume binding is done via {} and []).\n // TODO(valdrin) consider exposing a library-implementable hook.\n if (v && (v.search(/({{|\\[\\[)/) < 0)) {\n at.value = (a === 'style') ?\n Path.resolveUrlsInCssText(v, base) :\n Path.replaceAttrUrl(v, base);\n }\n }\n },\n\n fixUrlsInTemplates(element, base) {\n const t$ = element.querySelectorAll('template');\n for (let i = 0; i < t$.length; i++) {\n Path.fixUrlsInTemplate(t$[i], base);\n }\n },\n\n fixUrlsInTemplate(template, base) {\n // If template is not supported, still resolve urls within it.\n const content = template.content || template;\n const n$ = content.querySelectorAll(\n 'style, form[action], [src], [href], [url], [style]');\n for (let i = 0; i < n$.length; i++) {\n const n = n$[i];\n if (n.localName == 'style') {\n Path.resolveUrlsInStyle(n, base);\n } else {\n Path.fixUrlAttributes(n, base);\n }\n }\n Path.fixUrlsInTemplates(content, base);\n },\n\n resolveUrlsInStyle(style, linkUrl) {\n style.textContent = Path.resolveUrlsInCssText(style.textContent, linkUrl);\n },\n\n resolveUrlsInCssText(cssText, linkUrl) {\n let r = Path.replaceUrls(cssText, linkUrl, CSS_URL_REGEXP);\n r = Path.replaceUrls(r, linkUrl, CSS_IMPORT_REGEXP);\n return r;\n },\n\n replaceUrls(text, linkUrl, regexp) {\n return text.replace(regexp, (m, pre, url, post) => {\n let urlPath = url.replace(/[\"']/g, '');\n if (linkUrl) {\n urlPath = Path.resolveUrl(urlPath, linkUrl);\n }\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n },\n\n replaceAttrUrl(text, linkUrl) {\n if (text && ABS_URL_TEST.test(text)) {\n return text;\n } else {\n return Path.resolveUrl(text, linkUrl);\n }\n },\n\n resolveUrl(url, base) {\n // Lazy feature detection.\n if (Path.__workingURL === undefined) {\n Path.__workingURL = false;\n try {\n const u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n Path.__workingURL = (u.href === 'http://a/c%20d');\n } catch (e) {}\n }\n\n if (Path.__workingURL) {\n return (new URL(url, base)).href;\n }\n\n // Fallback to creating an anchor into a disconnected document.\n let doc = Path.__tempDoc;\n if (!doc) {\n doc = document.implementation.createHTMLDocument('temp');\n Path.__tempDoc = doc;\n doc.__base = doc.createElement('base');\n doc.head.appendChild(doc.__base);\n doc.__anchor = doc.createElement('a');\n }\n doc.__base.href = base;\n doc.__anchor.href = url;\n return doc.__anchor.href || url;\n }\n };\n\n /********************* Xhr processor *********************/\n const Xhr = {\n\n async: true,\n\n /**\n * @param {!string} url\n * @param {!function(!string, string=)} success\n * @param {!function(!string)} fail\n */\n load(url, success, fail) {\n if (!url) {\n fail('error: href must be specified');\n } else if (url.match(/^data:/)) {\n // Handle Data URI Scheme\n const pieces = url.split(',');\n const header = pieces[0];\n let resource = pieces[1];\n if (header.indexOf(';base64') > -1) {\n resource = atob(resource);\n } else {\n resource = decodeURIComponent(resource);\n }\n success(resource);\n } else {\n const request = new XMLHttpRequest();\n request.open('GET', url, Xhr.async);\n request.onload = () => {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly. Handle relative and full paths.\n let redirectedUrl = request.getResponseHeader('Location');\n if (redirectedUrl && redirectedUrl.indexOf('/') === 0) {\n // In IE location.origin might not work\n // https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7\n const origin = (location.origin || location.protocol + '//' + location.host);\n redirectedUrl = origin + redirectedUrl;\n }\n const resource = /** @type {string} */ (request.response || request.responseText);\n if (request.status === 304 || request.status === 0 ||\n request.status >= 200 && request.status < 300) {\n success(resource, redirectedUrl);\n } else {\n fail(resource);\n }\n };\n request.send();\n }\n }\n };\n\n /********************* importer *********************/\n\n const isIE = /Trident/.test(navigator.userAgent) ||\n /Edge\\/\\d./i.test(navigator.userAgent);\n\n const importSelector = 'link[rel=import]';\n\n // Used to disable loading of resources.\n const importDisableType = 'import-disable';\n\n const disabledLinkSelector = `link[rel=stylesheet][href][type=${importDisableType}]`;\n\n const importDependenciesSelector = `${importSelector}, ${disabledLinkSelector},\n style:not([type]), link[rel=stylesheet][href]:not([type]),\n script:not([type]), script[type=\"application/javascript\"],\n script[type=\"text/javascript\"]`;\n\n const importDependencyAttr = 'import-dependency';\n\n const rootImportSelector = `${importSelector}:not(${importDependencyAttr})`;\n\n const pendingScriptsSelector = `script[${importDependencyAttr}]`;\n\n const pendingStylesSelector = `style[${importDependencyAttr}],\n link[rel=stylesheet][${importDependencyAttr}]`;\n\n /**\n * Importer will:\n * - load any linked import documents (with deduping)\n * - whenever an import is loaded, prompt the parser to try to parse\n * - observe imported documents for new elements (these are handled via the\n * dynamic importer)\n */\n class Importer {\n constructor() {\n this.documents = {};\n // Used to keep track of pending loads, so that flattening and firing of\n // events can be done when all resources are ready.\n this.inflight = 0;\n this.dynamicImportsMO = new MutationObserver(m => this.handleMutations(m));\n // 1. Load imports contents\n // 2. Assign them to first import links on the document\n // 3. Wait for import styles & scripts to be done loading/running\n // 4. Fire load/error events\n whenDocumentReady(() => {\n // Observe changes on .\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.loadImports(document);\n });\n }\n\n /**\n * @param {!(HTMLDocument|DocumentFragment|Element)} doc\n */\n loadImports(doc) {\n const links = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = links.length; i < l; i++) {\n this.loadImport(links[i]);\n }\n this.processImportsIfLoadingDone();\n }\n\n /**\n * @param {!HTMLLinkElement} link\n */\n loadImport(link) {\n const url = link.href;\n // This resource is already being handled by another import.\n if (this.documents[url] !== undefined) {\n // If import is already loaded, we can safely associate it to the link\n // and fire the load/error event.\n const imp = this.documents[url];\n if (imp && imp['__loaded']) {\n link.import = imp;\n this.fireEventIfNeeded(link);\n }\n return;\n }\n this.inflight++;\n // Mark it as pending to notify others this url is being loaded.\n this.documents[url] = 'pending';\n Xhr.load(url, (resource, redirectedUrl) => {\n const doc = this.makeDocument(resource, redirectedUrl || url);\n this.documents[url] = doc;\n this.inflight--;\n // Load subtree.\n this.loadImports(doc);\n }, () => {\n // If load fails, handle error.\n this.documents[url] = null;\n this.inflight--;\n this.processImportsIfLoadingDone();\n });\n }\n\n /**\n * Creates a new document containing resource and normalizes urls accordingly.\n * @param {string=} resource\n * @param {string=} url\n * @return {!DocumentFragment}\n */\n makeDocument(resource, url) {\n if (!resource) {\n return document.createDocumentFragment();\n }\n\n if (isIE) {\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order. We disable the loading by\n // setting the type before setting innerHTML to avoid loading\n // resources twice.\n resource = resource.replace(STYLESHEET_REGEXP, (match, p1, p2) => {\n if (match.indexOf('type=') === -1) {\n return `${p1} type=${importDisableType} ${p2}`;\n }\n return match;\n });\n }\n\n let content;\n const template = /** @type {!HTMLTemplateElement} */\n (document.createElement('template'));\n template.innerHTML = resource;\n if (template.content) {\n // This creates issues in Safari10 when used with shadydom (see #12).\n content = template.content;\n } else {\n // not supported, create fragment and move content into it.\n content = document.createDocumentFragment();\n while (template.firstChild) {\n content.appendChild(template.firstChild);\n }\n }\n\n // Support in imported docs. Resolve url and remove its href.\n const baseEl = content.querySelector('base');\n if (baseEl) {\n url = Path.replaceAttrUrl(baseEl.getAttribute('href'), url);\n baseEl.removeAttribute('href');\n }\n\n // This is specific to users of (Polymer).\n // TODO(valdrin) remove this when Polymer uses importForElement.\n const s$ = content.querySelectorAll('dom-module');\n for (let i = 0, s; i < s$.length && (s = s$[i]); i++) {\n s.setAttribute('assetpath',\n Path.replaceAttrUrl(s.getAttribute('assetpath') || '', url));\n }\n\n const n$ = /** @type {!NodeList} */\n (content.querySelectorAll(importDependenciesSelector));\n // For source map hints.\n let inlineScriptIndex = 0;\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n // Listen for load/error events, then fix urls.\n whenElementLoaded(n);\n Path.fixUrls(n, url);\n // Mark for easier selectors.\n n.setAttribute(importDependencyAttr, '');\n // Generate source map hints for inline scripts.\n if (n.localName === 'script' && !n.src && n.textContent) {\n const num = inlineScriptIndex ? `-${inlineScriptIndex}` : '';\n const content = n.textContent + `\\n//# sourceURL=${url}${num}.js\\n`;\n // We use the src attribute so it triggers load/error events, and it's\n // easier to capture errors (e.g. parsing) like this.\n n.setAttribute('src', 'data:text/javascript;charset=utf-8,' + encodeURIComponent(content));\n n.textContent = '';\n inlineScriptIndex++;\n }\n }\n Path.fixUrlsInTemplates(content, url);\n return content;\n }\n\n /**\n * Waits for loaded imports to finish loading scripts and styles, then fires\n * the load/error events.\n */\n processImportsIfLoadingDone() {\n // Wait until all resources are ready, then load import resources.\n if (this.inflight) {\n return;\n }\n\n // Stop observing, flatten & load resource, then restart observing .\n this.dynamicImportsMO.disconnect();\n this.flatten(document);\n // We wait for styles to load, and at the same time we execute the scripts,\n // then fire the load/error events for imports to have faster whenReady\n // callback execution.\n // NOTE: This is different for native behavior where scripts would be\n // executed after the styles before them are loaded.\n // To achieve that, we could select pending styles and scripts in the\n // document and execute them sequentially in their dom order.\n let scriptsOk = false,\n stylesOk = false;\n const onLoadingDone = () => {\n if (stylesOk && scriptsOk) {\n // Restart observing.\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.fireEvents();\n }\n }\n this.waitForStyles(() => {\n stylesOk = true;\n onLoadingDone();\n });\n this.runScripts(() => {\n scriptsOk = true;\n onLoadingDone();\n });\n }\n\n /**\n * @param {!HTMLDocument} doc\n */\n flatten(doc) {\n const n$ = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n const imp = this.documents[n.href];\n n.import = /** @type {!Document} */ (imp);\n if (imp && imp.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // We set the .import to be the link itself, and update its readyState.\n // Other links with the same href will point to this link.\n this.documents[n.href] = n;\n n.readyState = 'loading';\n // Suppress Closure warning about incompatible subtype assignment.\n ( /** @type {!HTMLElement} */ (n).import = n);\n this.flatten(imp);\n n.appendChild(imp);\n }\n }\n }\n\n /**\n * Replaces all the imported scripts with a clone in order to execute them.\n * Updates the `currentScript`.\n * @param {!function()} callback\n */\n runScripts(callback) {\n const s$ = document.querySelectorAll(pendingScriptsSelector);\n const l = s$.length;\n const cloneScript = i => {\n if (i < l) {\n // The pending scripts have been generated through innerHTML and\n // browsers won't execute them for security reasons. We cannot use\n // s.cloneNode(true) either, the only way to run the script is manually\n // creating a new element and copying its attributes.\n const s = s$[i];\n const clone = /** @type {!HTMLScriptElement} */\n (document.createElement('script'));\n // Remove import-dependency attribute to avoid double cloning.\n s.removeAttribute(importDependencyAttr);\n for (let j = 0, ll = s.attributes.length; j < ll; j++) {\n clone.setAttribute(s.attributes[j].name, s.attributes[j].value);\n }\n // Update currentScript and replace original with clone script.\n currentScript = clone;\n s.parentNode.replaceChild(clone, s);\n whenElementLoaded(clone, () => {\n currentScript = null;\n cloneScript(i + 1);\n });\n } else {\n callback();\n }\n };\n cloneScript(0);\n }\n\n /**\n * Waits for all the imported stylesheets/styles to be loaded.\n * @param {!function()} callback\n */\n waitForStyles(callback) {\n const s$ = /** @type {!NodeList} */\n (document.querySelectorAll(pendingStylesSelector));\n let pending = s$.length;\n if (!pending) {\n callback();\n return;\n }\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10472273/\n // If there is one imported, we must move all imported\n // links and styles to .\n const needsMove = isIE && !!document.querySelector(disabledLinkSelector);\n for (let i = 0, l = s$.length, s; i < l && (s = s$[i]); i++) {\n // Listen for load/error events, remove selector once is done loading.\n whenElementLoaded(s, () => {\n s.removeAttribute(importDependencyAttr);\n if (--pending === 0) {\n callback();\n }\n });\n // Check if was already moved to head, to handle the case where the element\n // has already been moved but it is still loading.\n if (needsMove && s.parentNode !== document.head) {\n let rootImport = importForElement(s);\n while (rootImport && importForElement(rootImport)) {\n rootImport = importForElement(rootImport);\n }\n // Replace the element we're about to move with a placeholder.\n // NOTE: we first have to append the element to the new parent, then\n // we can put the placeholder at its place, otherwise load/error events\n // seem to be fired too early.\n const parent = s.parentNode,\n next = s.nextSibling,\n placeholder = document.createElement(s.localName);\n // Add reference of the moved element.\n placeholder['__appliedElement'] = s;\n // Disable this from appearing in document.styleSheets.\n placeholder.setAttribute('type', 'import-placeholder');\n // First, re-parent the element...\n if (rootImport.parentNode === document.head) {\n document.head.insertBefore(s, rootImport);\n } else {\n document.head.appendChild(s);\n }\n // ...and then, insert the placeholder at the right place.\n parent.insertBefore(placeholder, next);\n // Enable the loading of .\n s.removeAttribute('type');\n }\n }\n }\n\n /**\n * Fires load/error events for imports in the right order .\n */\n fireEvents() {\n const n$ = /** @type {!NodeList} */\n (document.querySelectorAll(importSelector));\n // Inverse order to have events firing bottom-up.\n for (let i = n$.length - 1, n; i >= 0 && (n = n$[i]); i--) {\n this.fireEventIfNeeded(n);\n }\n }\n\n /**\n * Fires load/error event for the import if this wasn't done already.\n * @param {!HTMLLinkElement} link\n */\n fireEventIfNeeded(link) {\n // Don't fire twice same event.\n if (!link['__loaded']) {\n link['__loaded'] = true;\n // Update link's import readyState.\n link.import && (link.import.readyState = 'complete');\n const eventType = link.import ? 'load' : 'error';\n link.dispatchEvent(newCustomEvent(eventType, {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }));\n }\n }\n\n /**\n * @param {Array} mutations\n */\n handleMutations(mutations) {\n for (let i = 0; i < mutations.length; i++) {\n const m = mutations[i];\n if (!m.addedNodes) {\n continue;\n }\n for (let ii = 0; ii < m.addedNodes.length; ii++) {\n const link = m.addedNodes[ii];\n if (!link || link.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n // NOTE: added scripts are not updating currentScript in IE.\n // TODO add test w/ script & stylesheet maybe\n if (isImportLink(link)) {\n this.loadImport( /** @type {!HTMLLinkElement} */ (link));\n } else {\n this.loadImports( /** @type {!Element} */ (link));\n }\n }\n }\n }\n }\n\n /**\n * @param {!Node} node\n * @return {boolean}\n */\n const isImportLink = node => {\n return node.nodeType === Node.ELEMENT_NODE && node.localName === 'link' &&\n ( /** @type {!HTMLLinkElement} */ (node).rel === 'import');\n };\n\n /**\n * Waits for an element to finish loading. If already done loading, it will\n * mark the element accordingly.\n * @param {!(HTMLLinkElement|HTMLScriptElement|HTMLStyleElement)} element\n * @param {function()=} callback\n */\n const whenElementLoaded = (element, callback) => {\n if (element['__loaded']) {\n callback && callback();\n } else if (element.localName === 'script' && !element.src) {\n // Inline scripts don't trigger load/error events, consider them already loaded.\n element['__loaded'] = true;\n callback && callback();\n } else {\n const onLoadingDone = event => {\n element.removeEventListener(event.type, onLoadingDone);\n element['__loaded'] = true;\n callback && callback();\n };\n element.addEventListener('load', onLoadingDone);\n // NOTE: We listen only for load events in IE/Edge, because in IE/Edge\n // \n\n*/\n\nlet ShadyCSS$1 = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS$1._elementsHaveApplied) {\n ShadyCSS$1.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS$1._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n 'use strict';\n\n if (customElements && customElements.polyfillWrapFlushCallback) {\n // Here we ensure that the public `HTMLImports.whenReady`\n // always comes *after* custom elements have upgraded.\n let flushCallback;\n function runAndClearCallback() {\n if (flushCallback) {\n let cb = flushCallback;\n flushCallback = null;\n cb();\n }\n }\n let origWhenReady = HTMLImports.whenReady;\n customElements.polyfillWrapFlushCallback(function(cb) {\n flushCallback = cb;\n origWhenReady(runAndClearCallback);\n });\n\n HTMLImports.whenReady = function(cb) {\n origWhenReady(function() {\n runAndClearCallback();\n cb();\n });\n };\n\n }\n\n HTMLImports.whenReady(function() {\n requestAnimationFrame(function() {\n window.dispatchEvent(new CustomEvent('WebComponentsReady'));\n });\n });\n\n})(window.WebComponents);\n\n/**\n * @license\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n // It's desireable to provide a default stylesheet\n // that's convenient for styling unresolved elements, but\n // it's cumbersome to have to include this manually in every page.\n // It would make sense to put inside some HTMLImport but\n // the HTMLImports polyfill does not allow loading of stylesheets\n // that block rendering. Therefore this injection is tolerated here.\n //\n // NOTE: position: relative fixes IE's failure to inherit opacity\n // when a child is not statically positioned.\n var style = document.createElement('style');\n style.textContent = ''\n + 'body {'\n + 'transition: opacity ease-in 0.2s;'\n + ' } \\n'\n + 'body[unresolved] {'\n + 'opacity: 0; display: block; overflow: hidden; position: relative;'\n + ' } \\n'\n ;\n var head = document.querySelector('head');\n head.insertBefore(style, head.firstChild);\n\n})(window.WebComponents);\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/*\n * Polyfills loaded: HTML Imports, Custom Elements, Shady DOM/Shady CSS, platform polyfills (URL/template)\n * Used in: IE 11\n */\n\n}());\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n// given a string of css, return a simple rule tree\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\nfunction lex(text) {\n let root = {\n start: 0,\n end: text.length\n };\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n.rules) {\n n.rules = [];\n }\n let p = n;\n let previous = p.rules[p.rules.length - 1];\n n = {\n start: i + 1,\n parent: p,\n previous: previous\n };\n p.rules.push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n.end = i + 1;\n n = n.parent || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\nfunction parseCss(node, text) {\n let t = text.substring(node.start, node.end - 1);\n node.parsedCssText = node.cssText = t.trim();\n if (node.parent) {\n let ss = node.previous ? node.previous.end : node.parent.start;\n t = text.substring(ss, node.start - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node.parsedSelector = node.selector = t.trim();\n node.atRule = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node.atRule) {\n if (s.indexOf(MEDIA_START) === 0) {\n node.type = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node.type = types.KEYFRAMES_RULE;\n node.keyframesName =\n node.selector.split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node.type = types.MIXIN_RULE;\n } else {\n node.type = types.STYLE_RULE;\n }\n }\n }\n let r$ = node.rules;\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n// conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n// expanded form that doesn't require trailing space `\\000033`\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n// stringify parsed css.\nexport function stringify(node, preserveProperties, text) {\n text = text || '';\n // calc rule cssText\n let cssText = '';\n if (node.cssText || node.rules) {\n let r$ = node.rules;\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node.cssText :\n removeCustomProps(node.cssText);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node.selector) {\n text += node.selector + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node.selector) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\nfunction _hasMixinRules(rules) {\n return rules[0].selector.indexOf(VAR_START) === 0;\n}\n\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\nexport let types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nlet OPEN_BRACE = '{';\nlet CLOSE_BRACE = '}';\n\n// helper regexp's\nlet RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nlet VAR_START = '--';\nlet MEDIA_START = '@media';\nlet AT_START = '@';\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let nativeShadow = !(window.ShadyDOM && window.ShadyDOM.inUse);\n// chrome 49 has semi-working css vars, check if box-shadow works\n// safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\nexport let nativeCssVariables = (!navigator.userAgent.match('AppleWebKit/601') &&\nwindow.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n\n// experimental support for native @apply\nfunction detectNativeApply() {\n let style = document.createElement('style');\n style.textContent = '.foo { @apply --foo }';\n document.head.appendChild(style);\n let nativeCssApply = (style.sheet.cssRules[0].cssText.indexOf('apply') >= 0);\n document.head.removeChild(style);\n return nativeCssApply;\n}\n\nexport let nativeCssApply = false && detectNativeApply();\n\nfunction parseSettings(settings) {\n if (settings) {\n nativeCssVariables = nativeCssVariables && !settings.shimcssproperties;\n nativeShadow = nativeShadow && !settings.shimshadow;\n }\n}\n\nif (window.ShadyCSS) {\n parseSettings(window.ShadyCSS);\n} else if (window.WebComponents) {\n parseSettings(window.WebComponents.flags);\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow, nativeCssVariables} from './style-settings'\nimport {parse, stringify, types} from './css-parse'\n\nexport function toCssText (rules, callback) {\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\nexport function rulesForStyle(style) {\n if (!style.__cssRules && style.textContent) {\n style.__cssRules = parse(style.textContent);\n }\n return style.__cssRules;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\nexport function isKeyframesSelector(rule) {\n return rule.parent &&\n rule.parent.type === types.KEYFRAMES_RULE;\n}\n\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n if (onlyActiveRules) {\n if (node.type === types.MEDIA_RULE) {\n let matchMedia = node.selector.match(rx.MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (node.type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n node.type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (node.type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node.rules;\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i+~])'\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {removeCustomPropAssignment} from './css-parse'\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleInfo from './style-info'\n\n// TODO: dedupe with shady\nconst p = window.Element.prototype;\nconst matchesSelector = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n // decorates styles with rule info and returns an array of used style\n // property names\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule.rules = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = StyleUtil.rx.VAR_ASSIGN;\n let cssText = rule.parsedCssText;\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule.parsedCssText);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(StyleUtil.rx.BRACKETED, '')\n .replace(StyleUtil.rx.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = StyleUtil.rx.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(scope.is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules.__cssBuild;\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let hostSelector = StyleTransformer\n ._calcHostScope(element.is, element.extends);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(StyleUtil.rx.HOST_PREFIX + rxHostSelector +\n StyleUtil.rx.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule.cssText) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule.keyframesName] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n // Transforms `@keyframes` names to be unique for the current host.\n // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');\n rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n rule.selector = rule.transformedSelector.replace(\n rule.keyframesName, rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i elements to co-operate with ShadyCSS\n\nExample:\n\n \n\n*/\n\n'use strict';\n\nlet ShadyCSS = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS._elementsHaveApplied) {\n ShadyCSS.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n(function(scope) {\n\n 'use strict';\n\n // defaultPrevented is broken in IE.\n // https://connect.microsoft.com/IE/feedback/details/790389/event-defaultprevented-returns-false-after-preventdefault-was-called\n var workingDefaultPrevented = (function() {\n var e = document.createEvent('Event');\n e.initEvent('foo', true, true);\n e.preventDefault();\n return e.defaultPrevented;\n })();\n\n if (!workingDefaultPrevented) {\n var origPreventDefault = Event.prototype.preventDefault;\n Event.prototype.preventDefault = function() {\n if (!this.cancelable) {\n return;\n }\n\n origPreventDefault.call(this);\n\n Object.defineProperty(this, 'defaultPrevented', {\n get: function() {\n return true;\n },\n configurable: true\n });\n };\n }\n\n var isIE = /Trident/.test(navigator.userAgent);\n\n // CustomEvent constructor shim\n if (!window.CustomEvent || isIE && (typeof window.CustomEvent !== 'function')) {\n window.CustomEvent = function(inType, params) {\n params = params || {};\n var e = document.createEvent('CustomEvent');\n e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);\n return e;\n };\n window.CustomEvent.prototype = window.Event.prototype;\n }\n\n // Event constructor shim\n if (!window.Event || isIE && (typeof window.Event !== 'function')) {\n var origEvent = window.Event;\n window.Event = function(inType, params) {\n params = params || {};\n var e = document.createEvent('Event');\n e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable));\n return e;\n };\n if (origEvent) {\n for (var i in origEvent) {\n window.Event[i] = origEvent[i];\n }\n }\n window.Event.prototype = origEvent.prototype;\n }\n\n if (!window.MouseEvent || isIE && (typeof window.MouseEvent !== 'function')) {\n var origMouseEvent = window.MouseEvent;\n window.MouseEvent = function(inType, params) {\n params = params || {};\n var e = document.createEvent('MouseEvent');\n e.initMouseEvent(inType,\n Boolean(params.bubbles), Boolean(params.cancelable),\n params.view || window, params.detail,\n params.screenX, params.screenY, params.clientX, params.clientY,\n params.ctrlKey, params.altKey, params.shiftKey, params.metaKey,\n params.button, params.relatedTarget);\n return e;\n };\n if (origMouseEvent) {\n for (var i in origMouseEvent) {\n window.MouseEvent[i] = origMouseEvent[i];\n }\n }\n window.MouseEvent.prototype = origMouseEvent.prototype;\n }\n\n // ES6 stuff\n if (!Array.from) {\n Array.from = function (object) {\n return [].slice.call(object);\n };\n }\n\n if (!Object.assign) {\n var assign = function(target, source) {\n var n$ = Object.getOwnPropertyNames(source);\n for (var i=0, p; i < n$.length; i++) {\n p = n$[i];\n target[p] = source[p];\n }\n }\n\n Object.assign = function(target, sources) {\n var args = [].slice.call(arguments, 1);\n for (var i=0, s; i < args.length; i++) {\n s = args[i];\n if (s) {\n assign(target, s);\n }\n }\n return target;\n }\n }\n\n})(window.WebComponents);\n","/* Any copyright is dedicated to the Public Domain.\n * http://creativecommons.org/publicdomain/zero/1.0/ */\n\n(function(scope) {\n 'use strict';\n\n // feature detect for URL constructor\n var hasWorkingUrl = false;\n if (!scope.forceJURL) {\n try {\n var u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n hasWorkingUrl = u.href === 'http://a/c%20d';\n } catch(e) {}\n }\n\n if (hasWorkingUrl)\n return;\n\n var relative = Object.create(null);\n relative['ftp'] = 21;\n relative['file'] = 0;\n relative['gopher'] = 70;\n relative['http'] = 80;\n relative['https'] = 443;\n relative['ws'] = 80;\n relative['wss'] = 443;\n\n var relativePathDotMapping = Object.create(null);\n relativePathDotMapping['%2e'] = '.';\n relativePathDotMapping['.%2e'] = '..';\n relativePathDotMapping['%2e.'] = '..';\n relativePathDotMapping['%2e%2e'] = '..';\n\n function isRelativeScheme(scheme) {\n return relative[scheme] !== undefined;\n }\n\n function invalid() {\n clear.call(this);\n this._isInvalid = true;\n }\n\n function IDNAToASCII(h) {\n if ('' == h) {\n invalid.call(this)\n }\n // XXX\n return h.toLowerCase()\n }\n\n function percentEscape(c) {\n var unicode = c.charCodeAt(0);\n if (unicode > 0x20 &&\n unicode < 0x7F &&\n // \" # < > ? `\n [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) == -1\n ) {\n return c;\n }\n return encodeURIComponent(c);\n }\n\n function percentEscapeQuery(c) {\n // XXX This actually needs to encode c using encoding and then\n // convert the bytes one-by-one.\n\n var unicode = c.charCodeAt(0);\n if (unicode > 0x20 &&\n unicode < 0x7F &&\n // \" # < > ` (do not escape '?')\n [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) == -1\n ) {\n return c;\n }\n return encodeURIComponent(c);\n }\n\n var EOF = undefined,\n ALPHA = /[a-zA-Z]/,\n ALPHANUMERIC = /[a-zA-Z0-9\\+\\-\\.]/;\n\n function parse(input, stateOverride, base) {\n function err(message) {\n errors.push(message)\n }\n\n var state = stateOverride || 'scheme start',\n cursor = 0,\n buffer = '',\n seenAt = false,\n seenBracket = false,\n errors = [];\n\n loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {\n var c = input[cursor];\n switch (state) {\n case 'scheme start':\n if (c && ALPHA.test(c)) {\n buffer += c.toLowerCase(); // ASCII-safe\n state = 'scheme';\n } else if (!stateOverride) {\n buffer = '';\n state = 'no scheme';\n continue;\n } else {\n err('Invalid scheme.');\n break loop;\n }\n break;\n\n case 'scheme':\n if (c && ALPHANUMERIC.test(c)) {\n buffer += c.toLowerCase(); // ASCII-safe\n } else if (':' == c) {\n this._scheme = buffer;\n buffer = '';\n if (stateOverride) {\n break loop;\n }\n if (isRelativeScheme(this._scheme)) {\n this._isRelative = true;\n }\n if ('file' == this._scheme) {\n state = 'relative';\n } else if (this._isRelative && base && base._scheme == this._scheme) {\n state = 'relative or authority';\n } else if (this._isRelative) {\n state = 'authority first slash';\n } else {\n state = 'scheme data';\n }\n } else if (!stateOverride) {\n buffer = '';\n cursor = 0;\n state = 'no scheme';\n continue;\n } else if (EOF == c) {\n break loop;\n } else {\n err('Code point not allowed in scheme: ' + c)\n break loop;\n }\n break;\n\n case 'scheme data':\n if ('?' == c) {\n this._query = '?';\n state = 'query';\n } else if ('#' == c) {\n this._fragment = '#';\n state = 'fragment';\n } else {\n // XXX error handling\n if (EOF != c && '\\t' != c && '\\n' != c && '\\r' != c) {\n this._schemeData += percentEscape(c);\n }\n }\n break;\n\n case 'no scheme':\n if (!base || !(isRelativeScheme(base._scheme))) {\n err('Missing scheme.');\n invalid.call(this);\n } else {\n state = 'relative';\n continue;\n }\n break;\n\n case 'relative or authority':\n if ('/' == c && '/' == input[cursor+1]) {\n state = 'authority ignore slashes';\n } else {\n err('Expected /, got: ' + c);\n state = 'relative';\n continue\n }\n break;\n\n case 'relative':\n this._isRelative = true;\n if ('file' != this._scheme)\n this._scheme = base._scheme;\n if (EOF == c) {\n this._host = base._host;\n this._port = base._port;\n this._path = base._path.slice();\n this._query = base._query;\n this._username = base._username;\n this._password = base._password;\n break loop;\n } else if ('/' == c || '\\\\' == c) {\n if ('\\\\' == c)\n err('\\\\ is an invalid code point.');\n state = 'relative slash';\n } else if ('?' == c) {\n this._host = base._host;\n this._port = base._port;\n this._path = base._path.slice();\n this._query = '?';\n this._username = base._username;\n this._password = base._password;\n state = 'query';\n } else if ('#' == c) {\n this._host = base._host;\n this._port = base._port;\n this._path = base._path.slice();\n this._query = base._query;\n this._fragment = '#';\n this._username = base._username;\n this._password = base._password;\n state = 'fragment';\n } else {\n var nextC = input[cursor+1]\n var nextNextC = input[cursor+2]\n if (\n 'file' != this._scheme || !ALPHA.test(c) ||\n (nextC != ':' && nextC != '|') ||\n (EOF != nextNextC && '/' != nextNextC && '\\\\' != nextNextC && '?' != nextNextC && '#' != nextNextC)) {\n this._host = base._host;\n this._port = base._port;\n this._username = base._username;\n this._password = base._password;\n this._path = base._path.slice();\n this._path.pop();\n }\n state = 'relative path';\n continue;\n }\n break;\n\n case 'relative slash':\n if ('/' == c || '\\\\' == c) {\n if ('\\\\' == c) {\n err('\\\\ is an invalid code point.');\n }\n if ('file' == this._scheme) {\n state = 'file host';\n } else {\n state = 'authority ignore slashes';\n }\n } else {\n if ('file' != this._scheme) {\n this._host = base._host;\n this._port = base._port;\n this._username = base._username;\n this._password = base._password;\n }\n state = 'relative path';\n continue;\n }\n break;\n\n case 'authority first slash':\n if ('/' == c) {\n state = 'authority second slash';\n } else {\n err(\"Expected '/', got: \" + c);\n state = 'authority ignore slashes';\n continue;\n }\n break;\n\n case 'authority second slash':\n state = 'authority ignore slashes';\n if ('/' != c) {\n err(\"Expected '/', got: \" + c);\n continue;\n }\n break;\n\n case 'authority ignore slashes':\n if ('/' != c && '\\\\' != c) {\n state = 'authority';\n continue;\n } else {\n err('Expected authority, got: ' + c);\n }\n break;\n\n case 'authority':\n if ('@' == c) {\n if (seenAt) {\n err('@ already seen.');\n buffer += '%40';\n }\n seenAt = true;\n for (var i = 0; i < buffer.length; i++) {\n var cp = buffer[i];\n if ('\\t' == cp || '\\n' == cp || '\\r' == cp) {\n err('Invalid whitespace in authority.');\n continue;\n }\n // XXX check URL code points\n if (':' == cp && null === this._password) {\n this._password = '';\n continue;\n }\n var tempC = percentEscape(cp);\n (null !== this._password) ? this._password += tempC : this._username += tempC;\n }\n buffer = '';\n } else if (EOF == c || '/' == c || '\\\\' == c || '?' == c || '#' == c) {\n cursor -= buffer.length;\n buffer = '';\n state = 'host';\n continue;\n } else {\n buffer += c;\n }\n break;\n\n case 'file host':\n if (EOF == c || '/' == c || '\\\\' == c || '?' == c || '#' == c) {\n if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':' || buffer[1] == '|')) {\n state = 'relative path';\n } else if (buffer.length == 0) {\n state = 'relative path start';\n } else {\n this._host = IDNAToASCII.call(this, buffer);\n buffer = '';\n state = 'relative path start';\n }\n continue;\n } else if ('\\t' == c || '\\n' == c || '\\r' == c) {\n err('Invalid whitespace in file host.');\n } else {\n buffer += c;\n }\n break;\n\n case 'host':\n case 'hostname':\n if (':' == c && !seenBracket) {\n // XXX host parsing\n this._host = IDNAToASCII.call(this, buffer);\n buffer = '';\n state = 'port';\n if ('hostname' == stateOverride) {\n break loop;\n }\n } else if (EOF == c || '/' == c || '\\\\' == c || '?' == c || '#' == c) {\n this._host = IDNAToASCII.call(this, buffer);\n buffer = '';\n state = 'relative path start';\n if (stateOverride) {\n break loop;\n }\n continue;\n } else if ('\\t' != c && '\\n' != c && '\\r' != c) {\n if ('[' == c) {\n seenBracket = true;\n } else if (']' == c) {\n seenBracket = false;\n }\n buffer += c;\n } else {\n err('Invalid code point in host/hostname: ' + c);\n }\n break;\n\n case 'port':\n if (/[0-9]/.test(c)) {\n buffer += c;\n } else if (EOF == c || '/' == c || '\\\\' == c || '?' == c || '#' == c || stateOverride) {\n if ('' != buffer) {\n var temp = parseInt(buffer, 10);\n if (temp != relative[this._scheme]) {\n this._port = temp + '';\n }\n buffer = '';\n }\n if (stateOverride) {\n break loop;\n }\n state = 'relative path start';\n continue;\n } else if ('\\t' == c || '\\n' == c || '\\r' == c) {\n err('Invalid code point in port: ' + c);\n } else {\n invalid.call(this);\n }\n break;\n\n case 'relative path start':\n if ('\\\\' == c)\n err(\"'\\\\' not allowed in path.\");\n state = 'relative path';\n if ('/' != c && '\\\\' != c) {\n continue;\n }\n break;\n\n case 'relative path':\n if (EOF == c || '/' == c || '\\\\' == c || (!stateOverride && ('?' == c || '#' == c))) {\n if ('\\\\' == c) {\n err('\\\\ not allowed in relative path.');\n }\n var tmp;\n if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {\n buffer = tmp;\n }\n if ('..' == buffer) {\n this._path.pop();\n if ('/' != c && '\\\\' != c) {\n this._path.push('');\n }\n } else if ('.' == buffer && '/' != c && '\\\\' != c) {\n this._path.push('');\n } else if ('.' != buffer) {\n if ('file' == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == '|') {\n buffer = buffer[0] + ':';\n }\n this._path.push(buffer);\n }\n buffer = '';\n if ('?' == c) {\n this._query = '?';\n state = 'query';\n } else if ('#' == c) {\n this._fragment = '#';\n state = 'fragment';\n }\n } else if ('\\t' != c && '\\n' != c && '\\r' != c) {\n buffer += percentEscape(c);\n }\n break;\n\n case 'query':\n if (!stateOverride && '#' == c) {\n this._fragment = '#';\n state = 'fragment';\n } else if (EOF != c && '\\t' != c && '\\n' != c && '\\r' != c) {\n this._query += percentEscapeQuery(c);\n }\n break;\n\n case 'fragment':\n if (EOF != c && '\\t' != c && '\\n' != c && '\\r' != c) {\n this._fragment += c;\n }\n break;\n }\n\n cursor++;\n }\n }\n\n function clear() {\n this._scheme = '';\n this._schemeData = '';\n this._username = '';\n this._password = null;\n this._host = '';\n this._port = '';\n this._path = [];\n this._query = '';\n this._fragment = '';\n this._isInvalid = false;\n this._isRelative = false;\n }\n\n // Does not process domain names or IP addresses.\n // Does not handle encoding for the query parameter.\n function jURL(url, base /* , encoding */) {\n if (base !== undefined && !(base instanceof jURL))\n base = new jURL(String(base));\n\n this._url = url;\n clear.call(this);\n\n var input = url.replace(/^[ \\t\\r\\n\\f]+|[ \\t\\r\\n\\f]+$/g, '');\n // encoding = encoding || 'utf-8'\n\n parse.call(this, input, null, base);\n }\n\n jURL.prototype = {\n toString: function() {\n return this.href;\n },\n get href() {\n if (this._isInvalid)\n return this._url;\n\n var authority = '';\n if ('' != this._username || null != this._password) {\n authority = this._username +\n (null != this._password ? ':' + this._password : '') + '@';\n }\n\n return this.protocol +\n (this._isRelative ? '//' + authority + this.host : '') +\n this.pathname + this._query + this._fragment;\n },\n set href(href) {\n clear.call(this);\n parse.call(this, href);\n },\n\n get protocol() {\n return this._scheme + ':';\n },\n set protocol(protocol) {\n if (this._isInvalid)\n return;\n parse.call(this, protocol + ':', 'scheme start');\n },\n\n get host() {\n return this._isInvalid ? '' : this._port ?\n this._host + ':' + this._port : this._host;\n },\n set host(host) {\n if (this._isInvalid || !this._isRelative)\n return;\n parse.call(this, host, 'host');\n },\n\n get hostname() {\n return this._host;\n },\n set hostname(hostname) {\n if (this._isInvalid || !this._isRelative)\n return;\n parse.call(this, hostname, 'hostname');\n },\n\n get port() {\n return this._port;\n },\n set port(port) {\n if (this._isInvalid || !this._isRelative)\n return;\n parse.call(this, port, 'port');\n },\n\n get pathname() {\n return this._isInvalid ? '' : this._isRelative ?\n '/' + this._path.join('/') : this._schemeData;\n },\n set pathname(pathname) {\n if (this._isInvalid || !this._isRelative)\n return;\n this._path = [];\n parse.call(this, pathname, 'relative path start');\n },\n\n get search() {\n return this._isInvalid || !this._query || '?' == this._query ?\n '' : this._query;\n },\n set search(search) {\n if (this._isInvalid || !this._isRelative)\n return;\n this._query = '?';\n if ('?' == search[0])\n search = search.slice(1);\n parse.call(this, search, 'query');\n },\n\n get hash() {\n return this._isInvalid || !this._fragment || '#' == this._fragment ?\n '' : this._fragment;\n },\n set hash(hash) {\n if (this._isInvalid)\n return;\n this._fragment = '#';\n if ('#' == hash[0])\n hash = hash.slice(1);\n parse.call(this, hash, 'fragment');\n },\n\n get origin() {\n var host;\n if (this._isInvalid || !this._scheme) {\n return '';\n }\n // javascript: Gecko returns String(\"\"), WebKit/Blink String(\"null\")\n // Gecko throws error for \"data://\"\n // data: Gecko returns \"\", Blink returns \"data://\", WebKit returns \"null\"\n // Gecko returns String(\"\") for file: mailto:\n // WebKit/Blink returns String(\"SCHEME://\") for file: mailto:\n switch (this._scheme) {\n case 'data':\n case 'file':\n case 'javascript':\n case 'mailto':\n return 'null';\n }\n host = this.host;\n if (!host) {\n return '';\n }\n return this._scheme + '://' + host;\n }\n };\n\n // Copy over the static methods\n var OriginalURL = scope.URL;\n if (OriginalURL) {\n jURL.createObjectURL = function(blob) {\n // IE extension allows a second optional options argument.\n // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx\n return OriginalURL.createObjectURL.apply(OriginalURL, arguments);\n };\n jURL.revokeObjectURL = function(url) {\n OriginalURL.revokeObjectURL(url);\n };\n }\n\n scope.URL = jURL;\n\n})(window);\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n// minimal template polyfill\n(function() {\n\n var needsTemplate = (typeof HTMLTemplateElement === 'undefined');\n\n // NOTE: Patch document.importNode to work around IE11 bug that\n // casues children of a document fragment imported while\n // there is a mutation observer to not have a parentNode (!?!)\n // It's important that this is the first patch to `importNode` so that\n // dom produced for later patches is correct.\n if (/Trident/.test(navigator.userAgent)) {\n (function() {\n var Native_importNode = Document.prototype.importNode;\n Document.prototype.importNode = function() {\n var n = Native_importNode.apply(this, arguments);\n // Copy all children to a new document fragment since\n // this one may be broken\n if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n var f = this.createDocumentFragment();\n f.appendChild(n);\n return f;\n } else {\n return n;\n }\n };\n })();\n }\n\n // NOTE: we rely on this cloneNode not causing element upgrade.\n // This means this polyfill must load before the CE polyfill and\n // this would need to be re-worked if a browser supports native CE\n // but not .\n var Native_cloneNode = Node.prototype.cloneNode;\n var Native_createElement = Document.prototype.createElement;\n var Native_importNode = Document.prototype.importNode;\n\n // returns true if nested templates cannot be cloned (they cannot be on\n // some impl's like Safari 8 and Edge)\n // OR if cloning a document fragment does not result in a document fragment\n var needsCloning = (function() {\n if (!needsTemplate) {\n var t = document.createElement('template');\n var t2 = document.createElement('template');\n t2.content.appendChild(document.createElement('div'));\n t.content.appendChild(t2);\n var clone = t.cloneNode(true);\n return (clone.content.childNodes.length === 0 || clone.content.firstChild.content.childNodes.length === 0\n || !(document.createDocumentFragment().cloneNode() instanceof DocumentFragment));\n }\n })();\n\n var TEMPLATE_TAG = 'template';\n var PolyfilledHTMLTemplateElement = function() {};\n\n if (needsTemplate) {\n\n var contentDoc = document.implementation.createHTMLDocument('template');\n var canDecorate = true;\n\n var templateStyle = document.createElement('style');\n templateStyle.textContent = TEMPLATE_TAG + '{display:none;}';\n\n var head = document.head;\n head.insertBefore(templateStyle, head.firstElementChild);\n\n /**\n Provides a minimal shim for the element.\n */\n PolyfilledHTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);\n\n\n // if elements do not have `innerHTML` on instances, then\n // templates can be patched by swizzling their prototypes.\n var canProtoPatch =\n !(document.createElement('div').hasOwnProperty('innerHTML'));\n\n /**\n The `decorate` method moves element children to the template's `content`.\n NOTE: there is no support for dynamically adding elements to templates.\n */\n PolyfilledHTMLTemplateElement.decorate = function(template) {\n // if the template is decorated, return fast\n if (template.content) {\n return;\n }\n template.content = contentDoc.createDocumentFragment();\n var child;\n while (child = template.firstChild) {\n template.content.appendChild(child);\n }\n // NOTE: prefer prototype patching for performance and\n // because on some browsers (IE11), re-defining `innerHTML`\n // can result in intermittent errors.\n if (canProtoPatch) {\n template.__proto__ = PolyfilledHTMLTemplateElement.prototype;\n } else {\n template.cloneNode = function(deep) {\n return PolyfilledHTMLTemplateElement._cloneNode(this, deep);\n };\n // add innerHTML to template, if possible\n // Note: this throws on Safari 7\n if (canDecorate) {\n try {\n defineInnerHTML(template);\n } catch (err) {\n canDecorate = false;\n }\n }\n }\n // bootstrap recursively\n PolyfilledHTMLTemplateElement.bootstrap(template.content);\n };\n\n function defineInnerHTML(obj) {\n Object.defineProperty(obj, 'innerHTML', {\n get: function() {\n var o = '';\n for (var e = this.content.firstChild; e; e = e.nextSibling) {\n o += e.outerHTML || escapeData(e.data);\n }\n return o;\n },\n set: function(text) {\n contentDoc.body.innerHTML = text;\n PolyfilledHTMLTemplateElement.bootstrap(contentDoc);\n while (this.content.firstChild) {\n this.content.removeChild(this.content.firstChild);\n }\n while (contentDoc.body.firstChild) {\n this.content.appendChild(contentDoc.body.firstChild);\n }\n },\n configurable: true\n });\n }\n\n defineInnerHTML(PolyfilledHTMLTemplateElement.prototype);\n\n /**\n The `bootstrap` method is called automatically and \"fixes\" all\n elements in the document referenced by the `doc` argument.\n */\n PolyfilledHTMLTemplateElement.bootstrap = function(doc) {\n var templates = doc.querySelectorAll(TEMPLATE_TAG);\n for (var i=0, l=templates.length, t; (i]/g;\n\n function escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\\u00A0':\n return ' ';\n }\n }\n\n function escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n }\n }\n\n // make cloning/importing work!\n if (needsTemplate || needsCloning) {\n\n PolyfilledHTMLTemplateElement._cloneNode = function(template, deep) {\n var clone = Native_cloneNode.call(template, false);\n // NOTE: decorate doesn't auto-fix children because they are already\n // decorated so they need special clone fixup.\n if (this.decorate) {\n this.decorate(clone);\n }\n if (deep) {\n // NOTE: use native clone node to make sure CE's wrapped\n // cloneNode does not cause elements to upgrade.\n clone.content.appendChild(\n Native_cloneNode.call(template.content, true));\n // now ensure nested templates are cloned correctly.\n this.fixClonedDom(clone.content, template.content);\n }\n return clone;\n };\n\n PolyfilledHTMLTemplateElement.prototype.cloneNode = function(deep) {\n return PolyfilledHTMLTemplateElement._cloneNode(this, deep);\n }\n\n // Given a source and cloned subtree, find 's in the cloned\n // subtree and replace them with cloned 's from source.\n // We must do this because only the source templates have proper .content.\n PolyfilledHTMLTemplateElement.fixClonedDom = function(clone, source) {\n // do nothing if cloned node is not an element\n if (!source.querySelectorAll) return;\n // these two lists should be coincident\n var s$ = source.querySelectorAll(TEMPLATE_TAG);\n var t$ = clone.querySelectorAll(TEMPLATE_TAG);\n for (var i=0, l=t$.length, t, s; i's.\n // However, the ownerDocument of the cloned template will be correct!\n // This is because the native import node creates the right document owned\n // subtree and `fixClonedDom` inserts cloned templates into this subtree,\n // thus updating the owner doc.\n Document.prototype.importNode = function(element, deep) {\n if (element.localName === TEMPLATE_TAG) {\n return PolyfilledHTMLTemplateElement._cloneNode(element, deep);\n } else {\n var dom = Native_importNode.call(this, element, deep);\n if (deep) {\n PolyfilledHTMLTemplateElement.fixClonedDom(dom, element);\n }\n return dom;\n }\n };\n\n if (needsCloning) {\n window.HTMLTemplateElement.prototype.cloneNode = function(deep) {\n return PolyfilledHTMLTemplateElement._cloneNode(this, deep);\n };\n }\n }\n\n if (needsTemplate) {\n window.HTMLTemplateElement = PolyfilledHTMLTemplateElement;\n }\n\n})();\n","!function(t,e){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define(e):t.ES6Promise=e()}(this,function(){\"use strict\";function t(t){return\"function\"==typeof t||\"object\"==typeof t&&null!==t}function e(t){return\"function\"==typeof t}function n(t){I=t}function r(t){J=t}function o(){return function(){return process.nextTick(a)}}function i(){return\"undefined\"!=typeof H?function(){H(a)}:c()}function s(){var t=0,e=new V(a),n=document.createTextNode(\"\");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;t {\n\n /********************* base setup *********************/\n const useNative = Boolean('import' in document.createElement('link'));\n\n // Polyfill `currentScript` for browsers without it.\n let currentScript = null;\n if ('currentScript' in document === false) {\n Object.defineProperty(document, 'currentScript', {\n get() {\n return currentScript ||\n // NOTE: only works when called in synchronously executing code.\n // readyState should check if `loading` but IE10 is\n // interactive when scripts run so we cheat. This is not needed by\n // html-imports polyfill but helps generally polyfill `currentScript`.\n (document.readyState !== 'complete' ?\n document.scripts[document.scripts.length - 1] : null);\n },\n configurable: true\n });\n }\n\n /********************* path fixup *********************/\n const ABS_URL_TEST = /(^\\/)|(^#)|(^[\\w-\\d]*:)/;\n const CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\n const CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\n const STYLESHEET_REGEXP = /(]*)(rel=['|\"]?stylesheet['|\"]?[^>]*>)/g;\n\n // path fixup: style elements in imports must be made relative to the main\n // document. We fixup url's in url() and @import.\n const Path = {\n\n fixUrls(element, base) {\n if (element.href) {\n element.setAttribute('href',\n Path.replaceAttrUrl(element.getAttribute('href'), base));\n }\n if (element.src) {\n element.setAttribute('src',\n Path.replaceAttrUrl(element.getAttribute('src'), base));\n }\n if (element.localName === 'style') {\n Path.resolveUrlsInStyle(element, base);\n }\n },\n\n fixUrlAttributes(element, base) {\n const attrs = ['action', 'src', 'href', 'url', 'style'];\n for (let i = 0, a; i < attrs.length && (a = attrs[i]); i++) {\n const at = element.attributes[a];\n const v = at && at.value;\n // Skip bound attribute values (assume binding is done via {} and []).\n // TODO(valdrin) consider exposing a library-implementable hook.\n if (v && (v.search(/({{|\\[\\[)/) < 0)) {\n at.value = (a === 'style') ?\n Path.resolveUrlsInCssText(v, base) :\n Path.replaceAttrUrl(v, base);\n }\n }\n },\n\n fixUrlsInTemplates(element, base) {\n const t$ = element.querySelectorAll('template');\n for (let i = 0; i < t$.length; i++) {\n Path.fixUrlsInTemplate(t$[i], base);\n }\n },\n\n fixUrlsInTemplate(template, base) {\n // If template is not supported, still resolve urls within it.\n const content = template.content || template;\n const n$ = content.querySelectorAll(\n 'style, form[action], [src], [href], [url], [style]');\n for (let i = 0; i < n$.length; i++) {\n const n = n$[i];\n if (n.localName == 'style') {\n Path.resolveUrlsInStyle(n, base);\n } else {\n Path.fixUrlAttributes(n, base);\n }\n }\n Path.fixUrlsInTemplates(content, base);\n },\n\n resolveUrlsInStyle(style, linkUrl) {\n style.textContent = Path.resolveUrlsInCssText(style.textContent, linkUrl);\n },\n\n resolveUrlsInCssText(cssText, linkUrl) {\n let r = Path.replaceUrls(cssText, linkUrl, CSS_URL_REGEXP);\n r = Path.replaceUrls(r, linkUrl, CSS_IMPORT_REGEXP);\n return r;\n },\n\n replaceUrls(text, linkUrl, regexp) {\n return text.replace(regexp, (m, pre, url, post) => {\n let urlPath = url.replace(/[\"']/g, '');\n if (linkUrl) {\n urlPath = Path.resolveUrl(urlPath, linkUrl);\n }\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n },\n\n replaceAttrUrl(text, linkUrl) {\n if (text && ABS_URL_TEST.test(text)) {\n return text;\n } else {\n return Path.resolveUrl(text, linkUrl);\n }\n },\n\n resolveUrl(url, base) {\n // Lazy feature detection.\n if (Path.__workingURL === undefined) {\n Path.__workingURL = false;\n try {\n const u = new URL('b', 'http://a');\n u.pathname = 'c%20d';\n Path.__workingURL = (u.href === 'http://a/c%20d');\n } catch (e) {}\n }\n\n if (Path.__workingURL) {\n return (new URL(url, base)).href;\n }\n\n // Fallback to creating an anchor into a disconnected document.\n let doc = Path.__tempDoc;\n if (!doc) {\n doc = document.implementation.createHTMLDocument('temp');\n Path.__tempDoc = doc;\n doc.__base = doc.createElement('base');\n doc.head.appendChild(doc.__base);\n doc.__anchor = doc.createElement('a');\n }\n doc.__base.href = base;\n doc.__anchor.href = url;\n return doc.__anchor.href || url;\n }\n };\n\n /********************* Xhr processor *********************/\n const Xhr = {\n\n async: true,\n\n /**\n * @param {!string} url\n * @param {!function(!string, string=)} success\n * @param {!function(!string)} fail\n */\n load(url, success, fail) {\n if (!url) {\n fail('error: href must be specified');\n } else if (url.match(/^data:/)) {\n // Handle Data URI Scheme\n const pieces = url.split(',');\n const header = pieces[0];\n let resource = pieces[1];\n if (header.indexOf(';base64') > -1) {\n resource = atob(resource);\n } else {\n resource = decodeURIComponent(resource);\n }\n success(resource);\n } else {\n const request = new XMLHttpRequest();\n request.open('GET', url, Xhr.async);\n request.onload = () => {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly. Handle relative and full paths.\n let redirectedUrl = request.getResponseHeader('Location');\n if (redirectedUrl && redirectedUrl.indexOf('/') === 0) {\n // In IE location.origin might not work\n // https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7\n const origin = (location.origin || location.protocol + '//' + location.host);\n redirectedUrl = origin + redirectedUrl;\n }\n const resource = /** @type {string} */ (request.response || request.responseText);\n if (request.status === 304 || request.status === 0 ||\n request.status >= 200 && request.status < 300) {\n success(resource, redirectedUrl);\n } else {\n fail(resource);\n }\n };\n request.send();\n }\n }\n };\n\n /********************* importer *********************/\n\n const isIE = /Trident/.test(navigator.userAgent) ||\n /Edge\\/\\d./i.test(navigator.userAgent);\n\n const importSelector = 'link[rel=import]';\n\n // Used to disable loading of resources.\n const importDisableType = 'import-disable';\n\n const disabledLinkSelector = `link[rel=stylesheet][href][type=${importDisableType}]`;\n\n const importDependenciesSelector = `${importSelector}, ${disabledLinkSelector},\n style:not([type]), link[rel=stylesheet][href]:not([type]),\n script:not([type]), script[type=\"application/javascript\"],\n script[type=\"text/javascript\"]`;\n\n const importDependencyAttr = 'import-dependency';\n\n const rootImportSelector = `${importSelector}:not(${importDependencyAttr})`;\n\n const pendingScriptsSelector = `script[${importDependencyAttr}]`;\n\n const pendingStylesSelector = `style[${importDependencyAttr}],\n link[rel=stylesheet][${importDependencyAttr}]`;\n\n /**\n * Importer will:\n * - load any linked import documents (with deduping)\n * - whenever an import is loaded, prompt the parser to try to parse\n * - observe imported documents for new elements (these are handled via the\n * dynamic importer)\n */\n class Importer {\n constructor() {\n this.documents = {};\n // Used to keep track of pending loads, so that flattening and firing of\n // events can be done when all resources are ready.\n this.inflight = 0;\n this.dynamicImportsMO = new MutationObserver(m => this.handleMutations(m));\n // 1. Load imports contents\n // 2. Assign them to first import links on the document\n // 3. Wait for import styles & scripts to be done loading/running\n // 4. Fire load/error events\n whenDocumentReady(() => {\n // Observe changes on .\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.loadImports(document);\n });\n }\n\n /**\n * @param {!(HTMLDocument|DocumentFragment|Element)} doc\n */\n loadImports(doc) {\n const links = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = links.length; i < l; i++) {\n this.loadImport(links[i]);\n }\n this.processImportsIfLoadingDone();\n }\n\n /**\n * @param {!HTMLLinkElement} link\n */\n loadImport(link) {\n const url = link.href;\n // This resource is already being handled by another import.\n if (this.documents[url] !== undefined) {\n // If import is already loaded, we can safely associate it to the link\n // and fire the load/error event.\n const imp = this.documents[url];\n if (imp && imp['__loaded']) {\n link.import = imp;\n this.fireEventIfNeeded(link);\n }\n return;\n }\n this.inflight++;\n // Mark it as pending to notify others this url is being loaded.\n this.documents[url] = 'pending';\n Xhr.load(url, (resource, redirectedUrl) => {\n const doc = this.makeDocument(resource, redirectedUrl || url);\n this.documents[url] = doc;\n this.inflight--;\n // Load subtree.\n this.loadImports(doc);\n }, () => {\n // If load fails, handle error.\n this.documents[url] = null;\n this.inflight--;\n this.processImportsIfLoadingDone();\n });\n }\n\n /**\n * Creates a new document containing resource and normalizes urls accordingly.\n * @param {string=} resource\n * @param {string=} url\n * @return {!DocumentFragment}\n */\n makeDocument(resource, url) {\n if (!resource) {\n return document.createDocumentFragment();\n }\n\n if (isIE) {\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order. We disable the loading by\n // setting the type before setting innerHTML to avoid loading\n // resources twice.\n resource = resource.replace(STYLESHEET_REGEXP, (match, p1, p2) => {\n if (match.indexOf('type=') === -1) {\n return `${p1} type=${importDisableType} ${p2}`;\n }\n return match;\n });\n }\n\n let content;\n const template = /** @type {!HTMLTemplateElement} */\n (document.createElement('template'));\n template.innerHTML = resource;\n if (template.content) {\n // This creates issues in Safari10 when used with shadydom (see #12).\n content = template.content;\n } else {\n // not supported, create fragment and move content into it.\n content = document.createDocumentFragment();\n while (template.firstChild) {\n content.appendChild(template.firstChild);\n }\n }\n\n // Support in imported docs. Resolve url and remove its href.\n const baseEl = content.querySelector('base');\n if (baseEl) {\n url = Path.replaceAttrUrl(baseEl.getAttribute('href'), url);\n baseEl.removeAttribute('href');\n }\n\n // This is specific to users of (Polymer).\n // TODO(valdrin) remove this when Polymer uses importForElement.\n const s$ = content.querySelectorAll('dom-module');\n for (let i = 0, s; i < s$.length && (s = s$[i]); i++) {\n s.setAttribute('assetpath',\n Path.replaceAttrUrl(s.getAttribute('assetpath') || '', url));\n }\n\n const n$ = /** @type {!NodeList} */\n (content.querySelectorAll(importDependenciesSelector));\n // For source map hints.\n let inlineScriptIndex = 0;\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n // Listen for load/error events, then fix urls.\n whenElementLoaded(n);\n Path.fixUrls(n, url);\n // Mark for easier selectors.\n n.setAttribute(importDependencyAttr, '');\n // Generate source map hints for inline scripts.\n if (n.localName === 'script' && !n.src && n.textContent) {\n const num = inlineScriptIndex ? `-${inlineScriptIndex}` : '';\n const content = n.textContent + `\\n//# sourceURL=${url}${num}.js\\n`;\n // We use the src attribute so it triggers load/error events, and it's\n // easier to capture errors (e.g. parsing) like this.\n n.setAttribute('src', 'data:text/javascript;charset=utf-8,' + encodeURIComponent(content));\n n.textContent = '';\n inlineScriptIndex++;\n }\n }\n Path.fixUrlsInTemplates(content, url);\n return content;\n }\n\n /**\n * Waits for loaded imports to finish loading scripts and styles, then fires\n * the load/error events.\n */\n processImportsIfLoadingDone() {\n // Wait until all resources are ready, then load import resources.\n if (this.inflight) {\n return;\n }\n\n // Stop observing, flatten & load resource, then restart observing .\n this.dynamicImportsMO.disconnect();\n this.flatten(document);\n // We wait for styles to load, and at the same time we execute the scripts,\n // then fire the load/error events for imports to have faster whenReady\n // callback execution.\n // NOTE: This is different for native behavior where scripts would be\n // executed after the styles before them are loaded.\n // To achieve that, we could select pending styles and scripts in the\n // document and execute them sequentially in their dom order.\n let scriptsOk = false,\n stylesOk = false;\n const onLoadingDone = () => {\n if (stylesOk && scriptsOk) {\n // Restart observing.\n this.dynamicImportsMO.observe(document.head, {\n childList: true,\n subtree: true\n });\n this.fireEvents();\n }\n }\n this.waitForStyles(() => {\n stylesOk = true;\n onLoadingDone();\n });\n this.runScripts(() => {\n scriptsOk = true;\n onLoadingDone();\n });\n }\n\n /**\n * @param {!HTMLDocument} doc\n */\n flatten(doc) {\n const n$ = /** @type {!NodeList} */\n (doc.querySelectorAll(importSelector));\n for (let i = 0, l = n$.length, n; i < l && (n = n$[i]); i++) {\n const imp = this.documents[n.href];\n n.import = /** @type {!Document} */ (imp);\n if (imp && imp.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // We set the .import to be the link itself, and update its readyState.\n // Other links with the same href will point to this link.\n this.documents[n.href] = n;\n n.readyState = 'loading';\n // Suppress Closure warning about incompatible subtype assignment.\n ( /** @type {!HTMLElement} */ (n).import = n);\n this.flatten(imp);\n n.appendChild(imp);\n }\n }\n }\n\n /**\n * Replaces all the imported scripts with a clone in order to execute them.\n * Updates the `currentScript`.\n * @param {!function()} callback\n */\n runScripts(callback) {\n const s$ = document.querySelectorAll(pendingScriptsSelector);\n const l = s$.length;\n const cloneScript = i => {\n if (i < l) {\n // The pending scripts have been generated through innerHTML and\n // browsers won't execute them for security reasons. We cannot use\n // s.cloneNode(true) either, the only way to run the script is manually\n // creating a new element and copying its attributes.\n const s = s$[i];\n const clone = /** @type {!HTMLScriptElement} */\n (document.createElement('script'));\n // Remove import-dependency attribute to avoid double cloning.\n s.removeAttribute(importDependencyAttr);\n for (let j = 0, ll = s.attributes.length; j < ll; j++) {\n clone.setAttribute(s.attributes[j].name, s.attributes[j].value);\n }\n // Update currentScript and replace original with clone script.\n currentScript = clone;\n s.parentNode.replaceChild(clone, s);\n whenElementLoaded(clone, () => {\n currentScript = null;\n cloneScript(i + 1);\n });\n } else {\n callback();\n }\n };\n cloneScript(0);\n }\n\n /**\n * Waits for all the imported stylesheets/styles to be loaded.\n * @param {!function()} callback\n */\n waitForStyles(callback) {\n const s$ = /** @type {!NodeList} */\n (document.querySelectorAll(pendingStylesSelector));\n let pending = s$.length;\n if (!pending) {\n callback();\n return;\n }\n // should be appended to . Not doing so\n // in IE/Edge breaks the cascading order\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10472273/\n // If there is one imported, we must move all imported\n // links and styles to .\n const needsMove = isIE && !!document.querySelector(disabledLinkSelector);\n for (let i = 0, l = s$.length, s; i < l && (s = s$[i]); i++) {\n // Listen for load/error events, remove selector once is done loading.\n whenElementLoaded(s, () => {\n s.removeAttribute(importDependencyAttr);\n if (--pending === 0) {\n callback();\n }\n });\n // Check if was already moved to head, to handle the case where the element\n // has already been moved but it is still loading.\n if (needsMove && s.parentNode !== document.head) {\n let rootImport = importForElement(s);\n while (rootImport && importForElement(rootImport)) {\n rootImport = importForElement(rootImport);\n }\n // Replace the element we're about to move with a placeholder.\n // NOTE: we first have to append the element to the new parent, then\n // we can put the placeholder at its place, otherwise load/error events\n // seem to be fired too early.\n const parent = s.parentNode,\n next = s.nextSibling,\n placeholder = document.createElement(s.localName);\n // Add reference of the moved element.\n placeholder['__appliedElement'] = s;\n // Disable this from appearing in document.styleSheets.\n placeholder.setAttribute('type', 'import-placeholder');\n // First, re-parent the element...\n if (rootImport.parentNode === document.head) {\n document.head.insertBefore(s, rootImport);\n } else {\n document.head.appendChild(s);\n }\n // ...and then, insert the placeholder at the right place.\n parent.insertBefore(placeholder, next);\n // Enable the loading of .\n s.removeAttribute('type');\n }\n }\n }\n\n /**\n * Fires load/error events for imports in the right order .\n */\n fireEvents() {\n const n$ = /** @type {!NodeList} */\n (document.querySelectorAll(importSelector));\n // Inverse order to have events firing bottom-up.\n for (let i = n$.length - 1, n; i >= 0 && (n = n$[i]); i--) {\n this.fireEventIfNeeded(n);\n }\n }\n\n /**\n * Fires load/error event for the import if this wasn't done already.\n * @param {!HTMLLinkElement} link\n */\n fireEventIfNeeded(link) {\n // Don't fire twice same event.\n if (!link['__loaded']) {\n link['__loaded'] = true;\n // Update link's import readyState.\n link.import && (link.import.readyState = 'complete');\n const eventType = link.import ? 'load' : 'error';\n link.dispatchEvent(newCustomEvent(eventType, {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }));\n }\n }\n\n /**\n * @param {Array} mutations\n */\n handleMutations(mutations) {\n for (let i = 0; i < mutations.length; i++) {\n const m = mutations[i];\n if (!m.addedNodes) {\n continue;\n }\n for (let ii = 0; ii < m.addedNodes.length; ii++) {\n const link = m.addedNodes[ii];\n if (!link || link.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n // NOTE: added scripts are not updating currentScript in IE.\n // TODO add test w/ script & stylesheet maybe\n if (isImportLink(link)) {\n this.loadImport( /** @type {!HTMLLinkElement} */ (link));\n } else {\n this.loadImports( /** @type {!Element} */ (link));\n }\n }\n }\n }\n }\n\n /**\n * @param {!Node} node\n * @return {boolean}\n */\n const isImportLink = node => {\n return node.nodeType === Node.ELEMENT_NODE && node.localName === 'link' &&\n ( /** @type {!HTMLLinkElement} */ (node).rel === 'import');\n };\n\n /**\n * Waits for an element to finish loading. If already done loading, it will\n * mark the element accordingly.\n * @param {!(HTMLLinkElement|HTMLScriptElement|HTMLStyleElement)} element\n * @param {function()=} callback\n */\n const whenElementLoaded = (element, callback) => {\n if (element['__loaded']) {\n callback && callback();\n } else if (element.localName === 'script' && !element.src) {\n // Inline scripts don't trigger load/error events, consider them already loaded.\n element['__loaded'] = true;\n callback && callback();\n } else {\n const onLoadingDone = event => {\n element.removeEventListener(event.type, onLoadingDone);\n element['__loaded'] = true;\n callback && callback();\n };\n element.addEventListener('load', onLoadingDone);\n // NOTE: We listen only for load events in IE/Edge, because in IE/Edge\n // \n\n*/\n\nlet ShadyCSS$1 = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS$1._elementsHaveApplied) {\n ShadyCSS$1.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS$1._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS$1._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/*\n * Polyfills loaded: None\n * Used in: Chrome\n */\n\n// TODO: This needs to not exist at all.\n\n// TODO(notwaldorf): Remove after this is addressed:\n// https://github.com/webcomponents/shadycss/issues/46\n\n}());\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n/*\nExtremely simple css parser. Intended to be not more than what we need\nand definitely not necessarily correct =).\n*/\n\n'use strict';\n\n// given a string of css, return a simple rule tree\nexport function parse(text) {\n text = clean(text);\n return parseCss(lex(text), text);\n}\n\n// remove stuff we don't care about that may hinder parsing\nfunction clean(cssText) {\n return cssText.replace(RX.comments, '').replace(RX.port, '');\n}\n\n// super simple {...} lexer that returns a node tree\nfunction lex(text) {\n let root = {\n start: 0,\n end: text.length\n };\n let n = root;\n for (let i = 0, l = text.length; i < l; i++) {\n if (text[i] === OPEN_BRACE) {\n if (!n.rules) {\n n.rules = [];\n }\n let p = n;\n let previous = p.rules[p.rules.length - 1];\n n = {\n start: i + 1,\n parent: p,\n previous: previous\n };\n p.rules.push(n);\n } else if (text[i] === CLOSE_BRACE) {\n n.end = i + 1;\n n = n.parent || root;\n }\n }\n return root;\n}\n\n// add selectors/cssText to node tree\nfunction parseCss(node, text) {\n let t = text.substring(node.start, node.end - 1);\n node.parsedCssText = node.cssText = t.trim();\n if (node.parent) {\n let ss = node.previous ? node.previous.end : node.parent.start;\n t = text.substring(ss, node.start - 1);\n t = _expandUnicodeEscapes(t);\n t = t.replace(RX.multipleSpaces, ' ');\n // TODO(sorvell): ad hoc; make selector include only after last ;\n // helps with mixin syntax\n t = t.substring(t.lastIndexOf(';') + 1);\n let s = node.parsedSelector = node.selector = t.trim();\n node.atRule = (s.indexOf(AT_START) === 0);\n // note, support a subset of rule types...\n if (node.atRule) {\n if (s.indexOf(MEDIA_START) === 0) {\n node.type = types.MEDIA_RULE;\n } else if (s.match(RX.keyframesRule)) {\n node.type = types.KEYFRAMES_RULE;\n node.keyframesName =\n node.selector.split(RX.multipleSpaces).pop();\n }\n } else {\n if (s.indexOf(VAR_START) === 0) {\n node.type = types.MIXIN_RULE;\n } else {\n node.type = types.STYLE_RULE;\n }\n }\n }\n let r$ = node.rules;\n if (r$) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n parseCss(r, text);\n }\n }\n return node;\n}\n\n// conversion of sort unicode escapes with spaces like `\\33 ` (and longer) into\n// expanded form that doesn't require trailing space `\\000033`\nfunction _expandUnicodeEscapes(s) {\n return s.replace(/\\\\([0-9a-f]{1,6})\\s/gi, function() {\n let code = arguments[1],\n repeat = 6 - code.length;\n while (repeat--) {\n code = '0' + code;\n }\n return '\\\\' + code;\n });\n}\n\n// stringify parsed css.\nexport function stringify(node, preserveProperties, text) {\n text = text || '';\n // calc rule cssText\n let cssText = '';\n if (node.cssText || node.rules) {\n let r$ = node.rules;\n if (r$ && !_hasMixinRules(r$)) {\n for (let i = 0, l = r$.length, r;\n (i < l) && (r = r$[i]); i++) {\n cssText = stringify(r, preserveProperties, cssText);\n }\n } else {\n cssText = preserveProperties ? node.cssText :\n removeCustomProps(node.cssText);\n cssText = cssText.trim();\n if (cssText) {\n cssText = ' ' + cssText + '\\n';\n }\n }\n }\n // emit rule if there is cssText\n if (cssText) {\n if (node.selector) {\n text += node.selector + ' ' + OPEN_BRACE + '\\n';\n }\n text += cssText;\n if (node.selector) {\n text += CLOSE_BRACE + '\\n\\n';\n }\n }\n return text;\n}\n\nfunction _hasMixinRules(rules) {\n return rules[0].selector.indexOf(VAR_START) === 0;\n}\n\nfunction removeCustomProps(cssText) {\n cssText = removeCustomPropAssignment(cssText);\n return removeCustomPropApply(cssText);\n}\n\nexport function removeCustomPropAssignment(cssText) {\n return cssText\n .replace(RX.customProp, '')\n .replace(RX.mixinProp, '');\n}\n\nfunction removeCustomPropApply(cssText) {\n return cssText\n .replace(RX.mixinApply, '')\n .replace(RX.varApply, '');\n}\n\nexport let types = {\n STYLE_RULE: 1,\n KEYFRAMES_RULE: 7,\n MEDIA_RULE: 4,\n MIXIN_RULE: 1000\n}\n\nlet OPEN_BRACE = '{';\nlet CLOSE_BRACE = '}';\n\n// helper regexp's\nlet RX = {\n comments: /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n port: /@import[^;]*;/gim,\n customProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\\n]|$)/gim,\n mixinProp: /(?:^[^;\\-\\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\\n]|$)?/gim,\n mixinApply: /@apply\\s*\\(?[^);]*\\)?\\s*(?:[;\\n]|$)?/gim,\n varApply: /[^;:]*?:[^;]*?var\\([^;]*\\)(?:[;\\n]|$)?/gim,\n keyframesRule: /^@[^\\s]*keyframes/,\n multipleSpaces: /\\s+/g\n}\n\nlet VAR_START = '--';\nlet MEDIA_START = '@media';\nlet AT_START = '@';\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport let nativeShadow = !(window.ShadyDOM && window.ShadyDOM.inUse);\n// chrome 49 has semi-working css vars, check if box-shadow works\n// safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782\nexport let nativeCssVariables = (!navigator.userAgent.match('AppleWebKit/601') &&\nwindow.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)'));\n\n// experimental support for native @apply\nfunction detectNativeApply() {\n let style = document.createElement('style');\n style.textContent = '.foo { @apply --foo }';\n document.head.appendChild(style);\n let nativeCssApply = (style.sheet.cssRules[0].cssText.indexOf('apply') >= 0);\n document.head.removeChild(style);\n return nativeCssApply;\n}\n\nexport let nativeCssApply = false && detectNativeApply();\n\nfunction parseSettings(settings) {\n if (settings) {\n nativeCssVariables = nativeCssVariables && !settings.shimcssproperties;\n nativeShadow = nativeShadow && !settings.shimshadow;\n }\n}\n\nif (window.ShadyCSS) {\n parseSettings(window.ShadyCSS);\n} else if (window.WebComponents) {\n parseSettings(window.WebComponents.flags);\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow, nativeCssVariables} from './style-settings'\nimport {parse, stringify, types} from './css-parse'\n\nexport function toCssText (rules, callback) {\n if (typeof rules === 'string') {\n rules = parse(rules);\n }\n if (callback) {\n forEachRule(rules, callback);\n }\n return stringify(rules, nativeCssVariables);\n}\n\nexport function rulesForStyle(style) {\n if (!style.__cssRules && style.textContent) {\n style.__cssRules = parse(style.textContent);\n }\n return style.__cssRules;\n}\n\n// Tests if a rule is a keyframes selector, which looks almost exactly\n// like a normal selector but is not (it has nothing to do with scoping\n// for example).\nexport function isKeyframesSelector(rule) {\n return rule.parent &&\n rule.parent.type === types.KEYFRAMES_RULE;\n}\n\nexport function forEachRule(node, styleRuleCallback, keyframesRuleCallback, onlyActiveRules) {\n if (!node) {\n return;\n }\n let skipRules = false;\n if (onlyActiveRules) {\n if (node.type === types.MEDIA_RULE) {\n let matchMedia = node.selector.match(rx.MEDIA_MATCH);\n if (matchMedia) {\n // if rule is a non matching @media rule, skip subrules\n if (!window.matchMedia(matchMedia[1]).matches) {\n skipRules = true;\n }\n }\n }\n }\n if (node.type === types.STYLE_RULE) {\n styleRuleCallback(node);\n } else if (keyframesRuleCallback &&\n node.type === types.KEYFRAMES_RULE) {\n keyframesRuleCallback(node);\n } else if (node.type === types.MIXIN_RULE) {\n skipRules = true;\n }\n let r$ = node.rules;\n if (r$ && !skipRules) {\n for (let i=0, l=r$.length, r; (i+~])'\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {removeCustomPropAssignment} from './css-parse'\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleInfo from './style-info'\n\n// TODO: dedupe with shady\nconst p = window.Element.prototype;\nconst matchesSelector = p.matches || p.matchesSelector ||\n p.mozMatchesSelector || p.msMatchesSelector ||\n p.oMatchesSelector || p.webkitMatchesSelector;\n\nconst IS_IE = navigator.userAgent.match('Trident');\n\nconst XSCOPE_NAME = 'x-scope';\n\nclass StyleProperties {\n get XSCOPE_NAME() {\n return XSCOPE_NAME;\n }\n // decorates styles with rule info and returns an array of used style\n // property names\n decorateStyles(rules) {\n let self = this, props = {}, keyframes = [], ruleIndex = 0;\n StyleUtil.forEachRule(rules, function(rule) {\n self.decorateRule(rule);\n // mark in-order position of ast rule in styles block, used for cache key\n rule.index = ruleIndex++;\n self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);\n }, function onKeyframesRule(rule) {\n keyframes.push(rule);\n });\n // Cache all found keyframes rules for later reference:\n rules._keyframes = keyframes;\n // return this list of property names *consumes* in these styles.\n let names = [];\n for (let i in props) {\n names.push(i);\n }\n return names;\n }\n\n // decorate a single rule with property info\n decorateRule(rule) {\n if (rule.propertyInfo) {\n return rule.propertyInfo;\n }\n let info = {}, properties = {};\n let hasProperties = this.collectProperties(rule, properties);\n if (hasProperties) {\n info.properties = properties;\n // TODO(sorvell): workaround parser seeing mixins as additional rules\n rule.rules = null;\n }\n info.cssText = this.collectCssText(rule);\n rule.propertyInfo = info;\n return info;\n }\n\n // collects the custom properties from a rule's cssText\n collectProperties(rule, properties) {\n let info = rule.propertyInfo;\n if (info) {\n if (info.properties) {\n Object.assign(properties, info.properties);\n return true;\n }\n } else {\n let m, rx = StyleUtil.rx.VAR_ASSIGN;\n let cssText = rule.parsedCssText;\n let value;\n let any;\n while ((m = rx.exec(cssText))) {\n // note: group 2 is var, 3 is mixin\n value = (m[2] || m[3]).trim();\n // value of 'inherit' or 'unset' is equivalent to not setting the property here\n if (value !== 'inherit' || value !== 'unset') {\n properties[m[1].trim()] = value;\n }\n any = true;\n }\n return any;\n }\n\n }\n\n // returns cssText of properties that consume variables/mixins\n collectCssText(rule) {\n return this.collectConsumingCssText(rule.parsedCssText);\n }\n\n // NOTE: we support consumption inside mixin assignment\n // but not production, so strip out {...}\n collectConsumingCssText(cssText) {\n return cssText.replace(StyleUtil.rx.BRACKETED, '')\n .replace(StyleUtil.rx.VAR_ASSIGN, '');\n }\n\n collectPropertiesInCssText(cssText, props) {\n let m;\n while ((m = StyleUtil.rx.VAR_CONSUMED.exec(cssText))) {\n let name = m[1];\n // This regex catches all variable names, and following non-whitespace char\n // If next char is not ':', then variable is a consumer\n if (m[2] !== ':') {\n props[name] = true;\n }\n }\n }\n\n // turns custom properties into realized values.\n reify(props) {\n // big perf optimization here: reify only *own* properties\n // since this object has __proto__ of the element's scope properties\n let names = Object.getOwnPropertyNames(props);\n for (let i=0, n; i < names.length; i++) {\n n = names[i];\n props[n] = this.valueForProperty(props[n], props);\n }\n }\n\n // given a property value, returns the reified value\n // a property value may be:\n // (1) a literal value like: red or 5px;\n // (2) a variable value like: var(--a), var(--a, red), or var(--a, --b) or\n // var(--a, var(--b));\n // (3) a literal mixin value like { properties }. Each of these properties\n // can have values that are: (a) literal, (b) variables, (c) @apply mixins.\n valueForProperty(property, props) {\n // case (1) default\n // case (3) defines a mixin and we have to reify the internals\n if (property) {\n if (property.indexOf(';') >=0) {\n property = this.valueForProperties(property, props);\n } else {\n // case (2) variable\n let self = this;\n let fn = function(prefix, value, fallback, suffix) {\n if (!value) {\n return prefix + suffix;\n }\n let propertyValue = self.valueForProperty(props[value], props);\n // if value is \"initial\", then the variable should be treated as unset\n if (!propertyValue || propertyValue === 'initial') {\n // fallback may be --a or var(--a) or literal\n propertyValue = self.valueForProperty(props[fallback] || fallback, props) ||\n fallback;\n } else if (propertyValue === 'apply-shim-inherit') {\n // CSS build will replace `inherit` with `apply-shim-inherit`\n // for use with native css variables.\n // Since we have full control, we can use `inherit` directly.\n propertyValue = 'inherit';\n }\n return prefix + (propertyValue || '') + suffix;\n };\n property = StyleUtil.processVariableAndFallback(property, fn);\n }\n }\n return property && property.trim() || '';\n }\n\n // note: we do not yet support mixin within mixin\n valueForProperties(property, props) {\n let parts = property.split(';');\n for (let i=0, p, m; i *' || parsedSelector === 'html');\n let isHost = parsedSelector.indexOf(':host') === 0 && !isRoot;\n // build info is either in scope (when scope is an element) or in the style\n // when scope is the default scope; note: this allows default scope to have\n // mixed mode built and unbuilt styles.\n if (cssBuild === 'shady') {\n // :root -> x-foo > *.x-foo for elements and html for custom-style\n isRoot = parsedSelector === (hostScope + ' > *.' + hostScope) || parsedSelector.indexOf('html') !== -1;\n // :host -> x-foo for elements, but sub-rules have .x-foo in them\n isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;\n }\n if (cssBuild === 'shadow') {\n isRoot = parsedSelector === ':host > *' || parsedSelector === 'html';\n isHost = isHost && !isRoot;\n }\n if (!isRoot && !isHost) {\n return;\n }\n let selectorToMatch = hostScope;\n if (isHost) {\n // need to transform :host under ShadowDOM because `:host` does not work with `matches`\n if (nativeShadow && !rule.transformedSelector) {\n // transform :host into a matchable selector\n rule.transformedSelector =\n StyleTransformer._transformRuleCss(\n rule,\n StyleTransformer._transformComplexSelector,\n StyleTransformer._calcElementScope(scope.is),\n hostScope\n );\n }\n selectorToMatch = rule.transformedSelector || hostScope;\n }\n callback({\n selector: selectorToMatch,\n isHost: isHost,\n isRoot: isRoot\n });\n }\n\n hostAndRootPropertiesForScope(scope, rules) {\n let hostProps = {}, rootProps = {}, self = this;\n // note: active rules excludes non-matching @media rules\n let cssBuild = rules && rules.__cssBuild;\n StyleUtil.forEachRule(rules, function(rule) {\n // if scope is StyleDefaults, use _element for matchesSelector\n self.whenHostOrRootRule(scope, rule, cssBuild, function(info) {\n let element = scope._element || scope;\n if (matchesSelector.call(element, info.selector)) {\n if (info.isHost) {\n self.collectProperties(rule, hostProps);\n } else {\n self.collectProperties(rule, rootProps);\n }\n }\n });\n }, null, true);\n return {rootProps: rootProps, hostProps: hostProps};\n }\n\n transformStyles(element, properties, scopeSelector) {\n let self = this;\n let hostSelector = StyleTransformer\n ._calcHostScope(element.is, element.extends);\n let rxHostSelector = element.extends ?\n '\\\\' + hostSelector.slice(0, -1) + '\\\\]' :\n hostSelector;\n let hostRx = new RegExp(StyleUtil.rx.HOST_PREFIX + rxHostSelector +\n StyleUtil.rx.HOST_SUFFIX);\n let rules = StyleInfo.get(element).styleRules;\n let keyframeTransforms =\n this._elementKeyframeTransforms(element, rules, scopeSelector);\n return StyleTransformer.elementStyles(element, rules, function(rule) {\n self.applyProperties(rule, properties);\n if (!nativeShadow &&\n !StyleUtil.isKeyframesSelector(rule) &&\n rule.cssText) {\n // NOTE: keyframe transforms only scope munge animation names, so it\n // is not necessary to apply them in ShadowDOM.\n self.applyKeyframeTransforms(rule, keyframeTransforms);\n self._scopeSelector(rule, hostRx, hostSelector, scopeSelector);\n }\n });\n }\n\n _elementKeyframeTransforms(element, rules, scopeSelector) {\n let keyframesRules = rules._keyframes;\n let keyframeTransforms = {};\n if (!nativeShadow && keyframesRules) {\n // For non-ShadowDOM, we transform all known keyframes rules in\n // advance for the current scope. This allows us to catch keyframes\n // rules that appear anywhere in the stylesheet:\n for (let i = 0, keyframesRule = keyframesRules[i];\n i < keyframesRules.length;\n keyframesRule = keyframesRules[++i]) {\n this._scopeKeyframes(keyframesRule, scopeSelector);\n keyframeTransforms[keyframesRule.keyframesName] =\n this._keyframesRuleTransformer(keyframesRule);\n }\n }\n return keyframeTransforms;\n }\n\n // Generate a factory for transforming a chunk of CSS text to handle a\n // particular scoped keyframes rule.\n _keyframesRuleTransformer(keyframesRule) {\n return function(cssText) {\n return cssText.replace(\n keyframesRule.keyframesNameRx,\n keyframesRule.transformedKeyframesName);\n };\n }\n\n // Transforms `@keyframes` names to be unique for the current host.\n // Example: @keyframes foo-anim -> @keyframes foo-anim-x-foo-0\n _scopeKeyframes(rule, scopeId) {\n rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');\n rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n rule.selector = rule.transformedSelector.replace(\n rule.keyframesName, rule.transformedKeyframesName);\n }\n\n // Strategy: x scope shim a selector e.g. to scope `.x-foo-42` (via classes):\n // non-host selector: .a.x-foo -> .x-foo-42 .a.x-foo\n // host selector: x-foo.wide -> .x-foo-42.wide\n // note: we use only the scope class (.x-foo-42) and not the hostSelector\n // (x-foo) to scope :host rules; this helps make property host rules\n // have low specificity. They are overrideable by class selectors but,\n // unfortunately, not by type selectors (e.g. overriding via\n // `.special` is ok, but not by `x-foo`).\n _scopeSelector(rule, hostRx, hostSelector, scopeId) {\n rule.transformedSelector = rule.transformedSelector || rule.selector;\n let selector = rule.transformedSelector;\n let scope = '.' + scopeId;\n let parts = selector.split(',');\n for (let i=0, l=parts.length, p; (i elements to co-operate with ShadyCSS\n\nExample:\n\n \n\n*/\n\n'use strict';\n\nlet ShadyCSS = window.ShadyCSS;\n\nlet enqueued = false;\n\nlet customStyles = [];\n\nlet hookFn = null;\n\n/*\nIf a page only has elements, it will flash unstyled content,\nas all the instances will boot asynchronously after page load.\n\nCalling ShadyCSS.updateStyles() will force the work to happen synchronously\n*/\nfunction enqueueDocumentValidation() {\n if (enqueued) {\n return;\n }\n enqueued = true;\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(validateDocument);\n } else if (document.readyState === 'complete') {\n validateDocument();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n validateDocument();\n }\n });\n }\n}\n\nfunction validateDocument() {\n requestAnimationFrame(() => {\n if (enqueued || ShadyCSS._elementsHaveApplied) {\n ShadyCSS.updateStyles();\n }\n enqueued = false;\n });\n}\n\nclass CustomStyle extends HTMLElement {\n static get _customStyles() {\n return customStyles;\n }\n static get processHook() {\n return hookFn;\n }\n static set processHook(fn) {\n hookFn = fn;\n }\n static get _documentDirty() {\n return enqueued;\n }\n static findStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (!c._style) {\n let style = c.querySelector('style');\n if (!style) {\n continue;\n }\n // HTMLImports polyfill may have cloned the style into the main document,\n // which is referenced with __appliedElement.\n // Also, we must copy over the attributes.\n if (style.__appliedElement) {\n for (let i = 0; i < style.attributes.length; i++) {\n let attr = style.attributes[i];\n style.__appliedElement.setAttribute(attr.name, attr.value);\n }\n }\n c._style = style.__appliedElement || style;\n if (hookFn) {\n hookFn(c._style);\n }\n ShadyCSS._transformCustomStyleForDocument(c._style);\n }\n }\n }\n static _revalidateApplyShim() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._revalidateApplyShim(c._style);\n }\n }\n }\n static applyStyles() {\n for (let i = 0; i < customStyles.length; i++) {\n let c = customStyles[i];\n if (c._style) {\n ShadyCSS._applyCustomStyleToDocument(c._style);\n }\n }\n enqueued = false;\n }\n constructor() {\n super();\n customStyles.push(this);\n enqueueDocumentValidation();\n }\n}\n\nwindow['CustomStyle'] = CustomStyle;\nwindow.customElements.define('custom-style', CustomStyle);","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport * as StyleUtil from './style-util'\nimport {nativeShadow} from './style-settings'\n\n/* Transforms ShadowDOM styling into ShadyDOM styling\n\n* scoping:\n\n * elements in scope get scoping selector class=\"x-foo-scope\"\n * selectors re-written as follows:\n\n div button -> div.x-foo-scope button.x-foo-scope\n\n* :host -> scopeName\n\n* :host(...) -> scopeName...\n\n* ::slotted(...) -> scopeName > ...\n\n* ...:dir(ltr|rtl) -> [dir=\"ltr|rtl\"] ..., ...[dir=\"ltr|rtl\"]\n\n* :host(:dir[rtl]) -> scopeName:dir(rtl) -> [dir=\"rtl\"] scopeName, scopeName[dir=\"rtl\"]\n\n*/\nconst SCOPE_NAME = 'style-scope';\n\nclass StyleTransformer {\n get SCOPE_NAME() {\n return SCOPE_NAME;\n }\n // Given a node and scope name, add a scoping class to each node\n // in the tree. This facilitates transforming css into scoped rules.\n dom(node, scope, shouldRemoveScope) {\n // one time optimization to skip scoping...\n if (node.__styleScoped) {\n node.__styleScoped = null;\n } else {\n this._transformDom(node, scope || '', shouldRemoveScope);\n }\n }\n\n _transformDom(node, selector, shouldRemoveScope) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.element(node, selector, shouldRemoveScope);\n }\n let c$ = (node.localName === 'template') ?\n (node.content || node._content).childNodes :\n node.children || node.childNodes;\n if (c$) {\n for (let i=0; i `:${type}(${inner.replace(/\\s/g, '')})`);\n selector = selector.replace(SLOTTED_START, `${HOST} $1`);\n selector = selector.replace(SIMPLE_SELECTOR_SEP, (m, c, s) => {\n if (!stop) {\n let info = this._transformCompoundSelector(s, c, scope, hostScope);\n stop = stop || info.stop;\n c = info.combinator;\n s = info.value;\n }\n return c + s;\n });\n return selector;\n }\n\n _transformCompoundSelector(selector, combinator, scope, hostScope) {\n // replace :host with host scoping class\n let slottedIndex = selector.indexOf(SLOTTED);\n if (selector.indexOf(HOST) >= 0) {\n selector = this._transformHostSelector(selector, hostScope);\n // replace other selectors with scoping class\n } else if (slottedIndex !== 0) {\n selector = scope ? this._transformSimpleSelector(selector, scope) :\n selector;\n }\n // mark ::slotted() scope jump to replace with descendant selector + arg\n // also ignore left-side combinator\n let slotted = false;\n if (slottedIndex >= 0) {\n combinator = '';\n slotted = true;\n }\n // process scope jumping selectors up to the scope jump and then stop\n let stop;\n if (slotted) {\n stop = true;\n if (slotted) {\n // .zonk ::slotted(.foo) -> .zonk.scope > .foo\n selector = selector.replace(SLOTTED_PAREN, (m, paren) => ` > ${paren}`);\n }\n }\n selector = selector.replace(DIR_PAREN, (m, before, dir) =>\n `[dir=\"${dir}\"] ${before}, ${before}[dir=\"${dir}\"]`);\n return {value: selector, combinator, stop};\n }\n\n _transformSimpleSelector(selector, scope) {\n let p$ = selector.split(PSEUDO_PREFIX);\n p$[0] += scope;\n return p$.join(PSEUDO_PREFIX);\n }\n\n // :host(...) -> scopeName...\n _transformHostSelector(selector, hostScope) {\n let m = selector.match(HOST_PAREN);\n let paren = m && m[2].trim() || '';\n if (paren) {\n if (!paren[0].match(SIMPLE_SELECTOR_PREFIX)) {\n // paren starts with a type selector\n let typeSelector = paren.split(SIMPLE_SELECTOR_PREFIX)[0];\n // if the type selector is our hostScope then avoid pre-pending it\n if (typeSelector === hostScope) {\n return paren;\n // otherwise, this selector should not match in this scope so\n // output a bogus selector.\n } else {\n return SELECTOR_NO_MATCH;\n }\n } else {\n // make sure to do a replace here to catch selectors like:\n // `:host(.foo)::before`\n return selector.replace(HOST_PAREN, function(m, host, paren) {\n return hostScope + paren;\n });\n }\n // if no paren, do a straight :host replacement.\n // TODO(sorvell): this should not strictly be necessary but\n // it's needed to maintain support for `:host[foo]` type selectors\n // which have been improperly used under Shady DOM. This should be\n // deprecated.\n } else {\n return selector.replace(HOST, hostScope);\n }\n }\n\n documentRule(rule) {\n // reset selector in case this is redone.\n rule.selector = rule.parsedSelector;\n this.normalizeRootSelector(rule);\n this._transformRule(rule, this._transformDocumentSelector);\n }\n\n normalizeRootSelector(rule) {\n if (rule.selector === ROOT) {\n rule.selector = 'html';\n }\n }\n\n _transformDocumentSelector(selector) {\n return selector.match(SLOTTED) ?\n this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) :\n this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);\n }\n}\n\nlet NTH = /:(nth[-\\w]+)\\(([^)]+)\\)/;\nlet SCOPE_DOC_SELECTOR = `:not(.${SCOPE_NAME})`;\nlet COMPLEX_SELECTOR_SEP = ',';\nlet SIMPLE_SELECTOR_SEP = /(^|[\\s>+~]+)((?:\\[.+?\\]|[^\\s>+~=\\[])+)/g;\nlet SIMPLE_SELECTOR_PREFIX = /[[.:#*]/;\nlet HOST = ':host';\nlet ROOT = ':root';\nlet SLOTTED = '::slotted';\nlet SLOTTED_START = new RegExp(`^(${SLOTTED})`);\n// NOTE: this supports 1 nested () pair for things like\n// :host(:not([selected]), more general support requires\n// parsing which seems like overkill\nlet HOST_PAREN = /(:host)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\n// similar to HOST_PAREN\nlet SLOTTED_PAREN = /(?:::slotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))/;\nlet DIR_PAREN = /(.*):dir\\((?:(ltr|rtl))\\)/;\nlet CSS_CLASS_PREFIX = '.';\nlet PSEUDO_PREFIX = ':';\nlet CLASS = 'class';\nlet SELECTOR_NO_MATCH = 'should_not_match';\n\nexport default new StyleTransformer()","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nexport default {};\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport templateMap from './template-map'\n\nconst promise = Promise.resolve();\n\nexport default class StyleInfo {\n static get(node) {\n return node.__styleInfo;\n }\n static set(node, styleInfo) {\n node.__styleInfo = styleInfo;\n return styleInfo;\n }\n static invalidate(elementName) {\n if (templateMap[elementName]) {\n templateMap[elementName]._applyShimInvalid = true;\n }\n }\n /*\n the template is marked as `validating` for one microtask so that all instances\n found in the tree crawl of `applyStyle` will update themselves,\n but the template will only be updated once.\n */\n static startValidating(elementName) {\n const template = templateMap[elementName];\n if (!template._validating) {\n template._validating = true;\n promise.then(() => {\n template._applyShimInvalid = false;\n template._validating = false;\n });\n }\n }\n constructor(ast, placeholder, ownStylePropertyNames, elementName, typeExtension, cssBuild) {\n this.styleRules = ast || null;\n this.placeholder = placeholder || null;\n this.ownStylePropertyNames = ownStylePropertyNames || [];\n this.overrideStyleProperties = null;\n this.elementName = elementName || '';\n this.cssBuild = cssBuild || '';\n this.typeExtension = typeExtension || '';\n this.styleProperties = null;\n this.scopeSelector = null;\n this.customStyle = null;\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {applyStylePlaceHolder} from './style-util'\nimport {nativeShadow} from './style-settings'\n\nlet placeholderMap = {};\n\nconst ce = window.customElements;\nif (ce && !nativeShadow) {\n const origDefine = ce.define;\n ce.define = function(name, clazz, options) {\n placeholderMap[name] = applyStylePlaceHolder(name);\n return origDefine.call(ce, name, clazz, options);\n };\n}\n\nexport default placeholderMap;\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n/**\n * The apply shim simulates the behavior of `@apply` proposed at\n * https://tabatkins.github.io/specs/css-apply-rule/.\n * The approach is to convert a property like this:\n *\n * --foo: {color: red; background: blue;}\n *\n * to this:\n *\n * --foo_-_color: red;\n * --foo_-_background: blue;\n *\n * Then where `@apply --foo` is used, that is converted to:\n *\n * color: var(--foo_-_color);\n * background: var(--foo_-_background);\n *\n * This approach generally works but there are some issues and limitations.\n * Consider, for example, that somewhere *between* where `--foo` is set and used,\n * another element sets it to:\n *\n * --foo: { border: 2px solid red; }\n *\n * We must now ensure that the color and background from the previous setting\n * do not apply. This is accomplished by changing the property set to this:\n *\n * --foo_-_border: 2px solid red;\n * --foo_-_color: initial;\n * --foo_-_background: initial;\n *\n * This works but introduces one new issue.\n * Consider this setup at the point where the `@apply` is used:\n *\n * background: orange;\n * @apply --foo;\n *\n * In this case the background will be unset (initial) rather than the desired\n * `orange`. We address this by altering the property set to use a fallback\n * value like this:\n *\n * color: var(--foo_-_color);\n * background: var(--foo_-_background, orange);\n * border: var(--foo_-_border);\n *\n * Note that the default is retained in the property set and the `background` is\n * the desired `orange`. This leads us to a limitation.\n *\n * Limitation 1:\n\n * Only properties in the rule where the `@apply`\n * is used are considered as default values.\n * If another rule matches the element and sets `background` with\n * less specificity than the rule in which `@apply` appears,\n * the `background` will not be set.\n *\n * Limitation 2:\n *\n * When using Polymer's `updateStyles` api, new properties may not be set for\n * `@apply` properties.\n\n*/\n\n'use strict';\n\nimport {rx, forEachRule, processVariableAndFallback, rulesForStyle} from './style-util'\nimport templateMap from './template-map'\nimport StyleInfo from './style-info'\n\nlet MIXIN_MATCH = rx.MIXIN_MATCH;\nlet VAR_ASSIGN = rx.VAR_ASSIGN;\n\nlet APPLY_NAME_CLEAN = /;\\s*/m;\nlet INITIAL_INHERIT = /^\\s*(initial)|(inherit)\\s*$/;\n\n// separator used between mixin-name and mixin-property-name when producing properties\n// NOTE: plain '-' may cause collisions in user styles\nlet MIXIN_VAR_SEP = '_-_';\n\n// map of mixin to property names\n// --foo: {border: 2px} -> {properties: {(--foo, ['border'])}, dependants: {'element-name': proto}}\nclass MixinMap {\n constructor() {\n this._map = {};\n }\n set(name, props) {\n name = name.trim();\n this._map[name] = {\n properties: props,\n dependants: {}\n }\n }\n get(name) {\n name = name.trim();\n return this._map[name];\n }\n}\n\nclass ApplyShim {\n constructor() {\n this._currentTemplate = null;\n this._measureElement = null;\n this._map = new MixinMap();\n this._separator = MIXIN_VAR_SEP;\n this._boundProduceCssProperties = (\n matchText, propertyName, valueProperty, valueMixin) =>\n this._produceCssProperties(\n matchText, propertyName, valueProperty, valueMixin);\n }\n // return true if `cssText` contains a mixin definition or consumption\n detectMixin(cssText) {\n const has = MIXIN_MATCH.test(cssText) || VAR_ASSIGN.test(cssText);\n // reset state of the regexes\n MIXIN_MATCH.lastIndex = 0;\n VAR_ASSIGN.lastIndex = 0;\n return has;\n }\n transformStyle(style, elementName) {\n let ast = rulesForStyle(style);\n this.transformRules(ast, elementName);\n return ast;\n }\n transformRules(rules, elementName) {\n this._currentTemplate = templateMap[elementName];\n forEachRule(rules, (r) => {\n this.transformRule(r);\n });\n this._currentTemplate = null;\n }\n transformRule(rule) {\n rule.cssText = this.transformCssText(rule.parsedCssText);\n // :root was only used for variable assignment in property shim,\n // but generates invalid selectors with real properties.\n // replace with `:host > *`, which serves the same effect\n if (rule.selector === ':root') {\n rule.selector = ':host > *';\n }\n }\n transformCssText(cssText) {\n // produce variables\n cssText = cssText.replace(VAR_ASSIGN, this._boundProduceCssProperties);\n // consume mixins\n return this._consumeCssProperties(cssText);\n }\n _getInitialValueForProperty(property) {\n if (!this._measureElement) {\n this._measureElement = document.createElement('meta');\n this._measureElement.style.all = 'initial';\n document.head.appendChild(this._measureElement);\n }\n return window.getComputedStyle(this._measureElement).getPropertyValue(property);\n }\n // replace mixin consumption with variable consumption\n _consumeCssProperties(text) {\n let m;\n // loop over text until all mixins with defintions have been applied\n while((m = MIXIN_MATCH.exec(text))) {\n let matchText = m[0];\n let mixinName = m[1];\n let idx = m.index;\n // collect properties before apply to be \"defaults\" if mixin might override them\n // match includes a \"prefix\", so find the start and end positions of @apply\n let applyPos = idx + matchText.indexOf('@apply');\n let afterApplyPos = idx + matchText.length;\n // find props defined before this @apply\n let textBeforeApply = text.slice(0, applyPos);\n let textAfterApply = text.slice(afterApplyPos);\n let defaults = this._cssTextToMap(textBeforeApply);\n let replacement = this._atApplyToCssProperties(mixinName, defaults);\n // use regex match position to replace mixin, keep linear processing time\n text = [textBeforeApply, replacement, textAfterApply].join('');\n // move regex search to _after_ replacement\n MIXIN_MATCH.lastIndex = idx + replacement.length;\n }\n return text;\n }\n // produce variable consumption at the site of mixin consumption\n // @apply --foo; -> for all props (${propname}: var(--foo_-_${propname}, ${fallback[propname]}}))\n // Example:\n // border: var(--foo_-_border); padding: var(--foo_-_padding, 2px)\n _atApplyToCssProperties(mixinName, fallbacks) {\n mixinName = mixinName.replace(APPLY_NAME_CLEAN, '');\n let vars = [];\n let mixinEntry = this._map.get(mixinName);\n // if we depend on a mixin before it is created\n // make a sentinel entry in the map to add this element as a dependency for when it is defined.\n if (!mixinEntry) {\n this._map.set(mixinName, {});\n mixinEntry = this._map.get(mixinName);\n }\n if (mixinEntry) {\n if (this._currentTemplate) {\n mixinEntry.dependants[this._currentTemplate.name] = this._currentTemplate;\n }\n let p, parts, f;\n for (p in mixinEntry.properties) {\n f = fallbacks && fallbacks[p];\n parts = [p, ': var(', mixinName, MIXIN_VAR_SEP, p];\n if (f) {\n parts.push(',', f);\n }\n parts.push(')');\n vars.push(parts.join(''));\n }\n }\n return vars.join('; ');\n }\n\n _replaceInitialOrInherit(property, value) {\n let match = INITIAL_INHERIT.exec(value);\n if (match) {\n if (match[1]) {\n // initial\n // replace `initial` with the concrete initial value for this property\n value = ApplyShim._getInitialValueForProperty(property);\n } else {\n // inherit\n // with this purposfully illegal value, the variable will be invalid at\n // compute time (https://www.w3.org/TR/css-variables/#invalid-at-computed-value-time)\n // and for inheriting values, will behave similarly\n // we cannot support the same behavior for non inheriting values like 'border'\n value = 'apply-shim-inherit';\n }\n }\n return value;\n }\n\n // \"parse\" a mixin definition into a map of properties and values\n // cssTextToMap('border: 2px solid black') -> ('border', '2px solid black')\n _cssTextToMap(text) {\n let props = text.split(';');\n let property, value;\n let out = {};\n for (let i = 0, p, sp; i < props.length; i++) {\n p = props[i];\n if (p) {\n sp = p.split(':');\n // ignore lines that aren't definitions like @media\n if (sp.length > 1) {\n property = sp[0].trim();\n // some properties may have ':' in the value, like data urls\n value = this._replaceInitialOrInherit(property, sp.slice(1).join(':'));\n out[property] = value;\n }\n }\n }\n return out;\n }\n\n _invalidateMixinEntry(mixinEntry) {\n for (let elementName in mixinEntry.dependants) {\n if (!this._currentTemplate || elementName !== this._currentTemplate.name) {\n StyleInfo.invalidate(elementName);\n }\n }\n }\n\n _produceCssProperties(matchText, propertyName, valueProperty, valueMixin) {\n // handle case where property value is a mixin\n if (valueProperty) {\n // form: --mixin2: var(--mixin1), where --mixin1 is in the map\n processVariableAndFallback(valueProperty, (prefix, value) => {\n if (value && this._map.get(value)) {\n valueMixin = '@apply ' + value + ';';\n }\n });\n }\n if (!valueMixin) {\n return matchText;\n }\n let mixinAsProperties = this._consumeCssProperties(valueMixin);\n let prefix = matchText.slice(0, matchText.indexOf('--'));\n let mixinValues = this._cssTextToMap(mixinAsProperties);\n let combinedProps = mixinValues;\n let mixinEntry = this._map.get(propertyName);\n let oldProps = mixinEntry && mixinEntry.properties;\n if (oldProps) {\n // NOTE: since we use mixin, the map of properties is updated here\n // and this is what we want.\n combinedProps = Object.assign(Object.create(oldProps), mixinValues);\n } else {\n this._map.set(propertyName, combinedProps);\n }\n let out = [];\n let p, v;\n // set variables defined by current mixin\n let needToInvalidate = false;\n for (p in combinedProps) {\n v = mixinValues[p];\n // if property not defined by current mixin, set initial\n if (v === undefined) {\n v = 'initial';\n }\n if (oldProps && !(p in oldProps)) {\n needToInvalidate = true;\n }\n out.push(propertyName + MIXIN_VAR_SEP + p + ': ' + v);\n }\n if (needToInvalidate) {\n this._invalidateMixinEntry(mixinEntry);\n }\n if (mixinEntry) {\n mixinEntry.properties = combinedProps;\n }\n // because the mixinMap is global, the mixin might conflict with\n // a different scope's simple variable definition:\n // Example:\n // some style somewhere:\n // --mixin1:{ ... }\n // --mixin2: var(--mixin1);\n // some other element:\n // --mixin1: 10px solid red;\n // --foo: var(--mixin1);\n // In this case, we leave the original variable definition in place.\n if (valueProperty) {\n prefix = matchText + ';' + prefix;\n }\n return prefix + out.join('; ') + ';';\n }\n}\n\nlet applyShim = new ApplyShim();\nwindow['ApplyShim'] = applyShim;\nexport default applyShim;\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {nativeShadow} from './style-settings'\nimport StyleTransformer from './style-transformer'\n\nexport let flush = function() {};\n\nif (!nativeShadow) {\n let elementNeedsScoping = (element) => {\n return (element.classList &&\n !element.classList.contains(StyleTransformer.SCOPE_NAME) ||\n // note: necessary for IE11\n (element instanceof SVGElement && (!element.hasAttribute('class') ||\n element.getAttribute('class').indexOf(StyleTransformer.SCOPE_NAME) < 0)));\n }\n\n let handler = (mxns) => {\n for (let x=0; x < mxns.length; x++) {\n let mxn = mxns[x];\n if (mxn.target === document.documentElement ||\n mxn.target === document.head) {\n continue;\n }\n for (let i=0; i < mxn.addedNodes.length; i++) {\n let n = mxn.addedNodes[i];\n if (elementNeedsScoping(n)) {\n let root = n.getRootNode();\n if (root.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n // may no longer be in a shadowroot\n let host = root.host;\n if (host) {\n let scope = host.is || host.localName;\n StyleTransformer.dom(n, scope);\n }\n }\n }\n }\n for (let i=0; i < mxn.removedNodes.length; i++) {\n let n = mxn.removedNodes[i];\n if (n.nodeType === Node.ELEMENT_NODE) {\n let classes = undefined;\n if (n.classList) {\n classes = Array.from(n.classList);\n } else if (n.hasAttribute('class')) {\n classes = n.getAttribute('class').split(/\\s+/);\n }\n if (classes !== undefined) {\n // NOTE: relies on the scoping class always being adjacent to the\n // SCOPE_NAME class.\n let classIdx = classes.indexOf(StyleTransformer.SCOPE_NAME);\n if (classIdx >= 0) {\n let scope = classes[classIdx + 1];\n if (scope) {\n StyleTransformer.dom(n, scope, true);\n }\n }\n }\n }\n }\n }\n };\n\n let observer = new MutationObserver(handler);\n let start = (node) => {\n observer.observe(node, {childList: true, subtree: true});\n }\n let nativeCustomElements = (window.customElements &&\n !window.customElements.flush);\n // need to start immediately with native custom elements\n // TODO(dfreedm): with polyfilled HTMLImports and native custom elements\n // excessive mutations may be observed; this can be optimized via cooperation\n // with the HTMLImports polyfill.\n if (nativeCustomElements) {\n start(document);\n } else {\n let delayedStart = () => {\n start(document.body);\n }\n // use polyfill timing if it's available\n if (window.HTMLImports) {\n window.HTMLImports.whenReady(delayedStart);\n // otherwise push beyond native imports being ready\n // which requires RAF + readystate interactive.\n } else {\n requestAnimationFrame(function() {\n if (document.readyState === 'loading') {\n let listener = function() {\n delayedStart();\n document.removeEventListener('readystatechange', listener);\n }\n document.addEventListener('readystatechange', listener);\n } else {\n delayedStart();\n }\n });\n }\n }\n\n flush = function() {\n handler(observer.takeRecords());\n }\n}\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n'use strict';\n\nimport {parse} from './css-parse'\nimport {nativeShadow, nativeCssVariables, nativeCssApply} from './style-settings'\nimport StyleTransformer from './style-transformer'\nimport * as StyleUtil from './style-util'\nimport StyleProperties from './style-properties'\nimport templateMap from './template-map'\nimport placeholderMap from './style-placeholder'\nimport StyleInfo from './style-info'\nimport StyleCache from './style-cache'\n\n// TODO(dfreedm): consider spliting into separate global\nimport ApplyShim from './apply-shim'\nimport {flush as watcherFlush} from './document-watcher'\n\nlet styleCache = new StyleCache();\n\nclass ShadyCSS {\n constructor() {\n this._scopeCounter = {};\n this._documentOwner = document.documentElement;\n this._documentOwnerStyleInfo = StyleInfo.set(document.documentElement, new StyleInfo({rules: []}));\n this._elementsHaveApplied = false;\n }\n get nativeShadow() {\n return nativeShadow;\n }\n get nativeCss() {\n return nativeCssVariables;\n }\n get nativeCssApply() {\n return nativeCssApply;\n }\n flush() {\n watcherFlush();\n }\n _generateScopeSelector(name) {\n let id = this._scopeCounter[name] = (this._scopeCounter[name] || 0) + 1;\n return `${name}-${id}`;\n }\n getStyleAst(style) {\n return StyleUtil.rulesForStyle(style);\n }\n styleAstToString(ast) {\n return StyleUtil.toCssText(ast);\n }\n _gatherStyles(template) {\n let styles = template.content.querySelectorAll('style');\n let cssText = [];\n for (let i = 0; i < styles.length; i++) {\n let s = styles[i];\n cssText.push(s.textContent);\n s.parentNode.removeChild(s);\n }\n return cssText.join('').trim();\n }\n _getCssBuild(template) {\n let style = template.content.querySelector('style');\n if (!style) {\n return '';\n }\n return style.getAttribute('css-build') || '';\n }\n prepareTemplate(template, elementName, typeExtension) {\n if (template._prepared) {\n return;\n }\n template._prepared = true;\n template.name = elementName;\n template.extends = typeExtension;\n templateMap[elementName] = template;\n let cssBuild = this._getCssBuild(template);\n let cssText = this._gatherStyles(template);\n let info = {\n is: elementName,\n extends: typeExtension,\n __cssBuild: cssBuild,\n };\n if (!this.nativeShadow) {\n StyleTransformer.dom(template.content, elementName);\n }\n // check if the styling has mixin definitions or uses\n let hasMixins = ApplyShim.detectMixin(cssText);\n let ast = parse(cssText);\n // only run the applyshim transforms if there is a mixin involved\n if (hasMixins && this.nativeCss && !this.nativeCssApply) {\n ApplyShim.transformRules(ast, elementName);\n }\n template._styleAst = ast;\n\n let ownPropertyNames = [];\n if (!this.nativeCss) {\n ownPropertyNames = StyleProperties.decorateStyles(template._styleAst, info);\n }\n if (!ownPropertyNames.length || this.nativeCss) {\n let root = this.nativeShadow ? template.content : null;\n let placeholder = placeholderMap[elementName];\n let style = this._generateStaticStyle(info, template._styleAst, root, placeholder);\n template._style = style;\n }\n template._ownPropertyNames = ownPropertyNames;\n }\n _generateStaticStyle(info, rules, shadowroot, placeholder) {\n let cssText = StyleTransformer.elementStyles(info, rules);\n if (cssText.length) {\n return StyleUtil.applyCss(cssText, info.is, shadowroot, placeholder);\n }\n }\n _prepareHost(host) {\n let is = host.getAttribute('is') || host.localName;\n let typeExtension;\n if (is !== host.localName) {\n typeExtension = host.localName;\n }\n let placeholder = placeholderMap[is];\n let template = templateMap[is];\n let ast;\n let ownStylePropertyNames;\n let cssBuild;\n if (template) {\n ast = template._styleAst;\n ownStylePropertyNames = template._ownPropertyNames;\n cssBuild = template._cssBuild;\n }\n return StyleInfo.set(host,\n new StyleInfo(\n ast,\n placeholder,\n ownStylePropertyNames,\n is,\n typeExtension,\n cssBuild\n )\n );\n }\n applyStyle(host, overrideProps) {\n let is = host.getAttribute('is') || host.localName;\n let styleInfo = StyleInfo.get(host);\n let hasApplied = Boolean(styleInfo);\n if (!styleInfo) {\n styleInfo = this._prepareHost(host);\n }\n // Only trip the `elementsHaveApplied` flag if a node other that the root document has `applyStyle` called\n if (!this._isRootOwner(host)) {\n this._elementsHaveApplied = true;\n }\n if (window.CustomStyle) {\n let CS = window.CustomStyle;\n if (CS._documentDirty) {\n CS.findStyles();\n if (!this.nativeCss) {\n this._updateProperties(this._documentOwner, this._documentOwnerStyleInfo);\n } else if (!this.nativeCssApply) {\n CS._revalidateApplyShim();\n }\n CS.applyStyles();\n // if no elements have booted yet, we can just update the document and be done\n if (!this._elementsHaveApplied) {\n return;\n }\n // if no native css custom properties, we must recalculate the whole tree\n if (!this.nativeCss) {\n this.updateStyles();\n /*\n When updateStyles() runs, this element may not have a shadowroot yet.\n If not, we need to make sure that this element runs `applyStyle` on itself at least once to generate a style\n */\n if (hasApplied) {\n return;\n }\n }\n }\n }\n if (overrideProps) {\n styleInfo.overrideStyleProperties =\n styleInfo.overrideStyleProperties || {};\n Object.assign(styleInfo.overrideStyleProperties, overrideProps);\n }\n if (this.nativeCss) {\n if (styleInfo.overrideStyleProperties) {\n this._updateNativeProperties(host, styleInfo.overrideStyleProperties);\n }\n let template = templateMap[is];\n // bail early if there is no shadowroot for this element\n if (!template && !this._isRootOwner(host)) {\n return;\n }\n if (template && template._applyShimInvalid && template._style) {\n // update template\n if (!template._validating) {\n ApplyShim.transformRules(template._styleAst, is);\n template._style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n StyleInfo.startValidating(is);\n }\n // update instance if native shadowdom\n if (this.nativeShadow) {\n let root = host.shadowRoot;\n if (root) {\n let style = root.querySelector('style');\n style.textContent = StyleTransformer.elementStyles(host, styleInfo.styleRules);\n }\n }\n styleInfo.styleRules = template._styleAst;\n }\n } else {\n this._updateProperties(host, styleInfo);\n if (styleInfo.ownStylePropertyNames && styleInfo.ownStylePropertyNames.length) {\n this._applyStyleProperties(host, styleInfo);\n }\n }\n if (hasApplied) {\n let root = this._isRootOwner(host) ? host : host.shadowRoot;\n // note: some elements may not have a root!\n if (root) {\n this._applyToDescendants(root);\n }\n }\n }\n _applyToDescendants(root) {\n // note: fallback to childNodes to support recursing into SVG which\n // does not support children in some browsers (Edge/IE)\n let c$ = root.children || root.childNodes;\n for (let i = 0, c; i < c$.length; i++) {\n c = c$[i];\n if (c.shadowRoot) {\n this.applyStyle(c);\n }\n this._applyToDescendants(c);\n }\n }\n _styleOwnerForNode(node) {\n let root = node.getRootNode();\n let host = root.host;\n if (host) {\n if (StyleInfo.get(host)) {\n return host;\n } else {\n return this._styleOwnerForNode(host);\n }\n }\n return this._documentOwner;\n }\n _isRootOwner(node) {\n return (node === this._documentOwner);\n }\n _applyStyleProperties(host, styleInfo) {\n let is = host.getAttribute('is') || host.localName;\n let cacheEntry = styleCache.fetch(is, styleInfo.styleProperties, styleInfo.ownStylePropertyNames);\n let cachedScopeSelector = cacheEntry && cacheEntry.scopeSelector;\n let cachedStyle = cacheEntry ? cacheEntry.styleElement : null;\n let oldScopeSelector = styleInfo.scopeSelector;\n // only generate new scope if cached style is not found\n styleInfo.scopeSelector = cachedScopeSelector || this._generateScopeSelector(is);\n let style = StyleProperties.applyElementStyle(host, styleInfo.styleProperties, styleInfo.scopeSelector, cachedStyle);\n if (!this.nativeShadow) {\n StyleProperties.applyElementScopeSelector(host, styleInfo.scopeSelector, oldScopeSelector);\n }\n if (!cacheEntry) {\n styleCache.store(is, styleInfo.styleProperties, style, styleInfo.scopeSelector);\n }\n return style;\n }\n _updateProperties(host, styleInfo) {\n let owner = this._styleOwnerForNode(host);\n let ownerStyleInfo = StyleInfo.get(owner);\n let ownerProperties = ownerStyleInfo.styleProperties;\n let props = Object.create(ownerProperties || null);\n let hostAndRootProps = StyleProperties.hostAndRootPropertiesForScope(host, styleInfo.styleRules);\n let propertyData = StyleProperties.propertyDataFromStyles(ownerStyleInfo.styleRules, host);\n let propertiesMatchingHost = propertyData.properties\n Object.assign(\n props,\n hostAndRootProps.hostProps,\n propertiesMatchingHost,\n hostAndRootProps.rootProps\n );\n this._mixinOverrideStyles(props, styleInfo.overrideStyleProperties);\n StyleProperties.reify(props);\n styleInfo.styleProperties = props;\n }\n _mixinOverrideStyles(props, overrides) {\n for (let p in overrides) {\n let v = overrides[p];\n // skip override props if they are not truthy or 0\n // in order to fall back to inherited values\n if (v || v === 0) {\n props[p] = v;\n }\n }\n }\n _updateNativeProperties(element, properties) {\n // remove previous properties\n for (let p in properties) {\n // NOTE: for bc with shim, don't apply null values.\n if (p === null) {\n element.style.removeProperty(p);\n } else {\n element.style.setProperty(p, properties[p]);\n }\n }\n }\n updateStyles(properties) {\n this.applyStyle(this._documentOwner, properties);\n }\n /* Custom Style operations */\n _transformCustomStyleForDocument(style) {\n let ast = StyleUtil.rulesForStyle(style);\n StyleUtil.forEachRule(ast, (rule) => {\n if (nativeShadow) {\n StyleTransformer.normalizeRootSelector(rule);\n } else {\n StyleTransformer.documentRule(rule);\n }\n if (this.nativeCss && !this.nativeCssApply) {\n ApplyShim.transformRule(rule);\n }\n });\n if (this.nativeCss) {\n style.textContent = StyleUtil.toCssText(ast);\n } else {\n this._documentOwnerStyleInfo.styleRules.rules.push(ast);\n }\n }\n _revalidateApplyShim(style) {\n if (this.nativeCss && !this.nativeCssApply) {\n let ast = StyleUtil.rulesForStyle(style);\n ApplyShim.transformRules(ast);\n style.textContent = StyleUtil.toCssText(ast);\n }\n }\n _applyCustomStyleToDocument(style) {\n if (!this.nativeCss) {\n StyleProperties.applyCustomStyle(style, this._documentOwnerStyleInfo.styleProperties);\n }\n }\n getComputedStyleValue(element, property) {\n let value;\n if (!this.nativeCss) {\n // element is either a style host, or an ancestor of a style host\n let styleInfo = StyleInfo.get(element) || StyleInfo.get(this._styleOwnerForNode(element));\n value = styleInfo.styleProperties[property];\n }\n // fall back to the property value from the computed styling\n value = value || window.getComputedStyle(element).getPropertyValue(property);\n // trim whitespace that can come after the `:` in css\n // example: padding: 2px -> \" 2px\"\n return value.trim();\n }\n // given an element and a classString, replaces\n // the element's class with the provided classString and adds\n // any necessary ShadyCSS static and property based scoping selectors\n setElementClass(element, classString) {\n let root = element.getRootNode();\n let classes = classString ? classString.split(/\\s/) : [];\n let scopeName = root.host && root.host.localName;\n // If no scope, try to discover scope name from existing class.\n // This can occur if, for example, a template stamped element that\n // has been scoped is manipulated when not in a root.\n if (!scopeName) {\n var classAttr = element.getAttribute('class');\n if (classAttr) {\n let k$ = classAttr.split(/\\s/);\n for (let i=0; i < k$.length; i++) {\n if (k$[i] === StyleTransformer.SCOPE_NAME) {\n scopeName = k$[i+1];\n break;\n }\n }\n }\n }\n if (scopeName) {\n classes.push(StyleTransformer.SCOPE_NAME, scopeName);\n }\n if (!this.nativeCss) {\n let styleInfo = StyleInfo.get(element);\n if (styleInfo && styleInfo.scopeSelector) {\n classes.push(StyleProperties.XSCOPE_NAME, styleInfo.scopeSelector);\n }\n }\n StyleUtil.setElementClassRaw(element, classes.join(' '));\n }\n _styleInfoForNode(node) {\n return StyleInfo.get(node);\n }\n}\n\nwindow['ShadyCSS'] = new ShadyCSS();","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n'use strict';\n\nexport default class StyleCache {\n constructor(typeMax = 100) {\n // map element name -> [{properties, styleElement, scopeSelector}]\n this.cache = {};\n this.typeMax = typeMax;\n }\n\n _validate(cacheEntry, properties, ownPropertyNames) {\n for (let idx = 0; idx < ownPropertyNames.length; idx++) {\n let pn = ownPropertyNames[idx];\n if (cacheEntry.properties[pn] !== properties[pn]) {\n return false;\n }\n }\n return true;\n }\n\n store(tagname, properties, styleElement, scopeSelector) {\n let list = this.cache[tagname] || [];\n list.push({properties, styleElement, scopeSelector});\n if (list.length > this.typeMax) {\n list.shift();\n }\n this.cache[tagname] = list;\n }\n\n fetch(tagname, properties, ownPropertyNames) {\n let list = this.cache[tagname];\n if (!list) {\n return;\n }\n // reverse list for most-recent lookups\n for (let idx = list.length - 1; idx >= 0; idx--) {\n let entry = list[idx];\n if (this._validate(entry, properties, ownPropertyNames)) {\n return entry;\n }\n }\n }\n}\n"]}
\ No newline at end of file