@readium/speech 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +1 -1
- package/build/index.js +32 -24
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -47,4 +47,4 @@ ${JSON.stringify(e,null,4)}`);function M(){b&&(p={tagName:"",hrefValue:"",openin
|
|
|
47
47
|
color: ${oi(g,d)};
|
|
48
48
|
background-color: ${g};
|
|
49
49
|
}`}e.highlightCSS=p,this._rebuildHighlightStylesheet(n)}_getSubKey(e,n){const r=`${e}::${n}`;let i=this._tintSubKeys.get(r);return i||(i=`${this.id}--${this._subKeyCounter++}`,this._tintSubKeys.set(r,i)),i}_rebuildHighlightStylesheet(e){const n=new Set,r=[];for(const i of this.items)i.highlightSubKey&&i.highlightCSS&&!n.has(i.highlightSubKey)&&(n.add(i.highlightSubKey),r.push(i.highlightCSS));e.innerHTML=r.join(`
|
|
50
|
-
`)}positionElement(e,n,r,i,s,o,a=0){const c=e.decoration?.style?.width,l=s;switch(c){case"viewport":{const u=Math.floor(n.inlineStart(l)/n.viewportInlineSize)*n.viewportInlineSize;n.applyPosition(i,u+n.inlineScrollOffset+a,n.blockStart(l)+n.blockScrollOffset,n.viewportInlineSize-2*a,n.blockSize(l),r);break}case"page":{const u=Math.floor(n.inlineStart(l)/n.pageInlineSize)*n.pageInlineSize;n.applyPosition(i,u+n.inlineScrollOffset+a,n.blockStart(l)+n.blockScrollOffset,n.pageInlineSize-2*a,n.blockSize(l),r);break}case"bounds":{n.applyPosition(i,n.inlineStart(o)+n.inlineScrollOffset,n.blockStart(l)+n.blockScrollOffset,n.inlineSize(o),n.blockSize(l),r);break}default:n.applyPosition(i,n.inlineStart(l)+n.inlineScrollOffset,n.blockStart(l)+n.blockScrollOffset,n.inlineSize(l),n.blockSize(l),r)}}computeOverlayRects(e,n,r,i){if(e.decoration?.style?.layout==="bounds")return[i?{left:r.left-i,right:r.right+i,top:r.top-i,bottom:r.bottom+i,width:r.width+i*2,height:r.height+i*2}:r];const s=e.decoration.style.type,o=s===R.Underline||s===R.Strikethrough,a=s===R.Strikethrough,c=o?Uh(e.range,["rt","rp"]):e.range;let l=Je(c,!0,n.isVertical,o?0:i);return l=l.sort((u,h)=>n.isVertical?(n.isVertLR?1:-1)*(u.left-h.left):u.top-h.top),l.map(u=>{let h=u;if(a){const d=n.blockSize(u)*.1,g=n.blockStart(u)+n.blockSize(u)/2-d/2;h=n.isVertical?{left:g,right:g+d,top:u.top,bottom:u.bottom,width:d,height:u.height}:{top:g,bottom:g+d,left:u.left,right:u.right,height:d,width:u.width}}return i&&o&&(h=n.isVertical?{...h,top:h.top-i,bottom:h.bottom+i,height:h.height+i*2}:{...h,left:h.left-i,right:h.right+i,width:h.width+i*2}),h})}repositionItem(e,n){if(!e.container)return!0;const r=e.decoration.style;if(r.type!==R.Template){const u=r.type??R.Highlight;if(u===R.TextColor||u===R.Mask)return!0}const i=1/this.effectiveZoom(),s=r.expand??0,o=e.range.getBoundingClientRect(),a=(()=>{if(r.type!==R.Outline)return 0;const u=r.width;return u==="page"||u==="viewport"?3:0})(),c=this.computeOverlayRects(e,n,o,s),l=Array.from(e.container.children);return l.length!==c.length?!1:(l.forEach((u,h)=>this.positionElement(e,n,i,u,c[h],o,a)),!0)}layout(e){if(this.experimentalHighlights&&!this.notTextFlag?.has(e.id))return this.experimentalLayout(e);const n=this.wnd.document.createElement("div");n.setAttribute("id",e.id),n.dataset.highlightId=e.decoration.id,n.style.setProperty("pointer-events","none");const r=Ee(this.wnd),i=1/this.effectiveZoom(),s=e.decoration.style.expand??0,o=e.range.getBoundingClientRect(),a=e.decoration.style,c=(()=>{if(a.type!==R.Outline)return 0;const h=a.width;return h==="page"||h==="viewport"?3:0})();let l;if(a.type===R.Template){a.stylesheet&&this.injectCustomStylesheet(a.stylesheet);const h=Kh(this.wnd,a.element);if(!h){e.container=n,e.clickableElements=[];return}h.style.setProperty("pointer-events","none"),l=h}else{const h=a,d=h.type??R.Highlight,g=h.tint??vn(d);if(d===R.TextColor){e.container=n,e.clickableElements=[];return}if(d===R.Mask){e.container=n,e.clickableElements=[],this.updateSharedMask();return}const p=this.getCurrentDarkMode(),m=this.getBackgroundColor(),b=h.enforceContrast!==!1,x=(()=>{switch(d){case R.Underline:{const S=b?ke(g,m):g,w=h.layout==="bounds",[T,F]=r.isVertical?["border-right","border-left"]:["border-bottom","border-top"];return[w?`${F}: 0.1em solid ${S} !important`:null,`${T}: 0.1em solid ${S} !important`,"background-color: transparent !important","box-sizing: border-box !important"].filter(Boolean).join("; ")}case R.Strikethrough:{const S=b?ke(g,m):g;return h.layout==="bounds"?[`background: repeating-linear-gradient(-45deg, transparent, transparent 19px, ${S} 19px, ${S} 20px) !important`,"background-color: transparent !important","box-sizing: border-box !important"].join("; "):[`background-color: ${S} !important`,"box-sizing: border-box !important"].join("; ")}case R.Outline:return[`outline: 2px solid ${b?ke(g,m):g} !important`,"outline-offset: 1px !important","background-color: transparent !important","box-sizing: border-box !important"].join("; ");case R.HighlightUnderline:{const S=b?ke(g,m):g,{r:w,g:T,b:F}=be(S),L=`rgba(${w}, ${T}, ${F}, 0.3)`,X=h.layout==="bounds",[M,y]=r.isVertical?["border-right","border-left"]:["border-bottom","border-top"];return[`background-color: ${L} !important`,X?`${y}: 0.1em solid ${S} !important`:null,`${M}: 0.1em solid ${S} !important`,"box-sizing: border-box !important"].filter(Boolean).join("; ")}case R.Highlight:default:return[`background-color: ${b?ke(g,m):g} !important`,`mix-blend-mode: ${p?"exclusion":"multiply"} !important`,"opacity: 1 !important","box-sizing: border-box !important","transform: translateZ(0) !important"].join("; ")}})(),A=this.wnd.document.createElement("template");A.innerHTML=`<div data-readium="true" class="readium-${d}" style="${x}"></div>`.trim(),l=A.content.firstElementChild}const u=this.computeOverlayRects(e,r,o,s);for(const h of u){const d=l.cloneNode(!0);d.style.setProperty("pointer-events","none"),this.positionElement(e,r,i,d,h,o,c),n.append(d)}e.container=n,e.clickableElements=Array.from(n.querySelectorAll("[data-activable='1']")),e.clickableElements.length||(e.clickableElements=Array.from(n.children))}renderLayout(e){this.wnd.cancelAnimationFrame(this.currentRender),this.currentRender=this.wnd.requestAnimationFrame(()=>{e=e.filter(n=>!this.experimentalHighlights||!!this.notTextFlag?.has(n.id)),!(!e||e.length===0)&&this.requireContainer().append(...e.map(n=>n.container).filter(n=>!!n))})}requireContainer(e=!1){if(e){let n;return this.wnd.document.getElementById(`${this.id}-style`)?n=this.wnd.document.getElementById(`${this.id}-style`):(n=this.wnd.document.createElement("style"),n.dataset.readium="true",n.id=`${this.id}-style`,this.wnd.document.head.appendChild(n)),n}return this.container||(this.shadowRoot||(this.shadowHost=this.wnd.document.createElement("div"),this.shadowHost.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none",this.wnd.document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"})),this.container=this.wnd.document.createElement("div"),this.container.setAttribute("id",this.id),this.container.dataset.group=this.name,this.container.dataset.readium="true",this.container.style.setProperty("pointer-events","none"),this.container.style.display="contents",this.shadowRoot.appendChild(this.container)),this.container}getCurrentDarkMode(){return ai(this.wnd,"--USER__appearance")==="readium-night-on"||Is(this.getBackgroundColor())}getBackgroundColor(){return ai(this.wnd,"--USER__backgroundColor")||this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color")}updateSharedMask(){const e=this.items.filter(d=>d.decoration.style?.type===R.Mask);if(e.length===0){this.maskSvg&&(this.maskSvg.remove(),this.maskSvg=void 0),this.shadowHost&&!this.container&&(this.shadowHost.remove(),this.shadowRoot=void 0,this.shadowHost=void 0);return}const n=Ee(this.wnd),r=1/this.effectiveZoom(),i=this.wnd.document.documentElement,s=i.scrollWidth,o=i.scrollHeight,a=[];for(const d of e){const g=d.decoration.style,p=g.layout??"boxes",m=g.width??"wrap",b=g.expand??0,x=d.range.getBoundingClientRect(),A=p==="bounds"?[b?{left:x.left-b,top:x.top-b,right:x.right+b,bottom:x.bottom+b,width:x.width+b*2,height:x.height+b*2}:x]:Je(d.range,!1,!1,b);for(const S of A){let w;switch(m){case"viewport":{const T=Math.floor(n.inlineStart(S)/n.viewportInlineSize)*n.viewportInlineSize;w=n.toRect(T,n.blockStart(S),n.viewportInlineSize,n.blockSize(S));break}case"page":{const T=Math.floor(n.inlineStart(S)/n.pageInlineSize)*n.pageInlineSize;w=n.toRect(T,n.blockStart(S),n.pageInlineSize,n.blockSize(S));break}case"bounds":{w=n.toRect(n.inlineStart(x),n.blockStart(S),n.inlineSize(x),n.blockSize(S));break}default:w=n.toRect(n.inlineStart(S),n.blockStart(S),n.inlineSize(S),n.blockSize(S))}a.push(w)}}const c=[`M0 0 H${s} V${o} H0 Z`,...a.map(d=>{const g=(d.left+n.xDocOffset)*r,p=(d.top+n.yDocOffset)*r,m=(d.right+n.xDocOffset)*r,b=(d.bottom+n.yDocOffset)*r;return`M${g} ${p} H${m} V${b} H${g} Z`})].join(" "),l="http://www.w3.org/2000/svg";if(!this.maskSvg){this.shadowRoot||(this.shadowHost=this.wnd.document.createElement("div"),this.shadowHost.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none",this.wnd.document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"})),this.maskSvg=this.wnd.document.createElementNS(l,"svg"),this.maskSvg.style.cssText=`position:absolute;top:0;left:0;width:${s}px;height:${o}px;pointer-events:none;z-index:9999`,this.maskSvg.dataset.readium="true";const d=this.wnd.document.createElementNS(l,"defs"),g=this.wnd.document.createElementNS(l,"clipPath"),p=`${this.id}-mask-clip`;g.setAttribute("id",p),g.setAttribute("clipPathUnits","userSpaceOnUse");const m=this.wnd.document.createElementNS(l,"path");m.setAttribute("clip-rule","evenodd"),g.appendChild(m),d.appendChild(g),this.maskSvg.appendChild(d);const b=this.wnd.document.createElementNS(l,"rect");b.setAttribute("id",`${this.id}-mask-rect`),b.setAttribute("clip-path",`url(#${p})`),b.style.pointerEvents="none",this.maskSvg.appendChild(b),this.shadowRoot.appendChild(this.maskSvg)}this.maskSvg.style.width=`${s}px`,this.maskSvg.style.height=`${o}px`;const u=this.maskSvg.querySelector("path");u&&u.setAttribute("d",c);const h=this.maskSvg.querySelector("rect");if(h){const d=e[0].decoration.style.tint,g=d??this.getBackgroundColor()??vn(R.Mask),p=d?"1":"0.5";h.setAttribute("x","0"),h.setAttribute("y","0"),h.setAttribute("width",String(s)),h.setAttribute("height",String(o)),h.setAttribute("fill",g),h.setAttribute("fill-opacity",p)}}injectCustomStylesheet(e){const n=`${this.id}-custom-style`;let r=this.wnd.document.getElementById(n);r||(r=this.wnd.document.createElement("style"),r.id=n,r.dataset.readium="true",this.wnd.document.head.appendChild(r)),r.innerHTML=e}clearContainer(){if(this.experimentalHighlights){const e=this.wnd.CSS.highlights;for(const n of this._tintSubKeys.values())e.delete(n);this._tintSubKeys.clear(),this._subKeyCounter=0}this.wnd.document.getElementById(`${this.id}-custom-style`)?.remove(),this.container&&(this.container.remove(),this.container=void 0)}}const oa=class Re extends Hu{constructor(){super(...arguments),this.observedResizeTargets=new Map,this.resizeFrame=0,this.lastGroupId=0,this.groups=new Map,this.handleResizer=this.handleResize.bind(this),this.scrollScheduled=!1,this.handleScroller=this.handleScroll.bind(this)}cleanup(){this.groups.forEach(e=>e.destroy()),this.groups.clear(),this.observedResizeTargets.clear()}updateHighlightStyles(){this.groups.forEach(e=>{e.requestLayout()})}handleResize(){this.wnd.clearTimeout(this.resizeFrame),this.resizeFrame=this.wnd.setTimeout(()=>{this.groups.forEach(e=>e.requestLayout())},50)}handleScroll(){this.scrollScheduled||(this.scrollScheduled=!0,this.wnd.requestAnimationFrame(()=>{this.scrollScheduled=!1,this.groups.forEach(e=>{e.hasOverlayItems&&e.repositionOverlays()})}))}mount(e,n){return this.wnd=e,n.register("decorate",Re.moduleName,(r,i)=>{const s=r;(s.action==="add"||s.action==="update")&&s.decoration.locator&&(s.decoration.locator=Sr.deserialize(s.decoration.locator)),this.groups.has(s.group)||this.groups.set(s.group,new Yh(e,n,`readium-decoration-${this.lastGroupId++}`,s.group));const o=this.groups.get(s.group);switch(s.action){case"add":o?.add(s.decoration);break;case"remove":o?.remove(s.decoration.id);break;case"clear":o?.clear();break;case"update":o?.update(s.decoration);break}i(!0)}),n.register("decoration_resize",Re.moduleName,(r,i)=>{const s=r;s.action==="watch"?this.addDecorationResizeTarget(s.selector):this.removeDecorationResizeTarget(s.selector),i(!0)}),n.register("decoration_activatable",Re.moduleName,(r,i)=>{const s=r,o=this.groups.get(s.group);o&&(o.activatable=s.activatable),i(!0)}),n.register("decoration_hoverable",Re.moduleName,(r,i)=>{const s=r,o=this.groups.get(s.group);o&&(o.hoverable=s.hoverable),i(!0)}),this.resizeObserver=new ResizeObserver(()=>e.requestAnimationFrame(()=>this.handleResize())),this.resizeObserver.observe(e.document.documentElement),e.addEventListener("orientationchange",this.handleResizer),e.addEventListener("resize",this.handleResizer),e.addEventListener("scroll",this.handleScroller,{passive:!0,capture:!0}),this.styleObserver=new MutationObserver(r=>{r.some(i=>i.type==="attributes"&&i.attributeName==="style"&&i.oldValue!==i.target.getAttribute("style"))&&this.updateHighlightStyles()}),this.styleObserver.observe(e.document.documentElement,{attributes:!0,attributeFilter:["style"],attributeOldValue:!0}),n.log("Decorator Mounted"),!0}unmount(e,n){return e.removeEventListener("orientationchange",this.handleResizer),e.removeEventListener("resize",this.handleResizer),e.removeEventListener("scroll",this.handleScroller,{capture:!0}),n.unregisterAll(Re.moduleName),this.resizeObserver.disconnect(),this.styleObserver.disconnect(),this.cleanup(),n.log("Decorator Unmounted"),!0}addDecorationResizeTarget(e){const n=this.observedResizeTargets.get(e);n&&this.resizeObserver.unobserve(n);const r=this.wnd.document.querySelector(e);r?(this.resizeObserver.observe(r),this.observedResizeTargets.set(e,r)):this.observedResizeTargets.delete(e)}removeDecorationResizeTarget(e){const n=this.observedResizeTargets.get(e);n&&(this.resizeObserver.unobserve(n),this.observedResizeTargets.delete(e))}};oa.moduleName="decorator";let la=oa;const ca=new Set(Object.values(R));function ua(t,e){return t===R.TextColor?typeof window<"u"&&"Highlight"in window:ca.has(t)?!0:!!e?.[t]}function jn(t,e){const{style:n}=t;if(n.type===R.Template){const r=n;return{...t,style:{...r,element:Oi(r,t)}}}if(n.type&&e?.[n.type]){const r=e[n.type];return{...t,style:{type:R.Template,layout:r.layout,width:r.width,stylesheet:r.stylesheet,element:Oi(r,t)}}}return t}function Oi(t,e){return typeof t.element=="function"?t.element(e):t.element}function Qh(t,e){if(t.type!==e.type)return!1;if(t.type===R.Template){const i=t,s=e;return i.layout===s.layout&&i.width===s.width&&i.stylesheet===s.stylesheet}const n=t,r=e;return n.tint===r.tint&&n.layout===r.layout&&n.width===r.width&&(n.enforceContrast??!0)===(r.enforceContrast??!0)&&(n.expand??0)===(r.expand??0)}function ha(t,e){return t.locator.href===e.locator.href&&JSON.stringify(t.locator.locations?.serialize?.()??t.locator.locations)===JSON.stringify(e.locator.locations?.serialize?.()??e.locator.locations)&&JSON.stringify(t.locator.text??null)===JSON.stringify(e.locator.text??null)&&Qh(t.style,e.style)&&JSON.stringify(t.extras??null)===JSON.stringify(e.extras??null)}class da{constructor(){this.queue=[],this.channel=typeof MessageChannel<"u"?new MessageChannel:void 0,this.channel&&(this.channel.port1.onmessage=()=>this.flush())}push(e){const n=this.queue.length===0;this.queue.push(e),n&&(this.channel?this.channel.port2.postMessage(null):setTimeout(()=>this.flush(),0))}flush(){const e=this.queue;this.queue=[],e.forEach(n=>n())}clear(){this.queue=[]}}class fa{constructor(){this.frame=new ga(this),this.host=new pa(this)}}class ga{constructor(e){this.channel=e,this.registrar=new Map,this.outbox=new da,this.ready=!0}register(e,n,r){(Array.isArray(e)?e:[e]).forEach(i=>{const s=this.registrar.get(i)??[];if(s.find(o=>o.module===n))throw new Error(`Duplicate callback for "${i}" in module "${n}"`);s.push({module:n,cb:r}),this.registrar.set(i,s)})}unregister(e,n){(Array.isArray(e)?e:[e]).forEach(r=>{const i=this.registrar.get(r);i&&this.registrar.set(r,i.filter(s=>s.module!==n))})}unregisterAll(e){this.registrar.forEach((n,r)=>{this.registrar.set(r,n.filter(i=>i.module!==e))})}_dispatch(e,n,r){const i=this.registrar.get(e);if(!i?.length){r(!1);return}i.forEach(s=>s.cb(n,r))}send(e,n){this.outbox.push(()=>this.channel.host._receive(e,n))}log(...e){this.outbox.push(()=>this.channel.host._receive("log",e))}destroy(){this.registrar.clear(),this.outbox.clear()}}class pa{constructor(e){this.channel=e,this.listeners=new Map,this.outbox=new da,this.ready=!0}send(e,n,r){this.outbox.push(()=>this.channel.frame._dispatch(e,n,r??(()=>{})))}on(e,n){const r=this.listeners.get(e)??[];r.push(n),this.listeners.set(e,r)}off(e,n){const r=this.listeners.get(e);r&&this.listeners.set(e,r.filter(i=>i!==n))}_receive(e,n){this.listeners.get(e)?.forEach(r=>r(n))}}class ma{constructor(e,n={}){this.host=e,this._decorations=new Map,this._activationState=new Map,this._hoverState=new Map,this._observers=new Map,this._hoveredDecorations=new Map,this._config=n,n.resizeWatchSelectors?.forEach(r=>this.addDecorationResizeTarget(r)),e.on("decoration_activated",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId);s&&this._observers.get(i.group)?.forEach(o=>o.onDecorationActivated?.({group:i.group,decoration:s,rect:i.rect,point:i.point}))}),e.on("decoration_pointer_enter",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId);s&&(this._hoveredDecorations.set(i.group,s),this._observers.get(i.group)?.forEach(o=>o.onDecorationPointerEnter?.({group:i.group,decoration:s,rect:i.rect,point:i.point})))}),e.on("decoration_pointer_leave",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId)??this._hoveredDecorations.get(i.group);this._hoveredDecorations.delete(i.group),s&&this._observers.get(i.group)?.forEach(o=>o.onDecorationPointerLeave?.({group:i.group,decoration:s,rect:i.rect,point:i.point}))})}addDecorationResizeTarget(e){this.host.send("decoration_resize",{action:"watch",selector:e})}removeDecorationResizeTarget(e){this.host.send("decoration_resize",{action:"unwatch",selector:e})}supportsDecorationStyle(e){return ua(e,this._config.decorationTemplates)}applyDecorations(e,n){const r=this._decorations.get(n)??[],i=new Map(r.map(c=>[c.id,c])),s=new Map(e.map(c=>[c.id,c]));for(const[c,l]of i){const u=s.get(c);u?ha(l,u)||this.host.send("decorate",{group:n,action:"update",decoration:jn(u,this._config.decorationTemplates)}):this.host.send("decorate",{group:n,action:"remove",decoration:{id:c}})}for(const[c,l]of s)i.has(c)||this.host.send("decorate",{group:n,action:"add",decoration:jn(l,this._config.decorationTemplates)});this._decorations.set(n,e);const o=this._activationState.get(n);o!==void 0&&this.host.send("decoration_activatable",{group:n,activatable:o});const a=this._hoverState.get(n);a!==void 0&&this.host.send("decoration_hoverable",{group:n,hoverable:a})}registerDecorationObserver(e,n){this._observers.has(e)||this._observers.set(e,new Set),this._observers.get(e).add(n),n.onDecorationActivated&&(this._activationState.set(e,!0),this.host.send("decoration_activatable",{group:e,activatable:!0})),(n.onDecorationPointerEnter||n.onDecorationPointerLeave)&&(this._hoverState.set(e,!0),this.host.send("decoration_hoverable",{group:e,hoverable:!0}))}unregisterDecorationObserver(e){this._observers.forEach((n,r)=>{if(!n.has(e))return;n.delete(e);const i=[...n].some(o=>o.onDecorationActivated);this._activationState.has(r)&&!i&&(this._activationState.delete(r),this.host.send("decoration_activatable",{group:r,activatable:!1}));const s=[...n].some(o=>o.onDecorationPointerEnter||o.onDecorationPointerLeave);this._hoverState.has(r)&&!s&&(this._hoverState.delete(r),this.host.send("decoration_hoverable",{group:r,hoverable:!1}))})}destroy(){this._decorations.clear(),this._activationState.clear(),this._hoverState.clear(),this._observers.clear(),this._hoveredDecorations.clear()}}function Zh(t){return new Ds({start:new It(t.start),end:t.end?new It(t.end):void 0})}function ya(t,e=window){const{text:n,cssSelector:r,domRange:i,fragment:s}=t,o=n?new br(n):void 0,a=r||i?new Map:void 0;a&&(r&&a.set("cssSelector",r),i&&a.set("domRange",Zh(i).serialize()));const l=a!==void 0||s!==void 0?new ue({fragments:s?[s]:void 0,otherLocations:a}):void 0;return new Sr({href:e.location.href,type:"text/html",text:o,locations:l})}class ba extends ma{constructor(e,n,r,i={}){super(e.host,i),this.channel=e,this.wnd=n,this.decorator=r}decorate(e,n){this.applyDecorations(e.map(({id:r,style:i,...s})=>({id:r,style:i,locator:ya(s,this.wnd)})),n)}destroy(){super.destroy(),this.decorator.unmount(this.wnd,this.channel.frame),this.channel.frame.destroy()}}function ed(t=window,e={}){const n=new fa,r=new la;return r.mount(t,n.frame),new ba(n,t,r,e)}class td{providers=new Map;register(e){if(this.providers.has(e.id))throw new Error(`A provider is already registered under id "${e.id}"`);this.providers.set(e.id,e)}unregister(e){this.providers.delete(e)}get(e){return this.providers.get(e)}list(){return[...this.providers.values()]}async getVoices(e){return this.require(e).getVoices()}async getAllVoices(){return Promise.all(this.list().map(async e=>({providerId:e.id,voices:await e.getVoices()})))}async createEngine(e,n){return this.require(e).createEngine(n)}async destroy(){await Promise.all(this.list().map(e=>e.destroy())),this.providers.clear()}require(e){const n=this.providers.get(e);if(!n)throw new Error(`No provider registered under id "${e}"`);return n}}const Lt={range:[0,5e3],step:100},$t={range:[.1,10],step:.1},_t={range:[0,2],step:.1},Bt={range:[0,1],step:.05},vr=["none","few","some","most","custom"],wr=["none","block-level","always"],xr=["plain","ssml"],Er=["none","utterance","block"],Ai=["format","inlineContextualization","verbosity","skip","contextualize","language"];function Cr(t){return t==null||typeof t=="boolean"?t:void 0}function re(t,e){return t==null||e.includes(t)?t:void 0}function ie(t,e){if(t==null)return t;if(typeof t!="number"||Number.isNaN(t))return;const n=Math.min(...e),r=Math.max(...e);return t>=n&&t<=r?t:void 0}function at(t){return t==null||Array.isArray(t)&&t.every(e=>typeof e=="string")?t:void 0}class Sa{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e={}){this.format=re(e.format,xr)??"plain",this.inlineContextualization=Cr(e.inlineContextualization)??!1,this.verbosity=re(e.verbosity,vr)??"few",this.skip=at(e.skip)??[],this.contextualize=at(e.contextualize)??[],this.language=re(e.language,wr)??"block-level",this.pauseDuration=ie(e.pauseDuration,Lt.range)??300,this.autoPause=re(e.autoPause,Er)??"none",this.rate=ie(e.rate,$t.range)??1,this.pitch=ie(e.pitch,_t.range)??1,this.volume=ie(e.volume,Bt.range)??1}}class Ue{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e={}){this.format=re(e.format,xr),this.inlineContextualization=Cr(e.inlineContextualization),this.verbosity=re(e.verbosity,vr),this.skip=at(e.skip),this.contextualize=at(e.contextualize),this.language=re(e.language,wr),this.pauseDuration=ie(e.pauseDuration,Lt.range),this.autoPause=re(e.autoPause,Er),this.rate=ie(e.rate,$t.range),this.pitch=ie(e.pitch,_t.range),this.volume=ie(e.volume,Bt.range)}merging(e){const n={...this};for(const r of Object.keys(e))e[r]!==void 0&&(n[r]=e[r]);return new Ue(n)}}class ht{_value;_effectiveValue;_isEffective;_onChange;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i}){this._value=e,this._effectiveValue=n,this._isEffective=r,this._onChange=i}set value(e){this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}clear(){this._value=null,this._onChange(this._value)}}class tt extends ht{_supportedValues;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i,supportedValues:s}){super({initialValue:e,effectiveValue:n,isEffective:r,onChange:i}),this._supportedValues=s}set value(e){if(e!=null&&re(e,this._supportedValues)===void 0)throw new Error(`Value '${String(e)}' is not in the supported values for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get supportedValues(){return this._supportedValues}}class va extends ht{set value(e){if(e!=null&&Cr(e)===void 0)throw new Error(`Value '${String(e)}' is not a boolean.`);this._value=e,this._onChange(this._value)}get value(){return this._value}}class Hn extends ht{set value(e){if(e!=null&&at(e)===void 0)throw new Error(`Value '${String(e)}' is not an array of strings.`);this._value=e,this._onChange(this._value)}get value(){return this._value}}class nt extends ht{_supportedRange;_step;_decimals;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i,supportedRange:s,step:o}){super({initialValue:e,effectiveValue:n,isEffective:r,onChange:i}),this._supportedRange=s,this._step=o,this._decimals=this._step.toString().includes(".")?this._step.toString().split(".")[1].length:0}set value(e){if(e!=null&&ie(e,this._supportedRange)===void 0)throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get supportedRange(){return this._supportedRange}get step(){return this._step}increment(){this._value!=null&&this._value<this._supportedRange[1]&&(this._value=Math.min(Math.round((this._value+this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[1]),this._onChange(this._value))}decrement(){this._value!=null&&this._value>this._supportedRange[0]&&(this._value=Math.max(Math.round((this._value-this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[0]),this._onChange(this._value))}format(e){return e.toString()}}class Wn{preferences;settings;constructor(e,n){this.preferences=new Ue({...e}),this.settings=n}clear(){this.preferences=new Ue({format:null,inlineContextualization:null,verbosity:null,skip:null,contextualize:null,language:null,pauseDuration:null,autoPause:null,rate:null,pitch:null,volume:null})}updatePreference(e,n){this.preferences[e]=n}get format(){return new tt({initialValue:this.preferences.format,effectiveValue:this.settings.format,isEffective:this.preferences.format!=null,onChange:e=>this.updatePreference("format",e??null),supportedValues:xr})}get inlineContextualization(){return new va({initialValue:this.preferences.inlineContextualization,effectiveValue:this.settings.inlineContextualization,isEffective:this.preferences.inlineContextualization!=null,onChange:e=>this.updatePreference("inlineContextualization",e??null)})}get verbosity(){return new tt({initialValue:this.preferences.verbosity,effectiveValue:this.settings.verbosity,isEffective:this.preferences.verbosity!=null,onChange:e=>this.updatePreference("verbosity",e??null),supportedValues:vr})}get skip(){return new Hn({initialValue:this.preferences.skip,effectiveValue:this.settings.skip,isEffective:this.preferences.skip!=null,onChange:e=>this.updatePreference("skip",e??null)})}get contextualize(){return new Hn({initialValue:this.preferences.contextualize,effectiveValue:this.settings.contextualize,isEffective:this.preferences.contextualize!=null,onChange:e=>this.updatePreference("contextualize",e??null)})}get language(){return new tt({initialValue:this.preferences.language,effectiveValue:this.settings.language,isEffective:this.preferences.language!=null,onChange:e=>this.updatePreference("language",e??null),supportedValues:wr})}get pauseDuration(){return new nt({initialValue:this.preferences.pauseDuration,effectiveValue:this.settings.pauseDuration,isEffective:this.preferences.pauseDuration!=null,onChange:e=>this.updatePreference("pauseDuration",e??null),supportedRange:Lt.range,step:Lt.step})}get autoPause(){return new tt({initialValue:this.preferences.autoPause,effectiveValue:this.settings.autoPause,isEffective:this.preferences.autoPause!=null,onChange:e=>this.updatePreference("autoPause",e??null),supportedValues:Er})}get rate(){return new nt({initialValue:this.preferences.rate,effectiveValue:this.settings.rate,isEffective:this.preferences.rate!=null,onChange:e=>this.updatePreference("rate",e??null),supportedRange:$t.range,step:$t.step})}get pitch(){return new nt({initialValue:this.preferences.pitch,effectiveValue:this.settings.pitch,isEffective:this.preferences.pitch!=null,onChange:e=>this.updatePreference("pitch",e??null),supportedRange:_t.range,step:_t.step})}get volume(){return new nt({initialValue:this.preferences.volume,effectiveValue:this.settings.volume,isEffective:this.preferences.volume!=null,onChange:e=>this.updatePreference("volume",e??null),supportedRange:Bt.range,step:Bt.step})}}const wa=["audio","figure","image","math","table","video"],xa=[...wa,"blockquote","chapter","cover","details","notice","part","preformatted","qna","row","rowheader","subtitle","tip"],nd=[...xa,"abstract","acknowledgments","afterword","appendix","aside","backlink","bibliography","biblioref","colophon","complementary","conclusion","credit","credits","dedication","definition","endnotes","epigraph","epilogue","errata","example","footnote","foreword","glossary","glossref","heading1","heading2","heading3","heading4","heading5","heading6","index","introduction","list","listItem","noteref","pagebreak","pagelist","preface","prologue","pullquote","separator","summary","term"],Ea={none:new Set(["aside","bibliography","endnotes","footnote","noteref","pullquote","pagebreak","details","columnheader","rowheader","row","cell","audio","image","figure","video","table","landmarks","loa","loi","lot","lov","toc"]),few:new Set(["aside","bibliography","endnotes","footnote","noteref","pullquote","pagebreak","details","columnheader","rowheader","row","cell","landmarks","loa","loi","lot","lov","toc"]),some:new Set(["aside","bibliography","endnotes","footnote","noteref","pullquote","pagebreak","landmarks","loa","loi","lot","lov","toc"]),most:new Set(["landmarks","loa","loi","lot","lov","toc"])},Ca={none:new Set,few:new Set(wa),some:new Set(xa),most:new Set(nd)},Gn={table:{few:"inline",some:"block",most:"block"}};function wt(t){const e={};for(const n of Object.keys(Gn))e[n]=Gn[n]?.[t]??"inline";return e}const ka={none:wt("none"),few:wt("few"),some:wt("some"),most:wt("most")},rd=Object.keys(Gn);function id(t,e){const n=t==="custom"?{}:ka[t];if(!e)return n;const r={...n};for(const i of Object.keys(e)){const s=e[i]?.[t];s&&(r[i]=s)}return r}class Kn{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e,n){this.format=e.format??n.format,this.inlineContextualization=e.inlineContextualization??n.inlineContextualization,this.verbosity=e.verbosity??n.verbosity,this.verbosity==="custom"?(this.skip=e.skip??n.skip,this.contextualize=e.contextualize??n.contextualize):(this.skip=[...Ea[this.verbosity]],this.contextualize=[...Ca[this.verbosity]]),this.language=e.language??n.language,this.pauseDuration=e.pauseDuration??n.pauseDuration,this.autoPause=e.autoPause??n.autoPause,this.rate=e.rate??n.rate,this.pitch=e.pitch??n.pitch,this.volume=e.volume??n.volume}}const O=t=>typeof t=="string",Xe=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},Ti=t=>t==null?"":String(t),sd=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},ad=/###/g,Ri=t=>t&&t.includes("###")?t.replace(ad,"."):t,Ni=t=>!t||O(t),rt=(t,e,n)=>{const r=O(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Ni(t))return{};const s=Ri(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Ni(t)?{}:{obj:t,k:Ri(r[i])}},Di=(t,e,n)=>{const{obj:r,k:i}=rt(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),a=rt(t,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=rt(t,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=n},od=(t,e,n,r)=>{const{obj:i,k:s}=rt(t,e,Object);i[s]=i[s]||[],i[s].push(n)},qt=(t,e)=>{const{obj:n,k:r}=rt(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},ld=(t,e,n)=>{const r=qt(t,n);return r!==void 0?r:qt(e,n)},Oa=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(Object.prototype.hasOwnProperty.call(t,r)?O(t[r])||t[r]instanceof String||O(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Oa(t[r],e[r],n):t[r]=e[r]);return t},ee=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),cd={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},ud=t=>O(t)?t.replace(/[&<>"'\/]/g,e=>cd[e]):t;class hd{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const dd=[" ",",","?","!",";"],fd=new hd(20),gd=(t,e,n)=>{e=e||"",n=n||"";const r=dd.filter(o=>!e.includes(o)&&!n.includes(o));if(r.length===0)return!0;const i=fd.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},Jn=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,a="";for(let c=s;c<r.length;++c)if(c!==s&&(a+=n),a+=r[c],o=i[a],o!==void 0){if(["string","number","boolean"].includes(typeof o)&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},ot=t=>t?.replace(/_/g,"-"),pd={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class Ut{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||pd,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(e=e.map(s=>O(s)?s.replace(/[\r\n\x00-\x1F\x7F]/g," "):s),O(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Ut(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Ut(this.logger,e)}}var Q=new Ut;class en{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}once(e,n){const r=(...i)=>{n(...i),this.off(e,r)};return this.on(e,r),this}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(e,...n)})}}class Fi extends en{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.includes(".")?a=e.split("."):(a=[e,n],r&&(Array.isArray(r)?a.push(...r):O(r)&&s?a.push(...r.split(s)):a.push(r)));const c=qt(this.data,a);return!c&&!n&&!r&&e.includes(".")&&(e=a[0],n=a[1],r=a.slice(2).join(".")),c||!o||!O(r)?c:Jn(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let a=[e,n];r&&(a=a.concat(o?r.split(o):r)),e.includes(".")&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),Di(this.data,a,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(O(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,o={silent:!1,skipCopy:!1}){let a=[e,n];e.includes(".")&&(a=e.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let c=qt(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Oa(c,r,s):c={...c,...r},Di(this.data,a,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var Aa={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const Ta=Symbol("i18next/PATH_KEY");function md(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Ta?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Ie(t,e){const{[Ta]:n}=t(md()),r=e?.keySeparator??".",i=e?.nsSeparator??":",s=e?.enableSelector==="strict";if(n.length>1&&i){const o=e?.ns,a=s?Array.isArray(o)?o:o?[o]:null:Array.isArray(o)?o:null;if(a&&(s?a:a.length>1?a.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}const wn=t=>!O(t)&&typeof t!="boolean"&&typeof t!="number";class Vt extends en{constructor(e,n={}){super(),sd(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Q.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=wn(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.includes(r),a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!gd(e,r,i);if(o&&!a){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:O(s)?[s]:s};const l=e.split(r);(r!==i||r===i&&this.options.ns.includes(l[0]))&&(s=l.shift()),e=l.join(i)}return{key:e,namespaces:O(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Ie(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map(k=>typeof k=="function"?Ie(k,{...this.options,...i}):String(k));const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],i),l=c[c.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const h=i.lng||this.language,d=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return d?s?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:h,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${a}`:s?{res:a,usedKey:a,exactUsedKey:a,usedLng:h,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:a;const g=this.resolve(e,i);let p=g?.res;const m=g?.usedKey||a,b=g?.exactUsedKey||a,x=["[object Number]","[object Function]","[object RegExp]"],A=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!O(i.count),T=Vt.hasDefaultValue(i),F=w?this.pluralResolver.getSuffix(h,i.count,i):"",L=i.ordinal&&w?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",X=w&&!i.ordinal&&i.count===0,M=X&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${F}`]||i[`defaultValue${L}`]||i.defaultValue;let y=p;S&&!p&&T&&(y=M);const gt=wn(y),ce=Object.prototype.toString.apply(y);if(S&&y&>&&!x.includes(ce)&&!(O(A)&&Array.isArray(y))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const k=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,y,{...i,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(g.res=k,g.usedParams=this.getUsedParamsDetails(i),g):k}if(o){const k=Array.isArray(y),_=k?[]:{},G=k?b:m;for(const V in y)if(Object.prototype.hasOwnProperty.call(y,V)){const H=`${G}${o}${V}`;T&&!p?_[V]=this.translate(H,{...i,defaultValue:wn(M)?M[V]:void 0,joinArrays:!1,ns:c}):_[V]=this.translate(H,{...i,joinArrays:!1,ns:c}),_[V]===H&&(_[V]=y[V])}p=_}}else if(S&&O(A)&&Array.isArray(p))p=p.join(A),p&&(p=this.extendTranslation(p,e,i,r));else{let k=!1,_=!1;!this.isValidLookup(p)&&T&&(k=!0,p=M),this.isValidLookup(p)||(_=!0,p=a);const V=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:p,H=T&&M!==p&&this.options.updateMissing;if(_||k||H){if(this.logger.log(H?"updateKey":"missingKey",h,l,w&&!H?`${a}${this.pluralResolver.getSuffix(h,i.count,i)}`:a,H?M:p),o){const f=this.resolve(a,{...i,keySeparator:!1});f&&f.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let U=[];const ve=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ve&&ve[0])for(let f=0;f<ve.length;f++)U.push(ve[f]);else this.options.saveMissingTo==="all"?U=this.languageUtils.toResolveHierarchy(i.lng||this.language):U.push(i.lng||this.language);const K=(f,v,C)=>{const E=T&&C!==p?C:V;this.options.missingKeyHandler?this.options.missingKeyHandler(f,l,v,E,H,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(f,l,v,E,H,i),this.emit("missingKey",f,l,v,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?U.forEach(f=>{const v=this.pluralResolver.getSuffixes(f,i);X&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!v.includes(`${this.options.pluralSeparator}zero`)&&v.push(`${this.options.pluralSeparator}zero`),v.forEach(C=>{K([f],a+C,i[`defaultValue${C}`]||M)})}):K(U,a,M))}p=this.extendTranslation(p,e,i,g,r),_&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(_||k)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,k?p:void 0,i))}return s?(g.res=p,g.usedParams=this.getUsedParamsDetails(i),g):p}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=O(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let l;if(c){const h=e.match(this.interpolator.nestingRegexp);l=h&&h.length}let u=r.replace&&!O(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),c){const h=e.match(this.interpolator.nestingRegexp),d=h&&h.length;l<d&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,a=O(o)?[o]:o;return e!=null&&a?.length&&r.applyPostProcessor!==!1&&(e=Aa.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,a;return O(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(c=>typeof c=="function"?Ie(c,{...this.options,...n}):c)),e.forEach(c=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(c,n),u=l.key;i=u;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const d=n.count!==void 0&&!O(n.count),g=d&&!n.ordinal&&n.count===0,p=n.context!==void 0&&(O(n.context)||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(b=>{this.isValidLookup(r)||(a=b,!this.checkedLoadedFor[`${m[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(this.checkedLoadedFor[`${m[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(x=>{if(this.isValidLookup(r))return;o=x;const A=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(A,u,x,b,n);else{let w;d&&(w=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,F=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(n.ordinal&&w.startsWith(F)&&A.push(u+w.replace(F,this.options.pluralSeparator)),A.push(u+w),g&&A.push(u+T)),p){const L=`${u}${this.options.contextSeparator||"_"}${n.context}`;A.push(L),d&&(n.ordinal&&w.startsWith(F)&&A.push(L+w.replace(F,this.options.pluralSeparator)),A.push(L+w),g&&A.push(L+T))}}let S;for(;S=A.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(x,b,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!O(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i={...i,count:e.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&r.startsWith(n)&&e[r]!==void 0)return!0;return!1}}class Ii{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Q.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=ot(e),!e||!e.includes("-"))return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=ot(e),!e||!e.includes("-"))return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(O(e)&&e.includes("-")){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>o===s?!0:!o.includes("-")&&!s.includes("-")?!1:!!(o.includes("-")&&!s.includes("-")&&o.slice(0,o.indexOf("-"))===s||o.startsWith(s)&&s.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),O(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.options.fallbackLng,i=Array.isArray(r)?r.join("|"):r;i!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=i);const s=n===void 0||n===!1||O(n),o=n===void 0&&typeof this.options.fallbackLng=="function",a=O(e)&&s&&!o;let c=null;if(a){let d;n===void 0?d="undefined":n===!1?d="boolean:false":d=`string:${n}`,c=`${e.length}:${e}|${d}`}if(c!==null){const d=this.resolveHierarchyCache[c];if(d!==void 0)return d.slice()}const l=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),u=[],h=d=>{d&&(this.isSupportedCode(d)?u.push(d):this.logger.warn(`rejecting language code not found in supportedLngs: ${d}`))};return O(e)&&(e.includes("-")||e.includes("_"))?(this.options.load!=="languageOnly"&&h(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&h(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&h(this.getLanguagePartFromCode(e))):O(e)&&h(this.formatLanguageCode(e)),l.forEach(d=>{u.includes(d)||h(this.formatLanguageCode(d))}),c!==null?(this.resolveHierarchyCache[c]=u,u.slice()):u}}const Pi={zero:0,one:1,two:2,few:3,many:4,other:5},Li={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class yd{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Q.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=ot(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Li;if(!e.match(/-|_/))return Li;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Pi[i]-Pi[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const $i=(t,e,n,r=".",i=!0)=>{let s=ld(t,e,n);return!s&&i&&O(n)&&(s=Jn(t,n,r),s===void 0&&(s=Jn(e,n,r))),s},bd=t=>t.replace(/\$/g,"$$$$");class _i{constructor(e={}){this.logger=Q.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:a,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:h,nestingPrefix:d,nestingPrefixEscaped:g,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:b,maxReplaces:x,alwaysFormat:A}=e.interpolation;this.escape=n!==void 0?n:ud,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?ee(s):o||"{{",this.suffix=a?ee(a):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":h?ee(h):"-",this.unescapeSuffix=this.unescapePrefix?"":u?ee(u):"",this.nestingPrefix=d?ee(d):g||ee("$t("),this.nestingSuffix=p?ee(p):m||ee(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=x||1e3,this.alwaysFormat=A!==void 0?A:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,a;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=g=>{if(!g.includes(this.formatSeparator)){const x=$i(n,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:g}):x}const p=g.split(this.formatSeparator),m=p.shift().trim(),b=p.join(this.formatSeparator).trim();return this.format($i(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:m})};this.resetRegExp(),!this.escapeValue&&typeof e=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>g},{regex:this.regexp,safeValue:g=>this.escapeValue?this.escape(g):g}].forEach(g=>{for(a=0;s=g.regex.exec(e);){const p=s[1].trim();if(o=l(p),o===void 0)if(typeof u=="function"){const b=u(e,s,i);o=O(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,p))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),o="";else!O(o)&&!this.useRawValueToEscape&&(o=Ti(o));const m=g.safeValue(o);if(e=e.replace(s[0],bd(m)),h?(g.regex.lastIndex+=m.length,g.regex.lastIndex-=s[0].length):g.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const a=(c,l)=>{const u=this.nestingOptionsSeparator;if(!c.includes(u))return c;const h=c.split(new RegExp(`${ee(u)}[ ]*{`));let d=`{${h[1]}`;c=h[0],d=this.interpolate(d,o);const g=d.match(/'/g),p=d.match(/"/g);((g?.length??0)%2===0&&!p||(p?.length??0)%2!==0)&&(d=d.replace(/'/g,'"'));try{o=JSON.parse(d),l&&(o={...l,...o})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,m),`${c}${u}${d}`}return o.defaultValue&&o.defaultValue.includes(this.prefix)&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!O(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const l=/{.*}/s.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(l!==-1&&(c=i[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,l)),s=n(a.call(this,i[1].trim(),o),o),s&&i[0]===e&&!O(s))return s;O(s)||(s=Ti(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,h)=>this.format(u,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Sd=t=>{let e=t.toLowerCase().trim();const n={};if(t.includes("(")){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].slice(0,-1);e==="currency"&&!i.includes(":")?n.currency||(n.currency=i.trim()):e==="relativetime"&&!i.includes(":")?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...c]=o.split(":"),l=c.join(":").trim().replace(/^'+|'+$/g,""),u=a.trim();n[u]||(n[u]=l),l==="false"&&(n[u]=!1),l==="true"&&(n[u]=!0),isNaN(l)||(n[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:n}},Bi=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let a=e[o];return a||(a=t(ot(r),i),e[o]=a),a(n)}},vd=t=>(e,n,r)=>t(ot(n),r)(e);class wd{constructor(e={}){this.logger=Q.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?Bi:vd;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return a=>o.format(a)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return a=>o.format(a)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return a=>o.format(a)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return a=>o.format(a,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return a=>o.format(a)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Bi(n)}format(e,n,r,i={}){if(!n||e==null)return e;const s=n.split(this.formatSeparator),o=[];for(let c=0;c<s.length;c++){let l=s[c];for(;l.indexOf("(")>-1&&!l.includes(")")&&c+1<s.length;)l=`${l}${this.formatSeparator}${s[++c]}`;o.push(l)}return o.reduce((c,l)=>{const{formatName:u,formatOptions:h}=Sd(l);if(this.formats[u]){let d=c;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;d=this.formats[u](c,p,{...h,...i,...g})}catch(g){this.logger.warn(g)}return d}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const xd=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Ed extends en{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Q.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},a={},c={};return e.forEach(l=>{let u=!0;n.forEach(h=>{const d=`${l}|${h}`;!r.reload&&this.store.hasResourceBundle(l,h)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?o[d]===void 0&&(o[d]=!0):(this.state[d]=1,u=!1,o[d]===void 0&&(o[d]=!0),s[d]===void 0&&(s[d]=!0),c[h]===void 0&&(c[h]=!0)))}),u||(a[l]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const a={};this.queue.forEach(c=>{od(c.loaded,[s],o),xd(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(l=>{a[l]||(a[l]={});const u=c.loaded[l];u.length&&u.forEach(h=>{a[l][h]===void 0&&(a[l][h]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const a=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read(e,n,r,i+1,s*2,o)},s);return}o(l,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const l=c(e,n);l&&typeof l.then=="function"?l.then(u=>a(null,u)).catch(a):a(null,l)}catch(l){a(l)}return}return c(e,n,a)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();O(e)&&(e=this.languageUtils.toResolveHierarchy(e)),O(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,n,r,i,s,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},l=this.backend.create.bind(this.backend);if(l.length<6)try{let u;l.length===5?u=l(e,n,r,i,c):u=l(e,n,r,i),u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}else l(e,n,r,i,a,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const xn=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),O(t[1])&&(e.defaultValue=t[1]),O(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),qi=t=>(O(t.ns)&&(t.ns=[t.ns]),O(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),O(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),xt=()=>{},Cd=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class it extends en{constructor(e={},n){if(super(),this.options=qi(e),this.services={},this.logger=Q,this.modules={external:[]},Cd(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(O(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const r=xn();this.options={...r,...this.options,...qi(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=r.overloadTranslationOptionHandler);const i=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?Q.init(i(this.modules.logger),this.options):Q.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=wd;const u=new Ii(this.options);this.store=new Fi(this.options.resources,this.options);const h=this.services;h.logger=Q,h.resourceStore=this.store,h.languageUtils=u,h.pluralResolver=new yd(u,{prepend:this.options.pluralSeparator}),l&&(h.formatter=i(l),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new _i(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Ed(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(d,...g)=>{this.emit(d,...g)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Vt(this.services,this.options),this.translator.on("*",(d,...g)=>{this.emit(d,...g)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,n||(n=xt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(l=>{this[l]=(...u)=>this.store[l](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(l=>{this[l]=(...u)=>(this.store[l](...u),this)});const a=Xe(),c=()=>{const l=(u,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(h),n(u,h)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return l(null,this.t.bind(this));this.changeLanguage(this.options.lng,l)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),a}loadResources(e,n=xt){let r=n;const i=O(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(l=>{l!=="cimode"&&(s.includes(l)||s.push(l))})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(e,n,r){const i=Xe();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=xt),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Aa.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!["cimode","dev"].includes(e)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!["cimode","dev"].includes(r)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Xe();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},s=(a,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...l)=>this.t(...l)),n&&n(a,(...l)=>this.t(...l))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const c=O(a)?a:a&&a[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(O(a)?[a]:a);l&&(this.language||i(l),this.translator.language||this.translator.changeLanguage(l),this.services.languageDetector?.cacheUserLanguage?.(l)),this.loadResources(l,u=>{s(u,l)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r,i){const s=i?.scopeNs,o=(a,c,...l)=>{let u;typeof c!="object"?u=this.options.overloadTranslationOptionHandler([a,c].concat(l)):u={...c},u.lng=u.lng||o.lng,u.lngs=u.lngs||o.lngs;const h=u.ns!==void 0&&u.ns!==null;u.ns=u.ns||o.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||o.keyPrefix);const d={...this.options,...u};Array.isArray(s)&&!h&&(d.ns=s),typeof u.keyPrefix=="function"&&(u.keyPrefix=Ie(u.keyPrefix,d));const g=this.options.keySeparator||".";let p;return u.keyPrefix&&Array.isArray(a)?p=a.map(m=>(typeof m=="function"&&(m=Ie(m,d)),`${u.keyPrefix}${g}${m}`)):(typeof a=="function"&&(a=Ie(a,d)),p=u.keyPrefix?`${u.keyPrefix}${g}${a}`:a),this.t(p,u)};return O(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=r,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,c)=>{const l=this.services.backendConnector.state[`${a}|${c}`];return l===-1||l===0||l===2};if(n.precheck){const a=n.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Xe();return this.options.ns?(O(e)&&(e=[e]),e.forEach(i=>{this.options.ns.includes(i)||this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Xe();O(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>!i.includes(o)&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new Ii(xn());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(r.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new it(e,n);return r.createInstance=it.createInstance,r}cloneInstance(e={},n=xt){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new it(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const a=Object.keys(this.store.data).reduce((c,l)=>(c[l]={...this.store.data[l]},c[l]=Object.keys(c[l]).reduce((u,h)=>(u[h]={...c[l][h]},u),c[l]),c),{});s.store=new Fi(a,i),s.services.resourceStore=s.store}if(e.interpolation){const c={...xn().interpolation,...this.options.interpolation,...e.interpolation},l={...i,interpolation:c};s.services.interpolator=new _i(l)}return s.translator=new Vt(s.services,i),s.translator.on("*",(a,...c)=>{s.emit(a,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const z=it.createInstance();z.createInstance;z.dir;z.init;z.loadResources;z.reloadResources;z.use;z.changeLanguage;z.getFixedT;z.t;z.exists;z.setDefaultNamespace;z.hasLoadedNamespace;z.loadNamespaces;z.loadLanguages;function dt(t){return t.plain===""&&t.ssml===""&&t.language===""}function kd(t){if(!t||dt(t))return;if(t.ssml===""&&t.language==="")return t.plain;const e={language:t.language};return t.plain!==""&&(e.plain=t.plain),t.ssml!==""&&(e.ssml=t.ssml),e}function Od(t,e){if(t.lang!==e.lang||t.tag!==e.tag)return!1;const n=Object.entries(t.attrs??{}),r=Object.entries(e.attrs??{});return n.length!==r.length?!1:n.every(([i,s])=>e.attrs?.[i]===s)}const zt=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),En=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Ad=/[\u00A0\u2007\u202F]/;function Td(t){return Ad.test(t)}function Ve(t,e){let n="",r=!1,i=!1;for(const s of t)if(Td(s))n+=s,r=!1,i=!0;else if(/\s/.test(s)){if(e&&!i||r)continue;n+=" ",r=!0}else s!==""&&s!==""&&(n+=s,r=!1,i=!0);return n}const Xn="#css(",Yn=")";function Ra(t){return`${Xn}${encodeURIComponent(t)}${Yn}`}function Na(t){if(!(!t||!t.startsWith(Xn)||!t.endsWith(Yn)))return decodeURIComponent(t.slice(Xn.length,-Yn.length))}const Qn="#domrange(",Zn=")";function Da(t){return`${Qn}${encodeURIComponent(JSON.stringify(t))}${Zn}`}function Fa(t){if(!(!t||!t.startsWith(Qn)||!t.endsWith(Zn)))try{const e=JSON.parse(decodeURIComponent(t.slice(Qn.length,-Zn.length)));return!e?.start?.cssSelector||typeof e.start.textNodeIndex!="number"?void 0:e}catch{return}}const er=":~:text=";function Et(t){return encodeURIComponent(t).replace(/-/g,"%2D")}function Ia(t){let e="";return t.prefix&&(e+=`${Et(t.prefix)}-,`),e+=Et(t.textStart),t.textEnd&&(e+=`,${Et(t.textEnd)}`),t.suffix&&(e+=`,-${Et(t.suffix)}`),`${er}${e}`}function Rd(t){if(!t)return;const e=t.indexOf(er);if(e===-1)return;const n=t.slice(e+er.length).split("&")[0];if(n)try{let r=n.split(",");const i={textStart:""};return r[0].endsWith("-")&&(i.prefix=decodeURIComponent(r[0].slice(0,-1)),r=r.slice(1)),r.length>0&&r[r.length-1].startsWith("-")&&(i.suffix=decodeURIComponent(r[r.length-1].slice(1)),r=r.slice(0,-1)),r.length===0||r[0]===""?void 0:(i.textStart=decodeURIComponent(r[0]),r.length>1&&(i.textEnd=decodeURIComponent(r[1])),i)}catch{return}}function tr(t){const e=t?.textref;if(!e)return;const n=e.indexOf(":~:"),r=n===-1?e:e.slice(0,n);let i,s;const o=Fa(r);if(o)s=o,i=o.start.cssSelector;else{const l=Na(r);l!==void 0?i=l:t?.id&&r===`#${CSS.escape(t.id)}`&&(i=r)}const a=Rd(e);if(i===void 0&&s===void 0&&a===void 0)return;const c={};return i!==void 0&&(c.cssSelector=i),s!==void 0&&(c.domRange=s),a?.textEnd!==void 0?c.fragment=Ia(a):a&&(c.text={highlight:a.textStart},a.prefix!==void 0&&(c.text.before=a.prefix),a.suffix!==void 0&&(c.text.after=a.suffix)),c}const Nd={contextualizations:{abstract:{block:{start:"Start of the abstract.",end:"End of the abstract."}},acknowledgments:{block:{start:"Start of the acknowledgments.",end:"End of the acknowledgments."}},afterword:{block:{start:"Start of the afterword.",end:"End of the afterword."}},appendix:{block:{start:"Start of the appendix.",end:"End of the appendix."}},aside:{block:{start:"Start of the aside.",end:"End of the aside."}},audio:{inline:{labelled:"Audio with a label: {{ description }}",unlabelled:"Audio with no label."}},bibliography:{block:{start:"Start of the bibliography.",end:"End of the bibliography."}},blockquote:{inline:"Blockquote."},cell:{inline:{withHeader:"{{ header }}: {{ value }}",withoutHeader:"{{ value }}"}},chapter:{block:{start:"Start of the chapter.",end:"End of the chapter."}},colophon:{inline:"Colophon."},complementary:{block:{start:"Start of the complementary content.",end:"End of the complementary content."}},conclusion:{block:{start:"Start of the conclusion.",end:"End of the conclusion."}},cover:{inline:{labelled:"Cover with a label: {{ description }}",unlabelled:"Cover with no label."}},credit:{inline:"Credit."},credits:{block:{start:"Start of the credits.",end:"End of the credits."}},dedication:{inline:"Dedication."},definition:{inline:"Definition."},details:{block:{start:"Start of the disclosure.",end:"End of the disclosure."}},endnotes:{block:{start:"Start of the endnotes.",end:"End of the endnotes."}},epigraph:{inline:"Epigraph."},epilogue:{block:{start:"Start of the epilogue.",end:"End of the epilogue."}},errata:{block:{start:"Start of the errata.",end:"End of the errata."}},example:{block:{start:"Start of the example.",end:"End of the example."}},figure:{inline:"Figure: {{ description }}"},footnote:{block:{start:"Start of the footnote.",end:"End of the footnote."}},foreword:{block:{start:"Start of the foreword.",end:"End of the foreword."}},glossary:{block:{start:"Start of the glossary.",end:"End of the glossary."}},heading1:{inline:"Heading level 1."},heading2:{inline:"Heading level 2."},heading3:{inline:"Heading level 3."},heading4:{inline:"Heading level 4."},heading5:{inline:"Heading level 5."},heading6:{inline:"Heading level 6."},image:{inline:{labelled:"Image with a label: {{ description }}",unlabelled:"Image with no label."}},index:{block:{start:"Start of the index.",end:"End of the index."}},introduction:{block:{start:"Start of the introduction.",end:"End of the introduction."}},list:{block:{start:"Start of the list.",end:"End of the list."}},listItem:{inline:"List item."},math:{inline:{labelled:"{{ description }}",unlabelled:"Math formula with no label."}},notice:{inline:"Notice."},pagebreak:{inline:"Pagebreak."},pagelist:{block:{start:"Start of the page list.",end:"End of the page list."}},part:{inline:"Part."},preface:{block:{start:"Start of the preface.",end:"End of the preface."}},prologue:{block:{start:"Start of the prologue.",end:"End of the prologue."}},pullquote:{inline:"Pullquote."},qna:{block:{start:"Start of the questions and answers.",end:"End of the questions and answers."}},row:{inline:"Row: {{ count }}"},rowheader:{inline:{withHeader:"{{ header }}: {{ value }}",withoutHeader:"{{ value }}"}},separator:{inline:"Separator."},subtitle:{inline:"Subtitle."},summary:{inline:"Summary."},table:{block:{end:"End of the table.",start:{labelled:"Table: {{ description }}. {{ lines }}. {{ columns }}.",unlabelled:"Table. {{ lines }}. {{ columns }}."}},inline:{labelled:"Table: {{ description }}. {{ lines }}. {{ columns }}.",unlabelled:"Table. {{ lines }}. {{ columns }}."},parts:{columns_one:"1 column",columns_other:"{{ count }} columns",lines_one:"1 line",lines_other:"{{ count }} lines"}},term:{inline:"Term."},tip:{inline:"Tip."},video:{inline:{labelled:"Video with a label: {{ description }}",unlabelled:"Video with no label."}}}},Dd={speech:Nd},kr=Dd.speech.contextualizations,Ui={en:kr},Fd={};async function Id(t){const e=Ui[t];if(e)return e;const n=Fd[t];if(!n)return kr;const r=(await n()).speech.contextualizations;return Ui[t]=r,r}const Pd=/<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;function Pa(t){return t.replace(Pd,"$1")}const Ld=/\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;function $d(t){return t.replace(Ld,(n,r,i)=>{const s=i.slice(r+n.length);return s.length===0||Qt(s)?"":" "}).replace(/ {2,}/g," ").trim()}function _d(t){return t.includes("<")}function Or(t){if(t===void 0)return;if(typeof t=="string")return{plain:t};const e={language:t.language};if(t.ssml){const n=$d(t.ssml);_d(n)&&(e.ssml=n)}return t.plain&&(e.plain=t.plain),e.plain||e.ssml?e:void 0}function tn(t){return t.replace(/<[^>]+>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ {2,}/g," ").trim()}const La=/<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;function $a(t){return new RegExp(La).test(t)}function Vi(t){return t.replace(/<[^>]+>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ {2,}/g," ")}const Bd=new RegExp(`\\s+|[${$n}]+|[${De}]+|[^\\s${$n}${De}]+`,"gu");function Cn(t){const e=[];for(const[n]of t.matchAll(Bd))/^\s/.test(n)?e.push({kind:"space"}):Tu(n)?e.push({kind:"open",text:n}):Qt(n)?e.push({kind:"close",text:n}):e.push({kind:"word",text:n});return e}function qd(t){let e="",n=!1;for(const r of t){if(r.kind==="space"){e&&(n=!0);continue}n&&(e+=" "),e+=r.text,n=!1}return e}function Ud(t){let e=t.length;for(;e>0&&(t[e-1].kind==="space"||t[e-1].kind==="open");)e--;return t.slice(e).some(n=>n.kind==="open")?t.splice(e):[]}function Vd(t){let e=0;for(;e<t.length&&(t[e].kind==="space"||t[e].kind==="close");)e++;return t.slice(0,e).some(n=>n.kind==="close")?t.splice(0,e):[]}function _a(t,e){const n=[];let r=0;for(const s of t.matchAll(La))n.push({tokens:Cn(Vi(t.slice(r,s.index))),language:e,tagged:!1}),n.push({tokens:Cn(tn(s[2])),language:s[1],tagged:!0}),r=s.index+s[0].length;n.push({tokens:Cn(Vi(t.slice(r))),language:e,tagged:!1});for(let s=0;s<n.length-1;s++)!n[s].tagged&&n[s+1].tagged?n[s+1].tokens.unshift(...Ud(n[s].tokens)):n[s].tagged&&!n[s+1].tagged&&n[s].tokens.push(...Vd(n[s+1].tokens));const i=[];for(const s of n){const o=qd(s.tokens);o&&i.push({plain:o,language:s.language})}return i}const Ba=/<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;function zd(t){return new RegExp(Ba).test(t)}function Md(t){const e=[];let n=0;for(const i of t.matchAll(Ba)){const s=t.slice(n,i.index).trim();s&&e.push({ssml:s}),e.push({placeholderId:i[1]}),n=i.index+i[0].length}const r=t.slice(n).trim();return r&&e.push({ssml:r}),e}const jd=["aside","audio","bibliography","cell","columnheader","details","endnotes","figure","footnote","image","landmarks","loa","loi","lot","lov","noteref","pagebreak","pullquote","row","rowheader","table","toc","video"],qa=["heading1","heading2","heading3","heading4","heading5","heading6","paragraph","blockquote","preformatted","pullquote","list","listItem","table","row","cell","columnheader","rowheader","audio","video","figure","image","math","abstract","acknowledgments","afterword","appendix","article","aside","bibliography","chapter","colophon","conclusion","dedication","endnotes","epigraph","epilogue","errata","example","footnote","foreword","glossary","index","introduction","notice","part","preface","prologue","qna","section","summary","tip"],Hd={footnote:{drops:["aside"],unconditional:!0},cover:{drops:["image"]},pullquote:{drops:["blockquote","aside"]},epigraph:{drops:["blockquote"]}},Wd=["noteref","pagebreak"],Gd=["audio","video","image","figure","math","table","cover"],Kd=["cell","rowheader"],Jd=["separator"];function Ua(t){const e=Or(t.text);return e?e.plain??(e.ssml?tn(e.ssml):""):""}function Xd(t){const e=new Map,n=new Map;let r=0,i;return t.forEach((s,o)=>{e.set(s,o+1);const a=s.children??[];if(r=Math.max(r,a.length),a.some(c=>c.role?.includes("columnheader"))){i=a.map(Ua);return}i&&a.forEach((c,l)=>{const u=c.role??[];if(!u.includes("cell")&&!u.includes("rowheader"))return;const h=i[l];h&&n.set(c,h)})}),{lines:t.length,columns:r,rowNumbers:e,cellHeaders:n}}const Yd=new Set(qa),Qd=new Set(Wd),Zd=new Set(Gd),Ar=new Set(Kd),ef=new Set(Jd);function lt(t,e,n,r){const i=n?`${e}.${n}`:void 0;if(i&&t.i18n.exists(i))return t.i18n.t(i,r);if(t.i18n.exists(e))return t.i18n.t(e,r)}function fe(t,e){return e==="ssml"?{ssml:zt(t),synthetic:!0}:{plain:t,synthetic:!0}}function ge(t,e,n,r){t.push(...r);for(let i=0;i<r.length;i++)e.push(n)}function Va(t,e,n,r,i,s,o){o?(i.some(a=>n.blockStarts.has(a))&&n.blockStarts.add(o),ge(t,e,s[0]??r,[o])):(t.push(...i),e.push(...s))}function Tr(t,e){return Ar.has(t)?!0:e.contextualize.has(t)}function tf(t,e,n){return e.some(r=>{const i=Hd[r];return i?.drops.includes(t)?i.unconditional||Tr(r,n):!1})}function zi(t,e,n,r,i,s,o,a){if(!Tr(i,r))return;if((r.i18n.exists(`${i}.block.start`)||r.i18n.exists(`${i}.block.end`))&&r.contextualizationShapes[i]!=="inline"){const l=s==="before"?`${i}.block.start`:`${i}.block.end`,u=lt(r,l,o,a);u&&ge(t,e,n,[fe(u,r.format)]);return}if(s==="before"){const l=lt(r,`${i}.inline`,o,a);if(l){const u=fe(l,r.format);if(Ar.has(i)&&(delete u.synthetic,r.language!=="none")){const h=typeof n.text=="object"?n.text.language:void 0;h&&(u.language=h)}ge(t,e,n,[u])}}}function Mi(t,e){return e.size>0&&t.some(n=>e.has(n))}function Rr(t,e){let n,r=!1;const i=[];for(const a of t){const c=e==="ssml"?a.ssml:a.plain;if(c&&(i.push(c),a.language!==void 0)){if(r&&a.language!==n)return;n=a.language,r=!0}}if(i.length===0)return;let s="";for(const a of i)a.length===1&&s.endsWith(a)||(s&&!Qt(a)&&(s+=" "),s+=a);const o=e==="ssml"?{ssml:s}:{plain:s};return n&&(o.language=n),t.some(a=>a.synthetic)&&(o.synthetic=!0),o}function nf(t,e){const n=Or(t.text),r=n?za(n,e.format,e.language):[];if(!e.contextualize.has("pagebreak"))return r;const i=e.i18n.exists("pagebreak.block.start")?"pagebreak.block.start":"pagebreak.inline",s=lt(e,i);if(s===void 0)return r;const o=fe(s,e.format);if(r.length===0)return[o];const a=Rr([o,...r],e.format);return a?(a.plain!==void 0&&(a.plain+="."),a.ssml!==void 0&&(a.ssml+="."),[a]):[o,...r]}function za(t,e,n){if(e==="plain"&&n!=="block-level"&&n!=="none"&&t.ssml&&$a(t.ssml))return _a(t.ssml,t.language).map(i=>{const s={plain:i.plain};return i.language&&(s.language=i.language),s});const r={};return t.language&&(r.language=t.language),e==="ssml"?r.ssml=t.ssml??zt(t.plain??""):r.plain=t.plain??tn(t.ssml??""),(n==="block-level"||n==="none")&&(r.ssml&&(r.ssml=Pa(r.ssml)),n==="none"&&delete r.language),[r]}function rf(t){return(t.role??[]).some(e=>Qd.has(e))}function sf(t,e,n,r,i,s){const o=typeof t.text=="object"?t.text.language:void 0,a=new Map((t.children??[]).map(d=>[d.id,d])),c=[],l=[],u=[];for(const d of Md(e)){if(d.placeholderId!==void 0){const p=a.get(d.placeholderId);if(!p)continue;i.inlineContextualization||!rf(p)?Ma(p,c,l,i,s):u.push(p);continue}if(!d.ssml)continue;if(i.format==="plain"&&i.language!=="block-level"&&i.language!=="none"&&$a(d.ssml)){for(const p of _a(d.ssml,o)){const m={plain:p.plain};p.language&&(m.language=p.language),c.push(m),l.push(t)}continue}const g={};o&&(g.language=o),i.format==="ssml"?g.ssml=d.ssml:g.plain=tn(d.ssml),(i.language==="block-level"||i.language==="none")&&(g.ssml&&(g.ssml=Pa(g.ssml)),i.language==="none"&&delete g.language),c.push(g),l.push(t)}const h=c.length>1?Rr(c,i.format):void 0;return Va(n,r,i,t,c,l,h),u}function ji(t,e,n,r){const i=`${e}.parts.${n}`;return t.i18n.exists(i,{count:r})?t.i18n.t(i,{count:r}):String(r)}function af(t){return t.description===void 0?{variantKey:"unlabelled"}:{variantKey:"labelled",params:{description:t.description}}}function Hi(t,e){const n=e.tableCellHeaders.get(t);return{variantKey:n!==void 0?"withHeader":"withoutHeader",params:{header:n??"",value:Ua(t)}}}const of={table:(t,e)=>{const n=(t.children??[]).filter(i=>i.role?.includes("row")),r=Xd(n);for(const[i,s]of r.rowNumbers)e.tableRowNumbers.set(i,s);for(const[i,s]of r.cellHeaders)e.tableCellHeaders.set(i,s);return{params:{lines:ji(e,"table","lines",r.lines),columns:ji(e,"table","columns",r.columns)}}},row:(t,e)=>({params:{count:String(e.tableRowNumbers.get(t)??"")}}),cell:Hi,rowheader:Hi};function Wi(t,e,n){const r=af(e);let i=r.variantKey,s=r.params;const o=of[t]?.(e,n);o&&(o.variantKey&&(i=o.variantKey),s={...s,...o.params});const a=n.contextualizationParams?.(t,e);return a&&(s={...s,...a}),{variantKey:i,params:s}}function Ma(t,e,n,r,i){const s=t.role??[];if(Mi(s,r.skip))return;const o=s.some(d=>Yd.has(d)),a=o&&!i,c=e.length,l=s.filter(d=>d!=="footnote"&&d!=="pagebreak"&&!tf(d,s,r)),u=s.some(d=>Zd.has(d)&&r.contextualize.has(d)),h=s.includes("table")&&t.description!==void 0&&!u;h&&ge(e,n,t,[fe(t.description,r.format)]);for(const d of l){if(d==="figure"&&t.description===void 0)continue;const{variantKey:g,params:p}=Wi(d,t,r);zi(e,n,t,r,d,"before",g,p)}if(s.includes("noteref"))for(const d of t.children??[]){const g=d.role??[];if(!Mi(g,r.skip))if(g.includes("footnote")){const p=[],m=[];he([d],p,m,r,i);const b=r.contextualize.has("footnote"),x=r.i18n.exists("footnote.block.start")||r.i18n.exists("footnote.block.end"),A=b?lt(r,x?"footnote.block.start":"footnote.inline"):void 0,S=b&&(A!==void 0||x),w=[],T=[];if(A!==void 0&&(w.push(fe(A,r.format)),T.push(d)),w.push(...p),T.push(...m),S&&x){const L=lt(r,"footnote.block.end");L!==void 0&&(w.push(fe(L,r.format)),T.push(d))}const F=S&&w.length>1?Rr(w,r.format):void 0;Va(e,n,r,d,w,T,F)}else he([d],e,n,r,i)}else if(!s.some(d=>ef.has(d))){const d=typeof t.text=="object"?t.text.ssml:void 0;if(d&&zd(d)){const g=sf(t,d,e,n,r,i);if(g.length>0){const p=i||o&&e.length>c;he(g,e,n,r,p)}}else if(s.includes("pagebreak")){if(ge(e,n,t,nf(t,r)),t.children){const g=i||o&&e.length>c;he(t.children,e,n,r,g)}}else{const p=s.some(m=>Ar.has(m)&&Tr(m,r))?void 0:Or(t.text);if(p&&ge(e,n,t,za(p,r.format,r.language)),t.children){const m=i||o&&e.length>c;he(t.children,e,n,r,m)}}}a&&e.length>c&&r.blockStarts.add(e[c]),t.description!==void 0&&!u&&!h&&ge(e,n,t,[fe(t.description,r.format)]);for(const d of l){if(d==="figure"&&t.description===void 0)continue;const{variantKey:g,params:p}=Wi(d,t,r);zi(e,n,t,r,d,"after",g,p)}}function he(t,e,n,r,i){t.forEach((s,o)=>Ma(s,e,n,r,o===0?i:!1))}function lf(t,e){const n=z.createInstance();return n.init({lng:t,resources:{[t]:{translation:e}},interpolation:{escapeValue:!1}}),n}function ja(t,e){if(typeof e=="string"||typeof t!="object")return e;const n={...t};for(const r of Object.keys(e))n[r]=ja(t[r],e[r]);return n}function cf(t,e){if(!e)return t;const n={...t};for(const r of Object.keys(e))n[r]=ja(t[r],e[r]);return n}async function Ha(t){const e=t.contextualizationLocale??"en",n=cf(await Id(e),t.contextualization?.contextualizations);return{contextualizations:n,i18n:lf(e,n),skip:new Set(t.skip??[]),contextualize:new Set(t.contextualize??[]),contextualizationShapes:t.contextualization?.shapes??{},contextualizationParams:t.contextualization?.params,format:t.format??"plain",inlineContextualization:t.inlineContextualization??!1,language:t.language??"block-level",blockStarts:new Set,tableRowNumbers:new Map,tableCellHeaders:new Map}}async function uf(t,e){const n=[],r=[];return he(t,n,r,await Ha(e),!1),Wa(n,r,Nr(t))}async function hf(t,e){const n=[],r=[],i=await Ha(e);he(t,n,r,i,!1);const s=n.map(o=>i.blockStarts.has(o));return{utterances:Wa(n,r,Nr(t)),sources:r,blockStarts:s}}function Nr(t,e=[],n=new Map){for(const r of t)n.set(r,e),r.children&&Nr(r.children,[r,...e],n);return n}function Wa(t,e,n){return t.map((r,i)=>{const s=e[i];let o=tr(s);if(!o&&s){for(const a of n.get(s)??[])if(o=tr(a),o)break}return o?{...r,locate:o}:r})}class df{engine;contentQueue=[];events=new Jt;navigatorState="idle";pendingAdvanceTimeout=null;_defaults;_preferences;_settings;_preferencesEditor=null;contextualizationOverrides;source;contentSources=[];contentBlockStarts=[];pendingResumeIndex=null;pendingResumeState=null;pendingAutoPauseIndex=null;constructor(e,n={}){this.engine=e,this._defaults=new Sa(n.defaults),this._preferences=new Ue(n.preferences),this._settings=new Kn(this._preferences,this._defaults),this.contextualizationOverrides=n.contextualizationOverrides,this.setupEngineListeners(),this.applyEngineParameters(),this.initializeEngine()}applyEngineParameters(){this.engine.setRate(this._settings.rate),this.engine.setPitch(this._settings.pitch),this.engine.setVolume(this._settings.volume)}async initializeEngine(){try{await this.engine.initialize?.()}catch(e){console.warn("Failed to initialize speech engine:",e)}}setupEngineListeners(){this.engine.on("start",()=>{this.setNavigatorState("playing"),this.emitEvent({type:"start"})}),this.engine.on("end",()=>{const e=this.engine.getCurrentUtteranceIndex(),n=this.engine.getUtteranceCount();if(e<n-1){const r=this._settings.autoPause==="utterance"||this.contentBlockStarts[e+1]===!0;this._settings.autoPause!=="none"&&r?(this.pendingAutoPauseIndex=e+1,this.setNavigatorState("paused"),this.emitEvent({type:"pause"})):this.pendingAdvanceTimeout=setTimeout(()=>{this.pendingAdvanceTimeout=null,this.engine.speak(e+1)},this._settings.pauseDuration)}else this.engine.setCurrentUtteranceIndex(0),this.setNavigatorState("idle");this.emitEvent({type:"end"})}),this.engine.on("pause",()=>{this.setNavigatorState("paused"),this.emitEvent({type:"pause"})}),this.engine.on("resume",()=>{this.setNavigatorState("playing"),this.emitEvent({type:"resume"})}),this.engine.on("stop",()=>{this.setNavigatorState("idle"),this.emitEvent({type:"stop"})}),this.engine.on("error",e=>{this.setNavigatorState("idle"),this.emitEvent(e)}),this.engine.on("ready",()=>{if(this.contentQueue.length===0)return;const e=this.pendingResumeIndex,n=this.pendingResumeState;if(this.pendingResumeIndex=null,this.pendingResumeState=null,this.navigatorState==="loading"){if(n==="playing"){this.setNavigatorState("playing"),this.engine.speak(e??0);return}if(n==="paused"){const r=e??0;r>0?this.engine.setCurrentUtteranceIndex(r,()=>this.setNavigatorState("paused")):this.setNavigatorState("paused");return}this.setNavigatorState("ready"),this.emitEvent({type:"ready"})}}),this.engine.on("boundary",e=>{this.emitEvent(e)}),this.engine.on("mark",e=>{this.emitEvent(e)}),this.engine.on("voiceschanged",()=>{this.emitEvent({type:"voiceschanged"})}),this.engine.on("languagefallback",e=>{this.emitEvent(e)}),this.engine.on("enginefallback",e=>{this.emitEvent(e)}),this.engine.on("enginerecovered",e=>{this.emitEvent(e)})}setNavigatorState(e){this.navigatorState=e}async getVoices(){return this.engine.getAvailableVoices()}setVoice(e){this.engine.setVoice(e)}getCurrentVoice(){return this.engine.getCurrentVoice()}setSpeakInContentLanguage(e){this.engine.setSpeakInContentLanguage(e)}getSpeakInContentLanguage(){return this.engine.getSpeakInContentLanguage()}loadContent(e){if(this.source)throw new Error("loadContent() cannot be used after loadGndContent() — the two are exclusive. Create a new navigator instance to switch content sources.");this.setContentQueue(e)}async loadGndContent(e){this.source=e,await this.reextract()}setContentQueue(e,n=null,r=null){this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,(this.navigatorState==="playing"||this.navigatorState==="paused")&&this.engine.stop();const i=Array.isArray(e)?e:[e];this.contentQueue=[...i],this.pendingResumeIndex=n,this.pendingResumeState=r,this.setNavigatorState("loading"),this.emitEvent({type:"loading"}),this.engine.loadUtterances(i,n??void 0),this.emitContentChangeEvent({content:i})}async reextract(){if(!this.source)return;const e=this.navigatorState==="playing"||this.navigatorState==="paused"?this.navigatorState:null,n=this.contentSources,r=this.getCurrentUtteranceIndex(),{utterances:i,sources:s,blockStarts:o}=await hf(this.source,{format:this._settings.format,inlineContextualization:this._settings.inlineContextualization,skip:this._settings.skip,contextualize:this._settings.contextualize,contextualization:{contextualizations:this.contextualizationOverrides?.contextualizations,shapes:id(this._settings.verbosity,this.contextualizationOverrides?.shapes),params:this.contextualizationOverrides?.params},language:this._settings.language});this.contentSources=s,this.contentBlockStarts=o;const a=e?this.resolveResumeIndex(n,r,s):null;this.setContentQueue(i,a,e)}resolveResumeIndex(e,n,r){for(let i=Math.min(n,e.length-1);i>=0;i--){const s=e[i];if(s===void 0)continue;const o=r.indexOf(s);if(o!==-1)return o}return null}getCurrentContent(){const e=this.getCurrentUtteranceIndex();return e<this.contentQueue.length?this.contentQueue[e]:null}getContentQueue(){return[...this.contentQueue]}getCurrentUtteranceIndex(){return this.engine.getCurrentUtteranceIndex()}play(){if(this.navigatorState==="paused")if(this.setNavigatorState("playing"),this.pendingAutoPauseIndex!==null){const e=this.pendingAutoPauseIndex;this.pendingAutoPauseIndex=null,this.engine.speak(e)}else this.engine.resume();else if(this.navigatorState==="ready"||this.navigatorState==="idle")this.setNavigatorState("playing"),this.engine.speak();else if(this.navigatorState==="playing")return}pause(){this.navigatorState==="playing"&&(this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,this.setNavigatorState("paused"),this.engine.pause())}stop(){this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,this.setNavigatorState("idle"),this.engine.stop(),this.emitEvent({type:"stop"})}clearPendingAdvance(){this.pendingAdvanceTimeout!==null&&(clearTimeout(this.pendingAdvanceTimeout),this.pendingAdvanceTimeout=null)}skipToPosition(e,n=!1){const r=this.getCurrentUtteranceIndex();return e<0||e>=this.contentQueue.length?!1:(e===r||(this.clearPendingAdvance(),this.navigatorState==="paused"&&!n?(this.pendingAutoPauseIndex!==null&&(this.pendingAutoPauseIndex=e),this.engine.setCurrentUtteranceIndex(e,i=>{i&&this.emitEvent({type:"skip",detail:{position:e}})})):(this.pendingAutoPauseIndex=null,this.setNavigatorState("playing"),this.engine.speak(e))),!0)}next(e=!1){const n=this.getCurrentUtteranceIndex();return this.skipToPosition(n+1,e)}previous(e=!1){const n=this.getCurrentUtteranceIndex();return this.skipToPosition(n-1,e)}jumpTo(e,n=!1){return this.skipToPosition(e,n)}getState(){return this.navigatorState}on(e,n){return this.events.on(e,n)}emitEvent(e){this.events.emit(e.type,e)}emitContentChangeEvent(e){this.events.emit("contentchange",{type:"contentchange",detail:e})}get settings(){return this._settings}get preferencesEditor(){return this._preferencesEditor===null&&(this._preferencesEditor=new Wn(this._preferences,this.settings)),this._preferencesEditor}async submitPreferences(e){!this.source&&Ai.some(n=>e[n]!==void 0)&&console.warn("submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."),this._preferences=this._preferences.merging(e),await this.applyPreferences()}async applyPreferences(){const e=this._settings;this._settings=new Kn(this._preferences,this._defaults),this.applyEngineParameters(),this._preferencesEditor!==null&&(this._preferencesEditor=new Wn(this._preferences,this._settings)),Ai.some(n=>!this.sameSettingValue(e[n],this._settings[n]))&&await this.reextract()}sameSettingValue(e,n){return Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every(r=>n.includes(r)):e===n}async destroy(){this.clearPendingAdvance(),this.events.clear(),await this.engine.destroy()}}const ff=["heading1","heading2","heading3","heading4","heading5","heading6"],Gi={"doc-abstract":"abstract","doc-acknowledgments":"acknowledgments","doc-afterword":"afterword","doc-appendix":"appendix",article:"article","doc-backlink":"backlink","doc-biblioentry":"listItem","doc-bibliography":"bibliography","doc-biblioref":"biblioref",blockquote:"blockquote",caption:"caption",cell:"cell","doc-chapter":"chapter","doc-colophon":"colophon",columnheader:"columnheader",complementary:"complementary","doc-conclusion":"conclusion","doc-cover":"cover","doc-credit":"credit","doc-credits":"credits","doc-dedication":"dedication",definition:"definition","doc-endnote":"footnote","doc-endnotes":"endnotes","doc-epigraph":"epigraph","doc-epilogue":"epilogue","doc-errata":"errata","doc-example":"example",figure:"figure","doc-footnote":"footnote","doc-foreword":"foreword","doc-glossary":"glossary","doc-glossref":"glossref",img:"image",image:"image","doc-index":"index","doc-introduction":"introduction",list:"list",listitem:"listItem",main:"main",math:"math",navigation:"navigation","doc-noteref":"noteref","doc-notice":"notice","doc-pagebreak":"pagebreak","doc-pagelist":"pagelist",paragraph:"paragraph","doc-part":"part","doc-preface":"preface","doc-prologue":"prologue","doc-pullquote":"pullquote",grid:"table",gridcell:"cell",presentation:"presentation",none:"presentation","doc-qna":"qna",qna:"qna",region:"region",row:"row",rowheader:"rowheader",separator:"separator","doc-subtitle":"subtitle",table:"table",term:"term","doc-tip":"tip","doc-toc":"toc"},gf={abstract:"abstract",acknowledgments:"acknowledgments",afterword:"afterword",appendix:"appendix",aside:"aside",backlink:"backlink",biblioentry:"listItem",bibliography:"bibliography",biblioref:"biblioref","table-cell":"cell",chapter:"chapter",colophon:"colophon",conclusion:"conclusion",cover:"cover",credit:"credit",credits:"credits",dedication:"dedication",glossdef:"definition",endnote:"footnote",endnotes:"endnotes",rearnote:"footnote",rearnotes:"endnotes",epigraph:"epigraph",epilogue:"epilogue",errata:"errata",example:"example",figure:"figure",footnote:"footnote",foreword:"foreword",glossary:"glossary",glossref:"glossref",index:"index",introduction:"introduction",landmarks:"landmarks",list:"list","list-item":"listItem",loa:"loa",loi:"loi",lot:"lot",lov:"lov",noteref:"noteref",notice:"notice",pagebreak:"pagebreak","page-list":"pagelist",pagelist:"pagelist",part:"part",preface:"preface",prologue:"prologue",pullquote:"pullquote",qna:"qna","table-row":"row",subtitle:"subtitle",table:"table",glossterm:"term",tip:"tip",toc:"toc"},pf={article:"article",aside:"aside",audio:"audio",blockquote:"blockquote",caption:"caption",figcaption:"caption",td:"cell",dd:"definition",details:"details",figure:"figure",header:"header",h1:"heading1",h2:"heading2",h3:"heading3",h4:"heading4",h5:"heading5",h6:"heading6",img:"image",ul:"list",ol:"list",li:"listItem",main:"main",math:"math",nav:"navigation",p:"paragraph",pre:"preformatted",tr:"row",section:"section",hr:"separator",summary:"summary",table:"table",dfn:"term",dt:"term",video:"video",svg:"image"},mf=new Set(["table","tr","td","th"]),yf=new Set(["table","row","cell","columnheader","rowheader"]);function bf(t){const e=t.getAttribute("role");if(!e)return!1;const n=e.split(/\s+/).filter(Boolean);return n.includes("presentation")||n.includes("none")}function Sf(t){for(let e=t.parentElement;e;e=e.parentElement)if(bf(e))return!0;return!1}function vf(t,e,n){return mf.has(e)||n.some(r=>yf.has(r))}function Tt(t,e){const n=t.getAttribute("role");return n?n.split(/\s+/).filter(Boolean).includes(e):!1}function wf(t){return t.tagName.toLowerCase()==="table"||Tt(t,"table")||Tt(t,"grid")||Tt(t,"treegrid")}function xf(t){return t.tagName.toLowerCase()==="tr"||Tt(t,"row")}function Ef(t){let e=null;for(let r=t.parentElement;r;r=r.parentElement)if(wf(r)){e=r;break}return e?e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>xf(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}).nextNode()===t:!1}function Ga(t){const e=[];let n=!1;const r=t.getAttribute("role");if(r)for(const s of r.split(/\s+/).filter(Boolean))if((s==="presentation"||s==="none")&&(n=!0),s==="heading"){let o=2;const a=parseInt(t.getAttribute("aria-level")??"",10);Number.isFinite(a)&&a>=1&&(o=Math.min(a,6)),e.push(ff[o-1])}else Gi[s]&&e.push(Gi[s]);const i=t.getAttribute("epub:type");if(i)for(const s of i.split(/\s+/).filter(Boolean)){const o=gf[s];o&&e.push(o)}return{attrRoles:e,presentational:n}}function Ka(t){const{attrRoles:e,presentational:n}=Ga(t);return e.length>0||n}function Rt(t){const e=[],n=o=>{e.includes(o)||e.push(o)},{attrRoles:r,presentational:i}=Ga(t),s=t.tagName.toLowerCase();if(i)return["presentation"];if(vf(t,s,r)&&Sf(t))return["presentation"];if(s==="body")n("body");else if(s==="th")switch(t.getAttribute("scope")){case"col":n("columnheader");break;case"row":n("rowheader");break;default:{const o=t.parentElement;o&&Ef(o)?n("columnheader"):t.previousElementSibling===null?n("rowheader"):n("cell")}}else{const o=pf[s];o&&n(o)}for(const o of r)n(o);return e}function Ki(t){return!!(t.getAttribute("aria-hidden")==="true"||t.hasAttribute("hidden"))}function Cf(t){let e="";const n=r=>{r.nodeType===3&&(e+=r.nodeValue??"");for(let i=r.firstChild;i;i=i.nextSibling)n(i)};return n(t),e}function nn(t){return Ve(Cf(t),!0).trim()}function nr(t){let e="";const n=(r,i)=>{if(r.nodeType===3){e+=r.nodeValue??"";return}if(!(r.nodeType===1&&!i&&Ka(r)))for(let s=r.firstChild;s;s=s.nextSibling)n(s,!1)};return n(t,!0),e}function Ji(t){return Ve(nr(t),!0).trim()}function kf(t){if(Ki(t))return[null,!1];const e=(t.getAttribute("aria-labelledby")??"").trim();if(e){const s=[...new Set(e.split(/\s+/).filter(Boolean))],o=t.ownerDocument,a=s.map(c=>o.getElementById(c)).filter(c=>c!==null);if(a.length>0){let c="";a.forEach((u,h)=>{if(Ki(u))return;const d=u.getAttribute("aria-label");c+=d||nr(u),h<a.length-1&&(c+=" ")});const l=Ve(c,!0).trim();if(l!=="")return[{language:"",plain:l},!0]}}const n=(t.getAttribute("aria-label")??"").trim();if(n)return[{language:"",plain:n},!0];const r=(t.getAttribute("aria-describedby")??"").trim();if(r){const o=[...new Set(r.split(/\s+/).filter(Boolean))].map(a=>t.ownerDocument.getElementById(a)).filter(a=>a!==null);if(o.length>0){const a=o.map(l=>nr(l)).join(" "),c=Ve(a,!0).trim();if(c!=="")return[{language:"",plain:c},!0]}}const i=t.tagName.toLowerCase();if(i==="img"){const s=(t.getAttribute("alt")??"").trim();if(s)return[{language:"",plain:s},!0];const o=(t.getAttribute("title")??"").trim();if(o)return[{language:"",plain:o},!0]}else if(i==="svg"){const s=t.querySelector(":scope > title");if(s){const o=nn(s);if(o)return[{language:"",plain:o},!0]}}else if(i==="math"){const s=(t.getAttribute("alttext")??"").trim();if(s)return[{language:"",plain:s},!0]}return[null,!0]}const Of={em:["emphasis"],b:["emphasis"],i:["emphasis",{level:"reduced"}],strong:["emphasis",{level:"strong"}],br:["break"]};function Af(t){return Of[t]??["",void 0]}const Tf=new Set(["script","style","template","noscript","textarea","select","datalist","iframe","rt","rp","rtc"]),Rf=["math","separator"];function rr(t){return t.role?.some(e=>Rf.includes(e))?!1:!t.audioref&&!t.imgref&&!t.textref&&!t.videoref&&(!t.text||dt(t.text))&&!(t.children&&t.children.length>0)&&!t.description}function Nf(t){return!t.audioref&&!t.imgref&&!t.textref&&!t.videoref&&(!t.text||dt(t.text))&&!!(t.children&&t.children.length>0)&&!(t.role&&t.role.length>0)&&!t.id}function Df(t){return!(t.role&&t.role.length>0)&&!t.id&&!t.textref&&!t.imgref&&!t.audioref&&!t.videoref}class Ct{el;object={};children=[];noText=!1;finalize(){const e=this.object,n=[];for(const r of this.children){const i=r.finalize();if(!rr(i)){if(Nf(i)){n.push(...i.children??[]);continue}n.push(i)}}if(n.length>0&&(e.children=n),e.role?.length&&e.children?.length===1&&!e.role.includes("presentation")){const r=e.children[0];r.role?.length&&e.role.every(i=>r.role.includes(i))&&delete e.role}if((!e.text||dt(e.text))&&e.children?.length===1){const r=e.children[0];Df(r)&&(r.text&&(e.text=r.text),e.children=r.children)}return e}}function ir(t){const e={};t.id&&(e.id=t.id),t.textref&&(e.textref=t.textref),t.imgref&&(e.imgref=t.imgref),t.audioref&&(e.audioref=t.audioref),t.videoref&&(e.videoref=t.videoref);const n=kd(t.text);return n!==void 0&&(e.text=n),t.role&&t.role.length>0&&(e.role=t.role),t.children&&t.children.length>0&&(e.children=t.children.map(ir)),t.description&&(e.description=t.description),e}function Ja(t){const e={};return t.id&&(e.id=t.id),t.textref&&(e.textref=t.textref),t.imgref&&(e.imgref=t.imgref),t.audioref&&(e.audioref=t.audioref),t.videoref&&(e.videoref=t.videoref),t.role&&(e.role=t.role),t.description&&(e.description=t.description),typeof t.text=="string"?e.text={plain:t.text,ssml:"",language:""}:t.text&&(e.text={plain:t.text.plain??"",ssml:t.text.ssml??"",language:t.text.language}),t.children&&(e.children=t.children.map(Ja)),e}const Ff=1;function Xi(t){for(let e=t;e;e=e.parentElement){const n=e.getAttribute("xml:lang");if(n)return n;const r=e.getAttribute("lang");if(r)return r}return""}function If(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType===Ff)return!0;return!1}function Xa(t,e){for(let n=e;n;n=n.parentElement)if(n===t)return!0;return!1}const Pf=new Set(["object","base","font","tt","i","b","u","big","small","em","strong","dfn","code","samp","kbd","var","cite","abbr","time","acronym","mark","ruby","rt","rp","rtc","a","img","br","wbr","map","q","sub","sup","bdo","iframe","embed","span","input","select","textarea","label","button","optgroup","option","legend","datalist","keygen","output","progress","meter","area","param","source","track","summary","command","basefont","bgsound","menuitem","data","bdi","s","strike","nobr","rb"]);function Lf(t){return Pf.has(t)}function $f(t){const e=t.slice(0,500);return/<\?xml\b/.test(e)||/xmlns:epub=/.test(e)||/DOCTYPE\s+html\s+PUBLIC\s+"-\/\/W3C\/\/DTD XHTML/i.test(e)?"application/xhtml+xml":"text/html"}function Ya(t){return typeof t=="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE}const ct={NONE:"",DESCENDANT:" ",CHILD:" > "},$={id:"id",class:"class",tag:"tag",attribute:"attribute",nthchild:"nthchild",nthoftype:"nthoftype"};function _f(t,e){return Object.values(t).includes(e)}const Bf="CssSelectorGenerator";function Mt(t="unknown problem",...e){console.warn(`${Bf}: ${t}`,...e)}const qf={selectors:[$.id,$.class,$.tag,$.attribute],includeTag:!1,whitelist:[],blacklist:[],combineWithinSelector:!0,combineBetweenSelectors:!0,root:null,maxCombinations:Number.POSITIVE_INFINITY,maxCandidates:Number.POSITIVE_INFINITY,useScope:!1,ignoreGeneratedClassNames:!1};function Ye(t){return!!t}function Uf(t){return Array.isArray(t)?t.filter(e=>_f($,e)):[]}function Qa(t){return t instanceof RegExp}function Vf(t){return["string","function"].includes(typeof t)||Qa(t)}function Yi(t){return Array.isArray(t)?t.filter(Vf):[]}function zf(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&typeof t.nodeType=="number"}function Qi(t){const e=[Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE];return zf(t)&&e.includes(t.nodeType)}function Za(t,e){if(Qi(t))return t.contains(e)||Mt("element root mismatch","Provided root does not contain the element. This will most likely result in producing a fallback selector using element's real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will not work as intended."),t;const n=e.getRootNode({composed:!1});return Qi(n)?(n.nodeType!==Node.DOCUMENT_NODE&&Mt("shadow root inferred","You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."),n):Fr(e)}function kn(t){return typeof t=="number"?t:Number.POSITIVE_INFINITY}function Mf(t,e={}){const n=Object.assign(Object.assign({},qf),e);return{selectors:Uf(n.selectors),whitelist:Yi(n.whitelist),blacklist:Yi(n.blacklist),root:Za(n.root,t),combineWithinSelector:Ye(n.combineWithinSelector),combineBetweenSelectors:Ye(n.combineBetweenSelectors),includeTag:Ye(n.includeTag),maxCombinations:kn(n.maxCombinations),maxCandidates:kn(n.maxCandidates),useScope:Ye(n.useScope),maxResults:kn(n.maxResults),ignoreGeneratedClassNames:Ye(n.ignoreGeneratedClassNames)}}function ft(t=[]){const[e=[],...n]=t;return n.length===0?e:n.reduce((r,i)=>{const s=new Set(i);return r.filter(o=>s.has(o))},e)}function jf(t){return[].concat(...t)}function Hf(t){return t.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function jt(t){const e=t.map(n=>{if(Qa(n))return r=>n.test(r);if(typeof n=="function")return r=>{const i=n(r);return typeof i!="boolean"?(Mt("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",n),!1):i};if(typeof n=="string"){const r=new RegExp("^"+Hf(n)+"$");return i=>r.test(i)}return Mt("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",n),()=>!1});return n=>e.some(r=>r(n))}function Dr(t,e,n){const r=Za(n,t[0]).querySelectorAll(e);if(r.length!==t.length)return!1;const i=new Set(r);return t.every(s=>i.has(s))}function eo(t,e){e=e??Fr(t);const n=[];let r=t;for(;r&&r!==e;)Ya(r)&&n.push(r),r=r.parentNode;return n}function Wf(t,e){return ft(t.map(n=>eo(n,e)))}function Gf(t){return typeof t=="object"&&t!==null&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function Fr(t){return t.ownerDocument.querySelector(":root")}const to=", ",Kf=new RegExp(["^$","\\s"].join("|")),Jf=new RegExp(["^$"].join("|")),no=[$.nthoftype,$.tag,$.id,$.class,$.attribute,$.nthchild],Xf=jt(["class","id","ng-*"]);function Yf({name:t}){return`[${t}]`}function Qf({name:t,value:e}){return`[${t}='${e}']`}function Zf({nodeName:t,nodeValue:e},n){const r=n.tagName.toLowerCase();return["input","option"].includes(r)&&t==="value"||t==="src"&&e?.startsWith("data:")?!1:!Xf(t)}function eg({nodeName:t,nodeValue:e}){return{name:ze(t),value:ze(e??void 0)}}function ro(t,e){const n=Array.from(t.attributes).filter(r=>Zf(r,t)).map(eg);return[...n.map(Yf),...n.map(Qf)]}function tg(t,e){const n=t.map(r=>ro(r));return ft(n)}const ng=/^[a-z_-]{3,}$/i,rg=/[bcdfghjklmnpqrstvwxyz]{4,}/i;function ig(t){if(!ng.test(t)||t.includes("_")&&!t.includes("__")||/^(css|sc|jsx|emotion|makeStyles|MuiButton|MuiBox)-/i.test(t))return!1;const e=t.split(new RegExp("--|__|[-]|(?<=[a-z])(?=[A-Z])")).filter(n=>n.length>0);if(e.length===0||e.length===1&&e[0].length<4)return!1;for(const n of e)if(n.length<=2||rg.test(n))return!1;return!0}function io(t,e){var n;const r=((n=t.getAttribute("class"))!==null&&n!==void 0?n:"").trim().split(/\s+/).filter(s=>!Jf.test(s));let i=r;if(e?.ignoreGeneratedClassNames){const s=jt(e.whitelist);i=r.filter(o=>{const a=`.${ze(o)}`;return s(a)?!0:ig(o)})}return i.map(s=>`.${ze(s)}`)}function sg(t,e){const n=t.map(r=>io(r,e));return ft(n)}function so(t,e){var n;const r=(n=t.getAttribute("id"))!==null&&n!==void 0?n:"",i=`#${ze(r)}`,s=t.getRootNode({composed:!1});return!Kf.test(r)&&Dr([t],i,s)?[i]:[]}function ag(t,e){return t.length===0||t.length>1?[]:so(t[0])}function ao(t,e){const n=t.parentNode,r=n&&"children"in n?n.children:null;if(r){for(let i=0;i<r.length;i++)if(r[i]===t)return[`:nth-child(${String(i+1)})`]}return[]}function og(t,e){return ft(t.map(n=>ao(n)))}function oo(t,e){return[ze(t.tagName.toLowerCase())]}function lo(t,e){const n=[...new Set(jf(t.map(r=>oo(r))))];return n.length===0||n.length>1?[]:[n[0]]}function co(t,e){const n=lo([t])[0],r=t.parentNode,i=r&&"children"in r?r:null;if(i){const o=Array.from(i.children).filter(a=>a.tagName.toLowerCase()===n).indexOf(t);if(o>-1)return[`${n}:nth-of-type(${String(o+1)})`]}return[]}function lg(t,e){return ft(t.map(n=>co(n)))}function*uo(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){let n=0,r=ho(1);for(;r.length<=t.length&&n<e;){n+=1;const i=new Array(r.length);for(let s=0;s<r.length;s++)i[s]=t[r[s]];yield i,r=ug(r,t.length-1)}}function cg(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){return Array.from(uo(t,{maxResults:e}))}function ug(t=[],e=0){const n=t.length;if(n===0)return t;let r=n-1;for(;r>=0&&t[r]===e-(n-1-r);)r-=1;if(r<0)return ho(n+1);t[r]+=1;for(let i=r+1;i<n;i++)t[i]=t[i-1]+1;return t}function ho(t=1){const e=new Array(t);for(let n=0;n<t;n++)e[n]=n;return e}function*hg(t={}){const e=Object.entries(t);if(e.length===0)return;const n=[{index:e.length-1,partial:{}}];for(;n.length>0;){const r=n.pop();if(!r)break;const{index:i,partial:s}=r;if(i<0){yield s;continue}const[o,a]=e[i];for(let c=a.length-1;c>=0;c--)n.push({index:i-1,partial:Object.assign(Object.assign({},s),{[o]:a[c]})})}}const dg="3a".toUpperCase(),fg=/[ !"#$%&'()[\]{|}<>*+,./;=?@^`~\\]/;function ze(t=""){return CSS?CSS.escape(t):gg(t)}function gg(t=""){return t.split("").map(e=>e===":"?`\\${dg} `:fg.test(e)?`\\${e}`:escape(e).replace(/%/g,"\\")).join("")}const pg={tag:lo,id:ag,class:sg,attribute:tg,nthchild:og,nthoftype:lg},mg={tag:oo,id:so,class:io,attribute:ro,nthchild:ao,nthoftype:co};function yg(t,e,n){return mg[e](t,n)}function bg(t,e,n){const r=pg[e];return r(t,n)}function Sg(t=[],e,n){return t.filter(r=>n(r)||!e(r))}function vg(t=[],e){return t.sort((n,r)=>{const i=e(n),s=e(r);return i&&!s?-1:!i&&s?1:0})}function rn(){const t=new Map;let e;return(n,r)=>{if(n.length!==1)return e??(e=Zi(n,r));const[i]=n;let s=t.get(i);return s||(s=Zi(n,r),t.set(i,s)),s}}function*wg(t,e,n=rn()){const r=new Set,i=n(t,e);for(const s of kg(i,e))r.has(s)||(r.add(s),yield s)}function Zi(t,e){const{blacklist:n,whitelist:r,combineWithinSelector:i,maxCombinations:s}=e,o=jt(n),a=jt(r),c=(l,u)=>{const h=bg(t,u,e),d=Sg(h,o,a),g=vg(d,a);return l[u]=i?Array.from(uo(g,{maxResults:s})):g.map(p=>[p]),l};return xg(e).reduce(c,{})}function xg(t){const{selectors:e,includeTag:n}=t,r=[...e];return n&&!r.includes("tag")&&r.push("tag"),r}function Eg(t){return t.includes($.tag)||t.includes($.nthoftype)?[...t]:[...t,$.tag]}function Cg(t){const{selectors:e,combineBetweenSelectors:n,includeTag:r,maxCandidates:i}=t,s=n?cg(e,{maxResults:i}):e.map(o=>[o]);return r?s.map(Eg):s}function*kg(t,e){for(const n of Cg(e))yield*Og(n,t)}function*Og(t,e){const n={};for(const r of t){const i=e[r];i&&i.length>0&&(n[r]=i)}for(const r of hg(n))yield Tg(r)}function Ag(t,e){return e[t]?e[t].join(""):""}function Tg(t={}){const e=[...no];return t[$.tag]&&t[$.nthoftype]&&e.splice(e.indexOf($.tag),1),e.map(n=>Ag(n,t)).join("")}function Rg(t,e){return[...t.map(n=>e+ct.DESCENDANT+n),...t.map(n=>e+ct.CHILD+n)]}function*Ng(t,e){if(e==="")yield*t;else for(const n of t)yield*Rg([n],e)}function*Dg(t,e,n="",r,i=rn()){const s=wg(t,r,i);for(const o of Ng(s,n))Dr(t,o,e)&&(yield o)}function*Fg(t,e,n="",r,i=rn()){if(t.length===0)return null;const s=[t.length>1?t:[],...Wf(t,e).map(o=>[o])];for(const o of s)for(const a of Dg(o,e,n,r,i))yield{foundElements:o,selector:a}}function*Ig({elements:t,root:e,rootSelector:n="",options:r}){let i=e,s=n,o=!0;const a=rn();for(;o;){let c=!1;for(const l of Fg(t,i,s,r,a)){const{foundElements:u,selector:h}=l;if(c=!0,Dr(t,h,e))yield h;else{i=u[0],s=h;break}}c||(o=!1)}}function Pg(t){(t instanceof NodeList||t instanceof HTMLCollection)&&(t=Array.from(t));const e=(Array.isArray(t)?t:[t]).filter(Ya);return[...new Set(e)]}function Lg(t){return{value:t,include:!1}}function $g(t,e,n=ct.NONE){const r={};return e.forEach(i=>{Reflect.set(r,i,yg(t,i).map(Lg))}),{element:t,operator:n,selectors:r}}function _g({selectors:t,operator:e}){let n=[...no];t[$.tag]&&t[$.nthoftype]&&(n=n.filter(i=>i!==$.tag));let r="";return n.forEach(i=>{var s;((s=t[i])!==null&&s!==void 0?s:[]).forEach(({value:a,include:c})=>{c&&(r+=a)})}),e+r}function Bg(t,e){const n=eo(t,e).reverse(),r=Gf(e),i=n.map((o,a)=>{var c;const l=$g(o,[$.nthchild],r&&a===0?ct.NONE:ct.CHILD);return((c=l.selectors.nthchild)!==null&&c!==void 0?c:[]).forEach(u=>{u.include=!0}),l});return[r?"":e?":scope":":root",...i.map(_g)].join("")}function qg(t,e){return t.map(n=>Bg(n,e)).join(to)}var Ug=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n};function fo(t,e={}){const n=Object.assign(Object.assign({},e),{maxResults:1});return Vg(t,n).next().value}function*Vg(t,e={}){var n;const r=Pg(t),i=Mf(r[0],e),s=(n=i.root)!==null&&n!==void 0?n:Fr(r[0]);let o=0;for(const c of Ig({elements:r,options:i,root:s,rootSelector:""}))if(yield c,o++,o>=i.maxResults)return;if(r.length>1){const{maxResults:c}=e,l=Ug(e,["maxResults"]);if(yield r.map(u=>fo(u,l)).join(to),o++,o>=i.maxResults)return}const a=e.root!==void 0;yield qg(r,i.useScope||a?s:void 0)}function Ir(t,e){const n=t.getAttribute("id");return n?`#${CSS.escape(n)}`:fo(t,{root:e?.documentElement??void 0})??void 0}function go(t){if(t)return t.startsWith("#")?t:Ra(t)}const zg=3;function Mg(t,e){let n=0;for(const r of Array.from(t.childNodes)){if(r===e)return n;r.nodeType===zg&&n++}return n}function es(t,e,n,r){const i=t.parentElement;if(!i)return;const s=r&&i===r.el?r.selector:Ir(i,n);if(s)return{cssSelector:s,textNodeIndex:Mg(i,t),charOffset:e}}function jg(t,e,n){const r=es(...t.first,e,n);if(!r)return;const i=es(...t.last,e,n);return i?{start:r,end:i}:{start:r}}function Hg(t){const e=mh(t);return e.status===de.SUCCESS?e.fragment:void 0}function ts(t){if(t===!0)return e=>e.length>0;if(Array.isArray(t)&&t.length>0){const e=new Set(t);return n=>n.some(r=>e.has(r))}return null}function Wg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Gg(t){return Wg(t)?{predicate:ts(t.roles),domRange:!!t.domRange,textFragment:!!t.textFragment}:{predicate:ts(t),domRange:!1,textFragment:!1}}class Kg{claimed=new Set;counters=new Map;allocate(e,n){for(;;){const r=(this.counters.get(e)??0)+1;this.counters.set(e,r);const i=`${e}${r}`;if(!(n(i)||this.claimed.has(i)))return this.claimed.add(i),i}}claim(e){return this.claimed.has(e)?!1:(this.claimed.add(e),!0)}}function Jg(t,e,n){const r=[],i=(s,o)=>{const a=s.getAttribute("id");if(a&&!e.has(a)&&e.set(a,s),o=o||s.getAttribute("aria-hidden")==="true"||s.hasAttribute("hidden"),!o&&s.tagName.toLowerCase()==="a"&&Rt(s).includes("noteref")){const l=s.getAttribute("href")??"";l.startsWith("#")&&r.push({id:l.slice(1),ref:s})}for(let c=s.firstElementChild;c;c=c.nextElementSibling)i(c,o)};i(t,!1);for(const s of r){const o=e.get(s.id);o&&(Xa(o,s.ref)||n.add(o))}}function Xg(t,e,n,r){const i={role:r},s=(e.getAttribute("title")??"").trim();s?i.text={plain:s,ssml:"",language:""}:n&&(i.text={plain:n.plain??"",ssml:n.ssml??"",language:n.language});const o=!!(i.text&&!dt(i.text)),a=!t.xmlParsed&&(If(e)||o&&e.firstChild!==null);if(!o&&!a){const u=nn(e);u&&(i.text={plain:u,ssml:"",language:""})}const c=Ir(e,t.docRoot),l=go(c);return l&&(i.textref=l),t.placeholder(e,"pagebreak",i),a}function Yg(t,e,n){const r={role:n},i=nn(e);i&&(r.text={plain:i,ssml:"",language:""});const s=e.getAttribute("href")??"";let o=e.getAttribute("id")??"";if(!o&&s.startsWith("#")&&(o=s.slice(1)),s.startsWith("#")){const a=s.slice(1),c=t.ids.get(a);if(c&&!Xa(c,e)&&t.noterefDepth<3){const l=t.spawnChild(c);l.convert(c);const u=l.result();u.length>0&&(r.children=u.map(h=>{const d=Ja(h);return delete d.id,d}))}}!r.children&&s&&(r.children=[{textref:s}]),t.placeholder(e,"noteref",r,o||void 0)}function Qg(t,e,n,r){const i={};if(n.length>0&&(i.role=n),r)i.text={plain:r.plain??"",ssml:r.ssml??"",language:r.language};else{const o=nn(e);o&&(i.text={plain:o,ssml:"",language:""})}const s=e.getAttribute("href");s&&(i.textref=s),t.placeholder(e,n[0]??"link",i)}const Zg=3,ep=1,tp=new Set(["summary","dfn","span"]);function ns(t,e){return tp.has(t)&&e.length>0?!0:!Lf(t)}class Ht{xmlParsed;ids=new Map;suppressed=new Set;idAlloc=new Kg;noterefDepth=0;allowNode=null;selectorPredicate=null;domRangeEnabled=!1;textFragmentEnabled=!1;docRoot=null;root=new Ct;current=this.root;foldedCaptions=new Set;segments=[];textAcc="";currentCtx={lang:"",tag:""};flowEndsWithSpace=!0;pendingChildren=[];flowFirstNode=null;flowFirstOffset=0;flowLastNode=null;flowLastOffset=0;lastFlowRange=null;lastFlowText=null;constructor(e){this.xmlParsed=e}spawnChild(e,n=1){const r=new Ht(this.xmlParsed);return r.ids=this.ids,r.suppressed=this.suppressed,r.idAlloc=this.idAlloc,r.noterefDepth=this.noterefDepth+n,r.allowNode=e,r.docRoot=this.docRoot,r.selectorPredicate=this.selectorPredicate,r.domRangeEnabled=this.domRangeEnabled,r.textFragmentEnabled=this.textFragmentEnabled,r}prescan(e){Jg(e,this.ids,this.suppressed)}convert(e){this.prescan(e),this.walk(e)}convertChildren(e){this.prescan(e);for(let n=e.firstChild;n;n=n.nextSibling)this.walk(n);this.flushText()}result(){const e=this.root.finalize();return!e.children||e.children.length===0?rr(e)?[]:[ir(e)]:e.children.map(ir)}descend(e,n){const r=new Ct;r.el=e,r.noText=this.foldedCaptions.has(e)||(!Ka(e)||n.includes("caption"))&&this.current.noText,this.current.children.push(r),this.current=r}appendChild(e){e.noText=this.current.noText,this.current.children.push(e)}walk(e){if(e.nodeType===Zg){this.text(e);return}if(e.nodeType!==ep)return;const n=e,r=this.current,i=this.head(n);if(!i)for(let s=n.firstChild;s;s=s.nextSibling)this.walk(s);this.tail(n,i,r)}head(e){const n=e.tagName.toLowerCase();if(Tf.has(n)||this.suppressed.has(e)&&e!==this.allowNode)return!0;const[r,i]=kf(e);if(!i&&e!==this.allowNode)return!0;const s=Rt(e);if((n==="img"||n==="svg")&&(s.includes("presentation")||r===null&&e.hasAttribute("alt")&&e.getAttribute("alt").trim()===""))return!0;if(n==="br")return this.current.noText||(this.closeSegment(),this.segments.push({kind:"break"}),this.flowEndsWithSpace=!0),!0;if(s.includes("pagebreak"))return!Xg(this,e,r,s);if(n==="a"&&s.includes("noteref")&&e.getAttribute("href"))return Yg(this,e,s),!0;if(n==="a"&&e.getAttribute("href"))return Qg(this,e,s,r),!0;if(n==="img"){const c={role:s},l=e.getAttribute("src");return l&&(c.imgref=l),r&&(c.description=r.plain),this.placeholder(e,"image",c),!0}if(n==="audio"||n==="video"){const c={role:s};let l=e.getAttribute("src");if(!l){const u=e.querySelector(":scope > source[src]");u&&(l=u.getAttribute("src"))}return n==="audio"?l&&(c.audioref=l):l&&(c.videoref=l),r&&(c.description=r.plain),this.placeholder(e,n,c),!0}if(s.includes("image")||s.includes("math")){const c={role:s};return r&&(c.description=r.plain),this.placeholder(e,s.includes("math")?"math":"image",c),!0}if(!ns(n,s))return!1;this.flushText(),this.descend(e,s);const o=this.current.object;if(s.length>0&&(o.role=s),r)o.description=r.plain,s.includes("figure")&&(this.current.noText=!0);else if(s.includes("figure")){const c=this.implicitCaptionOf(e);if(c){const l=Ji(c);l&&(o.description=l,this.current.noText=!0)}}else if(s.includes("table")){const c=this.implicitCaptionOf(e);if(c){const l=Ji(c);l&&(o.description=l,this.foldedCaptions.add(c))}}const a=e.getAttribute("id");return a&&(o.id=a),!1}implicitCaptionOf(e){for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(Rt(n).includes("caption")&&!n.getAttribute("aria-labelledby"))return n;return null}tail(e,n,r){if(n)return;const i=e.tagName.toLowerCase(),s=Rt(e);ns(i,s)&&(this.flushText(),this.selectorPredicate?.(s)&&this.applyTextref(e),this.current=r)}applyTextref(e){const n=this.current.object,r=Ir(e,this.docRoot);if(n.textref=go(r),this.domRangeEnabled&&this.lastFlowRange){const i=r?{el:e,selector:r}:void 0,s=jg(this.lastFlowRange,this.docRoot,i);s&&(n.textref=Da(s))}if(this.textFragmentEnabled&&this.lastFlowRange&&this.docRoot){const i=this.docRoot.createRange();i.setStart(...this.lastFlowRange.first),i.setEnd(...this.lastFlowRange.last);const s=Hg(i);s&&(n.textref=`${n.textref??"#"}${Ia(s)}`)}}text(e){if(this.current.noText)return;const n=e.nodeValue??"";if(/^\s*$/.test(n)){(this.textAcc.length>0||this.segments.length>0)&&(this.textAcc+=Ve(n,this.flowEndsWithSpace),this.updateFlowSpace());return}const r=this.textContext(e);if(Od(r,this.currentCtx)||(this.closeSegment(),this.currentCtx=r),this.textAcc+=Ve(n,this.flowEndsWithSpace),this.updateFlowSpace(),this.domRangeEnabled||this.textFragmentEnabled){const i=e;this.flowFirstNode===null&&(this.flowFirstNode=i,this.flowFirstOffset=n.search(/\S/)),this.flowLastNode=i,this.flowLastOffset=n.length-(n.match(/\s+$/)?.[0].length??0)}}textContext(e){const n={lang:Xi(e.parentElement),tag:""};for(let r=e.parentElement;r&&r!==this.current.el;r=r.parentElement){const[i,s]=Af(r.tagName.toLowerCase());if(i&&i!=="break"){n.tag=i,n.attrs=s;break}}return n}updateFlowSpace(){this.textAcc.length>0&&(this.flowEndsWithSpace=this.textAcc.endsWith(" "))}closeSegment(){this.textAcc.length!==0&&(this.segments.push({kind:"text",text:this.textAcc,ctx:this.currentCtx}),this.textAcc="")}resetFlow(){this.segments=[],this.textAcc="",this.currentCtx={lang:"",tag:""},this.flowEndsWithSpace=!0,this.pendingChildren=[],this.flowFirstNode=null,this.flowFirstOffset=0,this.flowLastNode=null,this.flowLastOffset=0}placeholder(e,n,r,i){if(rr(r))return;const s=new Ct;if(s.el=e,s.object=r,this.current.noText){this.appendChild(s);return}this.closeSegment(),this.pendingChildren.push(s),this.segments.push({kind:"placeholder",tag:n,child:s,candidateID:i??e.getAttribute("id")??void 0}),this.flowEndsWithSpace=!1}flushText(){this.closeSegment();let e=this.segments;const n=this.pendingChildren,r=this.flowFirstNode,i=this.flowFirstOffset,s=this.flowLastNode,o=this.flowLastOffset;if(this.resetFlow(),this.lastFlowRange=null,this.lastFlowText=null,e.length===0)return;for(;e.length>0;){const S=e[0];if(S.kind==="break"){e=e.slice(1);continue}if(S.kind==="text"){const w=S.text.replace(/^\s+/,"");if(w===""){e=e.slice(1);continue}e=[{...S,text:w},...e.slice(1)]}break}for(;e.length>0;){const S=e[e.length-1];if(S.kind==="break"){e=e.slice(0,-1);continue}if(S.kind==="text"){const w=S.text.replace(/\s+$/,"");if(w===""){e=e.slice(0,-1);continue}e=[...e.slice(0,-1),{...S,text:w}]}break}if(!e.some(S=>S.kind==="text"&&S.text.trim()!=="")){for(const S of n)this.appendChild(S);return}const c=[];for(const S of e)if(S.kind==="text"&&S.text.trim()!==""){const w=S.ctx.lang;c.includes(w)||c.push(w)}let l=Xi(this.current.el??null);c.length===1&&c[0]!==""&&(l=c[0]);let u=!1;for(const S of e)if(S.kind!=="text"||S.ctx.tag!==""||S.ctx.lang!==l){u=!0;break}if(u&&l===""&&(l="en"),u)for(const S of e){if(S.kind!=="placeholder")continue;let w=S.candidateID;(!w||!this.idAlloc.claim(w))&&(w=this.idAlloc.allocate(S.tag,T=>this.ids.has(T))),S.child.object.id=w}let h="",d=!1,g=!1,p=!1,m=!1;for(const S of e)if(S.kind==="text"){const w=S.text.startsWith(" "),T=S.text.replace(/^ +| +$/g,"");if(T===""){m=!0;continue}let F=!1;if(h.length>0){const L=d||m||w;g?F=!0:p?F=L&&!Qt(T):F=L}F&&(h+=" "),h+=T,d=S.text.endsWith(" "),g=!1,p=!1,m=!1}else S.kind==="break"?g=!0:S.kind==="placeholder"&&(p=!0);const b=e.some(S=>S.kind==="placeholder");this.lastFlowText=h.trim();const x={plain:u&&!b?"":h.trim(),ssml:"",language:l};if(u){let S="";for(const w of e)if(w.kind==="text"){let T=w.ctx.tag,F=w.ctx.attrs;if(w.ctx.lang!==l&&w.ctx.lang!==""&&(T="lang",F=void 0),T){S+=`<${T}`;for(const[L,X]of Object.entries(F??{}))S+=` ${L}="${En(X)}"`;w.ctx.lang!==l&&w.ctx.lang!==""&&(S+=` xml:lang="${En(w.ctx.lang)}"`),S+=`>${zt(w.text)}</${T}>`}else S+=zt(w.text)}else w.kind==="break"?S+="<break/>":w.kind==="placeholder"&&(S+=`<readium:${w.tag} id="${En(w.child.object.id)}" />`);x.ssml=S}const A=new Ct;A.object={text:x};for(const S of n)A.children.push(S);this.appendChild(A),r&&s&&(this.lastFlowRange={first:[r,i],last:[s,o]})}}const np=/<body[\s>]/i;function po(t,e,n){const{predicate:r,domRange:i,textFragment:s}=Gg(n?.textrefs);if(typeof t!="string"){const u=e??(t.ownerDocument.contentType==="text/html"?"text/html":"application/xhtml+xml"),h=new Ht(u==="application/xhtml+xml");return h.selectorPredicate=r,h.domRangeEnabled=i,h.textFragmentEnabled=s,h.docRoot=t.ownerDocument,h.convert(t),h.result()}const o=e??$f(t),a=new DOMParser().parseFromString(t,o),c=new Ht(o==="application/xhtml+xml");c.selectorPredicate=r,c.textFragmentEnabled=s,c.docRoot=a;const l=a.querySelector("body");return l&&!np.test(t)?c.convertChildren(l):c.convert(l??a.documentElement),c.result()}function rp(t,e,n){return{guided:po(t,e,n)}}exports.BUILTIN_DECORATION_TYPES=ca;exports.BooleanPreference=va;exports.DecorationController=ma;exports.DecorationLayout=aa;exports.DecorationStyleType=R;exports.DecorationWidth=sa;exports.Decorator=la;exports.DirectCommsChannel=fa;exports.DirectCommsFrame=ga;exports.DirectCommsHost=pa;exports.EnumPreference=tt;exports.FallbackEngineProvider=ju;exports.FallbackSpeechEngine=Rs;exports.Locator=Sr;exports.LocatorLocations=ue;exports.LocatorText=br;exports.Preference=ht;exports.RangePreference=nt;exports.ReadiumSpeechDecorationController=ba;exports.ReadiumSpeechNavigator=df;exports.ReadiumSpeechProviderRegistry=td;exports.SpeechDefaults=Sa;exports.SpeechPreferences=Ue;exports.SpeechPreferencesEditor=Wn;exports.SpeechServerAudioDecodeError=gr;exports.SpeechServerEngine=As;exports.SpeechServerEngineProvider=Vu;exports.SpeechServerError=qe;exports.SpeechServerNetworkError=pr;exports.SpeechServerStallError=fr;exports.SpeechSettings=Kn;exports.StringArrayPreference=Hn;exports.WebSpeechEngine=Ln;exports.WebSpeechEngineProvider=ku;exports.WebSpeechVoiceManager=P;exports.blockLevelRoles=qa;exports.chineseVariantMap=Pe;exports.chunkPlainText=xs;exports.chunkSsmlText=Es;exports.contextualizationShapesAtVerbosity=ka;exports.contextualizedAtVerbosity=Ca;exports.createLocator=ya;exports.decodeCssSelectorFragment=Na;exports.decodeDomRangeFragment=Fa;exports.decodeTextref=tr;exports.decorationsEqual=ha;exports.defaultContextualizations=kr;exports.encodeCssSelectorFragment=Ra;exports.encodeDomRangeFragment=Da;exports.extractUtterances=uf;exports.isRecoverableFailure=Ts;exports.makeGnd=rp;exports.mapServerVoice=dr;exports.mimeTypeForFormat=Cs;exports.parseMarkup=po;exports.resolveDecorationForWire=jn;exports.selectBitrate=Os;exports.selectFormat=ks;exports.setupDecorations=ed;exports.shapeableRoles=rd;exports.skippableRoles=jd;exports.skippedAtVerbosity=Ea;exports.supportsDecorationStyle=ua;exports.toSpeechServerError=Fe;
|
|
50
|
+
`)}positionElement(e,n,r,i,s,o,a=0){const c=e.decoration?.style?.width,l=s;switch(c){case"viewport":{const u=Math.floor(n.inlineStart(l)/n.viewportInlineSize)*n.viewportInlineSize;n.applyPosition(i,u+n.inlineScrollOffset+a,n.blockStart(l)+n.blockScrollOffset,n.viewportInlineSize-2*a,n.blockSize(l),r);break}case"page":{const u=Math.floor(n.inlineStart(l)/n.pageInlineSize)*n.pageInlineSize;n.applyPosition(i,u+n.inlineScrollOffset+a,n.blockStart(l)+n.blockScrollOffset,n.pageInlineSize-2*a,n.blockSize(l),r);break}case"bounds":{n.applyPosition(i,n.inlineStart(o)+n.inlineScrollOffset,n.blockStart(l)+n.blockScrollOffset,n.inlineSize(o),n.blockSize(l),r);break}default:n.applyPosition(i,n.inlineStart(l)+n.inlineScrollOffset,n.blockStart(l)+n.blockScrollOffset,n.inlineSize(l),n.blockSize(l),r)}}computeOverlayRects(e,n,r,i){if(e.decoration?.style?.layout==="bounds")return[i?{left:r.left-i,right:r.right+i,top:r.top-i,bottom:r.bottom+i,width:r.width+i*2,height:r.height+i*2}:r];const s=e.decoration.style.type,o=s===R.Underline||s===R.Strikethrough,a=s===R.Strikethrough,c=o?Uh(e.range,["rt","rp"]):e.range;let l=Je(c,!0,n.isVertical,o?0:i);return l=l.sort((u,h)=>n.isVertical?(n.isVertLR?1:-1)*(u.left-h.left):u.top-h.top),l.map(u=>{let h=u;if(a){const d=n.blockSize(u)*.1,g=n.blockStart(u)+n.blockSize(u)/2-d/2;h=n.isVertical?{left:g,right:g+d,top:u.top,bottom:u.bottom,width:d,height:u.height}:{top:g,bottom:g+d,left:u.left,right:u.right,height:d,width:u.width}}return i&&o&&(h=n.isVertical?{...h,top:h.top-i,bottom:h.bottom+i,height:h.height+i*2}:{...h,left:h.left-i,right:h.right+i,width:h.width+i*2}),h})}repositionItem(e,n){if(!e.container)return!0;const r=e.decoration.style;if(r.type!==R.Template){const u=r.type??R.Highlight;if(u===R.TextColor||u===R.Mask)return!0}const i=1/this.effectiveZoom(),s=r.expand??0,o=e.range.getBoundingClientRect(),a=(()=>{if(r.type!==R.Outline)return 0;const u=r.width;return u==="page"||u==="viewport"?3:0})(),c=this.computeOverlayRects(e,n,o,s),l=Array.from(e.container.children);return l.length!==c.length?!1:(l.forEach((u,h)=>this.positionElement(e,n,i,u,c[h],o,a)),!0)}layout(e){if(this.experimentalHighlights&&!this.notTextFlag?.has(e.id))return this.experimentalLayout(e);const n=this.wnd.document.createElement("div");n.setAttribute("id",e.id),n.dataset.highlightId=e.decoration.id,n.style.setProperty("pointer-events","none");const r=Ee(this.wnd),i=1/this.effectiveZoom(),s=e.decoration.style.expand??0,o=e.range.getBoundingClientRect(),a=e.decoration.style,c=(()=>{if(a.type!==R.Outline)return 0;const h=a.width;return h==="page"||h==="viewport"?3:0})();let l;if(a.type===R.Template){a.stylesheet&&this.injectCustomStylesheet(a.stylesheet);const h=Kh(this.wnd,a.element);if(!h){e.container=n,e.clickableElements=[];return}h.style.setProperty("pointer-events","none"),l=h}else{const h=a,d=h.type??R.Highlight,g=h.tint??vn(d);if(d===R.TextColor){e.container=n,e.clickableElements=[];return}if(d===R.Mask){e.container=n,e.clickableElements=[],this.updateSharedMask();return}const p=this.getCurrentDarkMode(),m=this.getBackgroundColor(),b=h.enforceContrast!==!1,x=(()=>{switch(d){case R.Underline:{const S=b?ke(g,m):g,w=h.layout==="bounds",[T,F]=r.isVertical?["border-right","border-left"]:["border-bottom","border-top"];return[w?`${F}: 0.1em solid ${S} !important`:null,`${T}: 0.1em solid ${S} !important`,"background-color: transparent !important","box-sizing: border-box !important"].filter(Boolean).join("; ")}case R.Strikethrough:{const S=b?ke(g,m):g;return h.layout==="bounds"?[`background: repeating-linear-gradient(-45deg, transparent, transparent 19px, ${S} 19px, ${S} 20px) !important`,"background-color: transparent !important","box-sizing: border-box !important"].join("; "):[`background-color: ${S} !important`,"box-sizing: border-box !important"].join("; ")}case R.Outline:return[`outline: 2px solid ${b?ke(g,m):g} !important`,"outline-offset: 1px !important","background-color: transparent !important","box-sizing: border-box !important"].join("; ");case R.HighlightUnderline:{const S=b?ke(g,m):g,{r:w,g:T,b:F}=be(S),L=`rgba(${w}, ${T}, ${F}, 0.3)`,X=h.layout==="bounds",[M,y]=r.isVertical?["border-right","border-left"]:["border-bottom","border-top"];return[`background-color: ${L} !important`,X?`${y}: 0.1em solid ${S} !important`:null,`${M}: 0.1em solid ${S} !important`,"box-sizing: border-box !important"].filter(Boolean).join("; ")}case R.Highlight:default:return[`background-color: ${b?ke(g,m):g} !important`,`mix-blend-mode: ${p?"exclusion":"multiply"} !important`,"opacity: 1 !important","box-sizing: border-box !important","transform: translateZ(0) !important"].join("; ")}})(),A=this.wnd.document.createElement("template");A.innerHTML=`<div data-readium="true" class="readium-${d}" style="${x}"></div>`.trim(),l=A.content.firstElementChild}const u=this.computeOverlayRects(e,r,o,s);for(const h of u){const d=l.cloneNode(!0);d.style.setProperty("pointer-events","none"),this.positionElement(e,r,i,d,h,o,c),n.append(d)}e.container=n,e.clickableElements=Array.from(n.querySelectorAll("[data-activable='1']")),e.clickableElements.length||(e.clickableElements=Array.from(n.children))}renderLayout(e){this.wnd.cancelAnimationFrame(this.currentRender),this.currentRender=this.wnd.requestAnimationFrame(()=>{e=e.filter(n=>!this.experimentalHighlights||!!this.notTextFlag?.has(n.id)),!(!e||e.length===0)&&this.requireContainer().append(...e.map(n=>n.container).filter(n=>!!n))})}requireContainer(e=!1){if(e){let n;return this.wnd.document.getElementById(`${this.id}-style`)?n=this.wnd.document.getElementById(`${this.id}-style`):(n=this.wnd.document.createElement("style"),n.dataset.readium="true",n.id=`${this.id}-style`,this.wnd.document.head.appendChild(n)),n}return this.container||(this.shadowRoot||(this.shadowHost=this.wnd.document.createElement("div"),this.shadowHost.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none",this.wnd.document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"})),this.container=this.wnd.document.createElement("div"),this.container.setAttribute("id",this.id),this.container.dataset.group=this.name,this.container.dataset.readium="true",this.container.style.setProperty("pointer-events","none"),this.container.style.display="contents",this.shadowRoot.appendChild(this.container)),this.container}getCurrentDarkMode(){return ai(this.wnd,"--USER__appearance")==="readium-night-on"||Is(this.getBackgroundColor())}getBackgroundColor(){return ai(this.wnd,"--USER__backgroundColor")||this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color")}updateSharedMask(){const e=this.items.filter(d=>d.decoration.style?.type===R.Mask);if(e.length===0){this.maskSvg&&(this.maskSvg.remove(),this.maskSvg=void 0),this.shadowHost&&!this.container&&(this.shadowHost.remove(),this.shadowRoot=void 0,this.shadowHost=void 0);return}const n=Ee(this.wnd),r=1/this.effectiveZoom(),i=this.wnd.document.documentElement,s=i.scrollWidth,o=i.scrollHeight,a=[];for(const d of e){const g=d.decoration.style,p=g.layout??"boxes",m=g.width??"wrap",b=g.expand??0,x=d.range.getBoundingClientRect(),A=p==="bounds"?[b?{left:x.left-b,top:x.top-b,right:x.right+b,bottom:x.bottom+b,width:x.width+b*2,height:x.height+b*2}:x]:Je(d.range,!1,!1,b);for(const S of A){let w;switch(m){case"viewport":{const T=Math.floor(n.inlineStart(S)/n.viewportInlineSize)*n.viewportInlineSize;w=n.toRect(T,n.blockStart(S),n.viewportInlineSize,n.blockSize(S));break}case"page":{const T=Math.floor(n.inlineStart(S)/n.pageInlineSize)*n.pageInlineSize;w=n.toRect(T,n.blockStart(S),n.pageInlineSize,n.blockSize(S));break}case"bounds":{w=n.toRect(n.inlineStart(x),n.blockStart(S),n.inlineSize(x),n.blockSize(S));break}default:w=n.toRect(n.inlineStart(S),n.blockStart(S),n.inlineSize(S),n.blockSize(S))}a.push(w)}}const c=[`M0 0 H${s} V${o} H0 Z`,...a.map(d=>{const g=(d.left+n.xDocOffset)*r,p=(d.top+n.yDocOffset)*r,m=(d.right+n.xDocOffset)*r,b=(d.bottom+n.yDocOffset)*r;return`M${g} ${p} H${m} V${b} H${g} Z`})].join(" "),l="http://www.w3.org/2000/svg";if(!this.maskSvg){this.shadowRoot||(this.shadowHost=this.wnd.document.createElement("div"),this.shadowHost.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none",this.wnd.document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"})),this.maskSvg=this.wnd.document.createElementNS(l,"svg"),this.maskSvg.style.cssText=`position:absolute;top:0;left:0;width:${s}px;height:${o}px;pointer-events:none;z-index:9999`,this.maskSvg.dataset.readium="true";const d=this.wnd.document.createElementNS(l,"defs"),g=this.wnd.document.createElementNS(l,"clipPath"),p=`${this.id}-mask-clip`;g.setAttribute("id",p),g.setAttribute("clipPathUnits","userSpaceOnUse");const m=this.wnd.document.createElementNS(l,"path");m.setAttribute("clip-rule","evenodd"),g.appendChild(m),d.appendChild(g),this.maskSvg.appendChild(d);const b=this.wnd.document.createElementNS(l,"rect");b.setAttribute("id",`${this.id}-mask-rect`),b.setAttribute("clip-path",`url(#${p})`),b.style.pointerEvents="none",this.maskSvg.appendChild(b),this.shadowRoot.appendChild(this.maskSvg)}this.maskSvg.style.width=`${s}px`,this.maskSvg.style.height=`${o}px`;const u=this.maskSvg.querySelector("path");u&&u.setAttribute("d",c);const h=this.maskSvg.querySelector("rect");if(h){const d=e[0].decoration.style.tint,g=d??this.getBackgroundColor()??vn(R.Mask),p=d?"1":"0.5";h.setAttribute("x","0"),h.setAttribute("y","0"),h.setAttribute("width",String(s)),h.setAttribute("height",String(o)),h.setAttribute("fill",g),h.setAttribute("fill-opacity",p)}}injectCustomStylesheet(e){const n=`${this.id}-custom-style`;let r=this.wnd.document.getElementById(n);r||(r=this.wnd.document.createElement("style"),r.id=n,r.dataset.readium="true",this.wnd.document.head.appendChild(r)),r.innerHTML=e}clearContainer(){if(this.experimentalHighlights){const e=this.wnd.CSS.highlights;for(const n of this._tintSubKeys.values())e.delete(n);this._tintSubKeys.clear(),this._subKeyCounter=0}this.wnd.document.getElementById(`${this.id}-custom-style`)?.remove(),this.container&&(this.container.remove(),this.container=void 0)}}const oa=class Re extends Hu{constructor(){super(...arguments),this.observedResizeTargets=new Map,this.resizeFrame=0,this.lastGroupId=0,this.groups=new Map,this.handleResizer=this.handleResize.bind(this),this.scrollScheduled=!1,this.handleScroller=this.handleScroll.bind(this)}cleanup(){this.groups.forEach(e=>e.destroy()),this.groups.clear(),this.observedResizeTargets.clear()}updateHighlightStyles(){this.groups.forEach(e=>{e.requestLayout()})}handleResize(){this.wnd.clearTimeout(this.resizeFrame),this.resizeFrame=this.wnd.setTimeout(()=>{this.groups.forEach(e=>e.requestLayout())},50)}handleScroll(){this.scrollScheduled||(this.scrollScheduled=!0,this.wnd.requestAnimationFrame(()=>{this.scrollScheduled=!1,this.groups.forEach(e=>{e.hasOverlayItems&&e.repositionOverlays()})}))}mount(e,n){return this.wnd=e,n.register("decorate",Re.moduleName,(r,i)=>{const s=r;(s.action==="add"||s.action==="update")&&s.decoration.locator&&(s.decoration.locator=Sr.deserialize(s.decoration.locator)),this.groups.has(s.group)||this.groups.set(s.group,new Yh(e,n,`readium-decoration-${this.lastGroupId++}`,s.group));const o=this.groups.get(s.group);switch(s.action){case"add":o?.add(s.decoration);break;case"remove":o?.remove(s.decoration.id);break;case"clear":o?.clear();break;case"update":o?.update(s.decoration);break}i(!0)}),n.register("decoration_resize",Re.moduleName,(r,i)=>{const s=r;s.action==="watch"?this.addDecorationResizeTarget(s.selector):this.removeDecorationResizeTarget(s.selector),i(!0)}),n.register("decoration_activatable",Re.moduleName,(r,i)=>{const s=r,o=this.groups.get(s.group);o&&(o.activatable=s.activatable),i(!0)}),n.register("decoration_hoverable",Re.moduleName,(r,i)=>{const s=r,o=this.groups.get(s.group);o&&(o.hoverable=s.hoverable),i(!0)}),this.resizeObserver=new ResizeObserver(()=>e.requestAnimationFrame(()=>this.handleResize())),this.resizeObserver.observe(e.document.documentElement),e.addEventListener("orientationchange",this.handleResizer),e.addEventListener("resize",this.handleResizer),e.addEventListener("scroll",this.handleScroller,{passive:!0,capture:!0}),this.styleObserver=new MutationObserver(r=>{r.some(i=>i.type==="attributes"&&i.attributeName==="style"&&i.oldValue!==i.target.getAttribute("style"))&&this.updateHighlightStyles()}),this.styleObserver.observe(e.document.documentElement,{attributes:!0,attributeFilter:["style"],attributeOldValue:!0}),n.log("Decorator Mounted"),!0}unmount(e,n){return e.removeEventListener("orientationchange",this.handleResizer),e.removeEventListener("resize",this.handleResizer),e.removeEventListener("scroll",this.handleScroller,{capture:!0}),n.unregisterAll(Re.moduleName),this.resizeObserver.disconnect(),this.styleObserver.disconnect(),this.cleanup(),n.log("Decorator Unmounted"),!0}addDecorationResizeTarget(e){const n=this.observedResizeTargets.get(e);n&&this.resizeObserver.unobserve(n);const r=this.wnd.document.querySelector(e);r?(this.resizeObserver.observe(r),this.observedResizeTargets.set(e,r)):this.observedResizeTargets.delete(e)}removeDecorationResizeTarget(e){const n=this.observedResizeTargets.get(e);n&&(this.resizeObserver.unobserve(n),this.observedResizeTargets.delete(e))}};oa.moduleName="decorator";let la=oa;const ca=new Set(Object.values(R));function ua(t,e){return t===R.TextColor?typeof window<"u"&&"Highlight"in window:ca.has(t)?!0:!!e?.[t]}function jn(t,e){const{style:n}=t;if(n.type===R.Template){const r=n;return{...t,style:{...r,element:Oi(r,t)}}}if(n.type&&e?.[n.type]){const r=e[n.type];return{...t,style:{type:R.Template,layout:r.layout,width:r.width,stylesheet:r.stylesheet,element:Oi(r,t)}}}return t}function Oi(t,e){return typeof t.element=="function"?t.element(e):t.element}function Qh(t,e){if(t.type!==e.type)return!1;if(t.type===R.Template){const i=t,s=e;return i.layout===s.layout&&i.width===s.width&&i.stylesheet===s.stylesheet}const n=t,r=e;return n.tint===r.tint&&n.layout===r.layout&&n.width===r.width&&(n.enforceContrast??!0)===(r.enforceContrast??!0)&&(n.expand??0)===(r.expand??0)}function ha(t,e){return t.locator.href===e.locator.href&&JSON.stringify(t.locator.locations?.serialize?.()??t.locator.locations)===JSON.stringify(e.locator.locations?.serialize?.()??e.locator.locations)&&JSON.stringify(t.locator.text??null)===JSON.stringify(e.locator.text??null)&&Qh(t.style,e.style)&&JSON.stringify(t.extras??null)===JSON.stringify(e.extras??null)}class da{constructor(){this.queue=[],this.channel=typeof MessageChannel<"u"?new MessageChannel:void 0,this.channel&&(this.channel.port1.onmessage=()=>this.flush())}push(e){const n=this.queue.length===0;this.queue.push(e),n&&(this.channel?this.channel.port2.postMessage(null):setTimeout(()=>this.flush(),0))}flush(){const e=this.queue;this.queue=[],e.forEach(n=>n())}clear(){this.queue=[]}}class fa{constructor(){this.frame=new ga(this),this.host=new pa(this)}}class ga{constructor(e){this.channel=e,this.registrar=new Map,this.outbox=new da,this.ready=!0}register(e,n,r){(Array.isArray(e)?e:[e]).forEach(i=>{const s=this.registrar.get(i)??[];if(s.find(o=>o.module===n))throw new Error(`Duplicate callback for "${i}" in module "${n}"`);s.push({module:n,cb:r}),this.registrar.set(i,s)})}unregister(e,n){(Array.isArray(e)?e:[e]).forEach(r=>{const i=this.registrar.get(r);i&&this.registrar.set(r,i.filter(s=>s.module!==n))})}unregisterAll(e){this.registrar.forEach((n,r)=>{this.registrar.set(r,n.filter(i=>i.module!==e))})}_dispatch(e,n,r){const i=this.registrar.get(e);if(!i?.length){r(!1);return}i.forEach(s=>s.cb(n,r))}send(e,n){this.outbox.push(()=>this.channel.host._receive(e,n))}log(...e){this.outbox.push(()=>this.channel.host._receive("log",e))}destroy(){this.registrar.clear(),this.outbox.clear()}}class pa{constructor(e){this.channel=e,this.listeners=new Map,this.outbox=new da,this.ready=!0}send(e,n,r){this.outbox.push(()=>this.channel.frame._dispatch(e,n,r??(()=>{})))}on(e,n){const r=this.listeners.get(e)??[];r.push(n),this.listeners.set(e,r)}off(e,n){const r=this.listeners.get(e);r&&this.listeners.set(e,r.filter(i=>i!==n))}_receive(e,n){this.listeners.get(e)?.forEach(r=>r(n))}}class ma{constructor(e,n={}){this.host=e,this._decorations=new Map,this._activationState=new Map,this._hoverState=new Map,this._observers=new Map,this._hoveredDecorations=new Map,this._config=n,n.resizeWatchSelectors?.forEach(r=>this.addDecorationResizeTarget(r)),e.on("decoration_activated",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId);s&&this._observers.get(i.group)?.forEach(o=>o.onDecorationActivated?.({group:i.group,decoration:s,rect:i.rect,point:i.point}))}),e.on("decoration_pointer_enter",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId);s&&(this._hoveredDecorations.set(i.group,s),this._observers.get(i.group)?.forEach(o=>o.onDecorationPointerEnter?.({group:i.group,decoration:s,rect:i.rect,point:i.point})))}),e.on("decoration_pointer_leave",r=>{const i=r,s=this._decorations.get(i.group)?.find(o=>o.id===i.decorationId)??this._hoveredDecorations.get(i.group);this._hoveredDecorations.delete(i.group),s&&this._observers.get(i.group)?.forEach(o=>o.onDecorationPointerLeave?.({group:i.group,decoration:s,rect:i.rect,point:i.point}))})}addDecorationResizeTarget(e){this.host.send("decoration_resize",{action:"watch",selector:e})}removeDecorationResizeTarget(e){this.host.send("decoration_resize",{action:"unwatch",selector:e})}supportsDecorationStyle(e){return ua(e,this._config.decorationTemplates)}applyDecorations(e,n){const r=this._decorations.get(n)??[],i=new Map(r.map(c=>[c.id,c])),s=new Map(e.map(c=>[c.id,c]));for(const[c,l]of i){const u=s.get(c);u?ha(l,u)||this.host.send("decorate",{group:n,action:"update",decoration:jn(u,this._config.decorationTemplates)}):this.host.send("decorate",{group:n,action:"remove",decoration:{id:c}})}for(const[c,l]of s)i.has(c)||this.host.send("decorate",{group:n,action:"add",decoration:jn(l,this._config.decorationTemplates)});this._decorations.set(n,e);const o=this._activationState.get(n);o!==void 0&&this.host.send("decoration_activatable",{group:n,activatable:o});const a=this._hoverState.get(n);a!==void 0&&this.host.send("decoration_hoverable",{group:n,hoverable:a})}registerDecorationObserver(e,n){this._observers.has(e)||this._observers.set(e,new Set),this._observers.get(e).add(n),n.onDecorationActivated&&(this._activationState.set(e,!0),this.host.send("decoration_activatable",{group:e,activatable:!0})),(n.onDecorationPointerEnter||n.onDecorationPointerLeave)&&(this._hoverState.set(e,!0),this.host.send("decoration_hoverable",{group:e,hoverable:!0}))}unregisterDecorationObserver(e){this._observers.forEach((n,r)=>{if(!n.has(e))return;n.delete(e);const i=[...n].some(o=>o.onDecorationActivated);this._activationState.has(r)&&!i&&(this._activationState.delete(r),this.host.send("decoration_activatable",{group:r,activatable:!1}));const s=[...n].some(o=>o.onDecorationPointerEnter||o.onDecorationPointerLeave);this._hoverState.has(r)&&!s&&(this._hoverState.delete(r),this.host.send("decoration_hoverable",{group:r,hoverable:!1}))})}destroy(){this._decorations.clear(),this._activationState.clear(),this._hoverState.clear(),this._observers.clear(),this._hoveredDecorations.clear()}}function Zh(t){return new Ds({start:new It(t.start),end:t.end?new It(t.end):void 0})}function ya(t,e=window){const{text:n,cssSelector:r,domRange:i,fragment:s}=t,o=n?new br(n):void 0,a=r||i?new Map:void 0;a&&(r&&a.set("cssSelector",r),i&&a.set("domRange",Zh(i).serialize()));const l=a!==void 0||s!==void 0?new ue({fragments:s?[s]:void 0,otherLocations:a}):void 0;return new Sr({href:e.location.href,type:"text/html",text:o,locations:l})}class ba extends ma{constructor(e,n,r,i={}){super(e.host,i),this.channel=e,this.wnd=n,this.decorator=r}decorate(e,n){this.applyDecorations(e.map(({id:r,style:i,...s})=>({id:r,style:i,locator:ya(s,this.wnd)})),n)}destroy(){super.destroy(),this.decorator.unmount(this.wnd,this.channel.frame),this.channel.frame.destroy()}}function ed(t=window,e={}){const n=new fa,r=new la;return r.mount(t,n.frame),new ba(n,t,r,e)}class td{providers=new Map;register(e){if(this.providers.has(e.id))throw new Error(`A provider is already registered under id "${e.id}"`);this.providers.set(e.id,e)}unregister(e){this.providers.delete(e)}get(e){return this.providers.get(e)}list(){return[...this.providers.values()]}async getVoices(e){return this.require(e).getVoices()}async getAllVoices(){return Promise.all(this.list().map(async e=>({providerId:e.id,voices:await e.getVoices()})))}async createEngine(e,n){return this.require(e).createEngine(n)}async destroy(){await Promise.all(this.list().map(e=>e.destroy())),this.providers.clear()}require(e){const n=this.providers.get(e);if(!n)throw new Error(`No provider registered under id "${e}"`);return n}}const Lt={range:[0,5e3],step:100},$t={range:[.1,10],step:.1},_t={range:[0,2],step:.1},Bt={range:[0,1],step:.05},vr=["none","few","some","most","custom"],wr=["none","block-level","always"],xr=["plain","ssml"],Er=["none","utterance","block"],Ai=["format","inlineContextualization","verbosity","skip","contextualize","language"];function Cr(t){return t==null||typeof t=="boolean"?t:void 0}function re(t,e){return t==null||e.includes(t)?t:void 0}function ie(t,e){if(t==null)return t;if(typeof t!="number"||Number.isNaN(t))return;const n=Math.min(...e),r=Math.max(...e);return t>=n&&t<=r?t:void 0}function at(t){return t==null||Array.isArray(t)&&t.every(e=>typeof e=="string")?t:void 0}class Sa{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e={}){this.format=re(e.format,xr)??"plain",this.inlineContextualization=Cr(e.inlineContextualization)??!1,this.verbosity=re(e.verbosity,vr)??"few",this.skip=at(e.skip)??[],this.contextualize=at(e.contextualize)??[],this.language=re(e.language,wr)??"block-level",this.pauseDuration=ie(e.pauseDuration,Lt.range)??300,this.autoPause=re(e.autoPause,Er)??"none",this.rate=ie(e.rate,$t.range)??1,this.pitch=ie(e.pitch,_t.range)??1,this.volume=ie(e.volume,Bt.range)??1}}class Ue{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e={}){this.format=re(e.format,xr),this.inlineContextualization=Cr(e.inlineContextualization),this.verbosity=re(e.verbosity,vr),this.skip=at(e.skip),this.contextualize=at(e.contextualize),this.language=re(e.language,wr),this.pauseDuration=ie(e.pauseDuration,Lt.range),this.autoPause=re(e.autoPause,Er),this.rate=ie(e.rate,$t.range),this.pitch=ie(e.pitch,_t.range),this.volume=ie(e.volume,Bt.range)}merging(e){const n={...this};for(const r of Object.keys(e))e[r]!==void 0&&(n[r]=e[r]);return new Ue(n)}}class ht{_value;_effectiveValue;_isEffective;_onChange;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i}){this._value=e,this._effectiveValue=n,this._isEffective=r,this._onChange=i}set value(e){this._value=e,this._onChange(this._value)}get value(){return this._value}get effectiveValue(){return this._effectiveValue}get isEffective(){return this._isEffective}clear(){this._value=null,this._onChange(this._value)}}class tt extends ht{_supportedValues;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i,supportedValues:s}){super({initialValue:e,effectiveValue:n,isEffective:r,onChange:i}),this._supportedValues=s}set value(e){if(e!=null&&re(e,this._supportedValues)===void 0)throw new Error(`Value '${String(e)}' is not in the supported values for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get supportedValues(){return this._supportedValues}}class va extends ht{set value(e){if(e!=null&&Cr(e)===void 0)throw new Error(`Value '${String(e)}' is not a boolean.`);this._value=e,this._onChange(this._value)}get value(){return this._value}}class Hn extends ht{set value(e){if(e!=null&&at(e)===void 0)throw new Error(`Value '${String(e)}' is not an array of strings.`);this._value=e,this._onChange(this._value)}get value(){return this._value}}class nt extends ht{_supportedRange;_step;_decimals;constructor({initialValue:e=null,effectiveValue:n,isEffective:r,onChange:i,supportedRange:s,step:o}){super({initialValue:e,effectiveValue:n,isEffective:r,onChange:i}),this._supportedRange=s,this._step=o,this._decimals=this._step.toString().includes(".")?this._step.toString().split(".")[1].length:0}set value(e){if(e!=null&&ie(e,this._supportedRange)===void 0)throw new Error(`Value '${String(e)}' is out of the supported range for this preference.`);this._value=e,this._onChange(this._value)}get value(){return this._value}get supportedRange(){return this._supportedRange}get step(){return this._step}increment(){this._value!=null&&this._value<this._supportedRange[1]&&(this._value=Math.min(Math.round((this._value+this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[1]),this._onChange(this._value))}decrement(){this._value!=null&&this._value>this._supportedRange[0]&&(this._value=Math.max(Math.round((this._value-this._step)*10**this._decimals)/10**this._decimals,this._supportedRange[0]),this._onChange(this._value))}format(e){return e.toString()}}class Wn{preferences;settings;constructor(e,n){this.preferences=new Ue({...e}),this.settings=n}clear(){this.preferences=new Ue({format:null,inlineContextualization:null,verbosity:null,skip:null,contextualize:null,language:null,pauseDuration:null,autoPause:null,rate:null,pitch:null,volume:null})}updatePreference(e,n){this.preferences[e]=n}get format(){return new tt({initialValue:this.preferences.format,effectiveValue:this.settings.format,isEffective:this.preferences.format!=null,onChange:e=>this.updatePreference("format",e??null),supportedValues:xr})}get inlineContextualization(){return new va({initialValue:this.preferences.inlineContextualization,effectiveValue:this.settings.inlineContextualization,isEffective:this.preferences.inlineContextualization!=null,onChange:e=>this.updatePreference("inlineContextualization",e??null)})}get verbosity(){return new tt({initialValue:this.preferences.verbosity,effectiveValue:this.settings.verbosity,isEffective:this.preferences.verbosity!=null,onChange:e=>this.updatePreference("verbosity",e??null),supportedValues:vr})}get skip(){return new Hn({initialValue:this.preferences.skip,effectiveValue:this.settings.skip,isEffective:this.preferences.skip!=null,onChange:e=>this.updatePreference("skip",e??null)})}get contextualize(){return new Hn({initialValue:this.preferences.contextualize,effectiveValue:this.settings.contextualize,isEffective:this.preferences.contextualize!=null,onChange:e=>this.updatePreference("contextualize",e??null)})}get language(){return new tt({initialValue:this.preferences.language,effectiveValue:this.settings.language,isEffective:this.preferences.language!=null,onChange:e=>this.updatePreference("language",e??null),supportedValues:wr})}get pauseDuration(){return new nt({initialValue:this.preferences.pauseDuration,effectiveValue:this.settings.pauseDuration,isEffective:this.preferences.pauseDuration!=null,onChange:e=>this.updatePreference("pauseDuration",e??null),supportedRange:Lt.range,step:Lt.step})}get autoPause(){return new tt({initialValue:this.preferences.autoPause,effectiveValue:this.settings.autoPause,isEffective:this.preferences.autoPause!=null,onChange:e=>this.updatePreference("autoPause",e??null),supportedValues:Er})}get rate(){return new nt({initialValue:this.preferences.rate,effectiveValue:this.settings.rate,isEffective:this.preferences.rate!=null,onChange:e=>this.updatePreference("rate",e??null),supportedRange:$t.range,step:$t.step})}get pitch(){return new nt({initialValue:this.preferences.pitch,effectiveValue:this.settings.pitch,isEffective:this.preferences.pitch!=null,onChange:e=>this.updatePreference("pitch",e??null),supportedRange:_t.range,step:_t.step})}get volume(){return new nt({initialValue:this.preferences.volume,effectiveValue:this.settings.volume,isEffective:this.preferences.volume!=null,onChange:e=>this.updatePreference("volume",e??null),supportedRange:Bt.range,step:Bt.step})}}const wa=["audio","figure","image","math","table","video"],xa=[...wa,"blockquote","chapter","cover","details","notice","part","preformatted","qna","row","rowheader","subtitle","tip"],nd=[...xa,"abstract","acknowledgments","afterword","appendix","aside","backlink","bibliography","biblioref","colophon","complementary","conclusion","credit","credits","dedication","definition","endnotes","epigraph","epilogue","errata","example","footnote","foreword","glossary","glossref","heading1","heading2","heading3","heading4","heading5","heading6","index","introduction","list","listItem","noteref","pagebreak","pagelist","preface","prologue","pullquote","separator","summary","term"],Ea={none:new Set(["aside","audio","bibliography","biblioref","cell","columnheader","details","endnotes","figure","footnote","glossary","image","landmarks","loa","loi","lot","lov","noteref","pagebreak","pullquote","row","rowheader","table","toc","video"]),few:new Set(["aside","bibliography","biblioref","cell","columnheader","details","endnotes","footnote","glossary","landmarks","loa","loi","lot","lov","noteref","pagebreak","pullquote","row","rowheader","toc"]),some:new Set(["aside","bibliography","biblioref","endnotes","footnote","glossary","landmarks","loa","loi","lot","lov","noteref","pagebreak","pullquote","toc"]),most:new Set(["landmarks","loa","loi","lot","lov","toc"])},Ca={none:new Set,few:new Set(wa),some:new Set(xa),most:new Set(nd)},Gn={table:{few:"inline",some:"block",most:"block"}};function wt(t){const e={};for(const n of Object.keys(Gn))e[n]=Gn[n]?.[t]??"inline";return e}const ka={none:wt("none"),few:wt("few"),some:wt("some"),most:wt("most")},rd=Object.keys(Gn);function id(t,e){const n=t==="custom"?{}:ka[t];if(!e)return n;const r={...n};for(const i of Object.keys(e)){const s=e[i]?.[t];s&&(r[i]=s)}return r}class Kn{format;inlineContextualization;verbosity;skip;contextualize;language;pauseDuration;autoPause;rate;pitch;volume;constructor(e,n){this.format=e.format??n.format,this.inlineContextualization=e.inlineContextualization??n.inlineContextualization,this.verbosity=e.verbosity??n.verbosity,this.verbosity==="custom"?(this.skip=e.skip??n.skip,this.contextualize=e.contextualize??n.contextualize):(this.skip=[...Ea[this.verbosity]],this.contextualize=[...Ca[this.verbosity]]),this.language=e.language??n.language,this.pauseDuration=e.pauseDuration??n.pauseDuration,this.autoPause=e.autoPause??n.autoPause,this.rate=e.rate??n.rate,this.pitch=e.pitch??n.pitch,this.volume=e.volume??n.volume}}const O=t=>typeof t=="string",Xe=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},Ti=t=>t==null?"":String(t),sd=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},ad=/###/g,Ri=t=>t&&t.includes("###")?t.replace(ad,"."):t,Ni=t=>!t||O(t),rt=(t,e,n)=>{const r=O(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Ni(t))return{};const s=Ri(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Ni(t)?{}:{obj:t,k:Ri(r[i])}},Di=(t,e,n)=>{const{obj:r,k:i}=rt(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),a=rt(t,o,Object);for(;a.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),a=rt(t,o,Object),a?.obj&&typeof a.obj[`${a.k}.${s}`]<"u"&&(a.obj=void 0);a.obj[`${a.k}.${s}`]=n},od=(t,e,n,r)=>{const{obj:i,k:s}=rt(t,e,Object);i[s]=i[s]||[],i[s].push(n)},qt=(t,e)=>{const{obj:n,k:r}=rt(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},ld=(t,e,n)=>{const r=qt(t,n);return r!==void 0?r:qt(e,n)},Oa=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(Object.prototype.hasOwnProperty.call(t,r)?O(t[r])||t[r]instanceof String||O(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Oa(t[r],e[r],n):t[r]=e[r]);return t},ee=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),cd={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},ud=t=>O(t)?t.replace(/[&<>"'\/]/g,e=>cd[e]):t;class hd{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const dd=[" ",",","?","!",";"],fd=new hd(20),gd=(t,e,n)=>{e=e||"",n=n||"";const r=dd.filter(o=>!e.includes(o)&&!n.includes(o));if(r.length===0)return!0;const i=fd.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},Jn=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,a="";for(let c=s;c<r.length;++c)if(c!==s&&(a+=n),a+=r[c],o=i[a],o!==void 0){if(["string","number","boolean"].includes(typeof o)&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},ot=t=>t?.replace(/_/g,"-"),pd={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class Ut{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||pd,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(e=e.map(s=>O(s)?s.replace(/[\r\n\x00-\x1F\x7F]/g," "):s),O(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Ut(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Ut(this.logger,e)}}var Q=new Ut;class en{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}once(e,n){const r=(...i)=>{n(...i),this.off(e,r)};return this.on(e,r),this}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(e,...n)})}}class Fi extends en{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.includes(".")?a=e.split("."):(a=[e,n],r&&(Array.isArray(r)?a.push(...r):O(r)&&s?a.push(...r.split(s)):a.push(r)));const c=qt(this.data,a);return!c&&!n&&!r&&e.includes(".")&&(e=a[0],n=a[1],r=a.slice(2).join(".")),c||!o||!O(r)?c:Jn(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let a=[e,n];r&&(a=a.concat(o?r.split(o):r)),e.includes(".")&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),Di(this.data,a,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(O(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,o={silent:!1,skipCopy:!1}){let a=[e,n];e.includes(".")&&(a=e.split("."),i=r,r=n,n=a[1]),this.addNamespaces(n);let c=qt(this.data,a)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Oa(c,r,s):c={...c,...r},Di(this.data,a,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var Aa={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const Ta=Symbol("i18next/PATH_KEY");function md(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Ta?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Ie(t,e){const{[Ta]:n}=t(md()),r=e?.keySeparator??".",i=e?.nsSeparator??":",s=e?.enableSelector==="strict";if(n.length>1&&i){const o=e?.ns,a=s?Array.isArray(o)?o:o?[o]:null:Array.isArray(o)?o:null;if(a&&(s?a:a.length>1?a.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}const wn=t=>!O(t)&&typeof t!="boolean"&&typeof t!="number";class Vt extends en{constructor(e,n={}){super(),sd(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Q.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=wn(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.includes(r),a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!gd(e,r,i);if(o&&!a){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:O(s)?[s]:s};const l=e.split(r);(r!==i||r===i&&this.options.ns.includes(l[0]))&&(s=l.shift()),e=l.join(i)}return{key:e,namespaces:O(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Ie(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]),e=e.map(k=>typeof k=="function"?Ie(k,{...this.options,...i}):String(k));const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],i),l=c[c.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const h=i.lng||this.language,d=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return d?s?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:h,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${a}`:s?{res:a,usedKey:a,exactUsedKey:a,usedLng:h,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:a;const g=this.resolve(e,i);let p=g?.res;const m=g?.usedKey||a,b=g?.exactUsedKey||a,x=["[object Number]","[object Function]","[object RegExp]"],A=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!O(i.count),T=Vt.hasDefaultValue(i),F=w?this.pluralResolver.getSuffix(h,i.count,i):"",L=i.ordinal&&w?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",X=w&&!i.ordinal&&i.count===0,M=X&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${F}`]||i[`defaultValue${L}`]||i.defaultValue;let y=p;S&&!p&&T&&(y=M);const gt=wn(y),ce=Object.prototype.toString.apply(y);if(S&&y&>&&!x.includes(ce)&&!(O(A)&&Array.isArray(y))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const k=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,y,{...i,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(g.res=k,g.usedParams=this.getUsedParamsDetails(i),g):k}if(o){const k=Array.isArray(y),_=k?[]:{},G=k?b:m;for(const V in y)if(Object.prototype.hasOwnProperty.call(y,V)){const H=`${G}${o}${V}`;T&&!p?_[V]=this.translate(H,{...i,defaultValue:wn(M)?M[V]:void 0,joinArrays:!1,ns:c}):_[V]=this.translate(H,{...i,joinArrays:!1,ns:c}),_[V]===H&&(_[V]=y[V])}p=_}}else if(S&&O(A)&&Array.isArray(p))p=p.join(A),p&&(p=this.extendTranslation(p,e,i,r));else{let k=!1,_=!1;!this.isValidLookup(p)&&T&&(k=!0,p=M),this.isValidLookup(p)||(_=!0,p=a);const V=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:p,H=T&&M!==p&&this.options.updateMissing;if(_||k||H){if(this.logger.log(H?"updateKey":"missingKey",h,l,w&&!H?`${a}${this.pluralResolver.getSuffix(h,i.count,i)}`:a,H?M:p),o){const f=this.resolve(a,{...i,keySeparator:!1});f&&f.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let U=[];const ve=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ve&&ve[0])for(let f=0;f<ve.length;f++)U.push(ve[f]);else this.options.saveMissingTo==="all"?U=this.languageUtils.toResolveHierarchy(i.lng||this.language):U.push(i.lng||this.language);const K=(f,v,C)=>{const E=T&&C!==p?C:V;this.options.missingKeyHandler?this.options.missingKeyHandler(f,l,v,E,H,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(f,l,v,E,H,i),this.emit("missingKey",f,l,v,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?U.forEach(f=>{const v=this.pluralResolver.getSuffixes(f,i);X&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!v.includes(`${this.options.pluralSeparator}zero`)&&v.push(`${this.options.pluralSeparator}zero`),v.forEach(C=>{K([f],a+C,i[`defaultValue${C}`]||M)})}):K(U,a,M))}p=this.extendTranslation(p,e,i,g,r),_&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(_||k)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,k?p:void 0,i))}return s?(g.res=p,g.usedParams=this.getUsedParamsDetails(i),g):p}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=O(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let l;if(c){const h=e.match(this.interpolator.nestingRegexp);l=h&&h.length}let u=r.replace&&!O(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),c){const h=e.match(this.interpolator.nestingRegexp),d=h&&h.length;l<d&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,a=O(o)?[o]:o;return e!=null&&a?.length&&r.applyPostProcessor!==!1&&(e=Aa.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,a;return O(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(c=>typeof c=="function"?Ie(c,{...this.options,...n}):c)),e.forEach(c=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(c,n),u=l.key;i=u;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const d=n.count!==void 0&&!O(n.count),g=d&&!n.ordinal&&n.count===0,p=n.context!==void 0&&(O(n.context)||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(b=>{this.isValidLookup(r)||(a=b,!this.checkedLoadedFor[`${m[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(this.checkedLoadedFor[`${m[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(x=>{if(this.isValidLookup(r))return;o=x;const A=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(A,u,x,b,n);else{let w;d&&(w=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,F=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(n.ordinal&&w.startsWith(F)&&A.push(u+w.replace(F,this.options.pluralSeparator)),A.push(u+w),g&&A.push(u+T)),p){const L=`${u}${this.options.contextSeparator||"_"}${n.context}`;A.push(L),d&&(n.ordinal&&w.startsWith(F)&&A.push(L+w.replace(F,this.options.pluralSeparator)),A.push(L+w),g&&A.push(L+T))}}let S;for(;S=A.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(x,b,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!O(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i={...i,count:e.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&r.startsWith(n)&&e[r]!==void 0)return!0;return!1}}class Ii{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Q.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=ot(e),!e||!e.includes("-"))return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=ot(e),!e||!e.includes("-"))return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(O(e)&&e.includes("-")){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>o===s?!0:!o.includes("-")&&!s.includes("-")?!1:!!(o.includes("-")&&!s.includes("-")&&o.slice(0,o.indexOf("-"))===s||o.startsWith(s)&&s.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),O(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.options.fallbackLng,i=Array.isArray(r)?r.join("|"):r;i!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=i);const s=n===void 0||n===!1||O(n),o=n===void 0&&typeof this.options.fallbackLng=="function",a=O(e)&&s&&!o;let c=null;if(a){let d;n===void 0?d="undefined":n===!1?d="boolean:false":d=`string:${n}`,c=`${e.length}:${e}|${d}`}if(c!==null){const d=this.resolveHierarchyCache[c];if(d!==void 0)return d.slice()}const l=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),u=[],h=d=>{d&&(this.isSupportedCode(d)?u.push(d):this.logger.warn(`rejecting language code not found in supportedLngs: ${d}`))};return O(e)&&(e.includes("-")||e.includes("_"))?(this.options.load!=="languageOnly"&&h(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&h(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&h(this.getLanguagePartFromCode(e))):O(e)&&h(this.formatLanguageCode(e)),l.forEach(d=>{u.includes(d)||h(this.formatLanguageCode(d))}),c!==null?(this.resolveHierarchyCache[c]=u,u.slice()):u}}const Pi={zero:0,one:1,two:2,few:3,many:4,other:5},Li={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class yd{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Q.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=ot(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Li;if(!e.match(/-|_/))return Li;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Pi[i]-Pi[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const $i=(t,e,n,r=".",i=!0)=>{let s=ld(t,e,n);return!s&&i&&O(n)&&(s=Jn(t,n,r),s===void 0&&(s=Jn(e,n,r))),s},bd=t=>t.replace(/\$/g,"$$$$");class _i{constructor(e={}){this.logger=Q.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:a,suffixEscaped:c,formatSeparator:l,unescapeSuffix:u,unescapePrefix:h,nestingPrefix:d,nestingPrefixEscaped:g,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:b,maxReplaces:x,alwaysFormat:A}=e.interpolation;this.escape=n!==void 0?n:ud,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?ee(s):o||"{{",this.suffix=a?ee(a):c||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":h?ee(h):"-",this.unescapeSuffix=this.unescapePrefix?"":u?ee(u):"",this.nestingPrefix=d?ee(d):g||ee("$t("),this.nestingSuffix=p?ee(p):m||ee(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=x||1e3,this.alwaysFormat=A!==void 0?A:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,a;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=g=>{if(!g.includes(this.formatSeparator)){const x=$i(n,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:g}):x}const p=g.split(this.formatSeparator),m=p.shift().trim(),b=p.join(this.formatSeparator).trim();return this.format($i(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:m})};this.resetRegExp(),!this.escapeValue&&typeof e=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>g},{regex:this.regexp,safeValue:g=>this.escapeValue?this.escape(g):g}].forEach(g=>{for(a=0;s=g.regex.exec(e);){const p=s[1].trim();if(o=l(p),o===void 0)if(typeof u=="function"){const b=u(e,s,i);o=O(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,p))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),o="";else!O(o)&&!this.useRawValueToEscape&&(o=Ti(o));const m=g.safeValue(o);if(e=e.replace(s[0],bd(m)),h?(g.regex.lastIndex+=m.length,g.regex.lastIndex-=s[0].length):g.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const a=(c,l)=>{const u=this.nestingOptionsSeparator;if(!c.includes(u))return c;const h=c.split(new RegExp(`${ee(u)}[ ]*{`));let d=`{${h[1]}`;c=h[0],d=this.interpolate(d,o);const g=d.match(/'/g),p=d.match(/"/g);((g?.length??0)%2===0&&!p||(p?.length??0)%2!==0)&&(d=d.replace(/'/g,'"'));try{o=JSON.parse(d),l&&(o={...l,...o})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,m),`${c}${u}${d}`}return o.defaultValue&&o.defaultValue.includes(this.prefix)&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!O(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const l=/{.*}/s.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(l!==-1&&(c=i[1].slice(l).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,l)),s=n(a.call(this,i[1].trim(),o),o),s&&i[0]===e&&!O(s))return s;O(s)||(s=Ti(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,h)=>this.format(u,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Sd=t=>{let e=t.toLowerCase().trim();const n={};if(t.includes("(")){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].slice(0,-1);e==="currency"&&!i.includes(":")?n.currency||(n.currency=i.trim()):e==="relativetime"&&!i.includes(":")?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[a,...c]=o.split(":"),l=c.join(":").trim().replace(/^'+|'+$/g,""),u=a.trim();n[u]||(n[u]=l),l==="false"&&(n[u]=!1),l==="true"&&(n[u]=!0),isNaN(l)||(n[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:n}},Bi=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let a=e[o];return a||(a=t(ot(r),i),e[o]=a),a(n)}},vd=t=>(e,n,r)=>t(ot(n),r)(e);class wd{constructor(e={}){this.logger=Q.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?Bi:vd;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return a=>o.format(a)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return a=>o.format(a)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return a=>o.format(a)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return a=>o.format(a,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return a=>o.format(a)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Bi(n)}format(e,n,r,i={}){if(!n||e==null)return e;const s=n.split(this.formatSeparator),o=[];for(let c=0;c<s.length;c++){let l=s[c];for(;l.indexOf("(")>-1&&!l.includes(")")&&c+1<s.length;)l=`${l}${this.formatSeparator}${s[++c]}`;o.push(l)}return o.reduce((c,l)=>{const{formatName:u,formatOptions:h}=Sd(l);if(this.formats[u]){let d=c;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;d=this.formats[u](c,p,{...h,...i,...g})}catch(g){this.logger.warn(g)}return d}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const xd=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Ed extends en{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Q.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},a={},c={};return e.forEach(l=>{let u=!0;n.forEach(h=>{const d=`${l}|${h}`;!r.reload&&this.store.hasResourceBundle(l,h)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?o[d]===void 0&&(o[d]=!0):(this.state[d]=1,u=!1,o[d]===void 0&&(o[d]=!0),s[d]===void 0&&(s[d]=!0),c[h]===void 0&&(c[h]=!0)))}),u||(a[l]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const a={};this.queue.forEach(c=>{od(c.loaded,[s],o),xd(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(l=>{a[l]||(a[l]={});const u=c.loaded[l];u.length&&u.forEach(h=>{a[l][h]===void 0&&(a[l][h]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const a=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read(e,n,r,i+1,s*2,o)},s);return}o(l,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const l=c(e,n);l&&typeof l.then=="function"?l.then(u=>a(null,u)).catch(a):a(null,l)}catch(l){a(l)}return}return c(e,n,a)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();O(e)&&(e=this.languageUtils.toResolveHierarchy(e)),O(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,a)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&a&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,a),this.loaded(e,o,a)})}saveMissing(e,n,r,i,s,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},l=this.backend.create.bind(this.backend);if(l.length<6)try{let u;l.length===5?u=l(e,n,r,i,c):u=l(e,n,r,i),u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}else l(e,n,r,i,a,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const xn=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),O(t[1])&&(e.defaultValue=t[1]),O(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),qi=t=>(O(t.ns)&&(t.ns=[t.ns]),O(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),O(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),xt=()=>{},Cd=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class it extends en{constructor(e={},n){if(super(),this.options=qi(e),this.services={},this.logger=Q,this.modules={external:[]},Cd(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(O(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const r=xn();this.options={...r,...this.options,...qi(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=r.overloadTranslationOptionHandler);const i=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?Q.init(i(this.modules.logger),this.options):Q.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=wd;const u=new Ii(this.options);this.store=new Fi(this.options.resources,this.options);const h=this.services;h.logger=Q,h.resourceStore=this.store,h.languageUtils=u,h.pluralResolver=new yd(u,{prepend:this.options.pluralSeparator}),l&&(h.formatter=i(l),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new _i(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Ed(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(d,...g)=>{this.emit(d,...g)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Vt(this.services,this.options),this.translator.on("*",(d,...g)=>{this.emit(d,...g)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,n||(n=xt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(l=>{this[l]=(...u)=>this.store[l](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(l=>{this[l]=(...u)=>(this.store[l](...u),this)});const a=Xe(),c=()=>{const l=(u,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(h),n(u,h)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return l(null,this.t.bind(this));this.changeLanguage(this.options.lng,l)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),a}loadResources(e,n=xt){let r=n;const i=O(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=a=>{if(!a||a==="cimode")return;this.services.languageUtils.toResolveHierarchy(a).forEach(l=>{l!=="cimode"&&(s.includes(l)||s.push(l))})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(a=>o(a)),this.services.backendConnector.load(s,this.options.ns,a=>{!a&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(a)})}else r(null)}reloadResources(e,n,r){const i=Xe();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=xt),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Aa.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!["cimode","dev"].includes(e)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!["cimode","dev"].includes(r)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Xe();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},s=(a,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...l)=>this.t(...l)),n&&n(a,(...l)=>this.t(...l))},o=a=>{!e&&!a&&this.services.languageDetector&&(a=[]);const c=O(a)?a:a&&a[0],l=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(O(a)?[a]:a);l&&(this.language||i(l),this.translator.language||this.translator.changeLanguage(l),this.services.languageDetector?.cacheUserLanguage?.(l)),this.loadResources(l,u=>{s(u,l)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r,i){const s=i?.scopeNs,o=(a,c,...l)=>{let u;typeof c!="object"?u=this.options.overloadTranslationOptionHandler([a,c].concat(l)):u={...c},u.lng=u.lng||o.lng,u.lngs=u.lngs||o.lngs;const h=u.ns!==void 0&&u.ns!==null;u.ns=u.ns||o.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||o.keyPrefix);const d={...this.options,...u};Array.isArray(s)&&!h&&(d.ns=s),typeof u.keyPrefix=="function"&&(u.keyPrefix=Ie(u.keyPrefix,d));const g=this.options.keySeparator||".";let p;return u.keyPrefix&&Array.isArray(a)?p=a.map(m=>(typeof m=="function"&&(m=Ie(m,d)),`${u.keyPrefix}${g}${m}`)):(typeof a=="function"&&(a=Ie(a,d)),p=u.keyPrefix?`${u.keyPrefix}${g}${a}`:a),this.t(p,u)};return O(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=r,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,c)=>{const l=this.services.backendConnector.state[`${a}|${c}`];return l===-1||l===0||l===2};if(n.precheck){const a=n.precheck(this,o);if(a!==void 0)return a}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Xe();return this.options.ns?(O(e)&&(e=[e]),e.forEach(i=>{this.options.ns.includes(i)||this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Xe();O(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>!i.includes(o)&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new Ii(xn());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(r.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new it(e,n);return r.createInstance=it.createInstance,r}cloneInstance(e={},n=xt){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new it(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(a=>{s[a]=this[a]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const a=Object.keys(this.store.data).reduce((c,l)=>(c[l]={...this.store.data[l]},c[l]=Object.keys(c[l]).reduce((u,h)=>(u[h]={...c[l][h]},u),c[l]),c),{});s.store=new Fi(a,i),s.services.resourceStore=s.store}if(e.interpolation){const c={...xn().interpolation,...this.options.interpolation,...e.interpolation},l={...i,interpolation:c};s.services.interpolator=new _i(l)}return s.translator=new Vt(s.services,i),s.translator.on("*",(a,...c)=>{s.emit(a,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const z=it.createInstance();z.createInstance;z.dir;z.init;z.loadResources;z.reloadResources;z.use;z.changeLanguage;z.getFixedT;z.t;z.exists;z.setDefaultNamespace;z.hasLoadedNamespace;z.loadNamespaces;z.loadLanguages;function dt(t){return t.plain===""&&t.ssml===""&&t.language===""}function kd(t){if(!t||dt(t))return;if(t.ssml===""&&t.language==="")return t.plain;const e={language:t.language};return t.plain!==""&&(e.plain=t.plain),t.ssml!==""&&(e.ssml=t.ssml),e}function Od(t,e){if(t.lang!==e.lang||t.tag!==e.tag)return!1;const n=Object.entries(t.attrs??{}),r=Object.entries(e.attrs??{});return n.length!==r.length?!1:n.every(([i,s])=>e.attrs?.[i]===s)}const zt=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),En=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Ad=/[\u00A0\u2007\u202F]/;function Td(t){return Ad.test(t)}function Ve(t,e){let n="",r=!1,i=!1;for(const s of t)if(Td(s))n+=s,r=!1,i=!0;else if(/\s/.test(s)){if(e&&!i||r)continue;n+=" ",r=!0}else s!==""&&s!==""&&(n+=s,r=!1,i=!0);return n}const Xn="#css(",Yn=")";function Ra(t){return`${Xn}${encodeURIComponent(t)}${Yn}`}function Na(t){if(!(!t||!t.startsWith(Xn)||!t.endsWith(Yn)))return decodeURIComponent(t.slice(Xn.length,-Yn.length))}const Qn="#domrange(",Zn=")";function Da(t){return`${Qn}${encodeURIComponent(JSON.stringify(t))}${Zn}`}function Fa(t){if(!(!t||!t.startsWith(Qn)||!t.endsWith(Zn)))try{const e=JSON.parse(decodeURIComponent(t.slice(Qn.length,-Zn.length)));return!e?.start?.cssSelector||typeof e.start.textNodeIndex!="number"?void 0:e}catch{return}}const er=":~:text=";function Et(t){return encodeURIComponent(t).replace(/-/g,"%2D")}function Ia(t){let e="";return t.prefix&&(e+=`${Et(t.prefix)}-,`),e+=Et(t.textStart),t.textEnd&&(e+=`,${Et(t.textEnd)}`),t.suffix&&(e+=`,-${Et(t.suffix)}`),`${er}${e}`}function Rd(t){if(!t)return;const e=t.indexOf(er);if(e===-1)return;const n=t.slice(e+er.length).split("&")[0];if(n)try{let r=n.split(",");const i={textStart:""};return r[0].endsWith("-")&&(i.prefix=decodeURIComponent(r[0].slice(0,-1)),r=r.slice(1)),r.length>0&&r[r.length-1].startsWith("-")&&(i.suffix=decodeURIComponent(r[r.length-1].slice(1)),r=r.slice(0,-1)),r.length===0||r[0]===""?void 0:(i.textStart=decodeURIComponent(r[0]),r.length>1&&(i.textEnd=decodeURIComponent(r[1])),i)}catch{return}}function tr(t){const e=t?.textref;if(!e)return;const n=e.indexOf(":~:"),r=n===-1?e:e.slice(0,n);let i,s;const o=Fa(r);if(o)s=o,i=o.start.cssSelector;else{const l=Na(r);l!==void 0?i=l:t?.id&&r===`#${CSS.escape(t.id)}`&&(i=r)}const a=Rd(e);if(i===void 0&&s===void 0&&a===void 0)return;const c={};return i!==void 0&&(c.cssSelector=i),s!==void 0&&(c.domRange=s),a?.textEnd!==void 0?c.fragment=Ia(a):a&&(c.text={highlight:a.textStart},a.prefix!==void 0&&(c.text.before=a.prefix),a.suffix!==void 0&&(c.text.after=a.suffix)),c}const Nd={contextualizations:{abstract:{block:{start:"Start of the abstract.",end:"End of the abstract."}},acknowledgments:{block:{start:"Start of the acknowledgments.",end:"End of the acknowledgments."}},afterword:{block:{start:"Start of the afterword.",end:"End of the afterword."}},appendix:{block:{start:"Start of the appendix.",end:"End of the appendix."}},aside:{block:{start:"Start of the aside.",end:"End of the aside."}},audio:{inline:{labelled:"Audio with a label: {{ description }}",unlabelled:"Audio with no label."}},bibliography:{block:{start:"Start of the bibliography.",end:"End of the bibliography."}},blockquote:{inline:"Blockquote."},cell:{inline:{withHeader:"{{ header }}: {{ value }}",withoutHeader:"{{ value }}"}},chapter:{block:{start:"Start of the chapter.",end:"End of the chapter."}},colophon:{inline:"Colophon."},complementary:{block:{start:"Start of the complementary content.",end:"End of the complementary content."}},conclusion:{block:{start:"Start of the conclusion.",end:"End of the conclusion."}},cover:{inline:{labelled:"Cover with a label: {{ description }}",unlabelled:"Cover with no label."}},credit:{inline:"Credit."},credits:{block:{start:"Start of the credits.",end:"End of the credits."}},dedication:{inline:"Dedication."},definition:{inline:"Definition."},details:{block:{start:"Start of the disclosure.",end:"End of the disclosure."}},endnotes:{block:{start:"Start of the endnotes.",end:"End of the endnotes."}},epigraph:{inline:"Epigraph."},epilogue:{block:{start:"Start of the epilogue.",end:"End of the epilogue."}},errata:{block:{start:"Start of the errata.",end:"End of the errata."}},example:{block:{start:"Start of the example.",end:"End of the example."}},figure:{inline:"Figure: {{ description }}"},footnote:{block:{start:"Start of the footnote.",end:"End of the footnote."}},foreword:{block:{start:"Start of the foreword.",end:"End of the foreword."}},glossary:{block:{start:"Start of the glossary.",end:"End of the glossary."}},heading1:{inline:"Heading level 1."},heading2:{inline:"Heading level 2."},heading3:{inline:"Heading level 3."},heading4:{inline:"Heading level 4."},heading5:{inline:"Heading level 5."},heading6:{inline:"Heading level 6."},image:{inline:{labelled:"Image with a label: {{ description }}",unlabelled:"Image with no label."}},index:{block:{start:"Start of the index.",end:"End of the index."}},introduction:{block:{start:"Start of the introduction.",end:"End of the introduction."}},list:{block:{start:"Start of the list.",end:"End of the list."}},listItem:{inline:"List item."},math:{inline:{labelled:"{{ description }}",unlabelled:"Math formula with no label."}},notice:{inline:"Notice."},pagebreak:{inline:"Pagebreak."},pagelist:{block:{start:"Start of the page list.",end:"End of the page list."}},part:{inline:"Part."},preface:{block:{start:"Start of the preface.",end:"End of the preface."}},prologue:{block:{start:"Start of the prologue.",end:"End of the prologue."}},pullquote:{inline:"Pullquote."},qna:{block:{start:"Start of the questions and answers.",end:"End of the questions and answers."}},row:{inline:"Row: {{ count }}"},rowheader:{inline:{withHeader:"{{ header }}: {{ value }}",withoutHeader:"{{ value }}"}},separator:{inline:"Separator."},subtitle:{inline:"Subtitle."},summary:{inline:"Summary."},table:{block:{end:"End of the table.",start:{labelled:"Table: {{ description }}. {{ lines }}. {{ columns }}.",unlabelled:"Table. {{ lines }}. {{ columns }}."}},inline:{labelled:"Table: {{ description }}. {{ lines }}. {{ columns }}.",unlabelled:"Table. {{ lines }}. {{ columns }}."},parts:{columns_one:"1 column",columns_other:"{{ count }} columns",lines_one:"1 line",lines_other:"{{ count }} lines"}},term:{inline:"Term."},tip:{inline:"Tip."},video:{inline:{labelled:"Video with a label: {{ description }}",unlabelled:"Video with no label."}}}},Dd={speech:Nd},kr=Dd.speech.contextualizations,Ui={en:kr},Fd={};async function Id(t){const e=Ui[t];if(e)return e;const n=Fd[t];if(!n)return kr;const r=(await n()).speech.contextualizations;return Ui[t]=r,r}const Pd=/<lang xml:lang="[^"]*">([\s\S]*?)<\/lang>/g;function Pa(t){return t.replace(Pd,"$1")}const Ld=/\s*<readium:[a-zA-Z][\w-]*\s+id="[^"]*"\s*\/>\s*/g;function $d(t){return t.replace(Ld,(n,r,i)=>{const s=i.slice(r+n.length);return s.length===0||Qt(s)?"":" "}).replace(/ {2,}/g," ").trim()}function _d(t){return t.includes("<")}function Or(t){if(t===void 0)return;if(typeof t=="string")return{plain:t};const e={language:t.language};if(t.ssml){const n=$d(t.ssml);_d(n)&&(e.ssml=n)}return t.plain&&(e.plain=t.plain),e.plain||e.ssml?e:void 0}function tn(t){return t.replace(/<[^>]+>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ {2,}/g," ").trim()}const La=/<lang xml:lang="([^"]*)">([\s\S]*?)<\/lang>/g;function $a(t){return new RegExp(La).test(t)}function Vi(t){return t.replace(/<[^>]+>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ {2,}/g," ")}const Bd=new RegExp(`\\s+|[${$n}]+|[${De}]+|[^\\s${$n}${De}]+`,"gu");function Cn(t){const e=[];for(const[n]of t.matchAll(Bd))/^\s/.test(n)?e.push({kind:"space"}):Tu(n)?e.push({kind:"open",text:n}):Qt(n)?e.push({kind:"close",text:n}):e.push({kind:"word",text:n});return e}function qd(t){let e="",n=!1;for(const r of t){if(r.kind==="space"){e&&(n=!0);continue}n&&(e+=" "),e+=r.text,n=!1}return e}function Ud(t){let e=t.length;for(;e>0&&(t[e-1].kind==="space"||t[e-1].kind==="open");)e--;return t.slice(e).some(n=>n.kind==="open")?t.splice(e):[]}function Vd(t){let e=0;for(;e<t.length&&(t[e].kind==="space"||t[e].kind==="close");)e++;return t.slice(0,e).some(n=>n.kind==="close")?t.splice(0,e):[]}function _a(t,e){const n=[];let r=0;for(const s of t.matchAll(La))n.push({tokens:Cn(Vi(t.slice(r,s.index))),language:e,tagged:!1}),n.push({tokens:Cn(tn(s[2])),language:s[1],tagged:!0}),r=s.index+s[0].length;n.push({tokens:Cn(Vi(t.slice(r))),language:e,tagged:!1});for(let s=0;s<n.length-1;s++)!n[s].tagged&&n[s+1].tagged?n[s+1].tokens.unshift(...Ud(n[s].tokens)):n[s].tagged&&!n[s+1].tagged&&n[s].tokens.push(...Vd(n[s+1].tokens));const i=[];for(const s of n){const o=qd(s.tokens);o&&i.push({plain:o,language:s.language})}return i}const Ba=/<readium:[a-zA-Z][\w-]*\s+id="([^"]*)"\s*\/>/g;function zd(t){return new RegExp(Ba).test(t)}function Md(t){const e=[];let n=0;for(const i of t.matchAll(Ba)){const s=t.slice(n,i.index).trim();s&&e.push({ssml:s}),e.push({placeholderId:i[1]}),n=i.index+i[0].length}const r=t.slice(n).trim();return r&&e.push({ssml:r}),e}const jd=["aside","audio","bibliography","biblioref","cell","columnheader","details","endnotes","figure","footnote","glossary","image","landmarks","loa","loi","lot","lov","noteref","pagebreak","pullquote","row","rowheader","table","toc","video"],qa=["heading1","heading2","heading3","heading4","heading5","heading6","paragraph","blockquote","preformatted","pullquote","list","listItem","table","row","cell","columnheader","rowheader","audio","video","figure","image","math","abstract","acknowledgments","afterword","appendix","article","aside","bibliography","chapter","colophon","conclusion","dedication","endnotes","epigraph","epilogue","errata","example","footnote","foreword","glossary","index","introduction","notice","part","preface","prologue","qna","section","summary","tip"],Hd={footnote:{drops:["aside"],unconditional:!0},cover:{drops:["image"]},pullquote:{drops:["blockquote","aside"]},epigraph:{drops:["blockquote"]}},Wd=["noteref","pagebreak"],Gd=["audio","video","image","figure","math","table","cover"],Kd=["cell","rowheader"],Jd=["separator"];function Ua(t){const e=Or(t.text);return e?e.plain??(e.ssml?tn(e.ssml):""):""}function Xd(t){const e=new Map,n=new Map;let r=0,i;return t.forEach((s,o)=>{e.set(s,o+1);const a=s.children??[];if(r=Math.max(r,a.length),a.some(c=>c.role?.includes("columnheader"))){i=a.map(Ua);return}i&&a.forEach((c,l)=>{const u=c.role??[];if(!u.includes("cell")&&!u.includes("rowheader"))return;const h=i[l];h&&n.set(c,h)})}),{lines:t.length,columns:r,rowNumbers:e,cellHeaders:n}}const Yd=new Set(qa),Qd=new Set(Wd),Zd=new Set(Gd),Ar=new Set(Kd),ef=new Set(Jd);function lt(t,e,n,r){const i=n?`${e}.${n}`:void 0;if(i&&t.i18n.exists(i))return t.i18n.t(i,r);if(t.i18n.exists(e))return t.i18n.t(e,r)}function fe(t,e){return e==="ssml"?{ssml:zt(t),synthetic:!0}:{plain:t,synthetic:!0}}function ge(t,e,n,r){t.push(...r);for(let i=0;i<r.length;i++)e.push(n)}function Va(t,e,n,r,i,s,o){o?(i.some(a=>n.blockStarts.has(a))&&n.blockStarts.add(o),ge(t,e,s[0]??r,[o])):(t.push(...i),e.push(...s))}function Tr(t,e){return Ar.has(t)?!0:e.contextualize.has(t)}function tf(t,e,n){return e.some(r=>{const i=Hd[r];return i?.drops.includes(t)?i.unconditional||Tr(r,n):!1})}function zi(t,e,n,r,i,s,o,a){if(!Tr(i,r))return;if((r.i18n.exists(`${i}.block.start`)||r.i18n.exists(`${i}.block.end`))&&r.contextualizationShapes[i]!=="inline"){const l=s==="before"?`${i}.block.start`:`${i}.block.end`,u=lt(r,l,o,a);u&&ge(t,e,n,[fe(u,r.format)]);return}if(s==="before"){const l=lt(r,`${i}.inline`,o,a);if(l){const u=fe(l,r.format);if(Ar.has(i)&&(delete u.synthetic,r.language!=="none")){const h=typeof n.text=="object"?n.text.language:void 0;h&&(u.language=h)}ge(t,e,n,[u])}}}function Mi(t,e){return e.size>0&&t.some(n=>e.has(n))}function Rr(t,e){let n,r=!1;const i=[];for(const a of t){const c=e==="ssml"?a.ssml:a.plain;if(c&&(i.push(c),a.language!==void 0)){if(r&&a.language!==n)return;n=a.language,r=!0}}if(i.length===0)return;let s="";for(const a of i)a.length===1&&s.endsWith(a)||(s&&!Qt(a)&&(s+=" "),s+=a);const o=e==="ssml"?{ssml:s}:{plain:s};return n&&(o.language=n),t.some(a=>a.synthetic)&&(o.synthetic=!0),o}function nf(t,e){const n=Or(t.text),r=n?za(n,e.format,e.language):[];if(!e.contextualize.has("pagebreak"))return r;const i=e.i18n.exists("pagebreak.block.start")?"pagebreak.block.start":"pagebreak.inline",s=lt(e,i);if(s===void 0)return r;const o=fe(s,e.format);if(r.length===0)return[o];const a=Rr([o,...r],e.format);return a?(a.plain!==void 0&&(a.plain+="."),a.ssml!==void 0&&(a.ssml+="."),[a]):[o,...r]}function za(t,e,n){if(e==="plain"&&n!=="block-level"&&n!=="none"&&t.ssml&&$a(t.ssml))return _a(t.ssml,t.language).map(i=>{const s={plain:i.plain};return i.language&&(s.language=i.language),s});const r={};return t.language&&(r.language=t.language),e==="ssml"?r.ssml=t.ssml??zt(t.plain??""):r.plain=t.plain??tn(t.ssml??""),(n==="block-level"||n==="none")&&(r.ssml&&(r.ssml=Pa(r.ssml)),n==="none"&&delete r.language),[r]}function rf(t){return(t.role??[]).some(e=>Qd.has(e))}function sf(t,e,n,r,i,s){const o=typeof t.text=="object"?t.text.language:void 0,a=new Map((t.children??[]).map(d=>[d.id,d])),c=[],l=[],u=[];for(const d of Md(e)){if(d.placeholderId!==void 0){const p=a.get(d.placeholderId);if(!p)continue;i.inlineContextualization||!rf(p)?Ma(p,c,l,i,s):u.push(p);continue}if(!d.ssml)continue;if(i.format==="plain"&&i.language!=="block-level"&&i.language!=="none"&&$a(d.ssml)){for(const p of _a(d.ssml,o)){const m={plain:p.plain};p.language&&(m.language=p.language),c.push(m),l.push(t)}continue}const g={};o&&(g.language=o),i.format==="ssml"?g.ssml=d.ssml:g.plain=tn(d.ssml),(i.language==="block-level"||i.language==="none")&&(g.ssml&&(g.ssml=Pa(g.ssml)),i.language==="none"&&delete g.language),c.push(g),l.push(t)}const h=c.length>1?Rr(c,i.format):void 0;return Va(n,r,i,t,c,l,h),u}function ji(t,e,n,r){const i=`${e}.parts.${n}`;return t.i18n.exists(i,{count:r})?t.i18n.t(i,{count:r}):String(r)}function af(t){return t.description===void 0?{variantKey:"unlabelled"}:{variantKey:"labelled",params:{description:t.description}}}function Hi(t,e){const n=e.tableCellHeaders.get(t);return{variantKey:n!==void 0?"withHeader":"withoutHeader",params:{header:n??"",value:Ua(t)}}}const of={table:(t,e)=>{const n=(t.children??[]).filter(i=>i.role?.includes("row")),r=Xd(n);for(const[i,s]of r.rowNumbers)e.tableRowNumbers.set(i,s);for(const[i,s]of r.cellHeaders)e.tableCellHeaders.set(i,s);return{params:{lines:ji(e,"table","lines",r.lines),columns:ji(e,"table","columns",r.columns)}}},row:(t,e)=>({params:{count:String(e.tableRowNumbers.get(t)??"")}}),cell:Hi,rowheader:Hi};function Wi(t,e,n){const r=af(e);let i=r.variantKey,s=r.params;const o=of[t]?.(e,n);o&&(o.variantKey&&(i=o.variantKey),s={...s,...o.params});const a=n.contextualizationParams?.(t,e);return a&&(s={...s,...a}),{variantKey:i,params:s}}function Ma(t,e,n,r,i){const s=t.role??[];if(Mi(s,r.skip))return;const o=s.some(d=>Yd.has(d)),a=o&&!i,c=e.length,l=s.filter(d=>d!=="footnote"&&d!=="pagebreak"&&!tf(d,s,r)),u=s.some(d=>Zd.has(d)&&r.contextualize.has(d)),h=s.includes("table")&&t.description!==void 0&&!u;h&&ge(e,n,t,[fe(t.description,r.format)]);for(const d of l){if(d==="figure"&&t.description===void 0)continue;const{variantKey:g,params:p}=Wi(d,t,r);zi(e,n,t,r,d,"before",g,p)}if(s.includes("noteref"))for(const d of t.children??[]){const g=d.role??[];if(!Mi(g,r.skip))if(g.includes("footnote")){const p=[],m=[];he([d],p,m,r,i);const b=r.contextualize.has("footnote"),x=r.i18n.exists("footnote.block.start")||r.i18n.exists("footnote.block.end"),A=b?lt(r,x?"footnote.block.start":"footnote.inline"):void 0,S=b&&(A!==void 0||x),w=[],T=[];if(A!==void 0&&(w.push(fe(A,r.format)),T.push(d)),w.push(...p),T.push(...m),S&&x){const L=lt(r,"footnote.block.end");L!==void 0&&(w.push(fe(L,r.format)),T.push(d))}const F=S&&w.length>1?Rr(w,r.format):void 0;Va(e,n,r,d,w,T,F)}else he([d],e,n,r,i)}else if(!s.some(d=>ef.has(d))){const d=typeof t.text=="object"?t.text.ssml:void 0;if(d&&zd(d)){const g=sf(t,d,e,n,r,i);if(g.length>0){const p=i||o&&e.length>c;he(g,e,n,r,p)}}else if(s.includes("pagebreak")){if(ge(e,n,t,nf(t,r)),t.children){const g=i||o&&e.length>c;he(t.children,e,n,r,g)}}else{const p=s.some(m=>Ar.has(m)&&Tr(m,r))?void 0:Or(t.text);if(p&&ge(e,n,t,za(p,r.format,r.language)),t.children){const m=i||o&&e.length>c;he(t.children,e,n,r,m)}}}a&&e.length>c&&r.blockStarts.add(e[c]),t.description!==void 0&&!u&&!h&&ge(e,n,t,[fe(t.description,r.format)]);for(const d of l){if(d==="figure"&&t.description===void 0)continue;const{variantKey:g,params:p}=Wi(d,t,r);zi(e,n,t,r,d,"after",g,p)}}function he(t,e,n,r,i){t.forEach((s,o)=>Ma(s,e,n,r,o===0?i:!1))}function lf(t,e){const n=z.createInstance();return n.init({lng:t,resources:{[t]:{translation:e}},interpolation:{escapeValue:!1}}),n}function ja(t,e){if(typeof e=="string"||typeof t!="object")return e;const n={...t};for(const r of Object.keys(e))n[r]=ja(t[r],e[r]);return n}function cf(t,e){if(!e)return t;const n={...t};for(const r of Object.keys(e))n[r]=ja(t[r],e[r]);return n}async function Ha(t){const e=t.contextualizationLocale??"en",n=cf(await Id(e),t.contextualization?.contextualizations);return{contextualizations:n,i18n:lf(e,n),skip:new Set(t.skip??[]),contextualize:new Set(t.contextualize??[]),contextualizationShapes:t.contextualization?.shapes??{},contextualizationParams:t.contextualization?.params,format:t.format??"plain",inlineContextualization:t.inlineContextualization??!1,language:t.language??"block-level",blockStarts:new Set,tableRowNumbers:new Map,tableCellHeaders:new Map}}async function uf(t,e){const n=[],r=[];return he(t,n,r,await Ha(e),!1),Wa(n,r,Nr(t))}async function hf(t,e){const n=[],r=[],i=await Ha(e);he(t,n,r,i,!1);const s=n.map(o=>i.blockStarts.has(o));return{utterances:Wa(n,r,Nr(t)),sources:r,blockStarts:s}}function Nr(t,e=[],n=new Map){for(const r of t)n.set(r,e),r.children&&Nr(r.children,[r,...e],n);return n}function Wa(t,e,n){return t.map((r,i)=>{const s=e[i];let o=tr(s);if(!o&&s){for(const a of n.get(s)??[])if(o=tr(a),o)break}return o?{...r,locate:o}:r})}class df{engine;contentQueue=[];events=new Jt;navigatorState="idle";pendingAdvanceTimeout=null;_defaults;_preferences;_settings;_preferencesEditor=null;contextualizationOverrides;source;contentSources=[];contentBlockStarts=[];pendingResumeIndex=null;pendingResumeState=null;pendingAutoPauseIndex=null;constructor(e,n={}){this.engine=e,this._defaults=new Sa(n.defaults),this._preferences=new Ue(n.preferences),this._settings=new Kn(this._preferences,this._defaults),this.contextualizationOverrides=n.contextualizationOverrides,this.setupEngineListeners(),this.applyEngineParameters(),this.initializeEngine()}applyEngineParameters(){this.engine.setRate(this._settings.rate),this.engine.setPitch(this._settings.pitch),this.engine.setVolume(this._settings.volume)}async initializeEngine(){try{await this.engine.initialize?.()}catch(e){console.warn("Failed to initialize speech engine:",e)}}setupEngineListeners(){this.engine.on("start",()=>{this.setNavigatorState("playing"),this.emitEvent({type:"start"})}),this.engine.on("end",()=>{const e=this.engine.getCurrentUtteranceIndex(),n=this.engine.getUtteranceCount();if(e<n-1){const r=this._settings.autoPause==="utterance"||this.contentBlockStarts[e+1]===!0;this._settings.autoPause!=="none"&&r?(this.pendingAutoPauseIndex=e+1,this.setNavigatorState("paused"),this.emitEvent({type:"pause"})):this.pendingAdvanceTimeout=setTimeout(()=>{this.pendingAdvanceTimeout=null,this.engine.speak(e+1)},this._settings.pauseDuration)}else this.engine.setCurrentUtteranceIndex(0),this.setNavigatorState("idle");this.emitEvent({type:"end"})}),this.engine.on("pause",()=>{this.setNavigatorState("paused"),this.emitEvent({type:"pause"})}),this.engine.on("resume",()=>{this.setNavigatorState("playing"),this.emitEvent({type:"resume"})}),this.engine.on("stop",()=>{this.setNavigatorState("idle"),this.emitEvent({type:"stop"})}),this.engine.on("error",e=>{this.setNavigatorState("idle"),this.emitEvent(e)}),this.engine.on("ready",()=>{if(this.contentQueue.length===0)return;const e=this.pendingResumeIndex,n=this.pendingResumeState;if(this.pendingResumeIndex=null,this.pendingResumeState=null,this.navigatorState==="loading"){if(n==="playing"){this.setNavigatorState("playing"),this.engine.speak(e??0);return}if(n==="paused"){const r=e??0;r>0?this.engine.setCurrentUtteranceIndex(r,()=>this.setNavigatorState("paused")):this.setNavigatorState("paused");return}this.setNavigatorState("ready"),this.emitEvent({type:"ready"})}}),this.engine.on("boundary",e=>{this.emitEvent(e)}),this.engine.on("mark",e=>{this.emitEvent(e)}),this.engine.on("voiceschanged",()=>{this.emitEvent({type:"voiceschanged"})}),this.engine.on("languagefallback",e=>{this.emitEvent(e)}),this.engine.on("enginefallback",e=>{this.emitEvent(e)}),this.engine.on("enginerecovered",e=>{this.emitEvent(e)})}setNavigatorState(e){this.navigatorState=e}async getVoices(){return this.engine.getAvailableVoices()}setVoice(e){this.engine.setVoice(e)}getCurrentVoice(){return this.engine.getCurrentVoice()}setSpeakInContentLanguage(e){this.engine.setSpeakInContentLanguage(e)}getSpeakInContentLanguage(){return this.engine.getSpeakInContentLanguage()}loadContent(e){if(this.source)throw new Error("loadContent() cannot be used after loadGndContent() — the two are exclusive. Create a new navigator instance to switch content sources.");this.setContentQueue(e)}async loadGndContent(e){this.source=e,await this.reextract()}setContentQueue(e,n=null,r=null){this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,(this.navigatorState==="playing"||this.navigatorState==="paused")&&this.engine.stop();const i=Array.isArray(e)?e:[e];this.contentQueue=[...i],this.pendingResumeIndex=n,this.pendingResumeState=r,this.setNavigatorState("loading"),this.emitEvent({type:"loading"}),this.engine.loadUtterances(i,n??void 0),this.emitContentChangeEvent({content:i})}async reextract(){if(!this.source)return;const e=this.navigatorState==="playing"||this.navigatorState==="paused"?this.navigatorState:null,n=this.contentSources,r=this.getCurrentUtteranceIndex(),{utterances:i,sources:s,blockStarts:o}=await hf(this.source,{format:this._settings.format,inlineContextualization:this._settings.inlineContextualization,skip:this._settings.skip,contextualize:this._settings.contextualize,contextualization:{contextualizations:this.contextualizationOverrides?.contextualizations,shapes:id(this._settings.verbosity,this.contextualizationOverrides?.shapes),params:this.contextualizationOverrides?.params},language:this._settings.language});this.contentSources=s,this.contentBlockStarts=o;const a=e?this.resolveResumeIndex(n,r,s):null;this.setContentQueue(i,a,e)}resolveResumeIndex(e,n,r){for(let i=Math.min(n,e.length-1);i>=0;i--){const s=e[i];if(s===void 0)continue;const o=r.indexOf(s);if(o!==-1)return o}return null}getCurrentContent(){const e=this.getCurrentUtteranceIndex();return e<this.contentQueue.length?this.contentQueue[e]:null}getContentQueue(){return[...this.contentQueue]}getCurrentUtteranceIndex(){return this.engine.getCurrentUtteranceIndex()}play(){if(this.navigatorState==="paused")if(this.setNavigatorState("playing"),this.pendingAutoPauseIndex!==null){const e=this.pendingAutoPauseIndex;this.pendingAutoPauseIndex=null,this.engine.speak(e)}else this.engine.resume();else if(this.navigatorState==="ready"||this.navigatorState==="idle")this.setNavigatorState("playing"),this.engine.speak();else if(this.navigatorState==="playing")return}pause(){this.navigatorState==="playing"&&(this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,this.setNavigatorState("paused"),this.engine.pause())}stop(){this.clearPendingAdvance(),this.pendingAutoPauseIndex=null,this.setNavigatorState("idle"),this.engine.stop(),this.emitEvent({type:"stop"})}clearPendingAdvance(){this.pendingAdvanceTimeout!==null&&(clearTimeout(this.pendingAdvanceTimeout),this.pendingAdvanceTimeout=null)}skipToPosition(e,n=!1){const r=this.getCurrentUtteranceIndex();return e<0||e>=this.contentQueue.length?!1:(e===r||(this.clearPendingAdvance(),this.navigatorState==="paused"&&!n?(this.pendingAutoPauseIndex!==null&&(this.pendingAutoPauseIndex=e),this.engine.setCurrentUtteranceIndex(e,i=>{i&&this.emitEvent({type:"skip",detail:{position:e}})})):(this.pendingAutoPauseIndex=null,this.setNavigatorState("playing"),this.engine.speak(e))),!0)}next(e=!1){const n=this.getCurrentUtteranceIndex();return this.skipToPosition(n+1,e)}previous(e=!1){const n=this.getCurrentUtteranceIndex();return this.skipToPosition(n-1,e)}jumpTo(e,n=!1){return this.skipToPosition(e,n)}getState(){return this.navigatorState}on(e,n){return this.events.on(e,n)}emitEvent(e){this.events.emit(e.type,e)}emitContentChangeEvent(e){this.events.emit("contentchange",{type:"contentchange",detail:e})}get settings(){return this._settings}get preferencesEditor(){return this._preferencesEditor===null&&(this._preferencesEditor=new Wn(this._preferences,this.settings)),this._preferencesEditor}async submitPreferences(e){!this.source&&Ai.some(n=>e[n]!==void 0)&&console.warn("submitPreferences(): extraction-affecting preferences (format, inlineContextualization, verbosity, skip, contextualize, language) have no effect on content loaded via loadContent() — use loadGndContent() to re-extract on submission."),this._preferences=this._preferences.merging(e),await this.applyPreferences()}async applyPreferences(){const e=this._settings;this._settings=new Kn(this._preferences,this._defaults),this.applyEngineParameters(),this._preferencesEditor!==null&&(this._preferencesEditor=new Wn(this._preferences,this._settings)),Ai.some(n=>!this.sameSettingValue(e[n],this._settings[n]))&&await this.reextract()}sameSettingValue(e,n){return Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every(r=>n.includes(r)):e===n}async destroy(){this.clearPendingAdvance(),this.events.clear(),await this.engine.destroy()}}const ff=["heading1","heading2","heading3","heading4","heading5","heading6"],Gi={"doc-abstract":"abstract","doc-acknowledgments":"acknowledgments","doc-afterword":"afterword","doc-appendix":"appendix",article:"article","doc-backlink":"backlink","doc-biblioentry":"listItem","doc-bibliography":"bibliography","doc-biblioref":"biblioref",blockquote:"blockquote",caption:"caption",cell:"cell","doc-chapter":"chapter","doc-colophon":"colophon",columnheader:"columnheader",complementary:"complementary","doc-conclusion":"conclusion","doc-cover":"cover","doc-credit":"credit","doc-credits":"credits","doc-dedication":"dedication",definition:"definition","doc-endnote":"footnote","doc-endnotes":"endnotes","doc-epigraph":"epigraph","doc-epilogue":"epilogue","doc-errata":"errata","doc-example":"example",figure:"figure","doc-footnote":"footnote","doc-foreword":"foreword","doc-glossary":"glossary","doc-glossref":"glossref",img:"image",image:"image","doc-index":"index","doc-introduction":"introduction",list:"list",listitem:"listItem",main:"main",math:"math",navigation:"navigation","doc-noteref":"noteref","doc-notice":"notice","doc-pagebreak":"pagebreak","doc-pagelist":"pagelist",paragraph:"paragraph","doc-part":"part","doc-preface":"preface","doc-prologue":"prologue","doc-pullquote":"pullquote",grid:"table",gridcell:"cell",presentation:"presentation",none:"presentation","doc-qna":"qna",qna:"qna",region:"region",row:"row",rowheader:"rowheader",separator:"separator","doc-subtitle":"subtitle",table:"table",term:"term","doc-tip":"tip","doc-toc":"toc"},gf={abstract:"abstract",acknowledgments:"acknowledgments",afterword:"afterword",appendix:"appendix",aside:"aside",backlink:"backlink",biblioentry:"listItem",bibliography:"bibliography",biblioref:"biblioref","table-cell":"cell",chapter:"chapter",colophon:"colophon",conclusion:"conclusion",cover:"cover",credit:"credit",credits:"credits",dedication:"dedication",glossdef:"definition",endnote:"footnote",endnotes:"endnotes",rearnote:"footnote",rearnotes:"endnotes",epigraph:"epigraph",epilogue:"epilogue",errata:"errata",example:"example",figure:"figure",footnote:"footnote",foreword:"foreword",glossary:"glossary",glossref:"glossref",index:"index",introduction:"introduction",landmarks:"landmarks",list:"list","list-item":"listItem",loa:"loa",loi:"loi",lot:"lot",lov:"lov",noteref:"noteref",notice:"notice",pagebreak:"pagebreak","page-list":"pagelist",pagelist:"pagelist",part:"part",preface:"preface",prologue:"prologue",pullquote:"pullquote",qna:"qna","table-row":"row",subtitle:"subtitle",table:"table",glossterm:"term",tip:"tip",toc:"toc"},pf={article:"article",aside:"aside",audio:"audio",blockquote:"blockquote",caption:"caption",figcaption:"caption",td:"cell",dd:"definition",details:"details",figure:"figure",header:"header",h1:"heading1",h2:"heading2",h3:"heading3",h4:"heading4",h5:"heading5",h6:"heading6",img:"image",ul:"list",ol:"list",li:"listItem",main:"main",math:"math",nav:"navigation",p:"paragraph",pre:"preformatted",tr:"row",section:"section",hr:"separator",summary:"summary",table:"table",dfn:"term",dt:"term",video:"video",svg:"image"},mf=new Set(["table","tr","td","th"]),yf=new Set(["table","row","cell","columnheader","rowheader"]);function bf(t){const e=t.getAttribute("role");if(!e)return!1;const n=e.split(/\s+/).filter(Boolean);return n.includes("presentation")||n.includes("none")}function Sf(t){for(let e=t.parentElement;e;e=e.parentElement)if(bf(e))return!0;return!1}function vf(t,e,n){return mf.has(e)||n.some(r=>yf.has(r))}function Tt(t,e){const n=t.getAttribute("role");return n?n.split(/\s+/).filter(Boolean).includes(e):!1}function wf(t){return t.tagName.toLowerCase()==="table"||Tt(t,"table")||Tt(t,"grid")||Tt(t,"treegrid")}function xf(t){return t.tagName.toLowerCase()==="tr"||Tt(t,"row")}function Ef(t){let e=null;for(let r=t.parentElement;r;r=r.parentElement)if(wf(r)){e=r;break}return e?e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>xf(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}).nextNode()===t:!1}function Ga(t){const e=[];let n=!1;const r=t.getAttribute("role");if(r)for(const s of r.split(/\s+/).filter(Boolean))if((s==="presentation"||s==="none")&&(n=!0),s==="heading"){let o=2;const a=parseInt(t.getAttribute("aria-level")??"",10);Number.isFinite(a)&&a>=1&&(o=Math.min(a,6)),e.push(ff[o-1])}else Gi[s]&&e.push(Gi[s]);const i=t.getAttribute("epub:type");if(i)for(const s of i.split(/\s+/).filter(Boolean)){const o=gf[s];o&&e.push(o)}return{attrRoles:e,presentational:n}}function Ka(t){const{attrRoles:e,presentational:n}=Ga(t);return e.length>0||n}function Rt(t){const e=[],n=o=>{e.includes(o)||e.push(o)},{attrRoles:r,presentational:i}=Ga(t),s=t.tagName.toLowerCase();if(i)return["presentation"];if(vf(t,s,r)&&Sf(t))return["presentation"];if(s==="body")n("body");else if(s==="th")switch(t.getAttribute("scope")){case"col":n("columnheader");break;case"row":n("rowheader");break;default:{const o=t.parentElement;o&&Ef(o)?n("columnheader"):t.previousElementSibling===null?n("rowheader"):n("cell")}}else{const o=pf[s];o&&n(o)}for(const o of r)n(o);return e}function Ki(t){return!!(t.getAttribute("aria-hidden")==="true"||t.hasAttribute("hidden"))}function Cf(t){let e="";const n=r=>{r.nodeType===3&&(e+=r.nodeValue??"");for(let i=r.firstChild;i;i=i.nextSibling)n(i)};return n(t),e}function nn(t){return Ve(Cf(t),!0).trim()}function nr(t){let e="";const n=(r,i)=>{if(r.nodeType===3){e+=r.nodeValue??"";return}if(!(r.nodeType===1&&!i&&Ka(r)))for(let s=r.firstChild;s;s=s.nextSibling)n(s,!1)};return n(t,!0),e}function Ji(t){return Ve(nr(t),!0).trim()}function kf(t){if(Ki(t))return[null,!1];const e=(t.getAttribute("aria-labelledby")??"").trim();if(e){const s=[...new Set(e.split(/\s+/).filter(Boolean))],o=t.ownerDocument,a=s.map(c=>o.getElementById(c)).filter(c=>c!==null);if(a.length>0){let c="";a.forEach((u,h)=>{if(Ki(u))return;const d=u.getAttribute("aria-label");c+=d||nr(u),h<a.length-1&&(c+=" ")});const l=Ve(c,!0).trim();if(l!=="")return[{language:"",plain:l},!0]}}const n=(t.getAttribute("aria-label")??"").trim();if(n)return[{language:"",plain:n},!0];const r=(t.getAttribute("aria-describedby")??"").trim();if(r){const o=[...new Set(r.split(/\s+/).filter(Boolean))].map(a=>t.ownerDocument.getElementById(a)).filter(a=>a!==null);if(o.length>0){const a=o.map(l=>nr(l)).join(" "),c=Ve(a,!0).trim();if(c!=="")return[{language:"",plain:c},!0]}}const i=t.tagName.toLowerCase();if(i==="img"){const s=(t.getAttribute("alt")??"").trim();if(s)return[{language:"",plain:s},!0];const o=(t.getAttribute("title")??"").trim();if(o)return[{language:"",plain:o},!0]}else if(i==="svg"){const s=t.querySelector(":scope > title");if(s){const o=nn(s);if(o)return[{language:"",plain:o},!0]}}else if(i==="math"){const s=(t.getAttribute("alttext")??"").trim();if(s)return[{language:"",plain:s},!0]}return[null,!0]}const Of={em:["emphasis"],b:["emphasis"],i:["emphasis",{level:"reduced"}],strong:["emphasis",{level:"strong"}],br:["break"]};function Af(t){return Of[t]??["",void 0]}const Tf=new Set(["script","style","template","noscript","textarea","select","datalist","iframe","rt","rp","rtc"]),Rf=["math","separator"];function rr(t){return t.role?.some(e=>Rf.includes(e))?!1:!t.audioref&&!t.imgref&&!t.textref&&!t.videoref&&(!t.text||dt(t.text))&&!(t.children&&t.children.length>0)&&!t.description}function Nf(t){return!t.audioref&&!t.imgref&&!t.textref&&!t.videoref&&(!t.text||dt(t.text))&&!!(t.children&&t.children.length>0)&&!(t.role&&t.role.length>0)&&!t.id}function Df(t){return!(t.role&&t.role.length>0)&&!t.id&&!t.textref&&!t.imgref&&!t.audioref&&!t.videoref}class Ct{el;object={};children=[];noText=!1;finalize(){const e=this.object,n=[];for(const r of this.children){const i=r.finalize();if(!rr(i)){if(Nf(i)){n.push(...i.children??[]);continue}n.push(i)}}if(n.length>0&&(e.children=n),e.role?.length&&e.children?.length===1&&!e.role.includes("presentation")){const r=e.children[0];r.role?.length&&e.role.every(i=>r.role.includes(i))&&delete e.role}if((!e.text||dt(e.text))&&e.children?.length===1){const r=e.children[0];Df(r)&&(r.text&&(e.text=r.text),e.children=r.children)}return e}}function ir(t){const e={};t.id&&(e.id=t.id),t.textref&&(e.textref=t.textref),t.imgref&&(e.imgref=t.imgref),t.audioref&&(e.audioref=t.audioref),t.videoref&&(e.videoref=t.videoref);const n=kd(t.text);return n!==void 0&&(e.text=n),t.role&&t.role.length>0&&(e.role=t.role),t.children&&t.children.length>0&&(e.children=t.children.map(ir)),t.description&&(e.description=t.description),e}function Ja(t){const e={};return t.id&&(e.id=t.id),t.textref&&(e.textref=t.textref),t.imgref&&(e.imgref=t.imgref),t.audioref&&(e.audioref=t.audioref),t.videoref&&(e.videoref=t.videoref),t.role&&(e.role=t.role),t.description&&(e.description=t.description),typeof t.text=="string"?e.text={plain:t.text,ssml:"",language:""}:t.text&&(e.text={plain:t.text.plain??"",ssml:t.text.ssml??"",language:t.text.language}),t.children&&(e.children=t.children.map(Ja)),e}const Ff=1;function Xi(t){for(let e=t;e;e=e.parentElement){const n=e.getAttribute("xml:lang");if(n)return n;const r=e.getAttribute("lang");if(r)return r}return""}function If(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType===Ff)return!0;return!1}function Xa(t,e){for(let n=e;n;n=n.parentElement)if(n===t)return!0;return!1}const Pf=new Set(["object","base","font","tt","i","b","u","big","small","em","strong","dfn","code","samp","kbd","var","cite","abbr","time","acronym","mark","ruby","rt","rp","rtc","a","img","br","wbr","map","q","sub","sup","bdo","iframe","embed","span","input","select","textarea","label","button","optgroup","option","legend","datalist","keygen","output","progress","meter","area","param","source","track","summary","command","basefont","bgsound","menuitem","data","bdi","s","strike","nobr","rb"]);function Lf(t){return Pf.has(t)}function $f(t){const e=t.slice(0,500);return/<\?xml\b/.test(e)||/xmlns:epub=/.test(e)||/DOCTYPE\s+html\s+PUBLIC\s+"-\/\/W3C\/\/DTD XHTML/i.test(e)?"application/xhtml+xml":"text/html"}function Ya(t){return typeof t=="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE}const ct={NONE:"",DESCENDANT:" ",CHILD:" > "},$={id:"id",class:"class",tag:"tag",attribute:"attribute",nthchild:"nthchild",nthoftype:"nthoftype"};function _f(t,e){return Object.values(t).includes(e)}const Bf="CssSelectorGenerator";function Mt(t="unknown problem",...e){console.warn(`${Bf}: ${t}`,...e)}const qf={selectors:[$.id,$.class,$.tag,$.attribute],includeTag:!1,whitelist:[],blacklist:[],combineWithinSelector:!0,combineBetweenSelectors:!0,root:null,maxCombinations:Number.POSITIVE_INFINITY,maxCandidates:Number.POSITIVE_INFINITY,useScope:!1,ignoreGeneratedClassNames:!1};function Ye(t){return!!t}function Uf(t){return Array.isArray(t)?t.filter(e=>_f($,e)):[]}function Qa(t){return t instanceof RegExp}function Vf(t){return["string","function"].includes(typeof t)||Qa(t)}function Yi(t){return Array.isArray(t)?t.filter(Vf):[]}function zf(t){return t!=null&&typeof t=="object"&&"nodeType"in t&&typeof t.nodeType=="number"}function Qi(t){const e=[Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE];return zf(t)&&e.includes(t.nodeType)}function Za(t,e){if(Qi(t))return t.contains(e)||Mt("element root mismatch","Provided root does not contain the element. This will most likely result in producing a fallback selector using element's real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will not work as intended."),t;const n=e.getRootNode({composed:!1});return Qi(n)?(n.nodeType!==Node.DOCUMENT_NODE&&Mt("shadow root inferred","You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."),n):Fr(e)}function kn(t){return typeof t=="number"?t:Number.POSITIVE_INFINITY}function Mf(t,e={}){const n=Object.assign(Object.assign({},qf),e);return{selectors:Uf(n.selectors),whitelist:Yi(n.whitelist),blacklist:Yi(n.blacklist),root:Za(n.root,t),combineWithinSelector:Ye(n.combineWithinSelector),combineBetweenSelectors:Ye(n.combineBetweenSelectors),includeTag:Ye(n.includeTag),maxCombinations:kn(n.maxCombinations),maxCandidates:kn(n.maxCandidates),useScope:Ye(n.useScope),maxResults:kn(n.maxResults),ignoreGeneratedClassNames:Ye(n.ignoreGeneratedClassNames)}}function ft(t=[]){const[e=[],...n]=t;return n.length===0?e:n.reduce((r,i)=>{const s=new Set(i);return r.filter(o=>s.has(o))},e)}function jf(t){return[].concat(...t)}function Hf(t){return t.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".+")}function jt(t){const e=t.map(n=>{if(Qa(n))return r=>n.test(r);if(typeof n=="function")return r=>{const i=n(r);return typeof i!="boolean"?(Mt("pattern matcher function invalid","Provided pattern matching function does not return boolean. It's result will be ignored.",n),!1):i};if(typeof n=="string"){const r=new RegExp("^"+Hf(n)+"$");return i=>r.test(i)}return Mt("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",n),()=>!1});return n=>e.some(r=>r(n))}function Dr(t,e,n){const r=Za(n,t[0]).querySelectorAll(e);if(r.length!==t.length)return!1;const i=new Set(r);return t.every(s=>i.has(s))}function eo(t,e){e=e??Fr(t);const n=[];let r=t;for(;r&&r!==e;)Ya(r)&&n.push(r),r=r.parentNode;return n}function Wf(t,e){return ft(t.map(n=>eo(n,e)))}function Gf(t){return typeof t=="object"&&t!==null&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function Fr(t){return t.ownerDocument.querySelector(":root")}const to=", ",Kf=new RegExp(["^$","\\s"].join("|")),Jf=new RegExp(["^$"].join("|")),no=[$.nthoftype,$.tag,$.id,$.class,$.attribute,$.nthchild],Xf=jt(["class","id","ng-*"]);function Yf({name:t}){return`[${t}]`}function Qf({name:t,value:e}){return`[${t}='${e}']`}function Zf({nodeName:t,nodeValue:e},n){const r=n.tagName.toLowerCase();return["input","option"].includes(r)&&t==="value"||t==="src"&&e?.startsWith("data:")?!1:!Xf(t)}function eg({nodeName:t,nodeValue:e}){return{name:ze(t),value:ze(e??void 0)}}function ro(t,e){const n=Array.from(t.attributes).filter(r=>Zf(r,t)).map(eg);return[...n.map(Yf),...n.map(Qf)]}function tg(t,e){const n=t.map(r=>ro(r));return ft(n)}const ng=/^[a-z_-]{3,}$/i,rg=/[bcdfghjklmnpqrstvwxyz]{4,}/i;function ig(t){if(!ng.test(t)||t.includes("_")&&!t.includes("__")||/^(css|sc|jsx|emotion|makeStyles|MuiButton|MuiBox)-/i.test(t))return!1;const e=t.split(new RegExp("--|__|[-]|(?<=[a-z])(?=[A-Z])")).filter(n=>n.length>0);if(e.length===0||e.length===1&&e[0].length<4)return!1;for(const n of e)if(n.length<=2||rg.test(n))return!1;return!0}function io(t,e){var n;const r=((n=t.getAttribute("class"))!==null&&n!==void 0?n:"").trim().split(/\s+/).filter(s=>!Jf.test(s));let i=r;if(e?.ignoreGeneratedClassNames){const s=jt(e.whitelist);i=r.filter(o=>{const a=`.${ze(o)}`;return s(a)?!0:ig(o)})}return i.map(s=>`.${ze(s)}`)}function sg(t,e){const n=t.map(r=>io(r,e));return ft(n)}function so(t,e){var n;const r=(n=t.getAttribute("id"))!==null&&n!==void 0?n:"",i=`#${ze(r)}`,s=t.getRootNode({composed:!1});return!Kf.test(r)&&Dr([t],i,s)?[i]:[]}function ag(t,e){return t.length===0||t.length>1?[]:so(t[0])}function ao(t,e){const n=t.parentNode,r=n&&"children"in n?n.children:null;if(r){for(let i=0;i<r.length;i++)if(r[i]===t)return[`:nth-child(${String(i+1)})`]}return[]}function og(t,e){return ft(t.map(n=>ao(n)))}function oo(t,e){return[ze(t.tagName.toLowerCase())]}function lo(t,e){const n=[...new Set(jf(t.map(r=>oo(r))))];return n.length===0||n.length>1?[]:[n[0]]}function co(t,e){const n=lo([t])[0],r=t.parentNode,i=r&&"children"in r?r:null;if(i){const o=Array.from(i.children).filter(a=>a.tagName.toLowerCase()===n).indexOf(t);if(o>-1)return[`${n}:nth-of-type(${String(o+1)})`]}return[]}function lg(t,e){return ft(t.map(n=>co(n)))}function*uo(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){let n=0,r=ho(1);for(;r.length<=t.length&&n<e;){n+=1;const i=new Array(r.length);for(let s=0;s<r.length;s++)i[s]=t[r[s]];yield i,r=ug(r,t.length-1)}}function cg(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){return Array.from(uo(t,{maxResults:e}))}function ug(t=[],e=0){const n=t.length;if(n===0)return t;let r=n-1;for(;r>=0&&t[r]===e-(n-1-r);)r-=1;if(r<0)return ho(n+1);t[r]+=1;for(let i=r+1;i<n;i++)t[i]=t[i-1]+1;return t}function ho(t=1){const e=new Array(t);for(let n=0;n<t;n++)e[n]=n;return e}function*hg(t={}){const e=Object.entries(t);if(e.length===0)return;const n=[{index:e.length-1,partial:{}}];for(;n.length>0;){const r=n.pop();if(!r)break;const{index:i,partial:s}=r;if(i<0){yield s;continue}const[o,a]=e[i];for(let c=a.length-1;c>=0;c--)n.push({index:i-1,partial:Object.assign(Object.assign({},s),{[o]:a[c]})})}}const dg="3a".toUpperCase(),fg=/[ !"#$%&'()[\]{|}<>*+,./;=?@^`~\\]/;function ze(t=""){return CSS?CSS.escape(t):gg(t)}function gg(t=""){return t.split("").map(e=>e===":"?`\\${dg} `:fg.test(e)?`\\${e}`:escape(e).replace(/%/g,"\\")).join("")}const pg={tag:lo,id:ag,class:sg,attribute:tg,nthchild:og,nthoftype:lg},mg={tag:oo,id:so,class:io,attribute:ro,nthchild:ao,nthoftype:co};function yg(t,e,n){return mg[e](t,n)}function bg(t,e,n){const r=pg[e];return r(t,n)}function Sg(t=[],e,n){return t.filter(r=>n(r)||!e(r))}function vg(t=[],e){return t.sort((n,r)=>{const i=e(n),s=e(r);return i&&!s?-1:!i&&s?1:0})}function rn(){const t=new Map;let e;return(n,r)=>{if(n.length!==1)return e??(e=Zi(n,r));const[i]=n;let s=t.get(i);return s||(s=Zi(n,r),t.set(i,s)),s}}function*wg(t,e,n=rn()){const r=new Set,i=n(t,e);for(const s of kg(i,e))r.has(s)||(r.add(s),yield s)}function Zi(t,e){const{blacklist:n,whitelist:r,combineWithinSelector:i,maxCombinations:s}=e,o=jt(n),a=jt(r),c=(l,u)=>{const h=bg(t,u,e),d=Sg(h,o,a),g=vg(d,a);return l[u]=i?Array.from(uo(g,{maxResults:s})):g.map(p=>[p]),l};return xg(e).reduce(c,{})}function xg(t){const{selectors:e,includeTag:n}=t,r=[...e];return n&&!r.includes("tag")&&r.push("tag"),r}function Eg(t){return t.includes($.tag)||t.includes($.nthoftype)?[...t]:[...t,$.tag]}function Cg(t){const{selectors:e,combineBetweenSelectors:n,includeTag:r,maxCandidates:i}=t,s=n?cg(e,{maxResults:i}):e.map(o=>[o]);return r?s.map(Eg):s}function*kg(t,e){for(const n of Cg(e))yield*Og(n,t)}function*Og(t,e){const n={};for(const r of t){const i=e[r];i&&i.length>0&&(n[r]=i)}for(const r of hg(n))yield Tg(r)}function Ag(t,e){return e[t]?e[t].join(""):""}function Tg(t={}){const e=[...no];return t[$.tag]&&t[$.nthoftype]&&e.splice(e.indexOf($.tag),1),e.map(n=>Ag(n,t)).join("")}function Rg(t,e){return[...t.map(n=>e+ct.DESCENDANT+n),...t.map(n=>e+ct.CHILD+n)]}function*Ng(t,e){if(e==="")yield*t;else for(const n of t)yield*Rg([n],e)}function*Dg(t,e,n="",r,i=rn()){const s=wg(t,r,i);for(const o of Ng(s,n))Dr(t,o,e)&&(yield o)}function*Fg(t,e,n="",r,i=rn()){if(t.length===0)return null;const s=[t.length>1?t:[],...Wf(t,e).map(o=>[o])];for(const o of s)for(const a of Dg(o,e,n,r,i))yield{foundElements:o,selector:a}}function*Ig({elements:t,root:e,rootSelector:n="",options:r}){let i=e,s=n,o=!0;const a=rn();for(;o;){let c=!1;for(const l of Fg(t,i,s,r,a)){const{foundElements:u,selector:h}=l;if(c=!0,Dr(t,h,e))yield h;else{i=u[0],s=h;break}}c||(o=!1)}}function Pg(t){(t instanceof NodeList||t instanceof HTMLCollection)&&(t=Array.from(t));const e=(Array.isArray(t)?t:[t]).filter(Ya);return[...new Set(e)]}function Lg(t){return{value:t,include:!1}}function $g(t,e,n=ct.NONE){const r={};return e.forEach(i=>{Reflect.set(r,i,yg(t,i).map(Lg))}),{element:t,operator:n,selectors:r}}function _g({selectors:t,operator:e}){let n=[...no];t[$.tag]&&t[$.nthoftype]&&(n=n.filter(i=>i!==$.tag));let r="";return n.forEach(i=>{var s;((s=t[i])!==null&&s!==void 0?s:[]).forEach(({value:a,include:c})=>{c&&(r+=a)})}),e+r}function Bg(t,e){const n=eo(t,e).reverse(),r=Gf(e),i=n.map((o,a)=>{var c;const l=$g(o,[$.nthchild],r&&a===0?ct.NONE:ct.CHILD);return((c=l.selectors.nthchild)!==null&&c!==void 0?c:[]).forEach(u=>{u.include=!0}),l});return[r?"":e?":scope":":root",...i.map(_g)].join("")}function qg(t,e){return t.map(n=>Bg(n,e)).join(to)}var Ug=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n};function fo(t,e={}){const n=Object.assign(Object.assign({},e),{maxResults:1});return Vg(t,n).next().value}function*Vg(t,e={}){var n;const r=Pg(t),i=Mf(r[0],e),s=(n=i.root)!==null&&n!==void 0?n:Fr(r[0]);let o=0;for(const c of Ig({elements:r,options:i,root:s,rootSelector:""}))if(yield c,o++,o>=i.maxResults)return;if(r.length>1){const{maxResults:c}=e,l=Ug(e,["maxResults"]);if(yield r.map(u=>fo(u,l)).join(to),o++,o>=i.maxResults)return}const a=e.root!==void 0;yield qg(r,i.useScope||a?s:void 0)}function Ir(t,e){const n=t.getAttribute("id");return n?`#${CSS.escape(n)}`:fo(t,{root:e?.documentElement??void 0})??void 0}function go(t){if(t)return t.startsWith("#")?t:Ra(t)}const zg=3;function Mg(t,e){let n=0;for(const r of Array.from(t.childNodes)){if(r===e)return n;r.nodeType===zg&&n++}return n}function es(t,e,n,r){const i=t.parentElement;if(!i)return;const s=r&&i===r.el?r.selector:Ir(i,n);if(s)return{cssSelector:s,textNodeIndex:Mg(i,t),charOffset:e}}function jg(t,e,n){const r=es(...t.first,e,n);if(!r)return;const i=es(...t.last,e,n);return i?{start:r,end:i}:{start:r}}function Hg(t){const e=mh(t);return e.status===de.SUCCESS?e.fragment:void 0}function ts(t){if(t===!0)return e=>e.length>0;if(Array.isArray(t)&&t.length>0){const e=new Set(t);return n=>n.some(r=>e.has(r))}return null}function Wg(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Gg(t){return Wg(t)?{predicate:ts(t.roles),domRange:!!t.domRange,textFragment:!!t.textFragment}:{predicate:ts(t),domRange:!1,textFragment:!1}}class Kg{claimed=new Set;counters=new Map;allocate(e,n){for(;;){const r=(this.counters.get(e)??0)+1;this.counters.set(e,r);const i=`${e}${r}`;if(!(n(i)||this.claimed.has(i)))return this.claimed.add(i),i}}claim(e){return this.claimed.has(e)?!1:(this.claimed.add(e),!0)}}function Jg(t,e,n){const r=[],i=(s,o)=>{const a=s.getAttribute("id");if(a&&!e.has(a)&&e.set(a,s),o=o||s.getAttribute("aria-hidden")==="true"||s.hasAttribute("hidden"),!o&&s.tagName.toLowerCase()==="a"&&Rt(s).includes("noteref")){const l=s.getAttribute("href")??"";l.startsWith("#")&&r.push({id:l.slice(1),ref:s})}for(let c=s.firstElementChild;c;c=c.nextElementSibling)i(c,o)};i(t,!1);for(const s of r){const o=e.get(s.id);o&&(Xa(o,s.ref)||n.add(o))}}function Xg(t,e,n,r){const i={role:r},s=(e.getAttribute("title")??"").trim();s?i.text={plain:s,ssml:"",language:""}:n&&(i.text={plain:n.plain??"",ssml:n.ssml??"",language:n.language});const o=!!(i.text&&!dt(i.text)),a=!t.xmlParsed&&(If(e)||o&&e.firstChild!==null);if(!o&&!a){const u=nn(e);u&&(i.text={plain:u,ssml:"",language:""})}const c=Ir(e,t.docRoot),l=go(c);return l&&(i.textref=l),t.placeholder(e,"pagebreak",i),a}function Yg(t,e,n){const r={role:n},i=nn(e);i&&(r.text={plain:i,ssml:"",language:""});const s=e.getAttribute("href")??"";let o=e.getAttribute("id")??"";if(!o&&s.startsWith("#")&&(o=s.slice(1)),s.startsWith("#")){const a=s.slice(1),c=t.ids.get(a);if(c&&!Xa(c,e)&&t.noterefDepth<3){const l=t.spawnChild(c);l.convert(c);const u=l.result();u.length>0&&(r.children=u.map(h=>{const d=Ja(h);return delete d.id,d}))}}!r.children&&s&&(r.children=[{textref:s}]),t.placeholder(e,"noteref",r,o||void 0)}function Qg(t,e,n,r){const i={};if(n.length>0&&(i.role=n),r)i.text={plain:r.plain??"",ssml:r.ssml??"",language:r.language};else{const o=nn(e);o&&(i.text={plain:o,ssml:"",language:""})}const s=e.getAttribute("href");s&&(i.textref=s),t.placeholder(e,n[0]??"link",i)}const Zg=3,ep=1,tp=new Set(["summary","dfn","span"]);function ns(t,e){return tp.has(t)&&e.length>0?!0:!Lf(t)}class Ht{xmlParsed;ids=new Map;suppressed=new Set;idAlloc=new Kg;noterefDepth=0;allowNode=null;selectorPredicate=null;domRangeEnabled=!1;textFragmentEnabled=!1;docRoot=null;root=new Ct;current=this.root;foldedCaptions=new Set;segments=[];textAcc="";currentCtx={lang:"",tag:""};flowEndsWithSpace=!0;pendingChildren=[];flowFirstNode=null;flowFirstOffset=0;flowLastNode=null;flowLastOffset=0;lastFlowRange=null;lastFlowText=null;constructor(e){this.xmlParsed=e}spawnChild(e,n=1){const r=new Ht(this.xmlParsed);return r.ids=this.ids,r.suppressed=this.suppressed,r.idAlloc=this.idAlloc,r.noterefDepth=this.noterefDepth+n,r.allowNode=e,r.docRoot=this.docRoot,r.selectorPredicate=this.selectorPredicate,r.domRangeEnabled=this.domRangeEnabled,r.textFragmentEnabled=this.textFragmentEnabled,r}prescan(e){Jg(e,this.ids,this.suppressed)}convert(e){this.prescan(e),this.walk(e)}convertChildren(e){this.prescan(e);for(let n=e.firstChild;n;n=n.nextSibling)this.walk(n);this.flushText()}result(){const e=this.root.finalize();return!e.children||e.children.length===0?rr(e)?[]:[ir(e)]:e.children.map(ir)}descend(e,n){const r=new Ct;r.el=e,r.noText=this.foldedCaptions.has(e)||(!Ka(e)||n.includes("caption"))&&this.current.noText,this.current.children.push(r),this.current=r}appendChild(e){e.noText=this.current.noText,this.current.children.push(e)}walk(e){if(e.nodeType===Zg){this.text(e);return}if(e.nodeType!==ep)return;const n=e,r=this.current,i=this.head(n);if(!i)for(let s=n.firstChild;s;s=s.nextSibling)this.walk(s);this.tail(n,i,r)}head(e){const n=e.tagName.toLowerCase();if(Tf.has(n)||this.suppressed.has(e)&&e!==this.allowNode)return!0;const[r,i]=kf(e);if(!i&&e!==this.allowNode)return!0;const s=Rt(e);if((n==="img"||n==="svg")&&(s.includes("presentation")||r===null&&e.hasAttribute("alt")&&e.getAttribute("alt").trim()===""))return!0;if(n==="br")return this.current.noText||(this.closeSegment(),this.segments.push({kind:"break"}),this.flowEndsWithSpace=!0),!0;if(s.includes("pagebreak"))return!Xg(this,e,r,s);if(n==="a"&&s.includes("noteref")&&e.getAttribute("href"))return Yg(this,e,s),!0;if(n==="a"&&e.getAttribute("href"))return Qg(this,e,s,r),!0;if(n==="img"){const c={role:s},l=e.getAttribute("src");return l&&(c.imgref=l),r&&(c.description=r.plain),this.placeholder(e,"image",c),!0}if(n==="audio"||n==="video"){const c={role:s};let l=e.getAttribute("src");if(!l){const u=e.querySelector(":scope > source[src]");u&&(l=u.getAttribute("src"))}return n==="audio"?l&&(c.audioref=l):l&&(c.videoref=l),r&&(c.description=r.plain),this.placeholder(e,n,c),!0}if(s.includes("image")||s.includes("math")){const c={role:s};return r&&(c.description=r.plain),this.placeholder(e,s.includes("math")?"math":"image",c),!0}if(!ns(n,s))return!1;this.flushText(),this.descend(e,s);const o=this.current.object;if(s.length>0&&(o.role=s),r)o.description=r.plain,s.includes("figure")&&(this.current.noText=!0);else if(s.includes("figure")){const c=this.implicitCaptionOf(e);if(c){const l=Ji(c);l&&(o.description=l,this.current.noText=!0)}}else if(s.includes("table")){const c=this.implicitCaptionOf(e);if(c){const l=Ji(c);l&&(o.description=l,this.foldedCaptions.add(c))}}const a=e.getAttribute("id");return a&&(o.id=a),!1}implicitCaptionOf(e){for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(Rt(n).includes("caption")&&!n.getAttribute("aria-labelledby"))return n;return null}tail(e,n,r){if(n)return;const i=e.tagName.toLowerCase(),s=Rt(e);ns(i,s)&&(this.flushText(),this.selectorPredicate?.(s)&&this.applyTextref(e),this.current=r)}applyTextref(e){const n=this.current.object,r=Ir(e,this.docRoot);if(n.textref=go(r),this.domRangeEnabled&&this.lastFlowRange){const i=r?{el:e,selector:r}:void 0,s=jg(this.lastFlowRange,this.docRoot,i);s&&(n.textref=Da(s))}if(this.textFragmentEnabled&&this.lastFlowRange&&this.docRoot){const i=this.docRoot.createRange();i.setStart(...this.lastFlowRange.first),i.setEnd(...this.lastFlowRange.last);const s=Hg(i);s&&(n.textref=`${n.textref??"#"}${Ia(s)}`)}}text(e){if(this.current.noText)return;const n=e.nodeValue??"";if(/^\s*$/.test(n)){(this.textAcc.length>0||this.segments.length>0)&&(this.textAcc+=Ve(n,this.flowEndsWithSpace),this.updateFlowSpace());return}const r=this.textContext(e);if(Od(r,this.currentCtx)||(this.closeSegment(),this.currentCtx=r),this.textAcc+=Ve(n,this.flowEndsWithSpace),this.updateFlowSpace(),this.domRangeEnabled||this.textFragmentEnabled){const i=e;this.flowFirstNode===null&&(this.flowFirstNode=i,this.flowFirstOffset=n.search(/\S/)),this.flowLastNode=i,this.flowLastOffset=n.length-(n.match(/\s+$/)?.[0].length??0)}}textContext(e){const n={lang:Xi(e.parentElement),tag:""};for(let r=e.parentElement;r&&r!==this.current.el;r=r.parentElement){const[i,s]=Af(r.tagName.toLowerCase());if(i&&i!=="break"){n.tag=i,n.attrs=s;break}}return n}updateFlowSpace(){this.textAcc.length>0&&(this.flowEndsWithSpace=this.textAcc.endsWith(" "))}closeSegment(){this.textAcc.length!==0&&(this.segments.push({kind:"text",text:this.textAcc,ctx:this.currentCtx}),this.textAcc="")}resetFlow(){this.segments=[],this.textAcc="",this.currentCtx={lang:"",tag:""},this.flowEndsWithSpace=!0,this.pendingChildren=[],this.flowFirstNode=null,this.flowFirstOffset=0,this.flowLastNode=null,this.flowLastOffset=0}placeholder(e,n,r,i){if(rr(r))return;const s=new Ct;if(s.el=e,s.object=r,this.current.noText){this.appendChild(s);return}this.closeSegment(),this.pendingChildren.push(s),this.segments.push({kind:"placeholder",tag:n,child:s,candidateID:i??e.getAttribute("id")??void 0}),this.flowEndsWithSpace=!1}flushText(){this.closeSegment();let e=this.segments;const n=this.pendingChildren,r=this.flowFirstNode,i=this.flowFirstOffset,s=this.flowLastNode,o=this.flowLastOffset;if(this.resetFlow(),this.lastFlowRange=null,this.lastFlowText=null,e.length===0)return;for(;e.length>0;){const S=e[0];if(S.kind==="break"){e=e.slice(1);continue}if(S.kind==="text"){const w=S.text.replace(/^\s+/,"");if(w===""){e=e.slice(1);continue}e=[{...S,text:w},...e.slice(1)]}break}for(;e.length>0;){const S=e[e.length-1];if(S.kind==="break"){e=e.slice(0,-1);continue}if(S.kind==="text"){const w=S.text.replace(/\s+$/,"");if(w===""){e=e.slice(0,-1);continue}e=[...e.slice(0,-1),{...S,text:w}]}break}if(!e.some(S=>S.kind==="text"&&S.text.trim()!=="")){for(const S of n)this.appendChild(S);return}const c=[];for(const S of e)if(S.kind==="text"&&S.text.trim()!==""){const w=S.ctx.lang;c.includes(w)||c.push(w)}let l=Xi(this.current.el??null);c.length===1&&c[0]!==""&&(l=c[0]);let u=!1;for(const S of e)if(S.kind!=="text"||S.ctx.tag!==""||S.ctx.lang!==l){u=!0;break}if(u&&l===""&&(l="en"),u)for(const S of e){if(S.kind!=="placeholder")continue;let w=S.candidateID;(!w||!this.idAlloc.claim(w))&&(w=this.idAlloc.allocate(S.tag,T=>this.ids.has(T))),S.child.object.id=w}let h="",d=!1,g=!1,p=!1,m=!1;for(const S of e)if(S.kind==="text"){const w=S.text.startsWith(" "),T=S.text.replace(/^ +| +$/g,"");if(T===""){m=!0;continue}let F=!1;if(h.length>0){const L=d||m||w;g?F=!0:p?F=L&&!Qt(T):F=L}F&&(h+=" "),h+=T,d=S.text.endsWith(" "),g=!1,p=!1,m=!1}else S.kind==="break"?g=!0:S.kind==="placeholder"&&(p=!0);const b=e.some(S=>S.kind==="placeholder");this.lastFlowText=h.trim();const x={plain:u&&!b?"":h.trim(),ssml:"",language:l};if(u){let S="";for(const w of e)if(w.kind==="text"){let T=w.ctx.tag,F=w.ctx.attrs;if(w.ctx.lang!==l&&w.ctx.lang!==""&&(T="lang",F=void 0),T){S+=`<${T}`;for(const[L,X]of Object.entries(F??{}))S+=` ${L}="${En(X)}"`;w.ctx.lang!==l&&w.ctx.lang!==""&&(S+=` xml:lang="${En(w.ctx.lang)}"`),S+=`>${zt(w.text)}</${T}>`}else S+=zt(w.text)}else w.kind==="break"?S+="<break/>":w.kind==="placeholder"&&(S+=`<readium:${w.tag} id="${En(w.child.object.id)}" />`);x.ssml=S}const A=new Ct;A.object={text:x};for(const S of n)A.children.push(S);this.appendChild(A),r&&s&&(this.lastFlowRange={first:[r,i],last:[s,o]})}}const np=/<body[\s>]/i;function po(t,e,n){const{predicate:r,domRange:i,textFragment:s}=Gg(n?.textrefs);if(typeof t!="string"){const u=e??(t.ownerDocument.contentType==="text/html"?"text/html":"application/xhtml+xml"),h=new Ht(u==="application/xhtml+xml");return h.selectorPredicate=r,h.domRangeEnabled=i,h.textFragmentEnabled=s,h.docRoot=t.ownerDocument,h.convert(t),h.result()}const o=e??$f(t),a=new DOMParser().parseFromString(t,o),c=new Ht(o==="application/xhtml+xml");c.selectorPredicate=r,c.textFragmentEnabled=s,c.docRoot=a;const l=a.querySelector("body");return l&&!np.test(t)?c.convertChildren(l):c.convert(l??a.documentElement),c.result()}function rp(t,e,n){return{guided:po(t,e,n)}}exports.BUILTIN_DECORATION_TYPES=ca;exports.BooleanPreference=va;exports.DecorationController=ma;exports.DecorationLayout=aa;exports.DecorationStyleType=R;exports.DecorationWidth=sa;exports.Decorator=la;exports.DirectCommsChannel=fa;exports.DirectCommsFrame=ga;exports.DirectCommsHost=pa;exports.EnumPreference=tt;exports.FallbackEngineProvider=ju;exports.FallbackSpeechEngine=Rs;exports.Locator=Sr;exports.LocatorLocations=ue;exports.LocatorText=br;exports.Preference=ht;exports.RangePreference=nt;exports.ReadiumSpeechDecorationController=ba;exports.ReadiumSpeechNavigator=df;exports.ReadiumSpeechProviderRegistry=td;exports.SpeechDefaults=Sa;exports.SpeechPreferences=Ue;exports.SpeechPreferencesEditor=Wn;exports.SpeechServerAudioDecodeError=gr;exports.SpeechServerEngine=As;exports.SpeechServerEngineProvider=Vu;exports.SpeechServerError=qe;exports.SpeechServerNetworkError=pr;exports.SpeechServerStallError=fr;exports.SpeechSettings=Kn;exports.StringArrayPreference=Hn;exports.WebSpeechEngine=Ln;exports.WebSpeechEngineProvider=ku;exports.WebSpeechVoiceManager=P;exports.blockLevelRoles=qa;exports.chineseVariantMap=Pe;exports.chunkPlainText=xs;exports.chunkSsmlText=Es;exports.contextualizationShapesAtVerbosity=ka;exports.contextualizedAtVerbosity=Ca;exports.createLocator=ya;exports.decodeCssSelectorFragment=Na;exports.decodeDomRangeFragment=Fa;exports.decodeTextref=tr;exports.decorationsEqual=ha;exports.defaultContextualizations=kr;exports.encodeCssSelectorFragment=Ra;exports.encodeDomRangeFragment=Da;exports.extractUtterances=uf;exports.isRecoverableFailure=Ts;exports.makeGnd=rp;exports.mapServerVoice=dr;exports.mimeTypeForFormat=Cs;exports.parseMarkup=po;exports.resolveDecorationForWire=jn;exports.selectBitrate=Os;exports.selectFormat=ks;exports.setupDecorations=ed;exports.shapeableRoles=rd;exports.skippableRoles=jd;exports.skippedAtVerbosity=Ea;exports.supportsDecorationStyle=ua;exports.toSpeechServerError=Fe;
|
package/build/index.js
CHANGED
|
@@ -6105,62 +6105,68 @@ const Qs = ["audio", "figure", "image", "math", "table", "video"], Zs = [
|
|
|
6105
6105
|
], Vh = {
|
|
6106
6106
|
none: /* @__PURE__ */ new Set([
|
|
6107
6107
|
"aside",
|
|
6108
|
+
"audio",
|
|
6108
6109
|
"bibliography",
|
|
6110
|
+
"biblioref",
|
|
6111
|
+
"cell",
|
|
6112
|
+
"columnheader",
|
|
6113
|
+
"details",
|
|
6109
6114
|
"endnotes",
|
|
6115
|
+
"figure",
|
|
6110
6116
|
"footnote",
|
|
6111
|
-
"
|
|
6112
|
-
"pullquote",
|
|
6113
|
-
"pagebreak",
|
|
6114
|
-
"details",
|
|
6115
|
-
"columnheader",
|
|
6116
|
-
"rowheader",
|
|
6117
|
-
"row",
|
|
6118
|
-
"cell",
|
|
6119
|
-
"audio",
|
|
6117
|
+
"glossary",
|
|
6120
6118
|
"image",
|
|
6121
|
-
"figure",
|
|
6122
|
-
"video",
|
|
6123
|
-
"table",
|
|
6124
6119
|
"landmarks",
|
|
6125
6120
|
"loa",
|
|
6126
6121
|
"loi",
|
|
6127
6122
|
"lot",
|
|
6128
6123
|
"lov",
|
|
6129
|
-
"
|
|
6124
|
+
"noteref",
|
|
6125
|
+
"pagebreak",
|
|
6126
|
+
"pullquote",
|
|
6127
|
+
"row",
|
|
6128
|
+
"rowheader",
|
|
6129
|
+
"table",
|
|
6130
|
+
"toc",
|
|
6131
|
+
"video"
|
|
6130
6132
|
]),
|
|
6131
6133
|
few: /* @__PURE__ */ new Set([
|
|
6132
6134
|
"aside",
|
|
6133
6135
|
"bibliography",
|
|
6136
|
+
"biblioref",
|
|
6137
|
+
"cell",
|
|
6138
|
+
"columnheader",
|
|
6139
|
+
"details",
|
|
6134
6140
|
"endnotes",
|
|
6135
6141
|
"footnote",
|
|
6136
|
-
"
|
|
6137
|
-
"pullquote",
|
|
6138
|
-
"pagebreak",
|
|
6139
|
-
"details",
|
|
6140
|
-
"columnheader",
|
|
6141
|
-
"rowheader",
|
|
6142
|
-
"row",
|
|
6143
|
-
"cell",
|
|
6142
|
+
"glossary",
|
|
6144
6143
|
"landmarks",
|
|
6145
6144
|
"loa",
|
|
6146
6145
|
"loi",
|
|
6147
6146
|
"lot",
|
|
6148
6147
|
"lov",
|
|
6148
|
+
"noteref",
|
|
6149
|
+
"pagebreak",
|
|
6150
|
+
"pullquote",
|
|
6151
|
+
"row",
|
|
6152
|
+
"rowheader",
|
|
6149
6153
|
"toc"
|
|
6150
6154
|
]),
|
|
6151
6155
|
some: /* @__PURE__ */ new Set([
|
|
6152
6156
|
"aside",
|
|
6153
6157
|
"bibliography",
|
|
6158
|
+
"biblioref",
|
|
6154
6159
|
"endnotes",
|
|
6155
6160
|
"footnote",
|
|
6156
|
-
"
|
|
6157
|
-
"pullquote",
|
|
6158
|
-
"pagebreak",
|
|
6161
|
+
"glossary",
|
|
6159
6162
|
"landmarks",
|
|
6160
6163
|
"loa",
|
|
6161
6164
|
"loi",
|
|
6162
6165
|
"lot",
|
|
6163
6166
|
"lov",
|
|
6167
|
+
"noteref",
|
|
6168
|
+
"pagebreak",
|
|
6169
|
+
"pullquote",
|
|
6164
6170
|
"toc"
|
|
6165
6171
|
]),
|
|
6166
6172
|
most: /* @__PURE__ */ new Set(["landmarks", "loa", "loi", "lot", "lov", "toc"])
|
|
@@ -7788,12 +7794,14 @@ const ap = [
|
|
|
7788
7794
|
"aside",
|
|
7789
7795
|
"audio",
|
|
7790
7796
|
"bibliography",
|
|
7797
|
+
"biblioref",
|
|
7791
7798
|
"cell",
|
|
7792
7799
|
"columnheader",
|
|
7793
7800
|
"details",
|
|
7794
7801
|
"endnotes",
|
|
7795
7802
|
"figure",
|
|
7796
7803
|
"footnote",
|
|
7804
|
+
"glossary",
|
|
7797
7805
|
"image",
|
|
7798
7806
|
"landmarks",
|
|
7799
7807
|
"loa",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/speech",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A TypeScript library for implementing read aloud features with Web technologies, following best practices for digital publishing.",
|
|
5
5
|
"author": "Readium Foundation",
|
|
6
6
|
"keywords": [
|