(function(e,t){t.rangy=e()})(function(){function u(n,r){var i=typeof n[r];return i==t||i==e&&!!n[r]||i=="unknown"}function a(t,n){return typeof t[n]==e&&!!t[n]}function f(e,t){return typeof e[t]!=n}function l(e){return function(t,n){var r=n.length;while(r--)if(!e(t,n[r]))return!1;return!0}}function d(e){return e&&c(e,o)&&p(e,s)}function v(e){return a(e,"body")?e.body:e.getElementsByTagName("body")[0]}function E(e){typeof console!=n&&u(console,"log")&&console.log(e)}function S(e,t){y&&t?alert(e):E(e)}function x(e){w.initialized=!0,w.supported=!1,S("Rangy is not supported in this environment. Reason: "+e,w.config.alertOnFail)}function T(e){S("Rangy warning: "+e,w.config.alertOnWarn)}function L(e){return e.message||e.description||String(e)}function A(){if(!y||w.initialized)return;var e,t=!1,n=!1;u(document,"createRange")&&(e=document.createRange(),c(e,i)&&p(e,r)&&(t=!0));var s=v(document);if(!s||s.nodeName.toLowerCase()!="body"){x("No body element found");return}s&&u(s,"createTextRange")&&(e=s.createTextRange(),d(e)&&(n=!0));if(!t&&!n){x("Neither Range nor TextRange are available");return}w.initialized=!0,w.features={implementsDomRange:t,implementsTextRange:n};var o,a;for(var f in g)(o=g[f])instanceof P&&o.init(o,w);for(var l=0,h=k.length;lt?(s.node=r,s.offset-=t):s.node==e.parentNode&&s.offset>l(e)&&++s.offset;return r}function w(e){if(e.nodeType==9)return e;if(typeof e.ownerDocument!=n)return e.ownerDocument;if(typeof e.document!=n)return e.document;if(e.parentNode)return w(e.parentNode);throw t.createError("getDocument: no document found for node")}function E(e){var r=w(e);if(typeof r.defaultView!=n)return r.defaultView;if(typeof r.parentWindow!=n)return r.parentWindow;throw t.createError("Cannot get a window object for node")}function S(e){if(typeof e.contentDocument!=n)return e.contentDocument;if(typeof e.contentWindow!=n)return e.contentWindow.document;throw t.createError("getIframeDocument: No Document object found for iframe element")}function x(e){if(typeof e.contentWindow!=n)return e.contentWindow;if(typeof e.contentDocument!=n)return e.contentDocument.defaultView;throw t.createError("getIframeWindow: No Window object found for iframe element")}function T(e){return e&&r.isHostMethod(e,"setTimeout")&&r.isHostObject(e,"document")}function N(e,t,n){var i;e?r.isHostProperty(e,"nodeType")?i=e.nodeType==1&&e.tagName.toLowerCase()=="iframe"?S(e):w(e):T(e)&&(i=e.document):i=document;if(!i)throw t.createError(n+"(): Parameter must be a Window object or DOM node");return i}function C(e){var t;while(t=e.parentNode)e=t;return e}function k(e,n,r,i){var s,o,u,a,f;if(e==r)return n===i?0:n[index:"+l(e)+",length:"+e.childNodes.length+"]["+(e.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return e.nodeName}function M(e){var t=w(e).createDocumentFragment(),n;while(n=e.firstChild)t.appendChild(n);return t}function D(e,t,n){var r=i(e),s=e.createElement("div");s.contentEditable=""+!!n,t&&(s.innerHTML=t);var o=r.firstChild;return o?r.insertBefore(s,o):r.appendChild(s),s}function P(e){return e.parentNode.removeChild(e)}function H(e){this.root=e,this._next=e}function B(e){return new H(e)}function j(e,t){this.node=e,this.offset=t}function F(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var n="undefined",r=e.util,i=r.getBody;r.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method"),r.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");var s=document.createElement("div");r.areHostMethods(s,["insertBefore","appendChild","cloneNode"]||!r.areHostObjects(s,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),r.isHostProperty(s,"innerHTML")||t.fail("Element is missing innerHTML property");var o=document.createTextNode("test");r.areHostMethods(o,["splitText","deleteData","insertData","appendData","cloneNode"]||!r.areHostObjects(s,["previousSibling","nextSibling","childNodes","parentNode"])||!r.areHostProperties(o,["data"]))||t.fail("Incomplete Text Node implementation");var u=function(e,t){var n=e.length;while(n--)if(e[n]===t)return!0;return!1},L=!1;(function(){var t=document.createElement("b");t.innerHTML="1";var n=t.firstChild;t.innerHTML="
",L=A(n),e.features.crashyTextNodes=L})();var _;typeof window.getComputedStyle!=n?_=function(e,t){return E(e).getComputedStyle(e,null)[t]}:typeof document.documentElement.currentStyle!=n?_=function(e,t){return e.currentStyle?e.currentStyle[t]:""}:t.fail("No means of obtaining computed style properties found"),H.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next,t,n;if(this._current){t=e.firstChild;if(t)this._next=t;else{n=null;while(e!==this.root&&!(n=e.nextSibling))e=e.parentNode;this._next=n}}return this._current},detach:function(){this._current=this._next=this.root=null}},j.prototype={equals:function(e){return!!e&&this.node===e.node&&this.offset==e.offset},inspect:function(){return"[DomPosition("+O(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},F.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},F.prototype.toString=function(){return this.message},e.dom={arrayContains:u,isHtmlNamespace:a,parentElement:f,getNodeIndex:l,getNodeLength:c,getCommonAncestor:h,isAncestorOf:p,isOrIsAncestorOf:d,getClosestAncestorIn:v,isCharacterDataNode:m,isTextOrCommentNode:g,insertAfter:y,splitDataNode:b,getDocument:w,getWindow:E,getIframeWindow:x,getIframeDocument:S,getBody:i,isWindow:T,getContentDocument:N,getRootContainer:C,comparePoints:k,isBrokenNode:A,inspectNode:O,getComputedStyleProperty:_,createTestElement:D,removeNode:P,fragmentFromNodeChildren:M,createIterator:B,DomPosition:j},e.DOMException=F}),w.createCoreModule("DomRange",["DomUtil"],function(e,t){function y(e,t){return e.nodeType!=3&&(a(e,t.startContainer)||a(e,t.endContainer))}function b(e){return e.document||f(e.startContainer)}function w(e){return v(e.startContainer)}function E(e){return new i(e.parentNode,u(e))}function S(e){return new i(e.parentNode,u (e)+1)}function x(e,t,r){var i=e.nodeType==11?e.firstChild:e;return o(t)?r==t.length?n.insertAfter(e,t):t.parentNode.insertBefore(e,r==0?t:c(t,r)):r>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[r]),i}function T(e,t,n){K(e),K(t);if(b(t)!=b(e))throw new s("WRONG_DOCUMENT_ERR");var r=l(e.startContainer,e.startOffset,t.endContainer,t.endOffset),i=l(e.endContainer,e.endOffset,t.startContainer,t.startOffset);return n?r<=0&&i>=0:r<0&&i>0}function N(e){var t;for(var n,r=b(e.range).createDocumentFragment(),i;n=e.next();){t=e.isPartiallySelectedSubtree(),n=n.cloneNode(!t),t&&(i=e.getSubtreeIterator(),n.appendChild(N(i)),i.detach());if(n.nodeType==10)throw new s("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}function C(e,t,r){var i,s;r=r||{stop:!1};for(var o,u;o=e.next();)if(e.isPartiallySelectedSubtree()){if(t(o)===!1){r.stop=!0;return}u=e.getSubtreeIterator(),C(u,t,r),u.detach();if(r.stop)return}else{i=n.createIterator(o);while(s=i.next())if(t(s)===!1){r.stop=!0;return}}}function k(e){var t;while(e.next())e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),k(t),t.detach()):e.remove()}function L(e){for(var t,n=b(e.range).createDocumentFragment(),r;t=e.next();){e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),r=e.getSubtreeIterator(),t.appendChild(L(r)),r.detach()):e.remove();if(t.nodeType==10)throw new s("HIERARCHY_REQUEST_ERR");n.appendChild(t)}return n}function A(e,t,n){var r=!!t&&!!t.length,i,s=!!n;r&&(i=new RegExp("^("+t.join("|")+")$"));var u=[];return C(new M(e,!1),function(t){if(r&&!i.test(t.nodeType))return;if(s&&!n(t))return;var a=e.startContainer;if(t==a&&o(a)&&e.startOffset==a.length)return;var f=e.endContainer;if(t==f&&o(f)&&e.endOffset==0)return;u.push(t)}),u}function O(e){var t=typeof e.getName=="undefined"?"Range":e.getName();return"["+t+"("+n.inspectNode(e.startContainer)+":"+e.startOffset+", "+n.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function M(e,t){this.range=e,this.clonePartiallySelectedTextNodes=t;if(!e.collapsed){this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset;var n=e.commonAncestorContainer;this.sc===this.ec&&o(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===n&&!o(this.sc)?this.sc.childNodes[this.so]:h(this.sc,n,!0),this._last=this.ec===n&&!o(this.ec)?this.ec.childNodes[this.eo-1]:h(this.ec,n,!0))}}function j(e){return function(t,n){var r,i=n?t:t.parentNode;while(i){r=i.nodeType;if(d(e,r))return i;i=i.parentNode}return null}}function R(e,t){if(q(e,t))throw new s("INVALID_NODE_TYPE_ERR")}function U(e,t){if(!d(t,e.nodeType))throw new s("INVALID_NODE_TYPE_ERR")}function z(e,t){if(t<0||t>(o(e)?e.length:e.childNodes.length))throw new s("INDEX_SIZE_ERR")}function W(e,t){if(F(e,!0)!==F(t,!0))throw new s("WRONG_DOCUMENT_ERR")}function X(e){if(I(e,!0))throw new s("NO_MODIFICATION_ALLOWED_ERR")}function V(e,t){if(!e)throw new s(t)}function $(e,t){return t<=(o(e)?e.length:e.childNodes.length)}function J(e){return!!e.startContainer&&!!e.endContainer&&(!m||!n.isBrokenNode(e.startContainer)&&!n.isBrokenNode(e.endContainer))&&v(e.startContainer)==v(e.endContainer)&&$(e.startContainer,e.startOffset)&&$(e.endContainer,e.endOffset)}function K(e){if(!J(e))throw new Error("Range error: Range is not valid. This usually happens after DOM mutation. Range: ("+e.inspect()+")")}function et(e,t){K(e);var n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=n===i;o(i)&&s>0&&s0&&r=u(n)&&s++,r=0),e.setStartAndEnd(n,r,i,s)}function tt(e){K(e);var t=e.commonAncestorContainer.parentNode.cloneNode(!1);return t.appendChild(e.cloneContents()),t.innerHTML}function ct(e){e.START_TO_START=rt,e.START_TO_END=it,e.END_TO_END=st,e.END_TO_START=ot,e.NODE_BEFORE=ut,e.NODE_AFTER=at,e.NODE_BEFORE_AND_AFTER=ft,e.NODE_INSIDE=lt}function ht(e){ct(e),ct(e.prototype)}function pt(e,t){return function(){K(this);var n=this.startContainer,r=this.startOffset,i=this.commonAncestorContainer,s=new M(this,!0),o,u;n!==i&&(o=h(n,i,!0),u=S(o),n=u.node,r=u.offset),C(s,X),s.reset();var a=e(s);return s.detach(),t(this,n,r,n,r),a}}function dt(t,n){function i(e,t){return function(n){U(n,_),U(v(n),D);var r=(e?E:S)(n);(t?s:a)(this,r.node,r.offset)}}function s(e,t,r){var i=e.endContainer,s=e.endOffset;if(t!==e.startContainer||r!==e.startOffset){if(v(t)!=v(i)||l(t,r,i,s)==1)i=t,s=r;n(e,t,r,i,s)}}function a(e,t,r){var i=e.startContainer,s=e.startOffset;if(t!==e.endContainer||r!==e.endOffset){if(v(t)!=v(i)||l(t,r,i,s)==-1)i=t,s=r;n(e,i,s,t,r)}}var f=function(){};f.prototype=e.rangePrototype,t.prototype=new f,r.extend(t.prototype,{setStart:function(e,t){R(e,!0),z(e,t),s(this,e,t)},setEnd:function(e,t){R(e,!0),z(e,t),a(this,e,t)},setStartAndEnd:function(){var e=arguments,t=e[0],r=e[1],i=t,s=r;switch(e.length){case 3:s=e[2];break;case 4:i=e[2],s=e[3]}n(this,t,r,i,s)},setBoundary:function(e,t,n){this["set"+(n?"Start":"End")](e,t)},setStartBefore:i(!0,!0),setStartAfter:i(!1,!0),setEndBefore:i(!0,!1),setEndAfter:i(!1,!1),collapse:function(e){K(this),e?n(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):n(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){R(e,!0),n(this,e,0,e,p(e))},selectNode:function(e){R(e,!1),U(e,_);var t=E(e),r=S(e);n(this,t.node,t.offset,r.node,r.offset)},extractContents:pt(L,n),deleteContents:pt(k,n),canSurroundContents:function(){K(this),X(this.startContainer),X(this.endContainer);var e=new M(this,!0),t=e._first&&y(e._first,this)||e._last&&y(e._last,this);return e.detach(),!t},splitBoundaries:function(){et(this)},splitBoundariesPreservingPositions:function(e){et(this,e)},normalizeBoundaries:function(){K(this);var e=this.startContainer,t=this.startOffset,r=this.endContainer,i=this.endOffset,s=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(r=e,i=e.length,e.appendData(t.data),g(t))},a=function( n){var s=n.previousSibling;if(s&&s.nodeType==n.nodeType){e=n;var o=n.length;t=s.length,n.insertData(0,s.data),g(s);if(e==r)i+=t,r=e;else if(r==n.parentNode){var a=u(n);i==a?(r=n,i=o):i>a&&i--}}},f=!0,l;if(o(r))i==r.length?s(r):i==0&&(l=r.previousSibling,l&&l.nodeType==r.nodeType&&(i=l.length,e==r&&(f=!1),l.appendData(r.data),g(r),r=l));else{if(i>0){var c=r.childNodes[i-1];c&&o(c)&&s(c)}f=!this.collapsed}if(f){if(o(e))t==0?a(e):t==e.length&&(l=e.nextSibling,l&&l.nodeType==e.nodeType&&(r==l&&(r=e,i+=e.length),e.appendData(l.data),g(l)));else if(tx",G=Q.firstChild.nodeType==3}catch(Y){}e.features.htmlParsingConforms=G;var Z=G?function(e){var t=this.startContainer,r=f(t);if(!t)throw new s("INVALID_STATE_ERR");var i=null;return t.nodeType==1?i=t:o(t)&&(i=n.parentElement(t)),i===null||i.nodeName=="HTML"&&n.isHtmlNamespace(f(i).documentElement)&&n.isHtmlNamespace(i)?i=r.createElement("body"):i=i.cloneNode(!1),i.innerHTML=e,n.fragmentFromNodeChildren(i)}:function(e){var t=b(this),r=t.createElement("body");return r.innerHTML=e,n.fragmentFromNodeChildren(r)},nt=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],rt=0,it=1,st=2,ot=3,ut=0,at=1,ft=2,lt=3;r.extend(e.rangePrototype,{compareBoundaryPoints:function(e,t){K(this),W(this.startContainer,t.startContainer);var n,r,i,s,o=e==ot||e==rt?"start":"end",u=e==it||e==rt?"start":"end";return n=this[o+"Container"],r=this[o+"Offset"],i=t[u+"Container"],s=t[u+"Offset"],l(n,r,i,s)},insertNode:function(e){K(this),U(e,H),X(this.startContainer);if(a(e,this.startContainer))throw new s("HIERARCHY_REQUEST_ERR");var t=x(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){K(this);var e,t;if(this.collapsed)return b(this).createDocumentFragment();if(this.startContainer===this.endContainer&&o(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=b(this).createDocumentFragment(),t.appendChild(e),t;var n=new M(this,!0);return e=N(n),n.detach(),e},canSurroundContents:function(){K(this),X(this.startContainer),X(this.endContainer);var e=new M(this,!0),t=e._first&&y(e._first,this)||e._last&&y(e._last,this);return e.detach(),!t},surroundContents:function(e){U(e,B);if(!this.canSurroundContents())throw new s("INVALID_STATE_ERR");var t=this.extractContents();if(e.hasChildNodes())while(e.lastChild)e.removeChild(e.lastChild);x(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){K(this);var e=new gt(b(this)),t=nt.length,n;while(t--)n=nt[t],e[n]=this[n];return e},toString:function(){K(this);var e=this.startContainer;if(e===this.endContainer&&o(e))return e.nodeType==3||e.nodeType==4?e.data.slice(this.startOffset,this.endOffset):"";var t=[],n=new M(this,!0);return C(n,function(e){(e.nodeType==3||e.nodeType==4)&&t.push(e.data)}),n.detach(),t.join("")},compareNode:function(e){K(this);var t=e.parentNode,n=u(e);if(!t)throw new s("NOT_FOUND_ERR");var r=this.comparePoint(t,n),i=this.comparePoint(t,n+1);return r<0?i>0?ft:ut:i>0?at:lt},comparePoint:function(e,t){return K(this),V(e,"HIERARCHY_REQUEST_ERR"),W(e,this.startContainer),l(e,t,this.startContainer,this.startOffset)<0?-1:l(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:Z,toHtml:function(){return tt(this)},intersectsNode:function(e,t){K(this);if(v(e)!=w(this))return!1;var n=e.parentNode,r=u(e);if(!n)return!0;var i=l(n,r,this.endContainer,this.endOffset),s=l(n,r+1,this.startContainer,this.startOffset);return t?i<=0&&s>=0:i<0&&s>0},isPointInRange:function(e,t){return K(this),V(e,"HIERARCHY_REQUEST_ERR"),W(e,this.startContainer),l(e,t,this.startContainer,this.startOffset)>=0&&l(e,t,this.endContainer,this.endOffset )<=0},intersectsRange:function(e){return T(this,e,!1)},intersectsOrTouchesRange:function(e){return T(this,e,!0)},intersection:function(e){if(this.intersectsRange(e)){var t=l(this.startContainer,this.startOffset,e.startContainer,e.startOffset),n=l(this.endContainer,this.endOffset,e.endContainer,e.endOffset),r=this.cloneRange();return t==-1&&r.setStart(e.startContainer,e.startOffset),n==1&&r.setEnd(e.endContainer,e.endOffset),r}return null},union:function(e){if(this.intersectsOrTouchesRange(e)){var t=this.cloneRange();return l(e.startContainer,e.startOffset,this.startContainer,this.startOffset)==-1&&t.setStart(e.startContainer,e.startOffset),l(e.endContainer,e.endOffset,this.endContainer,this.endOffset)==1&&t.setEnd(e.endContainer,e.endOffset),t}throw new s("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==lt},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,p(e))<=0},containsRange:function(e){var t=this.intersection(e);return t!==null&&e.equals(t)},containsNodeText:function(e){var t=this.cloneRange();t.selectNode(e);var n=t.getNodes([3]);if(n.length>0){t.setStart(n[0],0);var r=n.pop();return t.setEnd(r,r.length),this.containsRange(t)}return this.containsNodeContents(e)},getNodes:function(e,t){return K(this),A(this,e,t)},getDocument:function(){return b(this)},collapseBefore:function(e){this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){this.setStartAfter(e),this.collapse(!0)},getBookmark:function(t){var r=b(this),i=e.createRange(r);t=t||n.getBody(r),i.selectNodeContents(t);var s=this.intersection(i),o=0,u=0;return s&&(i.setEnd(s.startContainer,s.startOffset),o=i.toString().length,u=o+s.toString().length),{start:o,end:u,containerNode:t}},moveToBookmark:function(e){var t=e.containerNode,n=0;this.setStart(t,0),this.collapse(!0);var r=[t],i,s=!1,o=!1,u,a,f;while(!o&&(i=r.pop()))if(i.nodeType==3)u=n+i.length,!s&&e.start>=n&&e.start<=u&&(this.setStart(i,e.start-n),s=!0),s&&e.end>=n&&e.end<=u&&(this.setEnd(i,e.end-n),o=!0),n=u;else{f=i.childNodes,a=f.length;while(a--)r.push(f[a])}},getName:function(){return"DomRange"},equals:function(e){return gt.rangesEqual(this,e)},isValid:function(){return J(this)},inspect:function(){return O(this)},detach:function(){}}),dt(gt,mt),r.extend(gt,{rangeProperties:nt,RangeIterator:M,copyComparisonConstants:ht,createPrototypeRange:dt,inspect:O,toHtml:tt,getRangeDocument:b,rangesEqual:function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}}),e.DomRange=gt}),w.createCoreModule("WrappedRange",["DomRange"],function(e,t){var n,r,i=e.dom,s=e.util,o=i.DomPosition,u=e.DomRange,a=i.getBody,f=i.getContentDocument,l=i.isCharacterDataNode;e.features.implementsDomRange&&function(){function l(e){var t=o.length,n;while(t--)n=o[t],e[n]=e.nativeRange[n];e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset}function c(e,t,n,r,i){var s=e.startContainer!==t||e.startOffset!=n,o=e.endContainer!==r||e.endOffset!=i,u=!e.equals(e.nativeRange);if(s||o||u)e.setEnd(r,i),e.setStart(t,n)}var r,o=u.rangeProperties,h;n=function(e){if(!e)throw t.createError("WrappedRange: Range must be specified");this.nativeRange=e,l(this)},u.createPrototypeRange(n,c),r=n.prototype,r.selectNode=function(e){this.nativeRange.selectNode(e),l(this)},r.cloneContents=function(){return this.nativeRange.cloneContents()},r.surroundContents=function(e){this.nativeRange.surroundContents(e),l(this)},r.collapse=function(e){this.nativeRange.collapse(e),l(this)},r.cloneRange=function(){return new n(this.nativeRange.cloneRange())},r.refresh=function(){l(this)},r.toString=function(){return this.nativeRange.toString()};var p=document.createTextNode("test");a(document).appendChild(p);var d=document.createRange();d.setStart(p,0),d.setEnd(p,0);try{d.setStart(p,1),r.setStart=function(e,t){this.nativeRange.setStart(e,t),l(this)},r.setEnd=function(e,t){this.nativeRange.setEnd(e,t),l(this)},h=function(e){return function(t){this.nativeRange[e](t),l(this)}}}catch(v){r.setStart=function(e,t){try{this.nativeRange.setStart(e,t)}catch(n){this.nativeRange.setEnd(e,t),this.nativeRange.setStart(e,t)}l(this)},r.setEnd=function(e,t){try{this.nativeRange.setEnd(e,t)}catch(n){this.nativeRange.setStart(e,t),this.nativeRange.setEnd(e,t)}l(this)},h=function(e,t){return function(n){try{this.nativeRange[e](n)}catch(r){this.nativeRange[t](n),this.nativeRange[e](n)}l(this)}}}r.setStartBefore=h("setStartBefore","setEndBefore"),r.setStartAfter=h("setStartAfter","setEndAfter"),r.setEndBefore=h("setEndBefore","setStartBefore"),r.setEndAfter=h("setEndAfter","setStartAfter"),r.selectNodeContents=function(e){this.setStartAndEnd(e,0,i.getNodeLength(e))},d.selectNodeContents(p),d.setEnd(p,3);var m=document.createRange();m.selectNodeContents(p),m.setEnd(p,4),m.setStart(p,2),d.compareBoundaryPoints(d.START_TO_END,m)==-1&&d.compareBoundaryPoints(d.END_TO_START,m)==1?r.compareBoundaryPoints=function(e,t){return t=t.nativeRange||t,e==t.START_TO_END?e=t.END_TO_START:e==t.END_TO_START&&(e=t.START_TO_END),this.nativeRange.compareBoundaryPoints(e,t)}:r.compareBoundaryPoints=function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)};var g=document.createElement("div");g.innerHTML="123";var y=g.firstChild,b=a(document);b.appendChild(g),d.setStart(y,1),d.setEnd(y,2),d.deleteContents(),y.data=="13"&&(r.deleteContents=function(){this.nativeRange.deleteContents(),l(this)},r.extractContents=function(){var e=this.nativeRange.extractContents();return l(this),e}),b.removeChild(g),b=null,s.isHostMethod(d,"createContextualFragment")&&(r.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),a(document).removeChild(p),r.getName=function(){return"WrappedRange"},e.WrappedRange=n,e.createNativeRange=function(e){return e=f(e,t,"createNativeRange"),e.createRange()}}();if(e.features.implementsTextRange){var c=function( e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var r=n.parentElement();n=e.duplicate(),n.collapse(!1);var s=n.parentElement(),o=r==s?r:i.getCommonAncestor(r,s);return o==t?o:i.getCommonAncestor(t,o)},h=function(e){return e.compareEndPoints("StartToEnd",e)==0},p=function(e,t,n,r,s){var u=e.duplicate();u.collapse(n);var a=u.parentElement();i.isOrIsAncestorOf(t,a)||(a=t);if(!a.canHaveHTML){var f=new o(a.parentNode,i.getNodeIndex(a));return{boundaryPosition:f,nodeInfo:{nodeIndex:f.offset,containerElement:f.node}}}var c=i.getDocument(a).createElement("span");c.parentNode&&i.removeNode(c);var h,p=n?"StartToStart":"StartToEnd",d,v,m,g,y=s&&s.containerElement==a?s.nodeIndex:0,b=a.childNodes.length,w=b,E=w;for(;;){E==b?a.appendChild(c):a.insertBefore(c,a.childNodes[E]),u.moveToElementText(c),h=u.compareEndPoints(p,e);if(h==0||y==w)break;if(h==-1){if(w==y+1)break;y=E}else w=w==y+1?y:E;E=Math.floor((y+w)/2),a.removeChild(c)}g=c.nextSibling;if(h==-1&&g&&l(g)){u.setEndPoint(n?"EndToStart":"EndToEnd",e);var S;if(/[\r\n]/.test(g.data)){var x=u.duplicate(),T=x.text.replace(/\r\n/g,"\r").length;S=x.moveStart("character",T);while((h=x.compareEndPoints("StartToEnd",x))==-1)S++,x.moveStart("character",1)}else S=u.text.length;m=new o(g,S)}else d=(r||!n)&&c.previousSibling,v=(r||n)&&c.nextSibling,v&&l(v)?m=new o(v,0):d&&l(d)?m=new o(d,d.data.length):m=new o(a,i.getNodeIndex(c));return i.removeNode(c),{boundaryPosition:m,nodeInfo:{nodeIndex:E,containerElement:a}}},d=function(e,t){var n,r,s=e.offset,o=i.getDocument(e.node),u,f,c=a(o).createTextRange(),h=l(e.node);return h?(n=e.node,r=n.parentNode):(f=e.node.childNodes,n=s1,s=[],o=S(t);for(var u=0;u=36)_=!1;else{var h=l.cloneRange();l.setStart(f,0),h.setEnd(f,3),h.setStart(f,2),t.addRange(l),t.addRange(h),_=t.rangeCount==2}}i.removeNode(a),t.removeAllRanges();for(u=0;u1)et(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;t1?et(this,e):t&&this.addRange(e[0])}}Z.getRangeAt=function(e){if(e<0||e>=this.rangeCount)throw new f("INDEX_SIZE_ERR");return this._ranges[e].cloneRange()};var nt;if(N)nt=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=m(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==d?X(t):z(n)?W(t,n):I(t)};else if(o(C,"getRangeAt")&&typeof C.rangeCount==r)nt=function(t){if(H&&T&&t.docSelection.type==d)X(t);else{t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount;if(t.rangeCount){for(var n=0,r=t.rangeCount;n0)return e.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw t.createError("getNativeTextRange: selection contains no range")}),Z.getName=function(){return"WrappedSelection"},Z.inspect=function(){return ut(this)},Z.detach=function(){G(this.win,"delete"),K(this)},J.detachAll=function(){G(null,"deleteAll")},J.inspect=ut,J.isDirectionBackward=y,e.Selection=J,e.selectionPrototype=Z,e.addShimListener(function(e){typeof e.getSelection=="undefined"&&(e.getSelection=function(){return Y(e)}),e=null})});var F=!1,I=function(e){F||(F=!0,!w.initialized&&w.config.autoInitialize&&A())};return y&&(document.readyState=="complete"?I():(u(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",I,!1),C(window,"load",I))),w},this),function(e,t){e(t.rangy)}(function(e){return e.createModule("SaveRestore",["WrappedRange"],function(e,t){function o(e,t){return(t||document).getElementById(e)}function u(e,t){var r="selectionBoundary_"+ +(new Date)+"_"+(""+Math.random()).slice(2),i,o=n.getDocument(e.startContainer),u=e.cloneRange();return u.collapse(t),i=o.createElement("span"),i.id=r,i.style.lineHeight="0",i.style.display="none",i.className="rangySelectionBoundary",i.appendChild(o.createTextNode(s)),u.insertNode(i),i}function a(e,n,i,s){var u=o(i,e);u?(n[s?"setStartBefore":"setEndBefore"](u),r(u)):t.warn("Marker element has been removed. Cannot restore selection." )}function f(e,t){return t.compareBoundaryPoints(e.START_TO_START,e)}function l(t,n){var r,s,o=e.DomRange.getRangeDocument(t),a=t.toString(),f=i(n);return t.collapsed?(s=u(t,!1),{document:o,markerId:s.id,collapsed:!0}):(s=u(t,!1),r=u(t,!0),{document:o,startMarkerId:r.id,endMarkerId:s.id,collapsed:!1,backward:f,toString:function(){return"original text: '"+a+"', new text: '"+t.toString()+"'"}})}function c(n,i){var s=n.document;typeof i=="undefined"&&(i=!0);var u=e.createRange(s);if(n.collapsed){var f=o(n.markerId,s);if(f){f.style.display="inline";var l=f.previousSibling;l&&l.nodeType==3?(r(f),u.collapseToPoint(l,l.length)):(u.collapseBefore(f),r(f))}else t.warn("Marker element has been removed. Cannot restore selection.")}else a(s,u,n.startMarkerId,!0),a(s,u,n.endMarkerId,!1);return i&&u.normalizeBoundaries(),u}function h(t,n){var r=[],s,u,a=i(n);t=t.slice(0),t.sort(f);for(var c=0,h=t.length;c=0;--c)s=t[c],u=e.DomRange.getRangeDocument(s),s.collapsed?s.collapseAfter(o(r[c].markerId,u)):(s.setEndBefore(o(r[c].endMarkerId,u)),s.setStartAfter(o(r[c].startMarkerId,u)));return r}function p(n){if(!e.isSelectionValid(n))return t.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus."),null;var r=e.getSelection(n),i=r.getAllRanges(),s=i.length==1&&r.isBackward(),o=h(i,s);return s?r.setSingleRange(i[0],s):r.setRanges(i),{win:n,rangeInfos:o,restored:!1}}function d(e){var t=[],n=e.length;for(var r=n-1;r>=0;r--)t[r]=c(e[r],!0);return t}function v(t,n){if(!t.restored){var r=t.rangeInfos,i=e.getSelection(t.win),s=d(r),o=r.length;o==1&&n&&e.features.selectionHasExtend&&r[0].backward?(i.removeAllRanges(),i.addRange(s[0],!0)):i.setRanges(s),t.restored=!0}}function m(e,t){var n=o(t,e);n&&r(n)}function g(e){var t=e.rangeInfos;for(var n=0,r=t.length,i;n/g,">")}function u(e,t){t=t||[];var n=e.nodeType,r=e.childNodes,i=r.length,s=[n,e.nodeName,i].join(":"),a="",f="";switch(n){case 3:a=o(e.nodeValue);break;case 8:a="";break;default:a="<"+s+">",f=""}a&&t.push(a);for(var l=0;l>6|192,i&63|128):t.push(i>>12|224,i>>6&63|128,i&63|128);return t}function n(){var e=[];for(var t=0,n,r;t<256;++t){r=t,n=8;while(n--)(r&1)==1?r=r>>>1^3988292384:r>>>=1;e[t]=r>>>0}return e}function r(){return t||(t=n()),t}var t=null;return function(t){var n=e(t),i=-1,s=r();for(var o=0,u=n.length,a;o>>8^s[a];return(i^-1)>>>0}}(),s=e.dom,h=/^([^,]+),([^,\{]+)(\{([^}]+)\})?$/,y="rangySerializedSelection";r.extend(e,{serializePosition:f,deserializePosition:l,serializeRange:c,deserializeRange:p,canDeserializeRange:d,serializeSelection:v,deserializeSelection:m,canDeserializeSelection :g,restoreSelectionFromCookie:w,saveSelectionCookie:E,getElementChecksum:a,nodeToInfoString:u}),r.crc32=i}),e},this),function(e,t){e(t.rangy)}(function(e){return e.createModule("ClassApplier",["WrappedSelection"],function(e,t){function l(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)return!1;return!0}function c(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function h(e,t){return!!e&&(new RegExp("(?:^|\\s)"+t+"(?:\\s|$)")).test(e)}function p(e,t){if(typeof e.classList=="object")return e.classList.contains(t);var n=typeof e.className=="string",r=n?e.className:e.getAttribute("class");return h(r,t)}function d(e,t){if(typeof e.classList=="object")e.classList.add(t);else{var n=typeof e.className=="string",r=n?e.className:e.getAttribute("class");r?h(r,t)||(r+=" "+t):r=t,n?e.className=r:e.setAttribute("class",r)}}function m(e){var t=typeof e.className=="string";return t?e.className:e.getAttribute("class")}function g(e){return e&&e.split(/\s+/).sort().join(" ")}function y(e){return g(m(e))}function b(e,t){return y(e)==y(t)}function w(e,t){var n=t.split(/\s+/);for(var r=0,i=n.length;ri&&++a,s==t&&(o==n||o==n+1)&&(u=r,a+=i-n),s==t&&o>n+1&&--a,e.node=u,e.offset=a}function x(e,t,n){e.node==t&&e.offset>n&&--e.offset}function T(e,t,r,i){r==-1&&(r=t.childNodes.length);var s=e.parentNode,o=n.getNodeIndex(e);u(i,function(e){S(e,s,o,t,r)}),t.childNodes.length==r?t.appendChild(e):t.insertBefore(e,t.childNodes[r])}function N(e,t){var r=e.parentNode,i=n.getNodeIndex(e);u(t,function(e){x(e,r,i)}),n.removeNode(e)}function C(e,t,n,r,i){var s,o=[];while(s=e.firstChild)T(s,t,n++,i),o.push(s);return r&&N(e,i),o}function k(e,t){return C(e,e.parentNode,n.getNodeIndex(e),!0,t)}function L(e,t){var n=e.cloneRange();n.selectNodeContents(t);var r=n.intersection(e),i=r?r.toString():"";return i!=""}function A(e){var t=e.getNodes([3]),n=0,r;while((r=t[n])&&!L(e,r))++n;var i=t.length-1;while((r=t[i])&&!L(e,r))--i;return t.slice(n,i+1)}function O(e,t){if(e.attributes.length!=t.attributes.length)return!1;for(var n=0,r=e.attributes.length,i,s,o;n0&&t1){var i=n.getNodeIndex(r),s=[],o=0,a,f;u(t,function(t,a){f=t.parentNode,a>0&&(f.removeChild(t),f.hasChildNodes()||n.removeNode(f),e&&u(e,function(e){e.node==t&&(e.node=r,e.offset+=o),e.node==f&&e.offset>i&&(--e.offset,e.offset==i+1&&ae.start},isContiguousWith:function(e){return this.start==e.end||this.end==e.start},union:function(e){return new d(Math.min(this.start,e.start),Math.max(this.end,e.end))},intersection:function(e){return new d(Math.max(this.start,e.start),Math.min(this.end,e.end))},getComplements:function(e){var t=[];if(this.start>=e.start){if(this.end<=e.end)return[];t.push(new d(e.end,this.end))}else t.push(new d(this.start,Math.min(this.end,e.start))),this.end>e.end&&t.push(new d(e.end,this.end));return t},toString:function(){return"[CharacterRange("+this.start+", "+this.end+")]"}},d.fromCharacterRange=function(e){return new d(e.start,e.end)};var v={rangeToCharacterRange:function(e,t){var n=e.getBookmark(t);return new d(n.start,n.end)},characterRangeToRange:function(t,n,r){var i=e.createRange(t);return i.moveToBookmark({start:n.start,end:n.end,containerNode:r}),i},serializeSelection:function(e,t){var n=e.getAllRanges(),r=n.length,i=[],s=r==1&&e.isBackward();for(var o=0,u=n.length;o0},serialize:function(e){var t=this,n=t.highlights,r,i,u,f;return n.sort(a),e=s(e,{serializeHighlightText:!1,type:t.converter.type}),r=e.type,u=r!=t.converter.type,u&&(f=p(r)),i=["type:"+r],o(n,function(n){var r=n.characterRange,s;u&&(s=n.getContainerElement(),r=f.rangeToCharacterRange(t.converter.characterRangeToRange(t.doc,r,s),s));var o=[r.start,r.end,n.id,n.classApplier.className,n.containerElementId];e.serializeHighlightText&&o.push(n.getText()),i.push(o.join("$"))}),i.join("|")},deserialize:function(e){var t=e.split("|"),n=[],r=t[0],i,s,o,u=!1;if(!r||!(i=/^type:(\w+)$/.exec(r)))throw new Error("Serialized highlights are invalid.");s=i[1],s!=this.converter.type&&(o=p(s),u=!0),t.shift();var a,l,c,h,v;for(var g=t.length,y;g-->0;){y=t[g].split("$"),c=new d(+y[0],+y[1]),h=y[4]||null,u&&(v=f(this.doc,h),c=this.converter.rangeToCharacterRange(o.characterRangeToRange(this.doc,c,v),v)),a=this.classAppliers[y[3]];if(!a)throw new Error("No class applier found for class '"+y[3]+"'");l=new m(this.doc,c,a,this.converter,parseInt(y[2]),h),l.apply(),n.push(l)}this.highlights=n}},e.Highlighter=g,e.createHighlighter=function(e,t){return new g(e,t)}}),e},this),function(e,t){e(t.rangy)}(function(e){return e.createModule("TextRange",["WrappedSelection"],function(e,t){function E(e,t){function s(e,t,n){i.push({start:e,end:t,isWord:n})}var n=e.join(""),r,i=[],o=0,u,a;while(r=t.wordRegex.exec(n)){u=r.index,a=u+r[0].length,u>o&&s(o,u,!1);if(t.includeTrailingSpace)while(p.test(e[a]))++a;s(u,a,!0),o=a}return o0)l=x(e.chars.concat(t),n,s);return l.shift()},previousStartToken:function(){var e,t;while(c.length==1&&!(e=c[0]).isWord&&(t=o(!1)).length>0)c=x(t.reverse().concat(e.chars),n,s);return c.pop()},dispose:function(){r.dispose(),i.dispose(),l=c=null}}}function Nt(e,t,n,s,o){var u=0,a,f=e,l,c,h=Math.abs(n),p;if(n!==0){var d=n<0;switch(t){case r:l=St(e,d,null,s);while((a=l.next())&&u0){v=g(c,h);break}}else d=!0}}else if((c=u.indexOf(t))!=-1){v=g(c,c+t.length);break}}return d&&(v=g(c,h)),o.dispose(),v}function Ot(e){return function(){var t=!!gt,n=wt(),r=[n].concat(o.toArray(arguments)),i=e.apply(this,r);return t||Et(),i}}function Mt(e,t){return Ot(function(i,s,o,u){typeof o==n&&(o=s,s=r),u=D(u,A);var a=e;t&&(a=o>=0,this.collapse(!a));var f=Nt(i.getRangeBoundaryPosition(this,a),s,o,u.characterOptions,u.wordOptions),l=f.position;return this[a?"setStart":"setEnd"](l.node,l.offset),f.unitsMoved})}function _t(e){return Ot(function(t,n){n=a(n,T);var r,i=Ct(t,this,n,!e),s=0;while((r=i.next())&&h.test(r.character))++s;i.dispose();var o=s>0;return o&&this[e?"moveStart":"moveEnd"]("character",e?s:-s,{characterOptions:n}),o})}function Dt(e){return Ot(function(t,n){var r=!1;return this.changeEachRange(function(t){r=t[e](n)||r}),r})}var n="undefined",r="character",i="word",s=e.dom,o=e.util,u=o.extend,a=o.createOptions,f=s.getBody,l=/^[ \t\f\r\n]+$/,c=/^[ \t\f\r]+$/,h=/^[\t-\r \u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/,p=/^[\t \u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000]+$/,d=/^[\n-\r\u0085\u2028\u2029]$/,v="en",m=e.Selection.isDirectionBackward,g=!1,y=!1,b=!1,w=!0;(function(){var t=s.createTestElement(document,"

1

",!0),n=t.firstChild,r=e.getSelection();r.collapse(n.lastChild,2),r.setStart(n.firstChild,0),g=(""+r).length==1,t.innerHTML="1
",r.collapse(t,2),r.setStart(t.firstChild,0),y=(""+r).length==1,t.innerHTML="1

1

",r.collapse(t,2),r.setStart(t.firstChild,0),b=(""+r).length==1,s.removeNode(t),r.removeAllRanges()})();var T={includeBlockContentTrailingSpace:!0,includeSpaceBeforeBr:!0,includeSpaceBeforeBlock:!0,includePreLineTrailingSpace:!0,ignoreCharacters:""},C={includeBlockContentTrailingSpace:!w,includeSpaceBeforeBr:!y,includeSpaceBeforeBlock:!b,includePreLineTrailingSpace:!0},k={en:{wordRegex:/[a-z0-9]+('[a-z0-9]+)*/gi,includeTrailingSpace:!1,tokenizer:E}},L={caseSensitive:!1,withinRange:null,wholeWordsOnly:!1,wrap:!1,direction:"forward",wordOptions:null,characterOptions:null},A={wordOptions:null,characterOptions:null},O={wordOptions:null,characterOptions:null,trim:!1,trimStart:!0,trimEnd:!0},M={wordOptions:null,characterOptions:null,direction:"forward"},P=s.getComputedStyleProperty,H;(function(){var e=document.createElement("table"),t=f(document);t.appendChild(e),H=P(e,"display")=="block" ,t.removeChild(e)})();var B={table:"table",caption:"table-caption",colgroup:"table-column-group",col:"table-column",thead:"table-header-group",tbody:"table-row-group",tfoot:"table-footer-group",tr:"table-row",td:"table-cell",th:"table-cell"};Y.prototype={get:function(e){return this.store.hasOwnProperty(e)?this.store[e]:null},set:function(e,t){return this.store[e]=t}};var Z=0,et=0,rt={getPosition:function(e){var t=this.positions;return t.get(e)||t.set(e,new dt(this,e))},toString:function(){return"[NodeWrapper("+s.inspectNode(this.node)+")]"}};nt.prototype=rt;var it="EMPTY",st="NON_SPACE",ot="UNCOLLAPSIBLE_SPACE",ut="COLLAPSIBLE_SPACE",at="TRAILING_SPACE_BEFORE_BLOCK",ft="TRAILING_SPACE_IN_BLOCK",lt="TRAILING_SPACE_BEFORE_BR",ct="PRE_LINE_TRAILING_SPACE_BEFORE_LINE_BREAK",ht="TRAILING_LINE_BREAK_AFTER_BR",pt="INCLUDED_TRAILING_LINE_BREAK_AFTER_BR";u(rt,{isCharacterDataNode:tt("isCharacterDataNode",s.isCharacterDataNode,"node"),getNodeIndex:tt("nodeIndex",s.getNodeIndex,"node"),getLength:tt("nodeLength",s.getNodeLength,"node"),containsPositions:tt("containsPositions",U,"node"),isWhitespace:tt("isWhitespace",J,"node"),isCollapsedWhitespace:tt("isCollapsedWhitespace",K,"node"),getComputedDisplay:tt("computedDisplay",j,"node"),isCollapsed:tt("collapsed",Q,"node"),isIgnored:tt("ignored",G,"node"),next:tt("nextPos",V,"node"),previous:tt("previous",$,"node"),getTextNodeInfo:tt("textNodeInfo",function(e){var t=null,n=!1,r=P(e.parentNode,"whiteSpace"),i=r=="pre-line";if(i)t=c,n=!0;else if(r=="normal"||r=="nowrap")t=l,n=!0;return{node:e,text:e.data,spaceRegex:t,collapseSpaces:n,preLine:i}},"node"),hasInnerText:tt("hasInnerText",function(e,t){var n=this.session,r=n.getPosition(e.parentNode,this.getNodeIndex()+1),i=n.getPosition(e,0),s=t?r:i,o=t?i:r;while(s!==o){s.prepopulateChar();if(s.isDefinitelyNonEmpty())return!0;s=t?s.previousVisible():s.nextVisible()}return!1},"node"),isRenderedBlock:tt("isRenderedBlock",function(e){var t=e.getElementsByTagName("br");for(var n=0,r=t.length;n0)if(t.nodeType==3){var o=t.data,u=o.charAt(n-1),a=e.nodeWrapper.getTextNodeInfo(),f=a.spaceRegex;a.collapseSpaces?f.test(u)?n>1&&f.test(o.charAt(n-2))||(a.preLine&&o.charAt(n)==="\n"?(r=" ",i=ct):(r=" ",i=ut)):(r=u,i=st,s=!0):(r=u,i=ot,s=!0)}else{var l=t.childNodes[n-1];l&&l.nodeType==1&&!Q(l)&&(l.tagName.toLowerCase()=="br"?(r="\n",e.isBr=!0,i=ut,s=!1):e.checkForTrailingSpace=!0);if(!r){var c=t.childNodes[n];c&&c.nodeType==1&&!Q(c)&&(e.checkForLeadingSpace=!0)}}e.prepopulatedChar=!0,e.character=r,e.characterType=i,e.isCharInvariant=s}},isDefinitelyNonEmpty:function(){var e=this.characterType;return e==st||e==ot},resolveLeadingAndTrailingSpaces:function(){this.prepopulatedChar||this.prepopulateChar();if(this.checkForTrailingSpace){var e=this.session.getNodeWrapper(this.node.childNodes[this.offset-1]).getTrailingSpace();e&&(this.isTrailingSpace=!0,this.character=e,this.characterType=ut),this.checkForTrailingSpace=!1}if(this.checkForLeadingSpace){var t=this.session.getNodeWrapper(this.node.childNodes[this.offset]).getLeadingSpace();t&&(this.isLeadingSpace=!0,this.character=t,this.characterType=ut),this.checkForLeadingSpace=!1}},getPrecedingUncollapsedPosition:function(e){var t=this,n;while(t=t.previousVisible()){n=t.getCharacter(e);if(n!=="")return t}return null},getCharacter:function(e){function p(){return c||(l=h.getPrecedingUncollapsedPosition(e),c=!0),l}this.resolveLeadingAndTrailingSpaces();var t=this.character,n,r=N(e.ignoreCharacters),i=t!==""&&r.indexOf(t)>-1;if(this.isCharInvariant)return n=i?"":t,n;var s=["character",e.includeSpaceBeforeBr,e.includeBlockContentTrailingSpace,e.includePreLineTrailingSpace,r].join("_"),o=this.cache.get(s);if(o!==null)return o;var u="",a=this.characterType==ut,f,l,c=!1,h=this;if(a)if(this.type==pt)u="\n";else if(t!=" "||!(!p()||l.isTrailingSpace||l.character=="\n"||l.character==" "&&l.characterType==ut))if(t=="\n"&&this.isLeadingSpace)p()&&l.character!="\n"&&(u="\n");else{f=this.nextUncollapsed();if(f){f.isBr?this.type=lt:f.isTrailingSpace&&f.character=="\n"?this.type=ft:f.isLeadingSpace&&f.character=="\n"&&(this.type=at);if(f.character=="\n"){if(this.type!=lt||!!e.includeSpaceBeforeBr)if(this.type!=at||!!e.includeSpaceBeforeBlock)if(this.type!=ft||!f.isTrailingSpace||!!e.includeBlockContentTrailingSpace)if(this.type!=ct||f.type!=st||!!e.includePreLineTrailingSpace)t=="\n"?f.isTrailingSpace?this.isTrailingSpace||this.isBr&&(f.type=ht,p()&&l.isLeadingSpace&&!l.isTrailingSpace&&l.character=="\n"?f.character="":f.type=pt):u="\n":t==" "&&(u=" ")}else u=t}}return r.indexOf(u)>-1&&(u=""),this.cache.set(s,u),u},equals:function(e){return!!e&&this.node===e.node&&this.offset===e.offset},inspect:vt,toString:function(){return this.character}};dt.prototype=mt,u(mt,{next:tt("nextPos",function(e){var t=e.nodeWrapper,n=e.node,r=e.offset,i=t.session;if(!n)return null;var s,o,u;return r==t.getLength()?(s=n.parentNode,o=s?t.getNodeIndex()+1:0):t.isCharacterDataNode()?(s=n,o=r+1):(u=n.childNodes[r],i.getNodeWrapper(u).containsPositions()?(s=u,o=0):(s=n,o=r+1)),s?i.getPosition (s,o):null}),previous:tt("previous",function(e){var t=e.nodeWrapper,n=e.node,r=e.offset,i=t.session,o,u,a;return r==0?(o=n.parentNode,u=o?t.getNodeIndex():0):t.isCharacterDataNode()?(o=n,u=r-1):(a=n.childNodes[r-1],i.getNodeWrapper(a).containsPositions()?(o=a,u=s.getNodeLength(a)):(o=n,u=r-1)),o?i.getPosition(o,u):null}),nextVisible:tt("nextVisible",function(e){var t=e.next();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex()+1)),i}),nextUncollapsed:tt("nextUncollapsed",function(e){var t=e;while(t=t.nextVisible()){t.resolveLeadingAndTrailingSpaces();if(t.character!=="")return t}return null}),previousVisible:tt("previousVisible",function(e){var t=e.previous();if(!t)return null;var n=t.nodeWrapper,r=t.node,i=t;return n.isCollapsed()&&(i=n.session.getPosition(r.parentNode,n.getNodeIndex())),i})});var gt=null,yt=function(){function e(e){var t=new Y;return{get:function(n){var r=t.get(n[e]);if(r)for(var i=0,s;s=r[i++];)if(s.node===n)return s;return null},set:function(n){var r=n.node[e],i=t.get(r)||t.set(r,[]);i.push(n)}}}function n(){this.initCaches()}var t=o.isHostProperty(document.documentElement,"uniqueID");return n.prototype={initCaches:function(){this.elementCache=t?function(){var e=new Y;return{get:function(t){return e.get(t.uniqueID)},set:function(t){e.set(t.node.uniqueID,t)}}}():e("tagName"),this.textNodeCache=e("data"),this.otherNodeCache=e("nodeName")},getNodeWrapper:function(e){var t;switch(e.nodeType){case 1:t=this.elementCache;break;case 3:t=this.textNodeCache;break;default:t=this.otherNodeCache}var n=t.get(e);return n||(n=new nt(e,this),t.set(n)),n},getPosition:function(e,t){return this.getNodeWrapper(e).getPosition(t)},getRangeBoundaryPosition:function(e,t){var n=t?"start":"end";return this.getPosition(e[n+"Container"],e[n+"Offset"])},detach:function(){this.elementCache=this.textNodeCache=this.otherNodeCache=null}},n}();u(s,{nextNode:V,previousNode:$});var xt=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var n=0,r=e.length;n