text: ﻿(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 m(e,b,a){var d;return d=e.getWrapperElement().appendChild(document.createElement("div")),d.className=a?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof b?d.innerHTML=b:d.appendChild(b),d}function o(e,b){e.state.currentNotificationClose&&e.state.currentNotificationClose();
  e.state.currentNotificationClose=b}e.defineExtension("openDialog",function(f,b,a){function d(d){if("string"==typeof d)c.value=d;else if(!h&&(h=!0,k.parentNode.removeChild(k),j.focus(),a.onClose))a.onClose(k)}var c;a||(a={});o(this,null);var k=m(this,f,a.bottom),h=!1,j=this;if(c=k.getElementsByTagName("input")[0],c){if(a.value&&(c.value=a.value,!1!==a.selectValueOnOpen&&c.select()),a.onInput)e.on(c,"input",function(b){a.onInput(b,c.value,d)});if(a.onKeyUp)e.on(c,"keyup",function(b){a.onKeyUp(b,c.value,
  d)});e.on(c,"keydown",function(f){a&&a.onKeyDown&&a.onKeyDown(f,c.value,d)||((27==f.keyCode||!1!==a.closeOnEnter&&13==f.keyCode)&&(c.blur(),e.e_stop(f),d()),13==f.keyCode&&b(c.value,f))});if(!1!==a.closeOnBlur)e.on(c,"blur",d);c.focus()}else if(f=k.getElementsByTagName("button")[0]){e.on(f,"click",function(){d();j.focus()});if(!1!==a.closeOnBlur)e.on(f,"blur",d);f.focus()}return d});e.defineExtension("openConfirm",function(f,b,a){function d(){h||(h=!0,k.parentNode.removeChild(k),j.focus())}var c;
  o(this,null);var k=m(this,f,a&&a.bottom),a=k.getElementsByTagName("button"),h=!1,j=this,l=1;a[0].focus();for(f=0;f<a.length;++f)c=a[f],function(a){e.on(c,"click",function(b){e.e_preventDefault(b);d();a&&a(j)})}(b[f]),e.on(c,"blur",function(){--l;setTimeout(function(){0>=l&&d()},200)}),e.on(c,"focus",function(){++l})});e.defineExtension("openNotification",function(f,b){function a(){c||(c=!0,clearTimeout(k),d.parentNode.removeChild(d))}o(this,a);var d=m(this,f,b&&b.bottom),c=!1,k,h=b&&"undefined"!=
  typeof b.duration?b.duration:5E3;e.on(d,"click",function(b){e.e_preventDefault(b);a()});return h&&(k=setTimeout(a,h)),a})});
  (function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)})(function(e){function m(g,a){return"string"==typeof g?g=RegExp(g.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),a?"gi":"g"):g.global||(g=RegExp(g.source,g.ignoreCase?"gi":"g")),{token:function(a){g.lastIndex=a.pos;var b=
  g.exec(a.string);if(b&&b.index==a.pos)return a.pos+=b[0].length,"searching";b?a.pos=b.index:a.skipToEnd()}}}function o(){this.overlay=this.posFrom=this.posTo=this.lastQuery=this.query=null}function f(g){return g.state.search||(g.state.search=new o)}function b(g){return"string"==typeof g&&g==g.toLowerCase()}function a(g,a,d){return g.getSearchCursor(a,d,b(a))}function d(g,a,b,d,e){g.openDialog?g.openDialog(a,e,{value:d,selectValueOnOpen:!0}):e(prompt(b,d))}function c(g,a,b,d){g.openConfirm?g.openConfirm(a,
  d):confirm(b)&&d[0]()}function k(a){var b=a.match(/^\/(.*)\/([a-z]*)$/);if(b)try{a=RegExp(b[1],-1==b[2].indexOf("i")?"":"i")}catch(d){}return("string"==typeof a?""==a:a.test(""))&&(a=/x^/),a}function h(a,e){var c=f(a),i;if(c.query)return j(a,e);i=a.getSelection()||c.lastQuery;d(a,n,"Search for:",i,function(d){a.operation(function(){d&&!c.query&&(c.query=k(d),a.removeOverlay(c.overlay,b(c.query)),c.overlay=m(c.query,b(c.query)),a.addOverlay(c.overlay),a.showMatchesOnScrollbar&&(c.annotate&&(c.annotate.clear(),
  c.annotate=null),c.annotate=a.showMatchesOnScrollbar(c.query,b(c.query))),c.posFrom=c.posTo=a.getCursor(),j(a,e))})})}function j(g,b){g.operation(function(){var d=f(g),c=a(g,d.query,b?d.posFrom:d.posTo);(c.find(b)||(c=a(g,d.query,b?e.Pos(g.lastLine()):e.Pos(g.firstLine(),0)),c.find(b)))&&(g.setSelection(c.from(),c.to()),g.scrollIntoView({from:c.from(),to:c.to()}),d.posFrom=c.from(),d.posTo=c.to())})}function l(a){a.operation(function(){var b=f(a);(b.lastQuery=b.query,b.query)&&(b.query=null,a.removeOverlay(b.overlay),
  b.annotate&&(b.annotate.clear(),b.annotate=null))})}function q(b,e){if(!b.getOption("readOnly")){var n=b.getSelection()||f(b).lastQuery;d(b,r,"Replace:",n,function(f){f&&(f=k(f),d(b,p,"Replace with:","",function(d){if(e)b.operation(function(){for(var c,e=a(b,f);e.findNext();)"string"!=typeof f?(c=b.getRange(e.from(),e.to()).match(f),e.replace(d.replace(/\$(\d)/g,function(a,b){return c[b]}))):e.replace(d)});else{l(b);var n=a(b,f,b.getCursor()),h=function(){var d=n.from(),e;((e=n.findNext())||(n=a(b,
  f),(e=n.findNext())&&(!d||n.from().line!=d.line||n.from().ch!=d.ch)))&&(b.setSelection(n.from(),n.to()),b.scrollIntoView({from:n.from(),to:n.to()}),c(b,i,"Replace?",[function(){p(e)},h]))},p=function(a){n.replace("string"==typeof f?d:d.replace(/\$(\d)/g,function(b,d){return a[d]}));h()};h()}}))})}}var n='Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>',r='Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>',
  p='With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>',i="Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";e.commands.find=function(a){l(a);h(a)};e.commands.findNext=h;e.commands.findPrev=function(a){h(a,!0)};e.commands.clearSearch=l;e.commands.replace=q;e.commands.replaceAll=function(a){q(a,!0)}});
  (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 m(b,a,d,c){var e,h,j,l;this.atOccurrence=!1;this.doc=b;null==c&&"string"==typeof a&&(c=!1);d=d?b.clipPos(d):f(0,0);this.pos={from:d,to:d};"string"!=typeof a?(a.global||(a=RegExp(a.source,a.ignoreCase?"ig":"g")),this.matches=function(d,c){var e,h,i,g,j;if(d){a.lastIndex=0;e=b.getLine(c.line).slice(0,
  c.ch);for(h=0;!(a.lastIndex=h,j=a.exec(e),!j)&&!(i=j,g=i.index,h=i.index+(i[0].length||1),h==e.length););(h=i&&i[0].length||0)||(0==g&&0==e.length?i=void 0:g!=b.getLine(c.line).length&&h++)}else a.lastIndex=c.ch,e=b.getLine(c.line),h=(i=a.exec(e))&&i[0].length||0,g=i&&i.index,g+h==e.length||h||(h=1);if(i&&h)return{from:f(c.line,g),to:f(c.line,g+h),match:i}}):(e=a,c&&(a=a.toLowerCase()),h=c?function(a){return a.toLowerCase()}:function(a){return a},j=a.split("\n"),1==j.length?this.matches=a.length?
  function(d,c){if(d){var j=b.getLine(c.line).slice(0,c.ch),l=h(j),i=l.lastIndexOf(a);if(-1<i)return i=o(j,l,i),{from:f(c.line,i),to:f(c.line,i+e.length)}}else if(j=b.getLine(c.line).slice(c.ch),l=h(j),i=l.indexOf(a),-1<i)return i=o(j,l,i)+c.ch,{from:f(c.line,i),to:f(c.line,i+e.length)}}:function(){}:(l=e.split("\n"),this.matches=function(a,c){var d=j.length-1,e,i,g,k,m;if(a){if(c.line-(j.length-1)<b.firstLine()||h(b.getLine(c.line).slice(0,l[d].length))!=j[j.length-1])return;e=f(c.line,l[d].length);
  k=c.line-1;for(m=d-1;1<=m;--m,--k)if(j[m]!=h(b.getLine(k)))return;return(i=b.getLine(k),g=i.length-l[0].length,h(i.slice(g))!=j[0])?void 0:{from:f(k,g),to:e}}if(!(c.line+(j.length-1)>b.lastLine())&&(i=b.getLine(c.line),g=i.length-l[0].length,h(i.slice(g))==j[0])){e=f(c.line,g);k=c.line+1;for(m=1;m<d;++m,++k)if(j[m]!=h(b.getLine(k)))return;if(h(b.getLine(k).slice(0,l[d].length))==j[d])return{from:e,to:f(k,l[d].length)}}}))}function o(b,a,d){var c;if(b.length==a.length)return d;for(a=Math.min(d,b.length);;)if(c=
  b.slice(0,a).toLowerCase().length,c<d)++a;else if(c>d)--a;else return a}var f=e.Pos;m.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(b){function a(a){a=f(a,0);return d.pos={from:a,to:a},d.atOccurrence=!1,!1}for(var d=this,c=this.doc.clipPos(b?this.pos.from:this.pos.to),e;;){if(this.pos=this.matches(b,c))return this.atOccurrence=!0,this.pos.match||!0;if(b){if(!c.line)return a(0);c=f(c.line-1,this.doc.getLine(c.line-1).length)}else{if(e=
  this.doc.lineCount(),c.line==e-1)return a(e);c=f(c.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(b,a){if(this.atOccurrence){var d=e.splitLines(b);this.doc.replaceRange(d,this.pos.from,this.pos.to,a);this.pos.to=f(this.pos.from.line+d.length-1,d[d.length-1].length+(1==d.length?this.pos.from.ch:0))}}};e.defineExtension("getSearchCursor",function(b,a,d){return new m(this.doc,b,a,d)});e.defineDocExtension("getSearchCursor",
  function(b,a,d){return new m(this,b,a,d)});e.defineExtension("selectMatches",function(b,a){for(var d=[],c=this.getSearchCursor(b,this.getCursor("from"),a);c.findNext()&&!(0<e.cmpPos(c.to(),this.getCursor("to")));)d.push({anchor:c.from(),head:c.to()});d.length&&this.setSelections(d,0)})});