UNPKG

8.56 kBJavaScriptView Raw
1System.register([],function(){"use strict";return{execute:function(){var e=function(){function e(){this.start=0;this.end=0;this.previous=null;this.parent=null;this.rules=null;this.parsedCssText="";this.cssText="";this.atRule=false;this.type=0;this.keyframesName="";this.selector="";this.parsedSelector=""}return e}();function t(e){e=r(e);return i(n(e),e)}function r(e){return e.replace(c.comments,"").replace(c.port,"")}function n(t){var r=new e;r["start"]=0;r["end"]=t.length;var n=r;for(var i=0,s=t.length;i<s;i++){if(t[i]===o){if(!n["rules"]){n["rules"]=[]}var a=n;var c=a["rules"][a["rules"].length-1]||null;n=new e;n["start"]=i+1;n["parent"]=a;n["previous"]=c;a["rules"].push(n)}else if(t[i]===u){n["end"]=i+1;n=n["parent"]||r}}return r}function i(e,t){var r=t.substring(e["start"],e["end"]-1);e["parsedCssText"]=e["cssText"]=r.trim();if(e.parent){var n=e.previous?e.previous["end"]:e.parent["start"];r=t.substring(n,e["start"]-1);r=s(r);r=r.replace(c.multipleSpaces," ");r=r.substring(r.lastIndexOf(";")+1);var o=e["parsedSelector"]=e["selector"]=r.trim();e["atRule"]=o.indexOf(p)===0;if(e["atRule"]){if(o.indexOf(f)===0){e["type"]=a.MEDIA_RULE}else if(o.match(c.keyframesRule)){e["type"]=a.KEYFRAMES_RULE;e["keyframesName"]=e["selector"].split(c.multipleSpaces).pop()}}else{if(o.indexOf(l)===0){e["type"]=a.MIXIN_RULE}else{e["type"]=a.STYLE_RULE}}}var u=e["rules"];if(u){for(var v=0,h=u.length,m=void 0;v<h&&(m=u[v]);v++){i(m,t)}}return e}function s(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,function(){var e=arguments[1],t=6-e.length;while(t--){e="0"+e}return"\\"+e})}var a={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3};var o="{";var u="}";var c={comments:/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g};var l="--";var f="@media";var p="@";function v(e,t,r){e["lastIndex"]=0;var n=t.substring(r).match(e);if(n){var i=r+n["index"];return{start:i,end:i+n[0].length}}return null}var h=/\bvar\(/;var m=/\B--[\w-]+\s*:/;var g=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim;var d=/^[\t ]+\n/gm;function y(e,t,r){if(e[t]){return e[t]}if(r){return M(r,e)}return""}function S(e,t){var r=0;var n=t;for(;n<e.length;n++){var i=e[n];if(i==="("){r++}else if(i===")"){r--;if(r<=0){return n+1}}}return n}function E(e,t){var r=v(h,e,t);if(!r){return null}var n=S(e,r.start);var i=e.substring(r.end,n-1);var s=i.split(","),a=s[0],o=s.slice(1);return{start:r.start,end:n,propName:a.trim(),fallback:o.length>0?o.join(",").trim():undefined}}function b(e,t,r){var n=E(e,r);if(!n){t.push(e.substring(r,e.length));return e.length}var i=n.propName;var s=n.fallback!=null?x(n.fallback):undefined;t.push(e.substring(r,n.start),function(e){return y(e,i,s)});return n.end}function M(e,t){var r="";for(var n=0;n<e.length;n++){var i=e[n];r+=typeof i==="string"?i:i(t)}return r}function w(e,t){var r=false;var n=false;var i=t;for(;i<e.length;i++){var s=e[i];if(r){if(n&&s==='"'){r=false}if(!n&&s==="'"){r=false}}else{if(s==='"'){r=true;n=true}else if(s==="'"){r=true;n=false}else if(s===";"){return i+1}else if(s==="}"){return i}}}return i}function L(e){var t="";var r=0;while(true){var n=v(m,e,r);var i=n?n.start:e.length;t+=e.substring(r,i);if(n){r=w(e,i)}else{break}}return t}function x(e){var t=0;e=e.replace(g,"");e=L(e).replace(d,"");var r=[];while(t<e.length){t=b(e,r,t)}return r}function R(e){var t={};e.forEach(function(e){e.declarations.forEach(function(e){t[e.prop]=e.value})});var r={};var n=Object.entries(t);var i=function(e){var t=false;n.forEach(function(e){var n=e[0],i=e[1];var s=M(i,r);if(s!==r[n]){r[n]=s;t=true}});if(!t){return"break"}};for(var s=0;s<10;s++){var a=i();if(a==="break")break}return r}function T(e,t){if(t===void 0){t=0}if(!e.rules){return[]}var r=[];e.rules.filter(function(e){return e.type===a.STYLE_RULE}).forEach(function(e){var n=H(e.cssText);if(n.length>0){e.parsedSelector.split(",").forEach(function(e){e=e.trim();r.push({selector:e,declarations:n,specificity:k(),nu:t})})}t++});return r}function k(e){return 1}var I="!important";var _=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gm;function H(e){var t=[];var r;while(r=_.exec(e.trim())){var n=A(r[2]),i=n.value,s=n.important;t.push({prop:r[1].trim(),value:x(i),important:s})}return t}function A(e){var t=/\s+/gim;e=e.replace(t," ").trim();var r=e.endsWith(I);if(r){e=e.substr(0,e.length-I.length).trim()}return{value:e,important:r}}function U(e,t,r){var n=r.concat(N(t,e));var i=O(n);var s=i.filter(function(t){return $(e,t.selector)});return D(s)}function N(e,t){var r=[];while(t){var n=e.get(t);if(n){r.push(n)}t=t.parentElement}return r}function O(e){var t=[];e.forEach(function(e){t.push.apply(t,e.selectors)});return t}function D(e){e.sort(function(e,t){if(e.specificity===t.specificity){return e.nu-t.nu}return e.specificity-t.specificity});return e}function $(e,t){return e.matches(t)}function C(e){var r=t(e);var n=x(e);var i=T(r);return{original:e,template:n,selectors:i,isDynamic:n.length>1}}function G(e,t){var r=C(t.innerHTML);r.styleEl=t;e.push(r)}function Y(e){var t=O(e);var r=R(t);e.forEach(function(e){if(e.isDynamic){e.styleEl.innerHTML=M(e.template,r)}})}function j(e,t){var r=e.template.map(function(r){return typeof r==="string"?P(r,e.cssScopeId,t):r});var n=e.selectors.map(function(r){return Object.assign({},r,{selector:P(r.selector,e.cssScopeId,t)})});return Object.assign({},e,{template:r,selectors:n,cssScopeId:t})}function P(e,t,r){e=q(e,"\\."+t,"."+r);return e}function q(e,t,r){return e.replace(new RegExp(t,"g"),r)}function F(e,t){return W(e,t).then(function(){B(e,t)})}function W(e,t){var r=[];var n=e.querySelectorAll('link[rel="stylesheet"][href]');for(var i=0;i<n.length;i++){r.push(K(e,t,n[i]))}return Promise.all(r)}function B(e,t){var r=e.querySelectorAll("style");for(var n=0;n<r.length;n++){G(t,r[n])}}function K(e,t,r){var n=r.href;return fetch(n).then(function(e){return e.text()}).then(function(i){if(z(i)&&r.parentNode){if(J(i)){i=Q(i,n)}var s=e.createElement("style");s.innerHTML=i;G(t,s);r.parentNode.insertBefore(s,r);r.remove()}}).catch(function(e){console.error(e)})}var X=/[\s;{]--[-a-zA-Z0-9]+\s*:/m;function z(e){return e.indexOf("var(")>-1||X.test(e)}var Z=/url[\s]*\([\s]*['"]?(?![http|\/])([^\'\"\)]*)[\s]*['"]?\)[\s]*/gim;function J(e){Z.lastIndex=0;return Z.test(e)}function Q(e,t){var r=t.replace(/[^\/]*$/,"");return e.replace(Z,function(e,t){var n=r+t;return e.replace(t,n)})}var V=function(){function e(e,t){this.win=e;this.doc=t;this.count=0;this.hostStyleMap=new WeakMap;this.hostScopeMap=new WeakMap;this.globalScopes=[];this.scopesMap=new Map}e.prototype.initShim=function(){var e=this;return new Promise(function(t){e.win.requestAnimationFrame(function(){F(e.doc,e.globalScopes).then(function(){return t()})})})};e.prototype.addLink=function(e){var t=this;return K(this.doc,this.globalScopes,e).then(function(){t.updateGlobal()})};e.prototype.addGlobalStyle=function(e){G(this.globalScopes,e);this.updateGlobal()};e.prototype.createHostStyle=function(e,t,r){if(this.hostScopeMap.has(e)){throw new Error("host style already created")}var n=this.registerHostTemplate(r,t);var i=!!(n.isDynamic&&n.cssScopeId);var s=i||!n.styleEl;var a=this.doc.createElement("style");if(!s){a.innerHTML=r}else{if(i){a["s-sc"]=t=n.cssScopeId+"-"+this.count;a.innerHTML="/*needs update*/";this.hostStyleMap.set(e,a);this.hostScopeMap.set(e,j(n,t));this.count++}else{n.styleEl=a;if(!n.isDynamic){a.innerHTML=M(n.template,{})}this.globalScopes.push(n);this.updateGlobal();this.hostScopeMap.set(e,n)}}return a};e.prototype.removeHost=function(e){var t=this.hostStyleMap.get(e);if(t){t.remove()}this.hostStyleMap.delete(e);this.hostScopeMap.delete(e)};e.prototype.updateHost=function(e){var t=this.hostScopeMap.get(e);if(t&&t.isDynamic&&t.cssScopeId){var r=this.hostStyleMap.get(e);if(r){var n=U(e,this.hostScopeMap,this.globalScopes);var i=R(n);r.innerHTML=M(t.template,i)}}};e.prototype.updateGlobal=function(){Y(this.globalScopes)};e.prototype.registerHostTemplate=function(e,t){var r=this.scopesMap.get(t);if(!r){r=C(e);r.cssScopeId=t;this.scopesMap.set(t,r)}return r};return e}();var ee=window;function te(){return!(ee.CSS&&ee.CSS.supports&&ee.CSS.supports("color","var(--c)"))}if(!ee.__stencil_cssshim&&te()){ee.__stencil_cssshim=new V(ee,document)}}}});
\No newline at end of file