UNPKG

inlineresources

Version:

Inlines style sheets, images, fonts and scripts in HTML documents. Works in the browser.

7 lines 31.9 kB
/*! inlineresources - v1.0.1 - 2025-11-06 * http://www.github.com/cburgmer/inlineresources * Copyright (c) 2025 Christoph Burgmer; Licensed MIT */ /* Integrated dependencies: * url (MIT License), * css-font-face-src (BSD License) */ !function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).inlineresources=t()}(function(){return function n(o,s,a){function u(e,t){if(!s[e]){if(!o[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(i)return i(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}r=s[e]={exports:{}},o[e][0].call(r.exports,function(t){return u(o[e][1][t]||t)},r,r.exports,n,o,s,a)}return s[e].exports}for(var i="function"==typeof require&&require,t=0;t<a.length;t++)u(a[t]);return u}({1:[function(c,r,n){!function(e){!function(){!function(t){"object"==typeof n&&void 0!==r?r.exports=t():("undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:this).cssFontFaceSrc=t()}(function(){return function n(o,s,a){function u(r,t){if(!s[r]){if(!o[r]){var e="function"==typeof c&&c;if(!t&&e)return e(r,!0);if(i)return i(r,!0);t=new Error("Cannot find module '"+r+"'");throw t.code="MODULE_NOT_FOUND",t}e=s[r]={exports:{}};o[r][0].call(e.exports,function(t){var e=o[r][1][t];return u(e||t)},e,e.exports,n,o,s,a)}return s[r].exports}for(var i="function"==typeof c&&c,t=0;t<a.length;t++)u(a[t]);return u}({1:[function(M,t,e){"use strict";function H(t,e,r,n){this.message=t,this.expected=e,this.found=r,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,H)}function r(){this.constructor=n}var n,o;n=H,o=Error,r.prototype=o.prototype,n.prototype=new r,H.buildMessage=function(t,e){var s={literal:function(t){return'"'+n(t.text)+'"'},class:function(t){for(var e="",r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?o(t.parts[r][0])+"-"+o(t.parts[r][1]):o(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function r(t){return t.charCodeAt(0).toString(16).toUpperCase()}function n(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+r(t)})}function o(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(t){return"\\x"+r(t)})}return"Expected "+function(t){for(var e,r,n=new Array(t.length),o=0;o<t.length;o++)n[o]=(r=t[o],s[r.type](r));if(n.sort(),0<n.length){for(e=o=1;o<n.length;o++)n[o-1]!==n[o]&&(n[e]=n[o],e++);n.length=e}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(t)+" but "+((t=e)?'"'+n(t)+'"':"end of input")+" found."},t.exports={SyntaxError:H,parse:function(u,t){var i={},e={start:F},r=F,n="",o=function(){return[]},c=",",l=j(",",!1),h=function(t,e){return[t].concat(e)},f=function(t){return[t]},s=function(t,e){return{url:t,format:e}},a=function(t){return{url:t}},p="url(",g=j("url(",!1),m=")",d=j(")",!1),y="format(",N=j("format(",!1),v="local(",D=j("local(",!1),V=function(t){return{local:t}},b=/^[^)]/,x=S([")"],!0,!1),L=function(t){return _.extractValue(t.join(""))},$=/^[ \t\r\n\f]/,B=S([" ","\t","\r","\n","\f"],!1,!1),w=0,C=[{line:1,column:1}],A=0,R=[],U=0;if("startRule"in(t=void 0!==t?t:{})){if(!(t.startRule in e))throw new Error("Can't start parsing from rule \""+t.startRule+'".');r=e[t.startRule]}function j(t,e){return{type:"literal",text:t,ignoreCase:e}}function S(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function O(t){var e,r=C[t];if(r)return r;for(e=t-1;!C[e];)e--;for(r={line:(r=C[e]).line,column:r.column};e<t;)10===u.charCodeAt(e)?(r.line++,r.column=1):r.column++,e++;return C[t]=r}function E(t,e){var r=O(t),n=O(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:n.line,column:n.column}}}function I(t){w<A||(A<w&&(A=w,R=[]),R.push(t))}function z(t,e,r){return new H(H.buildMessage(t,e),t,e,r)}function F(){var t,e=function t(){var e,r,n,o,s,a;e=w;r=P();if(r!==i){for(n=[],o=q();o!==i;)n.push(o),o=q();if(n!==i)if(44===u.charCodeAt(w)?(o=c,w++):(o=i,0===U&&I(l)),o!==i){for(s=[],a=q();a!==i;)s.push(a),a=q();e=s!==i&&(a=t())!==i?r=h(r,a):(w=e,i)}else w=e,e=i;else w=e,e=i}else w=e,e=i;e===i&&(e=w,(r=P())!==i&&(r=f(r)),e=r);return e}();return e===i&&(e=w,(t=n)!==i&&(t=o()),e=t),e}function P(){var t=function(){var t,e,r,n;if(t=w,(e=T())!==i){if(r=[],(n=q())!==i)for(;n!==i;)r.push(n),n=q();else r=i;t=r!==i&&(n=function(){var t,e,r,n;t=w,u.substr(w,7)===y?(e=y,w+=7):(e=i,0===U&&I(N));t=e!==i&&(r=k(),r!==i)&&(41===u.charCodeAt(w)?(n=m,w++):(n=i,0===U&&I(d)),n!==i)?e=r:(w=t,i);return t}())!==i?e=s(e,n):(w=t,i)}else w=t,t=i;t===i&&(t=w,(e=T())!==i&&(e=a(e)),t=e);return t}();return t=t===i?function(){var t,e,r,n;t=w,u.substr(w,6)===v?(e=v,w+=6):(e=i,0===U&&I(D));t=e!==i&&(r=k(),r!==i)&&(41===u.charCodeAt(w)?(n=m,w++):(n=i,0===U&&I(d)),n!==i)?e=V(r):(w=t,i);return t}():t}function T(){var t,e,r,n=w;return u.substr(w,4)===p?(t=p,w+=4):(t=i,0===U&&I(g)),n=t!==i&&(e=k())!==i&&(41===u.charCodeAt(w)?(r=m,w++):(r=i,0===U&&I(d)),r!==i)?t=e:(w=n,i)}function k(){var t,e=w,r=[];if(b.test(u.charAt(w))?(t=u.charAt(w),w++):(t=i,0===U&&I(x)),t!==i)for(;t!==i;)r.push(t),b.test(u.charAt(w))?(t=u.charAt(w),w++):(t=i,0===U&&I(x));else r=i;return r!==i&&(r=L(r)),r}function q(){var t;return $.test(u.charAt(w))?(t=u.charAt(w),w++):(t=i,0===U&&I(B)),t}var _=M("../util");if((e=r())!==i&&w===u.length)return e;throw e!==i&&w<u.length&&I({type:"end"}),z(R,A<u.length?u.charAt(A):null,A<u.length?E(A,A+1):E(A,A))}}},{"../util":3}],2:[function(t,e,r){var n=t("./grammar");r.SyntaxError=function(t,e){this.message=t,this.offset=e},r.parse=function(t){try{return n.parse(t)}catch(t){throw new r.SyntaxError(t.message,t.offset)}},r.serialize=function(t){return t.map(function(t){var e;return t.url?(e='url("'+t.url+'")',t.format&&(e+=' format("'+t.format+'")')):e='local("'+t.local+'")',e}).join(", ")}},{"./grammar":1}],3:[function(t,e,r){r.extractValue=function(t){return t=t.replace(/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/,"$1"),r=/^'(.*)'$/,(e=/^"(.*)"$/).test(t)?t.replace(e,"$1"):r.test(t)?t.replace(r,"$1"):t;var e,r}},{}]},{},[2])(2)})}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,O,E){!function(S){!function(){var t=this,e="object"==typeof E&&E&&!E.nodeType&&E,r="object"==typeof O&&O&&!O.nodeType&&O,n="object"==typeof S&&S;n.global!==n&&n.window!==n&&n.self!==n||(t=n);var o,s,d=2147483647,y=36,v=26,a=38,u=700,i=/^xn--/,c=/[^\x20-\x7E]/,l=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=y-1,b=Math.floor,x=String.fromCharCode;function w(t){throw new RangeError(h[t])}function p(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function g(t,e){var r=t.split("@"),n="",r=(1<r.length&&(n=r[0]+"@",t=r[1]),(t=t.replace(l,".")).split("."));return n+p(r,e).join(".")}function C(t){for(var e,r,n=[],o=0,s=t.length;o<s;)55296<=(e=t.charCodeAt(o++))&&e<=56319&&o<s?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function m(t){return p(t,function(t){var e="";return 65535<t&&(e+=x((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=x(t)}).join("")}function A(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function R(t,e,r){var n=0;for(t=r?b(t/u):t>>1,t+=b(t/e);f*v>>1<t;n+=y)t=b(t/f);return b(n+(f+1)*t/(t+a))}function U(t){var e,r,n,o,s,a,u,i=[],c=t.length,l=0,h=128,f=72,p=t.lastIndexOf("-");for(p<0&&(p=0),r=0;r<p;++r)128<=t.charCodeAt(r)&&w("not-basic"),i.push(t.charCodeAt(r));for(n=0<p?p+1:0;n<c;){for(o=l,s=1,a=y;c<=n&&w("invalid-input"),u=t.charCodeAt(n++),(y<=(u=u-48<10?u-22:u-65<26?u-65:u-97<26?u-97:y)||u>b((d-l)/s))&&w("overflow"),l+=u*s,!(u<(u=a<=f?1:f+v<=a?v:a-f));a+=y)s>b(d/(u=y-u))&&w("overflow"),s*=u;f=R(l-o,e=i.length+1,0==o),b(l/e)>d-h&&w("overflow"),h+=b(l/e),l%=e,i.splice(l++,0,h)}return m(i)}function j(t){for(var e,r,n,o,s,a,u,i,c,l,h=[],f=(t=C(t)).length,p=128,g=72,m=e=0;m<f;++m)(u=t[m])<128&&h.push(x(u));for(r=n=h.length,n&&h.push("-");r<f;){for(o=d,m=0;m<f;++m)p<=(u=t[m])&&u<o&&(o=u);for(o-p>b((d-e)/(i=r+1))&&w("overflow"),e+=(o-p)*i,p=o,m=0;m<f;++m)if((u=t[m])<p&&++e>d&&w("overflow"),u==p){for(s=e,a=y;!(s<(c=a<=g?1:g+v<=a?v:a-g));a+=y)h.push(x(A(c+(l=s-c)%(c=y-c),0))),s=b(l/c);h.push(x(A(s,0))),g=R(e,i,r==n),e=0,++r}++e,++p}return h.join("")}if(o={version:"1.4.1",ucs2:{decode:C,encode:m},decode:U,encode:j,toASCII:function(t){return g(t,function(t){return c.test(t)?"xn--"+j(t):t})},toUnicode:function(t){return g(t,function(t){return i.test(t)?U(t.slice(4).toLowerCase()):t})}},e&&r)if(O.exports==e)r.exports=o;else for(s in o)o.hasOwnProperty(s)&&(e[s]=o[s]);else t.punycode=o}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){e=e||"&",r=r||"=";var o={};if("string"==typeof t&&0!==t.length){var s=/\+/g,e=(t=t.split(e),1e3),a=(n&&"number"==typeof n.maxKeys&&(e=n.maxKeys),t.length);0<e&&e<a&&(a=e);for(var u=0;u<a;++u){var i,c=t[u].replace(s,"%20"),l=c.indexOf(r),l=0<=l?(i=c.substr(0,l),c.substr(l+1)):(i=c,""),c=decodeURIComponent(i),l=decodeURIComponent(l);Object.prototype.hasOwnProperty.call(o,c)?h(o[c])?o[c].push(l):o[c]=[o[c],l]:o[c]=l}}return o};var h=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],4:[function(t,e,r){"use strict";function s(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}e.exports=function(r,n,o,t){return n=n||"&",o=o||"=","object"==typeof(r=null===r?void 0:r)?u(i(r),function(t){var e=encodeURIComponent(s(t))+o;return a(r[t])?u(r[t],function(t){return e+encodeURIComponent(s(t))}).join(n):e+encodeURIComponent(s(r[t]))}).join(n):t?encodeURIComponent(s(t))+o+encodeURIComponent(s(r)):""};var a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function u(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var i=Object.keys||function(t){var e,r=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(e);return r}},{}],5:[function(t,e,r){"use strict";r.decode=r.parse=t("./decode"),r.encode=r.stringify=t("./encode")},{"./decode":3,"./encode":4}],6:[function(t,e,r){"use strict";var A=t("punycode"),R=t("./util");function w(){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}r.parse=o,r.resolve=function(t,e){return o(t,!1,!0).resolve(e)},r.resolveObject=function(t,e){return t?o(t,!1,!0).resolveObject(e):e},r.format=function(t){R.isString(t)&&(t=o(t));return t instanceof w?t.format():w.prototype.format.call(t)},r.Url=w;var U=/^([a-z0-9.+-]+:)/i,n=/:[0-9]*$/,j=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,r=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),S=["'"].concat(r),O=["%","/","?",";","#"].concat(S),E=["/","?","#"],I=/^[+a-z0-9A-Z_-]{0,63}$/,F=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,P={javascript:!0,"javascript:":!0},T={javascript:!0,"javascript:":!0},k={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},q=t("querystring");function o(t,e,r){var n;return t&&R.isObject(t)&&t instanceof w?t:((n=new w).parse(t,e,r),n)}w.prototype.parse=function(t,e,r){if(!R.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),n=-1!==n&&n<t.indexOf("#")?"?":"#",o=t.split(n);o[0]=o[0].replace(/\\/g,"/");var s=(s=t=o.join(n)).trim();if(!r&&1===t.split("#").length){o=j.exec(s);if(o)return this.path=s,this.href=s,this.pathname=o[1],o[2]?(this.search=o[2],this.query=e?q.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var a,n=U.exec(s);if(n&&(a=(n=n[0]).toLowerCase(),this.protocol=a,s=s.substr(n.length)),!(r||n||s.match(/^\/\/[^@\/]+@[^@\/]+/))||!(x="//"===s.substr(0,2))||n&&T[n]||(s=s.substr(2),this.slashes=!0),!T[n]&&(x||n&&!k[n])){for(var u=-1,i=0;i<E.length;i++)-1!==(c=s.indexOf(E[i]))&&(-1===u||c<u)&&(u=c);-1!==(t=-1===u?s.lastIndexOf("@"):s.lastIndexOf("@",u))&&(o=s.slice(0,t),s=s.slice(t+1),this.auth=decodeURIComponent(o));for(var c,u=-1,i=0;i<O.length;i++)-1!==(c=s.indexOf(O[i]))&&(-1===u||c<u)&&(u=c);-1===u&&(u=s.length),this.host=s.slice(0,u),s=s.slice(u),this.parseHost(),this.hostname=this.hostname||"";r="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!r)for(var l=this.hostname.split(/\./),i=0,h=l.length;i<h;i++){var f=l[i];if(f&&!f.match(I)){for(var p="",g=0,m=f.length;g<m;g++)127<f.charCodeAt(g)?p+="x":p+=f[g];if(!p.match(I)){var d=l.slice(0,i),y=l.slice(i+1),v=f.match(F);v&&(d.push(v[1]),y.unshift(v[2])),y.length&&(s="/"+y.join(".")+s),this.hostname=d.join(".");break}}}255<this.hostname.length?this.hostname="":this.hostname=this.hostname.toLowerCase(),r||(this.hostname=A.toASCII(this.hostname));var b=this.port?":"+this.port:"",x=this.hostname||"";this.host=x+b,this.href+=this.host,r&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0])&&(s="/"+s)}if(!P[a])for(i=0,h=S.length;i<h;i++){var w,C=S[i];-1!==s.indexOf(C)&&((w=encodeURIComponent(C))===C&&(w=escape(C)),s=s.split(C).join(w))}n=s.indexOf("#"),-1!==n&&(this.hash=s.substr(n),s=s.slice(0,n)),t=s.indexOf("?");return-1!==t?(this.search=s.substr(t),this.query=s.substr(t+1),e&&(this.query=q.parse(this.query)),s=s.slice(0,t)):e&&(this.search="",this.query={}),s&&(this.pathname=s),k[a]&&this.hostname&&!this.pathname&&(this.pathname="/"),(this.pathname||this.search)&&(b=this.pathname||"",o=this.search||"",this.path=b+o),this.href=this.format(),this},w.prototype.format=function(){var t=this.auth||"",e=(t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@"),this.protocol||""),r=this.pathname||"",n=this.hash||"",o=!1,s="",t=(this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port)&&(o+=":"+this.port),this.query&&R.isObject(this.query)&&Object.keys(this.query).length&&(s=q.stringify(this.query)),this.search||s&&"?"+s||"");return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||k[e])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o=o||"",n&&"#"!==n.charAt(0)&&(n="#"+n),t&&"?"!==t.charAt(0)&&(t="?"+t),e+o+(r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(t=t.replace("#","%23"))+n},w.prototype.resolve=function(t){return this.resolveObject(o(t,!1,!0)).format()},w.prototype.resolveObject=function(t){R.isString(t)&&((f=new w).parse(t,!1,!0),t=f);for(var e=new w,r=Object.keys(this),n=0;n<r.length;n++){var o=r[n];e[o]=this[o]}if(e.hash=t.hash,""!==t.href)if(t.slashes&&!t.protocol){for(var s=Object.keys(t),a=0;a<s.length;a++){var u=s[a];"protocol"!==u&&(e[u]=t[u])}k[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/")}else if(t.protocol&&t.protocol!==e.protocol)if(k[t.protocol]){if(e.protocol=t.protocol,t.host||T[t.protocol])e.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),e.pathname=i.join("/")}e.search=t.search,e.query=t.query,e.host=t.host||"",e.auth=t.auth,e.hostname=t.hostname||t.host,e.port=t.port,(e.pathname||e.search)&&(f=e.pathname||"",p=e.search||"",e.path=f+p),e.slashes=e.slashes||t.slashes}else for(var c=Object.keys(t),l=0;l<c.length;l++){var h=c[l];e[h]=t[h]}else{var f=e.pathname&&"/"===e.pathname.charAt(0),p=t.host||t.pathname&&"/"===t.pathname.charAt(0),f=p||f||e.host&&t.pathname,g=f,m=e.pathname&&e.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],d=e.protocol&&!k[e.protocol];if(d&&(e.hostname="",e.port=null,e.host&&(""===m[0]?m[0]=e.host:m.unshift(e.host)),e.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),f=f&&(""===i[0]||""===m[0])),p)e.host=(t.host||""===t.host?t:e).host,e.hostname=(t.hostname||""===t.hostname?t:e).hostname,e.search=t.search,e.query=t.query,m=i;else if(i.length)(m=m||[]).pop(),m=m.concat(i),e.search=t.search,e.query=t.query;else if(!R.isNullOrUndefined(t.search))return d&&(e.hostname=e.host=m.shift(),x=!!(e.host&&0<e.host.indexOf("@"))&&e.host.split("@"))&&(e.auth=x.shift(),e.host=e.hostname=x.shift()),e.search=t.search,e.query=t.query,R.isNull(e.pathname)&&R.isNull(e.search)||(e.path=(e.pathname||"")+(e.search||"")),e.href=e.format(),e;if(m.length){for(var y=m.slice(-1)[0],p=(e.host||t.host||1<m.length)&&("."===y||".."===y)||""===y,v=0,b=m.length;0<=b;b--)"."===(y=m[b])?m.splice(b,1):".."===y?(m.splice(b,1),v++):v&&(m.splice(b,1),v--);if(!f&&!g)for(;v--;)m.unshift("..");!f||""===m[0]||m[0]&&"/"===m[0].charAt(0)||m.unshift(""),p&&"/"!==m.join("/").substr(-1)&&m.push("");var x,g=""===m[0]||m[0]&&"/"===m[0].charAt(0);d&&(e.hostname=e.host=!g&&m.length?m.shift():"",x=!!(e.host&&0<e.host.indexOf("@"))&&e.host.split("@"))&&(e.auth=x.shift(),e.host=e.hostname=x.shift()),(f=f||e.host&&m.length)&&!g&&m.unshift(""),m.length?e.pathname=m.join("/"):(e.pathname=null,e.path=null),R.isNull(e.pathname)&&R.isNull(e.search)||(e.path=(e.pathname||"")+(e.search||"")),e.auth=t.auth||e.auth,e.slashes=e.slashes||t.slashes}else e.pathname=null,e.search?e.path="/"+e.search:e.path=null}return e.href=e.format(),e},w.prototype.parseHost=function(){var t=this.host,e=n.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":7,punycode:2,querystring:5}],7:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],8:[function(t,e,r){"use strict";function n(t){var e,o="(url\\(\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*\\)|[^,\\s]+)",r="(?:\\s*"+o+")+",n=new RegExp(r,"g"),s=[];if(t.match(new RegExp("^\\s*((?:\\s*(url\\(\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*\\)|[^,\\s]+))+)(?:\\s*,\\s*((?:\\s*(url\\(\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*\\)|[^,\\s]+))+))*\\s*$"))){for(e=n.exec(t);e;)s.push(function(t){for(var e=new RegExp(o,"g"),r=[],n=e.exec(t);n;)r.push(n[1]),n=e.exec(t);return r}(e[0])),e=n.exec(t);return s}return[]}var o=t("./cssSupport");r.extractCssUrl=function(t){var e=/^url\(("[^"]+"|'[^']+'|[^\)]+)\)/;if(e.test(t))return e=e.exec(t)[1],o.unquoteString(e.replace(/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/,"$1"));throw new Error("Invalid url")};r.parse=function(t){return n(t).map(function(t){var e=function(t){for(var e=0;e<t.length;e++)try{return{url:r.extractCssUrl(t[e]),idx:e}}catch(t){}}(t);return e?{preUrl:t.slice(0,e.idx),url:e.url,postUrl:t.slice(e.idx+1)}:{preUrl:t}})},r.serialize=function(t){return t.map(function(t){var e=[].concat(t.preUrl);return t.url&&e.push('url("'+t.url+'")'),(e=t.postUrl?e.concat(t.postUrl):e).join(" ")}).join(", ")}},{"./cssSupport":9}],9:[function(t,e,s){"use strict";s.unquoteString=function(t){var e=/^"(.*)"$/,r=/^'(.*)'$/;return e.test(t)?t.replace(e,"$1"):r.test(t)?t.replace(r,"$1"):t},s.rulesForCssText=function(t,e){var r=document.implementation.createHTMLDocument(""),n=document.createElement("style");return n.textContent=t,e&&e.nonce&&(n.nonce=e.nonce),r.body.appendChild(n),t=n.sheet.cssRules,Array.prototype.slice.call(t)},s.cssRulesToText=function(t){return t.reduce(function(t,e){return t+e.cssText},"")},s.exchangeRule=function(t,e,r,n){e=t.indexOf(e);t[e]=s.rulesForCssText(r,n)[0]},s.changeFontFaceRuleSrc=function(t,e,r,n){var o="@font-face { font-family: "+e.style.getPropertyValue("font-family")+"; ";e.style.getPropertyValue("font-style")&&(o+="font-style: "+e.style.getPropertyValue("font-style")+"; "),e.style.getPropertyValue("font-weight")&&(o+="font-weight: "+e.style.getPropertyValue("font-weight")+"; "),e.style.getPropertyValue("unicode-range")&&(o+="unicode-range: "+e.style.getPropertyValue("unicode-range")+"; "),s.exchangeRule(t,e,o+="src: "+r+"}",n)}},{}],10:[function(t,e,o){"use strict";function u(t,e){return!1!==e.cache&&"none"!==e.cache&&e.cacheBucket?l.memoize(t,h,e.cacheBucket):t}function i(n,t,e){var o=a.rulesForCssText(n,e);return s.loadCSSImportsForRules(o,t,e).then(function(r){return s.loadAndInlineCSSResourcesForRules(o,e).then(function(t){var e=r.errors.concat(t.errors),t=r.hasChanges||t.hasChanges;return{hasChanges:t,content:n=t?a.cssRulesToText(o):n,errors:e}})})}function c(r,n){return l.ajax(r,n).then(function(t){return{content:t,cssRules:a.rulesForCssText(t,n)}}).then(function(t){var e=s.adjustPathsOfCssResources(r,t.cssRules,n);return{content:t.content,cssRules:t.cssRules,hasChanges:e}}).then(function(e){return s.loadCSSImportsForRules(e.cssRules,[],n).then(function(t){return{content:e.content,cssRules:e.cssRules,hasChanges:e.hasChanges||t.hasChanges,errors:t.errors}})}).then(function(e){return s.loadAndInlineCSSResourcesForRules(e.cssRules,n).then(function(t){return{content:e.content,cssRules:e.cssRules,hasChanges:e.hasChanges||t.hasChanges,errors:e.errors.concat(t.errors)}})}).then(function(t){var e=t.content;return{content:e=t.hasChanges?a.cssRulesToText(t.cssRules):e,errors:t.errors}})}var l=t("./util"),r=t("./inlineImage"),n=t("./inlineScript"),s=t("./inlineCss"),a=t("./cssSupport"),h=function(r){return r.map(function(t,e){return e===r.length-1&&(t={baseUrl:(e=t.baseUrl,l.joinUrl(e,"."))}),JSON.stringify(t)})};o.loadAndInlineStyles=function(t,e){var r=function(t){t=t.getElementsByTagName("style");return Array.prototype.filter.call(t,function(t){return!t.attributes.type||"text/css"===t.attributes.type.value})}(t),o=[],s=[],a=l.clone(e);return a.baseUrl=a.baseUrl||l.getDocumentBaseUrl(t),Promise.all(r.map(function(t){return r=a,n=s,t=(e=t).textContent,u(i,r)(t,n,r).then(function(t){return t.hasChanges&&(e.childNodes[0].nodeValue=t.content),l.cloneArray(t.errors)}).then(function(t){o=o.concat(t)});var e,r,n})).then(function(){return o})};o.loadAndInlineCssLinks=function(t,o){var t=function(t){t=t.getElementsByTagName("link");return Array.prototype.filter.call(t,function(t){return t.attributes.rel&&"stylesheet"===t.attributes.rel.value&&(!t.attributes.type||"text/css"===t.attributes.type.value)})}(t),a=[];return Promise.all(t.map(function(s){return e=o,r=(t=s).attributes.href.value,t=l.getDocumentBaseUrl(t.ownerDocument),!(n=l.clone(e)).baseUrl&&t&&(n.baseUrl=t),u(c,e)(r,n).then(function(t){return{content:t.content,errors:l.cloneArray(t.errors)}}).then(function(t){var e,r,n,o;e=s,r=t.content+"\n",o=e.parentNode,(r=r.trim())&&((n=e.ownerDocument.createElement("style")).type="text/css",n.appendChild(e.ownerDocument.createTextNode(r)),o.insertBefore(n,e)),o.removeChild(e),a=a.concat(t.errors)},function(t){a.push({resourceType:"stylesheet",url:t.url,msg:"Unable to load stylesheet "+t.url})});var t,e,r,n})).then(function(){return a})},o.loadAndInlineImages=r.inline,o.loadAndInlineScript=n.inline,o.inlineReferences=function(e,r){var n=[],t=[o.loadAndInlineImages,o.loadAndInlineStyles,o.loadAndInlineCssLinks];return!1!==r.inlineScripts&&t.push(o.loadAndInlineScript),Promise.all(t.map(function(t){return t(e,r).then(function(t){n=n.concat(t)})})).then(function(){return n})}},{"./cssSupport":9,"./inlineCss":11,"./inlineImage":12,"./inlineScript":13,"./util":14}],11:[function(t,e,h){"use strict";function i(t,e,r){t.style.setProperty(e,r,t.style.getPropertyPriority(e))}function r(t){return t.filter(function(t){return t.type===window.CSSRule.STYLE_RULE&&(t.style.getPropertyValue("background-image")||t.style.getPropertyValue("background"))})}function c(t){var e=[];return t.forEach(function(t){t.style.getPropertyValue("background-image")?e.push({property:"background-image",value:t.style.getPropertyValue("background-image"),rule:t}):t.style.getPropertyValue("background")&&e.push({property:"background",value:t.style.getPropertyValue("background"),rule:t})}),e}function u(t){return t.filter(function(t){return t.type===window.CSSRule.FONT_FACE_RULE&&t.style.getPropertyValue("src")})}function f(t){return t.filter(function(t){return t.type===window.CSSRule.IMPORT_RULE&&t.href})}function p(r,t,e){var n=r.indexOf(t);r.splice(n,1),e.forEach(function(t,e){r.splice(n+e,0,t)})}function s(t,s){var t=r(t),t=c(t),a=[],u=!1;return Promise.all(t.map(function(e){return t=e.value,r=s,n=l.parse(t),t=y(n),o=!1,g.collectAndReportErrors(t.map(function(e){var t=n[e].url;return g.getDataURIForImageURL(t,r).then(function(t){n[e].url=t,o=!0},function(t){throw{resourceType:"backgroundImage",url:t.url,msg:"Unable to load background-image "+t.url}})})).then(function(t){return{backgroundValue:l.serialize(n),hasChanges:o,errors:t}}).then(function(t){t.hasChanges&&(i(e.rule,e.property,t.backgroundValue),u=!0),a=a.concat(t.errors)});var t,r,n,o})).then(function(){return{hasChanges:u,errors:a}})}function a(r,n){var t=u(r),o=[],s=!1;return Promise.all(t.map(function(e){return function(t,n){var o,s=!1;try{o=d.parse(t)}catch(t){o=[]}return t=v(o),g.collectAndReportErrors(t.map(function(t){var e=o[t],r=e.format||"woff";return g.binaryAjax(e.url,n).then(function(t){t=btoa(t);e.url="data:font/"+r+";base64,"+t,s=!0},function(t){throw{resourceType:"fontFace",url:t.url,msg:"Unable to load font-face "+t.url}})})).then(function(t){return{srcDeclarationValue:d.serialize(o),hasChanges:s,errors:t}})}(e.style.getPropertyValue("src"),n).then(function(t){t.hasChanges&&(m.changeFontFaceRuleSrc(r,e,t.srcDeclarationValue,n),s=!0),o=o.concat(t.errors)})})).then(function(){return{hasChanges:s,errors:o}})}var g=t("./util"),m=t("./cssSupport"),l=t("./backgroundValueParser"),d=t("css-font-face-src"),y=function(t){var r=[];return t.forEach(function(t,e){t.url&&!g.isDataUri(t.url)&&r.push(e)}),r},v=function(t){var r=[];return t.forEach(function(t,e){t.url&&!g.isDataUri(t.url)&&r.push(e)}),r};h.adjustPathsOfCssResources=function(n,o,s){var t=r(o),t=c(t),a=!1;return t.forEach(function(t){var r=l.parse(t.value),e=y(r);0<e.length&&(e.forEach(function(t){var e=r[t].url,e=g.joinUrl(n,e);r[t].url=e}),e=l.serialize(r),i(t.rule,t.property,e),a=!0)}),u(o).forEach(function(t){var r,e=t.style.getPropertyValue("src");try{r=d.parse(e)}catch(t){return}0<(e=v(r)).length&&(e.forEach(function(t){var e=r[t].url,e=g.joinUrl(n,e);r[t].url=e}),m.changeFontFaceRuleSrc(o,t,d.serialize(r,s),s),a=!0)}),f(o).forEach(function(t){var e=t.href,e=g.joinUrl(n,e);m.exchangeRule(o,t,"@import url("+e+");",s),a=!0}),a},h.loadCSSImportsForRules=function(e,u,i){var t=f(e),c=[],l=!1;return Promise.all(t.map(function(t){return r=e,o=u,s=i,a=(n=t).href,a=m.unquoteString(a),t=g.joinUrl(s.baseUrl,a),(0<=o.indexOf(t)?(p(r,n,[]),Promise.resolve([])):(o.push(t),g.ajax(a,s).then(function(t){var e=m.rulesForCssText(t,s);return h.loadCSSImportsForRules(e,o,s).then(function(t){return h.adjustPathsOfCssResources(a,e,s),p(r,n,e),t.errors})},function(t){throw{resourceType:"stylesheet",url:t.url,msg:"Unable to load stylesheet "+t.url}}))).then(function(t){c=c.concat(t),l=!0},function(t){c.push(t)});var r,n,o,s,a})).then(function(){return{hasChanges:l,errors:c}})};h.loadAndInlineCSSResourcesForRules=function(e,r){var n=!1,o=[];return Promise.all([s,a].map(function(t){return t(e,r).then(function(t){n=n||t.hasChanges,o=o.concat(t.errors)})})).then(function(){return{hasChanges:n,errors:o}})}},{"./backgroundValueParser":8,"./cssSupport":9,"./util":14,"css-font-face-src":1}],12:[function(t,e,r){"use strict";function n(t){return Array.prototype.slice.call(t)}var s=t("./util");r.inline=function(t,o){var e=n(t.getElementsByTagName("img")),r=n(t.getElementsByTagName("image")),t=(t=t.getElementsByTagName("input"),Array.prototype.filter.call(t,function(t){return"image"===t.type})),r=(e=(e=e.concat(r)).concat(t)).filter(function(t){var e=null;return t.hasAttribute("src")?e=t.getAttribute("src"):t.hasAttributeNS("http://www.w3.org/1999/xlink","href")?e=t.getAttributeNS("http://www.w3.org/1999/xlink","href"):t.hasAttribute("href")&&(e=t.getAttribute("href")),null!==e&&!s.isDataUri(e)});return s.collectAndReportErrors(r.map(function(e){return r=o,n=null,(t=e).hasAttribute("src")?n=t.getAttribute("src"):t.hasAttributeNS("http://www.w3.org/1999/xlink","href")?n=t.getAttributeNS("http://www.w3.org/1999/xlink","href"):t.hasAttribute("href")&&(n=t.getAttribute("href")),t=s.getDocumentBaseUrl(t.ownerDocument),!(r=s.clone(r)).baseUrl&&t&&(r.baseUrl=t),s.getDataURIForImageURL(n,r).then(function(t){return t},function(t){throw{resourceType:"image",url:t.url,msg:"Unable to load image "+t.url}}).then(function(t){e.attributes.src?e.attributes.src.value=t:e.attributes["xlink:href"]?e.attributes["xlink:href"].value=t:e.attributes.href&&(e.attributes.href.value=t)});var t,r,n}))}},{"./util":14}],13:[function(t,e,r){"use strict";var s=t("./util");r.inline=function(t,o){t=function(t){t=t.getElementsByTagName("script");return Array.prototype.filter.call(t,function(t){return!!t.attributes.src})}(t);return s.collectAndReportErrors(t.map(function(r){return e=o,n=(t=r).attributes.src.value,t=s.getDocumentBaseUrl(t.ownerDocument),!(e=s.clone(e)).baseUrl&&t&&(e.baseUrl=t),s.ajax(n,e).catch(function(t){throw{resourceType:"script",url:t.url,msg:"Unable to load script "+t.url}}).then(function(t){var e;t=t,(e=r).attributes.removeNamedItem("src"),e.textContent=t.replace(/<\//g,"<\\/")});var t,e,n}))}},{"./util":14}],14:[function(t,e,c){"use strict";function r(t){function e(t,e){return t.substring(0,e.length)===e}return e(t,"<?xml")||e(t,"<svg")?"image/svg+xml":"image/png"}var n=t("url"),l=(c.getDocumentBaseUrl=function(t){return"about:blank"!==t.baseURI?t.baseURI:null},c.clone=function(t){var e,r={};for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},c.cloneArray=function(t){return Array.prototype.slice.apply(t,[0])},c.joinUrl=function(t,e){return t?n.resolve(t,e):e},c.isDataUri=function(t){return/^data:/.test(t)},c.collectAndReportErrors=function(t){var e=[];return Promise.all(t.map(function(t){return t.catch(function(t){e.push(t)})})).then(function(){return e})},null),a=(c.ajax=function(u,i){return new Promise(function(t,e){function r(){e({msg:"Unable to load url",url:a})}var n,o,s=new window.XMLHttpRequest,a=c.joinUrl(i.baseUrl,u);n=a,o=!1===(o=i.cache)||"none"===o||"repeated"===o?n+"?_="+(l=null!==l&&"repeated"===o?l:Date.now()):n,s.addEventListener("load",function(){200===s.status||0===s.status?t(s.response):r()},!1),s.addEventListener("error",r,!1);try{s.open("GET",o,!0),s.overrideMimeType(i.mimeType),s.send(null)}catch(t){r()}})},c.binaryAjax=function(t,e){e=c.clone(e);return e.mimeType="text/plain; charset=x-user-defined",c.ajax(t,e).then(function(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(255&t.charCodeAt(r));return e})},c.getDataURIForImageURL=function(t,e){return c.binaryAjax(t,e).then(function(t){var e=btoa(t);return"data:"+r(t)+";base64,"+e})},[]);c.memoize=function(n,o,s){if("object"!=typeof s)throw new Error("cacheBucket is not an object");return function(){var t=Array.prototype.slice.call(arguments),e=o(t),r=(a.indexOf(r=n)<0&&a.push(r),a.indexOf(r));return s[r]&&s[r][e]?s[r][e]:(t=n.apply(null,t),s[r]=s[r]||{},s[r][e]=t)}}},{url:6}]},{},[10])(10)});