polymer-platinum-rails 1.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +39 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/platinum-elements/LICENSE +202 -0
  5. data/app/assets/components/platinum-elements/README.md +2 -0
  6. data/app/assets/components/platinum-elements/bower.json +19 -0
  7. data/app/assets/components/platinum-push-messaging/README.md +4 -0
  8. data/app/assets/components/platinum-push-messaging/bower.json +37 -0
  9. data/app/assets/components/platinum-push-messaging/demo/index.html +130 -0
  10. data/app/assets/components/platinum-push-messaging/demo/manifest.json +4 -0
  11. data/app/assets/components/platinum-push-messaging/index.html +22 -0
  12. data/app/assets/components/platinum-push-messaging/platinum-push-messaging.html +427 -0
  13. data/app/assets/components/platinum-push-messaging/service-worker.js +151 -0
  14. data/app/assets/components/platinum-sw/README.md +43 -0
  15. data/app/assets/components/platinum-sw/bootstrap/sw-toolbox-setup.js +38 -0
  16. data/app/assets/components/platinum-sw/bower.json +37 -0
  17. data/app/assets/components/platinum-sw/demo/index.html +91 -0
  18. data/app/assets/components/platinum-sw/demo/sw-import.js +1 -0
  19. data/app/assets/components/platinum-sw/index.html +22 -0
  20. data/app/assets/components/platinum-sw/platinum-sw-cache.html +116 -0
  21. data/app/assets/components/platinum-sw/platinum-sw-elements.html +14 -0
  22. data/app/assets/components/platinum-sw/platinum-sw-fetch.html +130 -0
  23. data/app/assets/components/platinum-sw/platinum-sw-import-script.html +57 -0
  24. data/app/assets/components/platinum-sw/platinum-sw-register.html +342 -0
  25. data/app/assets/components/platinum-sw/service-worker.js +52 -0
  26. data/app/assets/components/polymer/LICENSE.txt +27 -0
  27. data/app/assets/components/polymer/bower.json +26 -0
  28. data/app/assets/components/polymer/build.log +27 -0
  29. data/app/assets/components/polymer/polymer-micro.html +523 -0
  30. data/app/assets/components/polymer/polymer-mini.html +1368 -0
  31. data/app/assets/components/polymer/polymer.html +3768 -0
  32. data/app/assets/components/sw-toolbox/CONTRIBUTING.md +30 -0
  33. data/app/assets/components/sw-toolbox/LICENSE +201 -0
  34. data/app/assets/components/sw-toolbox/README.md +156 -0
  35. data/app/assets/components/sw-toolbox/bower.json +14 -0
  36. data/app/assets/components/sw-toolbox/companion.js +23 -0
  37. data/app/assets/components/sw-toolbox/package.json +21 -0
  38. data/app/assets/components/sw-toolbox/sw-toolbox.js +148 -0
  39. data/app/assets/components/sw-toolbox/sw-toolbox.map.json +1 -0
  40. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  41. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  42. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  43. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  44. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  45. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  46. data/app/assets/components/webcomponentsjs/README.md +125 -0
  47. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  48. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  49. data/app/assets/components/webcomponentsjs/bower.json +14 -0
  50. data/app/assets/components/webcomponentsjs/build.log +33 -0
  51. data/app/assets/components/webcomponentsjs/package.json +31 -0
  52. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  53. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  54. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  55. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  56. data/lib/polymer-platinum-rails.rb +2 -0
  57. data/lib/polymer-platinum-rails/engine.rb +4 -0
  58. data/lib/polymer-platinum-rails/version.rb +3 -0
  59. metadata +149 -0
@@ -0,0 +1,148 @@
1
+ /*
2
+ Copyright 2014 Google Inc. All Rights Reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.toolbox=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
18
+ "use strict";function cache(e,t){return helpers.openCache(t).then(function(t){return t.add(e)})}function uncache(e,t){return helpers.openCache(t).then(function(t){return t["delete"](e)})}function precache(e){Array.isArray(e)||(e=[e]),options.preCacheItems=options.preCacheItems.concat(e)}require("serviceworker-cache-polyfill");var options=require("./options"),router=require("./router"),helpers=require("./helpers"),strategies=require("./strategies");helpers.debug("Service Worker Toolbox is loading"),self.addEventListener("install",function(e){var t=options.cacheName+"$$$inactive$$$";helpers.debug("install event fired"),helpers.debug("creating cache ["+t+"]"),helpers.debug("preCache list: "+(options.preCacheItems.join(", ")||"(none)")),e.waitUntil(helpers.openCache({cacheName:t}).then(function(e){return Promise.all(options.preCacheItems).then(e.addAll.bind(e))}))}),self.addEventListener("activate",function(e){helpers.debug("activate event fired");var t=options.cacheName+"$$$inactive$$$";e.waitUntil(helpers.renameCache(t,options.cacheName))}),self.addEventListener("fetch",function(e){var t=router.match(e.request);t?e.respondWith(t(e.request)):router["default"]&&e.respondWith(router["default"](e.request))}),module.exports={networkOnly:strategies.networkOnly,networkFirst:strategies.networkFirst,cacheOnly:strategies.cacheOnly,cacheFirst:strategies.cacheFirst,fastest:strategies.fastest,router:router,options:options,cache:cache,uncache:uncache,precache:precache};
19
+ },{"./helpers":2,"./options":3,"./router":5,"./strategies":9,"serviceworker-cache-polyfill":14}],2:[function(require,module,exports){
20
+ "use strict";function debug(e,n){n=n||{};var c=n.debug||globalOptions.debug;c&&console.log("[sw-toolbox] "+e)}function openCache(e){e=e||{};var n=e.cacheName||globalOptions.cacheName;return debug('Opening cache "'+n+'"',e),caches.open(n)}function fetchAndCache(e,n){n=n||{};var c=n.successResponses||globalOptions.successResponses;return fetch(e.clone()).then(function(t){return"GET"===e.method&&c.test(t.status)&&openCache(n).then(function(n){n.put(e,t)}),t.clone()})}function renameCache(e,n,c){return debug("Renaming cache: ["+e+"] to ["+n+"]",c),caches["delete"](n).then(function(){return Promise.all([caches.open(e),caches.open(n)]).then(function(n){var c=n[0],t=n[1];return c.keys().then(function(e){return Promise.all(e.map(function(e){return c.match(e).then(function(n){return t.put(e,n)})}))}).then(function(){return caches["delete"](e)})})})}var globalOptions=require("./options");module.exports={debug:debug,fetchAndCache:fetchAndCache,openCache:openCache,renameCache:renameCache};
21
+ },{"./options":3}],3:[function(require,module,exports){
22
+ "use strict";var scope;scope=self.registration?self.registration.scope:self.scope||new URL("./",self.location).href,module.exports={cacheName:"$$$toolbox-cache$$$"+scope+"$$$",debug:!1,preCacheItems:[],successResponses:/^0|([123]\d\d)|(40[14567])|410$/};
23
+ },{}],4:[function(require,module,exports){
24
+ "use strict";var url=new URL("./",self.location),basePath=url.pathname,pathRegexp=require("path-to-regexp"),Route=function(e,t,i,s){0!==t.indexOf("/")&&(t=basePath+t),this.method=e,this.keys=[],this.regexp=pathRegexp(t,this.keys),this.options=s,this.handler=i};Route.prototype.makeHandler=function(e){var t=this.regexp.exec(e),i={};return this.keys.forEach(function(e,s){i[e.name]=t[s+1]}),function(e){return this.handler(e,i,this.options)}.bind(this)},module.exports=Route;
25
+ },{"path-to-regexp":12}],5:[function(require,module,exports){
26
+ /*
27
+ Copyright 2014 Google Inc. All Rights Reserved.
28
+
29
+ Licensed under the Apache License, Version 2.0 (the "License");
30
+ you may not use this file except in compliance with the License.
31
+ You may obtain a copy of the License at
32
+
33
+ http://www.apache.org/licenses/LICENSE-2.0
34
+
35
+ Unless required by applicable law or agreed to in writing, software
36
+ distributed under the License is distributed on an "AS IS" BASIS,
37
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38
+ See the License for the specific language governing permissions and
39
+ limitations under the License.
40
+ */
41
+ 'use strict';
42
+
43
+ var Route = require('./route');
44
+
45
+ function regexEscape(s) {
46
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
47
+ }
48
+
49
+ var keyMatch = function(map, string) {
50
+ for (var item of map) {
51
+ var pattern = new RegExp(item[0]), value = item[1];
52
+ if (pattern.test(string)) {
53
+ return value;
54
+ }
55
+ }
56
+ return null;
57
+ };
58
+
59
+ var Router = function() {
60
+ this.routes = new Map();
61
+ this.default = null;
62
+ };
63
+
64
+ ['get', 'post', 'put', 'delete', 'head', 'any'].forEach(function(method) {
65
+ Router.prototype[method] = function(path, handler, options) {
66
+ return this.add(method, path, handler, options);
67
+ };
68
+ });
69
+
70
+ Router.prototype.add = function(method, path, handler, options) {
71
+ options = options || {};
72
+ var origin = options.origin || self.location.origin;
73
+ if (origin instanceof RegExp) {
74
+ origin = origin.source;
75
+ } else {
76
+ origin = regexEscape(origin);
77
+ }
78
+ method = method.toLowerCase();
79
+
80
+ var route = new Route(method, path, handler, options);
81
+
82
+ if (!this.routes.has(origin)) {
83
+ this.routes.set(origin, new Map());
84
+ }
85
+
86
+ var methodMap = this.routes.get(origin);
87
+ if (!methodMap.has(method)) {
88
+ methodMap.set(method, new Map());
89
+ }
90
+
91
+ var routeMap = methodMap.get(method);
92
+ routeMap.set(route.regexp.source, route);
93
+ };
94
+
95
+ Router.prototype.matchMethod = function(method, url) {
96
+ url = new URL(url);
97
+ var origin = url.origin;
98
+ var path = url.pathname;
99
+ method = method.toLowerCase();
100
+
101
+ var methods = keyMatch(this.routes, origin);
102
+ if (!methods) {
103
+ return null;
104
+ }
105
+
106
+ var routes = methods.get(method);
107
+ if (!routes) {
108
+ return null;
109
+ }
110
+
111
+ var route = keyMatch(routes, path);
112
+
113
+ if (route) {
114
+ return route.makeHandler(path);
115
+ }
116
+
117
+ return null;
118
+ };
119
+
120
+ Router.prototype.match = function(request) {
121
+ return this.matchMethod(request.method, request.url) || this.matchMethod('any', request.url);
122
+ };
123
+
124
+ module.exports = new Router();
125
+
126
+ },{"./route":4}],6:[function(require,module,exports){
127
+ "use strict";function cacheFirst(e,r,t){return helpers.debug("Strategy: cache first ["+e.url+"]",t),helpers.openCache(t).then(function(r){return r.match(e).then(function(r){return r?r:helpers.fetchAndCache(e,t)})})}var helpers=require("../helpers");module.exports=cacheFirst;
128
+ },{"../helpers":2}],7:[function(require,module,exports){
129
+ "use strict";function cacheOnly(e,r,c){return helpers.debug("Strategy: cache only ["+e.url+"]",c),helpers.openCache(c).then(function(r){return r.match(e)})}var helpers=require("../helpers");module.exports=cacheOnly;
130
+ },{"../helpers":2}],8:[function(require,module,exports){
131
+ "use strict";function fastest(e,r,t){helpers.debug("Strategy: fastest ["+e.url+"]",t);var n=!1,c=[],s=function(e){return c.push(e.toString()),n?Promise.reject(new Error('Both cache and network failed: "'+c.join('", "')+'"')):void(n=!0)};return new Promise(function(r,n){helpers.fetchAndCache(e.clone(),t).then(r,s),cacheOnly(e,t).then(r,s)})}var helpers=require("../helpers"),cacheOnly=require("./cacheOnly");module.exports=fastest;
132
+ },{"../helpers":2,"./cacheOnly":7}],9:[function(require,module,exports){
133
+ module.exports={networkOnly:require("./networkOnly"),networkFirst:require("./networkFirst"),cacheOnly:require("./cacheOnly"),cacheFirst:require("./cacheFirst"),fastest:require("./fastest")};
134
+ },{"./cacheFirst":6,"./cacheOnly":7,"./fastest":8,"./networkFirst":10,"./networkOnly":11}],10:[function(require,module,exports){
135
+ "use strict";function networkFirst(e,r,s){s=s||{};var t=s.successResponses||globalOptions.successResponses;return helpers.debug("Strategy: network first ["+e.url+"]",s),helpers.openCache(s).then(function(r){return helpers.fetchAndCache(e,s).then(function(n){return t.test(n.status)?n:r.match(e).then(function(e){return helpers.debug("Response was an HTTP error",s),e?(helpers.debug("Resolving with cached response instead",s),e):(helpers.debug("No cached result, resolving with HTTP error response from network",s),n)})})["catch"](function(t){return helpers.debug("Network error, fallback to cache ["+e.url+"]",s),r.match(e)})})}var globalOptions=require("../options"),helpers=require("../helpers");module.exports=networkFirst;
136
+ },{"../helpers":2,"../options":3}],11:[function(require,module,exports){
137
+ "use strict";function networkOnly(e,r,t){return helpers.debug("Strategy: network only ["+e.url+"]",t),fetch(e)}var helpers=require("../helpers");module.exports=networkOnly;
138
+ },{"../helpers":2}],12:[function(require,module,exports){
139
+ function parse(e){for(var t,r=[],n=0,o=0,p="";null!=(t=PATH_REGEXP.exec(e));){var a=t[0],i=t[1],s=t.index;if(p+=e.slice(o,s),o=s+a.length,i)p+=i[1];else{p&&(r.push(p),p="");var u=t[2],c=t[3],l=t[4],f=t[5],g=t[6],x=t[7],h="+"===g||"*"===g,m="?"===g||"*"===g,y=u||"/",T=l||f||(x?".*":"[^"+y+"]+?");r.push({name:c||n++,prefix:u||"",delimiter:y,optional:m,repeat:h,pattern:escapeGroup(T)})}}return o<e.length&&(p+=e.substr(o)),p&&r.push(p),r}function compile(e){return tokensToFunction(parse(e))}function tokensToFunction(e){for(var t=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(t[r]=new RegExp("^"+e[r].pattern+"$"));return function(r){var n="";r=r||{};for(var o=0;o<e.length;o++){var p=e[o];if("string"!=typeof p){var a=r[p.name];if(null==a){if(p.optional)continue;throw new TypeError('Expected "'+p.name+'" to be defined')}if(isarray(a)){if(!p.repeat)throw new TypeError('Expected "'+p.name+'" to not repeat');if(0===a.length){if(p.optional)continue;throw new TypeError('Expected "'+p.name+'" to not be empty')}for(var i=0;i<a.length;i++){if(!t[o].test(a[i]))throw new TypeError('Expected all "'+p.name+'" to match "'+p.pattern+'"');n+=(0===i?p.prefix:p.delimiter)+encodeURIComponent(a[i])}}else{if(!t[o].test(a))throw new TypeError('Expected "'+p.name+'" to match "'+p.pattern+'"');n+=p.prefix+encodeURIComponent(a)}}else n+=p}return n}}function escapeString(e){return e.replace(/([.+*?=^!:${}()[\]|\/])/g,"\\$1")}function escapeGroup(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function attachKeys(e,t){return e.keys=t,e}function flags(e){return e.sensitive?"":"i"}function regexpToRegexp(e,t){var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,pattern:null});return attachKeys(e,t)}function arrayToRegexp(e,t,r){for(var n=[],o=0;o<e.length;o++)n.push(pathToRegexp(e[o],t,r).source);var p=new RegExp("(?:"+n.join("|")+")",flags(r));return attachKeys(p,t)}function stringToRegexp(e,t,r){for(var n=parse(e),o=tokensToRegExp(n,r),p=0;p<n.length;p++)"string"!=typeof n[p]&&t.push(n[p]);return attachKeys(o,t)}function tokensToRegExp(e,t){t=t||{};for(var r=t.strict,n=t.end!==!1,o="",p=e[e.length-1],a="string"==typeof p&&/\/$/.test(p),i=0;i<e.length;i++){var s=e[i];if("string"==typeof s)o+=escapeString(s);else{var u=escapeString(s.prefix),c=s.pattern;s.repeat&&(c+="(?:"+u+c+")*"),c=s.optional?u?"(?:"+u+"("+c+"))?":"("+c+")?":u+"("+c+")",o+=c}}return r||(o=(a?o.slice(0,-2):o)+"(?:\\/(?=$))?"),o+=n?"$":r&&a?"":"(?=\\/|$)",new RegExp("^"+o,flags(t))}function pathToRegexp(e,t,r){return t=t||[],isarray(t)?r||(r={}):(r=t,t=[]),e instanceof RegExp?regexpToRegexp(e,t,r):isarray(e)?arrayToRegexp(e,t,r):stringToRegexp(e,t,r)}var isarray=require("isarray");module.exports=pathToRegexp,module.exports.parse=parse,module.exports.compile=compile,module.exports.tokensToFunction=tokensToFunction,module.exports.tokensToRegExp=tokensToRegExp;var PATH_REGEXP=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))"].join("|"),"g");
140
+ },{"isarray":13}],13:[function(require,module,exports){
141
+ module.exports=Array.isArray||function(r){return"[object Array]"==Object.prototype.toString.call(r)};
142
+ },{}],14:[function(require,module,exports){
143
+ Cache.prototype.add||(Cache.prototype.add=function(t){return this.addAll([t])}),Cache.prototype.addAll||(Cache.prototype.addAll=function(t){function e(t){this.name="NetworkError",this.code=19,this.message=t}var r=this;return e.prototype=Object.create(Error.prototype),Promise.resolve().then(function(){if(arguments.length<1)throw new TypeError;return t=t.map(function(t){return t instanceof Request?t:String(t)}),Promise.all(t.map(function(t){"string"==typeof t&&(t=new Request(t));var r=new URL(t.url).protocol;if("http:"!==r&&"https:"!==r)throw new e("Invalid scheme");return fetch(t.clone())}))}).then(function(e){return Promise.all(e.map(function(e,n){return r.put(t[n],e)}))}).then(function(){return void 0})});
144
+ },{}]},{},[1])(1)
145
+ });
146
+
147
+
148
+ //# sourceMappingURL=sw-toolbox.map.json
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["node_modules/browserify/node_modules/browser-pack/_prelude.js","lib/router.js","lib/sw-toolbox.js","lib/helpers.js","lib/options.js","lib/strategies/index.js","lib/route.js","lib/strategies/networkOnly.js","lib/strategies/networkFirst.js","lib/strategies/cacheOnly.js","lib/strategies/cacheFirst.js","lib/strategies/fastest.js","node_modules/serviceworker-cache-polyfill/index.js","node_modules/path-to-regexp/index.js","node_modules/path-to-regexp/node_modules/isarray/index.js"],"names":["cache","url","options","helpers","openCache","then","add","uncache","precache","items","Array","isArray","preCacheItems","concat","require","router","strategies","debug","self","addEventListener","event","inactiveCache","cacheName","join","waitUntil","Promise","all","addAll","bind","renameCache","handler","match","request","respondWith","module","exports","networkOnly","networkFirst","cacheOnly","cacheFirst","fastest","message","flag","globalOptions","console","log","caches","open","fetchAndCache","successResponses","fetch","clone","response","method","test","status","put","source","destination","results","sourceCache","destCache","keys","requests","map","scope","registration","URL","location","href","basePath","pathname","pathRegexp","Route","path","indexOf","this","regexp","prototype","makeHandler","exec","values","forEach","key","index","name","cacheResponse","error","rejected","reasons","maybeReject","reason","push","toString","reject","Error","resolve","Cache","NetworkError","code","Object","create","arguments","length","TypeError","Request","String","scheme","protocol","responses","i","undefined","parse","str","res","tokens","PATH_REGEXP","m","escaped","offset","slice","prefix","capture","group","suffix","asterisk","repeat","optional","delimiter","pattern","escapeGroup","substr","compile","tokensToFunction","matches","RegExp","obj","value","isarray","j","encodeURIComponent","escapeString","replace","attachKeys","re","flags","sensitive","regexpToRegexp","groups","arrayToRegexp","parts","pathToRegexp","stringToRegexp","tokensToRegExp","strict","end","route","lastToken","endsWithSlash","token","arr","call"],"mappings":"AAAA;AEeA,YA8CA,SAASA,OAAMC,EAAKC,GAClB,MAAOC,SAAQC,UAAUF,GAASG,KAAK,SAASL,GAC9C,MAAOA,GAAMM,IAAIL,KAIrB,QAASM,SAAQN,EAAKC,GACpB,MAAOC,SAAQC,UAAUF,GAASG,KAAK,SAASL,GAC9C,MAAOA,GAAAA,UAAaC,KAIxB,QAASO,UAASC,GACXC,MAAMC,QAAQF,KACjBA,GAASA,IAEXP,QAAQU,cAAgBV,QAAQU,cAAcC,OAAOJ,GA5DvDK,QAAQ,+BACR,IAAIZ,SAAUY,QAAQ,aAClBC,OAASD,QAAQ,YACjBX,QAAUW,QAAQ,aAClBE,WAAaF,QAAQ,eAEzBX,SAAQc,MAAM,qCAIdC,KAAKC,iBAAiB,UAAW,SAASC,GACxC,GAAIC,GAAgBnB,QAAQoB,UAAY,gBACxCnB,SAAQc,MAAM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E,QAAUA,EACf0E,KAAK9C,QAAUA,EAGjB2C,OAAMK,UAAUC,YAAc,SAAS9E,GACrC,GAAI8B,GAAQ6C,KAAKC,OAAOG,KAAK/E,GACzBgF,IAIJ,OAHAL,MAAKd,KAAKoB,QAAQ,SAASC,EAAKC,GAC9BH,EAAOE,EAAIE,MAAQtD,EAAMqD,EAAQ,KAE5B,SAASpD,GACd,MAAO4C,MAAK9C,QAAQE,EAASiD,EAAQL,KAAK1E,UAC1C0B,KAAKgD,OAGT1C,OAAOC,QAAUsC;;ALnDjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ASpFA,YAGA,SAASlC,YAAWP,EAASiD,EAAQ/E,GAEnC,MADAC,SAAQc,MAAM,0BAA4Be,EAAQ/B,IAAM,IAAKC,GACtDC,QAAQC,UAAUF,GAASG,KAAK,SAASL,GAC9C,MAAOA,GAAM+B,MAAMC,GAAS3B,KAAK,SAAU+C,GACzC,MAAIA,GACKA,EAGFjD,QAAQ6C,cAAchB,EAAS9B,OAV5C,GAAIC,SAAUW,QAAQ,aAetBoB,QAAOC,QAAUI;;ADhBjB,YAGA,SAASD,WAAUN,EAASiD,EAAQ/E,GAElC,MADAC,SAAQc,MAAM,yBAA2Be,EAAQ/B,IAAM,IAAKC,GACrDC,Q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AAO4C,MAAKjD,QAAQK,MAInBiE,MAAMnB,UAAUnD,SACnBsE,MAAMnB,UAAUnD,OAAS,SAAgBoC,GAIvC,QAASmC,GAAazD,GACpBmC,KAAKS,KAAO,eACZT,KAAKuB,KAAO,GACZvB,KAAKnC,QAAUA,EANjB,GAAIzC,GAAQ4E,IAUZ,OAFAsB,GAAapB,UAAYsB,OAAOC,OAAON,MAAMjB,WAEtCrD,QAAQuE,UAAU3F,KAAK,WAC5B,GAAIiG,UAAUC,OAAS,EAAG,KAAM,IAAIC,UAcpC,OATAzC,GAAWA,EAASC,IAAI,SAAShC,GAC/B,MAAIA,aAAmByE,SACdzE,EAGA0E,OAAO1E,KAIXP,QAAQC,IACbqC,EAASC,IAAI,SAAShC,GACG,gBAAZA,KACTA,EAAU,GAAIyE,SAAQzE,GAGxB,IAAI2E,GAAS,GAAIxC,KAAInC,EAAQ/B,KAAK2G,QAElC,IAAe,UAAXD,GAAiC,WAAXA,EACxB,KAAM,IAAIT,GAAa,iBAGzB,OAAOhD,OAAMlB,EAAQmB,cAGxB9C,KAAK,SAASwG,GAGf,MAAOpF,SAAQC,IACbmF,EAAU7C,IAAI,SAASZ,EAAU0D,GAC/B,MAAO9G,GAAMwD,IAAIO,EAAS+C,GAAI1D,QAGjC/C,KAAK,WACN,MAAO0G","file":"bundle.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\n\nvar Route = require('./route');\n\nfunction regexEscape(s) {\n return s.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n\nvar keyMatch = function(map, string) {\n for (var item of map) {\n var pattern = new RegExp(item[0]), value = item[1];\n if (pattern.test(string)) {\n return value;\n }\n }\n return null;\n};\n\nvar Router = function() {\n this.routes = new Map();\n this.default = null;\n};\n\n['get', 'post', 'put', 'delete', 'head', 'any'].forEach(function(method) {\n Router.prototype[method] = function(path, handler, options) {\n return this.add(method, path, handler, options);\n };\n});\n\nRouter.prototype.add = function(method, path, handler, options) {\n options = options || {};\n var origin = options.origin || self.location.origin;\n if (origin instanceof RegExp) {\n origin = origin.source;\n } else {\n origin = regexEscape(origin);\n }\n method = method.toLowerCase();\n\n var route = new Route(method, path, handler, options);\n\n if (!this.routes.has(origin)) {\n this.routes.set(origin, new Map());\n }\n\n var methodMap = this.routes.get(origin);\n if (!methodMap.has(method)) {\n methodMap.set(method, new Map());\n }\n\n var routeMap = methodMap.get(method);\n routeMap.set(route.regexp.source, route);\n};\n\nRouter.prototype.matchMethod = function(method, url) {\n url = new URL(url);\n var origin = url.origin;\n var path = url.pathname;\n method = method.toLowerCase();\n\n var methods = keyMatch(this.routes, origin);\n if (!methods) {\n return null;\n }\n\n var routes = methods.get(method);\n if (!routes) {\n return null;\n }\n\n var route = keyMatch(routes, path);\n\n if (route) {\n return route.makeHandler(path);\n }\n\n return null;\n};\n\nRouter.prototype.match = function(request) {\n return this.matchMethod(request.method, request.url) || this.matchMethod('any', request.url);\n};\n\nmodule.exports = new Router();\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\n\nrequire('serviceworker-cache-polyfill');\nvar options = require('./options');\nvar router = require('./router');\nvar helpers = require('./helpers');\nvar strategies = require('./strategies');\n\nhelpers.debug('Service Worker Toolbox is loading');\n\n// Install\n\nself.addEventListener('install', function(event) {\n var inactiveCache = options.cacheName + '$$$inactive$$$';\n helpers.debug('install event fired');\n helpers.debug('creating cache [' + inactiveCache + ']');\n helpers.debug('preCache list: ' + (options.preCacheItems.join(', ') || '(none)'));\n event.waitUntil(\n helpers.openCache({cacheName: inactiveCache}).then(function(cache) {\n return Promise.all(options.preCacheItems).then(cache.addAll.bind(cache));\n })\n );\n});\n\n// Activate\n\nself.addEventListener('activate', function(event) {\n helpers.debug('activate event fired');\n var inactiveCache = options.cacheName + '$$$inactive$$$';\n event.waitUntil(helpers.renameCache(inactiveCache, options.cacheName));\n});\n\n// Fetch\n\nself.addEventListener('fetch', function(event) {\n var handler = router.match(event.request);\n\n if (handler) {\n event.respondWith(handler(event.request));\n } else if (router.default) {\n event.respondWith(router.default(event.request));\n }\n});\n\n// Caching\n\nfunction cache(url, options) {\n return helpers.openCache(options).then(function(cache) {\n return cache.add(url);\n });\n}\n\nfunction uncache(url, options) {\n return helpers.openCache(options).then(function(cache) {\n return cache.delete(url);\n });\n}\n\nfunction precache(items) {\n if (!Array.isArray(items)) {\n items = [items];\n }\n options.preCacheItems = options.preCacheItems.concat(items);\n}\n\nmodule.exports = {\n networkOnly: strategies.networkOnly,\n networkFirst: strategies.networkFirst,\n cacheOnly: strategies.cacheOnly,\n cacheFirst: strategies.cacheFirst,\n fastest: strategies.fastest,\n router: router,\n options: options,\n cache: cache,\n uncache: uncache,\n precache: precache\n};\n","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\n\nvar globalOptions = require('./options');\n\nfunction debug(message, options) {\n options = options || {};\n var flag = options.debug || globalOptions.debug;\n if (flag) {\n console.log('[sw-toolbox] ' + message);\n }\n}\n\nfunction openCache(options) {\n options = options || {};\n var cacheName = options.cacheName || globalOptions.cacheName;\n debug('Opening cache \"' + cacheName + '\"', options);\n return caches.open(cacheName);\n}\n\nfunction fetchAndCache(request, options) {\n options = options || {};\n var successResponses = options.successResponses || globalOptions.successResponses;\n return fetch(request.clone()).then(function(response) {\n\n // Only cache GET requests with successful responses\n if (request.method === 'GET' && successResponses.test(response.status)) {\n openCache(options).then(function(cache) {\n cache.put(request, response);\n });\n }\n\n return response.clone();\n });\n}\n\nfunction renameCache(source, destination, options) {\n debug('Renaming cache: [' + source + '] to [' + destination + ']', options);\n return caches.delete(destination).then(function() {\n return Promise.all([\n caches.open(source),\n caches.open(destination)\n ]).then(function(results) {\n var sourceCache = results[0];\n var destCache = results[1];\n\n return sourceCache.keys().then(function(requests) {\n return Promise.all(requests.map(function(request) {\n return sourceCache.match(request).then(function(response) {\n return destCache.put(request, response);\n });\n }));\n }).then(function() {\n return caches.delete(source);\n });\n });\n });\n}\n\nmodule.exports = {\n debug: debug,\n fetchAndCache: fetchAndCache,\n openCache: openCache,\n renameCache: renameCache\n};\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\n\n// TODO: This is necessary to handle different implementations in the wild\n// The spec defines self.registration, but it was not implemented in Chrome 40.\nvar scope;\nif (self.registration) {\n scope = self.registration.scope;\n} else {\n scope = self.scope || new URL('./', self.location).href;\n}\n\nmodule.exports = {\n\tcacheName: '$$$toolbox-cache$$$' + scope + '$$$',\n\tdebug: false,\n\tpreCacheItems: [],\n\t// A regular expression to apply to HTTP response codes. Codes that match\n\t// will be considered successes, while others will not, and will not be\n\t// cached.\n\tsuccessResponses: /^0|([123]\\d\\d)|(40[14567])|410$/,\n};\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\nmodule.exports = {\n networkOnly: require('./networkOnly'),\n networkFirst: require('./networkFirst'),\n cacheOnly: require('./cacheOnly'),\n cacheFirst: require('./cacheFirst'),\n fastest: require('./fastest')\t\n};","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\n\n//TODO: Use self.registration.scope instead of self.location\nvar url = new URL('./', self.location);\nvar basePath = url.pathname;\nvar pathRegexp = require('path-to-regexp');\n\n\nvar Route = function(method, path, handler, options) {\n // The URL() constructor can't parse express-style routes as they are not\n // valid urls. This means we have to manually manipulate relative urls into\n // absolute ones. This check is extremely naive but implementing a tweaked\n // version of the full algorithm seems like overkill\n // (https://url.spec.whatwg.org/#concept-basic-url-parser)\n if (path.indexOf('/') !== 0) {\n path = basePath + path;\n }\n\n this.method = method;\n this.keys = [];\n this.regexp = pathRegexp(path, this.keys);\n this.options = options;\n this.handler = handler;\n};\n\nRoute.prototype.makeHandler = function(url) {\n var match = this.regexp.exec(url);\n var values = {};\n this.keys.forEach(function(key, index) {\n values[key.name] = match[index + 1];\n });\n return function(request) {\n return this.handler(request, values, this.options);\n }.bind(this);\n};\n\nmodule.exports = Route;\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar helpers = require('../helpers');\n\nfunction networkOnly(request, values, options) {\n helpers.debug('Strategy: network only [' + request.url + ']', options);\n return fetch(request);\n}\n\nmodule.exports = networkOnly;","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\nvar globalOptions = require('../options');\nvar helpers = require('../helpers');\n\nfunction networkFirst(request, values, options) {\n options = options || {};\n var successResponses = options.successResponses || globalOptions.successResponses;\n helpers.debug('Strategy: network first [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return helpers.fetchAndCache(request, options).then(function(response) {\n if (successResponses.test(response.status)) {\n return response;\n }\n\n return cache.match(request).then(function(cacheResponse) {\n helpers.debug('Response was an HTTP error', options);\n if (cacheResponse) {\n helpers.debug('Resolving with cached response instead', options);\n return cacheResponse;\n } else {\n // If we didn't have anything in the cache, it's better to return the\n // error page than to return nothing\n helpers.debug('No cached result, resolving with HTTP error response from network', options);\n return response;\n }\n });\n }).catch(function(error) {\n helpers.debug('Network error, fallback to cache [' + request.url + ']', options);\n return cache.match(request);\n });\n });\n}\n\nmodule.exports = networkFirst;","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar helpers = require('../helpers');\n\nfunction cacheOnly(request, values, options) {\n helpers.debug('Strategy: cache only [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request);\n });\n}\n\nmodule.exports = cacheOnly;\n","/*\n\tCopyright 2014 Google Inc. All Rights Reserved.\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n*/\n'use strict';\nvar helpers = require('../helpers');\n\nfunction cacheFirst(request, values, options) {\n helpers.debug('Strategy: cache first [' + request.url + ']', options);\n return helpers.openCache(options).then(function(cache) {\n return cache.match(request).then(function (response) {\n if (response) {\n return response;\n }\n\n return helpers.fetchAndCache(request, options);\n });\n });\n}\n\nmodule.exports = cacheFirst;","/*\n Copyright 2014 Google Inc. All Rights Reserved.\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'use strict';\nvar helpers = require('../helpers');\nvar cacheOnly = require('./cacheOnly');\n\nfunction fastest(request, values, options) {\n helpers.debug('Strategy: fastest [' + request.url + ']', options);\n var rejected = false;\n var reasons = [];\n\n var maybeReject = function(reason) {\n reasons.push(reason.toString());\n if (rejected) {\n return Promise.reject(new Error('Both cache and network failed: \"' + reasons.join('\", \"') + '\"'));\n }\n rejected = true;\n };\n\n return new Promise(function(resolve, reject) {\n helpers.fetchAndCache(request.clone(), options).then(resolve, maybeReject);\n cacheOnly(request, options).then(resolve, maybeReject);\n });\n}\n\nmodule.exports = fastest;","if (!Cache.prototype.add) {\n Cache.prototype.add = function add(request) {\n return this.addAll([request]);\n };\n}\n\nif (!Cache.prototype.addAll) {\n Cache.prototype.addAll = function addAll(requests) {\n var cache = this;\n\n // Since DOMExceptions are not constructable:\n function NetworkError(message) {\n this.name = 'NetworkError';\n this.code = 19;\n this.message = message;\n }\n NetworkError.prototype = Object.create(Error.prototype);\n\n return Promise.resolve().then(function() {\n if (arguments.length < 1) throw new TypeError();\n \n // Simulate sequence<(Request or USVString)> binding:\n var sequence = [];\n\n requests = requests.map(function(request) {\n if (request instanceof Request) {\n return request;\n }\n else {\n return String(request); // may throw TypeError\n }\n });\n\n return Promise.all(\n requests.map(function(request) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n var scheme = new URL(request.url).protocol;\n\n if (scheme !== 'http:' && scheme !== 'https:') {\n throw new NetworkError(\"Invalid scheme\");\n }\n\n return fetch(request.clone());\n })\n );\n }).then(function(responses) {\n // TODO: check that requests don't overwrite one another\n // (don't think this is possible to polyfill due to opaque responses)\n return Promise.all(\n responses.map(function(response, i) {\n return cache.put(requests[i], response);\n })\n );\n }).then(function() {\n return undefined;\n });\n };\n}\n","var isarray = require('isarray')\n\n/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \"/:test(\\\\d+)?\" => [\"/\", \"test\", \"\\d+\", undefined, \"?\", undefined]\n // \"/route(\\\\d+)\" => [undefined, undefined, undefined, \"\\d+\", undefined, undefined]\n // \"/*\" => [\"/\", undefined, undefined, undefined, undefined, \"*\"]\n '([\\\\/.])?(?:(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^()])+)\\\\))([+*?])?|(\\\\*))'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {String} str\n * @return {Array}\n */\nfunction parse (str) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var res\n\n while ((res = PATH_REGEXP.exec(str)) != null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n continue\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n }\n\n var prefix = res[2]\n var name = res[3]\n var capture = res[4]\n var group = res[5]\n var suffix = res[6]\n var asterisk = res[7]\n\n var repeat = suffix === '+' || suffix === '*'\n var optional = suffix === '?' || suffix === '*'\n var delimiter = prefix || '/'\n var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?')\n\n tokens.push({\n name: name || key++,\n prefix: prefix || '',\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: escapeGroup(pattern)\n })\n }\n\n // Match any characters still remaining.\n if (index < str.length) {\n path += str.substr(index)\n }\n\n // If the path exists, push it onto the end.\n if (path) {\n tokens.push(path)\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {String} str\n * @return {Function}\n */\nfunction compile (str) {\n return tokensToFunction(parse(str))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^' + tokens[i].pattern + '$')\n }\n }\n\n return function (obj) {\n var path = ''\n\n obj = obj || {}\n\n for (var i = 0; i < tokens.length; i++) {\n var key = tokens[i]\n\n if (typeof key === 'string') {\n path += key\n\n continue\n }\n\n var value = obj[key.name]\n\n if (value == null) {\n if (key.optional) {\n continue\n } else {\n throw new TypeError('Expected \"' + key.name + '\" to be defined')\n }\n }\n\n if (isarray(value)) {\n if (!key.repeat) {\n throw new TypeError('Expected \"' + key.name + '\" to not repeat')\n }\n\n if (value.length === 0) {\n if (key.optional) {\n continue\n } else {\n throw new TypeError('Expected \"' + key.name + '\" to not be empty')\n }\n }\n\n for (var j = 0; j < value.length; j++) {\n if (!matches[i].test(value[j])) {\n throw new TypeError('Expected all \"' + key.name + '\" to match \"' + key.pattern + '\"')\n }\n\n path += (j === 0 ? key.prefix : key.delimiter) + encodeURIComponent(value[j])\n }\n\n continue\n }\n\n if (!matches[i].test(value)) {\n throw new TypeError('Expected \"' + key.name + '\" to match \"' + key.pattern + '\"')\n }\n\n path += key.prefix + encodeURIComponent(value)\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {String} str\n * @return {String}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|\\/])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {String} group\n * @return {String}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$\\/()])/g, '\\\\$1')\n}\n\n/**\n * Attach the keys as a property of the regexp.\n *\n * @param {RegExp} re\n * @param {Array} keys\n * @return {RegExp}\n */\nfunction attachKeys (re, keys) {\n re.keys = keys\n return re\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {String}\n */\nfunction flags (options) {\n return options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {RegExp} path\n * @param {Array} keys\n * @return {RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return attachKeys(path, keys)\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {Array} path\n * @param {Array} keys\n * @param {Object} options\n * @return {RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))\n\n return attachKeys(regexp, keys)\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {String} path\n * @param {Array} keys\n * @param {Object} options\n * @return {RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n var tokens = parse(path)\n var re = tokensToRegExp(tokens, options)\n\n // Attach keys back to the regexp.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] !== 'string') {\n keys.push(tokens[i])\n }\n }\n\n return attachKeys(re, keys)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {Array} tokens\n * @param {Array} keys\n * @param {Object} options\n * @return {RegExp}\n */\nfunction tokensToRegExp (tokens, options) {\n options = options || {}\n\n var strict = options.strict\n var end = options.end !== false\n var route = ''\n var lastToken = tokens[tokens.length - 1]\n var endsWithSlash = typeof lastToken === 'string' && /\\/$/.test(lastToken)\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var prefix = escapeString(token.prefix)\n var capture = token.pattern\n\n if (token.repeat) {\n capture += '(?:' + prefix + capture + ')*'\n }\n\n if (token.optional) {\n if (prefix) {\n capture = '(?:' + prefix + '(' + capture + '))?'\n } else {\n capture = '(' + capture + ')?'\n }\n } else {\n capture = prefix + '(' + capture + ')'\n }\n\n route += capture\n }\n }\n\n // In non-strict mode we allow a slash at the end of match. If the path to\n // match already ends with a slash, we remove it for consistency. The slash\n // is valid at the end of a path match, not in the middle. This is important\n // in non-ending mode, where \"/test/\" shouldn't match \"/test//route\".\n if (!strict) {\n route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\\\/(?=$))?'\n }\n\n if (end) {\n route += '$'\n } else {\n // In non-ending mode, we need the capturing groups to match as much as\n // possible by using a positive lookahead to the end or next path segment.\n route += strict && endsWithSlash ? '' : '(?=\\\\/|$)'\n }\n\n return new RegExp('^' + route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(String|RegExp|Array)} path\n * @param {Array} [keys]\n * @param {Object} [options]\n * @return {RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n keys = keys || []\n\n if (!isarray(keys)) {\n options = keys\n keys = []\n } else if (!options) {\n options = {}\n }\n\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys, options)\n }\n\n if (isarray(path)) {\n return arrayToRegexp(path, keys, options)\n }\n\n return stringToRegexp(path, keys, options)\n}\n","module.exports = Array.isArray || function (arr) {\n return Object.prototype.toString.call(arr) == '[object Array]';\n};\n"]}
@@ -0,0 +1,956 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ * Code distributed by Google as part of the polymer project is also
8
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ */
10
+ // @version 0.7.3
11
+ if (typeof WeakMap === "undefined") {
12
+ (function() {
13
+ var defineProperty = Object.defineProperty;
14
+ var counter = Date.now() % 1e9;
15
+ var WeakMap = function() {
16
+ this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
17
+ };
18
+ WeakMap.prototype = {
19
+ set: function(key, value) {
20
+ var entry = key[this.name];
21
+ if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
22
+ value: [ key, value ],
23
+ writable: true
24
+ });
25
+ return this;
26
+ },
27
+ get: function(key) {
28
+ var entry;
29
+ return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
30
+ },
31
+ "delete": function(key) {
32
+ var entry = key[this.name];
33
+ if (!entry || entry[0] !== key) return false;
34
+ entry[0] = entry[1] = undefined;
35
+ return true;
36
+ },
37
+ has: function(key) {
38
+ var entry = key[this.name];
39
+ if (!entry) return false;
40
+ return entry[0] === key;
41
+ }
42
+ };
43
+ window.WeakMap = WeakMap;
44
+ })();
45
+ }
46
+
47
+ (function(global) {
48
+ var registrationsTable = new WeakMap();
49
+ var setImmediate;
50
+ if (/Trident|Edge/.test(navigator.userAgent)) {
51
+ setImmediate = setTimeout;
52
+ } else if (window.setImmediate) {
53
+ setImmediate = window.setImmediate;
54
+ } else {
55
+ var setImmediateQueue = [];
56
+ var sentinel = String(Math.random());
57
+ window.addEventListener("message", function(e) {
58
+ if (e.data === sentinel) {
59
+ var queue = setImmediateQueue;
60
+ setImmediateQueue = [];
61
+ queue.forEach(function(func) {
62
+ func();
63
+ });
64
+ }
65
+ });
66
+ setImmediate = function(func) {
67
+ setImmediateQueue.push(func);
68
+ window.postMessage(sentinel, "*");
69
+ };
70
+ }
71
+ var isScheduled = false;
72
+ var scheduledObservers = [];
73
+ function scheduleCallback(observer) {
74
+ scheduledObservers.push(observer);
75
+ if (!isScheduled) {
76
+ isScheduled = true;
77
+ setImmediate(dispatchCallbacks);
78
+ }
79
+ }
80
+ function wrapIfNeeded(node) {
81
+ return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
82
+ }
83
+ function dispatchCallbacks() {
84
+ isScheduled = false;
85
+ var observers = scheduledObservers;
86
+ scheduledObservers = [];
87
+ observers.sort(function(o1, o2) {
88
+ return o1.uid_ - o2.uid_;
89
+ });
90
+ var anyNonEmpty = false;
91
+ observers.forEach(function(observer) {
92
+ var queue = observer.takeRecords();
93
+ removeTransientObserversFor(observer);
94
+ if (queue.length) {
95
+ observer.callback_(queue, observer);
96
+ anyNonEmpty = true;
97
+ }
98
+ });
99
+ if (anyNonEmpty) dispatchCallbacks();
100
+ }
101
+ function removeTransientObserversFor(observer) {
102
+ observer.nodes_.forEach(function(node) {
103
+ var registrations = registrationsTable.get(node);
104
+ if (!registrations) return;
105
+ registrations.forEach(function(registration) {
106
+ if (registration.observer === observer) registration.removeTransientObservers();
107
+ });
108
+ });
109
+ }
110
+ function forEachAncestorAndObserverEnqueueRecord(target, callback) {
111
+ for (var node = target; node; node = node.parentNode) {
112
+ var registrations = registrationsTable.get(node);
113
+ if (registrations) {
114
+ for (var j = 0; j < registrations.length; j++) {
115
+ var registration = registrations[j];
116
+ var options = registration.options;
117
+ if (node !== target && !options.subtree) continue;
118
+ var record = callback(options);
119
+ if (record) registration.enqueue(record);
120
+ }
121
+ }
122
+ }
123
+ }
124
+ var uidCounter = 0;
125
+ function JsMutationObserver(callback) {
126
+ this.callback_ = callback;
127
+ this.nodes_ = [];
128
+ this.records_ = [];
129
+ this.uid_ = ++uidCounter;
130
+ }
131
+ JsMutationObserver.prototype = {
132
+ observe: function(target, options) {
133
+ target = wrapIfNeeded(target);
134
+ if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
135
+ throw new SyntaxError();
136
+ }
137
+ var registrations = registrationsTable.get(target);
138
+ if (!registrations) registrationsTable.set(target, registrations = []);
139
+ var registration;
140
+ for (var i = 0; i < registrations.length; i++) {
141
+ if (registrations[i].observer === this) {
142
+ registration = registrations[i];
143
+ registration.removeListeners();
144
+ registration.options = options;
145
+ break;
146
+ }
147
+ }
148
+ if (!registration) {
149
+ registration = new Registration(this, target, options);
150
+ registrations.push(registration);
151
+ this.nodes_.push(target);
152
+ }
153
+ registration.addListeners();
154
+ },
155
+ disconnect: function() {
156
+ this.nodes_.forEach(function(node) {
157
+ var registrations = registrationsTable.get(node);
158
+ for (var i = 0; i < registrations.length; i++) {
159
+ var registration = registrations[i];
160
+ if (registration.observer === this) {
161
+ registration.removeListeners();
162
+ registrations.splice(i, 1);
163
+ break;
164
+ }
165
+ }
166
+ }, this);
167
+ this.records_ = [];
168
+ },
169
+ takeRecords: function() {
170
+ var copyOfRecords = this.records_;
171
+ this.records_ = [];
172
+ return copyOfRecords;
173
+ }
174
+ };
175
+ function MutationRecord(type, target) {
176
+ this.type = type;
177
+ this.target = target;
178
+ this.addedNodes = [];
179
+ this.removedNodes = [];
180
+ this.previousSibling = null;
181
+ this.nextSibling = null;
182
+ this.attributeName = null;
183
+ this.attributeNamespace = null;
184
+ this.oldValue = null;
185
+ }
186
+ function copyMutationRecord(original) {
187
+ var record = new MutationRecord(original.type, original.target);
188
+ record.addedNodes = original.addedNodes.slice();
189
+ record.removedNodes = original.removedNodes.slice();
190
+ record.previousSibling = original.previousSibling;
191
+ record.nextSibling = original.nextSibling;
192
+ record.attributeName = original.attributeName;
193
+ record.attributeNamespace = original.attributeNamespace;
194
+ record.oldValue = original.oldValue;
195
+ return record;
196
+ }
197
+ var currentRecord, recordWithOldValue;
198
+ function getRecord(type, target) {
199
+ return currentRecord = new MutationRecord(type, target);
200
+ }
201
+ function getRecordWithOldValue(oldValue) {
202
+ if (recordWithOldValue) return recordWithOldValue;
203
+ recordWithOldValue = copyMutationRecord(currentRecord);
204
+ recordWithOldValue.oldValue = oldValue;
205
+ return recordWithOldValue;
206
+ }
207
+ function clearRecords() {
208
+ currentRecord = recordWithOldValue = undefined;
209
+ }
210
+ function recordRepresentsCurrentMutation(record) {
211
+ return record === recordWithOldValue || record === currentRecord;
212
+ }
213
+ function selectRecord(lastRecord, newRecord) {
214
+ if (lastRecord === newRecord) return lastRecord;
215
+ if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
216
+ return null;
217
+ }
218
+ function Registration(observer, target, options) {
219
+ this.observer = observer;
220
+ this.target = target;
221
+ this.options = options;
222
+ this.transientObservedNodes = [];
223
+ }
224
+ Registration.prototype = {
225
+ enqueue: function(record) {
226
+ var records = this.observer.records_;
227
+ var length = records.length;
228
+ if (records.length > 0) {
229
+ var lastRecord = records[length - 1];
230
+ var recordToReplaceLast = selectRecord(lastRecord, record);
231
+ if (recordToReplaceLast) {
232
+ records[length - 1] = recordToReplaceLast;
233
+ return;
234
+ }
235
+ } else {
236
+ scheduleCallback(this.observer);
237
+ }
238
+ records[length] = record;
239
+ },
240
+ addListeners: function() {
241
+ this.addListeners_(this.target);
242
+ },
243
+ addListeners_: function(node) {
244
+ var options = this.options;
245
+ if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
246
+ if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
247
+ if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
248
+ if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
249
+ },
250
+ removeListeners: function() {
251
+ this.removeListeners_(this.target);
252
+ },
253
+ removeListeners_: function(node) {
254
+ var options = this.options;
255
+ if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
256
+ if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
257
+ if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
258
+ if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
259
+ },
260
+ addTransientObserver: function(node) {
261
+ if (node === this.target) return;
262
+ this.addListeners_(node);
263
+ this.transientObservedNodes.push(node);
264
+ var registrations = registrationsTable.get(node);
265
+ if (!registrations) registrationsTable.set(node, registrations = []);
266
+ registrations.push(this);
267
+ },
268
+ removeTransientObservers: function() {
269
+ var transientObservedNodes = this.transientObservedNodes;
270
+ this.transientObservedNodes = [];
271
+ transientObservedNodes.forEach(function(node) {
272
+ this.removeListeners_(node);
273
+ var registrations = registrationsTable.get(node);
274
+ for (var i = 0; i < registrations.length; i++) {
275
+ if (registrations[i] === this) {
276
+ registrations.splice(i, 1);
277
+ break;
278
+ }
279
+ }
280
+ }, this);
281
+ },
282
+ handleEvent: function(e) {
283
+ e.stopImmediatePropagation();
284
+ switch (e.type) {
285
+ case "DOMAttrModified":
286
+ var name = e.attrName;
287
+ var namespace = e.relatedNode.namespaceURI;
288
+ var target = e.target;
289
+ var record = new getRecord("attributes", target);
290
+ record.attributeName = name;
291
+ record.attributeNamespace = namespace;
292
+ var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
293
+ forEachAncestorAndObserverEnqueueRecord(target, function(options) {
294
+ if (!options.attributes) return;
295
+ if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
296
+ return;
297
+ }
298
+ if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
299
+ return record;
300
+ });
301
+ break;
302
+
303
+ case "DOMCharacterDataModified":
304
+ var target = e.target;
305
+ var record = getRecord("characterData", target);
306
+ var oldValue = e.prevValue;
307
+ forEachAncestorAndObserverEnqueueRecord(target, function(options) {
308
+ if (!options.characterData) return;
309
+ if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
310
+ return record;
311
+ });
312
+ break;
313
+
314
+ case "DOMNodeRemoved":
315
+ this.addTransientObserver(e.target);
316
+
317
+ case "DOMNodeInserted":
318
+ var changedNode = e.target;
319
+ var addedNodes, removedNodes;
320
+ if (e.type === "DOMNodeInserted") {
321
+ addedNodes = [ changedNode ];
322
+ removedNodes = [];
323
+ } else {
324
+ addedNodes = [];
325
+ removedNodes = [ changedNode ];
326
+ }
327
+ var previousSibling = changedNode.previousSibling;
328
+ var nextSibling = changedNode.nextSibling;
329
+ var record = getRecord("childList", e.target.parentNode);
330
+ record.addedNodes = addedNodes;
331
+ record.removedNodes = removedNodes;
332
+ record.previousSibling = previousSibling;
333
+ record.nextSibling = nextSibling;
334
+ forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
335
+ if (!options.childList) return;
336
+ return record;
337
+ });
338
+ }
339
+ clearRecords();
340
+ }
341
+ };
342
+ global.JsMutationObserver = JsMutationObserver;
343
+ if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
344
+ })(this);
345
+
346
+ window.CustomElements = window.CustomElements || {
347
+ flags: {}
348
+ };
349
+
350
+ (function(scope) {
351
+ var flags = scope.flags;
352
+ var modules = [];
353
+ var addModule = function(module) {
354
+ modules.push(module);
355
+ };
356
+ var initializeModules = function() {
357
+ modules.forEach(function(module) {
358
+ module(scope);
359
+ });
360
+ };
361
+ scope.addModule = addModule;
362
+ scope.initializeModules = initializeModules;
363
+ scope.hasNative = Boolean(document.registerElement);
364
+ scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || HTMLImports.useNative);
365
+ })(window.CustomElements);
366
+
367
+ window.CustomElements.addModule(function(scope) {
368
+ var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : "none";
369
+ function forSubtree(node, cb) {
370
+ findAllElements(node, function(e) {
371
+ if (cb(e)) {
372
+ return true;
373
+ }
374
+ forRoots(e, cb);
375
+ });
376
+ forRoots(node, cb);
377
+ }
378
+ function findAllElements(node, find, data) {
379
+ var e = node.firstElementChild;
380
+ if (!e) {
381
+ e = node.firstChild;
382
+ while (e && e.nodeType !== Node.ELEMENT_NODE) {
383
+ e = e.nextSibling;
384
+ }
385
+ }
386
+ while (e) {
387
+ if (find(e, data) !== true) {
388
+ findAllElements(e, find, data);
389
+ }
390
+ e = e.nextElementSibling;
391
+ }
392
+ return null;
393
+ }
394
+ function forRoots(node, cb) {
395
+ var root = node.shadowRoot;
396
+ while (root) {
397
+ forSubtree(root, cb);
398
+ root = root.olderShadowRoot;
399
+ }
400
+ }
401
+ function forDocumentTree(doc, cb) {
402
+ _forDocumentTree(doc, cb, []);
403
+ }
404
+ function _forDocumentTree(doc, cb, processingDocuments) {
405
+ doc = wrap(doc);
406
+ if (processingDocuments.indexOf(doc) >= 0) {
407
+ return;
408
+ }
409
+ processingDocuments.push(doc);
410
+ var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
411
+ for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
412
+ if (n.import) {
413
+ _forDocumentTree(n.import, cb, processingDocuments);
414
+ }
415
+ }
416
+ cb(doc);
417
+ }
418
+ scope.forDocumentTree = forDocumentTree;
419
+ scope.forSubtree = forSubtree;
420
+ });
421
+
422
+ window.CustomElements.addModule(function(scope) {
423
+ var flags = scope.flags;
424
+ var forSubtree = scope.forSubtree;
425
+ var forDocumentTree = scope.forDocumentTree;
426
+ function addedNode(node) {
427
+ return added(node) || addedSubtree(node);
428
+ }
429
+ function added(node) {
430
+ if (scope.upgrade(node)) {
431
+ return true;
432
+ }
433
+ attached(node);
434
+ }
435
+ function addedSubtree(node) {
436
+ forSubtree(node, function(e) {
437
+ if (added(e)) {
438
+ return true;
439
+ }
440
+ });
441
+ }
442
+ function attachedNode(node) {
443
+ attached(node);
444
+ if (inDocument(node)) {
445
+ forSubtree(node, function(e) {
446
+ attached(e);
447
+ });
448
+ }
449
+ }
450
+ var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver === window.JsMutationObserver;
451
+ scope.hasPolyfillMutations = hasPolyfillMutations;
452
+ var isPendingMutations = false;
453
+ var pendingMutations = [];
454
+ function deferMutation(fn) {
455
+ pendingMutations.push(fn);
456
+ if (!isPendingMutations) {
457
+ isPendingMutations = true;
458
+ setTimeout(takeMutations);
459
+ }
460
+ }
461
+ function takeMutations() {
462
+ isPendingMutations = false;
463
+ var $p = pendingMutations;
464
+ for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
465
+ p();
466
+ }
467
+ pendingMutations = [];
468
+ }
469
+ function attached(element) {
470
+ if (hasPolyfillMutations) {
471
+ deferMutation(function() {
472
+ _attached(element);
473
+ });
474
+ } else {
475
+ _attached(element);
476
+ }
477
+ }
478
+ function _attached(element) {
479
+ if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) {
480
+ if (!element.__attached && inDocument(element)) {
481
+ element.__attached = true;
482
+ if (element.attachedCallback) {
483
+ element.attachedCallback();
484
+ }
485
+ }
486
+ }
487
+ }
488
+ function detachedNode(node) {
489
+ detached(node);
490
+ forSubtree(node, function(e) {
491
+ detached(e);
492
+ });
493
+ }
494
+ function detached(element) {
495
+ if (hasPolyfillMutations) {
496
+ deferMutation(function() {
497
+ _detached(element);
498
+ });
499
+ } else {
500
+ _detached(element);
501
+ }
502
+ }
503
+ function _detached(element) {
504
+ if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) {
505
+ if (element.__attached && !inDocument(element)) {
506
+ element.__attached = false;
507
+ if (element.detachedCallback) {
508
+ element.detachedCallback();
509
+ }
510
+ }
511
+ }
512
+ }
513
+ function inDocument(element) {
514
+ var p = element;
515
+ var doc = wrap(document);
516
+ while (p) {
517
+ if (p == doc) {
518
+ return true;
519
+ }
520
+ p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
521
+ }
522
+ }
523
+ function watchShadow(node) {
524
+ if (node.shadowRoot && !node.shadowRoot.__watched) {
525
+ flags.dom && console.log("watching shadow-root for: ", node.localName);
526
+ var root = node.shadowRoot;
527
+ while (root) {
528
+ observe(root);
529
+ root = root.olderShadowRoot;
530
+ }
531
+ }
532
+ }
533
+ function handler(mutations) {
534
+ if (flags.dom) {
535
+ var mx = mutations[0];
536
+ if (mx && mx.type === "childList" && mx.addedNodes) {
537
+ if (mx.addedNodes) {
538
+ var d = mx.addedNodes[0];
539
+ while (d && d !== document && !d.host) {
540
+ d = d.parentNode;
541
+ }
542
+ var u = d && (d.URL || d._URL || d.host && d.host.localName) || "";
543
+ u = u.split("/?").shift().split("/").pop();
544
+ }
545
+ }
546
+ console.group("mutations (%d) [%s]", mutations.length, u || "");
547
+ }
548
+ mutations.forEach(function(mx) {
549
+ if (mx.type === "childList") {
550
+ forEach(mx.addedNodes, function(n) {
551
+ if (!n.localName) {
552
+ return;
553
+ }
554
+ addedNode(n);
555
+ });
556
+ forEach(mx.removedNodes, function(n) {
557
+ if (!n.localName) {
558
+ return;
559
+ }
560
+ detachedNode(n);
561
+ });
562
+ }
563
+ });
564
+ flags.dom && console.groupEnd();
565
+ }
566
+ function takeRecords(node) {
567
+ node = wrap(node);
568
+ if (!node) {
569
+ node = wrap(document);
570
+ }
571
+ while (node.parentNode) {
572
+ node = node.parentNode;
573
+ }
574
+ var observer = node.__observer;
575
+ if (observer) {
576
+ handler(observer.takeRecords());
577
+ takeMutations();
578
+ }
579
+ }
580
+ var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
581
+ function observe(inRoot) {
582
+ if (inRoot.__observer) {
583
+ return;
584
+ }
585
+ var observer = new MutationObserver(handler);
586
+ observer.observe(inRoot, {
587
+ childList: true,
588
+ subtree: true
589
+ });
590
+ inRoot.__observer = observer;
591
+ }
592
+ function upgradeDocument(doc) {
593
+ doc = wrap(doc);
594
+ flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
595
+ addedNode(doc);
596
+ observe(doc);
597
+ flags.dom && console.groupEnd();
598
+ }
599
+ function upgradeDocumentTree(doc) {
600
+ forDocumentTree(doc, upgradeDocument);
601
+ }
602
+ var originalCreateShadowRoot = Element.prototype.createShadowRoot;
603
+ if (originalCreateShadowRoot) {
604
+ Element.prototype.createShadowRoot = function() {
605
+ var root = originalCreateShadowRoot.call(this);
606
+ CustomElements.watchShadow(this);
607
+ return root;
608
+ };
609
+ }
610
+ scope.watchShadow = watchShadow;
611
+ scope.upgradeDocumentTree = upgradeDocumentTree;
612
+ scope.upgradeSubtree = addedSubtree;
613
+ scope.upgradeAll = addedNode;
614
+ scope.attachedNode = attachedNode;
615
+ scope.takeRecords = takeRecords;
616
+ });
617
+
618
+ window.CustomElements.addModule(function(scope) {
619
+ var flags = scope.flags;
620
+ function upgrade(node) {
621
+ if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
622
+ var is = node.getAttribute("is");
623
+ var definition = scope.getRegisteredDefinition(is || node.localName);
624
+ if (definition) {
625
+ if (is && definition.tag == node.localName) {
626
+ return upgradeWithDefinition(node, definition);
627
+ } else if (!is && !definition.extends) {
628
+ return upgradeWithDefinition(node, definition);
629
+ }
630
+ }
631
+ }
632
+ }
633
+ function upgradeWithDefinition(element, definition) {
634
+ flags.upgrade && console.group("upgrade:", element.localName);
635
+ if (definition.is) {
636
+ element.setAttribute("is", definition.is);
637
+ }
638
+ implementPrototype(element, definition);
639
+ element.__upgraded__ = true;
640
+ created(element);
641
+ scope.attachedNode(element);
642
+ scope.upgradeSubtree(element);
643
+ flags.upgrade && console.groupEnd();
644
+ return element;
645
+ }
646
+ function implementPrototype(element, definition) {
647
+ if (Object.__proto__) {
648
+ element.__proto__ = definition.prototype;
649
+ } else {
650
+ customMixin(element, definition.prototype, definition.native);
651
+ element.__proto__ = definition.prototype;
652
+ }
653
+ }
654
+ function customMixin(inTarget, inSrc, inNative) {
655
+ var used = {};
656
+ var p = inSrc;
657
+ while (p !== inNative && p !== HTMLElement.prototype) {
658
+ var keys = Object.getOwnPropertyNames(p);
659
+ for (var i = 0, k; k = keys[i]; i++) {
660
+ if (!used[k]) {
661
+ Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k));
662
+ used[k] = 1;
663
+ }
664
+ }
665
+ p = Object.getPrototypeOf(p);
666
+ }
667
+ }
668
+ function created(element) {
669
+ if (element.createdCallback) {
670
+ element.createdCallback();
671
+ }
672
+ }
673
+ scope.upgrade = upgrade;
674
+ scope.upgradeWithDefinition = upgradeWithDefinition;
675
+ scope.implementPrototype = implementPrototype;
676
+ });
677
+
678
+ window.CustomElements.addModule(function(scope) {
679
+ var isIE11OrOlder = scope.isIE11OrOlder;
680
+ var upgradeDocumentTree = scope.upgradeDocumentTree;
681
+ var upgradeAll = scope.upgradeAll;
682
+ var upgradeWithDefinition = scope.upgradeWithDefinition;
683
+ var implementPrototype = scope.implementPrototype;
684
+ var useNative = scope.useNative;
685
+ function register(name, options) {
686
+ var definition = options || {};
687
+ if (!name) {
688
+ throw new Error("document.registerElement: first argument `name` must not be empty");
689
+ }
690
+ if (name.indexOf("-") < 0) {
691
+ throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'.");
692
+ }
693
+ if (isReservedTag(name)) {
694
+ throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid.");
695
+ }
696
+ if (getRegisteredDefinition(name)) {
697
+ throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered");
698
+ }
699
+ if (!definition.prototype) {
700
+ definition.prototype = Object.create(HTMLElement.prototype);
701
+ }
702
+ definition.__name = name.toLowerCase();
703
+ definition.lifecycle = definition.lifecycle || {};
704
+ definition.ancestry = ancestry(definition.extends);
705
+ resolveTagName(definition);
706
+ resolvePrototypeChain(definition);
707
+ overrideAttributeApi(definition.prototype);
708
+ registerDefinition(definition.__name, definition);
709
+ definition.ctor = generateConstructor(definition);
710
+ definition.ctor.prototype = definition.prototype;
711
+ definition.prototype.constructor = definition.ctor;
712
+ if (scope.ready) {
713
+ upgradeDocumentTree(document);
714
+ }
715
+ return definition.ctor;
716
+ }
717
+ function overrideAttributeApi(prototype) {
718
+ if (prototype.setAttribute._polyfilled) {
719
+ return;
720
+ }
721
+ var setAttribute = prototype.setAttribute;
722
+ prototype.setAttribute = function(name, value) {
723
+ changeAttribute.call(this, name, value, setAttribute);
724
+ };
725
+ var removeAttribute = prototype.removeAttribute;
726
+ prototype.removeAttribute = function(name) {
727
+ changeAttribute.call(this, name, null, removeAttribute);
728
+ };
729
+ prototype.setAttribute._polyfilled = true;
730
+ }
731
+ function changeAttribute(name, value, operation) {
732
+ name = name.toLowerCase();
733
+ var oldValue = this.getAttribute(name);
734
+ operation.apply(this, arguments);
735
+ var newValue = this.getAttribute(name);
736
+ if (this.attributeChangedCallback && newValue !== oldValue) {
737
+ this.attributeChangedCallback(name, oldValue, newValue);
738
+ }
739
+ }
740
+ function isReservedTag(name) {
741
+ for (var i = 0; i < reservedTagList.length; i++) {
742
+ if (name === reservedTagList[i]) {
743
+ return true;
744
+ }
745
+ }
746
+ }
747
+ var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ];
748
+ function ancestry(extnds) {
749
+ var extendee = getRegisteredDefinition(extnds);
750
+ if (extendee) {
751
+ return ancestry(extendee.extends).concat([ extendee ]);
752
+ }
753
+ return [];
754
+ }
755
+ function resolveTagName(definition) {
756
+ var baseTag = definition.extends;
757
+ for (var i = 0, a; a = definition.ancestry[i]; i++) {
758
+ baseTag = a.is && a.tag;
759
+ }
760
+ definition.tag = baseTag || definition.__name;
761
+ if (baseTag) {
762
+ definition.is = definition.__name;
763
+ }
764
+ }
765
+ function resolvePrototypeChain(definition) {
766
+ if (!Object.__proto__) {
767
+ var nativePrototype = HTMLElement.prototype;
768
+ if (definition.is) {
769
+ var inst = document.createElement(definition.tag);
770
+ var expectedPrototype = Object.getPrototypeOf(inst);
771
+ if (expectedPrototype === definition.prototype) {
772
+ nativePrototype = expectedPrototype;
773
+ }
774
+ }
775
+ var proto = definition.prototype, ancestor;
776
+ while (proto && proto !== nativePrototype) {
777
+ ancestor = Object.getPrototypeOf(proto);
778
+ proto.__proto__ = ancestor;
779
+ proto = ancestor;
780
+ }
781
+ definition.native = nativePrototype;
782
+ }
783
+ }
784
+ function instantiate(definition) {
785
+ return upgradeWithDefinition(domCreateElement(definition.tag), definition);
786
+ }
787
+ var registry = {};
788
+ function getRegisteredDefinition(name) {
789
+ if (name) {
790
+ return registry[name.toLowerCase()];
791
+ }
792
+ }
793
+ function registerDefinition(name, definition) {
794
+ registry[name] = definition;
795
+ }
796
+ function generateConstructor(definition) {
797
+ return function() {
798
+ return instantiate(definition);
799
+ };
800
+ }
801
+ var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
802
+ function createElementNS(namespace, tag, typeExtension) {
803
+ if (namespace === HTML_NAMESPACE) {
804
+ return createElement(tag, typeExtension);
805
+ } else {
806
+ return domCreateElementNS(namespace, tag);
807
+ }
808
+ }
809
+ function createElement(tag, typeExtension) {
810
+ if (tag) {
811
+ tag = tag.toLowerCase();
812
+ }
813
+ if (typeExtension) {
814
+ typeExtension = typeExtension.toLowerCase();
815
+ }
816
+ var definition = getRegisteredDefinition(typeExtension || tag);
817
+ if (definition) {
818
+ if (tag == definition.tag && typeExtension == definition.is) {
819
+ return new definition.ctor();
820
+ }
821
+ if (!typeExtension && !definition.is) {
822
+ return new definition.ctor();
823
+ }
824
+ }
825
+ var element;
826
+ if (typeExtension) {
827
+ element = createElement(tag);
828
+ element.setAttribute("is", typeExtension);
829
+ return element;
830
+ }
831
+ element = domCreateElement(tag);
832
+ if (tag.indexOf("-") >= 0) {
833
+ implementPrototype(element, HTMLElement);
834
+ }
835
+ return element;
836
+ }
837
+ var domCreateElement = document.createElement.bind(document);
838
+ var domCreateElementNS = document.createElementNS.bind(document);
839
+ var isInstance;
840
+ if (!Object.__proto__ && !useNative) {
841
+ isInstance = function(obj, ctor) {
842
+ var p = obj;
843
+ while (p) {
844
+ if (p === ctor.prototype) {
845
+ return true;
846
+ }
847
+ p = p.__proto__;
848
+ }
849
+ return false;
850
+ };
851
+ } else {
852
+ isInstance = function(obj, base) {
853
+ return obj instanceof base;
854
+ };
855
+ }
856
+ function wrapDomMethodToForceUpgrade(obj, methodName) {
857
+ var orig = obj[methodName];
858
+ obj[methodName] = function() {
859
+ var n = orig.apply(this, arguments);
860
+ upgradeAll(n);
861
+ return n;
862
+ };
863
+ }
864
+ wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
865
+ wrapDomMethodToForceUpgrade(document, "importNode");
866
+ if (isIE11OrOlder) {
867
+ (function() {
868
+ var importNode = document.importNode;
869
+ document.importNode = function() {
870
+ var n = importNode.apply(document, arguments);
871
+ if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) {
872
+ var f = document.createDocumentFragment();
873
+ f.appendChild(n);
874
+ return f;
875
+ } else {
876
+ return n;
877
+ }
878
+ };
879
+ })();
880
+ }
881
+ document.registerElement = register;
882
+ document.createElement = createElement;
883
+ document.createElementNS = createElementNS;
884
+ scope.registry = registry;
885
+ scope.instanceof = isInstance;
886
+ scope.reservedTagList = reservedTagList;
887
+ scope.getRegisteredDefinition = getRegisteredDefinition;
888
+ document.register = document.registerElement;
889
+ });
890
+
891
+ (function(scope) {
892
+ var useNative = scope.useNative;
893
+ var initializeModules = scope.initializeModules;
894
+ var isIE11OrOlder = /Trident/.test(navigator.userAgent);
895
+ if (useNative) {
896
+ var nop = function() {};
897
+ scope.watchShadow = nop;
898
+ scope.upgrade = nop;
899
+ scope.upgradeAll = nop;
900
+ scope.upgradeDocumentTree = nop;
901
+ scope.upgradeSubtree = nop;
902
+ scope.takeRecords = nop;
903
+ scope.instanceof = function(obj, base) {
904
+ return obj instanceof base;
905
+ };
906
+ } else {
907
+ initializeModules();
908
+ }
909
+ var upgradeDocumentTree = scope.upgradeDocumentTree;
910
+ if (!window.wrap) {
911
+ if (window.ShadowDOMPolyfill) {
912
+ window.wrap = ShadowDOMPolyfill.wrapIfNeeded;
913
+ window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;
914
+ } else {
915
+ window.wrap = window.unwrap = function(node) {
916
+ return node;
917
+ };
918
+ }
919
+ }
920
+ function bootstrap() {
921
+ upgradeDocumentTree(wrap(document));
922
+ if (window.HTMLImports) {
923
+ HTMLImports.__importsParsingHook = function(elt) {
924
+ upgradeDocumentTree(wrap(elt.import));
925
+ };
926
+ }
927
+ CustomElements.ready = true;
928
+ setTimeout(function() {
929
+ CustomElements.readyTime = Date.now();
930
+ if (window.HTMLImports) {
931
+ CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;
932
+ }
933
+ document.dispatchEvent(new CustomEvent("WebComponentsReady", {
934
+ bubbles: true
935
+ }));
936
+ });
937
+ }
938
+ if (isIE11OrOlder && typeof window.CustomEvent !== "function") {
939
+ window.CustomEvent = function(inType, params) {
940
+ params = params || {};
941
+ var e = document.createEvent("CustomEvent");
942
+ e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
943
+ return e;
944
+ };
945
+ window.CustomEvent.prototype = window.Event.prototype;
946
+ }
947
+ if (document.readyState === "complete" || scope.flags.eager) {
948
+ bootstrap();
949
+ } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
950
+ bootstrap();
951
+ } else {
952
+ var loadEvent = window.HTMLImports && !HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
953
+ window.addEventListener(loadEvent, bootstrap);
954
+ }
955
+ scope.isIE11OrOlder = isIE11OrOlder;
956
+ })(window.CustomElements);