Liferay.Loader.define("liferay!object-js-components-web$codemirror@5.65.12/addon/comment/comment",["module","exports","require","../../lib/codemirror"],(function(e,n,t){var i,o=void 0;window;i=function(e){"use strict";var n={},t=/[^\s\u00a0]/,i=e.Pos,o=e.cmpPos;function firstNonWS(e){var n=e.search(t);return-1==n?0:n}function getMode(e,n){var t=e.getMode();return!1!==t.useInnerComments&&t.innerMode?e.getModeAt(n):t}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",(function(e){e||(e=n);for(var t=this,o=1/0,l=this.listSelections(),r=null,a=l.length-1;a>=0;a--){var m=l[a].from(),c=l[a].to();m.line>=o||(c.line>=o&&(c=i(o,0)),o=m.line,null==r?t.uncomment(m,c,e)?r="un":(t.lineComment(m,c,e),r="line"):"un"==r?t.uncomment(m,c,e):t.lineComment(m,c,e))}})),e.defineExtension("lineComment",(function(e,o,l){l||(l=n);var r=this,a=getMode(r,e),m=r.getLine(e.line);if(null!=m&&!function probablyInsideString(e,n,t){return/\bstring\b/.test(e.getTokenTypeAt(i(n.line,0)))&&!/^[\'\"\`]/.test(t)}(r,e,m)){var c=l.lineComment||a.lineComment;if(c){var g=Math.min(0!=o.ch||o.line==e.line?o.line+1:o.line,r.lastLine()+1),s=null==l.padding?" ":l.padding,f=l.commentBlankLines||e.line==o.line;r.operation((function(){if(l.indent){for(var n=null,o=e.line;o<g;++o){var a=-1===(m=r.getLine(o)).search(t)?m:m.slice(0,firstNonWS(m));(null==n||n.length>a.length)&&(n=a)}for(o=e.line;o<g;++o){var m=r.getLine(o),d=n.length;(f||t.test(m))&&(m.slice(0,d)!=n&&(d=firstNonWS(m)),r.replaceRange(n+c+s,i(o,0),i(o,d)))}}else for(o=e.line;o<g;++o)(f||t.test(r.getLine(o)))&&r.replaceRange(c+s,i(o,0))}))}else(l.blockCommentStart||a.blockCommentStart)&&(l.fullLines=!0,r.blockComment(e,o,l))}})),e.defineExtension("blockComment",(function(e,l,r){r||(r=n);var a=this,m=getMode(a,e),c=r.blockCommentStart||m.blockCommentStart,g=r.blockCommentEnd||m.blockCommentEnd;if(c&&g){if(!/\bcomment\b/.test(a.getTokenTypeAt(i(e.line,0)))){var s=Math.min(l.line,a.lastLine());s!=e.line&&0==l.ch&&t.test(a.getLine(s))&&--s;var f=null==r.padding?" ":r.padding;e.line>s||a.operation((function(){if(0!=r.fullLines){var n=t.test(a.getLine(s));a.replaceRange(f+g,i(s)),a.replaceRange(c+f,i(e.line,0));var d=r.blockCommentLead||m.blockCommentLead;if(null!=d)for(var u=e.line+1;u<=s;++u)(u!=s||n)&&a.replaceRange(d+f,i(u,0))}else{var h=0==o(a.getCursor("to"),l),p=!a.somethingSelected();a.replaceRange(g,l),h&&a.setSelection(p?l:a.getCursor("from"),l),a.replaceRange(c,e)}}))}}else(r.lineComment||m.lineComment)&&0!=r.fullLines&&a.lineComment(e,l,r)})),e.defineExtension("uncomment",(function(e,o,l){l||(l=n);var r,a=this,m=getMode(a,e),c=Math.min(0!=o.ch||o.line==e.line?o.line:o.line-1,a.lastLine()),g=Math.min(e.line,c),s=l.lineComment||m.lineComment,f=[],d=null==l.padding?" ":l.padding;e:if(s){for(var u=g;u<=c;++u){var h=a.getLine(u),p=h.indexOf(s);if(p>-1&&!/comment/.test(a.getTokenTypeAt(i(u,p+1)))&&(p=-1),-1==p&&t.test(h))break e;if(p>-1&&t.test(h.slice(0,p)))break e;f.push(h)}if(a.operation((function(){for(var e=g;e<=c;++e){var n=f[e-g],t=n.indexOf(s),o=t+s.length;t<0||(n.slice(o,o+d.length)==d&&(o+=d.length),r=!0,a.replaceRange("",i(e,t),i(e,o)))}})),r)return!0}var v=l.blockCommentStart||m.blockCommentStart,C=l.blockCommentEnd||m.blockCommentEnd;if(!v||!C)return!1;var b=l.blockCommentLead||m.blockCommentLead,k=a.getLine(g),L=k.indexOf(v);if(-1==L)return!1;var x=c==g?k:a.getLine(c),S=x.indexOf(C,c==g?L+v.length:0),M=i(g,L+1),R=i(c,S+1);if(-1==S||!/comment/.test(a.getTokenTypeAt(M))||!/comment/.test(a.getTokenTypeAt(R))||a.getRange(M,R,"\n").indexOf(C)>-1)return!1;var y=k.lastIndexOf(v,e.ch),O=-1==y?-1:k.slice(0,e.ch).indexOf(C,y+v.length);if(-1!=y&&-1!=O&&O+C.length!=e.ch)return!1;O=x.indexOf(C,o.ch);var T=x.slice(o.ch).lastIndexOf(v,O-o.ch);return y=-1==O||-1==T?-1:o.ch+T,(-1==O||-1==y||y==o.ch)&&(a.operation((function(){a.replaceRange("",i(c,S-(d&&x.slice(S-d.length,S)==d?d.length:0)),i(c,S+C.length));var e=L+v.length;if(d&&k.slice(e,e+d.length)==d&&(e+=d.length),a.replaceRange("",i(g,L),i(g,e)),b)for(var n=g+1;n<=c;++n){var o=a.getLine(n),l=o.indexOf(b);if(-1!=l&&!t.test(o.slice(0,l))){var r=l+b.length;d&&o.slice(r,r+d.length)==d&&(r+=d.length),a.replaceRange("",i(n,l),i(n,r))}}})),!0)}))},"object"==typeof n&&"object"==typeof e?i(t("../../lib/codemirror")):"function"==typeof o&&o.amd?o(["../../lib/codemirror"],i):i(CodeMirror)}));
//# sourceMappingURL=comment.js.map