// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE !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 e,n,r=t.Pos;function i(t,e){for(var n,r,i=null!=(r=(n=t).flags)?r:(n.ignoreCase?"i":"")+(n.global?"g":"")+(n.multiline?"m":""),o=i,l=0;l>1,h=r(t.slice(0,l)).length;if(h==n)return l;h>n?o=l:i=l+1}}function s(t,s,c,f){var u;this.atOccurrence=!1,this.doc=t,c=c?t.clipPos(c):r(0,0),this.pos={from:c,to:c},"object"==typeof f?u=f.caseFold:(u=f,f=null),"string"==typeof s?(null==u&&(u=!1),this.matches=function(i,o){return(i?function(t,i,o,l){if(!i.length)return null;var s=l?e:n,c=s(i).split(/\r|\n\r?/);t:for(var f=o.line,u=o.ch,a=t.firstLine()-1+c.length;f>=a;f--,u=-1){var g=t.getLine(f);u>-1&&(g=g.slice(0,u));var m=s(g);if(1==c.length){var d=m.lastIndexOf(c[0]);if(-1==d)continue t;return{from:r(f,h(g,m,d,s)),to:r(f,h(g,m,d+c[0].length,s))}}var v=c[c.length-1];if(m.slice(0,v.length)==v){var p=1;for(o=f-c.length+1;p=s;o--,h=-1){var c=t.getLine(o);h>-1&&(c=c.slice(0,h));var f=l(c,e);if(f)return{from:r(o,f.index),to:r(o,f.index+f[0].length),match:f}}}:o)(t,s,n)}:this.matches=function(e,n){return(e?function(t,e,n){e=i(e,"gm");for(var o,h=1,s=n.line,c=t.firstLine();s>=c;){for(var f=0;fc);f++){var u=t.getLine(s++);l=null==l?u:l+"\n"+u}h*=2,e.lastIndex=n.ch;var a=e.exec(l);if(a){var g=l.slice(0,a.index).split("\n"),m=a[0].split("\n"),d=n.line+g.length-1,v=g[g.length-1].length;return{from:r(d,v),to:r(d+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:a}}}})(t,s,n)})}String.prototype.normalize?(e=function(t){return t.normalize("NFD").toLowerCase()},n=function(t){return t.normalize("NFD")}):(e=function(t){return t.toLowerCase()},n=function(t){return t}),s.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){for(var n=this.matches(e,this.doc.clipPos(e?this.pos.from:this.pos.to));n&&0==t.cmpPos(n.from,n.to);)e?n.from.ch?n.from=r(n.from.line,n.from.ch-1):n=n.from.line==this.doc.firstLine()?null:this.matches(e,this.doc.clipPos(r(n.from.line-1))):n.to.ch0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)})});