'use strict';var $jscomp={scope:{},findInternal:function(a,e,k){a instanceof String&&(a=String(a));for(var g=a.length,b=0;b<g;b++){var d=a[b];if(e.call(k,d,b,a))return{i:b,v:d}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,k){if(k.get||k.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[e]=k.value)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,e,k,g){if(e){k=$jscomp.global;a=a.split(".");for(g=0;g<a.length-1;g++){var b=a[g];b in k||(k[b]={});k=k[b]}a=a[a.length-1];g=k[a];e=e(g);e!=g&&null!=e&&$jscomp.defineProperty(k,a,{configurable:!0,writable:!0,value:e})}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,k){return $jscomp.findInternal(this,a,k).v}},"es6-impl","es3");
(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){function e(b,a,h,q){this.atOccurrence=!1;this.doc=b;null==q&&"string"==typeof a&&(q=!1);h=h?b.clipPos(h):g(0,0);this.pos={from:h,to:h};if("string"!=typeof a)a.global||(a=new RegExp(a.source,a.ignoreCase?"ig":"g")),this.matches=function(m,f){if(m){a.lastIndex=0;m=b.getLine(f.line).slice(0,f.ch);for(var l=
0,c,d;;){a.lastIndex=l;l=a.exec(m);if(!l)break;c=l;d=c.index;l=c.index+(c[0].length||1);if(l==m.length)break}(l=c&&c[0].length||0)||(0==d&&0==m.length?c=void 0:d!=b.getLine(f.line).length&&l++)}else a.lastIndex=f.ch,m=b.getLine(f.line),l=(c=a.exec(m))&&c[0].length||0,d=c&&c.index,d+l==m.length||l||(l=1);if(c&&l)return{from:g(f.line,d),to:g(f.line,d+l),match:c}};else{var d=a;q&&(a=a.toLowerCase());var e=q?function(a){return a.toLowerCase()}:function(a){return a},n=a.split("\n");if(1==n.length)this.matches=
a.length?function(m,f){if(m){m=b.getLine(f.line).slice(0,f.ch);var l=e(m),c=l.lastIndexOf(a);if(-1<c)return c=k(m,l,c),{from:g(f.line,c),to:g(f.line,c+d.length)}}else if(m=b.getLine(f.line).slice(f.ch),l=e(m),c=l.indexOf(a),-1<c)return c=k(m,l,c)+f.ch,{from:g(f.line,c),to:g(f.line,c+d.length)}}:function(){};else{var p=d.split("\n");this.matches=function(a,f){var d=n.length-1;if(a){if(!(f.line-(n.length-1)<b.firstLine()||e(b.getLine(f.line).slice(0,p[d].length))!=n[n.length-1])){a=g(f.line,p[d].length);
f=f.line-1;for(var c=d-1;1<=c;--c,--f)if(n[c]!=e(b.getLine(f)))return;var c=b.getLine(f),h=c.length-p[0].length;return e(c.slice(h))!=n[0]?void 0:{from:g(f,h),to:a}}}else if(!(f.line+(n.length-1)>b.lastLine())&&(c=b.getLine(f.line),h=c.length-p[0].length,e(c.slice(h))==n[0])){a=g(f.line,h);f=f.line+1;for(c=1;c<d;++c,++f)if(n[c]!=e(b.getLine(f)))return;return e(b.getLine(f).slice(0,p[d].length))!=n[d]?void 0:{from:a,to:g(f,p[d].length)}}}}}}function k(a,d,h){if(a.length==d.length)return h;for(d=Math.min(h,
a.length);;){var b=a.slice(0,d).toLowerCase().length;if(b<h)++d;else if(b>h)--d;else return d}}var g=a.Pos;e.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function b(a){a=g(a,0);h.pos={from:a,to:a};return h.atOccurrence=!1}for(var h=this,e=this.doc.clipPos(a?this.pos.from:this.pos.to);;){if(this.pos=this.matches(a,e))return this.atOccurrence=!0,this.pos.match||!0;if(a){if(!e.line)return b(0);e=g(e.line-1,this.doc.getLine(e.line-
1).length)}else{var k=this.doc.lineCount();if(e.line==k-1)return b(k);e=g(e.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(b,d){this.atOccurrence&&(b=a.splitLines(b),this.doc.replaceRange(b,this.pos.from,this.pos.to,d),this.pos.to=g(this.pos.from.line+b.length-1,b[b.length-1].length+(1==b.length?this.pos.from.ch:0)))}};a.defineExtension("getSearchCursor",function(a,d,h){return new e(this.doc,a,d,h)});
a.defineDocExtension("getSearchCursor",function(a,d,h){return new e(this,a,d,h)});a.defineExtension("selectMatches",function(b,d){var e=[];for(b=this.getSearchCursor(b,this.getCursor("from"),d);b.findNext()&&!(0<a.cmpPos(b.to(),this.getCursor("to")));)e.push({anchor:b.from(),head:b.to()});e.length&&this.setSelections(e,0)})});
