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