System.register([],function(_export,_context){"use strict";function n(n,t){e(n,"color",t,"data-rte-color");}function t(n,t){e(n,"backgroundColor",t,"data-rte-bg");}function o(n,t,o){for(;t&&t!==n;){if(t instanceof HTMLSpanElement&&t.hasAttribute(o))return t;t=t.parentNode;}return null;}function e(n,t,e,u){var i=window.getSelection();if(!i||0===i.rangeCount)return;var s=i.getRangeAt(0);if(!n.contains(s.commonAncestorContainer))return;var f=s.cloneRange();if(f.collapsed){var _c=o(n,f.startContainer,u);if(_c)return _c.style[t]=e,void r(n,u,t);var _s=document.createElement("span");_s.setAttribute(u,"1"),_s.style[t]=e,_s.appendChild(document.createTextNode("​")),f.insertNode(_s);var _a=document.createRange();return _a.setStart(_s.firstChild,1),_a.collapse(!0),i.removeAllRanges(),i.addRange(_a),void r(n,u,t);}var a=o(n,f.startContainer,u),d=o(n,f.endContainer,u);if(a&&a===d){if(function(n,t){var o=document.createRange();return o.selectNodeContents(t),n.compareBoundaryPoints(Range.START_TO_START,o)<=0&&n.compareBoundaryPoints(Range.END_TO_END,o)>=0;}(f,a))a.style[t]=e;else{var _n=function(n,t,o,e,r){var u=n.style[e],i=document.createRange();i.setStart(n,0),i.setEnd(t.startContainer,t.startOffset);var s=document.createRange();s.setStart(t.endContainer,t.endOffset),s.setEnd(n,n.childNodes.length);var f=document.createDocumentFragment(),a=function a(n){var t=document.createElement("span");return t.setAttribute(o,"1"),t.style[e]=n,t;};if(c(i)){var _n2=a(u);_n2.appendChild(i.cloneContents()),f.appendChild(_n2);}var d=a(r);if(d.appendChild(t.cloneContents()),f.appendChild(d),c(s)){var _n3=a(u);_n3.appendChild(s.cloneContents()),f.appendChild(_n3);}return n.replaceWith(f),d;}(a,f,u,t,e),_o=window.getSelection(),_r=document.createRange();_r.selectNodeContents(_n),_o!==null&&_o!==void 0&&_o.removeAllRanges(),_o===null||_o===void 0?void 0:_o.addRange(_r);}return void r(n,u,t);}var l=function(){var n=f.commonAncestorContainer;for(;n&&!(n instanceof HTMLElement);)n=n.parentNode;return n;}(),m=document.createTreeWalker(l||n,NodeFilter.SHOW_TEXT,{acceptNode:function acceptNode(n){if(!n.nodeValue||!n.nodeValue.trim())return NodeFilter.FILTER_REJECT;var t=document.createRange();t.selectNodeContents(n);return f.compareBoundaryPoints(Range.END_TO_START,t)<0&&f.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT;}}),p=[];var g;for(;g=m.nextNode();)p.push(g);p.forEach(function(r){var c=0,i=r.length;r===f.startContainer&&(c=f.startOffset),r===f.endContainer&&(i=f.endOffset),c>0&&(r=r.splitText(c)),i<r.length&&r.splitText(i);var s=o(n,r,u);if(s)return void(s.style[t]=e);var a=document.createElement("span");a.setAttribute(u,"1"),a.style[t]=e;r.parentElement.replaceChild(a,r),a.appendChild(r);}),r(n,u,t),i.removeAllRanges(),i.addRange(f);}function r(n,t,o){var e=Array.from(n.querySelectorAll("span[".concat(t,"]"))),r=function r(n){return n.style[o];};e.forEach(function(n){Array.from(n.querySelectorAll("span[".concat(t,"]"))).forEach(function(t){if(r(t)===r(n)){for(;t.firstChild;)n.insertBefore(t.firstChild,t);t.remove();}});var o=n.previousSibling;if(o instanceof HTMLSpanElement&&o.hasAttribute(t)&&r(o)===r(n)){for(;n.firstChild;)o.appendChild(n.firstChild);return void n.remove();}var e=n.nextSibling;if(e instanceof HTMLSpanElement&&e.hasAttribute(t)&&r(e)===r(n)){for(;e.firstChild;)n.appendChild(e.firstChild);e.remove();}});}function c(n){if(n.collapsed)return!1;return(n.cloneContents().textContent||"").length>0;}_export({a:n,s:t});return{setters:[],execute:function execute(){}};});
//# sourceMappingURL=color-utils.cjs.js.map
