text: (function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)})(function(n){function q(b,a){var c=b.flags;for(var d=c=null!=c?c:(b.ignoreCase?"i":"")+(b.global?"g":"")+(b.multiline?"m":""),e=0;e<a.length;e++)-1==d.indexOf(a.charAt(e))&&(d+=a.charAt(e));return c==d?b:new RegExp(b.source,d)}function w(b,a,c){a=q(a,"g");var d=c.line,e=c.ch;for(c=b.lastLine();d<=c;d++,e=0)if(a.lastIndex=
  e,e=b.getLine(d),e=a.exec(e))return{from:h(d,e.index),to:h(d,e.index+e[0].length),match:e}}function z(b,a,c){if(!/\\s|\\n|\n|\\W|\\D|\[\^/.test(a.source))return w(b,a,c);a=q(a,"gm");for(var d,e=1,f=c.line,k=b.lastLine();f<=k;){for(var g=0;g<e&&!(f>k);g++){var l=b.getLine(f++);d=null==d?l:d+"\n"+l}e*=2;a.lastIndex=c.ch;if(g=a.exec(d))return a=d.slice(0,g.index).split("\n"),b=g[0].split("\n"),c=c.line+a.length-1,a=a[a.length-1].length,{from:h(c,a),to:h(c+b.length-1,1==b.length?a+b[0].length:b[b.length-
  1].length),match:g}}}function x(b,a){for(var c=0,d;;){a.lastIndex=c;c=a.exec(b);if(!c)return d;d=c;c=d.index+(d[0].length||1);if(c==b.length)return d}}function A(b,a,c){a=q(a,"g");var d=c.line,e=c.ch;for(c=b.firstLine();d>=c;d--,e=-1){var f=b.getLine(d);-1<e&&(f=f.slice(0,e));if(e=x(f,a))return{from:h(d,e.index),to:h(d,e.index+e[0].length),match:e}}}function B(b,a,c){a=q(a,"gm");for(var d,e=1,f=c.line,k=b.firstLine();f>=k;){for(var g=0;g<e;g++){var l=b.getLine(f--);d=null==d?l.slice(0,c.ch):l+"\n"+
  d}e*=2;if(g=x(d,a))return a=d.slice(0,g.index).split("\n"),b=g[0].split("\n"),f+=a.length,a=a[a.length-1].length,{from:h(f,a),to:h(f+b.length-1,1==b.length?a+b[0].length:b[b.length-1].length),match:g}}}function p(b,a,c,d){if(b.length==a.length)return c;var e=0;for(a=c+Math.max(0,b.length-a.length);;){if(e==a)return e;var f=e+a>>1,k=d(b.slice(0,f)).length;if(k==c)return f;k>c?a=f:e=f+1}}function C(b,a,c,d){if(!a.length)return null;d=d?r:t;a=d(a).split(/\r|\n\r?/);var e=c.line;c=c.ch;var f=b.lastLine()+
  1-a.length;a:for(;e<=f;e++,c=0){var k=b.getLine(e).slice(c),g=d(k);if(1==a.length){var l=g.indexOf(a[0]);if(-1==l)continue a;p(k,g,l,d);return{from:h(e,p(k,g,l,d)+c),to:h(e,p(k,g,l+a[0].length,d)+c)}}l=g.length-a[0].length;if(g.slice(l)!=a[0])continue a;for(var m=1;m<a.length-1;m++)if(d(b.getLine(e+m))!=a[m])continue a;m=b.getLine(e+a.length-1);var y=d(m),u=a[a.length-1];if(y.slice(0,u.length)!=u)continue a;return{from:h(e,p(k,g,l,d)+c),to:h(e+a.length-1,p(m,y,u.length,d))}}}function D(b,a,c,d){if(!a.length)return null;
  d=d?r:t;a=d(a).split(/\r|\n\r?/);var e=c.line,f=c.ch,k=b.firstLine()-1+a.length;a:for(;e>=k;e--,f=-1){var g=b.getLine(e);-1<f&&(g=g.slice(0,f));f=d(g);if(1==a.length){c=f.lastIndexOf(a[0]);if(-1==c)continue a;return{from:h(e,p(g,f,c,d)),to:h(e,p(g,f,c+a[0].length,d))}}var l=a[a.length-1];if(f.slice(0,l.length)!=l)continue a;var m=1;for(c=e-a.length+1;m<a.length-1;m++)if(d(b.getLine(c+m))!=a[m])continue a;c=b.getLine(e+1-a.length);m=d(c);if(m.slice(m.length-a[0].length)!=a[0])continue a;return{from:h(e+
  1-a.length,p(c,m,c.length-a[0].length,d)),to:h(e,p(g,f,l.length,d))}}}function v(b,a,c,d){this.atOccurrence=!1;this.doc=b;c=c?b.clipPos(c):h(0,0);this.pos={from:c,to:c};if("object"==typeof d)var e=d.caseFold;else e=d,d=null;"string"==typeof a?(null==e&&(e=!1),this.matches=function(f,k){return(f?D:C)(b,a,k,e)}):(a=q(a,"gm"),this.matches=d&&!1===d.multiline?function(f,k){return(f?A:w)(b,a,k)}:function(f,k){return(f?B:z)(b,a,k)})}var h=n.Pos;if(String.prototype.normalize){var r=function(b){return b.normalize("NFD").toLowerCase()};
  var t=function(b){return b.normalize("NFD")}}else r=function(b){return b.toLowerCase()},t=function(b){return b};v.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(b){for(var a=this.matches(b,this.doc.clipPos(b?this.pos.from:this.pos.to));a&&0==n.cmpPos(a.from,a.to);)b?a.from.ch?a.from=h(a.from.line,a.from.ch-1):a=a.from.line==this.doc.firstLine()?null:this.matches(b,this.doc.clipPos(h(a.from.line-1))):a.to.ch<this.doc.getLine(a.to.line).length?
  a.to=h(a.to.line,a.to.ch+1):a=a.to.line==this.doc.lastLine()?null:this.matches(b,h(a.to.line+1,0));if(a)return this.pos=a,this.atOccurrence=!0,this.pos.match||!0;b=h(b?this.doc.firstLine():this.doc.lastLine()+1,0);this.pos={from:b,to:b};return this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(b,a){this.atOccurrence&&(b=n.splitLines(b),this.doc.replaceRange(b,this.pos.from,this.pos.to,a),this.pos.to=
  h(this.pos.from.line+b.length-1,b[b.length-1].length+(1==b.length?this.pos.from.ch:0)))}};n.defineExtension("getSearchCursor",function(b,a,c){return new v(this.doc,b,a,c)});n.defineDocExtension("getSearchCursor",function(b,a,c){return new v(this,b,a,c)});n.defineExtension("selectMatches",function(b,a){var c=[];for(b=this.getSearchCursor(b,this.getCursor("from"),a);b.findNext()&&!(0<n.cmpPos(b.to(),this.getCursor("to")));)c.push({anchor:b.from(),head:b.to()});c.length&&this.setSelections(c,0)})});
  