UNPKG

css-tree-animatable

Version:

Fork of css-tree with all but animatable CSS properties removed

1 lines 120 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).csstree=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t={exports:{}},n={};function r(e){return{prev:null,next:null,data:e}}function a(e,t,n){var r;return null!==i?(r=i,i=i.cursor,r.prev=t,r.next=n,r.cursor=e.cursor):r={prev:t,next:n,cursor:e.cursor},e.cursor=r,r}function s(e){var t=e.cursor;e.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=i,i=t}var i=null,o=function(){this.cursor=null,this.head=null,this.tail=null};o.createItem=r,o.prototype.createItem=r,o.prototype.updateCursors=function(e,t,n,r){for(var a=this.cursor;null!==a;)a.prev===e&&(a.prev=t),a.next===n&&(a.next=r),a=a.cursor},o.prototype.getSize=function(){for(var e=0,t=this.head;t;)e++,t=t.next;return e},o.prototype.fromArray=function(e){var t=null;this.head=null;for(var n=0;n<e.length;n++){var a=r(e[n]);null!==t?t.next=a:this.head=a,a.prev=t,t=a}return this.tail=t,this},o.prototype.toArray=function(){for(var e=this.head,t=[];e;)t.push(e.data),e=e.next;return t},o.prototype.toJSON=o.prototype.toArray,o.prototype.isEmpty=function(){return null===this.head},o.prototype.first=function(){return this.head&&this.head.data},o.prototype.last=function(){return this.tail&&this.tail.data},o.prototype.each=function(e,t){var n;void 0===t&&(t=this);for(var r=a(this,null,this.head);null!==r.next;)n=r.next,r.next=n.next,e.call(t,n.data,n,this);s(this)},o.prototype.forEach=o.prototype.each,o.prototype.eachRight=function(e,t){var n;void 0===t&&(t=this);for(var r=a(this,this.tail,null);null!==r.prev;)n=r.prev,r.prev=n.prev,e.call(t,n.data,n,this);s(this)},o.prototype.forEachRight=o.prototype.eachRight,o.prototype.nextUntil=function(e,t,n){if(null!==e){var r;void 0===n&&(n=this);for(var i=a(this,null,e);null!==i.next&&(r=i.next,i.next=r.next,!t.call(n,r.data,r,this)););s(this)}},o.prototype.prevUntil=function(e,t,n){if(null!==e){var r;void 0===n&&(n=this);for(var i=a(this,e,null);null!==i.prev&&(r=i.prev,i.prev=r.prev,!t.call(n,r.data,r,this)););s(this)}},o.prototype.some=function(e,t){var n=this.head;for(void 0===t&&(t=this);null!==n;){if(e.call(t,n.data,n,this))return!0;n=n.next}return!1},o.prototype.map=function(e,t){var n=new o,r=this.head;for(void 0===t&&(t=this);null!==r;)n.appendData(e.call(t,r.data,r,this)),r=r.next;return n},o.prototype.filter=function(e,t){var n=new o,r=this.head;for(void 0===t&&(t=this);null!==r;)e.call(t,r.data,r,this)&&n.appendData(r.data),r=r.next;return n},o.prototype.clear=function(){this.head=null,this.tail=null},o.prototype.copy=function(){for(var e=new o,t=this.head;null!==t;)e.insert(r(t.data)),t=t.next;return e},o.prototype.prepend=function(e){return this.updateCursors(null,e,this.head,e),null!==this.head?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this},o.prototype.prependData=function(e){return this.prepend(r(e))},o.prototype.append=function(e){return this.insert(e)},o.prototype.appendData=function(e){return this.insert(r(e))},o.prototype.insert=function(e,t){if(null!=t)if(this.updateCursors(t.prev,e,t,e),null===t.prev){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),null!==this.tail?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this},o.prototype.insertData=function(e,t){return this.insert(r(e),t)},o.prototype.remove=function(e){if(this.updateCursors(e,e.prev,e,e.next),null!==e.prev)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(null!==e.next)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e},o.prototype.push=function(e){this.insert(r(e))},o.prototype.pop=function(){if(null!==this.tail)return this.remove(this.tail)},o.prototype.unshift=function(e){this.prepend(r(e))},o.prototype.shift=function(){if(null!==this.head)return this.remove(this.head)},o.prototype.prependList=function(e){return this.insertList(e,this.head)},o.prototype.appendList=function(e){return this.insertList(e)},o.prototype.insertList=function(e,t){return null===e.head||(null!=t?(this.updateCursors(t.prev,e.tail,t,e.head),null!==t.prev?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),null!==this.tail?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null),this},o.prototype.replace=function(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)};var c=o,l=function(e,t){var n=Object.create(SyntaxError.prototype),r=new Error;return n.name=e,n.message=t,Object.defineProperty(n,"stack",{get:function(){return(r.stack||"").replace(/^(.+\n){1,3}/,e+": "+t+"\n")}}),n},u=l,h=" ";function p(e,t){function n(e,t){return r.slice(e,t).map((function(t,n){for(var r=String(e+n+1);r.length<c;)r=" "+r;return r+" |"+t})).join("\n")}var r=e.source.split(/\r\n?|\n|\f/),a=e.line,s=e.column,i=Math.max(1,a-t)-1,o=Math.min(a+t,r.length+1),c=Math.max(4,String(o).length)+1,l=0;(s+=(h.length-1)*(r[a-1].substr(0,s-1).match(/\t/g)||[]).length)>100&&(l=s-60+3,s=58);for(var u=i;u<=o;u++)u>=0&&u<r.length&&(r[u]=r[u].replace(/\t/g,h),r[u]=(l>0&&r[u].length>l?"…":"")+r[u].substr(l,98)+(r[u].length>l+100-1?"…":""));return[n(i,a),new Array(s+c+2).join("-")+"^",n(a,o)].filter(Boolean).join("\n")}var d=function(e,t,n,r,a){var s=u("SyntaxError",e);return s.source=t,s.offset=n,s.line=r,s.column=a,s.sourceFragment=function(e){return p(s,isNaN(e)?0:e)},Object.defineProperty(s,"formattedMessage",{get:function(){return"Parse error: "+s.message+"\n"+p(s,2)}}),s.parseError={offset:n,line:r,column:a},s},f={EOF:0,Ident:1,Function:2,AtKeyword:3,Hash:4,String:5,BadString:6,Url:7,BadUrl:8,Delim:9,Number:10,Percentage:11,Dimension:12,WhiteSpace:13,CDO:14,CDC:15,Colon:16,Semicolon:17,Comma:18,LeftSquareBracket:19,RightSquareBracket:20,LeftParenthesis:21,RightParenthesis:22,LeftCurlyBracket:23,RightCurlyBracket:24,Comment:25},y=Object.keys(f).reduce((function(e,t){return e[f[t]]=t,e}),{}),g={TYPE:f,NAME:y};function m(e){return e>=48&&e<=57}function k(e){return e>=65&&e<=90}function x(e){return e>=97&&e<=122}function b(e){return k(e)||x(e)}function v(e){return e>=128}function S(e){return b(e)||v(e)||95===e}function C(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function w(e){return 10===e||13===e||12===e}function A(e){return w(e)||32===e||9===e}function P(e,t){return 92===e&&(!w(t)&&0!==t)}var T=new Array(128);E.Eof=128,E.WhiteSpace=130,E.Digit=131,E.NameStart=132,E.NonPrintable=133;for(var L=0;L<T.length;L++)switch(!0){case A(L):T[L]=E.WhiteSpace;break;case m(L):T[L]=E.Digit;break;case S(L):T[L]=E.NameStart;break;case C(L):T[L]=E.NonPrintable;break;default:T[L]=L||E.Eof}function E(e){return e<128?T[e]:E.NameStart}var D={isDigit:m,isHexDigit:function(e){return m(e)||e>=65&&e<=70||e>=97&&e<=102},isUppercaseLetter:k,isLowercaseLetter:x,isLetter:b,isNonAscii:v,isNameStart:S,isName:function(e){return S(e)||m(e)||45===e},isNonPrintable:C,isNewline:w,isWhiteSpace:A,isValidEscape:P,isIdentifierStart:function(e,t,n){return 45===e?S(t)||45===t||P(t,n):!!S(e)||92===e&&P(e,t)},isNumberStart:function(e,t,n){return 43===e||45===e?m(t)?2:46===t&&m(n)?3:0:46===e?m(t)?2:0:m(e)?1:0},isBOM:function(e){return 65279===e||65534===e?1:0},charCodeCategory:E},O=D.isDigit,B=D.isHexDigit,I=D.isUppercaseLetter,N=D.isName,R=D.isWhiteSpace,M=D.isValidEscape;function W(e,t){return t<e.length?e.charCodeAt(t):0}function F(e,t,n){return 13===n&&10===W(e,t+1)?2:1}function z(e,t,n){var r=e.charCodeAt(t);return I(r)&&(r|=32),r===n}function Y(e,t){for(;t<e.length&&O(e.charCodeAt(t));t++);return t}function U(e,t){if(B(W(e,(t+=2)-1))){for(var n=Math.min(e.length,t+5);t<n&&B(W(e,t));t++);var r=W(e,t);R(r)&&(t+=F(e,t,r))}return t}var j={consumeEscaped:U,consumeName:function(e,t){for(;t<e.length;t++){var n=e.charCodeAt(t);if(!N(n)){if(!M(n,W(e,t+1)))break;t=U(e,t)-1}}return t},consumeNumber:function(e,t){var n=e.charCodeAt(t);if(43!==n&&45!==n||(n=e.charCodeAt(t+=1)),O(n)&&(t=Y(e,t+1),n=e.charCodeAt(t)),46===n&&O(e.charCodeAt(t+1))&&(n=e.charCodeAt(t+=2),t=Y(e,t)),z(e,t,101)){var r=0;45!==(n=e.charCodeAt(t+1))&&43!==n||(r=1,n=e.charCodeAt(t+2)),O(n)&&(t=Y(e,t+1+r+1))}return t},consumeBadUrlRemnants:function(e,t){for(;t<e.length;t++){var n=e.charCodeAt(t);if(41===n){t++;break}M(n,W(e,t+1))&&(t=U(e,t))}return t},cmpChar:z,cmpStr:function(e,t,n,r){if(n-t!==r.length)return!1;if(t<0||n>e.length)return!1;for(var a=t;a<n;a++){var s=e.charCodeAt(a),i=r.charCodeAt(a-t);if(I(s)&&(s|=32),s!==i)return!1}return!0},getNewlineLength:F,findWhiteSpaceStart:function(e,t){for(;t>=0&&R(e.charCodeAt(t));t--);return t+1},findWhiteSpaceEnd:function(e,t){for(;t<e.length&&R(e.charCodeAt(t));t++);return t}},q=g.TYPE,H=g.NAME,V=j.cmpStr,K=q.EOF,Q=q.WhiteSpace,G=q.Comment,X=16777215,_=24,Z=function(){this.offsetAndType=null,this.balance=null,this.reset()};Z.prototype={reset:function(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset},lookupType:function(e){return(e+=this.tokenIndex)<this.tokenCount?this.offsetAndType[e]>>_:K},lookupOffset:function(e){return(e+=this.tokenIndex)<this.tokenCount?this.offsetAndType[e-1]&X:this.source.length},lookupValue:function(e,t){return(e+=this.tokenIndex)<this.tokenCount&&V(this.source,this.offsetAndType[e-1]&X,this.offsetAndType[e]&X,t)},getTokenStart:function(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&X:this.offsetAndType[this.tokenCount]&X:this.firstCharOffset},getRawLength:function(e,t){var n,r=e,a=this.offsetAndType[Math.max(r-1,0)]&X;e:for(;r<this.tokenCount&&!((n=this.balance[r])<e);r++)switch(t(this.offsetAndType[r]>>_,this.source,a)){case 1:break e;case 2:r++;break e;default:a=this.offsetAndType[r]&X,this.balance[n]===r&&(r=n)}return r-this.tokenIndex},isBalanceEdge:function(e){return this.balance[this.tokenIndex]<e},isDelim:function(e,t){return t?this.lookupType(t)===q.Delim&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===q.Delim&&this.source.charCodeAt(this.tokenStart)===e},getTokenValue:function(){return this.source.substring(this.tokenStart,this.tokenEnd)},getTokenLength:function(){return this.tokenEnd-this.tokenStart},substrToCursor:function(e){return this.source.substring(e,this.tokenStart)},skipWS:function(){for(var e=this.tokenIndex,t=0;e<this.tokenCount&&this.offsetAndType[e]>>_===Q;e++,t++);t>0&&this.skip(t)},skipSC:function(){for(;this.tokenType===Q||this.tokenType===G;)this.next()},skip:function(e){var t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&X,t=this.offsetAndType[t],this.tokenType=t>>_,this.tokenEnd=t&X):(this.tokenIndex=this.tokenCount,this.next())},next:function(){var e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>_,this.tokenEnd=e&X):(this.tokenIndex=this.tokenCount,this.eof=!0,this.tokenType=K,this.tokenStart=this.tokenEnd=this.source.length)},dump:function(){var e=this.firstCharOffset;return Array.prototype.slice.call(this.offsetAndType,0,this.tokenCount).map((function(t,n){var r=e,a=t&X;return e=a,{idx:n,type:H[t>>_],chunk:this.source.substring(r,a),balance:this.balance[n]}}),this)}};var $=Z;function J(e){return e}function ee(e,t,n,r){var a,s;switch(e.type){case"Group":a=function(e,t,n,r){var a=" "===e.combinator||r?e.combinator:" "+e.combinator+" ",s=e.terms.map((function(e){return ee(e,t,n,r)})).join(a);return(e.explicit||n)&&(s=(r||","===s[0]?"[":"[ ")+s+(r?"]":" ]")),s}(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return ee(e.term,t,n,r)+t(0===(s=e).min&&0===s.max?"*":0===s.min&&1===s.max?"?":1===s.min&&0===s.max?s.comma?"#":"+":1===s.min&&1===s.max?"":(s.comma?"#":"")+(s.min===s.max?"{"+s.min+"}":"{"+s.min+","+(0!==s.max?s.max:"")+"}"),e);case"Type":a="<"+e.name+(e.opts?t(function(e){switch(e.type){case"Range":return" ["+(null===e.min?"-∞":e.min)+","+(null===e.max?"∞":e.max)+"]";default:throw new Error("Unknown node type `"+e.type+"`")}}(e.opts),e.opts):"")+">";break;case"Property":a="<'"+e.name+"'>";break;case"Keyword":a=e.name;break;case"AtKeyword":a="@"+e.name;break;case"Function":a=e.name+"(";break;case"String":case"Token":a=e.value;break;case"Comma":a=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(a,e)}var te=function(e,t){var n=J,r=!1,a=!1;return"function"==typeof t?n=t:t&&(r=Boolean(t.forceBraces),a=Boolean(t.compact),"function"==typeof t.decorate&&(n=t.decorate)),ee(e,n,r,a)},ne=l,re=te;function ae(e,t){var n=e&&e.loc&&e.loc[t];return n?{offset:n.offset,line:n.line,column:n.column}:null}var se=function(e,t){var n=ne("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},ie=function(e,t,n,r){var a=ne("SyntaxMatchError",e),s=function(e){for(var t=e.tokens,n=e.longestMatch,r=n<t.length?t[n].node:null,a=-1,s=0,i="",o=0;o<t.length;o++)o===n&&(a=i.length),null!==r&&t[o].node===r&&(o<=n?s++:s=0),i+=t[o].value;return{node:r,css:i,mismatchOffset:-1===a?i.length:a,last:null===r||s>1}}(r),i=s.mismatchOffset||0,o=s.node||n,c=ae(o,"end"),l=s.last?c:ae(o,"start"),u=s.css;return a.rawMessage=e,a.syntax=t?re(t):"<generic>",a.css=u,a.mismatchOffset=i,a.loc={source:o&&o.loc&&o.loc.source||"<unknown>",start:l,end:c},a.line=l?l.line:void 0,a.column=l?l.column:void 0,a.offset=l?l.offset:void 0,a.message=e+"\n syntax: "+a.syntax+"\n value: "+(a.css||"<empty string>")+"\n --------"+new Array(a.mismatchOffset+1).join("-")+"^",a},oe=Object.prototype.hasOwnProperty,ce=Object.create(null),le=Object.create(null);function ue(e,t){return t=t||0,e.length-t>=2&&45===e.charCodeAt(t)&&45===e.charCodeAt(t+1)}function he(e,t){if(t=t||0,e.length-t>=3&&45===e.charCodeAt(t)&&45!==e.charCodeAt(t+1)){var n=e.indexOf("-",t+2);if(-1!==n)return e.substring(t,n+1)}return""}var pe={keyword:function(e){if(oe.call(ce,e))return ce[e];var t=e.toLowerCase();if(oe.call(ce,t))return ce[e]=ce[t];var n=ue(t,0),r=n?"":he(t,0);return ce[e]=Object.freeze({basename:t.substr(r.length),name:t,vendor:r,prefix:r,custom:n})},property:function(e){if(oe.call(le,e))return le[e];var t=e,n=e[0];"/"===n?n="/"===e[1]?"//":"/":"_"!==n&&"*"!==n&&"$"!==n&&"#"!==n&&"+"!==n&&"&"!==n&&(n="");var r=ue(t,n.length);if(!r&&(t=t.toLowerCase(),oe.call(le,t)))return le[e]=le[t];var a=r?"":he(t,n.length),s=t.substr(0,n.length+a.length);return le[e]=Object.freeze({basename:t.substr(s.length),name:t.substr(n.length),hack:n,vendor:a,prefix:s,custom:r})},isCustomProperty:ue,vendorPrefix:he},de="undefined"!=typeof Uint32Array?Uint32Array:Array,fe=function(e,t){return null===e||e.length<t?new de(Math.max(t+1024,16384)):e},ye=$,ge=fe,me=g,ke=me.TYPE,xe=D,be=xe.isNewline,ve=xe.isName,Se=xe.isValidEscape,Ce=xe.isNumberStart,we=xe.isIdentifierStart,Ae=xe.charCodeCategory,Pe=xe.isBOM,Te=j,Le=Te.cmpStr,Ee=Te.getNewlineLength,De=Te.findWhiteSpaceEnd,Oe=Te.consumeEscaped,Be=Te.consumeName,Ie=Te.consumeNumber,Ne=Te.consumeBadUrlRemnants,Re=16777215,Me=24;function We(e,t){function n(t){return t<i?e.charCodeAt(t):0}function r(){return h=Ie(e,h),we(n(h),n(h+1),n(h+2))?(g=ke.Dimension,void(h=Be(e,h))):37===n(h)?(g=ke.Percentage,void h++):void(g=ke.Number)}function a(){const t=h;return h=Be(e,h),Le(e,t,h,"url")&&40===n(h)?34===n(h=De(e,h+1))||39===n(h)?(g=ke.Function,void(h=t+4)):void function(){for(g=ke.Url,h=De(e,h);h<e.length;h++){var t=e.charCodeAt(h);switch(Ae(t)){case 41:return void h++;case Ae.Eof:return;case Ae.WhiteSpace:return 41===n(h=De(e,h))||h>=e.length?void(h<e.length&&h++):(h=Ne(e,h),void(g=ke.BadUrl));case 34:case 39:case 40:case Ae.NonPrintable:return h=Ne(e,h),void(g=ke.BadUrl);case 92:if(Se(t,n(h+1))){h=Oe(e,h)-1;break}return h=Ne(e,h),void(g=ke.BadUrl)}}}():40===n(h)?(g=ke.Function,void h++):void(g=ke.Ident)}function s(t){for(t||(t=n(h++)),g=ke.String;h<e.length;h++){var r=e.charCodeAt(h);switch(Ae(r)){case t:return void h++;case Ae.Eof:return;case Ae.WhiteSpace:if(be(r))return h+=Ee(e,h,r),void(g=ke.BadString);break;case 92:if(h===e.length-1)break;var a=n(h+1);be(a)?h+=Ee(e,h+1,a):Se(r,a)&&(h=Oe(e,h)-1)}}}t||(t=new ye);for(var i=(e=String(e||"")).length,o=ge(t.offsetAndType,i+1),c=ge(t.balance,i+1),l=0,u=Pe(n(0)),h=u,p=0,d=0,f=0;h<i;){var y=e.charCodeAt(h),g=0;switch(c[l]=i,Ae(y)){case Ae.WhiteSpace:g=ke.WhiteSpace,h=De(e,h+1);break;case 34:s();break;case 35:ve(n(h+1))||Se(n(h+1),n(h+2))?(g=ke.Hash,h=Be(e,h+1)):(g=ke.Delim,h++);break;case 39:s();break;case 40:g=ke.LeftParenthesis,h++;break;case 41:g=ke.RightParenthesis,h++;break;case 43:Ce(y,n(h+1),n(h+2))?r():(g=ke.Delim,h++);break;case 44:g=ke.Comma,h++;break;case 45:Ce(y,n(h+1),n(h+2))?r():45===n(h+1)&&62===n(h+2)?(g=ke.CDC,h+=3):we(y,n(h+1),n(h+2))?a():(g=ke.Delim,h++);break;case 46:Ce(y,n(h+1),n(h+2))?r():(g=ke.Delim,h++);break;case 47:42===n(h+1)?(g=ke.Comment,1===(h=e.indexOf("*/",h+2)+2)&&(h=e.length)):(g=ke.Delim,h++);break;case 58:g=ke.Colon,h++;break;case 59:g=ke.Semicolon,h++;break;case 60:33===n(h+1)&&45===n(h+2)&&45===n(h+3)?(g=ke.CDO,h+=4):(g=ke.Delim,h++);break;case 64:we(n(h+1),n(h+2),n(h+3))?(g=ke.AtKeyword,h=Be(e,h+1)):(g=ke.Delim,h++);break;case 91:g=ke.LeftSquareBracket,h++;break;case 92:Se(y,n(h+1))?a():(g=ke.Delim,h++);break;case 93:g=ke.RightSquareBracket,h++;break;case 123:g=ke.LeftCurlyBracket,h++;break;case 125:g=ke.RightCurlyBracket,h++;break;case Ae.Digit:r();break;case Ae.NameStart:a();break;case Ae.Eof:break;default:g=ke.Delim,h++}switch(g){case p:for(p=(d=c[f=d&Re])>>Me,c[l]=f,c[f++]=l;f<l;f++)c[f]===i&&(c[f]=l);break;case ke.LeftParenthesis:case ke.Function:c[l]=d,d=(p=ke.RightParenthesis)<<Me|l;break;case ke.LeftSquareBracket:c[l]=d,d=(p=ke.RightSquareBracket)<<Me|l;break;case ke.LeftCurlyBracket:c[l]=d,d=(p=ke.RightCurlyBracket)<<Me|l}o[l++]=g<<Me|h}for(o[l]=ke.EOF<<Me|h,c[l]=i,c[i]=i;0!==d;)d=c[f=d&Re],c[f]=i;return t.source=e,t.firstCharOffset=u,t.offsetAndType=o,t.tokenCount=l,t.balance=c,t.reset(),t.next(),t}Object.keys(me).forEach((function(e){We[e]=me[e]})),Object.keys(xe).forEach((function(e){We[e]=xe[e]})),Object.keys(Te).forEach((function(e){We[e]=Te[e]}));var Fe=We,ze=Fe.isDigit,Ye=Fe.cmpChar,Ue=Fe.TYPE,je=Ue.Delim,qe=Ue.WhiteSpace,He=Ue.Comment,Ve=Ue.Ident,Ke=Ue.Number,Qe=Ue.Dimension,Ge=45,Xe=!0;function _e(e,t){return null!==e&&e.type===je&&e.value.charCodeAt(0)===t}function Ze(e,t,n){for(;null!==e&&(e.type===qe||e.type===He);)e=n(++t);return t}function $e(e,t,n,r){if(!e)return 0;var a=e.value.charCodeAt(t);if(43===a||a===Ge){if(n)return 0;t++}for(;t<e.value.length;t++)if(!ze(e.value.charCodeAt(t)))return 0;return r+1}function Je(e,t,n){var r=!1,a=Ze(e,t,n);if(null===(e=n(a)))return t;if(e.type!==Ke){if(!_e(e,43)&&!_e(e,Ge))return t;if(r=!0,a=Ze(n(++a),a,n),null===(e=n(a))&&e.type!==Ke)return 0}if(!r){var s=e.value.charCodeAt(0);if(43!==s&&s!==Ge)return 0}return $e(e,r?0:1,r,a)}var et=Fe.isHexDigit,tt=Fe.cmpChar,nt=Fe.TYPE,rt=nt.Ident,at=nt.Delim,st=nt.Number,it=nt.Dimension;function ot(e,t){return null!==e&&e.type===at&&e.value.charCodeAt(0)===t}function ct(e,t){return e.value.charCodeAt(0)===t}function lt(e,t,n){for(var r=t,a=0;r<e.value.length;r++){var s=e.value.charCodeAt(r);if(45===s&&n&&0!==a)return lt(e,t+a+1,!1)>0?6:0;if(!et(s))return 0;if(++a>6)return 0}return a}function ut(e,t,n){if(!e)return 0;for(;ot(n(t),63);){if(++e>6)return 0;t++}return t}var ht=Fe,pt=ht.isIdentifierStart,dt=ht.isHexDigit,ft=ht.isDigit,yt=ht.cmpStr,gt=ht.consumeNumber,mt=ht.TYPE,kt=function(e,t){var n=0;if(!e)return 0;if(e.type===Ke)return $e(e,0,false,n);if(e.type===Ve&&e.value.charCodeAt(0)===Ge){if(!Ye(e.value,1,110))return 0;switch(e.value.length){case 2:return Je(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Ge?0:(n=Ze(t(++n),n,t),$e(e=t(n),0,Xe,n));default:return e.value.charCodeAt(2)!==Ge?0:$e(e,3,Xe,n)}}else if(e.type===Ve||_e(e,43)&&t(n+1).type===Ve){if(e.type!==Ve&&(e=t(++n)),null===e||!Ye(e.value,0,110))return 0;switch(e.value.length){case 1:return Je(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Ge?0:(n=Ze(t(++n),n,t),$e(e=t(n),0,Xe,n));default:return e.value.charCodeAt(1)!==Ge?0:$e(e,2,Xe,n)}}else if(e.type===Qe){for(var r=e.value.charCodeAt(0),a=43===r||r===Ge?1:0,s=a;s<e.value.length&&ze(e.value.charCodeAt(s));s++);return s===a?0:Ye(e.value,s,110)?s+1===e.value.length?Je(t(++n),n,t):e.value.charCodeAt(s+1)!==Ge?0:s+2===e.value.length?(n=Ze(t(++n),n,t),$e(e=t(n),0,Xe,n)):$e(e,s+2,Xe,n):0}return 0},xt=function(e,t){var n=0;if(null===e||e.type!==rt||!tt(e.value,0,117))return 0;if(null===(e=t(++n)))return 0;if(ot(e,43))return null===(e=t(++n))?0:e.type===rt?ut(lt(e,0,!0),++n,t):ot(e,63)?ut(1,++n,t):0;if(e.type===st){if(!ct(e,43))return 0;var r=lt(e,1,!0);return 0===r?0:null===(e=t(++n))?n:e.type===it||e.type===st?ct(e,45)&&lt(e,1,!1)?n+1:0:ut(r,n,t)}return e.type===it&&ct(e,43)?ut(lt(e,1,!0),++n,t):0},bt=["unset","initial","inherit"],vt=["calc(","-moz-calc(","-webkit-calc("];function St(e,t){return t<e.length?e.charCodeAt(t):0}function Ct(e,t){return yt(e,0,e.length,t)}function wt(e,t){for(var n=0;n<t.length;n++)if(Ct(e,t[n]))return!0;return!1}function At(e,t){return t===e.length-2&&(92===e.charCodeAt(t)&&ft(e.charCodeAt(t+1)))}function Pt(e,t,n){if(e&&"Range"===e.type){var r=Number(void 0!==n&&n!==t.length?t.substr(0,n):t);if(isNaN(r))return!0;if(null!==e.min&&r<e.min)return!0;if(null!==e.max&&r>e.max)return!0}return!1}function Tt(e,t){var n=e.index,r=0;do{if(r++,e.balance<=n)break}while(e=t(r));return r}function Lt(e){return function(t,n,r){return null===t?0:t.type===mt.Function&&wt(t.value,vt)?Tt(t,n):e(t,n,r)}}function Et(e){return function(t){return null===t||t.type!==e?0:1}}function Dt(e){return function(t,n,r){if(null===t||t.type!==mt.Dimension)return 0;var a=gt(t.value,0);if(null!==e){var s=t.value.indexOf("\\",a),i=-1!==s&&At(t.value,s)?t.value.substring(a,s):t.value.substr(a);if(!1===e.hasOwnProperty(i.toLowerCase()))return 0}return Pt(r,t.value,a)?0:1}}function Ot(e){return"function"!=typeof e&&(e=function(){return 0}),function(t,n,r){return null!==t&&t.type===mt.Number&&0===Number(t.value)?1:e(t,n,r)}}var Bt,It={"ident-token":Et(mt.Ident),"function-token":Et(mt.Function),"at-keyword-token":Et(mt.AtKeyword),"hash-token":Et(mt.Hash),"string-token":Et(mt.String),"bad-string-token":Et(mt.BadString),"url-token":Et(mt.Url),"bad-url-token":Et(mt.BadUrl),"delim-token":Et(mt.Delim),"number-token":Et(mt.Number),"percentage-token":Et(mt.Percentage),"dimension-token":Et(mt.Dimension),"whitespace-token":Et(mt.WhiteSpace),"CDO-token":Et(mt.CDO),"CDC-token":Et(mt.CDC),"colon-token":Et(mt.Colon),"semicolon-token":Et(mt.Semicolon),"comma-token":Et(mt.Comma),"[-token":Et(mt.LeftSquareBracket),"]-token":Et(mt.RightSquareBracket),"(-token":Et(mt.LeftParenthesis),")-token":Et(mt.RightParenthesis),"{-token":Et(mt.LeftCurlyBracket),"}-token":Et(mt.RightCurlyBracket),string:Et(mt.String),ident:Et(mt.Ident),"custom-ident":function(e){if(null===e||e.type!==mt.Ident)return 0;var t=e.value.toLowerCase();return wt(t,bt)||Ct(t,"default")?0:1},"custom-property-name":function(e){return null===e||e.type!==mt.Ident||45!==St(e.value,0)||45!==St(e.value,1)?0:1},"hex-color":function(e){if(null===e||e.type!==mt.Hash)return 0;var t=e.value.length;if(4!==t&&5!==t&&7!==t&&9!==t)return 0;for(var n=1;n<t;n++)if(!dt(e.value.charCodeAt(n)))return 0;return 1},"id-selector":function(e){return null===e||e.type!==mt.Hash?0:pt(St(e.value,1),St(e.value,2),St(e.value,3))?1:0},"an-plus-b":kt,urange:xt,"declaration-value":function(e,t){if(!e)return 0;var n=0,r=0,a=e.index;e:do{switch(e.type){case mt.BadString:case mt.BadUrl:break e;case mt.RightCurlyBracket:case mt.RightParenthesis:case mt.RightSquareBracket:if(e.balance>e.index||e.balance<a)break e;r--;break;case mt.Semicolon:if(0===r)break e;break;case mt.Delim:if("!"===e.value&&0===r)break e;break;case mt.Function:case mt.LeftParenthesis:case mt.LeftSquareBracket:case mt.LeftCurlyBracket:r++}if(n++,e.balance<=a)break}while(e=t(n));return n},"any-value":function(e,t){if(!e)return 0;var n=e.index,r=0;e:do{switch(e.type){case mt.BadString:case mt.BadUrl:break e;case mt.RightCurlyBracket:case mt.RightParenthesis:case mt.RightSquareBracket:if(e.balance>e.index||e.balance<n)break e}if(r++,e.balance<=n)break}while(e=t(r));return r},dimension:Lt(Dt(null)),angle:Lt(Dt({deg:!0,grad:!0,rad:!0,turn:!0})),decibel:Lt(Dt({db:!0})),frequency:Lt(Dt({hz:!0,khz:!0})),flex:Lt(Dt({fr:!0})),length:Lt(Ot(Dt({px:!0,mm:!0,cm:!0,in:!0,pt:!0,pc:!0,q:!0,em:!0,ex:!0,ch:!0,rem:!0,vh:!0,vw:!0,vmin:!0,vmax:!0,vm:!0}))),resolution:Lt(Dt({dpi:!0,dpcm:!0,dppx:!0,x:!0})),semitones:Lt(Dt({st:!0})),time:Lt(Dt({s:!0,ms:!0})),percentage:Lt((function(e,t,n){return null===e||e.type!==mt.Percentage||Pt(n,e.value,e.value.length-1)?0:1})),zero:Ot(),number:Lt((function(e,t,n){if(null===e)return 0;var r=gt(e.value,0);return r===e.value.length||At(e.value,r)?Pt(n,e.value,r)?0:1:0})),integer:Lt((function(e,t,n){if(null===e||e.type!==mt.Number)return 0;for(var r=43===e.value.charCodeAt(0)||45===e.value.charCodeAt(0)?1:0;r<e.value.length;r++)if(!ft(e.value.charCodeAt(r)))return 0;return Pt(n,e.value,r)?0:1})),"-ms-legacy-expression":(Bt="expression",Bt+="(",function(e,t){return null!==e&&Ct(e.value,Bt)?Tt(e,t):0})},Nt=l,Rt=function(e,t,n){var r=Nt("SyntaxError",e);return r.input=t,r.offset=n,r.rawMessage=e,r.message=r.rawMessage+"\n "+r.input+"\n--"+new Array((r.offset||r.input.length)+1).join("-")+"^",r},Mt=Rt,Wt=function(e){this.str=e,this.pos=0};Wt.prototype={charCodeAt:function(e){return e<this.str.length?this.str.charCodeAt(e):0},charCode:function(){return this.charCodeAt(this.pos)},nextCharCode:function(){return this.charCodeAt(this.pos+1)},nextNonWsCode:function(e){return this.charCodeAt(this.findWsEnd(e))},findWsEnd:function(e){for(;e<this.str.length;e++){var t=this.str.charCodeAt(e);if(13!==t&&10!==t&&12!==t&&32!==t&&9!==t)break}return e},substringToPos:function(e){return this.str.substring(this.pos,this.pos=e)},eat:function(e){this.charCode()!==e&&this.error("Expect `"+String.fromCharCode(e)+"`"),this.pos++},peek:function(){return this.pos<this.str.length?this.str.charAt(this.pos++):""},error:function(e){throw new Mt(e,this.str,this.pos)}};var Ft=Wt,zt=123,Yt=function(e){for(var t="function"==typeof Uint32Array?new Uint32Array(128):new Array(128),n=0;n<128;n++)t[n]=e(String.fromCharCode(n))?1:0;return t}((function(e){return/[a-zA-Z0-9\-]/.test(e)})),Ut={" ":1,"&&":2,"||":3,"|":4};function jt(e){return e.substringToPos(e.findWsEnd(e.pos))}function qt(e){for(var t=e.pos;t<e.str.length;t++){var n=e.str.charCodeAt(t);if(n>=128||0===Yt[n])break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function Ht(e){for(var t=e.pos;t<e.str.length;t++){var n=e.str.charCodeAt(t);if(n<48||n>57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function Vt(e){var t=e.str.indexOf("'",e.pos+1);return-1===t&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function Kt(e){var t,n=null;return e.eat(zt),t=Ht(e),44===e.charCode()?(e.pos++,125!==e.charCode()&&(n=Ht(e))):n=t,e.eat(125),{min:Number(t),max:n?Number(n):0}}function Qt(e,t){var n=function(e){var t=null,n=!1;switch(e.charCode()){case 42:e.pos++,t={min:0,max:0};break;case 43:e.pos++,t={min:1,max:0};break;case 63:e.pos++,t={min:0,max:1};break;case 35:e.pos++,n=!0,t=e.charCode()===zt?Kt(e):{min:1,max:0};break;case zt:t=Kt(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}(e);return null!==n?(n.term=t,n):t}function Gt(e){var t=e.peek();return""===t?null:{type:"Token",value:t}}function Xt(e){var t,n=null;return e.eat(60),t=qt(e),40===e.charCode()&&41===e.nextCharCode()&&(e.pos+=2,t+="()"),91===e.charCodeAt(e.findWsEnd(e.pos))&&(jt(e),n=function(e){var t=null,n=null,r=1;return e.eat(91),45===e.charCode()&&(e.peek(),r=-1),-1==r&&8734===e.charCode()?e.peek():t=r*Number(Ht(e)),jt(e),e.eat(44),jt(e),8734===e.charCode()?e.peek():(r=1,45===e.charCode()&&(e.peek(),r=-1),n=r*Number(Ht(e))),e.eat(93),null===t&&null===n?null:{type:"Range",min:t,max:n}}(e)),e.eat(62),Qt(e,{type:"Type",name:t,opts:n})}function _t(e,t){function n(e,t){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:!1}}for(t=Object.keys(t).sort((function(e,t){return Ut[e]-Ut[t]}));t.length>0;){for(var r=t.shift(),a=0,s=0;a<e.length;a++){var i=e[a];"Combinator"===i.type&&(i.value===r?(-1===s&&(s=a-1),e.splice(a,1),a--):(-1!==s&&a-s>1&&(e.splice(s,a-s,n(e.slice(s,a),r)),a=s+1),s=-1))}-1!==s&&t.length&&e.splice(s,a-s,n(e.slice(s,a),r))}return r}function Zt(e){for(var t,n=[],r={},a=null,s=e.pos;t=$t(e);)"Spaces"!==t.type&&("Combinator"===t.type?(null!==a&&"Combinator"!==a.type||(e.pos=s,e.error("Unexpected combinator")),r[t.value]=!0):null!==a&&"Combinator"!==a.type&&(r[" "]=!0,n.push({type:"Combinator",value:" "})),n.push(t),a=t,s=e.pos);return null!==a&&"Combinator"===a.type&&(e.pos-=s,e.error("Unexpected combinator")),{type:"Group",terms:n,combinator:_t(n,r)||" ",disallowEmpty:!1,explicit:!1}}function $t(e){var t=e.charCode();if(t<128&&1===Yt[t])return function(e){var t;return t=qt(e),40===e.charCode()?(e.pos++,{type:"Function",name:t}):Qt(e,{type:"Keyword",name:t})}(e);switch(t){case 93:break;case 91:return Qt(e,function(e){var t;return e.eat(91),t=Zt(e),e.eat(93),t.explicit=!0,33===e.charCode()&&(e.pos++,t.disallowEmpty=!0),t}(e));case 60:return 39===e.nextCharCode()?function(e){var t;return e.eat(60),e.eat(39),t=qt(e),e.eat(39),e.eat(62),Qt(e,{type:"Property",name:t})}(e):Xt(e);case 124:return{type:"Combinator",value:e.substringToPos(124===e.nextCharCode()?e.pos+2:e.pos+1)};case 38:return e.pos++,e.eat(38),{type:"Combinator",value:"&&"};case 44:return e.pos++,{type:"Comma"};case 39:return Qt(e,{type:"String",value:Vt(e)});case 32:case 9:case 10:case 13:case 12:return{type:"Spaces",value:jt(e)};case 64:return(t=e.nextCharCode())<128&&1===Yt[t]?(e.pos++,{type:"AtKeyword",name:qt(e)}):Gt(e);case 42:case 43:case 63:case 35:case 33:break;case zt:if((t=e.nextCharCode())<48||t>57)return Gt(e);break;default:return Gt(e)}}function Jt(e){var t=new Ft(e),n=Zt(t);return t.pos!==e.length&&t.error("Unexpected input"),1===n.terms.length&&"Group"===n.terms[0].type&&(n=n.terms[0]),n}Jt("[a&&<b>#|<'c'>*||e() f{2} /,(% g#{1,2} h{2,})]!");var en=Jt,tn=function(){};function nn(e){return"function"==typeof e?e:tn}var rn=function(e,t,n){var r=tn,a=tn;if("function"==typeof t?r=t:t&&(r=nn(t.enter),a=nn(t.leave)),r===tn&&a===tn)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");!function e(t){switch(r.call(n,t),t.type){case"Group":t.terms.forEach(e);break;case"Multiplier":e(t.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+t.type)}a.call(n,t)}(e)},an=Fe,sn=new $,on={decorator:function(e){var t=null,n={len:0,node:null},r=[n],a="";return{children:e.children,node:function(n){var r=t;t=n,e.node.call(this,n),t=r},chunk:function(e){a+=e,n.node!==t?r.push({len:e.length,node:t}):n.len+=e.length},result:function(){return cn(a,r)}}}};function cn(e,t){var n=[],r=0,a=0,s=t?t[a].node:null;for(an(e,sn);!sn.eof;){if(t)for(;a<t.length&&r+t[a].len<=sn.tokenStart;)r+=t[a++].len,s=t[a].node;n.push({type:sn.tokenType,value:sn.getTokenValue(),index:sn.tokenIndex,balance:sn.balance[sn.tokenIndex],node:s}),sn.next()}return n}var ln=en,un={type:"Match"},hn={type:"Mismatch"},pn={type:"DisallowEmpty"};function dn(e,t,n){return t===un&&n===hn||e===un&&t===un&&n===un?e:("If"===e.type&&e.else===hn&&t===un&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function fn(e){return e.length>2&&40===e.charCodeAt(e.length-2)&&41===e.charCodeAt(e.length-1)}function yn(e){return"Keyword"===e.type||"AtKeyword"===e.type||"Function"===e.type||"Type"===e.type&&fn(e.name)}function gn(e,t,n){switch(e){case" ":for(var r=un,a=t.length-1;a>=0;a--){r=dn(o=t[a],r,hn)}return r;case"|":r=hn;var s=null;for(a=t.length-1;a>=0;a--){if(yn(o=t[a])&&(null===s&&a>0&&yn(t[a-1])&&(r=dn({type:"Enum",map:s=Object.create(null)},un,r)),null!==s)){var i=(fn(o.name)?o.name.slice(0,-1):o.name).toLowerCase();if(i in s==!1){s[i]=o;continue}}s=null,r=dn(o,un,r)}return r;case"&&":if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};for(r=hn,a=t.length-1;a>=0;a--){var o=t[a];c=t.length>1?gn(e,t.filter((function(e){return e!==o})),!1):un,r=dn(o,c,r)}return r;case"||":if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};for(r=n?un:hn,a=t.length-1;a>=0;a--){var c;o=t[a];c=t.length>1?gn(e,t.filter((function(e){return e!==o})),!0):un,r=dn(o,c,r)}return r}}function mn(e){if("function"==typeof e)return{type:"Generic",fn:e};switch(e.type){case"Group":var t=gn(e.combinator,e.terms.map(mn),!1);return e.disallowEmpty&&(t=dn(t,pn,hn)),t;case"Multiplier":return function(e){var t=un,n=mn(e.term);if(0===e.max)n=dn(n,pn,hn),(t=dn(n,null,hn)).then=dn(un,un,t),e.comma&&(t.then.else=dn({type:"Comma",syntax:e},t,hn));else for(var r=e.min||1;r<=e.max;r++)e.comma&&t!==un&&(t=dn({type:"Comma",syntax:e},t,hn)),t=dn(n,dn(un,un,t),hn);if(0===e.min)t=dn(un,un,t);else for(r=0;r<e.min-1;r++)e.comma&&t!==un&&(t=dn({type:"Comma",syntax:e},t,hn)),t=dn(n,t,hn);return t}(e);case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return 3===e.value.length?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}var kn={MATCH:un,MISMATCH:hn,DISALLOW_EMPTY:pn,buildMatchGraph:function(e,t){return"string"==typeof e&&(e=ln(e)),{type:"MatchGraph",match:mn(e),syntax:t||null,source:e}}},xn=Object.prototype.hasOwnProperty,bn=kn.MATCH,vn=kn.MISMATCH,Sn=kn.DISALLOW_EMPTY,Cn=g.TYPE,wn="Match";function An(e){for(var t=null,n=null,r=e;null!==r;)n=r.prev,r.prev=t,t=r,r=n;return t}function Pn(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=65&&r<=90&&(r|=32),r!==t.charCodeAt(n))return!1}return!0}function Tn(e){return null===e||(e.type===Cn.Comma||e.type===Cn.Function||e.type===Cn.LeftParenthesis||e.type===Cn.LeftSquareBracket||e.type===Cn.LeftCurlyBracket||e.type===Cn.Delim)}function Ln(e){return null===e||(e.type===Cn.RightParenthesis||e.type===Cn.RightSquareBracket||e.type===Cn.RightCurlyBracket||e.type===Cn.Delim)}function En(e,t,n){function r(){do{m++,g=m<e.length?e[m]:null}while(null!==g&&(g.type===Cn.WhiteSpace||g.type===Cn.Comment))}function a(t){var n=m+t;return n<e.length?e[n]:null}function s(e,t){return{nextState:e,matchStack:x,syntaxStack:u,thenStack:h,tokenIndex:m,prev:t}}function i(e){h={nextState:e,matchStack:x,syntaxStack:u,prev:h}}function o(e){p=s(e,p)}function c(){x={type:1,syntax:t.syntax,token:g,prev:x},r(),d=null,m>k&&(k=m)}function l(){x=2===x.type?x.prev:{type:3,syntax:u.syntax,token:x.token,prev:x},u=u.prev}var u=null,h=null,p=null,d=null,f=0,y=null,g=null,m=-1,k=0,x={type:0,syntax:null,token:null,prev:null};for(r();null===y&&++f<15e3;)switch(t.type){case"Match":if(null===h){if(null!==g&&(m!==e.length-1||"\\0"!==g.value&&"\\9"!==g.value)){t=vn;break}y=wn;break}if((t=h.nextState)===Sn){if(h.matchStack===x){t=vn;break}t=bn}for(;h.syntaxStack!==u;)l();h=h.prev;break;case"Mismatch":if(null!==d&&!1!==d)(null===p||m>p.tokenIndex)&&(p=d,d=!1);else if(null===p){y="Mismatch";break}t=p.nextState,h=p.thenStack,u=p.syntaxStack,x=p.matchStack,m=p.tokenIndex,g=m<e.length?e[m]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==vn&&o(t.else),t.then!==bn&&i(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":var b=t.syntax.terms;if(t.index===b.length){if(0===t.mask||t.syntax.all){t=vn;break}t=bn;break}if(t.mask===(1<<b.length)-1){t=bn;break}for(;t.index<b.length;t.index++){var v=1<<t.index;if(0==(t.mask&v)){o(t),i({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|v}),t=b[t.index++];break}}break;case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(null!==g)if(-1!==(P=g.value.toLowerCase()).indexOf("\\")&&(P=P.replace(/\\[09].*$/,"")),xn.call(t.map,P)){t=t.map[P];break}t=vn;break;case"Generic":var S=null!==u?u.opts:null,C=m+Math.floor(t.fn(g,a,S));if(!isNaN(C)&&C>m){for(;m<C;)c();t=bn}else t=vn;break;case"Type":case"Property":var w="Type"===t.type?"types":"properties",A=xn.call(n,w)?n[w][t.name]:null;if(!A||!A.match)throw new Error("Bad syntax reference: "+("Type"===t.type?"<"+t.name+">":"<'"+t.name+"'>"));if(!1!==d&&null!==g&&"Type"===t.type)if("custom-ident"===t.name&&g.type===Cn.Ident||"length"===t.name&&"0"===g.value){null===d&&(d=s(t,p)),t=vn;break}u={syntax:t.syntax,opts:t.syntax.opts||null!==u&&u.opts||null,prev:u},x={type:2,syntax:t.syntax,token:x.token,prev:x},t=A.match;break;case"Keyword":var P=t.name;if(null!==g){var T=g.value;if(-1!==T.indexOf("\\")&&(T=T.replace(/\\[09].*$/,"")),Pn(T,P)){c(),t=bn;break}}t=vn;break;case"AtKeyword":case"Function":if(null!==g&&Pn(g.value,t.name)){c(),t=bn;break}t=vn;break;case"Token":if(null!==g&&g.value===t.value){c(),t=bn;break}t=vn;break;case"Comma":null!==g&&g.type===Cn.Comma?Tn(x.token)?t=vn:(c(),t=Ln(g)?vn:bn):t=Tn(x.token)||Ln(g)?bn:vn;break;case"String":var L="";for(C=m;C<e.length&&L.length<t.value.length;C++)L+=e[C].value;if(Pn(L,t.value)){for(;m<C;)c();t=bn}else t=vn;break;default:throw new Error("Unknown node type: "+t.type)}switch(f,y){case null:console.warn("[csstree-match] BREAK after 15000 iterations"),y="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",x=null;break;case wn:for(;null!==u;)l();break;default:x=null}return{tokens:e,reason:y,iterations:f,match:x,longestMatch:k}}var Dn=function(e,t,n){var r=En(e,t,n||{});if(null===r.match)return r;var a=r.match,s=r.match={syntax:t.syntax||null,match:[]},i=[s];for(a=An(a).prev;null!==a;){switch(a.type){case 2:s.match.push(s={syntax:a.syntax,match:[]}),i.push(s);break;case 3:i.pop(),s=i[i.length-1];break;default:s.match.push({syntax:a.syntax||null,token:a.token.value,node:a.token.node})}a=a.prev}return r};function On(e){function t(e){return null!==e&&("Type"===e.type||"Property"===e.type||"Keyword"===e.type)}var n=null;return null!==this.matched&&function r(a){if(Array.isArray(a.match)){for(var s=0;s<a.match.length;s++)if(r(a.match[s]))return t(a.syntax)&&n.unshift(a.syntax),!0}else if(a.node===e)return n=t(a.syntax)?[a.syntax]:[],!0;return!1}(this.matched),n}function Bn(e,t,n){var r=On.call(e,t);return null!==r&&r.some(n)}var In={getTrace:On,isType:function(e,t){return Bn(this,e,(function(e){return"Type"===e.type&&e.name===t}))},isProperty:function(e,t){return Bn(this,e,(function(e){return"Property"===e.type&&e.name===t}))},isKeyword:function(e){return Bn(this,e,(function(e){return"Keyword"===e.type}))}},Nn=c;function Rn(e){return"node"in e?e.node:Rn(e.match[0])}function Mn(e){return"node"in e?e.node:Mn(e.match[e.match.length-1])}var Wn={matchFragments:function(e,t,n,r,a){var s=[];return null!==n.matched&&function n(i){if(null!==i.syntax&&i.syntax.type===r&&i.syntax.name===a){var o=Rn(i),c=Mn(i);e.syntax.walk(t,(function(e,t,n){if(e===o){var r=new Nn;do{if(r.appendData(t.data),t.data===c)break;t=t.next}while(null!==t);s.push({parent:n,nodes:r})}}))}Array.isArray(i.match)&&i.match.forEach(n)}(n.matched),s}},Fn=c,zn=Object.prototype.hasOwnProperty;function Yn(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}function Un(e){return Boolean(e)&&Yn(e.offset)&&Yn(e.line)&&Yn(e.column)}function jn(e,t){return function(n,r){if(!n||n.constructor!==Object)return r(n,"Type of node should be an Object");for(var a in n){var s=!0;if(!1!==zn.call(n,a)){if("type"===a)n.type!==e&&r(n,"Wrong node type `"+n.type+"`, expected `"+e+"`");else if("loc"===a){if(null===n.loc)continue;if(n.loc&&n.loc.constructor===Object)if("string"!=typeof n.loc.source)a+=".source";else if(Un(n.loc.start)){if(Un(n.loc.end))continue;a+=".end"}else a+=".start";s=!1}else if(t.hasOwnProperty(a)){var i=0;for(s=!1;!s&&i<t[a].length;i++){var o=t[a][i];switch(o){case String:s="string"==typeof n[a];break;case Boolean:s="boolean"==typeof n[a];break;case null:s=null===n[a];break;default:"string"==typeof o?s=n[a]&&n[a].type===o:Array.isArray(o)&&(s=n[a]instanceof Fn)}}}else r(n,"Unknown field `"+a+"` for "+e+" node type");s||r(n,"Bad value for `"+e+"."+a+"`")}}for(var a in t)zn.call(t,a)&&!1===zn.call(n,a)&&r(n,"Field `"+e+"."+a+"` is missed")}}function qn(e,t){var n=t.structure,r={type:String,loc:!0},a={type:'"'+e+'"'};for(var s in n)if(!1!==zn.call(n,s)){for(var i=[],o=r[s]=Array.isArray(n[s])?n[s].slice():[n[s]],c=0;c<o.length;c++){var l=o[c];if(l===String||l===Boolean)i.push(l.name);else if(null===l)i.push("null");else if("string"==typeof l)i.push("<"+l+">");else{if(!Array.isArray(l))throw new Error("Wrong value `"+l+"` in `"+e+"."+s+"` structure definition");i.push("List")}}a[s]=i.join(" | ")}return{docs:a,check:jn(e,r)}}var Hn=se,Vn=ie,Kn=pe,Qn=It,Gn=en,Xn=te,_n=rn,Zn=function(e,t){return"string"==typeof e?cn(e,null):t.generate(e,on)},$n=kn.buildMatchGraph,Jn=Dn,er=In,tr=Wn,nr=function(e){var t={};if(e.node)for(var n in e.node)if(zn.call(e.node,n)){var r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=qn(n,r)}return t},rr=$n("inherit | initial | unset"),ar=$n("inherit | initial | unset | <-ms-legacy-expression>");function sr(e,t,n){var r={};for(var a in e)e[a].syntax&&(r[a]=n?e[a].syntax:Xn(e[a].syntax,{compact:t}));return r}function ir(e,t,n){return{matched:e,iterations:n,error:t,getTrace:er.getTrace,isType:er.isType,isProperty:er.isProperty,isKeyword:er.isKeyword}}function or(e,t,n,r){var a,s=Zn(n,e.syntax);return function(e){for(var t=0;t<e.length;t++)if("var("===e[t].value.toLowerCase())return!0;return!1}(s)?ir(null,new Error("Matching for a tree with var() is not supported")):(r&&(a=Jn(s,e.valueCommonSyntax,e)),r&&a.match||(a=Jn(s,t.match,e)).match?ir(a.match,null,a.iterations):ir(null,new Vn(a.reason,t.syntax,n,a),a.iterations))}var cr=function(e,t,n){if(this.valueCommonSyntax=rr,this.syntax=t,this.generic=!1,this.atrules={},this.properties={},this.types={},this.structure=n||nr(e),e){if(e.types)for(var r in e.types)this.addType_(r,e.types[r]);if(e.generic)for(var r in this.generic=!0,Qn)this.addType_(r,Qn[r]);if(e.atrules)for(var r in e.atrules)this.addAtrule_(r,e.atrules[r]);if(e.properties)for(var r in e.properties)this.addProperty_(r,e.properties[r])}};cr.prototype={structure:{},checkStructure:function(e){function t(e,t){r.push({node:e,message:t})}var n=this.structure,r=[];return this.syntax.walk(e,(function(e){n.hasOwnProperty(e.type)?n[e.type].check(e,t):t(e,"Unknown node type `"+e.type+"`")})),!!r.length&&r},createDescriptor:function(e,t,n){var r={type:t,name:n},a={type:t,name:n,syntax:null,match:null};return"function"==typeof e?a.match=$n(e,r):("string"==typeof e?Object.defineProperty(a,"syntax",{get:function(){return Object.defineProperty(a,"syntax",{value:Gn(e)}),a.syntax}}):a.syntax=e,Object.defineProperty(a,"match",{get:function(){return Object.defineProperty(a,"match",{value:$n(a.syntax,r)}),a.match}})),a},addAtrule_:function(e,t){this.atrules[e]={prelude:t.prelude?this.createDescriptor(t.prelude,"AtrulePrelude",e):null,descriptors:t.descriptors?Object.keys(t.descriptors).reduce(((e,n)=>(e[n]=this.createDescriptor(t.descriptors[n],"AtruleDescriptor",n),e)),{}):null}},addProperty_:function(e,t){this.properties[e]=this.createDescriptor(t,"Property",e)},addType_:function(e,t){this.types[e]=this.createDescriptor(t,"Type",e),t===Qn["-ms-legacy-expression"]&&(this.valueCommonSyntax=ar)},matchAtrulePrelude:function(e,t){var n=Kn.keyword(e),r=n.vendor?this.getAtrulePrelude(n.name)||this.getAtrulePrelude(n.basename):this.getAtrulePrelude(n.name);return r?or(this,r,t,!0):n.basename in this.atrules?ir(null,new Error("At-rule `"+e+"` should not contain a prelude")):ir(null,new Hn("Unknown at-rule",e))},matchAtruleDescriptor:function(e,t,n){var r=Kn.keyword(e),a=Kn.keyword(t),s=r.vendor?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name];if(!s)return ir(null,new Hn("Unknown at-rule",e));if(!s.descriptors)return ir(null,new Error("At-rule `"+e+"` has no known descriptors"));var i=a.vendor?s.descriptors[a.name]||s.descriptors[a.basename]:s.descriptors[a.name];return i?or(this,i,n,!0):ir(null,new Hn("Unknown at-rule descriptor",t))},matchDeclaration:function(e){return"Declaration"!==e.type?ir(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)},matchProperty:function(e,t){var n=Kn.property(e);if(n.custom)return ir(null,new Error("Lexer matching doesn't applicable for custom properties"));var r=n.vendor?this.getProperty(n.name)||this.getProperty(n.basename):this.getProperty(n.name);return r?or(this,r,t,!0):ir(null,new Hn("Unknown property",e))},matchType:function(e,t){var n=this.getType(e);return n?or(this,n,t,!1):ir(null,new Hn("Unknown type",e))},match:function(e,t){return"string"==typeof e||e&&e.type?("string"!=typeof e&&e.match||(e=this.createDescriptor(e,"Type","anonymous")),or(this,e,t,!1)):ir(null,new Hn("Bad syntax"))},findValueFragments:function(e,t,n,r){return tr.matchFragments(this,t,this.matchProperty(e,t),n,r)},findDeclarationValueFragments:function(e,t,n){return tr.matchFragments(this,e.value,this.matchDeclaration(e),t,n)},findAllFragments:function(e,t,n){var r=[];return this.syntax.walk(e,{visit:"Declaration",enter:function(e){r.push.apply(r,this.findDeclarationValueFragments(e,t,n))}.bind(this)}),r},getAtrulePrelude:function(e){return this.atrules.hasOwnProperty(e)?this.atrules[e].prelude:null},getAtruleDescriptor:function(e,t){return this.atrules.hasOwnProperty(e)&&this.atrules.declarators&&this.atrules[e].declarators[t]||null},getProperty:function(e){return this.properties.hasOwnProperty(e)?this.properties[e]:null},getType:function(e){return this.types.hasOwnProperty(e)?this.types[e]:null},validate:function(){function e(r,a,s,i){if(s.hasOwnProperty(a))return s[a];s[a]=!1,null!==i.syntax&&_n(i.syntax,(function(i){if("Type"===i.type||"Property"===i.type){var o="Type"===i.type?r.types:r.properties,c="Type"===i.type?t:n;o.hasOwnProperty(i.name)&&!e(r,i.name,c,o[i.name])||(s[a]=!0)}}),this)}var t={},n={};for(var r in this.types)e(this,r,t,this.types[r]);for(var r in this.properties)e(this,r,n,this.properties[r]);return t=Object.keys(t).filter((function(e){return t[e]})),n=Object.keys(n).filter((function(e){return n[e]})),t.length||n.length?{types:t,properties:n}:null},dump:function(e,t){return{generic:this.generic,types:sr(this.types,!t,e),properties:sr(this.properties,!t,e)}},toString:function(){return JSON.stringify(this.dump())}};var lr=cr,ur={SyntaxError:Rt,parse:en,generate:te,walk:rn},hr=fe,pr=Fe.isBOM;var dr=function(){this.lines=null,this.columns=null,this.linesAndColumnsComputed=!1};dr.prototype={setSource:function(e,t,n,r){this.source=e,this.startOffset=void 0===t?0:t,this.startLine=void 0===n?1:n,this.startColumn=void 0===r?1:r,this.linesAndColumnsComputed=!1},ensureLinesAndColumnsComputed:function(){this.linesAndColumnsComputed||(!function(e,t){for(var n=t.length,r=hr(e.lines,n),a=e.startLine,s=hr(e.columns,n),i=e.startColumn,o=t.length>0?pr(t.charCodeAt(0)):0;o<n;o++){var c=t.charCodeAt(o);r[o]=a,s[o]=i++,10!==c&&13!==c&&12!==c||(13===c&&o+1<n&&10===t.charCodeAt(o+1)&&(r[++o]=a,s[o]=i),a++,i=1)}r[o]=a,s[o]=i,e.lines=r,e.columns=s}(this,this.source),this.linesAndColumnsComputed=!0)},getLocation:function(e,t){return this.ensureLinesAndColumnsComputed(),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}},getLocationRange:function(e,t,n){return this.ensureLinesAndColumnsComputed(),{source:n,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}};var fr=dr,yr=Fe.TYPE,gr=yr.WhiteSpace,mr=yr.Comment,kr=fr,xr=d,br=$,vr=c,Sr=Fe,Cr=j.findWhiteSpaceStart,wr=function(e){var t=this.createList(),n=null,r={recognizer:e,space:null,ignoreWS:!1,ignoreWSAfter:!1};for(this.scanner.skipSC();!this.scanner.eof;){switch(this.scanner.tokenType){case mr:this.scanner.next();continue;case gr:r.ignoreWS?this.scanner.next():r.space=this.WhiteSpace();continue}if(void 0===(n=e.getNode.call(this,r)))break;null!==r.space&&(t.push(r.space),r.space=null),t.push(n),r.ignoreWSAfter?(r.ignoreWSAfter=!1,r.ignoreWS=!0):r.ignoreWS=!1}return t},Ar=function(){},Pr=g.TYPE,Tr=g.NAME,Lr=Pr.WhiteSpace,Er=Pr.Ident,Dr=Pr.Function,Or=Pr.Url,Br=Pr.Hash,Ir=Pr.Percentage,Nr=Pr.Number;function Rr(e){return function(){return this[e]()}}var Mr=Object.prototype.hasOwnProperty;function Wr(e,t){var n=e.children,r=null;"function"!=typeof t?n.forEach(this.node,this):n.forEach((function(e){null!==r&&t.call(this,r),this.node(e),r=e}),this)}var Fr=c,zr=Object.prototype.hasOwnProperty,Yr=function(){};function Ur(e){return"function"==typeof e?e:Yr}function jr(e,t){return function(n,r,a){n.type===t&&e.call(this,n,r,a)}}function qr(e,t){var n=t.structure,r=[];for(var a in n)if(!1!==zr.call(n,a)){var s=n[a],i={name:a,type:!1,nullable:!1};Array.isArray(n[a])||(s=[n[a]]);for(var o=0;o<s.length;o++){var c=s[o];null===c?i.nullable=!0:"string"==typeof c?i.type="node":Array.isArray(c)&&(i.type="list")}i.type&&r.push(i)}return r.length?{context:t.walkContext,fields:r}:null}function Hr(e,t){var n=e.fields.slice(),r=e.context,a="string"==typeof r;return t&&n.rever