diff --git a/.bowerrc b/.bowerrc
index cfacd73..12c76c5 100644
--- a/.bowerrc
+++ b/.bowerrc
@@ -1,3 +1,3 @@
{
- "directory": "components"
+ "directory": "../components"
}
diff --git a/README.html b/README.html
deleted file mode 100644
index ce68188..0000000
--- a/README.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
dat.gui
-Quickly configurable controllers for the web.
-Usage
-Include
-<script src="gui.js"></script>
-
-With very little code, dat.GUI creates an interface that you can use to modify variables.
-var gui = new dat.gui();
-gui.add( object, 'someNumber', 0, 1 );
-
diff --git a/README.md b/README.md
index aed27ec..44cb127 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,234 @@
-# dat.gui
+# dat-gui
-Quickly configurable controllers for the web.
+With very little code, dat gui creates an interface that you can use to modify variables.
-## Usage
+## Basic Usage
-Include
+Download the [minified library]( todo ) and include it in your html.
```html
```
-With very little code, dat gui creates an interface that you can use to modify variables.
+The following code makes a number box for the variable `object.someNumber`.
```javascript
-var gui = new dat.gui();
-gui.add( object, 'someNumber', 0, 1 );
+var gui = new Gui();
+gui.add( object, 'someNumber' );
```
+dat-gui decides what type of controller to use based on the variable's initial value.
+
+```javascript
+var gui = new Gui();
+gui.add( object, 'stringProperty' ); // Text box
+gui.add( object, 'booleanProperty' ); // Check box
+gui.add( object, 'functionProperty' ); // Button
+```
+
+## Constraining Input
+
+You can specify limits on numbers. A number with a min and max value becomes a slider.
+
+```javascript
+gui.add( text, 'growthSpeed', -5, 5 ); // Min and max
+gui.add( text, 'noiseStrength' ).step( 5 ); // Increment amount
+gui.add( text, 'maxSize' ).min( 0 ).step( 0.25 ); // Mix and match
+```
+
+You can also provide a list of accepted values for a dropdown.
+
+```javascript
+// Choose from accepted values
+gui.add( text, 'message', [ 'pizza', 'chrome', 'hooray' ] );
+
+// Choose from named values
+gui.add( text, 'speed', { Stopped: 0, Slow: 0.1, Fast: 5 } );
+```
+
+## Color Controllers
+
+dat-gui has a color selector and understands many different representations of color. The following creates color controllers for color variables of different formats.
+
+
+```javascript
+var FizzyText = function() {
+
+ this.color0 = "#ffae23"; // CSS string
+ this.color1 = [ 0, 128, 255 ]; // RGB array
+ this.color2 = [ 0, 128, 255, 0.3 ]; // RGB with alpha
+ this.color3 = { h: 350, s: 0.9, v: 0.3 }; // Hue, saturation, value
+
+ // Define render logic ...
+
+};
+
+window.onload = function() {
+
+ var text = new FizzyText();
+ var gui = new Gui();
+
+ gui.addColor(text, 'color0');
+ gui.addColor(text, 'color1');
+ gui.addColor(text, 'color2');
+ gui.addColor(text, 'color3');
+
+};
+```
+
+## Events
+
+You can listen for events on individual controllers using an event listener syntax.
+
+```javascript
+var controller = gui.add(fizzyText, 'maxSize', 0, 10);
+
+controller.onChange(function(value) {
+ // Fires on every change, drag, keypress, etc.
+});
+
+controller.onFinishChange(function(value) {
+ // Fires when a controller loses focus.
+ alert("The new value is " + value);
+});
+```
+
+## Folders
+
+You can nest as many Gui's as you want. Nested Gui's act as collapsible folders.
+
+```javascript
+var gui = new Gui();
+
+var f1 = gui.addFolder('Flow Field');
+f1.add(text, 'speed');
+f1.add(text, 'noiseStrength');
+
+var f2 = gui.addFolder('Letters');
+f2.add(text, 'growthSpeed');
+f2.add(text, 'maxSize');
+f2.add(text, 'message');
+
+f2.open();
+```
+
+
+## Saving Values
+
+Add a save menu to the interface by calling `gui.remember` on all the objects you've added to the Gui.
+
+```javascript
+var fizzyText = new FizzyText();
+var gui = new Gui();
+
+gui.remember(fizzyText);
+
+// Add controllers ...
+```
+
+Click the gear icon to change your save settings. You can either save your Gui's values to localStorage, or by copying and pasting a JSON object into your source code as follows:
+
+```javascript
+var fizzyText = new FizzyText();
+var gui = new Gui({ load: JSON });
+
+gui.remember(fizzyText);
+
+// Add controllers ...
+```
+
+## Save to disk
+
+dat-gui comes with a node server that listens for changes to your Gui and saves them to disk. This way you don't have to worry about losing your local storage or copying and pasting a JSON string.
+
+First, run the node script:
+
+```sh
+$ node gui-server
+```
+
+Next, instantiate your Gui with a path to a JSON file to store settings.
+
+```javascript
+var gui = new Gui( { save: 'path/to/file.json' } );
+gui.remember( fizzyText );
+
+// Add controllers ...
+```
+
+## Custom Placement
+
+By default, Gui panels are created with fixed position, and are automatically appended to the body.
+
+You can change this behavior by setting the `autoPlace` parameter to `false`.
+
+```javascript
+var gui = new Gui( { autoPlace: false } );
+
+var customContainer = document.getElementById('my-gui-container');
+customContainer.appendChild(gui.domElement);
+```
+
+## HTML Elements
+
+Since dat-gui is built using [Web Components]( todo ), you can use HTML syntax to add controllers to the page.
+
+```html
+
+
+
+
+
+
+
+```
+
+## Defining Custom Controllers
+
+dat-gui uses [Polymer]( todo ) under the hood to define custom elements. A dat-gui controller is just a [Polymer element]( todo ) with two important requirements:
+
+- Controllers must extend ``.
+- Controllers must be associated with a data type.
+
+Take for example this (simplified) source for dat-gui's ``:
+
+```javascript
+Polymer( 'controller-number', {
+
+ // Define element ...
+
+} );
+
+Gui.register( 'controller-number', function( value ) {
+
+ return typeof value == 'number';
+
+} );
+```
+
+`Gui.register` takes an element name and a test function. The call to `Gui.register` tells dat-gui to add a `` to the panel when the user adds a variable whose type is `'number'`.
+
+A test function takes a value added with `gui.add` and returns a boolean that determines if the controller is appropriate for the value. This example uses [duck typing]( todo ) to register `` for values that have properties `x`, `y` and `z`.
+
+```javascript
+Gui.register( 'vector-controller', function( value ) {
+
+ return value.hasOwnProperty( 'x' ) &&
+ value.hasOwnProperty( 'y' ) &&
+ value.hasOwnProperty( 'z' );
+
+} );
+```
+
+## Publishing Custom Controllers
+
+You should use bower and format your plugin all nice and it should have a certain prefix yada yada.
\ No newline at end of file
diff --git a/build/gui.html b/build/gui.html
index 13ad920..5b1a5bc 100644
--- a/build/gui.html
+++ b/build/gui.html
@@ -425,8 +425,9 @@ if(f)g=void 0;else if(f=g[this.name],!f)return void console.error("Cannot find f
user-select: none;
width: 100%;
display: block;
- font: 500 10px 'Lucida Grande', sans-serif;
- color: #eee;
+ font: 500 11px 'Roboto', sans-serif;
+ color: #fff;
+ -webkit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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-undefined
-
-
-
-
-
-
-
-
-
-
-
-
- {{moduleName}}
- demo
-
-
-
-
-
-
-
-
-
diff --git a/components/core-component-page/demo.html b/components/core-component-page/demo.html
deleted file mode 100644
index fb80e5f..0000000
--- a/components/core-component-page/demo.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/core-component-page/index.html b/components/core-component-page/index.html
deleted file mode 100644
index 58856f3..0000000
--- a/components/core-component-page/index.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/platform/.bower.json b/components/platform/.bower.json
deleted file mode 100644
index cec6b4b..0000000
--- a/components/platform/.bower.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "platform",
- "main": "platform.js",
- "homepage": "https://github.com/Polymer/platform",
- "authors": [
- "The Polymer Authors"
- ],
- "description": "Integrate platform polyfills: load, build, test",
- "keywords": [
- "polymer",
- "web",
- "components"
- ],
- "license": "BSD",
- "private": true,
- "version": "0.3.5",
- "_release": "0.3.5",
- "_resolution": {
- "type": "version",
- "tag": "0.3.5",
- "commit": "413707498b62d2c66f923dcac6809d56e7d6dab6"
- },
- "_source": "git://github.com/Polymer/platform.git",
- "_target": ">=0.3.0 <1.0.0",
- "_originalSource": "Polymer/platform"
-}
\ No newline at end of file
diff --git a/components/platform/README.md b/components/platform/README.md
deleted file mode 100644
index 65b661e..0000000
--- a/components/platform/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Platform
-========
-
-Aggregated polyfills the Polymer platform.
-
-[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/platform/README)](https://github.com/igrigorik/ga-beacon)
diff --git a/components/platform/bower.json b/components/platform/bower.json
deleted file mode 100644
index 8d2c51d..0000000
--- a/components/platform/bower.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "platform",
- "main": "platform.js",
- "homepage": "https://github.com/Polymer/platform",
- "authors": [
- "The Polymer Authors"
- ],
- "description": "Integrate platform polyfills: load, build, test",
- "keywords": [
- "polymer",
- "web",
- "components"
- ],
- "license": "BSD",
- "private": true
-}
\ No newline at end of file
diff --git a/components/platform/build.log b/components/platform/build.log
deleted file mode 100644
index 90d5a17..0000000
--- a/components/platform/build.log
+++ /dev/null
@@ -1,39 +0,0 @@
-BUILD LOG
----------
-Build Time: 2014-08-07T17:12:14
-
-NODEJS INFORMATION
-==================
-nodejs: v0.10.28
-chai: 1.9.1
-grunt: 0.4.4
-grunt-audit: 0.0.3
-grunt-concat-sourcemap: 0.4.1
-grunt-contrib-concat: 0.4.0
-grunt-contrib-uglify: 0.5.0
-grunt-contrib-yuidoc: 0.5.2
-grunt-karma: 0.8.3
-karma: 0.12.14
-karma-crbot-reporter: 0.0.4
-karma-firefox-launcher: 0.1.3
-karma-ie-launcher: 0.1.5
-karma-mocha: 0.1.4
-karma-safari-launcher: 0.1.1
-karma-script-launcher: 0.1.0
-mocha: 1.20.1
-Platform: 0.3.5
-
-REPO REVISIONS
-==============
-CustomElements: 7fb280cb30f9fe26ed60c0fdb75a1eebe4c9dab1
-HTMLImports: fe9a92700b7a0bc7a9d582f4767ab23ec195a423
-NodeBind: c47bc1b40d1cf0123b29620820a7111471e83ff3
-ShadowDOM: c4da63735ba6c00a7d6af5c1b118f84bd6a2e114
-TemplateBinding: f11e2e7faa074f54e711f5abb40e278f3005500d
-WeakMap: 6662df5cb7146707238b08e7a65cf70056ae516a
-observe-js: 08b8dfa21bf49d9ac60bc495e77a0bfa57f84cde
-platform-dev: e1453ea29013959ee3e1f893eaf97806629631dc
-
-BUILD HASHES
-============
-build/platform.js: d4d1dc11321913bf930bb5109da0b5ed434c0a00
\ No newline at end of file
diff --git a/components/platform/platform.js b/components/platform/platform.js
deleted file mode 100644
index 3cd0e51..0000000
--- a/components/platform/platform.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * Code distributed by Google as part of the polymer project is also
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
- */
-// @version: 0.3.5
-
-window.Platform=window.Platform||{},window.logFlags=window.logFlags||{},function(a){var b=a.flags||{};location.search.slice(1).split("&").forEach(function(a){a=a.split("="),a[0]&&(b[a[0]]=a[1]||!0)});var c=document.currentScript||document.querySelector('script[src*="platform.js"]');if(c)for(var d,e=c.attributes,f=0;f1&&console.warn("platform.js is not the first script on the page. See http://www.polymer-project.org/docs/start/platform.html#setup for details."),b.register&&(window.CustomElements=window.CustomElements||{flags:{}},window.CustomElements.flags.register=b.register),b.imports&&(window.HTMLImports=window.HTMLImports||{flags:{}},window.HTMLImports.flags.imports=b.imports),a.flags=b}(Platform),"undefined"==typeof WeakMap&&!function(){var a=Object.defineProperty,b=Date.now()%1e9,c=function(){this.name="__st"+(1e9*Math.random()>>>0)+(b++ +"__")};c.prototype={set:function(b,c){var d=b[this.name];d&&d[0]===b?d[1]=c:a(b,this.name,{value:[b,c],writable:!0})},get:function(a){var b;return(b=a[this.name])&&b[0]===a?b[1]:void 0},"delete":function(a){var b=a[this.name];if(!b)return!1;var c=b[0]===a;return b[0]=b[1]=void 0,c},has:function(a){var b=a[this.name];return b?b[0]===a:!1}},window.WeakMap=c}(),function(global){"use strict";function detectObjectObserve(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={},d=[];return Object.observe(c,a),Array.observe(d,a),c.id=1,c.id=2,delete c.id,d.push(1,2),d.length=0,Object.deliverChangeRecords(a),5!==b.length?!1:"add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type||"splice"!=b[3].type||"splice"!=b[4].type?!1:(Object.unobserve(c,a),Array.unobserve(d,a),!0)}function detectEval(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;if(navigator.getDeviceStorage)return!1;try{var a=new Function("","return true;");return a()}catch(b){return!1}}function isIndex(a){return+a===a>>>0}function toNumber(a){return+a}function isObject(a){return a===Object(a)}function areSameValue(a,b){return a===b?0!==a||1/a===1/b:numberIsNaN(a)&&numberIsNaN(b)?!0:a!==a&&b!==b}function getPathCharType(a){if(void 0===a)return"eof";var b=a.charCodeAt(0);switch(b){case 91:case 93:case 46:case 34:case 39:case 48:return a;case 95:case 36:return"ident";case 32:case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return b>=97&&122>=b||b>=65&&90>=b?"ident":b>=49&&57>=b?"number":"else"}function noop(){}function parsePath(a){function b(){if(!(k>=a.length)){var b=a[k+1];return"inSingleQuote"==l&&"'"==b||"inDoubleQuote"==l&&'"'==b?(k++,d=b,m.append(),!0):void 0}}for(var c,d,e,f,g,h,i,j=[],k=-1,l="beforePath",m={push:function(){void 0!==e&&(j.push(e),e=void 0)},append:function(){void 0===e?e=d:e+=d}};l;)if(k++,c=a[k],"\\"!=c||!b(l)){if(f=getPathCharType(c),i=pathStateMachine[l],g=i[f]||i["else"]||"error","error"==g)return;if(l=g[0],h=m[g[1]]||noop,d=void 0===g[2]?c:g[2],h(),"afterPath"===l)return j}}function isIdent(a){return identRegExp.test(a)}function Path(a,b){if(b!==constructorIsPrivate)throw Error("Use Path.get to retrieve path objects");for(var c=0;cb&&a.check_();)b++;return testingExposeCycleCount&&(global.dirtyCheckCycleCount=b),b>0}function objectIsEmpty(a){for(var b in a)return!1;return!0}function diffIsEmpty(a){return objectIsEmpty(a.added)&&objectIsEmpty(a.removed)&&objectIsEmpty(a.changed)}function diffObjectFromOldObject(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var f in a)f in b||(c[f]=a[f]);return Array.isArray(a)&&a.length!==b.length&&(e.length=a.length),{added:c,removed:d,changed:e}}function runEOMTasks(){if(!eomTasks.length)return!1;for(var a=0;a0)){for(var a=0;ab||a>d?-1:b==c||d==a?0:c>a?d>b?b-c:d-c:b>d?d-a:b-a}function mergeSplice(a,b,c,d){for(var e=newSplice(b,c,d),f=!1,g=0,h=0;h=0){a.splice(h,1),h--,g-=i.addedCount-i.removed.length,e.addedCount+=i.addedCount-j;var k=e.removed.length+i.removed.length-j;if(e.addedCount||k){var c=i.removed;if(e.indexi.index+i.addedCount){var m=e.removed.slice(i.index+i.addedCount-e.index);Array.prototype.push.apply(c,m)}e.removed=c,i.indexf)continue;mergeSplice(c,f,[e.oldValue],1);break;default:console.error("Unexpected record type: "+JSON.stringify(e))}}return c}function projectArraySplices(a,b){var c=[];return createInitialSplices(a,b).forEach(function(b){return 1==b.addedCount&&1==b.removed.length?void(b.removed[0]!==a[b.index]&&c.push(b)):void(c=c.concat(calcSplices(a,b.index,b.index+b.addedCount,b.removed,0,b.removed.length)))}),c}var testingExposeCycleCount=global.testingExposeCycleCount,hasObserve=detectObjectObserve(),hasEval=detectEval(),numberIsNaN=global.Number.isNaN||function(a){return"number"==typeof a&&global.isNaN(a)},createObject="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},identStart="[$_a-zA-Z]",identPart="[$_a-zA-Z0-9]",identRegExp=new RegExp("^"+identStart+"+"+identPart+"*$"),pathStateMachine={beforePath:{ws:["beforePath"],ident:["inIdent","append"],"[":["beforeElement"],eof:["afterPath"]},inPath:{ws:["inPath"],".":["beforeIdent"],"[":["beforeElement"],eof:["afterPath"]},beforeIdent:{ws:["beforeIdent"],ident:["inIdent","append"]},inIdent:{ident:["inIdent","append"],0:["inIdent","append"],number:["inIdent","append"],ws:["inPath","push"],".":["beforeIdent","push"],"[":["beforeElement","push"],eof:["afterPath","push"]},beforeElement:{ws:["beforeElement"],0:["afterZero","append"],number:["inIndex","append"],"'":["inSingleQuote","append",""],'"':["inDoubleQuote","append",""]},afterZero:{ws:["afterElement","push"],"]":["inPath","push"]},inIndex:{0:["inIndex","append"],number:["inIndex","append"],ws:["afterElement"],"]":["inPath","push"]},inSingleQuote:{"'":["afterElement"],eof:["error"],"else":["inSingleQuote","append"]},inDoubleQuote:{'"':["afterElement"],eof:["error"],"else":["inDoubleQuote","append"]},afterElement:{ws:["afterElement"],"]":["inPath","push"]}},constructorIsPrivate={},pathCache={};Path.get=getPath,Path.prototype=createObject({__proto__:[],valid:!0,toString:function(){for(var a="",b=0;bcycles&&anyChanged);testingExposeCycleCount&&(global.dirtyCheckCycleCount=cycles),runningMicrotaskCheckpoint=!1}}},collectObservers&&(global.Platform.clearObservers=function(){allObservers=[]}),ObjectObserver.prototype=createObject({__proto__:Observer.prototype,arrayObserve:!1,connect_:function(){hasObserve?this.directObserver_=getObservedObject(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a){var b,c;if(hasObserve){if(!a)return!1;c={},b=diffObjectFromChangeRecords(this.value_,a,c)}else c=this.oldObject_,b=diffObjectFromOldObject(this.value_,this.oldObject_);return diffIsEmpty(b)?!1:(hasObserve||(this.oldObject_=this.copyObject(this.value_)),this.report_([b.added||{},b.removed||{},b.changed||{},function(a){return c[a]}]),!0)},disconnect_:function(){hasObserve?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==OPENED&&(hasObserve?this.directObserver_.deliver(!1):dirtyCheck(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}}),ArrayObserver.prototype=createObject({__proto__:ObjectObserver.prototype,arrayObserve:!0,copyObject:function(a){return a.slice()},check_:function(a){var b;if(hasObserve){if(!a)return!1;b=projectArraySplices(this.value_,a)}else b=calcSplices(this.value_,0,this.value_.length,this.oldObject_,0,this.oldObject_.length);return b&&b.length?(hasObserve||(this.oldObject_=this.copyObject(this.value_)),this.report_([b]),!0):!1}}),ArrayObserver.applySplices=function(a,b,c){c.forEach(function(c){for(var d=[c.index,c.removed.length],e=c.index;ej;j++)i[j]=new Array(h),i[j][0]=j;for(var k=0;h>k;k++)i[0][k]=k;for(var j=1;g>j;j++)for(var k=1;h>k;k++)if(this.equals(a[b+k-1],d[e+j-1]))i[j][k]=i[j-1][k-1];else{var l=i[j-1][k]+1,m=i[j][k-1]+1;i[j][k]=m>l?l:m}return i},spliceOperationsFromEditDistances:function(a){for(var b=a.length-1,c=a[0].length-1,d=a[b][c],e=[];b>0||c>0;)if(0!=b)if(0!=c){var f,g=a[b-1][c-1],h=a[b-1][c],i=a[b][c-1];f=i>h?g>h?h:g:g>i?i:g,f==g?(g==d?e.push(EDIT_LEAVE):(e.push(EDIT_UPDATE),d=g),b--,c--):f==h?(e.push(EDIT_DELETE),b--,d=h):(e.push(EDIT_ADD),c--,d=i)}else e.push(EDIT_DELETE),b--;else e.push(EDIT_ADD),c--;return e.reverse(),e},calcSplices:function(a,b,c,d,e,f){var g=0,h=0,i=Math.min(c-b,f-e);if(0==b&&0==e&&(g=this.sharedPrefix(a,d,i)),c==a.length&&f==d.length&&(h=this.sharedSuffix(a,d,i-g)),b+=g,e+=g,c-=h,f-=h,c-b==0&&f-e==0)return[];if(b==c){for(var j=newSplice(b,[],0);f>e;)j.removed.push(d[e++]);return[j]}if(e==f)return[newSplice(b,[],c-b)];for(var k=this.spliceOperationsFromEditDistances(this.calcEditDistances(a,b,c,d,e,f)),j=void 0,l=[],m=b,n=e,o=0;od;d++)if(!this.equals(a[d],b[d]))return d;return c},sharedSuffix:function(a,b,c){for(var d=a.length,e=b.length,f=0;c>f&&this.equals(a[--d],b[--e]);)f++;return f},calculateSplices:function(a,b){return this.calcSplices(a,0,a.length,b,0,b.length)},equals:function(a,b){return a===b}};var arraySplice=new ArraySplice;global.Observer=Observer,global.Observer.runEOM_=runEOM,global.Observer.observerSentinel_=observerSentinel,global.Observer.hasObjectObserve=hasObserve,global.ArrayObserver=ArrayObserver,global.ArrayObserver.calculateSplices=function(a,b){return arraySplice.calculateSplices(a,b)},global.ArraySplice=ArraySplice,global.ObjectObserver=ObjectObserver,global.PathObserver=PathObserver,global.CompoundObserver=CompoundObserver,global.Path=Path,global.ObserverTransform=ObserverTransform}("undefined"!=typeof global&&global&&"undefined"!=typeof module&&module?global:this||window),Platform.flags.shadow?(window.ShadowDOMPolyfill={},function(a){"use strict";function b(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;if(navigator.getDeviceStorage)return!1;try{var a=new Function("return true;");return a()}catch(b){return!1}}function c(a){if(!a)throw new Error("Assertion failed")}function d(a,b){for(var c=L(b),d=0;d0){for(var k=0;k0&&d.length>0;){var f=c.pop(),g=d.pop();if(f!==g)break;e=f}return e}function k(a,b,c){b instanceof Q.Window&&(b=b.document);var e,f=L(b),g=L(c),h=d(c,a),e=j(f,g);e||(e=g.root);for(var i=e;i;i=i.parent)for(var k=0;k0;f--)if(!r(b[f],a,e,b,d))return!1;return!0}function p(a,b,c,d){var e=cb,f=b[0]||c;return r(f,a,e,b,d)}function q(a,b,c,d){for(var e=db,f=1;f0&&r(c,a,e,b,d)}function r(a,b,c,d,e){var f=R.get(a);if(!f)return!0;var g=e||h(d,a);if(g===a){if(c===bb)return!0;c===db&&(c=cb)}else if(c===db&&!b.bubbles)return!0;if("relatedTarget"in b){var i=O(b),j=i.relatedTarget;if(j){if(j instanceof Object&&j.addEventListener){var l=P(j),m=k(b,a,l);if(m===g)return!0}else m=null;W.set(b,m)}}X.set(b,c);var n=b.type,o=!1;U.set(b,g),V.set(b,a),f.depth++;for(var p=0,q=f.length;q>p;p++){var r=f[p];if(r.removed)o=!0;else if(!(r.type!==n||!r.capture&&c===bb||r.capture&&c===db))try{if("function"==typeof r.handler?r.handler.call(a,b):r.handler.handleEvent(b),Z.get(b))return!1}catch(s){J||(J=s)}}if(f.depth--,o&&0===f.depth){var t=f.slice();f.length=0;for(var p=0;pd;d++)b[d]=f(a[d]);return b.length=e,b}function e(a,b){a.prototype[b]=function(){return d(this.impl[b].apply(this.impl,arguments))}}var f=a.wrap,g={enumerable:!1};c.prototype={item:function(a){return this[a]}},b(c.prototype,"item"),a.wrappers.NodeList=c,a.addWrapNodeListMethod=e,a.wrapNodeList=d}(window.ShadowDOMPolyfill),function(a){"use strict";a.wrapHTMLCollection=a.wrapNodeList,a.wrappers.HTMLCollection=a.wrappers.NodeList}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){A(a instanceof w)}function c(a){var b=new y;return b[0]=a,b.length=1,b}function d(a,b,c){C(b,"childList",{removedNodes:c,previousSibling:a.previousSibling,nextSibling:a.nextSibling})}function e(a,b){C(a,"childList",{removedNodes:b})}function f(a,b,d,e){if(a instanceof DocumentFragment){var f=h(a);O=!0;for(var g=f.length-1;g>=0;g--)a.removeChild(f[g]),f[g].parentNode_=b;O=!1;for(var g=0;ge;e++)d.appendChild(J(b[e]));return d}function q(a){if(void 0!==a.firstChild_)for(var b=a.firstChild_;b;){var c=b;b=b.nextSibling_,c.parentNode_=c.previousSibling_=c.nextSibling_=void 0}a.firstChild_=a.lastChild_=void 0}function r(a){if(a.invalidateShadowRenderer()){for(var b=a.firstChild;b;){A(b.parentNode===a);var c=b.nextSibling,d=J(b),e=d.parentNode;e&&V.call(e,d),b.previousSibling_=b.nextSibling_=b.parentNode_=null,b=c}a.firstChild_=a.lastChild_=null}else for(var c,f=J(a),g=f.firstChild;g;)c=g.nextSibling,V.call(f,g),g=c}function s(a){var b=a.parentNode;return b&&b.invalidateShadowRenderer()}function t(a){for(var b,c=0;cg;g++)e=q(b[g]),(f=p(e).root)&&f instanceof a.wrappers.ShadowRoot||(d[c++]=e);return c}function c(a,b){for(var d,e=a.firstElementChild;e;){if(e.matches(b))return e;if(d=c(e,b))return d;e=e.nextElementSibling}return null}function d(a,b){return a.matches(b)}function e(a,b,c){var d=a.localName;return d===b||d===c&&a.namespaceURI===B}function f(){return!0}function g(a,b,c){return a.localName===c}function h(a,b){return a.namespaceURI===b}function i(a,b,c){return a.namespaceURI===b&&a.localName===c}function j(a,b,c,d,e,f){for(var g=a.firstElementChild;g;)d(g,e,f)&&(c[b++]=g),b=j(g,b,c,d,e,f),g=g.nextElementSibling;return b}function k(c,d,e,f){var g,h=this.impl,i=p(this).root;if(i instanceof a.wrappers.ShadowRoot)return j(this,d,e,c,f,null);if(h instanceof z)g=u.call(h,f);else{if(!(h instanceof A))return j(this,d,e,c,f,null);g=t.call(h,f)}return b(g,d,e)}function l(c,d,e,f,g){var h,i=this.impl,k=p(this).root;if(k instanceof a.wrappers.ShadowRoot)return j(this,d,e,c,f,g);if(i instanceof z)h=w.call(i,f,g);else{if(!(i instanceof A))return j(this,d,e,c,f,g);h=v.call(i,f,g)}return b(h,d,e)}function m(c,d,e,f,g){var h,i=this.impl,k=p(this).root;if(k instanceof a.wrappers.ShadowRoot)return j(this,d,e,c,f,g);if(i instanceof z)h=y.call(i,f,g);else{if(!(i instanceof A))return j(this,d,e,c,f,g);h=x.call(i,f,g)}return b(h,d,e)}var n=a.wrappers.HTMLCollection,o=a.wrappers.NodeList,p=a.getTreeScope,q=a.wrap,r=document.querySelector,s=document.documentElement.querySelector,t=document.querySelectorAll,u=document.documentElement.querySelectorAll,v=document.getElementsByTagName,w=document.documentElement.getElementsByTagName,x=document.getElementsByTagNameNS,y=document.documentElement.getElementsByTagNameNS,z=window.Element,A=window.HTMLDocument,B="http://www.w3.org/1999/xhtml",C={querySelector:function(b){var d,e=this.impl,f=p(this).root;if(f instanceof a.wrappers.ShadowRoot)return c(this,b);if(e instanceof z)d=q(s.call(e,b));else{if(!(e instanceof A))return c(this,b);d=q(r.call(e,b))}return d&&(f=p(d).root)&&f instanceof a.wrappers.ShadowRoot?c(this,b):d},querySelectorAll:function(a){var b=new o;return b.length=k.call(this,d,0,b,a),b}},D={getElementsByTagName:function(a){var b=new n,c="*"===a?f:e;return b.length=l.call(this,c,0,b,a,a.toLowerCase()),b},getElementsByClassName:function(a){return this.querySelectorAll("."+a)},getElementsByTagNameNS:function(a,b){var c=new n,d=null;return d="*"===a?"*"===b?f:g:"*"===b?h:i,c.length=m.call(this,d,0,c,a||null,b),c}};a.GetElementsByInterface=D,a.SelectorsInterface=C}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){for(;a&&a.nodeType!==Node.ELEMENT_NODE;)a=a.nextSibling;return a}function c(a){for(;a&&a.nodeType!==Node.ELEMENT_NODE;)a=a.previousSibling;return a}var d=a.wrappers.NodeList,e={get firstElementChild(){return b(this.firstChild)},get lastElementChild(){return c(this.lastChild)},get childElementCount(){for(var a=0,b=this.firstElementChild;b;b=b.nextElementSibling)a++;return a},get children(){for(var a=new d,b=0,c=this.firstElementChild;c;c=c.nextElementSibling)a[b++]=c;return a.length=b,a},remove:function(){var a=this.parentNode;a&&a.removeChild(this)}},f={get nextElementSibling(){return b(this.nextSibling)},get previousElementSibling(){return c(this.previousSibling)}};a.ChildNodeInterface=f,a.ParentNodeInterface=e}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){d.call(this,a)}var c=a.ChildNodeInterface,d=a.wrappers.Node,e=a.enqueueMutation,f=a.mixin,g=a.registerWrapper,h=window.CharacterData;b.prototype=Object.create(d.prototype),f(b.prototype,{get textContent(){return this.data},set textContent(a){this.data=a},get data(){return this.impl.data},set data(a){var b=this.impl.data;e(this,"characterData",{oldValue:b}),this.impl.data=a}}),f(b.prototype,c),g(h,b,document.createTextNode("")),a.wrappers.CharacterData=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){return a>>>0}function c(a){d.call(this,a)}var d=a.wrappers.CharacterData,e=(a.enqueueMutation,a.mixin),f=a.registerWrapper,g=window.Text;c.prototype=Object.create(d.prototype),e(c.prototype,{splitText:function(a){a=b(a);var c=this.data;if(a>c.length)throw new Error("IndexSizeError");var d=c.slice(0,a),e=c.slice(a);this.data=d;var f=this.ownerDocument.createTextNode(e);return this.parentNode&&this.parentNode.insertBefore(f,this.nextSibling),f}}),f(g,c,document.createTextNode("")),a.wrappers.Text=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(b){a.invalidateRendererBasedOnAttribute(b,"class")}function c(a,b){this.impl=a,this.ownerElement_=b}c.prototype={get length(){return this.impl.length},item:function(a){return this.impl.item(a)},contains:function(a){return this.impl.contains(a)},add:function(){this.impl.add.apply(this.impl,arguments),b(this.ownerElement_)},remove:function(){this.impl.remove.apply(this.impl,arguments),b(this.ownerElement_)},toggle:function(){var a=this.impl.toggle.apply(this.impl,arguments);return b(this.ownerElement_),a},toString:function(){return this.impl.toString()}},a.wrappers.DOMTokenList=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(b,c){var d=b.parentNode;if(d&&d.shadowRoot){var e=a.getRendererForHost(d);e.dependsOnAttribute(c)&&e.invalidate()}}function c(a,b,c){k(a,"attributes",{name:b,namespace:null,oldValue:c})}function d(a){g.call(this,a)}var e=a.ChildNodeInterface,f=a.GetElementsByInterface,g=a.wrappers.Node,h=a.wrappers.DOMTokenList,i=a.ParentNodeInterface,j=a.SelectorsInterface,k=(a.addWrapNodeListMethod,a.enqueueMutation),l=a.mixin,m=(a.oneOf,a.registerWrapper),n=a.unwrap,o=a.wrappers,p=window.Element,q=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(a){return p.prototype[a]}),r=q[0],s=p.prototype[r],t=new WeakMap;d.prototype=Object.create(g.prototype),l(d.prototype,{createShadowRoot:function(){var b=new o.ShadowRoot(this);this.impl.polymerShadowRoot_=b;var c=a.getRendererForHost(this);return c.invalidate(),b},get shadowRoot(){return this.impl.polymerShadowRoot_||null},setAttribute:function(a,d){var e=this.impl.getAttribute(a);this.impl.setAttribute(a,d),c(this,a,e),b(this,a)},removeAttribute:function(a){var d=this.impl.getAttribute(a);this.impl.removeAttribute(a),c(this,a,d),b(this,a)},matches:function(a){return s.call(this.impl,a)},get classList(){var a=t.get(this);return a||t.set(this,a=new h(n(this).classList,this)),a},get className(){return n(this).className},set className(a){this.setAttribute("class",a)},get id(){return n(this).id},set id(a){this.setAttribute("id",a)}}),q.forEach(function(a){"matches"!==a&&(d.prototype[a]=function(a){return this.matches(a)})}),p.prototype.webkitCreateShadowRoot&&(d.prototype.webkitCreateShadowRoot=d.prototype.createShadowRoot),l(d.prototype,e),l(d.prototype,f),l(d.prototype,i),l(d.prototype,j),m(p,d,document.createElementNS(null,"x")),a.invalidateRendererBasedOnAttribute=b,a.matchesNames=q,a.wrappers.Element=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){switch(a){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"\xa0":return" "}}function c(a){return a.replace(z,b)}function d(a){return a.replace(A,b)}function e(a){for(var b={},c=0;c",B[f]?h:h+g(a)+""+f+">";case Node.TEXT_NODE:var k=a.data;return b&&C[b.localName]?k:d(k);case Node.COMMENT_NODE:return"";default:throw console.error(a),new Error("not implemented")}}function g(a){a instanceof y.HTMLTemplateElement&&(a=a.content);for(var b="",c=a.firstChild;c;c=c.nextSibling)b+=f(c,a);return b}function h(a,b,c){var d=c||"div";a.textContent="";var e=w(a.ownerDocument.createElement(d));e.innerHTML=b;for(var f;f=e.firstChild;)a.appendChild(x(f))}function i(a){o.call(this,a)}function j(a,b){var c=w(a.cloneNode(!1));c.innerHTML=b;for(var d,e=w(document.createDocumentFragment());d=c.firstChild;)e.appendChild(d);return x(e)}function k(b){return function(){return a.renderAllPending(),this.impl[b]}}function l(a){p(i,a,k(a))}function m(b){Object.defineProperty(i.prototype,b,{get:k(b),set:function(c){a.renderAllPending(),this.impl[b]=c},configurable:!0,enumerable:!0})}function n(b){Object.defineProperty(i.prototype,b,{value:function(){return a.renderAllPending(),this.impl[b].apply(this.impl,arguments)},configurable:!0,enumerable:!0})}var o=a.wrappers.Element,p=a.defineGetter,q=a.enqueueMutation,r=a.mixin,s=a.nodesWereAdded,t=a.nodesWereRemoved,u=a.registerWrapper,v=a.snapshotNodeList,w=a.unwrap,x=a.wrap,y=a.wrappers,z=/[&\u00A0"]/g,A=/[&\u00A0<>]/g,B=e(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),C=e(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),D=/MSIE/.test(navigator.userAgent),E=window.HTMLElement,F=window.HTMLTemplateElement;i.prototype=Object.create(o.prototype),r(i.prototype,{get innerHTML(){return g(this)},set innerHTML(a){if(D&&C[this.localName])return void(this.textContent=a);var b=v(this.childNodes);this.invalidateShadowRenderer()?this instanceof y.HTMLTemplateElement?h(this.content,a):h(this,a,this.tagName):!F&&this instanceof y.HTMLTemplateElement?h(this.content,a):this.impl.innerHTML=a;var c=v(this.childNodes);q(this,"childList",{addedNodes:c,removedNodes:b}),t(b),s(c,this)},get outerHTML(){return f(this,this.parentNode)},set outerHTML(a){var b=this.parentNode;if(b){b.invalidateShadowRenderer();var c=j(b,a);b.replaceChild(c,this)}},insertAdjacentHTML:function(a,b){var c,d;switch(String(a).toLowerCase()){case"beforebegin":c=this.parentNode,d=this;break;case"afterend":c=this.parentNode,d=this.nextSibling;break;case"afterbegin":c=this,d=this.firstChild;break;case"beforeend":c=this,d=null;break;default:return}var e=j(c,b);c.insertBefore(e,d)},get hidden(){return this.hasAttribute("hidden")},set hidden(a){a?this.setAttribute("hidden",""):this.removeAttribute("hidden")}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(l),["scrollLeft","scrollTop"].forEach(m),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(n),u(E,i,document.createElement("b")),a.wrappers.HTMLElement=i,a.getInnerHTML=g,a.setInnerHTML=h}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrap,g=window.HTMLCanvasElement;b.prototype=Object.create(c.prototype),d(b.prototype,{getContext:function(){var a=this.impl.getContext.apply(this.impl,arguments);return a&&f(a)}}),e(g,b,document.createElement("canvas")),a.wrappers.HTMLCanvasElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=window.HTMLContentElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get select(){return this.getAttribute("select")},set select(a){this.setAttribute("select",a)},setAttribute:function(a,b){c.prototype.setAttribute.call(this,a,b),"select"===String(a).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),f&&e(f,b),a.wrappers.HTMLContentElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrapHTMLCollection,g=a.unwrap,h=window.HTMLFormElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get elements(){return f(g(this).elements)}}),e(h,b,document.createElement("form")),a.wrappers.HTMLFormElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){d.call(this,a)}function c(a,b){if(!(this instanceof c))throw new TypeError("DOM object constructor cannot be called as a function.");var e=f(document.createElement("img"));d.call(this,e),g(e,this),void 0!==a&&(e.width=a),void 0!==b&&(e.height=b)}var d=a.wrappers.HTMLElement,e=a.registerWrapper,f=a.unwrap,g=a.rewrap,h=window.HTMLImageElement;b.prototype=Object.create(d.prototype),e(h,b,document.createElement("img")),c.prototype=b.prototype,a.wrappers.HTMLImageElement=b,a.wrappers.Image=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=(a.mixin,a.wrappers.NodeList,a.registerWrapper),e=window.HTMLShadowElement;b.prototype=Object.create(c.prototype),e&&d(e,b),a.wrappers.HTMLShadowElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){if(!a.defaultView)return a;var b=k.get(a);if(!b){for(b=a.implementation.createHTMLDocument("");b.lastChild;)b.removeChild(b.lastChild);k.set(a,b)}return b}function c(a){for(var c,d=b(a.ownerDocument),e=h(d.createDocumentFragment());c=a.firstChild;)e.appendChild(c);return e}function d(a){if(e.call(this,a),!l){var b=c(a);j.set(this,i(b))}}var e=a.wrappers.HTMLElement,f=a.mixin,g=a.registerWrapper,h=a.unwrap,i=a.wrap,j=new WeakMap,k=new WeakMap,l=window.HTMLTemplateElement;d.prototype=Object.create(e.prototype),f(d.prototype,{get content(){return l?i(this.impl.content):j.get(this)}}),l&&g(l,d),a.wrappers.HTMLTemplateElement=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.registerWrapper,e=window.HTMLMediaElement;b.prototype=Object.create(c.prototype),d(e,b,document.createElement("audio")),a.wrappers.HTMLMediaElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){d.call(this,a)}function c(a){if(!(this instanceof c))throw new TypeError("DOM object constructor cannot be called as a function.");var b=f(document.createElement("audio"));d.call(this,b),g(b,this),b.setAttribute("preload","auto"),void 0!==a&&b.setAttribute("src",a)}var d=a.wrappers.HTMLMediaElement,e=a.registerWrapper,f=a.unwrap,g=a.rewrap,h=window.HTMLAudioElement;b.prototype=Object.create(d.prototype),e(h,b,document.createElement("audio")),c.prototype=b.prototype,a.wrappers.HTMLAudioElement=b,a.wrappers.Audio=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){return a.replace(/\s+/g," ").trim()}function c(a){e.call(this,a)}function d(a,b,c,f){if(!(this instanceof d))throw new TypeError("DOM object constructor cannot be called as a function.");var g=i(document.createElement("option"));e.call(this,g),h(g,this),void 0!==a&&(g.text=a),void 0!==b&&g.setAttribute("value",b),c===!0&&g.setAttribute("selected",""),g.selected=f===!0}var e=a.wrappers.HTMLElement,f=a.mixin,g=a.registerWrapper,h=a.rewrap,i=a.unwrap,j=a.wrap,k=window.HTMLOptionElement;c.prototype=Object.create(e.prototype),f(c.prototype,{get text(){return b(this.textContent)},set text(a){this.textContent=b(String(a))},get form(){return j(i(this).form)}}),g(k,c,document.createElement("option")),d.prototype=c.prototype,a.wrappers.HTMLOptionElement=c,a.wrappers.Option=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.unwrap,g=a.wrap,h=window.HTMLSelectElement;b.prototype=Object.create(c.prototype),d(b.prototype,{add:function(a,b){"object"==typeof b&&(b=f(b)),f(this).add(f(a),b)},remove:function(a){return void 0===a?void c.prototype.remove.call(this):("object"==typeof a&&(a=f(a)),void f(this).remove(a))},get form(){return g(f(this).form)}}),e(h,b,document.createElement("select")),a.wrappers.HTMLSelectElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.unwrap,g=a.wrap,h=a.wrapHTMLCollection,i=window.HTMLTableElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get caption(){return g(f(this).caption)},createCaption:function(){return g(f(this).createCaption())},get tHead(){return g(f(this).tHead)},createTHead:function(){return g(f(this).createTHead())},createTFoot:function(){return g(f(this).createTFoot())},get tFoot(){return g(f(this).tFoot)},get tBodies(){return h(f(this).tBodies)
-},createTBody:function(){return g(f(this).createTBody())},get rows(){return h(f(this).rows)},insertRow:function(a){return g(f(this).insertRow(a))}}),e(i,b,document.createElement("table")),a.wrappers.HTMLTableElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrapHTMLCollection,g=a.unwrap,h=a.wrap,i=window.HTMLTableSectionElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get rows(){return f(g(this).rows)},insertRow:function(a){return h(g(this).insertRow(a))}}),e(i,b,document.createElement("thead")),a.wrappers.HTMLTableSectionElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrapHTMLCollection,g=a.unwrap,h=a.wrap,i=window.HTMLTableRowElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get cells(){return f(g(this).cells)},insertCell:function(a){return h(g(this).insertCell(a))}}),e(i,b,document.createElement("tr")),a.wrappers.HTMLTableRowElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){switch(a.localName){case"content":return new c(a);case"shadow":return new e(a);case"template":return new f(a)}d.call(this,a)}var c=a.wrappers.HTMLContentElement,d=a.wrappers.HTMLElement,e=a.wrappers.HTMLShadowElement,f=a.wrappers.HTMLTemplateElement,g=(a.mixin,a.registerWrapper),h=window.HTMLUnknownElement;b.prototype=Object.create(d.prototype),g(h,b),a.wrappers.HTMLUnknownElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.wrappers.Element,c=a.wrappers.HTMLElement,d=a.registerObject,e="http://www.w3.org/2000/svg",f=document.createElementNS(e,"title"),g=d(f),h=Object.getPrototypeOf(g.prototype).constructor;if(!("classList"in f)){var i=Object.getOwnPropertyDescriptor(b.prototype,"classList");Object.defineProperty(c.prototype,"classList",i),delete b.prototype.classList}a.wrappers.SVGElement=h}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){m.call(this,a)}var c=a.mixin,d=a.registerWrapper,e=a.unwrap,f=a.wrap,g=window.SVGUseElement,h="http://www.w3.org/2000/svg",i=f(document.createElementNS(h,"g")),j=document.createElementNS(h,"use"),k=i.constructor,l=Object.getPrototypeOf(k.prototype),m=l.constructor;b.prototype=Object.create(l),"instanceRoot"in j&&c(b.prototype,{get instanceRoot(){return f(e(this).instanceRoot)},get animatedInstanceRoot(){return f(e(this).animatedInstanceRoot)}}),d(g,b,j),a.wrappers.SVGUseElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.EventTarget,d=a.mixin,e=a.registerWrapper,f=a.wrap,g=window.SVGElementInstance;g&&(b.prototype=Object.create(c.prototype),d(b.prototype,{get correspondingElement(){return f(this.impl.correspondingElement)},get correspondingUseElement(){return f(this.impl.correspondingUseElement)},get parentNode(){return f(this.impl.parentNode)},get childNodes(){throw new Error("Not implemented")},get firstChild(){return f(this.impl.firstChild)},get lastChild(){return f(this.impl.lastChild)},get previousSibling(){return f(this.impl.previousSibling)},get nextSibling(){return f(this.impl.nextSibling)}}),e(g,b),a.wrappers.SVGElementInstance=b)}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.mixin,d=a.registerWrapper,e=a.unwrap,f=a.unwrapIfNeeded,g=a.wrap,h=window.CanvasRenderingContext2D;c(b.prototype,{get canvas(){return g(this.impl.canvas)},drawImage:function(){arguments[0]=f(arguments[0]),this.impl.drawImage.apply(this.impl,arguments)},createPattern:function(){return arguments[0]=e(arguments[0]),this.impl.createPattern.apply(this.impl,arguments)}}),d(h,b,document.createElement("canvas").getContext("2d")),a.wrappers.CanvasRenderingContext2D=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.mixin,d=a.registerWrapper,e=a.unwrapIfNeeded,f=a.wrap,g=window.WebGLRenderingContext;if(g){c(b.prototype,{get canvas(){return f(this.impl.canvas)},texImage2D:function(){arguments[5]=e(arguments[5]),this.impl.texImage2D.apply(this.impl,arguments)},texSubImage2D:function(){arguments[6]=e(arguments[6]),this.impl.texSubImage2D.apply(this.impl,arguments)}});var h=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};d(g,b,h),a.wrappers.WebGLRenderingContext=b}}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.registerWrapper,d=a.unwrap,e=a.unwrapIfNeeded,f=a.wrap,g=window.Range;b.prototype={get startContainer(){return f(this.impl.startContainer)},get endContainer(){return f(this.impl.endContainer)},get commonAncestorContainer(){return f(this.impl.commonAncestorContainer)},setStart:function(a,b){this.impl.setStart(e(a),b)},setEnd:function(a,b){this.impl.setEnd(e(a),b)},setStartBefore:function(a){this.impl.setStartBefore(e(a))},setStartAfter:function(a){this.impl.setStartAfter(e(a))},setEndBefore:function(a){this.impl.setEndBefore(e(a))},setEndAfter:function(a){this.impl.setEndAfter(e(a))},selectNode:function(a){this.impl.selectNode(e(a))},selectNodeContents:function(a){this.impl.selectNodeContents(e(a))},compareBoundaryPoints:function(a,b){return this.impl.compareBoundaryPoints(a,d(b))},extractContents:function(){return f(this.impl.extractContents())},cloneContents:function(){return f(this.impl.cloneContents())},insertNode:function(a){this.impl.insertNode(e(a))},surroundContents:function(a){this.impl.surroundContents(e(a))},cloneRange:function(){return f(this.impl.cloneRange())},isPointInRange:function(a,b){return this.impl.isPointInRange(e(a),b)},comparePoint:function(a,b){return this.impl.comparePoint(e(a),b)},intersectsNode:function(a){return this.impl.intersectsNode(e(a))},toString:function(){return this.impl.toString()}},g.prototype.createContextualFragment&&(b.prototype.createContextualFragment=function(a){return f(this.impl.createContextualFragment(a))}),c(window.Range,b,document.createRange()),a.wrappers.Range=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.GetElementsByInterface,c=a.ParentNodeInterface,d=a.SelectorsInterface,e=a.mixin,f=a.registerObject,g=f(document.createDocumentFragment());e(g.prototype,c),e(g.prototype,d),e(g.prototype,b);var h=f(document.createComment(""));a.wrappers.Comment=h,a.wrappers.DocumentFragment=g}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){var b=k(a.impl.ownerDocument.createDocumentFragment());c.call(this,b),i(b,this);var e=a.shadowRoot;m.set(this,e),this.treeScope_=new d(this,g(e||a)),l.set(this,a)}var c=a.wrappers.DocumentFragment,d=a.TreeScope,e=a.elementFromPoint,f=a.getInnerHTML,g=a.getTreeScope,h=a.mixin,i=a.rewrap,j=a.setInnerHTML,k=a.unwrap,l=new WeakMap,m=new WeakMap,n=/[ \t\n\r\f]/;b.prototype=Object.create(c.prototype),h(b.prototype,{get innerHTML(){return f(this)},set innerHTML(a){j(this,a),this.invalidateShadowRenderer()},get olderShadowRoot(){return m.get(this)||null},get host(){return l.get(this)||null},invalidateShadowRenderer:function(){return l.get(this).invalidateShadowRenderer()},elementFromPoint:function(a,b){return e(this,this.ownerDocument,a,b)},getElementById:function(a){return n.test(a)?null:this.querySelector('[id="'+a+'"]')}}),a.wrappers.ShadowRoot=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){a.previousSibling_=a.previousSibling,a.nextSibling_=a.nextSibling,a.parentNode_=a.parentNode}function c(a,c,e){var f=G(a),g=G(c),h=e?G(e):null;if(d(c),b(c),e)a.firstChild===e&&(a.firstChild_=e),e.previousSibling_=e.previousSibling;else{a.lastChild_=a.lastChild,a.lastChild===a.firstChild&&(a.firstChild_=a.firstChild);var i=H(f.lastChild);i&&(i.nextSibling_=i.nextSibling)}f.insertBefore(g,h)}function d(a){var c=G(a),d=c.parentNode;if(d){var e=H(d);b(a),a.previousSibling&&(a.previousSibling.nextSibling_=a),a.nextSibling&&(a.nextSibling.previousSibling_=a),e.lastChild===a&&(e.lastChild_=a),e.firstChild===a&&(e.firstChild_=a),d.removeChild(c)}}function e(a){I.set(a,[])}function f(a){var b=I.get(a);return b||I.set(a,b=[]),b}function g(a){for(var b=[],c=0,d=a.firstChild;d;d=d.nextSibling)b[c++]=d;return b}function h(){for(var a=0;ap;p++){var q=H(f[k++]);h.get(q)||d(q)}for(var r=n.addedCount,s=f[k]&&H(f[k]),p=0;r>p;p++){var t=e[j++],u=t.node;c(b,u,s),h.set(u,!0),t.sync(h)}l+=r}for(var m=l;m=0;e--){var f=d[e],g=p(f);if(g){var h=f.olderShadowRoot;h&&(c=o(h));for(var i=0;i=0;k--)j=Object.create(j);["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(a){var b=e[a];b&&(j[a]=function(){A(this)instanceof d||y(this),b.apply(A(this),arguments)})});var l={prototype:j};f&&(l.extends=f),d.prototype=e,d.prototype.constructor=d,a.constructorTable.set(j,d),a.nativePrototypeTable.set(e,j);F.call(z(this),b,l);return d},t([window.HTMLDocument||window.Document],["registerElement"])}t([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"].concat(u)),t([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","elementFromPoint","getElementById","getElementsByName","getSelection"]),v(b.prototype,j),v(b.prototype,l),v(b.prototype,n),v(b.prototype,{get implementation(){var a=C.get(this);return a?a:(a=new g(z(this).implementation),C.set(this,a),a)},get defaultView(){return A(z(this).defaultView)}}),w(window.Document,b,document.implementation.createHTMLDocument("")),window.HTMLDocument&&w(window.HTMLDocument,b),B([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),h(g,"createDocumentType"),h(g,"createDocument"),h(g,"createHTMLDocument"),i(g,"hasFeature"),w(window.DOMImplementation,g),t([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),a.adoptNodeNoRemove=d,a.wrappers.DOMImplementation=g,a.wrappers.Document=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.EventTarget,d=a.wrappers.Selection,e=a.mixin,f=a.registerWrapper,g=a.renderAllPending,h=a.unwrap,i=a.unwrapIfNeeded,j=a.wrap,k=window.Window,l=window.getComputedStyle,m=window.getDefaultComputedStyle,n=window.getSelection;b.prototype=Object.create(c.prototype),k.prototype.getComputedStyle=function(a,b){return j(this||window).getComputedStyle(i(a),b)},m&&(k.prototype.getDefaultComputedStyle=function(a,b){return j(this||window).getDefaultComputedStyle(i(a),b)}),k.prototype.getSelection=function(){return j(this||window).getSelection()},delete window.getComputedStyle,delete window.getSelection,["addEventListener","removeEventListener","dispatchEvent"].forEach(function(a){k.prototype[a]=function(){var b=j(this||window);return b[a].apply(b,arguments)},delete window[a]}),e(b.prototype,{getComputedStyle:function(a,b){return g(),l.call(h(this),i(a),b)},getSelection:function(){return g(),new d(n.call(h(this)))},get document(){return j(h(this).document)}}),m&&(b.prototype.getDefaultComputedStyle=function(a,b){return g(),m.call(h(this),i(a),b)}),f(k,b,window),a.wrappers.Window=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.unwrap,c=window.DataTransfer||window.Clipboard,d=c.prototype.setDragImage;d&&(c.prototype.setDragImage=function(a,c,e){d.call(this,b(a),c,e)})}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a instanceof e?a:new e(a&&d(a))}var c=a.registerWrapper,d=a.unwrap,e=window.FormData;c(e,b,new e),a.wrappers.FormData=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){var b=c[a],d=window[b];if(d){var e=document.createElement(a),f=e.constructor;window[b]=f}}var c=(a.isWrapperFor,{a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"});Object.keys(c).forEach(b),Object.getOwnPropertyNames(a.wrappers).forEach(function(b){window[b]=a.wrappers[b]})}(window.ShadowDOMPolyfill),function(a){function b(a,c){var d,e,f,g,h=a.firstElementChild;for(e=[],f=a.shadowRoot;f;)e.push(f),f=f.olderShadowRoot;for(g=e.length-1;g>=0;g--)if(d=e[g].querySelector(c))return d;for(;h;){if(d=b(h,c))return d;h=h.nextElementSibling}return null}function c(a,b,d){var e,f,g,h,i,j=a.firstElementChild;for(g=[],f=a.shadowRoot;f;)g.push(f),f=f.olderShadowRoot;for(h=g.length-1;h>=0;h--)for(e=g[h].querySelectorAll(b),i=0;id&&(c=b[d]);d++)c.parentNode.removeChild(c)},registerRoot:function(a,b,c){var d=this.registry[b]={root:a,name:b,extendsName:c},e=this.findStyles(a);d.rootStyles=e,d.scopeStyles=d.rootStyles;var f=this.registry[d.extendsName];return f&&(d.scopeStyles=f.scopeStyles.concat(d.scopeStyles)),d},findStyles:function(a){if(!a)return[];var b=a.querySelectorAll("style");return Array.prototype.filter.call(b,function(a){return!a.hasAttribute(A)})},applyScopeToContent:function(a,b){a&&(Array.prototype.forEach.call(a.querySelectorAll("*"),function(a){a.setAttribute(b,"")}),Array.prototype.forEach.call(a.querySelectorAll("template"),function(a){this.applyScopeToContent(a.content,b)},this))},insertDirectives:function(a){return a=this.insertPolyfillDirectivesInCssText(a),this.insertPolyfillRulesInCssText(a)},insertPolyfillDirectivesInCssText:function(a){return a=a.replace(m,function(a,b){return b.slice(0,-2)+"{"}),a.replace(n,function(a,b){return b+" {"})},insertPolyfillRulesInCssText:function(a){return a=a.replace(o,function(a,b){return b.slice(0,-1)}),a.replace(p,function(a,b,c,d){var e=a.replace(b,"").replace(c,"");return d+e})},scopeCssText:function(a,b){var c=this.extractUnscopedRulesFromCssText(a);if(a=this.insertPolyfillHostInCssText(a),a=this.convertColonHost(a),a=this.convertColonHostContext(a),a=this.convertShadowDOMSelectors(a),b){var a,d=this;g(a,function(c){a=d.scopeRules(c,b)})}return a=a+"\n"+c,a.trim()},extractUnscopedRulesFromCssText:function(a){for(var b,c="";b=q.exec(a);)c+=b[1].slice(0,-1)+"\n\n";for(;b=r.exec(a);)c+=b[0].replace(b[2],"").replace(b[1],b[3])+"\n\n";return c},convertColonHost:function(a){return this.convertColonRule(a,cssColonHostRe,this.colonHostPartReplacer)},convertColonHostContext:function(a){return this.convertColonRule(a,cssColonHostContextRe,this.colonHostContextPartReplacer)},convertColonRule:function(a,b,c){return a.replace(b,function(a,b,d,e){if(b=polyfillHostNoCombinator,d){for(var f,g=d.split(","),h=[],i=0,j=g.length;j>i&&(f=g[i]);i++)f=f.trim(),h.push(c(b,f,e));return h.join(",")}return b+e})},colonHostContextPartReplacer:function(a,b,c){return b.match(s)?this.colonHostPartReplacer(a,b,c):a+b+c+", "+b+" "+a+c},colonHostPartReplacer:function(a,b,c){return a+b.replace(s,"")+c},convertShadowDOMSelectors:function(a){for(var b=0;b","+","~"],d=a,e="["+b+"]";return c.forEach(function(a){var b=d.split(a);d=b.map(function(a){var b=a.trim().replace(polyfillHostRe,"");return b&&c.indexOf(b)<0&&b.indexOf(e)<0&&(a=b.replace(/([^:]*)(:*)(.*)/,"$1"+e+"$2$3")),a}).join(a)}),d},insertPolyfillHostInCssText:function(a){return a.replace(colonHostContextRe,t).replace(colonHostRe,s)},propertiesFromRule:function(a){var b=a.style.cssText;a.style.content&&!a.style.content.match(/['"]+|attr/)&&(b=b.replace(/content:[^;]*;/g,"content: '"+a.style.content+"';"));var c=a.style;for(var d in c)"initial"===c[d]&&(b+=d+": initial; ");return b},replaceTextInStyles:function(a,b){a&&b&&(a instanceof Array||(a=[a]),Array.prototype.forEach.call(a,function(a){a.textContent=b.call(this,a.textContent)},this))},addCssToDocument:function(a,b){a.match("@import")?i(a,b):h(a)}},l=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,m=/\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,n=/polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,o=/\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,p=/(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,q=/\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,r=/(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,s="-shadowcsshost",t="-shadowcsscontext",u=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";cssColonHostRe=new RegExp("("+s+u,"gim"),cssColonHostContextRe=new RegExp("("+t+u,"gim"),selectorReSuffix="([>\\s~+[.,{:][\\s\\S]*)?$",colonHostRe=/\:host/gim,colonHostContextRe=/\:host-context/gim,polyfillHostNoCombinator=s+"-no-combinator",polyfillHostRe=new RegExp(s,"gim"),polyfillHostContextRe=new RegExp(t,"gim"),shadowDOMSelectorsRe=[/\^\^/g,/\^/g,/\/shadow\//g,/\/shadow-deep\//g,/::shadow/g,/\/deep\//g,/::content/g];var v=document.createElement("iframe");v.style.display="none";var w,x=navigator.userAgent.match("Chrome"),y="shim-shadowdom",z="shim-shadowdom-css",A="no-shim";if(window.ShadowDOMPolyfill){h("style { display: none !important; }\n");var B=wrap(document),C=B.querySelector("head");C.insertBefore(j(),C.childNodes[0]),document.addEventListener("DOMContentLoaded",function(){var b=a.urlResolver;if(window.HTMLImports&&!HTMLImports.useNative){var c="link[rel=stylesheet]["+y+"]",d="style["+y+"]";HTMLImports.importer.documentPreloadSelectors+=","+c,HTMLImports.importer.importsPreloadSelectors+=","+c,HTMLImports.parser.documentSelectors=[HTMLImports.parser.documentSelectors,c,d].join(",");var e=HTMLImports.parser.parseGeneric;HTMLImports.parser.parseGeneric=function(a){if(!a[z]){var c=a.__importElement||a;if(!c.hasAttribute(y))return void e.call(this,a);a.__resource?(c=a.ownerDocument.createElement("style"),c.textContent=b.resolveCssText(a.__resource,a.href)):b.resolveStyle(c),c.textContent=k.shimStyle(c),c.removeAttribute(y,""),c.setAttribute(z,""),c[z]=!0,c.parentNode!==C&&(a.parentNode===C?C.replaceChild(c,a):this.addElementToDocument(c)),c.__importParsed=!0,this.markParsingComplete(a),this.parseNext()}};var f=HTMLImports.parser.hasResource;HTMLImports.parser.hasResource=function(a){return"link"===a.localName&&"stylesheet"===a.rel&&a.hasAttribute(y)?a.__resource:f.call(this,a)}}})}a.ShadowCSS=k}(window.Platform)):!function(){window.wrap=window.unwrap=function(a){return a
-},addEventListener("DOMContentLoaded",function(){if(CustomElements.useNative===!1){var a=Element.prototype.createShadowRoot;Element.prototype.createShadowRoot=function(){var b=a.call(this);return CustomElements.watchShadow(this),b}}}),Platform.templateContent=function(a){if(window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(a),!a.content&&!a._content){for(var b=document.createDocumentFragment();a.firstChild;)b.appendChild(a.firstChild);a._content=b}return a.content||a._content}}(window.Platform),function(a){"use strict";function b(a){return void 0!==m[a]}function c(){h.call(this),this._isInvalid=!0}function d(a){return""==a&&c.call(this),a.toLowerCase()}function e(a){var b=a.charCodeAt(0);return b>32&&127>b&&-1==[34,35,60,62,63,96].indexOf(b)?a:encodeURIComponent(a)}function f(a){var b=a.charCodeAt(0);return b>32&&127>b&&-1==[34,35,60,62,96].indexOf(b)?a:encodeURIComponent(a)}function g(a,g,h){function i(a){t.push(a)}var j=g||"scheme start",k=0,l="",r=!1,s=!1,t=[];a:for(;(a[k-1]!=o||0==k)&&!this._isInvalid;){var u=a[k];switch(j){case"scheme start":if(!u||!p.test(u)){if(g){i("Invalid scheme.");break a}l="",j="no scheme";continue}l+=u.toLowerCase(),j="scheme";break;case"scheme":if(u&&q.test(u))l+=u.toLowerCase();else{if(":"!=u){if(g){if(o==u)break a;i("Code point not allowed in scheme: "+u);break a}l="",k=0,j="no scheme";continue}if(this._scheme=l,l="",g)break a;b(this._scheme)&&(this._isRelative=!0),j="file"==this._scheme?"relative":this._isRelative&&h&&h._scheme==this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":"?"==u?(query="?",j="query"):"#"==u?(this._fragment="#",j="fragment"):o!=u&&" "!=u&&"\n"!=u&&"\r"!=u&&(this._schemeData+=e(u));break;case"no scheme":if(h&&b(h._scheme)){j="relative";continue}i("Missing scheme."),c.call(this);break;case"relative or authority":if("/"!=u||"/"!=a[k+1]){i("Expected /, got: "+u),j="relative";continue}j="authority ignore slashes";break;case"relative":if(this._isRelative=!0,"file"!=this._scheme&&(this._scheme=h._scheme),o==u){this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query=h._query;break a}if("/"==u||"\\"==u)"\\"==u&&i("\\ is an invalid code point."),j="relative slash";else if("?"==u)this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query="?",j="query";else{if("#"!=u){var v=a[k+1],w=a[k+2];("file"!=this._scheme||!p.test(u)||":"!=v&&"|"!=v||o!=w&&"/"!=w&&"\\"!=w&&"?"!=w&&"#"!=w)&&(this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._path.pop()),j="relative path";continue}this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query=h._query,this._fragment="#",j="fragment"}break;case"relative slash":if("/"!=u&&"\\"!=u){"file"!=this._scheme&&(this._host=h._host,this._port=h._port),j="relative path";continue}"\\"==u&&i("\\ is an invalid code point."),j="file"==this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!=u){i("Expected '/', got: "+u),j="authority ignore slashes";continue}j="authority second slash";break;case"authority second slash":if(j="authority ignore slashes","/"!=u){i("Expected '/', got: "+u);continue}break;case"authority ignore slashes":if("/"!=u&&"\\"!=u){j="authority";continue}i("Expected authority, got: "+u);break;case"authority":if("@"==u){r&&(i("@ already seen."),l+="%40"),r=!0;for(var x=0;x')})}),a.createDOM=b}(window.Platform),function(a){a.templateContent=a.templateContent||function(a){return a.content}}(window.Platform),function(a){a=a||(window.Inspector={});var b;window.sinspect=function(a,d){b||(b=window.open("","ShadowDOM Inspector",null,!0),b.document.write(c),b.api={shadowize:shadowize}),f(a||wrap(document.body),d)};var c=["",""," "," ShadowDOM Inspector "," "," "," ",' ",'
'," ",""].join("\n"),d=[],e=function(){var a=b.document,c=a.querySelector("#crumbs");c.textContent="";for(var e,g=0;e=d[g];g++){var h=a.createElement("a");h.href="#",h.textContent=e.localName,h.idx=g,h.onclick=function(a){for(var b;d.length>this.idx;)b=d.pop();f(b.shadow||b,b),a.preventDefault()},c.appendChild(a.createElement("li")).appendChild(h)}},f=function(a,c){var f=b.document;k=[];var g=c||a;d.push(g),e(),f.body.querySelector("#tree").innerHTML=""+j(a,a.childNodes)+" "},g=Array.prototype.forEach.call.bind(Array.prototype.forEach),h={STYLE:1,SCRIPT:1,"#comment":1,TEMPLATE:1},i=function(a){return h[a.nodeName]},j=function(a,b,c){if(i(a))return"";var d=c||"";if(a.localName||11==a.nodeType){var e=a.localName||"shadow-root",f=d+l(a);"content"==e&&(b=a.getDistributedNodes()),f+=" ";var h=d+" ";g(b,function(a){f+=j(a,a.childNodes,h)}),f+=d,{br:1}[e]||(f+="</"+e+"> ",f+=" ")}else{var k=a.textContent.trim();f=k?d+'"'+k+'" ':""}return f},k=[],l=function(a){var b="<",c=a.localName||"shadow-root";return a.webkitShadowRoot||a.shadowRoot?(b+=' '+c+" ",k.push(a)):b+=c||"shadow-root",a.attributes&&g(a.attributes,function(a){b+=" "+a.name+(a.value?'="'+a.value+'"':"")}),b+="> "};shadowize=function(){var a=Number(this.attributes.idx.value),b=k[a];b?f(b.webkitShadowRoot||b.shadowRoot,b):(console.log("bad shadowize node"),console.dir(this))},a.output=j}(window.Inspector),function(){var a=document.createElement("style");a.textContent="body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; } \n";var b=document.querySelector("head");b.insertBefore(a,b.firstChild)}(Platform),function(a){function b(a,b){return b=b||[],b.map||(b=[b]),a.apply(this,b.map(d))}function c(a,c,d){var e;switch(arguments.length){case 0:return;case 1:e=null;break;case 2:e=c.apply(this);break;default:e=b(d,c)}f[a]=e}function d(a){return f[a]}function e(a,c){HTMLImports.whenImportsReady(function(){b(c,a)})}var f={};a.marshal=d,a.modularize=c,a.using=e}(window),function(a){function b(a){f.textContent=d++,e.push(a)}function c(){for(;e.length;)e.shift()()}var d=0,e=[],f=document.createTextNode("");new(window.MutationObserver||JsMutationObserver)(c).observe(f,{characterData:!0}),a.endOfMicrotask=b}(Platform),function(a){function b(a,b,d,e){return a.replace(e,function(a,e,f,g){var h=f.replace(/["']/g,"");return h=c(b,h,d),e+"'"+h+"'"+g})}function c(a,b,c){if(b&&"/"===b[0])return b;var e=new URL(b,a);return c?e.href:d(e.href)}function d(a){var b=new URL(document.baseURI),c=new URL(a,b);return c.host===b.host&&c.port===b.port&&c.protocol===b.protocol?e(b,c):a}function e(a,b){for(var c=a.pathname,d=b.pathname,e=c.split("/"),f=d.split("/");e.length&&e[0]===f[0];)e.shift(),f.shift();for(var g=0,h=e.length-1;h>g;g++)f.unshift("..");return f.join("/")+b.search+b.hash}var f={resolveDom:function(a,b){b=b||a.ownerDocument.baseURI,this.resolveAttributes(a,b),this.resolveStyles(a,b);var c=a.querySelectorAll("template");if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)d.content&&this.resolveDom(d.content,b)},resolveTemplate:function(a){this.resolveDom(a.content,a.ownerDocument.baseURI)},resolveStyles:function(a,b){var c=a.querySelectorAll("style");if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)this.resolveStyle(d,b)},resolveStyle:function(a,b){b=b||a.ownerDocument.baseURI,a.textContent=this.resolveCssText(a.textContent,b)},resolveCssText:function(a,c,d){return a=b(a,c,d,g),b(a,c,d,h)},resolveAttributes:function(a,b){a.hasAttributes&&a.hasAttributes()&&this.resolveElementAttributes(a,b);var c=a&&a.querySelectorAll(j);if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)this.resolveElementAttributes(d,b)},resolveElementAttributes:function(a,d){d=d||a.ownerDocument.baseURI,i.forEach(function(e){var f,h=a.attributes[e],i=h&&h.value;i&&i.search(k)<0&&(f="style"===e?b(i,d,!1,g):c(d,i),h.value=f)})}},g=/(url\()([^)]*)(\))/g,h=/(@import[\s]+(?!url\())([^;]*)(;)/g,i=["href","src","action","style","url"],j="["+i.join("],[")+"]",k="{{.*}}";a.urlResolver=f}(Platform),function(a){function b(a){u.push(a),t||(t=!0,q(d))}function c(a){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(a)||a}function d(){t=!1;var a=u;u=[],a.sort(function(a,b){return a.uid_-b.uid_});var b=!1;a.forEach(function(a){var c=a.takeRecords();e(a),c.length&&(a.callback_(c,a),b=!0)}),b&&d()}function e(a){a.nodes_.forEach(function(b){var c=p.get(b);c&&c.forEach(function(b){b.observer===a&&b.removeTransientObservers()})})}function f(a,b){for(var c=a;c;c=c.parentNode){var d=p.get(c);if(d)for(var e=0;e0){var e=c[d-1],f=n(e,a);if(f)return void(c[d-1]=f)}else b(this.observer);c[d]=a},addListeners:function(){this.addListeners_(this.target)},addListeners_:function(a){var b=this.options;b.attributes&&a.addEventListener("DOMAttrModified",this,!0),b.characterData&&a.addEventListener("DOMCharacterDataModified",this,!0),b.childList&&a.addEventListener("DOMNodeInserted",this,!0),(b.childList||b.subtree)&&a.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},removeListeners_:function(a){var b=this.options;b.attributes&&a.removeEventListener("DOMAttrModified",this,!0),b.characterData&&a.removeEventListener("DOMCharacterDataModified",this,!0),b.childList&&a.removeEventListener("DOMNodeInserted",this,!0),(b.childList||b.subtree)&&a.removeEventListener("DOMNodeRemoved",this,!0)},addTransientObserver:function(a){if(a!==this.target){this.addListeners_(a),this.transientObservedNodes.push(a);var b=p.get(a);b||p.set(a,b=[]),b.push(this)}},removeTransientObservers:function(){var a=this.transientObservedNodes;this.transientObservedNodes=[],a.forEach(function(a){this.removeListeners_(a);for(var b=p.get(a),c=0;cc&&(b=a[c]);c++)this.require(b);this.checkDone()},addNode:function(a){this.inflight++,this.require(a),this.checkDone()},require:function(a){var b=a.src||a.href;a.__nodeUrl=b,this.dedupe(b,a)||this.fetch(b,a)},dedupe:function(a,b){if(this.pending[a])return this.pending[a].push(b),!0;return this.cache[a]?(this.onload(a,b,this.cache[a]),this.tail(),!0):(this.pending[a]=[b],!1)},fetch:function(a,d){if(c.load&&console.log("fetch",a,d),a.match(/^data:/)){var e=a.split(","),f=e[0],g=e[1];g=f.indexOf(";base64")>-1?atob(g):decodeURIComponent(g),setTimeout(function(){this.receive(a,d,null,g)}.bind(this),0)}else{var h=function(b,c,e){this.receive(a,d,b,c,e)}.bind(this);b.load(a,h)}},receive:function(a,b,c,d,e){this.cache[a]=d;var f=this.pending[a];e&&e!==a&&(this.cache[e]=d,f=f.concat(this.pending[e]));for(var g,h=0,i=f.length;i>h&&(g=f[h]);h++)this.onload(e||a,g,d),this.tail();this.pending[a]=null,e&&e!==a&&(this.pending[e]=null)},tail:function(){--this.inflight,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},b=b||{async:!0,ok:function(a){return a.status>=200&&a.status<300||304===a.status||0===a.status},load:function(c,d,e){var f=new XMLHttpRequest;return(a.flags.debug||a.flags.bust)&&(c+="?"+Math.random()),f.open("GET",c,b.async),f.addEventListener("readystatechange",function(){if(4===f.readyState){var a=f.getResponseHeader("Location"),c=null;if(a)var c="/"===a.substr(0,1)?location.origin+a:c;d.call(e,!b.ok(f)&&f,f.response||f.responseText,c)}}),f.send(),f},loadDocument:function(a,b,c){this.load(a,b,c).responseType="document"}},a.xhr=b,a.Loader=d}(window.HTMLImports),function(a){function b(a){return"link"===a.localName&&a.rel===g}function c(a){var b=d(a),c="data:text/javascript";try{c+=";base64,"+btoa(b)}catch(e){c+=";charset=utf-8,"+encodeURIComponent(b)}return c}function d(a){return a.textContent+e(a)}function e(a){var b=a.__nodeUrl;if(!b){b=a.ownerDocument.baseURI;var c="["+Math.floor(1e3*(Math.random()+1))+"]",d=a.textContent.match(/Polymer\(['"]([^'"]*)/);c=d&&d[1]||c,b+="/"+c+".js"}return"\n//# sourceURL="+b+"\n"}function f(a){var b=a.ownerDocument.createElement("style");return b.textContent=a.textContent,n.resolveUrlsInStyle(b),b}var g="import",h=a.flags,i=/Trident/.test(navigator.userAgent),j=window.ShadowDOMPolyfill?window.ShadowDOMPolyfill.wrapIfNeeded(document):document,k={documentSelectors:"link[rel="+g+"]",importsSelectors:["link[rel="+g+"]","link[rel=stylesheet]","style","script:not([type])",'script[type="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},parseNext:function(){var a=this.nextToParse();a&&this.parse(a)},parse:function(a){if(this.isParsed(a))return void(h.parse&&console.log("[%s] is already parsed",a.localName));var b=this[this.map[a.localName]];b&&(this.markParsing(a),b.call(this,a))},markParsing:function(a){h.parse&&console.log("parsing",a),this.parsingElement=a},markParsingComplete:function(a){a.__importParsed=!0,a.__importElement&&(a.__importElement.__importParsed=!0),this.parsingElement=null,h.parse&&console.log("completed",a)},invalidateParse:function(a){a&&a.__importLink&&(a.__importParsed=a.__importLink.__importParsed=!1,this.parseSoon())},parseSoon:function(){this._parseSoon&&cancelAnimationFrame(this._parseDelay);var a=this;this._parseSoon=requestAnimationFrame(function(){a.parseNext()})},parseImport:function(a){if(HTMLImports.__importsParsingHook&&HTMLImports.__importsParsingHook(a),a.import.__importParsed=!0,this.markParsingComplete(a),a.dispatchEvent(a.__resource?new CustomEvent("load",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),a.__pending)for(var b;a.__pending.length;)b=a.__pending.shift(),b&&b({target:a});this.parseNext()},parseLink:function(a){b(a)?this.parseImport(a):(a.href=a.href,this.parseGeneric(a))},parseStyle:function(a){var b=a;a=f(a),a.__importElement=b,this.parseGeneric(a)},parseGeneric:function(a){this.trackElement(a),this.addElementToDocument(a)},rootImportForElement:function(a){for(var b=a;b.ownerDocument.__importLink;)b=b.ownerDocument.__importLink;return b},addElementToDocument:function(a){for(var b=this.rootImportForElement(a.__importElement||a),c=b.__insertedElements=b.__insertedElements||0,d=b.nextElementSibling,e=0;c>e;e++)d=d&&d.nextElementSibling;b.parentNode.insertBefore(a,d)},trackElement:function(a,b){var c=this,d=function(d){b&&b(d),c.markParsingComplete(a),c.parseNext()};if(a.addEventListener("load",d),a.addEventListener("error",d),i&&"style"===a.localName){var e=!1;if(-1==a.textContent.indexOf("@import"))e=!0;else if(a.sheet){e=!0;for(var f,g=a.sheet.cssRules,h=g?g.length:0,j=0;h>j&&(f=g[j]);j++)f.type===CSSRule.IMPORT_RULE&&(e=e&&Boolean(f.styleSheet))}e&&a.dispatchEvent(new CustomEvent("load",{bubbles:!1}))}},parseScript:function(b){var d=document.createElement("script");d.__importElement=b,d.src=b.src?b.src:c(b),a.currentScript=b,this.trackElement(d,function(){d.parentNode.removeChild(d),a.currentScript=null}),this.addElementToDocument(d)},nextToParse:function(){return!this.parsingElement&&this.nextToParseInDoc(j)},nextToParseInDoc:function(a,c){for(var d,e=a.querySelectorAll(this.parseSelectorsForNode(a)),f=0,g=e.length;g>f&&(d=e[f]);f++)if(!this.isParsed(d))return this.hasResource(d)?b(d)?this.nextToParseInDoc(d.import,d):d:void 0;return c},parseSelectorsForNode:function(a){var b=a.ownerDocument||a;return b===j?this.documentSelectors:this.importsSelectors},isParsed:function(a){return a.__importParsed},hasResource:function(a){return b(a)&&!a.import?!1:!0}},l=/(url\()([^)]*)(\))/g,m=/(@import[\s]+(?!url\())([^;]*)(;)/g,n={resolveUrlsInStyle:function(a){var b=a.ownerDocument,c=b.createElement("a");return a.textContent=this.resolveUrlsInCssText(a.textContent,c),a},resolveUrlsInCssText:function(a,b){var c=this.replaceUrls(a,b,l);return c=this.replaceUrls(c,b,m)},replaceUrls:function(a,b,c){return a.replace(c,function(a,c,d,e){var f=d.replace(/["']/g,"");return b.href=f,f=b.href,c+"'"+f+"'"+e})}};a.parser=k,a.path=n,a.isIE=i}(HTMLImports),function(a){function b(a){return c(a,q)}function c(a,b){return"link"===a.localName&&a.getAttribute("rel")===b}function d(a,b){var c=a;c instanceof Document||(c=document.implementation.createHTMLDocument(q)),c._URL=b;var d=c.createElement("base");d.setAttribute("href",b),c.baseURI||(c.baseURI=b);var e=c.createElement("meta");return e.setAttribute("charset","utf-8"),c.head.appendChild(e),c.head.appendChild(d),a instanceof Document||(c.body.innerHTML=a),window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(c),c}function e(a,b){b=b||r,g(function(){h(a,b)},b)}function f(a){return"complete"===a.readyState||a.readyState===y}function g(a,b){if(f(b))a&&a();else{var c=function(){("complete"===b.readyState||b.readyState===y)&&(b.removeEventListener(z,c),g(a,b))};b.addEventListener(z,c)}}function h(a,b){function c(){f==g&&a&&a()}function d(){f++,c()}var e=b.querySelectorAll("link[rel=import]"),f=0,g=e.length;if(g)for(var h,j=0;g>j&&(h=e[j]);j++)i(h)?d.call(h):(h.addEventListener("load",d),h.addEventListener("error",d));else c()}function i(a){return o?a.import&&"loading"!==a.import.readyState||a.__loaded:a.__importParsed}function j(a){for(var b,c=0,d=a.length;d>c&&(b=a[c]);c++)k(b)&&l(b)}function k(a){return"link"===a.localName&&"import"===a.rel}function l(a){var b=a.import;b?m({target:a}):(a.addEventListener("load",m),a.addEventListener("error",m))}function m(a){a.target.__loaded=!0}var n="import"in document.createElement("link"),o=n,p=a.flags,q="import",r=window.ShadowDOMPolyfill?ShadowDOMPolyfill.wrapIfNeeded(document):document;if(o)var s={};else var t=(a.xhr,a.Loader),u=a.parser,s={documents:{},documentPreloadSelectors:"link[rel="+q+"]",importsPreloadSelectors:["link[rel="+q+"]"].join(","),loadNode:function(a){v.addNode(a)},loadSubtree:function(a){var b=this.marshalNodes(a);v.addNodes(b)},marshalNodes:function(a){return a.querySelectorAll(this.loadSelectorsForNode(a))},loadSelectorsForNode:function(a){var b=a.ownerDocument||a;return b===r?this.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(a,c,e){if(p.load&&console.log("loaded",a,c),c.__resource=e,b(c)){var f=this.documents[a];f||(f=d(e,a),f.__importLink=c,this.bootDocument(f),this.documents[a]=f),c.import=f}u.parseNext()},bootDocument:function(a){this.loadSubtree(a),this.observe(a),u.parseNext()},loadedAll:function(){u.parseNext()}},v=new t(s.loaded.bind(s),s.loadedAll.bind(s));var w={get:function(){return HTMLImports.currentScript||document.currentScript},configurable:!0};if(Object.defineProperty(document,"_currentScript",w),Object.defineProperty(r,"_currentScript",w),!document.baseURI){var x={get:function(){return window.location.href},configurable:!0};Object.defineProperty(document,"baseURI",x),Object.defineProperty(r,"baseURI",x)}var y=HTMLImports.isIE?"complete":"interactive",z="readystatechange";o&&new MutationObserver(function(a){for(var b,c=0,d=a.length;d>c&&(b=a[c]);c++)b.addedNodes&&j(b.addedNodes)}).observe(document.head,{childList:!0}),a.hasNative=n,a.useNative=o,a.importer=s,a.IMPORT_LINK_TYPE=q,a.isImportLoaded=i,a.importLoader=v,a.whenReady=e,a.whenImportsReady=e}(window.HTMLImports),function(a){function b(a){for(var b,d=0,e=a.length;e>d&&(b=a[d]);d++)"childList"===b.type&&b.addedNodes.length&&c(b.addedNodes)}function c(a){for(var b,e,g=0,h=a.length;h>g&&(e=a[g]);g++)b=b||e.ownerDocument,d(e)&&f.loadNode(e),e.children&&e.children.length&&c(e.children)}function d(a){return 1===a.nodeType&&g.call(a,f.loadSelectorsForNode(a))}function e(a){h.observe(a,{childList:!0,subtree:!0})}var f=(a.IMPORT_LINK_TYPE,a.importer),g=(a.parser,HTMLElement.prototype.matches||HTMLElement.prototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector),h=new MutationObserver(b);a.observe=e,f.observe=e}(HTMLImports),function(){function a(){HTMLImports.importer.bootDocument(b)}"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a,b){var c=document.createEvent("HTMLEvents");return c.initEvent(a,b.bubbles===!1?!1:!0,b.cancelable===!1?!1:!0,b.detail),c});var b=window.ShadowDOMPolyfill?window.ShadowDOMPolyfill.wrapIfNeeded(document):document;HTMLImports.whenImportsReady(function(){HTMLImports.ready=!0,HTMLImports.readyTime=(new Date).getTime(),b.dispatchEvent(new CustomEvent("HTMLImportsLoaded",{bubbles:!0}))}),HTMLImports.useNative||("complete"===document.readyState||"interactive"===document.readyState&&!window.attachEvent?a():document.addEventListener("DOMContentLoaded",a))}(),window.CustomElements=window.CustomElements||{flags:{}},function(a){function b(a,c,d){var e=a.firstElementChild;if(!e)for(e=a.firstChild;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;for(;e;)c(e,d)!==!0&&b(e,c,d),e=e.nextElementSibling;return null}function c(a,b){for(var c=a.shadowRoot;c;)d(c,b),c=c.olderShadowRoot}function d(a,d){b(a,function(a){return d(a)?!0:void c(a,d)}),c(a,d)}function e(a){return h(a)?(i(a),!0):void l(a)}function f(a){d(a,function(a){return e(a)?!0:void 0})}function g(a){return e(a)||f(a)}function h(b){if(!b.__upgraded__&&b.nodeType===Node.ELEMENT_NODE){var c=b.getAttribute("is")||b.localName,d=a.registry[c];if(d)return A.dom&&console.group("upgrade:",b.localName),a.upgrade(b),A.dom&&console.groupEnd(),!0}}function i(a){l(a),r(a)&&d(a,function(a){l(a)})}function j(a){if(E.push(a),!D){D=!0;var b=window.Platform&&window.Platform.endOfMicrotask||setTimeout;b(k)}}function k(){D=!1;for(var a,b=E,c=0,d=b.length;d>c&&(a=b[c]);c++)a();E=[]}function l(a){C?j(function(){m(a)}):m(a)}function m(a){(a.attachedCallback||a.detachedCallback||a.__upgraded__&&A.dom)&&(A.dom&&console.group("inserted:",a.localName),r(a)&&(a.__inserted=(a.__inserted||0)+1,a.__inserted<1&&(a.__inserted=1),a.__inserted>1?A.dom&&console.warn("inserted:",a.localName,"insert/remove count:",a.__inserted):a.attachedCallback&&(A.dom&&console.log("inserted:",a.localName),a.attachedCallback())),A.dom&&console.groupEnd())
-}function n(a){o(a),d(a,function(a){o(a)})}function o(a){C?j(function(){p(a)}):p(a)}function p(a){(a.attachedCallback||a.detachedCallback||a.__upgraded__&&A.dom)&&(A.dom&&console.group("removed:",a.localName),r(a)||(a.__inserted=(a.__inserted||0)-1,a.__inserted>0&&(a.__inserted=0),a.__inserted<0?A.dom&&console.warn("removed:",a.localName,"insert/remove count:",a.__inserted):a.detachedCallback&&a.detachedCallback()),A.dom&&console.groupEnd())}function q(a){return window.ShadowDOMPolyfill?ShadowDOMPolyfill.wrapIfNeeded(a):a}function r(a){for(var b=a,c=q(document);b;){if(b==c)return!0;b=b.parentNode||b.host}}function s(a){if(a.shadowRoot&&!a.shadowRoot.__watched){A.dom&&console.log("watching shadow-root for: ",a.localName);for(var b=a.shadowRoot;b;)t(b),b=b.olderShadowRoot}}function t(a){a.__watched||(w(a),a.__watched=!0)}function u(a){if(A.dom){var b=a[0];if(b&&"childList"===b.type&&b.addedNodes&&b.addedNodes){for(var c=b.addedNodes[0];c&&c!==document&&!c.host;)c=c.parentNode;var d=c&&(c.URL||c._URL||c.host&&c.host.localName)||"";d=d.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",a.length,d||"")}a.forEach(function(a){"childList"===a.type&&(G(a.addedNodes,function(a){a.localName&&g(a)}),G(a.removedNodes,function(a){a.localName&&n(a)}))}),A.dom&&console.groupEnd()}function v(){u(F.takeRecords()),k()}function w(a){F.observe(a,{childList:!0,subtree:!0})}function x(a){w(a)}function y(a){A.dom&&console.group("upgradeDocument: ",a.baseURI.split("/").pop()),g(a),A.dom&&console.groupEnd()}function z(a){a=q(a);for(var b,c=a.querySelectorAll("link[rel="+B+"]"),d=0,e=c.length;e>d&&(b=c[d]);d++)b.import&&b.import.__parsed&&z(b.import);y(a)}var A=window.logFlags||{},B=window.HTMLImports?HTMLImports.IMPORT_LINK_TYPE:"none",C=!window.MutationObserver||window.MutationObserver===window.JsMutationObserver;a.hasPolyfillMutations=C;var D=!1,E=[],F=new MutationObserver(u),G=Array.prototype.forEach.call.bind(Array.prototype.forEach);a.IMPORT_LINK_TYPE=B,a.watchShadow=s,a.upgradeDocumentTree=z,a.upgradeAll=g,a.upgradeSubtree=f,a.insertedNode=i,a.observeDocument=x,a.upgradeDocument=y,a.takeRecords=v}(window.CustomElements),function(a){function b(b,g){var h=g||{};if(!b)throw new Error("document.registerElement: first argument `name` must not be empty");if(b.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(b)+"'.");if(c(b))throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '"+String(b)+"'. The type name is invalid.");if(n(b))throw new Error("DuplicateDefinitionError: a type with name '"+String(b)+"' is already registered");if(!h.prototype)throw new Error("Options missing required prototype property");return h.__name=b.toLowerCase(),h.lifecycle=h.lifecycle||{},h.ancestry=d(h.extends),e(h),f(h),l(h.prototype),o(h.__name,h),h.ctor=p(h),h.ctor.prototype=h.prototype,h.prototype.constructor=h.ctor,a.ready&&a.upgradeDocumentTree(document),h.ctor}function c(a){for(var b=0;b=0&&i(d,HTMLElement),d}function s(a){if(!a.__upgraded__&&a.nodeType===Node.ELEMENT_NODE){var b=a.getAttribute("is"),c=n(b||a.localName);if(c){if(b&&c.tag==a.localName)return h(a,c);if(!b&&!c.extends)return h(a,c)}}}function t(b){var c=D.call(this,b);return a.upgradeAll(c),c}a||(a=window.CustomElements={flags:{}});var u=a.flags,v=Boolean(document.registerElement),w=!u.register&&v&&!window.ShadowDOMPolyfill&&(!window.HTMLImports||HTMLImports.useNative);if(w){var x=function(){};a.registry={},a.upgradeElement=x,a.watchShadow=x,a.upgrade=x,a.upgradeAll=x,a.upgradeSubtree=x,a.observeDocument=x,a.upgradeDocument=x,a.upgradeDocumentTree=x,a.takeRecords=x,a.reservedTagList=[]}else{var y=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"],z={},A="http://www.w3.org/1999/xhtml",B=document.createElement.bind(document),C=document.createElementNS.bind(document),D=Node.prototype.cloneNode;document.registerElement=b,document.createElement=r,document.createElementNS=q,Node.prototype.cloneNode=t,a.registry=z,a.upgrade=s}var E;E=Object.__proto__||w?function(a,b){return a instanceof b}:function(a,b){for(var c=a;c;){if(c===b.prototype)return!0;c=c.__proto__}return!1},a.instanceof=E,a.reservedTagList=y,document.register=document.registerElement,a.hasNative=v,a.useNative=w}(window.CustomElements),function(a){function b(a){return"link"===a.localName&&a.getAttribute("rel")===c}var c=a.IMPORT_LINK_TYPE,d={selectors:["link[rel="+c+"]"],map:{link:"parseLink"},parse:function(a){if(!a.__parsed){a.__parsed=!0;var b=a.querySelectorAll(d.selectors);e(b,function(a){d[d.map[a.localName]](a)}),CustomElements.upgradeDocument(a),CustomElements.observeDocument(a)}},parseLink:function(a){b(a)&&this.parseImport(a)},parseImport:function(a){a.import&&d.parse(a.import)}},e=Array.prototype.forEach.call.bind(Array.prototype.forEach);a.parser=d,a.IMPORT_LINK_TYPE=c}(window.CustomElements),function(a){function b(){CustomElements.parser.parse(document),CustomElements.upgradeDocument(document);var a=window.Platform&&Platform.endOfMicrotask?Platform.endOfMicrotask:setTimeout;a(function(){CustomElements.ready=!0,CustomElements.readyTime=Date.now(),window.HTMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0})),window.HTMLImports&&(HTMLImports.__importsParsingHook=function(a){CustomElements.parser.parse(a.import)})})}if("function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a,b){b=b||{};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,Boolean(b.bubbles),Boolean(b.cancelable),b.detail),c},window.CustomEvent.prototype=window.Event.prototype),"complete"===document.readyState||a.flags.eager)b();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var c=window.HTMLImports&&!HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(c,b)}else b()}(window.CustomElements),function(){if(window.ShadowDOMPolyfill){var a=["upgradeAll","upgradeSubtree","observeDocument","upgradeDocument"],b={};a.forEach(function(a){b[a]=CustomElements[a]}),a.forEach(function(a){CustomElements[a]=function(c){return b[a](wrap(c))}})}}(),function(a){function b(a){this.cache=Object.create(null),this.map=Object.create(null),this.requests=0,this.regex=a}var c=a.endOfMicrotask;b.prototype={extractUrls:function(a,b){for(var c,d,e=[];c=this.regex.exec(a);)d=new URL(c[1],b),e.push({matched:c[0],url:d.href});return e},process:function(a,b,c){var d=this.extractUrls(a,b),e=c.bind(null,this.map);this.fetch(d,e)},fetch:function(a,b){var c=a.length;if(!c)return b();for(var d,e,f,g=function(){0===--c&&b()},h=0;c>h;h++)d=a[h],f=d.url,e=this.cache[f],e||(e=this.xhr(f),e.match=d,this.cache[f]=e),e.wait(g)},handleXhr:function(a){var b=a.match,c=b.url,d=a.response||a.responseText||"";this.map[c]=d,this.fetch(this.extractUrls(d,c),a.resolve)},xhr:function(a){this.requests++;var b=new XMLHttpRequest;return b.open("GET",a,!0),b.send(),b.onerror=b.onload=this.handleXhr.bind(this,b),b.pending=[],b.resolve=function(){for(var a=b.pending,c=0;ch&&(e=a[h]);h++)this.resolveNode(e,b,d)}};var e=new b;a.styleResolver=e}(window.Platform),function(){"use strict";function a(a){for(;a.parentNode;)a=a.parentNode;return"function"==typeof a.getElementById?a:null}function b(a,b,c){var d=a.bindings_;return d||(d=a.bindings_={}),d[b]&&c[b].close(),d[b]=c}function c(a,b,c){return c}function d(a){return null==a?"":a}function e(a,b){a.data=d(b)}function f(a){return function(b){return e(a,b)}}function g(a,b,c,e){return c?void(e?a.setAttribute(b,""):a.removeAttribute(b)):void a.setAttribute(b,d(e))}function h(a,b,c){return function(d){g(a,b,c,d)}}function i(a){switch(a.type){case"checkbox":return u;case"radio":case"select-multiple":case"select-one":return"change";case"range":if(/Trident|MSIE/.test(navigator.userAgent))return"change";default:return"input"}}function j(a,b,c,e){a[b]=(e||d)(c)}function k(a,b,c){return function(d){return j(a,b,d,c)}}function l(){}function m(a,b,c,d){function e(){c.setValue(a[b]),c.discardChanges(),(d||l)(a),Platform.performMicrotaskCheckpoint()}var f=i(a);return a.addEventListener(f,e),{close:function(){a.removeEventListener(f,e),c.close()},observable_:c}}function n(a){return Boolean(a)}function o(b){if(b.form)return s(b.form.elements,function(a){return a!=b&&"INPUT"==a.tagName&&"radio"==a.type&&a.name==b.name});var c=a(b);if(!c)return[];var d=c.querySelectorAll('input[type="radio"][name="'+b.name+'"]');return s(d,function(a){return a!=b&&!a.form})}function p(a){"INPUT"===a.tagName&&"radio"===a.type&&o(a).forEach(function(a){var b=a.bindings_.checked;b&&b.observable_.setValue(!1)})}function q(a,b){var c,e,f,g=a.parentNode;g instanceof HTMLSelectElement&&g.bindings_&&g.bindings_.value&&(c=g,e=c.bindings_.value,f=c.value),a.value=d(b),c&&c.value!=f&&(e.observable_.setValue(c.value),e.observable_.discardChanges(),Platform.performMicrotaskCheckpoint())}function r(a){return function(b){q(a,b)}}var s=Array.prototype.filter.call.bind(Array.prototype.filter);Node.prototype.bind=function(a,b){console.error("Unhandled binding to Node: ",this,a,b)},Node.prototype.bindFinished=function(){};var t=c;Object.defineProperty(Platform,"enableBindingsReflection",{get:function(){return t===b},set:function(a){return t=a?b:c,a},configurable:!0}),Text.prototype.bind=function(a,b,c){if("textContent"!==a)return Node.prototype.bind.call(this,a,b,c);if(c)return e(this,b);var d=b;return e(this,d.open(f(this))),t(this,a,d)},Element.prototype.bind=function(a,b,c){var d="?"==a[a.length-1];if(d&&(this.removeAttribute(a),a=a.slice(0,-1)),c)return g(this,a,d,b);var e=b;return g(this,a,d,e.open(h(this,a,d))),t(this,a,e)};var u;!function(){var a=document.createElement("div"),b=a.appendChild(document.createElement("input"));b.setAttribute("type","checkbox");var c,d=0;b.addEventListener("click",function(){d++,c=c||"click"}),b.addEventListener("change",function(){d++,c=c||"change"});var e=document.createEvent("MouseEvent");e.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),b.dispatchEvent(e),u=1==d?"change":c}(),HTMLInputElement.prototype.bind=function(a,c,e){if("value"!==a&&"checked"!==a)return HTMLElement.prototype.bind.call(this,a,c,e);this.removeAttribute(a);var f="checked"==a?n:d,g="checked"==a?p:l;if(e)return j(this,a,c,f);var h=c,i=m(this,a,h,g);return j(this,a,h.open(k(this,a,f)),f),b(this,a,i)},HTMLTextAreaElement.prototype.bind=function(a,b,c){if("value"!==a)return HTMLElement.prototype.bind.call(this,a,b,c);if(this.removeAttribute("value"),c)return j(this,"value",b);var e=b,f=m(this,"value",e);return j(this,"value",e.open(k(this,"value",d))),t(this,a,f)},HTMLOptionElement.prototype.bind=function(a,b,c){if("value"!==a)return HTMLElement.prototype.bind.call(this,a,b,c);if(this.removeAttribute("value"),c)return q(this,b);var d=b,e=m(this,"value",d);return q(this,d.open(r(this))),t(this,a,e)},HTMLSelectElement.prototype.bind=function(a,c,d){if("selectedindex"===a&&(a="selectedIndex"),"selectedIndex"!==a&&"value"!==a)return HTMLElement.prototype.bind.call(this,a,c,d);if(this.removeAttribute(a),d)return j(this,a,c);var e=c,f=m(this,a,e);return j(this,a,e.open(k(this,a))),b(this,a,f)}}(this),function(a){"use strict";function b(a){if(!a)throw new Error("Assertion failed")}function c(a){for(var b;b=a.parentNode;)a=b;return a}function d(a,b){if(b){for(var d,e="#"+b;!d&&(a=c(a),a.protoContent_?d=a.protoContent_.querySelector(e):a.getElementById&&(d=a.getElementById(b)),!d&&a.templateCreator_);)a=a.templateCreator_;return d}}function e(a){return"template"==a.tagName&&"http://www.w3.org/2000/svg"==a.namespaceURI}function f(a){return"TEMPLATE"==a.tagName&&"http://www.w3.org/1999/xhtml"==a.namespaceURI}function g(a){return Boolean(L[a.tagName]&&a.hasAttribute("template"))}function h(a){return void 0===a.isTemplate_&&(a.isTemplate_="TEMPLATE"==a.tagName||g(a)),a.isTemplate_}function i(a,b){var c=a.querySelectorAll(N);h(a)&&b(a),G(c,b)}function j(a){function b(a){HTMLTemplateElement.decorate(a)||j(a.content)}i(a,b)}function k(a,b){Object.getOwnPropertyNames(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))})}function l(a){var b=a.ownerDocument;if(!b.defaultView)return b;var c=b.templateContentsOwner_;if(!c){for(c=b.implementation.createHTMLDocument("");c.lastChild;)c.removeChild(c.lastChild);b.templateContentsOwner_=c}return c}function m(a){if(!a.stagingDocument_){var b=a.ownerDocument;if(!b.stagingDocument_){b.stagingDocument_=b.implementation.createHTMLDocument(""),b.stagingDocument_.isStagingDocument=!0;var c=b.stagingDocument_.createElement("base");c.href=document.baseURI,b.stagingDocument_.head.appendChild(c),b.stagingDocument_.stagingDocument_=b.stagingDocument_}a.stagingDocument_=b.stagingDocument_}return a.stagingDocument_}function n(a){var b=a.ownerDocument.createElement("template");a.parentNode.insertBefore(b,a);for(var c=a.attributes,d=c.length;d-->0;){var e=c[d];K[e.name]&&("template"!==e.name&&b.setAttribute(e.name,e.value),a.removeAttribute(e.name))}return b}function o(a){var b=a.ownerDocument.createElement("template");a.parentNode.insertBefore(b,a);for(var c=a.attributes,d=c.length;d-->0;){var e=c[d];b.setAttribute(e.name,e.value),a.removeAttribute(e.name)}return a.parentNode.removeChild(a),b}function p(a,b,c){var d=a.content;if(c)return void d.appendChild(b);for(var e;e=b.firstChild;)d.appendChild(e)}function q(a){P?a.__proto__=HTMLTemplateElement.prototype:k(a,HTMLTemplateElement.prototype)}function r(a){a.setModelFn_||(a.setModelFn_=function(){a.setModelFnScheduled_=!1;var b=z(a,a.delegate_&&a.delegate_.prepareBinding);w(a,b,a.model_)}),a.setModelFnScheduled_||(a.setModelFnScheduled_=!0,Observer.runEOM_(a.setModelFn_))}function s(a,b,c,d){if(a&&a.length){for(var e,f=a.length,g=0,h=0,i=0,j=!0;f>h;){var g=a.indexOf("{{",h),k=a.indexOf("[[",h),l=!1,m="}}";if(k>=0&&(0>g||g>k)&&(g=k,l=!0,m="]]"),i=0>g?-1:a.indexOf(m,g+2),0>i){if(!e)return;e.push(a.slice(h));break}e=e||[],e.push(a.slice(h,g));var n=a.slice(g+2,i).trim();e.push(l),j=j&&l;var o=d&&d(n,b,c);e.push(null==o?Path.get(n):null),e.push(o),h=i+2}return h===f&&e.push(""),e.hasOnePath=5===e.length,e.isSimplePath=e.hasOnePath&&""==e[0]&&""==e[4],e.onlyOneTime=j,e.combinator=function(a){for(var b=e[0],c=1;cc?(this.keys.push(a),this.values.push(b)):this.values[c]=b},get:function(a){var b=this.keys.indexOf(a);if(!(0>b))return this.values[b]},"delete":function(a){var b=this.keys.indexOf(a);return 0>b?!1:(this.keys.splice(b,1),this.values.splice(b,1),!0)},forEach:function(a,b){for(var c=0;cb;)this.reportInstanceMoved(b),b++},closeInstanceBindings:function(a){for(var b=a.bindings_,c=0;c 1) {\n console.warn('platform.js is not the first script on the page. ' +\n 'See http://www.polymer-project.org/docs/start/platform.html#setup ' +\n 'for details.');\n }\n\n // CustomElements polyfill flag\n if (flags.register) {\n window.CustomElements = window.CustomElements || {flags: {}};\n window.CustomElements.flags.register = flags.register;\n }\n\n if (flags.imports) {\n window.HTMLImports = window.HTMLImports || {flags: {}};\n window.HTMLImports.flags.imports = flags.imports;\n }\n\n // export\n scope.flags = flags;\n})(Platform);\n","/*\n * Copyright 2012 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\nif (typeof WeakMap === 'undefined') {\n (function() {\n var defineProperty = Object.defineProperty;\n var counter = Date.now() % 1e9;\n\n var WeakMap = function() {\n this.name = '__st' + (Math.random() * 1e9 >>> 0) + (counter++ + '__');\n };\n\n WeakMap.prototype = {\n set: function(key, value) {\n var entry = key[this.name];\n if (entry && entry[0] === key)\n entry[1] = value;\n else\n defineProperty(key, this.name, {value: [key, value], writable: true});\n },\n get: function(key) {\n var entry;\n return (entry = key[this.name]) && entry[0] === key ?\n entry[1] : undefined;\n },\n delete: function(key) {\n var entry = key[this.name];\n if (!entry) return false;\n var hasValue = entry[0] === key;\n entry[0] = entry[1] = undefined;\n return hasValue;\n },\n has: function(key) {\n var entry = key[this.name];\n if (!entry) return false;\n return entry[0] === key;\n }\n };\n\n window.WeakMap = WeakMap;\n })();\n}\n","// Copyright 2012 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n(function(global) {\n 'use strict';\n\n var testingExposeCycleCount = global.testingExposeCycleCount;\n\n // Detect and do basic sanity checking on Object/Array.observe.\n function detectObjectObserve() {\n if (typeof Object.observe !== 'function' ||\n typeof Array.observe !== 'function') {\n return false;\n }\n\n var records = [];\n\n function callback(recs) {\n records = recs;\n }\n\n var test = {};\n var arr = [];\n Object.observe(test, callback);\n Array.observe(arr, callback);\n test.id = 1;\n test.id = 2;\n delete test.id;\n arr.push(1, 2);\n arr.length = 0;\n\n Object.deliverChangeRecords(callback);\n if (records.length !== 5)\n return false;\n\n if (records[0].type != 'add' ||\n records[1].type != 'update' ||\n records[2].type != 'delete' ||\n records[3].type != 'splice' ||\n records[4].type != 'splice') {\n return false;\n }\n\n Object.unobserve(test, callback);\n Array.unobserve(arr, callback);\n\n return true;\n }\n\n var hasObserve = detectObjectObserve();\n\n function detectEval() {\n // Don't test for eval if we're running in a Chrome App environment.\n // We check for APIs set that only exist in a Chrome App context.\n if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {\n return false;\n }\n\n // Firefox OS Apps do not allow eval. This feature detection is very hacky\n // but even if some other platform adds support for this function this code\n // will continue to work.\n if (navigator.getDeviceStorage) {\n return false;\n }\n\n try {\n var f = new Function('', 'return true;');\n return f();\n } catch (ex) {\n return false;\n }\n }\n\n var hasEval = detectEval();\n\n function isIndex(s) {\n return +s === s >>> 0;\n }\n\n function toNumber(s) {\n return +s;\n }\n\n function isObject(obj) {\n return obj === Object(obj);\n }\n\n var numberIsNaN = global.Number.isNaN || function(value) {\n return typeof value === 'number' && global.isNaN(value);\n }\n\n function areSameValue(left, right) {\n if (left === right)\n return left !== 0 || 1 / left === 1 / right;\n if (numberIsNaN(left) && numberIsNaN(right))\n return true;\n\n return left !== left && right !== right;\n }\n\n var createObject = ('__proto__' in {}) ?\n function(obj) { return obj; } :\n function(obj) {\n var proto = obj.__proto__;\n if (!proto)\n return obj;\n var newObject = Object.create(proto);\n Object.getOwnPropertyNames(obj).forEach(function(name) {\n Object.defineProperty(newObject, name,\n Object.getOwnPropertyDescriptor(obj, name));\n });\n return newObject;\n };\n\n var identStart = '[\\$_a-zA-Z]';\n var identPart = '[\\$_a-zA-Z0-9]';\n var identRegExp = new RegExp('^' + identStart + '+' + identPart + '*' + '$');\n\n function getPathCharType(char) {\n if (char === undefined)\n return 'eof';\n\n var code = char.charCodeAt(0);\n\n switch(code) {\n case 0x5B: // [\n case 0x5D: // ]\n case 0x2E: // .\n case 0x22: // \"\n case 0x27: // '\n case 0x30: // 0\n return char;\n\n case 0x5F: // _\n case 0x24: // $\n return 'ident';\n\n case 0x20: // Space\n case 0x09: // Tab\n case 0x0A: // Newline\n case 0x0D: // Return\n case 0xA0: // No-break space\n case 0xFEFF: // Byte Order Mark\n case 0x2028: // Line Separator\n case 0x2029: // Paragraph Separator\n return 'ws';\n }\n\n // a-z, A-Z\n if ((0x61 <= code && code <= 0x7A) || (0x41 <= code && code <= 0x5A))\n return 'ident';\n\n // 1-9\n if (0x31 <= code && code <= 0x39)\n return 'number';\n\n return 'else';\n }\n\n var pathStateMachine = {\n 'beforePath': {\n 'ws': ['beforePath'],\n 'ident': ['inIdent', 'append'],\n '[': ['beforeElement'],\n 'eof': ['afterPath']\n },\n\n 'inPath': {\n 'ws': ['inPath'],\n '.': ['beforeIdent'],\n '[': ['beforeElement'],\n 'eof': ['afterPath']\n },\n\n 'beforeIdent': {\n 'ws': ['beforeIdent'],\n 'ident': ['inIdent', 'append']\n },\n\n 'inIdent': {\n 'ident': ['inIdent', 'append'],\n '0': ['inIdent', 'append'],\n 'number': ['inIdent', 'append'],\n 'ws': ['inPath', 'push'],\n '.': ['beforeIdent', 'push'],\n '[': ['beforeElement', 'push'],\n 'eof': ['afterPath', 'push']\n },\n\n 'beforeElement': {\n 'ws': ['beforeElement'],\n '0': ['afterZero', 'append'],\n 'number': ['inIndex', 'append'],\n \"'\": ['inSingleQuote', 'append', ''],\n '\"': ['inDoubleQuote', 'append', '']\n },\n\n 'afterZero': {\n 'ws': ['afterElement', 'push'],\n ']': ['inPath', 'push']\n },\n\n 'inIndex': {\n '0': ['inIndex', 'append'],\n 'number': ['inIndex', 'append'],\n 'ws': ['afterElement'],\n ']': ['inPath', 'push']\n },\n\n 'inSingleQuote': {\n \"'\": ['afterElement'],\n 'eof': ['error'],\n 'else': ['inSingleQuote', 'append']\n },\n\n 'inDoubleQuote': {\n '\"': ['afterElement'],\n 'eof': ['error'],\n 'else': ['inDoubleQuote', 'append']\n },\n\n 'afterElement': {\n 'ws': ['afterElement'],\n ']': ['inPath', 'push']\n }\n }\n\n function noop() {}\n\n function parsePath(path) {\n var keys = [];\n var index = -1;\n var c, newChar, key, type, transition, action, typeMap, mode = 'beforePath';\n\n var actions = {\n push: function() {\n if (key === undefined)\n return;\n\n keys.push(key);\n key = undefined;\n },\n\n append: function() {\n if (key === undefined)\n key = newChar\n else\n key += newChar;\n }\n };\n\n function maybeUnescapeQuote() {\n if (index >= path.length)\n return;\n\n var nextChar = path[index + 1];\n if ((mode == 'inSingleQuote' && nextChar == \"'\") ||\n (mode == 'inDoubleQuote' && nextChar == '\"')) {\n index++;\n newChar = nextChar;\n actions.append();\n return true;\n }\n }\n\n while (mode) {\n index++;\n c = path[index];\n\n if (c == '\\\\' && maybeUnescapeQuote(mode))\n continue;\n\n type = getPathCharType(c);\n typeMap = pathStateMachine[mode];\n transition = typeMap[type] || typeMap['else'] || 'error';\n\n if (transition == 'error')\n return; // parse error;\n\n mode = transition[0];\n action = actions[transition[1]] || noop;\n newChar = transition[2] === undefined ? c : transition[2];\n action();\n\n if (mode === 'afterPath') {\n return keys;\n }\n }\n\n return; // parse error\n }\n\n function isIdent(s) {\n return identRegExp.test(s);\n }\n\n var constructorIsPrivate = {};\n\n function Path(parts, privateToken) {\n if (privateToken !== constructorIsPrivate)\n throw Error('Use Path.get to retrieve path objects');\n\n for (var i = 0; i < parts.length; i++) {\n this.push(String(parts[i]));\n }\n\n if (hasEval && this.length) {\n this.getValueFrom = this.compiledGetValueFromFn();\n }\n }\n\n // TODO(rafaelw): Make simple LRU cache\n var pathCache = {};\n\n function getPath(pathString) {\n if (pathString instanceof Path)\n return pathString;\n\n if (pathString == null || pathString.length == 0)\n pathString = '';\n\n if (typeof pathString != 'string') {\n if (isIndex(pathString.length)) {\n // Constructed with array-like (pre-parsed) keys\n return new Path(pathString, constructorIsPrivate);\n }\n\n pathString = String(pathString);\n }\n\n var path = pathCache[pathString];\n if (path)\n return path;\n\n var parts = parsePath(pathString);\n if (!parts)\n return invalidPath;\n\n var path = new Path(parts, constructorIsPrivate);\n pathCache[pathString] = path;\n return path;\n }\n\n Path.get = getPath;\n\n function formatAccessor(key) {\n if (isIndex(key)) {\n return '[' + key + ']';\n } else {\n return '[\"' + key.replace(/\"/g, '\\\\\"') + '\"]';\n }\n }\n\n Path.prototype = createObject({\n __proto__: [],\n valid: true,\n\n toString: function() {\n var pathString = '';\n for (var i = 0; i < this.length; i++) {\n var key = this[i];\n if (isIdent(key)) {\n pathString += i ? '.' + key : key;\n } else {\n pathString += formatAccessor(key);\n }\n }\n\n return pathString;\n },\n\n getValueFrom: function(obj, directObserver) {\n for (var i = 0; i < this.length; i++) {\n if (obj == null)\n return;\n obj = obj[this[i]];\n }\n return obj;\n },\n\n iterateObjects: function(obj, observe) {\n for (var i = 0; i < this.length; i++) {\n if (i)\n obj = obj[this[i - 1]];\n if (!isObject(obj))\n return;\n observe(obj, this[0]);\n }\n },\n\n compiledGetValueFromFn: function() {\n var str = '';\n var pathString = 'obj';\n str += 'if (obj != null';\n var i = 0;\n var key;\n for (; i < (this.length - 1); i++) {\n key = this[i];\n pathString += isIdent(key) ? '.' + key : formatAccessor(key);\n str += ' &&\\n ' + pathString + ' != null';\n }\n str += ')\\n';\n\n var key = this[i];\n pathString += isIdent(key) ? '.' + key : formatAccessor(key);\n\n str += ' return ' + pathString + ';\\nelse\\n return undefined;';\n return new Function('obj', str);\n },\n\n setValueFrom: function(obj, value) {\n if (!this.length)\n return false;\n\n for (var i = 0; i < this.length - 1; i++) {\n if (!isObject(obj))\n return false;\n obj = obj[this[i]];\n }\n\n if (!isObject(obj))\n return false;\n\n obj[this[i]] = value;\n return true;\n }\n });\n\n var invalidPath = new Path('', constructorIsPrivate);\n invalidPath.valid = false;\n invalidPath.getValueFrom = invalidPath.setValueFrom = function() {};\n\n var MAX_DIRTY_CHECK_CYCLES = 1000;\n\n function dirtyCheck(observer) {\n var cycles = 0;\n while (cycles < MAX_DIRTY_CHECK_CYCLES && observer.check_()) {\n cycles++;\n }\n if (testingExposeCycleCount)\n global.dirtyCheckCycleCount = cycles;\n\n return cycles > 0;\n }\n\n function objectIsEmpty(object) {\n for (var prop in object)\n return false;\n return true;\n }\n\n function diffIsEmpty(diff) {\n return objectIsEmpty(diff.added) &&\n objectIsEmpty(diff.removed) &&\n objectIsEmpty(diff.changed);\n }\n\n function diffObjectFromOldObject(object, oldObject) {\n var added = {};\n var removed = {};\n var changed = {};\n\n for (var prop in oldObject) {\n var newValue = object[prop];\n\n if (newValue !== undefined && newValue === oldObject[prop])\n continue;\n\n if (!(prop in object)) {\n removed[prop] = undefined;\n continue;\n }\n\n if (newValue !== oldObject[prop])\n changed[prop] = newValue;\n }\n\n for (var prop in object) {\n if (prop in oldObject)\n continue;\n\n added[prop] = object[prop];\n }\n\n if (Array.isArray(object) && object.length !== oldObject.length)\n changed.length = object.length;\n\n return {\n added: added,\n removed: removed,\n changed: changed\n };\n }\n\n var eomTasks = [];\n function runEOMTasks() {\n if (!eomTasks.length)\n return false;\n\n for (var i = 0; i < eomTasks.length; i++) {\n eomTasks[i]();\n }\n eomTasks.length = 0;\n return true;\n }\n\n var runEOM = hasObserve ? (function(){\n var eomObj = { pingPong: true };\n var eomRunScheduled = false;\n\n Object.observe(eomObj, function() {\n runEOMTasks();\n eomRunScheduled = false;\n });\n\n return function(fn) {\n eomTasks.push(fn);\n if (!eomRunScheduled) {\n eomRunScheduled = true;\n eomObj.pingPong = !eomObj.pingPong;\n }\n };\n })() :\n (function() {\n return function(fn) {\n eomTasks.push(fn);\n };\n })();\n\n var observedObjectCache = [];\n\n function newObservedObject() {\n var observer;\n var object;\n var discardRecords = false;\n var first = true;\n\n function callback(records) {\n if (observer && observer.state_ === OPENED && !discardRecords)\n observer.check_(records);\n }\n\n return {\n open: function(obs) {\n if (observer)\n throw Error('ObservedObject in use');\n\n if (!first)\n Object.deliverChangeRecords(callback);\n\n observer = obs;\n first = false;\n },\n observe: function(obj, arrayObserve) {\n object = obj;\n if (arrayObserve)\n Array.observe(object, callback);\n else\n Object.observe(object, callback);\n },\n deliver: function(discard) {\n discardRecords = discard;\n Object.deliverChangeRecords(callback);\n discardRecords = false;\n },\n close: function() {\n observer = undefined;\n Object.unobserve(object, callback);\n observedObjectCache.push(this);\n }\n };\n }\n\n /*\n * The observedSet abstraction is a perf optimization which reduces the total\n * number of Object.observe observations of a set of objects. The idea is that\n * groups of Observers will have some object dependencies in common and this\n * observed set ensures that each object in the transitive closure of\n * dependencies is only observed once. The observedSet acts as a write barrier\n * such that whenever any change comes through, all Observers are checked for\n * changed values.\n *\n * Note that this optimization is explicitly moving work from setup-time to\n * change-time.\n *\n * TODO(rafaelw): Implement \"garbage collection\". In order to move work off\n * the critical path, when Observers are closed, their observed objects are\n * not Object.unobserve(d). As a result, it's possible that if the observedSet\n * is kept open, but some Observers have been closed, it could cause \"leaks\"\n * (prevent otherwise collectable objects from being collected). At some\n * point, we should implement incremental \"gc\" which keeps a list of\n * observedSets which may need clean-up and does small amounts of cleanup on a\n * timeout until all is clean.\n */\n\n function getObservedObject(observer, object, arrayObserve) {\n var dir = observedObjectCache.pop() || newObservedObject();\n dir.open(observer);\n dir.observe(object, arrayObserve);\n return dir;\n }\n\n var observedSetCache = [];\n\n function newObservedSet() {\n var observerCount = 0;\n var observers = [];\n var objects = [];\n var rootObj;\n var rootObjProps;\n\n function observe(obj, prop) {\n if (!obj)\n return;\n\n if (obj === rootObj)\n rootObjProps[prop] = true;\n\n if (objects.indexOf(obj) < 0) {\n objects.push(obj);\n Object.observe(obj, callback);\n }\n\n observe(Object.getPrototypeOf(obj), prop);\n }\n\n function allRootObjNonObservedProps(recs) {\n for (var i = 0; i < recs.length; i++) {\n var rec = recs[i];\n if (rec.object !== rootObj ||\n rootObjProps[rec.name] ||\n rec.type === 'setPrototype') {\n return false;\n }\n }\n return true;\n }\n\n function callback(recs) {\n if (allRootObjNonObservedProps(recs))\n return;\n\n var observer;\n for (var i = 0; i < observers.length; i++) {\n observer = observers[i];\n if (observer.state_ == OPENED) {\n observer.iterateObjects_(observe);\n }\n }\n\n for (var i = 0; i < observers.length; i++) {\n observer = observers[i];\n if (observer.state_ == OPENED) {\n observer.check_();\n }\n }\n }\n\n var record = {\n object: undefined,\n objects: objects,\n open: function(obs, object) {\n if (!rootObj) {\n rootObj = object;\n rootObjProps = {};\n }\n\n observers.push(obs);\n observerCount++;\n obs.iterateObjects_(observe);\n },\n close: function(obs) {\n observerCount--;\n if (observerCount > 0) {\n return;\n }\n\n for (var i = 0; i < objects.length; i++) {\n Object.unobserve(objects[i], callback);\n Observer.unobservedCount++;\n }\n\n observers.length = 0;\n objects.length = 0;\n rootObj = undefined;\n rootObjProps = undefined;\n observedSetCache.push(this);\n }\n };\n\n return record;\n }\n\n var lastObservedSet;\n\n function getObservedSet(observer, obj) {\n if (!lastObservedSet || lastObservedSet.object !== obj) {\n lastObservedSet = observedSetCache.pop() || newObservedSet();\n lastObservedSet.object = obj;\n }\n lastObservedSet.open(observer, obj);\n return lastObservedSet;\n }\n\n var UNOPENED = 0;\n var OPENED = 1;\n var CLOSED = 2;\n var RESETTING = 3;\n\n var nextObserverId = 1;\n\n function Observer() {\n this.state_ = UNOPENED;\n this.callback_ = undefined;\n this.target_ = undefined; // TODO(rafaelw): Should be WeakRef\n this.directObserver_ = undefined;\n this.value_ = undefined;\n this.id_ = nextObserverId++;\n }\n\n Observer.prototype = {\n open: function(callback, target) {\n if (this.state_ != UNOPENED)\n throw Error('Observer has already been opened.');\n\n addToAll(this);\n this.callback_ = callback;\n this.target_ = target;\n this.connect_();\n this.state_ = OPENED;\n return this.value_;\n },\n\n close: function() {\n if (this.state_ != OPENED)\n return;\n\n removeFromAll(this);\n this.disconnect_();\n this.value_ = undefined;\n this.callback_ = undefined;\n this.target_ = undefined;\n this.state_ = CLOSED;\n },\n\n deliver: function() {\n if (this.state_ != OPENED)\n return;\n\n dirtyCheck(this);\n },\n\n report_: function(changes) {\n try {\n this.callback_.apply(this.target_, changes);\n } catch (ex) {\n Observer._errorThrownDuringCallback = true;\n console.error('Exception caught during observer callback: ' +\n (ex.stack || ex));\n }\n },\n\n discardChanges: function() {\n this.check_(undefined, true);\n return this.value_;\n }\n }\n\n var collectObservers = !hasObserve;\n var allObservers;\n Observer._allObserversCount = 0;\n\n if (collectObservers) {\n allObservers = [];\n }\n\n function addToAll(observer) {\n Observer._allObserversCount++;\n if (!collectObservers)\n return;\n\n allObservers.push(observer);\n }\n\n function removeFromAll(observer) {\n Observer._allObserversCount--;\n }\n\n var runningMicrotaskCheckpoint = false;\n\n var hasDebugForceFullDelivery = hasObserve && hasEval && (function() {\n try {\n eval('%RunMicrotasks()');\n return true;\n } catch (ex) {\n return false;\n }\n })();\n\n global.Platform = global.Platform || {};\n\n global.Platform.performMicrotaskCheckpoint = function() {\n if (runningMicrotaskCheckpoint)\n return;\n\n if (hasDebugForceFullDelivery) {\n eval('%RunMicrotasks()');\n return;\n }\n\n if (!collectObservers)\n return;\n\n runningMicrotaskCheckpoint = true;\n\n var cycles = 0;\n var anyChanged, toCheck;\n\n do {\n cycles++;\n toCheck = allObservers;\n allObservers = [];\n anyChanged = false;\n\n for (var i = 0; i < toCheck.length; i++) {\n var observer = toCheck[i];\n if (observer.state_ != OPENED)\n continue;\n\n if (observer.check_())\n anyChanged = true;\n\n allObservers.push(observer);\n }\n if (runEOMTasks())\n anyChanged = true;\n } while (cycles < MAX_DIRTY_CHECK_CYCLES && anyChanged);\n\n if (testingExposeCycleCount)\n global.dirtyCheckCycleCount = cycles;\n\n runningMicrotaskCheckpoint = false;\n };\n\n if (collectObservers) {\n global.Platform.clearObservers = function() {\n allObservers = [];\n };\n }\n\n function ObjectObserver(object) {\n Observer.call(this);\n this.value_ = object;\n this.oldObject_ = undefined;\n }\n\n ObjectObserver.prototype = createObject({\n __proto__: Observer.prototype,\n\n arrayObserve: false,\n\n connect_: function(callback, target) {\n if (hasObserve) {\n this.directObserver_ = getObservedObject(this, this.value_,\n this.arrayObserve);\n } else {\n this.oldObject_ = this.copyObject(this.value_);\n }\n\n },\n\n copyObject: function(object) {\n var copy = Array.isArray(object) ? [] : {};\n for (var prop in object) {\n copy[prop] = object[prop];\n };\n if (Array.isArray(object))\n copy.length = object.length;\n return copy;\n },\n\n check_: function(changeRecords, skipChanges) {\n var diff;\n var oldValues;\n if (hasObserve) {\n if (!changeRecords)\n return false;\n\n oldValues = {};\n diff = diffObjectFromChangeRecords(this.value_, changeRecords,\n oldValues);\n } else {\n oldValues = this.oldObject_;\n diff = diffObjectFromOldObject(this.value_, this.oldObject_);\n }\n\n if (diffIsEmpty(diff))\n return false;\n\n if (!hasObserve)\n this.oldObject_ = this.copyObject(this.value_);\n\n this.report_([\n diff.added || {},\n diff.removed || {},\n diff.changed || {},\n function(property) {\n return oldValues[property];\n }\n ]);\n\n return true;\n },\n\n disconnect_: function() {\n if (hasObserve) {\n this.directObserver_.close();\n this.directObserver_ = undefined;\n } else {\n this.oldObject_ = undefined;\n }\n },\n\n deliver: function() {\n if (this.state_ != OPENED)\n return;\n\n if (hasObserve)\n this.directObserver_.deliver(false);\n else\n dirtyCheck(this);\n },\n\n discardChanges: function() {\n if (this.directObserver_)\n this.directObserver_.deliver(true);\n else\n this.oldObject_ = this.copyObject(this.value_);\n\n return this.value_;\n }\n });\n\n function ArrayObserver(array) {\n if (!Array.isArray(array))\n throw Error('Provided object is not an Array');\n ObjectObserver.call(this, array);\n }\n\n ArrayObserver.prototype = createObject({\n\n __proto__: ObjectObserver.prototype,\n\n arrayObserve: true,\n\n copyObject: function(arr) {\n return arr.slice();\n },\n\n check_: function(changeRecords) {\n var splices;\n if (hasObserve) {\n if (!changeRecords)\n return false;\n splices = projectArraySplices(this.value_, changeRecords);\n } else {\n splices = calcSplices(this.value_, 0, this.value_.length,\n this.oldObject_, 0, this.oldObject_.length);\n }\n\n if (!splices || !splices.length)\n return false;\n\n if (!hasObserve)\n this.oldObject_ = this.copyObject(this.value_);\n\n this.report_([splices]);\n return true;\n }\n });\n\n ArrayObserver.applySplices = function(previous, current, splices) {\n splices.forEach(function(splice) {\n var spliceArgs = [splice.index, splice.removed.length];\n var addIndex = splice.index;\n while (addIndex < splice.index + splice.addedCount) {\n spliceArgs.push(current[addIndex]);\n addIndex++;\n }\n\n Array.prototype.splice.apply(previous, spliceArgs);\n });\n };\n\n function PathObserver(object, path) {\n Observer.call(this);\n\n this.object_ = object;\n this.path_ = getPath(path);\n this.directObserver_ = undefined;\n }\n\n PathObserver.prototype = createObject({\n __proto__: Observer.prototype,\n\n get path() {\n return this.path_;\n },\n\n connect_: function() {\n if (hasObserve)\n this.directObserver_ = getObservedSet(this, this.object_);\n\n this.check_(undefined, true);\n },\n\n disconnect_: function() {\n this.value_ = undefined;\n\n if (this.directObserver_) {\n this.directObserver_.close(this);\n this.directObserver_ = undefined;\n }\n },\n\n iterateObjects_: function(observe) {\n this.path_.iterateObjects(this.object_, observe);\n },\n\n check_: function(changeRecords, skipChanges) {\n var oldValue = this.value_;\n this.value_ = this.path_.getValueFrom(this.object_);\n if (skipChanges || areSameValue(this.value_, oldValue))\n return false;\n\n this.report_([this.value_, oldValue, this]);\n return true;\n },\n\n setValue: function(newValue) {\n if (this.path_)\n this.path_.setValueFrom(this.object_, newValue);\n }\n });\n\n function CompoundObserver(reportChangesOnOpen) {\n Observer.call(this);\n\n this.reportChangesOnOpen_ = reportChangesOnOpen;\n this.value_ = [];\n this.directObserver_ = undefined;\n this.observed_ = [];\n }\n\n var observerSentinel = {};\n\n CompoundObserver.prototype = createObject({\n __proto__: Observer.prototype,\n\n connect_: function() {\n if (hasObserve) {\n var object;\n var needsDirectObserver = false;\n for (var i = 0; i < this.observed_.length; i += 2) {\n object = this.observed_[i]\n if (object !== observerSentinel) {\n needsDirectObserver = true;\n break;\n }\n }\n\n if (needsDirectObserver)\n this.directObserver_ = getObservedSet(this, object);\n }\n\n this.check_(undefined, !this.reportChangesOnOpen_);\n },\n\n disconnect_: function() {\n for (var i = 0; i < this.observed_.length; i += 2) {\n if (this.observed_[i] === observerSentinel)\n this.observed_[i + 1].close();\n }\n this.observed_.length = 0;\n this.value_.length = 0;\n\n if (this.directObserver_) {\n this.directObserver_.close(this);\n this.directObserver_ = undefined;\n }\n },\n\n addPath: function(object, path) {\n if (this.state_ != UNOPENED && this.state_ != RESETTING)\n throw Error('Cannot add paths once started.');\n\n var path = getPath(path);\n this.observed_.push(object, path);\n if (!this.reportChangesOnOpen_)\n return;\n var index = this.observed_.length / 2 - 1;\n this.value_[index] = path.getValueFrom(object);\n },\n\n addObserver: function(observer) {\n if (this.state_ != UNOPENED && this.state_ != RESETTING)\n throw Error('Cannot add observers once started.');\n\n this.observed_.push(observerSentinel, observer);\n if (!this.reportChangesOnOpen_)\n return;\n var index = this.observed_.length / 2 - 1;\n this.value_[index] = observer.open(this.deliver, this);\n },\n\n startReset: function() {\n if (this.state_ != OPENED)\n throw Error('Can only reset while open');\n\n this.state_ = RESETTING;\n this.disconnect_();\n },\n\n finishReset: function() {\n if (this.state_ != RESETTING)\n throw Error('Can only finishReset after startReset');\n this.state_ = OPENED;\n this.connect_();\n\n return this.value_;\n },\n\n iterateObjects_: function(observe) {\n var object;\n for (var i = 0; i < this.observed_.length; i += 2) {\n object = this.observed_[i]\n if (object !== observerSentinel)\n this.observed_[i + 1].iterateObjects(object, observe)\n }\n },\n\n check_: function(changeRecords, skipChanges) {\n var oldValues;\n for (var i = 0; i < this.observed_.length; i += 2) {\n var object = this.observed_[i];\n var path = this.observed_[i+1];\n var value;\n if (object === observerSentinel) {\n var observable = path;\n value = this.state_ === UNOPENED ?\n observable.open(this.deliver, this) :\n observable.discardChanges();\n } else {\n value = path.getValueFrom(object);\n }\n\n if (skipChanges) {\n this.value_[i / 2] = value;\n continue;\n }\n\n if (areSameValue(value, this.value_[i / 2]))\n continue;\n\n oldValues = oldValues || [];\n oldValues[i / 2] = this.value_[i / 2];\n this.value_[i / 2] = value;\n }\n\n if (!oldValues)\n return false;\n\n // TODO(rafaelw): Having observed_ as the third callback arg here is\n // pretty lame API. Fix.\n this.report_([this.value_, oldValues, this.observed_]);\n return true;\n }\n });\n\n function identFn(value) { return value; }\n\n function ObserverTransform(observable, getValueFn, setValueFn,\n dontPassThroughSet) {\n this.callback_ = undefined;\n this.target_ = undefined;\n this.value_ = undefined;\n this.observable_ = observable;\n this.getValueFn_ = getValueFn || identFn;\n this.setValueFn_ = setValueFn || identFn;\n // TODO(rafaelw): This is a temporary hack. PolymerExpressions needs this\n // at the moment because of a bug in it's dependency tracking.\n this.dontPassThroughSet_ = dontPassThroughSet;\n }\n\n ObserverTransform.prototype = {\n open: function(callback, target) {\n this.callback_ = callback;\n this.target_ = target;\n this.value_ =\n this.getValueFn_(this.observable_.open(this.observedCallback_, this));\n return this.value_;\n },\n\n observedCallback_: function(value) {\n value = this.getValueFn_(value);\n if (areSameValue(value, this.value_))\n return;\n var oldValue = this.value_;\n this.value_ = value;\n this.callback_.call(this.target_, this.value_, oldValue);\n },\n\n discardChanges: function() {\n this.value_ = this.getValueFn_(this.observable_.discardChanges());\n return this.value_;\n },\n\n deliver: function() {\n return this.observable_.deliver();\n },\n\n setValue: function(value) {\n value = this.setValueFn_(value);\n if (!this.dontPassThroughSet_ && this.observable_.setValue)\n return this.observable_.setValue(value);\n },\n\n close: function() {\n if (this.observable_)\n this.observable_.close();\n this.callback_ = undefined;\n this.target_ = undefined;\n this.observable_ = undefined;\n this.value_ = undefined;\n this.getValueFn_ = undefined;\n this.setValueFn_ = undefined;\n }\n }\n\n var expectedRecordTypes = {\n add: true,\n update: true,\n delete: true\n };\n\n function diffObjectFromChangeRecords(object, changeRecords, oldValues) {\n var added = {};\n var removed = {};\n\n for (var i = 0; i < changeRecords.length; i++) {\n var record = changeRecords[i];\n if (!expectedRecordTypes[record.type]) {\n console.error('Unknown changeRecord type: ' + record.type);\n console.error(record);\n continue;\n }\n\n if (!(record.name in oldValues))\n oldValues[record.name] = record.oldValue;\n\n if (record.type == 'update')\n continue;\n\n if (record.type == 'add') {\n if (record.name in removed)\n delete removed[record.name];\n else\n added[record.name] = true;\n\n continue;\n }\n\n // type = 'delete'\n if (record.name in added) {\n delete added[record.name];\n delete oldValues[record.name];\n } else {\n removed[record.name] = true;\n }\n }\n\n for (var prop in added)\n added[prop] = object[prop];\n\n for (var prop in removed)\n removed[prop] = undefined;\n\n var changed = {};\n for (var prop in oldValues) {\n if (prop in added || prop in removed)\n continue;\n\n var newValue = object[prop];\n if (oldValues[prop] !== newValue)\n changed[prop] = newValue;\n }\n\n return {\n added: added,\n removed: removed,\n changed: changed\n };\n }\n\n function newSplice(index, removed, addedCount) {\n return {\n index: index,\n removed: removed,\n addedCount: addedCount\n };\n }\n\n var EDIT_LEAVE = 0;\n var EDIT_UPDATE = 1;\n var EDIT_ADD = 2;\n var EDIT_DELETE = 3;\n\n function ArraySplice() {}\n\n ArraySplice.prototype = {\n\n // Note: This function is *based* on the computation of the Levenshtein\n // \"edit\" distance. The one change is that \"updates\" are treated as two\n // edits - not one. With Array splices, an update is really a delete\n // followed by an add. By retaining this, we optimize for \"keeping\" the\n // maximum array items in the original array. For example:\n //\n // 'xxxx123' -> '123yyyy'\n //\n // With 1-edit updates, the shortest path would be just to update all seven\n // characters. With 2-edit updates, we delete 4, leave 3, and add 4. This\n // leaves the substring '123' intact.\n calcEditDistances: function(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n // \"Deletion\" columns\n var rowCount = oldEnd - oldStart + 1;\n var columnCount = currentEnd - currentStart + 1;\n var distances = new Array(rowCount);\n\n // \"Addition\" rows. Initialize null column.\n for (var i = 0; i < rowCount; i++) {\n distances[i] = new Array(columnCount);\n distances[i][0] = i;\n }\n\n // Initialize null row\n for (var j = 0; j < columnCount; j++)\n distances[0][j] = j;\n\n for (var i = 1; i < rowCount; i++) {\n for (var j = 1; j < columnCount; j++) {\n if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))\n distances[i][j] = distances[i - 1][j - 1];\n else {\n var north = distances[i - 1][j] + 1;\n var west = distances[i][j - 1] + 1;\n distances[i][j] = north < west ? north : west;\n }\n }\n }\n\n return distances;\n },\n\n // This starts at the final weight, and walks \"backward\" by finding\n // the minimum previous weight recursively until the origin of the weight\n // matrix.\n spliceOperationsFromEditDistances: function(distances) {\n var i = distances.length - 1;\n var j = distances[0].length - 1;\n var current = distances[i][j];\n var edits = [];\n while (i > 0 || j > 0) {\n if (i == 0) {\n edits.push(EDIT_ADD);\n j--;\n continue;\n }\n if (j == 0) {\n edits.push(EDIT_DELETE);\n i--;\n continue;\n }\n var northWest = distances[i - 1][j - 1];\n var west = distances[i - 1][j];\n var north = distances[i][j - 1];\n\n var min;\n if (west < north)\n min = west < northWest ? west : northWest;\n else\n min = north < northWest ? north : northWest;\n\n if (min == northWest) {\n if (northWest == current) {\n edits.push(EDIT_LEAVE);\n } else {\n edits.push(EDIT_UPDATE);\n current = northWest;\n }\n i--;\n j--;\n } else if (min == west) {\n edits.push(EDIT_DELETE);\n i--;\n current = west;\n } else {\n edits.push(EDIT_ADD);\n j--;\n current = north;\n }\n }\n\n edits.reverse();\n return edits;\n },\n\n /**\n * Splice Projection functions:\n *\n * A splice map is a representation of how a previous array of items\n * was transformed into a new array of items. Conceptually it is a list of\n * tuples of\n *\n * \n *\n * which are kept in ascending index order of. The tuple represents that at\n * the |index|, |removed| sequence of items were removed, and counting forward\n * from |index|, |addedCount| items were added.\n */\n\n /**\n * Lacking individual splice mutation information, the minimal set of\n * splices can be synthesized given the previous state and final state of an\n * array. The basic approach is to calculate the edit distance matrix and\n * choose the shortest path through it.\n *\n * Complexity: O(l * p)\n * l: The length of the current array\n * p: The length of the old array\n */\n calcSplices: function(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n var prefixCount = 0;\n var suffixCount = 0;\n\n var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);\n if (currentStart == 0 && oldStart == 0)\n prefixCount = this.sharedPrefix(current, old, minLength);\n\n if (currentEnd == current.length && oldEnd == old.length)\n suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);\n\n currentStart += prefixCount;\n oldStart += prefixCount;\n currentEnd -= suffixCount;\n oldEnd -= suffixCount;\n\n if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)\n return [];\n\n if (currentStart == currentEnd) {\n var splice = newSplice(currentStart, [], 0);\n while (oldStart < oldEnd)\n splice.removed.push(old[oldStart++]);\n\n return [ splice ];\n } else if (oldStart == oldEnd)\n return [ newSplice(currentStart, [], currentEnd - currentStart) ];\n\n var ops = this.spliceOperationsFromEditDistances(\n this.calcEditDistances(current, currentStart, currentEnd,\n old, oldStart, oldEnd));\n\n var splice = undefined;\n var splices = [];\n var index = currentStart;\n var oldIndex = oldStart;\n for (var i = 0; i < ops.length; i++) {\n switch(ops[i]) {\n case EDIT_LEAVE:\n if (splice) {\n splices.push(splice);\n splice = undefined;\n }\n\n index++;\n oldIndex++;\n break;\n case EDIT_UPDATE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n case EDIT_ADD:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.addedCount++;\n index++;\n break;\n case EDIT_DELETE:\n if (!splice)\n splice = newSplice(index, [], 0);\n\n splice.removed.push(old[oldIndex]);\n oldIndex++;\n break;\n }\n }\n\n if (splice) {\n splices.push(splice);\n }\n return splices;\n },\n\n sharedPrefix: function(current, old, searchLength) {\n for (var i = 0; i < searchLength; i++)\n if (!this.equals(current[i], old[i]))\n return i;\n return searchLength;\n },\n\n sharedSuffix: function(current, old, searchLength) {\n var index1 = current.length;\n var index2 = old.length;\n var count = 0;\n while (count < searchLength && this.equals(current[--index1], old[--index2]))\n count++;\n\n return count;\n },\n\n calculateSplices: function(current, previous) {\n return this.calcSplices(current, 0, current.length, previous, 0,\n previous.length);\n },\n\n equals: function(currentValue, previousValue) {\n return currentValue === previousValue;\n }\n };\n\n var arraySplice = new ArraySplice();\n\n function calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd) {\n return arraySplice.calcSplices(current, currentStart, currentEnd,\n old, oldStart, oldEnd);\n }\n\n function intersect(start1, end1, start2, end2) {\n // Disjoint\n if (end1 < start2 || end2 < start1)\n return -1;\n\n // Adjacent\n if (end1 == start2 || end2 == start1)\n return 0;\n\n // Non-zero intersect, span1 first\n if (start1 < start2) {\n if (end1 < end2)\n return end1 - start2; // Overlap\n else\n return end2 - start2; // Contained\n } else {\n // Non-zero intersect, span2 first\n if (end2 < end1)\n return end2 - start1; // Overlap\n else\n return end1 - start1; // Contained\n }\n }\n\n function mergeSplice(splices, index, removed, addedCount) {\n\n var splice = newSplice(index, removed, addedCount);\n\n var inserted = false;\n var insertionOffset = 0;\n\n for (var i = 0; i < splices.length; i++) {\n var current = splices[i];\n current.index += insertionOffset;\n\n if (inserted)\n continue;\n\n var intersectCount = intersect(splice.index,\n splice.index + splice.removed.length,\n current.index,\n current.index + current.addedCount);\n\n if (intersectCount >= 0) {\n // Merge the two splices\n\n splices.splice(i, 1);\n i--;\n\n insertionOffset -= current.addedCount - current.removed.length;\n\n splice.addedCount += current.addedCount - intersectCount;\n var deleteCount = splice.removed.length +\n current.removed.length - intersectCount;\n\n if (!splice.addedCount && !deleteCount) {\n // merged splice is a noop. discard.\n inserted = true;\n } else {\n var removed = current.removed;\n\n if (splice.index < current.index) {\n // some prefix of splice.removed is prepended to current.removed.\n var prepend = splice.removed.slice(0, current.index - splice.index);\n Array.prototype.push.apply(prepend, removed);\n removed = prepend;\n }\n\n if (splice.index + splice.removed.length > current.index + current.addedCount) {\n // some suffix of splice.removed is appended to current.removed.\n var append = splice.removed.slice(current.index + current.addedCount - splice.index);\n Array.prototype.push.apply(removed, append);\n }\n\n splice.removed = removed;\n if (current.index < splice.index) {\n splice.index = current.index;\n }\n }\n } else if (splice.index < current.index) {\n // Insert splice here.\n\n inserted = true;\n\n splices.splice(i, 0, splice);\n i++;\n\n var offset = splice.addedCount - splice.removed.length\n current.index += offset;\n insertionOffset += offset;\n }\n }\n\n if (!inserted)\n splices.push(splice);\n }\n\n function createInitialSplices(array, changeRecords) {\n var splices = [];\n\n for (var i = 0; i < changeRecords.length; i++) {\n var record = changeRecords[i];\n switch(record.type) {\n case 'splice':\n mergeSplice(splices, record.index, record.removed.slice(), record.addedCount);\n break;\n case 'add':\n case 'update':\n case 'delete':\n if (!isIndex(record.name))\n continue;\n var index = toNumber(record.name);\n if (index < 0)\n continue;\n mergeSplice(splices, index, [record.oldValue], 1);\n break;\n default:\n console.error('Unexpected record type: ' + JSON.stringify(record));\n break;\n }\n }\n\n return splices;\n }\n\n function projectArraySplices(array, changeRecords) {\n var splices = [];\n\n createInitialSplices(array, changeRecords).forEach(function(splice) {\n if (splice.addedCount == 1 && splice.removed.length == 1) {\n if (splice.removed[0] !== array[splice.index])\n splices.push(splice);\n\n return\n };\n\n splices = splices.concat(calcSplices(array, splice.index, splice.index + splice.addedCount,\n splice.removed, 0, splice.removed.length));\n });\n\n return splices;\n }\n\n global.Observer = Observer;\n global.Observer.runEOM_ = runEOM;\n global.Observer.observerSentinel_ = observerSentinel; // for testing.\n global.Observer.hasObjectObserve = hasObserve;\n global.ArrayObserver = ArrayObserver;\n global.ArrayObserver.calculateSplices = function(current, previous) {\n return arraySplice.calculateSplices(current, previous);\n };\n\n global.ArraySplice = ArraySplice;\n global.ObjectObserver = ObjectObserver;\n global.PathObserver = PathObserver;\n global.CompoundObserver = CompoundObserver;\n global.Path = Path;\n global.ObserverTransform = ObserverTransform;\n})(typeof global !== 'undefined' && global && typeof module !== 'undefined' && module ? global : this || window);\n","// select ShadowDOM impl\r\nif (Platform.flags.shadow) {\r\n","// Copyright 2012 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\nwindow.ShadowDOMPolyfill = {};\n\n(function(scope) {\n 'use strict';\n\n var constructorTable = new WeakMap();\n var nativePrototypeTable = new WeakMap();\n var wrappers = Object.create(null);\n\n function detectEval() {\n // Don't test for eval if we're running in a Chrome App environment.\n // We check for APIs set that only exist in a Chrome App context.\n if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {\n return false;\n }\n\n // Firefox OS Apps do not allow eval. This feature detection is very hacky\n // but even if some other platform adds support for this function this code\n // will continue to work.\n if (navigator.getDeviceStorage) {\n return false;\n }\n\n try {\n var f = new Function('return true;');\n return f();\n } catch (ex) {\n return false;\n }\n }\n\n var hasEval = detectEval();\n\n function assert(b) {\n if (!b)\n throw new Error('Assertion failed');\n };\n\n var defineProperty = Object.defineProperty;\n var getOwnPropertyNames = Object.getOwnPropertyNames;\n var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n function mixin(to, from) {\n var names = getOwnPropertyNames(from);\n for (var i = 0; i < names.length; i++) {\n var name = names[i];\n defineProperty(to, name, getOwnPropertyDescriptor(from, name));\n }\n return to;\n };\n\n function mixinStatics(to, from) {\n var names = getOwnPropertyNames(from);\n for (var i = 0; i < names.length; i++) {\n var name = names[i];\n switch (name) {\n case 'arguments':\n case 'caller':\n case 'length':\n case 'name':\n case 'prototype':\n case 'toString':\n continue;\n }\n defineProperty(to, name, getOwnPropertyDescriptor(from, name));\n }\n return to;\n };\n\n function oneOf(object, propertyNames) {\n for (var i = 0; i < propertyNames.length; i++) {\n if (propertyNames[i] in object)\n return propertyNames[i];\n }\n }\n\n var nonEnumerableDataDescriptor = {\n value: undefined,\n configurable: true,\n enumerable: false,\n writable: true\n };\n\n function defineNonEnumerableDataProperty(object, name, value) {\n nonEnumerableDataDescriptor.value = value;\n defineProperty(object, name, nonEnumerableDataDescriptor);\n }\n\n // Mozilla's old DOM bindings are bretty busted:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=855844\n // Make sure they are create before we start modifying things.\n getOwnPropertyNames(window);\n\n function getWrapperConstructor(node) {\n var nativePrototype = node.__proto__ || Object.getPrototypeOf(node);\n var wrapperConstructor = constructorTable.get(nativePrototype);\n if (wrapperConstructor)\n return wrapperConstructor;\n\n var parentWrapperConstructor = getWrapperConstructor(nativePrototype);\n\n var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor);\n registerInternal(nativePrototype, GeneratedWrapper, node);\n\n return GeneratedWrapper;\n }\n\n function addForwardingProperties(nativePrototype, wrapperPrototype) {\n installProperty(nativePrototype, wrapperPrototype, true);\n }\n\n function registerInstanceProperties(wrapperPrototype, instanceObject) {\n installProperty(instanceObject, wrapperPrototype, false);\n }\n\n var isFirefox = /Firefox/.test(navigator.userAgent);\n\n // This is used as a fallback when getting the descriptor fails in\n // installProperty.\n var dummyDescriptor = {\n get: function() {},\n set: function(v) {},\n configurable: true,\n enumerable: true\n };\n\n function isEventHandlerName(name) {\n return /^on[a-z]+$/.test(name);\n }\n\n function isIdentifierName(name) {\n return /^\\w[a-zA-Z_0-9]*$/.test(name);\n }\n\n function getGetter(name) {\n return hasEval && isIdentifierName(name) ?\n new Function('return this.impl.' + name) :\n function() { return this.impl[name]; };\n }\n\n function getSetter(name) {\n return hasEval && isIdentifierName(name) ?\n new Function('v', 'this.impl.' + name + ' = v') :\n function(v) { this.impl[name] = v; };\n }\n\n function getMethod(name) {\n return hasEval && isIdentifierName(name) ?\n new Function('return this.impl.' + name +\n '.apply(this.impl, arguments)') :\n function() { return this.impl[name].apply(this.impl, arguments); };\n }\n\n function getDescriptor(source, name) {\n try {\n return Object.getOwnPropertyDescriptor(source, name);\n } catch (ex) {\n // JSC and V8 both use data properties instead of accessors which can\n // cause getting the property desciptor to throw an exception.\n // https://bugs.webkit.org/show_bug.cgi?id=49739\n return dummyDescriptor;\n }\n }\n\n function installProperty(source, target, allowMethod, opt_blacklist) {\n var names = getOwnPropertyNames(source);\n for (var i = 0; i < names.length; i++) {\n var name = names[i];\n if (name === 'polymerBlackList_')\n continue;\n\n if (name in target)\n continue;\n\n if (source.polymerBlackList_ && source.polymerBlackList_[name])\n continue;\n\n if (isFirefox) {\n // Tickle Firefox's old bindings.\n source.__lookupGetter__(name);\n }\n var descriptor = getDescriptor(source, name);\n var getter, setter;\n if (allowMethod && typeof descriptor.value === 'function') {\n target[name] = getMethod(name);\n continue;\n }\n\n var isEvent = isEventHandlerName(name);\n if (isEvent)\n getter = scope.getEventHandlerGetter(name);\n else\n getter = getGetter(name);\n\n if (descriptor.writable || descriptor.set) {\n if (isEvent)\n setter = scope.getEventHandlerSetter(name);\n else\n setter = getSetter(name);\n }\n\n defineProperty(target, name, {\n get: getter,\n set: setter,\n configurable: descriptor.configurable,\n enumerable: descriptor.enumerable\n });\n }\n }\n\n /**\n * @param {Function} nativeConstructor\n * @param {Function} wrapperConstructor\n * @param {Object=} opt_instance If present, this is used to extract\n * properties from an instance object.\n */\n function register(nativeConstructor, wrapperConstructor, opt_instance) {\n var nativePrototype = nativeConstructor.prototype;\n registerInternal(nativePrototype, wrapperConstructor, opt_instance);\n mixinStatics(wrapperConstructor, nativeConstructor);\n }\n\n function registerInternal(nativePrototype, wrapperConstructor, opt_instance) {\n var wrapperPrototype = wrapperConstructor.prototype;\n assert(constructorTable.get(nativePrototype) === undefined);\n\n constructorTable.set(nativePrototype, wrapperConstructor);\n nativePrototypeTable.set(wrapperPrototype, nativePrototype);\n\n addForwardingProperties(nativePrototype, wrapperPrototype);\n if (opt_instance)\n registerInstanceProperties(wrapperPrototype, opt_instance);\n\n defineNonEnumerableDataProperty(\n wrapperPrototype, 'constructor', wrapperConstructor);\n // Set it again. Some VMs optimizes objects that are used as prototypes.\n wrapperConstructor.prototype = wrapperPrototype;\n }\n\n function isWrapperFor(wrapperConstructor, nativeConstructor) {\n return constructorTable.get(nativeConstructor.prototype) ===\n wrapperConstructor;\n }\n\n /**\n * Creates a generic wrapper constructor based on |object| and its\n * constructor.\n * @param {Node} object\n * @return {Function} The generated constructor.\n */\n function registerObject(object) {\n var nativePrototype = Object.getPrototypeOf(object);\n\n var superWrapperConstructor = getWrapperConstructor(nativePrototype);\n var GeneratedWrapper = createWrapperConstructor(superWrapperConstructor);\n registerInternal(nativePrototype, GeneratedWrapper, object);\n\n return GeneratedWrapper;\n }\n\n function createWrapperConstructor(superWrapperConstructor) {\n function GeneratedWrapper(node) {\n superWrapperConstructor.call(this, node);\n }\n var p = Object.create(superWrapperConstructor.prototype);\n p.constructor = GeneratedWrapper;\n GeneratedWrapper.prototype = p;\n\n return GeneratedWrapper;\n }\n\n var OriginalDOMImplementation = window.DOMImplementation;\n var OriginalEventTarget = window.EventTarget;\n var OriginalEvent = window.Event;\n var OriginalNode = window.Node;\n var OriginalWindow = window.Window;\n var OriginalRange = window.Range;\n var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;\n var OriginalWebGLRenderingContext = window.WebGLRenderingContext;\n var OriginalSVGElementInstance = window.SVGElementInstance;\n var OriginalFormData = window.FormData;\n \n function isWrapper(object) {\n return object instanceof wrappers.EventTarget ||\n object instanceof wrappers.Event ||\n object instanceof wrappers.Range ||\n object instanceof wrappers.DOMImplementation ||\n object instanceof wrappers.CanvasRenderingContext2D ||\n object instanceof wrappers.FormData ||\n wrappers.WebGLRenderingContext &&\n object instanceof wrappers.WebGLRenderingContext;\n }\n\n function isNative(object) {\n return OriginalEventTarget && object instanceof OriginalEventTarget ||\n object instanceof OriginalNode ||\n object instanceof OriginalEvent ||\n object instanceof OriginalWindow ||\n object instanceof OriginalRange ||\n object instanceof OriginalDOMImplementation ||\n object instanceof OriginalCanvasRenderingContext2D ||\n object instanceof OriginalFormData ||\n OriginalWebGLRenderingContext &&\n object instanceof OriginalWebGLRenderingContext ||\n OriginalSVGElementInstance &&\n object instanceof OriginalSVGElementInstance;\n }\n\n /**\n * Wraps a node in a WrapperNode. If there already exists a wrapper for the\n * |node| that wrapper is returned instead.\n * @param {Node} node\n * @return {WrapperNode}\n */\n function wrap(impl) {\n if (impl === null)\n return null;\n\n assert(isNative(impl));\n return impl.polymerWrapper_ ||\n (impl.polymerWrapper_ = new (getWrapperConstructor(impl))(impl));\n }\n\n /**\n * Unwraps a wrapper and returns the node it is wrapping.\n * @param {WrapperNode} wrapper\n * @return {Node}\n */\n function unwrap(wrapper) {\n if (wrapper === null)\n return null;\n assert(isWrapper(wrapper));\n return wrapper.impl;\n }\n\n /**\n * Unwraps object if it is a wrapper.\n * @param {Object} object\n * @return {Object} The native implementation object.\n */\n function unwrapIfNeeded(object) {\n return object && isWrapper(object) ? unwrap(object) : object;\n }\n\n /**\n * Wraps object if it is not a wrapper.\n * @param {Object} object\n * @return {Object} The wrapper for object.\n */\n function wrapIfNeeded(object) {\n return object && !isWrapper(object) ? wrap(object) : object;\n }\n\n /**\n * Overrides the current wrapper (if any) for node.\n * @param {Node} node\n * @param {WrapperNode=} wrapper If left out the wrapper will be created as\n * needed next time someone wraps the node.\n */\n function rewrap(node, wrapper) {\n if (wrapper === null)\n return;\n assert(isNative(node));\n assert(wrapper === undefined || isWrapper(wrapper));\n node.polymerWrapper_ = wrapper;\n }\n\n var getterDescriptor = {\n get: undefined,\n configurable: true,\n enumerable: true\n };\n\n function defineGetter(constructor, name, getter) {\n getterDescriptor.get = getter;\n defineProperty(constructor.prototype, name, getterDescriptor);\n }\n\n function defineWrapGetter(constructor, name) {\n defineGetter(constructor, name, function() {\n return wrap(this.impl[name]);\n });\n }\n\n /**\n * Forwards existing methods on the native object to the wrapper methods.\n * This does not wrap any of the arguments or the return value since the\n * wrapper implementation already takes care of that.\n * @param {Array.} constructors\n * @parem {Array.} names\n */\n function forwardMethodsToWrapper(constructors, names) {\n constructors.forEach(function(constructor) {\n names.forEach(function(name) {\n constructor.prototype[name] = function() {\n var w = wrapIfNeeded(this);\n return w[name].apply(w, arguments);\n };\n });\n });\n }\n\n scope.assert = assert;\n scope.constructorTable = constructorTable;\n scope.defineGetter = defineGetter;\n scope.defineWrapGetter = defineWrapGetter;\n scope.forwardMethodsToWrapper = forwardMethodsToWrapper;\n scope.isWrapper = isWrapper;\n scope.isWrapperFor = isWrapperFor;\n scope.mixin = mixin;\n scope.nativePrototypeTable = nativePrototypeTable;\n scope.oneOf = oneOf;\n scope.registerObject = registerObject;\n scope.registerWrapper = register;\n scope.rewrap = rewrap;\n scope.unwrap = unwrap;\n scope.unwrapIfNeeded = unwrapIfNeeded;\n scope.wrap = wrap;\n scope.wrapIfNeeded = wrapIfNeeded;\n scope.wrappers = wrappers;\n\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(context) {\n 'use strict';\n\n var OriginalMutationObserver = window.MutationObserver;\n var callbacks = [];\n var pending = false;\n var timerFunc;\n\n function handle() {\n pending = false;\n var copies = callbacks.slice(0);\n callbacks = [];\n for (var i = 0; i < copies.length; i++) {\n (0, copies[i])();\n }\n }\n\n if (OriginalMutationObserver) {\n var counter = 1;\n var observer = new OriginalMutationObserver(handle);\n var textNode = document.createTextNode(counter);\n observer.observe(textNode, {characterData: true});\n\n timerFunc = function() {\n counter = (counter + 1) % 2;\n textNode.data = counter;\n };\n\n } else {\n timerFunc = window.setImmediate || window.setTimeout;\n }\n\n function setEndOfMicrotask(func) {\n callbacks.push(func);\n if (pending)\n return;\n pending = true;\n timerFunc(handle, 0);\n }\n\n context.setEndOfMicrotask = setEndOfMicrotask;\n\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var setEndOfMicrotask = scope.setEndOfMicrotask\n var wrapIfNeeded = scope.wrapIfNeeded\n var wrappers = scope.wrappers;\n\n var registrationsTable = new WeakMap();\n var globalMutationObservers = [];\n var isScheduled = false;\n\n function scheduleCallback(observer) {\n if (isScheduled)\n return;\n setEndOfMicrotask(notifyObservers);\n isScheduled = true;\n }\n\n // http://dom.spec.whatwg.org/#mutation-observers\n function notifyObservers() {\n isScheduled = false;\n\n do {\n var notifyList = globalMutationObservers.slice();\n var anyNonEmpty = false;\n for (var i = 0; i < notifyList.length; i++) {\n var mo = notifyList[i];\n var queue = mo.takeRecords();\n removeTransientObserversFor(mo);\n if (queue.length) {\n mo.callback_(queue, mo);\n anyNonEmpty = true;\n }\n }\n } while (anyNonEmpty);\n }\n\n /**\n * @param {string} type\n * @param {Node} target\n * @constructor\n */\n function MutationRecord(type, target) {\n this.type = type;\n this.target = target;\n this.addedNodes = new wrappers.NodeList();\n this.removedNodes = new wrappers.NodeList();\n this.previousSibling = null;\n this.nextSibling = null;\n this.attributeName = null;\n this.attributeNamespace = null;\n this.oldValue = null;\n }\n\n /**\n * Registers transient observers to ancestor and its ancesors for the node\n * which was removed.\n * @param {!Node} ancestor\n * @param {!Node} node\n */\n function registerTransientObservers(ancestor, node) {\n for (; ancestor; ancestor = ancestor.parentNode) {\n var registrations = registrationsTable.get(ancestor);\n if (!registrations)\n continue;\n for (var i = 0; i < registrations.length; i++) {\n var registration = registrations[i];\n if (registration.options.subtree)\n registration.addTransientObserver(node);\n }\n }\n }\n\n function removeTransientObserversFor(observer) {\n for (var i = 0; i < observer.nodes_.length; i++) {\n var node = observer.nodes_[i];\n var registrations = registrationsTable.get(node);\n if (!registrations)\n return;\n for (var j = 0; j < registrations.length; j++) {\n var registration = registrations[j];\n if (registration.observer === observer)\n registration.removeTransientObservers();\n }\n }\n }\n\n // http://dom.spec.whatwg.org/#queue-a-mutation-record\n function enqueueMutation(target, type, data) {\n // 1.\n var interestedObservers = Object.create(null);\n var associatedStrings = Object.create(null);\n\n // 2.\n for (var node = target; node; node = node.parentNode) {\n // 3.\n var registrations = registrationsTable.get(node);\n if (!registrations)\n continue;\n for (var j = 0; j < registrations.length; j++) {\n var registration = registrations[j];\n var options = registration.options;\n // 1.\n if (node !== target && !options.subtree)\n continue;\n\n // 2.\n if (type === 'attributes' && !options.attributes)\n continue;\n\n // 3. If type is \"attributes\", options's attributeFilter is present, and\n // either options's attributeFilter does not contain name or namespace\n // is non-null, continue.\n if (type === 'attributes' && options.attributeFilter &&\n (data.namespace !== null ||\n options.attributeFilter.indexOf(data.name) === -1)) {\n continue;\n }\n\n // 4.\n if (type === 'characterData' && !options.characterData)\n continue;\n\n // 5.\n if (type === 'childList' && !options.childList)\n continue;\n\n // 6.\n var observer = registration.observer;\n interestedObservers[observer.uid_] = observer;\n\n // 7. If either type is \"attributes\" and options's attributeOldValue is\n // true, or type is \"characterData\" and options's characterDataOldValue\n // is true, set the paired string of registered observer's observer in\n // interested observers to oldValue.\n if (type === 'attributes' && options.attributeOldValue ||\n type === 'characterData' && options.characterDataOldValue) {\n associatedStrings[observer.uid_] = data.oldValue;\n }\n }\n }\n\n var anyRecordsEnqueued = false;\n\n // 4.\n for (var uid in interestedObservers) {\n var observer = interestedObservers[uid];\n var record = new MutationRecord(type, target);\n\n // 2.\n if ('name' in data && 'namespace' in data) {\n record.attributeName = data.name;\n record.attributeNamespace = data.namespace;\n }\n\n // 3.\n if (data.addedNodes)\n record.addedNodes = data.addedNodes;\n\n // 4.\n if (data.removedNodes)\n record.removedNodes = data.removedNodes;\n\n // 5.\n if (data.previousSibling)\n record.previousSibling = data.previousSibling;\n\n // 6.\n if (data.nextSibling)\n record.nextSibling = data.nextSibling;\n\n // 7.\n if (associatedStrings[uid] !== undefined)\n record.oldValue = associatedStrings[uid];\n\n // 8.\n observer.records_.push(record);\n\n anyRecordsEnqueued = true;\n }\n\n if (anyRecordsEnqueued)\n scheduleCallback();\n }\n\n var slice = Array.prototype.slice;\n\n /**\n * @param {!Object} options\n * @constructor\n */\n function MutationObserverOptions(options) {\n this.childList = !!options.childList;\n this.subtree = !!options.subtree;\n\n // 1. If either options' attributeOldValue or attributeFilter is present\n // and options' attributes is omitted, set options' attributes to true.\n if (!('attributes' in options) &&\n ('attributeOldValue' in options || 'attributeFilter' in options)) {\n this.attributes = true;\n } else {\n this.attributes = !!options.attributes;\n }\n\n // 2. If options' characterDataOldValue is present and options'\n // characterData is omitted, set options' characterData to true.\n if ('characterDataOldValue' in options && !('characterData' in options))\n this.characterData = true;\n else\n this.characterData = !!options.characterData;\n\n // 3. & 4.\n if (!this.attributes &&\n (options.attributeOldValue || 'attributeFilter' in options) ||\n // 5.\n !this.characterData && options.characterDataOldValue) {\n throw new TypeError();\n }\n\n this.characterData = !!options.characterData;\n this.attributeOldValue = !!options.attributeOldValue;\n this.characterDataOldValue = !!options.characterDataOldValue;\n if ('attributeFilter' in options) {\n if (options.attributeFilter == null ||\n typeof options.attributeFilter !== 'object') {\n throw new TypeError();\n }\n this.attributeFilter = slice.call(options.attributeFilter);\n } else {\n this.attributeFilter = null;\n }\n }\n\n var uidCounter = 0;\n\n /**\n * The class that maps to the DOM MutationObserver interface.\n * @param {Function} callback.\n * @constructor\n */\n function MutationObserver(callback) {\n this.callback_ = callback;\n this.nodes_ = [];\n this.records_ = [];\n this.uid_ = ++uidCounter;\n\n // This will leak. There is no way to implement this without WeakRefs :'(\n globalMutationObservers.push(this);\n }\n\n MutationObserver.prototype = {\n // http://dom.spec.whatwg.org/#dom-mutationobserver-observe\n observe: function(target, options) {\n target = wrapIfNeeded(target);\n\n var newOptions = new MutationObserverOptions(options);\n\n // 6.\n var registration;\n var registrations = registrationsTable.get(target);\n if (!registrations)\n registrationsTable.set(target, registrations = []);\n\n for (var i = 0; i < registrations.length; i++) {\n if (registrations[i].observer === this) {\n registration = registrations[i];\n // 6.1.\n registration.removeTransientObservers();\n // 6.2.\n registration.options = newOptions;\n }\n }\n\n // 7.\n if (!registration) {\n registration = new Registration(this, target, newOptions);\n registrations.push(registration);\n this.nodes_.push(target);\n }\n },\n\n // http://dom.spec.whatwg.org/#dom-mutationobserver-disconnect\n disconnect: function() {\n this.nodes_.forEach(function(node) {\n var registrations = registrationsTable.get(node);\n for (var i = 0; i < registrations.length; i++) {\n var registration = registrations[i];\n if (registration.observer === this) {\n registrations.splice(i, 1);\n // Each node can only have one registered observer associated with\n // this observer.\n break;\n }\n }\n }, this);\n this.records_ = [];\n },\n\n takeRecords: function() {\n var copyOfRecords = this.records_;\n this.records_ = [];\n return copyOfRecords;\n }\n };\n\n /**\n * Class used to represent a registered observer.\n * @param {MutationObserver} observer\n * @param {Node} target\n * @param {MutationObserverOptions} options\n * @constructor\n */\n function Registration(observer, target, options) {\n this.observer = observer;\n this.target = target;\n this.options = options;\n this.transientObservedNodes = [];\n }\n\n Registration.prototype = {\n /**\n * Adds a transient observer on node. The transient observer gets removed\n * next time we deliver the change records.\n * @param {Node} node\n */\n addTransientObserver: function(node) {\n // Don't add transient observers on the target itself. We already have all\n // the required listeners set up on the target.\n if (node === this.target)\n return;\n\n this.transientObservedNodes.push(node);\n var registrations = registrationsTable.get(node);\n if (!registrations)\n registrationsTable.set(node, registrations = []);\n\n // We know that registrations does not contain this because we already\n // checked if node === this.target.\n registrations.push(this);\n },\n\n removeTransientObservers: function() {\n var transientObservedNodes = this.transientObservedNodes;\n this.transientObservedNodes = [];\n\n for (var i = 0; i < transientObservedNodes.length; i++) {\n var node = transientObservedNodes[i];\n var registrations = registrationsTable.get(node);\n for (var j = 0; j < registrations.length; j++) {\n if (registrations[j] === this) {\n registrations.splice(j, 1);\n // Each node can only have one registered observer associated with\n // this observer.\n break;\n }\n }\n }\n }\n };\n\n scope.enqueueMutation = enqueueMutation;\n scope.registerTransientObservers = registerTransientObservers;\n scope.wrappers.MutationObserver = MutationObserver;\n scope.wrappers.MutationRecord = MutationRecord;\n\n})(window.ShadowDOMPolyfill);\n","/**\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n /**\n * A tree scope represents the root of a tree. All nodes in a tree point to\n * the same TreeScope object. The tree scope of a node get set the first time\n * it is accessed or when a node is added or remove to a tree.\n *\n * The root is a Node that has no parent.\n *\n * The parent is another TreeScope. For ShadowRoots, it is the TreeScope of\n * the host of the ShadowRoot.\n *\n * @param {!Node} root\n * @param {TreeScope} parent\n * @constructor\n */\n function TreeScope(root, parent) {\n /** @type {!Node} */\n this.root = root;\n\n /** @type {TreeScope} */\n this.parent = parent;\n }\n\n TreeScope.prototype = {\n get renderer() {\n if (this.root instanceof scope.wrappers.ShadowRoot) {\n return scope.getRendererForHost(this.root.host);\n }\n return null;\n },\n\n contains: function(treeScope) {\n for (; treeScope; treeScope = treeScope.parent) {\n if (treeScope === this)\n return true;\n }\n return false;\n }\n };\n\n function setTreeScope(node, treeScope) {\n if (node.treeScope_ !== treeScope) {\n node.treeScope_ = treeScope;\n for (var sr = node.shadowRoot; sr; sr = sr.olderShadowRoot) {\n sr.treeScope_.parent = treeScope;\n }\n for (var child = node.firstChild; child; child = child.nextSibling) {\n setTreeScope(child, treeScope);\n }\n }\n }\n\n function getTreeScope(node) {\n if (node instanceof scope.wrappers.Window) {\n debugger;\n }\n\n if (node.treeScope_)\n return node.treeScope_;\n var parent = node.parentNode;\n var treeScope;\n if (parent)\n treeScope = getTreeScope(parent);\n else\n treeScope = new TreeScope(node, null);\n return node.treeScope_ = treeScope;\n }\n\n scope.TreeScope = TreeScope;\n scope.getTreeScope = getTreeScope;\n scope.setTreeScope = setTreeScope;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;\n var getTreeScope = scope.getTreeScope;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n var wrappers = scope.wrappers;\n\n var wrappedFuns = new WeakMap();\n var listenersTable = new WeakMap();\n var handledEventsTable = new WeakMap();\n var currentlyDispatchingEvents = new WeakMap();\n var targetTable = new WeakMap();\n var currentTargetTable = new WeakMap();\n var relatedTargetTable = new WeakMap();\n var eventPhaseTable = new WeakMap();\n var stopPropagationTable = new WeakMap();\n var stopImmediatePropagationTable = new WeakMap();\n var eventHandlersTable = new WeakMap();\n var eventPathTable = new WeakMap();\n\n function isShadowRoot(node) {\n return node instanceof wrappers.ShadowRoot;\n }\n\n function rootOfNode(node) {\n return getTreeScope(node).root;\n }\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-paths\n function getEventPath(node, event) {\n var path = [];\n var current = node;\n path.push(current);\n while (current) {\n // 4.1.\n var destinationInsertionPoints = getDestinationInsertionPoints(current);\n if (destinationInsertionPoints && destinationInsertionPoints.length > 0) {\n // 4.1.1\n for (var i = 0; i < destinationInsertionPoints.length; i++) {\n var insertionPoint = destinationInsertionPoints[i];\n // 4.1.1.1\n if (isShadowInsertionPoint(insertionPoint)) {\n var shadowRoot = rootOfNode(insertionPoint);\n // 4.1.1.1.2\n var olderShadowRoot = shadowRoot.olderShadowRoot;\n if (olderShadowRoot)\n path.push(olderShadowRoot);\n }\n\n // 4.1.1.2\n path.push(insertionPoint);\n }\n\n // 4.1.2\n current = destinationInsertionPoints[\n destinationInsertionPoints.length - 1];\n\n // 4.2\n } else {\n if (isShadowRoot(current)) {\n if (inSameTree(node, current) && eventMustBeStopped(event)) {\n // Stop this algorithm\n break;\n }\n current = current.host;\n path.push(current);\n\n // 4.2.2\n } else {\n current = current.parentNode;\n if (current)\n path.push(current);\n }\n }\n }\n\n return path;\n }\n\n // http://w3c.github.io/webcomponents/spec/shadow/#dfn-events-always-stopped\n function eventMustBeStopped(event) {\n if (!event)\n return false;\n\n switch (event.type) {\n case 'abort':\n case 'error':\n case 'select':\n case 'change':\n case 'load':\n case 'reset':\n case 'resize':\n case 'scroll':\n case 'selectstart':\n return true;\n }\n return false;\n }\n\n // http://w3c.github.io/webcomponents/spec/shadow/#dfn-shadow-insertion-point\n function isShadowInsertionPoint(node) {\n return node instanceof HTMLShadowElement;\n // and make sure that there are no shadow precing this?\n // and that there is no content ancestor?\n }\n\n function getDestinationInsertionPoints(node) {\n return scope.getDestinationInsertionPoints(node);\n }\n\n // http://w3c.github.io/webcomponents/spec/shadow/#event-retargeting\n function eventRetargetting(path, currentTarget) {\n if (path.length === 0)\n return currentTarget;\n\n // The currentTarget might be the window object. Use its document for the\n // purpose of finding the retargetted node.\n if (currentTarget instanceof wrappers.Window)\n currentTarget = currentTarget.document;\n\n var currentTargetTree = getTreeScope(currentTarget);\n var originalTarget = path[0];\n var originalTargetTree = getTreeScope(originalTarget);\n var relativeTargetTree =\n lowestCommonInclusiveAncestor(currentTargetTree, originalTargetTree);\n\n for (var i = 0; i < path.length; i++) {\n var node = path[i];\n if (getTreeScope(node) === relativeTargetTree)\n return node;\n }\n\n return path[path.length - 1];\n }\n\n function getTreeScopeAncestors(treeScope) {\n var ancestors = [];\n for (;treeScope; treeScope = treeScope.parent) {\n ancestors.push(treeScope);\n }\n return ancestors;\n }\n\n function lowestCommonInclusiveAncestor(tsA, tsB) {\n var ancestorsA = getTreeScopeAncestors(tsA);\n var ancestorsB = getTreeScopeAncestors(tsB);\n\n var result = null;\n while (ancestorsA.length > 0 && ancestorsB.length > 0) {\n var a = ancestorsA.pop();\n var b = ancestorsB.pop();\n if (a === b)\n result = a;\n else\n break;\n }\n return result;\n }\n\n function getTreeScopeRoot(ts) {\n if (!ts.parent)\n return ts;\n return getTreeScopeRoot(ts.parent);\n }\n\n function relatedTargetResolution(event, currentTarget, relatedTarget) {\n // In case the current target is a window use its document for the purpose\n // of retargetting the related target.\n if (currentTarget instanceof wrappers.Window)\n currentTarget = currentTarget.document;\n\n var currentTargetTree = getTreeScope(currentTarget);\n var relatedTargetTree = getTreeScope(relatedTarget);\n\n var relatedTargetEventPath = getEventPath(relatedTarget, event);\n\n var lowestCommonAncestorTree;\n\n // 4\n var lowestCommonAncestorTree =\n lowestCommonInclusiveAncestor(currentTargetTree, relatedTargetTree);\n\n // 5\n if (!lowestCommonAncestorTree)\n lowestCommonAncestorTree = relatedTargetTree.root;\n\n // 6\n for (var commonAncestorTree = lowestCommonAncestorTree;\n commonAncestorTree;\n commonAncestorTree = commonAncestorTree.parent) {\n // 6.1\n var adjustedRelatedTarget;\n for (var i = 0; i < relatedTargetEventPath.length; i++) {\n var node = relatedTargetEventPath[i];\n if (getTreeScope(node) === commonAncestorTree)\n return node;\n }\n }\n\n return null;\n }\n\n function inSameTree(a, b) {\n return getTreeScope(a) === getTreeScope(b);\n }\n\n var NONE = 0;\n var CAPTURING_PHASE = 1;\n var AT_TARGET = 2;\n var BUBBLING_PHASE = 3;\n\n // pendingError is used to rethrow the first error we got during an event\n // dispatch. The browser actually reports all errors but to do that we would\n // need to rethrow the error asynchronously.\n var pendingError;\n\n function dispatchOriginalEvent(originalEvent) {\n // Make sure this event is only dispatched once.\n if (handledEventsTable.get(originalEvent))\n return;\n handledEventsTable.set(originalEvent, true);\n dispatchEvent(wrap(originalEvent), wrap(originalEvent.target));\n if (pendingError) {\n var err = pendingError;\n pendingError = null;\n throw err;\n }\n }\n\n function dispatchEvent(event, originalWrapperTarget) {\n if (currentlyDispatchingEvents.get(event))\n throw new Error('InvalidStateError');\n\n currentlyDispatchingEvents.set(event, true);\n\n // Render to ensure that the event path is correct.\n scope.renderAllPending();\n var eventPath;\n\n // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#events-and-the-window-object\n // All events dispatched on Nodes with a default view, except load events,\n // should propagate to the Window.\n\n // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end\n var overrideTarget;\n var win;\n var type = event.type;\n\n // Should really be not cancelable too but since Firefox has a bug there\n // we skip that check.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=999456\n if (type === 'load' && !event.bubbles) {\n var doc = originalWrapperTarget;\n if (doc instanceof wrappers.Document && (win = doc.defaultView)) {\n overrideTarget = doc;\n eventPath = [];\n }\n }\n\n if (!eventPath) {\n if (originalWrapperTarget instanceof wrappers.Window) {\n win = originalWrapperTarget;\n eventPath = [];\n } else {\n eventPath = getEventPath(originalWrapperTarget, event);\n\n if (event.type !== 'load') {\n var doc = eventPath[eventPath.length - 1];\n if (doc instanceof wrappers.Document)\n win = doc.defaultView;\n }\n }\n }\n\n eventPathTable.set(event, eventPath);\n\n if (dispatchCapturing(event, eventPath, win, overrideTarget)) {\n if (dispatchAtTarget(event, eventPath, win, overrideTarget)) {\n dispatchBubbling(event, eventPath, win, overrideTarget);\n }\n }\n\n eventPhaseTable.set(event, NONE);\n currentTargetTable.delete(event, null);\n currentlyDispatchingEvents.delete(event);\n\n return event.defaultPrevented;\n }\n\n function dispatchCapturing(event, eventPath, win, overrideTarget) {\n var phase = CAPTURING_PHASE;\n\n if (win) {\n if (!invoke(win, event, phase, eventPath, overrideTarget))\n return false;\n }\n\n for (var i = eventPath.length - 1; i > 0; i--) {\n if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget))\n return false;\n }\n\n return true;\n }\n\n function dispatchAtTarget(event, eventPath, win, overrideTarget) {\n var phase = AT_TARGET;\n var currentTarget = eventPath[0] || win;\n return invoke(currentTarget, event, phase, eventPath, overrideTarget);\n }\n\n function dispatchBubbling(event, eventPath, win, overrideTarget) {\n var phase = BUBBLING_PHASE;\n for (var i = 1; i < eventPath.length; i++) {\n if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget))\n return;\n }\n\n if (win && eventPath.length > 0) {\n invoke(win, event, phase, eventPath, overrideTarget);\n }\n }\n\n function invoke(currentTarget, event, phase, eventPath, overrideTarget) {\n var listeners = listenersTable.get(currentTarget);\n if (!listeners)\n return true;\n\n var target = overrideTarget || eventRetargetting(eventPath, currentTarget);\n\n if (target === currentTarget) {\n if (phase === CAPTURING_PHASE)\n return true;\n\n if (phase === BUBBLING_PHASE)\n phase = AT_TARGET;\n\n } else if (phase === BUBBLING_PHASE && !event.bubbles) {\n return true;\n }\n\n if ('relatedTarget' in event) {\n var originalEvent = unwrap(event);\n var unwrappedRelatedTarget = originalEvent.relatedTarget;\n\n // X-Tag sets relatedTarget on a CustomEvent. If they do that there is no\n // way to have relatedTarget return the adjusted target but worse is that\n // the originalEvent might not have a relatedTarget so we hit an assert\n // when we try to wrap it.\n if (unwrappedRelatedTarget) {\n // In IE we can get objects that are not EventTargets at this point.\n // Safari does not have an EventTarget interface so revert to checking\n // for addEventListener as an approximation.\n if (unwrappedRelatedTarget instanceof Object &&\n unwrappedRelatedTarget.addEventListener) {\n var relatedTarget = wrap(unwrappedRelatedTarget);\n\n var adjusted =\n relatedTargetResolution(event, currentTarget, relatedTarget);\n if (adjusted === target)\n return true;\n } else {\n adjusted = null;\n }\n relatedTargetTable.set(event, adjusted);\n }\n }\n\n eventPhaseTable.set(event, phase);\n var type = event.type;\n\n var anyRemoved = false;\n // targetTable.set(event, target);\n targetTable.set(event, target);\n currentTargetTable.set(event, currentTarget);\n\n // Keep track of the invoke depth so that we only clean up the removed\n // listeners if we are in the outermost invoke.\n listeners.depth++;\n\n for (var i = 0, len = listeners.length; i < len; i++) {\n var listener = listeners[i];\n if (listener.removed) {\n anyRemoved = true;\n continue;\n }\n\n if (listener.type !== type ||\n !listener.capture && phase === CAPTURING_PHASE ||\n listener.capture && phase === BUBBLING_PHASE) {\n continue;\n }\n\n try {\n if (typeof listener.handler === 'function')\n listener.handler.call(currentTarget, event);\n else\n listener.handler.handleEvent(event);\n\n if (stopImmediatePropagationTable.get(event))\n return false;\n\n } catch (ex) {\n if (!pendingError)\n pendingError = ex;\n }\n }\n\n listeners.depth--;\n\n if (anyRemoved && listeners.depth === 0) {\n var copy = listeners.slice();\n listeners.length = 0;\n for (var i = 0; i < copy.length; i++) {\n if (!copy[i].removed)\n listeners.push(copy[i]);\n }\n }\n\n return !stopPropagationTable.get(event);\n }\n\n function Listener(type, handler, capture) {\n this.type = type;\n this.handler = handler;\n this.capture = Boolean(capture);\n }\n Listener.prototype = {\n equals: function(that) {\n return this.handler === that.handler && this.type === that.type &&\n this.capture === that.capture;\n },\n get removed() {\n return this.handler === null;\n },\n remove: function() {\n this.handler = null;\n }\n };\n\n var OriginalEvent = window.Event;\n OriginalEvent.prototype.polymerBlackList_ = {\n returnValue: true,\n // TODO(arv): keyLocation is part of KeyboardEvent but Firefox does not\n // support constructable KeyboardEvent so we keep it here for now.\n keyLocation: true\n };\n\n /**\n * Creates a new Event wrapper or wraps an existin native Event object.\n * @param {string|Event} type\n * @param {Object=} options\n * @constructor\n */\n function Event(type, options) {\n if (type instanceof OriginalEvent) {\n var impl = type;\n if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload')\n return new BeforeUnloadEvent(impl);\n this.impl = impl;\n } else {\n return wrap(constructEvent(OriginalEvent, 'Event', type, options));\n }\n }\n Event.prototype = {\n get target() {\n return targetTable.get(this);\n },\n get currentTarget() {\n return currentTargetTable.get(this);\n },\n get eventPhase() {\n return eventPhaseTable.get(this);\n },\n get path() {\n var eventPath = eventPathTable.get(this);\n if (!eventPath)\n return [];\n // TODO(arv): Event path should contain window.\n return eventPath.slice();\n },\n stopPropagation: function() {\n stopPropagationTable.set(this, true);\n },\n stopImmediatePropagation: function() {\n stopPropagationTable.set(this, true);\n stopImmediatePropagationTable.set(this, true);\n }\n };\n registerWrapper(OriginalEvent, Event, document.createEvent('Event'));\n\n function unwrapOptions(options) {\n if (!options || !options.relatedTarget)\n return options;\n return Object.create(options, {\n relatedTarget: {value: unwrap(options.relatedTarget)}\n });\n }\n\n function registerGenericEvent(name, SuperEvent, prototype) {\n var OriginalEvent = window[name];\n var GenericEvent = function(type, options) {\n if (type instanceof OriginalEvent)\n this.impl = type;\n else\n return wrap(constructEvent(OriginalEvent, name, type, options));\n };\n GenericEvent.prototype = Object.create(SuperEvent.prototype);\n if (prototype)\n mixin(GenericEvent.prototype, prototype);\n if (OriginalEvent) {\n // - Old versions of Safari fails on new FocusEvent (and others?).\n // - IE does not support event constructors.\n // - createEvent('FocusEvent') throws in Firefox.\n // => Try the best practice solution first and fallback to the old way\n // if needed.\n try {\n registerWrapper(OriginalEvent, GenericEvent, new OriginalEvent('temp'));\n } catch (ex) {\n registerWrapper(OriginalEvent, GenericEvent,\n document.createEvent(name));\n }\n }\n return GenericEvent;\n }\n\n var UIEvent = registerGenericEvent('UIEvent', Event);\n var CustomEvent = registerGenericEvent('CustomEvent', Event);\n\n var relatedTargetProto = {\n get relatedTarget() {\n var relatedTarget = relatedTargetTable.get(this);\n // relatedTarget can be null.\n if (relatedTarget !== undefined)\n return relatedTarget;\n return wrap(unwrap(this).relatedTarget);\n }\n };\n\n function getInitFunction(name, relatedTargetIndex) {\n return function() {\n arguments[relatedTargetIndex] = unwrap(arguments[relatedTargetIndex]);\n var impl = unwrap(this);\n impl[name].apply(impl, arguments);\n };\n }\n\n var mouseEventProto = mixin({\n initMouseEvent: getInitFunction('initMouseEvent', 14)\n }, relatedTargetProto);\n\n var focusEventProto = mixin({\n initFocusEvent: getInitFunction('initFocusEvent', 5)\n }, relatedTargetProto);\n\n var MouseEvent = registerGenericEvent('MouseEvent', UIEvent, mouseEventProto);\n var FocusEvent = registerGenericEvent('FocusEvent', UIEvent, focusEventProto);\n\n // In case the browser does not support event constructors we polyfill that\n // by calling `createEvent('Foo')` and `initFooEvent` where the arguments to\n // `initFooEvent` are derived from the registered default event init dict.\n var defaultInitDicts = Object.create(null);\n\n var supportsEventConstructors = (function() {\n try {\n new window.FocusEvent('focus');\n } catch (ex) {\n return false;\n }\n return true;\n })();\n\n /**\n * Constructs a new native event.\n */\n function constructEvent(OriginalEvent, name, type, options) {\n if (supportsEventConstructors)\n return new OriginalEvent(type, unwrapOptions(options));\n\n // Create the arguments from the default dictionary.\n var event = unwrap(document.createEvent(name));\n var defaultDict = defaultInitDicts[name];\n var args = [type];\n Object.keys(defaultDict).forEach(function(key) {\n var v = options != null && key in options ?\n options[key] : defaultDict[key];\n if (key === 'relatedTarget')\n v = unwrap(v);\n args.push(v);\n });\n event['init' + name].apply(event, args);\n return event;\n }\n\n if (!supportsEventConstructors) {\n var configureEventConstructor = function(name, initDict, superName) {\n if (superName) {\n var superDict = defaultInitDicts[superName];\n initDict = mixin(mixin({}, superDict), initDict);\n }\n\n defaultInitDicts[name] = initDict;\n };\n\n // The order of the default event init dictionary keys is important, the\n // arguments to initFooEvent is derived from that.\n configureEventConstructor('Event', {bubbles: false, cancelable: false});\n configureEventConstructor('CustomEvent', {detail: null}, 'Event');\n configureEventConstructor('UIEvent', {view: null, detail: 0}, 'Event');\n configureEventConstructor('MouseEvent', {\n screenX: 0,\n screenY: 0,\n clientX: 0,\n clientY: 0,\n ctrlKey: false,\n altKey: false,\n shiftKey: false,\n metaKey: false,\n button: 0,\n relatedTarget: null\n }, 'UIEvent');\n configureEventConstructor('FocusEvent', {relatedTarget: null}, 'UIEvent');\n }\n\n // Safari 7 does not yet have BeforeUnloadEvent.\n // https://bugs.webkit.org/show_bug.cgi?id=120849\n var OriginalBeforeUnloadEvent = window.BeforeUnloadEvent;\n\n function BeforeUnloadEvent(impl) {\n Event.call(this, impl);\n }\n BeforeUnloadEvent.prototype = Object.create(Event.prototype);\n mixin(BeforeUnloadEvent.prototype, {\n get returnValue() {\n return this.impl.returnValue;\n },\n set returnValue(v) {\n this.impl.returnValue = v;\n }\n });\n\n if (OriginalBeforeUnloadEvent)\n registerWrapper(OriginalBeforeUnloadEvent, BeforeUnloadEvent);\n\n function isValidListener(fun) {\n if (typeof fun === 'function')\n return true;\n return fun && fun.handleEvent;\n }\n\n function isMutationEvent(type) {\n switch (type) {\n case 'DOMAttrModified':\n case 'DOMAttributeNameChanged':\n case 'DOMCharacterDataModified':\n case 'DOMElementNameChanged':\n case 'DOMNodeInserted':\n case 'DOMNodeInsertedIntoDocument':\n case 'DOMNodeRemoved':\n case 'DOMNodeRemovedFromDocument':\n case 'DOMSubtreeModified':\n return true;\n }\n return false;\n }\n\n var OriginalEventTarget = window.EventTarget;\n\n /**\n * This represents a wrapper for an EventTarget.\n * @param {!EventTarget} impl The original event target.\n * @constructor\n */\n function EventTarget(impl) {\n this.impl = impl;\n }\n\n // Node and Window have different internal type checks in WebKit so we cannot\n // use the same method as the original function.\n var methodNames = [\n 'addEventListener',\n 'removeEventListener',\n 'dispatchEvent'\n ];\n\n [Node, Window].forEach(function(constructor) {\n var p = constructor.prototype;\n methodNames.forEach(function(name) {\n Object.defineProperty(p, name + '_', {value: p[name]});\n });\n });\n\n function getTargetToListenAt(wrapper) {\n if (wrapper instanceof wrappers.ShadowRoot)\n wrapper = wrapper.host;\n return unwrap(wrapper);\n }\n\n EventTarget.prototype = {\n addEventListener: function(type, fun, capture) {\n if (!isValidListener(fun) || isMutationEvent(type))\n return;\n\n var listener = new Listener(type, fun, capture);\n var listeners = listenersTable.get(this);\n if (!listeners) {\n listeners = [];\n listeners.depth = 0;\n listenersTable.set(this, listeners);\n } else {\n // Might have a duplicate.\n for (var i = 0; i < listeners.length; i++) {\n if (listener.equals(listeners[i]))\n return;\n }\n }\n\n listeners.push(listener);\n\n var target = getTargetToListenAt(this);\n target.addEventListener_(type, dispatchOriginalEvent, true);\n },\n removeEventListener: function(type, fun, capture) {\n capture = Boolean(capture);\n var listeners = listenersTable.get(this);\n if (!listeners)\n return;\n var count = 0, found = false;\n for (var i = 0; i < listeners.length; i++) {\n if (listeners[i].type === type && listeners[i].capture === capture) {\n count++;\n if (listeners[i].handler === fun) {\n found = true;\n listeners[i].remove();\n }\n }\n }\n\n if (found && count === 1) {\n var target = getTargetToListenAt(this);\n target.removeEventListener_(type, dispatchOriginalEvent, true);\n }\n },\n dispatchEvent: function(event) {\n // We want to use the native dispatchEvent because it triggers the default\n // actions (like checking a checkbox). However, if there are no listeners\n // in the composed tree then there are no events that will trigger and\n // listeners in the non composed tree that are part of the event path are\n // not notified.\n //\n // If we find out that there are no listeners in the composed tree we add\n // a temporary listener to the target which makes us get called back even\n // in that case.\n\n var nativeEvent = unwrap(event);\n var eventType = nativeEvent.type;\n\n // Allow dispatching the same event again. This is safe because if user\n // code calls this during an existing dispatch of the same event the\n // native dispatchEvent throws (that is required by the spec).\n handledEventsTable.set(nativeEvent, false);\n\n // Force rendering since we prefer native dispatch and that works on the\n // composed tree.\n scope.renderAllPending();\n\n var tempListener;\n if (!hasListenerInAncestors(this, eventType)) {\n tempListener = function() {};\n this.addEventListener(eventType, tempListener, true);\n }\n\n try {\n return unwrap(this).dispatchEvent_(nativeEvent);\n } finally {\n if (tempListener)\n this.removeEventListener(eventType, tempListener, true);\n }\n }\n };\n\n function hasListener(node, type) {\n var listeners = listenersTable.get(node);\n if (listeners) {\n for (var i = 0; i < listeners.length; i++) {\n if (!listeners[i].removed && listeners[i].type === type)\n return true;\n }\n }\n return false;\n }\n\n function hasListenerInAncestors(target, type) {\n for (var node = unwrap(target); node; node = node.parentNode) {\n if (hasListener(wrap(node), type))\n return true;\n }\n return false;\n }\n\n if (OriginalEventTarget)\n registerWrapper(OriginalEventTarget, EventTarget);\n\n function wrapEventTargetMethods(constructors) {\n forwardMethodsToWrapper(constructors, methodNames);\n }\n\n var originalElementFromPoint = document.elementFromPoint;\n\n function elementFromPoint(self, document, x, y) {\n scope.renderAllPending();\n\n var element = wrap(originalElementFromPoint.call(document.impl, x, y));\n if (!element)\n return null;\n var path = getEventPath(element, null);\n\n // scope the path to this TreeScope\n var idx = path.lastIndexOf(self);\n if (idx == -1)\n return null;\n else\n path = path.slice(0, idx);\n\n // TODO(dfreedm): pass idx to eventRetargetting to avoid array copy\n return eventRetargetting(path, self);\n }\n\n /**\n * Returns a function that is to be used as a getter for `onfoo` properties.\n * @param {string} name\n * @return {Function}\n */\n function getEventHandlerGetter(name) {\n return function() {\n var inlineEventHandlers = eventHandlersTable.get(this);\n return inlineEventHandlers && inlineEventHandlers[name] &&\n inlineEventHandlers[name].value || null;\n };\n }\n\n /**\n * Returns a function that is to be used as a setter for `onfoo` properties.\n * @param {string} name\n * @return {Function}\n */\n function getEventHandlerSetter(name) {\n var eventType = name.slice(2);\n return function(value) {\n var inlineEventHandlers = eventHandlersTable.get(this);\n if (!inlineEventHandlers) {\n inlineEventHandlers = Object.create(null);\n eventHandlersTable.set(this, inlineEventHandlers);\n }\n\n var old = inlineEventHandlers[name];\n if (old)\n this.removeEventListener(eventType, old.wrapped, false);\n\n if (typeof value === 'function') {\n var wrapped = function(e) {\n var rv = value.call(this, e);\n if (rv === false)\n e.preventDefault();\n else if (name === 'onbeforeunload' && typeof rv === 'string')\n e.returnValue = rv;\n // mouseover uses true for preventDefault but preventDefault for\n // mouseover is ignored by browsers these day.\n };\n\n this.addEventListener(eventType, wrapped, false);\n inlineEventHandlers[name] = {\n value: value,\n wrapped: wrapped\n };\n }\n };\n }\n\n scope.elementFromPoint = elementFromPoint;\n scope.getEventHandlerGetter = getEventHandlerGetter;\n scope.getEventHandlerSetter = getEventHandlerSetter;\n scope.wrapEventTargetMethods = wrapEventTargetMethods;\n scope.wrappers.BeforeUnloadEvent = BeforeUnloadEvent;\n scope.wrappers.CustomEvent = CustomEvent;\n scope.wrappers.Event = Event;\n scope.wrappers.EventTarget = EventTarget;\n scope.wrappers.FocusEvent = FocusEvent;\n scope.wrappers.MouseEvent = MouseEvent;\n scope.wrappers.UIEvent = UIEvent;\n\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var UIEvent = scope.wrappers.UIEvent;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n // TouchEvent is WebKit/Blink only.\n var OriginalTouchEvent = window.TouchEvent;\n if (!OriginalTouchEvent)\n return;\n\n var nativeEvent;\n try {\n nativeEvent = document.createEvent('TouchEvent');\n } catch (ex) {\n // In Chrome creating a TouchEvent fails if the feature is not turned on\n // which it isn't on desktop Chrome.\n return;\n }\n\n var nonEnumDescriptor = {enumerable: false};\n\n function nonEnum(obj, prop) {\n Object.defineProperty(obj, prop, nonEnumDescriptor);\n }\n\n function Touch(impl) {\n this.impl = impl;\n }\n\n Touch.prototype = {\n get target() {\n return wrap(this.impl.target);\n }\n };\n\n var descr = {\n configurable: true,\n enumerable: true,\n get: null\n };\n\n [\n 'clientX',\n 'clientY',\n 'screenX',\n 'screenY',\n 'pageX',\n 'pageY',\n 'identifier',\n 'webkitRadiusX',\n 'webkitRadiusY',\n 'webkitRotationAngle',\n 'webkitForce'\n ].forEach(function(name) {\n descr.get = function() {\n return this.impl[name];\n };\n Object.defineProperty(Touch.prototype, name, descr);\n });\n\n function TouchList() {\n this.length = 0;\n nonEnum(this, 'length');\n }\n\n TouchList.prototype = {\n item: function(index) {\n return this[index];\n }\n };\n\n function wrapTouchList(nativeTouchList) {\n var list = new TouchList();\n for (var i = 0; i < nativeTouchList.length; i++) {\n list[i] = new Touch(nativeTouchList[i]);\n }\n list.length = i;\n return list;\n }\n\n function TouchEvent(impl) {\n UIEvent.call(this, impl);\n }\n\n TouchEvent.prototype = Object.create(UIEvent.prototype);\n\n mixin(TouchEvent.prototype, {\n get touches() {\n return wrapTouchList(unwrap(this).touches);\n },\n\n get targetTouches() {\n return wrapTouchList(unwrap(this).targetTouches);\n },\n\n get changedTouches() {\n return wrapTouchList(unwrap(this).changedTouches);\n },\n\n initTouchEvent: function() {\n // The only way to use this is to reuse the TouchList from an existing\n // TouchEvent. Since this is WebKit/Blink proprietary API we will not\n // implement this until someone screams.\n throw new Error('Not implemented');\n }\n });\n\n registerWrapper(OriginalTouchEvent, TouchEvent, nativeEvent);\n\n scope.wrappers.Touch = Touch;\n scope.wrappers.TouchEvent = TouchEvent;\n scope.wrappers.TouchList = TouchList;\n\n})(window.ShadowDOMPolyfill);\n\n","// Copyright 2012 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var wrap = scope.wrap;\n\n var nonEnumDescriptor = {enumerable: false};\n\n function nonEnum(obj, prop) {\n Object.defineProperty(obj, prop, nonEnumDescriptor);\n }\n\n function NodeList() {\n this.length = 0;\n nonEnum(this, 'length');\n }\n NodeList.prototype = {\n item: function(index) {\n return this[index];\n }\n };\n nonEnum(NodeList.prototype, 'item');\n\n function wrapNodeList(list) {\n if (list == null)\n return list;\n var wrapperList = new NodeList();\n for (var i = 0, length = list.length; i < length; i++) {\n wrapperList[i] = wrap(list[i]);\n }\n wrapperList.length = length;\n return wrapperList;\n }\n\n function addWrapNodeListMethod(wrapperConstructor, name) {\n wrapperConstructor.prototype[name] = function() {\n return wrapNodeList(this.impl[name].apply(this.impl, arguments));\n };\n }\n\n scope.wrappers.NodeList = NodeList;\n scope.addWrapNodeListMethod = addWrapNodeListMethod;\n scope.wrapNodeList = wrapNodeList;\n\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n // TODO(arv): Implement.\n\n scope.wrapHTMLCollection = scope.wrapNodeList;\n scope.wrappers.HTMLCollection = scope.wrappers.NodeList;\n\n})(window.ShadowDOMPolyfill);\n","/**\n * Copyright 2012 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var EventTarget = scope.wrappers.EventTarget;\n var NodeList = scope.wrappers.NodeList;\n var TreeScope = scope.TreeScope;\n var assert = scope.assert;\n var defineWrapGetter = scope.defineWrapGetter;\n var enqueueMutation = scope.enqueueMutation;\n var getTreeScope = scope.getTreeScope;\n var isWrapper = scope.isWrapper;\n var mixin = scope.mixin;\n var registerTransientObservers = scope.registerTransientObservers;\n var registerWrapper = scope.registerWrapper;\n var setTreeScope = scope.setTreeScope;\n var unwrap = scope.unwrap;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n var wrapIfNeeded = scope.wrapIfNeeded;\n var wrappers = scope.wrappers;\n\n function assertIsNodeWrapper(node) {\n assert(node instanceof Node);\n }\n\n function createOneElementNodeList(node) {\n var nodes = new NodeList();\n nodes[0] = node;\n nodes.length = 1;\n return nodes;\n }\n\n var surpressMutations = false;\n\n /**\n * Called before node is inserted into a node to enqueue its removal from its\n * old parent.\n * @param {!Node} node The node that is about to be removed.\n * @param {!Node} parent The parent node that the node is being removed from.\n * @param {!NodeList} nodes The collected nodes.\n */\n function enqueueRemovalForInsertedNodes(node, parent, nodes) {\n enqueueMutation(parent, 'childList', {\n removedNodes: nodes,\n previousSibling: node.previousSibling,\n nextSibling: node.nextSibling\n });\n }\n\n function enqueueRemovalForInsertedDocumentFragment(df, nodes) {\n enqueueMutation(df, 'childList', {\n removedNodes: nodes\n });\n }\n\n /**\n * Collects nodes from a DocumentFragment or a Node for removal followed\n * by an insertion.\n *\n * This updates the internal pointers for node, previousNode and nextNode.\n */\n function collectNodes(node, parentNode, previousNode, nextNode) {\n if (node instanceof DocumentFragment) {\n var nodes = collectNodesForDocumentFragment(node);\n\n // The extra loop is to work around bugs with DocumentFragments in IE.\n surpressMutations = true;\n for (var i = nodes.length - 1; i >= 0; i--) {\n node.removeChild(nodes[i]);\n nodes[i].parentNode_ = parentNode;\n }\n surpressMutations = false;\n\n for (var i = 0; i < nodes.length; i++) {\n nodes[i].previousSibling_ = nodes[i - 1] || previousNode;\n nodes[i].nextSibling_ = nodes[i + 1] || nextNode;\n }\n\n if (previousNode)\n previousNode.nextSibling_ = nodes[0];\n if (nextNode)\n nextNode.previousSibling_ = nodes[nodes.length - 1];\n\n return nodes;\n }\n\n var nodes = createOneElementNodeList(node);\n var oldParent = node.parentNode;\n if (oldParent) {\n // This will enqueue the mutation record for the removal as needed.\n oldParent.removeChild(node);\n }\n\n node.parentNode_ = parentNode;\n node.previousSibling_ = previousNode;\n node.nextSibling_ = nextNode;\n if (previousNode)\n previousNode.nextSibling_ = node;\n if (nextNode)\n nextNode.previousSibling_ = node;\n\n return nodes;\n }\n\n function collectNodesNative(node) {\n if (node instanceof DocumentFragment)\n return collectNodesForDocumentFragment(node);\n\n var nodes = createOneElementNodeList(node);\n var oldParent = node.parentNode;\n if (oldParent)\n enqueueRemovalForInsertedNodes(node, oldParent, nodes);\n return nodes;\n }\n\n function collectNodesForDocumentFragment(node) {\n var nodes = new NodeList();\n var i = 0;\n for (var child = node.firstChild; child; child = child.nextSibling) {\n nodes[i++] = child;\n }\n nodes.length = i;\n enqueueRemovalForInsertedDocumentFragment(node, nodes);\n return nodes;\n }\n\n function snapshotNodeList(nodeList) {\n // NodeLists are not live at the moment so just return the same object.\n return nodeList;\n }\n\n // http://dom.spec.whatwg.org/#node-is-inserted\n function nodeWasAdded(node, treeScope) {\n setTreeScope(node, treeScope);\n node.nodeIsInserted_();\n }\n\n function nodesWereAdded(nodes, parent) {\n var treeScope = getTreeScope(parent);\n for (var i = 0; i < nodes.length; i++) {\n nodeWasAdded(nodes[i], treeScope);\n }\n }\n\n // http://dom.spec.whatwg.org/#node-is-removed\n function nodeWasRemoved(node) {\n setTreeScope(node, new TreeScope(node, null));\n }\n\n function nodesWereRemoved(nodes) {\n for (var i = 0; i < nodes.length; i++) {\n nodeWasRemoved(nodes[i]);\n }\n }\n\n function ensureSameOwnerDocument(parent, child) {\n var ownerDoc = parent.nodeType === Node.DOCUMENT_NODE ?\n parent : parent.ownerDocument;\n if (ownerDoc !== child.ownerDocument)\n ownerDoc.adoptNode(child);\n }\n\n function adoptNodesIfNeeded(owner, nodes) {\n if (!nodes.length)\n return;\n\n var ownerDoc = owner.ownerDocument;\n\n // All nodes have the same ownerDocument when we get here.\n if (ownerDoc === nodes[0].ownerDocument)\n return;\n\n for (var i = 0; i < nodes.length; i++) {\n scope.adoptNodeNoRemove(nodes[i], ownerDoc);\n }\n }\n\n function unwrapNodesForInsertion(owner, nodes) {\n adoptNodesIfNeeded(owner, nodes);\n var length = nodes.length;\n\n if (length === 1)\n return unwrap(nodes[0]);\n\n var df = unwrap(owner.ownerDocument.createDocumentFragment());\n for (var i = 0; i < length; i++) {\n df.appendChild(unwrap(nodes[i]));\n }\n return df;\n }\n\n function clearChildNodes(wrapper) {\n if (wrapper.firstChild_ !== undefined) {\n var child = wrapper.firstChild_;\n while (child) {\n var tmp = child;\n child = child.nextSibling_;\n tmp.parentNode_ = tmp.previousSibling_ = tmp.nextSibling_ = undefined;\n }\n }\n wrapper.firstChild_ = wrapper.lastChild_ = undefined;\n }\n\n function removeAllChildNodes(wrapper) {\n if (wrapper.invalidateShadowRenderer()) {\n var childWrapper = wrapper.firstChild;\n while (childWrapper) {\n assert(childWrapper.parentNode === wrapper);\n var nextSibling = childWrapper.nextSibling;\n var childNode = unwrap(childWrapper);\n var parentNode = childNode.parentNode;\n if (parentNode)\n originalRemoveChild.call(parentNode, childNode);\n childWrapper.previousSibling_ = childWrapper.nextSibling_ =\n childWrapper.parentNode_ = null;\n childWrapper = nextSibling;\n }\n wrapper.firstChild_ = wrapper.lastChild_ = null;\n } else {\n var node = unwrap(wrapper);\n var child = node.firstChild;\n var nextSibling;\n while (child) {\n nextSibling = child.nextSibling;\n originalRemoveChild.call(node, child);\n child = nextSibling;\n }\n }\n }\n\n function invalidateParent(node) {\n var p = node.parentNode;\n return p && p.invalidateShadowRenderer();\n }\n\n function cleanupNodes(nodes) {\n for (var i = 0, n; i < nodes.length; i++) {\n n = nodes[i];\n n.parentNode.removeChild(n);\n }\n }\n\n var originalImportNode = document.importNode;\n var originalCloneNode = window.Node.prototype.cloneNode;\n\n function cloneNode(node, deep, opt_doc) {\n var clone;\n if (opt_doc)\n clone = wrap(originalImportNode.call(opt_doc, node.impl, false));\n else\n clone = wrap(originalCloneNode.call(node.impl, false));\n\n if (deep) {\n for (var child = node.firstChild; child; child = child.nextSibling) {\n clone.appendChild(cloneNode(child, true, opt_doc));\n }\n\n if (node instanceof wrappers.HTMLTemplateElement) {\n var cloneContent = clone.content;\n for (var child = node.content.firstChild;\n child;\n child = child.nextSibling) {\n cloneContent.appendChild(cloneNode(child, true, opt_doc));\n }\n }\n }\n // TODO(arv): Some HTML elements also clone other data like value.\n return clone;\n }\n\n function contains(self, child) {\n if (!child || getTreeScope(self) !== getTreeScope(child))\n return false;\n\n for (var node = child; node; node = node.parentNode) {\n if (node === self)\n return true;\n }\n return false;\n }\n\n var OriginalNode = window.Node;\n\n /**\n * This represents a wrapper of a native DOM node.\n * @param {!Node} original The original DOM node, aka, the visual DOM node.\n * @constructor\n * @extends {EventTarget}\n */\n function Node(original) {\n assert(original instanceof OriginalNode);\n\n EventTarget.call(this, original);\n\n // These properties are used to override the visual references with the\n // logical ones. If the value is undefined it means that the logical is the\n // same as the visual.\n\n /**\n * @type {Node|undefined}\n * @private\n */\n this.parentNode_ = undefined;\n\n /**\n * @type {Node|undefined}\n * @private\n */\n this.firstChild_ = undefined;\n\n /**\n * @type {Node|undefined}\n * @private\n */\n this.lastChild_ = undefined;\n\n /**\n * @type {Node|undefined}\n * @private\n */\n this.nextSibling_ = undefined;\n\n /**\n * @type {Node|undefined}\n * @private\n */\n this.previousSibling_ = undefined;\n\n this.treeScope_ = undefined;\n }\n\n var OriginalDocumentFragment = window.DocumentFragment;\n var originalAppendChild = OriginalNode.prototype.appendChild;\n var originalCompareDocumentPosition =\n OriginalNode.prototype.compareDocumentPosition;\n var originalInsertBefore = OriginalNode.prototype.insertBefore;\n var originalRemoveChild = OriginalNode.prototype.removeChild;\n var originalReplaceChild = OriginalNode.prototype.replaceChild;\n\n var isIe = /Trident/.test(navigator.userAgent);\n\n var removeChildOriginalHelper = isIe ?\n function(parent, child) {\n try {\n originalRemoveChild.call(parent, child);\n } catch (ex) {\n if (!(parent instanceof OriginalDocumentFragment))\n throw ex;\n }\n } :\n function(parent, child) {\n originalRemoveChild.call(parent, child);\n };\n\n Node.prototype = Object.create(EventTarget.prototype);\n mixin(Node.prototype, {\n appendChild: function(childWrapper) {\n return this.insertBefore(childWrapper, null);\n },\n\n insertBefore: function(childWrapper, refWrapper) {\n assertIsNodeWrapper(childWrapper);\n\n var refNode;\n if (refWrapper) {\n if (isWrapper(refWrapper)) {\n refNode = unwrap(refWrapper);\n } else {\n refNode = refWrapper;\n refWrapper = wrap(refNode);\n }\n } else {\n refWrapper = null;\n refNode = null;\n }\n\n refWrapper && assert(refWrapper.parentNode === this);\n\n var nodes;\n var previousNode =\n refWrapper ? refWrapper.previousSibling : this.lastChild;\n\n var useNative = !this.invalidateShadowRenderer() &&\n !invalidateParent(childWrapper);\n\n if (useNative)\n nodes = collectNodesNative(childWrapper);\n else\n nodes = collectNodes(childWrapper, this, previousNode, refWrapper);\n\n if (useNative) {\n ensureSameOwnerDocument(this, childWrapper);\n clearChildNodes(this);\n originalInsertBefore.call(this.impl, unwrap(childWrapper), refNode);\n } else {\n if (!previousNode)\n this.firstChild_ = nodes[0];\n if (!refWrapper) {\n this.lastChild_ = nodes[nodes.length - 1];\n if (this.firstChild_ === undefined)\n this.firstChild_ = this.firstChild;\n }\n\n var parentNode = refNode ? refNode.parentNode : this.impl;\n\n // insertBefore refWrapper no matter what the parent is?\n if (parentNode) {\n originalInsertBefore.call(parentNode,\n unwrapNodesForInsertion(this, nodes), refNode);\n } else {\n adoptNodesIfNeeded(this, nodes);\n }\n }\n\n enqueueMutation(this, 'childList', {\n addedNodes: nodes,\n nextSibling: refWrapper,\n previousSibling: previousNode\n });\n\n nodesWereAdded(nodes, this);\n\n return childWrapper;\n },\n\n removeChild: function(childWrapper) {\n assertIsNodeWrapper(childWrapper);\n if (childWrapper.parentNode !== this) {\n // IE has invalid DOM trees at times.\n var found = false;\n var childNodes = this.childNodes;\n for (var ieChild = this.firstChild; ieChild;\n ieChild = ieChild.nextSibling) {\n if (ieChild === childWrapper) {\n found = true;\n break;\n }\n }\n if (!found) {\n // TODO(arv): DOMException\n throw new Error('NotFoundError');\n }\n }\n\n var childNode = unwrap(childWrapper);\n var childWrapperNextSibling = childWrapper.nextSibling;\n var childWrapperPreviousSibling = childWrapper.previousSibling;\n\n if (this.invalidateShadowRenderer()) {\n // We need to remove the real node from the DOM before updating the\n // pointers. This is so that that mutation event is dispatched before\n // the pointers have changed.\n var thisFirstChild = this.firstChild;\n var thisLastChild = this.lastChild;\n\n var parentNode = childNode.parentNode;\n if (parentNode)\n removeChildOriginalHelper(parentNode, childNode);\n\n if (thisFirstChild === childWrapper)\n this.firstChild_ = childWrapperNextSibling;\n if (thisLastChild === childWrapper)\n this.lastChild_ = childWrapperPreviousSibling;\n if (childWrapperPreviousSibling)\n childWrapperPreviousSibling.nextSibling_ = childWrapperNextSibling;\n if (childWrapperNextSibling) {\n childWrapperNextSibling.previousSibling_ =\n childWrapperPreviousSibling;\n }\n\n childWrapper.previousSibling_ = childWrapper.nextSibling_ =\n childWrapper.parentNode_ = undefined;\n } else {\n clearChildNodes(this);\n removeChildOriginalHelper(this.impl, childNode);\n }\n\n if (!surpressMutations) {\n enqueueMutation(this, 'childList', {\n removedNodes: createOneElementNodeList(childWrapper),\n nextSibling: childWrapperNextSibling,\n previousSibling: childWrapperPreviousSibling\n });\n }\n\n registerTransientObservers(this, childWrapper);\n\n return childWrapper;\n },\n\n replaceChild: function(newChildWrapper, oldChildWrapper) {\n assertIsNodeWrapper(newChildWrapper);\n\n var oldChildNode;\n if (isWrapper(oldChildWrapper)) {\n oldChildNode = unwrap(oldChildWrapper);\n } else {\n oldChildNode = oldChildWrapper;\n oldChildWrapper = wrap(oldChildNode);\n }\n\n if (oldChildWrapper.parentNode !== this) {\n // TODO(arv): DOMException\n throw new Error('NotFoundError');\n }\n\n var nextNode = oldChildWrapper.nextSibling;\n var previousNode = oldChildWrapper.previousSibling;\n var nodes;\n\n var useNative = !this.invalidateShadowRenderer() &&\n !invalidateParent(newChildWrapper);\n\n if (useNative) {\n nodes = collectNodesNative(newChildWrapper);\n } else {\n if (nextNode === newChildWrapper)\n nextNode = newChildWrapper.nextSibling;\n nodes = collectNodes(newChildWrapper, this, previousNode, nextNode);\n }\n\n if (!useNative) {\n if (this.firstChild === oldChildWrapper)\n this.firstChild_ = nodes[0];\n if (this.lastChild === oldChildWrapper)\n this.lastChild_ = nodes[nodes.length - 1];\n\n oldChildWrapper.previousSibling_ = oldChildWrapper.nextSibling_ =\n oldChildWrapper.parentNode_ = undefined;\n\n // replaceChild no matter what the parent is?\n if (oldChildNode.parentNode) {\n originalReplaceChild.call(\n oldChildNode.parentNode,\n unwrapNodesForInsertion(this, nodes),\n oldChildNode);\n }\n } else {\n ensureSameOwnerDocument(this, newChildWrapper);\n clearChildNodes(this);\n originalReplaceChild.call(this.impl, unwrap(newChildWrapper),\n oldChildNode);\n }\n\n enqueueMutation(this, 'childList', {\n addedNodes: nodes,\n removedNodes: createOneElementNodeList(oldChildWrapper),\n nextSibling: nextNode,\n previousSibling: previousNode\n });\n\n nodeWasRemoved(oldChildWrapper);\n nodesWereAdded(nodes, this);\n\n return oldChildWrapper;\n },\n\n /**\n * Called after a node was inserted. Subclasses override this to invalidate\n * the renderer as needed.\n * @private\n */\n nodeIsInserted_: function() {\n for (var child = this.firstChild; child; child = child.nextSibling) {\n child.nodeIsInserted_();\n }\n },\n\n hasChildNodes: function() {\n return this.firstChild !== null;\n },\n\n /** @type {Node} */\n get parentNode() {\n // If the parentNode has not been overridden, use the original parentNode.\n return this.parentNode_ !== undefined ?\n this.parentNode_ : wrap(this.impl.parentNode);\n },\n\n /** @type {Node} */\n get firstChild() {\n return this.firstChild_ !== undefined ?\n this.firstChild_ : wrap(this.impl.firstChild);\n },\n\n /** @type {Node} */\n get lastChild() {\n return this.lastChild_ !== undefined ?\n this.lastChild_ : wrap(this.impl.lastChild);\n },\n\n /** @type {Node} */\n get nextSibling() {\n return this.nextSibling_ !== undefined ?\n this.nextSibling_ : wrap(this.impl.nextSibling);\n },\n\n /** @type {Node} */\n get previousSibling() {\n return this.previousSibling_ !== undefined ?\n this.previousSibling_ : wrap(this.impl.previousSibling);\n },\n\n get parentElement() {\n var p = this.parentNode;\n while (p && p.nodeType !== Node.ELEMENT_NODE) {\n p = p.parentNode;\n }\n return p;\n },\n\n get textContent() {\n // TODO(arv): This should fallback to this.impl.textContent if there\n // are no shadow trees below or above the context node.\n var s = '';\n for (var child = this.firstChild; child; child = child.nextSibling) {\n if (child.nodeType != Node.COMMENT_NODE) {\n s += child.textContent;\n }\n }\n return s;\n },\n set textContent(textContent) {\n var removedNodes = snapshotNodeList(this.childNodes);\n\n if (this.invalidateShadowRenderer()) {\n removeAllChildNodes(this);\n if (textContent !== '') {\n var textNode = this.impl.ownerDocument.createTextNode(textContent);\n this.appendChild(textNode);\n }\n } else {\n clearChildNodes(this);\n this.impl.textContent = textContent;\n }\n\n var addedNodes = snapshotNodeList(this.childNodes);\n\n enqueueMutation(this, 'childList', {\n addedNodes: addedNodes,\n removedNodes: removedNodes\n });\n\n nodesWereRemoved(removedNodes);\n nodesWereAdded(addedNodes, this);\n },\n\n get childNodes() {\n var wrapperList = new NodeList();\n var i = 0;\n for (var child = this.firstChild; child; child = child.nextSibling) {\n wrapperList[i++] = child;\n }\n wrapperList.length = i;\n return wrapperList;\n },\n\n cloneNode: function(deep) {\n return cloneNode(this, deep);\n },\n\n contains: function(child) {\n return contains(this, wrapIfNeeded(child));\n },\n\n compareDocumentPosition: function(otherNode) {\n // This only wraps, it therefore only operates on the composed DOM and not\n // the logical DOM.\n return originalCompareDocumentPosition.call(this.impl,\n unwrapIfNeeded(otherNode));\n },\n\n normalize: function() {\n var nodes = snapshotNodeList(this.childNodes);\n var remNodes = [];\n var s = '';\n var modNode;\n\n for (var i = 0, n; i < nodes.length; i++) {\n n = nodes[i];\n if (n.nodeType === Node.TEXT_NODE) {\n if (!modNode && !n.data.length)\n this.removeNode(n);\n else if (!modNode)\n modNode = n;\n else {\n s += n.data;\n remNodes.push(n);\n }\n } else {\n if (modNode && remNodes.length) {\n modNode.data += s;\n cleanupNodes(remNodes);\n }\n remNodes = [];\n s = '';\n modNode = null;\n if (n.childNodes.length)\n n.normalize();\n }\n }\n\n // handle case where >1 text nodes are the last children\n if (modNode && remNodes.length) {\n modNode.data += s;\n cleanupNodes(remNodes);\n }\n }\n });\n\n defineWrapGetter(Node, 'ownerDocument');\n\n // We use a DocumentFragment as a base and then delete the properties of\n // DocumentFragment.prototype from the wrapper Node. Since delete makes\n // objects slow in some JS engines we recreate the prototype object.\n registerWrapper(OriginalNode, Node, document.createDocumentFragment());\n delete Node.prototype.querySelector;\n delete Node.prototype.querySelectorAll;\n Node.prototype = mixin(Object.create(EventTarget.prototype), Node.prototype);\n\n scope.cloneNode = cloneNode;\n scope.nodeWasAdded = nodeWasAdded;\n scope.nodeWasRemoved = nodeWasRemoved;\n scope.nodesWereAdded = nodesWereAdded;\n scope.nodesWereRemoved = nodesWereRemoved;\n scope.snapshotNodeList = snapshotNodeList;\n scope.wrappers.Node = Node;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLCollection = scope.wrappers.HTMLCollection;\n var NodeList = scope.wrappers.NodeList;\n var getTreeScope = scope.getTreeScope;\n var wrap = scope.wrap;\n\n var originalDocumentQuerySelector = document.querySelector;\n var originalElementQuerySelector = document.documentElement.querySelector;\n\n var originalDocumentQuerySelectorAll = document.querySelectorAll;\n var originalElementQuerySelectorAll = document.documentElement.querySelectorAll;\n\n var originalDocumentGetElementsByTagName = document.getElementsByTagName;\n var originalElementGetElementsByTagName = document.documentElement.getElementsByTagName;\n\n var originalDocumentGetElementsByTagNameNS = document.getElementsByTagNameNS;\n var originalElementGetElementsByTagNameNS = document.documentElement.getElementsByTagNameNS;\n\n var OriginalElement = window.Element;\n var OriginalDocument = window.HTMLDocument;\n\n function filterNodeList(list, index, result) {\n var wrappedItem = null;\n var root = null;\n for (var i = 0, length = list.length; i < length; i++) {\n wrappedItem = wrap(list[i]);\n if (root = getTreeScope(wrappedItem).root) {\n if (root instanceof scope.wrappers.ShadowRoot) {\n continue;\n }\n }\n result[index++] = wrappedItem;\n }\n \n return index;\n }\n\n function findOne(node, selector) {\n var m, el = node.firstElementChild;\n while (el) {\n if (el.matches(selector))\n return el;\n m = findOne(el, selector);\n if (m)\n return m;\n el = el.nextElementSibling;\n }\n return null;\n }\n\n function matchesSelector(el, selector) {\n return el.matches(selector);\n }\n\n var XHTML_NS = 'http://www.w3.org/1999/xhtml';\n\n function matchesTagName(el, localName, localNameLowerCase) {\n var ln = el.localName;\n return ln === localName ||\n ln === localNameLowerCase && el.namespaceURI === XHTML_NS;\n }\n\n function matchesEveryThing() {\n return true;\n }\n\n function matchesLocalNameOnly(el, ns, localName) {\n return el.localName === localName;\n }\n\n function matchesNameSpace(el, ns) {\n return el.namespaceURI === ns;\n }\n\n function matchesLocalNameNS(el, ns, localName) {\n return el.namespaceURI === ns && el.localName === localName;\n }\n\n function findElements(node, index, result, p, arg0, arg1) {\n var el = node.firstElementChild;\n while (el) {\n if (p(el, arg0, arg1))\n result[index++] = el;\n index = findElements(el, index, result, p, arg0, arg1);\n el = el.nextElementSibling;\n }\n return index;\n }\n\n // find and findAll will only match Simple Selectors,\n // Structural Pseudo Classes are not guarenteed to be correct\n // http://www.w3.org/TR/css3-selectors/#simple-selectors\n\n function querySelectorAllFiltered (p, index, result, selector) {\n var target = this.impl;\n var list;\n var root = getTreeScope(this).root;\n if (root instanceof scope.wrappers.ShadowRoot) {\n // We are in the shadow tree and the logical tree is\n // going to be disconnected so we do a manual tree traversal\n return findElements(this, index, result, p, selector, null);\n } else if (target instanceof OriginalElement) {\n list = originalElementQuerySelectorAll.call(target, selector);\n } else if (target instanceof OriginalDocument) {\n list = originalDocumentQuerySelectorAll.call(target, selector);\n } else {\n // When we get a ShadowRoot the logical tree is going to be disconnected\n // so we do a manual tree traversal\n return findElements(this, index, result, p, selector, null);\n }\n\n return filterNodeList(list, index, result);\n }\n\n var SelectorsInterface = {\n querySelector: function(selector) {\n var target = this.impl;\n var wrappedItem;\n var root = getTreeScope(this).root;\n if (root instanceof scope.wrappers.ShadowRoot) {\n // We are in the shadow tree and the logical tree is\n // going to be disconnected so we do a manual tree traversal\n return findOne(this, selector);\n } else if (target instanceof OriginalElement) {\n wrappedItem = wrap(originalElementQuerySelector.call(target, selector));\n } else if (target instanceof OriginalDocument) {\n wrappedItem = wrap(originalDocumentQuerySelector.call(target, selector));\n } else {\n // When we get a ShadowRoot the logical tree is going to be disconnected\n // so we do a manual tree traversal\n return findOne(this, selector);\n }\n\n if (!wrappedItem) {\n // When the original query returns nothing\n // we return nothing (to be consistent with the other wrapped calls)\n return wrappedItem;\n } else if (root = getTreeScope(wrappedItem).root) {\n if (root instanceof scope.wrappers.ShadowRoot) {\n // When the original query returns an element in the ShadowDOM\n // we must do a manual tree traversal\n return findOne(this, selector);\n }\n }\n\n return wrappedItem;\n },\n querySelectorAll: function(selector) {\n var result = new NodeList();\n\n result.length = querySelectorAllFiltered.call(this,\n matchesSelector,\n 0,\n result,\n selector);\n\n return result;\n }\n };\n\n function getElementsByTagNameFiltered (p, index, result, localName, lowercase) {\n var target = this.impl;\n var list;\n var root = getTreeScope(this).root;\n if (root instanceof scope.wrappers.ShadowRoot) {\n // We are in the shadow tree and the logical tree is\n // going to be disconnected so we do a manual tree traversal\n return findElements(this, index, result, p, localName, lowercase);\n } else if (target instanceof OriginalElement) {\n list = originalElementGetElementsByTagName.call(target, localName, lowercase);\n } else if (target instanceof OriginalDocument) {\n list = originalDocumentGetElementsByTagName.call(target, localName, lowercase);\n } else {\n // When we get a ShadowRoot the logical tree is going to be disconnected\n // so we do a manual tree traversal\n return findElements(this, index, result, p, localName, lowercase);\n }\n\n return filterNodeList(list, index, result);\n }\n\n function getElementsByTagNameNSFiltered (p, index, result, ns, localName) {\n var target = this.impl;\n var list;\n var root = getTreeScope(this).root;\n if (root instanceof scope.wrappers.ShadowRoot) {\n // We are in the shadow tree and the logical tree is\n // going to be disconnected so we do a manual tree traversal\n return findElements(this, index, result, p, ns, localName);\n } else if (target instanceof OriginalElement) {\n list = originalElementGetElementsByTagNameNS.call(target, ns, localName);\n } else if (target instanceof OriginalDocument) {\n list = originalDocumentGetElementsByTagNameNS.call(target, ns, localName);\n } else {\n // When we get a ShadowRoot the logical tree is going to be disconnected\n // so we do a manual tree traversal\n return findElements(this, index, result, p, ns, localName);\n }\n\n return filterNodeList(list, index, result);\n }\n\n var GetElementsByInterface = {\n getElementsByTagName: function(localName) {\n var result = new HTMLCollection();\n var match = localName === '*' ? matchesEveryThing : matchesTagName;\n\n result.length = getElementsByTagNameFiltered.call(this, \n match,\n 0, \n result,\n localName,\n localName.toLowerCase());\n\n return result;\n },\n\n getElementsByClassName: function(className) {\n // TODO(arv): Check className?\n return this.querySelectorAll('.' + className);\n },\n\n getElementsByTagNameNS: function(ns, localName) {\n var result = new HTMLCollection();\n var match = null;\n\n if (ns === '*') {\n match = localName === '*' ? matchesEveryThing : matchesLocalNameOnly;\n } else {\n match = localName === '*' ? matchesNameSpace : matchesLocalNameNS;\n }\n \n result.length = getElementsByTagNameNSFiltered.call(this, \n match,\n 0,\n result,\n ns || null,\n localName);\n\n return result;\n }\n };\n\n scope.GetElementsByInterface = GetElementsByInterface;\n scope.SelectorsInterface = SelectorsInterface;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var NodeList = scope.wrappers.NodeList;\n\n function forwardElement(node) {\n while (node && node.nodeType !== Node.ELEMENT_NODE) {\n node = node.nextSibling;\n }\n return node;\n }\n\n function backwardsElement(node) {\n while (node && node.nodeType !== Node.ELEMENT_NODE) {\n node = node.previousSibling;\n }\n return node;\n }\n\n var ParentNodeInterface = {\n get firstElementChild() {\n return forwardElement(this.firstChild);\n },\n\n get lastElementChild() {\n return backwardsElement(this.lastChild);\n },\n\n get childElementCount() {\n var count = 0;\n for (var child = this.firstElementChild;\n child;\n child = child.nextElementSibling) {\n count++;\n }\n return count;\n },\n\n get children() {\n var wrapperList = new NodeList();\n var i = 0;\n for (var child = this.firstElementChild;\n child;\n child = child.nextElementSibling) {\n wrapperList[i++] = child;\n }\n wrapperList.length = i;\n return wrapperList;\n },\n\n remove: function() {\n var p = this.parentNode;\n if (p)\n p.removeChild(this);\n }\n };\n\n var ChildNodeInterface = {\n get nextElementSibling() {\n return forwardElement(this.nextSibling);\n },\n\n get previousElementSibling() {\n return backwardsElement(this.previousSibling);\n }\n };\n\n scope.ChildNodeInterface = ChildNodeInterface;\n scope.ParentNodeInterface = ParentNodeInterface;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var ChildNodeInterface = scope.ChildNodeInterface;\n var Node = scope.wrappers.Node;\n var enqueueMutation = scope.enqueueMutation;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n\n var OriginalCharacterData = window.CharacterData;\n\n function CharacterData(node) {\n Node.call(this, node);\n }\n CharacterData.prototype = Object.create(Node.prototype);\n mixin(CharacterData.prototype, {\n get textContent() {\n return this.data;\n },\n set textContent(value) {\n this.data = value;\n },\n get data() {\n return this.impl.data;\n },\n set data(value) {\n var oldValue = this.impl.data;\n enqueueMutation(this, 'characterData', {\n oldValue: oldValue\n });\n this.impl.data = value;\n }\n });\n\n mixin(CharacterData.prototype, ChildNodeInterface);\n\n registerWrapper(OriginalCharacterData, CharacterData,\n document.createTextNode(''));\n\n scope.wrappers.CharacterData = CharacterData;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var CharacterData = scope.wrappers.CharacterData;\n var enqueueMutation = scope.enqueueMutation;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n\n function toUInt32(x) {\n return x >>> 0;\n }\n\n var OriginalText = window.Text;\n\n function Text(node) {\n CharacterData.call(this, node);\n }\n Text.prototype = Object.create(CharacterData.prototype);\n mixin(Text.prototype, {\n splitText: function(offset) {\n offset = toUInt32(offset);\n var s = this.data;\n if (offset > s.length)\n throw new Error('IndexSizeError');\n var head = s.slice(0, offset);\n var tail = s.slice(offset);\n this.data = head;\n var newTextNode = this.ownerDocument.createTextNode(tail);\n if (this.parentNode)\n this.parentNode.insertBefore(newTextNode, this.nextSibling);\n return newTextNode;\n }\n });\n\n registerWrapper(OriginalText, Text, document.createTextNode(''));\n\n scope.wrappers.Text = Text;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n function invalidateClass(el) {\n scope.invalidateRendererBasedOnAttribute(el, 'class');\n }\n\n function DOMTokenList(impl, ownerElement) {\n this.impl = impl;\n this.ownerElement_ = ownerElement;\n }\n\n DOMTokenList.prototype = {\n get length() {\n return this.impl.length;\n },\n item: function(index) {\n return this.impl.item(index);\n },\n contains: function(token) {\n return this.impl.contains(token);\n },\n add: function() {\n this.impl.add.apply(this.impl, arguments);\n invalidateClass(this.ownerElement_);\n },\n remove: function() {\n this.impl.remove.apply(this.impl, arguments);\n invalidateClass(this.ownerElement_);\n },\n toggle: function(token) {\n var rv = this.impl.toggle.apply(this.impl, arguments);\n invalidateClass(this.ownerElement_);\n return rv;\n },\n toString: function() {\n return this.impl.toString();\n }\n };\n\n scope.wrappers.DOMTokenList = DOMTokenList;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var ChildNodeInterface = scope.ChildNodeInterface;\n var GetElementsByInterface = scope.GetElementsByInterface;\n var Node = scope.wrappers.Node;\n var DOMTokenList = scope.wrappers.DOMTokenList;\n var ParentNodeInterface = scope.ParentNodeInterface;\n var SelectorsInterface = scope.SelectorsInterface;\n var addWrapNodeListMethod = scope.addWrapNodeListMethod;\n var enqueueMutation = scope.enqueueMutation;\n var mixin = scope.mixin;\n var oneOf = scope.oneOf;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrappers = scope.wrappers;\n\n var OriginalElement = window.Element;\n\n var matchesNames = [\n 'matches', // needs to come first.\n 'mozMatchesSelector',\n 'msMatchesSelector',\n 'webkitMatchesSelector',\n ].filter(function(name) {\n return OriginalElement.prototype[name];\n });\n\n var matchesName = matchesNames[0];\n\n var originalMatches = OriginalElement.prototype[matchesName];\n\n function invalidateRendererBasedOnAttribute(element, name) {\n // Only invalidate if parent node is a shadow host.\n var p = element.parentNode;\n if (!p || !p.shadowRoot)\n return;\n\n var renderer = scope.getRendererForHost(p);\n if (renderer.dependsOnAttribute(name))\n renderer.invalidate();\n }\n\n function enqueAttributeChange(element, name, oldValue) {\n // This is not fully spec compliant. We should use localName (which might\n // have a different case than name) and the namespace (which requires us\n // to get the Attr object).\n enqueueMutation(element, 'attributes', {\n name: name,\n namespace: null,\n oldValue: oldValue\n });\n }\n\n var classListTable = new WeakMap();\n\n function Element(node) {\n Node.call(this, node);\n }\n Element.prototype = Object.create(Node.prototype);\n mixin(Element.prototype, {\n createShadowRoot: function() {\n var newShadowRoot = new wrappers.ShadowRoot(this);\n this.impl.polymerShadowRoot_ = newShadowRoot;\n\n var renderer = scope.getRendererForHost(this);\n renderer.invalidate();\n\n return newShadowRoot;\n },\n\n get shadowRoot() {\n return this.impl.polymerShadowRoot_ || null;\n },\n\n // getDestinationInsertionPoints added in ShadowRenderer.js\n\n setAttribute: function(name, value) {\n var oldValue = this.impl.getAttribute(name);\n this.impl.setAttribute(name, value);\n enqueAttributeChange(this, name, oldValue);\n invalidateRendererBasedOnAttribute(this, name);\n },\n\n removeAttribute: function(name) {\n var oldValue = this.impl.getAttribute(name);\n this.impl.removeAttribute(name);\n enqueAttributeChange(this, name, oldValue);\n invalidateRendererBasedOnAttribute(this, name);\n },\n\n matches: function(selector) {\n return originalMatches.call(this.impl, selector);\n },\n\n get classList() {\n var list = classListTable.get(this);\n if (!list) {\n classListTable.set(this,\n list = new DOMTokenList(unwrap(this).classList, this));\n }\n return list;\n },\n\n get className() {\n return unwrap(this).className;\n },\n\n set className(v) {\n this.setAttribute('class', v);\n },\n\n get id() {\n return unwrap(this).id;\n },\n\n set id(v) {\n this.setAttribute('id', v);\n }\n });\n\n matchesNames.forEach(function(name) {\n if (name !== 'matches') {\n Element.prototype[name] = function(selector) {\n return this.matches(selector);\n };\n }\n });\n\n if (OriginalElement.prototype.webkitCreateShadowRoot) {\n Element.prototype.webkitCreateShadowRoot =\n Element.prototype.createShadowRoot;\n }\n\n mixin(Element.prototype, ChildNodeInterface);\n mixin(Element.prototype, GetElementsByInterface);\n mixin(Element.prototype, ParentNodeInterface);\n mixin(Element.prototype, SelectorsInterface);\n\n registerWrapper(OriginalElement, Element,\n document.createElementNS(null, 'x'));\n\n scope.invalidateRendererBasedOnAttribute = invalidateRendererBasedOnAttribute;\n scope.matchesNames = matchesNames;\n scope.wrappers.Element = Element;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var Element = scope.wrappers.Element;\n var defineGetter = scope.defineGetter;\n var enqueueMutation = scope.enqueueMutation;\n var mixin = scope.mixin;\n var nodesWereAdded = scope.nodesWereAdded;\n var nodesWereRemoved = scope.nodesWereRemoved;\n var registerWrapper = scope.registerWrapper;\n var snapshotNodeList = scope.snapshotNodeList;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n var wrappers = scope.wrappers;\n\n /////////////////////////////////////////////////////////////////////////////\n // innerHTML and outerHTML\n\n // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString\n var escapeAttrRegExp = /[&\\u00A0\"]/g;\n var escapeDataRegExp = /[&\\u00A0<>]/g;\n\n function escapeReplace(c) {\n switch (c) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"'\n case '\\u00A0':\n return ' ';\n }\n }\n\n function escapeAttr(s) {\n return s.replace(escapeAttrRegExp, escapeReplace);\n }\n\n function escapeData(s) {\n return s.replace(escapeDataRegExp, escapeReplace);\n }\n\n function makeSet(arr) {\n var set = {};\n for (var i = 0; i < arr.length; i++) {\n set[arr[i]] = true;\n }\n return set;\n }\n\n // http://www.whatwg.org/specs/web-apps/current-work/#void-elements\n var voidElements = makeSet([\n 'area',\n 'base',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n ]);\n\n var plaintextParents = makeSet([\n 'style',\n 'script',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'plaintext',\n 'noscript'\n ]);\n\n function getOuterHTML(node, parentNode) {\n switch (node.nodeType) {\n case Node.ELEMENT_NODE:\n var tagName = node.tagName.toLowerCase();\n var s = '<' + tagName;\n var attrs = node.attributes;\n for (var i = 0, attr; attr = attrs[i]; i++) {\n s += ' ' + attr.name + '=\"' + escapeAttr(attr.value) + '\"';\n }\n s += '>';\n if (voidElements[tagName])\n return s;\n\n return s + getInnerHTML(node) + '' + tagName + '>';\n\n case Node.TEXT_NODE:\n var data = node.data;\n if (parentNode && plaintextParents[parentNode.localName])\n return data;\n return escapeData(data);\n\n case Node.COMMENT_NODE:\n return '';\n\n default:\n console.error(node);\n throw new Error('not implemented');\n }\n }\n\n function getInnerHTML(node) {\n if (node instanceof wrappers.HTMLTemplateElement)\n node = node.content;\n\n var s = '';\n for (var child = node.firstChild; child; child = child.nextSibling) {\n s += getOuterHTML(child, node);\n }\n return s;\n }\n\n function setInnerHTML(node, value, opt_tagName) {\n var tagName = opt_tagName || 'div';\n node.textContent = '';\n var tempElement = unwrap(node.ownerDocument.createElement(tagName));\n tempElement.innerHTML = value;\n var firstChild;\n while (firstChild = tempElement.firstChild) {\n node.appendChild(wrap(firstChild));\n }\n }\n\n // IE11 does not have MSIE in the user agent string.\n var oldIe = /MSIE/.test(navigator.userAgent);\n\n var OriginalHTMLElement = window.HTMLElement;\n var OriginalHTMLTemplateElement = window.HTMLTemplateElement;\n\n function HTMLElement(node) {\n Element.call(this, node);\n }\n HTMLElement.prototype = Object.create(Element.prototype);\n mixin(HTMLElement.prototype, {\n get innerHTML() {\n return getInnerHTML(this);\n },\n set innerHTML(value) {\n // IE9 does not handle set innerHTML correctly on plaintextParents. It\n // creates element children. For example\n //\n // scriptElement.innerHTML = 'test '\n //\n // Creates a single HTMLAnchorElement child.\n if (oldIe && plaintextParents[this.localName]) {\n this.textContent = value;\n return;\n }\n\n var removedNodes = snapshotNodeList(this.childNodes);\n\n if (this.invalidateShadowRenderer()) {\n if (this instanceof wrappers.HTMLTemplateElement)\n setInnerHTML(this.content, value);\n else\n setInnerHTML(this, value, this.tagName);\n\n // If we have a non native template element we need to handle this\n // manually since setting impl.innerHTML would add the html as direct\n // children and not be moved over to the content fragment.\n } else if (!OriginalHTMLTemplateElement &&\n this instanceof wrappers.HTMLTemplateElement) {\n setInnerHTML(this.content, value);\n } else {\n this.impl.innerHTML = value;\n }\n\n var addedNodes = snapshotNodeList(this.childNodes);\n\n enqueueMutation(this, 'childList', {\n addedNodes: addedNodes,\n removedNodes: removedNodes\n });\n\n nodesWereRemoved(removedNodes);\n nodesWereAdded(addedNodes, this);\n },\n\n get outerHTML() {\n return getOuterHTML(this, this.parentNode);\n },\n set outerHTML(value) {\n var p = this.parentNode;\n if (p) {\n p.invalidateShadowRenderer();\n var df = frag(p, value);\n p.replaceChild(df, this);\n }\n },\n\n insertAdjacentHTML: function(position, text) {\n var contextElement, refNode;\n switch (String(position).toLowerCase()) {\n case 'beforebegin':\n contextElement = this.parentNode;\n refNode = this;\n break;\n case 'afterend':\n contextElement = this.parentNode;\n refNode = this.nextSibling;\n break;\n case 'afterbegin':\n contextElement = this;\n refNode = this.firstChild;\n break;\n case 'beforeend':\n contextElement = this;\n refNode = null;\n break;\n default:\n return;\n }\n\n var df = frag(contextElement, text);\n contextElement.insertBefore(df, refNode);\n },\n\n get hidden() {\n return this.hasAttribute('hidden');\n },\n set hidden(v) {\n if (v) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n });\n\n function frag(contextElement, html) {\n // TODO(arv): This does not work with SVG and other non HTML elements.\n var p = unwrap(contextElement.cloneNode(false));\n p.innerHTML = html;\n var df = unwrap(document.createDocumentFragment());\n var c;\n while (c = p.firstChild) {\n df.appendChild(c);\n }\n return wrap(df);\n }\n\n function getter(name) {\n return function() {\n scope.renderAllPending();\n return this.impl[name];\n };\n }\n\n function getterRequiresRendering(name) {\n defineGetter(HTMLElement, name, getter(name));\n }\n\n [\n 'clientHeight',\n 'clientLeft',\n 'clientTop',\n 'clientWidth',\n 'offsetHeight',\n 'offsetLeft',\n 'offsetTop',\n 'offsetWidth',\n 'scrollHeight',\n 'scrollWidth',\n ].forEach(getterRequiresRendering);\n\n function getterAndSetterRequiresRendering(name) {\n Object.defineProperty(HTMLElement.prototype, name, {\n get: getter(name),\n set: function(v) {\n scope.renderAllPending();\n this.impl[name] = v;\n },\n configurable: true,\n enumerable: true\n });\n }\n\n [\n 'scrollLeft',\n 'scrollTop',\n ].forEach(getterAndSetterRequiresRendering);\n\n function methodRequiresRendering(name) {\n Object.defineProperty(HTMLElement.prototype, name, {\n value: function() {\n scope.renderAllPending();\n return this.impl[name].apply(this.impl, arguments);\n },\n configurable: true,\n enumerable: true\n });\n }\n\n [\n 'getBoundingClientRect',\n 'getClientRects',\n 'scrollIntoView'\n ].forEach(methodRequiresRendering);\n\n // HTMLElement is abstract so we use a subclass that has no members.\n registerWrapper(OriginalHTMLElement, HTMLElement,\n document.createElement('b'));\n\n scope.wrappers.HTMLElement = HTMLElement;\n\n // TODO: Find a better way to share these two with WrapperShadowRoot.\n scope.getInnerHTML = getInnerHTML;\n scope.setInnerHTML = setInnerHTML\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var wrap = scope.wrap;\n\n var OriginalHTMLCanvasElement = window.HTMLCanvasElement;\n\n function HTMLCanvasElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype);\n\n mixin(HTMLCanvasElement.prototype, {\n getContext: function() {\n var context = this.impl.getContext.apply(this.impl, arguments);\n return context && wrap(context);\n }\n });\n\n registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement,\n document.createElement('canvas'));\n\n scope.wrappers.HTMLCanvasElement = HTMLCanvasElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n\n var OriginalHTMLContentElement = window.HTMLContentElement;\n\n function HTMLContentElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLContentElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLContentElement.prototype, {\n get select() {\n return this.getAttribute('select');\n },\n set select(value) {\n this.setAttribute('select', value);\n },\n\n setAttribute: function(n, v) {\n HTMLElement.prototype.setAttribute.call(this, n, v);\n if (String(n).toLowerCase() === 'select')\n this.invalidateShadowRenderer(true);\n }\n\n // getDistributedNodes is added in ShadowRenderer\n });\n\n if (OriginalHTMLContentElement)\n registerWrapper(OriginalHTMLContentElement, HTMLContentElement);\n\n scope.wrappers.HTMLContentElement = HTMLContentElement;\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var wrapHTMLCollection = scope.wrapHTMLCollection;\n var unwrap = scope.unwrap;\n\n var OriginalHTMLFormElement = window.HTMLFormElement;\n\n function HTMLFormElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLFormElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLFormElement.prototype, {\n get elements() {\n // Note: technically this should be an HTMLFormControlsCollection, but\n // that inherits from HTMLCollection, so should be good enough. Spec:\n // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlformcontrolscollection\n return wrapHTMLCollection(unwrap(this).elements);\n }\n });\n\n registerWrapper(OriginalHTMLFormElement, HTMLFormElement,\n document.createElement('form'));\n\n scope.wrappers.HTMLFormElement = HTMLFormElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var rewrap = scope.rewrap;\n\n var OriginalHTMLImageElement = window.HTMLImageElement;\n\n function HTMLImageElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLImageElement.prototype = Object.create(HTMLElement.prototype);\n\n registerWrapper(OriginalHTMLImageElement, HTMLImageElement,\n document.createElement('img'));\n\n function Image(width, height) {\n if (!(this instanceof Image)) {\n throw new TypeError(\n 'DOM object constructor cannot be called as a function.');\n }\n\n var node = unwrap(document.createElement('img'));\n HTMLElement.call(this, node);\n rewrap(node, this);\n\n if (width !== undefined)\n node.width = width;\n if (height !== undefined)\n node.height = height;\n }\n\n Image.prototype = HTMLImageElement.prototype;\n\n scope.wrappers.HTMLImageElement = HTMLImageElement;\n scope.wrappers.Image = Image;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var NodeList = scope.wrappers.NodeList;\n var registerWrapper = scope.registerWrapper;\n\n var OriginalHTMLShadowElement = window.HTMLShadowElement;\n\n function HTMLShadowElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);\n\n // getDistributedNodes is added in ShadowRenderer\n\n if (OriginalHTMLShadowElement)\n registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement);\n\n scope.wrappers.HTMLShadowElement = HTMLShadowElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var contentTable = new WeakMap();\n var templateContentsOwnerTable = new WeakMap();\n\n // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner\n function getTemplateContentsOwner(doc) {\n if (!doc.defaultView)\n return doc;\n var d = templateContentsOwnerTable.get(doc);\n if (!d) {\n // TODO(arv): This should either be a Document or HTMLDocument depending\n // on doc.\n d = doc.implementation.createHTMLDocument('');\n while (d.lastChild) {\n d.removeChild(d.lastChild);\n }\n templateContentsOwnerTable.set(doc, d);\n }\n return d;\n }\n\n function extractContent(templateElement) {\n // templateElement is not a wrapper here.\n var doc = getTemplateContentsOwner(templateElement.ownerDocument);\n var df = unwrap(doc.createDocumentFragment());\n var child;\n while (child = templateElement.firstChild) {\n df.appendChild(child);\n }\n return df;\n }\n\n var OriginalHTMLTemplateElement = window.HTMLTemplateElement;\n\n function HTMLTemplateElement(node) {\n HTMLElement.call(this, node);\n if (!OriginalHTMLTemplateElement) {\n var content = extractContent(node);\n contentTable.set(this, wrap(content));\n }\n }\n HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);\n\n mixin(HTMLTemplateElement.prototype, {\n get content() {\n if (OriginalHTMLTemplateElement)\n return wrap(this.impl.content);\n return contentTable.get(this);\n },\n\n // TODO(arv): cloneNode needs to clone content.\n\n });\n\n if (OriginalHTMLTemplateElement)\n registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement);\n\n scope.wrappers.HTMLTemplateElement = HTMLTemplateElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var registerWrapper = scope.registerWrapper;\n\n var OriginalHTMLMediaElement = window.HTMLMediaElement;\n\n function HTMLMediaElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLMediaElement.prototype = Object.create(HTMLElement.prototype);\n\n registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement,\n document.createElement('audio'));\n\n scope.wrappers.HTMLMediaElement = HTMLMediaElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLMediaElement = scope.wrappers.HTMLMediaElement;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var rewrap = scope.rewrap;\n\n var OriginalHTMLAudioElement = window.HTMLAudioElement;\n\n function HTMLAudioElement(node) {\n HTMLMediaElement.call(this, node);\n }\n HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype);\n\n registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement,\n document.createElement('audio'));\n\n function Audio(src) {\n if (!(this instanceof Audio)) {\n throw new TypeError(\n 'DOM object constructor cannot be called as a function.');\n }\n\n var node = unwrap(document.createElement('audio'));\n HTMLMediaElement.call(this, node);\n rewrap(node, this);\n\n node.setAttribute('preload', 'auto');\n if (src !== undefined)\n node.setAttribute('src', src);\n }\n\n Audio.prototype = HTMLAudioElement.prototype;\n\n scope.wrappers.HTMLAudioElement = HTMLAudioElement;\n scope.wrappers.Audio = Audio;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var rewrap = scope.rewrap;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var OriginalHTMLOptionElement = window.HTMLOptionElement;\n\n function trimText(s) {\n return s.replace(/\\s+/g, ' ').trim();\n }\n\n function HTMLOptionElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLOptionElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLOptionElement.prototype, {\n get text() {\n return trimText(this.textContent);\n },\n set text(value) {\n this.textContent = trimText(String(value));\n },\n get form() {\n return wrap(unwrap(this).form);\n }\n });\n\n registerWrapper(OriginalHTMLOptionElement, HTMLOptionElement,\n document.createElement('option'));\n\n function Option(text, value, defaultSelected, selected) {\n if (!(this instanceof Option)) {\n throw new TypeError(\n 'DOM object constructor cannot be called as a function.');\n }\n\n var node = unwrap(document.createElement('option'));\n HTMLElement.call(this, node);\n rewrap(node, this);\n\n if (text !== undefined)\n node.text = text;\n if (value !== undefined)\n node.setAttribute('value', value);\n if (defaultSelected === true)\n node.setAttribute('selected', '');\n node.selected = selected === true;\n }\n\n Option.prototype = HTMLOptionElement.prototype;\n\n scope.wrappers.HTMLOptionElement = HTMLOptionElement;\n scope.wrappers.Option = Option;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var OriginalHTMLSelectElement = window.HTMLSelectElement;\n\n function HTMLSelectElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLSelectElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLSelectElement.prototype, {\n add: function(element, before) {\n if (typeof before === 'object') // also includes null\n before = unwrap(before);\n unwrap(this).add(unwrap(element), before);\n },\n\n remove: function(indexOrNode) {\n // Spec only allows index but implementations allow index or node.\n // remove() is also allowed which is same as remove(undefined)\n if (indexOrNode === undefined) {\n HTMLElement.prototype.remove.call(this);\n return;\n }\n\n if (typeof indexOrNode === 'object')\n indexOrNode = unwrap(indexOrNode);\n\n unwrap(this).remove(indexOrNode);\n },\n\n get form() {\n return wrap(unwrap(this).form);\n }\n });\n\n registerWrapper(OriginalHTMLSelectElement, HTMLSelectElement,\n document.createElement('select'));\n\n scope.wrappers.HTMLSelectElement = HTMLSelectElement;\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n var wrapHTMLCollection = scope.wrapHTMLCollection;\n\n var OriginalHTMLTableElement = window.HTMLTableElement;\n\n function HTMLTableElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLTableElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLTableElement.prototype, {\n get caption() {\n return wrap(unwrap(this).caption);\n },\n createCaption: function() {\n return wrap(unwrap(this).createCaption());\n },\n\n get tHead() {\n return wrap(unwrap(this).tHead);\n },\n createTHead: function() {\n return wrap(unwrap(this).createTHead());\n },\n\n createTFoot: function() {\n return wrap(unwrap(this).createTFoot());\n },\n get tFoot() {\n return wrap(unwrap(this).tFoot);\n },\n\n get tBodies() {\n return wrapHTMLCollection(unwrap(this).tBodies);\n },\n createTBody: function() {\n return wrap(unwrap(this).createTBody());\n },\n\n get rows() {\n return wrapHTMLCollection(unwrap(this).rows);\n },\n insertRow: function(index) {\n return wrap(unwrap(this).insertRow(index));\n }\n });\n\n registerWrapper(OriginalHTMLTableElement, HTMLTableElement,\n document.createElement('table'));\n\n scope.wrappers.HTMLTableElement = HTMLTableElement;\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var wrapHTMLCollection = scope.wrapHTMLCollection;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var OriginalHTMLTableSectionElement = window.HTMLTableSectionElement;\n\n function HTMLTableSectionElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLTableSectionElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLTableSectionElement.prototype, {\n get rows() {\n return wrapHTMLCollection(unwrap(this).rows);\n },\n insertRow: function(index) {\n return wrap(unwrap(this).insertRow(index));\n }\n });\n\n registerWrapper(OriginalHTMLTableSectionElement, HTMLTableSectionElement,\n document.createElement('thead'));\n\n scope.wrappers.HTMLTableSectionElement = HTMLTableSectionElement;\n})(window.ShadowDOMPolyfill);\n","/*\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var wrapHTMLCollection = scope.wrapHTMLCollection;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var OriginalHTMLTableRowElement = window.HTMLTableRowElement;\n\n function HTMLTableRowElement(node) {\n HTMLElement.call(this, node);\n }\n HTMLTableRowElement.prototype = Object.create(HTMLElement.prototype);\n mixin(HTMLTableRowElement.prototype, {\n get cells() {\n return wrapHTMLCollection(unwrap(this).cells);\n },\n\n insertCell: function(index) {\n return wrap(unwrap(this).insertCell(index));\n }\n });\n\n registerWrapper(OriginalHTMLTableRowElement, HTMLTableRowElement,\n document.createElement('tr'));\n\n scope.wrappers.HTMLTableRowElement = HTMLTableRowElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLContentElement = scope.wrappers.HTMLContentElement;\n var HTMLElement = scope.wrappers.HTMLElement;\n var HTMLShadowElement = scope.wrappers.HTMLShadowElement;\n var HTMLTemplateElement = scope.wrappers.HTMLTemplateElement;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n\n var OriginalHTMLUnknownElement = window.HTMLUnknownElement;\n\n function HTMLUnknownElement(node) {\n switch (node.localName) {\n case 'content':\n return new HTMLContentElement(node);\n case 'shadow':\n return new HTMLShadowElement(node);\n case 'template':\n return new HTMLTemplateElement(node);\n }\n HTMLElement.call(this, node);\n }\n HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype);\n registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement);\n scope.wrappers.HTMLUnknownElement = HTMLUnknownElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var Element = scope.wrappers.Element;\n var HTMLElement = scope.wrappers.HTMLElement;\n var registerObject = scope.registerObject;\n\n var SVG_NS = 'http://www.w3.org/2000/svg';\n var svgTitleElement = document.createElementNS(SVG_NS, 'title');\n var SVGTitleElement = registerObject(svgTitleElement);\n var SVGElement = Object.getPrototypeOf(SVGTitleElement.prototype).constructor;\n\n // IE11 does not have classList for SVG elements. The spec says that classList\n // is an accessor on Element, but IE11 puts classList on HTMLElement, leaving\n // SVGElement without a classList property. We therefore move the accessor for\n // IE11.\n if (!('classList' in svgTitleElement)) {\n var descr = Object.getOwnPropertyDescriptor(Element.prototype, 'classList');\n Object.defineProperty(HTMLElement.prototype, 'classList', descr);\n delete Element.prototype.classList;\n }\n\n scope.wrappers.SVGElement = SVGElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var OriginalSVGUseElement = window.SVGUseElement;\n\n // IE uses SVGElement as parent interface, SVG2 (Blink & Gecko) uses\n // SVGGraphicsElement. Use the element to get the right prototype.\n\n var SVG_NS = 'http://www.w3.org/2000/svg';\n var gWrapper = wrap(document.createElementNS(SVG_NS, 'g'));\n var useElement = document.createElementNS(SVG_NS, 'use');\n var SVGGElement = gWrapper.constructor;\n var parentInterfacePrototype = Object.getPrototypeOf(SVGGElement.prototype);\n var parentInterface = parentInterfacePrototype.constructor;\n\n function SVGUseElement(impl) {\n parentInterface.call(this, impl);\n }\n\n SVGUseElement.prototype = Object.create(parentInterfacePrototype);\n\n // Firefox does not expose instanceRoot.\n if ('instanceRoot' in useElement) {\n mixin(SVGUseElement.prototype, {\n get instanceRoot() {\n return wrap(unwrap(this).instanceRoot);\n },\n get animatedInstanceRoot() {\n return wrap(unwrap(this).animatedInstanceRoot);\n },\n });\n }\n\n registerWrapper(OriginalSVGUseElement, SVGUseElement, useElement);\n\n scope.wrappers.SVGUseElement = SVGUseElement;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var EventTarget = scope.wrappers.EventTarget;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var wrap = scope.wrap;\n\n var OriginalSVGElementInstance = window.SVGElementInstance;\n if (!OriginalSVGElementInstance)\n return;\n\n function SVGElementInstance(impl) {\n EventTarget.call(this, impl);\n }\n\n SVGElementInstance.prototype = Object.create(EventTarget.prototype);\n mixin(SVGElementInstance.prototype, {\n /** @type {SVGElement} */\n get correspondingElement() {\n return wrap(this.impl.correspondingElement);\n },\n\n /** @type {SVGUseElement} */\n get correspondingUseElement() {\n return wrap(this.impl.correspondingUseElement);\n },\n\n /** @type {SVGElementInstance} */\n get parentNode() {\n return wrap(this.impl.parentNode);\n },\n\n /** @type {SVGElementInstanceList} */\n get childNodes() {\n throw new Error('Not implemented');\n },\n\n /** @type {SVGElementInstance} */\n get firstChild() {\n return wrap(this.impl.firstChild);\n },\n\n /** @type {SVGElementInstance} */\n get lastChild() {\n return wrap(this.impl.lastChild);\n },\n\n /** @type {SVGElementInstance} */\n get previousSibling() {\n return wrap(this.impl.previousSibling);\n },\n\n /** @type {SVGElementInstance} */\n get nextSibling() {\n return wrap(this.impl.nextSibling);\n }\n });\n\n registerWrapper(OriginalSVGElementInstance, SVGElementInstance);\n\n scope.wrappers.SVGElementInstance = SVGElementInstance;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n\n var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;\n\n function CanvasRenderingContext2D(impl) {\n this.impl = impl;\n }\n\n mixin(CanvasRenderingContext2D.prototype, {\n get canvas() {\n return wrap(this.impl.canvas);\n },\n\n drawImage: function() {\n arguments[0] = unwrapIfNeeded(arguments[0]);\n this.impl.drawImage.apply(this.impl, arguments);\n },\n\n createPattern: function() {\n arguments[0] = unwrap(arguments[0]);\n return this.impl.createPattern.apply(this.impl, arguments);\n }\n });\n\n registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D,\n document.createElement('canvas').getContext('2d'));\n\n scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n\n var OriginalWebGLRenderingContext = window.WebGLRenderingContext;\n\n // IE10 does not have WebGL.\n if (!OriginalWebGLRenderingContext)\n return;\n\n function WebGLRenderingContext(impl) {\n this.impl = impl;\n }\n\n mixin(WebGLRenderingContext.prototype, {\n get canvas() {\n return wrap(this.impl.canvas);\n },\n\n texImage2D: function() {\n arguments[5] = unwrapIfNeeded(arguments[5]);\n this.impl.texImage2D.apply(this.impl, arguments);\n },\n\n texSubImage2D: function() {\n arguments[6] = unwrapIfNeeded(arguments[6]);\n this.impl.texSubImage2D.apply(this.impl, arguments);\n }\n });\n\n // Blink/WebKit has broken DOM bindings. Usually we would create an instance\n // of the object and pass it into registerWrapper as a \"blueprint\" but\n // creating WebGL contexts is expensive and might fail so we use a dummy\n // object with dummy instance properties for these broken browsers.\n var instanceProperties = /WebKit/.test(navigator.userAgent) ?\n {drawingBufferHeight: null, drawingBufferWidth: null} : {};\n\n registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext,\n instanceProperties);\n\n scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n\n var OriginalRange = window.Range;\n\n function Range(impl) {\n this.impl = impl;\n }\n Range.prototype = {\n get startContainer() {\n return wrap(this.impl.startContainer);\n },\n get endContainer() {\n return wrap(this.impl.endContainer);\n },\n get commonAncestorContainer() {\n return wrap(this.impl.commonAncestorContainer);\n },\n setStart: function(refNode,offset) {\n this.impl.setStart(unwrapIfNeeded(refNode), offset);\n },\n setEnd: function(refNode,offset) {\n this.impl.setEnd(unwrapIfNeeded(refNode), offset);\n },\n setStartBefore: function(refNode) {\n this.impl.setStartBefore(unwrapIfNeeded(refNode));\n },\n setStartAfter: function(refNode) {\n this.impl.setStartAfter(unwrapIfNeeded(refNode));\n },\n setEndBefore: function(refNode) {\n this.impl.setEndBefore(unwrapIfNeeded(refNode));\n },\n setEndAfter: function(refNode) {\n this.impl.setEndAfter(unwrapIfNeeded(refNode));\n },\n selectNode: function(refNode) {\n this.impl.selectNode(unwrapIfNeeded(refNode));\n },\n selectNodeContents: function(refNode) {\n this.impl.selectNodeContents(unwrapIfNeeded(refNode));\n },\n compareBoundaryPoints: function(how, sourceRange) {\n return this.impl.compareBoundaryPoints(how, unwrap(sourceRange));\n },\n extractContents: function() {\n return wrap(this.impl.extractContents());\n },\n cloneContents: function() {\n return wrap(this.impl.cloneContents());\n },\n insertNode: function(node) {\n this.impl.insertNode(unwrapIfNeeded(node));\n },\n surroundContents: function(newParent) {\n this.impl.surroundContents(unwrapIfNeeded(newParent));\n },\n cloneRange: function() {\n return wrap(this.impl.cloneRange());\n },\n isPointInRange: function(node, offset) {\n return this.impl.isPointInRange(unwrapIfNeeded(node), offset);\n },\n comparePoint: function(node, offset) {\n return this.impl.comparePoint(unwrapIfNeeded(node), offset);\n },\n intersectsNode: function(node) {\n return this.impl.intersectsNode(unwrapIfNeeded(node));\n },\n toString: function() {\n return this.impl.toString();\n }\n };\n\n // IE9 does not have createContextualFragment.\n if (OriginalRange.prototype.createContextualFragment) {\n Range.prototype.createContextualFragment = function(html) {\n return wrap(this.impl.createContextualFragment(html));\n };\n }\n\n registerWrapper(window.Range, Range, document.createRange());\n\n scope.wrappers.Range = Range;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var GetElementsByInterface = scope.GetElementsByInterface;\n var ParentNodeInterface = scope.ParentNodeInterface;\n var SelectorsInterface = scope.SelectorsInterface;\n var mixin = scope.mixin;\n var registerObject = scope.registerObject;\n\n var DocumentFragment = registerObject(document.createDocumentFragment());\n mixin(DocumentFragment.prototype, ParentNodeInterface);\n mixin(DocumentFragment.prototype, SelectorsInterface);\n mixin(DocumentFragment.prototype, GetElementsByInterface);\n\n var Comment = registerObject(document.createComment(''));\n\n scope.wrappers.Comment = Comment;\n scope.wrappers.DocumentFragment = DocumentFragment;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var DocumentFragment = scope.wrappers.DocumentFragment;\n var TreeScope = scope.TreeScope;\n var elementFromPoint = scope.elementFromPoint;\n var getInnerHTML = scope.getInnerHTML;\n var getTreeScope = scope.getTreeScope;\n var mixin = scope.mixin;\n var rewrap = scope.rewrap;\n var setInnerHTML = scope.setInnerHTML;\n var unwrap = scope.unwrap;\n\n var shadowHostTable = new WeakMap();\n var nextOlderShadowTreeTable = new WeakMap();\n\n var spaceCharRe = /[ \\t\\n\\r\\f]/;\n\n function ShadowRoot(hostWrapper) {\n var node = unwrap(hostWrapper.impl.ownerDocument.createDocumentFragment());\n DocumentFragment.call(this, node);\n\n // createDocumentFragment associates the node with a wrapper\n // DocumentFragment instance. Override that.\n rewrap(node, this);\n\n var oldShadowRoot = hostWrapper.shadowRoot;\n nextOlderShadowTreeTable.set(this, oldShadowRoot);\n\n this.treeScope_ =\n new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper));\n\n shadowHostTable.set(this, hostWrapper);\n }\n ShadowRoot.prototype = Object.create(DocumentFragment.prototype);\n mixin(ShadowRoot.prototype, {\n get innerHTML() {\n return getInnerHTML(this);\n },\n set innerHTML(value) {\n setInnerHTML(this, value);\n this.invalidateShadowRenderer();\n },\n\n get olderShadowRoot() {\n return nextOlderShadowTreeTable.get(this) || null;\n },\n\n get host() {\n return shadowHostTable.get(this) || null;\n },\n\n invalidateShadowRenderer: function() {\n return shadowHostTable.get(this).invalidateShadowRenderer();\n },\n\n elementFromPoint: function(x, y) {\n return elementFromPoint(this, this.ownerDocument, x, y);\n },\n\n getElementById: function(id) {\n if (spaceCharRe.test(id))\n return null;\n return this.querySelector('[id=\"' + id + '\"]');\n }\n });\n\n scope.wrappers.ShadowRoot = ShadowRoot;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var Element = scope.wrappers.Element;\n var HTMLContentElement = scope.wrappers.HTMLContentElement;\n var HTMLShadowElement = scope.wrappers.HTMLShadowElement;\n var Node = scope.wrappers.Node;\n var ShadowRoot = scope.wrappers.ShadowRoot;\n var assert = scope.assert;\n var getTreeScope = scope.getTreeScope;\n var mixin = scope.mixin;\n var oneOf = scope.oneOf;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n /**\n * Updates the fields of a wrapper to a snapshot of the logical DOM as needed.\n * Up means parentNode\n * Sideways means previous and next sibling.\n * @param {!Node} wrapper\n */\n function updateWrapperUpAndSideways(wrapper) {\n wrapper.previousSibling_ = wrapper.previousSibling;\n wrapper.nextSibling_ = wrapper.nextSibling;\n wrapper.parentNode_ = wrapper.parentNode;\n }\n\n /**\n * Updates the fields of a wrapper to a snapshot of the logical DOM as needed.\n * Down means first and last child\n * @param {!Node} wrapper\n */\n function updateWrapperDown(wrapper) {\n wrapper.firstChild_ = wrapper.firstChild;\n wrapper.lastChild_ = wrapper.lastChild;\n }\n\n function updateAllChildNodes(parentNodeWrapper) {\n assert(parentNodeWrapper instanceof Node);\n for (var childWrapper = parentNodeWrapper.firstChild;\n childWrapper;\n childWrapper = childWrapper.nextSibling) {\n updateWrapperUpAndSideways(childWrapper);\n }\n updateWrapperDown(parentNodeWrapper);\n }\n\n function insertBefore(parentNodeWrapper, newChildWrapper, refChildWrapper) {\n var parentNode = unwrap(parentNodeWrapper);\n var newChild = unwrap(newChildWrapper);\n var refChild = refChildWrapper ? unwrap(refChildWrapper) : null;\n\n remove(newChildWrapper);\n updateWrapperUpAndSideways(newChildWrapper);\n\n if (!refChildWrapper) {\n parentNodeWrapper.lastChild_ = parentNodeWrapper.lastChild;\n if (parentNodeWrapper.lastChild === parentNodeWrapper.firstChild)\n parentNodeWrapper.firstChild_ = parentNodeWrapper.firstChild;\n\n var lastChildWrapper = wrap(parentNode.lastChild);\n if (lastChildWrapper)\n lastChildWrapper.nextSibling_ = lastChildWrapper.nextSibling;\n } else {\n if (parentNodeWrapper.firstChild === refChildWrapper)\n parentNodeWrapper.firstChild_ = refChildWrapper;\n\n refChildWrapper.previousSibling_ = refChildWrapper.previousSibling;\n }\n\n parentNode.insertBefore(newChild, refChild);\n }\n\n function remove(nodeWrapper) {\n var node = unwrap(nodeWrapper)\n var parentNode = node.parentNode;\n if (!parentNode)\n return;\n\n var parentNodeWrapper = wrap(parentNode);\n updateWrapperUpAndSideways(nodeWrapper);\n\n if (nodeWrapper.previousSibling)\n nodeWrapper.previousSibling.nextSibling_ = nodeWrapper;\n if (nodeWrapper.nextSibling)\n nodeWrapper.nextSibling.previousSibling_ = nodeWrapper;\n\n if (parentNodeWrapper.lastChild === nodeWrapper)\n parentNodeWrapper.lastChild_ = nodeWrapper;\n if (parentNodeWrapper.firstChild === nodeWrapper)\n parentNodeWrapper.firstChild_ = nodeWrapper;\n\n parentNode.removeChild(node);\n }\n\n var distributedNodesTable = new WeakMap();\n var destinationInsertionPointsTable = new WeakMap();\n var rendererForHostTable = new WeakMap();\n\n function resetDistributedNodes(insertionPoint) {\n distributedNodesTable.set(insertionPoint, []);\n }\n\n function getDistributedNodes(insertionPoint) {\n var rv = distributedNodesTable.get(insertionPoint);\n if (!rv)\n distributedNodesTable.set(insertionPoint, rv = []);\n return rv;\n }\n\n function getChildNodesSnapshot(node) {\n var result = [], i = 0;\n for (var child = node.firstChild; child; child = child.nextSibling) {\n result[i++] = child;\n }\n return result;\n }\n\n var request = oneOf(window, [\n 'requestAnimationFrame',\n 'mozRequestAnimationFrame',\n 'webkitRequestAnimationFrame',\n 'setTimeout'\n ]);\n\n var pendingDirtyRenderers = [];\n var renderTimer;\n\n function renderAllPending() {\n // TODO(arv): Order these in document order. That way we do not have to\n // render something twice.\n for (var i = 0; i < pendingDirtyRenderers.length; i++) {\n var renderer = pendingDirtyRenderers[i];\n var parentRenderer = renderer.parentRenderer;\n if (parentRenderer && parentRenderer.dirty)\n continue;\n renderer.render();\n }\n\n pendingDirtyRenderers = [];\n }\n\n function handleRequestAnimationFrame() {\n renderTimer = null;\n renderAllPending();\n }\n\n /**\n * Returns existing shadow renderer for a host or creates it if it is needed.\n * @params {!Element} host\n * @return {!ShadowRenderer}\n */\n function getRendererForHost(host) {\n var renderer = rendererForHostTable.get(host);\n if (!renderer) {\n renderer = new ShadowRenderer(host);\n rendererForHostTable.set(host, renderer);\n }\n return renderer;\n }\n\n function getShadowRootAncestor(node) {\n var root = getTreeScope(node).root;\n if (root instanceof ShadowRoot)\n return root;\n return null;\n }\n\n function getRendererForShadowRoot(shadowRoot) {\n return getRendererForHost(shadowRoot.host);\n }\n\n var spliceDiff = new ArraySplice();\n spliceDiff.equals = function(renderNode, rawNode) {\n return unwrap(renderNode.node) === rawNode;\n };\n\n /**\n * RenderNode is used as an in memory \"render tree\". When we render the\n * composed tree we create a tree of RenderNodes, then we diff this against\n * the real DOM tree and make minimal changes as needed.\n */\n function RenderNode(node) {\n this.skip = false;\n this.node = node;\n this.childNodes = [];\n }\n\n RenderNode.prototype = {\n append: function(node) {\n var rv = new RenderNode(node);\n this.childNodes.push(rv);\n return rv;\n },\n\n sync: function(opt_added) {\n if (this.skip)\n return;\n\n var nodeWrapper = this.node;\n // plain array of RenderNodes\n var newChildren = this.childNodes;\n // plain array of real nodes.\n var oldChildren = getChildNodesSnapshot(unwrap(nodeWrapper));\n var added = opt_added || new WeakMap();\n\n var splices = spliceDiff.calculateSplices(newChildren, oldChildren);\n\n var newIndex = 0, oldIndex = 0;\n var lastIndex = 0;\n for (var i = 0; i < splices.length; i++) {\n var splice = splices[i];\n for (; lastIndex < splice.index; lastIndex++) {\n oldIndex++;\n newChildren[newIndex++].sync(added);\n }\n\n var removedCount = splice.removed.length;\n for (var j = 0; j < removedCount; j++) {\n var wrapper = wrap(oldChildren[oldIndex++]);\n if (!added.get(wrapper))\n remove(wrapper);\n }\n\n var addedCount = splice.addedCount;\n var refNode = oldChildren[oldIndex] && wrap(oldChildren[oldIndex]);\n for (var j = 0; j < addedCount; j++) {\n var newChildRenderNode = newChildren[newIndex++];\n var newChildWrapper = newChildRenderNode.node;\n insertBefore(nodeWrapper, newChildWrapper, refNode);\n\n // Keep track of added so that we do not remove the node after it\n // has been added.\n added.set(newChildWrapper, true);\n\n newChildRenderNode.sync(added);\n }\n\n lastIndex += addedCount;\n }\n\n for (var i = lastIndex; i < newChildren.length; i++) {\n newChildren[i].sync(added);\n }\n }\n };\n\n function ShadowRenderer(host) {\n this.host = host;\n this.dirty = false;\n this.invalidateAttributes();\n this.associateNode(host);\n }\n\n ShadowRenderer.prototype = {\n\n // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#rendering-shadow-trees\n render: function(opt_renderNode) {\n if (!this.dirty)\n return;\n\n this.invalidateAttributes();\n\n var host = this.host;\n\n this.distribution(host);\n var renderNode = opt_renderNode || new RenderNode(host);\n this.buildRenderTree(renderNode, host);\n\n var topMostRenderer = !opt_renderNode;\n if (topMostRenderer)\n renderNode.sync();\n\n this.dirty = false;\n },\n\n get parentRenderer() {\n return getTreeScope(this.host).renderer;\n },\n\n invalidate: function() {\n if (!this.dirty) {\n this.dirty = true;\n var parentRenderer = this.parentRenderer;\n if (parentRenderer)\n parentRenderer.invalidate();\n pendingDirtyRenderers.push(this);\n if (renderTimer)\n return;\n renderTimer = window[request](handleRequestAnimationFrame, 0);\n }\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms\n distribution: function(root) {\n this.resetAll(root);\n this.distributionResolution(root);\n },\n\n resetAll: function(node) {\n if (isInsertionPoint(node))\n resetDistributedNodes(node);\n else\n resetDestinationInsertionPoints(node);\n\n for (var child = node.firstChild; child; child = child.nextSibling) {\n this.resetAll(child);\n }\n\n if (node.shadowRoot)\n this.resetAll(node.shadowRoot);\n\n if (node.olderShadowRoot)\n this.resetAll(node.olderShadowRoot);\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#distribution-results\n distributionResolution: function(node) {\n if (isShadowHost(node)) {\n var shadowHost = node;\n // 1.1\n var pool = poolPopulation(shadowHost);\n\n var shadowTrees = getShadowTrees(shadowHost);\n\n // 1.2\n for (var i = 0; i < shadowTrees.length; i++) {\n // 1.2.1\n this.poolDistribution(shadowTrees[i], pool);\n }\n\n // 1.3\n for (var i = shadowTrees.length - 1; i >= 0; i--) {\n var shadowTree = shadowTrees[i];\n\n // 1.3.1\n // TODO(arv): We should keep the shadow insertion points on the\n // shadow root (or renderer) so we don't have to search the tree\n // every time.\n var shadow = getShadowInsertionPoint(shadowTree);\n\n // 1.3.2\n if (shadow) {\n\n // 1.3.2.1\n var olderShadowRoot = shadowTree.olderShadowRoot;\n if (olderShadowRoot) {\n // 1.3.2.1.1\n pool = poolPopulation(olderShadowRoot);\n }\n\n // 1.3.2.2\n for (var j = 0; j < pool.length; j++) {\n // 1.3.2.2.1\n destributeNodeInto(pool[j], shadow);\n }\n }\n\n // 1.3.3\n this.distributionResolution(shadowTree);\n }\n }\n\n for (var child = node.firstChild; child; child = child.nextSibling) {\n this.distributionResolution(child);\n }\n },\n\n // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-distribution-algorithm\n poolDistribution: function (node, pool) {\n if (node instanceof HTMLShadowElement)\n return;\n\n if (node instanceof HTMLContentElement) {\n var content = node;\n this.updateDependentAttributes(content.getAttribute('select'));\n\n var anyDistributed = false;\n\n // 1.1\n for (var i = 0; i < pool.length; i++) {\n var node = pool[i];\n if (!node)\n continue;\n if (matches(node, content)) {\n destributeNodeInto(node, content);\n pool[i] = undefined;\n anyDistributed = true;\n }\n }\n\n // 1.2\n // Fallback content\n if (!anyDistributed) {\n for (var child = content.firstChild;\n child;\n child = child.nextSibling) {\n destributeNodeInto(child, content);\n }\n }\n\n return;\n }\n\n for (var child = node.firstChild; child; child = child.nextSibling) {\n this.poolDistribution(child, pool);\n }\n },\n\n buildRenderTree: function(renderNode, node) {\n var children = this.compose(node);\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n var childRenderNode = renderNode.append(child);\n this.buildRenderTree(childRenderNode, child);\n }\n\n if (isShadowHost(node)) {\n var renderer = getRendererForHost(node);\n renderer.dirty = false;\n }\n\n },\n\n compose: function(node) {\n var children = [];\n var p = node.shadowRoot || node;\n for (var child = p.firstChild; child; child = child.nextSibling) {\n if (isInsertionPoint(child)) {\n this.associateNode(p);\n var distributedNodes = getDistributedNodes(child);\n for (var j = 0; j < distributedNodes.length; j++) {\n var distributedNode = distributedNodes[j];\n if (isFinalDestination(child, distributedNode))\n children.push(distributedNode);\n }\n } else {\n children.push(child);\n }\n }\n return children;\n },\n\n /**\n * Invalidates the attributes used to keep track of which attributes may\n * cause the renderer to be invalidated.\n */\n invalidateAttributes: function() {\n this.attributes = Object.create(null);\n },\n\n /**\n * Parses the selector and makes this renderer dependent on the attribute\n * being used in the selector.\n * @param {string} selector\n */\n updateDependentAttributes: function(selector) {\n if (!selector)\n return;\n\n var attributes = this.attributes;\n\n // .class\n if (/\\.\\w+/.test(selector))\n attributes['class'] = true;\n\n // #id\n if (/#\\w+/.test(selector))\n attributes['id'] = true;\n\n selector.replace(/\\[\\s*([^\\s=\\|~\\]]+)/g, function(_, name) {\n attributes[name] = true;\n });\n\n // Pseudo selectors have been removed from the spec.\n },\n\n dependsOnAttribute: function(name) {\n return this.attributes[name];\n },\n\n associateNode: function(node) {\n node.impl.polymerShadowRenderer_ = this;\n }\n };\n\n // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-population-algorithm\n function poolPopulation(node) {\n var pool = [];\n for (var child = node.firstChild; child; child = child.nextSibling) {\n if (isInsertionPoint(child)) {\n pool.push.apply(pool, getDistributedNodes(child));\n } else {\n pool.push(child);\n }\n }\n return pool;\n }\n\n function getShadowInsertionPoint(node) {\n if (node instanceof HTMLShadowElement)\n return node;\n if (node instanceof HTMLContentElement)\n return null;\n for (var child = node.firstChild; child; child = child.nextSibling) {\n var res = getShadowInsertionPoint(child);\n if (res)\n return res;\n }\n return null;\n }\n\n function destributeNodeInto(child, insertionPoint) {\n getDistributedNodes(insertionPoint).push(child);\n var points = destinationInsertionPointsTable.get(child);\n if (!points)\n destinationInsertionPointsTable.set(child, [insertionPoint]);\n else\n points.push(insertionPoint);\n }\n\n function getDestinationInsertionPoints(node) {\n return destinationInsertionPointsTable.get(node);\n }\n\n function resetDestinationInsertionPoints(node) {\n // IE11 crashes when delete is used.\n destinationInsertionPointsTable.set(node, undefined);\n }\n\n // AllowedSelectors :\n // TypeSelector\n // *\n // ClassSelector\n // IDSelector\n // AttributeSelector\n var selectorStartCharRe = /^[*.#[a-zA-Z_|]/;\n\n function matches(node, contentElement) {\n var select = contentElement.getAttribute('select');\n if (!select)\n return true;\n\n // Here we know the select attribute is a non empty string.\n select = select.trim();\n if (!select)\n return true;\n\n if (!(node instanceof Element))\n return false;\n\n if (!selectorStartCharRe.test(select))\n return false;\n\n try {\n return node.matches(select);\n } catch (ex) {\n // Invalid selector.\n return false;\n }\n }\n\n function isFinalDestination(insertionPoint, node) {\n var points = getDestinationInsertionPoints(node);\n return points && points[points.length - 1] === insertionPoint;\n }\n\n function isInsertionPoint(node) {\n return node instanceof HTMLContentElement ||\n node instanceof HTMLShadowElement;\n }\n\n function isShadowHost(shadowHost) {\n return shadowHost.shadowRoot;\n }\n\n // Returns the shadow trees as an array, with the youngest tree at the\n // beginning of the array.\n function getShadowTrees(host) {\n var trees = [];\n\n for (var tree = host.shadowRoot; tree; tree = tree.olderShadowRoot) {\n trees.push(tree);\n }\n return trees;\n }\n\n function render(host) {\n new ShadowRenderer(host).render();\n };\n\n // Need to rerender shadow host when:\n //\n // - a direct child to the ShadowRoot is added or removed\n // - a direct child to the host is added or removed\n // - a new shadow root is created\n // - a direct child to a content/shadow element is added or removed\n // - a sibling to a content/shadow element is added or removed\n // - content[select] is changed\n // - an attribute in a direct child to a host is modified\n\n /**\n * This gets called when a node was added or removed to it.\n */\n Node.prototype.invalidateShadowRenderer = function(force) {\n var renderer = this.impl.polymerShadowRenderer_;\n if (renderer) {\n renderer.invalidate();\n return true;\n }\n\n return false;\n };\n\n HTMLContentElement.prototype.getDistributedNodes =\n HTMLShadowElement.prototype.getDistributedNodes = function() {\n // TODO(arv): We should only rerender the dirty ancestor renderers (from\n // the root and down).\n renderAllPending();\n return getDistributedNodes(this);\n };\n\n Element.prototype.getDestinationInsertionPoints = function() {\n renderAllPending();\n return getDestinationInsertionPoints(this) || [];\n };\n\n HTMLContentElement.prototype.nodeIsInserted_ =\n HTMLShadowElement.prototype.nodeIsInserted_ = function() {\n // Invalidate old renderer if any.\n this.invalidateShadowRenderer();\n\n var shadowRoot = getShadowRootAncestor(this);\n var renderer;\n if (shadowRoot)\n renderer = getRendererForShadowRoot(shadowRoot);\n this.impl.polymerShadowRenderer_ = renderer;\n if (renderer)\n renderer.invalidate();\n };\n\n scope.getRendererForHost = getRendererForHost;\n scope.getShadowTrees = getShadowTrees;\n scope.renderAllPending = renderAllPending;\n\n scope.getDestinationInsertionPoints = getDestinationInsertionPoints;\n\n // Exposed for testing\n scope.visual = {\n insertBefore: insertBefore,\n remove: remove,\n };\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var HTMLElement = scope.wrappers.HTMLElement;\n var assert = scope.assert;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n\n var elementsWithFormProperty = [\n 'HTMLButtonElement',\n 'HTMLFieldSetElement',\n 'HTMLInputElement',\n 'HTMLKeygenElement',\n 'HTMLLabelElement',\n 'HTMLLegendElement',\n 'HTMLObjectElement',\n // HTMLOptionElement is handled in HTMLOptionElement.js\n 'HTMLOutputElement',\n // HTMLSelectElement is handled in HTMLSelectElement.js\n 'HTMLTextAreaElement',\n ];\n\n function createWrapperConstructor(name) {\n if (!window[name])\n return;\n\n // Ensure we are not overriding an already existing constructor.\n assert(!scope.wrappers[name]);\n\n var GeneratedWrapper = function(node) {\n // At this point all of them extend HTMLElement.\n HTMLElement.call(this, node);\n }\n GeneratedWrapper.prototype = Object.create(HTMLElement.prototype);\n mixin(GeneratedWrapper.prototype, {\n get form() {\n return wrap(unwrap(this).form);\n },\n });\n\n registerWrapper(window[name], GeneratedWrapper,\n document.createElement(name.slice(4, -7)));\n scope.wrappers[name] = GeneratedWrapper;\n }\n\n elementsWithFormProperty.forEach(createWrapperConstructor);\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2014 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n\n var OriginalSelection = window.Selection;\n\n function Selection(impl) {\n this.impl = impl;\n }\n Selection.prototype = {\n get anchorNode() {\n return wrap(this.impl.anchorNode);\n },\n get focusNode() {\n return wrap(this.impl.focusNode);\n },\n addRange: function(range) {\n this.impl.addRange(unwrap(range));\n },\n collapse: function(node, index) {\n this.impl.collapse(unwrapIfNeeded(node), index);\n },\n containsNode: function(node, allowPartial) {\n return this.impl.containsNode(unwrapIfNeeded(node), allowPartial);\n },\n extend: function(node, offset) {\n this.impl.extend(unwrapIfNeeded(node), offset);\n },\n getRangeAt: function(index) {\n return wrap(this.impl.getRangeAt(index));\n },\n removeRange: function(range) {\n this.impl.removeRange(unwrap(range));\n },\n selectAllChildren: function(node) {\n this.impl.selectAllChildren(unwrapIfNeeded(node));\n },\n toString: function() {\n return this.impl.toString();\n }\n };\n\n // WebKit extensions. Not implemented.\n // readonly attribute Node baseNode;\n // readonly attribute long baseOffset;\n // readonly attribute Node extentNode;\n // readonly attribute long extentOffset;\n // [RaisesException] void setBaseAndExtent([Default=Undefined] optional Node baseNode,\n // [Default=Undefined] optional long baseOffset,\n // [Default=Undefined] optional Node extentNode,\n // [Default=Undefined] optional long extentOffset);\n // [RaisesException, ImplementedAs=collapse] void setPosition([Default=Undefined] optional Node node,\n // [Default=Undefined] optional long offset);\n\n registerWrapper(window.Selection, Selection, window.getSelection());\n\n scope.wrappers.Selection = Selection;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var GetElementsByInterface = scope.GetElementsByInterface;\n var Node = scope.wrappers.Node;\n var ParentNodeInterface = scope.ParentNodeInterface;\n var Selection = scope.wrappers.Selection;\n var SelectorsInterface = scope.SelectorsInterface;\n var ShadowRoot = scope.wrappers.ShadowRoot;\n var TreeScope = scope.TreeScope;\n var cloneNode = scope.cloneNode;\n var defineWrapGetter = scope.defineWrapGetter;\n var elementFromPoint = scope.elementFromPoint;\n var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;\n var matchesNames = scope.matchesNames;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var renderAllPending = scope.renderAllPending;\n var rewrap = scope.rewrap;\n var unwrap = scope.unwrap;\n var wrap = scope.wrap;\n var wrapEventTargetMethods = scope.wrapEventTargetMethods;\n var wrapNodeList = scope.wrapNodeList;\n\n var implementationTable = new WeakMap();\n\n function Document(node) {\n Node.call(this, node);\n this.treeScope_ = new TreeScope(this, null);\n }\n Document.prototype = Object.create(Node.prototype);\n\n defineWrapGetter(Document, 'documentElement');\n\n // Conceptually both body and head can be in a shadow but suporting that seems\n // overkill at this point.\n defineWrapGetter(Document, 'body');\n defineWrapGetter(Document, 'head');\n\n // document cannot be overridden so we override a bunch of its methods\n // directly on the instance.\n\n function wrapMethod(name) {\n var original = document[name];\n Document.prototype[name] = function() {\n return wrap(original.apply(this.impl, arguments));\n };\n }\n\n [\n 'createComment',\n 'createDocumentFragment',\n 'createElement',\n 'createElementNS',\n 'createEvent',\n 'createEventNS',\n 'createRange',\n 'createTextNode',\n 'getElementById'\n ].forEach(wrapMethod);\n\n var originalAdoptNode = document.adoptNode;\n\n function adoptNodeNoRemove(node, doc) {\n originalAdoptNode.call(doc.impl, unwrap(node));\n adoptSubtree(node, doc);\n }\n\n function adoptSubtree(node, doc) {\n if (node.shadowRoot)\n doc.adoptNode(node.shadowRoot);\n if (node instanceof ShadowRoot)\n adoptOlderShadowRoots(node, doc);\n for (var child = node.firstChild; child; child = child.nextSibling) {\n adoptSubtree(child, doc);\n }\n }\n\n function adoptOlderShadowRoots(shadowRoot, doc) {\n var oldShadowRoot = shadowRoot.olderShadowRoot;\n if (oldShadowRoot)\n doc.adoptNode(oldShadowRoot);\n }\n\n var originalGetSelection = document.getSelection;\n\n mixin(Document.prototype, {\n adoptNode: function(node) {\n if (node.parentNode)\n node.parentNode.removeChild(node);\n adoptNodeNoRemove(node, this);\n return node;\n },\n elementFromPoint: function(x, y) {\n return elementFromPoint(this, this, x, y);\n },\n importNode: function(node, deep) {\n return cloneNode(node, deep, this.impl);\n },\n getSelection: function() {\n renderAllPending();\n return new Selection(originalGetSelection.call(unwrap(this)));\n },\n getElementsByName: function(name) {\n return SelectorsInterface.querySelectorAll.call(this,\n '[name=' + JSON.stringify(String(name)) + ']');\n }\n });\n\n if (document.registerElement) {\n var originalRegisterElement = document.registerElement;\n Document.prototype.registerElement = function(tagName, object) {\n var prototype, extendsOption;\n if (object !== undefined) {\n prototype = object.prototype;\n extendsOption = object.extends;\n }\n\n if (!prototype)\n prototype = Object.create(HTMLElement.prototype);\n\n\n // If we already used the object as a prototype for another custom\n // element.\n if (scope.nativePrototypeTable.get(prototype)) {\n // TODO(arv): DOMException\n throw new Error('NotSupportedError');\n }\n\n // Find first object on the prototype chain that already have a native\n // prototype. Keep track of all the objects before that so we can create\n // a similar structure for the native case.\n var proto = Object.getPrototypeOf(prototype);\n var nativePrototype;\n var prototypes = [];\n while (proto) {\n nativePrototype = scope.nativePrototypeTable.get(proto);\n if (nativePrototype)\n break;\n prototypes.push(proto);\n proto = Object.getPrototypeOf(proto);\n }\n\n if (!nativePrototype) {\n // TODO(arv): DOMException\n throw new Error('NotSupportedError');\n }\n\n // This works by creating a new prototype object that is empty, but has\n // the native prototype as its proto. The original prototype object\n // passed into register is used as the wrapper prototype.\n\n var newPrototype = Object.create(nativePrototype);\n for (var i = prototypes.length - 1; i >= 0; i--) {\n newPrototype = Object.create(newPrototype);\n }\n\n // Add callbacks if present.\n // Names are taken from:\n // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/bindings/v8/CustomElementConstructorBuilder.cpp&sq=package:chromium&type=cs&l=156\n // and not from the spec since the spec is out of date.\n [\n 'createdCallback',\n 'attachedCallback',\n 'detachedCallback',\n 'attributeChangedCallback',\n ].forEach(function(name) {\n var f = prototype[name];\n if (!f)\n return;\n newPrototype[name] = function() {\n // if this element has been wrapped prior to registration,\n // the wrapper is stale; in this case rewrap\n if (!(wrap(this) instanceof CustomElementConstructor)) {\n rewrap(this);\n }\n f.apply(wrap(this), arguments);\n };\n });\n\n var p = {prototype: newPrototype};\n if (extendsOption)\n p.extends = extendsOption;\n\n function CustomElementConstructor(node) {\n if (!node) {\n if (extendsOption) {\n return document.createElement(extendsOption, tagName);\n } else {\n return document.createElement(tagName);\n }\n }\n this.impl = node;\n }\n CustomElementConstructor.prototype = prototype;\n CustomElementConstructor.prototype.constructor = CustomElementConstructor;\n\n scope.constructorTable.set(newPrototype, CustomElementConstructor);\n scope.nativePrototypeTable.set(prototype, newPrototype);\n\n // registration is synchronous so do it last\n var nativeConstructor = originalRegisterElement.call(unwrap(this),\n tagName, p);\n return CustomElementConstructor;\n };\n\n forwardMethodsToWrapper([\n window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument\n ], [\n 'registerElement',\n ]);\n }\n\n // We also override some of the methods on document.body and document.head\n // for convenience.\n forwardMethodsToWrapper([\n window.HTMLBodyElement,\n window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument\n window.HTMLHeadElement,\n window.HTMLHtmlElement,\n ], [\n 'appendChild',\n 'compareDocumentPosition',\n 'contains',\n 'getElementsByClassName',\n 'getElementsByTagName',\n 'getElementsByTagNameNS',\n 'insertBefore',\n 'querySelector',\n 'querySelectorAll',\n 'removeChild',\n 'replaceChild',\n ].concat(matchesNames));\n\n forwardMethodsToWrapper([\n window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument\n ], [\n 'adoptNode',\n 'importNode',\n 'contains',\n 'createComment',\n 'createDocumentFragment',\n 'createElement',\n 'createElementNS',\n 'createEvent',\n 'createEventNS',\n 'createRange',\n 'createTextNode',\n 'elementFromPoint',\n 'getElementById',\n 'getElementsByName',\n 'getSelection',\n ]);\n\n mixin(Document.prototype, GetElementsByInterface);\n mixin(Document.prototype, ParentNodeInterface);\n mixin(Document.prototype, SelectorsInterface);\n\n mixin(Document.prototype, {\n get implementation() {\n var implementation = implementationTable.get(this);\n if (implementation)\n return implementation;\n implementation =\n new DOMImplementation(unwrap(this).implementation);\n implementationTable.set(this, implementation);\n return implementation;\n },\n\n get defaultView() {\n return wrap(unwrap(this).defaultView);\n }\n });\n\n registerWrapper(window.Document, Document,\n document.implementation.createHTMLDocument(''));\n\n // Both WebKit and Gecko uses HTMLDocument for document. HTML5/DOM only has\n // one Document interface and IE implements the standard correctly.\n if (window.HTMLDocument)\n registerWrapper(window.HTMLDocument, Document);\n\n wrapEventTargetMethods([\n window.HTMLBodyElement,\n window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument\n window.HTMLHeadElement,\n ]);\n\n function DOMImplementation(impl) {\n this.impl = impl;\n }\n\n function wrapImplMethod(constructor, name) {\n var original = document.implementation[name];\n constructor.prototype[name] = function() {\n return wrap(original.apply(this.impl, arguments));\n };\n }\n\n function forwardImplMethod(constructor, name) {\n var original = document.implementation[name];\n constructor.prototype[name] = function() {\n return original.apply(this.impl, arguments);\n };\n }\n\n wrapImplMethod(DOMImplementation, 'createDocumentType');\n wrapImplMethod(DOMImplementation, 'createDocument');\n wrapImplMethod(DOMImplementation, 'createHTMLDocument');\n forwardImplMethod(DOMImplementation, 'hasFeature');\n\n registerWrapper(window.DOMImplementation, DOMImplementation);\n\n forwardMethodsToWrapper([\n window.DOMImplementation,\n ], [\n 'createDocumentType',\n 'createDocument',\n 'createHTMLDocument',\n 'hasFeature',\n ]);\n\n scope.adoptNodeNoRemove = adoptNodeNoRemove;\n scope.wrappers.DOMImplementation = DOMImplementation;\n scope.wrappers.Document = Document;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var EventTarget = scope.wrappers.EventTarget;\n var Selection = scope.wrappers.Selection;\n var mixin = scope.mixin;\n var registerWrapper = scope.registerWrapper;\n var renderAllPending = scope.renderAllPending;\n var unwrap = scope.unwrap;\n var unwrapIfNeeded = scope.unwrapIfNeeded;\n var wrap = scope.wrap;\n\n var OriginalWindow = window.Window;\n var originalGetComputedStyle = window.getComputedStyle;\n var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;\n var originalGetSelection = window.getSelection;\n\n function Window(impl) {\n EventTarget.call(this, impl);\n }\n Window.prototype = Object.create(EventTarget.prototype);\n\n OriginalWindow.prototype.getComputedStyle = function(el, pseudo) {\n return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo);\n };\n\n // Mozilla proprietary extension.\n if (originalGetDefaultComputedStyle) {\n OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) {\n return wrap(this || window).getDefaultComputedStyle(\n unwrapIfNeeded(el), pseudo);\n };\n }\n\n OriginalWindow.prototype.getSelection = function() {\n return wrap(this || window).getSelection();\n };\n\n // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065\n delete window.getComputedStyle;\n delete window.getSelection;\n\n ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(\n function(name) {\n OriginalWindow.prototype[name] = function() {\n var w = wrap(this || window);\n return w[name].apply(w, arguments);\n };\n\n // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065\n delete window[name];\n });\n\n mixin(Window.prototype, {\n getComputedStyle: function(el, pseudo) {\n renderAllPending();\n return originalGetComputedStyle.call(unwrap(this), unwrapIfNeeded(el),\n pseudo);\n },\n getSelection: function() {\n renderAllPending();\n return new Selection(originalGetSelection.call(unwrap(this)));\n },\n\n get document() {\n return wrap(unwrap(this).document);\n }\n });\n\n // Mozilla proprietary extension.\n if (originalGetDefaultComputedStyle) {\n Window.prototype.getDefaultComputedStyle = function(el, pseudo) {\n renderAllPending();\n return originalGetDefaultComputedStyle.call(unwrap(this),\n unwrapIfNeeded(el),pseudo);\n };\n }\n\n registerWrapper(OriginalWindow, Window, window);\n\n scope.wrappers.Window = Window;\n\n})(window.ShadowDOMPolyfill);\n","/**\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var unwrap = scope.unwrap;\n\n // DataTransfer (Clipboard in old Blink/WebKit) has a single method that\n // requires wrapping. Since it is only a method we do not need a real wrapper,\n // we can just override the method.\n\n var OriginalDataTransfer = window.DataTransfer || window.Clipboard;\n var OriginalDataTransferSetDragImage =\n OriginalDataTransfer.prototype.setDragImage;\n\n if (OriginalDataTransferSetDragImage) {\n OriginalDataTransfer.prototype.setDragImage = function(image, x, y) {\n OriginalDataTransferSetDragImage.call(this, unwrap(image), x, y);\n };\n }\n\n})(window.ShadowDOMPolyfill);\n","/**\n * Copyright 2014 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n 'use strict';\n\n var registerWrapper = scope.registerWrapper;\n var unwrap = scope.unwrap;\n\n var OriginalFormData = window.FormData;\n\n function FormData(formElement) {\n if (formElement instanceof OriginalFormData)\n this.impl = formElement;\n else\n this.impl = new OriginalFormData(formElement && unwrap(formElement));\n }\n\n registerWrapper(OriginalFormData, FormData, new OriginalFormData());\n\n scope.wrappers.FormData = FormData;\n\n})(window.ShadowDOMPolyfill);\n","// Copyright 2013 The Polymer Authors. All rights reserved.\n// Use of this source code is goverened by a BSD-style\n// license that can be found in the LICENSE file.\n\n(function(scope) {\n 'use strict';\n\n var isWrapperFor = scope.isWrapperFor;\n\n // This is a list of the elements we currently override the global constructor\n // for.\n var elements = {\n 'a': 'HTMLAnchorElement',\n // Do not create an applet element by default since it shows a warning in\n // IE.\n // https://github.com/Polymer/polymer/issues/217\n // 'applet': 'HTMLAppletElement',\n 'area': 'HTMLAreaElement',\n 'audio': 'HTMLAudioElement',\n 'base': 'HTMLBaseElement',\n 'body': 'HTMLBodyElement',\n 'br': 'HTMLBRElement',\n 'button': 'HTMLButtonElement',\n 'canvas': 'HTMLCanvasElement',\n 'caption': 'HTMLTableCaptionElement',\n 'col': 'HTMLTableColElement',\n // 'command': 'HTMLCommandElement', // Not fully implemented in Gecko.\n 'content': 'HTMLContentElement',\n 'data': 'HTMLDataElement',\n 'datalist': 'HTMLDataListElement',\n 'del': 'HTMLModElement',\n 'dir': 'HTMLDirectoryElement',\n 'div': 'HTMLDivElement',\n 'dl': 'HTMLDListElement',\n 'embed': 'HTMLEmbedElement',\n 'fieldset': 'HTMLFieldSetElement',\n 'font': 'HTMLFontElement',\n 'form': 'HTMLFormElement',\n 'frame': 'HTMLFrameElement',\n 'frameset': 'HTMLFrameSetElement',\n 'h1': 'HTMLHeadingElement',\n 'head': 'HTMLHeadElement',\n 'hr': 'HTMLHRElement',\n 'html': 'HTMLHtmlElement',\n 'iframe': 'HTMLIFrameElement',\n 'img': 'HTMLImageElement',\n 'input': 'HTMLInputElement',\n 'keygen': 'HTMLKeygenElement',\n 'label': 'HTMLLabelElement',\n 'legend': 'HTMLLegendElement',\n 'li': 'HTMLLIElement',\n 'link': 'HTMLLinkElement',\n 'map': 'HTMLMapElement',\n 'marquee': 'HTMLMarqueeElement',\n 'menu': 'HTMLMenuElement',\n 'menuitem': 'HTMLMenuItemElement',\n 'meta': 'HTMLMetaElement',\n 'meter': 'HTMLMeterElement',\n 'object': 'HTMLObjectElement',\n 'ol': 'HTMLOListElement',\n 'optgroup': 'HTMLOptGroupElement',\n 'option': 'HTMLOptionElement',\n 'output': 'HTMLOutputElement',\n 'p': 'HTMLParagraphElement',\n 'param': 'HTMLParamElement',\n 'pre': 'HTMLPreElement',\n 'progress': 'HTMLProgressElement',\n 'q': 'HTMLQuoteElement',\n 'script': 'HTMLScriptElement',\n 'select': 'HTMLSelectElement',\n 'shadow': 'HTMLShadowElement',\n 'source': 'HTMLSourceElement',\n 'span': 'HTMLSpanElement',\n 'style': 'HTMLStyleElement',\n 'table': 'HTMLTableElement',\n 'tbody': 'HTMLTableSectionElement',\n // WebKit and Moz are wrong:\n // https://bugs.webkit.org/show_bug.cgi?id=111469\n // https://bugzilla.mozilla.org/show_bug.cgi?id=848096\n // 'td': 'HTMLTableCellElement',\n 'template': 'HTMLTemplateElement',\n 'textarea': 'HTMLTextAreaElement',\n 'thead': 'HTMLTableSectionElement',\n 'time': 'HTMLTimeElement',\n 'title': 'HTMLTitleElement',\n 'tr': 'HTMLTableRowElement',\n 'track': 'HTMLTrackElement',\n 'ul': 'HTMLUListElement',\n 'video': 'HTMLVideoElement',\n };\n\n function overrideConstructor(tagName) {\n var nativeConstructorName = elements[tagName];\n var nativeConstructor = window[nativeConstructorName];\n if (!nativeConstructor)\n return;\n var element = document.createElement(tagName);\n var wrapperConstructor = element.constructor;\n window[nativeConstructorName] = wrapperConstructor;\n }\n\n Object.keys(elements).forEach(overrideConstructor);\n\n Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) {\n window[name] = scope.wrappers[name]\n });\n\n})(window.ShadowDOMPolyfill);\n","/*\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 // convenient global\n window.wrap = ShadowDOMPolyfill.wrapIfNeeded;\n window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;\n\n // users may want to customize other types\n // TODO(sjmiles): 'button' is now supported by ShadowDOMPolyfill, but\n // I've left this code here in case we need to temporarily patch another\n // type\n /*\n (function() {\n var elts = {HTMLButtonElement: 'button'};\n for (var c in elts) {\n window[c] = function() { throw 'Patched Constructor'; };\n window[c].prototype = Object.getPrototypeOf(\n document.createElement(elts[c]));\n }\n })();\n */\n\n // patch in prefixed name\n Object.defineProperty(Element.prototype, 'webkitShadowRoot',\n Object.getOwnPropertyDescriptor(Element.prototype, 'shadowRoot'));\n\n var originalCreateShadowRoot = Element.prototype.createShadowRoot;\n Element.prototype.createShadowRoot = function() {\n var root = originalCreateShadowRoot.call(this);\n CustomElements.watchShadow(this);\n return root;\n };\n\n Element.prototype.webkitCreateShadowRoot = Element.prototype.createShadowRoot;\n\n function queryShadow(node, selector) {\n var m, el = node.firstElementChild;\n var shadows, sr, i;\n shadows = [];\n sr = node.shadowRoot;\n while(sr) {\n shadows.push(sr);\n sr = sr.olderShadowRoot;\n }\n for(i = shadows.length - 1; i >= 0; i--) {\n m = shadows[i].querySelector(selector);\n if (m) {\n return m;\n }\n }\n while(el) {\n m = queryShadow(el, selector);\n if (m) {\n return m;\n }\n el = el.nextElementSibling;\n }\n return null;\n }\n\n function queryAllShadows(node, selector, results) {\n var el = node.firstElementChild;\n var temp, sr, shadows, i, j;\n shadows = [];\n sr = node.shadowRoot;\n while(sr) {\n shadows.push(sr);\n sr = sr.olderShadowRoot;\n }\n for (i = shadows.length - 1; i >= 0; i--) {\n temp = shadows[i].querySelectorAll(selector);\n for(j = 0; j < temp.length; j++) {\n results.push(temp[j]);\n }\n }\n while (el) {\n queryAllShadows(el, selector, results);\n el = el.nextElementSibling;\n }\n return results;\n }\n\n scope.queryAllShadows = function(node, selector, all) {\n if (all) {\n return queryAllShadows(node, selector, []);\n } else {\n return queryShadow(node, selector);\n }\n };\n})(window.Platform);\n","/*\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/*\n This is a limited shim for ShadowDOM css styling.\n https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles\n \n The intention here is to support only the styling features which can be \n relatively simply implemented. The goal is to allow users to avoid the \n most obvious pitfalls and do so without compromising performance significantly. \n For ShadowDOM styling that's not covered here, a set of best practices\n can be provided that should allow users to accomplish more complex styling.\n\n The following is a list of specific ShadowDOM styling features and a brief\n discussion of the approach used to shim.\n\n Shimmed features:\n\n * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host\n element using the :host rule. To shim this feature, the :host styles are \n reformatted and prefixed with a given scope name and promoted to a \n document level stylesheet.\n For example, given a scope name of .foo, a rule like this:\n \n :host {\n background: red;\n }\n }\n \n becomes:\n \n .foo {\n background: red;\n }\n \n * encapsultion: Styles defined within ShadowDOM, apply only to \n dom inside the ShadowDOM. Polymer uses one of two techniques to imlement\n this feature.\n \n By default, rules are prefixed with the host element tag name \n as a descendant selector. This ensures styling does not leak out of the 'top'\n of the element's ShadowDOM. For example,\n\n div {\n font-weight: bold;\n }\n \n becomes:\n\n x-foo div {\n font-weight: bold;\n }\n \n becomes:\n\n\n Alternatively, if Platform.ShadowCSS.strictStyling is set to true then \n selectors are scoped by adding an attribute selector suffix to each\n simple selector that contains the host element tag name. Each element \n in the element's ShadowDOM template is also given the scope attribute. \n Thus, these rules match only elements that have the scope attribute.\n For example, given a scope name of x-foo, a rule like this:\n \n div {\n font-weight: bold;\n }\n \n becomes:\n \n div[x-foo] {\n font-weight: bold;\n }\n\n Note that elements that are dynamically added to a scope must have the scope\n selector added to them manually.\n\n * upper/lower bound encapsulation: Styles which are defined outside a\n shadowRoot should not cross the ShadowDOM boundary and should not apply\n inside a shadowRoot.\n\n This styling behavior is not emulated. Some possible ways to do this that \n were rejected due to complexity and/or performance concerns include: (1) reset\n every possible property for every possible selector for a given scope name;\n (2) re-implement css in javascript.\n \n As an alternative, users should make sure to use selectors\n specific to the scope in which they are working.\n \n * ::distributed: This behavior is not emulated. It's often not necessary\n to style the contents of a specific insertion point and instead, descendants\n of the host element can be styled selectively. Users can also create an \n extra node around an insertion point and style that node's contents\n via descendent selectors. For example, with a shadowRoot like this:\n \n \n \n \n could become:\n \n \n \n \n
\n \n Note the use of @polyfill in the comment above a ShadowDOM specific style\n declaration. This is a directive to the styling shim to use the selector \n in comments in lieu of the next selector when running under polyfill.\n*/\n(function(scope) {\n\nvar ShadowCSS = {\n strictStyling: false,\n registry: {},\n // Shim styles for a given root associated with a name and extendsName\n // 1. cache root styles by name\n // 2. optionally tag root nodes with scope name\n // 3. shim polyfill directives /* @polyfill */ and /* @polyfill-rule */\n // 4. shim :host and scoping\n shimStyling: function(root, name, extendsName) {\n var scopeStyles = this.prepareRoot(root, name, extendsName);\n var typeExtension = this.isTypeExtension(extendsName);\n var scopeSelector = this.makeScopeSelector(name, typeExtension);\n // use caching to make working with styles nodes easier and to facilitate\n // lookup of extendee\n var cssText = stylesToCssText(scopeStyles, true);\n cssText = this.scopeCssText(cssText, scopeSelector);\n // cache shimmed css on root for user extensibility\n if (root) {\n root.shimmedStyle = cssText;\n }\n // add style to document\n this.addCssToDocument(cssText, name);\n },\n /*\n * Shim a style element with the given selector. Returns cssText that can\n * be included in the document via Platform.ShadowCSS.addCssToDocument(css).\n */\n shimStyle: function(style, selector) {\n return this.shimCssText(style.textContent, selector);\n },\n /*\n * Shim some cssText with the given selector. Returns cssText that can\n * be included in the document via Platform.ShadowCSS.addCssToDocument(css).\n */\n shimCssText: function(cssText, selector) {\n cssText = this.insertDirectives(cssText);\n return this.scopeCssText(cssText, selector);\n },\n makeScopeSelector: function(name, typeExtension) {\n if (name) {\n return typeExtension ? '[is=' + name + ']' : name;\n }\n return '';\n },\n isTypeExtension: function(extendsName) {\n return extendsName && extendsName.indexOf('-') < 0;\n },\n prepareRoot: function(root, name, extendsName) {\n var def = this.registerRoot(root, name, extendsName);\n this.replaceTextInStyles(def.rootStyles, this.insertDirectives);\n // remove existing style elements\n this.removeStyles(root, def.rootStyles);\n // apply strict attr\n if (this.strictStyling) {\n this.applyScopeToContent(root, name);\n }\n return def.scopeStyles;\n },\n removeStyles: function(root, styles) {\n for (var i=0, l=styles.length, s; (i .bar { }\n *\n * to\n *\n * scopeName.foo > .bar\n */\n convertColonHost: function(cssText) {\n return this.convertColonRule(cssText, cssColonHostRe,\n this.colonHostPartReplacer);\n },\n /*\n * convert a rule like :host-context(.foo) > .bar { }\n *\n * to\n *\n * scopeName.foo > .bar, .foo scopeName > .bar { }\n * \n * and\n *\n * :host-context(.foo:host) .bar { ... }\n * \n * to\n * \n * scopeName.foo .bar { ... }\n */\n convertColonHostContext: function(cssText) {\n return this.convertColonRule(cssText, cssColonHostContextRe,\n this.colonHostContextPartReplacer);\n },\n convertColonRule: function(cssText, regExp, partReplacer) {\n // p1 = :host, p2 = contents of (), p3 rest of rule\n return cssText.replace(regExp, function(m, p1, p2, p3) {\n p1 = polyfillHostNoCombinator;\n if (p2) {\n var parts = p2.split(','), r = [];\n for (var i=0, l=parts.length, p; (i .zot becomes .foo[name].bar[name] > .zot[name]\n applyStrictSelectorScope: function(selector, scopeSelector) {\n scopeSelector = scopeSelector.replace(/\\[is=([^\\]]*)\\]/g, '$1');\n var splits = [' ', '>', '+', '~'],\n scoped = selector,\n attrName = '[' + scopeSelector + ']';\n splits.forEach(function(sep) {\n var parts = scoped.split(sep);\n scoped = parts.map(function(p) {\n // remove :host since it should be unnecessary\n var t = p.trim().replace(polyfillHostRe, '');\n if (t && (splits.indexOf(t) < 0) && (t.indexOf(attrName) < 0)) {\n p = t.replace(/([^:]*)(:*)(.*)/, '$1' + attrName + '$2$3')\n }\n return p;\n }).join(sep);\n });\n return scoped;\n },\n insertPolyfillHostInCssText: function(selector) {\n return selector.replace(colonHostContextRe, polyfillHostContext).replace(\n colonHostRe, polyfillHost);\n },\n propertiesFromRule: function(rule) {\n var cssText = rule.style.cssText;\n // TODO(sorvell): Safari cssom incorrectly removes quotes from the content\n // property. (https://bugs.webkit.org/show_bug.cgi?id=118045)\n // don't replace attr rules\n if (rule.style.content && !rule.style.content.match(/['\"]+|attr/)) {\n cssText = cssText.replace(/content:[^;]*;/g, 'content: \\'' + \n rule.style.content + '\\';');\n }\n // TODO(sorvell): we can workaround this issue here, but we need a list\n // of troublesome properties to fix https://github.com/Polymer/platform/issues/53\n //\n // inherit rules can be omitted from cssText\n // TODO(sorvell): remove when Blink bug is fixed:\n // https://code.google.com/p/chromium/issues/detail?id=358273\n var style = rule.style;\n for (var i in style) {\n if (style[i] === 'initial') {\n cssText += i + ': initial; ';\n }\n }\n return cssText;\n },\n replaceTextInStyles: function(styles, action) {\n if (styles && action) {\n if (!(styles instanceof Array)) {\n styles = [styles];\n }\n Array.prototype.forEach.call(styles, function(s) {\n s.textContent = action.call(this, s.textContent);\n }, this);\n }\n },\n addCssToDocument: function(cssText, name) {\n if (cssText.match('@import')) {\n addOwnSheet(cssText, name);\n } else {\n addCssToDocument(cssText);\n }\n }\n};\n\nvar selectorRe = /([^{]*)({[\\s\\S]*?})/gim,\n cssCommentRe = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//gim,\n // TODO(sorvell): remove either content or comment\n cssCommentNextSelectorRe = /\\/\\*\\s*@polyfill ([^*]*\\*+([^/*][^*]*\\*+)*\\/)([^{]*?){/gim,\n cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\\:[\\s]*?['\"](.*?)['\"][;\\s]*}([^{]*?){/gim, \n // TODO(sorvell): remove either content or comment\n cssCommentRuleRe = /\\/\\*\\s@polyfill-rule([^*]*\\*+([^/*][^*]*\\*+)*)\\//gim,\n cssContentRuleRe = /(polyfill-rule)[^}]*(content\\:[\\s]*['\"](.*?)['\"])[;\\s]*[^}]*}/gim,\n // TODO(sorvell): remove either content or comment\n cssCommentUnscopedRuleRe = /\\/\\*\\s@polyfill-unscoped-rule([^*]*\\*+([^/*][^*]*\\*+)*)\\//gim,\n cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\\:[\\s]*['\"](.*?)['\"])[;\\s]*[^}]*}/gim,\n cssPseudoRe = /::(x-[^\\s{,(]*)/gim,\n cssPartRe = /::part\\(([^)]*)\\)/gim,\n // note: :host pre-processed to -shadowcsshost.\n polyfillHost = '-shadowcsshost',\n // note: :host-context pre-processed to -shadowcsshostcontext.\n polyfillHostContext = '-shadowcsscontext',\n parenSuffix = ')(?:\\\\((' +\n '(?:\\\\([^)(]*\\\\)|[^)(]*)+?' +\n ')\\\\))?([^,{]*)';\n cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'),\n cssColonHostContextRe = new RegExp('(' + polyfillHostContext + parenSuffix, 'gim'),\n selectorReSuffix = '([>\\\\s~+\\[.,{:][\\\\s\\\\S]*)?$',\n colonHostRe = /\\:host/gim,\n colonHostContextRe = /\\:host-context/gim,\n /* host name without combinator */\n polyfillHostNoCombinator = polyfillHost + '-no-combinator',\n polyfillHostRe = new RegExp(polyfillHost, 'gim'),\n polyfillHostContextRe = new RegExp(polyfillHostContext, 'gim'),\n shadowDOMSelectorsRe = [\n /\\^\\^/g,\n /\\^/g,\n /\\/shadow\\//g,\n /\\/shadow-deep\\//g,\n /::shadow/g,\n /\\/deep\\//g,\n /::content/g\n ];\n\nfunction stylesToCssText(styles, preserveComments) {\n var cssText = '';\n Array.prototype.forEach.call(styles, function(s) {\n cssText += s.textContent + '\\n\\n';\n });\n // strip comments for easier processing\n if (!preserveComments) {\n cssText = cssText.replace(cssCommentRe, '');\n }\n return cssText;\n}\n\nfunction cssTextToStyle(cssText) {\n var style = document.createElement('style');\n style.textContent = cssText;\n return style;\n}\n\nfunction cssToRules(cssText) {\n var style = cssTextToStyle(cssText);\n document.head.appendChild(style);\n var rules = [];\n if (style.sheet) {\n // TODO(sorvell): Firefox throws when accessing the rules of a stylesheet\n // with an @import\n // https://bugzilla.mozilla.org/show_bug.cgi?id=625013\n try {\n rules = style.sheet.cssRules;\n } catch(e) {\n //\n }\n } else {\n console.warn('sheet not found', style);\n }\n style.parentNode.removeChild(style);\n return rules;\n}\n\nvar frame = document.createElement('iframe');\nframe.style.display = 'none';\n\nfunction initFrame() {\n frame.initialized = true;\n document.body.appendChild(frame);\n var doc = frame.contentDocument;\n var base = doc.createElement('base');\n base.href = document.baseURI;\n doc.head.appendChild(base);\n}\n\nfunction inFrame(fn) {\n if (!frame.initialized) {\n initFrame();\n }\n document.body.appendChild(frame);\n fn(frame.contentDocument);\n document.body.removeChild(frame);\n}\n\n// TODO(sorvell): use an iframe if the cssText contains an @import to workaround\n// https://code.google.com/p/chromium/issues/detail?id=345114\nvar isChrome = navigator.userAgent.match('Chrome');\nfunction withCssRules(cssText, callback) {\n if (!callback) {\n return;\n }\n var rules;\n if (cssText.match('@import') && isChrome) {\n var style = cssTextToStyle(cssText);\n inFrame(function(doc) {\n doc.head.appendChild(style.impl);\n rules = style.sheet.cssRules;\n callback(rules);\n });\n } else {\n rules = cssToRules(cssText);\n callback(rules);\n }\n}\n\nfunction rulesToCss(cssRules) {\n for (var i=0, css=[]; i < cssRules.length; i++) {\n css.push(cssRules[i].cssText);\n }\n return css.join('\\n\\n');\n}\n\nfunction addCssToDocument(cssText) {\n if (cssText) {\n getSheet().appendChild(document.createTextNode(cssText));\n }\n}\n\nfunction addOwnSheet(cssText, name) {\n var style = cssTextToStyle(cssText);\n style.setAttribute(name, '');\n style.setAttribute(SHIMMED_ATTRIBUTE, '');\n document.head.appendChild(style);\n}\n\nvar SHIM_ATTRIBUTE = 'shim-shadowdom';\nvar SHIMMED_ATTRIBUTE = 'shim-shadowdom-css';\nvar NO_SHIM_ATTRIBUTE = 'no-shim';\n\nvar sheet;\nfunction getSheet() {\n if (!sheet) {\n sheet = document.createElement(\"style\");\n sheet.setAttribute(SHIMMED_ATTRIBUTE, '');\n sheet[SHIMMED_ATTRIBUTE] = true;\n }\n return sheet;\n}\n\n// add polyfill stylesheet to document\nif (window.ShadowDOMPolyfill) {\n addCssToDocument('style { display: none !important; }\\n');\n var doc = wrap(document);\n var head = doc.querySelector('head');\n head.insertBefore(getSheet(), head.childNodes[0]);\n\n // TODO(sorvell): monkey-patching HTMLImports is abusive;\n // consider a better solution.\n document.addEventListener('DOMContentLoaded', function() {\n var urlResolver = scope.urlResolver;\n \n if (window.HTMLImports && !HTMLImports.useNative) {\n var SHIM_SHEET_SELECTOR = 'link[rel=stylesheet]' +\n '[' + SHIM_ATTRIBUTE + ']';\n var SHIM_STYLE_SELECTOR = 'style[' + SHIM_ATTRIBUTE + ']';\n HTMLImports.importer.documentPreloadSelectors += ',' + SHIM_SHEET_SELECTOR;\n HTMLImports.importer.importsPreloadSelectors += ',' + SHIM_SHEET_SELECTOR;\n\n HTMLImports.parser.documentSelectors = [\n HTMLImports.parser.documentSelectors,\n SHIM_SHEET_SELECTOR,\n SHIM_STYLE_SELECTOR\n ].join(',');\n \n var originalParseGeneric = HTMLImports.parser.parseGeneric;\n\n HTMLImports.parser.parseGeneric = function(elt) {\n if (elt[SHIMMED_ATTRIBUTE]) {\n return;\n }\n var style = elt.__importElement || elt;\n if (!style.hasAttribute(SHIM_ATTRIBUTE)) {\n originalParseGeneric.call(this, elt);\n return;\n }\n if (elt.__resource) {\n style = elt.ownerDocument.createElement('style');\n style.textContent = urlResolver.resolveCssText(\n elt.__resource, elt.href);\n } else {\n urlResolver.resolveStyle(style); \n }\n style.textContent = ShadowCSS.shimStyle(style);\n style.removeAttribute(SHIM_ATTRIBUTE, '');\n style.setAttribute(SHIMMED_ATTRIBUTE, '');\n style[SHIMMED_ATTRIBUTE] = true;\n // place in document\n if (style.parentNode !== head) {\n // replace links in head\n if (elt.parentNode === head) {\n head.replaceChild(style, elt);\n } else {\n this.addElementToDocument(style);\n }\n }\n style.__importParsed = true;\n this.markParsingComplete(elt);\n this.parseNext();\n }\n\n var hasResource = HTMLImports.parser.hasResource;\n HTMLImports.parser.hasResource = function(node) {\n if (node.localName === 'link' && node.rel === 'stylesheet' &&\n node.hasAttribute(SHIM_ATTRIBUTE)) {\n return (node.__resource);\n } else {\n return hasResource.call(this, node);\n }\n }\n\n }\n });\n}\n\n// exports\nscope.ShadowCSS = ShadowCSS;\n\n})(window.Platform);\n","/*\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 // so we can call wrap/unwrap without testing for ShadowDOMPolyfill\n window.wrap = window.unwrap = function(n){\n return n;\n }\n\n addEventListener('DOMContentLoaded', function() {\n if (CustomElements.useNative === false) {\n var originalCreateShadowRoot = Element.prototype.createShadowRoot;\n Element.prototype.createShadowRoot = function() {\n var root = originalCreateShadowRoot.call(this);\n CustomElements.watchShadow(this);\n return root;\n };\n }\n });\n\n Platform.templateContent = function(inTemplate) {\n // if MDV exists, it may need to boostrap this template to reveal content\n if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {\n HTMLTemplateElement.bootstrap(inTemplate);\n }\n // fallback when there is no Shadow DOM polyfill, no MDV polyfill, and no\n // native template support\n if (!inTemplate.content && !inTemplate._content) {\n var frag = document.createDocumentFragment();\n while (inTemplate.firstChild) {\n frag.appendChild(inTemplate.firstChild);\n }\n inTemplate._content = frag;\n }\n return inTemplate.content || inTemplate._content;\n };\n\n})(window.Platform);\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 hasWorkingUrl = u.href === 'http://a/b';\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 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 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 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 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._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 }\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 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\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})(this);\n","/*\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// Old versions of iOS do not have bind.\n\nif (!Function.prototype.bind) {\n Function.prototype.bind = function(scope) {\n var self = this;\n var args = Array.prototype.slice.call(arguments, 1);\n return function() {\n var args2 = args.slice();\n args2.push.apply(args2, arguments);\n return self.apply(scope, args2);\n };\n };\n}\n\n// mixin\n\n// copy all properties from inProps (et al) to inObj\nfunction mixin(inObj/*, inProps, inMoreProps, ...*/) {\n var obj = inObj || {};\n for (var i = 1; i < arguments.length; i++) {\n var p = arguments[i];\n try {\n for (var n in p) {\n copyProperty(n, p, obj);\n }\n } catch(x) {\n }\n }\n return obj;\n}\n\n// copy property inName from inSource object to inTarget object\nfunction copyProperty(inName, inSource, inTarget) {\n var pd = getPropertyDescriptor(inSource, inName);\n Object.defineProperty(inTarget, inName, pd);\n}\n\n// get property descriptor for inName on inObject, even if\n// inName exists on some link in inObject's prototype chain\nfunction getPropertyDescriptor(inObject, inName) {\n if (inObject) {\n var pd = Object.getOwnPropertyDescriptor(inObject, inName);\n return pd || getPropertyDescriptor(Object.getPrototypeOf(inObject), inName);\n }\n}\n\n// export\n\nscope.mixin = mixin;\n\n})(window.Platform);\n","/*\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 // polyfill DOMTokenList\n // * add/remove: allow these methods to take multiple classNames\n // * toggle: add a 2nd argument which forces the given state rather\n // than toggling.\n\n var add = DOMTokenList.prototype.add;\n var remove = DOMTokenList.prototype.remove;\n DOMTokenList.prototype.add = function() {\n for (var i = 0; i < arguments.length; i++) {\n add.call(this, arguments[i]);\n }\n };\n DOMTokenList.prototype.remove = function() {\n for (var i = 0; i < arguments.length; i++) {\n remove.call(this, arguments[i]);\n }\n };\n DOMTokenList.prototype.toggle = function(name, bool) {\n if (arguments.length == 1) {\n bool = !this.contains(name);\n }\n bool ? this.add(name) : this.remove(name);\n };\n DOMTokenList.prototype.switch = function(oldName, newName) {\n oldName && this.remove(oldName);\n newName && this.add(newName);\n };\n\n // add array() to NodeList, NamedNodeMap, HTMLCollection\n\n var ArraySlice = function() {\n return Array.prototype.slice.call(this);\n };\n\n var namedNodeMap = (window.NamedNodeMap || window.MozNamedAttrMap || {});\n\n NodeList.prototype.array = ArraySlice;\n namedNodeMap.prototype.array = ArraySlice;\n HTMLCollection.prototype.array = ArraySlice;\n\n // polyfill performance.now\n\n if (!window.performance) {\n var start = Date.now();\n // only at millisecond precision\n window.performance = {now: function(){ return Date.now() - start }};\n }\n\n // polyfill for requestAnimationFrame\n\n if (!window.requestAnimationFrame) {\n window.requestAnimationFrame = (function() {\n var nativeRaf = window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame;\n\n return nativeRaf ?\n function(callback) {\n return nativeRaf(function() {\n callback(performance.now());\n });\n } :\n function( callback ){\n return window.setTimeout(callback, 1000 / 60);\n };\n })();\n }\n\n if (!window.cancelAnimationFrame) {\n window.cancelAnimationFrame = (function() {\n return window.webkitCancelAnimationFrame ||\n window.mozCancelAnimationFrame ||\n function(id) {\n clearTimeout(id);\n };\n })();\n }\n\n // utility\n\n function createDOM(inTagOrNode, inHTML, inAttrs) {\n var dom = typeof inTagOrNode == 'string' ?\n document.createElement(inTagOrNode) : inTagOrNode.cloneNode(true);\n dom.innerHTML = inHTML;\n if (inAttrs) {\n for (var n in inAttrs) {\n dom.setAttribute(n, inAttrs[n]);\n }\n }\n return dom;\n }\n // Make a stub for Polymer() for polyfill purposes; under the HTMLImports\n // polyfill, scripts in the main document run before imports. That means\n // if (1) polymer is imported and (2) Polymer() is called in the main document\n // in a script after the import, 2 occurs before 1. We correct this here\n // by specfiically patching Polymer(); this is not necessary under native\n // HTMLImports.\n var elementDeclarations = [];\n\n var polymerStub = function(name, dictionary) {\n elementDeclarations.push(arguments);\n }\n window.Polymer = polymerStub;\n\n // deliver queued delcarations\n scope.deliverDeclarations = function() {\n scope.deliverDeclarations = function() {\n throw 'Possible attempt to load Polymer twice';\n };\n return elementDeclarations;\n }\n\n // Once DOMContent has loaded, any main document scripts that depend on\n // Polymer() should have run. Calling Polymer() now is an error until\n // polymer is imported.\n window.addEventListener('DOMContentLoaded', function() {\n if (window.Polymer === polymerStub) {\n window.Polymer = function() {\n console.error('You tried to use polymer without loading it first. To ' +\n 'load polymer, ');\n };\n }\n });\n\n // exports\n scope.createDOM = createDOM;\n\n})(window.Platform);\n","/*\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// poor man's adapter for template.content on various platform scenarios\n(function(scope) {\n scope.templateContent = scope.templateContent || function(inTemplate) {\n return inTemplate.content;\n };\n})(window.Platform);\n","/*\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 scope = scope || (window.Inspector = {});\n \n var inspector;\n\n window.sinspect = function(inNode, inProxy) {\n if (!inspector) {\n inspector = window.open('', 'ShadowDOM Inspector', null, true);\n inspector.document.write(inspectorHTML);\n //inspector.document.close();\n inspector.api = {\n shadowize: shadowize\n };\n }\n inspect(inNode || wrap(document.body), inProxy);\n };\n\n var inspectorHTML = [\n '',\n '',\n ' ',\n ' ShadowDOM Inspector ',\n ' ',\n ' ',\n ' ',\n ' ',\n '
',\n ' ',\n ''\n ].join('\\n');\n \n var crumbs = [];\n\n var displayCrumbs = function() {\n // alias our document\n var d = inspector.document;\n // get crumbbar\n var cb = d.querySelector('#crumbs');\n // clear crumbs\n cb.textContent = '';\n // build new crumbs\n for (var i=0, c; c=crumbs[i]; i++) {\n var a = d.createElement('a');\n a.href = '#';\n a.textContent = c.localName;\n a.idx = i;\n a.onclick = function(event) {\n var c;\n while (crumbs.length > this.idx) {\n c = crumbs.pop();\n }\n inspect(c.shadow || c, c);\n event.preventDefault();\n };\n cb.appendChild(d.createElement('li')).appendChild(a);\n }\n };\n\n var inspect = function(inNode, inProxy) {\n // alias our document\n var d = inspector.document;\n // reset list of drillable nodes\n drillable = [];\n // memoize our crumb proxy\n var proxy = inProxy || inNode;\n crumbs.push(proxy);\n // update crumbs\n displayCrumbs();\n // reflect local tree\n d.body.querySelector('#tree').innerHTML =\n '' + output(inNode, inNode.childNodes) + ' ';\n };\n\n var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);\n\n var blacklisted = {STYLE:1, SCRIPT:1, \"#comment\": 1, TEMPLATE: 1};\n var blacklist = function(inNode) {\n return blacklisted[inNode.nodeName];\n };\n\n var output = function(inNode, inChildNodes, inIndent) {\n if (blacklist(inNode)) {\n return '';\n }\n var indent = inIndent || '';\n if (inNode.localName || inNode.nodeType == 11) {\n var name = inNode.localName || 'shadow-root';\n //inChildNodes = ShadowDOM.localNodes(inNode);\n var info = indent + describe(inNode);\n // if only textNodes\n // TODO(sjmiles): make correct for ShadowDOM\n /*if (!inNode.children.length && inNode.localName !== 'content' && inNode.localName !== 'shadow') {\n info += catTextContent(inChildNodes);\n } else*/ {\n // TODO(sjmiles): native has no reference to its projection\n if (name == 'content' /*|| name == 'shadow'*/) {\n inChildNodes = inNode.getDistributedNodes();\n }\n info += ' ';\n var ind = indent + ' ';\n forEach(inChildNodes, function(n) {\n info += output(n, n.childNodes, ind);\n });\n info += indent;\n }\n if (!({br:1}[name])) {\n info += '</' + name + '> ';\n info += ' ';\n }\n } else {\n var text = inNode.textContent.trim();\n info = text ? indent + '\"' + text + '\"' + ' ' : '';\n }\n return info;\n };\n\n var catTextContent = function(inChildNodes) {\n var info = '';\n forEach(inChildNodes, function(n) {\n info += n.textContent.trim();\n });\n return info;\n };\n\n var drillable = [];\n\n var describe = function(inNode) {\n var tag = '' + '<';\n var name = inNode.localName || 'shadow-root';\n if (inNode.webkitShadowRoot || inNode.shadowRoot) {\n tag += ' ' + name + ' ';\n drillable.push(inNode);\n } else {\n tag += name || 'shadow-root';\n }\n if (inNode.attributes) {\n forEach(inNode.attributes, function(a) {\n tag += ' ' + a.name + (a.value ? '=\"' + a.value + '\"' : '');\n });\n }\n tag += '>'+ ' ';\n return tag;\n };\n\n // remote api\n\n shadowize = function() {\n var idx = Number(this.attributes.idx.value);\n //alert(idx);\n var node = drillable[idx];\n if (node) {\n inspect(node.webkitShadowRoot || node.shadowRoot, node)\n } else {\n console.log(\"bad shadowize node\");\n console.dir(this);\n }\n };\n \n // export\n \n scope.output = output;\n \n})(window.Inspector);\n","/*\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 // TODO(sorvell): 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 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;' \n + ' } \\n'\n ;\n var head = document.querySelector('head');\n head.insertBefore(style, head.firstChild);\n\n})(Platform);\n","/*\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 function withDependencies(task, depends) {\n depends = depends || [];\n if (!depends.map) {\n depends = [depends];\n }\n return task.apply(this, depends.map(marshal));\n }\n\n function module(name, dependsOrFactory, moduleFactory) {\n var module;\n switch (arguments.length) {\n case 0:\n return;\n case 1:\n module = null;\n break;\n case 2:\n // dependsOrFactory is `factory` in this case\n module = dependsOrFactory.apply(this);\n break;\n default:\n // dependsOrFactory is `depends` in this case\n module = withDependencies(moduleFactory, dependsOrFactory);\n break;\n }\n modules[name] = module;\n };\n\n function marshal(name) {\n return modules[name];\n }\n\n var modules = {};\n\n function using(depends, task) {\n HTMLImports.whenImportsReady(function() {\n withDependencies(task, depends);\n });\n };\n\n // exports\n\n scope.marshal = marshal;\n // `module` confuses commonjs detectors\n scope.modularize = module;\n scope.using = using;\n\n})(window);\n","/*\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\nvar iterations = 0;\nvar callbacks = [];\nvar twiddle = document.createTextNode('');\n\nfunction endOfMicrotask(callback) {\n twiddle.textContent = iterations++;\n callbacks.push(callback);\n}\n\nfunction atEndOfMicrotask() {\n while (callbacks.length) {\n callbacks.shift()();\n }\n}\n\nnew (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask)\n .observe(twiddle, {characterData: true})\n ;\n\n// exports\n\nscope.endOfMicrotask = endOfMicrotask;\n\n})(Platform);\n\n","/*\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\nvar urlResolver = {\n resolveDom: function(root, url) {\n url = url || root.ownerDocument.baseURI;\n this.resolveAttributes(root, url);\n this.resolveStyles(root, url);\n // handle template.content\n var templates = root.querySelectorAll('template');\n if (templates) {\n for (var i = 0, l = templates.length, t; (i < l) && (t = templates[i]); i++) {\n if (t.content) {\n this.resolveDom(t.content, url);\n }\n }\n }\n },\n resolveTemplate: function(template) {\n this.resolveDom(template.content, template.ownerDocument.baseURI);\n },\n resolveStyles: function(root, url) {\n var styles = root.querySelectorAll('style');\n if (styles) {\n for (var i = 0, l = styles.length, s; (i < l) && (s = styles[i]); i++) {\n this.resolveStyle(s, url);\n }\n }\n },\n resolveStyle: function(style, url) {\n url = url || style.ownerDocument.baseURI;\n style.textContent = this.resolveCssText(style.textContent, url);\n },\n resolveCssText: function(cssText, baseUrl, keepAbsolute) {\n cssText = replaceUrlsInCssText(cssText, baseUrl, keepAbsolute, CSS_URL_REGEXP);\n return replaceUrlsInCssText(cssText, baseUrl, keepAbsolute, CSS_IMPORT_REGEXP);\n },\n resolveAttributes: function(root, url) {\n if (root.hasAttributes && root.hasAttributes()) {\n this.resolveElementAttributes(root, url);\n }\n // search for attributes that host urls\n var nodes = root && root.querySelectorAll(URL_ATTRS_SELECTOR);\n if (nodes) {\n for (var i = 0, l = nodes.length, n; (i < l) && (n = nodes[i]); i++) {\n this.resolveElementAttributes(n, url);\n }\n }\n },\n resolveElementAttributes: function(node, url) {\n url = url || node.ownerDocument.baseURI;\n URL_ATTRS.forEach(function(v) {\n var attr = node.attributes[v];\n var value = attr && attr.value;\n var replacement;\n if (value && value.search(URL_TEMPLATE_SEARCH) < 0) {\n if (v === 'style') {\n replacement = replaceUrlsInCssText(value, url, false, CSS_URL_REGEXP);\n } else {\n replacement = resolveRelativeUrl(url, value);\n }\n attr.value = replacement;\n }\n });\n }\n};\n\nvar CSS_URL_REGEXP = /(url\\()([^)]*)(\\))/g;\nvar CSS_IMPORT_REGEXP = /(@import[\\s]+(?!url\\())([^;]*)(;)/g;\nvar URL_ATTRS = ['href', 'src', 'action', 'style', 'url'];\nvar URL_ATTRS_SELECTOR = '[' + URL_ATTRS.join('],[') + ']';\nvar URL_TEMPLATE_SEARCH = '{{.*}}';\n\nfunction replaceUrlsInCssText(cssText, baseUrl, keepAbsolute, regexp) {\n return cssText.replace(regexp, function(m, pre, url, post) {\n var urlPath = url.replace(/[\"']/g, '');\n urlPath = resolveRelativeUrl(baseUrl, urlPath, keepAbsolute);\n return pre + '\\'' + urlPath + '\\'' + post;\n });\n}\n\nfunction resolveRelativeUrl(baseUrl, url, keepAbsolute) {\n // do not resolve '/' absolute urls\n if (url && url[0] === '/') {\n return url;\n }\n var u = new URL(url, baseUrl);\n return keepAbsolute ? u.href : makeDocumentRelPath(u.href);\n}\n\nfunction makeDocumentRelPath(url) {\n var root = new URL(document.baseURI);\n var u = new URL(url, root);\n if (u.host === root.host && u.port === root.port &&\n u.protocol === root.protocol) {\n return makeRelPath(root, u);\n } else {\n return url;\n }\n}\n\n// make a relative path from source to target\nfunction makeRelPath(sourceUrl, targetUrl) {\n var source = sourceUrl.pathname;\n var target = targetUrl.pathname;\n var s = source.split('/');\n var t = target.split('/');\n while (s.length && s[0] === t[0]){\n s.shift();\n t.shift();\n }\n for (var i = 0, l = s.length - 1; i < l; i++) {\n t.unshift('..');\n }\n return t.join('/') + targetUrl.search + targetUrl.hash;\n}\n\n// exports\nscope.urlResolver = urlResolver;\n\n})(Platform);\n","/*\n * Copyright 2012 The Polymer Authors. All rights reserved.\n * Use of this source code is goverened by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(global) {\n\n var registrationsTable = new WeakMap();\n\n // We use setImmediate or postMessage for our future callback.\n var setImmediate = window.msSetImmediate;\n\n // Use post message to emulate setImmediate.\n if (!setImmediate) {\n var setImmediateQueue = [];\n var sentinel = String(Math.random());\n window.addEventListener('message', function(e) {\n if (e.data === sentinel) {\n var queue = setImmediateQueue;\n setImmediateQueue = [];\n queue.forEach(function(func) {\n func();\n });\n }\n });\n setImmediate = function(func) {\n setImmediateQueue.push(func);\n window.postMessage(sentinel, '*');\n };\n }\n\n // This is used to ensure that we never schedule 2 callas to setImmediate\n var isScheduled = false;\n\n // Keep track of observers that needs to be notified next time.\n var scheduledObservers = [];\n\n /**\n * Schedules |dispatchCallback| to be called in the future.\n * @param {MutationObserver} observer\n */\n function scheduleCallback(observer) {\n scheduledObservers.push(observer);\n if (!isScheduled) {\n isScheduled = true;\n setImmediate(dispatchCallbacks);\n }\n }\n\n function wrapIfNeeded(node) {\n return window.ShadowDOMPolyfill &&\n window.ShadowDOMPolyfill.wrapIfNeeded(node) ||\n node;\n }\n\n function dispatchCallbacks() {\n // http://dom.spec.whatwg.org/#mutation-observers\n\n isScheduled = false; // Used to allow a new setImmediate call above.\n\n var observers = scheduledObservers;\n scheduledObservers = [];\n // Sort observers based on their creation UID (incremental).\n observers.sort(function(o1, o2) {\n return o1.uid_ - o2.uid_;\n });\n\n var anyNonEmpty = false;\n observers.forEach(function(observer) {\n\n // 2.1, 2.2\n var queue = observer.takeRecords();\n // 2.3. Remove all transient registered observers whose observer is mo.\n removeTransientObserversFor(observer);\n\n // 2.4\n if (queue.length) {\n observer.callback_(queue, observer);\n anyNonEmpty = true;\n }\n });\n\n // 3.\n if (anyNonEmpty)\n dispatchCallbacks();\n }\n\n function removeTransientObserversFor(observer) {\n observer.nodes_.forEach(function(node) {\n var registrations = registrationsTable.get(node);\n if (!registrations)\n return;\n registrations.forEach(function(registration) {\n if (registration.observer === observer)\n registration.removeTransientObservers();\n });\n });\n }\n\n /**\n * This function is used for the \"For each registered observer observer (with\n * observer's options as options) in target's list of registered observers,\n * run these substeps:\" and the \"For each ancestor ancestor of target, and for\n * each registered observer observer (with options options) in ancestor's list\n * of registered observers, run these substeps:\" part of the algorithms. The\n * |options.subtree| is checked to ensure that the callback is called\n * correctly.\n *\n * @param {Node} target\n * @param {function(MutationObserverInit):MutationRecord} callback\n */\n function forEachAncestorAndObserverEnqueueRecord(target, callback) {\n for (var node = target; node; node = node.parentNode) {\n var registrations = registrationsTable.get(node);\n\n if (registrations) {\n for (var j = 0; j < registrations.length; j++) {\n var registration = registrations[j];\n var options = registration.options;\n\n // Only target ignores subtree.\n if (node !== target && !options.subtree)\n continue;\n\n var record = callback(options);\n if (record)\n registration.enqueue(record);\n }\n }\n }\n }\n\n var uidCounter = 0;\n\n /**\n * The class that maps to the DOM MutationObserver interface.\n * @param {Function} callback.\n * @constructor\n */\n function JsMutationObserver(callback) {\n this.callback_ = callback;\n this.nodes_ = [];\n this.records_ = [];\n this.uid_ = ++uidCounter;\n }\n\n JsMutationObserver.prototype = {\n observe: function(target, options) {\n target = wrapIfNeeded(target);\n\n // 1.1\n if (!options.childList && !options.attributes && !options.characterData ||\n\n // 1.2\n options.attributeOldValue && !options.attributes ||\n\n // 1.3\n options.attributeFilter && options.attributeFilter.length &&\n !options.attributes ||\n\n // 1.4\n options.characterDataOldValue && !options.characterData) {\n\n throw new SyntaxError();\n }\n\n var registrations = registrationsTable.get(target);\n if (!registrations)\n registrationsTable.set(target, registrations = []);\n\n // 2\n // If target's list of registered observers already includes a registered\n // observer associated with the context object, replace that registered\n // observer's options with options.\n var registration;\n for (var i = 0; i < registrations.length; i++) {\n if (registrations[i].observer === this) {\n registration = registrations[i];\n registration.removeListeners();\n registration.options = options;\n break;\n }\n }\n\n // 3.\n // Otherwise, add a new registered observer to target's list of registered\n // observers with the context object as the observer and options as the\n // options, and add target to context object's list of nodes on which it\n // is registered.\n if (!registration) {\n registration = new Registration(this, target, options);\n registrations.push(registration);\n this.nodes_.push(target);\n }\n\n registration.addListeners();\n },\n\n disconnect: function() {\n this.nodes_.forEach(function(node) {\n var registrations = registrationsTable.get(node);\n for (var i = 0; i < registrations.length; i++) {\n var registration = registrations[i];\n if (registration.observer === this) {\n registration.removeListeners();\n registrations.splice(i, 1);\n // Each node can only have one registered observer associated with\n // this observer.\n break;\n }\n }\n }, this);\n this.records_ = [];\n },\n\n takeRecords: function() {\n var copyOfRecords = this.records_;\n this.records_ = [];\n return copyOfRecords;\n }\n };\n\n /**\n * @param {string} type\n * @param {Node} target\n * @constructor\n */\n function MutationRecord(type, target) {\n this.type = type;\n this.target = target;\n this.addedNodes = [];\n this.removedNodes = [];\n this.previousSibling = null;\n this.nextSibling = null;\n this.attributeName = null;\n this.attributeNamespace = null;\n this.oldValue = null;\n }\n\n function copyMutationRecord(original) {\n var record = new MutationRecord(original.type, original.target);\n record.addedNodes = original.addedNodes.slice();\n record.removedNodes = original.removedNodes.slice();\n record.previousSibling = original.previousSibling;\n record.nextSibling = original.nextSibling;\n record.attributeName = original.attributeName;\n record.attributeNamespace = original.attributeNamespace;\n record.oldValue = original.oldValue;\n return record;\n };\n\n // We keep track of the two (possibly one) records used in a single mutation.\n var currentRecord, recordWithOldValue;\n\n /**\n * Creates a record without |oldValue| and caches it as |currentRecord| for\n * later use.\n * @param {string} oldValue\n * @return {MutationRecord}\n */\n function getRecord(type, target) {\n return currentRecord = new MutationRecord(type, target);\n }\n\n /**\n * Gets or creates a record with |oldValue| based in the |currentRecord|\n * @param {string} oldValue\n * @return {MutationRecord}\n */\n function getRecordWithOldValue(oldValue) {\n if (recordWithOldValue)\n return recordWithOldValue;\n recordWithOldValue = copyMutationRecord(currentRecord);\n recordWithOldValue.oldValue = oldValue;\n return recordWithOldValue;\n }\n\n function clearRecords() {\n currentRecord = recordWithOldValue = undefined;\n }\n\n /**\n * @param {MutationRecord} record\n * @return {boolean} Whether the record represents a record from the current\n * mutation event.\n */\n function recordRepresentsCurrentMutation(record) {\n return record === recordWithOldValue || record === currentRecord;\n }\n\n /**\n * Selects which record, if any, to replace the last record in the queue.\n * This returns |null| if no record should be replaced.\n *\n * @param {MutationRecord} lastRecord\n * @param {MutationRecord} newRecord\n * @param {MutationRecord}\n */\n function selectRecord(lastRecord, newRecord) {\n if (lastRecord === newRecord)\n return lastRecord;\n\n // Check if the the record we are adding represents the same record. If\n // so, we keep the one with the oldValue in it.\n if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord))\n return recordWithOldValue;\n\n return null;\n }\n\n /**\n * Class used to represent a registered observer.\n * @param {MutationObserver} observer\n * @param {Node} target\n * @param {MutationObserverInit} options\n * @constructor\n */\n function Registration(observer, target, options) {\n this.observer = observer;\n this.target = target;\n this.options = options;\n this.transientObservedNodes = [];\n }\n\n Registration.prototype = {\n enqueue: function(record) {\n var records = this.observer.records_;\n var length = records.length;\n\n // There are cases where we replace the last record with the new record.\n // For example if the record represents the same mutation we need to use\n // the one with the oldValue. If we get same record (this can happen as we\n // walk up the tree) we ignore the new record.\n if (records.length > 0) {\n var lastRecord = records[length - 1];\n var recordToReplaceLast = selectRecord(lastRecord, record);\n if (recordToReplaceLast) {\n records[length - 1] = recordToReplaceLast;\n return;\n }\n } else {\n scheduleCallback(this.observer);\n }\n\n records[length] = record;\n },\n\n addListeners: function() {\n this.addListeners_(this.target);\n },\n\n addListeners_: function(node) {\n var options = this.options;\n if (options.attributes)\n node.addEventListener('DOMAttrModified', this, true);\n\n if (options.characterData)\n node.addEventListener('DOMCharacterDataModified', this, true);\n\n if (options.childList)\n node.addEventListener('DOMNodeInserted', this, true);\n\n if (options.childList || options.subtree)\n node.addEventListener('DOMNodeRemoved', this, true);\n },\n\n removeListeners: function() {\n this.removeListeners_(this.target);\n },\n\n removeListeners_: function(node) {\n var options = this.options;\n if (options.attributes)\n node.removeEventListener('DOMAttrModified', this, true);\n\n if (options.characterData)\n node.removeEventListener('DOMCharacterDataModified', this, true);\n\n if (options.childList)\n node.removeEventListener('DOMNodeInserted', this, true);\n\n if (options.childList || options.subtree)\n node.removeEventListener('DOMNodeRemoved', this, true);\n },\n\n /**\n * Adds a transient observer on node. The transient observer gets removed\n * next time we deliver the change records.\n * @param {Node} node\n */\n addTransientObserver: function(node) {\n // Don't add transient observers on the target itself. We already have all\n // the required listeners set up on the target.\n if (node === this.target)\n return;\n\n this.addListeners_(node);\n this.transientObservedNodes.push(node);\n var registrations = registrationsTable.get(node);\n if (!registrations)\n registrationsTable.set(node, registrations = []);\n\n // We know that registrations does not contain this because we already\n // checked if node === this.target.\n registrations.push(this);\n },\n\n removeTransientObservers: function() {\n var transientObservedNodes = this.transientObservedNodes;\n this.transientObservedNodes = [];\n\n transientObservedNodes.forEach(function(node) {\n // Transient observers are never added to the target.\n this.removeListeners_(node);\n\n var registrations = registrationsTable.get(node);\n for (var i = 0; i < registrations.length; i++) {\n if (registrations[i] === this) {\n registrations.splice(i, 1);\n // Each node can only have one registered observer associated with\n // this observer.\n break;\n }\n }\n }, this);\n },\n\n handleEvent: function(e) {\n // Stop propagation since we are managing the propagation manually.\n // This means that other mutation events on the page will not work\n // correctly but that is by design.\n e.stopImmediatePropagation();\n\n switch (e.type) {\n case 'DOMAttrModified':\n // http://dom.spec.whatwg.org/#concept-mo-queue-attributes\n\n var name = e.attrName;\n var namespace = e.relatedNode.namespaceURI;\n var target = e.target;\n\n // 1.\n var record = new getRecord('attributes', target);\n record.attributeName = name;\n record.attributeNamespace = namespace;\n\n // 2.\n var oldValue =\n e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;\n\n forEachAncestorAndObserverEnqueueRecord(target, function(options) {\n // 3.1, 4.2\n if (!options.attributes)\n return;\n\n // 3.2, 4.3\n if (options.attributeFilter && options.attributeFilter.length &&\n options.attributeFilter.indexOf(name) === -1 &&\n options.attributeFilter.indexOf(namespace) === -1) {\n return;\n }\n // 3.3, 4.4\n if (options.attributeOldValue)\n return getRecordWithOldValue(oldValue);\n\n // 3.4, 4.5\n return record;\n });\n\n break;\n\n case 'DOMCharacterDataModified':\n // http://dom.spec.whatwg.org/#concept-mo-queue-characterdata\n var target = e.target;\n\n // 1.\n var record = getRecord('characterData', target);\n\n // 2.\n var oldValue = e.prevValue;\n\n\n forEachAncestorAndObserverEnqueueRecord(target, function(options) {\n // 3.1, 4.2\n if (!options.characterData)\n return;\n\n // 3.2, 4.3\n if (options.characterDataOldValue)\n return getRecordWithOldValue(oldValue);\n\n // 3.3, 4.4\n return record;\n });\n\n break;\n\n case 'DOMNodeRemoved':\n this.addTransientObserver(e.target);\n // Fall through.\n case 'DOMNodeInserted':\n // http://dom.spec.whatwg.org/#concept-mo-queue-childlist\n var target = e.relatedNode;\n var changedNode = e.target;\n var addedNodes, removedNodes;\n if (e.type === 'DOMNodeInserted') {\n addedNodes = [changedNode];\n removedNodes = [];\n } else {\n\n addedNodes = [];\n removedNodes = [changedNode];\n }\n var previousSibling = changedNode.previousSibling;\n var nextSibling = changedNode.nextSibling;\n\n // 1.\n var record = getRecord('childList', target);\n record.addedNodes = addedNodes;\n record.removedNodes = removedNodes;\n record.previousSibling = previousSibling;\n record.nextSibling = nextSibling;\n\n forEachAncestorAndObserverEnqueueRecord(target, function(options) {\n // 2.1, 3.2\n if (!options.childList)\n return;\n\n // 2.2, 3.3\n return record;\n });\n\n }\n\n clearRecords();\n }\n };\n\n global.JsMutationObserver = JsMutationObserver;\n\n if (!global.MutationObserver)\n global.MutationObserver = JsMutationObserver;\n\n\n})(this);\n","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\nwindow.HTMLImports = window.HTMLImports || {flags:{}};","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n\n // imports\n var path = scope.path;\n var xhr = scope.xhr;\n var flags = scope.flags;\n\n // TODO(sorvell): this loader supports a dynamic list of urls\n // and an oncomplete callback that is called when the loader is done.\n // The polyfill currently does *not* need this dynamism or the onComplete\n // concept. Because of this, the loader could be simplified quite a bit.\n var Loader = function(onLoad, onComplete) {\n this.cache = {};\n this.onload = onLoad;\n this.oncomplete = onComplete;\n this.inflight = 0;\n this.pending = {};\n };\n\n Loader.prototype = {\n addNodes: function(nodes) {\n // number of transactions to complete\n this.inflight += nodes.length;\n // commence transactions\n for (var i=0, l=nodes.length, n; (i -1) {\n body = atob(body);\n } else {\n body = decodeURIComponent(body);\n }\n setTimeout(function() {\n this.receive(url, elt, null, body);\n }.bind(this), 0);\n } else {\n var receiveXhr = function(err, resource, redirectedUrl) {\n this.receive(url, elt, err, resource, redirectedUrl);\n }.bind(this);\n xhr.load(url, receiveXhr);\n // TODO(sorvell): blocked on)\n // https://code.google.com/p/chromium/issues/detail?id=257221\n // xhr'ing for a document makes scripts in imports runnable; otherwise\n // they are not; however, it requires that we have doctype=html in\n // the import which is unacceptable. This is only needed on Chrome\n // to avoid the bug above.\n /*\n if (isDocumentLink(elt)) {\n xhr.loadDocument(url, receiveXhr);\n } else {\n xhr.load(url, receiveXhr);\n }\n */\n }\n },\n receive: function(url, elt, err, resource, redirectedUrl) {\n this.cache[url] = resource;\n var $p = this.pending[url];\n if ( redirectedUrl && redirectedUrl !== url ) {\n this.cache[redirectedUrl] = resource;\n $p = $p.concat(this.pending[redirectedUrl]);\n }\n for (var i=0, l=$p.length, p; (i= 200 && request.status < 300)\n || (request.status === 304)\n || (request.status === 0);\n },\n load: function(url, next, nextContext) {\n var request = new XMLHttpRequest();\n if (scope.flags.debug || scope.flags.bust) {\n url += '?' + Math.random();\n }\n request.open('GET', url, xhr.async);\n request.addEventListener('readystatechange', function(e) {\n if (request.readyState === 4) {\n // Servers redirecting an import can add a Location header to help us\n // polyfill correctly.\n var locationHeader = request.getResponseHeader(\"Location\");\n var redirectedUrl = null;\n if (locationHeader) {\n var redirectedUrl = (locationHeader.substr( 0, 1 ) === \"/\")\n ? location.origin + locationHeader // Location is a relative path\n : redirectedUrl; // Full path\n }\n next.call(nextContext, !xhr.ok(request) && request,\n request.response || request.responseText, redirectedUrl);\n }\n });\n request.send();\n return request;\n },\n loadDocument: function(url, next, nextContext) {\n this.load(url, next, nextContext).responseType = 'document';\n }\n };\n\n // exports\n scope.xhr = xhr;\n scope.Loader = Loader;\n\n})(window.HTMLImports);\n","/*\n * Copyright 2013 The Polymer Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style\n * license that can be found in the LICENSE file.\n */\n\n(function(scope) {\n\nvar IMPORT_LINK_TYPE = 'import';\nvar flags = scope.flags;\nvar isIe = /Trident/.test(navigator.userAgent);\n// TODO(sorvell): SD polyfill intrusion\nvar mainDoc = window.ShadowDOMPolyfill ? \n window.ShadowDOMPolyfill.wrapIfNeeded(document) : document;\n\n// importParser\n// highlander object to manage parsing of imports\n// parses import related elements\n// and ensures proper parse order\n// parse order is enforced by crawling the tree and monitoring which elements\n// have been parsed; async parsing is also supported.\n\n// highlander object for parsing a document tree\nvar importParser = {\n // parse selectors for main document elements\n documentSelectors: 'link[rel=' + IMPORT_LINK_TYPE + ']',\n // parse selectors for import document elements\n importsSelectors: [\n 'link[rel=' + IMPORT_LINK_TYPE + ']',\n 'link[rel=stylesheet]',\n 'style',\n 'script:not([type])',\n 'script[type=\"text/javascript\"]'\n ].join(','),\n map: {\n link: 'parseLink',\n script: 'parseScript',\n style: 'parseStyle'\n },\n // try to parse the next import in the tree\n parseNext: function() {\n var next = this.nextToParse();\n if (next) {\n this.parse(next);\n }\n },\n parse: function(elt) {\n if (this.isParsed(elt)) {\n flags.parse && console.log('[%s] is already parsed', elt.localName);\n return;\n }\n var fn = this[this.map[elt.localName]];\n if (fn) {\n this.markParsing(elt);\n fn.call(this, elt);\n }\n },\n // only 1 element may be parsed at a time; parsing is async so each\n // parsing implementation must inform the system that parsing is complete\n // via markParsingComplete.\n // To prompt the system to parse the next element, parseNext should then be\n // called.\n // Note, parseNext used to be included at the end of markParsingComplete, but\n // we must not do this so that, for example, we can (1) mark parsing complete \n // then (2) fire an import load event, and then (3) parse the next resource.\n markParsing: function(elt) {\n flags.parse && console.log('parsing', elt);\n this.parsingElement = elt;\n },\n markParsingComplete: function(elt) {\n elt.__importParsed = true;\n if (elt.__importElement) {\n elt.__importElement.__importParsed = true;\n }\n this.parsingElement = null;\n flags.parse && console.log('completed', elt);\n },\n invalidateParse: function(doc) {\n if (doc && doc.__importLink) {\n doc.__importParsed = doc.__importLink.__importParsed = false;\n this.parseSoon();\n }\n },\n parseSoon: function() {\n if (this._parseSoon) {\n cancelAnimationFrame(this._parseDelay);\n }\n var parser = this;\n this._parseSoon = requestAnimationFrame(function() {\n parser.parseNext();\n });\n },\n parseImport: function(elt) {\n // TODO(sorvell): consider if there's a better way to do this;\n // expose an imports parsing hook; this is needed, for example, by the\n // CustomElements polyfill.\n if (HTMLImports.__importsParsingHook) {\n HTMLImports.__importsParsingHook(elt);\n }\n elt.import.__importParsed = true;\n this.markParsingComplete(elt);\n // fire load event\n if (elt.__resource) {\n elt.dispatchEvent(new CustomEvent('load', {bubbles: false})); \n } else {\n elt.dispatchEvent(new CustomEvent('error', {bubbles: false}));\n }\n // TODO(sorvell): workaround for Safari addEventListener not working\n // for elements not in the main document.\n if (elt.__pending) {\n var fn;\n while (elt.__pending.length) {\n fn = elt.__pending.shift();\n if (fn) {\n fn({target: elt});\n }\n }\n }\n this.parseNext();\n },\n parseLink: function(linkElt) {\n if (nodeIsImport(linkElt)) {\n this.parseImport(linkElt);\n } else {\n // make href absolute\n linkElt.href = linkElt.href;\n this.parseGeneric(linkElt);\n }\n },\n parseStyle: function(elt) {\n // TODO(sorvell): style element load event can just not fire so clone styles\n var src = elt;\n elt = cloneStyle(elt);\n elt.__importElement = src;\n this.parseGeneric(elt);\n },\n parseGeneric: function(elt) {\n this.trackElement(elt);\n this.addElementToDocument(elt);\n },\n rootImportForElement: function(elt) {\n var n = elt;\n while (n.ownerDocument.__importLink) {\n n = n.ownerDocument.__importLink;\n }\n return n;\n },\n addElementToDocument: function(elt) {\n var port = this.rootImportForElement(elt.__importElement || elt);\n var l = port.__insertedElements = port.__insertedElements || 0;\n var refNode = port.nextElementSibling;\n for (var i=0; i < l; i++) {\n refNode = refNode && refNode.nextElementSibling;\n }\n port.parentNode.insertBefore(elt, refNode);\n },\n // tracks when a loadable element has loaded\n trackElement: function(elt, callback) {\n var self = this;\n var done = function(e) {\n if (callback) {\n callback(e);\n }\n self.markParsingComplete(elt);\n self.parseNext();\n };\n elt.addEventListener('load', done);\n elt.addEventListener('error', done);\n\n // NOTE: IE does not fire \"load\" event for styles that have already loaded\n // This is in violation of the spec, so we try our hardest to work around it\n if (isIe && elt.localName === 'style') {\n var fakeLoad = false;\n // If there's not @import in the textContent, assume it has loaded\n if (elt.textContent.indexOf('@import') == -1) {\n fakeLoad = true;\n // if we have a sheet, we have been parsed\n } else if (elt.sheet) {\n fakeLoad = true;\n var csr = elt.sheet.cssRules;\n var len = csr ? csr.length : 0;\n // search the rules for @import's\n for (var i = 0, r; (i < len) && (r = csr[i]); i++) {\n if (r.type === CSSRule.IMPORT_RULE) {\n // if every @import has resolved, fake the load\n fakeLoad = fakeLoad && Boolean(r.styleSheet);\n }\n }\n }\n // dispatch a fake load event and continue parsing\n if (fakeLoad) {\n elt.dispatchEvent(new CustomEvent('load', {bubbles: false}));\n }\n }\n },\n // NOTE: execute scripts by injecting them and watching for the load/error\n // event. Inline scripts are handled via dataURL's because browsers tend to\n // provide correct parsing errors in this case. If this has any compatibility\n // issues, we can switch to injecting the inline script with textContent.\n // Scripts with dataURL's do not appear to generate load events and therefore\n // we assume they execute synchronously.\n parseScript: function(scriptElt) {\n var script = document.createElement('script');\n script.__importElement = scriptElt;\n script.src = scriptElt.src ? scriptElt.src : \n generateScriptDataUrl(scriptElt);\n scope.currentScript = scriptElt;\n this.trackElement(script, function(e) {\n script.parentNode.removeChild(script);\n scope.currentScript = null; \n });\n this.addElementToDocument(script);\n },\n // determine the next element in the tree which should be parsed\n nextToParse: function() {\n return !this.parsingElement && this.nextToParseInDoc(mainDoc);\n },\n nextToParseInDoc: function(doc, link) {\n var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));\n for (var i=0, l=nodes.length, p=0, n; (i.content\n // see https://code.google.com/p/chromium/issues/detail?id=249381.\n elt.__resource = resource;\n if (isDocumentLink(elt)) {\n var doc = this.documents[url];\n // if we've never seen a document at this url\n if (!doc) {\n // generate an HTMLDocument from data\n doc = makeDocument(resource, url);\n doc.__importLink = elt;\n // TODO(sorvell): we cannot use MO to detect parsed nodes because\n // SD polyfill does not report these as mutations.\n this.bootDocument(doc);\n // cache document\n this.documents[url] = doc;\n }\n // don't store import record until we're actually loaded\n // store document resource\n elt.import = doc;\n }\n parser.parseNext();\n },\n bootDocument: function(doc) {\n this.loadSubtree(doc);\n this.observe(doc);\n parser.parseNext();\n },\n loadedAll: function() {\n parser.parseNext();\n }\n };\n\n // loader singleton\n var importLoader = new Loader(importer.loaded.bind(importer), \n importer.loadedAll.bind(importer));\n\n function isDocumentLink(elt) {\n return isLinkRel(elt, IMPORT_LINK_TYPE);\n }\n\n function isLinkRel(elt, rel) {\n return elt.localName === 'link' && elt.getAttribute('rel') === rel;\n }\n\n function isScript(elt) {\n return elt.localName === 'script';\n }\n\n function makeDocument(resource, url) {\n // create a new HTML document\n var doc = resource;\n if (!(doc instanceof Document)) {\n doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);\n }\n // cache the new document's source url\n doc._URL = url;\n // establish a relative path via \n var base = doc.createElement('base');\n base.setAttribute('href', url);\n // add baseURI support to browsers (IE) that lack it.\n if (!doc.baseURI) {\n doc.baseURI = url;\n }\n // ensure UTF-8 charset\n var meta = doc.createElement('meta');\n meta.setAttribute('charset', 'utf-8');\n\n doc.head.appendChild(meta);\n doc.head.appendChild(base);\n // install HTML last as it may trigger CustomElement upgrades\n // TODO(sjmiles): problem wrt to template boostrapping below,\n // template bootstrapping must (?) come before element upgrade\n // but we cannot bootstrap templates until they are in a document\n // which is too late\n if (!(resource instanceof Document)) {\n // install html\n doc.body.innerHTML = resource;\n }\n // TODO(sorvell): ideally this code is not aware of Template polyfill,\n // but for now the polyfill needs help to bootstrap these templates\n if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {\n HTMLTemplateElement.bootstrap(doc);\n }\n return doc;\n }\n} else {\n // do nothing if using native imports\n var importer = {};\n}\n\n// NOTE: We cannot polyfill document.currentScript because it's not possible\n// both to override and maintain the ability to capture the native value;\n// therefore we choose to expose _currentScript both when native imports\n// and the polyfill are in use.\nvar currentScriptDescriptor = {\n get: function() {\n return HTMLImports.currentScript || document.currentScript;\n },\n configurable: true\n};\n\nObject.defineProperty(document, '_currentScript', currentScriptDescriptor);\nObject.defineProperty(mainDoc, '_currentScript', currentScriptDescriptor);\n\n// Polyfill document.baseURI for browsers without it.\nif (!document.baseURI) {\n var baseURIDescriptor = {\n get: function() {\n return window.location.href;\n },\n configurable: true\n };\n\n Object.defineProperty(document, 'baseURI', baseURIDescriptor);\n Object.defineProperty(mainDoc, 'baseURI', baseURIDescriptor);\n}\n\n// call a callback when all HTMLImports in the document at call (or at least\n// document ready) time have loaded.\n// 1. ensure the document is in a ready state (has dom), then \n// 2. watch for loading of imports and call callback when done\nfunction whenImportsReady(callback, doc) {\n doc = doc || mainDoc;\n // if document is loading, wait and try again\n whenDocumentReady(function() {\n watchImportsLoad(callback, doc);\n }, doc);\n}\n\n// call the callback when the document is in a ready state (has dom)\nvar requiredReadyState = HTMLImports.isIE ? 'complete' : 'interactive';\nvar READY_EVENT = 'readystatechange';\nfunction isDocumentReady(doc) {\n return (doc.readyState === 'complete' ||\n doc.readyState === requiredReadyState);\n}\n\n// call when we ensure the document is in a ready state\nfunction whenDocumentReady(callback, doc) {\n if (!isDocumentReady(doc)) {\n var checkReady = function() {\n if (doc.readyState === 'complete' || \n doc.readyState === requiredReadyState) {\n doc.removeEventListener(READY_EVENT, checkReady);\n whenDocumentReady(callback, doc);\n }\n }\n doc.addEventListener(READY_EVENT, checkReady);\n } else if (callback) {\n callback();\n }\n}\n\n// call when we ensure all imports have loaded\nfunction watchImportsLoad(callback, doc) {\n var imports = doc.querySelectorAll('link[rel=import]');\n var loaded = 0, l = imports.length;\n function checkDone(d) { \n if (loaded == l) {\n callback && callback();\n }\n }\n function loadedImport(e) {\n loaded++;\n checkDone();\n }\n if (l) {\n for (var i=0, imp; (i 1) {\r\n logFlags.dom && console.warn('inserted:', element.localName,\r\n 'insert/remove count:', element.__inserted)\r\n } else if (element.attachedCallback) {\r\n logFlags.dom && console.log('inserted:', element.localName);\r\n element.attachedCallback();\r\n }\r\n }\r\n logFlags.dom && console.groupEnd();\r\n }\r\n}\r\n\r\nfunction removedNode(node) {\r\n removed(node);\r\n forSubtree(node, function(e) {\r\n removed(e);\r\n });\r\n}\r\n\r\nfunction removed(element) {\r\n if (hasPolyfillMutations) {\r\n deferMutation(function() {\r\n _removed(element);\r\n });\r\n } else {\r\n _removed(element);\r\n }\r\n}\r\n\r\nfunction _removed(element) {\r\n // TODO(sjmiles): temporary: do work on all custom elements so we can track\r\n // behavior even when callbacks not defined\r\n if (element.attachedCallback || element.detachedCallback || (element.__upgraded__ && logFlags.dom)) {\r\n logFlags.dom && console.group('removed:', element.localName);\r\n if (!inDocument(element)) {\r\n element.__inserted = (element.__inserted || 0) - 1;\r\n // if we are in a 'inserted' state, bluntly adjust to an 'removed' state\r\n if (element.__inserted > 0) {\r\n element.__inserted = 0;\r\n }\r\n // if we are 'over removed', squelch the callback\r\n if (element.__inserted < 0) {\r\n logFlags.dom && console.warn('removed:', element.localName,\r\n 'insert/remove count:', element.__inserted)\r\n } else if (element.detachedCallback) {\r\n element.detachedCallback();\r\n }\r\n }\r\n logFlags.dom && console.groupEnd();\r\n }\r\n}\r\n\r\n// SD polyfill intrustion due mainly to the fact that 'document'\r\n// is not entirely wrapped\r\nfunction wrapIfNeeded(node) {\r\n return window.ShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node)\r\n : node;\r\n}\r\n\r\nfunction inDocument(element) {\r\n var p = element;\r\n var doc = wrapIfNeeded(document);\r\n while (p) {\r\n if (p == doc) {\r\n return true;\r\n }\r\n p = p.parentNode || p.host;\r\n }\r\n}\r\n\r\nfunction watchShadow(node) {\r\n if (node.shadowRoot && !node.shadowRoot.__watched) {\r\n logFlags.dom && console.log('watching shadow-root for: ', node.localName);\r\n // watch all unwatched roots...\r\n var root = node.shadowRoot;\r\n while (root) {\r\n watchRoot(root);\r\n root = root.olderShadowRoot;\r\n }\r\n }\r\n}\r\n\r\nfunction watchRoot(root) {\r\n if (!root.__watched) {\r\n observe(root);\r\n root.__watched = true;\r\n }\r\n}\r\n\r\nfunction handler(mutations) {\r\n //\r\n if (logFlags.dom) {\r\n var mx = mutations[0];\r\n if (mx && mx.type === 'childList' && mx.addedNodes) {\r\n if (mx.addedNodes) {\r\n var d = mx.addedNodes[0];\r\n while (d && d !== document && !d.host) {\r\n d = d.parentNode;\r\n }\r\n var u = d && (d.URL || d._URL || (d.host && d.host.localName)) || '';\r\n u = u.split('/?').shift().split('/').pop();\r\n }\r\n }\r\n console.group('mutations (%d) [%s]', mutations.length, u || '');\r\n }\r\n //\r\n mutations.forEach(function(mx) {\r\n //logFlags.dom && console.group('mutation');\r\n if (mx.type === 'childList') {\r\n forEach(mx.addedNodes, function(n) {\r\n //logFlags.dom && console.log(n.localName);\r\n if (!n.localName) {\r\n return;\r\n }\r\n // nodes added may need lifecycle management\r\n addedNode(n);\r\n });\r\n // removed nodes may need lifecycle management\r\n forEach(mx.removedNodes, function(n) {\r\n //logFlags.dom && console.log(n.localName);\r\n if (!n.localName) {\r\n return;\r\n }\r\n removedNode(n);\r\n });\r\n }\r\n //logFlags.dom && console.groupEnd();\r\n });\r\n logFlags.dom && console.groupEnd();\r\n};\r\n\r\nvar observer = new MutationObserver(handler);\r\n\r\nfunction takeRecords() {\r\n // TODO(sjmiles): ask Raf why we have to call handler ourselves\r\n handler(observer.takeRecords());\r\n takeMutations();\r\n}\r\n\r\nvar forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);\r\n\r\nfunction observe(inRoot) {\r\n observer.observe(inRoot, {childList: true, subtree: true});\r\n}\r\n\r\nfunction observeDocument(doc) {\r\n observe(doc);\r\n}\r\n\r\nfunction upgradeDocument(doc) {\r\n logFlags.dom && console.group('upgradeDocument: ', (doc.baseURI).split('/').pop());\r\n addedNode(doc);\r\n logFlags.dom && console.groupEnd();\r\n}\r\n\r\nfunction upgradeDocumentTree(doc) {\r\n doc = wrapIfNeeded(doc);\r\n //console.log('upgradeDocumentTree: ', (doc.baseURI).split('/').pop());\r\n // upgrade contained imported documents\r\n var imports = doc.querySelectorAll('link[rel=' + IMPORT_LINK_TYPE + ']');\r\n for (var i=0, l=imports.length, n; (i= 0) {\n implement(element, HTMLElement);\n }\n return element;\n }\n\n function upgradeElement(element) {\n if (!element.__upgraded__ && (element.nodeType === Node.ELEMENT_NODE)) {\n var is = element.getAttribute('is');\n var definition = getRegisteredDefinition(is || element.localName);\n if (definition) {\n if (is && definition.tag == element.localName) {\n return upgrade(element, definition);\n } else if (!is && !definition.extends) {\n return upgrade(element, definition);\n }\n }\n }\n }\n\n function cloneNode(deep) {\n // call original clone\n var n = domCloneNode.call(this, deep);\n // upgrade the element and subtree\n scope.upgradeAll(n);\n // return the clone\n return n;\n }\n // capture native createElement before we override it\n\n var domCreateElement = document.createElement.bind(document);\n var domCreateElementNS = document.createElementNS.bind(document);\n\n // capture native cloneNode before we override it\n\n var domCloneNode = Node.prototype.cloneNode;\n\n // exports\n\n document.registerElement = register;\n document.createElement = createElement; // override\n document.createElementNS = createElementNS; // override\n Node.prototype.cloneNode = cloneNode; // override\n\n scope.registry = registry;\n\n /**\n * Upgrade an element to a custom element. Upgrading an element\n * causes the custom prototype to be applied, an `is` attribute\n * to be attached (as needed), and invocation of the `readyCallback`.\n * `upgrade` does nothing if the element is already upgraded, or\n * if it matches no registered custom tag name.\n *\n * @method ugprade\n * @param {Element} element The element to upgrade.\n * @return {Element} The upgraded element.\n */\n scope.upgrade = upgradeElement;\n}\n\n// Create a custom 'instanceof'. This is necessary when CustomElements\n// are implemented via a mixin strategy, as for example on IE10.\nvar isInstance;\nif (!Object.__proto__ && !useNative) {\n isInstance = function(obj, ctor) {\n var p = obj;\n while (p) {\n // NOTE: this is not technically correct since we're not checking if\n // an object is an instance of a constructor; however, this should\n // be good enough for the mixin strategy.\n if (p === ctor.prototype) {\n return true;\n }\n p = p.__proto__;\n }\n return false;\n }\n} else {\n isInstance = function(obj, base) {\n return obj instanceof base;\n }\n}\n\n// exports\nscope.instanceof = isInstance;\nscope.reservedTagList = reservedTagList;\n\n// bc\ndocument.register = document.registerElement;\n\nscope.hasNative = hasNative;\nscope.useNative = useNative;\n\n})(window.CustomElements);\n","/*\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// import\n\nvar IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;\n\n// highlander object for parsing a document tree\n\nvar parser = {\n selectors: [\n 'link[rel=' + IMPORT_LINK_TYPE + ']'\n ],\n map: {\n link: 'parseLink'\n },\n parse: function(inDocument) {\n if (!inDocument.__parsed) {\n // only parse once\n inDocument.__parsed = true;\n // all parsable elements in inDocument (depth-first pre-order traversal)\n var elts = inDocument.querySelectorAll(parser.selectors);\n // for each parsable node type, call the mapped parsing method\n forEach(elts, function(e) {\n parser[parser.map[e.localName]](e);\n });\n // upgrade all upgradeable static elements, anything dynamically\n // created should be caught by observer\n CustomElements.upgradeDocument(inDocument);\n // observe document for dom changes\n CustomElements.observeDocument(inDocument);\n }\n },\n parseLink: function(linkElt) {\n // imports\n if (isDocumentLink(linkElt)) {\n this.parseImport(linkElt);\n }\n },\n parseImport: function(linkElt) {\n if (linkElt.import) {\n parser.parse(linkElt.import);\n }\n }\n};\n\nfunction isDocumentLink(inElt) {\n return (inElt.localName === 'link'\n && inElt.getAttribute('rel') === IMPORT_LINK_TYPE);\n}\n\nvar forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);\n\n// exports\n\nscope.parser = parser;\nscope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;\n\n})(window.CustomElements);","/*\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(function(scope){\n\n// bootstrap parsing\nfunction bootstrap() {\n // parse document\n CustomElements.parser.parse(document);\n // one more pass before register is 'live'\n CustomElements.upgradeDocument(document);\n // choose async\n var async = window.Platform && Platform.endOfMicrotask ? \n Platform.endOfMicrotask :\n setTimeout;\n async(function() {\n // set internal 'ready' flag, now document.registerElement will trigger \n // synchronous upgrades\n CustomElements.ready = true;\n // capture blunt profiling data\n CustomElements.readyTime = Date.now();\n if (window.HTMLImports) {\n CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;\n }\n // notify the system that we are bootstrapped\n document.dispatchEvent(\n new CustomEvent('WebComponentsReady', {bubbles: true})\n );\n\n // install upgrade hook if HTMLImports are available\n if (window.HTMLImports) {\n HTMLImports.__importsParsingHook = function(elt) {\n CustomElements.parser.parse(elt.import);\n }\n }\n });\n}\n\n// CustomEvent shim for IE\nif (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// When loading at readyState complete time (or via flag), boot custom elements\n// immediately.\n// If relevant, HTMLImports must already be loaded.\nif (document.readyState === 'complete' || scope.flags.eager) {\n bootstrap();\n// When loading at readyState interactive time, bootstrap only if HTMLImports\n// are not pending. Also avoid IE as the semantics of this state are unreliable.\n} else if (document.readyState === 'interactive' && !window.attachEvent &&\n (!window.HTMLImports || window.HTMLImports.ready)) {\n bootstrap();\n// When loading at other readyStates, wait for the appropriate DOM event to \n// bootstrap.\n} else {\n var loadEvent = window.HTMLImports && !HTMLImports.ready ?\n 'HTMLImportsLoaded' : 'DOMContentLoaded';\n window.addEventListener(loadEvent, bootstrap);\n}\n\n})(window.CustomElements);\n","/*\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() {\n\nif (window.ShadowDOMPolyfill) {\n\n // ensure wrapped inputs for these functions\n var fns = ['upgradeAll', 'upgradeSubtree', 'observeDocument',\n 'upgradeDocument'];\n\n // cache originals\n var original = {};\n fns.forEach(function(fn) {\n original[fn] = CustomElements[fn];\n });\n\n // override\n fns.forEach(function(fn) {\n CustomElements[fn] = function(inNode) {\n return original[fn](wrap(inNode));\n };\n });\n\n}\n\n})();\n","/*\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 var endOfMicrotask = scope.endOfMicrotask;\n\n // Generic url loader\n function Loader(regex) {\n this.cache = Object.create(null);\n this.map = Object.create(null);\n this.requests = 0;\n this.regex = regex;\n }\n Loader.prototype = {\n\n // TODO(dfreedm): there may be a better factoring here\n // extract absolute urls from the text (full of relative urls)\n extractUrls: function(text, base) {\n var matches = [];\n var matched, u;\n while ((matched = this.regex.exec(text))) {\n u = new URL(matched[1], base);\n matches.push({matched: matched[0], url: u.href});\n }\n return matches;\n },\n // take a text blob, a root url, and a callback and load all the urls found within the text\n // returns a map of absolute url to text\n process: function(text, root, callback) {\n var matches = this.extractUrls(text, root);\n\n // every call to process returns all the text this loader has ever received\n var done = callback.bind(null, this.map);\n this.fetch(matches, done);\n },\n // build a mapping of url -> text from matches\n fetch: function(matches, callback) {\n var inflight = matches.length;\n\n // return early if there is no fetching to be done\n if (!inflight) {\n return callback();\n }\n\n // wait for all subrequests to return\n var done = function() {\n if (--inflight === 0) {\n callback();\n }\n };\n\n // start fetching all subrequests\n var m, req, url;\n for (var i = 0; i < inflight; i++) {\n m = matches[i];\n url = m.url;\n req = this.cache[url];\n // if this url has already been requested, skip requesting it again\n if (!req) {\n req = this.xhr(url);\n req.match = m;\n this.cache[url] = req;\n }\n // wait for the request to process its subrequests\n req.wait(done);\n }\n },\n handleXhr: function(request) {\n var match = request.match;\n var url = match.url;\n\n // handle errors with an empty string\n var response = request.response || request.responseText || '';\n this.map[url] = response;\n this.fetch(this.extractUrls(response, url), request.resolve);\n },\n xhr: function(url) {\n this.requests++;\n var request = new XMLHttpRequest();\n request.open('GET', url, true);\n request.send();\n request.onerror = request.onload = this.handleXhr.bind(this, request);\n\n // queue of tasks to run after XHR returns\n request.pending = [];\n request.resolve = function() {\n var pending = request.pending;\n for(var i = 0; i < pending.length; i++) {\n pending[i]();\n }\n request.pending = null;\n };\n\n // if we have already resolved, pending is null, async call the callback\n request.wait = function(fn) {\n if (request.pending) {\n request.pending.push(fn);\n } else {\n endOfMicrotask(fn);\n }\n };\n\n return request;\n }\n };\n\n scope.Loader = Loader;\n})(window.Platform);\n","/*\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\nvar urlResolver = scope.urlResolver;\nvar Loader = scope.Loader;\n\nfunction StyleResolver() {\n this.loader = new Loader(this.regex);\n}\nStyleResolver.prototype = {\n regex: /@import\\s+(?:url)?[\"'\\(]*([^'\"\\)]*)['\"\\)]*;/g,\n // Recursively replace @imports with the text at that url\n resolve: function(text, url, callback) {\n var done = function(map) {\n callback(this.flatten(text, url, map));\n }.bind(this);\n this.loader.process(text, url, done);\n },\n // resolve the textContent of a style node\n resolveNode: function(style, url, callback) {\n var text = style.textContent;\n var done = function(text) {\n style.textContent = text;\n callback(style);\n };\n this.resolve(text, url, done);\n },\n // flatten all the @imports to text\n flatten: function(text, base, map) {\n var matches = this.loader.extractUrls(text, base);\n var match, url, intermediate;\n for (var i = 0; i < matches.length; i++) {\n match = matches[i];\n url = match.url;\n // resolve any css text to be relative to the importer, keep absolute url\n intermediate = urlResolver.resolveCssText(map[url], url, true);\n // flatten intermediate @imports\n intermediate = this.flatten(intermediate, base, map);\n text = text.replace(match.matched, intermediate);\n }\n return text;\n },\n loadStyles: function(styles, base, callback) {\n var loaded=0, l = styles.length;\n // called in the context of the style\n function loadedStyle(style) {\n loaded++;\n if (loaded === l && callback) {\n callback();\n }\n }\n for (var i=0, s; (i element.\n * @constructor\n * @extends {HTMLElement}\n */\n global.HTMLTemplateElement = function() {\n throw TypeError('Illegal constructor');\n };\n }\n\n var hasProto = '__proto__' in {};\n\n function mixin(to, from) {\n Object.getOwnPropertyNames(from).forEach(function(name) {\n Object.defineProperty(to, name,\n Object.getOwnPropertyDescriptor(from, name));\n });\n }\n\n // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner\n function getOrCreateTemplateContentsOwner(template) {\n var doc = template.ownerDocument\n if (!doc.defaultView)\n return doc;\n var d = doc.templateContentsOwner_;\n if (!d) {\n // TODO(arv): This should either be a Document or HTMLDocument depending\n // on doc.\n d = doc.implementation.createHTMLDocument('');\n while (d.lastChild) {\n d.removeChild(d.lastChild);\n }\n doc.templateContentsOwner_ = d;\n }\n return d;\n }\n\n function getTemplateStagingDocument(template) {\n if (!template.stagingDocument_) {\n var owner = template.ownerDocument;\n if (!owner.stagingDocument_) {\n owner.stagingDocument_ = owner.implementation.createHTMLDocument('');\n owner.stagingDocument_.isStagingDocument = true;\n // TODO(rafaelw): Remove when fix for\n // https://codereview.chromium.org/164803002/\n // makes it to Chrome release.\n var base = owner.stagingDocument_.createElement('base');\n base.href = document.baseURI;\n owner.stagingDocument_.head.appendChild(base);\n\n owner.stagingDocument_.stagingDocument_ = owner.stagingDocument_;\n }\n\n template.stagingDocument_ = owner.stagingDocument_;\n }\n\n return template.stagingDocument_;\n }\n\n // For non-template browsers, the parser will disallow in certain\n // locations, so we allow \"attribute templates\" which combine the template\n // element with the top-level container node of the content, e.g.\n //\n // Bar \n //\n // becomes\n //\n // \n // + #document-fragment\n // + \n // + Bar \n //\n function extractTemplateFromAttributeTemplate(el) {\n var template = el.ownerDocument.createElement('template');\n el.parentNode.insertBefore(template, el);\n\n var attribs = el.attributes;\n var count = attribs.length;\n while (count-- > 0) {\n var attrib = attribs[count];\n if (templateAttributeDirectives[attrib.name]) {\n if (attrib.name !== 'template')\n template.setAttribute(attrib.name, attrib.value);\n el.removeAttribute(attrib.name);\n }\n }\n\n return template;\n }\n\n function extractTemplateFromSVGTemplate(el) {\n var template = el.ownerDocument.createElement('template');\n el.parentNode.insertBefore(template, el);\n\n var attribs = el.attributes;\n var count = attribs.length;\n while (count-- > 0) {\n var attrib = attribs[count];\n template.setAttribute(attrib.name, attrib.value);\n el.removeAttribute(attrib.name);\n }\n\n el.parentNode.removeChild(el);\n return template;\n }\n\n function liftNonNativeTemplateChildrenIntoContent(template, el, useRoot) {\n var content = template.content;\n if (useRoot) {\n content.appendChild(el);\n return;\n }\n\n var child;\n while (child = el.firstChild) {\n content.appendChild(child);\n }\n }\n\n var templateObserver;\n if (typeof MutationObserver == 'function') {\n templateObserver = new MutationObserver(function(records) {\n for (var i = 0; i < records.length; i++) {\n records[i].target.refChanged_();\n }\n });\n }\n\n /**\n * Ensures proper API and content model for template elements.\n * @param {HTMLTemplateElement} opt_instanceRef The template element which\n * |el| template element will return as the value of its ref(), and whose\n * content will be used as source when createInstance() is invoked.\n */\n HTMLTemplateElement.decorate = function(el, opt_instanceRef) {\n if (el.templateIsDecorated_)\n return false;\n\n var templateElement = el;\n templateElement.templateIsDecorated_ = true;\n\n var isNativeHTMLTemplate = isHTMLTemplate(templateElement) &&\n hasTemplateElement;\n var bootstrapContents = isNativeHTMLTemplate;\n var liftContents = !isNativeHTMLTemplate;\n var liftRoot = false;\n\n if (!isNativeHTMLTemplate) {\n if (isAttributeTemplate(templateElement)) {\n assert(!opt_instanceRef);\n templateElement = extractTemplateFromAttributeTemplate(el);\n templateElement.templateIsDecorated_ = true;\n isNativeHTMLTemplate = hasTemplateElement;\n liftRoot = true;\n } else if (isSVGTemplate(templateElement)) {\n templateElement = extractTemplateFromSVGTemplate(el);\n templateElement.templateIsDecorated_ = true;\n isNativeHTMLTemplate = hasTemplateElement;\n }\n }\n\n if (!isNativeHTMLTemplate) {\n fixTemplateElementPrototype(templateElement);\n var doc = getOrCreateTemplateContentsOwner(templateElement);\n templateElement.content_ = doc.createDocumentFragment();\n }\n\n if (opt_instanceRef) {\n // template is contained within an instance, its direct content must be\n // empty\n templateElement.instanceRef_ = opt_instanceRef;\n } else if (liftContents) {\n liftNonNativeTemplateChildrenIntoContent(templateElement,\n el,\n liftRoot);\n } else if (bootstrapContents) {\n bootstrapTemplatesRecursivelyFrom(templateElement.content);\n }\n\n return true;\n };\n\n // TODO(rafaelw): This used to decorate recursively all templates from a given\n // node. This happens by default on 'DOMContentLoaded', but may be needed\n // in subtrees not descendent from document (e.g. ShadowRoot).\n // Review whether this is the right public API.\n HTMLTemplateElement.bootstrap = bootstrapTemplatesRecursivelyFrom;\n\n var htmlElement = global.HTMLUnknownElement || HTMLElement;\n\n var contentDescriptor = {\n get: function() {\n return this.content_;\n },\n enumerable: true,\n configurable: true\n };\n\n if (!hasTemplateElement) {\n // Gecko is more picky with the prototype than WebKit. Make sure to use the\n // same prototype as created in the constructor.\n HTMLTemplateElement.prototype = Object.create(htmlElement.prototype);\n\n Object.defineProperty(HTMLTemplateElement.prototype, 'content',\n contentDescriptor);\n }\n\n function fixTemplateElementPrototype(el) {\n if (hasProto)\n el.__proto__ = HTMLTemplateElement.prototype;\n else\n mixin(el, HTMLTemplateElement.prototype);\n }\n\n function ensureSetModelScheduled(template) {\n if (!template.setModelFn_) {\n template.setModelFn_ = function() {\n template.setModelFnScheduled_ = false;\n var map = getBindings(template,\n template.delegate_ && template.delegate_.prepareBinding);\n processBindings(template, map, template.model_);\n };\n }\n\n if (!template.setModelFnScheduled_) {\n template.setModelFnScheduled_ = true;\n Observer.runEOM_(template.setModelFn_);\n }\n }\n\n mixin(HTMLTemplateElement.prototype, {\n bind: function(name, value, oneTime) {\n if (name != 'ref')\n return Element.prototype.bind.call(this, name, value, oneTime);\n\n var self = this;\n var ref = oneTime ? value : value.open(function(ref) {\n self.setAttribute('ref', ref);\n self.refChanged_();\n });\n\n this.setAttribute('ref', ref);\n this.refChanged_();\n if (oneTime)\n return;\n\n if (!this.bindings_) {\n this.bindings_ = { ref: value };\n } else {\n this.bindings_.ref = value;\n }\n\n return value;\n },\n\n processBindingDirectives_: function(directives) {\n if (this.iterator_)\n this.iterator_.closeDeps();\n\n if (!directives.if && !directives.bind && !directives.repeat) {\n if (this.iterator_) {\n this.iterator_.close();\n this.iterator_ = undefined;\n }\n\n return;\n }\n\n if (!this.iterator_) {\n this.iterator_ = new TemplateIterator(this);\n }\n\n this.iterator_.updateDependencies(directives, this.model_);\n\n if (templateObserver) {\n templateObserver.observe(this, { attributes: true,\n attributeFilter: ['ref'] });\n }\n\n return this.iterator_;\n },\n\n createInstance: function(model, bindingDelegate, delegate_) {\n if (bindingDelegate)\n delegate_ = this.newDelegate_(bindingDelegate);\n else if (!delegate_)\n delegate_ = this.delegate_;\n\n if (!this.refContent_)\n this.refContent_ = this.ref_.content;\n var content = this.refContent_;\n if (content.firstChild === null)\n return emptyInstance;\n\n var map = getInstanceBindingMap(content, delegate_);\n var stagingDocument = getTemplateStagingDocument(this);\n var instance = stagingDocument.createDocumentFragment();\n instance.templateCreator_ = this;\n instance.protoContent_ = content;\n instance.bindings_ = [];\n instance.terminator_ = null;\n var instanceRecord = instance.templateInstance_ = {\n firstNode: null,\n lastNode: null,\n model: model\n };\n\n var i = 0;\n var collectTerminator = false;\n for (var child = content.firstChild; child; child = child.nextSibling) {\n // The terminator of the instance is the clone of the last child of the\n // content. If the last child is an active template, it may produce\n // instances as a result of production, so simply collecting the last\n // child of the instance after it has finished producing may be wrong.\n if (child.nextSibling === null)\n collectTerminator = true;\n\n var clone = cloneAndBindInstance(child, instance, stagingDocument,\n map.children[i++],\n model,\n delegate_,\n instance.bindings_);\n clone.templateInstance_ = instanceRecord;\n if (collectTerminator)\n instance.terminator_ = clone;\n }\n\n instanceRecord.firstNode = instance.firstChild;\n instanceRecord.lastNode = instance.lastChild;\n instance.templateCreator_ = undefined;\n instance.protoContent_ = undefined;\n return instance;\n },\n\n get model() {\n return this.model_;\n },\n\n set model(model) {\n this.model_ = model;\n ensureSetModelScheduled(this);\n },\n\n get bindingDelegate() {\n return this.delegate_ && this.delegate_.raw;\n },\n\n refChanged_: function() {\n if (!this.iterator_ || this.refContent_ === this.ref_.content)\n return;\n\n this.refContent_ = undefined;\n this.iterator_.valueChanged();\n this.iterator_.updateIteratedValue(this.iterator_.getUpdatedValue());\n },\n\n clear: function() {\n this.model_ = undefined;\n this.delegate_ = undefined;\n if (this.bindings_ && this.bindings_.ref)\n this.bindings_.ref.close()\n this.refContent_ = undefined;\n if (!this.iterator_)\n return;\n this.iterator_.valueChanged();\n this.iterator_.close()\n this.iterator_ = undefined;\n },\n\n setDelegate_: function(delegate) {\n this.delegate_ = delegate;\n this.bindingMap_ = undefined;\n if (this.iterator_) {\n this.iterator_.instancePositionChangedFn_ = undefined;\n this.iterator_.instanceModelFn_ = undefined;\n }\n },\n\n newDelegate_: function(bindingDelegate) {\n if (!bindingDelegate)\n return;\n\n function delegateFn(name) {\n var fn = bindingDelegate && bindingDelegate[name];\n if (typeof fn != 'function')\n return;\n\n return function() {\n return fn.apply(bindingDelegate, arguments);\n };\n }\n\n return {\n bindingMaps: {},\n raw: bindingDelegate,\n prepareBinding: delegateFn('prepareBinding'),\n prepareInstanceModel: delegateFn('prepareInstanceModel'),\n prepareInstancePositionChanged:\n delegateFn('prepareInstancePositionChanged')\n };\n },\n\n set bindingDelegate(bindingDelegate) {\n if (this.delegate_) {\n throw Error('Template must be cleared before a new bindingDelegate ' +\n 'can be assigned');\n }\n\n this.setDelegate_(this.newDelegate_(bindingDelegate));\n },\n\n get ref_() {\n var ref = searchRefId(this, this.getAttribute('ref'));\n if (!ref)\n ref = this.instanceRef_;\n\n if (!ref)\n return this;\n\n var nextRef = ref.ref_;\n return nextRef ? nextRef : ref;\n }\n });\n\n // Returns\n // a) undefined if there are no mustaches.\n // b) [TEXT, (ONE_TIME?, PATH, DELEGATE_FN, TEXT)+] if there is at least one mustache.\n function parseMustaches(s, name, node, prepareBindingFn) {\n if (!s || !s.length)\n return;\n\n var tokens;\n var length = s.length;\n var startIndex = 0, lastIndex = 0, endIndex = 0;\n var onlyOneTime = true;\n while (lastIndex < length) {\n var startIndex = s.indexOf('{{', lastIndex);\n var oneTimeStart = s.indexOf('[[', lastIndex);\n var oneTime = false;\n var terminator = '}}';\n\n if (oneTimeStart >= 0 &&\n (startIndex < 0 || oneTimeStart < startIndex)) {\n startIndex = oneTimeStart;\n oneTime = true;\n terminator = ']]';\n }\n\n endIndex = startIndex < 0 ? -1 : s.indexOf(terminator, startIndex + 2);\n\n if (endIndex < 0) {\n if (!tokens)\n return;\n\n tokens.push(s.slice(lastIndex)); // TEXT\n break;\n }\n\n tokens = tokens || [];\n tokens.push(s.slice(lastIndex, startIndex)); // TEXT\n var pathString = s.slice(startIndex + 2, endIndex).trim();\n tokens.push(oneTime); // ONE_TIME?\n onlyOneTime = onlyOneTime && oneTime;\n var delegateFn = prepareBindingFn &&\n prepareBindingFn(pathString, name, node);\n // Don't try to parse the expression if there's a prepareBinding function\n if (delegateFn == null) {\n tokens.push(Path.get(pathString)); // PATH\n } else {\n tokens.push(null);\n }\n tokens.push(delegateFn); // DELEGATE_FN\n lastIndex = endIndex + 2;\n }\n\n if (lastIndex === length)\n tokens.push(''); // TEXT\n\n tokens.hasOnePath = tokens.length === 5;\n tokens.isSimplePath = tokens.hasOnePath &&\n tokens[0] == '' &&\n tokens[4] == '';\n tokens.onlyOneTime = onlyOneTime;\n\n tokens.combinator = function(values) {\n var newValue = tokens[0];\n\n for (var i = 1; i < tokens.length; i += 4) {\n var value = tokens.hasOnePath ? values : values[(i - 1) / 4];\n if (value !== undefined)\n newValue += value;\n newValue += tokens[i + 3];\n }\n\n return newValue;\n }\n\n return tokens;\n };\n\n function processOneTimeBinding(name, tokens, node, model) {\n if (tokens.hasOnePath) {\n var delegateFn = tokens[3];\n var value = delegateFn ? delegateFn(model, node, true) :\n tokens[2].getValueFrom(model);\n return tokens.isSimplePath ? value : tokens.combinator(value);\n }\n\n var values = [];\n for (var i = 1; i < tokens.length; i += 4) {\n var delegateFn = tokens[i + 2];\n values[(i - 1) / 4] = delegateFn ? delegateFn(model, node) :\n tokens[i + 1].getValueFrom(model);\n }\n\n return tokens.combinator(values);\n }\n\n function processSinglePathBinding(name, tokens, node, model) {\n var delegateFn = tokens[3];\n var observer = delegateFn ? delegateFn(model, node, false) :\n new PathObserver(model, tokens[2]);\n\n return tokens.isSimplePath ? observer :\n new ObserverTransform(observer, tokens.combinator);\n }\n\n function processBinding(name, tokens, node, model) {\n if (tokens.onlyOneTime)\n return processOneTimeBinding(name, tokens, node, model);\n\n if (tokens.hasOnePath)\n return processSinglePathBinding(name, tokens, node, model);\n\n var observer = new CompoundObserver();\n\n for (var i = 1; i < tokens.length; i += 4) {\n var oneTime = tokens[i];\n var delegateFn = tokens[i + 2];\n\n if (delegateFn) {\n var value = delegateFn(model, node, oneTime);\n if (oneTime)\n observer.addPath(value)\n else\n observer.addObserver(value);\n continue;\n }\n\n var path = tokens[i + 1];\n if (oneTime)\n observer.addPath(path.getValueFrom(model))\n else\n observer.addPath(model, path);\n }\n\n return new ObserverTransform(observer, tokens.combinator);\n }\n\n function processBindings(node, bindings, model, instanceBindings) {\n for (var i = 0; i < bindings.length; i += 2) {\n var name = bindings[i]\n var tokens = bindings[i + 1];\n var value = processBinding(name, tokens, node, model);\n var binding = node.bind(name, value, tokens.onlyOneTime);\n if (binding && instanceBindings)\n instanceBindings.push(binding);\n }\n\n node.bindFinished();\n if (!bindings.isTemplate)\n return;\n\n node.model_ = model;\n var iter = node.processBindingDirectives_(bindings);\n if (instanceBindings && iter)\n instanceBindings.push(iter);\n }\n\n function parseWithDefault(el, name, prepareBindingFn) {\n var v = el.getAttribute(name);\n return parseMustaches(v == '' ? '{{}}' : v, name, el, prepareBindingFn);\n }\n\n function parseAttributeBindings(element, prepareBindingFn) {\n assert(element);\n\n var bindings = [];\n var ifFound = false;\n var bindFound = false;\n\n for (var i = 0; i < element.attributes.length; i++) {\n var attr = element.attributes[i];\n var name = attr.name;\n var value = attr.value;\n\n // Allow bindings expressed in attributes to be prefixed with underbars.\n // We do this to allow correct semantics for browsers that don't implement\n // where certain attributes might trigger side-effects -- and\n // for IE which sanitizes certain attributes, disallowing mustache\n // replacements in their text.\n while (name[0] === '_') {\n name = name.substring(1);\n }\n\n if (isTemplate(element) &&\n (name === IF || name === BIND || name === REPEAT)) {\n continue;\n }\n\n var tokens = parseMustaches(value, name, element,\n prepareBindingFn);\n if (!tokens)\n continue;\n\n bindings.push(name, tokens);\n }\n\n if (isTemplate(element)) {\n bindings.isTemplate = true;\n bindings.if = parseWithDefault(element, IF, prepareBindingFn);\n bindings.bind = parseWithDefault(element, BIND, prepareBindingFn);\n bindings.repeat = parseWithDefault(element, REPEAT, prepareBindingFn);\n\n if (bindings.if && !bindings.bind && !bindings.repeat)\n bindings.bind = parseMustaches('{{}}', BIND, element, prepareBindingFn);\n }\n\n return bindings;\n }\n\n function getBindings(node, prepareBindingFn) {\n if (node.nodeType === Node.ELEMENT_NODE)\n return parseAttributeBindings(node, prepareBindingFn);\n\n if (node.nodeType === Node.TEXT_NODE) {\n var tokens = parseMustaches(node.data, 'textContent', node,\n prepareBindingFn);\n if (tokens)\n return ['textContent', tokens];\n }\n\n return [];\n }\n\n function cloneAndBindInstance(node, parent, stagingDocument, bindings, model,\n delegate,\n instanceBindings,\n instanceRecord) {\n var clone = parent.appendChild(stagingDocument.importNode(node, false));\n\n var i = 0;\n for (var child = node.firstChild; child; child = child.nextSibling) {\n cloneAndBindInstance(child, clone, stagingDocument,\n bindings.children[i++],\n model,\n delegate,\n instanceBindings);\n }\n\n if (bindings.isTemplate) {\n HTMLTemplateElement.decorate(clone, node);\n if (delegate)\n clone.setDelegate_(delegate);\n }\n\n processBindings(clone, bindings, model, instanceBindings);\n return clone;\n }\n\n function createInstanceBindingMap(node, prepareBindingFn) {\n var map = getBindings(node, prepareBindingFn);\n map.children = {};\n var index = 0;\n for (var child = node.firstChild; child; child = child.nextSibling) {\n map.children[index++] = createInstanceBindingMap(child, prepareBindingFn);\n }\n\n return map;\n }\n\n var contentUidCounter = 1;\n\n // TODO(rafaelw): Setup a MutationObserver on content which clears the id\n // so that bindingMaps regenerate when the template.content changes.\n function getContentUid(content) {\n var id = content.id_;\n if (!id)\n id = content.id_ = contentUidCounter++;\n return id;\n }\n\n // Each delegate is associated with a set of bindingMaps, one for each\n // content which may be used by a template. The intent is that each binding\n // delegate gets the opportunity to prepare the instance (via the prepare*\n // delegate calls) once across all uses.\n // TODO(rafaelw): Separate out the parse map from the binding map. In the\n // current implementation, if two delegates need a binding map for the same\n // content, the second will have to reparse.\n function getInstanceBindingMap(content, delegate_) {\n var contentId = getContentUid(content);\n if (delegate_) {\n var map = delegate_.bindingMaps[contentId];\n if (!map) {\n map = delegate_.bindingMaps[contentId] =\n createInstanceBindingMap(content, delegate_.prepareBinding) || [];\n }\n return map;\n }\n\n var map = content.bindingMap_;\n if (!map) {\n map = content.bindingMap_ =\n createInstanceBindingMap(content, undefined) || [];\n }\n return map;\n }\n\n Object.defineProperty(Node.prototype, 'templateInstance', {\n get: function() {\n var instance = this.templateInstance_;\n return instance ? instance :\n (this.parentNode ? this.parentNode.templateInstance : undefined);\n }\n });\n\n var emptyInstance = document.createDocumentFragment();\n emptyInstance.bindings_ = [];\n emptyInstance.terminator_ = null;\n\n function TemplateIterator(templateElement) {\n this.closed = false;\n this.templateElement_ = templateElement;\n this.instances = [];\n this.deps = undefined;\n this.iteratedValue = [];\n this.presentValue = undefined;\n this.arrayObserver = undefined;\n }\n\n TemplateIterator.prototype = {\n closeDeps: function() {\n var deps = this.deps;\n if (deps) {\n if (deps.ifOneTime === false)\n deps.ifValue.close();\n if (deps.oneTime === false)\n deps.value.close();\n }\n },\n\n updateDependencies: function(directives, model) {\n this.closeDeps();\n\n var deps = this.deps = {};\n var template = this.templateElement_;\n\n var ifValue = true;\n if (directives.if) {\n deps.hasIf = true;\n deps.ifOneTime = directives.if.onlyOneTime;\n deps.ifValue = processBinding(IF, directives.if, template, model);\n\n ifValue = deps.ifValue;\n\n // oneTime if & predicate is false. nothing else to do.\n if (deps.ifOneTime && !ifValue) {\n this.valueChanged();\n return;\n }\n\n if (!deps.ifOneTime)\n ifValue = ifValue.open(this.updateIfValue, this);\n }\n\n if (directives.repeat) {\n deps.repeat = true;\n deps.oneTime = directives.repeat.onlyOneTime;\n deps.value = processBinding(REPEAT, directives.repeat, template, model);\n } else {\n deps.repeat = false;\n deps.oneTime = directives.bind.onlyOneTime;\n deps.value = processBinding(BIND, directives.bind, template, model);\n }\n\n var value = deps.value;\n if (!deps.oneTime)\n value = value.open(this.updateIteratedValue, this);\n\n if (!ifValue) {\n this.valueChanged();\n return;\n }\n\n this.updateValue(value);\n },\n\n /**\n * Gets the updated value of the bind/repeat. This can potentially call\n * user code (if a bindingDelegate is set up) so we try to avoid it if we\n * already have the value in hand (from Observer.open).\n */\n getUpdatedValue: function() {\n var value = this.deps.value;\n if (!this.deps.oneTime)\n value = value.discardChanges();\n return value;\n },\n\n updateIfValue: function(ifValue) {\n if (!ifValue) {\n this.valueChanged();\n return;\n }\n\n this.updateValue(this.getUpdatedValue());\n },\n\n updateIteratedValue: function(value) {\n if (this.deps.hasIf) {\n var ifValue = this.deps.ifValue;\n if (!this.deps.ifOneTime)\n ifValue = ifValue.discardChanges();\n if (!ifValue) {\n this.valueChanged();\n return;\n }\n }\n\n this.updateValue(value);\n },\n\n updateValue: function(value) {\n if (!this.deps.repeat)\n value = [value];\n var observe = this.deps.repeat &&\n !this.deps.oneTime &&\n Array.isArray(value);\n this.valueChanged(value, observe);\n },\n\n valueChanged: function(value, observeValue) {\n if (!Array.isArray(value))\n value = [];\n\n if (value === this.iteratedValue)\n return;\n\n this.unobserve();\n this.presentValue = value;\n if (observeValue) {\n this.arrayObserver = new ArrayObserver(this.presentValue);\n this.arrayObserver.open(this.handleSplices, this);\n }\n\n this.handleSplices(ArrayObserver.calculateSplices(this.presentValue,\n this.iteratedValue));\n },\n\n getLastInstanceNode: function(index) {\n if (index == -1)\n return this.templateElement_;\n var instance = this.instances[index];\n var terminator = instance.terminator_;\n if (!terminator)\n return this.getLastInstanceNode(index - 1);\n\n if (terminator.nodeType !== Node.ELEMENT_NODE ||\n this.templateElement_ === terminator) {\n return terminator;\n }\n\n var subtemplateIterator = terminator.iterator_;\n if (!subtemplateIterator)\n return terminator;\n\n return subtemplateIterator.getLastTemplateNode();\n },\n\n getLastTemplateNode: function() {\n return this.getLastInstanceNode(this.instances.length - 1);\n },\n\n insertInstanceAt: function(index, fragment) {\n var previousInstanceLast = this.getLastInstanceNode(index - 1);\n var parent = this.templateElement_.parentNode;\n this.instances.splice(index, 0, fragment);\n\n parent.insertBefore(fragment, previousInstanceLast.nextSibling);\n },\n\n extractInstanceAt: function(index) {\n var previousInstanceLast = this.getLastInstanceNode(index - 1);\n var lastNode = this.getLastInstanceNode(index);\n var parent = this.templateElement_.parentNode;\n var instance = this.instances.splice(index, 1)[0];\n\n while (lastNode !== previousInstanceLast) {\n var node = previousInstanceLast.nextSibling;\n if (node == lastNode)\n lastNode = previousInstanceLast;\n\n instance.appendChild(parent.removeChild(node));\n }\n\n return instance;\n },\n\n getDelegateFn: function(fn) {\n fn = fn && fn(this.templateElement_);\n return typeof fn === 'function' ? fn : null;\n },\n\n handleSplices: function(splices) {\n if (this.closed || !splices.length)\n return;\n\n var template = this.templateElement_;\n\n if (!template.parentNode) {\n this.close();\n return;\n }\n\n ArrayObserver.applySplices(this.iteratedValue, this.presentValue,\n splices);\n\n var delegate = template.delegate_;\n if (this.instanceModelFn_ === undefined) {\n this.instanceModelFn_ =\n this.getDelegateFn(delegate && delegate.prepareInstanceModel);\n }\n\n if (this.instancePositionChangedFn_ === undefined) {\n this.instancePositionChangedFn_ =\n this.getDelegateFn(delegate &&\n delegate.prepareInstancePositionChanged);\n }\n\n // Instance Removals\n var instanceCache = new Map;\n var removeDelta = 0;\n for (var i = 0; i < splices.length; i++) {\n var splice = splices[i];\n var removed = splice.removed;\n for (var j = 0; j < removed.length; j++) {\n var model = removed[j];\n var instance = this.extractInstanceAt(splice.index + removeDelta);\n if (instance !== emptyInstance) {\n instanceCache.set(model, instance);\n }\n }\n\n removeDelta -= splice.addedCount;\n }\n\n // Instance Insertions\n for (var i = 0; i < splices.length; i++) {\n var splice = splices[i];\n var addIndex = splice.index;\n for (; addIndex < splice.index + splice.addedCount; addIndex++) {\n var model = this.iteratedValue[addIndex];\n var instance = instanceCache.get(model);\n if (instance) {\n instanceCache.delete(model);\n } else {\n if (this.instanceModelFn_) {\n model = this.instanceModelFn_(model);\n }\n\n if (model === undefined) {\n instance = emptyInstance;\n } else {\n instance = template.createInstance(model, undefined, delegate);\n }\n }\n\n this.insertInstanceAt(addIndex, instance);\n }\n }\n\n instanceCache.forEach(function(instance) {\n this.closeInstanceBindings(instance);\n }, this);\n\n if (this.instancePositionChangedFn_)\n this.reportInstancesMoved(splices);\n },\n\n reportInstanceMoved: function(index) {\n var instance = this.instances[index];\n if (instance === emptyInstance)\n return;\n\n this.instancePositionChangedFn_(instance.templateInstance_, index);\n },\n\n reportInstancesMoved: function(splices) {\n var index = 0;\n var offset = 0;\n for (var i = 0; i < splices.length; i++) {\n var splice = splices[i];\n if (offset != 0) {\n while (index < splice.index) {\n this.reportInstanceMoved(index);\n index++;\n }\n } else {\n index = splice.index;\n }\n\n while (index < splice.index + splice.addedCount) {\n this.reportInstanceMoved(index);\n index++;\n }\n\n offset += splice.addedCount - splice.removed.length;\n }\n\n if (offset == 0)\n return;\n\n var length = this.instances.length;\n while (index < length) {\n this.reportInstanceMoved(index);\n index++;\n }\n },\n\n closeInstanceBindings: function(instance) {\n var bindings = instance.bindings_;\n for (var i = 0; i < bindings.length; i++) {\n bindings[i].close();\n }\n },\n\n unobserve: function() {\n if (!this.arrayObserver)\n return;\n\n this.arrayObserver.close();\n this.arrayObserver = undefined;\n },\n\n close: function() {\n if (this.closed)\n return;\n this.unobserve();\n for (var i = 0; i < this.instances.length; i++) {\n this.closeInstanceBindings(this.instances[i]);\n }\n\n this.instances.length = 0;\n this.closeDeps();\n this.templateElement_.iterator_ = undefined;\n this.closed = true;\n }\n };\n\n // Polyfill-specific API.\n HTMLTemplateElement.forAllTemplatesFrom_ = forAllTemplatesFrom;\n})(this);\n","/*\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// inject style sheet\nvar style = document.createElement('style');\nstyle.textContent = 'template {display: none !important;} /* injected by platform.js */';\nvar head = document.querySelector('head');\nhead.insertBefore(style, head.firstChild);\n\n// flush (with logging)\nvar flushing;\nfunction flush() {\n if (!flushing) {\n flushing = true;\n scope.endOfMicrotask(function() {\n flushing = false;\n logFlags.data && console.group('Platform.flush()');\n scope.performMicrotaskCheckpoint();\n logFlags.data && console.groupEnd();\n });\n }\n};\n\n// polling dirty checker\n// flush periodically if platform does not have object observe.\nif (!Observer.hasObjectObserve) {\n var FLUSH_POLL_INTERVAL = 125;\n window.addEventListener('WebComponentsReady', function() {\n flush();\n scope.flushPoll = setInterval(flush, FLUSH_POLL_INTERVAL);\n });\n} else {\n // make flush a no-op when we have Object.observe\n flush = function() {};\n}\n\nif (window.CustomElements && !CustomElements.useNative) {\n var originalImportNode = Document.prototype.importNode;\n Document.prototype.importNode = function(node, deep) {\n var imported = originalImportNode.call(this, node, deep);\n CustomElements.upgradeAll(imported);\n return imported;\n }\n}\n\n// exports\nscope.flush = flush;\n\n})(window.Platform);\n\n"]}
\ No newline at end of file
diff --git a/components/polymer/.bower.json b/components/polymer/.bower.json
deleted file mode 100644
index bbd6f0c..0000000
--- a/components/polymer/.bower.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "polymer",
- "private": true,
- "dependencies": {
- "platform": "Polymer/platform#>=0.3.0 <1.0.0",
- "core-component-page": "Polymer/core-component-page#>=0.3.0 <1.0.0"
- },
- "homepage": "https://github.com/Polymer/polymer",
- "version": "0.3.5",
- "_release": "0.3.5",
- "_resolution": {
- "type": "version",
- "tag": "0.3.5",
- "commit": "a09a0e689fdeab11b53b41eaed033781733bf1eb"
- },
- "_source": "git://github.com/Polymer/polymer.git",
- "_target": "~0.3.5",
- "_originalSource": "Polymer/polymer"
-}
\ No newline at end of file
diff --git a/components/polymer/README.md b/components/polymer/README.md
deleted file mode 100644
index 236a88c..0000000
--- a/components/polymer/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Polymer
-
-[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/polymer/README)](https://github.com/igrigorik/ga-beacon)
-
-Build Status: [http://build.chromium.org/p/client.polymer/waterfall](http://build.chromium.org/p/client.polymer/waterfall)
-
-## Brief Overview
-
-For more detailed info goto [http://polymer-project.org/](http://polymer-project.org/).
-
-Polymer is a new type of library for the web, designed to leverage the existing browser infrastructure to provide the encapsulation and extendability currently only available in JS libraries.
-
-Polymer is based on a set of future technologies, including [Shadow DOM](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html), [Custom Elements](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html) and Model Driven Views. Currently these technologies are implemented as polyfills or shims, but as browsers adopt these features natively, the platform code that drives Polymer evacipates, leaving only the value-adds.
-
-## Tools & Testing
-
-For running tests or building minified files, consult the [tooling information](http://www.polymer-project.org/resources/tooling-strategy.html).
diff --git a/components/polymer/bower.json b/components/polymer/bower.json
deleted file mode 100644
index faff32b..0000000
--- a/components/polymer/bower.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "polymer",
- "private": true,
- "dependencies": {
- "platform": "Polymer/platform#>=0.3.0 <1.0.0",
- "core-component-page": "Polymer/core-component-page#>=0.3.0 <1.0.0"
- }
-}
\ No newline at end of file
diff --git a/components/polymer/build.log b/components/polymer/build.log
deleted file mode 100644
index b39ce40..0000000
--- a/components/polymer/build.log
+++ /dev/null
@@ -1,33 +0,0 @@
-BUILD LOG
----------
-Build Time: 2014-08-07T17:12:22
-
-NODEJS INFORMATION
-==================
-nodejs: v0.10.28
-chai: 1.9.1
-grunt: 0.4.4
-grunt-audit: 0.0.3
-grunt-contrib-uglify: 0.4.0
-grunt-contrib-yuidoc: 0.5.2
-grunt-karma: 0.8.3
-grunt-string-replace: 0.2.7
-karma: 0.12.14
-karma-crbot-reporter: 0.0.4
-karma-firefox-launcher: 0.1.3
-karma-ie-launcher: 0.1.5
-karma-mocha: 0.1.3
-karma-safari-launcher: 0.1.1
-karma-script-launcher: 0.1.0
-mocha: 1.18.2
-Polymer: 0.3.5
-
-REPO REVISIONS
-==============
-polymer-expressions: 529532103a215b641d4efd607536ce87ec7723f6
-polymer-gestures: 725191c5457b6e96c37a9db852e943fe3b40635f
-polymer-dev: 56417b55d75f0a69d19e313c218c86b23c1daf18
-
-BUILD HASHES
-============
-build/polymer.js: d1d70d03f791f2808e9dad16dc0e43bcbbd25c2d
\ No newline at end of file
diff --git a/components/polymer/layout.html b/components/polymer/layout.html
deleted file mode 100644
index 46dec0a..0000000
--- a/components/polymer/layout.html
+++ /dev/null
@@ -1,278 +0,0 @@
-
-
\ No newline at end of file
diff --git a/components/polymer/polymer.html b/components/polymer/polymer.html
deleted file mode 100644
index 424006a..0000000
--- a/components/polymer/polymer.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/components/polymer/polymer.js b/components/polymer/polymer.js
deleted file mode 100644
index 8d46df3..0000000
--- a/components/polymer/polymer.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * Code distributed by Google as part of the polymer project is also
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
- */
-// @version: 0.3.5
-window.PolymerGestures={},function(a){var b=!1,c=document.createElement("meta");if(c.createShadowRoot){var d=c.createShadowRoot(),e=document.createElement("span");d.appendChild(e),c.addEventListener("testpath",function(a){a.path&&(b=a.path[0]===e),a.stopPropagation()});var f=new CustomEvent("testpath",{bubbles:!0});document.head.appendChild(c),e.dispatchEvent(f),c.parentNode.removeChild(c),d=e=null}c=null;var g={shadow:function(a){return a?a.shadowRoot||a.webkitShadowRoot:void 0},canTarget:function(a){return a&&Boolean(a.elementFromPoint)},targetingShadow:function(a){var b=this.shadow(a);return this.canTarget(b)?b:void 0},olderShadow:function(a){var b=a.olderShadowRoot;if(!b){var c=a.querySelector("shadow");c&&(b=c.olderShadowRoot)}return b},allShadows:function(a){for(var b=[],c=this.shadow(a);c;)b.push(c),c=this.olderShadow(c);return b},searchRoot:function(a,b,c){var d,e;return a?(d=a.elementFromPoint(b,c),d?e=this.targetingShadow(d):a!==document&&(e=this.olderShadow(a)),this.searchRoot(e,b,c)||d):void 0},owner:function(a){if(!a)return document;for(var b=a;b.parentNode;)b=b.parentNode;return b.nodeType!=Node.DOCUMENT_NODE&&b.nodeType!=Node.DOCUMENT_FRAGMENT_NODE&&(b=document),b},findTarget:function(a){if(b&&a.path)return a.path[0];var c=a.clientX,d=a.clientY,e=this.owner(a.target);return e.elementFromPoint(c,d)||(e=document),this.searchRoot(e,c,d)},findTouchAction:function(a){var c;if(b&&a.path){for(var d=a.path,e=0;e=0?a=this.walk(a,e):b=this.walk(b,-e);a&&b&&a!==b;)a=a.parentNode||a.host,b=b.parentNode||b.host;return a},walk:function(a,b){for(var c=0;a&&b>c;c++)a=a.parentNode||a.host;return a},depth:function(a){for(var b=0;a;)b++,a=a.parentNode||a.host;return b},deepContains:function(a,b){var c=this.LCA(a,b);return c===a},insideNode:function(a,b,c){var d=a.getBoundingClientRect();return d.left<=b&&b<=d.right&&d.top<=c&&c<=d.bottom}};a.targetFinding=g,a.findTarget=g.findTarget.bind(g),a.deepContains=g.deepContains.bind(g),a.insideNode=g.insideNode}(window.PolymerGestures),function(){function a(a){return"html /deep/ "+b(a)}function b(a){return'[touch-action="'+a+'"]'}function c(a){return"{ -ms-touch-action: "+a+"; touch-action: "+a+";}"}var d=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],e="",f="string"==typeof document.head.style.touchAction,g=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(f){d.forEach(function(d){String(d)===d?(e+=b(d)+c(d)+"\n",g&&(e+=a(d)+c(d)+"\n")):(e+=d.selectors.map(b)+c(d.rule)+"\n",g&&(e+=d.selectors.map(a)+c(d.rule)+"\n"))});var h=document.createElement("style");h.textContent=e,document.head.appendChild(h)}}(),function(a){var b=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],c=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],d=function(){return function(){}},e={preventTap:d,makeBaseEvent:function(a,b){var c=document.createEvent("Event");return c.initEvent(a,b.bubbles||!1,b.cancelable||!1),c.preventTap=e.preventTap(c),c},makeGestureEvent:function(a,b){b=b||Object.create(null);for(var c,d=this.makeBaseEvent(a,b),e=0,f=Object.keys(b);e-1?this.values[c]=b:(this.keys.push(a),this.values.push(b))},has:function(a){return this.keys.indexOf(a)>-1},"delete":function(a){var b=this.keys.indexOf(a);b>-1&&(this.keys.splice(b,1),this.values.splice(b,1))},get:function(a){var b=this.keys.indexOf(a);return this.values[b]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(a,b){this.values.forEach(function(c,d){a.call(b,c,this.keys[d],this)},this)},pointers:function(){return this.keys.length}},a.PointerMap=b}(window.PolymerGestures),function(a){var b=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],c=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],d="undefined"!=typeof SVGElementInstance,e=a.eventFactory,f={pointermap:new a.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(a,b){var c=b,d=c.events;d&&(d.forEach(function(a){c[a]&&(this.eventMap[a]=c[a].bind(c))},this),this.eventSources[a]=c,this.eventSourceList.push(c))},registerGesture:function(a,b){var c=Object.create(null);c.listeners=0,c.index=this.gestures.length;for(var d,e=0;ee&&(c=this.eventSourceList[e]);e++)c.register.call(c,a,b)},unregister:function(a){for(var b,c=this.eventSourceList.length,d=0;c>d&&(b=this.eventSourceList[d]);d++)b.unregister.call(b,a)},down:function(a){this.fireEvent("down",a)},move:function(a){a.type="move",this.fillGestureQueue(a)},up:function(a){this.fireEvent("up",a)},cancel:function(a){a.tapPrevented=!0,this.fireEvent("up",a)},eventHandler:function(a){if(!a._handledByPG){var b=a.type,c=this.eventMap&&this.eventMap[b];c&&c(a),a._handledByPG=!0}},listen:function(a,b){for(var c,d=0,e=b.length;e>d&&(c=b[d]);d++)this.addEvent(a,c)},unlisten:function(a,b){for(var c,d=0,e=b.length;e>d&&(c=b[d]);d++)this.removeEvent(a,c)},addEvent:function(a,b){a.addEventListener(b,this.boundHandler)},removeEvent:function(a,b){a.removeEventListener(b,this.boundHandler)},makeEvent:function(a,b){var c=e.makePointerEvent(a,b);return c.preventDefault=b.preventDefault,c.tapPrevented=b.tapPrevented,c._target=c._target||b.target,c},fireEvent:function(a,b){var c=this.makeEvent(a,b);return this.dispatchEvent(c)},cloneEvent:function(a){for(var e,f=Object.create(null),g=0;g0&&d.listeners--,0===d.listeners){var e=f.gestures[d.index];e&&(e.enabled=!1)}a._pgListeners>0&&a._pgListeners--,0===a._pgListeners&&f.unregister(a)}return Boolean(d)},a.removeEventListener=function(b,c,d,e){d&&(a.deactivateGesture(b,c),b.removeEventListener(c,d,e))}}(window.PolymerGestures),function(a){var b=a.dispatcher,c=b.pointermap,d=25,e=[0,1,4,2],f=!1;try{f=1===new MouseEvent("test",{buttons:1}).buttons}catch(g){}var h={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(a){b.listen(a,this.events)},unregister:function(a){b.unlisten(a,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(a){for(var b,c=this.lastTouches,e=a.clientX,f=a.clientY,g=0,h=c.length;h>g&&(b=c[g]);g++){var i=Math.abs(e-b.x),j=Math.abs(f-b.y);if(d>=i&&d>=j)return!0}},prepareEvent:function(a){var c=b.cloneEvent(a);return c.pointerId=this.POINTER_ID,c.isPrimary=!0,c.pointerType=this.POINTER_TYPE,c._source="mouse",f||(c.buttons=e[c.which]||0),c},mousedown:function(d){if(!this.isEventSimulatedFromTouch(d)){var e=c.has(this.POINTER_ID);e&&this.mouseup(d);var f=this.prepareEvent(d);f.target=a.findTarget(d),c.set(this.POINTER_ID,f.target),b.down(f)}},mousemove:function(a){if(!this.isEventSimulatedFromTouch(a)){var d=c.get(this.POINTER_ID);if(d){var e=this.prepareEvent(a);e.target=d,0===e.buttons?(b.cancel(e),this.cleanupMouse()):b.move(e)}}},mouseup:function(d){if(!this.isEventSimulatedFromTouch(d)){var e=this.prepareEvent(d);e.relatedTarget=a.findTarget(d),e.target=c.get(this.POINTER_ID),b.up(e),this.cleanupMouse()}},cleanupMouse:function(){c["delete"](this.POINTER_ID)}};a.mouseEvents=h}(window.PolymerGestures),function(a){var b=a.dispatcher,c=(a.targetFinding.allShadows.bind(a.targetFinding),b.pointermap),d=(Array.prototype.map.call.bind(Array.prototype.map),2500),e=200,f=20,g=!1,h={events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(a,c){c||b.listen(a,this.events)},unregister:function(a){b.unlisten(a,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(a){var b=a,c=this.scrollTypes;return b===c.EMITTER?"none":b===c.XSCROLLER?"X":b===c.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(a){return this.firstTouch===a.identifier},setPrimaryTouch:function(a){(0===c.pointers()||1===c.pointers()&&c.has(1))&&(this.firstTouch=a.identifier,this.firstXY={X:a.clientX,Y:a.clientY},this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(a){a.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var a=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(a,e)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(a){var b=0;return("touchstart"===a||"touchmove"===a)&&(b=1),b},findTarget:function(b,d){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(b)){var e={clientX:b.clientX,clientY:b.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return a.findTarget(e)}return a.findTarget(b)}return c.get(d)},touchToPointer:function(a){var c=this.currentTouchEvent,d=b.cloneEvent(a),e=d.pointerId=a.identifier+2;d.target=this.findTarget(a,e),d.bubbles=!0,d.cancelable=!0,d.detail=this.clickCount,d.buttons=this.typeToButtons(c.type),d.width=a.webkitRadiusX||a.radiusX||0,d.height=a.webkitRadiusY||a.radiusY||0,d.pressure=a.webkitForce||a.force||.5,d.isPrimary=this.isPrimaryTouch(a),d.pointerType=this.POINTER_TYPE,d._source="touch";var f=this;return d.preventDefault=function(){f.scrolling=!1,f.firstXY=null,c.preventDefault()},d},processTouches:function(a,b){var d=a.changedTouches;this.currentTouchEvent=a;for(var e,f,g=0;g=j}return c}},findTouch:function(a,b){for(var c,d=0,e=a.length;e>d&&(c=a[d]);d++)if(c.identifier===b)return!0},vacuumTouches:function(a){var b=a.touches;if(c.pointers()>=b.length){var d=[];c.forEach(function(a,c){if(1!==c&&!this.findTouch(b,c-2)){var e=a;d.push(e)}},this),d.forEach(function(a){this.cancel(a),c.delete(a.pointerId)})}},touchstart:function(a){this.vacuumTouches(a),this.setPrimaryTouch(a.changedTouches[0]),this.dedupSynthMouse(a),this.scrolling||(this.clickCount++,this.processTouches(a,this.down))},down:function(a){b.down(a)},touchmove:function(a){if(g)a.cancelable&&this.processTouches(a,this.move);else if(this.scrolling){if(this.firstXY){var b=a.changedTouches[0],c=b.clientX-this.firstXY.X,d=b.clientY-this.firstXY.Y,e=Math.sqrt(c*c+d*d);e>=f&&(this.touchcancel(a),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(a)?this.scrolling=!0:(this.scrolling=!1,a.preventDefault(),this.processTouches(a,this.move))},move:function(a){b.move(a)},touchend:function(a){this.dedupSynthMouse(a),this.processTouches(a,this.up)},up:function(c){c.relatedTarget=a.findTarget(c),b.up(c)},cancel:function(a){b.cancel(a)},touchcancel:function(a){a._cancel=!0,this.processTouches(a,this.cancel)},cleanUpPointer:function(a){c["delete"](a.pointerId),this.removePrimaryPointer(a)},dedupSynthMouse:function(b){var c=a.mouseEvents.lastTouches,e=b.changedTouches[0];if(this.isPrimaryTouch(e)){var f={x:e.clientX,y:e.clientY};c.push(f);var g=function(a,b){var c=a.indexOf(b);c>-1&&a.splice(c,1)}.bind(null,c,f);setTimeout(g,d)}}};a.touchEvents=h}(window.PolymerGestures),function(a){var b=a.dispatcher,c=b.pointermap,d=window.MSPointerEvent&&"number"==typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE,e={events:["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"],register:function(a){a===document&&b.listen(a,this.events)},unregister:function(a){b.unlisten(a,this.events)},POINTER_TYPES:["","unavailable","touch","pen","mouse"],prepareEvent:function(a){var c=a;return c=b.cloneEvent(a),d&&(c.pointerType=this.POINTER_TYPES[a.pointerType]),c._source="ms",c},cleanup:function(a){c["delete"](a)},MSPointerDown:function(d){var e=this.prepareEvent(d);e.target=a.findTarget(d),c.set(d.pointerId,e.target),b.down(e)},MSPointerMove:function(a){var d=this.prepareEvent(a);d.target=c.get(d.pointerId),b.move(d)},MSPointerUp:function(d){var e=this.prepareEvent(d);e.relatedTarget=a.findTarget(d),e.target=c.get(e.pointerId),b.up(e),this.cleanup(d.pointerId)},MSPointerCancel:function(d){var e=this.prepareEvent(d);e.relatedTarget=a.findTarget(d),e.target=c.get(e.pointerId),b.cancel(e),this.cleanup(d.pointerId)}};a.msEvents=e}(window.PolymerGestures),function(a){var b=a.dispatcher,c=b.pointermap,d={events:["pointerdown","pointermove","pointerup","pointercancel"],prepareEvent:function(a){var c=b.cloneEvent(a);return c._source="pointer",c},register:function(a){a===document&&b.listen(a,this.events)},unregister:function(a){b.unlisten(a,this.events)},cleanup:function(a){c["delete"](a)},pointerdown:function(d){var e=this.prepareEvent(d);e.target=a.findTarget(d),c.set(e.pointerId,e.target),b.down(e)},pointermove:function(a){var d=this.prepareEvent(a);d.target=c.get(d.pointerId),b.move(d)},pointerup:function(d){var e=this.prepareEvent(d);e.relatedTarget=a.findTarget(d),e.target=c.get(e.pointerId),b.up(e),this.cleanup(d.pointerId)},pointercancel:function(d){var e=this.prepareEvent(d);e.relatedTarget=a.findTarget(d),e.target=c.get(e.pointerId),b.cancel(e),this.cleanup(d.pointerId)}};a.pointerEvents=d}(window.PolymerGestures),function(a){var b=a.dispatcher,c=window.navigator;if(window.PointerEvent)b.registerSource("pointer",a.pointerEvents);else if(c.msPointerEnabled)b.registerSource("ms",a.msEvents);else if(b.registerSource("mouse",a.mouseEvents),void 0!==window.ontouchstart){b.registerSource("touch",a.touchEvents);var d=c.userAgent.match("Safari")&&!c.userAgent.match("Chrome");d&&document.body.addEventListener("touchstart",function(){})}b.register(document,!0)}(window.PolymerGestures),function(a){var b=a.dispatcher,c=a.eventFactory,d=new a.PointerMap,e={events:["down","move","up"],exposes:["trackstart","track","trackx","tracky","trackend"],defaultActions:{track:"none",trackx:"pan-y",tracky:"pan-x"},WIGGLE_THRESHOLD:4,clampDir:function(a){return a>0?1:-1},calcPositionDelta:function(a,b){var c=0,d=0;return a&&b&&(c=b.pageX-a.pageX,d=b.pageY-a.pageY),{x:c,y:d}},fireTrack:function(a,b,d){var e=d,f=this.calcPositionDelta(e.downEvent,b),g=this.calcPositionDelta(e.lastMoveEvent,b);if(g.x)e.xDirection=this.clampDir(g.x);else if("trackx"===a)return;if(g.y)e.yDirection=this.clampDir(g.y);else if("tracky"===a)return;var h={bubbles:!0,cancelable:!0,trackInfo:e.trackInfo,relatedTarget:b.relatedTarget,pointerType:b.pointerType,pointerId:b.pointerId,_source:"track"};"tracky"!==a&&(h.x=b.x,h.dx=f.x,h.ddx=g.x,h.clientX=b.clientX,h.pageX=b.pageX,h.screenX=b.screenX,h.xDirection=e.xDirection),"trackx"!==a&&(h.dy=f.y,h.ddy=g.y,h.y=b.y,h.clientY=b.clientY,h.pageY=b.pageY,h.screenY=b.screenY,h.yDirection=e.yDirection);var i=c.makeGestureEvent(a,h);e.downTarget.dispatchEvent(i)},down:function(a){if(a.isPrimary&&("mouse"===a.pointerType?1===a.buttons:!0)){var b={downEvent:a,downTarget:a.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};d.set(a.pointerId,b)}},move:function(a){var b=d.get(a.pointerId);if(b){if(!b.tracking){var c=this.calcPositionDelta(b.downEvent,a),e=c.x*c.x+c.y*c.y;e>this.WIGGLE_THRESHOLD&&(b.tracking=!0,b.lastMoveEvent=b.downEvent,this.fireTrack("trackstart",a,b))}b.tracking&&(this.fireTrack("track",a,b),this.fireTrack("trackx",a,b),this.fireTrack("tracky",a,b)),b.lastMoveEvent=a}},up:function(a){var b=d.get(a.pointerId);b&&(b.tracking&&this.fireTrack("trackend",a,b),d.delete(a.pointerId))}};b.registerGesture("track",e)}(window.PolymerGestures),function(a){var b=a.dispatcher,c=a.eventFactory,d={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var a=Date.now()-this.heldPointer.timeStamp,b=this.held?"holdpulse":"hold";this.fireHold(b,a),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(a){a.isPrimary&&!this.heldPointer&&(this.heldPointer=a,this.target=a.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(a){this.heldPointer&&this.heldPointer.pointerId===a.pointerId&&this.cancel()},move:function(a){if(this.heldPointer&&this.heldPointer.pointerId===a.pointerId){var b=a.clientX-this.heldPointer.clientX,c=a.clientY-this.heldPointer.clientY;b*b+c*c>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(a,b){var d={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};b&&(d.holdTime=b);var e=c.makeGestureEvent(a,d);this.target.dispatchEvent(e)}};b.registerGesture("hold",d)}(window.PolymerGestures),function(a){var b=a.dispatcher,c=a.eventFactory,d=new a.PointerMap,e={events:["down","up"],exposes:["tap"],down:function(a){a.isPrimary&&!a.tapPrevented&&d.set(a.pointerId,{target:a.target,buttons:a.buttons,x:a.clientX,y:a.clientY})},shouldTap:function(a,b){return"mouse"===a.pointerType?1===b.buttons:!a.tapPrevented},up:function(b){var e=d.get(b.pointerId);if(e&&this.shouldTap(b,e)){var f=a.targetFinding.LCA(e.target,b.relatedTarget);if(f){var g=c.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:b.clientX,y:b.clientY,detail:b.detail,pointerType:b.pointerType,pointerId:b.pointerId,altKey:b.altKey,ctrlKey:b.ctrlKey,metaKey:b.metaKey,shiftKey:b.shiftKey,_source:"tap"});f.dispatchEvent(g)}}d.delete(b.pointerId)}};c.preventTap=function(a){return function(){a.tapPrevented=!0,d.delete(a.pointerId)}},b.registerGesture("tap",e)}(window.PolymerGestures),function(a){"use strict";function b(a,b){if(!a)throw new Error("ASSERT: "+b)}function c(a){return a>=48&&57>=a}function d(a){return 32===a||9===a||11===a||12===a||160===a||a>=5760&&"\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\ufeff".indexOf(String.fromCharCode(a))>0}function e(a){return 10===a||13===a||8232===a||8233===a}function f(a){return 36===a||95===a||a>=65&&90>=a||a>=97&&122>=a}function g(a){return 36===a||95===a||a>=65&&90>=a||a>=97&&122>=a||a>=48&&57>=a}function h(a){return"this"===a}function i(){for(;Y>X&&d(W.charCodeAt(X));)++X}function j(){var a,b;for(a=X++;Y>X&&(b=W.charCodeAt(X),g(b));)++X;return W.slice(a,X)}function k(){var a,b,c;return a=X,b=j(),c=1===b.length?S.Identifier:h(b)?S.Keyword:"null"===b?S.NullLiteral:"true"===b||"false"===b?S.BooleanLiteral:S.Identifier,{type:c,value:b,range:[a,X]}}function l(){var a,b,c=X,d=W.charCodeAt(X),e=W[X];switch(d){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:return++X,{type:S.Punctuator,value:String.fromCharCode(d),range:[c,X]};default:if(a=W.charCodeAt(X+1),61===a)switch(d){case 37:case 38:case 42:case 43:case 45:case 47:case 60:case 62:case 124:return X+=2,{type:S.Punctuator,value:String.fromCharCode(d)+String.fromCharCode(a),range:[c,X]};case 33:case 61:return X+=2,61===W.charCodeAt(X)&&++X,{type:S.Punctuator,value:W.slice(c,X),range:[c,X]}}}return b=W[X+1],e===b&&"&|".indexOf(e)>=0?(X+=2,{type:S.Punctuator,value:e+b,range:[c,X]}):"<>=!+-*%&|^/".indexOf(e)>=0?(++X,{type:S.Punctuator,value:e,range:[c,X]}):void s({},V.UnexpectedToken,"ILLEGAL")}function m(){var a,d,e;if(e=W[X],b(c(e.charCodeAt(0))||"."===e,"Numeric literal must start with a decimal digit or a decimal point"),d=X,a="","."!==e){for(a=W[X++],e=W[X],"0"===a&&e&&c(e.charCodeAt(0))&&s({},V.UnexpectedToken,"ILLEGAL");c(W.charCodeAt(X));)a+=W[X++];e=W[X]}if("."===e){for(a+=W[X++];c(W.charCodeAt(X));)a+=W[X++];e=W[X]}if("e"===e||"E"===e)if(a+=W[X++],e=W[X],("+"===e||"-"===e)&&(a+=W[X++]),c(W.charCodeAt(X)))for(;c(W.charCodeAt(X));)a+=W[X++];else s({},V.UnexpectedToken,"ILLEGAL");return f(W.charCodeAt(X))&&s({},V.UnexpectedToken,"ILLEGAL"),{type:S.NumericLiteral,value:parseFloat(a),range:[d,X]}}function n(){var a,c,d,f="",g=!1;for(a=W[X],b("'"===a||'"'===a,"String literal must starts with a quote"),c=X,++X;Y>X;){if(d=W[X++],d===a){a="";break}if("\\"===d)if(d=W[X++],d&&e(d.charCodeAt(0)))"\r"===d&&"\n"===W[X]&&++X;else switch(d){case"n":f+="\n";break;case"r":f+="\r";break;case"t":f+=" ";break;case"b":f+="\b";break;case"f":f+="\f";break;case"v":f+="";break;default:f+=d}else{if(e(d.charCodeAt(0)))break;f+=d}}return""!==a&&s({},V.UnexpectedToken,"ILLEGAL"),{type:S.StringLiteral,value:f,octal:g,range:[c,X]}}function o(a){return a.type===S.Identifier||a.type===S.Keyword||a.type===S.BooleanLiteral||a.type===S.NullLiteral}function p(){var a;return i(),X>=Y?{type:S.EOF,range:[X,X]}:(a=W.charCodeAt(X),40===a||41===a||58===a?l():39===a||34===a?n():f(a)?k():46===a?c(W.charCodeAt(X+1))?m():l():c(a)?m():l())}function q(){var a;return a=$,X=a.range[1],$=p(),X=a.range[1],a}function r(){var a;a=X,$=p(),X=a}function s(a,c){var d,e=Array.prototype.slice.call(arguments,2),f=c.replace(/%(\d)/g,function(a,c){return b(cX&&(a.push(bb()),!v(")"));)u(",");return u(")"),a}function E(){var a;return a=q(),o(a)||t(a),Z.createIdentifier(a.value)}function F(){return u("."),E()}function G(){var a;return u("["),a=bb(),u("]"),a}function H(){var a,b,c;for(a=C();;)if(v("["))c=G(),a=Z.createMemberExpression("[",a,c);else if(v("."))c=F(),a=Z.createMemberExpression(".",a,c);else{if(!v("("))break;b=D(),a=Z.createCallExpression(a,b)}return a}function I(){var a,b;return $.type!==S.Punctuator&&$.type!==S.Keyword?b=ab():v("+")||v("-")||v("!")?(a=q(),b=I(),b=Z.createUnaryExpression(a.value,b)):w("delete")||w("void")||w("typeof")?s({},V.UnexpectedToken):b=ab(),b}function J(a){var b=0;if(a.type!==S.Punctuator&&a.type!==S.Keyword)return 0;switch(a.value){case"||":b=1;break;case"&&":b=2;break;case"==":case"!=":case"===":case"!==":b=6;break;case"<":case">":case"<=":case">=":case"instanceof":b=7;break;case"in":b=7;break;case"+":case"-":b=9;break;case"*":case"/":case"%":b=11}return b}function K(){var a,b,c,d,e,f,g,h;if(g=I(),b=$,c=J(b),0===c)return g;for(b.prec=c,q(),e=I(),d=[g,b,e];(c=J($))>0;){for(;d.length>2&&c<=d[d.length-2].prec;)e=d.pop(),f=d.pop().value,g=d.pop(),a=Z.createBinaryExpression(f,g,e),d.push(a);b=q(),b.prec=c,d.push(b),a=I(),d.push(a)}for(h=d.length-1,a=d[h];h>1;)a=Z.createBinaryExpression(d[h-1].value,d[h-2],a),h-=2;return a}function L(){var a,b,c;return a=K(),v("?")&&(q(),b=L(),u(":"),c=L(),a=Z.createConditionalExpression(a,b,c)),a}function M(){var a,b;return a=q(),a.type!==S.Identifier&&t(a),b=v("(")?D():[],Z.createFilter(a.value,b)}function N(){for(;v("|");)q(),M()}function O(){i(),r();var a=bb();a&&(","===$.value||"in"==$.value&&a.type===U.Identifier?Q(a):(N(),"as"===$.value?P(a):Z.createTopLevel(a))),$.type!==S.EOF&&t($)}function P(a){q();var b=q().value;Z.createAsExpression(a,b)}function Q(a){var b;","===$.value&&(q(),$.type!==S.Identifier&&t($),b=q().value),q();var c=bb();N(),Z.createInExpression(a.name,b,c)}function R(a,b){return Z=b,W=a,X=0,Y=W.length,$=null,_={labelSet:{}},O()}var S,T,U,V,W,X,Y,Z,$,_;S={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8},T={},T[S.BooleanLiteral]="Boolean",T[S.EOF]="",T[S.Identifier]="Identifier",T[S.Keyword]="Keyword",T[S.NullLiteral]="Null",T[S.NumericLiteral]="Numeric",T[S.Punctuator]="Punctuator",T[S.StringLiteral]="String",U={ArrayExpression:"ArrayExpression",BinaryExpression:"BinaryExpression",CallExpression:"CallExpression",ConditionalExpression:"ConditionalExpression",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",Identifier:"Identifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ThisExpression:"ThisExpression",UnaryExpression:"UnaryExpression"},V={UnexpectedToken:"Unexpected token %0",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared"};var ab=H,bb=L;a.esprima={parse:R}}(this),function(a){"use strict";function b(a,b,d,e){var f;try{if(f=c(a),f.scopeIdent&&(d.nodeType!==Node.ELEMENT_NODE||"TEMPLATE"!==d.tagName||"bind"!==b&&"repeat"!==b))throw Error("as and in can only be used within ")}catch(g){return void console.error("Invalid expression syntax: "+a,g)}return function(a,b,c){var d=f.getBinding(a,e,c);return f.scopeIdent&&d&&(b.polymerExpressionScopeIdent_=f.scopeIdent,f.indexIdent&&(b.polymerExpressionIndexIdent_=f.indexIdent)),d}}function c(a){var b=q[a];if(!b){var c=new j;esprima.parse(a,c),b=new l(c),q[a]=b}return b}function d(a){this.value=a,this.valueFn_=void 0}function e(a){this.name=a,this.path=Path.get(a)}function f(a,b,c){this.computed="["==c,this.dynamicDeps="function"==typeof a||a.dynamicDeps||this.computed&&!(b instanceof d),this.simplePath=!this.dynamicDeps&&(b instanceof e||b instanceof d)&&(a instanceof f||a instanceof e),this.object=this.simplePath?a:i(a),this.property=!this.computed||this.simplePath?b:i(b)}function g(a,b){this.name=a,this.args=[];for(var c=0;ca},">":function(a,b){return a>b},"<=":function(a,b){return b>=a},">=":function(a,b){return a>=b},"==":function(a,b){return a==b},"!=":function(a,b){return a!=b},"===":function(a,b){return a===b},"!==":function(a,b){return a!==b},"&&":function(a,b){return a&&b},"||":function(a,b){return a||b}};j.prototype={createUnaryExpression:function(a,b){if(!r[a])throw Error("Disallowed operator: "+a);return b=i(b),function(c,d,e){return r[a](b(c,d,e))}},createBinaryExpression:function(a,b,c){if(!s[a])throw Error("Disallowed operator: "+a);switch(b=i(b),c=i(c),a){case"||":return this.dynamicDeps=!0,function(a,d,e){return b(a,d,e)||c(a,d,e)};case"&&":return this.dynamicDeps=!0,function(a,d,e){return b(a,d,e)&&c(a,d,e)}}return function(d,e,f){return s[a](b(d,e,f),c(d,e,f))}},createConditionalExpression:function(a,b,c){return a=i(a),b=i(b),c=i(c),this.dynamicDeps=!0,function(d,e,f){return a(d,e,f)?b(d,e,f):c(d,e,f)}},createIdentifier:function(a){var b=new e(a);return b.type="Identifier",b},createMemberExpression:function(a,b,c){var d=new f(b,c,a);return d.dynamicDeps&&(this.dynamicDeps=!0),d},createCallExpression:function(a,b){if(!(a instanceof e))throw Error("Only identifier function invocations are allowed");var c=new g(a.name,b);return function(a,b,d){return c.transform(a,b,d,!1)}},createLiteral:function(a){return new d(a.value)},createArrayExpression:function(a){for(var b=0;b0;)b=this.filters[d].transform(a,void 0,c,!0,[b]);return this.expression.setValue?this.expression.setValue(a,b):void 0}};var t="@"+Math.random().toString(36).slice(2);p.prototype={styleObject:function(a){var b=[];for(var c in a)b.push(m(c)+": "+a[c]);return b.join("; ")},tokenList:function(a){var b=[];for(var c in a)a[c]&&b.push(c);return b.join(" ")},prepareInstancePositionChanged:function(a){var b=a.polymerExpressionIndexIdent_;if(b)return function(a,c){a.model[b]=c}},prepareBinding:function(a,c,d){var e=Path.get(a);{if(o(a)||!e.valid)return b(a,c,d,this);if(1==e.length)return function(a,b,c){if(c)return e.getValueFrom(a);var d=n(a,e[0]);return new PathObserver(d,e)}}},prepareInstanceModel:function(a){var b=a.polymerExpressionScopeIdent_;if(b){var c=a.templateInstance?a.templateInstance.model:a.model,d=a.polymerExpressionIndexIdent_;return function(a){return u(c,a,b,d)}}}};var u="__proto__"in{}?function(a,b,c,d){var e={};return e[c]=b,e[d]=void 0,e[t]=a,e.__proto__=a,e}:function(a,b,c,d){var e=Object.create(a);return Object.defineProperty(e,c,{value:b,configurable:!0,writable:!0}),Object.defineProperty(e,d,{value:void 0,configurable:!0,writable:!0}),Object.defineProperty(e,t,{value:a,configurable:!0,writable:!0}),e};a.PolymerExpressions=p,p.getExpression=c}(this),Polymer={version:"0.3.5"},"function"==typeof window.Polymer&&(Polymer={}),function(a){function b(a,b){return a&&b&&Object.getOwnPropertyNames(b).forEach(function(c){var d=Object.getOwnPropertyDescriptor(b,c);d&&(Object.defineProperty(a,c,d),"function"==typeof d.value&&(d.value.nom=c))}),a}a.extend=b}(Polymer),function(a){function b(a,b,d){return a?a.stop():a=new c(this),a.go(b,d),a}var c=function(a){this.context=a,this.boundComplete=this.complete.bind(this)};c.prototype={go:function(a,b){this.callback=a;var c;b?(c=setTimeout(this.boundComplete,b),this.handle=function(){clearTimeout(c)}):(c=requestAnimationFrame(this.boundComplete),this.handle=function(){cancelAnimationFrame(c)})},stop:function(){this.handle&&(this.handle(),this.handle=null)},complete:function(){this.handle&&(this.stop(),this.callback.call(this.context))}},a.job=b}(Polymer),function(){var a={};HTMLElement.register=function(b,c){a[b]=c},HTMLElement.getPrototypeForTag=function(b){var c=b?a[b]:HTMLElement.prototype;return c||Object.getPrototypeOf(document.createElement(b))};var b=Event.prototype.stopPropagation;Event.prototype.stopPropagation=function(){this.cancelBubble=!0,b.apply(this,arguments)}}(Polymer),function(a){function b(a){var e=b.caller,g=e.nom,h=e._super;h||(g||(g=e.nom=c.call(this,e)),g||console.warn("called super() on a method not installed declaratively (has no .nom property)"),h=d(e,g,f(this)));var i=h[g];return i?(i._super||d(i,g,h),i.apply(this,a||[])):void 0}function c(a){for(var b=this.__proto__;b&&b!==HTMLElement.prototype;){for(var c,d=Object.getOwnPropertyNames(b),e=0,f=d.length;f>e&&(c=d[e]);e++){var g=Object.getOwnPropertyDescriptor(b,c);if("function"==typeof g.value&&g.value===a)return c}b=b.__proto__}}function d(a,b,c){var d=e(c,b,a);return d[b]&&(d[b].nom=b),a._super=d}function e(a,b,c){for(;a;){if(a[b]!==c&&a[b])return a;a=f(a)}return Object}function f(a){return a.__proto__}a.super=b}(Polymer),function(a){function b(a){return a}function c(a,b){var c=typeof b;return b instanceof Date&&(c="date"),d[c](a,b)}var d={string:b,undefined:b,date:function(a){return new Date(Date.parse(a)||Date.now())},"boolean":function(a){return""===a?!0:"false"===a?!1:!!a},number:function(a){var b=parseFloat(a);return 0===b&&(b=parseInt(a)),isNaN(b)?a:b},object:function(a,b){if(null===b)return a;try{return JSON.parse(a.replace(/'/g,'"'))}catch(c){return a}},"function":function(a,b){return b}};a.deserializeValue=c}(Polymer),function(a){var b=a.extend,c={};c.declaration={},c.instance={},c.publish=function(a,c){for(var d in a)b(c,a[d])},a.api=c}(Polymer),function(a){var b={async:function(a,b,c){Platform.flush(),b=b&&b.length?b:[b];var d=function(){(this[a]||a).apply(this,b)}.bind(this),e=c?setTimeout(d,c):requestAnimationFrame(d);return c?e:~e},cancelAsync:function(a){0>a?cancelAnimationFrame(~a):clearTimeout(a)},fire:function(a,b,c,d,e){var f=c||this,b=null===b||void 0===b?{}:b,g=new CustomEvent(a,{bubbles:void 0!==d?d:!0,cancelable:void 0!==e?e:!0,detail:b});return f.dispatchEvent(g),g},asyncFire:function(){this.async("fire",arguments)},classFollows:function(a,b,c){b&&b.classList.remove(c),a&&a.classList.add(c)},injectBoundHTML:function(a,b){var c=document.createElement("template");c.innerHTML=a;var d=this.instanceTemplate(c);return b&&(b.textContent="",b.appendChild(d)),d}},c=function(){},d={};b.asyncMethod=b.async,a.api.instance.utils=b,a.nop=c,a.nob=d}(Polymer),function(a){var b=window.logFlags||{},c="on-",d={EVENT_PREFIX:c,addHostListeners:function(){var a=this.eventDelegates;b.events&&Object.keys(a).length>0&&console.log("[%s] addHostListeners:",this.localName,a);for(var c in a){var d=a[c];PolymerGestures.addEventListener(this,c,this.element.getEventHandler(this,this,d))}},dispatchMethod:function(a,c,d){if(a){b.events&&console.group("[%s] dispatch [%s]",a.localName,c);var e="function"==typeof c?c:a[c];e&&e[d?"apply":"call"](a,d),b.events&&console.groupEnd(),Platform.flush()}}};a.api.instance.events=d,a.addEventListener=PolymerGestures.addEventListener,a.removeEventListener=PolymerGestures.removeEventListener}(Polymer),function(a){var b={copyInstanceAttributes:function(){var a=this._instanceAttributes;for(var b in a)this.hasAttribute(b)||this.setAttribute(b,a[b])},takeAttributes:function(){if(this._publishLC)for(var a,b=0,c=this.attributes,d=c.length;(a=c[b])&&d>b;b++)this.attributeToProperty(a.name,a.value)},attributeToProperty:function(b,c){var b=this.propertyForAttribute(b);if(b){if(c&&c.search(a.bindPattern)>=0)return;var d=this[b],c=this.deserializeValue(c,d);c!==d&&(this[b]=c)}},propertyForAttribute:function(a){var b=this._publishLC&&this._publishLC[a];return b},deserializeValue:function(b,c){return a.deserializeValue(b,c)},serializeValue:function(a,b){return"boolean"===b?a?"":void 0:"object"!==b&&"function"!==b&&void 0!==a?a:void 0},reflectPropertyToAttribute:function(a){var b=typeof this[a],c=this.serializeValue(this[a],b);void 0!==c?this.setAttribute(a,c):"boolean"===b&&this.removeAttribute(a)}};a.api.instance.attributes=b}(Polymer),function(a){function b(a,b){return a===b?0!==a||1/a===1/b:f(a)&&f(b)?!0:a!==a&&b!==b}function c(a,b){return void 0===b&&null===a?b:null===b||void 0===b?a:b}var d=window.logFlags||{},e={object:void 0,type:"update",name:void 0,oldValue:void 0},f=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},g={createPropertyObserver:function(){var a=this._observeNames;if(a&&a.length){var b=this._propertyObserver=new CompoundObserver(!0);this.registerObserver(b);for(var c,d=0,e=a.length;e>d&&(c=a[d]);d++)b.addPath(this,c),this.observeArrayValue(c,this[c],null)}},openPropertyObserver:function(){this._propertyObserver&&this._propertyObserver.open(this.notifyPropertyChanges,this)},notifyPropertyChanges:function(a,b,c){var d,e,f={};for(var g in b)if(d=c[2*g+1],e=this.observe[d]){var h=b[g],i=a[g];this.observeArrayValue(d,i,h),f[e]||(void 0!==h&&null!==h||void 0!==i&&null!==i)&&(f[e]=!0,this.invokeMethod(e,[h,i,arguments]))}},deliverChanges:function(){this._propertyObserver&&this._propertyObserver.deliver()},propertyChanged_:function(a){this.reflect[a]&&this.reflectPropertyToAttribute(a)},observeArrayValue:function(a,b,c){var e=this.observe[a];if(e&&(Array.isArray(c)&&(d.observe&&console.log("[%s] observeArrayValue: unregister observer [%s]",this.localName,a),this.closeNamedObserver(a+"__array")),Array.isArray(b))){d.observe&&console.log("[%s] observeArrayValue: register observer [%s]",this.localName,a,b);var f=new ArrayObserver(b);f.open(function(a,b){this.invokeMethod(e,[b])},this),this.registerNamedObserver(a+"__array",f)}},emitPropertyChangeRecord:function(a,c,d){if(!b(c,d)&&(this.propertyChanged_(a,c,d),Observer.hasObjectObserve)){var f=this.notifier_;f||(f=this.notifier_=Object.getNotifier(this)),e.object=this,e.name=a,e.oldValue=d,f.notify(e)}},bindToAccessor:function(a,c,d){var e=a+"_",f=a+"Observable_";this[f]=c;var g=this[e],h=this,i=c.open(function(b,c){h[e]=b,h.emitPropertyChangeRecord(a,b,c)});if(d&&!b(g,i)){var j=d(g,i);b(i,j)||(i=j,c.setValue&&c.setValue(i))}this[e]=i,this.emitPropertyChangeRecord(a,i,g);var k={close:function(){c.close(),h[f]=void 0}};return this.registerObserver(k),k},createComputedProperties:function(){if(this._computedNames)for(var a=0;ae&&(c=d[e]);e++)b[c.id]=c},attributeChangedCallback:function(a){"class"!==a&&"style"!==a&&this.attributeToProperty(a,this.getAttribute(a)),this.attributeChanged&&this.attributeChanged.apply(this,arguments)},onMutation:function(a,b){var c=new MutationObserver(function(a){b.call(this,c,a),c.disconnect()}.bind(this));c.observe(a,{childList:!0,subtree:!0})}};c.prototype=d,d.constructor=c,a.Base=c,a.isBase=b,a.api.instance.base=d}(Polymer),function(a){function b(a){return a.__proto__}function c(a,b){var c="",d=!1;b&&(c=b.localName,d=b.hasAttribute("is"));var e=Platform.ShadowCSS.makeScopeSelector(c,d);return Platform.ShadowCSS.shimCssText(a,e)}var d=(window.logFlags||{},window.ShadowDOMPolyfill),e="element",f="controller",g={STYLE_SCOPE_ATTRIBUTE:e,installControllerStyles:function(){var a=this.findStyleScope();if(a&&!this.scopeHasNamedStyle(a,this.localName)){for(var c=b(this),d="";c&&c.element;)d+=c.element.cssTextForScope(f),c=b(c);d&&this.installScopeCssText(d,a)}},installScopeStyle:function(a,b,c){var c=c||this.findStyleScope(),b=b||"";if(c&&!this.scopeHasNamedStyle(c,this.localName+b)){var d="";if(a instanceof Array)for(var e,f=0,g=a.length;g>f&&(e=a[f]);f++)d+=e.textContent+"\n\n";else d=a.textContent;this.installScopeCssText(d,c,b)}},installScopeCssText:function(a,b,e){if(b=b||this.findStyleScope(),e=e||"",b){d&&(a=c(a,b.host));var g=this.element.cssTextToScopeStyle(a,f);Polymer.applyStyleToScope(g,b),this.styleCacheForScope(b)[this.localName+e]=!0}},findStyleScope:function(a){for(var b=a||this;b.parentNode;)b=b.parentNode;return b},scopeHasNamedStyle:function(a,b){var c=this.styleCacheForScope(a);return c[b]},styleCacheForScope:function(a){if(d){var b=a.host?a.host.localName:a.localName;return h[b]||(h[b]={})}return a._scopeStyles=a._scopeStyles||{}}},h={};a.api.instance.styles=g}(Polymer),function(a){function b(a,b){if(1===arguments.length&&"string"!=typeof arguments[0]){b=a;var c=document._currentScript;if(a=c&&c.parentNode&&c.parentNode.getAttribute?c.parentNode.getAttribute("name"):"",!a)throw"Element name could not be inferred."}if(f[a])throw"Already registered (Polymer) prototype for element "+a;e(a,b),d(a)}function c(a,b){h[a]=b}function d(a){h[a]&&(h[a].registerWhenReady(),delete h[a])}function e(a,b){return i[a]=b||{}}function f(a){return i[a]}var g=a.extend,h=(a.api,{}),i={};a.getRegisteredPrototype=f,a.waitingForPrototype=c,window.Polymer=b,g(Polymer,a);var j=Platform.deliverDeclarations();if(j)for(var k,l=0,m=j.length;m>l&&(k=j[l]);l++)b.apply(null,k)}(Polymer),function(a){var b={resolveElementPaths:function(a){Platform.urlResolver.resolveDom(a)},addResolvePathApi:function(){var a=this.getAttribute("assetpath")||"",b=new URL(a,this.ownerDocument.baseURI);this.prototype.resolvePath=function(a,c){var d=new URL(a,c||b);return d.href}}};a.api.declaration.path=b}(Polymer),function(a){function b(a,b){var c=new URL(a.getAttribute("href"),b).href;return"@import '"+c+"';"}function c(a,b){if(a){b===document&&(b=document.head),i&&(b=document.head);var c=d(a.textContent),e=a.getAttribute(h);e&&c.setAttribute(h,e);var f=b.firstElementChild;if(b===document.head){var g="style["+h+"]",j=document.head.querySelectorAll(g);j.length&&(f=j[j.length-1].nextElementSibling)}b.insertBefore(c,f)}}function d(a,b){b=b||document,b=b.createElement?b:b.ownerDocument;var c=b.createElement("style");return c.textContent=a,c}function e(a){return a&&a.__resource||""}function f(a,b){return q?q.call(a,b):void 0}var g=(window.logFlags||{},a.api.instance.styles),h=g.STYLE_SCOPE_ATTRIBUTE,i=window.ShadowDOMPolyfill,j="style",k="@import",l="link[rel=stylesheet]",m="global",n="polymer-scope",o={loadStyles:function(a){var b=this.fetchTemplate(),c=b&&this.templateContent();if(c){this.convertSheetsToStyles(c);var d=this.findLoadableStyles(c);if(d.length){var e=b.ownerDocument.baseURI;return Platform.styleResolver.loadStyles(d,e,a)}}a&&a()},convertSheetsToStyles:function(a){for(var c,e,f=a.querySelectorAll(l),g=0,h=f.length;h>g&&(c=f[g]);g++)e=d(b(c,this.ownerDocument.baseURI),this.ownerDocument),this.copySheetAttributes(e,c),c.parentNode.replaceChild(e,c)},copySheetAttributes:function(a,b){for(var c,d=0,e=b.attributes,f=e.length;(c=e[d])&&f>d;d++)"rel"!==c.name&&"href"!==c.name&&a.setAttribute(c.name,c.value)},findLoadableStyles:function(a){var b=[];if(a)for(var c,d=a.querySelectorAll(j),e=0,f=d.length;f>e&&(c=d[e]);e++)c.textContent.match(k)&&b.push(c);return b},installSheets:function(){this.cacheSheets(),this.cacheStyles(),this.installLocalSheets(),this.installGlobalStyles()},cacheSheets:function(){this.sheets=this.findNodes(l),this.sheets.forEach(function(a){a.parentNode&&a.parentNode.removeChild(a)})},cacheStyles:function(){this.styles=this.findNodes(j+"["+n+"]"),this.styles.forEach(function(a){a.parentNode&&a.parentNode.removeChild(a)})},installLocalSheets:function(){var a=this.sheets.filter(function(a){return!a.hasAttribute(n)}),b=this.templateContent();if(b){var c="";if(a.forEach(function(a){c+=e(a)+"\n"}),c){var f=d(c,this.ownerDocument);b.insertBefore(f,b.firstChild)}}},findNodes:function(a,b){var c=this.querySelectorAll(a).array(),d=this.templateContent();if(d){var e=d.querySelectorAll(a).array();c=c.concat(e)}return b?c.filter(b):c},installGlobalStyles:function(){var a=this.styleForScope(m);c(a,document.head)},cssTextForScope:function(a){var b="",c="["+n+"="+a+"]",d=function(a){return f(a,c)},g=this.sheets.filter(d);g.forEach(function(a){b+=e(a)+"\n\n"});var h=this.styles.filter(d);return h.forEach(function(a){b+=a.textContent+"\n\n"}),b},styleForScope:function(a){var b=this.cssTextForScope(a);return this.cssTextToScopeStyle(b,a)},cssTextToScopeStyle:function(a,b){if(a){var c=d(a);return c.setAttribute(h,this.getAttribute("name")+"-"+b),c}}},p=HTMLElement.prototype,q=p.matches||p.matchesSelector||p.webkitMatchesSelector||p.mozMatchesSelector;a.api.declaration.styles=o,a.applyStyleToScope=c}(Polymer),function(a){var b=(window.logFlags||{},a.api.instance.events),c=b.EVENT_PREFIX,d={};["webkitAnimationStart","webkitAnimationEnd","webkitTransitionEnd","DOMFocusOut","DOMFocusIn","DOMMouseScroll"].forEach(function(a){d[a.toLowerCase()]=a});var e={parseHostEvents:function(){var a=this.prototype.eventDelegates;this.addAttributeDelegates(a)},addAttributeDelegates:function(a){for(var b,c=0;b=this.attributes[c];c++)this.hasEventPrefix(b.name)&&(a[this.removeEventPrefix(b.name)]=b.value.replace("{{","").replace("}}","").trim())},hasEventPrefix:function(a){return a&&"o"===a[0]&&"n"===a[1]&&"-"===a[2]},removeEventPrefix:function(a){return a.slice(f)},findController:function(a){for(;a.parentNode;){if(a.eventController)return a.eventController;a=a.parentNode}return a.host},getEventHandler:function(a,b,c){var d=this;return function(e){a&&a.PolymerBase||(a=d.findController(b));var f=[e,e.detail,e.currentTarget];a.dispatchMethod(a,c,f)}},prepareEventBinding:function(a,b){if(this.hasEventPrefix(b)){var c=this.removeEventPrefix(b);c=d[c]||c;var e=this;return function(b,d,f){function g(){return"{{ "+a+" }}"}var h=e.getEventHandler(void 0,d,a);return PolymerGestures.addEventListener(d,c,h),f?void 0:{open:g,discardChanges:g,close:function(){PolymerGestures.removeEventListener(d,c,h)}}}}}},f=c.length;a.api.declaration.events=e}(Polymer),function(a){var b={inferObservers:function(a){var b,c=a.observe;for(var d in a)"Changed"===d.slice(-7)&&(c||(c=a.observe={}),b=d.slice(0,-7),c[b]=c[b]||d)},explodeObservers:function(a){var b=a.observe;if(b){var c={};for(var d in b)for(var e,f=d.split(" "),g=0;e=f[g];g++)c[e]=b[d];a.observe=c}},optimizePropertyMaps:function(a){if(a.observe){var b=a._observeNames=[];for(var c in a.observe)for(var d,e=c.split(" "),f=0;d=e[f];f++)b.push(d)}if(a.publish){var b=a._publishNames=[];for(var c in a.publish)b.push(c)}if(a.computed){var b=a._computedNames=[];for(var c in a.computed)b.push(c)}},publishProperties:function(a,b){var c=a.publish;c&&(this.requireProperties(c,a,b),a._publishLC=this.lowerCaseMap(c))},requireProperties:function(a,b){b.reflect=b.reflect||{};for(var c in a){var d=a[c];d&&void 0!==d.reflect&&(b.reflect[c]=Boolean(d.reflect),d=d.value),void 0!==d&&(b[c]=d)}},lowerCaseMap:function(a){var b={};for(var c in a)b[c.toLowerCase()]=c;return b},createPropertyAccessor:function(a){var b=this.prototype,c=a+"_",d=a+"Observable_";b[c]=b[a],Object.defineProperty(b,a,{get:function(){var a=this[d];return a&&a.deliver(),this[c]},set:function(b){var e=this[d];if(e)return void e.setValue(b);var f=this[c];return this[c]=b,this.emitPropertyChangeRecord(a,b,f),b},configurable:!0})},createPropertyAccessors:function(a){var b=a._publishNames;if(b&&b.length)for(var c,d=0,e=b.length;e>d&&(c=b[d]);d++)this.createPropertyAccessor(c);var b=a._computedNames;if(b&&b.length)for(var c,d=0,e=b.length;e>d&&(c=b[d]);d++)this.createPropertyAccessor(c)}};a.api.declaration.properties=b}(Polymer),function(a){var b="attributes",c=/\s|,/,d={inheritAttributesObjects:function(a){this.inheritObject(a,"publishLC"),this.inheritObject(a,"_instanceAttributes")},publishAttributes:function(a){var d=this.getAttribute(b);if(d)for(var e,f=a.publish||(a.publish={}),g=d.split(c),h=0,i=g.length;i>h;h++)e=g[h].trim(),e&&void 0===f[e]&&(f[e]=void 0)},accumulateInstanceAttributes:function(){for(var a,b=this.prototype._instanceAttributes,c=this.attributes,d=0,e=c.length;e>d&&(a=c[d]);d++)this.isInstanceAttribute(a.name)&&(b[a.name]=a.value)},isInstanceAttribute:function(a){return!this.blackList[a]&&"on-"!==a.slice(0,3)},blackList:{name:1,"extends":1,constructor:1,noscript:1,assetpath:1,"cache-csstext":1}};d.blackList[b]=1,a.api.declaration.attributes=d}(Polymer),function(a){var b=a.api.declaration.events,c=new PolymerExpressions,d=c.prepareBinding;c.prepareBinding=function(a,e,f){return b.prepareEventBinding(a,e,f)||d.call(c,a,e,f)};var e={syntax:c,fetchTemplate:function(){return this.querySelector("template")},templateContent:function(){var a=this.fetchTemplate();return a&&Platform.templateContent(a)},installBindingDelegate:function(a){a&&(a.bindingDelegate=this.syntax)}};a.api.declaration.mdv=e}(Polymer),function(a){function b(a){if(!Object.__proto__){var b=Object.getPrototypeOf(a);a.__proto__=b,d(b)&&(b.__proto__=Object.getPrototypeOf(b))}}var c=a.api,d=a.isBase,e=a.extend,f=window.ShadowDOMPolyfill,g={register:function(a,b){this.buildPrototype(a,b),this.registerPrototype(a,b),this.publishConstructor()},buildPrototype:function(b,c){var d=a.getRegisteredPrototype(b),e=this.generateBasePrototype(c);this.desugarBeforeChaining(d,e),this.prototype=this.chainPrototypes(d,e),this.desugarAfterChaining(b,c)},desugarBeforeChaining:function(a,b){a.element=this,this.publishAttributes(a,b),this.publishProperties(a,b),this.inferObservers(a),this.explodeObservers(a)},chainPrototypes:function(a,c){this.inheritMetaData(a,c);var d=this.chainObject(a,c);return b(d),d},inheritMetaData:function(a,b){this.inheritObject("observe",a,b),this.inheritObject("publish",a,b),this.inheritObject("reflect",a,b),this.inheritObject("_publishLC",a,b),this.inheritObject("_instanceAttributes",a,b),this.inheritObject("eventDelegates",a,b)},desugarAfterChaining:function(a,b){this.optimizePropertyMaps(this.prototype),this.createPropertyAccessors(this.prototype),this.installBindingDelegate(this.fetchTemplate()),this.installSheets(),this.resolveElementPaths(this),this.accumulateInstanceAttributes(),this.parseHostEvents(),this.addResolvePathApi(),f&&Platform.ShadowCSS.shimStyling(this.templateContent(),a,b),this.prototype.registerCallback&&this.prototype.registerCallback(this)},publishConstructor:function(){var a=this.getAttribute("constructor");a&&(window[a]=this.ctor)},generateBasePrototype:function(a){var b=this.findBasePrototype(a);if(!b){var b=HTMLElement.getPrototypeForTag(a);b=this.ensureBaseApi(b),h[a]=b}return b},findBasePrototype:function(a){return h[a]},ensureBaseApi:function(a){if(a.PolymerBase)return a;var b=Object.create(a);return c.publish(c.instance,b),this.mixinMethod(b,a,c.instance.mdv,"bind"),b},mixinMethod:function(a,b,c,d){var e=function(a){return b[d].apply(this,a)};a[d]=function(){return this.mixinSuper=e,c[d].apply(this,arguments)}},inheritObject:function(a,b,c){var d=b[a]||{};b[a]=this.chainObject(d,c[a])},registerPrototype:function(a,b){var c={prototype:this.prototype},d=this.findTypeExtension(b);d&&(c.extends=d),HTMLElement.register(a,this.prototype),this.ctor=document.registerElement(a,c)},findTypeExtension:function(a){if(a&&a.indexOf("-")<0)return a;var b=this.findBasePrototype(a);return b.element?this.findTypeExtension(b.element.extends):void 0}},h={};g.chainObject=Object.__proto__?function(a,b){return a&&b&&a!==b&&(a.__proto__=b),a}:function(a,b){if(a&&b&&a!==b){var c=Object.create(b);a=e(c,a)}return a},c.declaration.prototype=g}(Polymer),function(a){function b(a){return document.contains(a)?i:h}function c(){return h.length?h[0]:i[0]}function d(a){e.waitToReady=!0,CustomElements.ready=!1,HTMLImports.whenImportsReady(function(){e.addReadyCallback(a),e.waitToReady=!1,e.check()})}var e={wait:function(a){a.__queue||(a.__queue={},f.push(a))},enqueue:function(a,c,d){var e=a.__queue&&!a.__queue.check;return e&&(b(a).push(a),a.__queue.check=c,a.__queue.go=d),0!==this.indexOf(a)},indexOf:function(a){var c=b(a).indexOf(a);return c>=0&&document.contains(a)&&(c+=HTMLImports.useNative||HTMLImports.ready?h.length:1e9),c},go:function(a){var b=this.remove(a);b&&(a.__queue.flushable=!0,this.addToFlushQueue(b),this.check())},remove:function(a){var c=this.indexOf(a);if(0===c)return b(a).shift()},check:function(){var a=this.nextElement();return a&&a.__queue.check.call(a),this.canReady()?(this.ready(),!0):void 0},nextElement:function(){return c()},canReady:function(){return!this.waitToReady&&this.isEmpty()},isEmpty:function(){for(var a,b=0,c=f.length;c>b&&(a=f[b]);b++)if(a.__queue&&!a.__queue.flushable)return;return!0},addToFlushQueue:function(a){g.push(a)},flush:function(){if(!this.flushing){this.flushing=!0;for(var a;g.length;)a=g.shift(),a.__queue.go.call(a),a.__queue=null;this.flushing=!1}},ready:function(){this.flush(),CustomElements.ready===!1&&(CustomElements.upgradeDocumentTree(document),CustomElements.ready=!0),Platform.flush(),requestAnimationFrame(this.flushReadyCallbacks)},addReadyCallback:function(a){a&&j.push(a)},flushReadyCallbacks:function(){if(j)for(var a;j.length;)(a=j.shift())()},waitToReady:!0},f=[],g=[],h=[],i=[],j=[];document.addEventListener("WebComponentsReady",function(){CustomElements.ready=!1}),a.elements=f,a.queue=e,a.whenReady=a.whenPolymerReady=d}(Polymer),function(a){function b(a,b){a?(document.head.appendChild(a),d(b)):b&&b()}function c(a,c){if(a&&a.length){for(var d,e,f=document.createDocumentFragment(),g=0,h=a.length;h>g&&(d=a[g]);g++)e=document.createElement("link"),e.rel="import",e.href=d,f.appendChild(e);b(f,c)}else c&&c()}var d=a.whenPolymerReady;a.import=c,a.importElements=b}(Polymer),function(a){function b(a){return Boolean(HTMLElement.getPrototypeForTag(a))}function c(a){return a&&a.indexOf("-")>=0}var d=a.extend,e=a.api,f=a.queue,g=a.whenPolymerReady,h=a.getRegisteredPrototype,i=a.waitingForPrototype,j=d(Object.create(HTMLElement.prototype),{createdCallback:function(){this.getAttribute("name")&&this.init()},init:function(){this.name=this.getAttribute("name"),this.extends=this.getAttribute("extends"),f.wait(this),this.loadResources(),this.registerWhenReady()
-},registerWhenReady:function(){this.registered||this.waitingForPrototype(this.name)||this.waitingForQueue()||this.waitingForResources()||f.go(this)},_register:function(){c(this.extends)&&!b(this.extends)&&console.warn("%s is attempting to extend %s, an unregistered element or one that was not registered with Polymer.",this.name,this.extends),this.register(this.name,this.extends),this.registered=!0},waitingForPrototype:function(a){return h(a)?void 0:(i(a,this),this.handleNoScript(a),!0)},handleNoScript:function(a){this.hasAttribute("noscript")&&!this.noscript&&(this.noscript=!0,Polymer(a))},waitingForResources:function(){return this._needsResources},waitingForQueue:function(){return f.enqueue(this,this.registerWhenReady,this._register)},loadResources:function(){this._needsResources=!0,this.loadStyles(function(){this._needsResources=!1,this.registerWhenReady()}.bind(this))}});e.publish(e.declaration,j),g(function(){document.body.removeAttribute("unresolved"),document.dispatchEvent(new CustomEvent("polymer-ready",{bubbles:!0}))}),document.registerElement("polymer-element",{prototype:j})}(Polymer),function(){var a=document.createElement("polymer-element");a.setAttribute("name","auto-binding"),a.setAttribute("extends","template"),a.init(),Polymer("auto-binding",{createdCallback:function(){this.syntax=this.bindingDelegate=this.makeSyntax(),Polymer.whenPolymerReady(function(){this.model=this,this.setAttribute("bind",""),this.async(function(){this.marshalNodeReferences(this.parentNode),this.fire("template-bound")})}.bind(this))},makeSyntax:function(){var a=Object.create(Polymer.api.declaration.events),b=this;a.findController=function(){return b.model};var c=new PolymerExpressions,d=c.prepareBinding;return c.prepareBinding=function(b,e,f){return a.prepareEventBinding(b,e,f)||d.call(c,b,e,f)},c}})}();
-//# sourceMappingURL=polymer.js.map
\ No newline at end of file
diff --git a/components/polymer/polymer.js.map b/components/polymer/polymer.js.map
deleted file mode 100644
index 81afef8..0000000
--- a/components/polymer/polymer.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"polymer.js","sources":["../../polymer-gestures/src/scope.js","../../polymer-gestures/src/targetfind.js","../../polymer-gestures/src/touch-action.js","../../polymer-gestures/src/eventFactory.js","../../polymer-gestures/src/pointermap.js","../../polymer-gestures/src/dispatcher.js","../../polymer-gestures/src/mouse.js","../../polymer-gestures/src/touch.js","../../polymer-gestures/src/ms.js","../../polymer-gestures/src/pointer.js","../../polymer-gestures/src/platform-events.js","../../polymer-gestures/src/track.js","../../polymer-gestures/src/hold.js","../../polymer-gestures/src/tap.js","../../polymer-expressions/third_party/esprima/esprima.js","../../polymer-expressions/src/polymer-expressions.js","polymer-versioned.js","../src/boot.js","../src/lib/lang.js","../src/lib/job.js","../src/lib/dom.js","../src/lib/super.js","../src/lib/deserialize.js","../src/api.js","../src/instance/utils.js","../src/instance/events.js","../src/instance/attributes.js","../src/instance/properties.js","../src/instance/mdv.js","../src/instance/base.js","../src/instance/styles.js","../src/declaration/polymer.js","../src/declaration/path.js","../src/declaration/styles.js","../src/declaration/events.js","../src/declaration/properties.js","../src/declaration/attributes.js","../src/declaration/mdv.js","../src/declaration/prototype.js","../src/declaration/queue.js","../src/declaration/import.js","../src/declaration/polymer-element.js","../src/lib/auto-binding.js"],"names":["window","PolymerGestures","scope","HAS_FULL_PATH","pathTest","document","createElement","createShadowRoot","sr","s","appendChild","addEventListener","ev","path","stopPropagation","CustomEvent","bubbles","head","dispatchEvent","parentNode","removeChild","target","shadow","inEl","shadowRoot","webkitShadowRoot","canTarget","Boolean","elementFromPoint","targetingShadow","this","olderShadow","os","olderShadowRoot","se","querySelector","allShadows","element","shadows","push","searchRoot","inRoot","x","y","t","owner","nodeType","Node","DOCUMENT_NODE","DOCUMENT_FRAGMENT_NODE","findTarget","inEvent","clientX","clientY","findTouchAction","n","i","length","ELEMENT_NODE","hasAttribute","getAttribute","host","LCA","a","b","contains","adepth","depth","bdepth","d","walk","u","deepContains","common","insideNode","node","rect","getBoundingClientRect","left","right","top","bottom","targetFinding","bind","shadowSelector","v","selector","rule","attrib2css","selectors","styles","hasTouchAction","style","touchAction","hasShadowRoot","ShadowDOMPolyfill","forEach","r","String","map","el","textContent","MOUSE_PROPS","MOUSE_DEFAULTS","NOP_FACTORY","eventFactory","preventTap","makeBaseEvent","inType","inDict","e","createEvent","initEvent","cancelable","makeGestureEvent","Object","create","k","keys","makePointerEvent","p","buttons","pressure","pointerId","width","height","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","_source","PointerMap","USE_MAP","m","Map","pointers","POINTERS_FN","values","prototype","size","set","inId","indexOf","has","delete","splice","get","clear","callback","thisArg","call","CLONE_PROPS","CLONE_DEFAULTS","HAS_SVG_INSTANCE","SVGElementInstance","dispatcher","pointermap","eventMap","eventSources","eventSourceList","gestures","dependencyMap","down","listeners","index","up","gestureQueue","registerSource","name","source","newEvents","events","registerGesture","obj","g","exposes","toLowerCase","register","initial","es","l","unregister","fireEvent","move","type","fillGestureQueue","cancel","tapPrevented","eventHandler","_handledByPG","fn","listen","addEvent","unlisten","removeEvent","eventName","boundHandler","removeEventListener","makeEvent","preventDefault","_target","cloneEvent","eventCopy","correspondingUseElement","clone","gestureTrigger","j","enabled","requestAnimationFrame","boundGestureTrigger","activateGesture","gesture","dep","recognizer","_pgListeners","actionNode","defaultActions","setAttribute","handler","capture","deactivateGesture","DEDUP_DIST","WHICH_TO_BUTTONS","HAS_BUTTONS","MouseEvent","mouseEvents","POINTER_ID","POINTER_TYPE","lastTouches","isEventSimulatedFromTouch","lts","dx","Math","abs","dy","prepareEvent","which","mousedown","mouseup","mousemove","cleanupMouse","relatedTarget","DEDUP_TIMEOUT","Array","CLICK_COUNT_TIMEOUT","HYSTERESIS","HAS_TOUCH_ACTION","touchEvents","scrollTypes","EMITTER","XSCROLLER","YSCROLLER","touchActionToScrollType","st","firstTouch","isPrimaryTouch","inTouch","identifier","setPrimaryTouch","firstXY","X","Y","scrolling","cancelResetClickCount","removePrimaryPointer","inPointer","resetClickCount","clickCount","resetId","setTimeout","clearTimeout","typeToButtons","ret","touch","id","currentTouchEvent","fastPath","touchToPointer","cte","detail","webkitRadiusX","radiusX","webkitRadiusY","radiusY","webkitForce","force","self","processTouches","inFunction","tl","changedTouches","_cancel","cleanUpPointer","shouldScroll","scrollAxis","oa","da","doa","findTouch","inTL","vacuumTouches","touches","value","key","touchstart","dedupSynthMouse","touchmove","dd","sqrt","touchcancel","touchend","lt","HAS_BITMAP_TYPE","MSPointerEvent","MSPOINTER_TYPE_MOUSE","msEvents","POINTER_TYPES","cleanup","MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel","pointerEvents","pointerdown","pointermove","pointerup","pointercancel","nav","navigator","PointerEvent","msPointerEnabled","undefined","ontouchstart","isSafari","userAgent","match","body","track","trackx","tracky","WIGGLE_THRESHOLD","clampDir","inDelta","calcPositionDelta","inA","inB","pageX","pageY","fireTrack","inTrackingData","downEvent","lastMoveEvent","xDirection","yDirection","gestureProto","trackInfo","ddx","screenX","ddy","screenY","downTarget","tracking","hold","HOLD_DELAY","heldPointer","holdJob","pulse","Date","now","timeStamp","held","fireHold","clearInterval","setInterval","inHoldTime","holdTime","tap","shouldTap","downState","start","altKey","ctrlKey","metaKey","shiftKey","global","assert","condition","message","Error","isDecimalDigit","ch","isWhiteSpace","fromCharCode","isLineTerminator","isIdentifierStart","isIdentifierPart","isKeyword","skipWhitespace","charCodeAt","getIdentifier","slice","scanIdentifier","Token","Identifier","Keyword","NullLiteral","BooleanLiteral","range","scanPunctuator","code2","ch2","code","ch1","Punctuator","throwError","Messages","UnexpectedToken","scanNumericLiteral","number","NumericLiteral","parseFloat","scanStringLiteral","quote","str","octal","StringLiteral","isIdentifierName","token","advance","EOF","lex","lookahead","peek","pos","messageFormat","error","args","arguments","msg","replace","whole","description","throwUnexpected","expect","matchKeyword","keyword","parseArrayInitialiser","elements","parseExpression","delegate","createArrayExpression","parseObjectPropertyKey","createLiteral","createIdentifier","parseObjectProperty","createProperty","parseObjectInitialiser","properties","createObjectExpression","parseGroupExpression","expr","parsePrimaryExpression","createThisExpression","parseArguments","parseNonComputedProperty","parseNonComputedMember","parseComputedMember","parseLeftHandSideExpression","property","createMemberExpression","createCallExpression","parseUnaryExpression","parsePostfixExpression","createUnaryExpression","binaryPrecedence","prec","parseBinaryExpression","stack","operator","pop","createBinaryExpression","parseConditionalExpression","consequent","alternate","createConditionalExpression","parseFilter","createFilter","parseFilters","parseTopLevel","Syntax","parseInExpression","parseAsExpression","createTopLevel","createAsExpression","indexName","createInExpression","parse","inDelegate","state","labelSet","TokenName","ArrayExpression","BinaryExpression","CallExpression","ConditionalExpression","EmptyStatement","ExpressionStatement","Literal","LabeledStatement","LogicalExpression","MemberExpression","ObjectExpression","Program","Property","ThisExpression","UnaryExpression","UnknownLabel","Redeclaration","esprima","prepareBinding","expressionText","filterRegistry","expression","getExpression","scopeIdent","tagName","ex","console","model","oneTime","binding","getBinding","polymerExpressionScopeIdent_","indexIdent","polymerExpressionIndexIdent_","expressionParseCache","ASTDelegate","Expression","valueFn_","IdentPath","Path","object","accessor","computed","dynamicDeps","simplePath","getFn","Filter","notImplemented","arg","valueFn","filters","deps","currentPath","ConstantObservable","value_","convertStylePropertyName","c","findScope","prop","parentScopeName","hasOwnProperty","isLiteralExpression","pathString","isNaN","Number","PolymerExpressions","observer","addPath","getValueFrom","setValue","newValue","setValueFrom",{"end":{"file":"../../polymer-expressions/src/polymer-expressions.js","comments_before":[],"nlb":false,"endpos":3539,"pos":3531,"col":8,"line":117,"value":"fullPath","type":"name"},"start":{"file":"../../polymer-expressions/src/polymer-expressions.js","comments_before":[],"nlb":false,"endpos":3539,"pos":3531,"col":8,"line":117,"value":"fullPath","type":"name"},"name":"fullPath"},"fullPath","fullPath_","parts","context","propName","transform","toModelDirection","initialArgs","toModel","toDOM","apply","unaryOperators","+","-","!","binaryOperators","*","/","%","<",">","<=",">=","==","!=","===","!==","&&","||","op","argument","test","ident","filter","arr","kind","open","discardChanges","deliver","close","firstTime","firstValue","startReset","getValue","finishReset","setValueFn","CompoundObserver","ObserverTransform","count","random","toString","styleObject","join","tokenList","tokens","prepareInstancePositionChanged","template","templateInstance","valid","PathObserver","prepareInstanceModel","scopeName","parentScope","createScopeObject","__proto__","defineProperty","configurable","writable","Polymer","version","extend","api","getOwnPropertyNames","pd","getOwnPropertyDescriptor","nom","job","wait","stop","Job","go","inContext","boundComplete","complete","h","handle","cancelAnimationFrame","registry","HTMLElement","tag","getPrototypeForTag","getPrototypeOf","originalStopPropagation","Event","cancelBubble","$super","arrayOfArgs","caller","_super","nameInThis","warn","memoizeSuper","n$","method","proto","nextSuper","super","noopHandler","deserializeValue","currentValue","inferredType","typeHandlers","string","date","boolean","parseInt","JSON","function","declaration","instance","publish","apis","utils","async","timeout","Platform","flush","cancelAsync","fire","onNode","event","asyncFire","classFollows","anew","old","className","classList","remove","add","injectBoundHTML","html","innerHTML","fragment","instanceTemplate","nop","nob","asyncMethod","log","logFlags","EVENT_PREFIX","addHostListeners","eventDelegates","localName","methodName","getEventHandler","dispatchMethod","group","groupEnd","attributes","copyInstanceAttributes","a$","_instanceAttributes","takeAttributes","_publishLC","attributeToProperty","propertyForAttribute","search","bindPattern","stringValue","serializeValue","reflectPropertyToAttribute","serializedValue","removeAttribute","areSameValue","numberIsNaN","resolveBindingValue","oldValue","updateRecord","createPropertyObserver","_observeNames","o","_propertyObserver","registerObserver","observeArrayValue","openPropertyObserver","notifyPropertyChanges","newValues","oldValues","paths","called","observe","ov","nv","invokeMethod","deliverChanges","propertyChanged_","reflect","callbackName","isArray","closeNamedObserver","ArrayObserver","registerNamedObserver","emitPropertyChangeRecord","Observer","hasObjectObserve","notifier","notifier_","getNotifier","notify","bindToAccessor","observable","resolveFn","privateName","privateObservable","resolvedValue","createComputedProperties","_computedNames","syntax","bindProperty","_observers","closeObservers","observers","o$","_namedObservers","closeNamedObservers","mdv","bindingDelegate","dom","createInstance","bindings_","enableBindingsReflection","path_","_recordBinding","mixinSuper","bindFinished","makeElementReady","asyncUnbindAll","_unbound","unbind","_unbindAllJob","unbindAll","cancelUnbindAll","mustachePattern","isBase","PolymerBase","base","created","ready","createdCallback","prepareElement","ownerDocument","isStagingDocument","_elementPrepared","shadowRoots","_readied","parseDeclarations","attachedCallback","attached","enteredView","hasBeenAttached","domReady","detachedCallback","preventDispose","detached","leftView","enteredViewCallback","leftViewCallback","enteredDocumentCallback","leftDocumentCallback","parseDeclaration","elementElement","fetchTemplate","root","shadowFromTemplate","shadowRootReady","lightFromTemplate","refNode","eventController","insertBefore","marshalNodeReferences","$","querySelectorAll","attributeChangedCallback","attributeChanged","onMutation","listener","MutationObserver","mutations","disconnect","childList","subtree","constructor","Base","shimCssText","cssText","is","ShadowCSS","makeScopeSelector","hasShadowDOMPolyfill","STYLE_SCOPE_ATTRIBUTE","STYLE_CONTROLLER_SCOPE","installControllerStyles","findStyleScope","scopeHasNamedStyle","cssTextForScope","installScopeCssText","installScopeStyle","cssTextToScopeStyle","applyStyleToScope","styleCacheForScope","cache","polyfillScopeStyleCache","_scopeStyles","script","_currentScript","getRegisteredPrototype","registerPrototype","notifyPrototype","waitingForPrototype","client","waitPrototype","registerWhenReady","prototypesByName","declarations","deliverDeclarations","resolveElementPaths","urlResolver","resolveDom","addResolvePathApi","assetPath","URL","baseURI","resolvePath","urlPath","href","importRuleForSheet","sheet","baseUrl","createStyleElement","attr","firstElementChild","s$","nextElementSibling","cssTextFromSheet","__resource","matchesSelector","inSelector","matches","STYLE_SELECTOR","STYLE_LOADABLE_MATCH","SHEET_SELECTOR","STYLE_GLOBAL_SCOPE","SCOPE_ATTR","loadStyles","content","templateContent","convertSheetsToStyles","findLoadableStyles","templateUrl","styleResolver","copySheetAttributes","replaceChild","link","loadables","installSheets","cacheSheets","cacheStyles","installLocalSheets","installGlobalStyles","sheets","findNodes","firstChild","matcher","nodes","array","templateNodes","concat","styleForScope","scopeDescriptor","webkitMatchesSelector","mozMatchesSelector","mixedCaseEventTypes","parseHostEvents","delegates","addAttributeDelegates","hasEventPrefix","removeEventPrefix","trim","prefixLength","findController","controller","currentTarget","prepareEventBinding","eventType","bindingValue","inferObservers","explodeObservers","exploded","ni","names","split","optimizePropertyMaps","_publishNames","publishProperties","requireProperties","lowerCaseMap","propertyInfos","createPropertyAccessor","createPropertyAccessors","ATTRIBUTES_ATTRIBUTE","ATTRIBUTES_REGEX","inheritAttributesObjects","inheritObject","publishAttributes","accumulateInstanceAttributes","clonable","isInstanceAttribute","blackList","extends","noscript","assetpath","cache-csstext","installBindingDelegate","ensurePrototypeTraversal","ancestor","extendeeName","buildPrototype","publishConstructor","extension","generateBasePrototype","desugarBeforeChaining","chainPrototypes","desugarAfterChaining","inheritMetaData","chained","chainObject","extendee","shimStyling","registerCallback","symbol","ctor","extnds","findBasePrototype","ensureBaseApi","memoizedBases","extended","mixinMethod","info","typeExtension","findTypeExtension","registerElement","inherited","queueForElement","mainQueue","importQueue","nextQueued","whenPolymerReady","queue","waitToReady","CustomElements","HTMLImports","whenImportsReady","addReadyCallback","check","__queue","enqueue","shouldAdd","useNative","readied","flushable","addToFlushQueue","shift","nextElement","canReady","isEmpty","flushQueue","flushing","upgradeDocumentTree","flushReadyCallbacks","readyCallbacks","whenReady","importElements","elementOrFragment","importUrls","urls","url","frag","createDocumentFragment","rel","import","isRegistered","isCustomTag","init","loadResources","registered","waitingForQueue","waitingForResources","_register","handleNoScript","_needsResources","makeSyntax"],"mappings":";;;;;;;;;;AASAA,OAAOC,mBCAP,SAAUC,GACR,GAAIC,IAAgB,EAGhBC,EAAWC,SAASC,cAAc,OACtC,IAAIF,EAASG,iBAAkB,CAC7B,GAAIC,GAAKJ,EAASG,mBACdE,EAAIJ,SAASC,cAAc,OAC/BE,GAAGE,YAAYD,GACfL,EAASO,iBAAiB,WAAY,SAASC,GACzCA,EAAGC,OAELV,EAAgBS,EAAGC,KAAK,KAAOJ,GAEjCG,EAAGE,mBAEL,IAAIF,GAAK,GAAIG,aAAY,YAAaC,SAAS,GAE/CX,UAASY,KAAKP,YAAYN,GAC1BK,EAAES,cAAcN,GAChBR,EAASe,WAAWC,YAAYhB,GAChCI,EAAKC,EAAI,KAEXL,EAAW,IAEX,IAAIiB,IACFC,OAAQ,SAASC,GACf,MAAIA,GACKA,EAAKC,YAAcD,EAAKE,iBADjC,QAIFC,UAAW,SAASJ,GAClB,MAAOA,IAAUK,QAAQL,EAAOM,mBAElCC,gBAAiB,SAASN,GACxB,GAAId,GAAIqB,KAAKR,OAAOC,EACpB,OAAIO,MAAKJ,UAAUjB,GACVA,EADT,QAIFsB,YAAa,SAAST,GACpB,GAAIU,GAAKV,EAAOW,eAChB,KAAKD,EAAI,CACP,GAAIE,GAAKZ,EAAOa,cAAc,SAC1BD,KACFF,EAAKE,EAAGD,iBAGZ,MAAOD,IAETI,WAAY,SAASC,GAEnB,IADA,GAAIC,MAAc7B,EAAIqB,KAAKR,OAAOe,GAC5B5B,GACJ6B,EAAQC,KAAK9B,GACbA,EAAIqB,KAAKC,YAAYtB,EAEvB,OAAO6B,IAETE,WAAY,SAASC,EAAQC,EAAGC,GAC9B,GAAIC,GAAOpC,C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,GAAIH,aAAY,iBAAkBC,SAAS,OAM/CX,SAAS4/B,gBAAgB,mBAAoBt3B,UAAWA,KAEvDwf,SCnGH,WAEE,GAAI9lB,GAAUhC,SAASC,cAAc,kBACrC+B,GAAQqL,aAAa,OAAQ,gBAC7BrL,EAAQqL,aAAa,UAAW,YAChCrL,EAAQsgC,OAERxa,QAAQ,gBAENoL,gBAAiB,WACfzxB,KAAK0vB,OAAS1vB,KAAKmwB,gBAAkBnwB,KAAKqhC,aAG1Chb,QAAQoY,iBAAiB,WACvBz+B,KAAKmf,MAAQnf,KACbA,KAAK4L,aAAa,OAAQ,IAG1B5L,KAAK4pB,MAAM,WAIT5pB,KAAKwzB,sBAAsBxzB,KAAKX,YAGhCW,KAAKiqB,KAAK,qBAEZ5mB,KAAKrD,QAGTqhC,WAAY,WACV,GAAIv4B,GAASzD,OAAOC,OAAO+gB,QAAQG,IAAI+C,YAAYzgB,QAC/CmH,EAAOjQ,IACX8I,GAAOwxB,eAAiB,WAAa,MAAOrqB,GAAKkP,MAEjD,IAAIuQ,GAAS,GAAIjO,oBACb/C,EAAiBgR,EAAOhR,cAK5B,OAJAgR,GAAOhR,eAAiB,SAAS4C,EAAY3Y,EAAM9F,GACjD,MAAOiG,GAAO2xB,oBAAoBnZ,EAAY3Y,EAAM9F,IAC7C6b,EAAejX,KAAKioB,EAAQpO,EAAY3Y,EAAM9F,IAEhD6sB","sourcesContent":["/**\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 */\nwindow.PolymerGestures = {};\n","/*\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 var HAS_FULL_PATH = false;\n\n // test for full event path support\n var pathTest = document.createElement('meta');\n if (pathTest.createShadowRoot) {\n var sr = pathTest.createShadowRoot();\n var s = document.createElement('span');\n sr.appendChild(s);\n pathTest.addEventListener('testpath', function(ev) {\n if (ev.path) {\n // if the span is in the event path, then path[0] is the real source for all events\n HAS_FULL_PATH = ev.path[0] === s;\n }\n ev.stopPropagation();\n });\n var ev = new CustomEvent('testpath', {bubbles: true});\n // must add node to DOM to trigger event listener\n document.head.appendChild(pathTest);\n s.dispatchEvent(ev);\n pathTest.parentNode.removeChild(pathTest);\n sr = s = null;\n }\n pathTest = null;\n\n var target = {\n shadow: function(inEl) {\n if (inEl) {\n return inEl.shadowRoot || inEl.webkitShadowRoot;\n }\n },\n canTarget: function(shadow) {\n return shadow && Boolean(shadow.elementFromPoint);\n },\n targetingShadow: function(inEl) {\n var s = this.shadow(inEl);\n if (this.canTarget(s)) {\n return s;\n }\n },\n olderShadow: function(shadow) {\n var os = shadow.olderShadowRoot;\n if (!os) {\n var se = shadow.querySelector('shadow');\n if (se) {\n os = se.olderShadowRoot;\n }\n }\n return os;\n },\n allShadows: function(element) {\n var shadows = [], s = this.shadow(element);\n while(s) {\n shadows.push(s);\n s = this.olderShadow(s);\n }\n return shadows;\n },\n searchRoot: function(inRoot, x, y) {\n var t, st, sr, os;\n if (inRoot) {\n t = inRoot.elementFromPoint(x, y);\n if (t) {\n // found element, check if it has a ShadowRoot\n sr = this.targetingShadow(t);\n } else if (inRoot !== document) {\n // check for sibling roots\n sr = this.olderShadow(inRoot);\n }\n // search other roots, fall back to light dom element\n return this.searchRoot(sr, x, y) || t;\n }\n },\n owner: function(element) {\n if (!element) {\n return document;\n }\n var s = element;\n // walk up until you hit the shadow root or document\n while (s.parentNode) {\n s = s.parentNode;\n }\n // the owner element is expected to be a Document or ShadowRoot\n if (s.nodeType != Node.DOCUMENT_NODE && s.nodeType != Node.DOCUMENT_FRAGMENT_NODE) {\n s = document;\n }\n return s;\n },\n findTarget: function(inEvent) {\n if (HAS_FULL_PATH && inEvent.path) {\n return inEvent.path[0];\n }\n var x = inEvent.clientX, y = inEvent.clientY;\n // if the listener is in the shadow root, it is much faster to start there\n var s = this.owner(inEvent.target);\n // if x, y is not in this root, fall back to document search\n if (!s.elementFromPoint(x, y)) {\n s = document;\n }\n return this.searchRoot(s, x, y);\n },\n findTouchAction: function(inEvent) {\n var n;\n if (HAS_FULL_PATH && inEvent.path) {\n var path = inEvent.path;\n for (var i = 0; i < path.length; i++) {\n n = path[i];\n if (n.nodeType === Node.ELEMENT_NODE && n.hasAttribute('touch-action')) {\n return n.getAttribute('touch-action');\n }\n }\n } else {\n n = inEvent.target;\n while(n) {\n if (n.hasAttribute('touch-action')) {\n return n.getAttribute('touch-action');\n }\n n = n.parentNode || n.host;\n }\n }\n // auto is default\n return \"auto\";\n },\n LCA: function(a, b) {\n if (a === b) {\n return a;\n }\n if (a && !b) {\n return a;\n }\n if (b && !a) {\n return b;\n }\n if (!b && !a) {\n return document;\n }\n // fast case, a is a direct descendant of b or vice versa\n if (a.contains && a.contains(b)) {\n return a;\n }\n if (b.contains && b.contains(a)) {\n return b;\n }\n var adepth = this.depth(a);\n var bdepth = this.depth(b);\n var d = adepth - bdepth;\n if (d >= 0) {\n a = this.walk(a, d);\n } else {\n b = this.walk(b, -d);\n }\n while (a && b && a !== b) {\n a = a.parentNode || a.host;\n b = b.parentNode || b.host;\n }\n return a;\n },\n walk: function(n, u) {\n for (var i = 0; n && (i < u); i++) {\n n = n.parentNode || n.host;\n }\n return n;\n },\n depth: function(n) {\n var d = 0;\n while(n) {\n d++;\n n = n.parentNode || n.host;\n }\n return d;\n },\n deepContains: function(a, b) {\n var common = this.LCA(a, b);\n // if a is the common ancestor, it must \"deeply\" contain b\n return common === a;\n },\n insideNode: function(node, x, y) {\n var rect = node.getBoundingClientRect();\n return (rect.left <= x) && (x <= rect.right) && (rect.top <= y) && (y <= rect.bottom);\n }\n };\n scope.targetFinding = target;\n /**\n * Given an event, finds the \"deepest\" node that could have been the original target before ShadowDOM retargetting\n *\n * @param {Event} Event An event object with clientX and clientY properties\n * @return {Element} The probable event origninator\n */\n scope.findTarget = target.findTarget.bind(target);\n /**\n * Determines if the \"container\" node deeply contains the \"containee\" node, including situations where the \"containee\" is contained by one or more ShadowDOM\n * roots.\n *\n * @param {Node} container\n * @param {Node} containee\n * @return {Boolean}\n */\n scope.deepContains = target.deepContains.bind(target);\n\n /**\n * Determines if the x/y position is inside the given node.\n *\n * Example:\n *\n * function upHandler(event) {\n * var innode = PolymerGestures.insideNode(event.target, event.clientX, event.clientY);\n * if (innode) {\n * // wait for tap?\n * } else {\n * // tap will never happen\n * }\n * }\n *\n * @param {Node} node\n * @param {Number} x Screen X position\n * @param {Number} y screen Y position\n * @return {Boolean}\n */\n scope.insideNode = target.insideNode;\n\n})(window.PolymerGestures);\n","/*\n *\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() {\n function shadowSelector(v) {\n return 'html /deep/ ' + selector(v);\n }\n function selector(v) {\n return '[touch-action=\"' + v + '\"]';\n }\n function rule(v) {\n return '{ -ms-touch-action: ' + v + '; touch-action: ' + v + ';}';\n }\n var attrib2css = [\n 'none',\n 'auto',\n 'pan-x',\n 'pan-y',\n {\n rule: 'pan-x pan-y',\n selectors: [\n 'pan-x pan-y',\n 'pan-y pan-x'\n ]\n },\n 'manipulation'\n ];\n var styles = '';\n // only install stylesheet if the browser has touch action support\n var hasTouchAction = typeof document.head.style.touchAction === 'string';\n // only add shadow selectors if shadowdom is supported\n var hasShadowRoot = !window.ShadowDOMPolyfill && document.head.createShadowRoot;\n\n if (hasTouchAction) {\n attrib2css.forEach(function(r) {\n if (String(r) === r) {\n styles += selector(r) + rule(r) + '\\n';\n if (hasShadowRoot) {\n styles += shadowSelector(r) + rule(r) + '\\n';\n }\n } else {\n styles += r.selectors.map(selector) + rule(r.rule) + '\\n';\n if (hasShadowRoot) {\n styles += r.selectors.map(shadowSelector) + rule(r.rule) + '\\n';\n }\n }\n });\n\n var el = document.createElement('style');\n el.textContent = styles;\n document.head.appendChild(el);\n }\n})();\n","/*\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/**\n * This is the constructor for new PointerEvents.\n *\n * New Pointer Events must be given a type, and an optional dictionary of\n * initialization properties.\n *\n * Due to certain platform requirements, events returned from the constructor\n * identify as MouseEvents.\n *\n * @constructor\n * @param {String} inType The type of the event to create.\n * @param {Object} [inDict] An optional dictionary of initial event properties.\n * @return {Event} A new PointerEvent of type `inType` and initialized with properties from `inDict`.\n */\n(function(scope) {\n\n var MOUSE_PROPS = [\n 'bubbles',\n 'cancelable',\n 'view',\n 'detail',\n 'screenX',\n 'screenY',\n 'clientX',\n 'clientY',\n 'ctrlKey',\n 'altKey',\n 'shiftKey',\n 'metaKey',\n 'button',\n 'relatedTarget',\n 'pageX',\n 'pageY'\n ];\n\n var MOUSE_DEFAULTS = [\n false,\n false,\n null,\n null,\n 0,\n 0,\n 0,\n 0,\n false,\n false,\n false,\n false,\n 0,\n null,\n 0,\n 0\n ];\n\n var NOP_FACTORY = function(){ return function(){}; };\n\n var eventFactory = {\n // TODO(dfreedm): this is overridden by tap recognizer, needs review\n preventTap: NOP_FACTORY,\n makeBaseEvent: function(inType, inDict) {\n var e = document.createEvent('Event');\n e.initEvent(inType, inDict.bubbles || false, inDict.cancelable || false);\n e.preventTap = eventFactory.preventTap(e);\n return e;\n },\n makeGestureEvent: function(inType, inDict) {\n inDict = inDict || Object.create(null);\n\n var e = this.makeBaseEvent(inType, inDict);\n for (var i = 0, keys = Object.keys(inDict), k; i < keys.length; i++) {\n k = keys[i];\n e[k] = inDict[k];\n }\n return e;\n },\n makePointerEvent: function(inType, inDict) {\n inDict = inDict || Object.create(null);\n\n var e = this.makeBaseEvent(inType, inDict);\n // define inherited MouseEvent properties\n for(var i = 0, p; i < MOUSE_PROPS.length; i++) {\n p = MOUSE_PROPS[i];\n e[p] = inDict[p] || MOUSE_DEFAULTS[i];\n }\n e.buttons = inDict.buttons || 0;\n\n // Spec requires that pointers without pressure specified use 0.5 for down\n // state and 0 for up state.\n var pressure = 0;\n if (inDict.pressure) {\n pressure = inDict.pressure;\n } else {\n pressure = e.buttons ? 0.5 : 0;\n }\n\n // add x/y properties aliased to clientX/Y\n e.x = e.clientX;\n e.y = e.clientY;\n\n // define the properties of the PointerEvent interface\n e.pointerId = inDict.pointerId || 0;\n e.width = inDict.width || 0;\n e.height = inDict.height || 0;\n e.pressure = pressure;\n e.tiltX = inDict.tiltX || 0;\n e.tiltY = inDict.tiltY || 0;\n e.pointerType = inDict.pointerType || '';\n e.hwTimestamp = inDict.hwTimestamp || 0;\n e.isPrimary = inDict.isPrimary || false;\n e._source = inDict._source || '';\n return e;\n }\n };\n\n scope.eventFactory = eventFactory;\n})(window.PolymerGestures);\n","/*\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/**\n * This module implements an map of pointer states\n */\n(function(scope) {\n var USE_MAP = window.Map && window.Map.prototype.forEach;\n var POINTERS_FN = function(){ return this.size; };\n function PointerMap() {\n if (USE_MAP) {\n var m = new Map();\n m.pointers = POINTERS_FN;\n return m;\n } else {\n this.keys = [];\n this.values = [];\n }\n }\n\n PointerMap.prototype = {\n set: function(inId, inEvent) {\n var i = this.keys.indexOf(inId);\n if (i > -1) {\n this.values[i] = inEvent;\n } else {\n this.keys.push(inId);\n this.values.push(inEvent);\n }\n },\n has: function(inId) {\n return this.keys.indexOf(inId) > -1;\n },\n 'delete': function(inId) {\n var i = this.keys.indexOf(inId);\n if (i > -1) {\n this.keys.splice(i, 1);\n this.values.splice(i, 1);\n }\n },\n get: function(inId) {\n var i = this.keys.indexOf(inId);\n return this.values[i];\n },\n clear: function() {\n this.keys.length = 0;\n this.values.length = 0;\n },\n // return value, key, map\n forEach: function(callback, thisArg) {\n this.values.forEach(function(v, i) {\n callback.call(thisArg, v, this.keys[i], this);\n }, this);\n },\n pointers: function() {\n return this.keys.length;\n }\n };\n\n scope.PointerMap = PointerMap;\n})(window.PolymerGestures);\n","/*\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 var CLONE_PROPS = [\n // MouseEvent\n 'bubbles',\n 'cancelable',\n 'view',\n 'detail',\n 'screenX',\n 'screenY',\n 'clientX',\n 'clientY',\n 'ctrlKey',\n 'altKey',\n 'shiftKey',\n 'metaKey',\n 'button',\n 'relatedTarget',\n // DOM Level 3\n 'buttons',\n // PointerEvent\n 'pointerId',\n 'width',\n 'height',\n 'pressure',\n 'tiltX',\n 'tiltY',\n 'pointerType',\n 'hwTimestamp',\n 'isPrimary',\n // event instance\n 'type',\n 'target',\n 'currentTarget',\n 'which',\n 'pageX',\n 'pageY',\n 'timeStamp',\n // gesture addons\n 'preventTap',\n 'tapPrevented',\n '_source'\n ];\n\n var CLONE_DEFAULTS = [\n // MouseEvent\n false,\n false,\n null,\n null,\n 0,\n 0,\n 0,\n 0,\n false,\n false,\n false,\n false,\n 0,\n null,\n // DOM Level 3\n 0,\n // PointerEvent\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n '',\n 0,\n false,\n // event instance\n '',\n null,\n null,\n 0,\n 0,\n 0,\n 0,\n function(){},\n false\n ];\n\n var HAS_SVG_INSTANCE = (typeof SVGElementInstance !== 'undefined');\n\n var eventFactory = scope.eventFactory;\n\n /**\n * This module is for normalizing events. Mouse and Touch events will be\n * collected here, and fire PointerEvents that have the same semantics, no\n * matter the source.\n * Events fired:\n * - pointerdown: a pointing is added\n * - pointerup: a pointer is removed\n * - pointermove: a pointer is moved\n * - pointerover: a pointer crosses into an element\n * - pointerout: a pointer leaves an element\n * - pointercancel: a pointer will no longer generate events\n */\n var dispatcher = {\n pointermap: new scope.PointerMap(),\n eventMap: Object.create(null),\n // Scope objects for native events.\n // This exists for ease of testing.\n eventSources: Object.create(null),\n eventSourceList: [],\n gestures: [],\n // map gesture event -> {listeners: int, index: gestures[int]}\n dependencyMap: {\n // make sure down and up are in the map to trigger \"register\"\n down: {listeners: 0, index: -1},\n up: {listeners: 0, index: -1}\n },\n gestureQueue: [],\n /**\n * Add a new event source that will generate pointer events.\n *\n * `inSource` must contain an array of event names named `events`, and\n * functions with the names specified in the `events` array.\n * @param {string} name A name for the event source\n * @param {Object} source A new source of platform events.\n */\n registerSource: function(name, source) {\n var s = source;\n var newEvents = s.events;\n if (newEvents) {\n newEvents.forEach(function(e) {\n if (s[e]) {\n this.eventMap[e] = s[e].bind(s);\n }\n }, this);\n this.eventSources[name] = s;\n this.eventSourceList.push(s);\n }\n },\n registerGesture: function(name, source) {\n var obj = Object.create(null);\n obj.listeners = 0;\n obj.index = this.gestures.length;\n for (var i = 0, g; i < source.exposes.length; i++) {\n g = source.exposes[i].toLowerCase();\n this.dependencyMap[g] = obj;\n }\n this.gestures.push(source);\n },\n register: function(element, initial) {\n var l = this.eventSourceList.length;\n for (var i = 0, es; (i < l) && (es = this.eventSourceList[i]); i++) {\n // call eventsource register\n es.register.call(es, element, initial);\n }\n },\n unregister: function(element) {\n var l = this.eventSourceList.length;\n for (var i = 0, es; (i < l) && (es = this.eventSourceList[i]); i++) {\n // call eventsource register\n es.unregister.call(es, element);\n }\n },\n // EVENTS\n down: function(inEvent) {\n this.fireEvent('down', inEvent);\n },\n move: function(inEvent) {\n // pipe move events into gesture queue directly\n inEvent.type = 'move';\n this.fillGestureQueue(inEvent);\n },\n up: function(inEvent) {\n this.fireEvent('up', inEvent);\n },\n cancel: function(inEvent) {\n inEvent.tapPrevented = true;\n this.fireEvent('up', inEvent);\n },\n // LISTENER LOGIC\n eventHandler: function(inEvent) {\n // This is used to prevent multiple dispatch of events from\n // platform events. This can happen when two elements in different scopes\n // are set up to create pointer events, which is relevant to Shadow DOM.\n\n // TODO(dfreedm): make this check more granular, allow for minimal event generation\n // e.g inEvent._handledByPG['tap'] and inEvent._handledByPG['track'], etc\n if (inEvent._handledByPG) {\n return;\n }\n var type = inEvent.type;\n var fn = this.eventMap && this.eventMap[type];\n if (fn) {\n fn(inEvent);\n }\n inEvent._handledByPG = true;\n },\n // set up event listeners\n listen: function(target, events) {\n for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {\n this.addEvent(target, e);\n }\n },\n // remove event listeners\n unlisten: function(target, events) {\n for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {\n this.removeEvent(target, e);\n }\n },\n addEvent: function(target, eventName) {\n target.addEventListener(eventName, this.boundHandler);\n },\n removeEvent: function(target, eventName) {\n target.removeEventListener(eventName, this.boundHandler);\n },\n // EVENT CREATION AND TRACKING\n /**\n * Creates a new Event of type `inType`, based on the information in\n * `inEvent`.\n *\n * @param {string} inType A string representing the type of event to create\n * @param {Event} inEvent A platform event with a target\n * @return {Event} A PointerEvent of type `inType`\n */\n makeEvent: function(inType, inEvent) {\n var e = eventFactory.makePointerEvent(inType, inEvent);\n e.preventDefault = inEvent.preventDefault;\n e.tapPrevented = inEvent.tapPrevented;\n e._target = e._target || inEvent.target;\n return e;\n },\n // make and dispatch an event in one call\n fireEvent: function(inType, inEvent) {\n var e = this.makeEvent(inType, inEvent);\n return this.dispatchEvent(e);\n },\n /**\n * Returns a snapshot of inEvent, with writable properties.\n *\n * @param {Event} inEvent An event that contains properties to copy.\n * @return {Object} An object containing shallow copies of `inEvent`'s\n * properties.\n */\n cloneEvent: function(inEvent) {\n var eventCopy = Object.create(null), p;\n for (var i = 0; i < CLONE_PROPS.length; i++) {\n p = CLONE_PROPS[i];\n eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i];\n // Work around SVGInstanceElement shadow tree\n // Return the element that is represented by the instance for Safari, Chrome, IE.\n // This is the behavior implemented by Firefox.\n if (p === 'target' || p === 'relatedTarget') {\n if (HAS_SVG_INSTANCE && eventCopy[p] instanceof SVGElementInstance) {\n eventCopy[p] = eventCopy[p].correspondingUseElement;\n }\n }\n }\n // keep the semantics of preventDefault\n eventCopy.preventDefault = function() {\n inEvent.preventDefault();\n };\n return eventCopy;\n },\n /**\n * Dispatches the event to its target.\n *\n * @param {Event} inEvent The event to be dispatched.\n * @return {Boolean} True if an event handler returns true, false otherwise.\n */\n dispatchEvent: function(inEvent) {\n var t = inEvent._target;\n if (t) {\n t.dispatchEvent(inEvent);\n // clone the event for the gesture system to process\n // clone after dispatch to pick up gesture prevention code\n var clone = this.cloneEvent(inEvent);\n clone.target = t;\n this.fillGestureQueue(clone);\n }\n },\n gestureTrigger: function() {\n // process the gesture queue\n for (var i = 0, e; i < this.gestureQueue.length; i++) {\n e = this.gestureQueue[i];\n for (var j = 0, g, fn; j < this.gestures.length; j++) {\n g = this.gestures[j];\n fn = g[e.type];\n if (g.enabled && fn) {\n fn.call(g, e);\n }\n }\n }\n this.gestureQueue.length = 0;\n },\n fillGestureQueue: function(ev) {\n // only trigger the gesture queue once\n if (!this.gestureQueue.length) {\n requestAnimationFrame(this.boundGestureTrigger);\n }\n this.gestureQueue.push(ev);\n }\n };\n dispatcher.boundHandler = dispatcher.eventHandler.bind(dispatcher);\n dispatcher.boundGestureTrigger = dispatcher.gestureTrigger.bind(dispatcher);\n scope.dispatcher = dispatcher;\n\n /**\n * Listen for `gesture` on `node` with the `handler` function\n *\n * If `handler` is the first listener for `gesture`, the underlying gesture recognizer is then enabled.\n *\n * @param {Element} node\n * @param {string} gesture\n * @return Boolean `gesture` is a valid gesture\n */\n scope.activateGesture = function(node, gesture) {\n var g = gesture.toLowerCase();\n var dep = dispatcher.dependencyMap[g];\n if (dep) {\n var recognizer = dispatcher.gestures[dep.index];\n if (dep.listeners === 0) {\n if (recognizer) {\n recognizer.enabled = true;\n }\n }\n dep.listeners++;\n if (!node._pgListeners) {\n dispatcher.register(node);\n node._pgListeners = 0;\n }\n // TODO(dfreedm): re-evaluate bookkeeping to avoid using attributes\n if (recognizer) {\n var touchAction = recognizer.defaultActions && recognizer.defaultActions[g];\n var actionNode;\n switch(node.nodeType) {\n case Node.ELEMENT_NODE:\n actionNode = node;\n break;\n case Node.DOCUMENT_FRAGMENT_NODE:\n actionNode = node.host;\n break;\n default:\n actionNode = null;\n break;\n }\n if (touchAction && actionNode && !actionNode.hasAttribute('touch-action')) {\n actionNode.setAttribute('touch-action', touchAction);\n }\n }\n node._pgListeners++;\n }\n return Boolean(dep);\n };\n\n /**\n *\n * Listen for `gesture` from `node` with `handler` function.\n *\n * @param {Element} node\n * @param {string} gesture\n * @param {Function} handler\n * @param {Boolean} capture\n */\n scope.addEventListener = function(node, gesture, handler, capture) {\n if (handler) {\n scope.activateGesture(node, gesture);\n node.addEventListener(gesture, handler, capture);\n }\n };\n\n /**\n * Tears down the gesture configuration for `node`\n *\n * If `handler` is the last listener for `gesture`, the underlying gesture recognizer is disabled.\n *\n * @param {Element} node\n * @param {string} gesture\n * @return Boolean `gesture` is a valid gesture\n */\n scope.deactivateGesture = function(node, gesture) {\n var g = gesture.toLowerCase();\n var dep = dispatcher.dependencyMap[g];\n if (dep) {\n if (dep.listeners > 0) {\n dep.listeners--;\n }\n if (dep.listeners === 0) {\n var recognizer = dispatcher.gestures[dep.index];\n if (recognizer) {\n recognizer.enabled = false;\n }\n }\n if (node._pgListeners > 0) {\n node._pgListeners--;\n }\n if (node._pgListeners === 0) {\n dispatcher.unregister(node);\n }\n }\n return Boolean(dep);\n };\n\n /**\n * Stop listening for `gesture` from `node` with `handler` function.\n *\n * @param {Element} node\n * @param {string} gesture\n * @param {Function} handler\n * @param {Boolean} capture\n */\n scope.removeEventListener = function(node, gesture, handler, capture) {\n if (handler) {\n scope.deactivateGesture(node, gesture);\n node.removeEventListener(gesture, handler, capture);\n }\n };\n})(window.PolymerGestures);\n","/*\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 var dispatcher = scope.dispatcher;\n var pointermap = dispatcher.pointermap;\n // radius around touchend that swallows mouse events\n var DEDUP_DIST = 25;\n\n var WHICH_TO_BUTTONS = [0, 1, 4, 2];\n\n var HAS_BUTTONS = false;\n try {\n HAS_BUTTONS = new MouseEvent('test', {buttons: 1}).buttons === 1;\n } catch (e) {}\n\n // handler block for native mouse events\n var mouseEvents = {\n POINTER_ID: 1,\n POINTER_TYPE: 'mouse',\n events: [\n 'mousedown',\n 'mousemove',\n 'mouseup'\n ],\n exposes: [\n 'down',\n 'up',\n 'move'\n ],\n register: function(target) {\n dispatcher.listen(target, this.events);\n },\n unregister: function(target) {\n dispatcher.unlisten(target, this.events);\n },\n lastTouches: [],\n // collide with the global mouse listener\n isEventSimulatedFromTouch: function(inEvent) {\n var lts = this.lastTouches;\n var x = inEvent.clientX, y = inEvent.clientY;\n for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {\n // simulated mouse events will be swallowed near a primary touchend\n var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);\n if (dx <= DEDUP_DIST && dy <= DEDUP_DIST) {\n return true;\n }\n }\n },\n prepareEvent: function(inEvent) {\n var e = dispatcher.cloneEvent(inEvent);\n e.pointerId = this.POINTER_ID;\n e.isPrimary = true;\n e.pointerType = this.POINTER_TYPE;\n e._source = 'mouse';\n if (!HAS_BUTTONS) {\n e.buttons = WHICH_TO_BUTTONS[e.which] || 0;\n }\n return e;\n },\n mousedown: function(inEvent) {\n if (!this.isEventSimulatedFromTouch(inEvent)) {\n var p = pointermap.has(this.POINTER_ID);\n // TODO(dfreedman) workaround for some elements not sending mouseup\n // http://crbug/149091\n if (p) {\n this.mouseup(inEvent);\n }\n var e = this.prepareEvent(inEvent);\n e.target = scope.findTarget(inEvent);\n pointermap.set(this.POINTER_ID, e.target);\n dispatcher.down(e);\n }\n },\n mousemove: function(inEvent) {\n if (!this.isEventSimulatedFromTouch(inEvent)) {\n var target = pointermap.get(this.POINTER_ID);\n if (target) {\n var e = this.prepareEvent(inEvent);\n e.target = target;\n // handle case where we missed a mouseup\n if (e.buttons === 0) {\n dispatcher.cancel(e);\n this.cleanupMouse();\n } else {\n dispatcher.move(e);\n }\n }\n }\n },\n mouseup: function(inEvent) {\n if (!this.isEventSimulatedFromTouch(inEvent)) {\n var e = this.prepareEvent(inEvent);\n e.relatedTarget = scope.findTarget(inEvent);\n e.target = pointermap.get(this.POINTER_ID);\n dispatcher.up(e);\n this.cleanupMouse();\n }\n },\n cleanupMouse: function() {\n pointermap['delete'](this.POINTER_ID);\n }\n };\n\n scope.mouseEvents = mouseEvents;\n})(window.PolymerGestures);\n","/*\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 var dispatcher = scope.dispatcher;\n var allShadows = scope.targetFinding.allShadows.bind(scope.targetFinding);\n var pointermap = dispatcher.pointermap;\n var touchMap = Array.prototype.map.call.bind(Array.prototype.map);\n // This should be long enough to ignore compat mouse events made by touch\n var DEDUP_TIMEOUT = 2500;\n var CLICK_COUNT_TIMEOUT = 200;\n var HYSTERESIS = 20;\n var ATTRIB = 'touch-action';\n // TODO(dfreedm): disable until http://crbug.com/399765 is resolved\n // var HAS_TOUCH_ACTION = ATTRIB in document.head.style;\n var HAS_TOUCH_ACTION = false;\n\n // handler block for native touch events\n var touchEvents = {\n events: [\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'touchcancel'\n ],\n exposes: [\n 'down',\n 'up',\n 'move'\n ],\n register: function(target, initial) {\n if (initial) {\n return;\n }\n dispatcher.listen(target, this.events);\n },\n unregister: function(target) {\n dispatcher.unlisten(target, this.events);\n },\n scrollTypes: {\n EMITTER: 'none',\n XSCROLLER: 'pan-x',\n YSCROLLER: 'pan-y',\n },\n touchActionToScrollType: function(touchAction) {\n var t = touchAction;\n var st = this.scrollTypes;\n if (t === st.EMITTER) {\n return 'none';\n } else if (t === st.XSCROLLER) {\n return 'X';\n } else if (t === st.YSCROLLER) {\n return 'Y';\n } else {\n return 'XY';\n }\n },\n POINTER_TYPE: 'touch',\n firstTouch: null,\n isPrimaryTouch: function(inTouch) {\n return this.firstTouch === inTouch.identifier;\n },\n setPrimaryTouch: function(inTouch) {\n // set primary touch if there no pointers, or the only pointer is the mouse\n if (pointermap.pointers() === 0 || (pointermap.pointers() === 1 && pointermap.has(1))) {\n this.firstTouch = inTouch.identifier;\n this.firstXY = {X: inTouch.clientX, Y: inTouch.clientY};\n this.scrolling = null;\n this.cancelResetClickCount();\n }\n },\n removePrimaryPointer: function(inPointer) {\n if (inPointer.isPrimary) {\n this.firstTouch = null;\n this.firstXY = null;\n this.resetClickCount();\n }\n },\n clickCount: 0,\n resetId: null,\n resetClickCount: function() {\n var fn = function() {\n this.clickCount = 0;\n this.resetId = null;\n }.bind(this);\n this.resetId = setTimeout(fn, CLICK_COUNT_TIMEOUT);\n },\n cancelResetClickCount: function() {\n if (this.resetId) {\n clearTimeout(this.resetId);\n }\n },\n typeToButtons: function(type) {\n var ret = 0;\n if (type === 'touchstart' || type === 'touchmove') {\n ret = 1;\n }\n return ret;\n },\n findTarget: function(touch, id) {\n if (this.currentTouchEvent.type === 'touchstart') {\n if (this.isPrimaryTouch(touch)) {\n var fastPath = {\n clientX: touch.clientX,\n clientY: touch.clientY,\n path: this.currentTouchEvent.path,\n target: this.currentTouchEvent.target\n };\n return scope.findTarget(fastPath);\n } else {\n return scope.findTarget(touch);\n }\n }\n // reuse target we found in touchstart\n return pointermap.get(id);\n },\n touchToPointer: function(inTouch) {\n var cte = this.currentTouchEvent;\n var e = dispatcher.cloneEvent(inTouch);\n // Spec specifies that pointerId 1 is reserved for Mouse.\n // Touch identifiers can start at 0.\n // Add 2 to the touch identifier for compatibility.\n var id = e.pointerId = inTouch.identifier + 2;\n e.target = this.findTarget(inTouch, id);\n e.bubbles = true;\n e.cancelable = true;\n e.detail = this.clickCount;\n e.buttons = this.typeToButtons(cte.type);\n e.width = inTouch.webkitRadiusX || inTouch.radiusX || 0;\n e.height = inTouch.webkitRadiusY || inTouch.radiusY || 0;\n e.pressure = inTouch.webkitForce || inTouch.force || 0.5;\n e.isPrimary = this.isPrimaryTouch(inTouch);\n e.pointerType = this.POINTER_TYPE;\n e._source = 'touch';\n // forward touch preventDefaults\n var self = this;\n e.preventDefault = function() {\n self.scrolling = false;\n self.firstXY = null;\n cte.preventDefault();\n };\n return e;\n },\n processTouches: function(inEvent, inFunction) {\n var tl = inEvent.changedTouches;\n this.currentTouchEvent = inEvent;\n for (var i = 0, t, p; i < tl.length; i++) {\n t = tl[i];\n p = this.touchToPointer(t);\n if (inEvent.type === 'touchstart') {\n pointermap.set(p.pointerId, p.target);\n }\n if (pointermap.has(p.pointerId)) {\n inFunction.call(this, p);\n }\n if (inEvent.type === 'touchend' || inEvent._cancel) {\n this.cleanUpPointer(p);\n }\n }\n },\n // For single axis scrollers, determines whether the element should emit\n // pointer events or behave as a scroller\n shouldScroll: function(inEvent) {\n if (this.firstXY) {\n var ret;\n var touchAction = scope.targetFinding.findTouchAction(inEvent);\n var scrollAxis = this.touchActionToScrollType(touchAction);\n if (scrollAxis === 'none') {\n // this element is a touch-action: none, should never scroll\n ret = false;\n } else if (scrollAxis === 'XY') {\n // this element should always scroll\n ret = true;\n } else {\n var t = inEvent.changedTouches[0];\n // check the intended scroll axis, and other axis\n var a = scrollAxis;\n var oa = scrollAxis === 'Y' ? 'X' : 'Y';\n var da = Math.abs(t['client' + a] - this.firstXY[a]);\n var doa = Math.abs(t['client' + oa] - this.firstXY[oa]);\n // if delta in the scroll axis > delta other axis, scroll instead of\n // making events\n ret = da >= doa;\n }\n return ret;\n }\n },\n findTouch: function(inTL, inId) {\n for (var i = 0, l = inTL.length, t; i < l && (t = inTL[i]); i++) {\n if (t.identifier === inId) {\n return true;\n }\n }\n },\n // In some instances, a touchstart can happen without a touchend. This\n // leaves the pointermap in a broken state.\n // Therefore, on every touchstart, we remove the touches that did not fire a\n // touchend event.\n // To keep state globally consistent, we fire a\n // pointercancel for this \"abandoned\" touch\n vacuumTouches: function(inEvent) {\n var tl = inEvent.touches;\n // pointermap.pointers() should be < tl.length here, as the touchstart has not\n // been processed yet.\n if (pointermap.pointers() >= tl.length) {\n var d = [];\n pointermap.forEach(function(value, key) {\n // Never remove pointerId == 1, which is mouse.\n // Touch identifiers are 2 smaller than their pointerId, which is the\n // index in pointermap.\n if (key !== 1 && !this.findTouch(tl, key - 2)) {\n var p = value;\n d.push(p);\n }\n }, this);\n d.forEach(function(p) {\n this.cancel(p);\n pointermap.delete(p.pointerId);\n });\n }\n },\n touchstart: function(inEvent) {\n this.vacuumTouches(inEvent);\n this.setPrimaryTouch(inEvent.changedTouches[0]);\n this.dedupSynthMouse(inEvent);\n if (!this.scrolling) {\n this.clickCount++;\n this.processTouches(inEvent, this.down);\n }\n },\n down: function(inPointer) {\n dispatcher.down(inPointer);\n },\n touchmove: function(inEvent) {\n if (HAS_TOUCH_ACTION) {\n // touchevent.cancelable == false is sent when the page is scrolling under native Touch Action in Chrome 36\n // https://groups.google.com/a/chromium.org/d/msg/input-dev/wHnyukcYBcA/b9kmtwM1jJQJ\n if (inEvent.cancelable) {\n this.processTouches(inEvent, this.move);\n }\n } else {\n if (!this.scrolling) {\n if (this.scrolling === null && this.shouldScroll(inEvent)) {\n this.scrolling = true;\n } else {\n this.scrolling = false;\n inEvent.preventDefault();\n this.processTouches(inEvent, this.move);\n }\n } else if (this.firstXY) {\n var t = inEvent.changedTouches[0];\n var dx = t.clientX - this.firstXY.X;\n var dy = t.clientY - this.firstXY.Y;\n var dd = Math.sqrt(dx * dx + dy * dy);\n if (dd >= HYSTERESIS) {\n this.touchcancel(inEvent);\n this.scrolling = true;\n this.firstXY = null;\n }\n }\n }\n },\n move: function(inPointer) {\n dispatcher.move(inPointer);\n },\n touchend: function(inEvent) {\n this.dedupSynthMouse(inEvent);\n this.processTouches(inEvent, this.up);\n },\n up: function(inPointer) {\n inPointer.relatedTarget = scope.findTarget(inPointer);\n dispatcher.up(inPointer);\n },\n cancel: function(inPointer) {\n dispatcher.cancel(inPointer);\n },\n touchcancel: function(inEvent) {\n inEvent._cancel = true;\n this.processTouches(inEvent, this.cancel);\n },\n cleanUpPointer: function(inPointer) {\n pointermap['delete'](inPointer.pointerId);\n this.removePrimaryPointer(inPointer);\n },\n // prevent synth mouse events from creating pointer events\n dedupSynthMouse: function(inEvent) {\n var lts = scope.mouseEvents.lastTouches;\n var t = inEvent.changedTouches[0];\n // only the primary finger will synth mouse events\n if (this.isPrimaryTouch(t)) {\n // remember x/y of last touch\n var lt = {x: t.clientX, y: t.clientY};\n lts.push(lt);\n var fn = (function(lts, lt){\n var i = lts.indexOf(lt);\n if (i > -1) {\n lts.splice(i, 1);\n }\n }).bind(null, lts, lt);\n setTimeout(fn, DEDUP_TIMEOUT);\n }\n }\n };\n\n scope.touchEvents = touchEvents;\n})(window.PolymerGestures);\n","/*\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 var dispatcher = scope.dispatcher;\n var pointermap = dispatcher.pointermap;\n var HAS_BITMAP_TYPE = window.MSPointerEvent && typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE === 'number';\n var msEvents = {\n events: [\n 'MSPointerDown',\n 'MSPointerMove',\n 'MSPointerUp',\n 'MSPointerCancel',\n ],\n register: function(target) {\n if (target !== document) {\n return;\n }\n dispatcher.listen(target, this.events);\n },\n unregister: function(target) {\n dispatcher.unlisten(target, this.events);\n },\n POINTER_TYPES: [\n '',\n 'unavailable',\n 'touch',\n 'pen',\n 'mouse'\n ],\n prepareEvent: function(inEvent) {\n var e = inEvent;\n e = dispatcher.cloneEvent(inEvent);\n if (HAS_BITMAP_TYPE) {\n e.pointerType = this.POINTER_TYPES[inEvent.pointerType];\n }\n e._source = 'ms';\n return e;\n },\n cleanup: function(id) {\n pointermap['delete'](id);\n },\n MSPointerDown: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.target = scope.findTarget(inEvent);\n pointermap.set(inEvent.pointerId, e.target);\n dispatcher.down(e);\n },\n MSPointerMove: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.move(e);\n },\n MSPointerUp: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.relatedTarget = scope.findTarget(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.up(e);\n this.cleanup(inEvent.pointerId);\n },\n MSPointerCancel: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.relatedTarget = scope.findTarget(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.cancel(e);\n this.cleanup(inEvent.pointerId);\n }\n };\n\n scope.msEvents = msEvents;\n})(window.PolymerGestures);\n","/*\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 var dispatcher = scope.dispatcher;\n var pointermap = dispatcher.pointermap;\n var pointerEvents = {\n events: [\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n 'pointercancel'\n ],\n prepareEvent: function(inEvent) {\n var e = dispatcher.cloneEvent(inEvent);\n e._source = 'pointer';\n return e;\n },\n register: function(target) {\n if (target !== document) {\n return;\n }\n dispatcher.listen(target, this.events);\n },\n unregister: function(target) {\n dispatcher.unlisten(target, this.events);\n },\n cleanup: function(id) {\n pointermap['delete'](id);\n },\n pointerdown: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.target = scope.findTarget(inEvent);\n pointermap.set(e.pointerId, e.target);\n dispatcher.down(e);\n },\n pointermove: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.move(e);\n },\n pointerup: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.relatedTarget = scope.findTarget(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.up(e);\n this.cleanup(inEvent.pointerId);\n },\n pointercancel: function(inEvent) {\n var e = this.prepareEvent(inEvent);\n e.relatedTarget = scope.findTarget(inEvent);\n e.target = pointermap.get(e.pointerId);\n dispatcher.cancel(e);\n this.cleanup(inEvent.pointerId);\n }\n };\n\n scope.pointerEvents = pointerEvents;\n})(window.PolymerGestures);\n","/*\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/**\n * This module contains the handlers for native platform events.\n * From here, the dispatcher is called to create unified pointer events.\n * Included are touch events (v1), mouse events, and MSPointerEvents.\n */\n(function(scope) {\n var dispatcher = scope.dispatcher;\n var nav = window.navigator;\n\n if (window.PointerEvent) {\n dispatcher.registerSource('pointer', scope.pointerEvents);\n } else if (nav.msPointerEnabled) {\n dispatcher.registerSource('ms', scope.msEvents);\n } else {\n dispatcher.registerSource('mouse', scope.mouseEvents);\n if (window.ontouchstart !== undefined) {\n dispatcher.registerSource('touch', scope.touchEvents);\n /*\n * NOTE: an empty touch listener on body will reactivate nodes imported from templates with touch listeners\n * Removing it will re-break the nodes\n *\n * Work around for https://bugs.webkit.org/show_bug.cgi?id=135628\n */\n var isSafari = nav.userAgent.match('Safari') && !nav.userAgent.match('Chrome');\n if (isSafari) {\n document.body.addEventListener('touchstart', function(){});\n }\n }\n }\n dispatcher.register(document, true);\n})(window.PolymerGestures);\n","/*\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/**\n * This event denotes the beginning of a series of tracking events.\n *\n * @module PointerGestures\n * @submodule Events\n * @class trackstart\n */\n/**\n * Pixels moved in the x direction since trackstart.\n * @type Number\n * @property dx\n */\n/**\n * Pixes moved in the y direction since trackstart.\n * @type Number\n * @property dy\n */\n/**\n * Pixels moved in the x direction since the last track.\n * @type Number\n * @property ddx\n */\n/**\n * Pixles moved in the y direction since the last track.\n * @type Number\n * @property ddy\n */\n/**\n * The clientX position of the track gesture.\n * @type Number\n * @property clientX\n */\n/**\n * The clientY position of the track gesture.\n * @type Number\n * @property clientY\n */\n/**\n * The pageX position of the track gesture.\n * @type Number\n * @property pageX\n */\n/**\n * The pageY position of the track gesture.\n * @type Number\n * @property pageY\n */\n/**\n * The screenX position of the track gesture.\n * @type Number\n * @property screenX\n */\n/**\n * The screenY position of the track gesture.\n * @type Number\n * @property screenY\n */\n/**\n * The last x axis direction of the pointer.\n * @type Number\n * @property xDirection\n */\n/**\n * The last y axis direction of the pointer.\n * @type Number\n * @property yDirection\n */\n/**\n * A shared object between all tracking events.\n * @type Object\n * @property trackInfo\n */\n/**\n * The element currently under the pointer.\n * @type Element\n * @property relatedTarget\n */\n/**\n * The type of pointer that make the track gesture.\n * @type String\n * @property pointerType\n */\n/**\n *\n * This event fires for all pointer movement being tracked.\n *\n * @class track\n * @extends trackstart\n */\n/**\n * This event fires when the pointer is no longer being tracked.\n *\n * @class trackend\n * @extends trackstart\n */\n\n (function(scope) {\n var dispatcher = scope.dispatcher;\n var eventFactory = scope.eventFactory;\n var pointermap = new scope.PointerMap();\n var track = {\n events: [\n 'down',\n 'move',\n 'up',\n ],\n exposes: [\n 'trackstart',\n 'track',\n 'trackx',\n 'tracky',\n 'trackend'\n ],\n defaultActions: {\n 'track': 'none',\n 'trackx': 'pan-y',\n 'tracky': 'pan-x'\n },\n WIGGLE_THRESHOLD: 4,\n clampDir: function(inDelta) {\n return inDelta > 0 ? 1 : -1;\n },\n calcPositionDelta: function(inA, inB) {\n var x = 0, y = 0;\n if (inA && inB) {\n x = inB.pageX - inA.pageX;\n y = inB.pageY - inA.pageY;\n }\n return {x: x, y: y};\n },\n fireTrack: function(inType, inEvent, inTrackingData) {\n var t = inTrackingData;\n var d = this.calcPositionDelta(t.downEvent, inEvent);\n var dd = this.calcPositionDelta(t.lastMoveEvent, inEvent);\n if (dd.x) {\n t.xDirection = this.clampDir(dd.x);\n } else if (inType === 'trackx') {\n return;\n }\n if (dd.y) {\n t.yDirection = this.clampDir(dd.y);\n } else if (inType === 'tracky') {\n return;\n }\n var gestureProto = {\n bubbles: true,\n cancelable: true,\n trackInfo: t.trackInfo,\n relatedTarget: inEvent.relatedTarget,\n pointerType: inEvent.pointerType,\n pointerId: inEvent.pointerId,\n _source: 'track'\n };\n if (inType !== 'tracky') {\n gestureProto.x = inEvent.x;\n gestureProto.dx = d.x;\n gestureProto.ddx = dd.x;\n gestureProto.clientX = inEvent.clientX;\n gestureProto.pageX = inEvent.pageX;\n gestureProto.screenX = inEvent.screenX;\n gestureProto.xDirection = t.xDirection;\n }\n if (inType !== 'trackx') {\n gestureProto.dy = d.y;\n gestureProto.ddy = dd.y;\n gestureProto.y = inEvent.y;\n gestureProto.clientY = inEvent.clientY;\n gestureProto.pageY = inEvent.pageY;\n gestureProto.screenY = inEvent.screenY;\n gestureProto.yDirection = t.yDirection;\n }\n var e = eventFactory.makeGestureEvent(inType, gestureProto);\n t.downTarget.dispatchEvent(e);\n },\n down: function(inEvent) {\n if (inEvent.isPrimary && (inEvent.pointerType === 'mouse' ? inEvent.buttons === 1 : true)) {\n var p = {\n downEvent: inEvent,\n downTarget: inEvent.target,\n trackInfo: {},\n lastMoveEvent: null,\n xDirection: 0,\n yDirection: 0,\n tracking: false\n };\n pointermap.set(inEvent.pointerId, p);\n }\n },\n move: function(inEvent) {\n var p = pointermap.get(inEvent.pointerId);\n if (p) {\n if (!p.tracking) {\n var d = this.calcPositionDelta(p.downEvent, inEvent);\n var move = d.x * d.x + d.y * d.y;\n // start tracking only if finger moves more than WIGGLE_THRESHOLD\n if (move > this.WIGGLE_THRESHOLD) {\n p.tracking = true;\n p.lastMoveEvent = p.downEvent;\n this.fireTrack('trackstart', inEvent, p);\n }\n }\n if (p.tracking) {\n this.fireTrack('track', inEvent, p);\n this.fireTrack('trackx', inEvent, p);\n this.fireTrack('tracky', inEvent, p);\n }\n p.lastMoveEvent = inEvent;\n }\n },\n up: function(inEvent) {\n var p = pointermap.get(inEvent.pointerId);\n if (p) {\n if (p.tracking) {\n this.fireTrack('trackend', inEvent, p);\n }\n pointermap.delete(inEvent.pointerId);\n }\n }\n };\n dispatcher.registerGesture('track', track);\n })(window.PolymerGestures);\n","/*\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/**\n * This event is fired when a pointer is held down for 200ms.\n *\n * @module PointerGestures\n * @submodule Events\n * @class hold\n */\n/**\n * Type of pointer that made the holding event.\n * @type String\n * @property pointerType\n */\n/**\n * Screen X axis position of the held pointer\n * @type Number\n * @property clientX\n */\n/**\n * Screen Y axis position of the held pointer\n * @type Number\n * @property clientY\n */\n/**\n * Type of pointer that made the holding event.\n * @type String\n * @property pointerType\n */\n/**\n * This event is fired every 200ms while a pointer is held down.\n *\n * @class holdpulse\n * @extends hold\n */\n/**\n * Milliseconds pointer has been held down.\n * @type Number\n * @property holdTime\n */\n/**\n * This event is fired when a held pointer is released or moved.\n *\n * @class release\n */\n\n(function(scope) {\n var dispatcher = scope.dispatcher;\n var eventFactory = scope.eventFactory;\n var hold = {\n // wait at least HOLD_DELAY ms between hold and pulse events\n HOLD_DELAY: 200,\n // pointer can move WIGGLE_THRESHOLD pixels before not counting as a hold\n WIGGLE_THRESHOLD: 16,\n events: [\n 'down',\n 'move',\n 'up',\n ],\n exposes: [\n 'hold',\n 'holdpulse',\n 'release'\n ],\n heldPointer: null,\n holdJob: null,\n pulse: function() {\n var hold = Date.now() - this.heldPointer.timeStamp;\n var type = this.held ? 'holdpulse' : 'hold';\n this.fireHold(type, hold);\n this.held = true;\n },\n cancel: function() {\n clearInterval(this.holdJob);\n if (this.held) {\n this.fireHold('release');\n }\n this.held = false;\n this.heldPointer = null;\n this.target = null;\n this.holdJob = null;\n },\n down: function(inEvent) {\n if (inEvent.isPrimary && !this.heldPointer) {\n this.heldPointer = inEvent;\n this.target = inEvent.target;\n this.holdJob = setInterval(this.pulse.bind(this), this.HOLD_DELAY);\n }\n },\n up: function(inEvent) {\n if (this.heldPointer && this.heldPointer.pointerId === inEvent.pointerId) {\n this.cancel();\n }\n },\n move: function(inEvent) {\n if (this.heldPointer && this.heldPointer.pointerId === inEvent.pointerId) {\n var x = inEvent.clientX - this.heldPointer.clientX;\n var y = inEvent.clientY - this.heldPointer.clientY;\n if ((x * x + y * y) > this.WIGGLE_THRESHOLD) {\n this.cancel();\n }\n }\n },\n fireHold: function(inType, inHoldTime) {\n var p = {\n bubbles: true,\n cancelable: true,\n pointerType: this.heldPointer.pointerType,\n pointerId: this.heldPointer.pointerId,\n x: this.heldPointer.clientX,\n y: this.heldPointer.clientY,\n _source: 'hold'\n };\n if (inHoldTime) {\n p.holdTime = inHoldTime;\n }\n var e = eventFactory.makeGestureEvent(inType, p);\n this.target.dispatchEvent(e);\n }\n };\n dispatcher.registerGesture('hold', hold);\n})(window.PolymerGestures);\n","/*\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/**\n * This event is fired when a pointer quickly goes down and up, and is used to\n * denote activation.\n *\n * Any gesture event can prevent the tap event from being created by calling\n * `event.preventTap`.\n *\n * Any pointer event can prevent the tap by setting the `tapPrevented` property\n * on itself.\n *\n * @module PointerGestures\n * @submodule Events\n * @class tap\n */\n/**\n * X axis position of the tap.\n * @property x\n * @type Number\n */\n/**\n * Y axis position of the tap.\n * @property y\n * @type Number\n */\n/**\n * Type of the pointer that made the tap.\n * @property pointerType\n * @type String\n */\n(function(scope) {\n var dispatcher = scope.dispatcher;\n var eventFactory = scope.eventFactory;\n var pointermap = new scope.PointerMap();\n var tap = {\n events: [\n 'down',\n 'up'\n ],\n exposes: [\n 'tap'\n ],\n down: function(inEvent) {\n if (inEvent.isPrimary && !inEvent.tapPrevented) {\n pointermap.set(inEvent.pointerId, {\n target: inEvent.target,\n buttons: inEvent.buttons,\n x: inEvent.clientX,\n y: inEvent.clientY\n });\n }\n },\n shouldTap: function(e, downState) {\n if (e.pointerType === 'mouse') {\n // only allow left click to tap for mouse\n return downState.buttons === 1;\n }\n return !e.tapPrevented;\n },\n up: function(inEvent) {\n var start = pointermap.get(inEvent.pointerId);\n if (start && this.shouldTap(inEvent, start)) {\n // up.relatedTarget is target currently under finger\n var t = scope.targetFinding.LCA(start.target, inEvent.relatedTarget);\n if (t) {\n var e = eventFactory.makeGestureEvent('tap', {\n bubbles: true,\n cancelable: true,\n x: inEvent.clientX,\n y: inEvent.clientY,\n detail: inEvent.detail,\n pointerType: inEvent.pointerType,\n pointerId: inEvent.pointerId,\n altKey: inEvent.altKey,\n ctrlKey: inEvent.ctrlKey,\n metaKey: inEvent.metaKey,\n shiftKey: inEvent.shiftKey,\n _source: 'tap'\n });\n t.dispatchEvent(e);\n }\n }\n pointermap.delete(inEvent.pointerId);\n }\n };\n // patch eventFactory to remove id from tap's pointermap for preventTap calls\n eventFactory.preventTap = function(e) {\n return function() {\n e.tapPrevented = true;\n pointermap.delete(e.pointerId);\n };\n };\n dispatcher.registerGesture('tap', tap);\n})(window.PolymerGestures);\n","/*\n Copyright (C) 2013 Ariya Hidayat \n Copyright (C) 2013 Thaddee Tyl \n Copyright (C) 2012 Ariya Hidayat \n Copyright (C) 2012 Mathias Bynens \n Copyright (C) 2012 Joost-Wim Boekesteijn \n Copyright (C) 2012 Kris Kowal \n Copyright (C) 2012 Yusuke Suzuki \n Copyright (C) 2012 Arpad Borsos \n Copyright (C) 2011 Ariya Hidayat \n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n(function (global) {\n 'use strict';\n\n var Token,\n TokenName,\n Syntax,\n Messages,\n source,\n index,\n length,\n delegate,\n lookahead,\n state;\n\n Token = {\n BooleanLiteral: 1,\n EOF: 2,\n Identifier: 3,\n Keyword: 4,\n NullLiteral: 5,\n NumericLiteral: 6,\n Punctuator: 7,\n StringLiteral: 8\n };\n\n TokenName = {};\n TokenName[Token.BooleanLiteral] = 'Boolean';\n TokenName[Token.EOF] = '';\n TokenName[Token.Identifier] = 'Identifier';\n TokenName[Token.Keyword] = 'Keyword';\n TokenName[Token.NullLiteral] = 'Null';\n TokenName[Token.NumericLiteral] = 'Numeric';\n TokenName[Token.Punctuator] = 'Punctuator';\n TokenName[Token.StringLiteral] = 'String';\n\n Syntax = {\n ArrayExpression: 'ArrayExpression',\n BinaryExpression: 'BinaryExpression',\n CallExpression: 'CallExpression',\n ConditionalExpression: 'ConditionalExpression',\n EmptyStatement: 'EmptyStatement',\n ExpressionStatement: 'ExpressionStatement',\n Identifier: 'Identifier',\n Literal: 'Literal',\n LabeledStatement: 'LabeledStatement',\n LogicalExpression: 'LogicalExpression',\n MemberExpression: 'MemberExpression',\n ObjectExpression: 'ObjectExpression',\n Program: 'Program',\n Property: 'Property',\n ThisExpression: 'ThisExpression',\n UnaryExpression: 'UnaryExpression'\n };\n\n // Error messages should be identical to V8.\n Messages = {\n UnexpectedToken: 'Unexpected token %0',\n UnknownLabel: 'Undefined label \\'%0\\'',\n Redeclaration: '%0 \\'%1\\' has already been declared'\n };\n\n // Ensure the condition is true, otherwise throw an error.\n // This is only to have a better contract semantic, i.e. another safety net\n // to catch a logic error. The condition shall be fulfilled in normal case.\n // Do NOT use this to enforce a certain condition on any user input.\n\n function assert(condition, message) {\n if (!condition) {\n throw new Error('ASSERT: ' + message);\n }\n }\n\n function isDecimalDigit(ch) {\n return (ch >= 48 && ch <= 57); // 0..9\n }\n\n\n // 7.2 White Space\n\n function isWhiteSpace(ch) {\n return (ch === 32) || // space\n (ch === 9) || // tab\n (ch === 0xB) ||\n (ch === 0xC) ||\n (ch === 0xA0) ||\n (ch >= 0x1680 && '\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);\n }\n\n // 7.3 Line Terminators\n\n function isLineTerminator(ch) {\n return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);\n }\n\n // 7.6 Identifier Names and Identifiers\n\n function isIdentifierStart(ch) {\n return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)\n (ch >= 65 && ch <= 90) || // A..Z\n (ch >= 97 && ch <= 122); // a..z\n }\n\n function isIdentifierPart(ch) {\n return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)\n (ch >= 65 && ch <= 90) || // A..Z\n (ch >= 97 && ch <= 122) || // a..z\n (ch >= 48 && ch <= 57); // 0..9\n }\n\n // 7.6.1.1 Keywords\n\n function isKeyword(id) {\n return (id === 'this')\n }\n\n // 7.4 Comments\n\n function skipWhitespace() {\n while (index < length && isWhiteSpace(source.charCodeAt(index))) {\n ++index;\n }\n }\n\n function getIdentifier() {\n var start, ch;\n\n start = index++;\n while (index < length) {\n ch = source.charCodeAt(index);\n if (isIdentifierPart(ch)) {\n ++index;\n } else {\n break;\n }\n }\n\n return source.slice(start, index);\n }\n\n function scanIdentifier() {\n var start, id, type;\n\n start = index;\n\n id = getIdentifier();\n\n // There is no keyword or literal with only one character.\n // Thus, it must be an identifier.\n if (id.length === 1) {\n type = Token.Identifier;\n } else if (isKeyword(id)) {\n type = Token.Keyword;\n } else if (id === 'null') {\n type = Token.NullLiteral;\n } else if (id === 'true' || id === 'false') {\n type = Token.BooleanLiteral;\n } else {\n type = Token.Identifier;\n }\n\n return {\n type: type,\n value: id,\n range: [start, index]\n };\n }\n\n\n // 7.7 Punctuators\n\n function scanPunctuator() {\n var start = index,\n code = source.charCodeAt(index),\n code2,\n ch1 = source[index],\n ch2;\n\n switch (code) {\n\n // Check for most common single-character punctuators.\n case 46: // . dot\n case 40: // ( open bracket\n case 41: // ) close bracket\n case 59: // ; semicolon\n case 44: // , comma\n case 123: // { open curly brace\n case 125: // } close curly brace\n case 91: // [\n case 93: // ]\n case 58: // :\n case 63: // ?\n ++index;\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code),\n range: [start, index]\n };\n\n default:\n code2 = source.charCodeAt(index + 1);\n\n // '=' (char #61) marks an assignment or comparison operator.\n if (code2 === 61) {\n switch (code) {\n case 37: // %\n case 38: // &\n case 42: // *:\n case 43: // +\n case 45: // -\n case 47: // /\n case 60: // <\n case 62: // >\n case 124: // |\n index += 2;\n return {\n type: Token.Punctuator,\n value: String.fromCharCode(code) + String.fromCharCode(code2),\n range: [start, index]\n };\n\n case 33: // !\n case 61: // =\n index += 2;\n\n // !== and ===\n if (source.charCodeAt(index) === 61) {\n ++index;\n }\n return {\n type: Token.Punctuator,\n value: source.slice(start, index),\n range: [start, index]\n };\n default:\n break;\n }\n }\n break;\n }\n\n // Peek more characters.\n\n ch2 = source[index + 1];\n\n // Other 2-character punctuators: && ||\n\n if (ch1 === ch2 && ('&|'.indexOf(ch1) >= 0)) {\n index += 2;\n return {\n type: Token.Punctuator,\n value: ch1 + ch2,\n range: [start, index]\n };\n }\n\n if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {\n ++index;\n return {\n type: Token.Punctuator,\n value: ch1,\n range: [start, index]\n };\n }\n\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n // 7.8.3 Numeric Literals\n function scanNumericLiteral() {\n var number, start, ch;\n\n ch = source[index];\n assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),\n 'Numeric literal must start with a decimal digit or a decimal point');\n\n start = index;\n number = '';\n if (ch !== '.') {\n number = source[index++];\n ch = source[index];\n\n // Hex number starts with '0x'.\n // Octal number starts with '0'.\n if (number === '0') {\n // decimal number starts with '0' such as '09' is illegal.\n if (ch && isDecimalDigit(ch.charCodeAt(0))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === '.') {\n number += source[index++];\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n ch = source[index];\n }\n\n if (ch === 'e' || ch === 'E') {\n number += source[index++];\n\n ch = source[index];\n if (ch === '+' || ch === '-') {\n number += source[index++];\n }\n if (isDecimalDigit(source.charCodeAt(index))) {\n while (isDecimalDigit(source.charCodeAt(index))) {\n number += source[index++];\n }\n } else {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n }\n\n if (isIdentifierStart(source.charCodeAt(index))) {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.NumericLiteral,\n value: parseFloat(number),\n range: [start, index]\n };\n }\n\n // 7.8.4 String Literals\n\n function scanStringLiteral() {\n var str = '', quote, start, ch, octal = false;\n\n quote = source[index];\n assert((quote === '\\'' || quote === '\"'),\n 'String literal must starts with a quote');\n\n start = index;\n ++index;\n\n while (index < length) {\n ch = source[index++];\n\n if (ch === quote) {\n quote = '';\n break;\n } else if (ch === '\\\\') {\n ch = source[index++];\n if (!ch || !isLineTerminator(ch.charCodeAt(0))) {\n switch (ch) {\n case 'n':\n str += '\\n';\n break;\n case 'r':\n str += '\\r';\n break;\n case 't':\n str += '\\t';\n break;\n case 'b':\n str += '\\b';\n break;\n case 'f':\n str += '\\f';\n break;\n case 'v':\n str += '\\x0B';\n break;\n\n default:\n str += ch;\n break;\n }\n } else {\n if (ch === '\\r' && source[index] === '\\n') {\n ++index;\n }\n }\n } else if (isLineTerminator(ch.charCodeAt(0))) {\n break;\n } else {\n str += ch;\n }\n }\n\n if (quote !== '') {\n throwError({}, Messages.UnexpectedToken, 'ILLEGAL');\n }\n\n return {\n type: Token.StringLiteral,\n value: str,\n octal: octal,\n range: [start, index]\n };\n }\n\n function isIdentifierName(token) {\n return token.type === Token.Identifier ||\n token.type === Token.Keyword ||\n token.type === Token.BooleanLiteral ||\n token.type === Token.NullLiteral;\n }\n\n function advance() {\n var ch;\n\n skipWhitespace();\n\n if (index >= length) {\n return {\n type: Token.EOF,\n range: [index, index]\n };\n }\n\n ch = source.charCodeAt(index);\n\n // Very common: ( and ) and ;\n if (ch === 40 || ch === 41 || ch === 58) {\n return scanPunctuator();\n }\n\n // String literal starts with single quote (#39) or double quote (#34).\n if (ch === 39 || ch === 34) {\n return scanStringLiteral();\n }\n\n if (isIdentifierStart(ch)) {\n return scanIdentifier();\n }\n\n // Dot (.) char #46 can also start a floating-point number, hence the need\n // to check the next character.\n if (ch === 46) {\n if (isDecimalDigit(source.charCodeAt(index + 1))) {\n return scanNumericLiteral();\n }\n return scanPunctuator();\n }\n\n if (isDecimalDigit(ch)) {\n return scanNumericLiteral();\n }\n\n return scanPunctuator();\n }\n\n function lex() {\n var token;\n\n token = lookahead;\n index = token.range[1];\n\n lookahead = advance();\n\n index = token.range[1];\n\n return token;\n }\n\n function peek() {\n var pos;\n\n pos = index;\n lookahead = advance();\n index = pos;\n }\n\n // Throw an exception\n\n function throwError(token, messageFormat) {\n var error,\n args = Array.prototype.slice.call(arguments, 2),\n msg = messageFormat.replace(\n /%(\\d)/g,\n function (whole, index) {\n assert(index < args.length, 'Message reference must be in range');\n return args[index];\n }\n );\n\n error = new Error(msg);\n error.index = index;\n error.description = msg;\n throw error;\n }\n\n // Throw an exception because of the token.\n\n function throwUnexpected(token) {\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // Expect the next token to match the specified punctuator.\n // If not, an exception will be thrown.\n\n function expect(value) {\n var token = lex();\n if (token.type !== Token.Punctuator || token.value !== value) {\n throwUnexpected(token);\n }\n }\n\n // Return true if the next token matches the specified punctuator.\n\n function match(value) {\n return lookahead.type === Token.Punctuator && lookahead.value === value;\n }\n\n // Return true if the next token matches the specified keyword\n\n function matchKeyword(keyword) {\n return lookahead.type === Token.Keyword && lookahead.value === keyword;\n }\n\n function consumeSemicolon() {\n // Catch the very common case first: immediately a semicolon (char #59).\n if (source.charCodeAt(index) === 59) {\n lex();\n return;\n }\n\n skipWhitespace();\n\n if (match(';')) {\n lex();\n return;\n }\n\n if (lookahead.type !== Token.EOF && !match('}')) {\n throwUnexpected(lookahead);\n }\n }\n\n // 11.1.4 Array Initialiser\n\n function parseArrayInitialiser() {\n var elements = [];\n\n expect('[');\n\n while (!match(']')) {\n if (match(',')) {\n lex();\n elements.push(null);\n } else {\n elements.push(parseExpression());\n\n if (!match(']')) {\n expect(',');\n }\n }\n }\n\n expect(']');\n\n return delegate.createArrayExpression(elements);\n }\n\n // 11.1.5 Object Initialiser\n\n function parseObjectPropertyKey() {\n var token;\n\n skipWhitespace();\n token = lex();\n\n // Note: This function is called only from parseObjectProperty(), where\n // EOF and Punctuator tokens are already filtered out.\n if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {\n return delegate.createLiteral(token);\n }\n\n return delegate.createIdentifier(token.value);\n }\n\n function parseObjectProperty() {\n var token, key;\n\n token = lookahead;\n skipWhitespace();\n\n if (token.type === Token.EOF || token.type === Token.Punctuator) {\n throwUnexpected(token);\n }\n\n key = parseObjectPropertyKey();\n expect(':');\n return delegate.createProperty('init', key, parseExpression());\n }\n\n function parseObjectInitialiser() {\n var properties = [];\n\n expect('{');\n\n while (!match('}')) {\n properties.push(parseObjectProperty());\n\n if (!match('}')) {\n expect(',');\n }\n }\n\n expect('}');\n\n return delegate.createObjectExpression(properties);\n }\n\n // 11.1.6 The Grouping Operator\n\n function parseGroupExpression() {\n var expr;\n\n expect('(');\n\n expr = parseExpression();\n\n expect(')');\n\n return expr;\n }\n\n\n // 11.1 Primary Expressions\n\n function parsePrimaryExpression() {\n var type, token, expr;\n\n if (match('(')) {\n return parseGroupExpression();\n }\n\n type = lookahead.type;\n\n if (type === Token.Identifier) {\n expr = delegate.createIdentifier(lex().value);\n } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {\n expr = delegate.createLiteral(lex());\n } else if (type === Token.Keyword) {\n if (matchKeyword('this')) {\n lex();\n expr = delegate.createThisExpression();\n }\n } else if (type === Token.BooleanLiteral) {\n token = lex();\n token.value = (token.value === 'true');\n expr = delegate.createLiteral(token);\n } else if (type === Token.NullLiteral) {\n token = lex();\n token.value = null;\n expr = delegate.createLiteral(token);\n } else if (match('[')) {\n expr = parseArrayInitialiser();\n } else if (match('{')) {\n expr = parseObjectInitialiser();\n }\n\n if (expr) {\n return expr;\n }\n\n throwUnexpected(lex());\n }\n\n // 11.2 Left-Hand-Side Expressions\n\n function parseArguments() {\n var args = [];\n\n expect('(');\n\n if (!match(')')) {\n while (index < length) {\n args.push(parseExpression());\n if (match(')')) {\n break;\n }\n expect(',');\n }\n }\n\n expect(')');\n\n return args;\n }\n\n function parseNonComputedProperty() {\n var token;\n\n token = lex();\n\n if (!isIdentifierName(token)) {\n throwUnexpected(token);\n }\n\n return delegate.createIdentifier(token.value);\n }\n\n function parseNonComputedMember() {\n expect('.');\n\n return parseNonComputedProperty();\n }\n\n function parseComputedMember() {\n var expr;\n\n expect('[');\n\n expr = parseExpression();\n\n expect(']');\n\n return expr;\n }\n\n function parseLeftHandSideExpression() {\n var expr, args, property;\n\n expr = parsePrimaryExpression();\n\n while (true) {\n if (match('[')) {\n property = parseComputedMember();\n expr = delegate.createMemberExpression('[', expr, property);\n } else if (match('.')) {\n property = parseNonComputedMember();\n expr = delegate.createMemberExpression('.', expr, property);\n } else if (match('(')) {\n args = parseArguments();\n expr = delegate.createCallExpression(expr, args);\n } else {\n break;\n }\n }\n\n return expr;\n }\n\n // 11.3 Postfix Expressions\n\n var parsePostfixExpression = parseLeftHandSideExpression;\n\n // 11.4 Unary Operators\n\n function parseUnaryExpression() {\n var token, expr;\n\n if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {\n expr = parsePostfixExpression();\n } else if (match('+') || match('-') || match('!')) {\n token = lex();\n expr = parseUnaryExpression();\n expr = delegate.createUnaryExpression(token.value, expr);\n } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {\n throwError({}, Messages.UnexpectedToken);\n } else {\n expr = parsePostfixExpression();\n }\n\n return expr;\n }\n\n function binaryPrecedence(token) {\n var prec = 0;\n\n if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {\n return 0;\n }\n\n switch (token.value) {\n case '||':\n prec = 1;\n break;\n\n case '&&':\n prec = 2;\n break;\n\n case '==':\n case '!=':\n case '===':\n case '!==':\n prec = 6;\n break;\n\n case '<':\n case '>':\n case '<=':\n case '>=':\n case 'instanceof':\n prec = 7;\n break;\n\n case 'in':\n prec = 7;\n break;\n\n case '+':\n case '-':\n prec = 9;\n break;\n\n case '*':\n case '/':\n case '%':\n prec = 11;\n break;\n\n default:\n break;\n }\n\n return prec;\n }\n\n // 11.5 Multiplicative Operators\n // 11.6 Additive Operators\n // 11.7 Bitwise Shift Operators\n // 11.8 Relational Operators\n // 11.9 Equality Operators\n // 11.10 Binary Bitwise Operators\n // 11.11 Binary Logical Operators\n\n function parseBinaryExpression() {\n var expr, token, prec, stack, right, operator, left, i;\n\n left = parseUnaryExpression();\n\n token = lookahead;\n prec = binaryPrecedence(token);\n if (prec === 0) {\n return left;\n }\n token.prec = prec;\n lex();\n\n right = parseUnaryExpression();\n\n stack = [left, token, right];\n\n while ((prec = binaryPrecedence(lookahead)) > 0) {\n\n // Reduce: make a binary expression from the three topmost entries.\n while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {\n right = stack.pop();\n operator = stack.pop().value;\n left = stack.pop();\n expr = delegate.createBinaryExpression(operator, left, right);\n stack.push(expr);\n }\n\n // Shift.\n token = lex();\n token.prec = prec;\n stack.push(token);\n expr = parseUnaryExpression();\n stack.push(expr);\n }\n\n // Final reduce to clean-up the stack.\n i = stack.length - 1;\n expr = stack[i];\n while (i > 1) {\n expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);\n i -= 2;\n }\n\n return expr;\n }\n\n\n // 11.12 Conditional Operator\n\n function parseConditionalExpression() {\n var expr, consequent, alternate;\n\n expr = parseBinaryExpression();\n\n if (match('?')) {\n lex();\n consequent = parseConditionalExpression();\n expect(':');\n alternate = parseConditionalExpression();\n\n expr = delegate.createConditionalExpression(expr, consequent, alternate);\n }\n\n return expr;\n }\n\n // Simplification since we do not support AssignmentExpression.\n var parseExpression = parseConditionalExpression;\n\n // Polymer Syntax extensions\n\n // Filter ::\n // Identifier\n // Identifier \"(\" \")\"\n // Identifier \"(\" FilterArguments \")\"\n\n function parseFilter() {\n var identifier, args;\n\n identifier = lex();\n\n if (identifier.type !== Token.Identifier) {\n throwUnexpected(identifier);\n }\n\n args = match('(') ? parseArguments() : [];\n\n return delegate.createFilter(identifier.value, args);\n }\n\n // Filters ::\n // \"|\" Filter\n // Filters \"|\" Filter\n\n function parseFilters() {\n while (match('|')) {\n lex();\n parseFilter();\n }\n }\n\n // TopLevel ::\n // LabelledExpressions\n // AsExpression\n // InExpression\n // FilterExpression\n\n // AsExpression ::\n // FilterExpression as Identifier\n\n // InExpression ::\n // Identifier, Identifier in FilterExpression\n // Identifier in FilterExpression\n\n // FilterExpression ::\n // Expression\n // Expression Filters\n\n function parseTopLevel() {\n skipWhitespace();\n peek();\n\n var expr = parseExpression();\n if (expr) {\n if (lookahead.value === ',' || lookahead.value == 'in' &&\n expr.type === Syntax.Identifier) {\n parseInExpression(expr);\n } else {\n parseFilters();\n if (lookahead.value === 'as') {\n parseAsExpression(expr);\n } else {\n delegate.createTopLevel(expr);\n }\n }\n }\n\n if (lookahead.type !== Token.EOF) {\n throwUnexpected(lookahead);\n }\n }\n\n function parseAsExpression(expr) {\n lex(); // as\n var identifier = lex().value;\n delegate.createAsExpression(expr, identifier);\n }\n\n function parseInExpression(identifier) {\n var indexName;\n if (lookahead.value === ',') {\n lex();\n if (lookahead.type !== Token.Identifier)\n throwUnexpected(lookahead);\n indexName = lex().value;\n }\n\n lex(); // in\n var expr = parseExpression();\n parseFilters();\n delegate.createInExpression(identifier.name, indexName, expr);\n }\n\n function parse(code, inDelegate) {\n delegate = inDelegate;\n source = code;\n index = 0;\n length = source.length;\n lookahead = null;\n state = {\n labelSet: {}\n };\n\n return parseTopLevel();\n }\n\n global.esprima = {\n parse: parse\n };\n})(this);\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(function (global) {\n 'use strict';\n\n function prepareBinding(expressionText, name, node, filterRegistry) {\n var expression;\n try {\n expression = getExpression(expressionText);\n if (expression.scopeIdent &&\n (node.nodeType !== Node.ELEMENT_NODE ||\n node.tagName !== 'TEMPLATE' ||\n (name !== 'bind' && name !== 'repeat'))) {\n throw Error('as and in can only be used within ');\n }\n } catch (ex) {\n console.error('Invalid expression syntax: ' + expressionText, ex);\n return;\n }\n\n return function(model, node, oneTime) {\n var binding = expression.getBinding(model, filterRegistry, oneTime);\n if (expression.scopeIdent && binding) {\n node.polymerExpressionScopeIdent_ = expression.scopeIdent;\n if (expression.indexIdent)\n node.polymerExpressionIndexIdent_ = expression.indexIdent;\n }\n\n return binding;\n }\n }\n\n // TODO(rafaelw): Implement simple LRU.\n var expressionParseCache = Object.create(null);\n\n function getExpression(expressionText) {\n var expression = expressionParseCache[expressionText];\n if (!expression) {\n var delegate = new ASTDelegate();\n esprima.parse(expressionText, delegate);\n expression = new Expression(delegate);\n expressionParseCache[expressionText] = expression;\n }\n return expression;\n }\n\n function Literal(value) {\n this.value = value;\n this.valueFn_ = undefined;\n }\n\n Literal.prototype = {\n valueFn: function() {\n if (!this.valueFn_) {\n var value = this.value;\n this.valueFn_ = function() {\n return value;\n }\n }\n\n return this.valueFn_;\n }\n }\n\n function IdentPath(name) {\n this.name = name;\n this.path = Path.get(name);\n }\n\n IdentPath.prototype = {\n valueFn: function() {\n if (!this.valueFn_) {\n var name = this.name;\n var path = this.path;\n this.valueFn_ = function(model, observer) {\n if (observer)\n observer.addPath(model, path);\n\n return path.getValueFrom(model);\n }\n }\n\n return this.valueFn_;\n },\n\n setValue: function(model, newValue) {\n if (this.path.length == 1);\n model = findScope(model, this.path[0]);\n\n return this.path.setValueFrom(model, newValue);\n }\n };\n\n function MemberExpression(object, property, accessor) {\n this.computed = accessor == '[';\n\n this.dynamicDeps = typeof object == 'function' ||\n object.dynamicDeps ||\n (this.computed && !(property instanceof Literal));\n\n this.simplePath =\n !this.dynamicDeps &&\n (property instanceof IdentPath || property instanceof Literal) &&\n (object instanceof MemberExpression || object instanceof IdentPath);\n\n this.object = this.simplePath ? object : getFn(object);\n this.property = !this.computed || this.simplePath ?\n property : getFn(property);\n }\n\n MemberExpression.prototype = {\n get fullPath() {\n if (!this.fullPath_) {\n\n var parts = this.object instanceof MemberExpression ?\n this.object.fullPath.slice() : [this.object.name];\n parts.push(this.property instanceof IdentPath ?\n this.property.name : this.property.value);\n this.fullPath_ = Path.get(parts);\n }\n\n return this.fullPath_;\n },\n\n valueFn: function() {\n if (!this.valueFn_) {\n var object = this.object;\n\n if (this.simplePath) {\n var path = this.fullPath;\n\n this.valueFn_ = function(model, observer) {\n if (observer)\n observer.addPath(model, path);\n\n return path.getValueFrom(model);\n };\n } else if (!this.computed) {\n var path = Path.get(this.property.name);\n\n this.valueFn_ = function(model, observer, filterRegistry) {\n var context = object(model, observer, filterRegistry);\n\n if (observer)\n observer.addPath(context, path);\n\n return path.getValueFrom(context);\n }\n } else {\n // Computed property.\n var property = this.property;\n\n this.valueFn_ = function(model, observer, filterRegistry) {\n var context = object(model, observer, filterRegistry);\n var propName = property(model, observer, filterRegistry);\n if (observer)\n observer.addPath(context, [propName]);\n\n return context ? context[propName] : undefined;\n };\n }\n }\n return this.valueFn_;\n },\n\n setValue: function(model, newValue) {\n if (this.simplePath) {\n this.fullPath.setValueFrom(model, newValue);\n return newValue;\n }\n\n var object = this.object(model);\n var propName = this.property instanceof IdentPath ? this.property.name :\n this.property(model);\n return object[propName] = newValue;\n }\n };\n\n function Filter(name, args) {\n this.name = name;\n this.args = [];\n for (var i = 0; i < args.length; i++) {\n this.args[i] = getFn(args[i]);\n }\n }\n\n Filter.prototype = {\n transform: function(model, observer, filterRegistry, toModelDirection,\n initialArgs) {\n var fn = filterRegistry[this.name];\n var context = model;\n if (fn) {\n context = undefined;\n } else {\n fn = context[this.name];\n if (!fn) {\n console.error('Cannot find function or filter: ' + this.name);\n return;\n }\n }\n\n // If toModelDirection is falsey, then the \"normal\" (dom-bound) direction\n // is used. Otherwise, it looks for a 'toModel' property function on the\n // object.\n if (toModelDirection) {\n fn = fn.toModel;\n } else if (typeof fn.toDOM == 'function') {\n fn = fn.toDOM;\n }\n\n if (typeof fn != 'function') {\n console.error('Cannot find function or filter: ' + this.name);\n return;\n }\n\n var args = initialArgs || [];\n for (var i = 0; i < this.args.length; i++) {\n args.push(getFn(this.args[i])(model, observer, filterRegistry));\n }\n\n return fn.apply(context, args);\n }\n };\n\n function notImplemented() { throw Error('Not Implemented'); }\n\n var unaryOperators = {\n '+': function(v) { return +v; },\n '-': function(v) { return -v; },\n '!': function(v) { return !v; }\n };\n\n var binaryOperators = {\n '+': function(l, r) { return l+r; },\n '-': function(l, r) { return l-r; },\n '*': function(l, r) { return l*r; },\n '/': function(l, r) { return l/r; },\n '%': function(l, r) { return l%r; },\n '<': function(l, r) { return l': function(l, r) { return l>r; },\n '<=': function(l, r) { return l<=r; },\n '>=': function(l, r) { return l>=r; },\n '==': function(l, r) { return l==r; },\n '!=': function(l, r) { return l!=r; },\n '===': function(l, r) { return l===r; },\n '!==': function(l, r) { return l!==r; },\n '&&': function(l, r) { return l&&r; },\n '||': function(l, r) { return l||r; },\n };\n\n function getFn(arg) {\n return typeof arg == 'function' ? arg : arg.valueFn();\n }\n\n function ASTDelegate() {\n this.expression = null;\n this.filters = [];\n this.deps = {};\n this.currentPath = undefined;\n this.scopeIdent = undefined;\n this.indexIdent = undefined;\n this.dynamicDeps = false;\n }\n\n ASTDelegate.prototype = {\n createUnaryExpression: function(op, argument) {\n if (!unaryOperators[op])\n throw Error('Disallowed operator: ' + op);\n\n argument = getFn(argument);\n\n return function(model, observer, filterRegistry) {\n return unaryOperators[op](argument(model, observer, filterRegistry));\n };\n },\n\n createBinaryExpression: function(op, left, right) {\n if (!binaryOperators[op])\n throw Error('Disallowed operator: ' + op);\n\n left = getFn(left);\n right = getFn(right);\n\n switch (op) {\n case '||':\n this.dynamicDeps = true;\n return function(model, observer, filterRegistry) {\n return left(model, observer, filterRegistry) ||\n right(model, observer, filterRegistry);\n };\n case '&&':\n this.dynamicDeps = true;\n return function(model, observer, filterRegistry) {\n return left(model, observer, filterRegistry) &&\n right(model, observer, filterRegistry);\n };\n }\n\n return function(model, observer, filterRegistry) {\n return binaryOperators[op](left(model, observer, filterRegistry),\n right(model, observer, filterRegistry));\n };\n },\n\n createConditionalExpression: function(test, consequent, alternate) {\n test = getFn(test);\n consequent = getFn(consequent);\n alternate = getFn(alternate);\n\n this.dynamicDeps = true;\n\n return function(model, observer, filterRegistry) {\n return test(model, observer, filterRegistry) ?\n consequent(model, observer, filterRegistry) :\n alternate(model, observer, filterRegistry);\n }\n },\n\n createIdentifier: function(name) {\n var ident = new IdentPath(name);\n ident.type = 'Identifier';\n return ident;\n },\n\n createMemberExpression: function(accessor, object, property) {\n var ex = new MemberExpression(object, property, accessor);\n if (ex.dynamicDeps)\n this.dynamicDeps = true;\n return ex;\n },\n\n createCallExpression: function(expression, args) {\n if (!(expression instanceof IdentPath))\n throw Error('Only identifier function invocations are allowed');\n\n var filter = new Filter(expression.name, args);\n\n return function(model, observer, filterRegistry) {\n return filter.transform(model, observer, filterRegistry, false);\n };\n },\n\n createLiteral: function(token) {\n return new Literal(token.value);\n },\n\n createArrayExpression: function(elements) {\n for (var i = 0; i < elements.length; i++)\n elements[i] = getFn(elements[i]);\n\n return function(model, observer, filterRegistry) {\n var arr = []\n for (var i = 0; i < elements.length; i++)\n arr.push(elements[i](model, observer, filterRegistry));\n return arr;\n }\n },\n\n createProperty: function(kind, key, value) {\n return {\n key: key instanceof IdentPath ? key.name : key.value,\n value: value\n };\n },\n\n createObjectExpression: function(properties) {\n for (var i = 0; i < properties.length; i++)\n properties[i].value = getFn(properties[i].value);\n\n return function(model, observer, filterRegistry) {\n var obj = {};\n for (var i = 0; i < properties.length; i++)\n obj[properties[i].key] =\n properties[i].value(model, observer, filterRegistry);\n return obj;\n }\n },\n\n createFilter: function(name, args) {\n this.filters.push(new Filter(name, args));\n },\n\n createAsExpression: function(expression, scopeIdent) {\n this.expression = expression;\n this.scopeIdent = scopeIdent;\n },\n\n createInExpression: function(scopeIdent, indexIdent, expression) {\n this.expression = expression;\n this.scopeIdent = scopeIdent;\n this.indexIdent = indexIdent;\n },\n\n createTopLevel: function(expression) {\n this.expression = expression;\n },\n\n createThisExpression: notImplemented\n }\n\n function ConstantObservable(value) {\n this.value_ = value;\n }\n\n ConstantObservable.prototype = {\n open: function() { return this.value_; },\n discardChanges: function() { return this.value_; },\n deliver: function() {},\n close: function() {},\n }\n\n function Expression(delegate) {\n this.scopeIdent = delegate.scopeIdent;\n this.indexIdent = delegate.indexIdent;\n\n if (!delegate.expression)\n throw Error('No expression found.');\n\n this.expression = delegate.expression;\n getFn(this.expression); // forces enumeration of path dependencies\n\n this.filters = delegate.filters;\n this.dynamicDeps = delegate.dynamicDeps;\n }\n\n Expression.prototype = {\n getBinding: function(model, filterRegistry, oneTime) {\n if (oneTime)\n return this.getValue(model, undefined, filterRegistry);\n\n var observer = new CompoundObserver();\n // captures deps.\n var firstValue = this.getValue(model, observer, filterRegistry);\n var firstTime = true;\n var self = this;\n\n function valueFn() {\n // deps cannot have changed on first value retrieval.\n if (firstTime) {\n firstTime = false;\n return firstValue;\n }\n\n if (self.dynamicDeps)\n observer.startReset();\n\n var value = self.getValue(model,\n self.dynamicDeps ? observer : undefined,\n filterRegistry);\n if (self.dynamicDeps)\n observer.finishReset();\n\n return value;\n }\n\n function setValueFn(newValue) {\n self.setValue(model, newValue, filterRegistry);\n return newValue;\n }\n\n return new ObserverTransform(observer, valueFn, setValueFn, true);\n },\n\n getValue: function(model, observer, filterRegistry) {\n var value = getFn(this.expression)(model, observer, filterRegistry);\n for (var i = 0; i < this.filters.length; i++) {\n value = this.filters[i].transform(model, observer, filterRegistry,\n false, [value]);\n }\n\n return value;\n },\n\n setValue: function(model, newValue, filterRegistry) {\n var count = this.filters ? this.filters.length : 0;\n while (count-- > 0) {\n newValue = this.filters[count].transform(model, undefined,\n filterRegistry, true, [newValue]);\n }\n\n if (this.expression.setValue)\n return this.expression.setValue(model, newValue);\n }\n }\n\n /**\n * Converts a style property name to a css property name. For example:\n * \"WebkitUserSelect\" to \"-webkit-user-select\"\n */\n function convertStylePropertyName(name) {\n return String(name).replace(/[A-Z]/g, function(c) {\n return '-' + c.toLowerCase();\n });\n }\n\n var parentScopeName = '@' + Math.random().toString(36).slice(2);\n\n // Single ident paths must bind directly to the appropriate scope object.\n // I.e. Pushed values in two-bindings need to be assigned to the actual model\n // object.\n function findScope(model, prop) {\n while (model[parentScopeName] &&\n !Object.prototype.hasOwnProperty.call(model, prop)) {\n model = model[parentScopeName];\n }\n\n return model;\n }\n\n function isLiteralExpression(pathString) {\n switch (pathString) {\n case '':\n return false;\n\n case 'false':\n case 'null':\n case 'true':\n return true;\n }\n\n if (!isNaN(Number(pathString)))\n return true;\n\n return false;\n };\n\n function PolymerExpressions() {}\n\n PolymerExpressions.prototype = {\n // \"built-in\" filters\n styleObject: function(value) {\n var parts = [];\n for (var key in value) {\n parts.push(convertStylePropertyName(key) + ': ' + value[key]);\n }\n return parts.join('; ');\n },\n\n tokenList: function(value) {\n var tokens = [];\n for (var key in value) {\n if (value[key])\n tokens.push(key);\n }\n return tokens.join(' ');\n },\n\n // binding delegate API\n prepareInstancePositionChanged: function(template) {\n var indexIdent = template.polymerExpressionIndexIdent_;\n if (!indexIdent)\n return;\n\n return function(templateInstance, index) {\n templateInstance.model[indexIdent] = index;\n };\n },\n\n prepareBinding: function(pathString, name, node) {\n var path = Path.get(pathString);\n\n if (!isLiteralExpression(pathString) && path.valid) {\n if (path.length == 1) {\n return function(model, node, oneTime) {\n if (oneTime)\n return path.getValueFrom(model);\n\n var scope = findScope(model, path[0]);\n return new PathObserver(scope, path);\n };\n }\n return; // bail out early if pathString is simple path.\n }\n\n return prepareBinding(pathString, name, node, this);\n },\n\n prepareInstanceModel: function(template) {\n var scopeName = template.polymerExpressionScopeIdent_;\n if (!scopeName)\n return;\n\n var parentScope = template.templateInstance ?\n template.templateInstance.model :\n template.model;\n\n var indexName = template.polymerExpressionIndexIdent_;\n\n return function(model) {\n return createScopeObject(parentScope, model, scopeName, indexName);\n };\n }\n };\n\n var createScopeObject = ('__proto__' in {}) ?\n function(parentScope, model, scopeName, indexName) {\n var scope = {};\n scope[scopeName] = model;\n scope[indexName] = undefined;\n scope[parentScopeName] = parentScope;\n scope.__proto__ = parentScope;\n return scope;\n } :\n function(parentScope, model, scopeName, indexName) {\n var scope = Object.create(parentScope);\n Object.defineProperty(scope, scopeName,\n { value: model, configurable: true, writable: true });\n Object.defineProperty(scope, indexName,\n { value: undefined, configurable: true, writable: true });\n Object.defineProperty(scope, parentScopeName,\n { value: parentScope, configurable: true, writable: true });\n return scope;\n };\n\n global.PolymerExpressions = PolymerExpressions;\n PolymerExpressions.getExpression = getExpression;\n})(this);\n","/*\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 */\nPolymer = {\n version: '0.3.5'\n};\n","/*\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// TODO(sorvell): this ensures Polymer is an object and not a function\n// Platform is currently defining it as a function to allow for async loading\n// of polymer; once we refine the loading process this likely goes away.\nif (typeof window.Polymer === 'function') {\n Polymer = {};\n}\n\n","/*\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 // copy own properties from 'api' to 'prototype, with name hinting for 'super'\n function extend(prototype, api) {\n if (prototype && api) {\n // use only own properties of 'api'\n Object.getOwnPropertyNames(api).forEach(function(n) {\n // acquire property descriptor\n var pd = Object.getOwnPropertyDescriptor(api, n);\n if (pd) {\n // clone property via descriptor\n Object.defineProperty(prototype, n, pd);\n // cache name-of-method for 'super' engine\n if (typeof pd.value == 'function') {\n // hint the 'super' engine\n pd.value.nom = n;\n }\n }\n });\n }\n return prototype;\n }\n \n // exports\n\n scope.extend = extend;\n\n})(Polymer);\n","/*\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 // usage\n \n // invoke cb.call(this) in 100ms, unless the job is re-registered,\n // which resets the timer\n // \n // this.myJob = this.job(this.myJob, cb, 100)\n //\n // returns a job handle which can be used to re-register a job\n\n var Job = function(inContext) {\n this.context = inContext;\n this.boundComplete = this.complete.bind(this)\n };\n Job.prototype = {\n go: function(callback, wait) {\n this.callback = callback;\n var h;\n if (!wait) {\n h = requestAnimationFrame(this.boundComplete);\n this.handle = function() {\n cancelAnimationFrame(h);\n }\n } else {\n h = setTimeout(this.boundComplete, wait);\n this.handle = function() {\n clearTimeout(h);\n }\n }\n },\n stop: function() {\n if (this.handle) {\n this.handle();\n this.handle = null;\n }\n },\n complete: function() {\n if (this.handle) {\n this.stop();\n this.callback.call(this.context);\n }\n }\n };\n \n function job(job, callback, wait) {\n if (job) {\n job.stop();\n } else {\n job = new Job(this);\n }\n job.go(callback, wait);\n return job;\n }\n \n // exports \n\n scope.job = job;\n \n})(Polymer);\n","/*\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 var registry = {};\n\n HTMLElement.register = function(tag, prototype) {\n registry[tag] = prototype;\n }\n\n // get prototype mapped to node \n HTMLElement.getPrototypeForTag = function(tag) {\n var prototype = !tag ? HTMLElement.prototype : registry[tag];\n // TODO(sjmiles): creating is likely to have wasteful side-effects\n return prototype || Object.getPrototypeOf(document.createElement(tag));\n };\n\n // we have to flag propagation stoppage for the event dispatcher\n var originalStopPropagation = Event.prototype.stopPropagation;\n Event.prototype.stopPropagation = function() {\n this.cancelBubble = true;\n originalStopPropagation.apply(this, arguments);\n };\n \n // TODO(sorvell): remove when we're sure imports does not need\n // to load stylesheets\n /*\n HTMLImports.importer.preloadSelectors += \n ', polymer-element link[rel=stylesheet]';\n */\n})(Polymer);\n","/*\r\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n (function(scope) {\r\n // super\r\n\r\n // `arrayOfArgs` is an optional array of args like one might pass\r\n // to `Function.apply`\r\n\r\n // TODO(sjmiles):\r\n // $super must be installed on an instance or prototype chain\r\n // as `super`, and invoked via `this`, e.g.\r\n // `this.super();`\r\n\r\n // will not work if function objects are not unique, for example,\r\n // when using mixins.\r\n // The memoization strategy assumes each function exists on only one \r\n // prototype chain i.e. we use the function object for memoizing)\r\n // perhaps we can bookkeep on the prototype itself instead\r\n function $super(arrayOfArgs) {\r\n // since we are thunking a method call, performance is important here: \r\n // memoize all lookups, once memoized the fast path calls no other \r\n // functions\r\n //\r\n // find the caller (cannot be `strict` because of 'caller')\r\n var caller = $super.caller;\r\n // memoized 'name of method' \r\n var nom = caller.nom;\r\n // memoized next implementation prototype\r\n var _super = caller._super;\r\n if (!_super) {\r\n if (!nom) {\r\n nom = caller.nom = nameInThis.call(this, caller);\r\n }\r\n if (!nom) {\r\n console.warn('called super() on a method not installed declaratively (has no .nom property)');\r\n }\r\n // super prototype is either cached or we have to find it\r\n // by searching __proto__ (at the 'top')\r\n // invariant: because we cache _super on fn below, we never reach \r\n // here from inside a series of calls to super(), so it's ok to \r\n // start searching from the prototype of 'this' (at the 'top')\r\n // we must never memoize a null super for this reason\r\n _super = memoizeSuper(caller, nom, getPrototypeOf(this));\r\n }\r\n // our super function\r\n var fn = _super[nom];\r\n if (fn) {\r\n // memoize information so 'fn' can call 'super'\r\n if (!fn._super) {\r\n // must not memoize null, or we lose our invariant above\r\n memoizeSuper(fn, nom, _super);\r\n }\r\n // invoke the inherited method\r\n // if 'fn' is not function valued, this will throw\r\n return fn.apply(this, arrayOfArgs || []);\r\n }\r\n }\r\n\r\n function nameInThis(value) {\r\n var p = this.__proto__;\r\n while (p && p !== HTMLElement.prototype) {\r\n // TODO(sjmiles): getOwnPropertyNames is absurdly expensive\r\n var n$ = Object.getOwnPropertyNames(p);\r\n for (var i=0, l=n$.length, n; i 0) && console.log('[%s] addHostListeners:', this.localName, events);\n // NOTE: host events look like bindings but really are not;\n // (1) we don't want the attribute to be set and (2) we want to support\n // multiple event listeners ('host' and 'instance') and Node.bind\n // by default supports 1 thing being bound.\n for (var type in events) {\n var methodName = events[type];\n PolymerGestures.addEventListener(this, type, this.element.getEventHandler(this, this, methodName));\n }\n },\n // call 'method' or function method on 'obj' with 'args', if the method exists\n dispatchMethod: function(obj, method, args) {\n if (obj) {\n log.events && console.group('[%s] dispatch [%s]', obj.localName, method);\n var fn = typeof method === 'function' ? method : obj[method];\n if (fn) {\n fn[args ? 'apply' : 'call'](obj, args);\n }\n log.events && console.groupEnd();\n Platform.flush();\n }\n }\n };\n\n // exports\n\n scope.api.instance.events = events;\n\n // alias PolymerGestures event listener logic\n scope.addEventListener = PolymerGestures.addEventListener;\n scope.removeEventListener = PolymerGestures.removeEventListener;\n\n})(Polymer);\n","/*\r\n * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n(function(scope) {\r\n\r\n // instance api for attributes\r\n\r\n var attributes = {\r\n copyInstanceAttributes: function () {\r\n var a$ = this._instanceAttributes;\r\n for (var k in a$) {\r\n if (!this.hasAttribute(k)) {\r\n this.setAttribute(k, a$[k]);\r\n }\r\n }\r\n },\r\n // for each attribute on this, deserialize value to property as needed\r\n takeAttributes: function() {\r\n // if we have no publish lookup table, we have no attributes to take\r\n // TODO(sjmiles): ad hoc\r\n if (this._publishLC) {\r\n for (var i=0, a$=this.attributes, l=a$.length, a; (a=a$[i]) && i= 0) {\r\n return;\r\n }\r\n // get original value\r\n var currentValue = this[name];\r\n // deserialize Boolean or Number values from attribute\r\n var value = this.deserializeValue(value, currentValue);\r\n // only act if the value has changed\r\n if (value !== currentValue) {\r\n // install new value (has side-effects)\r\n this[name] = value;\r\n }\r\n }\r\n },\r\n // return the published property matching name, or undefined\r\n propertyForAttribute: function(name) {\r\n var match = this._publishLC && this._publishLC[name];\r\n //console.log('propertyForAttribute:', name, 'matches', match);\r\n return match;\r\n },\r\n // convert representation of 'stringValue' based on type of 'currentValue'\r\n deserializeValue: function(stringValue, currentValue) {\r\n return scope.deserializeValue(stringValue, currentValue);\r\n },\r\n serializeValue: function(value, inferredType) {\r\n if (inferredType === 'boolean') {\r\n return value ? '' : undefined;\r\n } else if (inferredType !== 'object' && inferredType !== 'function'\r\n && value !== undefined) {\r\n return value;\r\n }\r\n },\r\n reflectPropertyToAttribute: function(name) {\r\n var inferredType = typeof this[name];\r\n // try to intelligently serialize property value\r\n var serializedValue = this.serializeValue(this[name], inferredType);\r\n // boolean properties must reflect as boolean attributes\r\n if (serializedValue !== undefined) {\r\n this.setAttribute(name, serializedValue);\r\n // TODO(sorvell): we should remove attr for all properties\r\n // that have undefined serialization; however, we will need to\r\n // refine the attr reflection system to achieve this; pica, for example,\r\n // relies on having inferredType object properties not removed as\r\n // attrs.\r\n } else if (inferredType === 'boolean') {\r\n this.removeAttribute(name);\r\n }\r\n }\r\n };\r\n\r\n // exports\r\n\r\n scope.api.instance.attributes = attributes;\r\n\r\n})(Polymer);\r\n","/*\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 // imports\n\n var log = window.logFlags || {};\n\n // magic words\n\n var OBSERVE_SUFFIX = 'Changed';\n\n // element api\n\n var empty = [];\n\n var updateRecord = {\n object: undefined,\n type: 'update',\n name: undefined,\n oldValue: undefined\n };\n\n var numberIsNaN = Number.isNaN || function(value) {\n return typeof value === 'number' && isNaN(value);\n }\n\n function areSameValue(left, right) {\n if (left === right)\n return left !== 0 || 1 / left === 1 / right;\n if (numberIsNaN(left) && numberIsNaN(right))\n return true;\n\n return left !== left && right !== right;\n }\n\n // capture A's value if B's value is null or undefined,\n // otherwise use B's value\n function resolveBindingValue(oldValue, value) {\n if (value === undefined && oldValue === null) {\n return value;\n }\n return (value === null || value === undefined) ? oldValue : value;\n }\n\n var properties = {\n createPropertyObserver: function() {\n var n$ = this._observeNames;\n if (n$ && n$.length) {\n var o = this._propertyObserver = new CompoundObserver(true);\n this.registerObserver(o);\n // TODO(sorvell): may not be kosher to access the value here (this[n]);\n // previously we looked at the descriptor on the prototype\n // this doesn't work for inheritance and not for accessors without\n // a value property\n for (var i=0, l=n$.length, n; (i initialization, oldest first\n parseDeclarations: function(p) {\n if (p && p.element) {\n this.parseDeclarations(p.__proto__);\n p.parseDeclaration.call(this, p.element);\n }\n },\n // parse input as needed, override for custom behavior\n parseDeclaration: function(elementElement) {\n var template = this.fetchTemplate(elementElement);\n if (template) {\n var root = this.shadowFromTemplate(template);\n this.shadowRoots[elementElement.name] = root;\n }\n },\n // return a shadow-root template (if desired), override for custom behavior\n fetchTemplate: function(elementElement) {\n return elementElement.querySelector('template');\n },\n // utility function that creates a shadow root from a \n shadowFromTemplate: function(template) {\n if (template) {\n // make a shadow root\n var root = this.createShadowRoot();\n // stamp template\n // which includes parsing and applying MDV bindings before being\n // inserted (to avoid {{}} in attribute values)\n // e.g. to prevent from generating a 404.\n var dom = this.instanceTemplate(template);\n // append to shadow dom\n root.appendChild(dom);\n // perform post-construction initialization tasks on shadow root\n this.shadowRootReady(root, template);\n // return the created shadow root\n return root;\n }\n },\n // utility function that stamps a into light-dom\n lightFromTemplate: function(template, refNode) {\n if (template) {\n // TODO(sorvell): mark this element as an eventController so that\n // event listeners on bound nodes inside it will be called on it.\n // Note, the expectation here is that events on all descendants\n // should be handled by this element.\n this.eventController = this;\n // stamp template\n // which includes parsing and applying MDV bindings before being\n // inserted (to avoid {{}} in attribute values)\n // e.g. to prevent from generating a 404.\n var dom = this.instanceTemplate(template);\n // append to shadow dom\n if (refNode) {\n this.insertBefore(dom, refNode);\n } else {\n this.appendChild(dom);\n }\n // perform post-construction initialization tasks on ahem, light root\n this.shadowRootReady(this);\n // return the created shadow root\n return dom;\n }\n },\n shadowRootReady: function(root) {\n // locate nodes with id and store references to them in this.$ hash\n this.marshalNodeReferences(root);\n },\n // locate nodes with id and store references to them in this.$ hash\n marshalNodeReferences: function(root) {\n // establish $ instance variable\n var $ = this.$ = this.$ || {};\n // populate $ from nodes with ID from the LOCAL tree\n if (root) {\n var n$ = root.querySelectorAll(\"[id]\");\n for (var i=0, l=n$.length, n; (i elements with the attribute \n * polymer-scope='controller' into the scope of element. This is intended\n * to be a called during custom element construction.\n */\n installControllerStyles: function() {\n // apply controller styles, but only if they are not yet applied\n var scope = this.findStyleScope();\n if (scope && !this.scopeHasNamedStyle(scope, this.localName)) {\n // allow inherited controller styles\n var proto = getPrototypeOf(this), cssText = '';\n while (proto && proto.element) {\n cssText += proto.element.cssTextForScope(STYLE_CONTROLLER_SCOPE);\n proto = getPrototypeOf(proto);\n }\n if (cssText) {\n this.installScopeCssText(cssText, scope);\n }\n }\n },\n installScopeStyle: function(style, name, scope) {\n var scope = scope || this.findStyleScope(), name = name || '';\n if (scope && !this.scopeHasNamedStyle(scope, this.localName + name)) {\n var cssText = '';\n if (style instanceof Array) {\n for (var i=0, l=style.length, s; (i elements into the \n * element's template.\n * @param elementElement The element to style.\n */\n installSheets: function() {\n this.cacheSheets();\n this.cacheStyles();\n this.installLocalSheets();\n this.installGlobalStyles();\n },\n /**\n * Remove all sheets from element and store for later use.\n */\n cacheSheets: function() {\n this.sheets = this.findNodes(SHEET_SELECTOR);\n this.sheets.forEach(function(s) {\n if (s.parentNode) {\n s.parentNode.removeChild(s);\n }\n });\n },\n cacheStyles: function() {\n this.styles = this.findNodes(STYLE_SELECTOR + '[' + SCOPE_ATTR + ']');\n this.styles.forEach(function(s) {\n if (s.parentNode) {\n s.parentNode.removeChild(s);\n }\n });\n },\n /**\n * Takes external stylesheets loaded in an element and moves\n * their content into a
-
diff --git a/package.json b/package.json
index 1d7c4a0..5d075be 100644
--- a/package.json
+++ b/package.json
@@ -5,11 +5,13 @@
"gulp": "^3.8.7",
"gulp-connect": "^2.0.6",
"gulp-load-plugins": "^0.5.3",
- "gulp-markdown": "^1.0.0",
+ "gulp-plates": "0.0.5",
"gulp-qunit": "^0.3.3",
+ "gulp-rename": "^1.2.0",
"gulp-stylus": "^1.3.0",
"gulp-vulcanize": "^1.0.0",
"gulp-watch": "^0.6.9",
+ "marked": "^0.3.2",
"nib": "^1.0.3"
}
}
diff --git a/tests/jquery.js b/tests/jquery.js
deleted file mode 100644
index 4a9c729..0000000
--- a/tests/jquery.js
+++ /dev/null
@@ -1,9046 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.6.4
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Mon Sep 12 18:54:48 2011 -0400
- */
-(function( window, undefined ) {
-
-// Use the correct document accordingly with window argument (sandbox)
-var document = window.document,
- navigator = window.navigator,
- location = window.location;
-var jQuery = (function() {
-
-// Define a local copy of jQuery
-var jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context, rootjQuery );
- },
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$,
-
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // A simple way to check for HTML strings or ID strings
- // Prioritize #id over to avoid XSS via location.hash (#9521)
- quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
-
- // Check if a string has a non-whitespace character in it
- rnotwhite = /\S/,
-
- // Used for trimming whitespace
- trimLeft = /^\s+/,
- trimRight = /\s+$/,
-
- // Check for digits
- rdigit = /\d/,
-
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
-
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
-
- // Useragent RegExp
- rwebkit = /(webkit)[ \/]([\w.]+)/,
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- rmsie = /(msie) ([\w.]+)/,
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
-
- // Matches dashed string for camelizing
- rdashAlpha = /-([a-z]|[0-9])/ig,
- rmsPrefix = /^-ms-/,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return ( letter + "" ).toUpperCase();
- },
-
- // Keep a UserAgent string for use with jQuery.browser
- userAgent = navigator.userAgent,
-
- // For matching the engine and version of the browser
- browserMatch,
-
- // The deferred used on DOM ready
- readyList,
-
- // The ready event handler
- DOMContentLoaded,
-
- // Save a reference to some core methods
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty,
- push = Array.prototype.push,
- slice = Array.prototype.slice,
- trim = String.prototype.trim,
- indexOf = Array.prototype.indexOf,
-
- // [[Class]] -> type pairs
- class2type = {};
-
-jQuery.fn = jQuery.prototype = {
- constructor: jQuery,
- init: function( selector, context, rootjQuery ) {
- var match, elem, ret, doc;
-
- // Handle $(""), $(null), or $(undefined)
- if ( !selector ) {
- return this;
- }
-
- // Handle $(DOMElement)
- if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
- }
-
- // The body element only exists once, optimize finding it
- if ( selector === "body" && !context && document.body ) {
- this.context = document;
- this[0] = document.body;
- this.selector = selector;
- this.length = 1;
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- // Are we dealing with HTML string or an ID?
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = quickExpr.exec( selector );
- }
-
- // Verify a match, and that no context was specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
- doc = (context ? context.ownerDocument || context : document);
-
- // If a single string is passed in and it's a single tag
- // just do a createElement and skip the rest
- ret = rsingleTag.exec( selector );
-
- if ( ret ) {
- if ( jQuery.isPlainObject( context ) ) {
- selector = [ document.createElement( ret[1] ) ];
- jQuery.fn.attr.call( selector, context, true );
-
- } else {
- selector = [ doc.createElement( ret[1] ) ];
- }
-
- } else {
- ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
- selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
- }
-
- return jQuery.merge( this, selector );
-
- // HANDLE: $("#id")
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return (context || rootjQuery).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
-
- if (selector.selector !== undefined) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- },
-
- // Start with an empty selector
- selector: "",
-
- // The current version of jQuery being used
- jquery: "1.6.4",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
-
- toArray: function() {
- return slice.call( this, 0 );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
-
- // Return a 'clean' array
- this.toArray() :
-
- // Return just the object
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems, name, selector ) {
- // Build a new jQuery matched element set
- var ret = this.constructor();
-
- if ( jQuery.isArray( elems ) ) {
- push.apply( ret, elems );
-
- } else {
- jQuery.merge( ret, elems );
- }
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- ret.context = this.context;
-
- if ( name === "find" ) {
- ret.selector = this.selector + (this.selector ? " " : "") + selector;
- } else if ( name ) {
- ret.selector = this.selector + "." + name + "(" + selector + ")";
- }
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
-
- ready: function( fn ) {
- // Attach the listeners
- jQuery.bindReady();
-
- // Add the callback
- readyList.done( fn );
-
- return this;
- },
-
- eq: function( i ) {
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, +i + 1 );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ),
- "slice", slice.call(arguments).join(",") );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
-
- end: function() {
- return this.prevObject || this.constructor(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: [].sort,
- splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- noConflict: function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
- },
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
- // Either a released hold or an DOMready/load event and not yet ready
- if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger( "ready" ).unbind( "ready" );
- }
- }
- },
-
- bindReady: function() {
- if ( readyList ) {
- return;
- }
-
- readyList = jQuery._Deferred();
-
- // Catch cases where $(document).ready() is called after the
- // browser event has already occurred.
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Mozilla, Opera and webkit nightlies currently support this event
- if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else if ( document.attachEvent ) {
- // ensure firing before onload,
- // maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var toplevel = false;
-
- try {
- toplevel = window.frameElement == null;
- } catch(e) {}
-
- if ( document.documentElement.doScroll && toplevel ) {
- doScrollCheck();
- }
- }
- },
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- // A crude way of determining if an object is a window
- isWindow: function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
- },
-
- isNaN: function( obj ) {
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
- },
-
- type: function( obj ) {
- return obj == null ?
- String( obj ) :
- class2type[ toString.call(obj) ] || "object";
- },
-
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- } catch ( e ) {
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || hasOwn.call( obj, key );
- },
-
- isEmptyObject: function( obj ) {
- for ( var name in obj ) {
- return false;
- }
- return true;
- },
-
- error: function( msg ) {
- throw msg;
- },
-
- parseJSON: function( data ) {
- if ( typeof data !== "string" || !data ) {
- return null;
- }
-
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
-
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- return window.JSON.parse( data );
- }
-
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test( data.replace( rvalidescape, "@" )
- .replace( rvalidtokens, "]" )
- .replace( rvalidbraces, "")) ) {
-
- return (new Function( "return " + data ))();
-
- }
- jQuery.error( "Invalid JSON: " + data );
- },
-
- // Cross-browser xml parsing
- parseXML: function( data ) {
- var xml, tmp;
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data , "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
- },
-
- noop: function() {},
-
- // Evaluates a script in a global context
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && rnotwhite.test( data ) ) {
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data );
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
- },
-
- // args is for internal usage only
- each: function( object, callback, args ) {
- var name, i = 0,
- length = object.length,
- isObj = length === undefined || jQuery.isFunction( object );
-
- if ( args ) {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.apply( object[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( object[ i++ ], args ) === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
- break;
- }
- }
- }
- }
-
- return object;
- },
-
- // Use native String.trim function wherever possible
- trim: trim ?
- function( text ) {
- return text == null ?
- "" :
- trim.call( text );
- } :
-
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
- },
-
- // results is for internal usage only
- makeArray: function( array, results ) {
- var ret = results || [];
-
- if ( array != null ) {
- // The window, strings (and functions) also have 'length'
- // The extra typeof function check is to prevent crashes
- // in Safari 2 (See: #3039)
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- var type = jQuery.type( array );
-
- if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
- push.call( ret, array );
- } else {
- jQuery.merge( ret, array );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, array ) {
- if ( !array ) {
- return -1;
- }
-
- if ( indexOf ) {
- return indexOf.call( array, elem );
- }
-
- for ( var i = 0, length = array.length; i < length; i++ ) {
- if ( array[ i ] === elem ) {
- return i;
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var i = first.length,
- j = 0;
-
- if ( typeof second.length === "number" ) {
- for ( var l = second.length; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, inv ) {
- var ret = [], retVal;
- inv = !!inv;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var value, key, ret = [],
- i = 0,
- length = elems.length,
- // jquery objects are treated as arrays
- isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
-
- // Go through the array, translating each of the items to their
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( key in elems ) {
- value = callback( elems[ key ], key, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
- }
-
- // Flatten any nested arrays
- return ret.concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- if ( typeof context === "string" ) {
- var tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- var args = slice.call( arguments, 2 ),
- proxy = function() {
- return fn.apply( context, args.concat( slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
-
- return proxy;
- },
-
- // Mutifunctional method to get and set values to a collection
- // The value/s can optionally be executed if it's a function
- access: function( elems, key, value, exec, fn, pass ) {
- var length = elems.length;
-
- // Setting many attributes
- if ( typeof key === "object" ) {
- for ( var k in key ) {
- jQuery.access( elems, k, key[k], exec, fn, value );
- }
- return elems;
- }
-
- // Setting one attribute
- if ( value !== undefined ) {
- // Optionally, function values get executed if exec is true
- exec = !pass && exec && jQuery.isFunction(value);
-
- for ( var i = 0; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
- }
-
- return elems;
- }
-
- // Getting an attribute
- return length ? fn( elems[0], key ) : undefined;
- },
-
- now: function() {
- return (new Date()).getTime();
- },
-
- // Use of jQuery.browser is frowned upon.
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
- uaMatch: function( ua ) {
- ua = ua.toLowerCase();
-
- var match = rwebkit.exec( ua ) ||
- ropera.exec( ua ) ||
- rmsie.exec( ua ) ||
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
- [];
-
- return { browser: match[1] || "", version: match[2] || "0" };
- },
-
- sub: function() {
- function jQuerySub( selector, context ) {
- return new jQuerySub.fn.init( selector, context );
- }
- jQuery.extend( true, jQuerySub, this );
- jQuerySub.superclass = this;
- jQuerySub.fn = jQuerySub.prototype = this();
- jQuerySub.fn.constructor = jQuerySub;
- jQuerySub.sub = this.sub;
- jQuerySub.fn.init = function init( selector, context ) {
- if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
- context = jQuerySub( context );
- }
-
- return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
- };
- jQuerySub.fn.init.prototype = jQuerySub.fn;
- var rootjQuerySub = jQuerySub(document);
- return jQuerySub;
- },
-
- browser: {}
-});
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-browserMatch = jQuery.uaMatch( userAgent );
-if ( browserMatch.browser ) {
- jQuery.browser[ browserMatch.browser ] = true;
- jQuery.browser.version = browserMatch.version;
-}
-
-// Deprecated, use jQuery.browser.webkit instead
-if ( jQuery.browser.webkit ) {
- jQuery.browser.safari = true;
-}
-
-// IE doesn't match non-breaking spaces with \s
-if ( rnotwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
- DOMContentLoaded = function() {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- };
-
-} else if ( document.attachEvent ) {
- DOMContentLoaded = function() {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" ) {
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
- };
-}
-
-// The DOM ready check for Internet Explorer
-function doScrollCheck() {
- if ( jQuery.isReady ) {
- return;
- }
-
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch(e) {
- setTimeout( doScrollCheck, 1 );
- return;
- }
-
- // and execute any waiting functions
- jQuery.ready();
-}
-
-return jQuery;
-
-})();
-
-
-var // Promise methods
- promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
- // Static reference to slice
- sliceDeferred = [].slice;
-
-jQuery.extend({
- // Create a simple deferred (one callbacks list)
- _Deferred: function() {
- var // callbacks list
- callbacks = [],
- // stored [ context , args ]
- fired,
- // to avoid firing when already doing so
- firing,
- // flag to know if the deferred has been cancelled
- cancelled,
- // the deferred itself
- deferred = {
-
- // done( f1, f2, ...)
- done: function() {
- if ( !cancelled ) {
- var args = arguments,
- i,
- length,
- elem,
- type,
- _fired;
- if ( fired ) {
- _fired = fired;
- fired = 0;
- }
- for ( i = 0, length = args.length; i < length; i++ ) {
- elem = args[ i ];
- type = jQuery.type( elem );
- if ( type === "array" ) {
- deferred.done.apply( deferred, elem );
- } else if ( type === "function" ) {
- callbacks.push( elem );
- }
- }
- if ( _fired ) {
- deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
- }
- }
- return this;
- },
-
- // resolve with given context and args
- resolveWith: function( context, args ) {
- if ( !cancelled && !fired && !firing ) {
- // make sure args are available (#8421)
- args = args || [];
- firing = 1;
- try {
- while( callbacks[ 0 ] ) {
- callbacks.shift().apply( context, args );
- }
- }
- finally {
- fired = [ context, args ];
- firing = 0;
- }
- }
- return this;
- },
-
- // resolve with this as context and given arguments
- resolve: function() {
- deferred.resolveWith( this, arguments );
- return this;
- },
-
- // Has this deferred been resolved?
- isResolved: function() {
- return !!( firing || fired );
- },
-
- // Cancel
- cancel: function() {
- cancelled = 1;
- callbacks = [];
- return this;
- }
- };
-
- return deferred;
- },
-
- // Full fledged deferred (two callbacks list)
- Deferred: function( func ) {
- var deferred = jQuery._Deferred(),
- failDeferred = jQuery._Deferred(),
- promise;
- // Add errorDeferred methods, then and promise
- jQuery.extend( deferred, {
- then: function( doneCallbacks, failCallbacks ) {
- deferred.done( doneCallbacks ).fail( failCallbacks );
- return this;
- },
- always: function() {
- return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
- },
- fail: failDeferred.done,
- rejectWith: failDeferred.resolveWith,
- reject: failDeferred.resolve,
- isRejected: failDeferred.isResolved,
- pipe: function( fnDone, fnFail ) {
- return jQuery.Deferred(function( newDefer ) {
- jQuery.each( {
- done: [ fnDone, "resolve" ],
- fail: [ fnFail, "reject" ]
- }, function( handler, data ) {
- var fn = data[ 0 ],
- action = data[ 1 ],
- returned;
- if ( jQuery.isFunction( fn ) ) {
- deferred[ handler ](function() {
- returned = fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise().then( newDefer.resolve, newDefer.reject );
- } else {
- newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
- }
- });
- } else {
- deferred[ handler ]( newDefer[ action ] );
- }
- });
- }).promise();
- },
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- if ( obj == null ) {
- if ( promise ) {
- return promise;
- }
- promise = obj = {};
- }
- var i = promiseMethods.length;
- while( i-- ) {
- obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
- }
- return obj;
- }
- });
- // Make sure only one callback list will be used
- deferred.done( failDeferred.cancel ).fail( deferred.cancel );
- // Unexpose cancel
- delete deferred.cancel;
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
- return deferred;
- },
-
- // Deferred helper
- when: function( firstParam ) {
- var args = arguments,
- i = 0,
- length = args.length,
- count = length,
- deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
- firstParam :
- jQuery.Deferred();
- function resolveFunc( i ) {
- return function( value ) {
- args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
- if ( !( --count ) ) {
- // Strange bug in FF4:
- // Values changed onto the arguments object sometimes end up as undefined values
- // outside the $.when method. Cloning the object into a fresh array solves the issue
- deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
- }
- };
- }
- if ( length > 1 ) {
- for( ; i < length; i++ ) {
- if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
- args[ i ].promise().then( resolveFunc(i), deferred.reject );
- } else {
- --count;
- }
- }
- if ( !count ) {
- deferred.resolveWith( deferred, args );
- }
- } else if ( deferred !== firstParam ) {
- deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
- }
- return deferred.promise();
- }
-});
-
-
-
-jQuery.support = (function() {
-
- var div = document.createElement( "div" ),
- documentElement = document.documentElement,
- all,
- a,
- select,
- opt,
- input,
- marginDiv,
- support,
- fragment,
- body,
- testElementParent,
- testElement,
- testElementStyle,
- tds,
- events,
- eventName,
- i,
- isSupported;
-
- // Preliminary tests
- div.setAttribute("className", "t");
- div.innerHTML = " a ";
-
-
- all = div.getElementsByTagName( "*" );
- a = div.getElementsByTagName( "a" )[ 0 ];
-
- // Can't get basic test support
- if ( !all || !all.length || !a ) {
- return {};
- }
-
- // First batch of supports tests
- select = document.createElement( "select" );
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName( "input" )[ 0 ];
-
- support = {
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: ( div.firstChild.nodeType === 3 ),
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName( "tbody" ).length,
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName( "link" ).length,
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- style: /top/.test( a.getAttribute("style") ),
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
-
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.55$/.test( a.style.opacity ),
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
-
- // Make sure that if no value is specified for a checkbox
- // that it defaults to "on".
- // (WebKit defaults to "" instead)
- checkOn: ( input.value === "on" ),
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
-
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- getSetAttribute: div.className !== "t",
-
- // Will be defined later
- submitBubbles: true,
- changeBubbles: true,
- focusinBubbles: false,
- deleteExpando: true,
- noCloneEvent: true,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableMarginRight: true
- };
-
- // Make sure checked status is properly cloned
- input.checked = true;
- support.noCloneChecked = input.cloneNode( true ).checked;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Test to see if it's possible to delete an expando from an element
- // Fails in Internet Explorer
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
-
- if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
- div.attachEvent( "onclick", function() {
- // Cloning a node shouldn't copy over any
- // bound event handlers (IE does this)
- support.noCloneEvent = false;
- });
- div.cloneNode( true ).fireEvent( "onclick" );
- }
-
- // Check if a radio maintains it's value
- // after being appended to the DOM
- input = document.createElement("input");
- input.value = "t";
- input.setAttribute("type", "radio");
- support.radioValue = input.value === "t";
-
- input.setAttribute("checked", "checked");
- div.appendChild( input );
- fragment = document.createDocumentFragment();
- fragment.appendChild( div.firstChild );
-
- // WebKit doesn't clone checked state correctly in fragments
- support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- div.innerHTML = "";
-
- // Figure out if the W3C box model works as expected
- div.style.width = div.style.paddingLeft = "1px";
-
- body = document.getElementsByTagName( "body" )[ 0 ];
- // We use our own, invisible, body unless the body is already present
- // in which case we use a div (#9239)
- testElement = document.createElement( body ? "div" : "body" );
- testElementStyle = {
- visibility: "hidden",
- width: 0,
- height: 0,
- border: 0,
- margin: 0,
- background: "none"
- };
- if ( body ) {
- jQuery.extend( testElementStyle, {
- position: "absolute",
- left: "-1000px",
- top: "-1000px"
- });
- }
- for ( i in testElementStyle ) {
- testElement.style[ i ] = testElementStyle[ i ];
- }
- testElement.appendChild( div );
- testElementParent = body || documentElement;
- testElementParent.insertBefore( testElement, testElementParent.firstChild );
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- support.appendChecked = input.checked;
-
- support.boxModel = div.offsetWidth === 2;
-
- if ( "zoom" in div.style ) {
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- // (IE < 8 does this)
- div.style.display = "inline";
- div.style.zoom = 1;
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
-
- // Check if elements with layout shrink-wrap their children
- // (IE 6 does this)
- div.style.display = "";
- div.innerHTML = "
";
- support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
- }
-
- div.innerHTML = "";
- tds = div.getElementsByTagName( "td" );
-
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- // (only IE 8 fails this test)
- isSupported = ( tds[ 0 ].offsetHeight === 0 );
-
- tds[ 0 ].style.display = "";
- tds[ 1 ].style.display = "none";
-
- // Check if empty table cells still have offsetWidth/Height
- // (IE < 8 fail this test)
- support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
- div.innerHTML = "";
-
- // Check if div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container. For more
- // info see bug #3333
- // Fails in WebKit before Feb 2011 nightlies
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- if ( document.defaultView && document.defaultView.getComputedStyle ) {
- marginDiv = document.createElement( "div" );
- marginDiv.style.width = "0";
- marginDiv.style.marginRight = "0";
- div.appendChild( marginDiv );
- support.reliableMarginRight =
- ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
- }
-
- // Remove the body element we added
- testElement.innerHTML = "";
- testElementParent.removeChild( testElement );
-
- // Technique from Juriy Zaytsev
- // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
- // We only care about the case where non-standard event systems
- // are used, namely in IE. Short-circuiting here helps us to
- // avoid an eval call (in setAttribute) which can cause CSP
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
- if ( div.attachEvent ) {
- for( i in {
- submit: 1,
- change: 1,
- focusin: 1
- } ) {
- eventName = "on" + i;
- isSupported = ( eventName in div );
- if ( !isSupported ) {
- div.setAttribute( eventName, "return;" );
- isSupported = ( typeof div[ eventName ] === "function" );
- }
- support[ i + "Bubbles" ] = isSupported;
- }
- }
-
- // Null connected elements to avoid leaks in IE
- testElement = fragment = select = opt = body = marginDiv = div = input = null;
-
- return support;
-})();
-
-// Keep track of boxModel
-jQuery.boxModel = jQuery.support.boxModel;
-
-
-
-
-var rbrace = /^(?:\{.*\}|\[.*\])$/,
- rmultiDash = /([A-Z])/g;
-
-jQuery.extend({
- cache: {},
-
- // Please use with caution
- uuid: 0,
-
- // Unique for each copy of jQuery on the page
- // Non-digits removed to match rinlinejQuery
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
-
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
-
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, ret,
- internalKey = jQuery.expando,
- getByName = typeof name === "string",
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
- return;
- }
-
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- elem[ jQuery.expando ] = id = ++jQuery.uuid;
- } else {
- id = jQuery.expando;
- }
- }
-
- if ( !cache[ id ] ) {
- cache[ id ] = {};
-
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
- // metadata on plain JS objects when the object is serialized using
- // JSON.stringify
- if ( !isNode ) {
- cache[ id ].toJSON = jQuery.noop;
- }
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
- } else {
- cache[ id ] = jQuery.extend(cache[ id ], name);
- }
- }
-
- thisCache = cache[ id ];
-
- // Internal jQuery data is stored in a separate object inside the object's data
- // cache in order to avoid key collisions between internal data and user-defined
- // data
- if ( pvt ) {
- if ( !thisCache[ internalKey ] ) {
- thisCache[ internalKey ] = {};
- }
-
- thisCache = thisCache[ internalKey ];
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
- // not attempt to inspect the internal events object using jQuery.data, as this
- // internal data object is undocumented and subject to change.
- if ( name === "events" && !thisCache[name] ) {
- return thisCache[ internalKey ] && thisCache[ internalKey ].events;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( getByName ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
- },
-
- removeData: function( elem, name, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache,
-
- // Reference to internal data cache key
- internalKey = jQuery.expando,
-
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
-
- // See jQuery.data for more information
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
-
- if ( thisCache ) {
-
- // Support interoperable removal of hyphenated or camelcased keys
- if ( !thisCache[ name ] ) {
- name = jQuery.camelCase( name );
- }
-
- delete thisCache[ name ];
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( !isEmptyDataObject(thisCache) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( pvt ) {
- delete cache[ id ][ internalKey ];
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject(cache[ id ]) ) {
- return;
- }
- }
-
- var internalCache = cache[ id ][ internalKey ];
-
- // Browsers that fail expando deletion also refuse to delete expandos on
- // the window, but it will allow it on all other JS objects; other browsers
- // don't care
- // Ensure that `cache` is not a window object #10080
- if ( jQuery.support.deleteExpando || !cache.setInterval ) {
- delete cache[ id ];
- } else {
- cache[ id ] = null;
- }
-
- // We destroyed the entire user cache at once because it's faster than
- // iterating through each key, but we need to continue to persist internal
- // data if it existed
- if ( internalCache ) {
- cache[ id ] = {};
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
- // metadata on plain JS objects when the object is serialized using
- // JSON.stringify
- if ( !isNode ) {
- cache[ id ].toJSON = jQuery.noop;
- }
-
- cache[ id ][ internalKey ] = internalCache;
-
- // Otherwise, we need to eliminate the expando on the node to avoid
- // false lookups in the cache for entries that no longer exist
- } else if ( isNode ) {
- // IE does not allow us to delete expando properties from nodes,
- // nor does it have a removeAttribute function on Document nodes;
- // we must handle all of these cases
- if ( jQuery.support.deleteExpando ) {
- delete elem[ jQuery.expando ];
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( jQuery.expando );
- } else {
- elem[ jQuery.expando ] = null;
- }
- }
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return jQuery.data( elem, name, data, true );
- },
-
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- if ( elem.nodeName ) {
- var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
-
- if ( match ) {
- return !(match === true || elem.getAttribute("classid") !== match);
- }
- }
-
- return true;
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var data = null;
-
- if ( typeof key === "undefined" ) {
- if ( this.length ) {
- data = jQuery.data( this[0] );
-
- if ( this[0].nodeType === 1 ) {
- var attr = this[0].attributes, name;
- for ( var i = 0, l = attr.length; i < l; i++ ) {
- name = attr[i].name;
-
- if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.substring(5) );
-
- dataAttr( this[0], name, data[ name ] );
- }
- }
- }
- }
-
- return data;
-
- } else if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- var parts = key.split(".");
- parts[1] = parts[1] ? "." + parts[1] : "";
-
- if ( value === undefined ) {
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
-
- // Try to fetch any internally stored data first
- if ( data === undefined && this.length ) {
- data = jQuery.data( this[0], key );
- data = dataAttr( this[0], key, data );
- }
-
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
-
- } else {
- return this.each(function() {
- var $this = jQuery( this ),
- args = [ parts[0], value ];
-
- $this.triggerHandler( "setData" + parts[1] + "!", args );
- jQuery.data( this, key, value );
- $this.triggerHandler( "changeData" + parts[1] + "!", args );
- });
- }
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- !jQuery.isNaN( data ) ? parseFloat( data ) :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
-// property to be considered empty objects; this property always exists in
-// order to make sure JSON.stringify does not expose internal metadata
-function isEmptyDataObject( obj ) {
- for ( var name in obj ) {
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-
-
-
-
-function handleQueueMarkDefer( elem, type, src ) {
- var deferDataKey = type + "defer",
- queueDataKey = type + "queue",
- markDataKey = type + "mark",
- defer = jQuery.data( elem, deferDataKey, undefined, true );
- if ( defer &&
- ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
- ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
- // Give room for hard-coded callbacks to fire first
- // and eventually mark/queue something else on the element
- setTimeout( function() {
- if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
- !jQuery.data( elem, markDataKey, undefined, true ) ) {
- jQuery.removeData( elem, deferDataKey, true );
- defer.resolve();
- }
- }, 0 );
- }
-}
-
-jQuery.extend({
-
- _mark: function( elem, type ) {
- if ( elem ) {
- type = (type || "fx") + "mark";
- jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
- }
- },
-
- _unmark: function( force, elem, type ) {
- if ( force !== true ) {
- type = elem;
- elem = force;
- force = false;
- }
- if ( elem ) {
- type = type || "fx";
- var key = type + "mark",
- count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
- if ( count ) {
- jQuery.data( elem, key, count, true );
- } else {
- jQuery.removeData( elem, key, true );
- handleQueueMarkDefer( elem, type, "mark" );
- }
- }
- },
-
- queue: function( elem, type, data ) {
- if ( elem ) {
- type = (type || "fx") + "queue";
- var q = jQuery.data( elem, type, undefined, true );
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !q || jQuery.isArray(data) ) {
- q = jQuery.data( elem, type, jQuery.makeArray(data), true );
- } else {
- q.push( data );
- }
- }
- return q || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- fn = queue.shift(),
- defer;
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- }
-
- if ( fn ) {
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift("inprogress");
- }
-
- fn.call(elem, function() {
- jQuery.dequeue(elem, type);
- });
- }
-
- if ( !queue.length ) {
- jQuery.removeData( elem, type + "queue", true );
- handleQueueMarkDefer( elem, type, "queue" );
- }
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- }
-
- if ( data === undefined ) {
- return jQuery.queue( this[0], type );
- }
- return this.each(function() {
- var queue = jQuery.queue( this, type, data );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
- type = type || "fx";
-
- return this.queue( type, function() {
- var elem = this;
- setTimeout(function() {
- jQuery.dequeue( elem, type );
- }, time );
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, object ) {
- if ( typeof type !== "string" ) {
- object = type;
- type = undefined;
- }
- type = type || "fx";
- var defer = jQuery.Deferred(),
- elements = this,
- i = elements.length,
- count = 1,
- deferDataKey = type + "defer",
- queueDataKey = type + "queue",
- markDataKey = type + "mark",
- tmp;
- function resolve() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- }
- while( i-- ) {
- if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
- ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
- jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
- jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
- count++;
- tmp.done( resolve );
- }
- }
- resolve();
- return defer.promise();
- }
-});
-
-
-
-
-var rclass = /[\n\t\r]/g,
- rspace = /\s+/,
- rreturn = /\r/g,
- rtype = /^(?:button|input)$/i,
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
- rclickable = /^a(?:rea)?$/i,
- rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
- nodeHook, boolHook;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.attr );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- },
-
- prop: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.prop );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each(function() {
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch( e ) {}
- });
- },
-
- addClass: function( value ) {
- var classNames, i, l, elem,
- setClass, c, cl;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call(this, j, this.className) );
- });
- }
-
- if ( value && typeof value === "string" ) {
- classNames = value.split( rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
-
- if ( elem.nodeType === 1 ) {
- if ( !elem.className && classNames.length === 1 ) {
- elem.className = value;
-
- } else {
- setClass = " " + elem.className + " ";
-
- for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
- setClass += classNames[ c ] + " ";
- }
- }
- elem.className = jQuery.trim( setClass );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classNames, i, l, elem, className, c, cl;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call(this, j, this.className) );
- });
- }
-
- if ( (value && typeof value === "string") || value === undefined ) {
- classNames = (value || "").split( rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
-
- if ( elem.nodeType === 1 && elem.className ) {
- if ( value ) {
- className = (" " + elem.className + " ").replace( rclass, " " );
- for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- className = className.replace(" " + classNames[ c ] + " ", " ");
- }
- elem.className = jQuery.trim( className );
-
- } else {
- elem.className = "";
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.split( rspace );
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space seperated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
-
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
-
- // toggle whole className
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ";
- for ( var i = 0, l = this.length; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- var hooks, ret,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return undefined;
- }
-
- var isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var self = jQuery(this), val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, self.val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map(val, function ( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- },
- select: {
- get: function( elem ) {
- var value,
- index = elem.selectedIndex,
- values = [],
- options = elem.options,
- one = elem.type === "select-one";
-
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
-
- // Loop through all the selected options
- for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
- var option = options[ i ];
-
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
- if ( one && !values.length && options.length ) {
- return jQuery( options[ index ] ).val();
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var values = jQuery.makeArray( value );
-
- jQuery(elem).find("option").each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
-
- if ( !values.length ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- },
-
- attrFn: {
- val: true,
- css: true,
- html: true,
- text: true,
- data: true,
- width: true,
- height: true,
- offset: true
- },
-
- attrFix: {
- // Always normalize to ensure hook usage
- tabindex: "tabIndex"
- },
-
- attr: function( elem, name, value, pass ) {
- var nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return undefined;
- }
-
- if ( pass && name in jQuery.attrFn ) {
- return jQuery( elem )[ name ]( value );
- }
-
- // Fallback to prop when attributes are not supported
- if ( !("getAttribute" in elem) ) {
- return jQuery.prop( elem, name, value );
- }
-
- var ret, hooks,
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- // Normalize the name if needed
- if ( notxml ) {
- name = jQuery.attrFix[ name ] || name;
-
- hooks = jQuery.attrHooks[ name ];
-
- if ( !hooks ) {
- // Use boolHook for boolean attributes
- if ( rboolean.test( name ) ) {
- hooks = boolHook;
-
- // Use nodeHook if available( IE6/7 )
- } else if ( nodeHook ) {
- hooks = nodeHook;
- }
- }
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
- return undefined;
-
- } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, "" + value );
- return value;
- }
-
- } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
-
- ret = elem.getAttribute( name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret === null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, name ) {
- var propName;
- if ( elem.nodeType === 1 ) {
- name = jQuery.attrFix[ name ] || name;
-
- jQuery.attr( elem, name, "" );
- elem.removeAttribute( name );
-
- // Set corresponding property to false for boolean attributes
- if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
- elem[ propName ] = false;
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to it's default in case type is set after value
- // This is for element creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- },
- // Use the value property for back compat
- // Use the nodeHook for button elements in IE6/7 (#1954)
- value: {
- get: function( elem, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.get( elem, name );
- }
- return name in elem ?
- elem.value :
- null;
- },
- set: function( elem, value, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.set( elem, value, name );
- }
- // Does not return so that setAttribute is also used
- elem.value = value;
- }
- }
- },
-
- propFix: {
- tabindex: "tabIndex",
- readonly: "readOnly",
- "for": "htmlFor",
- "class": "className",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- cellpadding: "cellPadding",
- rowspan: "rowSpan",
- colspan: "colSpan",
- usemap: "useMap",
- frameborder: "frameBorder",
- contenteditable: "contentEditable"
- },
-
- prop: function( elem, name, value ) {
- var nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return undefined;
- }
-
- var ret, hooks,
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- return (elem[ name ] = value);
- }
-
- } else {
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- return elem[ name ];
- }
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- var attributeNode = elem.getAttributeNode("tabindex");
-
- return attributeNode && attributeNode.specified ?
- parseInt( attributeNode.value, 10 ) :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
- }
- }
-});
-
-// Add the tabindex propHook to attrHooks for back-compat
-jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
-
-// Hook for boolean attributes
-boolHook = {
- get: function( elem, name ) {
- // Align boolean attributes with corresponding properties
- // Fall back to attribute presence where some booleans are not supported
- var attrNode;
- return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
- name.toLowerCase() :
- undefined;
- },
- set: function( elem, value, name ) {
- var propName;
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- // value is true since we know at this point it's type boolean and not false
- // Set boolean attributes to the same name and set the DOM property
- propName = jQuery.propFix[ name ] || name;
- if ( propName in elem ) {
- // Only set the IDL specifically if it already exists on the element
- elem[ propName ] = true;
- }
-
- elem.setAttribute( name, name.toLowerCase() );
- }
- return name;
- }
-};
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !jQuery.support.getSetAttribute ) {
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret;
- ret = elem.getAttributeNode( name );
- // Return undefined if nodeValue is empty string
- return ret && ret.nodeValue !== "" ?
- ret.nodeValue :
- undefined;
- },
- set: function( elem, value, name ) {
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- ret = document.createAttribute( name );
- elem.setAttributeNode( ret );
- }
- return (ret.nodeValue = value + "");
- }
- };
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each([ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- });
- });
-}
-
-
-// Some attributes require a special call on IE
-if ( !jQuery.support.hrefNormalized ) {
- jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- get: function( elem ) {
- var ret = elem.getAttribute( name, 2 );
- return ret === null ? undefined : ret;
- }
- });
- });
-}
-
-if ( !jQuery.support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
- // Return undefined in the case of empty string
- // Normalize to lowercase since IE uppercases css property names
- return elem.style.cssText.toLowerCase() || undefined;
- },
- set: function( elem, value ) {
- return (elem.style.cssText = "" + value);
- }
- };
-}
-
-// Safari mis-reports the default selected property of an option
-// Accessing the parent's selectedIndex property fixes it
-if ( !jQuery.support.optSelected ) {
- jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- }
- });
-}
-
-// Radios and checkboxes getter/setter
-if ( !jQuery.support.checkOn ) {
- jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- get: function( elem ) {
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
- };
- });
-}
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
- }
- }
- });
-});
-
-
-
-
-var rnamespaces = /\.(.*)$/,
- rformElems = /^(?:textarea|input|select)$/i,
- rperiod = /\./g,
- rspaces = / /g,
- rescape = /[^\w\s.|`]/g,
- fcleanup = function( nm ) {
- return nm.replace(rescape, "\\$&");
- };
-
-/*
- * A number of helper functions used for managing events.
- * Many of the ideas behind this code originated from
- * Dean Edwards' addEvent library.
- */
-jQuery.event = {
-
- // Bind an event to an element
- // Original by Dean Edwards
- add: function( elem, types, handler, data ) {
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- if ( handler === false ) {
- handler = returnFalse;
- } else if ( !handler ) {
- // Fixes bug #7229. Fix recommended by jdalton
- return;
- }
-
- var handleObjIn, handleObj;
-
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- }
-
- // Make sure that the function being executed has a unique ID
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure
- var elemData = jQuery._data( elem );
-
- // If no elemData is found then we must be trying to bind to one of the
- // banned noData elements
- if ( !elemData ) {
- return;
- }
-
- var events = elemData.events,
- eventHandle = elemData.handle;
-
- if ( !events ) {
- elemData.events = events = {};
- }
-
- if ( !eventHandle ) {
- elemData.handle = eventHandle = function( e ) {
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
- jQuery.event.handle.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- }
-
- // Add elem as a property of the handle function
- // This is to prevent a memory leak with non-native events in IE.
- eventHandle.elem = elem;
-
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = types.split(" ");
-
- var type, i = 0, namespaces;
-
- while ( (type = types[ i++ ]) ) {
- handleObj = handleObjIn ?
- jQuery.extend({}, handleObjIn) :
- { handler: handler, data: data };
-
- // Namespaced event handlers
- if ( type.indexOf(".") > -1 ) {
- namespaces = type.split(".");
- type = namespaces.shift();
- handleObj.namespace = namespaces.slice(0).sort().join(".");
-
- } else {
- namespaces = [];
- handleObj.namespace = "";
- }
-
- handleObj.type = type;
- if ( !handleObj.guid ) {
- handleObj.guid = handler.guid;
- }
-
- // Get the current list of functions bound to this event
- var handlers = events[ type ],
- special = jQuery.event.special[ type ] || {};
-
- // Init the event handler queue
- if ( !handlers ) {
- handlers = events[ type ] = [];
-
- // Check for a special event handler
- // Only use addEventListener/attachEvent if the special
- // events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add the function to the element's handler list
- handlers.push( handleObj );
-
- // Keep track of which events have been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- global: {},
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, pos ) {
- // don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- if ( handler === false ) {
- handler = returnFalse;
- }
-
- var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
- events = elemData && elemData.events;
-
- if ( !elemData || !events ) {
- return;
- }
-
- // types is actually an event object here
- if ( types && types.type ) {
- handler = types.handler;
- types = types.type;
- }
-
- // Unbind all events for the element
- if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
- types = types || "";
-
- for ( type in events ) {
- jQuery.event.remove( elem, type + types );
- }
-
- return;
- }
-
- // Handle multiple events separated by a space
- // jQuery(...).unbind("mouseover mouseout", fn);
- types = types.split(" ");
-
- while ( (type = types[ i++ ]) ) {
- origType = type;
- handleObj = null;
- all = type.indexOf(".") < 0;
- namespaces = [];
-
- if ( !all ) {
- // Namespaced event handlers
- namespaces = type.split(".");
- type = namespaces.shift();
-
- namespace = new RegExp("(^|\\.)" +
- jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
-
- eventType = events[ type ];
-
- if ( !eventType ) {
- continue;
- }
-
- if ( !handler ) {
- for ( j = 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( all || namespace.test( handleObj.namespace ) ) {
- jQuery.event.remove( elem, origType, handleObj.handler, j );
- eventType.splice( j--, 1 );
- }
- }
-
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
-
- for ( j = pos || 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( handler.guid === handleObj.guid ) {
- // remove the given handler for the given type
- if ( all || namespace.test( handleObj.namespace ) ) {
- if ( pos == null ) {
- eventType.splice( j--, 1 );
- }
-
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
-
- if ( pos != null ) {
- break;
- }
- }
- }
-
- // remove generic event handler if no more handlers exist
- if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- ret = null;
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- var handle = elemData.handle;
- if ( handle ) {
- handle.elem = null;
- }
-
- delete elemData.events;
- delete elemData.handle;
-
- if ( jQuery.isEmptyObject( elemData ) ) {
- jQuery.removeData( elem, undefined, true );
- }
- }
- },
-
- // Events that are safe to short-circuit if no handlers are attached.
- // Native DOM events should not be added, they may have inline handlers.
- customEvent: {
- "getData": true,
- "setData": true,
- "changeData": true
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- // Event object or event type
- var type = event.type || event,
- namespaces = [],
- exclusive;
-
- if ( type.indexOf("!") >= 0 ) {
- // Exclusive events trigger only for the exact event (no namespaces)
- type = type.slice(0, -1);
- exclusive = true;
- }
-
- if ( type.indexOf(".") >= 0 ) {
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split(".");
- type = namespaces.shift();
- namespaces.sort();
- }
-
- if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
- // No jQuery handlers for this event type, and it can't have inline handlers
- return;
- }
-
- // Caller can pass in an Event, Object, or just an event type string
- event = typeof event === "object" ?
- // jQuery.Event object
- event[ jQuery.expando ] ? event :
- // Object literal
- new jQuery.Event( type, event ) :
- // Just the event type (string)
- new jQuery.Event( type );
-
- event.type = type;
- event.exclusive = exclusive;
- event.namespace = namespaces.join(".");
- event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
-
- // triggerHandler() and global events don't bubble or run the default action
- if ( onlyHandlers || !elem ) {
- event.preventDefault();
- event.stopPropagation();
- }
-
- // Handle a global trigger
- if ( !elem ) {
- // TODO: Stop taunting the data cache; remove global events and always attach to document
- jQuery.each( jQuery.cache, function() {
- // internalKey variable is just used to make it easier to find
- // and potentially change this stuff later; currently it just
- // points to jQuery.expando
- var internalKey = jQuery.expando,
- internalCache = this[ internalKey ];
- if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
- jQuery.event.trigger( event, data, internalCache.handle.elem );
- }
- });
- return;
- }
-
- // Don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- event.target = elem;
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data != null ? jQuery.makeArray( data ) : [];
- data.unshift( event );
-
- var cur = elem,
- // IE doesn't like method names with a colon (#3533, #8272)
- ontype = type.indexOf(":") < 0 ? "on" + type : "";
-
- // Fire event on the current element, then bubble up the DOM tree
- do {
- var handle = jQuery._data( cur, "handle" );
-
- event.currentTarget = cur;
- if ( handle ) {
- handle.apply( cur, data );
- }
-
- // Trigger an inline bound script
- if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
- event.result = false;
- event.preventDefault();
- }
-
- // Bubble up to document, then to window
- cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
- } while ( cur && !event.isPropagationStopped() );
-
- // If nobody prevented the default action, do it now
- if ( !event.isDefaultPrevented() ) {
- var old,
- special = jQuery.event.special[ type ] || {};
-
- if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
- !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
-
- // Call a native DOM method on the target with the same name name as the event.
- // Can't use an .isFunction)() check here because IE6/7 fails that test.
- // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
- try {
- if ( ontype && elem[ type ] ) {
- // Don't re-trigger an onFOO event when we call its FOO() method
- old = elem[ ontype ];
-
- if ( old ) {
- elem[ ontype ] = null;
- }
-
- jQuery.event.triggered = type;
- elem[ type ]();
- }
- } catch ( ieError ) {}
-
- if ( old ) {
- elem[ ontype ] = old;
- }
-
- jQuery.event.triggered = undefined;
- }
- }
-
- return event.result;
- },
-
- handle: function( event ) {
- event = jQuery.event.fix( event || window.event );
- // Snapshot the handlers list since a called handler may add/remove events.
- var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
- run_all = !event.exclusive && !event.namespace,
- args = Array.prototype.slice.call( arguments, 0 );
-
- // Use the fix-ed Event rather than the (read-only) native event
- args[0] = event;
- event.currentTarget = this;
-
- for ( var j = 0, l = handlers.length; j < l; j++ ) {
- var handleObj = handlers[ j ];
-
- // Triggered event must 1) be non-exclusive and have no namespace, or
- // 2) have namespace(s) a subset or equal to those in the bound event.
- if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
- // Pass in a reference to the handler function itself
- // So that we can later remove it
- event.handler = handleObj.handler;
- event.data = handleObj.data;
- event.handleObj = handleObj;
-
- var ret = handleObj.handler.apply( this, args );
-
- if ( ret !== undefined ) {
- event.result = ret;
- if ( ret === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
-
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
- return event.result;
- },
-
- props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
-
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
-
- // store a copy of the original event object
- // and "clone" to set read-only properties
- var originalEvent = event;
- event = jQuery.Event( originalEvent );
-
- for ( var i = this.props.length, prop; i; ) {
- prop = this.props[ --i ];
- event[ prop ] = originalEvent[ prop ];
- }
-
- // Fix target property, if necessary
- if ( !event.target ) {
- // Fixes #1925 where srcElement might not be defined either
- event.target = event.srcElement || document;
- }
-
- // check if target is a textnode (safari)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
-
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && event.fromElement ) {
- event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
- }
-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
- var eventDocument = event.target.ownerDocument || document,
- doc = eventDocument.documentElement,
- body = eventDocument.body;
-
- event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
- event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
- }
-
- // Add which for key events
- if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
- event.which = event.charCode != null ? event.charCode : event.keyCode;
- }
-
- // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
- if ( !event.metaKey && event.ctrlKey ) {
- event.metaKey = event.ctrlKey;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && event.button !== undefined ) {
- event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
- }
-
- return event;
- },
-
- // Deprecated, use jQuery.guid instead
- guid: 1E8,
-
- // Deprecated, use jQuery.proxy instead
- proxy: jQuery.proxy,
-
- special: {
- ready: {
- // Make sure the ready event is setup
- setup: jQuery.bindReady,
- teardown: jQuery.noop
- },
-
- live: {
- add: function( handleObj ) {
- jQuery.event.add( this,
- liveConvert( handleObj.origType, handleObj.selector ),
- jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
- },
-
- remove: function( handleObj ) {
- jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
- }
- },
-
- beforeunload: {
- setup: function( data, namespaces, eventHandle ) {
- // We only want to do this special case on windows
- if ( jQuery.isWindow( this ) ) {
- this.onbeforeunload = eventHandle;
- }
- },
-
- teardown: function( namespaces, eventHandle ) {
- if ( this.onbeforeunload === eventHandle ) {
- this.onbeforeunload = null;
- }
- }
- }
- }
-};
-
-jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle, false );
- }
- } :
- function( elem, type, handle ) {
- if ( elem.detachEvent ) {
- elem.detachEvent( "on" + type, handle );
- }
- };
-
-jQuery.Event = function( src, props ) {
- // Allow instantiation without the 'new' keyword
- if ( !this.preventDefault ) {
- return new jQuery.Event( src, props );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
-
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
- src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
-
- // Event type
- } else {
- this.type = src;
- }
-
- // Put explicitly provided properties onto the event object
- if ( props ) {
- jQuery.extend( this, props );
- }
-
- // timeStamp is buggy for some events on Firefox(#3843)
- // So we won't rely on the native value
- this.timeStamp = jQuery.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
-
-function returnFalse() {
- return false;
-}
-function returnTrue() {
- return true;
-}
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
- preventDefault: function() {
- this.isDefaultPrevented = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
-
- // if preventDefault exists run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
-
- // otherwise set the returnValue property of the original event to false (IE)
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- this.isPropagationStopped = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
- // if stopPropagation exists run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
- // otherwise set the cancelBubble property of the original event to true (IE)
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- this.isImmediatePropagationStopped = returnTrue;
- this.stopPropagation();
- },
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse
-};
-
-// Checks if an event happened on an element within another element
-// Used in jQuery.event.special.mouseenter and mouseleave handlers
-var withinElement = function( event ) {
-
- // Check if mouse(over|out) are still within the same parent element
- var related = event.relatedTarget,
- inside = false,
- eventType = event.type;
-
- event.type = event.data;
-
- if ( related !== this ) {
-
- if ( related ) {
- inside = jQuery.contains( this, related );
- }
-
- if ( !inside ) {
-
- jQuery.event.handle.apply( this, arguments );
-
- event.type = eventType;
- }
- }
-},
-
-// In case of event delegation, we only need to rename the event.type,
-// liveHandler will take care of the rest.
-delegate = function( event ) {
- event.type = event.data;
- jQuery.event.handle.apply( this, arguments );
-};
-
-// Create mouseenter and mouseleave events
-jQuery.each({
- mouseenter: "mouseover",
- mouseleave: "mouseout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- setup: function( data ) {
- jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
- },
- teardown: function( data ) {
- jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
- }
- };
-});
-
-// submit delegation
-if ( !jQuery.support.submitBubbles ) {
-
- jQuery.event.special.submit = {
- setup: function( data, namespaces ) {
- if ( !jQuery.nodeName( this, "form" ) ) {
- jQuery.event.add(this, "click.specialSubmit", function( e ) {
- // Avoid triggering error on non-existent type attribute in IE VML (#7071)
- var elem = e.target,
- type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
-
- if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
- trigger( "submit", this, arguments );
- }
- });
-
- jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
- var elem = e.target,
- type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
-
- if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
- trigger( "submit", this, arguments );
- }
- });
-
- } else {
- return false;
- }
- },
-
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialSubmit" );
- }
- };
-
-}
-
-// change delegation, happens here so we have bind.
-if ( !jQuery.support.changeBubbles ) {
-
- var changeFilters,
-
- getVal = function( elem ) {
- var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
- val = elem.value;
-
- if ( type === "radio" || type === "checkbox" ) {
- val = elem.checked;
-
- } else if ( type === "select-multiple" ) {
- val = elem.selectedIndex > -1 ?
- jQuery.map( elem.options, function( elem ) {
- return elem.selected;
- }).join("-") :
- "";
-
- } else if ( jQuery.nodeName( elem, "select" ) ) {
- val = elem.selectedIndex;
- }
-
- return val;
- },
-
- testChange = function testChange( e ) {
- var elem = e.target, data, val;
-
- if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
- return;
- }
-
- data = jQuery._data( elem, "_change_data" );
- val = getVal(elem);
-
- // the current data will be also retrieved by beforeactivate
- if ( e.type !== "focusout" || elem.type !== "radio" ) {
- jQuery._data( elem, "_change_data", val );
- }
-
- if ( data === undefined || val === data ) {
- return;
- }
-
- if ( data != null || val ) {
- e.type = "change";
- e.liveFired = undefined;
- jQuery.event.trigger( e, arguments[1], elem );
- }
- };
-
- jQuery.event.special.change = {
- filters: {
- focusout: testChange,
-
- beforedeactivate: testChange,
-
- click: function( e ) {
- var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
-
- if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
- testChange.call( this, e );
- }
- },
-
- // Change has to be called before submit
- // Keydown will be called before keypress, which is used in submit-event delegation
- keydown: function( e ) {
- var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
-
- if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
- (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
- type === "select-multiple" ) {
- testChange.call( this, e );
- }
- },
-
- // Beforeactivate happens also before the previous element is blurred
- // with this event you can't trigger a change event, but you can store
- // information
- beforeactivate: function( e ) {
- var elem = e.target;
- jQuery._data( elem, "_change_data", getVal(elem) );
- }
- },
-
- setup: function( data, namespaces ) {
- if ( this.type === "file" ) {
- return false;
- }
-
- for ( var type in changeFilters ) {
- jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
- }
-
- return rformElems.test( this.nodeName );
- },
-
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialChange" );
-
- return rformElems.test( this.nodeName );
- }
- };
-
- changeFilters = jQuery.event.special.change.filters;
-
- // Handle when the input is .focus()'d
- changeFilters.focus = changeFilters.beforeactivate;
-}
-
-function trigger( type, elem, args ) {
- // Piggyback on a donor event to simulate a different one.
- // Fake originalEvent to avoid donor's stopPropagation, but if the
- // simulated event prevents default then we do the same on the donor.
- // Don't pass args or remember liveFired; they apply to the donor event.
- var event = jQuery.extend( {}, args[ 0 ] );
- event.type = type;
- event.originalEvent = {};
- event.liveFired = undefined;
- jQuery.event.handle.call( elem, event );
- if ( event.isDefaultPrevented() ) {
- args[ 0 ].preventDefault();
- }
-}
-
-// Create "bubbling" focus and blur events
-if ( !jQuery.support.focusinBubbles ) {
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
- // Attach a single capturing handler while someone wants focusin/focusout
- var attaches = 0;
-
- jQuery.event.special[ fix ] = {
- setup: function() {
- if ( attaches++ === 0 ) {
- document.addEventListener( orig, handler, true );
- }
- },
- teardown: function() {
- if ( --attaches === 0 ) {
- document.removeEventListener( orig, handler, true );
- }
- }
- };
-
- function handler( donor ) {
- // Donor event is always a native one; fix it and switch its type.
- // Let focusin/out handler cancel the donor focus/blur event.
- var e = jQuery.event.fix( donor );
- e.type = fix;
- e.originalEvent = {};
- jQuery.event.trigger( e, null, e.target );
- if ( e.isDefaultPrevented() ) {
- donor.preventDefault();
- }
- }
- });
-}
-
-jQuery.each(["bind", "one"], function( i, name ) {
- jQuery.fn[ name ] = function( type, data, fn ) {
- var handler;
-
- // Handle object literals
- if ( typeof type === "object" ) {
- for ( var key in type ) {
- this[ name ](key, data, type[key], fn);
- }
- return this;
- }
-
- if ( arguments.length === 2 || data === false ) {
- fn = data;
- data = undefined;
- }
-
- if ( name === "one" ) {
- handler = function( event ) {
- jQuery( this ).unbind( event, handler );
- return fn.apply( this, arguments );
- };
- handler.guid = fn.guid || jQuery.guid++;
- } else {
- handler = fn;
- }
-
- if ( type === "unload" && name !== "one" ) {
- this.one( type, data, fn );
-
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.add( this[i], type, handler, data );
- }
- }
-
- return this;
- };
-});
-
-jQuery.fn.extend({
- unbind: function( type, fn ) {
- // Handle object literals
- if ( typeof type === "object" && !type.preventDefault ) {
- for ( var key in type ) {
- this.unbind(key, type[key]);
- }
-
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.remove( this[i], type, fn );
- }
- }
-
- return this;
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.live( types, data, fn, selector );
- },
-
- undelegate: function( selector, types, fn ) {
- if ( arguments.length === 0 ) {
- return this.unbind( "live" );
-
- } else {
- return this.die( types, null, fn, selector );
- }
- },
-
- trigger: function( type, data ) {
- return this.each(function() {
- jQuery.event.trigger( type, data, this );
- });
- },
-
- triggerHandler: function( type, data ) {
- if ( this[0] ) {
- return jQuery.event.trigger( type, data, this[0], true );
- }
- },
-
- toggle: function( fn ) {
- // Save reference to arguments for access in closure
- var args = arguments,
- guid = fn.guid || jQuery.guid++,
- i = 0,
- toggler = function( event ) {
- // Figure out which function to execute
- var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
- jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
-
- // Make sure that clicks stop
- event.preventDefault();
-
- // and execute the function
- return args[ lastToggle ].apply( this, arguments ) || false;
- };
-
- // link all the functions, so any of them can unbind this click handler
- toggler.guid = guid;
- while ( i < args.length ) {
- args[ i++ ].guid = guid;
- }
-
- return this.click( toggler );
- },
-
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-});
-
-var liveMap = {
- focus: "focusin",
- blur: "focusout",
- mouseenter: "mouseover",
- mouseleave: "mouseout"
-};
-
-jQuery.each(["live", "die"], function( i, name ) {
- jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
- var type, i = 0, match, namespaces, preType,
- selector = origSelector || this.selector,
- context = origSelector ? this : jQuery( this.context );
-
- if ( typeof types === "object" && !types.preventDefault ) {
- for ( var key in types ) {
- context[ name ]( key, data, types[key], selector );
- }
-
- return this;
- }
-
- if ( name === "die" && !types &&
- origSelector && origSelector.charAt(0) === "." ) {
-
- context.unbind( origSelector );
-
- return this;
- }
-
- if ( data === false || jQuery.isFunction( data ) ) {
- fn = data || returnFalse;
- data = undefined;
- }
-
- types = (types || "").split(" ");
-
- while ( (type = types[ i++ ]) != null ) {
- match = rnamespaces.exec( type );
- namespaces = "";
-
- if ( match ) {
- namespaces = match[0];
- type = type.replace( rnamespaces, "" );
- }
-
- if ( type === "hover" ) {
- types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
- continue;
- }
-
- preType = type;
-
- if ( liveMap[ type ] ) {
- types.push( liveMap[ type ] + namespaces );
- type = type + namespaces;
-
- } else {
- type = (liveMap[ type ] || type) + namespaces;
- }
-
- if ( name === "live" ) {
- // bind live handler
- for ( var j = 0, l = context.length; j < l; j++ ) {
- jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
- { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
- }
-
- } else {
- // unbind live handler
- context.unbind( "live." + liveConvert( type, selector ), fn );
- }
- }
-
- return this;
- };
-});
-
-function liveHandler( event ) {
- var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
- elems = [],
- selectors = [],
- events = jQuery._data( this, "events" );
-
- // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
- if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
- return;
- }
-
- if ( event.namespace ) {
- namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
-
- event.liveFired = this;
-
- var live = events.live.slice(0);
-
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
-
- if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
- selectors.push( handleObj.selector );
-
- } else {
- live.splice( j--, 1 );
- }
- }
-
- match = jQuery( event.target ).closest( selectors, event.currentTarget );
-
- for ( i = 0, l = match.length; i < l; i++ ) {
- close = match[i];
-
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
-
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
- elem = close.elem;
- related = null;
-
- // Those two events require additional checking
- if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
- event.type = handleObj.preType;
- related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
-
- // Make sure not to accidentally match a child element with the same selector
- if ( related && jQuery.contains( elem, related ) ) {
- related = elem;
- }
- }
-
- if ( !related || related !== elem ) {
- elems.push({ elem: elem, handleObj: handleObj, level: close.level });
- }
- }
- }
- }
-
- for ( i = 0, l = elems.length; i < l; i++ ) {
- match = elems[i];
-
- if ( maxLevel && match.level > maxLevel ) {
- break;
- }
-
- event.currentTarget = match.elem;
- event.data = match.handleObj.data;
- event.handleObj = match.handleObj;
-
- ret = match.handleObj.origHandler.apply( match.elem, arguments );
-
- if ( ret === false || event.isPropagationStopped() ) {
- maxLevel = match.level;
-
- if ( ret === false ) {
- stop = false;
- }
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
-
- return stop;
-}
-
-function liveConvert( type, selector ) {
- return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
-}
-
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- if ( fn == null ) {
- fn = data;
- data = null;
- }
-
- return arguments.length > 0 ?
- this.bind( name, data, fn ) :
- this.trigger( name );
- };
-
- if ( jQuery.attrFn ) {
- jQuery.attrFn[ name ] = true;
- }
-});
-
-
-
-/*!
- * Sizzle CSS Selector Engine
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- * More information: http://sizzlejs.com/
- */
-(function(){
-
-var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
- done = 0,
- toString = Object.prototype.toString,
- hasDuplicate = false,
- baseHasDuplicate = true,
- rBackslash = /\\/g,
- rNonWord = /\W/;
-
-// Here we check if the JavaScript engine is using some sort of
-// optimization where it does not always call our comparision
-// function. If that is the case, discard the hasDuplicate value.
-// Thus far that includes Google Chrome.
-[0, 0].sort(function() {
- baseHasDuplicate = false;
- return 0;
-});
-
-var Sizzle = function( selector, context, results, seed ) {
- results = results || [];
- context = context || document;
-
- var origContext = context;
-
- if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
- return [];
- }
-
- if ( !selector || typeof selector !== "string" ) {
- return results;
- }
-
- var m, set, checkSet, extra, ret, cur, pop, i,
- prune = true,
- contextXML = Sizzle.isXML( context ),
- parts = [],
- soFar = selector;
-
- // Reset the position of the chunker regexp (start from head)
- do {
- chunker.exec( "" );
- m = chunker.exec( soFar );
-
- if ( m ) {
- soFar = m[3];
-
- parts.push( m[1] );
-
- if ( m[2] ) {
- extra = m[3];
- break;
- }
- }
- } while ( m );
-
- if ( parts.length > 1 && origPOS.exec( selector ) ) {
-
- if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
- set = posProcess( parts[0] + parts[1], context );
-
- } else {
- set = Expr.relative[ parts[0] ] ?
- [ context ] :
- Sizzle( parts.shift(), context );
-
- while ( parts.length ) {
- selector = parts.shift();
-
- if ( Expr.relative[ selector ] ) {
- selector += parts.shift();
- }
-
- set = posProcess( selector, set );
- }
- }
-
- } else {
- // Take a shortcut and set the context if the root selector is an ID
- // (but not if it'll be faster if the inner selector is an ID)
- if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
- Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
-
- ret = Sizzle.find( parts.shift(), context, contextXML );
- context = ret.expr ?
- Sizzle.filter( ret.expr, ret.set )[0] :
- ret.set[0];
- }
-
- if ( context ) {
- ret = seed ?
- { expr: parts.pop(), set: makeArray(seed) } :
- Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
-
- set = ret.expr ?
- Sizzle.filter( ret.expr, ret.set ) :
- ret.set;
-
- if ( parts.length > 0 ) {
- checkSet = makeArray( set );
-
- } else {
- prune = false;
- }
-
- while ( parts.length ) {
- cur = parts.pop();
- pop = cur;
-
- if ( !Expr.relative[ cur ] ) {
- cur = "";
- } else {
- pop = parts.pop();
- }
-
- if ( pop == null ) {
- pop = context;
- }
-
- Expr.relative[ cur ]( checkSet, pop, contextXML );
- }
-
- } else {
- checkSet = parts = [];
- }
- }
-
- if ( !checkSet ) {
- checkSet = set;
- }
-
- if ( !checkSet ) {
- Sizzle.error( cur || selector );
- }
-
- if ( toString.call(checkSet) === "[object Array]" ) {
- if ( !prune ) {
- results.push.apply( results, checkSet );
-
- } else if ( context && context.nodeType === 1 ) {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
- results.push( set[i] );
- }
- }
-
- } else {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
- results.push( set[i] );
- }
- }
- }
-
- } else {
- makeArray( checkSet, results );
- }
-
- if ( extra ) {
- Sizzle( extra, origContext, results, seed );
- Sizzle.uniqueSort( results );
- }
-
- return results;
-};
-
-Sizzle.uniqueSort = function( results ) {
- if ( sortOrder ) {
- hasDuplicate = baseHasDuplicate;
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- for ( var i = 1; i < results.length; i++ ) {
- if ( results[i] === results[ i - 1 ] ) {
- results.splice( i--, 1 );
- }
- }
- }
- }
-
- return results;
-};
-
-Sizzle.matches = function( expr, set ) {
- return Sizzle( expr, null, null, set );
-};
-
-Sizzle.matchesSelector = function( node, expr ) {
- return Sizzle( expr, null, null, [node] ).length > 0;
-};
-
-Sizzle.find = function( expr, context, isXML ) {
- var set;
-
- if ( !expr ) {
- return [];
- }
-
- for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
- var match,
- type = Expr.order[i];
-
- if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
- var left = match[1];
- match.splice( 1, 1 );
-
- if ( left.substr( left.length - 1 ) !== "\\" ) {
- match[1] = (match[1] || "").replace( rBackslash, "" );
- set = Expr.find[ type ]( match, context, isXML );
-
- if ( set != null ) {
- expr = expr.replace( Expr.match[ type ], "" );
- break;
- }
- }
- }
- }
-
- if ( !set ) {
- set = typeof context.getElementsByTagName !== "undefined" ?
- context.getElementsByTagName( "*" ) :
- [];
- }
-
- return { set: set, expr: expr };
-};
-
-Sizzle.filter = function( expr, set, inplace, not ) {
- var match, anyFound,
- old = expr,
- result = [],
- curLoop = set,
- isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
-
- while ( expr && set.length ) {
- for ( var type in Expr.filter ) {
- if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
- var found, item,
- filter = Expr.filter[ type ],
- left = match[1];
-
- anyFound = false;
-
- match.splice(1,1);
-
- if ( left.substr( left.length - 1 ) === "\\" ) {
- continue;
- }
-
- if ( curLoop === result ) {
- result = [];
- }
-
- if ( Expr.preFilter[ type ] ) {
- match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
-
- if ( !match ) {
- anyFound = found = true;
-
- } else if ( match === true ) {
- continue;
- }
- }
-
- if ( match ) {
- for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
- if ( item ) {
- found = filter( item, match, i, curLoop );
- var pass = not ^ !!found;
-
- if ( inplace && found != null ) {
- if ( pass ) {
- anyFound = true;
-
- } else {
- curLoop[i] = false;
- }
-
- } else if ( pass ) {
- result.push( item );
- anyFound = true;
- }
- }
- }
- }
-
- if ( found !== undefined ) {
- if ( !inplace ) {
- curLoop = result;
- }
-
- expr = expr.replace( Expr.match[ type ], "" );
-
- if ( !anyFound ) {
- return [];
- }
-
- break;
- }
- }
- }
-
- // Improper expression
- if ( expr === old ) {
- if ( anyFound == null ) {
- Sizzle.error( expr );
-
- } else {
- break;
- }
- }
-
- old = expr;
- }
-
- return curLoop;
-};
-
-Sizzle.error = function( msg ) {
- throw "Syntax error, unrecognized expression: " + msg;
-};
-
-var Expr = Sizzle.selectors = {
- order: [ "ID", "NAME", "TAG" ],
-
- match: {
- ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
- ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
- TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
- CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
- POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
- PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
- },
-
- leftMatch: {},
-
- attrMap: {
- "class": "className",
- "for": "htmlFor"
- },
-
- attrHandle: {
- href: function( elem ) {
- return elem.getAttribute( "href" );
- },
- type: function( elem ) {
- return elem.getAttribute( "type" );
- }
- },
-
- relative: {
- "+": function(checkSet, part){
- var isPartStr = typeof part === "string",
- isTag = isPartStr && !rNonWord.test( part ),
- isPartStrNotTag = isPartStr && !isTag;
-
- if ( isTag ) {
- part = part.toLowerCase();
- }
-
- for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
- if ( (elem = checkSet[i]) ) {
- while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
-
- checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
- elem || false :
- elem === part;
- }
- }
-
- if ( isPartStrNotTag ) {
- Sizzle.filter( part, checkSet, true );
- }
- },
-
- ">": function( checkSet, part ) {
- var elem,
- isPartStr = typeof part === "string",
- i = 0,
- l = checkSet.length;
-
- if ( isPartStr && !rNonWord.test( part ) ) {
- part = part.toLowerCase();
-
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
-
- if ( elem ) {
- var parent = elem.parentNode;
- checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
- }
- }
-
- } else {
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
-
- if ( elem ) {
- checkSet[i] = isPartStr ?
- elem.parentNode :
- elem.parentNode === part;
- }
- }
-
- if ( isPartStr ) {
- Sizzle.filter( part, checkSet, true );
- }
- }
- },
-
- "": function(checkSet, part, isXML){
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
-
- if ( typeof part === "string" && !rNonWord.test( part ) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
-
- checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
- },
-
- "~": function( checkSet, part, isXML ) {
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
-
- if ( typeof part === "string" && !rNonWord.test( part ) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
-
- checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
- }
- },
-
- find: {
- ID: function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- return m && m.parentNode ? [m] : [];
- }
- },
-
- NAME: function( match, context ) {
- if ( typeof context.getElementsByName !== "undefined" ) {
- var ret = [],
- results = context.getElementsByName( match[1] );
-
- for ( var i = 0, l = results.length; i < l; i++ ) {
- if ( results[i].getAttribute("name") === match[1] ) {
- ret.push( results[i] );
- }
- }
-
- return ret.length === 0 ? null : ret;
- }
- },
-
- TAG: function( match, context ) {
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- return context.getElementsByTagName( match[1] );
- }
- }
- },
- preFilter: {
- CLASS: function( match, curLoop, inplace, result, not, isXML ) {
- match = " " + match[1].replace( rBackslash, "" ) + " ";
-
- if ( isXML ) {
- return match;
- }
-
- for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
- if ( elem ) {
- if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
- if ( !inplace ) {
- result.push( elem );
- }
-
- } else if ( inplace ) {
- curLoop[i] = false;
- }
- }
- }
-
- return false;
- },
-
- ID: function( match ) {
- return match[1].replace( rBackslash, "" );
- },
-
- TAG: function( match, curLoop ) {
- return match[1].replace( rBackslash, "" ).toLowerCase();
- },
-
- CHILD: function( match ) {
- if ( match[1] === "nth" ) {
- if ( !match[2] ) {
- Sizzle.error( match[0] );
- }
-
- match[2] = match[2].replace(/^\+|\s*/g, '');
-
- // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
- var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
- match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
- !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
-
- // calculate the numbers (first)n+(last) including if they are negative
- match[2] = (test[1] + (test[2] || 1)) - 0;
- match[3] = test[3] - 0;
- }
- else if ( match[2] ) {
- Sizzle.error( match[0] );
- }
-
- // TODO: Move to normal caching system
- match[0] = done++;
-
- return match;
- },
-
- ATTR: function( match, curLoop, inplace, result, not, isXML ) {
- var name = match[1] = match[1].replace( rBackslash, "" );
-
- if ( !isXML && Expr.attrMap[name] ) {
- match[1] = Expr.attrMap[name];
- }
-
- // Handle if an un-quoted value was used
- match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
-
- if ( match[2] === "~=" ) {
- match[4] = " " + match[4] + " ";
- }
-
- return match;
- },
-
- PSEUDO: function( match, curLoop, inplace, result, not ) {
- if ( match[1] === "not" ) {
- // If we're dealing with a complex expression, or a simple one
- if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
- match[3] = Sizzle(match[3], null, null, curLoop);
-
- } else {
- var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
-
- if ( !inplace ) {
- result.push.apply( result, ret );
- }
-
- return false;
- }
-
- } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
- return true;
- }
-
- return match;
- },
-
- POS: function( match ) {
- match.unshift( true );
-
- return match;
- }
- },
-
- filters: {
- enabled: function( elem ) {
- return elem.disabled === false && elem.type !== "hidden";
- },
-
- disabled: function( elem ) {
- return elem.disabled === true;
- },
-
- checked: function( elem ) {
- return elem.checked === true;
- },
-
- selected: function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- if ( elem.parentNode ) {
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- parent: function( elem ) {
- return !!elem.firstChild;
- },
-
- empty: function( elem ) {
- return !elem.firstChild;
- },
-
- has: function( elem, i, match ) {
- return !!Sizzle( match[3], elem ).length;
- },
-
- header: function( elem ) {
- return (/h\d/i).test( elem.nodeName );
- },
-
- text: function( elem ) {
- var attr = elem.getAttribute( "type" ), type = elem.type;
- // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
- // use getAttribute instead to test this case
- return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
- },
-
- radio: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
- },
-
- checkbox: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
- },
-
- file: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
- },
-
- password: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
- },
-
- submit: function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return (name === "input" || name === "button") && "submit" === elem.type;
- },
-
- image: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
- },
-
- reset: function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return (name === "input" || name === "button") && "reset" === elem.type;
- },
-
- button: function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && "button" === elem.type || name === "button";
- },
-
- input: function( elem ) {
- return (/input|select|textarea|button/i).test( elem.nodeName );
- },
-
- focus: function( elem ) {
- return elem === elem.ownerDocument.activeElement;
- }
- },
- setFilters: {
- first: function( elem, i ) {
- return i === 0;
- },
-
- last: function( elem, i, match, array ) {
- return i === array.length - 1;
- },
-
- even: function( elem, i ) {
- return i % 2 === 0;
- },
-
- odd: function( elem, i ) {
- return i % 2 === 1;
- },
-
- lt: function( elem, i, match ) {
- return i < match[3] - 0;
- },
-
- gt: function( elem, i, match ) {
- return i > match[3] - 0;
- },
-
- nth: function( elem, i, match ) {
- return match[3] - 0 === i;
- },
-
- eq: function( elem, i, match ) {
- return match[3] - 0 === i;
- }
- },
- filter: {
- PSEUDO: function( elem, match, i, array ) {
- var name = match[1],
- filter = Expr.filters[ name ];
-
- if ( filter ) {
- return filter( elem, i, match, array );
-
- } else if ( name === "contains" ) {
- return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
-
- } else if ( name === "not" ) {
- var not = match[3];
-
- for ( var j = 0, l = not.length; j < l; j++ ) {
- if ( not[j] === elem ) {
- return false;
- }
- }
-
- return true;
-
- } else {
- Sizzle.error( name );
- }
- },
-
- CHILD: function( elem, match ) {
- var type = match[1],
- node = elem;
-
- switch ( type ) {
- case "only":
- case "first":
- while ( (node = node.previousSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- if ( type === "first" ) {
- return true;
- }
-
- node = elem;
-
- case "last":
- while ( (node = node.nextSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- return true;
-
- case "nth":
- var first = match[2],
- last = match[3];
-
- if ( first === 1 && last === 0 ) {
- return true;
- }
-
- var doneName = match[0],
- parent = elem.parentNode;
-
- if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
- var count = 0;
-
- for ( node = parent.firstChild; node; node = node.nextSibling ) {
- if ( node.nodeType === 1 ) {
- node.nodeIndex = ++count;
- }
- }
-
- parent.sizcache = doneName;
- }
-
- var diff = elem.nodeIndex - last;
-
- if ( first === 0 ) {
- return diff === 0;
-
- } else {
- return ( diff % first === 0 && diff / first >= 0 );
- }
- }
- },
-
- ID: function( elem, match ) {
- return elem.nodeType === 1 && elem.getAttribute("id") === match;
- },
-
- TAG: function( elem, match ) {
- return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
- },
-
- CLASS: function( elem, match ) {
- return (" " + (elem.className || elem.getAttribute("class")) + " ")
- .indexOf( match ) > -1;
- },
-
- ATTR: function( elem, match ) {
- var name = match[1],
- result = Expr.attrHandle[ name ] ?
- Expr.attrHandle[ name ]( elem ) :
- elem[ name ] != null ?
- elem[ name ] :
- elem.getAttribute( name ),
- value = result + "",
- type = match[2],
- check = match[4];
-
- return result == null ?
- type === "!=" :
- type === "=" ?
- value === check :
- type === "*=" ?
- value.indexOf(check) >= 0 :
- type === "~=" ?
- (" " + value + " ").indexOf(check) >= 0 :
- !check ?
- value && result !== false :
- type === "!=" ?
- value !== check :
- type === "^=" ?
- value.indexOf(check) === 0 :
- type === "$=" ?
- value.substr(value.length - check.length) === check :
- type === "|=" ?
- value === check || value.substr(0, check.length + 1) === check + "-" :
- false;
- },
-
- POS: function( elem, match, i, array ) {
- var name = match[2],
- filter = Expr.setFilters[ name ];
-
- if ( filter ) {
- return filter( elem, i, match, array );
- }
- }
- }
-};
-
-var origPOS = Expr.match.POS,
- fescape = function(all, num){
- return "\\" + (num - 0 + 1);
- };
-
-for ( var type in Expr.match ) {
- Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
- Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
-}
-
-var makeArray = function( array, results ) {
- array = Array.prototype.slice.call( array, 0 );
-
- if ( results ) {
- results.push.apply( results, array );
- return results;
- }
-
- return array;
-};
-
-// Perform a simple check to determine if the browser is capable of
-// converting a NodeList to an array using builtin methods.
-// Also verifies that the returned array holds DOM nodes
-// (which is not the case in the Blackberry browser)
-try {
- Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
-
-// Provide a fallback method if it does not work
-} catch( e ) {
- makeArray = function( array, results ) {
- var i = 0,
- ret = results || [];
-
- if ( toString.call(array) === "[object Array]" ) {
- Array.prototype.push.apply( ret, array );
-
- } else {
- if ( typeof array.length === "number" ) {
- for ( var l = array.length; i < l; i++ ) {
- ret.push( array[i] );
- }
-
- } else {
- for ( ; array[i]; i++ ) {
- ret.push( array[i] );
- }
- }
- }
-
- return ret;
- };
-}
-
-var sortOrder, siblingCheck;
-
-if ( document.documentElement.compareDocumentPosition ) {
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
- return a.compareDocumentPosition ? -1 : 1;
- }
-
- return a.compareDocumentPosition(b) & 4 ? -1 : 1;
- };
-
-} else {
- sortOrder = function( a, b ) {
- // The nodes are identical, we can exit early
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
-
- // Fallback to using sourceIndex (in IE) if it's available on both nodes
- } else if ( a.sourceIndex && b.sourceIndex ) {
- return a.sourceIndex - b.sourceIndex;
- }
-
- var al, bl,
- ap = [],
- bp = [],
- aup = a.parentNode,
- bup = b.parentNode,
- cur = aup;
-
- // If the nodes are siblings (or identical) we can do a quick check
- if ( aup === bup ) {
- return siblingCheck( a, b );
-
- // If no parents were found then the nodes are disconnected
- } else if ( !aup ) {
- return -1;
-
- } else if ( !bup ) {
- return 1;
- }
-
- // Otherwise they're somewhere else in the tree so we need
- // to build up a full list of the parentNodes for comparison
- while ( cur ) {
- ap.unshift( cur );
- cur = cur.parentNode;
- }
-
- cur = bup;
-
- while ( cur ) {
- bp.unshift( cur );
- cur = cur.parentNode;
- }
-
- al = ap.length;
- bl = bp.length;
-
- // Start walking down the tree looking for a discrepancy
- for ( var i = 0; i < al && i < bl; i++ ) {
- if ( ap[i] !== bp[i] ) {
- return siblingCheck( ap[i], bp[i] );
- }
- }
-
- // We ended someplace up the tree so do a sibling check
- return i === al ?
- siblingCheck( a, bp[i], -1 ) :
- siblingCheck( ap[i], b, 1 );
- };
-
- siblingCheck = function( a, b, ret ) {
- if ( a === b ) {
- return ret;
- }
-
- var cur = a.nextSibling;
-
- while ( cur ) {
- if ( cur === b ) {
- return -1;
- }
-
- cur = cur.nextSibling;
- }
-
- return 1;
- };
-}
-
-// Utility function for retreiving the text value of an array of DOM nodes
-Sizzle.getText = function( elems ) {
- var ret = "", elem;
-
- for ( var i = 0; elems[i]; i++ ) {
- elem = elems[i];
-
- // Get the text from text nodes and CDATA nodes
- if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
- ret += elem.nodeValue;
-
- // Traverse everything else, except comment nodes
- } else if ( elem.nodeType !== 8 ) {
- ret += Sizzle.getText( elem.childNodes );
- }
- }
-
- return ret;
-};
-
-// Check to see if the browser returns elements by name when
-// querying by getElementById (and provide a workaround)
-(function(){
- // We're going to inject a fake input element with a specified name
- var form = document.createElement("div"),
- id = "script" + (new Date()).getTime(),
- root = document.documentElement;
-
- form.innerHTML = " ";
-
- // Inject it into the root element, check its status, and remove it quickly
- root.insertBefore( form, root.firstChild );
-
- // The workaround has to do additional checks after a getElementById
- // Which slows things down for other browsers (hence the branching)
- if ( document.getElementById( id ) ) {
- Expr.find.ID = function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
-
- return m ?
- m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
- [m] :
- undefined :
- [];
- }
- };
-
- Expr.filter.ID = function( elem, match ) {
- var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
-
- return elem.nodeType === 1 && node && node.nodeValue === match;
- };
- }
-
- root.removeChild( form );
-
- // release memory in IE
- root = form = null;
-})();
-
-(function(){
- // Check to see if the browser returns only elements
- // when doing getElementsByTagName("*")
-
- // Create a fake element
- var div = document.createElement("div");
- div.appendChild( document.createComment("") );
-
- // Make sure no comments are found
- if ( div.getElementsByTagName("*").length > 0 ) {
- Expr.find.TAG = function( match, context ) {
- var results = context.getElementsByTagName( match[1] );
-
- // Filter out possible comments
- if ( match[1] === "*" ) {
- var tmp = [];
-
- for ( var i = 0; results[i]; i++ ) {
- if ( results[i].nodeType === 1 ) {
- tmp.push( results[i] );
- }
- }
-
- results = tmp;
- }
-
- return results;
- };
- }
-
- // Check to see if an attribute returns normalized href attributes
- div.innerHTML = " ";
-
- if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
- div.firstChild.getAttribute("href") !== "#" ) {
-
- Expr.attrHandle.href = function( elem ) {
- return elem.getAttribute( "href", 2 );
- };
- }
-
- // release memory in IE
- div = null;
-})();
-
-if ( document.querySelectorAll ) {
- (function(){
- var oldSizzle = Sizzle,
- div = document.createElement("div"),
- id = "__sizzle__";
-
- div.innerHTML = "
";
-
- // Safari can't handle uppercase or unicode characters when
- // in quirks mode.
- if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
- return;
- }
-
- Sizzle = function( query, context, extra, seed ) {
- context = context || document;
-
- // Only use querySelectorAll on non-XML documents
- // (ID selectors don't work in non-HTML documents)
- if ( !seed && !Sizzle.isXML(context) ) {
- // See if we find a selector to speed up
- var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
-
- if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
- // Speed-up: Sizzle("TAG")
- if ( match[1] ) {
- return makeArray( context.getElementsByTagName( query ), extra );
-
- // Speed-up: Sizzle(".CLASS")
- } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
- return makeArray( context.getElementsByClassName( match[2] ), extra );
- }
- }
-
- if ( context.nodeType === 9 ) {
- // Speed-up: Sizzle("body")
- // The body element only exists once, optimize finding it
- if ( query === "body" && context.body ) {
- return makeArray( [ context.body ], extra );
-
- // Speed-up: Sizzle("#ID")
- } else if ( match && match[3] ) {
- var elem = context.getElementById( match[3] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id === match[3] ) {
- return makeArray( [ elem ], extra );
- }
-
- } else {
- return makeArray( [], extra );
- }
- }
-
- try {
- return makeArray( context.querySelectorAll(query), extra );
- } catch(qsaError) {}
-
- // qSA works strangely on Element-rooted queries
- // We can work around this by specifying an extra ID on the root
- // and working up from there (Thanks to Andrew Dupont for the technique)
- // IE 8 doesn't work on object elements
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var oldContext = context,
- old = context.getAttribute( "id" ),
- nid = old || id,
- hasParent = context.parentNode,
- relativeHierarchySelector = /^\s*[+~]/.test( query );
-
- if ( !old ) {
- context.setAttribute( "id", nid );
- } else {
- nid = nid.replace( /'/g, "\\$&" );
- }
- if ( relativeHierarchySelector && hasParent ) {
- context = context.parentNode;
- }
-
- try {
- if ( !relativeHierarchySelector || hasParent ) {
- return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
- }
-
- } catch(pseudoError) {
- } finally {
- if ( !old ) {
- oldContext.removeAttribute( "id" );
- }
- }
- }
- }
-
- return oldSizzle(query, context, extra, seed);
- };
-
- for ( var prop in oldSizzle ) {
- Sizzle[ prop ] = oldSizzle[ prop ];
- }
-
- // release memory in IE
- div = null;
- })();
-}
-
-(function(){
- var html = document.documentElement,
- matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
-
- if ( matches ) {
- // Check to see if it's possible to do matchesSelector
- // on a disconnected node (IE 9 fails this)
- var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
- pseudoWorks = false;
-
- try {
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( document.documentElement, "[test!='']:sizzle" );
-
- } catch( pseudoError ) {
- pseudoWorks = true;
- }
-
- Sizzle.matchesSelector = function( node, expr ) {
- // Make sure that attribute selectors are quoted
- expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
-
- if ( !Sizzle.isXML( node ) ) {
- try {
- if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
- var ret = matches.call( node, expr );
-
- // IE 9's matchesSelector returns false on disconnected nodes
- if ( ret || !disconnectedMatch ||
- // As well, disconnected nodes are said to be in a document
- // fragment in IE 9, so check for that
- node.document && node.document.nodeType !== 11 ) {
- return ret;
- }
- }
- } catch(e) {}
- }
-
- return Sizzle(expr, null, null, [node]).length > 0;
- };
- }
-})();
-
-(function(){
- var div = document.createElement("div");
-
- div.innerHTML = "
";
-
- // Opera can't find a second classname (in 9.6)
- // Also, make sure that getElementsByClassName actually exists
- if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
- return;
- }
-
- // Safari caches class attributes, doesn't catch changes (in 3.2)
- div.lastChild.className = "e";
-
- if ( div.getElementsByClassName("e").length === 1 ) {
- return;
- }
-
- Expr.order.splice(1, 0, "CLASS");
- Expr.find.CLASS = function( match, context, isXML ) {
- if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
- return context.getElementsByClassName(match[1]);
- }
- };
-
- // release memory in IE
- div = null;
-})();
-
-function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
-
- if ( elem ) {
- var match = false;
-
- elem = elem[dir];
-
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
-
- if ( elem.nodeType === 1 && !isXML ){
- elem.sizcache = doneName;
- elem.sizset = i;
- }
-
- if ( elem.nodeName.toLowerCase() === cur ) {
- match = elem;
- break;
- }
-
- elem = elem[dir];
- }
-
- checkSet[i] = match;
- }
- }
-}
-
-function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
-
- if ( elem ) {
- var match = false;
-
- elem = elem[dir];
-
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
-
- if ( elem.nodeType === 1 ) {
- if ( !isXML ) {
- elem.sizcache = doneName;
- elem.sizset = i;
- }
-
- if ( typeof cur !== "string" ) {
- if ( elem === cur ) {
- match = true;
- break;
- }
-
- } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
- match = elem;
- break;
- }
- }
-
- elem = elem[dir];
- }
-
- checkSet[i] = match;
- }
- }
-}
-
-if ( document.documentElement.contains ) {
- Sizzle.contains = function( a, b ) {
- return a !== b && (a.contains ? a.contains(b) : true);
- };
-
-} else if ( document.documentElement.compareDocumentPosition ) {
- Sizzle.contains = function( a, b ) {
- return !!(a.compareDocumentPosition(b) & 16);
- };
-
-} else {
- Sizzle.contains = function() {
- return false;
- };
-}
-
-Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
-
- return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-var posProcess = function( selector, context ) {
- var match,
- tmpSet = [],
- later = "",
- root = context.nodeType ? [context] : context;
-
- // Position selectors must be done after the filter
- // And so must :not(positional) so we move all PSEUDOs to the end
- while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
- later += match[0];
- selector = selector.replace( Expr.match.PSEUDO, "" );
- }
-
- selector = Expr.relative[selector] ? selector + "*" : selector;
-
- for ( var i = 0, l = root.length; i < l; i++ ) {
- Sizzle( selector, root[i], tmpSet );
- }
-
- return Sizzle.filter( later, tmpSet );
-};
-
-// EXPOSE
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[":"] = jQuery.expr.filters;
-jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-
-
-})();
-
-
-var runtil = /Until$/,
- rparentsprev = /^(?:parents|prevUntil|prevAll)/,
- // Note: This RegExp should be improved, or likely pulled from Sizzle
- rmultiselector = /,/,
- isSimple = /^.[^:#\[\.,]*$/,
- slice = Array.prototype.slice,
- POS = jQuery.expr.match.POS,
- // methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.fn.extend({
- find: function( selector ) {
- var self = this,
- i, l;
-
- if ( typeof selector !== "string" ) {
- return jQuery( selector ).filter(function() {
- for ( i = 0, l = self.length; i < l; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- });
- }
-
- var ret = this.pushStack( "", "find", selector ),
- length, n, r;
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- length = ret.length;
- jQuery.find( selector, this[i], ret );
-
- if ( i > 0 ) {
- // Make sure that the results are unique
- for ( n = length; n < ret.length; n++ ) {
- for ( r = 0; r < length; r++ ) {
- if ( ret[r] === ret[n] ) {
- ret.splice(n--, 1);
- break;
- }
- }
- }
- }
- }
-
- return ret;
- },
-
- has: function( target ) {
- var targets = jQuery( target );
- return this.filter(function() {
- for ( var i = 0, l = targets.length; i < l; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
- return true;
- }
- }
- });
- },
-
- not: function( selector ) {
- return this.pushStack( winnow(this, selector, false), "not", selector);
- },
-
- filter: function( selector ) {
- return this.pushStack( winnow(this, selector, true), "filter", selector );
- },
-
- is: function( selector ) {
- return !!selector && ( typeof selector === "string" ?
- jQuery.filter( selector, this ).length > 0 :
- this.filter( selector ).length > 0 );
- },
-
- closest: function( selectors, context ) {
- var ret = [], i, l, cur = this[0];
-
- // Array
- if ( jQuery.isArray( selectors ) ) {
- var match, selector,
- matches = {},
- level = 1;
-
- if ( cur && selectors.length ) {
- for ( i = 0, l = selectors.length; i < l; i++ ) {
- selector = selectors[i];
-
- if ( !matches[ selector ] ) {
- matches[ selector ] = POS.test( selector ) ?
- jQuery( selector, context || this.context ) :
- selector;
- }
- }
-
- while ( cur && cur.ownerDocument && cur !== context ) {
- for ( selector in matches ) {
- match = matches[ selector ];
-
- if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
- ret.push({ selector: selector, elem: cur, level: level });
- }
- }
-
- cur = cur.parentNode;
- level++;
- }
- }
-
- return ret;
- }
-
- // String
- var pos = POS.test( selectors ) || typeof selectors !== "string" ?
- jQuery( selectors, context || this.context ) :
- 0;
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- cur = this[i];
-
- while ( cur ) {
- if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
- ret.push( cur );
- break;
-
- } else {
- cur = cur.parentNode;
- if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
- break;
- }
- }
- }
- }
-
- ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
-
- return this.pushStack( ret, "closest", selectors );
- },
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
- }
-
- // index in selector
- if ( typeof elem === "string" ) {
- return jQuery.inArray( this[0], jQuery( elem ) );
- }
-
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
-
- add: function( selector, context ) {
- var set = typeof selector === "string" ?
- jQuery( selector, context ) :
- jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
- all = jQuery.merge( this.get(), set );
-
- return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
- all :
- jQuery.unique( all ) );
- },
-
- andSelf: function() {
- return this.add( this.prevObject );
- }
-});
-
-// A painfully simple check to see if an element is disconnected
-// from a document (should be improved, where feasible).
-function isDisconnected( node ) {
- return !node || !node.parentNode || node.parentNode.nodeType === 11;
-}
-
-jQuery.each({
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return jQuery.dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return jQuery.nth( elem, 2, "nextSibling" );
- },
- prev: function( elem ) {
- return jQuery.nth( elem, 2, "previousSibling" );
- },
- nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return jQuery.sibling( elem.parentNode.firstChild, elem );
- },
- children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.makeArray( elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until ),
- // The variable 'args' was introduced in
- // https://github.com/jquery/jquery/commit/52a0238
- // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
- // http://code.google.com/p/v8/issues/detail?id=1050
- args = slice.call(arguments);
-
- if ( !runtil.test( name ) ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
-
- ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
-
- if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
-
- return this.pushStack( ret, name, args.join(",") );
- };
-});
-
-jQuery.extend({
- filter: function( expr, elems, not ) {
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- return elems.length === 1 ?
- jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
- jQuery.find.matches(expr, elems);
- },
-
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
-
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
-
- nth: function( cur, result, dir, elem ) {
- result = result || 1;
- var num = 0;
-
- for ( ; cur; cur = cur[dir] ) {
- if ( cur.nodeType === 1 && ++num === result ) {
- break;
- }
- }
-
- return cur;
- },
-
- sibling: function( n, elem ) {
- var r = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
-
- return r;
- }
-});
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, keep ) {
-
- // Can't pass null or undefined to indexOf in Firefox 4
- // Set to 0 to skip string check
- qualifier = qualifier || 0;
-
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep(elements, function( elem, i ) {
- var retVal = !!qualifier.call( elem, i, elem );
- return retVal === keep;
- });
-
- } else if ( qualifier.nodeType ) {
- return jQuery.grep(elements, function( elem, i ) {
- return (elem === qualifier) === keep;
- });
-
- } else if ( typeof qualifier === "string" ) {
- var filtered = jQuery.grep(elements, function( elem ) {
- return elem.nodeType === 1;
- });
-
- if ( isSimple.test( qualifier ) ) {
- return jQuery.filter(qualifier, filtered, !keep);
- } else {
- qualifier = jQuery.filter( qualifier, filtered );
- }
- }
-
- return jQuery.grep(elements, function( elem, i ) {
- return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
- });
-}
-
-
-
-
-var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
- rleadingWhitespace = /^\s+/,
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
- rtagName = /<([\w:]+)/,
- rtbody = /", "" ],
- legend: [ 1, "", " " ],
- thead: [ 1, "" ],
- tr: [ 2, "" ],
- td: [ 3, "" ],
- col: [ 2, "" ],
- area: [ 1, "", " " ],
- _default: [ 0, "", "" ]
- };
-
-wrapMap.optgroup = wrapMap.option;
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-// IE can't serialize and
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-test markup, will be hidden
-
-