/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
"use strict";var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);n.prototype=t.prototype,e.prototype=new n};define("vs/languages/handlebars/common/handlebars",["require","exports","vs/editor/common/modes","vs/editor/common/modes/supports","vs/languages/html/common/html"],function(e,t,n,r,o){!function(e){e[e.HTML=0]="HTML",e[e.Expression=1]="Expression",e[e.UnescapedExpression=2]="UnescapedExpression"}(t.States||(t.States={}));var i=t.States,s=function(e){function t(t,n,r,o,i,s,a,c){e.call(this,t,n,o,i,s,a,c),this.kind=n,this.handlebarsKind=r,this.lastTagName=o,this.lastAttributeName=i,this.embeddedContentType=s,this.attributeValueQuote=a,this.attributeValue=c}return __extends(t,e),t.prototype.makeClone=function(){return new t(this.getMode(),this.kind,this.handlebarsKind,this.lastTagName,this.lastAttributeName,this.embeddedContentType,this.attributeValueQuote,this.attributeValue)},t.prototype.equals=function(n){return n instanceof t?e.prototype.equals.call(this,n):!1},t.prototype.tokenize=function(t){switch(this.handlebarsKind){case i.HTML:if(t.advanceIfString("{{{").length>0)return this.handlebarsKind=i.UnescapedExpression,{type:"delimiter.expression.unescaped.handlebars",bracket:n.Bracket.Open};if(t.advanceIfString("{{").length>0)return this.handlebarsKind=i.Expression,{type:"delimiter.expression.handlebars",bracket:n.Bracket.Open};break;case i.Expression:case i.UnescapedExpression:if(this.handlebarsKind===i.Expression&&t.advanceIfString("}}").length>0)return this.handlebarsKind=i.HTML,{type:"delimiter.expression.handlebars",bracket:n.Bracket.Close};if(this.handlebarsKind===i.UnescapedExpression&&t.advanceIfString("}}}").length>0)return this.handlebarsKind=i.HTML,{type:"delimiter.expression.unescaped.handlebars",bracket:n.Bracket.Close};if(t.skipWhitespace().length>0)return{type:""};if("#"===t.peek())return t.advanceWhile(/^[^\s}]/),{type:"keyword.helper.handlebars",bracket:n.Bracket.Open};if("/"===t.peek())return t.advanceWhile(/^[^\s}]/),{type:"keyword.helper.handlebars",bracket:n.Bracket.Close};if(t.advanceIfString("else")){var r=t.peek();if(" "===r||"	"===r||"}"===r)return{type:"keyword.helper.handlebars"};t.goBack(4)}if(t.advanceWhile(/^[^\s}]/).length>0)return{type:"variable.identifier.handlebars"}}return e.prototype.tokenize.call(this,t)},t}(o.State);t.HandlebarsState=s;var a=function(e){function t(t,n,r){e.call(this,t,n,r),this.formattingSupport=null}return __extends(t,e),t.prototype.asyncCtor=function(){var t=this;return e.prototype.asyncCtor.call(this).then(function(){var e=t.characterPairSupport.getAutoClosingPairs().slice(0).concat([{open:"{",close:"}"}]);t.characterPairSupport=new r.CharacterPairSupport(t,{autoClosingPairs:e.slice(0),surroundingPairs:[{open:"<",close:">"},{open:'"',close:'"'},{open:"'",close:"'"}]})})},t.prototype.getInitialState=function(){return new s(this,o.States.Content,i.HTML,"","","","","")},t.prototype.getLeavingNestedModeData=function(t,n){var r=e.prototype.getLeavingNestedModeData.call(this,t,n);return r&&(r.stateAfterNestedMode=new s(this,o.States.Content,i.HTML,"","","","","")),r},t}(o.HTMLMode);t.HandlebarsMode=a});