var A=(t,o,l)=>{if(!o.has(t))throw TypeError("Cannot "+l)};var b=(t,o,l)=>{if(o.has(t))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(t):o.set(t,l)};var d=(t,o,l)=>(A(t,o,"access private method"),l);(function(t,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(t=typeof globalThis<"u"?globalThis:t||self,t["bionic-read-help"]=o())})(this,function(){var p,T,h,f,m,B,u,C,g,E;"use strict";const t={get bionicAlgorithm(){return[-1,.25,.25,.35,.5,.65]},get bionicTypes(){return{static:"static",interactive:"interactive"}},get bionicOpacity(){return .75},get bionicTextColor(){return"#000"},get bionicStyles(){return{global:{display:"flex","flex-direction":"column",border:"1px solid #a9a9a9","border-radius":" 0.5rem",padding:"5px",overflow:"hidden","text-align":"justify"},label:{display:"flex","justify-content":"center","align-items":"center",gap:"10px","background-color":"#c5c5c5",color:"#000",padding:"5px 10px","border-radius":"0.5rem",border:"1px solid #a0a0a0","margin-top":"0.25rem",height:"1.5rem","max-height":"2rem"},toolbar:{padding:"inherit","background-color":"#d9d9d9","margin-left":"-0.65rem","margin-top":"-0.65rem","margin-right":"-0.65rem","margin-bottom":"0.75rem",display:"flex","flex-wrap":"wrap","flex-direction":"row","justify-content":"space-around","align-items":"center","border-bottom":"1px solid #cecece"},input:{display:"flex",padding:"5px 0px","text-align":"center","border-radius":"0.25rem","background-color":"#fff",border:"1px solid #a0a0a0"}}},get bionicToolsBar(){return{toolbar:{dom:()=>{let i=document.createElement("span");return i.id="wc-bionic-toolbar",o(i,t.bionicStyles.toolbar),[t.bionicToolsBar.bionic.dom(),t.bionicToolsBar.opacity.dom(),t.bionicToolsBar.algorithm.dom(),t.bionicToolsBar["text-color"].dom()].map(e=>i.appendChild(e)),i.setAttribute("part",i.id),i}},bionic:{id:"bionic-check",dom:()=>{let i=document.createElement("label");i.textContent="Bionic";let e=document.createElement("input");return e.type="checkbox",e.id=t.bionicToolsBar.bionic.id,o(e,t.bionicStyles.input),i.appendChild(e),o(i,t.bionicStyles.label),i}},opacity:{id:"bionic-opacity",dom:()=>{let i=document.createElement("label");i.textContent="Opacity";let e=document.createElement("input");return e.id=t.bionicToolsBar.opacity.id,e.type="range",e.min=0,e.max=1,e.step=.01,o(e,t.bionicStyles.input),o(i,t.bionicStyles.label),i.appendChild(e),i}},"text-color":{id:"bionic-text-color",dom:()=>{let i=document.createElement("label");i.textContent="Text color";let e=document.createElement("input");return e.id=t.bionicToolsBar["text-color"].id,e.type="color",o(i,t.bionicStyles.label),i.appendChild(e),i}},algorithm:{id:"bionic-algorithm",dom:()=>{let i=document.createElement("label");i.textContent="Algorithm";let e=document.createElement("input");return e.type="text",e.id=t.bionicToolsBar.algorithm.id,o(e,t.bionicStyles.input),o(i,t.bionicStyles.label),i.appendChild(e),i}}}}};function o(i,e){for(const n in e)i.style[n]=e[n]}const a=class a extends HTMLElement{constructor(){super();b(this,p);b(this,h);b(this,m);b(this,u);b(this,g);this.content="",this.attachShadow({mode:"open"});let n=document.createElement("template");this.shadowRoot.append(n.content.cloneNode(!0)),this.isBionic=!0,this.bionicOpacity=t.bionicOpacity,this.bionicTextColor=t.bionicTextColor,this.bionicAlgo=t.bionicAlgorithm,this.bionicToolsBar={dom:t.bionicToolsBar.toolbar.dom()},this.bionicType=t.bionicTypes.static}static get tagName(){return"wc-bionic-read-help"}static get attributes(){return Object.freeze({"brh-opacity":"brh-opacity","brh-algorithm":"brh-algorithm","brh-type":"brh-type","brh-text-color":"brh-text-color"})}static get observedAttributes(){return Object.values(a.attributes)}connectedCallback(){setTimeout(()=>{this.content=d(this,h,f).call(this),d(this,p,T).call(this)})}attributeChangedCallback(n,r,c){switch(n){case a.attributes["brh-opacity"]:this.bionicOpacity=Number(c)>=0?c:1;break;case a.attributes["brh-text-color"]:this.bionicTextColor=c;break;case a.attributes["brh-algorithm"]:this.bionicAlgo=c?Array.from(c.split(" ").map(Number).filter(Boolean)):t.bionicAlgorithm;break;case a.attributes["brh-type"]:this.bionicType=t.bionicTypes[c]||t.bionicTypes.static;break}}updateElement(){this.shadowRoot.innerHTML="",this.bionicType===t.bionicTypes.interactive&&this.shadowRoot.appendChild(this.bionicToolsBar.dom),this.style.color=this.bionicTextColor;const n=this.isBionic?d(this,u,C).call(this):this.content.join(" "),r=document.createElement("span");r.id=a.tagName+"-text",r.setAttribute("part",r.id),r.innerHTML=n,this.shadowRoot.appendChild(r)}};p=new WeakSet,T=function(){this.bionicType===t.bionicTypes.interactive&&o(this,t.bionicStyles.global),d(this,m,B).call(this),this.updateElement()},h=new WeakSet,f=function(){return this.textContent.trim().split(/\s+/g).filter(n=>n.trim().length>0)},m=new WeakSet,B=function(){if(this.bionicType===t.bionicTypes.static)return;const n=this.bionicToolsBar.dom.querySelector(`#${t.bionicToolsBar.bionic.id}`),r=this.bionicToolsBar.dom.querySelector(`#${t.bionicToolsBar.opacity.id}`),c=this.bionicToolsBar.dom.querySelector(`#${t.bionicToolsBar.algorithm.id}`),y=this.bionicToolsBar.dom.querySelector(`#${t.bionicToolsBar["text-color"].id}`);n.checked=this.isBionic,n.onchange=s=>{this.isBionic=s.target.checked,c.disabled=!this.isBionic,r.disabled=!this.isBionic,y.disabled=!this.isBionic,this.updateElement()},r.value=this.bionicOpacity,r.onchange=s=>{this.bionicOpacity=s.target.value,this.updateElement()},y.value=this.bionicTextColor,y.oninput=s=>{this.bionicTextColor=s.target.value,this.style.color=this.bionicTextColor},c.value=this.bionicAlgo.join(" "),c.onchange=s=>{const x=s.target.value;this.bionicAlgo=x?Array.from(x.split(" ").map(Number).filter(Boolean)):t.bionicAlgorithm,c.value=this.bionicAlgo.join(" "),this.updateElement()}},u=new WeakSet,C=function(){let n=[];for(let r of this.content)n.push(d(this,g,E).call(this,r));return n.join(" ")},g=new WeakSet,E=function(n){let r=this.bionicAlgo[n.length-1]||this.bionicAlgo.at(-1),c=Math.ceil(n.length*r);return`${n.slice(0,c)}${n.slice(c)}`};let l=a;return customElements.define(l.tagName,l),l});