ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"],function(g,b,D){"use strict";var u=g("../range").Range;function R(t,e){for(var n=e.column||t.getOption("printMarginColumn"),p=0!=e.allowMerge,r=Math.min(e.startRow,e.endRow),d=Math.max(e.startRow,e.endRow),i=t.session;r<=d;){var f=i.getLine(r);if(f.length>n){if(c=E(f,n,5)){var y=/^\s*/.exec(f)[0];i.replace(new u(r,c.start,r,c.end),"\n"+y)}d++}else if(p&&/\S/.test(f)&&r!=d){var h=i.getLine(r+1);if(h&&/\S/.test(h)){var c,v=f.replace(/\s+$/,""),S=h.replace(/^\s+/,""),x=v+" "+S;if((c=E(x,n,5))&&c.start>v.length||x.length<n){var W=new u(r,v.length,r+1,h.length-S.length);i.replace(W," "),r--,d--}else v.length<f.length&&i.remove(new u(r,v.length,r,f.length))}}r++}function E(w,s,j){if(!(w.length<s)){var A=w.slice(0,s),C=w.slice(s),l=/^(?:(\s+)|(\S+)(\s+))/.exec(C),a=/(?:(\s+)|(\s+)(\S+))$/.exec(A),o=0,M=0;if(a&&!a[2]&&(o=s-a[1].length,M=s),l&&!l[2]&&(o||(o=s),M=s+l[1].length),o)return{start:o,end:M};if(a&&a[2]&&a.index>j)return{start:a.index,end:a.index+a[2].length};if(l&&l[2])return{start:o=s+l[2].length,end:o+l[3].length}}}}function $(t){if("insertstring"==t.command.name&&/\S/.test(t.args)){var e=t.editor,n=e.selection.cursor;if(n.column<=e.renderer.$printMarginColumn)return;var p=e.session.$undoManager.$lastDelta;R(e,{startRow:n.row,endRow:n.row,allowMerge:!1}),p!=e.session.$undoManager.$lastDelta&&e.session.markUndoGroup()}}var m=g("../editor").Editor;g("../config").defineOptions(m.prototype,"editor",{hardWrap:{set:function(t){t?this.commands.on("afterExec",$):this.commands.off("afterExec",$)},value:!1}}),b.hardWrap=R}),ace.require(["ace/ext/hardwrap"],function(g){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=g)});