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