1(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"),require("../htmlmixed/htmlmixed"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror","../htmlmixed/htmlmixed"],a);else a(CodeMirror)})(function(a){"use strict";var b={noEndTag:true,soyState:"param-def"};var c={alias:{noEndTag:true},delpackage:{noEndTag:true},namespace:{noEndTag:true,soyState:"namespace-def"},"@param":b,"@param?":b,"@inject":b,"@inject?":b,"@state":b,template:{soyState:"templ-def",variableScope:true},literal:{},msg:{},fallbackmsg:{noEndTag:true,reduceIndent:true},select:{},plural:{},"let":{soyState:"var-def"},"if":{},elseif:{noEndTag:true,reduceIndent:true},"else":{noEndTag:true,reduceIndent:true},"switch":{},"case":{noEndTag:true,reduceIndent:true},"default":{noEndTag:true,reduceIndent:true},foreach:{variableScope:true,soyState:"for-loop"},ifempty:{noEndTag:true,reduceIndent:true},"for":{variableScope:true,soyState:"for-loop"},call:{soyState:"templ-ref"},param:{soyState:"param-ref"},print:{noEndTag:true},deltemplate:{soyState:"templ-def",variableScope:true},delcall:{soyState:"templ-ref"},log:{},element:{variableScope:true}};var d=Object.keys(c).filter(function(a){return!c[a].noEndTag||c[a].reduceIndent});a.defineMode("soy",function(b){var e=a.getMode(b,"text/plain");var f={html:a.getMode(b,{name:"text/html",multilineTagIndentFactor:2,multilineTagIndentPastTag:false}),attributes:e,text:e,uri:e,trusted_resource_uri:e,css:a.getMode(b,"text/css"),js:a.getMode(b,{name:"text/javascript",statementIndent:2*b.indentUnit})};function g(a){return a[a.length-1]}function h(a,b,c){if(a.sol()){for(var d=0;d<b.indent;d++){if(!a.eat(/\s/))break}if(d)return null}var e=a.string;var f=c.exec(e.substr(a.pos));if(f){a.string=e.substr(0,a.pos+f.index)}var h=a.hideFirstChars(b.indent,function(){var c=g(b.localStates);return c.mode.token(a,c.state)});a.string=e;return h}function i(a,b){while(a){if(a.element===b)return true;a=a.next}return false}function j(a,b){return{element:b,next:a}}function k(a){if(!a.context)return;if(a.context.scope){a.variables=a.context.scope}a.context=a.context.previousContext}function l(a,b,c){return i(a,b)?"variable-2":c?"variable":"variable-2 error"}function m(a,b,c){this.previousContext=a;this.tag=b;this.kind=null;this.scope=c}function n(a,b){var c;if(a.match(/[[]/)){b.soyState.push("list-literal");b.context=new m(b.context,"list-literal",b.variables);b.lookupVariables=false;return null}else if(a.match(/map\b/)){b.soyState.push("map-literal");return"keyword"}else if(a.match(/record\b/)){b.soyState.push("record-literal");return"keyword"}else if(a.match(/([\w]+)(?=\()/)){return"variable callee"}else if(c=a.match(/^["']/)){b.soyState.push("string");b.quoteKind=c[0];return"string"}else if(a.match(/^[(]/)){b.soyState.push("open-parentheses");return null}else if(a.match(/(null|true|false)(?!\w)/)||a.match(/0x([0-9a-fA-F]{2,})/)||a.match(/-?([0-9]*[.])?[0-9]+(e[0-9]*)?/)){return"atom"}else if(a.match(/(\||[+\-*\/%]|[=!]=|\?:|[<>]=?)/)){return"operator"}else if(c=a.match(/^\$([\w]+)/)){return l(b.variables,c[1],!b.lookupVariables)}else if(c=a.match(/^\w+/)){return/^(?:as|and|or|not|in|if)$/.test(c[0])?"keyword":null}a.next();return null}return{startState:function(){return{soyState:[],variables:j(null,"ij"),scopes:null,indent:0,quoteKind:null,context:null,lookupVariables:true,localStates:[{mode:f.html,state:a.startState(f.html)}]}},copyState:function(b){return{tag:b.tag,soyState:b.soyState.concat([]),variables:b.variables,context:b.context,indent:b.indent,quoteKind:b.quoteKind,lookupVariables:b.lookupVariables,localStates:b.localStates.map(function(b){return{mode:b.mode,state:a.copyState(b.mode,b.state)}})}},token:function(e,i){var o;switch(g(i.soyState)){case"comment":if(e.match(/^.*?\*\//)){i.soyState.pop()}else{e.skipToEnd()}if(!i.context||!i.context.scope){var p=/@param\??\s+(\S+)/g;var q=e.current();for(var o;o=p.exec(q);){i.variables=j(i.variables,o[1])}}return"comment";case"string":var o=e.match(/^.*?(["']|\\[\s\S])/);if(!o){e.skipToEnd()}else if(o[1]==i.quoteKind){i.quoteKind=null;i.soyState.pop()}return"string"}if(!i.soyState.length||g(i.soyState)!="literal"){if(e.match(/^\/\*/)){i.soyState.push("comment");return"comment"}else if(e.match(e.sol()?/^\s*\/\/.*/:/^\s+\/\/.*/)){return"comment"}}switch(g(i.soyState)){case"templ-def":if(o=e.match(/^\.?([\w]+(?!\.[\w]+)*)/)){i.soyState.pop();return"def"}e.next();return null;case"templ-ref":if(o=e.match(/(\.?[a-zA-Z_][a-zA-Z_0-9]+)+/)){i.soyState.pop();if(o[0][0]=="."){return"variable-2"}return"variable"}if(o=e.match(/^\$([\w]+)/)){i.soyState.pop();return l(i.variables,o[1],!i.lookupVariables)}e.next();return null;case"namespace-def":if(o=e.match(/^\.?([\w\.]+)/)){i.soyState.pop();return"variable"}e.next();return null;case"param-def":if(o=e.match(/^\w+/)){i.variables=j(i.variables,o[0]);i.soyState.pop();i.soyState.push("param-type");return"def"}e.next();return null;case"param-ref":if(o=e.match(/^\w+/)){i.soyState.pop();return"property"}e.next();return null;case"open-parentheses":if(e.match(/[)]/)){i.soyState.pop();return null}return n(e,i);case"param-type":var r=e.peek();if("}]=>,".indexOf(r)!=-1){i.soyState.pop();return null}else if(r=="["){i.soyState.push("param-type-record");return null}else if(r=="("){i.soyState.push("param-type-template");return null}else if(r=="<"){i.soyState.push("param-type-parameter");return null}else if(o=e.match(/^([\w]+|[?])/)){return"type"}e.next();return null;case"param-type-record":var r=e.peek();if(r=="]"){i.soyState.pop();return null}if(e.match(/^\w+/)){i.soyState.push("param-type");return"property"}e.next();return null;case"param-type-parameter":if(e.match(/^[>]/)){i.soyState.pop();return null}if(e.match(/^[<,]/)){i.soyState.push("param-type");return null}e.next();return null;case"param-type-template":if(e.match(/[>]/)){i.soyState.pop();i.soyState.push("param-type");return null}if(e.match(/^\w+/)){i.soyState.push("param-type");return"def"}e.next();return null;case"var-def":if(o=e.match(/^\$([\w]+)/)){i.variables=j(i.variables,o[1]);i.soyState.pop();return"def"}e.next();return null;case"for-loop":if(e.match(/\bin\b/)){i.soyState.pop();return"keyword"}if(e.peek()=="$"){i.soyState.push("var-def");return null}e.next();return null;case"record-literal":if(e.match(/^[)]/)){i.soyState.pop();return null}if(e.match(/[(,]/)){i.soyState.push("map-value");i.soyState.push("record-key");return null}e.next();return null;case"map-literal":if(e.match(/^[)]/)){i.soyState.pop();return null}if(e.match(/[(,]/)){i.soyState.push("map-value");i.soyState.push("map-value");return null}e.next();return null;case"list-literal":if(e.match(/\]/)){i.soyState.pop();i.lookupVariables=true;k(i);return null}if(e.match(/\bfor\b/)){i.lookupVariables=true;i.soyState.push("for-loop");return"keyword"}return n(e,i);case"record-key":if(e.match(/[\w]+/)){return"property"}if(e.match(/^[:]/)){i.soyState.pop();return null}e.next();return null;case"map-value":if(e.peek()==")"||e.peek()==","||e.match(/^[:)]/)){i.soyState.pop();return null}return n(e,i);case"import":if(e.eat(";")){i.soyState.pop();i.indent-=2*b.indentUnit;return null}if(e.match(/\w+(?=\s+as)/)){return"variable"}if(o=e.match(/\w+/)){return/(from|as)/.test(o[0])?"keyword":"def"}if(o=e.match(/^["']/)){i.soyState.push("string");i.quoteKind=o[0];return"string"}e.next();return null;case"tag":var s=i.tag[0]=="/";var t=s?i.tag.substring(1):i.tag;var u=c[t];if(e.match(/^\/?}/)){var v=e.current()=="/}";if(v&&!s){k(i)}if(i.tag=="/template"||i.tag=="/deltemplate"){i.variables=j(null,"ij");i.indent=0}else{i.indent-=b.indentUnit*(v||d.indexOf(i.tag)==-1?2:1)}i.soyState.pop();return"keyword"}else if(e.match(/^([\w?]+)(?==)/)){if(i.context&&i.context.tag==t&&e.current()=="kind"&&(o=e.match(/^="([^"]+)/,false))){var w=o[1];i.context.kind=w;var x=f[w]||f.html;var y=g(i.localStates);if(y.mode.indent){i.indent+=y.mode.indent(y.state,"","")}i.localStates.push({mode:x,state:a.startState(x)})}return"attribute"}return n(e,i);case"literal":if(e.match(/^(?=\{\/literal})/)){i.soyState.pop();return this.token(e,i)}return h(e,i,/\{\/literal}/)}if(e.match(/^\{literal}/)){i.indent+=b.indentUnit;i.soyState.push("literal");i.context=new m(i.context,"literal",i.variables);return"keyword"}else if(o=e.match(/^\{([\/@\\]?\w+\??)(?=$|[\s}]|\/[\/*])/)){var z=i.tag;i.tag=o[1];var s=i.tag[0]=="/";var A=!!c[i.tag];var t=s?i.tag.substring(1):i.tag;var u=c[t];if(i.tag!="/switch")i.indent+=((s||u&&u.reduceIndent)&&z!="switch"?1:2)*b.indentUnit;i.soyState.push("tag");var B=false;if(u){if(!s){if(u.soyState)i.soyState.push(u.soyState)}if(!u.noEndTag&&(A||!s)){i.context=new m(i.context,i.tag,u.variableScope?i.variables:null)}else if(s){if(!i.context||i.context.tag!=t){B=true}else if(i.context){if(i.context.kind){i.localStates.pop();var y=g(i.localStates);if(y.mode.indent){i.indent-=y.mode.indent(y.state,"","")}}k(i)}}}else if(s){B=true}return(B?"error ":"")+"keyword"}else if(e.eat("{")){i.tag="print";i.indent+=2*b.indentUnit;i.soyState.push("tag");return"keyword"}else if(!i.context&&e.match(/\bimport\b/)){i.soyState.push("import");i.indent+=2*b.indentUnit;return"keyword"}return h(e,i,/\{|\s+\/\/|\/\*/)},indent:function(c,d,e){var f=c.indent,h=g(c.soyState);if(h=="comment")return a.Pass;if(h=="literal"){if(/^\{\/literal}/.test(d))f-=b.indentUnit}else{if(/^\s*\{\/(template|deltemplate)\b/.test(d))return 0;if(/^\{(\/|(fallbackmsg|elseif|else|ifempty)\b)/.test(d))f-=b.indentUnit;if(c.tag!="switch"&&/^\{(case|default)\b/.test(d))f-=b.indentUnit;if(/^\{\/switch\b/.test(d))f-=b.indentUnit}var i=g(c.localStates);if(f&&i.mode.indent){f+=i.mode.indent(i.state,d,e)}return f},innerMode:function(a){if(a.soyState.length&&g(a.soyState)!="literal")return null;else return g(a.localStates)},electricInput:/^\s*\{(\/|\/template|\/deltemplate|\/switch|fallbackmsg|elseif|else|case|default|ifempty|\/literal\})$/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",useInnerComments:false,fold:"indent"}},"htmlmixed");a.registerHelper("wordChars","soy",/[\w$]/);a.registerHelper("hintWords","soy",Object.keys(c).concat(["css","debugger"]));a.defineMIME("text/x-soy","soy")});
2//# sourceMappingURL=soy.min.js.map