Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*! rasterizeHTML.js - v1.2.2 - 2016-09-06
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2016 Christoph Burgmer; Licensed MIT */
/* Integrated dependencies:
* url (MIT License),
* css-mediaquery (BSD License),
* CSSOM.js (MIT License),
* ayepromise (BSD License & WTFPL),
* xmlserializer (MIT License),
* sane-domparser-error (BSD License),
* css-font-face-src (BSD License),
* inlineresources (MIT License) */
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.rasterizeHTML=a()}}(function(){var a;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(b,c,d){!function(e,f){"function"==typeof a&&a.amd?a(["url","css-mediaquery","xmlserializer","sane-domparser-error","ayepromise","inlineresources"],function(a,b,c,d,g,h){return e.rasterizeHTML=f(a,b,c,d,g,h)}):"object"==typeof d?c.exports=f(b("url"),b("css-mediaquery"),b("xmlserializer"),b("sane-domparser-error"),b("ayepromise"),b("inlineresources")):e.rasterizeHTML=f(url,cssMediaQuery,xmlserializer,sanedomparsererror,ayepromise,inlineresources)}(this,function(a,b,c,d,e,f){var g=function(a){"use strict";var b={},c=[];b.joinUrl=function(b,c){return b?a.resolve(b,c):c},b.getConstantUniqueIdFor=function(a){return c.indexOf(a)<0&&c.push(a),c.indexOf(a)},b.clone=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c};var d=function(a){return"object"==typeof a&&null!==a},e=function(a){return d(a)&&Object.prototype.toString.apply(a).match(/\[object (Canvas|HTMLCanvasElement)\]/i)};return b.parseOptionalParameters=function(a){var c={canvas:null,options:{}};return null==a[0]||e(a[0])?(c.canvas=a[0]||null,c.options=b.clone(a[1])):c.options=b.clone(a[0]),c},b}(a),h=function(a,b){"use strict";var c={},d=function(a,b,c){var d=a[b];return a[b]=function(){var a=Array.prototype.slice.call(arguments);return c.apply(this,[a,d])},d};return c.baseUrlRespectingXhr=function(b,c){var e=function(){var e=new b;return d(e,"open",function(b,d){var e=b.shift(),f=b.shift(),g=a.joinUrl(c,f);return d.apply(this,[e,g].concat(b))}),e};return e},c.finishNotifyingXhr=function(a){var c=0,e=0,f=!1,g=b.defer(),h=function(){var a=c-e;a<=0&&f&&g.resolve({totalCount:c})},i=function(){var b=new a;return d(b,"send",function(a,b){return c+=1,b.apply(this,arguments)}),b.addEventListener("load",function(){e+=1,h()}),b};return i.waitForRequestsToFinish=function(){return f=!0,h(),g.promise},i},c}(g,e),i=function(){"use strict";var a={},b=function(a){return Array.prototype.slice.call(a)};a.addClassName=function(a,b){a.className+=" "+b},a.addClassNameRecursively=function(b,c){a.addClassName(b,c),b.parentNode!==b.ownerDocument&&a.addClassNameRecursively(b.parentNode,c)};var c=function(a,c){var d=a.parentStyleSheet,e=b(d.cssRules).indexOf(a);d.insertRule(c,e+1),d.deleteRule(e)},d=function(a,b){var d=a.cssText.replace(/^[^\{]+/,""),e=b+" "+d;c(a,e)},e=function(a){return b(a).reduce(function(a,b){return a+b.cssText},"")},f=function(a){a.textContent=e(a.sheet.cssRules)},g=function(a){return"((?:^|[^.#:\\w])|(?=\\W))("+a.join("|")+")(?=\\W|$)"},h=function(a,c,e){var h=g(c);b(a.querySelectorAll("style")).forEach(function(a){var c=b(a.sheet.cssRules).filter(function(a){return a.selectorText&&new RegExp(h,"i").test(a.selectorText)});c.length&&(c.forEach(function(a){var b=a.selectorText.replace(new RegExp(h,"gi"),function(a,b,c){return b+e(c)});b!==a.selectorText&&d(a,b)}),f(a))})};return a.rewriteCssSelectorWith=function(a,b,c){h(a,[b],function(){return c})},a.lowercaseCssTypeSelectors=function(a,b){h(a,b,function(a){return a.toLowerCase()})},a.findHtmlOnlyNodeNames=function(a){var b,c=a.ownerDocument.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),d={},e={};do b=c.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===c.currentNode.namespaceURI?d[b]=!0:e[b]=!0;while(c.nextNode());return Object.keys(d).filter(function(a){return!e[a]})},a}(),j=function(a){"use strict";var b={},c=function(a){return Array.prototype.slice.call(a)},d={active:!0,hover:!0,focus:!1,target:!1};return b.fakeUserAction=function(b,c,e){var f=b.querySelector(c),g=":"+e,h="rasterizehtml"+e;f&&(d[e]?a.addClassNameRecursively(f,h):a.addClassName(f,h),a.rewriteCssSelectorWith(b,g,"."+h))},b.persistInputValues=function(a){var b=a.querySelectorAll("input"),d=a.querySelectorAll("textarea"),e=function(a){return"checkbox"===a.type||"radio"===a.type};c(b).filter(e).forEach(function(a){a.checked?a.setAttribute("checked",""):a.removeAttribute("checked")}),c(b).filter(function(a){return!e(a)}).forEach(function(a){a.setAttribute("value",a.value)}),c(d).forEach(function(a){a.textContent=a.value})},b.rewriteTagNameSelectorsToLowerCase=function(b){a.lowercaseCssTypeSelectors(b,a.findHtmlOnlyNodeNames(b))},b}(i),k=function(a){"use strict";var b,c={},d=function(){var a='<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="10" height="10"><style>@media (max-width: 1em) { svg { background: #00f; } }</style></svg>',b="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(a),c=document.createElement("img");return c.src=b,c},f=function(a,b,c,d){var e=document.createElement("canvas");e.width=a.width,e.height=a.height;var f,g=e.getContext("2d");return g.drawImage(a,0,0),f=g.getImageData(0,0,1,1).data,f[0]===b&&f[1]===c&&f[2]===d},g=function(){var a=d(),b=e.defer();return document.querySelector("body").appendChild(a),a.onload=function(){document.querySelector("body").removeChild(a);try{b.resolve(!f(a,0,0,255))}catch(a){b.resolve(!0)}},a.onerror=function(){b.reject()},b.promise};c.needsEmWorkaround=function(){return void 0===b&&(b=g()),b};var h=function(a){return Array.prototype.slice.call(a)},i=function(a){return h(a).map(function(a){return a.cssText}).join("\n")},j=function(a,b){return"@media "+a+"{"+i(b)+"}"},k=function(a,b,c){try{a.insertRule(c,b+1)}catch(a){return}a.deleteRule(b)},l=function(a,b){var c=a.parentStyleSheet,d=h(c.cssRules).indexOf(a);k(c,d,b)},m=function(a){a.textContent=i(a.sheet.cssRules)},n=function(a){var b=a.modifier?a.modifier+"-"+a.feature:a.feature;return a.value?"("+b+": "+a.value+")":"("+b+")"},o=function(a){var b=[];return a.inverse&&b.push("not"),b.push(a.type),a.expressions.length>0&&b.push("and "+a.expressions.map(n).join(" and ")),b.join(" ")};c.serializeQuery=function(a){var b=a.map(o);return b.join(", ")};var p=function(a){return 16*a},q=function(a){var b=/^((?:\d+\.)?\d+)em/.exec(a);return b?p(parseFloat(b[1]))+"px":a},r=function(b){var d=a.parse(b),e=!1;if(d.forEach(function(a){a.expressions.forEach(function(a){var b=q(a.value);e|=b!==a.value,a.value=b})}),e)return c.serializeQuery(d)},s=function(a){var b=!1;return a.forEach(function(a){var c=r(a.media.mediaText);c&&l(a,j(c,a.cssRules)),b|=!!c}),b};return c.workAroundWebKitEmSizeIssue=function(a){var b=a.querySelectorAll("style");h(b).forEach(function(a){var b=h(a.sheet.cssRules).filter(function(a){return a.type===window.CSSRule.MEDIA_RULE}),c=s(b);c&&m(a)})},c}(b),l=function(a,b,c,d,e){"use strict";var f={},g=function(a,b,c,d){var e=a.createElement(b);return e.style.visibility="hidden",e.style.width=c+"px",e.style.height=d+"px",e.style.position="absolute",e.style.top=-1e4-d+"px",e.style.left=-1e4-c+"px",a.getElementsByTagName("body")[0].appendChild(e),e};f.executeJavascript=function(a,d){var f=g(e.document,"iframe",d.width,d.height),h=a.outerHTML,i=[],j=c.defer(),k=d.executeJsTimeout||0,l=function(){var a=f.contentDocument;e.document.getElementsByTagName("body")[0].removeChild(f),j.resolve({document:a,errors:i})},m=function(){var a=c.defer();return k>0?setTimeout(a.resolve,k):a.resolve(),a.promise},n=f.contentWindow.XMLHttpRequest,o=b.finishNotifyingXhr(n),p=b.baseUrlRespectingXhr(o,d.baseUrl);return f.onload=function(){m().then(o.waitForRequestsToFinish).then(l)},f.contentDocument.open(),f.contentWindow.XMLHttpRequest=p,f.contentWindow.onerror=function(a){i.push({resourceType:"scriptExecution",msg:a})},f.contentDocument.write("<!DOCTYPE html>"),f.contentDocument.write(h),f.contentDocument.close(),j.promise};var h=function(a,b,c){var d=a.createElement("iframe");return d.style.width=b+"px",d.style.height=c+"px",d.style.visibility="hidden",d.style.position="absolute",d.style.top=-1e4-c+"px",d.style.left=-1e4-b+"px",d.sandbox="allow-same-origin",d.scrolling="no",d},i=function(a,b,c){var d=Math.floor(a/c),f=Math.floor(b/c);return h(e.document,d,f)},j=function(a,b,c,d){return{width:Math.max(a.width*d,b),height:Math.max(a.height*d,c)}},k=function(a,b){var c=a.querySelector(b);if(c)return c;if(a.ownerDocument.querySelector(b)===a)return a;throw{message:"Clipping selector not found"}},l=function(a,b,c,d,f){var g,h,i,l,m,n,o,p,q=Math.max(a.scrollWidth,a.clientWidth),r=Math.max(a.scrollHeight,a.clientHeight);return b?(n=k(a,b),o=n.getBoundingClientRect(),g=o.top,h=o.left,i=o.width,l=o.height):(g=0,h=0,i=q,l=r),p=j({width:i,height:l},c,d,f),m=e.getComputedStyle(a.ownerDocument.documentElement).fontSize,{left:h,top:g,width:p.width,height:p.height,viewportWidth:q,viewportHeight:r,rootFontSize:m}},m=function(a,b){var c=a.tagName;return b.querySelector(c)},n=function(a){var b=a.tagName.toLowerCase();return"html"===b||"body"===b?a.outerHTML:'<body style="margin: 0;">'+a.outerHTML+"</body>"};f.calculateDocumentContentSize=function(a,b){var d,f=c.defer(),g=b.zoom||1;return d=i(b.width,b.height,g),e.document.getElementsByTagName("body")[0].appendChild(d),d.onload=function(){var c,h=d.contentDocument;try{c=l(m(a,h),b.clip,b.width,b.height,g),f.resolve(c)}catch(a){f.reject(a)}finally{e.document.getElementsByTagName("body")[0].removeChild(d)}},d.contentDocument.open(),d.contentDocument.write("<!DOCTYPE html>"),d.contentDocument.write(n(a)),d.contentDocument.close(),f.promise},f.parseHtmlFragment=function(a){var b=e.document.implementation.createHTMLDocument("");b.documentElement.innerHTML=a;var c=b.querySelector("body").firstChild;if(!c)throw"Invalid source";return c};var o=function(a,b){var c,d,f,g,h=/<html((?:\s+[^>]*)?)>/im.exec(b),i=e.document.implementation.createHTMLDocument("");if(h)for(c="<div"+h[1]+"></div>",i.documentElement.innerHTML=c,f=i.querySelector("div"),d=0;d<f.attributes.length;d++)g=f.attributes[d],a.documentElement.setAttribute(g.name,g.value)};f.parseHTML=function(a){var b=e.document.implementation.createHTMLDocument("");return b.documentElement.innerHTML=a,o(b,a),b};var p=function(a){try{return d.failOnParseError(a)}catch(a){throw{message:"Invalid source",originalError:a}}};f.validateXHTML=function(a){var b=new DOMParser,c=b.parseFromString(a,"application/xml");p(c)};var q=null,r=function(a,b){return"none"===b||"repeated"===b?(null!==q&&"repeated"===b||(q=Date.now()),a+"?_="+q):a},s=function(b,d){var e=new window.XMLHttpRequest,f=a.joinUrl(d.baseUrl,b),g=r(f,d.cache),h=c.defer(),i=function(a){h.reject({message:"Unable to load page",originalError:a})};e.addEventListener("load",function(){200===e.status||0===e.status?h.resolve(e.responseXML):i(e.statusText)},!1),e.addEventListener("error",function(a){i(a)},!1);try{e.open("GET",g,!0),e.responseType="document",e.send(null)}catch(a){i(a)}return h.promise};return f.loadDocument=function(a,b){return s(a,b).then(function(a){return p(a)})},f}(g,h,e,d,window),m=function(a,b){"use strict";var c,d={},e=function(a,b){return b?URL.createObjectURL(new Blob([a],{type:"image/svg+xml"})):"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(a)},f=function(a){a instanceof Blob&&URL.revokeObjectURL(a)},g='<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"><foreignObject></foreignObject></svg>',h=function(b){var c=document.createElement("canvas"),d=new Image,e=a.defer();return d.onload=function(){var a=c.getContext("2d");try{a.drawImage(d,0,0),c.toDataURL("image/png"),e.resolve(!0)}catch(a){e.resolve(!1)}},d.onerror=e.reject,d.src=b,e.promise},i=function(){var a=e(g,!0);return h(a).then(function(b){return f(a),!b&&h(e(g,!1)).then(function(a){return a})},function(){return!1})},j=function(){if(b.Blob)try{return new Blob(["<b></b>"],{type:"text/xml"}),!0}catch(a){}return!1},k=function(){var c=a.defer();return j&&b.URL?i().then(function(a){c.resolve(!a)},function(){c.reject()}):c.resolve(!1),c.promise},l=function(){return void 0===c&&(c=k()),c},m=function(a){return l().then(function(b){return e(a,b)})};return d.renderSvg=function(b){var c,d,e=a.defer(),g=function(){d.onload=null,d.onerror=null},h=function(){c&&f(c)};return d=new Image,d.onload=function(){g(),h(),e.resolve(d)},d.onerror=function(){h(),e.reject()},m(b).then(function(a){c=a,d.src=c},e.reject),e.promise},d}(e,window),n=function(a,b,c,d,e){"use strict";var f={},g=function(a,b){var c=b||1,d={width:a.width,height:a.height,"font-size":a.rootFontSize};return 1!==c&&(d.style="transform:scale("+c+"); transform-origin: 0 0;"),d},h=function(a){var b,c,d,e;b=Math.round(a.viewportWidth),c=Math.round(a.viewportHeight),d=-a.left,e=-a.top;var f={x:d,y:e,width:b,height:c};return f},i=function(a){var b=a.style||"";a.style=b+"float: left;"},j=function(a){a.externalResourcesRequired=!0},k=function(){return'<style scoped="">html::-webkit-scrollbar { display: none; }</style>'},l=function(a){var b=Object.keys(a);return b.length?" "+b.map(function(b){return b+'="'+a[b]+'"'}).join(" "):""},m=function(a,c,d){var f=e.serializeToString(a);b.validateXHTML(f);var m=h(c);return i(m),j(m),'<svg xmlns="http://www.w3.org/2000/svg"'+l(g(c,d))+">"+k()+"<foreignObject"+l(m)+">"+f+"</foreignObject></svg>"};return f.getSvgForDocument=function(a,b,e){return c.rewriteTagNameSelectorsToLowerCase(a),d.needsEmWorkaround().then(function(c){return c&&d.workAroundWebKitEmSizeIssue(a),m(a,b,e)})},f.drawDocumentAsSvg=function(a,d){return["hover","active","focus","target"].forEach(function(b){d[b]&&c.fakeUserAction(a,d[b],b)}),b.calculateDocumentContentSize(a,d).then(function(b){return f.getSvgForDocument(a,b,d.zoom)})},f}(g,l,j,k,c),o=function(a,b,c,d,e,f){"use strict";var g={},h=function(a){return{message:"Error rendering page",originalError:a}},i=function(a){return e.renderSvg(a).then(function(b){return{image:b,svg:a}},function(a){throw h(a)})},j=function(a,b){try{b.getContext("2d").drawImage(a,0,0)}catch(a){throw h(a)}},k=function(a,b,c){return d.drawDocumentAsSvg(a,c).then(i).then(function(a){return b&&j(a.image,b),a})},l=function(a,d){return b.executeJavascript(a,d).then(function(a){var b=a.document;return c.persistInputValues(b),{document:b,errors:a.errors}})};return g.rasterize=function(b,c,d){var e;return e=a.clone(d),e.inlineScripts=d.executeJs===!0,f.inlineReferences(b,e).then(function(a){return d.executeJs?l(b,d).then(function(b){return{element:b.document.documentElement,errors:a.concat(b.errors)}}):{element:b,errors:a}}).then(function(a){return k(a.element,c,d).then(function(b){return{image:b.image,svg:b.svg,errors:a.errors}})})},g}(g,l,j,n,m,f),p=function(a,b,c){"use strict";var d={},e=function(a,b){var c=300,d=200,e=a?a.width:c,f=a?a.height:d,g=void 0!==b.width?b.width:e,h=void 0!==b.height?b.height:f;return{width:g,height:h}},f=function(b){var c,d=e(b.canvas,b.options);return c=a.clone(b.options),c.width=d.width,c.height=d.height,c};d.drawDocument=function(){var b=arguments[0],d=Array.prototype.slice.call(arguments,1),e=a.parseOptionalParameters(d),g=b.documentElement?b.documentElement:b;return c.rasterize(g,e.canvas,f(e))};var g=function(a,c,e){var f=b.parseHtmlFragment(a);return d.drawDocument(f,c,e)};d.drawHtmlFragment=function(){var b=arguments[0],c=Array.prototype.slice.call(arguments,1),d=a.parseOptionalParameters(c);return g(b,d.canvas,d.options)};var h=function(a,c,e){var f=b.parseHTML(a);return d.drawDocument(f,c,e)};d.drawHTML=function(){var b=arguments[0],c=Array.prototype.slice.call(arguments,1),d=a.parseOptionalParameters(c);return h(b,d.canvas,d.options)};var i=function(b,c,d){var e=document.implementation.createHTMLDocument("");e.replaceChild(b.documentElement,e.documentElement);var f=d?a.clone(d):{};return d.baseUrl||(f.baseUrl=c),{document:e,options:f}},j=function(a,c,e){return b.loadDocument(a,e).then(function(b){var f=i(b,a,e);return d.drawDocument(f.document,c,f.options)})};return d.drawURL=function(){var b=arguments[0],c=Array.prototype.slice.call(arguments,1),d=a.parseOptionalParameters(c);return j(b,d.canvas,d.options)},d}(g,l,o);return p})},{ayepromise:2,"css-mediaquery":8,inlineresources:29,"sane-domparser-error":38,url:3,xmlserializer:39}],2:[function(b,c,d){!function(b,e){"function"==typeof a&&a.amd?a(e):"object"==typeof d?c.exports=e():b.ayepromise=e()}(this,function(){"use strict";var a={},b=function(){var a=!1;return function(b){return function(){a||(a=!0,b.apply(null,arguments))}}},c=function(a){var b=a&&a.then;if("object"==typeof a&&"function"==typeof b)return function(){return b.apply(a,arguments)}},d=function(b,c){var d=a.defer(),e=function(a,b){setTimeout(function(){var c;try{c=a(b)}catch(a){return void d.reject(a)}c===d.promise?d.reject(new TypeError("Cannot resolve promise with itself")):d.resolve(c)},1)},g=function(a){b&&b.call?e(b,a):d.resolve(a)},h=function(a){c&&c.call?e(c,a):d.reject(a)};return{promise:d.promise,handle:function(a,b){a===f?g(b):h(b)}}},e=0,f=1,g=2;return a.defer=function(){var a,h=e,i=[],j=function(b,c){h=b,a=c,i.forEach(function(b){b.handle(h,a)}),i=null},k=function(a){j(f,a)},l=function(a){j(g,a)},m=function(b,c){var f=d(b,c);return h===e?i.push(f):f.handle(h,a),f.promise},n=function(a){var c=b();try{a(c(o),c(l))}catch(a){c(l)(a)}},o=function(a){var b;try{b=c(a)}catch(a){return void l(a)}b?n(b):k(a)},p=b();return{resolve:p(o),reject:p(l),promise:{then:m,fail:function(a){return m(null,a)}}}},a})},{}],3:[function(a,b,c){"use strict";function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j.isObject(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return j.isString(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}var i=a("punycode"),j=a("./util");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var k=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,m=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,n=["<",">",'"',"`"," ","\r","\n","\t"],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[+a-z0-9A-Z_-]{0,63}$/,u=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a.indexOf("?"),e=d!==-1&&d<a.indexOf("#")?"?":"#",f=a.split(e),g=/\\/g;f[0]=f[0].replace(g,"/"),a=f.join(e);var h=a;if(h=h.trim(),!c&&1===a.split("#").length){var l=m.exec(h);if(l)return this.path=h,this.href=h,this.pathname=l[1],l[2]?(this.search=l[2],b?this.query=y.parse(this.search.substr(1)):this.query=this.search.substr(1)):b&&(this.search="",this.query={}),this}var n=k.exec(h);if(n){n=n[0];var o=n.toLowerCase();this.protocol=o,h=h.substr(n.length)}if(c||n||h.match(/^\/\/[^@\/]+@[^@\/]+/)){var z="//"===h.substr(0,2);!z||n&&w[n]||(h=h.substr(2),this.slashes=!0)}if(!w[n]&&(z||n&&!x[n])){for(var A=-1,B=0;B<r.length;B++){var C=h.indexOf(r[B]);C!==-1&&(A===-1||C<A)&&(A=C)}var D,E;E=A===-1?h.lastIndexOf("@"):h.lastIndexOf("@",A),E!==-1&&(D=h.slice(0,E),h=h.slice(E+1),this.auth=decodeURIComponent(D)),A=-1;for(var B=0;B<q.length;B++){var C=h.indexOf(q[B]);C!==-1&&(A===-1||C<A)&&(A=C)}A===-1&&(A=h.length),this.host=h.slice(0,A),h=h.slice(A),this.parseHost(),this.hostname=this.hostname||"";var F="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!F)for(var G=this.hostname.split(/\./),B=0,H=G.length;B<H;B++){var I=G[B];if(I&&!I.match(t)){for(var J="",K=0,L=I.length;K<L;K++)J+=I.charCodeAt(K)>127?"x":I[K];if(!J.match(t)){var M=G.slice(0,B),N=G.slice(B+1),O=I.match(u);O&&(M.push(O[1]),N.unshift(O[2])),N.length&&(h="/"+N.join(".")+h),this.hostname=M.join(".");break}}}this.hostname.length>s?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=i.toASCII(this.hostname));var P=this.port?":"+this.port:"",Q=this.hostname||"";this.host=Q+P,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==h[0]&&(h="/"+h))}if(!v[o])for(var B=0,H=p.length;B<H;B++){var R=p[B];if(h.indexOf(R)!==-1){var S=encodeURIComponent(R);S===R&&(S=escape(R)),h=h.split(R).join(S)}}var T=h.indexOf("#");T!==-1&&(this.hash=h.substr(T),h=h.slice(0,T));var U=h.indexOf("?");if(U!==-1?(this.search=h.substr(U),this.query=h.substr(U+1),b&&(this.query=y.parse(this.query)),h=h.slice(0,U)):b&&(this.search="",this.query={}),h&&(this.pathname=h),x[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",V=this.search||"";this.path=P+V}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&Object.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==b.substr(-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}for(var c=new d,e=Object.keys(this),f=0;f<e.length;f++){var g=e[f];c[g]=this[g]}if(c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol){for(var h=Object.keys(a),i=0;i<h.length;i++){var k=h[i];"protocol"!==k&&(c[k]=a[k])}return x[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c}if(a.protocol&&a.protocol!==c.protocol){if(!x[a.protocol]){for(var l=Object.keys(a),m=0;m<l.length;m++){var n=l[m];c[n]=a[n]}return c.href=c.format(),c}if(c.protocol=a.protocol,a.host||w[a.protocol])c.pathname=a.pathname;else{for(var o=(a.pathname||"").split("/");o.length&&!(a.host=o.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==o[0]&&o.unshift(""),o.length<2&&o.unshift(""),c.pathname=o.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var p=c.pathname||"",q=c.search||"";c.path=p+q}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var r=c.pathname&&"/"===c.pathname.charAt(0),s=a.host||a.pathname&&"/"===a.pathname.charAt(0),t=s||r||c.host&&a.pathname,u=t,v=c.pathname&&c.pathname.split("/")||[],o=a.pathname&&a.pathname.split("/")||[],y=c.protocol&&!x[c.protocol];if(y&&(c.hostname="",c.port=null,c.host&&(""===v[0]?v[0]=c.host:v.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===o[0]?o[0]=a.host:o.unshift(a.host)),a.host=null),t=t&&(""===o[0]||""===v[0])),s)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,v=o;else if(o.length)v||(v=[]),v.pop(),v=v.concat(o),c.search=a.search,c.query=a.query;else if(!j.isNullOrUndefined(a.search)){if(y){c.hostname=c.host=v.shift();var z=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");z&&(c.auth=z.shift(),c.host=c.hostname=z.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!v.length)return c.pathname=null,c.search?c.path="/"+c.search:c.path=null,c.href=c.format(),c;for(var A=v.slice(-1)[0],B=(c.host||a.host||v.length>1)&&("."===A||".."===A)||""===A,C=0,D=v.length;D>=0;D--)A=v[D],"."===A?v.splice(D,1):".."===A?(v.splice(D,1),C++):C&&(v.splice(D,1),C--);if(!t&&!u)for(;C--;C)v.unshift("..");!t||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),B&&"/"!==v.join("/").substr(-1)&&v.push("");var E=""===v[0]||v[0]&&"/"===v[0].charAt(0);if(y){c.hostname=c.host=E?"":v.length?v.shift():"";var z=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");z&&(c.auth=z.shift(),c.host=c.hostname=z.shift())}return t=t||c.host&&v.length,t&&!E&&v.unshift(""),v.length?c.pathname=v.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=l.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{"./util":4,punycode:34,querystring:37}],4:[function(a,b,c){"use strict";b.exports={isString:function(a){return"string"==typeof a},isObject:function(a){return"object"==typeof a&&null!==a},isNull:function(a){return null===a},isNullOrUndefined:function(a){return null==a}}},{}],5:[function(a,b,c){b.exports=function(){function b(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}function c(a,b,c,d,e,f){this.message=a,this.expected=b,this.found=c,this.offset=d,this.line=e,this.column=f,this.name="SyntaxError"}function d(b){function d(a){function c(a,c,d){var e,f;for(e=c;e<d;e++)f=b.charAt(e),"\n"===f?(a.seenCR||a.line++,a.column=1,a.seenCR=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(a.line++,a.column=1,a.seenCR=!0):(a.column++,a.seenCR=!1)}return T!==a&&(T>a&&(T=0,U={line:1,column:1,seenCR:!1}),c(U,T,a),T=a),U}function e(a){R<V||(R>V&&(V=R,W=[]),W.push(a))}function f(a,e,f){function g(a){var b=1;for(a.sort(function(a,b){return a.description<b.description?-1:a.description>b.description?1:0});b<a.length;)a[b-1]===a[b]?a.splice(b,1):b++}function h(a,b){function c(a){function b(a){return a.charCodeAt(0).toString(16).toUpperCase()}return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(a){return"\\x0"+b(a)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(a){return"\\x"+b(a)}).replace(/[\u0180-\u0FFF]/g,function(a){return"\\u0"+b(a)}).replace(/[\u1080-\uFFFF]/g,function(a){return"\\u"+b(a)})}var d,e,f,g=new Array(a.length);for(f=0;f<a.length;f++)g[f]=a[f].description;return d=a.length>1?g.slice(0,-1).join(", ")+" or "+g[a.length-1]:g[0],e=b?'"'+c(b)+'"':"end of input","Expected "+d+" but "+e+" found."}var i=d(f),j=f<b.length?b.charAt(f):null;return null!==e&&g(e),new c(null!==a?a:h(e,j),e,j,f,i.line,i.column)}function g(){var a,b;return a=h(),a===r&&(a=R,b=[],b!==r&&(S=a,b=u()),a=b),a}function h(){var a,c,d,f,g,j;if(a=R,c=i(),c!==r){for(d=[],f=o();f!==r;)d.push(f),f=o();if(d!==r)if(44===b.charCodeAt(R)?(f=w,R++):(f=r,0===X&&e(x)),f!==r){for(g=[],j=o();j!==r;)g.push(j),j=o();g!==r?(j=h(),j!==r?(S=a,c=y(c,j),a=c):(R=a,a=v)):(R=a,a=v)}else R=a,a=v;else R=a,a=v}else R=a,a=v;return a===r&&(a=R,c=i(),c!==r&&(S=a,c=z(c)),a=c),a}function i(){var a;return a=j(),a===r&&(a=m()),a}function j(){var a,b,c,d;if(a=R,b=k(),b!==r){if(c=[],d=o(),d!==r)for(;d!==r;)c.push(d),d=o();else c=v;c!==r?(d=l(),d!==r?(S=a,b=A(b,d),a=b):(R=a,a=v)):(R=a,a=v)}else R=a,a=v;return a===r&&(a=R,b=k(),b!==r&&(S=a,b=B(b)),a=b),a}function k(){var a,c,d,f;return a=R,b.substr(R,4)===C?(c=C,R+=4):(c=r,0===X&&e(D)),c!==r?(d=n(),d!==r?(41===b.charCodeAt(R)?(f=E,R++):(f=r,0===X&&e(F)),f!==r?(S=a,c=G(d),a=c):(R=a,a=v)):(R=a,a=v)):(R=a,a=v),a}function l(){var a,c,d,f;return a=R,b.substr(R,7)===H?(c=H,R+=7):(c=r,0===X&&e(I)),c!==r?(d=n(),d!==r?(41===b.charCodeAt(R)?(f=E,R++):(f=r,0===X&&e(F)),f!==r?(S=a,c=G(d),a=c):(R=a,a=v)):(R=a,a=v)):(R=a,a=v),a}function m(){var a,c,d,f;return a=R,b.substr(R,6)===J?(c=J,R+=6):(c=r,0===X&&e(K)),c!==r?(d=n(),d!==r?(41===b.charCodeAt(R)?(f=E,R++):(f=r,0===X&&e(F)),f!==r?(S=a,c=L(d),a=c):(R=a,a=v)):(R=a,a=v)):(R=a,a=v),a}function n(){var a,c,d;if(a=R,c=[],M.test(b.charAt(R))?(d=b.charAt(R),R++):(d=r,0===X&&e(N)),d!==r)for(;d!==r;)c.push(d),M.test(b.charAt(R))?(d=b.charAt(R),R++):(d=r,0===X&&e(N));else c=v;return c!==r&&(S=a,c=O(c)),a=c}function o(){var a;return P.test(b.charAt(R))?(a=b.charAt(R),R++):(a=r,0===X&&e(Q)),a}var p,q=arguments.length>1?arguments[1]:{},r={},s={start:g},t=g,u=function(){return[]},v=r,w=",",x={type:"literal",value:",",description:'","'},y=function(a,b){return[a].concat(b)},z=function(a){return[a]},A=function(a,b){return{url:a,format:b}},B=function(a){return{url:a}},C="url(",D={type:"literal",value:"url(",description:'"url("'},E=")",F={type:"literal",value:")",description:'")"'},G=function(a){return a},H="format(",I={type:"literal",value:"format(",description:'"format("'},J="local(",K={type:"literal",value:"local(",description:'"local("'},L=function(a){return{local:a}},M=/^[^)]/,N={type:"class",value:"[^)]",description:"[^)]"},O=function(a){return Y.extractValue(a.join(""))},P=/^[ \t\r\n\f]/,Q={type:"class",value:"[ \\t\\r\\n\\f]",description:"[ \\t\\r\\n\\f]"},R=0,S=0,T=0,U={line:1,column:1,seenCR:!1},V=0,W=[],X=0;if("startRule"in q){if(!(q.startRule in s))throw new Error("Can't start parsing from rule \""+q.startRule+'".');t=s[q.startRule]}var Y=a("../util");if(p=t(),p!==r&&R===b.length)return p;throw p!==r&&R<b.length&&e({type:"end",description:"end of input"}),f(null,W,V)}return b(c,Error),{SyntaxError:c,parse:d}}()},{"../util":7}],6:[function(a,b,c){var d=a("./grammar");c.SyntaxError=function(a,b){this.message=a,this.offset=b},c.parse=function(a){try{return d.parse(a)}catch(a){throw new c.SyntaxError(a.message,a.offset)}},c.serialize=function(a){return a.map(function(a){var b;return a.url?(b='url("'+a.url+'")',a.format&&(b+=' format("'+a.format+'")')):b='local("'+a.local+'")',b}).join(", ")}},{"./grammar":5}],7:[function(a,b,c){var d=function(a){var b=/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/;return a.replace(b,"$1")},e=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)?a.replace(b,"$1"):c.test(a)?a.replace(c,"$1"):a};c.extractValue=function(a){return e(d(a))}},{}],8:[function(a,b,c){"use strict";function d(a,b){return e(a).some(function(a){var c=a.inverse,d="all"===a.type||b.type===a.type;if(d&&c||!d&&!c)return!1;var e=a.expressions.every(function(a){var c=a.feature,d=a.modifier,e=a.value,i=b[c];if(!i)return!1;switch(c){case"orientation":case"scan":return i.toLowerCase()===e.toLowerCase();case"width":case"height":case"device-width":case"device-height":e=h(e),i=h(i);break;case"resolution":e=g(e),i=g(i);break;case"aspect-ratio":case"device-aspect-ratio":case"device-pixel-ratio":e=f(e),i=f(i);break;case"grid":case"color":case"color-index":case"monochrome":e=parseInt(e,10)||1,i=parseInt(i,10)||0}switch(d){case"min":return i>=e;case"max":return i<=e;default:return i===e}});return e&&!c||!e&&c})}function e(a){return a.split(",").map(function(a){a=a.trim();var b=a.match(i),c=b[1],d=b[2],e=b[3]||"",f={};return f.inverse=!!c&&"not"===c.toLowerCase(),f.type=d?d.toLowerCase():"all",e=e.match(/\([^\)]+\)/g)||[],f.expressions=e.map(function(a){var b=a.match(j),c=b[1].toLowerCase().match(k);return{modifier:c[1],feature:c[2],value:b[2]}}),f})}function f(a){var b,c=Number(a);return c||(b=a.match(/^(\d+)\s*\/\s*(\d+)$/),c=b[1]/b[2]),c}function g(a){var b=parseFloat(a),c=String(a).match(m)[1];switch(c){case"dpcm":return b/2.54;case"dppx":return 96*b;default:return b}}function h(a){var b=parseFloat(a),c=String(a).match(l)[1];switch(c){case"em":return 16*b;case"rem":return 16*b;case"cm":return 96*b/2.54;case"mm":return 96*b/2.54/10;case"in":return 96*b;case"pt":return 72*b;
case"pc":return 72*b/12;default:return b}}c.match=d,c.parse=e;var i=/(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i,j=/\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/,k=/^(?:(min|max)-)?(.+)/,l=/(em|rem|px|cm|mm|in|pt|pc)?$/,m=/(dpi|dpcm|dppx)?$/},{}],9:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,MatcherList:a("./MatcherList").MatcherList};d.CSSDocumentRule=function(){d.CSSRule.call(this),this.matcher=new d.MatcherList,this.cssRules=[]},d.CSSDocumentRule.prototype=new d.CSSRule,d.CSSDocumentRule.prototype.constructor=d.CSSDocumentRule,d.CSSDocumentRule.prototype.type=10,Object.defineProperty(d.CSSDocumentRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;b<c;b++)a.push(this.cssRules[b].cssText);return"@-moz-document "+this.matcher.matcherText+" {"+a.join("")+"}"}}),c.CSSDocumentRule=d.CSSDocumentRule},{"./CSSRule":15,"./MatcherList":21}],10:[function(a,b,c){var d={CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSRule:a("./CSSRule").CSSRule};d.CSSFontFaceRule=function(){d.CSSRule.call(this),this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSFontFaceRule.prototype=new d.CSSRule,d.CSSFontFaceRule.prototype.constructor=d.CSSFontFaceRule,d.CSSFontFaceRule.prototype.type=5,Object.defineProperty(d.CSSFontFaceRule.prototype,"cssText",{get:function(){return"@font-face {"+this.style.cssText+"}"}}),c.CSSFontFaceRule=d.CSSFontFaceRule},{"./CSSRule":15,"./CSSStyleDeclaration":16}],11:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,CSSStyleSheet:a("./CSSStyleSheet").CSSStyleSheet,MediaList:a("./MediaList").MediaList};d.CSSImportRule=function(){d.CSSRule.call(this),this.href="",this.media=new d.MediaList,this.styleSheet=new d.CSSStyleSheet},d.CSSImportRule.prototype=new d.CSSRule,d.CSSImportRule.prototype.constructor=d.CSSImportRule,d.CSSImportRule.prototype.type=3,Object.defineProperty(d.CSSImportRule.prototype,"cssText",{get:function(){var a=this.media.mediaText;return"@import url("+this.href+")"+(a?" "+a:"")+";"},set:function(a){for(var b,c,d=0,e="",f="";c=a.charAt(d);d++)switch(c){case" ":case"\t":case"\r":case"\n":case"\f":"after-import"===e?e="url":f+=c;break;case"@":e||a.indexOf("@import",d)!==d||(e="after-import",d+="import".length,f="");break;case"u":if("url"===e&&a.indexOf("url(",d)===d){if(b=a.indexOf(")",d+1),b===-1)throw d+': ")" not found';d+="url(".length;var g=a.slice(d,b);g[0]===g[g.length-1]&&('"'!==g[0]&&"'"!==g[0]||(g=g.slice(1,-1))),this.href=g,d=b,e="media"}break;case'"':if("url"===e){if(b=a.indexOf('"',d+1),!b)throw d+": '\"' not found";this.href=a.slice(d+1,b),d=b,e="media"}break;case"'":if("url"===e){if(b=a.indexOf("'",d+1),!b)throw d+': "\'" not found';this.href=a.slice(d+1,b),d=b,e="media"}break;case";":"media"===e&&f&&(this.media.mediaText=f.trim());break;default:"media"===e&&(f+=c)}}}),c.CSSImportRule=d.CSSImportRule},{"./CSSRule":15,"./CSSStyleSheet":18,"./MediaList":22}],12:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration};d.CSSKeyframeRule=function(){d.CSSRule.call(this),this.keyText="",this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSKeyframeRule.prototype=new d.CSSRule,d.CSSKeyframeRule.prototype.constructor=d.CSSKeyframeRule,d.CSSKeyframeRule.prototype.type=9,Object.defineProperty(d.CSSKeyframeRule.prototype,"cssText",{get:function(){return this.keyText+" {"+this.style.cssText+"} "}}),c.CSSKeyframeRule=d.CSSKeyframeRule},{"./CSSRule":15,"./CSSStyleDeclaration":16}],13:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule};d.CSSKeyframesRule=function(){d.CSSRule.call(this),this.name="",this.cssRules=[]},d.CSSKeyframesRule.prototype=new d.CSSRule,d.CSSKeyframesRule.prototype.constructor=d.CSSKeyframesRule,d.CSSKeyframesRule.prototype.type=8,Object.defineProperty(d.CSSKeyframesRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;b<c;b++)a.push(" "+this.cssRules[b].cssText);return"@"+(this._vendorPrefix||"")+"keyframes "+this.name+" { \n"+a.join("\n")+"\n}"}}),c.CSSKeyframesRule=d.CSSKeyframesRule},{"./CSSRule":15}],14:[function(a,b,c){var d={CSSRule:a("./CSSRule").CSSRule,MediaList:a("./MediaList").MediaList};d.CSSMediaRule=function(){d.CSSRule.call(this),this.media=new d.MediaList,this.cssRules=[]},d.CSSMediaRule.prototype=new d.CSSRule,d.CSSMediaRule.prototype.constructor=d.CSSMediaRule,d.CSSMediaRule.prototype.type=4,Object.defineProperty(d.CSSMediaRule.prototype,"cssText",{get:function(){for(var a=[],b=0,c=this.cssRules.length;b<c;b++)a.push(this.cssRules[b].cssText);return"@media "+this.media.mediaText+" {"+a.join("")+"}"}}),c.CSSMediaRule=d.CSSMediaRule},{"./CSSRule":15,"./MediaList":22}],15:[function(a,b,c){var d={};d.CSSRule=function(){this.parentRule=null,this.parentStyleSheet=null},d.CSSRule.UNKNOWN_RULE=0,d.CSSRule.STYLE_RULE=1,d.CSSRule.CHARSET_RULE=2,d.CSSRule.IMPORT_RULE=3,d.CSSRule.MEDIA_RULE=4,d.CSSRule.FONT_FACE_RULE=5,d.CSSRule.PAGE_RULE=6,d.CSSRule.KEYFRAMES_RULE=7,d.CSSRule.KEYFRAME_RULE=8,d.CSSRule.MARGIN_RULE=9,d.CSSRule.NAMESPACE_RULE=10,d.CSSRule.COUNTER_STYLE_RULE=11,d.CSSRule.SUPPORTS_RULE=12,d.CSSRule.DOCUMENT_RULE=13,d.CSSRule.FONT_FEATURE_VALUES_RULE=14,d.CSSRule.VIEWPORT_RULE=15,d.CSSRule.REGION_STYLE_RULE=16,d.CSSRule.prototype={constructor:d.CSSRule},c.CSSRule=d.CSSRule},{}],16:[function(a,b,c){var d={};d.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}},d.CSSStyleDeclaration.prototype={constructor:d.CSSStyleDeclaration,getPropertyValue:function(a){return this[a]||""},setProperty:function(a,b,c){if(this[a]){var d=Array.prototype.indexOf.call(this,a);d<0&&(this[this.length]=a,this.length++)}else this[this.length]=a,this.length++;this[a]=b,this._importants[a]=c},removeProperty:function(a){if(!(a in this))return"";var b=Array.prototype.indexOf.call(this,a);if(b<0)return"";var c=this[a];return this[a]="",Array.prototype.splice.call(this,b,1),c},getPropertyCSSValue:function(){},getPropertyPriority:function(a){return this._importants[a]||""},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var a=[],b=0,c=this.length;b<c;++b){var d=this[b],e=this.getPropertyValue(d),f=this.getPropertyPriority(d);f&&(f=" !"+f),a[b]=d+": "+e+f+";"}return a.join(" ")},set cssText(a){var b,c;for(b=this.length;b--;)c=this[b],this[c]="";Array.prototype.splice.call(this,0,this.length),this._importants={};var e=d.parse("#bogus{"+a+"}").cssRules[0].style,f=e.length;for(b=0;b<f;++b)c=e[b],this.setProperty(e[b],e.getPropertyValue(c),e.getPropertyPriority(c))}},c.CSSStyleDeclaration=d.CSSStyleDeclaration,d.parse=a("./parse").parse},{"./parse":26}],17:[function(a,b,c){var d={CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSRule:a("./CSSRule").CSSRule};d.CSSStyleRule=function(){d.CSSRule.call(this),this.selectorText="",this.style=new d.CSSStyleDeclaration,this.style.parentRule=this},d.CSSStyleRule.prototype=new d.CSSRule,d.CSSStyleRule.prototype.constructor=d.CSSStyleRule,d.CSSStyleRule.prototype.type=1,Object.defineProperty(d.CSSStyleRule.prototype,"cssText",{get:function(){var a;return a=this.selectorText?this.selectorText+" {"+this.style.cssText+"}":""},set:function(a){var b=d.CSSStyleRule.parse(a);this.style=b.style,this.selectorText=b.selectorText}}),d.CSSStyleRule.parse=function(a){for(var b,c,e,f=0,g="selector",h=f,i="",j={selector:!0,value:!0},k=new d.CSSStyleRule,l="";e=a.charAt(f);f++)switch(e){case" ":case"\t":case"\r":case"\n":case"\f":if(j[g])switch(a.charAt(f-1)){case" ":case"\t":case"\r":case"\n":case"\f":break;default:i+=" "}break;case'"':if(h=f+1,b=a.indexOf('"',h)+1,!b)throw'" is missing';i+=a.slice(f,b),f=b-1;break;case"'":if(h=f+1,b=a.indexOf("'",h)+1,!b)throw"' is missing";i+=a.slice(f,b),f=b-1;break;case"/":if("*"===a.charAt(f+1)){if(f+=2,b=a.indexOf("*/",f),b===-1)throw new SyntaxError("Missing */");f=b+1}else i+=e;break;case"{":"selector"===g&&(k.selectorText=i.trim(),i="",g="name");break;case":":"name"===g?(c=i.trim(),i="",g="value"):i+=e;break;case"!":"value"===g&&a.indexOf("!important",f)===f?(l="important",f+="important".length):i+=e;break;case";":"value"===g?(k.style.setProperty(c,i.trim(),l),l="",i="",g="name"):i+=e;break;case"}":if("value"===g)k.style.setProperty(c,i.trim(),l),l="",i="";else{if("name"===g)break;i+=e}g="selector";break;default:i+=e}return k},c.CSSStyleRule=d.CSSStyleRule},{"./CSSRule":15,"./CSSStyleDeclaration":16}],18:[function(a,b,c){var d={StyleSheet:a("./StyleSheet").StyleSheet,CSSStyleRule:a("./CSSStyleRule").CSSStyleRule};d.CSSStyleSheet=function(){d.StyleSheet.call(this),this.cssRules=[]},d.CSSStyleSheet.prototype=new d.StyleSheet,d.CSSStyleSheet.prototype.constructor=d.CSSStyleSheet,d.CSSStyleSheet.prototype.insertRule=function(a,b){if(b<0||b>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var c=d.parse(a).cssRules[0];return c.parentStyleSheet=this,this.cssRules.splice(b,0,c),b},d.CSSStyleSheet.prototype.deleteRule=function(a){if(a<0||a>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(a,1)},d.CSSStyleSheet.prototype.toString=function(){for(var a="",b=this.cssRules,c=0;c<b.length;c++)a+=b[c].cssText+"\n";return a},c.CSSStyleSheet=d.CSSStyleSheet,d.parse=a("./parse").parse},{"./CSSStyleRule":17,"./StyleSheet":23,"./parse":26}],19:[function(a,b,c){var d={};d.CSSValue=function(){},d.CSSValue.prototype={constructor:d.CSSValue,set cssText(a){var b=this._getConstructorName();throw new Error('DOMException: property "cssText" of "'+b+'" is readonly and can not be replaced with "'+a+'"!')},get cssText(){var a=this._getConstructorName();throw new Error('getter "cssText" of "'+a+'" is not implemented!')},_getConstructorName:function(){var a=this.constructor.toString(),b=a.match(/function\s([^\(]+)/),c=b[1];return c}},c.CSSValue=d.CSSValue},{}],20:[function(a,b,c){var d={CSSValue:a("./CSSValue").CSSValue};d.CSSValueExpression=function(a,b){this._token=a,this._idx=b},d.CSSValueExpression.prototype=new d.CSSValue,d.CSSValueExpression.prototype.constructor=d.CSSValueExpression,d.CSSValueExpression.prototype.parse=function(){for(var a,b=this._token,c=this._idx,d="",e="",f="",g=[];;++c){if(d=b.charAt(c),""===d){f="css expression error: unfinished expression!";break}switch(d){case"(":g.push(d),e+=d;break;case")":g.pop(d),e+=d;break;case"/":(a=this._parseJSComment(b,c))?a.error?f="css expression error: unfinished comment in expression!":c=a.idx:(a=this._parseJSRexExp(b,c))?(c=a.idx,e+=a.text):e+=d;break;case"'":case'"':a=this._parseJSString(b,c,d),a?(c=a.idx,e+=a.text):e+=d;break;default:e+=d}if(f)break;if(0===g.length)break}var h;return h=f?{error:f}:{idx:c,expression:e}},d.CSSValueExpression.prototype._parseJSComment=function(a,b){var c,d=a.charAt(b+1);if("/"===d||"*"===d){var e,f,g=b;if("/"===d?f="\n":"*"===d&&(f="*/"),e=a.indexOf(f,g+1+1),e!==-1)return e=e+f.length-1,c=a.substring(b,e+1),{idx:e,text:c};var h="css expression error: unfinished comment in expression!";return{error:h}}return!1},d.CSSValueExpression.prototype._parseJSString=function(a,b,c){var d,e=this._findMatchedIdx(a,b,c);return e!==-1&&(d=a.substring(b,e+c.length),{idx:e,text:d})},d.CSSValueExpression.prototype._parseJSRexExp=function(a,b){var c=a.substring(0,b).replace(/\s+$/,""),d=[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/],e=d.some(function(a){return a.test(c)});if(e){var f="/";return this._parseJSString(a,b,f)}return!1},d.CSSValueExpression.prototype._findMatchedIdx=function(a,b,c){for(var d,e=b,f=-1;;){if(d=a.indexOf(c,e+1),d===-1){d=f;break}var g=a.substring(b+1,d),h=g.match(/\\+$/);if(!h||h[0]%2===0)break;e=d}var i=a.indexOf("\n",b+1);return i<d&&(d=f),d},c.CSSValueExpression=d.CSSValueExpression},{"./CSSValue":19}],21:[function(a,b,c){var d={};d.MatcherList=function(){this.length=0},d.MatcherList.prototype={constructor:d.MatcherList,get matcherText(){return Array.prototype.join.call(this,", ")},set matcherText(a){for(var b=a.split(","),c=this.length=b.length,d=0;d<c;d++)this[d]=b[d].trim()},appendMatcher:function(a){Array.prototype.indexOf.call(this,a)===-1&&(this[this.length]=a,this.length++)},deleteMatcher:function(a){var b=Array.prototype.indexOf.call(this,a);b!==-1&&Array.prototype.splice.call(this,b,1)}},c.MatcherList=d.MatcherList},{}],22:[function(a,b,c){var d={};d.MediaList=function(){this.length=0},d.MediaList.prototype={constructor:d.MediaList,get mediaText(){return Array.prototype.join.call(this,", ")},set mediaText(a){for(var b=a.split(","),c=this.length=b.length,d=0;d<c;d++)this[d]=b[d].trim()},appendMedium:function(a){Array.prototype.indexOf.call(this,a)===-1&&(this[this.length]=a,this.length++)},deleteMedium:function(a){var b=Array.prototype.indexOf.call(this,a);b!==-1&&Array.prototype.splice.call(this,b,1)}},c.MediaList=d.MediaList},{}],23:[function(a,b,c){var d={};d.StyleSheet=function(){this.parentStyleSheet=null},c.StyleSheet=d.StyleSheet},{}],24:[function(a,b,c){var d={CSSStyleSheet:a("./CSSStyleSheet").CSSStyleSheet,CSSStyleRule:a("./CSSStyleRule").CSSStyleRule,CSSMediaRule:a("./CSSMediaRule").CSSMediaRule,CSSStyleDeclaration:a("./CSSStyleDeclaration").CSSStyleDeclaration,CSSKeyframeRule:a("./CSSKeyframeRule").CSSKeyframeRule,CSSKeyframesRule:a("./CSSKeyframesRule").CSSKeyframesRule};d.clone=function a(b){var c=new d.CSSStyleSheet,e=b.cssRules;if(!e)return c;for(var f={1:d.CSSStyleRule,4:d.CSSMediaRule,8:d.CSSKeyframesRule,9:d.CSSKeyframeRule},g=0,h=e.length;g<h;g++){var i=e[g],j=c.cssRules[g]=new f[i.type],k=i.style;if(k){for(var l=j.style=new d.CSSStyleDeclaration,m=0,n=k.length;m<n;m++){var o=l[m]=k[m];l[o]=k[o],l._importants[o]=k.getPropertyPriority(o)}l.length=k.length}i.hasOwnProperty("keyText")&&(j.keyText=i.keyText),i.hasOwnProperty("selectorText")&&(j.selectorText=i.selectorText),i.hasOwnProperty("mediaText")&&(j.mediaText=i.mediaText),i.hasOwnProperty("cssRules")&&(j.cssRules=a(i).cssRules)}return c},c.clone=d.clone},{"./CSSKeyframeRule":12,"./CSSKeyframesRule":13,"./CSSMediaRule":14,"./CSSStyleDeclaration":16,"./CSSStyleRule":17,"./CSSStyleSheet":18}],25:[function(a,b,c){"use strict";c.CSSStyleDeclaration=a("./CSSStyleDeclaration").CSSStyleDeclaration,c.CSSRule=a("./CSSRule").CSSRule,c.CSSStyleRule=a("./CSSStyleRule").CSSStyleRule,c.MediaList=a("./MediaList").MediaList,c.CSSMediaRule=a("./CSSMediaRule").CSSMediaRule,c.CSSImportRule=a("./CSSImportRule").CSSImportRule,c.CSSFontFaceRule=a("./CSSFontFaceRule").CSSFontFaceRule,c.StyleSheet=a("./StyleSheet").StyleSheet,c.CSSStyleSheet=a("./CSSStyleSheet").CSSStyleSheet,c.CSSKeyframesRule=a("./CSSKeyframesRule").CSSKeyframesRule,c.CSSKeyframeRule=a("./CSSKeyframeRule").CSSKeyframeRule,c.MatcherList=a("./MatcherList").MatcherList,c.CSSDocumentRule=a("./CSSDocumentRule").CSSDocumentRule,c.CSSValue=a("./CSSValue").CSSValue,c.CSSValueExpression=a("./CSSValueExpression").CSSValueExpression,c.parse=a("./parse").parse,c.clone=a("./clone").clone},{"./CSSDocumentRule":9,"./CSSFontFaceRule":10,"./CSSImportRule":11,"./CSSKeyframeRule":12,"./CSSKeyframesRule":13,"./CSSMediaRule":14,"./CSSRule":15,"./CSSStyleDeclaration":16,"./CSSStyleRule":17,"./CSSStyleSheet":18,"./CSSValue":19,"./CSSValueExpression":20,"./MatcherList":21,"./MediaList":22,"./StyleSheet":23,"./clone":24,"./parse":26}],26:[function(a,b,c){var d={};d.parse=function(a){for(var b,c,e,f,g,h,i,j,k,l,m=0,n="before-selector",o="",p={selector:!0,value:!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,"documentRule-begin":!0},q=new d.CSSStyleSheet,r=q,s="",t=/@(-(?:\w+-)+)?keyframes/g,u=function(b){var c=a.substring(0,m).split("\n"),d=c.length,e=c.pop().length+1,f=new Error(b+" (line "+d+", char "+e+")");throw f.line=d,f.char=e,f.styleSheet=q,f};l=a.charAt(m);m++)switch(l){case" ":case"\t":case"\r":case"\n":case"\f":p[n]&&(o+=l);break;case'"':b=m+1;do b=a.indexOf('"',b)+1,b||u('Unmatched "');while("\\"===a[b-2]);switch(o+=a.slice(m,b),m=b-1,n){case"before-value":n="value";break;case"importRule-begin":n="importRule"}break;case"'":b=m+1;do b=a.indexOf("'",b)+1,b||u("Unmatched '");while("\\"===a[b-2]);switch(o+=a.slice(m,b),m=b-1,n){case"before-value":n="value";break;case"importRule-begin":n="importRule"}break;case"/":"*"===a.charAt(m+1)?(m+=2,b=a.indexOf("*/",m),b===-1?u("Missing */"):m=b+1):o+=l,"importRule-begin"===n&&(o+=" ",n="importRule");break;case"@":if(a.indexOf("@-moz-document",m)===m){n="documentRule-begin",k=new d.CSSDocumentRule,k.__starts=m,m+="-moz-document".length,o="";break}if(a.indexOf("@media",m)===m){n="atBlock",g=new d.CSSMediaRule,g.__starts=m,m+="media".length,o="";break}if(a.indexOf("@import",m)===m){n="importRule-begin",m+="import".length,o+="@import";break}if(a.indexOf("@font-face",m)===m){n="fontFaceRule-begin",m+="font-face".length,i=new d.CSSFontFaceRule,i.__starts=m,o="";break}t.lastIndex=m;var v=t.exec(a);if(v&&v.index===m){n="keyframesRule-begin",j=new d.CSSKeyframesRule,j.__starts=m,j._vendorPrefix=v[1],m+=v[0].length-1,o="";break}"selector"===n&&(n="atRule"),o+=l;break;case"{":"selector"===n||"atRule"===n?(f.selectorText=o.trim(),f.style.__starts=m,o="",n="before-name"):"atBlock"===n?(g.media.mediaText=o.trim(),r=c=g,g.parentStyleSheet=q,o="",n="before-selector"):"fontFaceRule-begin"===n?(c&&(i.parentRule=c),i.parentStyleSheet=q,f=i,o="",n="before-name"):"keyframesRule-begin"===n?(j.name=o.trim(),c&&(j.parentRule=c),j.parentStyleSheet=q,r=c=j,o="",n="keyframeRule-begin"):"keyframeRule-begin"===n?(f=new d.CSSKeyframeRule,f.keyText=o.trim(),f.__starts=m,o="",n="before-name"):"documentRule-begin"===n&&(k.matcher.matcherText=o.trim(),c&&(k.parentRule=c),r=c=k,k.parentStyleSheet=q,o="",n="before-selector");break;case":":"name"===n?(e=o.trim(),o="",n="before-value"):o+=l;break;case"(":if("value"===n)if("expression"===o.trim()){var w=new d.CSSValueExpression(a,m).parse();w.error?u(w.error):(o+=w.expression,m=w.idx)}else n="value-parenthesis",o+=l;else o+=l;break;case")":"value-parenthesis"===n&&(n="value"),o+=l;break;case"!":"value"===n&&a.indexOf("!important",m)===m?(s="important",m+="important".length):o+=l;break;case";":switch(n){case"value":f.style.setProperty(e,o.trim(),s),s="",o="",n="before-name";break;case"atRule":o="",n="before-selector";break;case"importRule":h=new d.CSSImportRule,h.parentStyleSheet=h.styleSheet.parentStyleSheet=q,h.cssText=o+l,q.cssRules.push(h),o="",n="before-selector";break;default:o+=l}break;case"}":switch(n){case"value":f.style.setProperty(e,o.trim(),s),s="";case"before-name":case"name":f.__ends=m+1,c&&(f.parentRule=c),f.parentStyleSheet=q,r.cssRules.push(f),o="",n=r.constructor===d.CSSKeyframesRule?"keyframeRule-begin":"before-selector";break;case"keyframeRule-begin":case"before-selector":case"selector":c||u("Unexpected }"),r.__ends=m+1,q.cssRules.push(r),r=q,c=null,o="",n="before-selector"}break;default:switch(n){case"before-selector":n="selector",f=new d.CSSStyleRule,f.__starts=m;break;case"before-name":n="name";break;case"before-value":n="value";break;case"importRule-begin":n="importRule"}o+=l}return q},c.parse=d.parse,d.CSSStyleSheet=a("./CSSStyleSheet").CSSStyleSheet,d.CSSStyleRule=a("./CSSStyleRule").CSSStyleRule,d.CSSImportRule=a("./CSSImportRule").CSSImportRule,d.CSSMediaRule=a("./CSSMediaRule").CSSMediaRule,d.CSSFontFaceRule=a("./CSSFontFaceRule").CSSFontFaceRule,d.CSSStyleDeclaration=a("./CSSStyleDeclaration").CSSStyleDeclaration,d.CSSKeyframeRule=a("./CSSKeyframeRule").CSSKeyframeRule,d.CSSKeyframesRule=a("./CSSKeyframesRule").CSSKeyframesRule,d.CSSValueExpression=a("./CSSValueExpression").CSSValueExpression,d.CSSDocumentRule=a("./CSSDocumentRule").CSSDocumentRule},{"./CSSDocumentRule":9,"./CSSFontFaceRule":10,"./CSSImportRule":11,"./CSSKeyframeRule":12,"./CSSKeyframesRule":13,"./CSSMediaRule":14,"./CSSStyleDeclaration":16,"./CSSStyleRule":17,"./CSSStyleSheet":18,"./CSSValueExpression":20}],27:[function(a,b,c){"use strict";var d=a("./cssSupport"),e=function(a){var b=/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/;return a.replace(b,"$1")};c.extractCssUrl=function(a){var b,c=/^url\(([^\)]+)\)/;if(!c.test(a))throw new Error("Invalid url");return b=c.exec(a)[1],d.unquoteString(e(b))};var f=function(a){var b,c="\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*",d="(url\\("+c+"\\)|[^,\\s]+)",e="(?:\\s*"+d+")+",f="^\\s*("+e+")(?:\\s*,\\s*("+e+"))*\\s*$",g=new RegExp(e,"g"),h=[],i=function(a){var b,c=new RegExp(d,"g"),e=[];for(b=c.exec(a);b;)e.push(b[1]),b=c.exec(a);return e};if(a.match(new RegExp(f))){for(b=g.exec(a);b;)h.push(i(b[0])),b=g.exec(a);return h}return[]},g=function(a){var b,d;for(b=0;b<a.length;b++)try{return d=c.extractCssUrl(a[b]),{url:d,idx:b}}catch(a){}};c.parse=function(a){var b=f(a);return b.map(function(a){var b=g(a);return b?{preUrl:a.slice(0,b.idx),url:b.url,postUrl:a.slice(b.idx+1)}:{preUrl:a}})},c.serialize=function(a){var b=a.map(function(a){var b=[].concat(a.preUrl);return a.url&&b.push('url("'+a.url+'")'),a.postUrl&&(b=b.concat(a.postUrl)),b.join(" ")});return b.join(", ")}},{"./cssSupport":28}],28:[function(a,b,c){"use strict";var d;try{d=a("cssom")}catch(a){}c.unquoteString=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)?a.replace(b,"$1"):c.test(a)?a.replace(c,"$1"):a};var e=function(a){var b,c=document.implementation.createHTMLDocument(""),d=document.createElement("style");return d.textContent=a,c.body.appendChild(d),b=d.sheet.cssRules,Array.prototype.slice.call(b)},f=function(){var a=e("a{background:url(i)}");return!a.length||a[0].cssText.indexOf("url()")>=0}(),g=function(){var a=e('@font-face { font-family: "f"; src: url("f"); }');return!a.length||/url\(['"]*\)/.test(a[0].cssText)}();c.rulesForCssText=function(a){return(f||g)&&d&&d.parse?d.parse(a).cssRules:e(a)},c.cssRulesToText=function(a){return a.reduce(function(a,b){return a+b.cssText},"")},c.exchangeRule=function(a,b,d){var e=a.indexOf(b);a[e]=c.rulesForCssText(d)[0]},c.changeFontFaceRuleSrc=function(a,b,d){var e="@font-face { font-family: "+b.style.getPropertyValue("font-family")+"; ";b.style.getPropertyValue("font-style")&&(e+="font-style: "+b.style.getPropertyValue("font-style")+"; "),b.style.getPropertyValue("font-weight")&&(e+="font-weight: "+b.style.getPropertyValue("font-weight")+"; "),e+="src: "+d+"}",c.exchangeRule(a,b,e)}},{cssom:25}],29:[function(a,b,c){"use strict";var d=a("./util"),e=a("./inlineImage"),f=a("./inlineScript"),g=a("./inlineCss"),h=a("./cssSupport"),i=function(a){return d.joinUrl(a,".")},j=function(a){var b=a.map(function(b,c){return c===a.length-1&&(b={baseUrl:i(b.baseUrl)}),JSON.stringify(b)});return b},k=function(a,b){return b.cache!==!1&&"none"!==b.cache&&b.cacheBucket?d.memoize(a,j,b.cacheBucket):a},l=function(a,b,c){var d=h.rulesForCssText(a);return g.loadCSSImportsForRules(d,b,c).then(function(b){return g.loadAndInlineCSSResourcesForRules(d,c).then(function(c){var e=b.errors.concat(c.errors),f=b.hasChanges||c.hasChanges;return f&&(a=h.cssRulesToText(d)),{hasChanges:f,content:a,errors:e}})})},m=function(a,b,c){var e=a.textContent,f=k(l,b);return f(e,c,b).then(function(b){return b.hasChanges&&(a.childNodes[0].nodeValue=b.content),d.cloneArray(b.errors)})},n=function(a){var b=a.getElementsByTagName("style");return Array.prototype.filter.call(b,function(a){return!a.attributes.type||"text/css"===a.attributes.type.value})};c.loadAndInlineStyles=function(a,b){var c,e=n(a),f=[],g=[];return c=d.clone(b),c.baseUrl=c.baseUrl||d.getDocumentBaseUrl(a),d.all(e.map(function(a){return m(a,c,g).then(function(a){f=f.concat(a)})})).then(function(){return f})};var o=function(a,b){var c,d=a.parentNode;b=b.trim(),b&&(c=a.ownerDocument.createElement("style"),c.type="text/css",c.appendChild(a.ownerDocument.createTextNode(b)),d.insertBefore(c,a)),d.removeChild(a)},p=function(a,b){return d.ajax(a,b).then(function(a){var b=h.rulesForCssText(a);return{content:a,cssRules:b}}).then(function(b){var c=g.adjustPathsOfCssResources(a,b.cssRules);return{content:b.content,cssRules:b.cssRules,hasChanges:c}}).then(function(a){return g.loadCSSImportsForRules(a.cssRules,[],b).then(function(b){return{content:a.content,cssRules:a.cssRules,hasChanges:a.hasChanges||b.hasChanges,errors:b.errors}})}).then(function(a){return g.loadAndInlineCSSResourcesForRules(a.cssRules,b).then(function(b){return{content:a.content,cssRules:a.cssRules,hasChanges:a.hasChanges||b.hasChanges,errors:a.errors.concat(b.errors)}})}).then(function(a){var b=a.content;return a.hasChanges&&(b=h.cssRulesToText(a.cssRules)),{content:b,errors:a.errors}})},q=function(a,b){var c=a.attributes.href.value,e=d.getDocumentBaseUrl(a.ownerDocument),f=d.clone(b);!f.baseUrl&&e&&(f.baseUrl=e);var g=k(p,b);return g(c,f).then(function(a){return{content:a.content,errors:d.cloneArray(a.errors)}})},r=function(a){var b=a.getElementsByTagName("link");return Array.prototype.filter.call(b,function(a){return a.attributes.rel&&"stylesheet"===a.attributes.rel.value&&(!a.attributes.type||"text/css"===a.attributes.type.value)})};c.loadAndInlineCssLinks=function(a,b){var c=r(a),e=[];return d.all(c.map(function(a){return q(a,b).then(function(b){o(a,b.content+"\n"),e=e.concat(b.errors)},function(a){e.push({resourceType:"stylesheet",url:a.url,msg:"Unable to load stylesheet "+a.url})})})).then(function(){return e})},c.loadAndInlineImages=e.inline,c.loadAndInlineScript=f.inline,c.inlineReferences=function(a,b){var e=[],f=[c.loadAndInlineImages,c.loadAndInlineStyles,c.loadAndInlineCssLinks];return b.inlineScripts!==!1&&f.push(c.loadAndInlineScript),d.all(f.map(function(c){return c(a,b).then(function(a){e=e.concat(a)})})).then(function(){return e})}},{"./cssSupport":28,"./inlineCss":30,"./inlineImage":31,"./inlineScript":32,"./util":33}],30:[function(a,b,c){"use strict";var d=a("ayepromise"),e=a("./util"),f=a("./cssSupport"),g=a("./backgroundValueParser"),h=a("css-font-face-src"),i=function(a,b,c){a.style.setProperty(b,c,a.style.getPropertyPriority(b))},j=function(a){return a.filter(function(a){return a.type===window.CSSRule.STYLE_RULE&&(a.style.getPropertyValue("background-image")||a.style.getPropertyValue("background"))})},k=function(a){var b=[];return a.forEach(function(a){a.style.getPropertyValue("background-image")?b.push({property:"background-image",value:a.style.getPropertyValue("background-image"),rule:a}):a.style.getPropertyValue("background")&&b.push({property:"background",value:a.style.getPropertyValue("background"),rule:a})}),b},l=function(a){return a.filter(function(a){return a.type===window.CSSRule.FONT_FACE_RULE&&a.style.getPropertyValue("src")})},m=function(a){return a.filter(function(a){return a.type===window.CSSRule.IMPORT_RULE&&a.href})},n=function(a){var b=[];return a.forEach(function(a,c){a.url&&!e.isDataUri(a.url)&&b.push(c)}),b},o=function(a){var b=[];return a.forEach(function(a,c){a.url&&!e.isDataUri(a.url)&&b.push(c)}),b};c.adjustPathsOfCssResources=function(a,b){var c=j(b),d=k(c),p=!1;return d.forEach(function(b){var c,d=g.parse(b.value),f=n(d);f.length>0&&(f.forEach(function(b){var c=d[b].url,f=e.joinUrl(a,c);d[b].url=f}),c=g.serialize(d),i(b.rule,b.property,c),p=!0)}),l(b).forEach(function(c){var d,g,i=c.style.getPropertyValue("src");try{d=h.parse(i)}catch(a){return}g=o(d),g.length>0&&(g.forEach(function(b){var c=d[b].url,f=e.joinUrl(a,c);d[b].url=f}),f.changeFontFaceRuleSrc(b,c,h.serialize(d)),p=!0)}),m(b).forEach(function(c){var d=c.href,g=e.joinUrl(a,d);f.exchangeRule(b,c,"@import url("+g+");"),p=!0}),p};var p=function(a,b,c){var d=a.indexOf(b);a.splice(d,1),c.forEach(function(b,c){a.splice(d+c,0,b)})},q=function(a){var b=d.defer();return b.resolve(a),b.promise},r=function(a,b,d,g){var h,i=b.href;return i=f.unquoteString(i),h=e.joinUrl(g.baseUrl,i),d.indexOf(h)>=0?(p(a,b,[]),q([])):(d.push(h),e.ajax(i,g).then(function(e){var h=f.rulesForCssText(e);return c.loadCSSImportsForRules(h,d,g).then(function(d){return c.adjustPathsOfCssResources(i,h),p(a,b,h),d.errors})},function(a){throw{resourceType:"stylesheet",url:a.url,msg:"Unable to load stylesheet "+a.url}}))};c.loadCSSImportsForRules=function(a,b,c){var d=m(a),f=[],g=!1;return e.all(d.map(function(d){return r(a,d,b,c).then(function(a){f=f.concat(a),g=!0},function(a){f.push(a)})})).then(function(){return{hasChanges:g,errors:f}})};var s=function(a,b){var c=g.parse(a),d=n(c),f=!1;return e.collectAndReportErrors(d.map(function(a){var d=c[a].url;return e.getDataURIForImageURL(d,b).then(function(b){c[a].url=b,f=!0},function(a){throw{resourceType:"backgroundImage",url:a.url,msg:"Unable to load background-image "+a.url}})})).then(function(a){return{backgroundValue:g.serialize(c),hasChanges:f,errors:a}})},t=function(a,b){var c=j(a),d=k(c),f=[],g=!1;return e.all(d.map(function(a){return s(a.value,b).then(function(b){b.hasChanges&&(i(a.rule,a.property,b.backgroundValue),g=!0),f=f.concat(b.errors)})})).then(function(){return{hasChanges:g,errors:f}})},u=function(a,b){var c,d,f=!1;try{c=h.parse(a)}catch(a){c=[]}return d=o(c),e.collectAndReportErrors(d.map(function(a){var d=c[a],g=d.format||"woff";return e.binaryAjax(d.url,b).then(function(a){var b=btoa(a);d.url="data:font/"+g+";base64,"+b,f=!0},function(a){throw{resourceType:"fontFace",url:a.url,msg:"Unable to load font-face "+a.url}})})).then(function(a){return{srcDeclarationValue:h.serialize(c),hasChanges:f,errors:a}})},v=function(a,b){var c=l(a),d=[],g=!1;return e.all(c.map(function(c){var e=c.style.getPropertyValue("src");return u(e,b).then(function(b){b.hasChanges&&(f.changeFontFaceRuleSrc(a,c,b.srcDeclarationValue),g=!0),d=d.concat(b.errors)})})).then(function(){return{hasChanges:g,errors:d}})};c.loadAndInlineCSSResourcesForRules=function(a,b){var c=!1,d=[];return e.all([t,v].map(function(e){return e(a,b).then(function(a){c=c||a.hasChanges,d=d.concat(a.errors)})})).then(function(){return{hasChanges:c,errors:d}})}},{"./backgroundValueParser":27,"./cssSupport":28,"./util":33,ayepromise:2,"css-font-face-src":6}],31:[function(a,b,c){"use strict";var d=a("./util"),e=function(a,b){var c=null;a.hasAttribute("src")?c=a.getAttribute("src"):a.hasAttributeNS("http://www.w3.org/1999/xlink","href")?c=a.getAttributeNS("http://www.w3.org/1999/xlink","href"):a.hasAttribute("href")&&(c=a.getAttribute("href"));var e=d.getDocumentBaseUrl(a.ownerDocument),f=d.clone(b);return!f.baseUrl&&e&&(f.baseUrl=e),d.getDataURIForImageURL(c,f).then(function(a){return a},function(a){throw{resourceType:"image",url:a.url,msg:"Unable to load image "+a.url}})},f=function(a){return a.filter(function(a){var b=null;return a.hasAttribute("src")?b=a.getAttribute("src"):a.hasAttributeNS("http://www.w3.org/1999/xlink","href")?b=a.getAttributeNS("http://www.w3.org/1999/xlink","href"):a.hasAttribute("href")&&(b=a.getAttribute("href")),null!==b&&!d.isDataUri(b)})},g=function(a){return Array.prototype.filter.call(a,function(a){return"image"===a.type})},h=function(a){return Array.prototype.slice.call(a)};c.inline=function(a,b){var c=h(a.getElementsByTagName("img")),i=h(a.getElementsByTagName("image")),j=g(a.getElementsByTagName("input"));c=c.concat(i),c=c.concat(j);var k=f(c);return d.collectAndReportErrors(k.map(function(a){return e(a,b).then(function(b){a.attributes.src?a.attributes.src.value=b:a.attributes["xlink:href"]?a.attributes["xlink:href"].value=b:a.attributes.href&&(a.attributes.href.value=b)})}))}},{"./util":33}],32:[function(a,b,c){"use strict";var d=a("./util"),e=function(a,b){var c=a.attributes.src.value,e=d.getDocumentBaseUrl(a.ownerDocument),f=d.clone(b);return!f.baseUrl&&e&&(f.baseUrl=e),d.ajax(c,f).fail(function(a){throw{resourceType:"script",url:a.url,msg:"Unable to load script "+a.url}})},f=function(a){return a.replace(/<\//g,"<\\/")},g=function(a,b){a.attributes.removeNamedItem("src"),a.textContent=f(b)},h=function(a){var b=a.getElementsByTagName("script");return Array.prototype.filter.call(b,function(a){return!!a.attributes.src})};c.inline=function(a,b){var c=h(a);return d.collectAndReportErrors(c.map(function(a){return e(a,b).then(function(b){g(a,b)})}))}},{"./util":33}],33:[function(a,b,c){"use strict";var d=a("url"),e=a("ayepromise");c.getDocumentBaseUrl=function(a){return"about:blank"!==a.baseURI?a.baseURI:null;
},c.clone=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},c.cloneArray=function(a){return Array.prototype.slice.apply(a,[0])},c.joinUrl=function(a,b){return a?d.resolve(a,b):b},c.isDataUri=function(a){return/^data:/.test(a)},c.all=function(a){var b=e.defer(),c=a.length,d=[];return 0===a.length?(b.resolve([]),b.promise):(a.forEach(function(a,e){a.then(function(a){c-=1,d[e]=a,0===c&&b.resolve(d)},function(a){b.reject(a)})}),b.promise)},c.collectAndReportErrors=function(a){var b=[];return c.all(a.map(function(a){return a.fail(function(a){b.push(a)})})).then(function(){return b})};var f=null,g=function(a,b){return b===!1||"none"===b||"repeated"===b?(null!==f&&"repeated"===b||(f=Date.now()),a+"?_="+f):a};c.ajax=function(a,b){var d,f=new window.XMLHttpRequest,h=e.defer(),i=c.joinUrl(b.baseUrl,a),j=function(){h.reject({msg:"Unable to load url",url:i})};d=g(i,b.cache),f.addEventListener("load",function(){200===f.status||0===f.status?h.resolve(f.response):j()},!1),f.addEventListener("error",j,!1);try{f.open("GET",d,!0),f.overrideMimeType(b.mimeType),f.send(null)}catch(a){j()}return h.promise},c.binaryAjax=function(a,b){var d=c.clone(b);return d.mimeType="text/plain; charset=x-user-defined",c.ajax(a,d).then(function(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(255&a.charCodeAt(c));return b})};var h=function(a){var b=function(a,b){return a.substring(0,b.length)===b};return b(a,"<?xml")||b(a,"<svg")?"image/svg+xml":"image/png"};c.getDataURIForImageURL=function(a,b){return c.binaryAjax(a,b).then(function(a){var b=btoa(a),c=h(a);return"data:"+c+";base64,"+b})};var i=[],j=function(a){return i.indexOf(a)<0&&i.push(a),i.indexOf(a)};c.memoize=function(a,b,c){if("object"!=typeof c)throw new Error("cacheBucket is not an object");return function(){var d,e=Array.prototype.slice.call(arguments),f=b(e),g=j(a);return c[g]&&c[g][f]?c[g][f]:(d=a.apply(null,e),c[g]=c[g]||{},c[g][f]=d,d)}}},{ayepromise:2,url:3}],34:[function(b,c,d){(function(b){!function(e){function f(a){throw RangeError(I[a])}function g(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function h(a,b){var c=a.split("@"),d="";c.length>1&&(d=c[0]+"@",a=c[1]),a=a.replace(H,".");var e=a.split("."),f=g(e,b).join(".");return d+f}function i(a){for(var b,c,d=[],e=0,f=a.length;e<f;)b=a.charCodeAt(e++),b>=55296&&b<=56319&&e<f?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function j(a){return g(a,function(a){var b="";return a>65535&&(a-=65536,b+=L(a>>>10&1023|55296),a=56320|1023&a),b+=L(a)}).join("")}function k(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:x}function l(a,b){return a+22+75*(a<26)-((0!=b)<<5)}function m(a,b,c){var d=0;for(a=c?K(a/B):a>>1,a+=K(a/b);a>J*z>>1;d+=x)a=K(a/J);return K(d+(J+1)*a/(a+A))}function n(a){var b,c,d,e,g,h,i,l,n,o,p=[],q=a.length,r=0,s=D,t=C;for(c=a.lastIndexOf(E),c<0&&(c=0),d=0;d<c;++d)a.charCodeAt(d)>=128&&f("not-basic"),p.push(a.charCodeAt(d));for(e=c>0?c+1:0;e<q;){for(g=r,h=1,i=x;e>=q&&f("invalid-input"),l=k(a.charCodeAt(e++)),(l>=x||l>K((w-r)/h))&&f("overflow"),r+=l*h,n=i<=t?y:i>=t+z?z:i-t,!(l<n);i+=x)o=x-n,h>K(w/o)&&f("overflow"),h*=o;b=p.length+1,t=m(r-g,b,0==g),K(r/b)>w-s&&f("overflow"),s+=K(r/b),r%=b,p.splice(r++,0,s)}return j(p)}function o(a){var b,c,d,e,g,h,j,k,n,o,p,q,r,s,t,u=[];for(a=i(a),q=a.length,b=D,c=0,g=C,h=0;h<q;++h)p=a[h],p<128&&u.push(L(p));for(d=e=u.length,e&&u.push(E);d<q;){for(j=w,h=0;h<q;++h)p=a[h],p>=b&&p<j&&(j=p);for(r=d+1,j-b>K((w-c)/r)&&f("overflow"),c+=(j-b)*r,b=j,h=0;h<q;++h)if(p=a[h],p<b&&++c>w&&f("overflow"),p==b){for(k=c,n=x;o=n<=g?y:n>=g+z?z:n-g,!(k<o);n+=x)t=k-o,s=x-o,u.push(L(l(o+t%s,0))),k=K(t/s);u.push(L(l(k,0))),g=m(c,r,d==e),c=0,++d}++c,++b}return u.join("")}function p(a){return h(a,function(a){return F.test(a)?n(a.slice(4).toLowerCase()):a})}function q(a){return h(a,function(a){return G.test(a)?"xn--"+o(a):a})}var r="object"==typeof d&&d&&!d.nodeType&&d,s="object"==typeof c&&c&&!c.nodeType&&c,t="object"==typeof b&&b;t.global!==t&&t.window!==t&&t.self!==t||(e=t);var u,v,w=2147483647,x=36,y=1,z=26,A=38,B=700,C=72,D=128,E="-",F=/^xn--/,G=/[^\x20-\x7E]/,H=/[\x2E\u3002\uFF0E\uFF61]/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},J=x-y,K=Math.floor,L=String.fromCharCode;if(u={version:"1.3.2",ucs2:{decode:i,encode:j},decode:n,encode:o,toASCII:q,toUnicode:p},"function"==typeof a&&"object"==typeof a.amd&&a.amd)a("punycode",function(){return u});else if(r&&s)if(c.exports==r)s.exports=u;else for(v in u)u.hasOwnProperty(v)&&(r[v]=u[v]);else e.punycode=u}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],35:[function(a,b,c){"use strict";function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=function(a,b,c,f){b=b||"&",c=c||"=";var g={};if("string"!=typeof a||0===a.length)return g;var h=/\+/g;a=a.split(b);var i=1e3;f&&"number"==typeof f.maxKeys&&(i=f.maxKeys);var j=a.length;i>0&&j>i&&(j=i);for(var k=0;k<j;++k){var l,m,n,o,p=a[k].replace(h,"%20"),q=p.indexOf(c);q>=0?(l=p.substr(0,q),m=p.substr(q+1)):(l=p,m=""),n=decodeURIComponent(l),o=decodeURIComponent(m),d(g,n)?e(g[n])?g[n].push(o):g[n]=[g[n],o]:g[n]=o}return g};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}},{}],36:[function(a,b,c){"use strict";function d(a,b){if(a.map)return a.map(b);for(var c=[],d=0;d<a.length;d++)c.push(b(a[d],d));return c}var e=function(a){switch(typeof a){case"string":return a;case"boolean":return a?"true":"false";case"number":return isFinite(a)?a:"";default:return""}};b.exports=function(a,b,c,h){return b=b||"&",c=c||"=",null===a&&(a=void 0),"object"==typeof a?d(g(a),function(g){var h=encodeURIComponent(e(g))+c;return f(a[g])?d(a[g],function(a){return h+encodeURIComponent(e(a))}).join(b):h+encodeURIComponent(e(a[g]))}).join(b):h?encodeURIComponent(e(h))+c+encodeURIComponent(e(a)):""};var f=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},g=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}},{}],37:[function(a,b,c){"use strict";c.decode=c.parse=a("./decode"),c.encode=c.stringify=a("./encode")},{"./decode":35,"./encode":36}],38:[function(a,b,c){"use strict";var d=function(a){var b=new XMLSerializer;return Array.prototype.map.call(a.childNodes,function(a){return b.serializeToString(a)}).join("")},e=function(a){return"parsererror"===a.documentElement.tagName&&"http://www.mozilla.org/newlayout/xml/parsererror.xml"===a.documentElement.namespaceURI?a.documentElement:("xml"===a.documentElement.tagName||"html"===a.documentElement.tagName)&&a.documentElement.childNodes&&a.documentElement.childNodes.length>0&&"parsererror"===a.documentElement.childNodes[0].nodeName?a.documentElement.childNodes[0]:"html"===a.documentElement.tagName&&a.documentElement.childNodes&&a.documentElement.childNodes.length>0&&"body"===a.documentElement.childNodes[0].nodeName&&a.documentElement.childNodes[0].childNodes&&a.documentElement.childNodes[0].childNodes.length&&"parsererror"===a.documentElement.childNodes[0].childNodes[0].nodeName?a.documentElement.childNodes[0].childNodes[0]:void 0},f=[new RegExp("^<h3[^>]*>This page contains the following errors:</h3><div[^>]*>(.+?)\n?</div>"),new RegExp("^(.+)\n")],g=function(a){var b,c,e=d(a);for(b=0;b<f.length;b++)if(c=f[b].exec(e))return c[1]},h=function(a){var b;if(null===a)throw new Error("Parse error");var c=e(a);if(void 0!==c)throw b=g(c)||"Parse error",new Error(b)};c.failOnParseError=function(a){return h(a),a}},{}],39:[function(a,b,c){var d=function(a){return a.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")},e=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},f=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},g=function(a){var b=a.value;return" "+a.name+'="'+e(b)+'"'},h=function(a){var b=a.tagName;return"http://www.w3.org/1999/xhtml"===a.namespaceURI&&(b=b.toLowerCase()),b},i=function(a,b){var c=Array.prototype.map.call(a.attributes||a.attrs,function(a){return a.name}).indexOf("xmlns")>=0;return c||!b&&a.namespaceURI===a.parentNode.namespaceURI?"":' xmlns="'+a.namespaceURI+'"'},j=function(a){return Array.prototype.map.call(a.childNodes,function(a){return o(a)}).join("")},k=function(a,b){var c="<"+h(a);return c+=i(a,b),Array.prototype.forEach.call(a.attributes||a.attrs,function(a){c+=g(a)}),a.childNodes.length>0?(c+=">",c+=j(a),c+="</"+h(a)+">"):c+="/>",c},l=function(a){var b=a.nodeValue||a.value||"";return f(b)},m=function(a){return"<!--"+a.data.replace(/-/g,"&#45;")+"-->"},n=function(a){return"<![CDATA["+a.nodeValue+"]]>"},o=function(a,b){var c=b&&b.rootNode;return"#document"===a.nodeName||"#document-fragment"===a.nodeName?j(a):a.tagName?k(a,c):"#text"===a.nodeName?l(a):"#comment"===a.nodeName?m(a):"#cdata-section"===a.nodeName?n(a):void 0};c.serializeToString=function(a){return d(o(a,{rootNode:!0}))}},{}]},{},[1])(1)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.