!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,i,r){var o=e.getLineHandle(t.line),f=t.ch-1,l=f>=0&&c[o.text.charAt(f)]||c[o.text.charAt(++f)];if(!l)return null;var u=">"==l.charAt(1)?1:-1;if(i&&u>0!=(f==t.ch))return null;var h=e.getTokenTypeAt(a(t.line,f+1)),s=n(e,a(t.line,f+(u>0?1:0)),u,h||null,r);return null==s?null:{from:a(t.line,f),to:s&&s.pos,match:s&&s.ch==l.charAt(0),forward:u>0}}function n(e,t,n,i,r){for(var o=r&&r.maxScanLineLength||1e4,f=r&&r.maxScanLines||1e3,l=[],u=r&&r.bracketRegex?r.bracketRegex:/[(){}[\]]/,h=n>0?Math.min(t.line+f,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-f),s=t.line;s!=h;s+=n){var m=e.getLine(s);if(m){var d=n>0?0:m.length-1,g=n>0?m.length:-1;if(!(m.length>o))for(s==t.line&&(d=t.ch-(n<0?1:0));d!=g;d+=n){var p=m.charAt(d);if(u.test(p)&&(void 0===i||e.getTokenTypeAt(a(s,d+1))==i)){var v=c[p];if(">"==v.charAt(1)==n>0)l.push(p);else{if(!l.length)return{pos:a(s,d),ch:p};l.pop()}}}}}return s-n!=(n>0?e.lastLine():e.firstLine())&&null}function i(e,n,i){for(var r=e.state.matchBrackets.maxHighlightLineLength||1e3,c=[],f=e.listSelections(),l=0;l<f.length;l++){var u=f[l].empty()&&t(e,f[l].head,!1,i);if(u&&e.getLine(u.from.line).length<=r){var h=u.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";c.push(e.markText(u.from,a(u.from.line,u.from.ch+1),{className:h})),u.to&&e.getLine(u.to.line).length<=r&&c.push(e.markText(u.to,a(u.to.line,u.to.ch+1),{className:h}))}}if(c.length){o&&e.state.focused&&e.focus();var s=function(){e.operation(function(){for(var e=0;e<c.length;e++)c[e].clear()})};if(!n)return s;setTimeout(s,800)}}function r(e){e.operation(function(){f&&(f(),f=null),f=i(e,!1,e.state.matchBrackets)})}var o=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<8),a=e.Pos,c={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},f=null;e.defineOption("matchBrackets",!1,function(t,n,i){i&&i!=e.Init&&t.off("cursorActivity",r),n&&(t.state.matchBrackets="object"==typeof n?n:{},t.on("cursorActivity",r))}),e.defineExtension("matchBrackets",function(){i(this,!0)}),e.defineExtension("findMatchingBracket",function(e,n,i){return t(this,e,n,i)}),e.defineExtension("scanForBracket",function(e,t,i,r){return n(this,e,t,i,r)})});