!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript"],t):t(CodeMirror)}(function(t){"use strict";function e(t,e,n,r){this.state=t,this.mode=e,this.depth=n,this.prev=r}t.defineMode("jsx",function(n,r){var i=t.getMode(n,{name:"xml",allowMissing:!0,multilineTagIndentPastTag:!1,allowMissingTagName:!0}),a=t.getMode(n,r&&r.base||"javascript");function o(t){var e=t.tagName;t.tagName=null;var n=i.indent(t,"","");return t.tagName=e,n}return{startState:function(){return{context:new e(t.startState(a),a)}},copyState:function(n){return{context:function n(r){return new e(t.copyState(r.mode,r.state),r.mode,r.depth,r.prev&&n(r.prev))}(n.context)}},token:function r(s,c){return c.context.mode==i?function(s,c,p){if(2==p.depth)return s.match(/^.*?\*\//)?p.depth=1:s.skipToEnd(),"comment";if("{"==s.peek()){i.skipAttribute(p.state);var d=o(p.state),u=p.state.context;if(u&&s.match(/^[^>]*>\s*$/,!1)){for(;u.prev&&!u.startOfLine;)u=u.prev;u.startOfLine?d-=n.indentUnit:p.prev.state.lexical&&(d=p.prev.state.lexical.indented)}else 1==p.depth&&(d+=n.indentUnit);return c.context=new e(t.startState(a,d),a,0,c.context),null}if(1==p.depth){if("<"==s.peek())return i.skipAttribute(p.state),c.context=new e(t.startState(i,o(p.state)),i,0,c.context),null;if(s.match("//"))return s.skipToEnd(),"comment";if(s.match("/*"))return p.depth=2,r(s,c)}var x,f=i.token(s,p.state),l=s.current();return/\btag\b/.test(f)?/>$/.test(l)?p.state.context?p.depth=0:c.context=c.context.prev:/^</.test(l)&&(p.depth=1):!f&&(x=l.indexOf("{"))>-1&&s.backUp(l.length-x),f}(s,c,c.context):function(n,r,o){if("<"==n.peek()&&a.expressionAllowed(n,o.state))return r.context=new e(t.startState(i,a.indent(o.state,"","")),i,0,r.context),a.skipExpression(o.state),null;var s=a.token(n,o.state);if(!s&&null!=o.depth){var c=n.current();"{"==c?o.depth++:"}"==c&&0==--o.depth&&(r.context=r.context.prev)}return s}(s,c,c.context)},indent:function(t,e,n){return t.context.mode.indent(t.context.state,e,n)},innerMode:function(t){return t.context}}},"xml","javascript"),t.defineMIME("text/jsx","jsx"),t.defineMIME("text/typescript-jsx",{name:"jsx",base:{name:"javascript",typescript:!0}})});