ace.define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"],(function(e,t,n){"use strict";var r=e("../lib/lang");t.$detectIndentation=function(e,t){function n(e){for(var t=0,n=e;n<r.length;n+=e)t+=r[n]||0;return t}for(var r=[],i=[],o=0,s=0,a=Math.min(e.length,1e3),c=0;c<a;c++){var g=e[c];if(/^\s*[^*+\-\s]/.test(g)){if("\t"==g[0])o++,s=-Number.MAX_VALUE;else{var l=g.match(/^ */)[0].length;if(l&&"\t"!=g[l]){var h=l-s;h>0&&!(s%h)&&!(l%h)&&(i[h]=(i[h]||0)+1),r[l]=(r[l]||0)+1}s=l}for(;c<a&&"\\"==g[g.length-1];)g=e[c++]}}var u=i.reduce((function(e,t){return e+t}),0),f={score:0,length:0},d=0;for(c=1;c<12;c++){var p=n(c);1==c?(d=p,p=r[1]?.9:.8,r.length||(p=0)):p/=d,i[c]&&(p+=i[c]/u),p>f.score&&(f={score:p,length:c})}if(f.score&&f.score>1.4)var v=f.length;return o>d+1?((1==v||d<o/4||f.score<1.8)&&(v=void 0),{ch:"\t",length:v}):d>o+1?{ch:" ",length:v}:void 0},t.detectIndentation=function(e){var n=e.getLines(0,1e3),r=t.$detectIndentation(n)||{};return r.ch&&e.setUseSoftTabs(" "==r.ch),r.length&&e.setTabSize(r.length),r},t.trimTrailingSpace=function(e,t){var n=e.getDocument(),r=n.getAllLines(),i=t&&t.trimEmpty?-1:0,o=[],s=-1;t&&t.keepCursorPosition&&(e.selection.rangeCount?e.selection.rangeList.ranges.forEach((function(e,t,n){var r=n[t+1];r&&r.cursor.row==e.cursor.row||o.push(e.cursor)})):o.push(e.selection.getCursor()),s=0);for(var a=o[s]&&o[s].row,c=0,g=r.length;c<g;c++){var l=r[c],h=l.search(/\s+$/);c==a&&(h<o[s].column&&h>i&&(h=o[s].column),s++,a=o[s]?o[s].row:-1),h>i&&n.removeInLine(c,h,l.length)}},t.convertIndentation=function(e,t,n){var i=e.getTabString()[0],o=e.getTabSize();n||(n=o),t||(t=i);for(var s="\t"==t?t:r.stringRepeat(t,n),a=e.doc,c=a.getAllLines(),g={},l={},h=0,u=c.length;h<u;h++){var f=c[h].match(/^\s*/)[0];if(f){var d=e.$getStringScreenWidth(f)[0],p=Math.floor(d/o),v=d%o,m=g[p]||(g[p]=r.stringRepeat(s,p));(m+=l[v]||(l[v]=r.stringRepeat(" ",v)))!=f&&(a.removeInLine(h,0,f.length),a.insertInLine({row:h,column:0},m))}}e.setTabSize(n),e.setUseSoftTabs(" "==t)},t.$parseStringArg=function(e){var t={};/t/.test(e)?t.ch="\t":/s/.test(e)&&(t.ch=" ");var n=e.match(/\d+/);return n&&(t.length=parseInt(n[0],10)),t},t.$parseArg=function(e){return e?"string"==typeof e?t.$parseStringArg(e):"string"==typeof e.text?t.$parseStringArg(e.text):e:{}},t.commands=[{name:"detectIndentation",description:"Detect indentation from content",exec:function(e){t.detectIndentation(e.session)}},{name:"trimTrailingSpace",description:"Trim trailing whitespace",exec:function(e,n){t.trimTrailingSpace(e.session,n)}},{name:"convertIndentation",description:"Convert indentation to ...",exec:function(e,n){var r=t.$parseArg(n);t.convertIndentation(e.session,r.ch,r.length)}},{name:"setIndentation",description:"Set indentation",exec:function(e,n){var r=t.$parseArg(n);r.length&&e.session.setTabSize(r.length),r.ch&&e.session.setUseSoftTabs(" "==r.ch)}}]})),ace.require(["ace/ext/whitespace"],(function(e){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=e)}));