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