(function(){function g(b,a){for(var c=[];a>0;c[--a]=b);return c.join("")}function f(b){if(b)return d.escapeRegExp(b);return"\\s"}var i=String.prototype.trim,d={isBlank:function(b){return!!b.match(/^\s*$/)},capitalize:function(b){return b.charAt(0).toUpperCase()+b.substring(1).toLowerCase()},chop:function(b,a){a=a||b.length;for(var c=[],d=0;d=0&&c++,e=e+(d>=0?d:0)+a.length;return c},chars:function(b){return b.split("")},escapeHTML:function(b){return String(b||"").replace(/&/g,"&").replace(//g,">")},unescapeHTML:function(b){return String(b||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeRegExp:function(b){return String(b||"").replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},insert:function(b,a,c){b=b.split("");b.splice(a,0,c);return b.join("")},includes:function(b,a){return b.indexOf(a)!== -1},join:function(b){b=String(b);for(var a="",c=1;c=a.length&&b.substring(0,a.length)===a},endsWith:function(b,a){return b.length>=a.length&&b.substring(b.length-a.length)===a},succ:function(b){var a=b.split("");a.splice(b.length-1,1,String.fromCharCode(b.charCodeAt(b.length- 1)+1));return a.join("")},titleize:function(b){b=b.split(" ");for(var a,c=0;c1&&(c=c[0]):c=" ";switch(d){case "right":e= a-b.length;e=g(c,e);b+=e;break;case "both":e=a-b.length;e={left:g(c,Math.ceil(e/2)),right:g(c,Math.floor(e/2))};b=e.left+b+e.right;break;default:e=a-b.length,e=g(c,e),b=e+b}return b},lpad:function(b,a,c){return d.pad(b,a,c)},rpad:function(b,a,c){return d.pad(b,a,c,"right")},lrpad:function(b,a,c){return d.pad(b,a,c,"both")},sprintf:function(){for(var b=0,a,c=arguments[b++],d=[],e,h,f;c;){if(e=/^[^\x25]+/.exec(c))d.push(e[0]);else if(e=/^\x25{2}/.exec(c))d.push("%");else if(e=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(c)){if((a= arguments[e[1]||b++])==null||a==void 0)throw"Too few arguments.";if(/[^s]/.test(e[7])&&typeof a!="number")throw"Expecting number but found "+typeof a;switch(e[7]){case "b":a=a.toString(2);break;case "c":a=String.fromCharCode(a);break;case "d":a=parseInt(a);break;case "e":a=e[6]?a.toExponential(e[6]):a.toExponential();break;case "f":a=e[6]?parseFloat(a).toFixed(e[6]):parseFloat(a);break;case "o":a=a.toString(8);break;case "s":a=(a=String(a))&&e[6]?a.substring(0,e[6]):a;break;case "u":a=Math.abs(a); break;case "x":a=a.toString(16);break;case "X":a=a.toString(16).toUpperCase()}a=/[def]/.test(e[7])&&e[2]&&a>=0?"+"+a:a;h=e[3]?e[3]=="0"?"0":e[3].charAt(1):" ";f=e[5]-String(a).length-0;h=e[5]?g(h,f):"";d.push(""+(e[4]?a+h:h+a))}else throw"Huh ?!";c=c.substring(e[0].length)}return d.join("")}};d.strip=d.trim;d.lstrip=d.ltrim;d.rstrip=d.rtrim;d.center=d.lrpad;d.ljust=d.lpad;d.rjust=d.rpad;typeof window==="undefined"&&typeof module!=="undefined"?module.exports=d:typeof this._!=="undefined"?this._.mixin(d): this._=d})();