/**
 * Copyright 2018 Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as t,html as e,css as i}from"../../../../lit/index.js";class RichTextEditorHighlight extends t{static get styles(){return[i`
        :host {
          outline: 1px dotted currentColor;
        }
        :host(:empty) {
          outline: none;
          border-left: 1px dotted currentColor;
          margin-right: -0.2em;
        }
        :host([hidden]) {
          display: none !important;
        }
      `]}static get properties(){return{hidden:{type:Boolean,reflect:!0},id:{type:String,reflect:!0},range:{type:Object}}}render(){return e`<slot></slot>`}static get tag(){return"rich-text-editor-highlight"}constructor(){super(),this.haxUIElement=!0;let t=Math.floor(65536*(1+Math.random())).toString(16).substring(1);this.id="rte-"+"ss-s-s-s-sss".replace(/s/g,t)}firstUpdated(t){super.firstUpdated&&super.firstUpdated(t)}emptyContents(){[...this.childNodes].forEach((t=>{this.parentNode&&this.parentNode.insertBefore(t,this)})),globalThis.document.body.append(this),this.hidden=!0,this.range=void 0}wrap(t){if(!t)return;this.hidden||t===this.range||this.emptyContents(),this.range=t;let e=t.extractContents();this.append(e);try{t.insertNode(this)}catch(t){}t.selectNodeContents(this),this.hidden=!1}unwrap(t){let e=[...this.childNodes].reverse();e.length;t&&t.setStartBefore(this),e.forEach(((e,i)=>{t&&t.insertNode(e)})),globalThis.document.body.append(this),this.hidden=!0,this.range=t}}customElements.define(RichTextEditorHighlight.tag,RichTextEditorHighlight);export{RichTextEditorHighlight};globalThis.RichTextEditorHighlight=globalThis.RichTextEditorHighlight||{},globalThis.RichTextEditorHighlight.requestAvailability=()=>(globalThis.RichTextEditorHighlight.instance||(globalThis.RichTextEditorHighlight.instance=globalThis.document.createElement("rich-text-editor-highlight"),globalThis.document.body.appendChild(globalThis.RichTextEditorHighlight.instance)),globalThis.RichTextEditorHighlight.instance);