Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/fileman/html_editor/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/fileman/html_editor/range.min.js |
(function(e){if(window.rangy){return}var t=typeof e.define=="function"&&e.define.amd;var n="object",r="function",i="undefined";var a=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"];var o=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"];var s=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"];var f=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"];function c(e,t){var i=typeof e[t];return i==r||!!(i==n&&e[t])||i=="unknown"}function l(e,t){return!!(typeof e[t]==n&&e[t])}function u(e,t){return typeof e[t]!=i}function d(e){return function(t,n){var r=n.length;while(r--){if(!e(t,n[r])){return false}}return true}}var h=d(c);var g=d(l);var v=d(u);function p(e){return e&&h(e,f)&&v(e,s)}function m(e){return l(e,"body")?e.body:e.getElementsByTagName("body")[0]}var R={};var C={version:"1.3alpha.804",initialized:false,supported:true,util:{isHostMethod:c,isHostObject:l,isHostProperty:u,areHostMethods:h,areHostObjects:g,areHostProperties:v,isTextRange:p,getBody:m},features:{},modules:R,config:{alertOnFail:true,alertOnWarn:false,preferTextRange:false}};function N(e){if(l(window,"console")&&c(window.console,"log")){window.console.log(e)}}function E(e,t){if(t){window.alert(e)}else{N(e)}}function w(e){C.initialized=true;C.supported=false;E("Rangy is not supported on this page in your browser. Reason: "+e,C.config.alertOnFail)}C.fail=w;function S(e){E("Rangy warning: "+e,C.config.alertOnWarn)}C.warn=S;if({}.hasOwnProperty){C.util.extend=function(e,t,n){var r,i;for(var a in t){if(t.hasOwnProperty(a)){r=e[a];i=t[a];if(n&&r!==null&&typeof r=="object"&&i!==null&&typeof i=="object"){C.util.extend(r,i,true)}e[a]=i}}return e}}else{w("hasOwnProperty not supported")}(function(){var e=document.createElement("div");e.appendChild(document.createElement("span"));var t=[].slice;var n;try{if(t.call(e.childNodes,0)[0].nodeType==1){n=function(e){return t.call(e,0)}}}catch(r){}if(!n){n=function(e){var t=[];for(var n=0,r=e.length;n<r;++n){t[n]=e[n]}return t}}C.util.toArray=n})();var y;if(c(document,"addEventListener")){y=function(e,t,n){e.addEventListener(t,n,false)}}else if(c(document,"attachEvent")){y=function(e,t,n){e.attachEvent("on"+t,n)}}else{w("Document does not have required addEventListener or attachEvent method")}C.util.addListener=y;var O=[];function T(e){return e.message||e.description||String(e)}function _(){if(C.initialized){return}var e;var t=false,n=false;if(c(document,"createRange")){e=document.createRange();if(h(e,o)&&v(e,a)){t=true}e.detach()}var r=m(document);if(!r||r.nodeName.toLowerCase()!="body"){w("No body element found");return}if(r&&c(r,"createTextRange")){e=r.createTextRange();if(p(e)){n=true}}if(!t&&!n){w("Neither Range nor TextRange are available");return}C.initialized=true;C.features={implementsDomRange:t,implementsTextRange:n};var i,s;for(var f in R){if((i=R[f])instanceof x){i.init(i,C)}}for(var l=0,u=O.length;l<u;++l){try{O[l](C)}catch(d){s="Rangy init listener threw an exception. Continuing. Detail: "+T(d);N(s)}}}C.init=_;C.addInitListener=function(e){if(C.initialized){e(C)}else{O.push(e)}};var D=[];C.addCreateMissingNativeApiListener=function(e){D.push(e)};function A(e){e=e||window;_();for(var t=0,n=D.length;t<n;++t){D[t](e)}}C.createMissingNativeApi=A;function x(e,t,n){this.name=e;this.dependencies=t;this.initialized=false;this.supported=false;this.initializer=n}x.prototype={init:function(e){var t=this.dependencies||[];for(var n=0,r=t.length,i,a;n<r;++n){a=t[n];i=R[a];if(!i||!(i instanceof x)){throw new Error("required module '"+a+"' not found")}i.init();if(!i.supported){throw new Error("required module '"+a+"' not supported")}}this.initializer(this)},fail:function(e){this.initialized=true;this.supported=false;throw new Error("Module '"+this.name+"' failed to load: "+e)},warn:function(e){C.warn("Module "+this.name+": "+e)},deprecationNotice:function(e,t){C.warn("DEPRECATED: "+e+" in module "+this.name+"is deprecated. Please use "+t+" instead")},createError:function(e){return new Error("Error in Rangy "+this.name+" module: "+e)}};function P(e,t,n,r){var i=new x(t,n,function(e){if(!e.initialized){e.initialized=true;try{r(C,e);e.supported=true}catch(n){var i="Module '"+t+"' failed to load: "+T(n);N(i)}}});R[t]=i}C.createModule=function(e){var t,n;if(arguments.length==2){t=arguments[1];n=[]}else{t=arguments[2];n=arguments[1]}P(false,e,n,t)};C.createCoreModule=function(e,t,n){P(true,e,t,n)};function b(){}C.RangePrototype=b;C.rangePrototype=new b;function I(){}C.selectionPrototype=new I;var B=false;var H=function(e){if(!B){B=true;if(!C.initialized){_()}}};if(typeof window==i){w("No window found");return}if(typeof document==i){w("No document found");return}if(c(document,"addEventListener")){document.addEventListener("DOMContentLoaded",H,false)}y(window,"load",H);if(t){e.define(function(){C.amd=true;return C})}e.rangy=C})(this);rangy.createCoreModule("DomUtil",[],function(e,t){var n="undefined";var r=e.util;if(!r.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])){t.fail("document missing a Node creation method")}if(!r.isHostMethod(document,"getElementsByTagName")){t.fail("document missing getElementsByTagName method")}var i=document.createElement("div");if(!r.areHostMethods(i,["insertBefore","appendChild","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"]))){t.fail("Incomplete Element implementation")}if(!r.isHostProperty(i,"innerHTML")){t.fail("Element is missing innerHTML property")}var a=document.createTextNode("test");if(!r.areHostMethods(a,["splitText","deleteData","insertData","appendData","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"])||!r.areHostProperties(a,["data"]))){t.fail("Incomplete Text Node implementation")}var o=function(e,t){var n=e.length;while(n--){if(e[n]===t){return true}}return false};function s(e){var t;return typeof e.namespaceURI==n||((t=e.namespaceURI)===null||t=="http://www.w3.org/1999/xhtml")}function f(e){var t=e.parentNode;return t.nodeType==1?t:null}function c(e){var t=0;while(e=e.previousSibling){++t}return t}function l(e){switch(e.nodeType){case 7:case 10:return 0;case 3:case 8:return e.length;default:return e.childNodes.length}}function u(e,t){var n=[],r;for(r=e;r;r=r.parentNode){n.push(r)}for(r=t;r;r=r.parentNode){if(o(n,r)){return r}}return null}function d(e,t,n){var r=n?t:t.parentNode;while(r){if(r===e){return true}else{r=r.parentNode}}return false}function h(e,t){return d(e,t,true)}function g(e,t,n){var r,i=n?e:e.parentNode;while(i){r=i.parentNode;if(r===t){return i}i=r}return null}function v(e){var t=e.nodeType;return t==3||t==4||t==8}function p(e){if(!e){return false}var t=e.nodeType;return t==3||t==8}function m(e,t){var n=t.nextSibling,r=t.parentNode;if(n){r.insertBefore(e,n)}else{r.appendChild(e)}return e}function R(e,t,n){var r=e.cloneNode(false);r.deleteData(0,t);e.deleteData(t,e.length-t);m(r,e);if(n){for(var i=0,a;a=n[i++];){if(a.node==e&&a.offset>t){a.node=r;a.offset-=t}else if(a.node==e.parentNode&&a.offset>c(e)){++a.offset}}}return r}function C(e){if(e.nodeType==9){return e}else if(typeof e.ownerDocument!=n){return e.ownerDocument}else if(typeof e.document!=n){return e.document}else if(e.parentNode){return C(e.parentNode)}else{throw t.createError("getDocument: no document found for node")}}function N(e){var r=C(e);if(typeof r.defaultView!=n){return r.defaultView}else if(typeof r.parentWindow!=n){return r.parentWindow}else{throw t.createError("Cannot get a window object for node")}}function E(e){if(typeof e.contentDocument!=n){return e.contentDocument}else if(typeof e.contentWindow!=n){return e.contentWindow.document}else{throw t.createError("getIframeDocument: No Document object found for iframe element")}}function w(e){if(typeof e.contentWindow!=n){return e.contentWindow}else if(typeof e.contentDocument!=n){return e.contentDocument.defaultView}else{throw t.createError("getIframeWindow: No Window object found for iframe element")}}function S(e){return e&&r.isHostMethod(e,"setTimeout")&&r.isHostObject(e,"document")}function y(e,t,n){var i;if(!e){i=document}else if(r.isHostProperty(e,"nodeType")){i=e.nodeType==1&&e.tagName.toLowerCase()=="iframe"?E(e):C(e)}else if(S(e)){i=e.document}if(!i){throw t.createError(n+"(): Parameter must be a Window object or DOM node")}return i}function O(e){var t;while(t=e.parentNode){e=t}return e}function T(e,n,r,i){var a,o,s,f,l;if(e==r){return n===i?0:n<i?-1:1}else if(a=g(r,e,true)){return n<=c(a)?-1:1}else if(a=g(e,r,true)){return c(a)<i?-1:1}else{o=u(e,r);if(!o){throw new Error("comparePoints error: nodes have no common ancestor")}s=e===o?o:g(e,o,true);f=r===o?o:g(r,o,true);if(s===f){throw t.createError("comparePoints got to case 4 and childA and childB are the same!")}else{l=o.firstChild;while(l){if(l===s){return-1}else if(l===f){return 1}l=l.nextSibling}}}}var _=false;function D(e){try{e.parentNode;return false}catch(t){return true}}(function(){var t=document.createElement("b");t.innerHTML="1";var n=t.firstChild;t.innerHTML="<br>";_=D(n);e.features.crashyTextNodes=_})();function A(e){if(!e){return"[No node]"}if(_&&D(e)){return"[Broken node]"}if(v(e)){return'"'+e.data+'"'}if(e.nodeType==1){var t=e.id?' id="'+e.id+'"':"";return"<"+e.nodeName+t+">["+c(e)+"]["+e.childNodes.length+"]["+(e.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return e.nodeName}function x(e){var t=C(e).createDocumentFragment(),n;while(n=e.firstChild){t.appendChild(n)}return t}var P;if(typeof window.getComputedStyle!=n){P=function(e,t){return N(e).getComputedStyle(e,null)[t]}}else if(typeof document.documentElement.currentStyle!=n){P=function(e,t){return e.currentStyle[t]}}else{t.fail("No means of obtaining computed style properties found")}function b(e){this.root=e;this._next=e}b.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next;var 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}};function I(e){return new b(e)}function B(e,t){this.node=e;this.offset=t}B.prototype={equals:function(e){return!!e&&this.node===e.node&&this.offset==e.offset},inspect:function(){return"[DomPosition("+A(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}};function H(e){this.code=this[e];this.codeName=e;this.message="DOMException: "+this.codeName}H.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};H.prototype.toString=function(){return this.message};e.dom={arrayContains:o,isHtmlNamespace:s,parentElement:f,getNodeIndex:c,getNodeLength:l,getCommonAncestor:u,isAncestorOf:d,isOrIsAncestorOf:h,getClosestAncestorIn:g,isCharacterDataNode:v,isTextOrCommentNode:p,insertAfter:m,splitDataNode:R,getDocument:C,getWindow:N,getIframeWindow:w,getIframeDocument:E,getBody:r.getBody,isWindow:S,getContentDocument:y,getRootContainer:O,comparePoints:T,isBrokenNode:D,inspectNode:A,getComputedStyleProperty:P,fragmentFromNodeChildren:x,createIterator:I,DomPosition:B};e.DOMException=H});rangy.createCoreModule("DomRange",["DomUtil"],function(e,t){var n=e.dom;var r=e.util;var i=n.DomPosition;var a=e.DOMException;var o=n.isCharacterDataNode;var s=n.getNodeIndex;var f=n.isOrIsAncestorOf;var c=n.getDocument;var l=n.comparePoints;var u=n.splitDataNode;var d=n.getClosestAncestorIn;var h=n.getNodeLength;var g=n.arrayContains;var v=n.getRootContainer;var p=e.features.crashyTextNodes;function m(e,t){return e.nodeType!=3&&(f(e,t.startContainer)||f(e,t.endContainer))}function R(e){return e.document||c(e.startContainer)}function C(e){return new i(e.parentNode,s(e))}function N(e){return new i(e.parentNode,s(e)+1)}function E(e,t,r){var i=e.nodeType==11?e.firstChild:e;if(o(t)){if(r==t.length){n.insertAfter(e,t)}else{t.parentNode.insertBefore(e,r==0?t:u(t,r))}}else if(r>=t.childNodes.length){t.appendChild(e)}else{t.insertBefore(e,t.childNodes[r])}return i}function w(e,t,n){Z(e);Z(t);if(R(t)!=R(e)){throw new a("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 S(e){var t;for(var n,r=R(e.range).createDocumentFragment(),i;n=e.next();){t=e.isPartiallySelectedSubtree();n=n.cloneNode(!t);if(t){i=e.getSubtreeIterator();n.appendChild(S(i));i.detach(true)}if(n.nodeType==10){throw new a("HIERARCHY_REQUEST_ERR")}r.appendChild(n)}return r}function y(e,t,r){var i,a;r=r||{stop:false};for(var o,s;o=e.next();){if(e.isPartiallySelectedSubtree()){if(t(o)===false){r.stop=true;return}else{s=e.getSubtreeIterator();y(s,t,r);s.detach(true);if(r.stop){return}}}else{i=n.createIterator(o);while(a=i.next()){if(t(a)===false){r.stop=true;return}}}}}function O(e){var t;while(e.next()){if(e.isPartiallySelectedSubtree()){t=e.getSubtreeIterator();O(t);t.detach(true)}else{e.remove()}}}function T(e){for(var t,n=R(e.range).createDocumentFragment(),r;t=e.next();){if(e.isPartiallySelectedSubtree()){t=t.cloneNode(false);r=e.getSubtreeIterator();t.appendChild(T(r));r.detach(true)}else{e.remove()}if(t.nodeType==10){throw new a("HIERARCHY_REQUEST_ERR")}n.appendChild(t)}return n}function _(e,t,n){var r=!!(t&&t.length),i;var a=!!n;if(r){i=new RegExp("^("+t.join("|")+")$")}var s=[];y(new A(e,false),function(t){if(r&&!i.test(t.nodeType)){return}if(a&&!n(t)){return}var f=e.startContainer;if(t==f&&o(f)&&e.startOffset==f.length){return}var c=e.endContainer;if(t==c&&o(c)&&e.endOffset==0){return}s.push(t)});return s}function D(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 A(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;if(this.sc===this.ec&&o(this.sc)){this.isSingleCharacterDataNode=true;this._first=this._last=this._next=this.sc}else{this._first=this._next=this.sc===n&&!o(this.sc)?this.sc.childNodes[this.so]:d(this.sc,n,true);this._last=this.ec===n&&!o(this.ec)?this.ec.childNodes[this.eo-1]:d(this.ec,n,true)}}}A.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:false,reset:function(){this._current=null;this._next=this._first},hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next;if(e){this._next=e!==this._last?e.nextSibling:null;if(o(e)&&this.clonePartiallySelectedTextNodes){if(e===this.ec){(e=e.cloneNode(true)).deleteData(this.eo,e.length-this.eo)}if(this._current===this.sc){(e=e.cloneNode(true)).deleteData(0,this.so)}}}return e},remove:function(){var e=this._current,t,n;if(o(e)&&(e===this.sc||e===this.ec)){t=e===this.sc?this.so:0;n=e===this.ec?this.eo:e.length;if(t!=n){e.deleteData(t,n-t)}}else{if(e.parentNode){e.parentNode.removeChild(e)}else{}}},isPartiallySelectedSubtree:function(){var e=this._current;return m(e,this.range)},getSubtreeIterator:function(){var e;if(this.isSingleCharacterDataNode){e=this.range.cloneRange();e.collapse(false)}else{e=new Re(R(this.range));var t=this._current;var n=t,r=0,i=t,a=h(t);if(f(t,this.sc)){n=this.sc;r=this.so}if(f(t,this.ec)){i=this.ec;a=this.eo}pe(e,n,r,i,a)}return new A(e,this.clonePartiallySelectedTextNodes)},detach:function(e){if(e){this.range.detach()}this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};function x(e){this.code=this[e];this.codeName=e;this.message="RangeException: "+this.codeName}x.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2};x.prototype.toString=function(){return this.message};var P=[1,3,4,5,7,8,10];var b=[2,9,11];var I=[5,6,10,12];var B=[1,3,4,5,7,8,10,11];var H=[1,3,4,5,7,8];function M(e){return function(t,n){var r,i=n?t:t.parentNode;while(i){r=i.nodeType;if(g(e,r)){return i}i=i.parentNode}return null}}var L=M([9,11]);var W=M(I);var k=M([6,10,12]);function F(e,t){if(k(e,t)){throw new x("INVALID_NODE_TYPE_ERR")}}function U(e){if(!e.startContainer){throw new a("INVALID_STATE_ERR")}}function j(e,t){if(!g(t,e.nodeType)){throw new x("INVALID_NODE_TYPE_ERR")}}function V(e,t){if(t<0||t>(o(e)?e.length:e.childNodes.length)){throw new a("INDEX_SIZE_ERR")}}function z(e,t){if(L(e,true)!==L(t,true)){throw new a("WRONG_DOCUMENT_ERR")}}function Y(e){if(W(e,true)){throw new a("NO_MODIFICATION_ALLOWED_ERR")}}function q(e,t){if(!e){throw new a(t)}}function Q(e){return p&&n.isBrokenNode(e)||!g(b,e.nodeType)&&!L(e,true)}function G(e,t){return t<=(o(e)?e.length:e.childNodes.length)}function X(e){return!!e.startContainer&&!!e.endContainer&&!Q(e.startContainer)&&!Q(e.endContainer)&&G(e.startContainer,e.startOffset)&&G(e.endContainer,e.endOffset)}function Z(e){U(e);if(!X(e)){throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}}var $=document.createElement("style");var J=false;try{$.innerHTML="<b>x</b>";J=$.firstChild.nodeType==3}catch(K){}e.features.htmlParsingConforms=J;var ee=J?function(e){var t=this.startContainer;var r=c(t);if(!t){throw new a("INVALID_STATE_ERR")}var i=null;if(t.nodeType==1){i=t}else if(o(t)){i=n.parentElement(t)}if(i===null||i.nodeName=="HTML"&&n.isHtmlNamespace(c(i).documentElement)&&n.isHtmlNamespace(i)){i=r.createElement("body")}else{i=i.cloneNode(false)}i.innerHTML=e;return n.fragmentFromNodeChildren(i)}:function(e){U(this);var t=R(this);var r=t.createElement("body");r.innerHTML=e;return n.fragmentFromNodeChildren(r)};function te(e,t){Z(e);var n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset;var f=n===i;if(o(i)&&a>0&&a<i.length){u(i,a,t)}if(o(n)&&r>0&&r<n.length){n=u(n,r,t);if(f){a-=r;i=n}else if(i==n.parentNode&&a>=s(n)){a++}r=0}e.setStartAndEnd(n,r,i,a)}var ne=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"];var re=0,ie=1,ae=2,oe=3;var se=0,fe=1,ce=2,le=3;r.extend(e.rangePrototype,{compareBoundaryPoints:function(e,t){Z(this);z(this.startContainer,t.startContainer);var n,r,i,a;var o=e==oe||e==re?"start":"end";var s=e==ie||e==re?"start":"end";n=this[o+"Container"];r=this[o+"Offset"];i=t[s+"Container"];a=t[s+"Offset"];return l(n,r,i,a)},insertNode:function(e){Z(this);j(e,B);Y(this.startContainer);if(f(e,this.startContainer)){throw new a("HIERARCHY_REQUEST_ERR")}var t=E(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){Z(this);var e,t;if(this.collapsed){return R(this).createDocumentFragment()}else{if(this.startContainer===this.endContainer&&o(this.startContainer)){e=this.startContainer.cloneNode(true);e.data=e.data.slice(this.startOffset,this.endOffset);t=R(this).createDocumentFragment();t.appendChild(e);return t}else{var n=new A(this,true);e=S(n);n.detach()}return e}},canSurroundContents:function(){Z(this);Y(this.startContainer);Y(this.endContainer);var e=new A(this,true);var t=e._first&&m(e._first,this)||e._last&&m(e._last,this);e.detach();return!t},surroundContents:function(e){j(e,H);if(!this.canSurroundContents()){throw new x("BAD_BOUNDARYPOINTS_ERR")}var t=this.extractContents();if(e.hasChildNodes()){while(e.lastChild){e.removeChild(e.lastChild)}}E(e,this.startContainer,this.startOffset);e.appendChild(t);this.selectNode(e)},cloneRange:function(){Z(this);var e=new Re(R(this));var t=ne.length,n;while(t--){n=ne[t];e[n]=this[n]}return e},toString:function(){Z(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):""}else{var t=[],n=new A(this,true);y(n,function(e){if(e.nodeType==3||e.nodeType==4){t.push(e.data)}});n.detach();return t.join("")}},compareNode:function(e){Z(this);var t=e.parentNode;var n=s(e);if(!t){throw new a("NOT_FOUND_ERR")}var r=this.comparePoint(t,n),i=this.comparePoint(t,n+1);if(r<0){return i>0?ce:se}else{return i>0?fe:le}},comparePoint:function(e,t){Z(this);q(e,"HIERARCHY_REQUEST_ERR");z(e,this.startContainer);if(l(e,t,this.startContainer,this.startOffset)<0){return-1}else if(l(e,t,this.endContainer,this.endOffset)>0){return 1}return 0},createContextualFragment:ee,toHtml:function(){Z(this);var e=this.commonAncestorContainer.parentNode.cloneNode(false);e.appendChild(this.cloneContents());return e.innerHTML},intersectsNode:function(e,t){Z(this);q(e,"NOT_FOUND_ERR");if(c(e)!==R(this)){return false}var n=e.parentNode,r=s(e);q(n,"NOT_FOUND_ERR");var i=l(n,r,this.endContainer,this.endOffset),a=l(n,r+1,this.startContainer,this.startOffset);return t?i<=0&&a>=0:i<0&&a>0},isPointInRange:function(e,t){Z(this);q(e,"HIERARCHY_REQUEST_ERR");z(e,this.startContainer);return l(e,t,this.startContainer,this.startOffset)>=0&&l(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e){return w(this,e,false)},intersectsOrTouchesRange:function(e){return w(this,e,true)},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);var r=this.cloneRange();if(t==-1){r.setStart(e.startContainer,e.startOffset)}if(n==1){r.setEnd(e.endContainer,e.endOffset)}return r}return null},union:function(e){if(this.intersectsOrTouchesRange(e)){var t=this.cloneRange();if(l(e.startContainer,e.startOffset,this.startContainer,this.startOffset)==-1){t.setStart(e.startContainer,e.startOffset)}if(l(e.endContainer,e.endOffset,this.endContainer,this.endOffset)==1){t.setEnd(e.endContainer,e.endOffset)}return t}else{throw new x("Ranges do not intersect")}},containsNode:function(e,t){if(t){return this.intersectsNode(e,false)}else{return this.compareNode(e)==le}},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,h(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();t.setEnd(r,r.length);var i=this.containsRange(t);t.detach();return i}else{return this.containsNodeContents(e)}},getNodes:function(e,t){Z(this);return _(this,e,t)},getDocument:function(){return R(this)},collapseBefore:function(e){U(this);this.setEndBefore(e);this.collapse(false)},collapseAfter:function(e){U(this);this.setStartAfter(e);this.collapse(true)},getBookmark:function(t){var r=R(this);var i=e.createRange(r);t=t||n.getBody(r);i.selectNodeContents(t);var a=this.intersection(i);var o=0,s=0;if(a){i.setEnd(a.startContainer,a.startOffset);o=i.toString().length;s=o+a.toString().length;i.detach()}return{start:o,end:s,containerNode:t}},moveToBookmark:function(e){var t=e.containerNode;var n=0;this.setStart(t,0);this.collapse(true);var r=[t],i,a=false,o=false;var s,f,c;while(!o&&(i=r.pop())){if(i.nodeType==3){s=n+i.length;if(!a&&e.start>=n&&e.start<=s){this.setStart(i,e.start-n);a=true}if(a&&e.end>=n&&e.end<=s){this.setEnd(i,e.end-n);o=true}n=s}else{c=i.childNodes;f=c.length;while(f--){r.push(c[f])}}}},getName:function(){return"DomRange"},equals:function(e){return Re.rangesEqual(this,e)},isValid:function(){return X(this)},inspect:function(){return D(this)}});function ue(e){e.START_TO_START=re;e.START_TO_END=ie;e.END_TO_END=ae;e.END_TO_START=oe;e.NODE_BEFORE=se;e.NODE_AFTER=fe;e.NODE_BEFORE_AND_AFTER=ce;e.NODE_INSIDE=le}function de(e){ue(e);ue(e.prototype)}function he(e,t){return function(){Z(this);var n=this.startContainer,r=this.startOffset,i=this.commonAncestorContainer;var a=new A(this,true);var o,s;if(n!==i){o=d(n,i,true);s=N(o);n=s.node;r=s.offset}y(a,Y);a.reset();var f=e(a);a.detach();t(this,n,r,n,r);return f}}function ge(t,n,i){function a(e,t){return function(n){U(this);j(n,P);j(v(n),b);var r=(e?C:N)(n);(t?f:c)(this,r.node,r.offset)}}function f(e,t,r){var i=e.endContainer,a=e.endOffset;if(t!==e.startContainer||r!==e.startOffset){if(v(t)!=v(i)||l(t,r,i,a)==1){i=t;a=r}n(e,t,r,i,a)}}function c(e,t,r){var i=e.startContainer,a=e.startOffset;if(t!==e.endContainer||r!==e.endOffset){if(v(t)!=v(i)||l(t,r,i,a)==-1){i=t;a=r}n(e,i,a,t,r)}}var u=function(){};u.prototype=e.rangePrototype;t.prototype=new u;r.extend(t.prototype,{setStart:function(e,t){U(this);F(e,true);V(e,t);f(this,e,t)},setEnd:function(e,t){U(this);F(e,true);V(e,t);c(this,e,t)},setStartAndEnd:function(){U(this);var e=arguments;var t=e[0],r=e[1],i=t,a=r;switch(e.length){case 3:a=e[2];break;case 4:i=e[2];a=e[3];break}n(this,t,r,i,a)},setBoundary:function(e,t,n){this["set"+(n?"Start":"End")](e,t)},setStartBefore:a(true,true),setStartAfter:a(false,true),setEndBefore:a(true,false),setEndAfter:a(false,false),collapse:function(e){Z(this);if(e){n(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset)}else{n(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)}},selectNodeContents:function(e){U(this);F(e,true);n(this,e,0,e,h(e))},selectNode:function(e){U(this);F(e,false);j(e,P);var t=C(e),r=N(e);n(this,t.node,t.offset,r.node,r.offset)},extractContents:he(T,n),deleteContents:he(O,n),canSurroundContents:function(){Z(this);Y(this.startContainer);Y(this.endContainer);var e=new A(this,true);var t=e._first&&m(e._first,this)||e._last&&m(e._last,this);e.detach();return!t},detach:function(){i(this)},splitBoundaries:function(){te(this)},splitBoundariesPreservingPositions:function(e){te(this,e)},normalizeBoundaries:function(){Z(this);var e=this.startContainer,t=this.startOffset,r=this.endContainer,i=this.endOffset;var a=function(e){var t=e.nextSibling;if(t&&t.nodeType==e.nodeType){r=e;i=e.length;e.appendData(t.data);t.parentNode.removeChild(t)}};var f=function(n){var a=n.previousSibling;if(a&&a.nodeType==n.nodeType){e=n;var o=n.length;t=a.length;n.insertData(0,a.data);a.parentNode.removeChild(a);if(e==r){i+=t;r=e}else if(r==n.parentNode){var f=s(n);if(i==f){r=n;i=o}else if(i>f){i--}}}};var c=true;if(o(r)){if(r.length==i){a(r)}}else{if(i>0){var l=r.childNodes[i-1];if(l&&o(l)){a(l)}}c=!this.collapsed}if(c){if(o(e)){if(t==0){f(e)}}else{if(t<e.childNodes.length){var u=e.childNodes[t];if(u&&o(u)){f(u)}}}}else{e=r;t=i}n(this,e,t,r,i)},collapseToPoint:function(e,t){U(this);F(e,true);V(e,t);this.setStartAndEnd(e,t)}});de(t)}function ve(e){e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset;e.commonAncestorContainer=e.collapsed?e.startContainer:n.getCommonAncestor(e.startContainer,e.endContainer)}function pe(e,t,r,i,a){e.startContainer=t;e.startOffset=r;e.endContainer=i;e.endOffset=a;e.document=n.getDocument(t);ve(e)}function me(e){U(e);e.startContainer=e.startOffset=e.endContainer=e.endOffset=e.document=null;e.collapsed=e.commonAncestorContainer=null}function Re(e){this.startContainer=e;this.startOffset=0;this.endContainer=e;this.endOffset=0;this.document=e;ve(this)}ge(Re,pe,me);r.extend(Re,{rangeProperties:ne,RangeIterator:A,copyComparisonConstants:de,createPrototypeRange:ge,inspect:D,getRangeDocument:R,rangesEqual:function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}});e.DomRange=Re;e.RangeException=x});rangy.createCoreModule("WrappedRange",["DomRange"],function(e,t){var n,r;var i=e.dom;var a=e.util;var o=i.DomPosition;var s=e.DomRange;var f=i.getBody;var c=i.getContentDocument;var l=i.isCharacterDataNode;if(e.features.implementsDomRange){(function(){var r;var o=s.rangeProperties;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 u(e,t,n,r,i){var a=e.startContainer!==t||e.startOffset!=n;var o=e.endContainer!==r||e.endOffset!=i;var s=!e.equals(e.nativeRange);if(a||o||s){e.setEnd(r,i);e.setStart(t,n)}}function d(e){e.nativeRange.detach();e.detached=true;var t=o.length;while(t--){e[o[t]]=null}}var h;n=function(e){if(!e){throw t.createError("WrappedRange: Range must be specified")}this.nativeRange=e;l(this)};s.createPrototypeRange(n,u,d);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 g=document.createTextNode("test");f(document).appendChild(g);var v=document.createRange();v.setStart(g,0);v.setEnd(g,0);try{v.setStart(g,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(p){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))};v.selectNodeContents(g);v.setEnd(g,3);var m=document.createRange();m.selectNodeContents(g);m.setEnd(g,4);m.setStart(g,2);if(v.compareBoundaryPoints(v.START_TO_END,m)==-1&&v.compareBoundaryPoints(v.END_TO_START,m)==1){r.compareBoundaryPoints=function(e,t){t=t.nativeRange||t;if(e==t.START_TO_END){e=t.END_TO_START}else if(e==t.END_TO_START){e=t.START_TO_END}return this.nativeRange.compareBoundaryPoints(e,t)}}else{r.compareBoundaryPoints=function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)}}var R=document.createElement("div");R.innerHTML="123";var C=R.firstChild;var N=f(document);N.appendChild(R);v.setStart(C,1);v.setEnd(C,2);v.deleteContents();if(C.data=="13"){r.deleteContents=function(){this.nativeRange.deleteContents();l(this)};r.extractContents=function(){var e=this.nativeRange.extractContents();l(this);return e}}else{}N.removeChild(R);N=null;if(a.isHostMethod(v,"createContextualFragment")){r.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}}f(document).removeChild(g);v.detach();m.detach();r.getName=function(){return"WrappedRange"};e.WrappedRange=n;e.createNativeRange=function(e){e=c(e,t,"createNativeRange");return e.createRange()}})()}if(e.features.implementsTextRange){var u=function(e){var t=e.parentElement();var n=e.duplicate();n.collapse(true);var r=n.parentElement();n=e.duplicate();n.collapse(false);var a=n.parentElement();var o=r==a?r:i.getCommonAncestor(r,a);return o==t?o:i.getCommonAncestor(t,o)};var d=function(e){return e.compareEndPoints("StartToEnd",e)==0};var h=function(e,t,n,r,a){var s=e.duplicate();s.collapse(n);var f=s.parentElement();if(!i.isOrIsAncestorOf(t,f)){f=t}if(!f.canHaveHTML){var c=new o(f.parentNode,i.getNodeIndex(f));return{boundaryPosition:c,nodeInfo:{nodeIndex:c.offset,containerElement:c.node}}}var u=i.getDocument(f).createElement("span");if(u.parentNode){u.parentNode.removeChild(u)}var d,h=n?"StartToStart":"StartToEnd";var g,v,p,m;var R=a&&a.containerElement==f?a.nodeIndex:0;var C=f.childNodes.length;var N=C;var E=N;while(true){if(E==C){f.appendChild(u)}else{f.insertBefore(u,f.childNodes[E])}s.moveToElementText(u);d=s.compareEndPoints(h,e); if(d==0||R==N){break}else if(d==-1){if(N==R+1){break}else{R=E}}else{N=N==R+1?R:E}E=Math.floor((R+N)/2);f.removeChild(u)}m=u.nextSibling;if(d==-1&&m&&l(m)){s.setEndPoint(n?"EndToStart":"EndToEnd",e);var w;if(/[\r\n]/.test(m.data)){var S=s.duplicate();var y=S.text.replace(/\r\n/g,"\r").length;w=S.moveStart("character",y);while((d=S.compareEndPoints("StartToEnd",S))==-1){w++;S.moveStart("character",1)}}else{w=s.text.length}p=new o(m,w)}else{g=(r||!n)&&u.previousSibling;v=(r||n)&&u.nextSibling;if(v&&l(v)){p=new o(v,0)}else if(g&&l(g)){p=new o(g,g.data.length)}else{p=new o(f,i.getNodeIndex(u))}}u.parentNode.removeChild(u);return{boundaryPosition:p,nodeInfo:{nodeIndex:E,containerElement:f}}};var g=function(e,t){var n,r,a=e.offset;var o=i.getDocument(e.node);var s,c,u=f(o).createTextRange();var d=l(e.node);if(d){n=e.node;r=n.parentNode}else{c=e.node.childNodes;n=a<c.length?c[a]:null;r=e.node}s=o.createElement("span");s.innerHTML="&#feff;";if(n){r.insertBefore(s,n)}else{r.appendChild(s)}u.moveToElementText(s);u.collapse(!t);r.removeChild(s);if(d){u[t?"moveStart":"moveEnd"]("character",a)}return u};r=function(e){this.textRange=e;this.refresh()};r.prototype=new s(document);r.prototype.refresh=function(){var e,t,n;var r=u(this.textRange);if(d(this.textRange)){t=e=h(this.textRange,r,true,true).boundaryPosition}else{n=h(this.textRange,r,true,false);e=n.boundaryPosition;t=h(this.textRange,r,false,false,n.nodeInfo).boundaryPosition}this.setStart(e.node,e.offset);this.setEnd(t.node,t.offset)};r.prototype.getName=function(){return"WrappedTextRange"};s.copyComparisonConstants(r);r.rangeToTextRange=function(e){if(e.collapsed){return g(new o(e.startContainer,e.startOffset),true)}else{var t=g(new o(e.startContainer,e.startOffset),true);var n=g(new o(e.endContainer,e.endOffset),false);var r=f(s.getRangeDocument(e)).createTextRange();r.setEndPoint("StartToStart",t);r.setEndPoint("EndToEnd",n);return r}};e.WrappedTextRange=r;if(!e.features.implementsDomRange||e.config.preferTextRange){var v=function(){return this}();if(typeof v.Range=="undefined"){v.Range=r}e.createNativeRange=function(e){e=c(e,t,"createNativeRange");return f(e).createTextRange()};e.WrappedRange=r}}e.createRange=function(n){n=c(n,t,"createRange");return new e.WrappedRange(e.createNativeRange(n))};e.createRangyRange=function(e){e=c(e,t,"createRangyRange");return new s(e)};e.createIframeRange=function(n){t.deprecationNotice("createIframeRange()","createRange(iframeEl)");return e.createRange(n)};e.createIframeRangyRange=function(n){t.deprecationNotice("createIframeRangyRange()","createRangyRange(iframeEl)");return e.createRangyRange(n)};e.addCreateMissingNativeApiListener(function(t){var n=t.document;if(typeof n.createRange=="undefined"){n.createRange=function(){return e.createRange(n)}}n=t=null})});rangy.createCoreModule("WrappedSelection",["DomRange","WrappedRange"],function(e,t){e.config.checkSelectionRanges=true;var n="boolean";var r="number";var i=e.dom;var a=e.util;var o=a.isHostMethod;var s=e.DomRange;var f=e.WrappedRange;var c=e.DOMException;var l=i.DomPosition;var u;var d;var h=e.features;var g="Control";var v=i.getDocument;var p=i.getBody;var m=s.rangesEqual;function R(e){return typeof e=="string"?/^backward(s)?$/i.test(e):!!e}function C(e,n){if(!e){return window}else if(i.isWindow(e)){return e}else if(e instanceof G){return e.win}else{var r=i.getContentDocument(e,t,n);return i.getWindow(r)}}function N(e){return C(e,"getWinSelection").getSelection()}function E(e){return C(e,"getDocSelection").document.selection}function w(e){var t=false;if(e.anchorNode){t=i.comparePoints(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)==1}return t}var S=o(window,"getSelection"),y=a.isHostObject(document,"selection");h.implementsWinGetSelection=S;h.implementsDocSelection=y;var O=y&&(!S||e.config.preferTextRange);if(O){u=E;e.isSelectionValid=function(e){var t=C(e,"isSelectionValid").document,n=t.selection;return n.type!="None"||v(n.createRange().parentElement())==t}}else if(S){u=N;e.isSelectionValid=function(){return true}}else{t.fail("Neither document.selection or window.getSelection() detected.")}e.getNativeSelection=u;var T=u();var _=e.createNativeRange(document);var D=p(document);var A=a.areHostProperties(T,["anchorNode","focusNode","anchorOffset","focusOffset"]);h.selectionHasAnchorAndFocus=A;var x=o(T,"extend");h.selectionHasExtend=x;var P=typeof T.rangeCount==r;h.selectionHasRangeCount=P;var b=false;var I=true;var B=x?function(t,n){var r=s.getRangeDocument(n);var i=e.createRange(r);i.collapseToPoint(n.endContainer,n.endOffset);t.addRange(F(i));t.extend(n.startContainer,n.startOffset)}:null;if(a.areHostMethods(T,["addRange","getRangeAt","removeAllRanges"])&&typeof T.rangeCount==r&&h.implementsDomRange){(function(){var t=window.getSelection();if(t){var n=t.rangeCount;var r=n>1;var i=[];var a=w(t);for(var o=0;o<n;++o){i[o]=t.getRangeAt(o)}var s=p(document);var f=s.appendChild(document.createElement("div"));f.contentEditable="false";var c=f.appendChild(document.createTextNode("\u00a0\u00a0\u00a0"));if(navigator.userAgent.toLowerCase().indexOf("chrome")!=-1){I=false;b=false}else{var l=document.createRange();l.setStart(c,1);l.collapse(true);t.addRange(l);I=t.rangeCount==1;t.removeAllRanges();var u=l.cloneRange();l.setStart(c,0);u.setEnd(c,3);u.setStart(c,2);t.addRange(l);t.addRange(u);b=t.rangeCount==2}s.removeChild(f);t.removeAllRanges();for(o=0;o<n;++o){if(o==0&&a){if(B){B(t,i[o])}else{e.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because browser does not support Selection.extend");t.addRange(i[o])}}else{t.addRange(i[o])}}}})()}h.selectionSupportsMultipleRanges=b;h.collapsedNonEditableSelectionsSupported=I;var H=false,M;if(D&&o(D,"createControlRange")){M=D.createControlRange();if(a.areHostProperties(M,["item","add"])){H=true}}h.implementsControlRange=H;if(A){d=function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}}else{d=function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:false}}function L(e,t,n){var r=n?"end":"start",i=n?"start":"end";e.anchorNode=t[r+"Container"];e.anchorOffset=t[r+"Offset"];e.focusNode=t[i+"Container"];e.focusOffset=t[i+"Offset"]}function W(e){var t=e.nativeSelection;e.anchorNode=t.anchorNode;e.anchorOffset=t.anchorOffset;e.focusNode=t.focusNode;e.focusOffset=t.focusOffset}function k(e){e.anchorNode=e.focusNode=null;e.anchorOffset=e.focusOffset=0;e.rangeCount=0;e.isCollapsed=true;e._ranges.length=0}function F(t){var n;if(t instanceof s){n=e.createNativeRange(t.getDocument());n.setEnd(t.endContainer,t.endOffset);n.setStart(t.startContainer,t.startOffset)}else if(t instanceof f){n=t.nativeRange}else if(h.implementsDomRange&&t instanceof i.getWindow(t.startContainer).Range){n=t}return n}function U(e){if(!e.length||e[0].nodeType!=1){return false}for(var t=1,n=e.length;t<n;++t){if(!i.isAncestorOf(e[0],e[t])){return false}}return true}function j(e){var n=e.getNodes();if(!U(n)){throw t.createError("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element")}return n[0]}function V(e){return!!e&&typeof e.text!="undefined"}function z(e,t){var n=new f(t);e._ranges=[n];L(e,n,false);e.rangeCount=1;e.isCollapsed=n.collapsed}function Y(t){t._ranges.length=0;if(t.docSelection.type=="None"){k(t)}else{var n=t.docSelection.createRange();if(V(n)){z(t,n)}else{t.rangeCount=n.length;var r,i=v(n.item(0));for(var a=0;a<t.rangeCount;++a){r=e.createRange(i);r.selectNode(n.item(a));t._ranges.push(r)}t.isCollapsed=t.rangeCount==1&&t._ranges[0].collapsed;L(t,t._ranges[t.rangeCount-1],false)}}}function q(e,n){var r=e.docSelection.createRange();var i=j(n);var a=v(r.item(0));var o=p(a).createControlRange();for(var s=0,f=r.length;s<f;++s){o.add(r.item(s))}try{o.add(i)}catch(c){throw t.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}o.select();Y(e)}var Q;if(o(T,"getRangeAt")){Q=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}}else if(A){Q=function(t){var n=v(t.anchorNode);var r=e.createRange(n);r.setStartAndEnd(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset);if(r.collapsed!==this.isCollapsed){r.setStartAndEnd(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)}return r}}function G(e,t,n){this.nativeSelection=e;this.docSelection=t;this._ranges=[];this.win=n;this.refresh()}G.prototype=e.selectionPrototype;function X(e){e.win=e.anchorNode=e.focusNode=e._ranges=null;e.rangeCount=e.anchorOffset=e.focusOffset=0;e.detached=true}var Z=[];function $(e,t){var n=Z.length,r,i;while(n--){r=Z[n];i=r.selection;if(t=="deleteAll"){X(i)}else if(r.win==e){if(t=="delete"){Z.splice(n,1);return true}else{return i}}}if(t=="deleteAll"){Z.length=0}return null}var J=function(e){if(e&&e instanceof G){e.refresh();return e}e=C(e,"getNativeSelection");var t=$(e);var n=u(e),r=y?E(e):null;if(t){t.nativeSelection=n;t.docSelection=r;t.refresh()}else{t=new G(n,r,e);Z.push({win:e,selection:t})}return t};e.getSelection=J;e.getIframeSelection=function(n){t.deprecationNotice("getIframeSelection()","getSelection(iframeEl)");return e.getSelection(i.getIframeWindow(n))};var K=G.prototype;function ee(e,n){var r=v(n[0].startContainer);var i=p(r).createControlRange();for(var a=0,o,s=n.length;a<s;++a){o=j(n[a]);try{i.add(o)}catch(f){throw t.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}i.select();Y(e)}if(!O&&A&&a.areHostMethods(T,["removeAllRanges","addRange"])){K.removeAllRanges=function(){this.nativeSelection.removeAllRanges();k(this)};var te=function(e,t){B(e.nativeSelection,t);e.refresh()};if(P){K.addRange=function(t,n){if(H&&y&&this.docSelection.type==g){q(this,t)}else{if(R(n)&&x){te(this,t)}else{var r;if(b){r=this.rangeCount}else{this.removeAllRanges();r=0}this.nativeSelection.addRange(F(t).cloneRange());this.rangeCount=this.nativeSelection.rangeCount;if(this.rangeCount==r+1){if(e.config.checkSelectionRanges){var i=Q(this.nativeSelection,this.rangeCount-1);if(i&&!m(i,t)){t=new f(i)}}this._ranges[this.rangeCount-1]=t;L(this,t,ie(this.nativeSelection));this.isCollapsed=d(this)}else{this.refresh()}}}}}else{K.addRange=function(e,t){if(R(t)&&x){te(this,e)}else{this.nativeSelection.addRange(F(e));this.refresh()}}}K.setRanges=function(e){if(H&&e.length>1){ee(this,e)}else{this.removeAllRanges();for(var t=0,n=e.length;t<n;++t){this.addRange(e[t])}}}}else if(o(T,"empty")&&o(_,"select")&&H&&O){K.removeAllRanges=function(){try{this.docSelection.empty();if(this.docSelection.type!="None"){var e;if(this.anchorNode){e=v(this.anchorNode)}else if(this.docSelection.type==g){var t=this.docSelection.createRange();if(t.length){e=v(t.item(0))}}if(e){var n=p(e).createTextRange();n.select();this.docSelection.empty()}}}catch(r){}k(this)};K.addRange=function(t){if(this.docSelection.type==g){q(this,t)}else{e.WrappedTextRange.rangeToTextRange(t).select();this._ranges[0]=t;this.rangeCount=1;this.isCollapsed=this._ranges[0].collapsed;L(this,t,false)}};K.setRanges=function(e){this.removeAllRanges();var t=e.length;if(t>1){ee(this,e)}else if(t){this.addRange(e[0])}}}else{t.fail("No means of selecting a Range or TextRange was found");return false}K.getRangeAt=function(e){if(e<0||e>=this.rangeCount){throw new c("INDEX_SIZE_ERR")}else{return this._ranges[e].cloneRange()}};var ne;if(O){ne=function(t){var n;if(e.isSelectionValid(t.win)){n=t.docSelection.createRange()}else{n=p(t.win.document).createTextRange();n.collapse(true)}if(t.docSelection.type==g){Y(t)}else if(V(n)){z(t,n)}else{k(t)}}}else if(o(T,"getRangeAt")&&typeof T.rangeCount==r){ne=function(t){if(H&&y&&t.docSelection.type==g){Y(t)}else if(t&&t.nativeSelection){t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount;if(t.rangeCount){for(var n=0,r=t.rangeCount;n<r;++n){t._ranges[n]=new e.WrappedRange(t.nativeSelection.getRangeAt(n))}L(t,t._ranges[t.rangeCount-1],ie(t.nativeSelection));t.isCollapsed=d(t)}else{k(t)}}}}else if(A&&typeof T.isCollapsed==n&&typeof _.collapsed==n&&h.implementsDomRange){ne=function(e){var t,n=e.nativeSelection;if(n.anchorNode){t=Q(n,0);e._ranges=[t];e.rangeCount=1;W(e);e.isCollapsed=d(e)}else{k(e)}}}else{t.fail("No means of obtaining a Range or TextRange from the user's selection was found");return false}K.refresh=function(e){var t=e?this._ranges.slice(0):null;var n=this.anchorNode,r=this.anchorOffset;ne(this);if(e){var i=t.length;if(i!=this._ranges.length){return true}if(this.anchorNode!=n||this.anchorOffset!=r){return true}while(i--){if(!m(t[i],this._ranges[i])){return true}}return false}};var re=function(e,t){var n=e.getAllRanges();e.removeAllRanges();for(var r=0,i=n.length;r<i;++r){if(!m(t,n[r])){e.addRange(n[r])}}if(!e.rangeCount){k(e)}};if(H){K.removeRange=function(e){if(this.docSelection.type==g){var t=this.docSelection.createRange();var n=j(e);var r=v(t.item(0));var i=p(r).createControlRange();var a,o=false;for(var s=0,f=t.length;s<f;++s){a=t.item(s);if(a!==n||o){i.add(t.item(s))}else{o=true}}i.select();Y(this)}else{re(this,e)}}}else{K.removeRange=function(e){re(this,e)}}var ie;if(!O&&A&&h.implementsDomRange){ie=w;K.isBackward=function(){return ie(this)}}else{ie=K.isBackward=function(){return false}}K.isBackwards=K.isBackward;K.toString=function(){var e=[];for(var t=0,n=this.rangeCount;t<n;++t){e[t]=""+this._ranges[t]}return e.join("")};function ae(e,t){if(e.win.document!=v(t)){throw new c("WRONG_DOCUMENT_ERR")}}K.collapse=function(t,n){ae(this,t);var r=e.createRange(t);r.collapseToPoint(t,n);this.setSingleRange(r);this.isCollapsed=true};K.collapseToStart=function(){if(this.rangeCount){var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)}else{throw new c("INVALID_STATE_ERR")}};K.collapseToEnd=function(){if(this.rangeCount){var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)}else{throw new c("INVALID_STATE_ERR")}};K.selectAllChildren=function(t){ae(this,t);var n=e.createRange(t);n.selectNodeContents(t);this.setSingleRange(n)};K.deleteFromDocument=function(){if(H&&y&&this.docSelection.type==g){var e=this.docSelection.createRange();var t;while(e.length){t=e.item(0);e.remove(t);t.parentNode.removeChild(t)}this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();if(n.length){this.removeAllRanges();for(var r=0,i=n.length;r<i;++r){n[r].deleteContents()}this.addRange(n[i-1])}}};K.eachRange=function(e,t){for(var n=0,r=this._ranges.length;n<r;++n){if(e(this.getRangeAt(n))){return t}}};K.getAllRanges=function(){var e=[];this.eachRange(function(t){e.push(t)});return e};K.setSingleRange=function(e,t){this.removeAllRanges();this.addRange(e,t)};K.callMethodOnEachRange=function(e,t){var n=[];this.eachRange(function(r){n.push(r[e].apply(r,t))});return n};function oe(t){return function(n,r){var i;if(this.rangeCount){i=this.getRangeAt(0);i["set"+(t?"Start":"End")](n,r)}else{i=e.createRange(this.win.document);i.setStartAndEnd(n,r)}this.setSingleRange(i,this.isBackward())}}K.setStart=oe(true);K.setEnd=oe(false);e.rangePrototype.select=function(e){J(this.getDocument()).setSingleRange(this,e)};K.changeEachRange=function(e){var t=[];var n=this.isBackward();this.eachRange(function(n){e(n);t.push(n)});this.removeAllRanges();if(n&&t.length==1){this.addRange(t[0],"backward")}else{this.setRanges(t)}};K.containsNode=function(e,t){return this.eachRange(function(n){return n.containsNode(e,t)},true)};K.getBookmark=function(e){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[e])}};K.moveToBookmark=function(t){var n=[];for(var r=0,i,a;i=t.rangeBookmarks[r++];){a=e.createRange(this.win);a.moveToBookmark(i);n.push(a)}if(t.backward){this.setSingleRange(n[0],"backward")}else{this.setRanges(n)}};K.toHtml=function(){return this.callMethodOnEachRange("toHtml").join("")};function se(e){var t=[];var n=new l(e.anchorNode,e.anchorOffset);var r=new l(e.focusNode,e.focusOffset);var i=typeof e.getName=="function"?e.getName():"Selection";if(typeof e.rangeCount!="undefined"){for(var a=0,o=e.rangeCount;a<o;++a){t[a]=s.inspect(e.getRangeAt(a))}}return"["+i+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+r.inspect()+"]"}K.getName=function(){return"WrappedSelection"};K.inspect=function(){return se(this)};K.detach=function(){$(this.win,"delete");X(this)};G.detachAll=function(){$(null,"deleteAll")};G.inspect=se;G.isDirectionBackward=R;e.Selection=G;e.selectionPrototype=K;e.addCreateMissingNativeApiListener(function(e){if(typeof e.getSelection=="undefined"){e.getSelection=function(){return J(e)}}e=null})}); //# sourceMappingURL=range.map.js