var Common;!function(t){!function(t){"use strict";class e{constructor(t){this._rootNodes=[];this._text=t}parseCss(){this._inComment=!1;this._currentQuotationMark="";this._nextCharIsEscaped=!1;this._lastCheckpoint=0;this._state=i.Selector;this._currentRuleset=null;this._currentDeclaration=null;this._currentMediaQuery=null;for(this._index=0;this._index<this._text.length;this._index++)this.handleQuoteCharacter()||this.handleCommentCharacter()||this.handleLeadingWhitespace()||this.handleMediaQueryStart()||this.handleMediaQueryOpenBracket()||this.handleMediaQueryCloseBracket()||this.handleSelectorOpenBracket()||this.handlePropertyColon()||this.handleValueSemicolon()||this.handleSelectorCloseBracket();this.handleIncompleteBlocks();return this._rootNodes}handleMediaQueryStart(){if(this._state===i.Selector&&!this._currentMediaQuery&&this._lastCheckpoint>=this._index&&"@"===this._text[this._index]&&"@media "===this._text.substr(this._index,7).toLowerCase()){this._state=i.Media;return!0}return!1}handleMediaQueryOpenBracket(){if(this._state===i.Media&&"{"===this._text[this._index]){var t=this._text.substring(this._lastCheckpoint,this._index);this._currentMediaQuery={originalOffset:this._lastCheckpoint,query:t,rulesets:[]};this._lastCheckpoint=this._index+1;this._state=i.Selector;return!0}return!1}handleMediaQueryCloseBracket(){if(this._state===i.Selector&&"}"===this._text[this._index]&&this._currentMediaQuery){this._lastCheckpoint=this._index+1;this._state=i.Selector;this._rootNodes.push(this._currentMediaQuery);this._currentMediaQuery=null;return!0}return!1}handleSelectorOpenBracket(){if(this._state===i.Selector&&"{"===this._text[this._index]){var t=this._text.substring(this._lastCheckpoint,this._index);this._currentRuleset={originalOffset:this._lastCheckpoint,selector:t,declarations:[]};this._lastCheckpoint=this._index+1;this._state=i.Property;return!0}return!1}handlePropertyColon(){if(this._state===i.Property&&":"===this._text[this._index]){var t=this._text.substring(this._lastCheckpoint,this._index);this._currentDeclaration={originalOffset:this._lastCheckpoint,property:t,value:""};this._lastCheckpoint=this._index+1;this._state=i.Value;return!0}return!1}handleValueSemicolon(){if(this._state===i.Value&&";"===this._text[this._index]){var t=this._text.substring(this._lastCheckpoint,this._index);this._currentDeclaration.value=t;this._currentRuleset.declarations.push(this._currentDeclaration);this._currentDeclaration=null;this._lastCheckpoint=this._index+1;this._state=i.Property;return!0}return!1}handleSelectorCloseBracket(){if("}"===this._text[this._index]){if(this._state===i.Property){var t={originalOffset:this._lastCheckpoint,property:this._text.substring(this._lastCheckpoint,this._index),value:null};t.property.trim()&&this._currentRuleset.declarations.push(t);this._lastCheckpoint=this._index+1;this._state=i.Selector;this._currentMediaQuery?this._currentMediaQuery.rulesets.push(this._currentRuleset):this._rootNodes.push(this._currentRuleset);this._currentRuleset=null;return!0}if(this._state===i.Value){var e=this._text.substring(this._lastCheckpoint,this._index);this._currentDeclaration.value=e;this._currentDeclaration.isMissingSemicolon=!0;this._currentRuleset.declarations.push(this._currentDeclaration);this._currentDeclaration=null;this._lastCheckpoint=this._index+1;this._state=i.Selector;this._currentMediaQuery?this._currentMediaQuery.rulesets.push(this._currentRuleset):this._rootNodes.push(this._currentRuleset);this._currentRuleset=null;return!0}}return!1}handleIncompleteBlocks(){this._currentMediaQuery?this._lastCheckpoint=this._currentMediaQuery.originalOffset:this._currentRuleset&&(this._lastCheckpoint=this._currentRuleset.originalOffset);if(this._lastCheckpoint<this._text.length-1){var t={selector:this._text.substr(this._lastCheckpoint),originalOffset:this._lastCheckpoint,declarations:null};this._rootNodes.push(t)}}handleCommentCharacter(){if("/*"===this._text.substr(this._index,2)){var t=this._text.indexOf("*/",this._index);-1===t&&(t=this._text.length);this._index=t+"*/".length-1;return!0}return!1}handleQuoteCharacter(){if(this._currentQuotationMark){this._nextCharIsEscaped?this._nextCharIsEscaped=!1:this._text[this._index]===this._currentQuotationMark?this._currentQuotationMark="":"\\"===this._text[this._index]&&(this._nextCharIsEscaped=!0);return!0}if('"'===this._text[this._index]||"'"===this._text[this._index]){this._currentQuotationMark=this._text[this._index];return!0}return!1}handleLeadingWhitespace(){if(this._lastCheckpoint===this._index&&0===this._text[this._index].trim().length){this._lastCheckpoint++;return!0}return!1}}t.CssParser=e;let i;!function(t){t[t.Selector=0]="Selector";t[t.Media=1]="Media";t[t.Property=2]="Property";t[t.Value=3]="Value"}(i||(i={}))}(t.FormatService||(t.FormatService={}))}(Common||(Common={}));
