(function(){"use strict";function r(e){var n=e.search(t);return n==-1?0:n}var e={},t=/[^\s\u00a0]/,n=CodeMirror.Pos;CodeMirror.commands.toggleComment=function(e){var t=e.getCursor("start"),n=e.getCursor("end");e.uncomment(t,n)||e.lineComment(t,n)},CodeMirror.defineExtension("lineComment",function(i,s,o){o||(o=e);var u=this,a=u.getModeAt(i),f=o.lineComment||a.lineComment;if(!f){if(o.blockCommentStart||a.blockCommentStart)o.fullLines=!0,u.blockComment(i,s,o);return}var l=u.getLine(i.line);if(l==null)return;var c=Math.min(s.ch!=0||s.line==i.line?s.line+1:s.line,u.lastLine()+1),h=o.padding==null?" ":o.padding,p=o.commentBlankLines||i.line==s.line;u.operation(function(){if(o.indent){var e=l.slice(0,r(l));for(var s=i.line;s<c;++s){var a=u.getLine(s),d=e.length;if(!p&&!t.test(a))continue;a.slice(0,d)!=e&&(d=r(a)),u.replaceRange(e+f+h,n(s,0),n(s,d))}}else for(var s=i.line;s<c;++s)(p||t.test(u.getLine(s)))&&u.replaceRange(f+h,n(s,0))})}),CodeMirror.defineExtension("blockComment",function(r,i,s){s||(s=e);var o=this,u=o.getModeAt(r),a=s.blockCommentStart||u.blockCommentStart,f=s.blockCommentEnd||u.blockCommentEnd;if(!a||!f){(s.lineComment||u.lineComment)&&s.fullLines!=0&&o.lineComment(r,i,s);return}var l=Math.min(i.line,o.lastLine());l!=r.line&&i.ch==0&&t.test(o.getLine(l))&&--l;var c=s.padding==null?" ":s.padding;if(r.line>l)return;o.operation(function(){if(s.fullLines!=0){var e=t.test(o.getLine(l));o.replaceRange(c+f,n(l)),o.replaceRange(a+c,n(r.line,0));var h=s.blockCommentLead||u.blockCommentLead;if(h!=null)for(var p=r.line+1;p<=l;++p)(p!=l||e)&&o.replaceRange(h+c,n(p,0))}else o.replaceRange(f,i),o.replaceRange(a,r)})}),CodeMirror.defineExtension("uncomment",function(r,i,s){s||(s=e);var o=this,u=o.getModeAt(r),a=Math.min(i.line,o.lastLine()),f=Math.min(r.line,a),l=s.lineComment||u.lineComment,c=[],h=s.padding==null?" ":s.padding,p;e:{if(!l)break e;for(var d=f;d<=a;++d){var v=o.getLine(d),m=v.indexOf(l);if(!(m!=-1||d==a&&d!=f||!t.test(v)))break e;if(d!=f&&m>-1&&t.test(v.slice(0,m)))break e;c.push(v)}o.operation(function(){for(var e=f;e<=a;++e){var t=c[e-f],r=t.indexOf(l),i=r+l.length;if(r<0)continue;t.slice(i,i+h.length)==h&&(i+=h.length),p=!0,o.replaceRange("",n(e,r),n(e,i))}});if(p)return!0}var g=s.blockCommentStart||u.blockCommentStart,y=s.blockCommentEnd||u.blockCommentEnd;if(!g||!y)return!1;var b=s.blockCommentLead||u.blockCommentLead,w=o.getLine(f),E=a==f?w:o.getLine(a),S=w.indexOf(g),x=E.lastIndexOf(y);return x==-1&&f!=a&&(E=o.getLine(--a),x=E.lastIndexOf(y)),S==-1||x==-1?!1:(o.operation(function(){o.replaceRange("",n(a,x-(h&&E.slice(x-h.length,x)==h?h.length:0)),n(a,x+y.length));var e=S+g.length;h&&w.slice(e,e+h.length)==h&&(e+=h.length),o.replaceRange("",n(f,S),n(f,e));if(b)for(var r=f+1;r<=a;++r){var i=o.getLine(r),s=i.indexOf(b);if(s==-1||t.test(i.slice(0,s)))continue;var u=s+b.length;h&&i.slice(u,u+h.length)==h&&(u+=h.length),o.replaceRange("",n(r,s),n(r,u))}}),!0)})})();