/
var
/
www
/
html
/
cetesb
/
lib
/
editor
/
atto
/
yui
/
build
/
moodle-editor_atto-rangy
/
Upload File
HOME
window.rangy=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 m(e){window.alert("Rangy not supported in your browser. Reason: "+e),v.initialized=!0,v.supported=!1}function g(e){var t="Rangy warning: "+e;v.config.alertOnWarn?window.alert(t):typeof window.console!=n&&typeof window.console.log!=n&&window.console.log(t)}function w(){if(v.initialized)return;var e,t=!1,n=!1;u(document,"createRange")&&(e=document.createRange(),c(e,i)&&p(e,r)&&(t=!0),e.detach());var s=a(document,"body")?document.body:document.getElementsByTagName("body")[0];s&&u(s,"createTextRange")&&(e=s.createTextRange(),d(e)&&(n=!0)),!t&&!n&&m("Neither Range nor TextRange are implemented"),v.initialized=!0,v.features={implementsDomRange:t,implementsTextRange:n};var o=b.concat(y);for(var f=0,l=o.length;f<l;++f)try{o[f](v)}catch(h){a(window,"console")&&u(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",h)}}function S(e){e=e||window,w();for(var t=0,n=E.length;t<n;++t)E[t](e)}function x(e){this.name=e,this.initialized=!1,this.supported=!1}var e="object",t="function",n="undefined",r=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],i=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],s=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],o=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"],c=l(u),h=l(a),p=l(f),v={version:"1.2.3",initialized:!1,supported:!0,util:{isHostMethod:u,isHostObject:a,isHostProperty:f,areHostMethods:c,areHostObjects:h,areHostProperties:p,isTextRange:d},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};v.fail=m,v.warn=g,{}.hasOwnProperty?v.util.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}:m("hasOwnProperty not supported");var y=[],b=[];v.init=w,v.addInitListener=function(e){v.initialized?e(v):y.push(e)};var E=[];v.addCreateMissingNativeApiListener=function(e){E.push(e)},v.createMissingNativeApi=S,x.prototype.fail=function(e){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+e)},x.prototype.warn=function(e){v.warn("Module "+this.name+": "+e)},x.prototype.createError=function(e){return new Error("Error in Rangy "+this.name+" module: "+e)},v.createModule=function(e,t){var n=new x(e);v.modules[e]=n,b.push(function(e){t(e,n),n.initialized=!0,n.supported=!0})},v.requireModules=function(e){for(var t=0,n=e.length,r,i;t<n;++t){i=e[t],r=v.modules[i];if(!r||!(r instanceof x))throw new Error("Module '"+i+"' not found");if(!r.supported)throw new Error("Module '"+i+"' not supported")}};var T=!1,N=function(e){T||(T=!0,v.initialized||w())};if(typeof window==n){m("No window found");return}if(typeof document==n){m("No document found");return}return u(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",N,!1),u(window,"addEventListener")?window.addEventListener("load",N,!1):u(window,"attachEvent")?window.attachEvent("onload",N):m("Window does not have required addEventListener or attachEvent method"),v}(),rangy.createModule("DomUtil",function(e,t){function u(e){var t;return typeof e.namespaceURI==n||(t=e.namespaceURI)===null||t=="http://www.w3.org/1999/xhtml"}function a(e){var t=e.parentNode;return t.nodeType==1?t:null}function f(e){var t=0;while(e=e.previousSibling)t++;return t}function l(e){var t;return d(e)?e.length:(t=e.childNodes)?t.length:0}function c(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 h(e,t,n){var r=n?t:t.parentNode;while(r){if(r===e)return!0;r=r.parentNode}return!1}function p(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 d(e){var t=e.nodeType;return t==3||t==4||t==8}function v(e,t){var n=t.nextSibling,r=t.parentNode;return n?r.insertBefore(e,n):r.appendChild(e),e}function m(e,t){var n=e.cloneNode(!1);return n.deleteData(0,t),e.deleteData(t,e.length-t),v(n,e),n}function g(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 g(e.parentNode);throw new Error("getDocument: no document found for node")}function y(e){var t=g(e);if(typeof t.defaultView!=n)return t.defaultView;if(typeof t.parentWindow!=n)return t.parentWindow;throw new Error("Cannot get a window object for node")}function b(e){if(typeof e.contentDocument!=n)return e.contentDocument;if(typeof e.contentWindow!=n)return e.contentWindow.document;throw new Error("getIframeWindow: No Document object found for iframe element")}function w(e){if(typeof e.contentWindow!=n)return e.contentWindow;if(typeof e.contentDocument!=n)return e.contentDocument.defaultView;throw new Error("getIframeWindow: No Window object found for iframe element")}function E(e){return r.isHostObject(e,"body")?e.body:e.getElementsByTagName("body")[0]}function S(e){var t;while(t=e.parentNode)e=t;return e}function x(e,t,n,r){var i,s,o,u,a;if(e==n)return t===r?0:t<r?-1:1;if(i=p(n,e,!0))return t<=f(i)?-1:1;if(i=p(e,n,!0))return f(i)<r?-1:1;s=c(e,n),o=e===s?s:p(e,s,!0),u=n===s?s:p(n,s,!0);if(o===u)throw new Error("comparePoints got to case 4 and childA and childB are the same!");a=s.firstChild;while(a){if(a===o)return-1;if(a===u)return 1;a=a.nextSibling}throw new Error("Should not be here!")}function T(e){var t=g (e).createDocumentFragment(),n;while(n=e.firstChild)t.appendChild(n);return t}function N(e){if(!e)return"[No node]";if(d(e))return'"'+e.data+'"';if(e.nodeType==1){var t=e.id?' id="'+e.id+'"':"";return"<"+e.nodeName+t+">["+e.childNodes.length+"]"}return e.nodeName}function C(e){this.root=e,this._next=e}function k(e){return new C(e)}function L(e,t){this.node=e,this.offset=t}function A(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var n="undefined",r=e.util;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 i=document.createElement("div");r.areHostMethods(i,["insertBefore","appendChild","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),r.isHostProperty(i,"innerHTML")||t.fail("Element is missing innerHTML property");var s=document.createTextNode("test");r.areHostMethods(s,["splitText","deleteData","insertData","appendData","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"])||!r.areHostProperties(s,["data"]))||t.fail("Incomplete Text Node implementation");var o=function(e,t){var n=e.length;while(n--)if(e[n]===t)return!0;return!1};C.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}},L.prototype={equals:function(e){return this.node===e.node&this.offset==e.offset},inspect:function(){return"[DomPosition("+N(this.node)+":"+this.offset+")]"}},A.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},A.prototype.toString=function(){return this.message},e.dom={arrayContains:o,isHtmlNamespace:u,parentElement:a,getNodeIndex:f,getNodeLength:l,getCommonAncestor:c,isAncestorOf:h,getClosestAncestorIn:p,isCharacterDataNode:d,insertAfter:v,splitDataNode:m,getDocument:g,getWindow:y,getIframeWindow:w,getIframeDocument:b,getBody:E,getRootContainer:S,comparePoints:x,inspectNode:N,fragmentFromNodeChildren:T,createIterator:k,DomPosition:L},e.DOMException=A}),rangy.createModule("DomRange",function(e,t){function s(e,t){return e.nodeType!=3&&(n.isAncestorOf(e,t.startContainer,!0)||n.isAncestorOf(e,t.endContainer,!0))}function o(e){return n.getDocument(e.startContainer)}function u(e,t,n){var r=e._listeners[t];if(r)for(var i=0,s=r.length;i<s;++i)r[i].call(e,{target:e,args:n})}function a(e){return new r(e.parentNode,n.getNodeIndex(e))}function f(e){return new r(e.parentNode,n.getNodeIndex(e)+1)}function l(e,t,r){var i=e.nodeType==11?e.firstChild:e;return n.isCharacterDataNode(t)?r==t.length?n.insertAfter(e,t):t.parentNode.insertBefore(e,r==0?t:n.splitDataNode(t,r)):r>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[r]),i}function c(e){var t;for(var n,r=o(e.range).createDocumentFragment(),s;n=e.next();){t=e.isPartiallySelectedSubtree(),n=n.cloneNode(!t),t&&(s=e.getSubtreeIterator(),n.appendChild(c(s)),s.detach(!0));if(n.nodeType==10)throw new i("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}function h(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(),h(u,t,r),u.detach(!0);if(r.stop)return}else{i=n.createIterator(o);while(s=i.next())if(t(s)===!1){r.stop=!0;return}}}function p(e){var t;while(e.next())e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),p(t),t.detach(!0)):e.remove()}function d(e){for(var t,n=o(e.range).createDocumentFragment(),r;t=e.next();){e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),r=e.getSubtreeIterator(),t.appendChild(d(r)),r.detach(!0)):e.remove();if(t.nodeType==10)throw new i("HIERARCHY_REQUEST_ERR");n.appendChild(t)}return n}function v(e,t,n){var r=!!t&&!!t.length,i,s=!!n;r&&(i=new RegExp("^("+t.join("|")+")$"));var o=[];return h(new g(e,!1),function(e){(!r||i.test(e.nodeType))&&(!s||n(e))&&o.push(e)}),o}function m(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 g(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 r=e.commonAncestorContainer;this.sc===this.ec&&n.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===r&&!n.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:n.getClosestAncestorIn(this.sc,r,!0),this._last=this.ec===r&&!n.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:n.getClosestAncestorIn(this.ec,r,!0))}}function y(e){this.code=this[e],this.codeName=e,this.message="RangeException: "+this.codeName}function b(e,t,n){this.nodes=v(e,t,n),this._next=this.nodes[0],this._position=0}function N(e){return function(t,r){var i,s=r?t:t.parentNode;while(s){i=s.nodeType;if(n.arrayContains(e,i))return s;s=s.parentNode}return null}}function O(e,t){if(A(e,t))throw new y("INVALID_NODE_TYPE_ERR")}function M(e){if(!e.startContainer)throw new i("INVALID_STATE_ERR")}function _(e,t){if(!n.arrayContains(t,e.nodeType))throw new y("INVALID_NODE_TYPE_ERR")}function D(e,t){if(t<0||t>(n.isCharacterDataNode(e)?e.length:e.childNodes.length))throw new i("INDEX_SIZE_ERR")}function P(e,t){if(k(e,!0)!==k(t,!0))throw new i("WRONG_DOCUMENT_ERR")}function H(e){if(L(e,!0))throw new i("NO_MODIFICATION_ALLOWED_ERR")}function B(e,t){if(!e)throw new i(t)}function j(e){return!n.arrayContains(E,e.nodeType)&&!k(e,!0)} function F(e,t){return t<=(n.isCharacterDataNode(e)?e.length:e.childNodes.length)}function I(e){return!!e.startContainer&&!!e.endContainer&&!j(e.startContainer)&&!j(e.endContainer)&&F(e.startContainer,e.startOffset)&&F(e.endContainer,e.endOffset)}function q(e){M(e);if(!I(e))throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}function et(){}function tt(e){e.START_TO_START=V,e.START_TO_END=$,e.END_TO_END=J,e.END_TO_START=K,e.NODE_BEFORE=Q,e.NODE_AFTER=G,e.NODE_BEFORE_AND_AFTER=Y,e.NODE_INSIDE=Z}function nt(e){tt(e),tt(e.prototype)}function rt(e,t){return function(){q(this);var r=this.startContainer,i=this.startOffset,s=this.commonAncestorContainer,o=new g(this,!0),u,a;r!==s&&(u=n.getClosestAncestorIn(r,s,!0),a=f(u),r=a.node,i=a.offset),h(o,H),o.reset();var l=e(o);return o.detach(),t(this,r,i,r,i),l}}function it(t,r,i){function o(e,t){return function(n){M(this),_(n,w),_(C(n),E);var r=(e?a:f)(n);(t?u:l)(this,r.node,r.offset)}}function u(e,t,i){var s=e.endContainer,o=e.endOffset;if(t!==e.startContainer||i!==e.startOffset){if(C(t)!=C(s)||n.comparePoints(t,i,s,o)==1)s=t,o=i;r(e,t,i,s,o)}}function l(e,t,i){var s=e.startContainer,o=e.startOffset;if(t!==e.endContainer||i!==e.endOffset){if(C(t)!=C(s)||n.comparePoints(t,i,s,o)==-1)s=t,o=i;r(e,s,o,t,i)}}function c(e,t,n){(t!==e.startContainer||n!==e.startOffset||t!==e.endContainer||n!==e.endOffset)&&r(e,t,n,t,n)}t.prototype=new et,e.util.extend(t.prototype,{setStart:function(e,t){M(this),O(e,!0),D(e,t),u(this,e,t)},setEnd:function(e,t){M(this),O(e,!0),D(e,t),l(this,e,t)},setStartBefore:o(!0,!0),setStartAfter:o(!1,!0),setEndBefore:o(!0,!1),setEndAfter:o(!1,!1),collapse:function(e){q(this),e?r(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):r(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){M(this),O(e,!0),r(this,e,0,e,n.getNodeLength(e))},selectNode:function(e){M(this),O(e,!1),_(e,w);var t=a(e),n=f(e);r(this,t.node,t.offset,n.node,n.offset)},extractContents:rt(d,r),deleteContents:rt(p,r),canSurroundContents:function(){q(this),H(this.startContainer),H(this.endContainer);var e=new g(this,!0),t=e._first&&s(e._first,this)||e._last&&s(e._last,this);return e.detach(),!t},detach:function(){i(this)},splitBoundaries:function(){q(this);var e=this.startContainer,t=this.startOffset,i=this.endContainer,s=this.endOffset,o=e===i;n.isCharacterDataNode(i)&&s>0&&s<i.length&&n.splitDataNode(i,s),n.isCharacterDataNode(e)&&t>0&&t<e.length&&(e=n.splitDataNode(e,t),o?(s-=t,i=e):i==e.parentNode&&s>=n.getNodeIndex(e)&&s++,t=0),r(this,e,t,i,s)},normalizeBoundaries:function(){q(this);var e=this.startContainer,t=this.startOffset,i=this.endContainer,s=this.endOffset,o=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(i=e,s=e.length,e.appendData(t.data),t.parentNode.removeChild(t))},u=function(r){var o=r.previousSibling;if(o&&o.nodeType==r.nodeType){e=r;var u=r.length;t=o.length,r.insertData(0,o.data),o.parentNode.removeChild(o);if(e==i)s+=t,i=e;else if(i==r.parentNode){var a=n.getNodeIndex(r);s==a?(i=r,s=u):s>a&&s--}}},a=!0;if(n.isCharacterDataNode(i))i.length==s&&o(i);else{if(s>0){var f=i.childNodes[s-1];f&&n.isCharacterDataNode(f)&&o(f)}a=!this.collapsed}if(a){if(n.isCharacterDataNode(e))t==0&&u(e);else if(t<e.childNodes.length){var l=e.childNodes[t];l&&n.isCharacterDataNode(l)&&u(l)}}else e=i,t=s;r(this,e,t,i,s)},collapseToPoint:function(e,t){M(this),O(e,!0),D(e,t),c(this,e,t)}}),nt(t)}function st(e){e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset,e.commonAncestorContainer=e.collapsed?e.startContainer:n.getCommonAncestor(e.startContainer,e.endContainer)}function ot(e,t,n,r,i){var s=e.startContainer!==t||e.startOffset!==n,o=e.endContainer!==r||e.endOffset!==i;e.startContainer=t,e.startOffset=n,e.endContainer=r,e.endOffset=i,st(e),u(e,"boundarychange",{startMoved:s,endMoved:o})}function ut(e){M(e),e.startContainer=e.startOffset=e.endContainer=e.endOffset=null,e.collapsed=e.commonAncestorContainer=null,u(e,"detach",null),e._listeners=null}function at(e){this.startContainer=e,this.startOffset=0,this.endContainer=e,this.endOffset=0,this._listeners={boundarychange:[],detach:[]},st(this)}e.requireModules(["DomUtil"]);var n=e.dom,r=n.DomPosition,i=e.DOMException;g.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next;return e&&(this._next=e!==this._last?e.nextSibling:null,n.isCharacterDataNode(e)&&this.clonePartiallySelectedTextNodes&&(e===this.ec&&(e=e.cloneNode(!0)).deleteData(this.eo,e.length-this.eo),this._current===this.sc&&(e=e.cloneNode(!0)).deleteData(0,this.so))),e},remove:function(){var e=this._current,t,r;!n.isCharacterDataNode(e)||e!==this.sc&&e!==this.ec?e.parentNode&&e.parentNode.removeChild(e):(t=e===this.sc?this.so:0,r=e===this.ec?this.eo:e.length,t!=r&&e.deleteData(t,r-t))},isPartiallySelectedSubtree:function(){var e=this._current;return s(e,this.range)},getSubtreeIterator:function(){var e;if(this.isSingleCharacterDataNode)e=this.range.cloneRange(),e.collapse();else{e=new at(o(this.range));var t=this._current,r=t,i=0,s=t,u=n.getNodeLength(t);n.isAncestorOf(t,this.sc,!0)&&(r=this.sc,i=this.so),n.isAncestorOf(t,this.ec,!0)&&(s=this.ec,u=this.eo),ot(e,r,i,s,u)}return new g(e,this.clonePartiallySelectedTextNodes)},detach:function(e){e&&this.range.detach(),this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}},y.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2},y.prototype.toString=function(){return this.message},b.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){return this._current=this._next,this._next=this.nodes[++this._position],this._current},detach:function(){this._current=this._next=this.nodes=null}};var w=[1,3,4,5,7,8,10],E=[2,9,11],S=[5,6,10 ,12],x=[1,3,4,5,7,8,10,11],T=[1,3,4,5,7,8],C=n.getRootContainer,k=N([9,11]),L=N(S),A=N([6,10,12]),R=document.createElement("style"),U=!1;try{R.innerHTML="<b>x</b>",U=R.firstChild.nodeType==3}catch(z){}e.features.htmlParsingConforms=U;var W=U?function(e){var t=this.startContainer,r=n.getDocument(t);if(!t)throw new i("INVALID_STATE_ERR");var s=null;return t.nodeType==1?s=t:n.isCharacterDataNode(t)&&(s=n.parentElement(t)),s===null||s.nodeName=="HTML"&&n.isHtmlNamespace(n.getDocument(s).documentElement)&&n.isHtmlNamespace(s)?s=r.createElement("body"):s=s.cloneNode(!1),s.innerHTML=e,n.fragmentFromNodeChildren(s)}:function(e){M(this);var t=o(this),r=t.createElement("body");return r.innerHTML=e,n.fragmentFromNodeChildren(r)},X=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],V=0,$=1,J=2,K=3,Q=0,G=1,Y=2,Z=3;et.prototype={attachListener:function(e,t){this._listeners[e].push(t)},compareBoundaryPoints:function(e,t){q(this),P(this.startContainer,t.startContainer);var r,i,s,o,u=e==K||e==V?"start":"end",a=e==$||e==V?"start":"end";return r=this[u+"Container"],i=this[u+"Offset"],s=t[a+"Container"],o=t[a+"Offset"],n.comparePoints(r,i,s,o)},insertNode:function(e){q(this),_(e,x),H(this.startContainer);if(n.isAncestorOf(e,this.startContainer,!0))throw new i("HIERARCHY_REQUEST_ERR");var t=l(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){q(this);var e,t;if(this.collapsed)return o(this).createDocumentFragment();if(this.startContainer===this.endContainer&&n.isCharacterDataNode(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=o(this).createDocumentFragment(),t.appendChild(e),t;var r=new g(this,!0);return e=c(r),r.detach(),e},canSurroundContents:function(){q(this),H(this.startContainer),H(this.endContainer);var e=new g(this,!0),t=e._first&&s(e._first,this)||e._last&&s(e._last,this);return e.detach(),!t},surroundContents:function(e){_(e,T);if(!this.canSurroundContents())throw new y("BAD_BOUNDARYPOINTS_ERR");var t=this.extractContents();if(e.hasChildNodes())while(e.lastChild)e.removeChild(e.lastChild);l(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){q(this);var e=new at(o(this)),t=X.length,n;while(t--)n=X[t],e[n]=this[n];return e},toString:function(){q(this);var e=this.startContainer;if(e===this.endContainer&&n.isCharacterDataNode(e))return e.nodeType==3||e.nodeType==4?e.data.slice(this.startOffset,this.endOffset):"";var t=[],r=new g(this,!0);return h(r,function(e){(e.nodeType==3||e.nodeType==4)&&t.push(e.data)}),r.detach(),t.join("")},compareNode:function(e){q(this);var t=e.parentNode,r=n.getNodeIndex(e);if(!t)throw new i("NOT_FOUND_ERR");var s=this.comparePoint(t,r),o=this.comparePoint(t,r+1);return s<0?o>0?Y:Q:o>0?G:Z},comparePoint:function(e,t){return q(this),B(e,"HIERARCHY_REQUEST_ERR"),P(e,this.startContainer),n.comparePoints(e,t,this.startContainer,this.startOffset)<0?-1:n.comparePoints(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:W,toHtml:function(){q(this);var e=o(this).createElement("div");return e.appendChild(this.cloneContents()),e.innerHTML},intersectsNode:function(e,t){q(this),B(e,"NOT_FOUND_ERR");if(n.getDocument(e)!==o(this))return!1;var r=e.parentNode,i=n.getNodeIndex(e);B(r,"NOT_FOUND_ERR");var s=n.comparePoints(r,i,this.endContainer,this.endOffset),u=n.comparePoints(r,i+1,this.startContainer,this.startOffset);return t?s<=0&&u>=0:s<0&&u>0},isPointInRange:function(e,t){return q(this),B(e,"HIERARCHY_REQUEST_ERR"),P(e,this.startContainer),n.comparePoints(e,t,this.startContainer,this.startOffset)>=0&&n.comparePoints(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e,t){q(this);if(o(e)!=o(this))throw new i("WRONG_DOCUMENT_ERR");var r=n.comparePoints(this.startContainer,this.startOffset,e.endContainer,e.endOffset),s=n.comparePoints(this.endContainer,this.endOffset,e.startContainer,e.startOffset);return t?r<=0&&s>=0:r<0&&s>0},intersection:function(e){if(this.intersectsRange(e)){var t=n.comparePoints(this.startContainer,this.startOffset,e.startContainer,e.startOffset),r=n.comparePoints(this.endContainer,this.endOffset,e.endContainer,e.endOffset),i=this.cloneRange();return t==-1&&i.setStart(e.startContainer,e.startOffset),r==1&&i.setEnd(e.endContainer,e.endOffset),i}return null},union:function(e){if(this.intersectsRange(e,!0)){var t=this.cloneRange();return n.comparePoints(e.startContainer,e.startOffset,this.startContainer,this.startOffset)==-1&&t.setStart(e.startContainer,e.startOffset),n.comparePoints(e.endContainer,e.endOffset,this.endContainer,this.endOffset)==1&&t.setEnd(e.endContainer,e.endOffset),t}throw new y("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==Z},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,n.getNodeLength(e))<=0},containsRange:function(e){return this.intersection(e).equals(e)},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);return t.detach(),i}return this.containsNodeContents(e)},createNodeIterator:function(e,t){return q(this),new b(this,e,t)},getNodes:function(e,t){return q(this),v(this,e,t)},getDocument:function(){return o(this)},collapseBefore:function(e){M(this),this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){M(this),this.setStartAfter(e),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(e){return at.rangesEqual(this,e)},isValid:function(){return I(this)},inspect:function(){return m(this)}},it(at,ot,ut),e.rangePrototype=et.prototype,at.rangeProperties=X,at.RangeIterator=g,at.copyComparisonConstants=nt,at.createPrototypeRange=it,at.inspect=m,at.getRangeDocument=o,at.rangesEqual=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t .startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset},e.DomRange=at,e.RangeException=y}),rangy.createModule("WrappedRange",function(e,t){function o(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var i=n.parentElement();n=e.duplicate(),n.collapse(!1);var s=n.parentElement(),o=i==s?i:r.getCommonAncestor(i,s);return o==t?o:r.getCommonAncestor(t,o)}function u(e){return e.compareEndPoints("StartToEnd",e)==0}function a(e,t,n,s){var o=e.duplicate();o.collapse(n);var u=o.parentElement();r.isAncestorOf(t,u,!0)||(u=t);if(!u.canHaveHTML)return new i(u.parentNode,r.getNodeIndex(u));var a=r.getDocument(u).createElement("span");a.parentNode&&a.parentNode.removeChild(a);var f,l=n?"StartToStart":"StartToEnd",c,h,p,d;do u.insertBefore(a,a.previousSibling),o.moveToElementText(a);while((f=o.compareEndPoints(l,e))>0&&a.previousSibling);d=a.nextSibling;if(f==-1&&d&&r.isCharacterDataNode(d)){o.setEndPoint(n?"EndToStart":"EndToEnd",e);var v;if(/[\r\n]/.test(d.data)){var m=o.duplicate(),g=m.text.replace(/\r\n/g,"\r").length;v=m.moveStart("character",g);while((f=m.compareEndPoints("StartToEnd",m))==-1)v++,m.moveStart("character",1)}else v=o.text.length;p=new i(d,v)}else c=(s||!n)&&a.previousSibling,h=(s||n)&&a.nextSibling,h&&r.isCharacterDataNode(h)?p=new i(h,0):c&&r.isCharacterDataNode(c)?p=new i(c,c.length):p=new i(u,r.getNodeIndex(a));return a.parentNode.removeChild(a),p}function f(e,t){var n,i,s=e.offset,o=r.getDocument(e.node),u,a,f=o.body.createTextRange(),l=r.isCharacterDataNode(e.node);return l?(n=e.node,i=n.parentNode):(a=e.node.childNodes,n=s<a.length?a[s]:null,i=e.node),u=o.createElement("span"),u.innerHTML="&#feff;",n?i.insertBefore(u,n):i.appendChild(u),f.moveToElementText(u),f.collapse(!t),i.removeChild(u),l&&f[t?"moveStart":"moveEnd"]("character",s),f}e.requireModules(["DomUtil","DomRange"]);var n,r=e.dom,i=r.DomPosition,s=e.DomRange;if(e.features.implementsDomRange&&(!e.features.implementsTextRange||!e.config.preferTextRange))(function(){function u(e){var t=i.length,n;while(t--)n=i[t],e[n]=e.nativeRange[n]}function a(e,t,n,r,i){var s=e.startContainer!==t||e.startOffset!=n,o=e.endContainer!==r||e.endOffset!=i;if(s||o)e.setEnd(r,i),e.setStart(t,n)}function f(e){e.nativeRange.detach(),e.detached=!0;var t=i.length,n;while(t--)n=i[t],e[n]=null}var t,i=s.rangeProperties,o,l;n=function(e){if(!e)throw new Error("Range must be specified");this.nativeRange=e,u(this)},s.createPrototypeRange(n,a,f),t=n.prototype,t.selectNode=function(e){this.nativeRange.selectNode(e),u(this)},t.deleteContents=function(){this.nativeRange.deleteContents(),u(this)},t.extractContents=function(){var e=this.nativeRange.extractContents();return u(this),e},t.cloneContents=function(){return this.nativeRange.cloneContents()},t.surroundContents=function(e){this.nativeRange.surroundContents(e),u(this)},t.collapse=function(e){this.nativeRange.collapse(e),u(this)},t.cloneRange=function(){return new n(this.nativeRange.cloneRange())},t.refresh=function(){u(this)},t.toString=function(){return this.nativeRange.toString()};var c=document.createTextNode("test");r.getBody(document).appendChild(c);var h=document.createRange();h.setStart(c,0),h.setEnd(c,0);try{h.setStart(c,1),o=!0,t.setStart=function(e,t){this.nativeRange.setStart(e,t),u(this)},t.setEnd=function(e,t){this.nativeRange.setEnd(e,t),u(this)},l=function(e){return function(t){this.nativeRange[e](t),u(this)}}}catch(p){o=!1,t.setStart=function(e,t){try{this.nativeRange.setStart(e,t)}catch(n){this.nativeRange.setEnd(e,t),this.nativeRange.setStart(e,t)}u(this)},t.setEnd=function(e,t){try{this.nativeRange.setEnd(e,t)}catch(n){this.nativeRange.setStart(e,t),this.nativeRange.setEnd(e,t)}u(this)},l=function(e,t){return function(n){try{this.nativeRange[e](n)}catch(r){this.nativeRange[t](n),this.nativeRange[e](n)}u(this)}}}t.setStartBefore=l("setStartBefore","setEndBefore"),t.setStartAfter=l("setStartAfter","setEndAfter"),t.setEndBefore=l("setEndBefore","setStartBefore"),t.setEndAfter=l("setEndAfter","setStartAfter"),h.selectNodeContents(c),h.startContainer==c&&h.endContainer==c&&h.startOffset==0&&h.endOffset==c.length?t.selectNodeContents=function(e){this.nativeRange.selectNodeContents(e),u(this)}:t.selectNodeContents=function(e){this.setStart(e,0),this.setEnd(e,s.getEndOffset(e))},h.selectNodeContents(c),h.setEnd(c,3);var d=document.createRange();d.selectNodeContents(c),d.setEnd(c,4),d.setStart(c,2),h.compareBoundaryPoints(h.START_TO_END,d)==-1&h.compareBoundaryPoints(h.END_TO_START,d)==1?t.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)}:t.compareBoundaryPoints=function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)},e.util.isHostMethod(h,"createContextualFragment")&&(t.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),r.getBody(document).removeChild(c),h.detach(),d.detach()})(),e.createNativeRange=function(e){return e=e||document,e.createRange()};else if(e.features.implementsTextRange){n=function(e){this.textRange=e,this.refresh()},n.prototype=new s(document),n.prototype.refresh=function(){var e,t,n=o(this.textRange);u(this.textRange)?t=e=a(this.textRange,n,!0,!0):(e=a(this.textRange,n,!0,!1),t=a(this.textRange,n,!1,!1)),this.setStart(e.node,e.offset),this.setEnd(t.node,t.offset)},s.copyComparisonConstants(n);var l=function(){return this}();typeof l.Range=="undefined"&&(l.Range=n),e.createNativeRange=function(e){return e=e||document,e.body.createTextRange()}}e.features.implementsTextRange&&(n.rangeToTextRange=function(e){if(e.collapsed){var t=f(new i(e.startContainer,e.startOffset),!0);return t}var n=f(new i(e.startContainer,e.startOffset),!0),s=f(new i(e.endContainer,e.endOffset),!1),o=r.getDocument(e.startContainer).body.createTextRange();return o.setEndPoint("StartToStart",n),o.setEndPoint("EndToEnd",s),o}),n.prototype.getName=function(){return"WrappedRange"},e.WrappedRange= n,e.createRange=function(t){return t=t||document,new n(e.createNativeRange(t))},e.createRangyRange=function(e){return e=e||document,new s(e)},e.createIframeRange=function(t){return e.createRange(r.getIframeDocument(t))},e.createIframeRangyRange=function(t){return e.createRangyRange(r.getIframeDocument(t))},e.addCreateMissingNativeApiListener(function(t){var n=t.document;typeof n.createRange=="undefined"&&(n.createRange=function(){return e.createRange(this)}),n=t=null})}),rangy.createModule("WrappedSelection",function(e,t){function p(e){return(e||window).getSelection()}function d(e){return(e||window).document.selection}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 A(e){var t=e.nativeSelection;e.anchorNode=t.anchorNode,e.anchorOffset=t.anchorOffset,e.focusNode=t.focusNode,e.focusOffset=t.focusOffset}function O(e){e.anchorNode=e.focusNode=null,e.anchorOffset=e.focusOffset=0,e.rangeCount=0,e.isCollapsed=!0,e._ranges.length=0}function M(t){var n;return t instanceof o?(n=t._selectionNativeRange,n||(n=e.createNativeRange(i.getDocument(t.startContainer)),n.setEnd(t.endContainer,t.endOffset),n.setStart(t.startContainer,t.startOffset),t._selectionNativeRange=n,t.attachListener("detach",function(){this._selectionNativeRange=null}))):t instanceof u?n=t.nativeRange:e.features.implementsDomRange&&t instanceof i.getWindow(t.startContainer).Range&&(n=t),n}function _(e){if(!e.length||e[0].nodeType!=1)return!1;for(var t=1,n=e.length;t<n;++t)if(!i.isAncestorOf(e[0],e[t]))return!1;return!0}function D(e){var t=e.getNodes();if(!_(t))throw new Error("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element");return t[0]}function P(e){return!!e&&typeof e.text!="undefined"}function H(e,t){var n=new u(t);e._ranges=[n],L(e,n,!1),e.rangeCount=1,e.isCollapsed=n.collapsed}function B(t){t._ranges.length=0;if(t.docSelection.type=="None")O(t);else{var n=t.docSelection.createRange();if(P(n))H(t,n);else{t.rangeCount=n.length;var r,s=i.getDocument(n.item(0));for(var o=0;o<t.rangeCount;++o)r=e.createRange(s),r.selectNode(n.item(o)),t._ranges.push(r);t.isCollapsed=t.rangeCount==1&&t._ranges[0].collapsed,L(t,t._ranges[t.rangeCount-1],!1)}}}function j(e,t){var n=e.docSelection.createRange(),r=D(t),s=i.getDocument(n.item(0)),o=i.getBody(s).createControlRange();for(var u=0,a=n.length;u<a;++u)o.add(n.item(u));try{o.add(r)}catch(f){throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}o.select(),B(e)}function I(e,t,n){this.nativeSelection=e,this.docSelection=t,this._ranges=[],this.win=n,this.refresh()}function R(e,t){var n=i.getDocument(t[0].startContainer),r=i.getBody(n).createControlRange();for(var s=0,o;s<rangeCount;++s){o=D(t[s]);try{r.add(o)}catch(u){throw new Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)")}}r.select(),B(e)}function V(e,t){if(e.anchorNode&&i.getDocument(e.anchorNode)!==i.getDocument(t))throw new a("WRONG_DOCUMENT_ERR")}function $(e){var t=[],n=new f(e.anchorNode,e.anchorOffset),r=new f(e.focusNode,e.focusOffset),i=typeof e.getName=="function"?e.getName():"Selection";if(typeof e.rangeCount!="undefined")for(var s=0,u=e.rangeCount;s<u;++s)t[s]=o.inspect(e.getRangeAt(s));return"["+i+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+r.inspect()+"]"}e.requireModules(["DomUtil","DomRange","WrappedRange"]),e.config.checkSelectionRanges=!0;var n="boolean",r="_rangySelection",i=e.dom,s=e.util,o=e.DomRange,u=e.WrappedRange,a=e.DOMException,f=i.DomPosition,l,c,h="Control",v=e.util.isHostMethod(window,"getSelection"),m=e.util.isHostObject(document,"selection"),g=m&&(!v||e.config.preferTextRange);g?(l=d,e.isSelectionValid=function(e){var t=(e||window).document,n=t.selection;return n.type!="None"||i.getDocument(n.createRange().parentElement())==t}):v?(l=p,e.isSelectionValid=function(){return!0}):t.fail("Neither document.selection or window.getSelection() detected."),e.getNativeSelection=l;var y=l(),b=e.createNativeRange(document),w=i.getBody(document),E=s.areHostObjects(y,["anchorNode","focusNode"]&&s.areHostProperties(y,["anchorOffset","focusOffset"]));e.features.selectionHasAnchorAndFocus=E;var S=s.isHostMethod(y,"extend");e.features.selectionHasExtend=S;var x=typeof y.rangeCount=="number";e.features.selectionHasRangeCount=x;var T=!1,N=!0;s.areHostMethods(y,["addRange","getRangeAt","removeAllRanges"])&&typeof y.rangeCount=="number"&&e.features.implementsDomRange&&function(){var e=document.createElement("iframe");e.frameBorder=0,e.style.position="absolute",e.style.left="-10000px",w.appendChild(e);var t=i.getIframeDocument(e);t.open(),t.write("<html><head></head><body>12</body></html>"),t.close();var n=i.getIframeWindow(e).getSelection(),r=t.documentElement,s=r.lastChild,o=s.firstChild,u=t.createRange();u.setStart(o,1),u.collapse(!0),n.addRange(u),N=n.rangeCount==1,n.removeAllRanges();var a=u.cloneRange();u.setStart(o,0),a.setEnd(o,2),n.addRange(u),n.addRange(a),T=n.rangeCount==2,u.detach(),a.detach(),w.removeChild(e)}(),e.features.selectionSupportsMultipleRanges=T,e.features.collapsedNonEditableSelectionsSupported=N;var C=!1,k;w&&s.isHostMethod(w,"createControlRange")&&(k=w.createControlRange(),s.areHostProperties(k,["item","add"])&&(C=!0)),e.features.implementsControlRange=C,E?c=function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:c=function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:!1};var F;s.isHostMethod(y,"getRangeAt")?F=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}:E&&(F=function(t){var n=i.getDocument(t.anchorNode),r=e.createRange(n);return r.setStart(t.anchorNode,t.anchorOffset),r.setEnd(t.focusNode,t.focusOffset),r.collapsed!==this.isCollapsed&&(r.setStart(t.focusNode,t.focusOffset),r.setEnd(t.anchorNode,t.anchorOffset)),r }),e.getSelection=function(e){e=e||window;var t=e[r],n=l(e),i=m?d(e):null;return t?(t.nativeSelection=n,t.docSelection=i,t.refresh(e)):(t=new I(n,i,e),e[r]=t),t},e.getIframeSelection=function(t){return e.getSelection(i.getIframeWindow(t))};var q=I.prototype;if(!g&&E&&s.areHostMethods(y,["removeAllRanges","addRange"])){q.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),O(this)};var U=function(t,n){var r=o.getRangeDocument(n),i=e.createRange(r);i.collapseToPoint(n.endContainer,n.endOffset),t.nativeSelection.addRange(M(i)),t.nativeSelection.extend(n.startContainer,n.startOffset),t.refresh()};x?q.addRange=function(t,n){if(C&&m&&this.docSelection.type==h)j(this,t);else if(n&&S)U(this,t);else{var r;T?r=this.rangeCount:(this.removeAllRanges(),r=0),this.nativeSelection.addRange(M(t)),this.rangeCount=this.nativeSelection.rangeCount;if(this.rangeCount==r+1){if(e.config.checkSelectionRanges){var i=F(this.nativeSelection,this.rangeCount-1);i&&!o.rangesEqual(i,t)&&(t=new u(i))}this._ranges[this.rangeCount-1]=t,L(this,t,X(this.nativeSelection)),this.isCollapsed=c(this)}else this.refresh()}}:q.addRange=function(e,t){t&&S?U(this,e):(this.nativeSelection.addRange(M(e)),this.refresh())},q.setRanges=function(e){if(C&&e.length>1)R(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;t<n;++t)this.addRange(e[t])}}}else{if(!(s.isHostMethod(y,"empty")&&s.isHostMethod(b,"select")&&C&&g))return t.fail("No means of selecting a Range or TextRange was found"),!1;q.removeAllRanges=function(){try{this.docSelection.empty();if(this.docSelection.type!="None"){var e;if(this.anchorNode)e=i.getDocument(this.anchorNode);else if(this.docSelection.type==h){var t=this.docSelection.createRange();t.length&&(e=i.getDocument(t.item(0)).body.createTextRange())}if(e){var n=e.body.createTextRange();n.select(),this.docSelection.empty()}}}catch(r){}O(this)},q.addRange=function(e){this.docSelection.type==h?j(this,e):(u.rangeToTextRange(e).select(),this._ranges[0]=e,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,L(this,e,!1))},q.setRanges=function(e){this.removeAllRanges();var t=e.length;t>1?R(this,e):t&&this.addRange(e[0])}}q.getRangeAt=function(e){if(e<0||e>=this.rangeCount)throw new a("INDEX_SIZE_ERR");return this._ranges[e]};var z;if(g)z=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=i.getBody(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==h?B(t):P(n)?H(t,n):O(t)};else if(s.isHostMethod(y,"getRangeAt")&&typeof y.rangeCount=="number")z=function(t){if(C&&m&&t.docSelection.type==h)B(t);else{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],X(t.nativeSelection)),t.isCollapsed=c(t)}else O(t)}};else{if(!E||typeof y.isCollapsed!=n||typeof b.collapsed!=n||!e.features.implementsDomRange)return t.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;z=function(e){var t,n=e.nativeSelection;n.anchorNode?(t=F(n,0),e._ranges=[t],e.rangeCount=1,A(e),e.isCollapsed=c(e)):O(e)}}q.refresh=function(e){var t=e?this._ranges.slice(0):null;z(this);if(e){var n=t.length;if(n!=this._ranges.length)return!1;while(n--)if(!o.rangesEqual(t[n],this._ranges[n]))return!1;return!0}};var W=function(e,t){var n=e.getAllRanges(),r=!1;e.removeAllRanges();for(var i=0,s=n.length;i<s;++i)r||t!==n[i]?e.addRange(n[i]):r=!0;e.rangeCount||O(e)};C?q.removeRange=function(e){if(this.docSelection.type==h){var t=this.docSelection.createRange(),n=D(e),r=i.getDocument(t.item(0)),s=i.getBody(r).createControlRange(),o,u=!1;for(var a=0,f=t.length;a<f;++a)o=t.item(a),o!==n||u?s.add(t.item(a)):u=!0;s.select(),B(this)}else W(this,e)}:q.removeRange=function(e){W(this,e)};var X;!g&&E&&e.features.implementsDomRange?(X=function(e){var t=!1;return e.anchorNode&&(t=i.comparePoints(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)==1),t},q.isBackwards=function(){return X(this)}):X=q.isBackwards=function(){return!1},q.toString=function(){var e=[];for(var t=0,n=this.rangeCount;t<n;++t)e[t]=""+this._ranges[t];return e.join("")},q.collapse=function(t,n){V(this,t);var r=e.createRange(i.getDocument(t));r.collapseToPoint(t,n),this.removeAllRanges(),this.addRange(r),this.isCollapsed=!0},q.collapseToStart=function(){if(!this.rangeCount)throw new a("INVALID_STATE_ERR");var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)},q.collapseToEnd=function(){if(!this.rangeCount)throw new a("INVALID_STATE_ERR");var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)},q.selectAllChildren=function(t){V(this,t);var n=e.createRange(i.getDocument(t));n.selectNodeContents(t),this.removeAllRanges(),this.addRange(n)},q.deleteFromDocument=function(){if(C&&m&&this.docSelection.type==h){var e=this.docSelection.createRange(),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();this.removeAllRanges();for(var r=0,i=n.length;r<i;++r)n[r].deleteContents();this.addRange(n[i-1])}},q.getAllRanges=function(){return this._ranges.slice(0)},q.setSingleRange=function(e){this.setRanges([e])},q.containsNode=function(e,t){for(var n=0,r=this._ranges.length;n<r;++n)if(this._ranges[n].containsNode(e,t))return!0;return!1},q.toHtml=function(){var e="";if(this.rangeCount){var t=o.getRangeDocument(this._ranges[0]).createElement("div");for(var n=0,r=this._ranges.length;n<r;++n)t.appendChild(this._ranges[n].cloneContents());e=t.innerHTML}return e},q.getName=function(){return"WrappedSelection"},q.inspect=function(){return $(this)},q.detach=function(){this.win[r]=null,this.win=this.anchorNode=this.focusNode=null},I.inspect=$,e.Selection=I,e.selectionPrototype=q,e.addCreateMissingNativeApiListener(function(t){typeof t.getSelection=="undefined"&&(t.getSelection=function(){return e.getSelection(this)}),t=null})}),rangy.createModule("CssClassApplier",function(e, t){function i(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function s(e,t){return e.className&&(new RegExp("(?:^|\\s)"+t+"(?:\\s|$)")).test(e.className)}function o(e,t){e.className?s(e,t)||(e.className+=" "+t):e.className=t}function a(e){return e.split(/\s+/).sort().join(" ")}function f(e){return a(e.className)}function l(e,t){return f(e)==f(t)}function c(e){var t=e.parentNode;while(e.hasChildNodes())t.insertBefore(e.firstChild,e);t.removeChild(e)}function h(e,t){var n=e.cloneRange();n.selectNodeContents(t);var r=n.intersection(e),i=r?r.toString():"";return n.detach(),i!=""}function p(e){return e.getNodes([3],function(t){return h(e,t)})}function d(e,t){if(e.attributes.length!=t.attributes.length)return!1;for(var n=0,r=e.attributes.length,i,s,o;n<r;++n){i=e.attributes[n],o=i.name;if(o!="class"){s=t.attributes.getNamedItem(o);if(i.specified!=s.specified)return!1;if(i.specified&&i.nodeValue!==s.nodeValue)return!1}}return!0}function v(e,t){for(var r=0,i=e.attributes.length,s;r<i;++r){s=e.attributes[r].name;if((!t||!n.arrayContains(t,s))&&e.attributes[r].specified&&s!="class")return!0}return!1}function m(e,t){for(var n in t)if(t.hasOwnProperty(n)&&e[n]!==t[n])return!1;return!0}function b(e){var t;return e&&e.nodeType==1&&((t=e.parentNode)&&t.nodeType==9&&t.designMode=="on"||y(e)&&!y(e.parentNode))}function w(e){return(y(e)||e.nodeType!=1&&y(e.parentNode))&&!b(e)}function S(e){return e&&e.nodeType==1&&!E.test(g(e,"display"))}function T(e){if(e.data.length==0)return!0;if(x.test(e.data))return!1;var t=g(e.parentNode,"whiteSpace");switch(t){case"pre":case"pre-wrap":case"-moz-pre-wrap":return!1;case"pre-line":if(/[\r\n]/.test(e.data))return!1}return S(e.previousSibling)||S(e.nextSibling)}function N(e,t){return n.isCharacterDataNode(e)?t==0?!!e.previousSibling:t==e.length?!!e.nextSibling:!0:t>0&&t<e.childNodes.length}function C(e,r,i,s){var o,u=i==0;if(n.isAncestorOf(r,e))return e;if(n.isCharacterDataNode(r))if(i==0)i=n.getNodeIndex(r),r=r.parentNode;else{if(i!=r.length)throw t.createError("splitNodeAt should not be called with offset in the middle of a data node ("+i+" in "+r.data);i=n.getNodeIndex(r)+1,r=r.parentNode}if(N(r,i)){if(!o){o=r.cloneNode(!1),o.id&&o.removeAttribute("id");var a;while(a=r.childNodes[i])o.appendChild(a);n.insertAfter(o,r)}return r==e?o:C(e,o.parentNode,n.getNodeIndex(o),s)}if(e!=r){o=r.parentNode;var f=n.getNodeIndex(r);return u||f++,C(e,o,f,s)}return e}function k(e,t){return e.tagName==t.tagName&&l(e,t)&&d(e,t)}function L(e){var t=e?"nextSibling":"previousSibling";return function(n,r){var i=n.parentNode,s=n[t];if(s){if(s&&s.nodeType==3)return s}else if(r){s=i[t];if(s&&s.nodeType==1&&k(i,s))return s[e?"firstChild":"lastChild"]}return null}}function M(e){this.isElementMerge=e.nodeType==1,this.firstTextNode=this.isElementMerge?e.lastChild:e,this.textNodes=[this.firstTextNode]}function P(e,t,n){this.cssClass=e;var r,s,o,u,f=null;if(typeof t=="object"&&t!==null){n=t.tagNames,f=t.elementProperties;for(s=0;u=_[s++];)t.hasOwnProperty(u)&&(this[u]=t[u]);r=t.normalize}else r=t;this.normalize=typeof r=="undefined"?!0:r,this.attrExceptions=[];var l=document.createElement(this.elementTagName);this.elementProperties={};for(var c in f)f.hasOwnProperty(c)&&(D.hasOwnProperty(c)&&(c=D[c]),l[c]=f[c],this.elementProperties[c]=l[c],this.attrExceptions.push(c));this.elementSortedClassName=this.elementProperties.hasOwnProperty("className")?a(this.elementProperties.className+" "+e):e,this.applyToAnyTagName=!1;var h=typeof n;if(h=="string")n=="*"?this.applyToAnyTagName=!0:this.tagNames=i(n.toLowerCase()).split(/\s*,\s*/);else if(h=="object"&&typeof n.length=="number"){this.tagNames=[];for(s=0,o=n.length;s<o;++s)n[s]=="*"?this.applyToAnyTagName=!0:this.tagNames.push(n[s].toLowerCase())}else this.tagNames=[this.elementTagName]}function H(e,t,n){return new P(e,t,n)}e.requireModules(["WrappedSelection","WrappedRange"]);var n=e.dom,r="span",u=function(){function e(e,t,n){return t&&n?" ":""}return function(t,n){t.className&&(t.className=t.className.replace(new RegExp("(?:^|\\s)"+n+"(?:\\s|$)"),e))}}(),g;typeof window.getComputedStyle!="undefined"?g=function(e,t){return n.getWindow(e).getComputedStyle(e,null)[t]}:typeof document.documentElement.currentStyle!="undefined"?g=function(e,t){return e.currentStyle[t]}:t.fail("No means of obtaining computed style properties found");var y;(function(){var e=document.createElement("div");typeof e.isContentEditable=="boolean"?y=function(e){return e&&e.nodeType==1&&e.isContentEditable}:y=function(e){return!e||e.nodeType!=1||e.contentEditable=="false"?!1:e.contentEditable=="true"||y(e.parentNode)}})();var E=/^inline(-block|-table)?$/i,x=/[^\r\n\t\f \u200B]/,A=L(!1),O=L(!0);M.prototype={doMerge:function(){var e=[],t,n,r;for(var i=0,s=this.textNodes.length;i<s;++i)t=this.textNodes[i],n=t.parentNode,e[i]=t.data,i&&(n.removeChild(t),n.hasChildNodes()||n.parentNode.removeChild(n));return this.firstTextNode.data=r=e.join(""),r},getLength:function(){var e=this.textNodes.length,t=0;while(e--)t+=this.textNodes[e].length;return t},toString:function(){var e=[];for(var t=0,n=this.textNodes.length;t<n;++t)e[t]="'"+this.textNodes[t].data+"'";return"[Merge("+e.join(",")+")]"}};var _=["elementTagName","ignoreWhiteSpace","applyToEditableOnly"],D={"class":"className"};P.prototype={elementTagName:r,elementProperties:{},ignoreWhiteSpace:!0,applyToEditableOnly:!1,hasClass:function(e){return e.nodeType==1&&n.arrayContains(this.tagNames,e.tagName.toLowerCase())&&s(e,this.cssClass)},getSelfOrAncestorWithClass:function(e){while(e){if(this.hasClass(e,this.cssClass))return e;e=e.parentNode}return null},isModifiable:function(e){return!this.applyToEditableOnly||w(e)},isIgnorableWhiteSpaceNode:function(e){return this.ignoreWhiteSpace&&e&&e.nodeType==3&&T(e)},postApply:function(e,t,n){var r=e[0],i=e[e.length-1],s=[],o,u=r,a=i,f=0,l=i.length,c,h;for(var p=0,d=e.length;p<d;++p)c=e[p],h=A(c,!n),h?(o||(o=new M(h),s.push(o)),o.textNodes.push(c),c===r&&(u=o.firstTextNode,f=u.length),c===i&&(a=o .firstTextNode,l=o.getLength())):o=null;var v=O(i,!n);v&&(o||(o=new M(i),s.push(o)),o.textNodes.push(v));if(s.length){for(p=0,d=s.length;p<d;++p)s[p].doMerge();t.setStart(u,f),t.setEnd(a,l)}},createContainer:function(t){var n=t.createElement(this.elementTagName);return e.util.extend(n,this.elementProperties),o(n,this.cssClass),n},applyToTextNode:function(e){var t=e.parentNode;if(t.childNodes.length==1&&n.arrayContains(this.tagNames,t.tagName.toLowerCase()))o(t,this.cssClass);else{var r=this.createContainer(n.getDocument(e));e.parentNode.insertBefore(r,e),r.appendChild(e)}},isRemovable:function(e){return e.tagName.toLowerCase()==this.elementTagName&&f(e)==this.elementSortedClassName&&m(e,this.elementProperties)&&!v(e,this.attrExceptions)&&this.isModifiable(e)},undoToTextNode:function(e,t,n){if(!t.containsNode(n)){var r=t.cloneRange();r.selectNode(n),r.isPointInRange(t.endContainer,t.endOffset)&&(C(n,t.endContainer,t.endOffset,[t]),t.setEndAfter(n)),r.isPointInRange(t.startContainer,t.startOffset)&&(n=C(n,t.startContainer,t.startOffset,[t]))}this.isRemovable(n)?c(n):u(n,this.cssClass)},applyToRange:function(e){e.splitBoundaries();var t=p(e);if(t.length){var n;for(var r=0,i=t.length;r<i;++r)n=t[r],!this.isIgnorableWhiteSpaceNode(n)&&!this.getSelfOrAncestorWithClass(n)&&this.isModifiable(n)&&this.applyToTextNode(n);e.setStart(t[0],0),n=t[t.length-1],e.setEnd(n,n.length),this.normalize&&this.postApply(t,e,!1)}},applyToSelection:function(t){t=t||window;var n=e.getSelection(t),r,i=n.getAllRanges();n.removeAllRanges();var s=i.length;while(s--)r=i[s],this.applyToRange(r),n.addRange(r)},undoToRange:function(e){e.splitBoundaries();var t=p(e),n,r,i=t[t.length-1];if(t.length){for(var s=0,o=t.length;s<o;++s)n=t[s],r=this.getSelfOrAncestorWithClass(n),r&&this.isModifiable(n)&&this.undoToTextNode(n,e,r),e.setStart(t[0],0),e.setEnd(i,i.length);this.normalize&&this.postApply(t,e,!0)}},undoToSelection:function(t){t=t||window;var n=e.getSelection(t),r=n.getAllRanges(),i;n.removeAllRanges();for(var s=0,o=r.length;s<o;++s)i=r[s],this.undoToRange(i),n.addRange(i)},getTextSelectedByRange:function(e,t){var n=t.cloneRange();n.selectNodeContents(e);var r=n.intersection(t),i=r?r.toString():"";return n.detach(),i},isAppliedToRange:function(e){if(e.collapsed)return!!this.getSelfOrAncestorWithClass(e.commonAncestorContainer);var t=e.getNodes([3]);for(var n=0,r;r=t[n++];)if(!this.isIgnorableWhiteSpaceNode(r)&&h(e,r)&&this.isModifiable(r)&&!this.getSelfOrAncestorWithClass(r))return!1;return!0},isAppliedToSelection:function(t){t=t||window;var n=e.getSelection(t),r=n.getAllRanges(),i=r.length;while(i--)if(!this.isAppliedToRange(r[i]))return!1;return!0},toggleRange:function(e){this.isAppliedToRange(e)?this.undoToRange(e):this.applyToRange(e)},toggleSelection:function(e){this.isAppliedToSelection(e)?this.undoToSelection(e):this.applyToSelection(e)},detach:function(){}},P.util={hasClass:s,addClass:o,removeClass:u,hasSameClasses:l,replaceWithOwnChildren:c,elementsHaveSameNonClassAttributes:d,elementHasNonClassAttributes:v,splitNodeAt:C,isEditableElement:y,isEditingHost:b,isEditable:w},e.CssClassApplier=P,e.createCssClassApplier=H}),rangy.createModule("SaveRestore",function(e,t){function i(e,t){return(t||document).getElementById(e)}function s(e,t){var i="selectionBoundary_"+ +(new Date)+"_"+(""+Math.random()).slice(2),s,o=n.getDocument(e.startContainer),u=e.cloneRange();return u.collapse(t),s=o.createElement("span"),s.id=i,s.style.lineHeight="0",s.style.display="none",s.className="rangySelectionBoundary",s.appendChild(o.createTextNode(r)),u.insertNode(s),u.detach(),s}function o(e,n,r,s){var o=i(r,e);o?(n[s?"setStartBefore":"setEndBefore"](o),o.parentNode.removeChild(o)):t.warn("Marker element has been removed. Cannot restore selection.")}function u(e,t){return t.compareBoundaryPoints(e.START_TO_START,e)}function a(n){n=n||window;var r=n.document;if(!e.isSelectionValid(n)){t.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus.");return}var o=e.getSelection(n),a=o.getAllRanges(),f=[],l,c,h;a.sort(u);for(var p=0,d=a.length;p<d;++p)h=a[p],h.collapsed?(c=s(h,!1),f.push({markerId:c.id,collapsed:!0})):(c=s(h,!1),l=s(h,!0),f[p]={startMarkerId:l.id,endMarkerId:c.id,collapsed:!1,backwards:a.length==1&&o.isBackwards()});for(p=d-1;p>=0;--p)h=a[p],h.collapsed?h.collapseBefore(i(f[p].markerId,r)):(h.setEndBefore(i(f[p].endMarkerId,r)),h.setStartAfter(i(f[p].startMarkerId,r)));return o.setRanges(a),{win:n,doc:r,rangeInfos:f,restored:!1}}function f(n,r){if(!n.restored){var s=n.rangeInfos,u=e.getSelection(n.win),a=[];for(var f=s.length,l=f-1,c,h;l>=0;--l){c=s[l],h=e.createRange(n.doc);if(c.collapsed){var p=i(c.markerId,n.doc);if(p){p.style.display="inline";var d=p.previousSibling;d&&d.nodeType==3?(p.parentNode.removeChild(p),h.collapseToPoint(d,d.length)):(h.collapseBefore(p),p.parentNode.removeChild(p))}else t.warn("Marker element has been removed. Cannot restore selection.")}else o(n.doc,h,c.startMarkerId,!0),o(n.doc,h,c.endMarkerId,!1);f==1&&h.normalizeBoundaries(),a[l]=h}f==1&&r&&e.features.selectionHasExtend&&s[0].backwards?(u.removeAllRanges(),u.addRange(a[0],!0)):u.setRanges(a),n.restored=!0}}function l(e,t){var n=i(t,e);n&&n.parentNode.removeChild(n)}function c(e){var t=e.rangeInfos;for(var n=0,r=t.length,i;n<r;++n)i=t[n],i.collapsed?l(e.doc,i.markerId):(l(e.doc,i.startMarkerId),l(e.doc,i.endMarkerId))}e.requireModules(["DomUtil","DomRange","WrappedRange"]);var n=e.dom,r="\ufeff";e.saveSelection=a,e.restoreSelection=f,e.removeMarkerElement=l,e.removeMarkers=c}),rangy.createModule("Serializer",function(e,t){function s(e){return e.replace(/</g,"<").replace(/>/g,">")}function o(e,t){t=t||[];var n=e.nodeType,r=e.childNodes,i=r.length,u=[n,e.nodeName,i].join(":"),a="",f="";switch(n){case 3:a=s(e.nodeValue);break;case 8:a="<!--"+s(e.nodeValue)+"-->";break;default:a="<"+u+">",f="</>"}a&&t.push(a);for(var l=0;l<i;++l)o(r[l],t);return f&&t.push(f),t}function u(e){var t= o(e).join("");return r(t).toString(16)}function a(e,t,n){var r=[],s=e;n=n||i.getDocument(e).documentElement;while(s&&s!=n)r.push(i.getNodeIndex(s,!0)),s=s.parentNode;return r.join("/")+":"+t}function f(e,n,r){n?r=r||i.getDocument(n):(r=r||document,n=r.documentElement);var s=e.split(":"),o=n,u=s[0]?s[0].split("/"):[],a=u.length,f;while(a--){f=parseInt(u[a],10);if(!(f<o.childNodes.length))throw t.createError("deserializePosition failed: node "+i.inspectNode(o)+" has no child with index "+f+", "+a);o=o.childNodes[parseInt(u[a],10)]}return new i.DomPosition(o,parseInt(s[1],10))}function l(t,n,r){r=r||e.DomRange.getRangeDocument(t).documentElement;if(!i.isAncestorOf(r,t.commonAncestorContainer,!0))throw new Error("serializeRange: range is not wholly contained within specified root node");var s=a(t.startContainer,t.startOffset,r)+","+a(t.endContainer,t.endOffset,r);return n||(s+="{"+u(r)+"}"),s}function c(t,n,r){n?r=r||i.getDocument(n):(r=r||document,n=r.documentElement);var s=/^([^,]+),([^,\{]+)({([^}]+)})?$/.exec(t),o=s[4],a=u(n);if(o&&o!==u(n))throw new Error("deserializeRange: checksums of serialized range root node ("+o+") and target root node ("+a+") do not match");var l=f(s[1],n,r),c=f(s[2],n,r),h=e.createRange(r);return h.setStart(l.node,l.offset),h.setEnd(c.node,c.offset),h}function h(e,t,n){t?n=n||i.getDocument(t):(n=n||document,t=n.documentElement);var r=/^([^,]+),([^,]+)({([^}]+)})?$/.exec(e),s=r[3];return!s||s===u(t)}function p(t,n,r){t=t||e.getSelection();var i=t.getAllRanges(),s=[];for(var o=0,u=i.length;o<u;++o)s[o]=l(i[o],n,r);return s.join("|")}function d(t,n,r){n?r=r||i.getWindow(n):(r=r||window,n=r.document.documentElement);var s=t.split("|"),o=e.getSelection(r),u=[];for(var a=0,f=s.length;a<f;++a)u[a]=c(s[a],n,r.document);return o.setRanges(u),o}function v(e,t,n){var r;t?r=n?n.document:i.getDocument(t):(n=n||window,t=n.document.documentElement);var s=e.split("|");for(var o=0,u=s.length;o<u;++o)if(!h(s[o],t,r))return!1;return!0}function g(e){var t=e.split(/[;,]/);for(var n=0,r=t.length,i,s;n<r;++n){i=t[n].split("=");if(i[0].replace(/^\s+/,"")==m){s=i[1];if(s)return decodeURIComponent(s.replace(/\s+$/,""))}}return null}function y(e){e=e||window;var t=g(e.document.cookie);t&&d(t,e.doc)}function b(t,n){t=t||window,n=typeof n=="object"?n:{};var r=n.expires?";expires="+n.expires.toUTCString():"",i=n.path?";path="+n.path:"",s=n.domain?";domain="+n.domain:"",o=n.secure?";secure":"",u=p(e.getSelection(t));t.document.cookie=encodeURIComponent(m)+"="+encodeURIComponent(u)+r+i+s+o}e.requireModules(["WrappedSelection","WrappedRange"]);var n="undefined";(typeof encodeURIComponent==n||typeof decodeURIComponent==n)&&t.fail("Global object is missing encodeURIComponent and/or decodeURIComponent method");var r=function(){function e(e){var t=[];for(var n=0,r=e.length,i;n<r;++n)i=e.charCodeAt(n),i<128?t.push(i):i<2048?t.push(i>>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<u;++o)a=(i^n[o])&255,i=i>>>8^s[a];return(i^-1)>>>0}}(),i=e.dom,m="rangySerializedSelection";e.serializePosition=a,e.deserializePosition=f,e.serializeRange=l,e.deserializeRange=c,e.canDeserializeRange=h,e.serializeSelection=p,e.deserializeSelection=d,e.canDeserializeSelection=v,e.restoreSelectionFromCookie=y,e.saveSelectionCookie=b,e.getElementChecksum=u}),YUI.add("moodle-editor_atto-rangy",function(e,t){rangy.initialized||rangy.init()},"@VERSION@",{requires:[]});