/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
class StyleNode{constructor(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""}}export{StyleNode};export function parse(r){return parseCss(function lex(s){let r=new StyleNode;r.start=0,r.end=s.length;let n=r;for(let l=0,p=s.length;l<p;l++)if(s[l]===e){n.rules||(n.rules=[]);let e=n,t=e.rules[e.rules.length-1]||null;n=new StyleNode,n.start=l+1,n.parent=e,n.previous=t,e.rules.push(n)}else s[l]===t&&(n.end=l+1,n=n.parent||r);return r}(r=function clean(e){return e.replace(s.comments,"").replace(s.port,"")}(r)),r)}function parseCss(e,t){let p=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=p.trim(),e.parent){let i=e.previous?e.previous.end:e.parent.start;p=t.substring(i,e.start-1),p=function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){let e=arguments[1],t=6-e.length;for(;t--;)e="0"+e;return"\\"+e}))}(p),p=p.replace(s.multipleSpaces," "),p=p.substring(p.lastIndexOf(";")+1);let o=e.parsedSelector=e.selector=p.trim();e.atRule=0===o.indexOf(l),e.atRule?0===o.indexOf(n)?e.type=types.MEDIA_RULE:o.match(s.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(s.multipleSpaces).pop()):0===o.indexOf(r)?e.type=types.MIXIN_RULE:e.type=types.STYLE_RULE}let i=e.rules;if(i)for(let e,s=0,r=i.length;s<r&&(e=i[s]);s++)parseCss(e,t);return e}export function stringify(n,l,p=""){let i="";if(n.cssText||n.rules){let e=n.rules;if(e&&!function _hasMixinRules(e){let t=e[0];return Boolean(t)&&Boolean(t.selector)&&0===t.selector.indexOf(r)}(e))for(let t,s=0,r=e.length;s<r&&(t=e[s]);s++)i=stringify(t,l,i);else i=l?n.cssText:function removeCustomProps(e){return e=removeCustomPropAssignment(e),function removeCustomPropApply(e){return e.replace(s.mixinApply,"").replace(s.varApply,"")}(e)}(n.cssText),i=i.trim(),i&&(i="  "+i+"\n")}return i&&(n.selector&&(p+=n.selector+" "+e+"\n"),p+=i,n.selector&&(p+=t+"\n\n")),p}export function removeCustomPropAssignment(e){return e.replace(s.customProp,"").replace(s.mixinProp,"")}export const types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3};const e="{",t="}",s={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},r="--",n="@media",l="@";