Liferay.Loader.define("liferay!template-web$codemirror@5.65.2/addon/wrap/hardwrap",["module","exports","require","../../lib/codemirror"],(function(r,t,e){var a,n=void 0;window;a=function(r){"use strict";var t=r.Pos;function findParagraph(r,t,e){for(var a=e.paragraphStart||r.getHelper(t,"paragraphStart"),n=t.line,o=r.firstLine();n>o;--n){var i=r.getLine(n);if(a&&a.test(i))break;if(!/\S/.test(i)){++n;break}}for(var f=e.paragraphEnd||r.getHelper(t,"paragraphEnd"),l=t.line+1,h=r.lastLine();l<=h;++l){if(i=r.getLine(l),f&&f.test(i)){++l;break}if(!/\S/.test(i))break}return{from:n,to:l}}function findBreakPoint(r,t,e,a,n){for(var o=t;o<r.length&&" "==r.charAt(o);)o++;for(;o>0&&!e.test(r.slice(o-1,o+1));--o);if(!n&&o<=r.match(/^[ \t]*/)[0].length)for(o=t+1;o<r.length-1&&!e.test(r.slice(o-1,o+1));++o);for(var i=!0;;i=!1){var f=o;if(a)for(;" "==r.charAt(f-1);)--f;if(0!=f||!i)return{from:f,to:o};o=t}}function wrapRange(e,a,n,o){a=e.clipPos(a),n=e.clipPos(n);var i=o.column||80,f=o.wrapOn||/\s\S|-[^\.\d]/,l=!1!==o.forceBreak,h=!1!==o.killTrailingSpace,g=[],p="",c=a.line,s=e.getRange(a,n,!1);if(!s.length)return null;var m=s[0].match(/^[ \t]*/)[0];m.length>=i&&(i=m.length+1);for(var d=0;d<s.length;++d){var u=s[d],v=p.length,w=0;p&&u&&!f.test(p.charAt(p.length-1)+u.charAt(0))&&(p+=" ",w=1);var P="";if(d&&(P=u.match(/^\s*/)[0],u=u.slice(P.length)),p+=u,d){var b=p.length>i&&m==P&&findBreakPoint(p,i,f,h,l);b&&b.from==v&&b.to==v+w?(p=m+u,++c):g.push({text:[w?" ":""],from:t(c,v),to:t(c+1,P.length)})}for(;p.length>i;){var k=findBreakPoint(p,i,f,h,l);if(!(k.from!=k.to||l&&m!==p.slice(0,k.to)))break;g.push({text:["",m],from:t(c,k.from),to:t(c,k.to)}),p=m+p.slice(k.to),++c}}return g.length&&e.operation((function(){for(var t=0;t<g.length;++t){var a=g[t];(a.text||r.cmpPos(a.from,a.to))&&e.replaceRange(a.text,a.from,a.to)}})),g.length?{from:g[0].from,to:r.changeEnd(g[g.length-1])}:null}r.defineExtension("wrapParagraph",(function(r,e){e=e||{},r||(r=this.getCursor());var a=findParagraph(this,r,e);return wrapRange(this,t(a.from,0),t(a.to-1),e)})),r.commands.wrapLines=function(r){r.operation((function(){for(var e=r.listSelections(),a=r.lastLine()+1,n=e.length-1;n>=0;n--){var o,i=e[n];if(i.empty()){var f=findParagraph(r,i.head,{});o={from:t(f.from,0),to:t(f.to-1)}}else o={from:i.from(),to:i.to()};o.to.line>=a||(a=o.from.line,wrapRange(r,o.from,o.to,{}))}}))},r.defineExtension("wrapRange",(function(r,t,e){return wrapRange(this,r,t,e||{})})),r.defineExtension("wrapParagraphsInRange",(function(r,e,a){a=a||{};for(var n=this,o=[],i=r.line;i<=e.line;){var f=findParagraph(n,t(i,0),a);o.push(f),i=f.to}var l=!1;return o.length&&n.operation((function(){for(var r=o.length-1;r>=0;--r)l=l||wrapRange(n,t(o[r].from,0),t(o[r].to-1),a)})),l}))},"object"==typeof t&&"object"==typeof r?a(e("../../lib/codemirror")):"function"==typeof n&&n.amd?n(["../../lib/codemirror"],a):a(CodeMirror)}));
//# sourceMappingURL=hardwrap.js.map