YUI.add("aui-char-counter",function(e,t){var n=e.Lang,r=n.isNumber,i="char-counter",s="counter",o="input",u="maxLength",a="scrollLeft",f="scrollTop";e.Node.DOM_EVENTS.compositionend=1,e.Node.DOM_EVENTS.compositionstart=1;var l=e.Component.create({NAME:i,ATTRS:{counter:{setter:e.one},input:{setter:e.one},maxLength:{lazyAdd:!1,setter:function(e){return this._setMaxLength(e)},validator:r,value:Infinity}},EXTENDS:e.Base,prototype:{_eventHandles:null,_inputComposition:!1,initializer:function(){var e=this;e.bindUI(),e.checkLength()},bindUI:function(){var t=this,n=t.get(o);t.publish("maxLength"),t.after("maxLengthChange",t.checkLength),n&&(t._eventHandles=[n.on("compositionend",e.bind(t._onInputCompositionEnd,t)),n.on("compositionstart",e.bind(t._onInputCompositionStart,t)),n.on(o,e.bind(t._onInputChange,t))])},syncUI:function(){var e=this,t=e.get(s);if(t){var n=e.get(o).val(),r=e.get(u)-e._getNormalizedLength(n);t.html(r)}},destroy:function(){var t=this;(new e.EventHandle(t._eventHandles)).detach()},checkLength:function(){var e=this,t=e.get(o);if(!t)return!1;var n=e.get(u),r=t.val(),i=e._getNormalizedLength(r);if(i>n){var s=t.get("scrollTop"),l=t.get("scrollLeft"),c=n-(i-r.length);r=r.substring(0,c),t.val(r),t.set(f,s),t.set(a,l)}e.syncUI(),i>=n&&e.fire("maxLength")},_getNormalizedLength:function(e){var t=e.match(/(\r\n|\n|\r)/g),n=0;return t!==null&&(n=t.length),e.length+n},_onInputChange:function(e){var t=this;t._inputComposition||t.checkLength()},_onInputCompositionEnd:function(){var e=this;e._inputComposition=!1,e.checkLength()},_onInputCompositionStart:function(){var e=this;e._inputComposition=!0},_setMaxLength:function(e){var t=this,n=t.get(o);return n&&e<Infinity&&n.set(u,e),e}}});e.CharCounter=l},"2.0.0",{requires:["aui-node","aui-event-input","aui-component"]});
