KISSY.Editor.add("walker",function(n){function o(e,c){if(this._.end)return k;var a,b=this.range,g,p=this.guard,q=this.type,u=e?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start){this._.start=1;b.trim();if(b.collapsed){this.end();return k}}if(!e&&!this._.guardLTR){var v=b.endContainer,w=new r(v[0].childNodes[b.endOffset]);this._.guardLTR=function(d,l){return(d=s._4e_wrap(d))&&d[0]&&(!l||!s._4e_equals(v,d))&&(!w[0]||!d._4e_equals(w))&&(d[0].nodeType!=m.NODE_ELEMENT||!l||d._4e_name()!="body")}}if(e&&
!this._.guardRTL){var x=b.startContainer,y=b.startOffset>0&&new r(x[0].childNodes[b.startOffset-1]);this._.guardRTL=function(d,l){return(d=s._4e_wrap(d))&&d[0]&&(!l||!d._4e_equals(x))&&(!y[0]||!d._4e_equals(y))&&(d[0].nodeType!=m.NODE_ELEMENT||!l||d._4e_name()!="body")}}var z=e?this._.guardRTL:this._.guardLTR;g=p?function(d,l){if(z(d,l)===h)return h;return p(d,l)}:z;if(this.current)a=this.current[u](h,q,g);else if(e){a=b.endContainer;if(b.endOffset>0){a=new r(a[0].childNodes[b.endOffset-1]);if(g(a)===
h)a=k}else a=g(a,i)===h?k:a._4e_previousSourceNode(i,q,g)}else{a=b.startContainer;if((a=new r(a[0].childNodes[b.startOffset]))&&a[0]){if(g(a)===h)a=k}else a=g(b.startContainer,i)===h?k:b.startContainer._4e_nextSourceNode(i,q,g)}for(;a&&a[0]&&!this._.end;){this.current=a;if(!this.evaluator||this.evaluator(a)!==h){if(!c)return a}else if(c&&this.evaluator)return h;a=a[u](h,q,g)}this.end();return this.current=k}function A(e){for(var c,a=k;c=o.call(this,e);)a=c;return a}function f(e){this.range=e;this._=
{}}var i=true,h=false,k=null,t=KISSY,m=n.NODE,s=t.DOM,r=t.Node;t.augment(f,{end:function(){this._.end=1},next:function(){return o.call(this)},previous:function(){return o.call(this,i)},checkForward:function(){return o.call(this,h,i)!==h},checkBackward:function(){return o.call(this,i,i)!==h},lastForward:function(){return A.call(this)},lastBackward:function(){return A.call(this,i)},reset:function(){delete this.current;this._={}}});f.blockBoundary=function(e){return function(c){c=s._4e_wrap(c);return!(c&&
c[0].nodeType==m.NODE_ELEMENT&&c._4e_isBlockBoundary(e))}};f.listItemBoundary=function(){return this.blockBoundary({br:1})};f.bookmark=function(e,c){function a(b){return b&&b[0]&&b._4e_name()=="span"&&b.attr("_ke_bookmark")}return function(b){var g,p;g=b&&b[0]&&b[0].nodeType==m.NODE_TEXT&&(p=b.parent())&&a(p);g=e?g:g||a(b);return c^g}};f.whitespaces=function(e){return function(c){c=(c=c[0]||c)&&c.nodeType==m.NODE_TEXT&&!t.trim(c.nodeValue);return e^c}};f.invisible=function(e){var c=f.whitespaces();
return function(a){a=c(a)||a[0].nodeType==m.NODE_ELEMENT&&!a[0].offsetHeight;return e^a}};n.Walker=f;n.Walker=f;var j=f.prototype;n.Utils.extern(j,{end:j.end,next:j.next,previous:j.previous,checkForward:j.checkForward,checkBackward:j.checkBackward,lastForward:j.lastForward,lastBackward:j.lastBackward,reset:j.reset});n.Utils.extern(f,{blockBoundary:f.blockBoundary,listItemBoundary:f.listItemBoundary,bookmark:f.bookmark,whitespaces:f.whitespaces,invisible:f.invisible})});
