@bonniepdf/previewer 2026.11.13 → 2026.11.21
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/README.md +2 -2
- package/dist/{chunk-GCCYT6QM.cjs → chunk-F4NNJ6YM.cjs} +1 -1
- package/dist/{chunk-7GN6MXS6.js → chunk-NR23RQIX.js} +1 -1
- package/dist/element.cjs +1 -1
- package/dist/element.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +17 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@bonniepdf/previewer)
|
|
4
4
|
[](https://github.com/bonniepdf/BonniePDF-Previewer/blob/master/LICENSE)
|
|
5
5
|
|
|
6
|
-
[Live examples](https://www.bonniepdf.dev/examples) · [BonniePDF for TypeScript](https://github.com/bonniepdf/BonniePDF-TypeScript) · [BonniePDF for .NET](https://github.com/bonniepdf/BonniePDF-NET) · [npm](https://www.npmjs.com/package/@bonniepdf/previewer)
|
|
6
|
+
[Documentation](https://www.bonniepdf.dev/docs/typescript/previewer) · [Accessibility inspector](https://www.bonniepdf.dev/docs/typescript/previewer-accessibility-view) · [Live examples](https://www.bonniepdf.dev/examples/industry-templates) · [BonniePDF for TypeScript](https://github.com/bonniepdf/BonniePDF-TypeScript) · [BonniePDF for .NET](https://github.com/bonniepdf/BonniePDF-NET) · [@bonniepdf/core on npm](https://www.npmjs.com/package/@bonniepdf/core) · [npm](https://www.npmjs.com/package/@bonniepdf/previewer)
|
|
7
7
|
|
|
8
8
|
Show BonniePDF documents in a web page before anyone downloads them. `@bonniepdf/previewer` is a framework-agnostic document viewer: a paginated, zoomable preview with a thumbnail rail, page navigation, fullscreen, a Download PDF button and an optional accessibility inspector. It ships as a `<bonnie-pdf-previewer>` web component inside a Shadow DOM, so host-page CSS cannot reach it.
|
|
9
9
|
|
|
@@ -169,7 +169,7 @@ Attributes are read when the element connects to the page.
|
|
|
169
169
|
| `wcag-checks` | `"false"` starts the inspector with WCAG contrast findings hidden. |
|
|
170
170
|
| `download-filename` | Filename for Download, overriding the one derived from the document title. |
|
|
171
171
|
| `selection-color` | Any CSS colour for selection highlights. Defaults to the system `Highlight` colour. |
|
|
172
|
-
| `footer` | Renders a footer bar with text on the left and conformance pills such as `PDF/A-2a` and `PDF/UA-1` on the right. |
|
|
172
|
+
| `footer` | Renders a footer bar with text on the left and conformance pills such as `PDF/A-2a` and `PDF/UA-1`, or `PDF/A-4f` and `PDF/UA-2` for PDF 2.0, on the right. |
|
|
173
173
|
| `footer-label` | Footer text. Defaults to `Generated by @bonniepdf/previewer`. |
|
|
174
174
|
| `preference-key` | Persists thumbnail and inspector visibility and the chosen zoom in `localStorage` under this key. |
|
|
175
175
|
| `hide-border` | Removes the outer border and corner radius. |
|
|
@@ -660,4 +660,4 @@
|
|
|
660
660
|
</div>`;}function mt(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function Nt(s){return s?`<footer class="bpp-footer" data-footer aria-label="Document conformance">
|
|
661
661
|
<span class="bpp-footer-text">${mt(s.text)}</span>
|
|
662
662
|
<div class="bpp-footer-tags" data-footer-tags></div>
|
|
663
|
-
</footer>`:""}function vt(s){return Number.isFinite(s.left)&&Number.isFinite(s.top)&&Number.isFinite(s.right)&&Number.isFinite(s.bottom)&&s.width>0&&s.height>0}function Rt(s,n){let o=s.top+s.height/2,i=n.top+n.height/2,l=Math.max(1,Math.min(s.height,n.height)*.35);return Math.abs(o-i)<=l}function zt(s){let n=s.filter(i=>i.width>0&&i.height>0).map(i=>({...i})).sort((i,l)=>i.top-l.top||i.left-l.left),o=[];for(let i of n){let l=o.at(-1);if(l&&Rt(l,i)){let c=l.left+l.width,N=i.left-c,L=Math.max(2,Math.max(l.height,i.height)*1.25);if(N<=L){let A=Math.min(l.left,i.left),H=Math.min(l.top,i.top),j=Math.max(c,i.left+i.width),P=Math.max(l.top+l.height,i.top+i.height);l.left=A,l.top=H,l.width=j-A,l.height=P-H;continue}}o.push(i);}return o}function $t(s,n){try{let o=s.createRange();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}catch{return null}}function Dt(s,n){let o=n.getSelection();if(s instanceof ShadowRoot&&o){if(typeof o.getComposedRanges=="function")try{let l=o.getComposedRanges({shadowRoots:[s]}).map(c=>$t(n,c)).filter(c=>c!==null&&!c.collapsed);if(l.length>0)return l}catch{}let i=s.getSelection?.();if(i&&!i.isCollapsed)return Array.from({length:i.rangeCount},(l,c)=>i.getRangeAt(c)).filter(l=>!l.collapsed)}return !o||o.isCollapsed?[]:Array.from({length:o.rangeCount},(i,l)=>o.getRangeAt(l)).filter(i=>!i.collapsed)}function Ot(s,n){return s.right>n.left&&s.left<n.right&&s.bottom>n.top&&s.top<n.bottom}function Ft(s,n){if(n.contains(s.commonAncestorContainer))return true;try{return s.intersectsNode(n)}catch{return false}}function Bt(s,n){let o=n.getBoundingClientRect();if(!vt(o))return [];let i=[];for(let l of s){if(!vt(l)||!Ot(l,o))continue;let c=Math.max(l.left,o.left),N=Math.max(l.top,o.top),L=Math.min(l.right,o.right),A=Math.min(l.bottom,o.bottom);L<=c||A<=N||i.push({left:c-o.left,top:N-o.top,width:L-c,height:A-N});}return zt(i)}function Vt(s){for(let n of s)n.querySelector(":scope > .bpp-selection-layer")?.remove();}function wt(s){let{root:n,ownerDocument:o,pageElements:i,signal:l}=s,c=0,N=()=>Vt(i),L=()=>{if(c=0,l.aborted)return;let H=Dt(n,o);if(H.length===0){N();return}let j=[];for(let P of H)if(!(P.toString().length===0||typeof P.getClientRects!="function"))try{j.push({range:P,rects:Array.from(P.getClientRects())});}catch{}for(let P of i){let le=j.filter(({range:B})=>Ft(B,P)).flatMap(({rects:B})=>B),ue=Bt(le,P),F=P.querySelector(":scope > .bpp-selection-layer");if(ue.length===0){F?.remove();continue}F||(F=o.createElement("div"),F.className="bpp-selection-layer",F.setAttribute("aria-hidden","true"),P.appendChild(F));let ke=ue.map(B=>{let K=o.createElement("span");return K.className="bpp-selection-rect",K.style.left=`${B.left}px`,K.style.top=`${B.top}px`,K.style.width=`${B.width}px`,K.style.height=`${B.height}px`,K});F.replaceChildren(...ke);}},A=()=>{if(l.aborted||c!==0)return;let H=o.defaultView?.requestAnimationFrame;H?c=H.call(o.defaultView,L):L();};return o.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("pointerup",A,{signal:l}),n.addEventListener("pointermove",H=>{H.buttons===1&&A();},{signal:l}),n.addEventListener("keyup",A,{signal:l}),l.addEventListener("abort",()=>{c!==0&&o.defaultView?.cancelAnimationFrame?.(c),c=0,N();},{once:true}),{refresh:A,clear:N}}var st=24,xt=1.25,yt=.1,Et=5,jt="1500px 0px",Wt="800px 0px",Ye=200,lt=640,Gt=320,Ne=s=>Math.min(Math.max(s,yt),Et),Je=new WeakMap;function pt(s,n){return {value:s.style.getPropertyValue(n),priority:s.style.getPropertyPriority(n)}}function dt(s,n,o){o.value?s.style.setProperty(n,o.value,o.priority):s.style.removeProperty(n);}function Ut(s,n){let o=Je.get(s);if(!o){let i=s.body;o={owners:new Set,documentElement:s.documentElement,documentElementOverflow:pt(s.documentElement,"overflow"),documentElementScrollbarGutter:pt(s.documentElement,"scrollbar-gutter"),body:i,bodyOverflow:i?pt(i,"overflow"):null},Je.set(s,o);}o.owners.has(n)||(o.owners.add(n),o.documentElement.style.setProperty("overflow","hidden"),o.documentElement.style.setProperty("scrollbar-gutter","auto"),o.body?.style.setProperty("overflow","hidden"));}function Zt(s,n){let o=Je.get(s);o&&(o.owners.delete(n),!(o.owners.size>0)&&(dt(o.documentElement,"overflow",o.documentElementOverflow),dt(o.documentElement,"scrollbar-gutter",o.documentElementScrollbarGutter),o.body&&o.bodyOverflow&&dt(o.body,"overflow",o.bodyOverflow),Je.delete(s)));}function Lt(s,n={}){let o={plugins:n.plugins??[],showThumbnails:n.showThumbnails??false,showInspector:n.showInspector,initialZoom:n.initialZoom,onViewStateChange:n.onViewStateChange??(()=>{}),fitMode:n.fitMode??"fit-page",title:n.title??"PDF preview",downloadFilename:n.downloadFilename??"document.pdf",hideBorder:n.hideBorder??false,styleScrollbars:n.styleScrollbars??false,selectionColor:n.selectionColor?.trim()||void 0,footer:n.footer?{text:n.footer.text??"Generated by @bonniepdf/previewer",conformance:n.footer.conformance??true}:void 0,toolbar:{thumbnails:n.toolbar?.thumbnails??true,pageNav:n.toolbar?.pageNav??true,zoom:n.toolbar?.zoom??true,fullscreen:n.toolbar?.fullscreen??true,download:n.toolbar?.download??true}};ht(s,o),o.selectionColor&&s.querySelector(".bpp")?.style.setProperty("--bpdf-selection",o.selectionColor);let i=s instanceof ShadowRoot?s.host:s,l=i.ownerDocument,c=a=>s.querySelector(a),N=new AbortController,L=[],A=null,H=false,j=null,P=0,le=false,ue=null,F=o.plugins,ke=[],B=[],K=[],W=()=>1,ae=()=>{},G=[],Q=null,D=false,x=null,k=null,te=null,se=null,R=null,V=null,ne=o.showThumbnails,he=o.initialZoom?.mode==="custom"?{mode:"custom",scale:Ne(o.initialZoom.scale??1)}:{mode:o.initialZoom?.mode??o.fitMode};function Me(){o.onViewStateChange({showThumbnails:ne,showInspector:D,zoom:{...he}});}let Re={error:3,warning:2,info:1,ok:0};function Qe(){if(!V)return;let a=null;for(let p of G)p.badgeTone&&(a===null||Re[p.badgeTone]>Re[a])&&(a=p.badgeTone);a&&a!=="ok"?(V.hidden=false,V.className=`bpp-side-toggle-dot bpp-side-toggle-dot-${a}`):V.hidden=true;}function ze(){te&&(te.hidden=G.length<2);}function Ge(){D=true,x&&(x.hidden=false),k&&(k.hidden=false),R?.setAttribute("aria-pressed","true"),R?.classList.add("bpp-btn-active"),Me();}function xe(){D=false,x&&(x.hidden=true),k&&(k.hidden=true),R?.setAttribute("aria-pressed","false"),R?.classList.remove("bpp-btn-active"),G.find(a=>a.id===Q)?.onVisibilityChange?.(false),Me();}function ye(a){if(!a)return;let p=G.find(v=>v.id===a);if(!p||D&&Q===a)return;let b=Q;if(D||Ge(),b&&b!==a){let v=G.find(S=>S.id===b);v&&(v.element.hidden=true,v.tabBtn.setAttribute("aria-selected","false"),v.tabBtn.classList.remove("bpp-side-tab-active"),v.onVisibilityChange?.(false));}Q=a,p.element.hidden=false,p.tabBtn.setAttribute("aria-selected","true"),p.tabBtn.classList.add("bpp-side-tab-active"),p.onVisibilityChange?.(true);}function oe(a){let p=c(".bpp-body")?.clientWidth??0,b=p>0?p-Gt:lt,v=Math.max(Ye,Math.min(lt,b));return Math.min(Math.max(a,Ye),v)}function Ce(a){if(!x)return;let p=oe(a);x.style.width=`${p}px`,k?.setAttribute("aria-valuenow",String(Math.round(p)));}function $e(a){let p=false,b=0,v=0;a.addEventListener("pointerdown",m=>{x&&(p=true,b=m.clientX,v=x.getBoundingClientRect().width,a.setPointerCapture(m.pointerId),a.classList.add("bpp-side-resizer-active"),m.preventDefault());}),a.addEventListener("pointermove",m=>{p&&Ce(v+(b-m.clientX));});let S=m=>{p&&(p=false,a.hasPointerCapture(m.pointerId)&&a.releasePointerCapture(m.pointerId),a.classList.remove("bpp-side-resizer-active"));};a.addEventListener("pointerup",S),a.addEventListener("pointercancel",S),a.addEventListener("keydown",m=>{if(!x)return;let O=m.shiftKey?48:16,T=x.getBoundingClientRect().width;m.key==="ArrowLeft"?(Ce(T+O),m.preventDefault()):m.key==="ArrowRight"&&(Ce(T-O),m.preventDefault());});}function _e(){x||(x=l.createElement("aside"),x.className="bpp-side",x.hidden=true,x.setAttribute("aria-label","Inspector"),te=l.createElement("div"),te.className="bpp-side-tabs",te.setAttribute("role","tablist"),te.hidden=true,se=l.createElement("div"),se.className="bpp-side-body",x.append(te,se),k=l.createElement("div"),k.className="bpp-side-resizer",k.hidden=true,k.setAttribute("role","separator"),k.setAttribute("aria-orientation","vertical"),k.setAttribute("aria-label","Resize inspector panel"),k.setAttribute("aria-valuemin",String(Ye)),k.setAttribute("aria-valuemax",String(lt)),k.setAttribute("aria-valuenow",String(Ye)),k.tabIndex=0,$e(k),c(".bpp-body")?.append(k,x),R=l.createElement("button"),R.type="button",R.className="bpp-btn bpp-side-toggle",R.title="Toggle inspector panel",R.setAttribute("aria-label","Toggle inspector panel"),R.setAttribute("aria-pressed","false"),R.innerHTML=re("panel-right","bpp-icon"),V=l.createElement("span"),V.className="bpp-side-toggle-dot",V.hidden=true,R.append(V),R.addEventListener("click",()=>{D?xe():ye(Q??G[0]?.id??null);}),(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(R));}let Ue={ownerDocument:l,hostElement:i,addToolbarItem(a){(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(a);},addSidePanel({id:a,label:p,element:b,defaultOpen:v,onVisibilityChange:S}){_e();let m=l.createElement("button");m.type="button",m.className="bpp-side-tab",m.setAttribute("role","tab"),m.setAttribute("aria-selected","false");let O=l.createElement("span");O.className="bpp-side-tab-label",O.textContent=p;let T=l.createElement("span");T.className="bpp-side-tab-badge",T.hidden=true,m.append(O,T),m.addEventListener("click",()=>ye(a)),b.dataset.sidePanel=a,b.hidden=true,se.append(b);let ie={id:a,label:p,element:b,tabBtn:m,badgeEl:T,onVisibilityChange:S,badgeTone:null};return G.push(ie),G.sort((M,X)=>M.label.localeCompare(X.label,void 0,{sensitivity:"base"})),te.replaceChildren(...G.map(M=>M.tabBtn)),ze(),(o.showInspector??v)&&!D&&Q===null&&ye(a),{setVisible(M){M?ye(a):Q===a&&D&&xe();},setBadge(M,X="info"){M==null||M===""?(T.hidden=true,T.textContent="",ie.badgeTone=null):(T.hidden=false,T.textContent=M,T.className=`bpp-side-tab-badge bpp-side-tab-badge-${X}`,ie.badgeTone=X),Qe();}}},pageElement:a=>B[a]??null,overlayFor(a){let p=B[a];if(!p)return null;let b=K[a];return b||(b=l.createElement("div"),b.className="bpp-overlay",p.append(b),K[a]=b),b},scale:()=>W(),pageCount:()=>B.length,scrollToPage:a=>ae(a)};for(let a of F)try{let p=a.setup?.(Ue);p&&ke.push(p);}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" setup failed`,p);}function et(a){let p=c("[data-footer-tags]");if(!p)return;let b=[];if(o.footer?.conformance){let v=a?/^PdfA(\d)([a-e])$/i.exec(a.conformance.trim()):null;v&&b.push(`PDF/A-${v[1]}${v[2]}`),a?.accessibilityMode===1&&b.push("PDF/UA-1");}p.replaceChildren(...b.map(v=>{let S=l.createElement("span");return S.className="bpp-footer-tag",S.textContent=v,S}));}let De=F.some(a=>a.needsLayout===true),Ze=n.downloadFilename;function Te(){ue&&(URL.revokeObjectURL(ue),ue=null);}function qe(){let a=c(".bpp"),p=c("[data-error]");if(p&&(p.hidden=true),le)a?.classList.add("bpp-busy"),a?.setAttribute("aria-busy","true");else {let b=c("[data-loading]");b&&(b.hidden=false);}}function Ae(){let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-loading]");p&&(p.hidden=true);let b=c("[data-error]");b&&(b.hidden=true);}function He(a){Ae();let p=c("[data-error]");if(!p)return;p.classList.toggle("bpp-error-banner",le);let b=p.querySelector("[data-error-detail]");b&&(b.textContent=a instanceof Error?a.message:String(a)),p.hidden=false;}function Ke(a,p){if(Array.isArray(a)){if(H)return;P++;let b=p??{};h(a,{fontFaceCss:b.fontFaceCss,snapshot:b.snapshot,report:b.report,filename:b.downloadFilename??o.downloadFilename,pdf:b.pdfUrl??b.pdfProvider,legacyDownload:true});return}return Oe(a,p??{})}async function Oe(a,p){if(H)return;let b=++P,v=()=>b===P&&!H;qe();try{let S=await a;if(!v())return;let m,O=p.pdf,T;if(qt(S)){if(m=await S.generateSvgDocumentAsync({captureLayout:De}),!v())return;O??=()=>S.generateBytesAsync(),T=S.metadata?.title;}else if(Kt(S))m=S;else throw new TypeError("load() expects a BonniePDF Document, an SVG document export, or a promise of either.");T??=m.snapshot?.meta?.title,h(at(m.pages),{fontFaceCss:m.fontFaceCss,snapshot:m.snapshot,report:m.report,filename:p.downloadFilename??Ze??Xt(T)??o.downloadFilename,pdf:O});}catch(S){if(!v())return;throw He(S),i.dispatchEvent(new CustomEvent("bpp-load-error",{detail:{error:S},bubbles:true,composed:true})),S}}function h(a,p){if(H)return;Te(),N.abort(),N=new AbortController;for(let u of L)u.disconnect();L=[],Fe();let b=N.signal;Ee(p.fontFaceCss);let v=c("[data-scroll]"),S=c("[data-pages]"),m=c("[data-thumbs]"),O=c("[data-thumbs-list]"),T=u=>a[u].svg,ie=[],$=[],M=a.map((u,y)=>{let I=l.createElement("li"),z=l.createElement("button");z.type="button",z.className=`bpp-thumb${y===0?" bpp-thumb-active":""}`,z.setAttribute("aria-label",`Go to page ${y+1}`),y===0&&z.setAttribute("aria-current","page"),z.dataset.thumb=String(y+1),$.push(z);let Pe=l.createElement("span");Pe.className="bpp-thumb-canvas",Pe.setAttribute("aria-hidden","true"),Pe.style.aspectRatio=`${u.width} / ${u.height}`,ie.push(Pe);let ge=l.createElement("span");return ge.className="bpp-thumb-label",ge.textContent=String(y+1),z.append(Pe,ge),I.append(z),I}),X=[],ee=a.map((u,y)=>{let I=l.createElement("div");I.className="bpp-page",I.dataset.pageIndex=String(y),I.style.width=`${u.width}px`,I.style.height=`${u.height}px`;let z=l.createElement("div");return z.className="bpp-page-canvas",I.append(z),X.push(z),I});O.replaceChildren(...M),S.replaceChildren(...ee),Be(X,T,u=>`p${u}-`,v,jt),Be(ie,T,u=>`t${u}-`,m,Wt,true);let be=wt({root:s,ownerDocument:l,pageElements:ee,signal:b}),U=he.mode,fe=he.mode==="custom"?Ne(he.scale??1):1,Z=1,Le={width:v.clientWidth,height:v.clientHeight},pe=a.length,Ve=c(".bpp"),e=c("[data-toggle-thumbs]"),t=c("[data-prev]"),r=c("[data-next]"),f=c("[data-zoom-out]"),d=c("[data-zoom-in]"),g=c("[data-zoom-select]"),C=c("[data-custom-zoom]"),w=c("[data-current-page]"),E=c("[data-total-pages]"),q=c("[data-page-label]"),Y=c("[data-fullscreen]"),de=c("[data-download]"),J=Ve?.classList.contains("bpp-fullscreen")??false,_=null,ce=()=>{if(U==="custom")return fe;let u=a[Z-1]??a[0];if(!u||Le.width===0)return 1;let y=Math.max(Le.width-st*2,1)/u.width;return U==="fit-width"?y:Math.min(y,Math.max(Le.height-st*2,1)/u.height)},ve=(u=ce())=>{e?.classList.toggle("bpp-btn-active",ne),e?.setAttribute("aria-pressed",String(ne)),e?.setAttribute("title",ne?"Hide page thumbnails":"Show page thumbnails"),w&&(w.textContent=String(Z)),q?.setAttribute("aria-label",`Page ${Z} of ${pe}`),t&&(t.disabled=Z<=1),r&&(r.disabled=Z>=pe),f&&(f.disabled=u<=yt),d&&(d.disabled=u>=Et),Y&&(Y.classList.toggle("bpp-btn-active",J),Y.setAttribute("aria-pressed",String(J)),Y.setAttribute("aria-label",J?"Exit full screen":"Full screen"),Y.setAttribute("title",J?"Exit full screen":"Full screen")),g&&(C&&(C.textContent=`${Math.round(u*100)}%`,C.hidden=U!=="custom"),g.value=U),$.forEach((y,I)=>{let z=I+1===Z;y.classList.toggle("bpp-thumb-active",z),z?y.setAttribute("aria-current","page"):y.removeAttribute("aria-current");});},Se=()=>{let u=ce();ee.forEach((y,I)=>{let z=a[I];z&&(y.style.width=`${z.width*u}px`,y.style.height=`${z.height*u}px`);}),be.refresh(),ve(u);for(let y of F)try{y.sync?.({scale:u,currentPage:Z});}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" sync failed`,I);}},nt=()=>{he=U==="custom"?{mode:U,scale:fe}:{mode:U},J&&(_=null),Me();},kt=()=>{try{return i.matches(":popover-open")}catch{return false}},we=l.fullscreenElement===i?"native":kt()?"popover":null,ot=u=>{if(u===J)return;u?(_=U==="custom"?{mode:U,scale:fe}:{mode:U},U="fit-page"):_&&(U=_.mode,_.mode==="custom"&&(fe=Ne(_.scale??1)),_=null),J=u,J?Ut(l,i):Zt(l,i),Ve?.classList.toggle("bpp-fullscreen",J),Le={width:v.clientWidth,height:v.clientHeight},ve();let y=l.defaultView;typeof y?.requestAnimationFrame=="function"?y.requestAnimationFrame(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();}):Se();},Tt=()=>{if(we==="popover"){try{i.hidePopover?.();}catch{}i.removeAttribute("popover"),i.classList.remove("bpp-popover-host"),we=null;}else we==="native"&&l.fullscreenElement===i&&l.exitFullscreen?.().catch(()=>{});},Mt=()=>{let u=i;if(typeof u.showPopover=="function")try{i.classList.add("bpp-popover-host"),i.setAttribute("popover","manual"),u.showPopover(),we="popover";return}catch{i.removeAttribute("popover"),i.classList.remove("bpp-popover-host");}typeof i.requestFullscreen=="function"&&(we="native",i.requestFullscreen().catch(()=>{we=null;}));},rt=u=>{ot(u),u?Mt():Tt();};j=()=>{J&&rt(false);};let bt=u=>{Z=Math.min(Math.max(u,1),pe),ve();},je=u=>{let y=Math.min(Math.max(u,1),pe),I=ee[y-1];if(!I||(bt(y),typeof v.scrollTo!="function"))return;let z=I.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollTo({top:Math.max(v.scrollTop+z-st,0),behavior:"smooth"});};if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();});u.observe(v),L.push(u);}if(typeof IntersectionObserver<"u"){let u=new Map,y=new IntersectionObserver(I=>{for(let ge of I){let it=Number(ge.target.dataset.pageIndex);u.set(it,ge.isIntersecting?ge.intersectionRatio:0);}let z=-1,Pe=0;u.forEach((ge,it)=>{ge>Pe&&(z=it,Pe=ge);}),z>=0&&bt(z+1);},{root:v,threshold:[.1,.25,.5,.75,1]});ee.forEach(I=>y.observe(I)),L.push(y);}e?.addEventListener("click",()=>{ne=!ne,m&&(m.hidden=!ne),Se(),Me();},{signal:b}),t?.addEventListener("click",()=>je(Z-1),{signal:b}),r?.addEventListener("click",()=>je(Z+1),{signal:b}),$.forEach(u=>u.addEventListener("click",()=>je(Number(u.dataset.thumb)),{signal:b})),v.addEventListener("click",u=>{let y=u.target?.closest?.("[data-bp-link-page]");if(!y)return;let I=Number(y.getAttribute("data-bp-link-page"));Number.isFinite(I)&&I>=1&&je(I);},{signal:b}),f?.addEventListener("click",()=>{fe=Ne(ce()/xt),U="custom",Se(),nt();},{signal:b}),d?.addEventListener("click",()=>{fe=Ne(ce()*xt),U="custom",Se(),nt();},{signal:b}),g?.addEventListener("change",()=>{let u=g.value;u==="fit-page"||u==="fit-width"?U=u:u!=="custom"&&(fe=Ne(Number(u)),U="custom"),Se(),nt();},{signal:b}),Y?.addEventListener("click",()=>rt(!J),{signal:b}),l.addEventListener("fullscreenchange",()=>{l.fullscreenElement===i?(we="native",J||ot(true)):we==="native"&&(we=null,J&&ot(false));},{signal:b}),l.addEventListener("keydown",u=>{u.key==="Escape"&&J&&rt(false);},{signal:b});let Ct=p.filename,Ie=p.pdf,_t=P,We;if(de&&(de.disabled=Ie===void 0,p.legacyDownload||Yt(de,Ie!==void 0)),de?.addEventListener("click",async()=>{if(!We&&Ie!==void 0){de.disabled=true;try{let u=typeof Ie=="function"?await Ie():Ie;if(typeof u=="string")We=u;else {let y=URL.createObjectURL(u instanceof Blob?u:new Blob([u],{type:"application/pdf"}));if(_t!==P||H){URL.revokeObjectURL(y);return}ue=y,We=y;}}catch{}finally{de.disabled=false;}}We&&Jt(l,We,Ct);},{signal:b}),E&&(E.textContent=String(pe)),w&&(w.textContent=pe>0?"1":"0"),m&&(m.hidden=!ne),Ae(),le=true,et(p.snapshot?.meta),B=ee,K=new Array(a.length).fill(null),W=ce,ae=je,F.length>0){let u={...Ue,pages:a,snapshot:p.snapshot,report:p.report};for(let y of F)try{y.load?.(u);}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" load failed`,I);}}Se();}function Fe(){for(let a of F)try{a.teardown?.();}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" teardown failed`,p);}K=[];}function Xe(a){if(H)return false;let p=false;for(let b of F)try{b.selectSnapshotNode?.(a)&&(p=!0);}catch(v){console.error(`[bonniepdf-previewer] plugin "${b.name}" selection failed`,v);}return p}function Be(a,p,b,v,S,m=false){let O=new Map,T=($,M)=>{if($.dataset.mounted==="true")return;let X=O.get(M);if(X===void 0&&(X=gt(p(M),b(M)),O.set(M,X)),$.innerHTML=X,m){let ee=$.querySelector("svg");ee&&ee.setAttribute("aria-hidden","true");for(let be of $.querySelectorAll("a"))be.removeAttribute("href"),be.removeAttribute("xlink:href"),be.removeAttribute("target"),be.setAttribute("tabindex","-1");}$.dataset.mounted="true";},ie=$=>{$.dataset.mounted==="true"&&($.replaceChildren(),$.dataset.mounted="false");};if(a.forEach(($,M)=>{$.dataset.lazyIndex=String(M);}),a[0]&&T(a[0],0),v&&typeof IntersectionObserver<"u"){let $=new IntersectionObserver(M=>{for(let X of M){let ee=X.target,be=Number(ee.dataset.lazyIndex);X.isIntersecting?T(ee,be):ie(ee);}},{root:v,rootMargin:S});a.forEach(M=>$.observe(M)),L.push($);}else a.forEach(($,M)=>T($,M));}function Ee(a){a&&(A||(A=l.createElement("style"),A.setAttribute("data-bpp-fonts",""),l.head.appendChild(A)),A.textContent!==a&&(A.textContent=a));}function me(){if(H)return;P++,Te(),N.abort(),N=new AbortController;for(let ie of L)ie.disconnect();L=[],Fe(),le=false,c("[data-pages]")?.replaceChildren(),c("[data-thumbs-list]")?.replaceChildren();let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-error]");p&&(p.hidden=true);let b=c("[data-loading]");b&&(b.hidden=false);let v=c("[data-current-page]");v&&(v.textContent="0");let S=c("[data-total-pages]");S&&(S.textContent="0");let m=c("[data-prev]");m&&(m.disabled=true);let O=c("[data-next]");O&&(O.disabled=true);let T=c("[data-download]");T&&(T.disabled=true);}function tt(){if(!H){j?.(),j=null,H=true,Fe();for(let a of ke.splice(0))try{a();}catch{}N.abort();for(let a of L)a.disconnect();L=[],A&&(A.remove(),A=null),Te();}}return {load:Ke,selectSnapshotNode:Xe,clear:me,dispose:tt}}function qt(s){let n=s;return typeof n=="object"&&n!==null&&typeof n.generateSvgDocumentAsync=="function"&&typeof n.generateBytesAsync=="function"}function Kt(s){let n=s?.pages;return Array.isArray(n)&&n.every(o=>typeof o=="string")}function Xt(s){let n=(s??"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80).replace(/-+$/,"");return n?`${n}.pdf`:void 0}function Yt(s,n){let o=s.closest(".bpp-group");if(!o)return;o.hidden=!n;let i=o.previousElementSibling;i instanceof HTMLElement&&i.classList.contains("bpp-sep")&&(i.hidden=!n);}function Jt(s,n,o){let i=s.createElement("a");i.href=n,i.download=o,i.rel="noopener",s.body.appendChild(i),i.click(),i.remove();}var St={error:3,warning:2,info:1},ct={error:"Error",warning:"Warning",info:"Info"},Qt={error:"circle-x",warning:"triangle-alert",info:"info"},en="WCAG";function Pt(s={}){let n=s.label??"Accessibility",o=s.issuesLabel??"Issues",i=s.openByDefault??false,l=s.markIssuesOnPage??true,c=Math.max(0,s.defaultExpandDepth??1/0),N=s.preferenceKey,L=null,A=null,H=null,j=null,P=null,le=false,ue=false,F=()=>le||ue,ke=Me(N),B=ke?.onlyIssues??s.onlyIssues??false,K=ke?.showWcag??s.showWcagChecks??true,W=new Map,ae=new Map,G=new Map,Q=new Map,D=new Set,x=null,k=null,te=null,se=[],R=[],V=null,ne=null;function he(e){return x?e.id===x.id?true:e.type==="Page"&&x.children.includes(e)&&x.sourceId!==void 0&&e.sourceId===x.sourceId:false}function Me(e){if(e)try{let t=globalThis.localStorage?.getItem(e);if(!t)return;let r=JSON.parse(t);return {onlyIssues:r.onlyIssues===!0,showWcag:r.showWcag!==!1}}catch{return}}function Re(){if(N)try{globalThis.localStorage?.setItem(N,JSON.stringify({onlyIssues:B,showWcag:K}));}catch{}}function Qe(e){return e.standard.toUpperCase().startsWith(en)}function ze(){return k?K?[...k.findings]:k.findings.filter(e=>!Qe(e)):[]}function Ge(){Q.clear();for(let e of ze()){if(!e.nodeId)continue;let t=Q.get(e.nodeId);t?t.push(e):Q.set(e.nodeId,[e]);}}function xe(e){let t=Q.get(e);if(!t||t.length===0)return null;let r="info";for(let f of t)St[f.severity]>St[r]&&(r=f.severity);return r}function ye(e,t,r){e.style.left=`${t.x*r}px`,e.style.top=`${t.y*r}px`,e.style.width=`${t.width*r}px`,e.style.height=`${t.height*r}px`;}function oe(e){for(let t of e)t.element.remove();e.length=0;}function Ce(e,t,r){if(L)for(let f of t.rects){let d=L.overlayFor(f.page);if(!d)continue;let g=L.ownerDocument.createElement("div");g.className=r,ye(g,f,L.scale()),d.append(g),e.push({element:g,rect:f});}}function $e(){if(oe(se),!l||!x)return;let e=t=>{let r=xe(t.id);r&&Ce(se,t,`bpp-cv-mark bpp-cv-mark-${r}`);for(let f of t.children)e(f);};e(x);}function _e(e){oe(R);let t=xe(e.id),r=t?`bpp-cv-sel bpp-cv-sel-${t}`:"bpp-cv-sel";Ce(R,e,r);}function Ue(e,t,r){if(!x)return null;let f=null,d=-1,g=1/0,C=(w,E)=>{for(let q of w.rects){if(q.page!==e||t<q.x||t>q.x+q.width||r<q.y||r>q.y+q.height)continue;let Y=q.width*q.height;(E>d||E===d&&Y<g)&&(f=w,d=E,g=Y);}for(let q of w.children)C(q,E+1);};return C(x,0),f}function et(){if(D.clear(),!x)return;let e=(t,r)=>{let f=xe(t.id)==="error";for(let d of t.children)e(d,r+1)&&(f=true);return t.children.length>0&&(r<c||f)&&D.add(t.id),f};e(x,0),B&&De();}function De(){for(let e of Q.keys())Ze(e);}function Ze(e){let t=G.get(e);for(;t;)D.add(t.id),t=G.get(t.id);}function Te(e,t){e.children.length!==0&&(t?D.add(e.id):D.delete(e.id),qe(e.id));}function qe(e){let t=W.get(e);if(!t)return;let r=t.parentElement?.querySelector(":scope > ul");if(!r)return;let f=D.has(e);t.setAttribute("aria-expanded",String(f)),r.hidden=!f;}function Ae(e){if(x){if(D.clear(),e){let t=r=>{r.children.length>0&&D.add(r.id);for(let f of r.children)t(f);};t(x);}else x.children.length>0&&D.add(x.id);pe();}}function He(e,t=false){if(!L)return;if(he(e)){V=null;for(let f of W.values())f.setAttribute("aria-selected","false");oe(R),O(null),t&&Ke(e.id);return}V=e.id;for(let[f,d]of W)d.setAttribute("aria-selected",String(f===e.id));_e(e),O(e),t&&Ke(e.id);let r=e.rects[0];r&&L.scrollToPage(r.page+1);}function Ke(e){Ze(e);let t=G.get(e);for(;t;)qe(t.id),t=G.get(t.id);let r=W.get(e);r&&(Ee(e),typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest"}));}function Oe(e,t,r){L&&L.hostElement.dispatchEvent(new CustomEvent("bonniepdf-node-select",{bubbles:true,composed:true,detail:{nodeId:e.id,sourceId:e.sourceId,sourceNavigation:t,origin:r}}));}function h(e,t,r){let d=L.ownerDocument.createElement(e);return t&&(d.className=t),r!=null&&(d.textContent=r),d}function Fe(e){let t=e.rects[0];if(!t)return "";let r=[...new Set(e.rects.map(w=>w.page))].sort((w,E)=>w-E),f=r.length===1?`Page ${r[0]+1}`:`Pages ${r[0]+1}\u2013${r[r.length-1]+1}`,d=`${Math.round(t.width)}\xD7${Math.round(t.height)} pt`,g=`at ${Math.round(t.x)}, ${Math.round(t.y)}`,C=e.rects.length>1?` \xB7 ${e.rects.length} fragments`:"";return `${f} \xB7 ${d} ${g}${C}`}function Xe(e,t,r){let f=h("ul");f.setAttribute("role",t);for(let d of e){let g=xe(d.id),C=g!=null||p(d);if(B&&!C)continue;let w=h("li");w.setAttribute("role","none");let E=h("button","bpp-tree-row bpp-cv-row");E.type="button",E.setAttribute("role","treeitem"),E.setAttribute("aria-selected","false"),E.setAttribute("aria-level",String(r)),E.dataset.nodeId=d.id,E.tabIndex=-1;let q=d.children.length>0,Y=h("span",q?"bpp-tree-twisty":"bpp-tree-twisty bpp-tree-twisty-leaf");Y.setAttribute("aria-hidden","true"),E.append(Y);let de=d.a11y,J=de?.artifact?"Artifact":de?.role||(de?.tagged?"Tagged":"");if(J){let _=h("span","bpp-cv-role",J);J==="Artifact"?(_.classList.add("bpp-cv-role-artifact"),_.title="Artifact (outside the reading order)"):de?.tagged&&(_.classList.add("bpp-cv-role-tagged"),_.title="Tagged content",E.setAttribute("aria-description","Tagged content")),E.append(_);}if(E.append(h("span","bpp-tree-type",d.type)),g){let _=Q.get(d.id).length,ce=`${ct[g]}: ${_} ${_===1?"finding":"findings"}`,ve=h("span",`bpp-cv-issue-icon bpp-cv-issue-icon-${g}`);ve.setAttribute("role","img"),ve.setAttribute("aria-label",ce),ve.title=ce,ve.innerHTML=re(Qt[g]),E.append(ve);}if(d.name&&E.append(h("span","bpp-tree-name",d.name)),E.addEventListener("click",_=>{if(q&&_.target?.closest(".bpp-tree-twisty")){Te(d,!D.has(d.id)),Ee(d.id);return}Ee(d.id),He(d),Oe(d,he(d)||_.ctrlKey||_.metaKey,"tree");}),E.addEventListener("keydown",_=>tt(_,d)),E.addEventListener("focus",()=>Ee(d.id)),E.addEventListener("mouseenter",()=>{V!==d.id&&_e(d);}),E.addEventListener("mouseleave",()=>{if(V){let _=ae.get(V);_&&_e(_);}else oe(R);}),W.set(d.id,E),w.append(E),q){let _=Xe(d.children,"group",r+1);if(_.childElementCount>0){let ce=D.has(d.id);E.setAttribute("aria-expanded",String(ce)),_.hidden=!ce,w.append(_);}else Y.classList.add("bpp-tree-twisty-leaf");}f.append(w);}return f}function Be(){return Z?Array.from(Z.querySelectorAll(".bpp-tree-row")).filter(t=>{let r=t.parentElement;for(;r&&r!==Z;){if(r.tagName==="UL"&&r.hidden)return false;r=r.parentElement;}return true}):[]}function Ee(e){te=e;for(let[t,r]of W)r.tabIndex=t===e?0:-1;}function me(e){if(!e)return;let t=e.dataset.nodeId;t&&Ee(t),e.focus();}function tt(e,t){let r=Be(),f=W.get(t.id),d=f?r.indexOf(f):-1,g=t.children.length>0&&W.get(t.id)?.hasAttribute("aria-expanded")===true,C=D.has(t.id);switch(e.key){case "ArrowDown":e.preventDefault(),me(r[d+1]);break;case "ArrowUp":e.preventDefault(),me(r[d-1]);break;case "ArrowRight":e.preventDefault(),g&&!C?Te(t,true):g&&me(r[d+1]);break;case "ArrowLeft":{if(e.preventDefault(),g&&C){Te(t,false);break}let w=G.get(t.id);w&&me(W.get(w.id));break}case "Home":e.preventDefault(),me(r[0]);break;case "End":e.preventDefault(),me(r[r.length-1]);break;case "*":e.preventDefault(),Ae(true),me(W.get(t.id));break;}}function a(e){return /^H[1-6]$/.test(e)?"heading":e==="Figure"?"figure":e==="Artifact"?"artifact":e==="Table"||e==="TH"||e==="TD"||e==="TR"?"table":"default"}function p(e){for(let t of e.children)if(xe(t.id)||p(t))return true;return false}function b(e){for(let t of ae.values())if(e(t))return t;return null}function v(e){ae.clear(),G.clear();let t=r=>{ae.set(r.id,r);for(let f of r.children)G.set(f.id,r),t(f);};t(e);}function S(e,t){let r=h("div",`bpp-cv-finding bpp-cv-finding-${e.severity}`),f=h("div","bpp-cv-finding-head");f.append(h("span",`bpp-cv-badge bpp-cv-badge-${e.severity}`,ct[e.severity])),f.append(h("span","bpp-cv-clause",e.clause)),r.append(f);let d=e.nodeId?ae.get(e.nodeId):void 0;if(t&&d){let g=h("p","bpp-cv-finding-where");g.append(h("span","bpp-cv-finding-el",d.name?`${d.type} \u201C${d.name}\u201D`:d.type)),e.page!=null&&g.append(h("span","bpp-cv-finding-page",` \xB7 page ${e.page+1}`)),r.append(g);}if(r.append(h("p","bpp-cv-msg",e.message)),e.fixHint){let g=h("p","bpp-cv-fix");g.append(h("span","bpp-cv-fix-label","Fix: ")),g.append(L.ownerDocument.createTextNode(e.fixHint)),r.append(g);}if(t&&e.nodeId){let g=h("button","bpp-cv-jump","Go to element");g.type="button",g.addEventListener("click",C=>{let w=d??b(E=>E.id===e.nodeId);w&&(A?.setVisible(true),He(w,true),W.get(w.id)?.focus(),Oe(w,C.ctrlKey||C.metaKey,"finding"));}),r.append(g);}return r}let m=null;function O(e){if(!m)return;m.replaceChildren();let t=e?Q.get(e.id):void 0;if(!e){m.append(h("p","bpp-cv-empty","Select an element to see its accessibility details."));return}let r=h("div","bpp-cv-detail-head");r.append(h("span","bpp-cv-detail-type",e.type)),e.name&&r.append(h("span","bpp-cv-detail-name",e.name)),e.a11y?.role&&r.append(h("span",`bpp-cv-role bpp-cv-role-${a(e.a11y.role)}`,e.a11y.role)),m.append(r);let f=Fe(e);if(f&&m.append(h("p","bpp-cv-geom",f)),e.a11y?.alt&&m.append(h("p","bpp-cv-attr",`Alt: \u201C${e.a11y.alt}\u201D`)),!t||t.length===0){m.append(h("p","bpp-cv-empty",e.a11y?"No accessibility issues on this element.":"This element carries no structure role."));return}for(let d of t)m.append(S(d,false));}function T(){let e={error:0,warning:0,info:0};for(let t of ze())e[t.severity]++;return e}function ie(){if(!H)return;if(!k){H.setBadge(null);return}let{error:e,warning:t}=T();e===0&&t===0?H.setBadge("\u2713","ok"):H.setBadge(String(e+t),e>0?"error":"warning");}function $(e,t,r,f){let d=h("label","bpp-cv-filter");d.title=r;let g=L.ownerDocument.createElement("input");return g.type="checkbox",g.checked=t,g.addEventListener("change",()=>f(g.checked)),d.append(g,L.ownerDocument.createTextNode(` ${e}`)),d}let M=null;function X(){let e=h("div","bpp-cv-header");if(!k)return e.append(h("span","bpp-cv-empty","No compliance report; showing structure roles only.")),e;let t=T(),r=h("div","bpp-cv-pills"),f=(g,C,w)=>{r.append(h("span",`bpp-cv-pill bpp-cv-pill-${g}${C===0?" bpp-cv-pill-zero":""}`,`${C} ${w}`));};f("error",t.error,t.error===1?"error":"errors"),f("warning",t.warning,t.warning===1?"warning":"warnings"),f("info",t.info,"info"),e.append(r);let d=k.findings.find(g=>g.standard.startsWith("PDF/UA"))?.standard??"PDF/UA-1";return e.append(h("div",`bpp-cv-verdict ${k.passed?"bpp-cv-verdict-pass":"bpp-cv-verdict-fail"}`,k.passed?`Passes ${d} checks`:`Does not meet ${d}`)),e}function ee(){M&&M.replaceChildren(X(),be());}function be(){let e=h("div","bpp-cv-settings"),t=h("div","bpp-cv-filters");k&&(t.append($("Show only elements with issues",B,"Hide every branch of the tree with no findings in it",d=>{B=d,B&&De(),Re(),pe();})),t.append(U())),e.append(t);let r=h("div","bpp-cv-tree-actions"),f=(d,g,C)=>{let w=h("button","bpp-cv-action",d);w.type="button",w.title=g,w.addEventListener("click",C),r.append(w);};return f("Expand all","Expand every branch of the tree",()=>Ae(true)),f("Collapse all","Collapse the tree back to the document",()=>Ae(false)),e.append(r),e}function U(){return $("Include WCAG contrast checks",K,"WCAG 2.2 SC 1.4.3 text-contrast findings. PDF/UA-1 sets no numeric contrast requirement, so these are a separate standard you may be tracking separately.",e=>{K=e,Re(),Le();})}function fe(){if(!P)return;if(P.replaceChildren(),!k){P.append(h("p","bpp-cv-empty","No compliance report was supplied, so there are no findings to list."));return}let e=h("div","bpp-cv-issues-head");e.append(X()),e.append(U()),P.append(e);let t=h("div","bpp-cv-issues-list"),r=ze(),f=["error","warning","info"];for(let d of f){let g=r.filter(w=>w.severity===d);if(g.length===0)continue;let C=h("section","bpp-cv-issues-group");C.append(h("div","bpp-cv-section-title",`${ct[d]}${g.length===1?"":"s"} (${g.length})`));for(let w of g){let E=S(w,w.nodeId!=null);w.nodeId||E.prepend(h("span","bpp-cv-scope","Document")),C.append(E);}t.append(C);}t.childElementCount===0&&t.append(h("p","bpp-cv-empty",K?"No findings. This document passes every check the preflight runs.":"No findings, with contrast checks excluded. Include them to check text contrast too.")),P.append(t);}let Z=null;function Le(){Ge(),B&&De(),ee(),fe(),pe();let e=V?ae.get(V):null;O(e??null),ie(),F()&&$e(),e?_e(e):oe(R);}function pe(){if(!Z||!x)return;W.clear();let e=Xe([x],"tree",1);if(e.classList.add("bpp-tree","bpp-cv-tree"),e.setAttribute("aria-label",n),Z.replaceChildren(e),e.childElementCount===0&&Z.append(h("p","bpp-cv-empty",K?"No elements with issues. Clear the filter to see the whole document.":"No elements with issues. Contrast checks are hidden \u2014 include them, or clear the filter to see the whole document.")),V){let r=W.get(V);r&&r.setAttribute("aria-selected","true");}let t=te&&W.has(te)?te:Be()[0]?.dataset.nodeId;t&&Ee(t);}function Ve(e,t){let r=F();e==="tree"?le=t:ue=t;let f=F();f!==r&&(f?$e():(oe(se),oe(R)));}return {name:"compliance-view",needsLayout:true,setup(e){L=e;let t=e.ownerDocument;return j=t.createElement("div"),j.className="bpp-cv-host",A=e.addSidePanel({id:"compliance",label:n,element:j,defaultOpen:i,onVisibilityChange:r=>Ve("tree",r)}),P=t.createElement("div"),P.className="bpp-cv-host bpp-cv-issues",H=e.addSidePanel({id:"compliance-issues",label:o,element:P,onVisibilityChange:r=>Ve("issues",r)}),()=>{L=null,A=null,H=null,j=null,P=null;}},load(e){if(L=e,W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),oe(se),oe(R),V=null,te=null,x=null,k=e.report??null,ne?.abort(),ne=null,!j)return;if(!e.snapshot){j.textContent="No structure data for this document.",P&&(P.textContent="No structure data for this document."),H?.setBadge(null),oe(se),oe(R);return}x=e.snapshot.root,v(x),Ge(),et(),j.replaceChildren(),M=h("div","bpp-cv-summary"),j.append(M),Z=h("div","bpp-cv-tree-host"),j.append(Z);let t=h("div","bpp-cv-detail");t.append(h("div","bpp-cv-section-title","Element")),m=h("div","bpp-cv-detail-body"),t.append(m),j.append(t),ee(),fe(),pe(),O(null),ie(),ne=new AbortController;for(let r=0;r<e.pageCount();r++){let f=e.pageElement(r);if(!f)continue;let d=r;f.addEventListener("click",g=>{if(!F()&&!g.ctrlKey&&!g.metaKey||!L)return;let C=L.scale();if(C<=0)return;let w=f.getBoundingClientRect(),E=(g.clientX-w.left)/C,q=(g.clientY-w.top)/C,Y=Ue(d,E,q);Y&&(le||A?.setVisible(true),He(Y,true),Oe(Y,he(Y)||g.ctrlKey||g.metaKey,"page"));},{signal:ne.signal});}F()&&$e();},sync({scale:e}){for(let t of se)ye(t.element,t.rect,e);for(let t of R)ye(t.element,t.rect,e);},selectSnapshotNode(e){let t=ae.get(e);return t?(le||A?.setVisible(true),He(t,true),true):false},teardown(){oe(se),oe(R),W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),V=null,te=null,x=null,k=null,ne?.abort(),ne=null;}}}var ut=class extends HTMLElement{handle=null;pending=null;connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});if(!this.handle){this.handle=Lt(n,this.readOptions());let o=this.pending;this.pending=null,o?.run(this.handle);}}disconnectedCallback(){this.handle?.dispose(),this.handle=null;}load(n,o){if(this.handle)return Array.isArray(n)?this.handle.load(n,o):this.handle.load(n,o);if(this.pending?.settle(),Array.isArray(n)){this.pending={run:i=>i.load(n,o),settle:()=>{}};return}return new Promise((i,l)=>{this.pending={run:c=>{c.load(n,o).then(i,l);},settle:i};})}selectSnapshotNode(n){return this.handle?.selectSnapshotNode(n)??false}clear(){this.pending?.settle(),this.pending=null,this.handle?.clear();}readOptions(){let n=this.getAttribute("show-thumbnails"),o=this.getAttribute("show-inspector"),i=this.getAttribute("preference-key"),l=i?this.readPreferences(i):void 0,c=[];if(this.hasAttribute("compliance-view")||this.hasAttribute("structure-view")){let N=this.getAttribute("wcag-checks");c.push(Pt({showWcagChecks:N===null?void 0:N!=="false",preferenceKey:i?`${i}:a11y`:void 0}));}return {plugins:c.length>0?c:void 0,toolbar:this.readToolbarConfig(),showThumbnails:l?.showThumbnails??(n===null?void 0:n!=="false"),showInspector:l?.showInspector??(o===null?void 0:o!=="false"),initialZoom:l?.zoom,onViewStateChange:i?N=>this.writePreferences(i,N):void 0,fitMode:this.getAttribute("fit-mode")==="fit-width"?"fit-width":"fit-page",title:this.getAttribute("label")??void 0,downloadFilename:this.getAttribute("download-filename")??void 0,hideBorder:this.getAttribute("hide-border")==="true"||this.hasAttribute("hide-border")&&this.getAttribute("hide-border")!=="false",styleScrollbars:this.getAttribute("style-scrollbars")==="true",selectionColor:this.getAttribute("selection-color")??void 0,footer:this.hasAttribute("footer")&&this.getAttribute("footer")!=="false"?{text:this.getAttribute("footer-label")??void 0}:void 0}}readToolbarConfig(){let n=i=>{let l=this.getAttribute(i);return l===null?void 0:l!=="false"},o={thumbnails:n("show-thumbnails-toggle"),pageNav:n("show-page-nav"),zoom:n("show-zoom"),fullscreen:n("show-fullscreen"),download:n("show-download")};return Object.values(o).some(i=>i!==void 0)?o:void 0}readPreferences(n){try{let o=this.ownerDocument.defaultView?.localStorage.getItem(n);if(!o)return;let i=JSON.parse(o);return {showThumbnails:typeof i.showThumbnails=="boolean"?i.showThumbnails:void 0,showInspector:typeof i.showInspector=="boolean"?i.showInspector:void 0,zoom:this.readZoomPreference(i.zoom)}}catch{return}}readZoomPreference(n){if(!n||typeof n!="object")return;let o=n;if(o.mode==="fit-page"||o.mode==="fit-width")return {mode:o.mode};if(o.mode==="custom"&&typeof o.scale=="number"&&Number.isFinite(o.scale)&&o.scale>0)return {mode:"custom",scale:o.scale}}writePreferences(n,o){try{this.ownerDocument.defaultView?.localStorage.setItem(n,JSON.stringify(o));}catch{}}};function wn(s="bonnie-pdf-previewer"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,ut);}exports.a=tn;exports.b=Lt;exports.c=Pt;exports.d=ut;exports.e=wn;
|
|
663
|
+
</footer>`:""}function vt(s){return Number.isFinite(s.left)&&Number.isFinite(s.top)&&Number.isFinite(s.right)&&Number.isFinite(s.bottom)&&s.width>0&&s.height>0}function Rt(s,n){let o=s.top+s.height/2,i=n.top+n.height/2,l=Math.max(1,Math.min(s.height,n.height)*.35);return Math.abs(o-i)<=l}function zt(s){let n=s.filter(i=>i.width>0&&i.height>0).map(i=>({...i})).sort((i,l)=>i.top-l.top||i.left-l.left),o=[];for(let i of n){let l=o.at(-1);if(l&&Rt(l,i)){let c=l.left+l.width,N=i.left-c,L=Math.max(2,Math.max(l.height,i.height)*1.25);if(N<=L){let A=Math.min(l.left,i.left),H=Math.min(l.top,i.top),j=Math.max(c,i.left+i.width),P=Math.max(l.top+l.height,i.top+i.height);l.left=A,l.top=H,l.width=j-A,l.height=P-H;continue}}o.push(i);}return o}function $t(s,n){try{let o=s.createRange();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}catch{return null}}function Dt(s,n){let o=n.getSelection();if(s instanceof ShadowRoot&&o){if(typeof o.getComposedRanges=="function")try{let l=o.getComposedRanges({shadowRoots:[s]}).map(c=>$t(n,c)).filter(c=>c!==null&&!c.collapsed);if(l.length>0)return l}catch{}let i=s.getSelection?.();if(i&&!i.isCollapsed)return Array.from({length:i.rangeCount},(l,c)=>i.getRangeAt(c)).filter(l=>!l.collapsed)}return !o||o.isCollapsed?[]:Array.from({length:o.rangeCount},(i,l)=>o.getRangeAt(l)).filter(i=>!i.collapsed)}function Ot(s,n){return s.right>n.left&&s.left<n.right&&s.bottom>n.top&&s.top<n.bottom}function Ft(s,n){if(n.contains(s.commonAncestorContainer))return true;try{return s.intersectsNode(n)}catch{return false}}function Bt(s,n){let o=n.getBoundingClientRect();if(!vt(o))return [];let i=[];for(let l of s){if(!vt(l)||!Ot(l,o))continue;let c=Math.max(l.left,o.left),N=Math.max(l.top,o.top),L=Math.min(l.right,o.right),A=Math.min(l.bottom,o.bottom);L<=c||A<=N||i.push({left:c-o.left,top:N-o.top,width:L-c,height:A-N});}return zt(i)}function Vt(s){for(let n of s)n.querySelector(":scope > .bpp-selection-layer")?.remove();}function wt(s){let{root:n,ownerDocument:o,pageElements:i,signal:l}=s,c=0,N=()=>Vt(i),L=()=>{if(c=0,l.aborted)return;let H=Dt(n,o);if(H.length===0){N();return}let j=[];for(let P of H)if(!(P.toString().length===0||typeof P.getClientRects!="function"))try{j.push({range:P,rects:Array.from(P.getClientRects())});}catch{}for(let P of i){let le=j.filter(({range:B})=>Ft(B,P)).flatMap(({rects:B})=>B),ue=Bt(le,P),F=P.querySelector(":scope > .bpp-selection-layer");if(ue.length===0){F?.remove();continue}F||(F=o.createElement("div"),F.className="bpp-selection-layer",F.setAttribute("aria-hidden","true"),P.appendChild(F));let ke=ue.map(B=>{let K=o.createElement("span");return K.className="bpp-selection-rect",K.style.left=`${B.left}px`,K.style.top=`${B.top}px`,K.style.width=`${B.width}px`,K.style.height=`${B.height}px`,K});F.replaceChildren(...ke);}},A=()=>{if(l.aborted||c!==0)return;let H=o.defaultView?.requestAnimationFrame;H?c=H.call(o.defaultView,L):L();};return o.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("pointerup",A,{signal:l}),n.addEventListener("pointermove",H=>{H.buttons===1&&A();},{signal:l}),n.addEventListener("keyup",A,{signal:l}),l.addEventListener("abort",()=>{c!==0&&o.defaultView?.cancelAnimationFrame?.(c),c=0,N();},{once:true}),{refresh:A,clear:N}}var st=24,xt=1.25,yt=.1,Et=5,jt="1500px 0px",Wt="800px 0px",Ye=200,lt=640,Gt=320,Ne=s=>Math.min(Math.max(s,yt),Et),Je=new WeakMap;function pt(s,n){return {value:s.style.getPropertyValue(n),priority:s.style.getPropertyPriority(n)}}function dt(s,n,o){o.value?s.style.setProperty(n,o.value,o.priority):s.style.removeProperty(n);}function Ut(s,n){let o=Je.get(s);if(!o){let i=s.body;o={owners:new Set,documentElement:s.documentElement,documentElementOverflow:pt(s.documentElement,"overflow"),documentElementScrollbarGutter:pt(s.documentElement,"scrollbar-gutter"),body:i,bodyOverflow:i?pt(i,"overflow"):null},Je.set(s,o);}o.owners.has(n)||(o.owners.add(n),o.documentElement.style.setProperty("overflow","hidden"),o.documentElement.style.setProperty("scrollbar-gutter","auto"),o.body?.style.setProperty("overflow","hidden"));}function Zt(s,n){let o=Je.get(s);o&&(o.owners.delete(n),!(o.owners.size>0)&&(dt(o.documentElement,"overflow",o.documentElementOverflow),dt(o.documentElement,"scrollbar-gutter",o.documentElementScrollbarGutter),o.body&&o.bodyOverflow&&dt(o.body,"overflow",o.bodyOverflow),Je.delete(s)));}function Lt(s,n={}){let o={plugins:n.plugins??[],showThumbnails:n.showThumbnails??false,showInspector:n.showInspector,initialZoom:n.initialZoom,onViewStateChange:n.onViewStateChange??(()=>{}),fitMode:n.fitMode??"fit-page",title:n.title??"PDF preview",downloadFilename:n.downloadFilename??"document.pdf",hideBorder:n.hideBorder??false,styleScrollbars:n.styleScrollbars??false,selectionColor:n.selectionColor?.trim()||void 0,footer:n.footer?{text:n.footer.text??"Generated by @bonniepdf/previewer",conformance:n.footer.conformance??true}:void 0,toolbar:{thumbnails:n.toolbar?.thumbnails??true,pageNav:n.toolbar?.pageNav??true,zoom:n.toolbar?.zoom??true,fullscreen:n.toolbar?.fullscreen??true,download:n.toolbar?.download??true}};ht(s,o),o.selectionColor&&s.querySelector(".bpp")?.style.setProperty("--bpdf-selection",o.selectionColor);let i=s instanceof ShadowRoot?s.host:s,l=i.ownerDocument,c=a=>s.querySelector(a),N=new AbortController,L=[],A=null,H=false,j=null,P=0,le=false,ue=null,F=o.plugins,ke=[],B=[],K=[],W=()=>1,ae=()=>{},G=[],Q=null,D=false,x=null,k=null,te=null,se=null,R=null,V=null,ne=o.showThumbnails,he=o.initialZoom?.mode==="custom"?{mode:"custom",scale:Ne(o.initialZoom.scale??1)}:{mode:o.initialZoom?.mode??o.fitMode};function Me(){o.onViewStateChange({showThumbnails:ne,showInspector:D,zoom:{...he}});}let Re={error:3,warning:2,info:1,ok:0};function Qe(){if(!V)return;let a=null;for(let p of G)p.badgeTone&&(a===null||Re[p.badgeTone]>Re[a])&&(a=p.badgeTone);a&&a!=="ok"?(V.hidden=false,V.className=`bpp-side-toggle-dot bpp-side-toggle-dot-${a}`):V.hidden=true;}function ze(){te&&(te.hidden=G.length<2);}function Ge(){D=true,x&&(x.hidden=false),k&&(k.hidden=false),R?.setAttribute("aria-pressed","true"),R?.classList.add("bpp-btn-active"),Me();}function xe(){D=false,x&&(x.hidden=true),k&&(k.hidden=true),R?.setAttribute("aria-pressed","false"),R?.classList.remove("bpp-btn-active"),G.find(a=>a.id===Q)?.onVisibilityChange?.(false),Me();}function ye(a){if(!a)return;let p=G.find(v=>v.id===a);if(!p||D&&Q===a)return;let b=Q;if(D||Ge(),b&&b!==a){let v=G.find(S=>S.id===b);v&&(v.element.hidden=true,v.tabBtn.setAttribute("aria-selected","false"),v.tabBtn.classList.remove("bpp-side-tab-active"),v.onVisibilityChange?.(false));}Q=a,p.element.hidden=false,p.tabBtn.setAttribute("aria-selected","true"),p.tabBtn.classList.add("bpp-side-tab-active"),p.onVisibilityChange?.(true);}function oe(a){let p=c(".bpp-body")?.clientWidth??0,b=p>0?p-Gt:lt,v=Math.max(Ye,Math.min(lt,b));return Math.min(Math.max(a,Ye),v)}function Ce(a){if(!x)return;let p=oe(a);x.style.width=`${p}px`,k?.setAttribute("aria-valuenow",String(Math.round(p)));}function $e(a){let p=false,b=0,v=0;a.addEventListener("pointerdown",m=>{x&&(p=true,b=m.clientX,v=x.getBoundingClientRect().width,a.setPointerCapture(m.pointerId),a.classList.add("bpp-side-resizer-active"),m.preventDefault());}),a.addEventListener("pointermove",m=>{p&&Ce(v+(b-m.clientX));});let S=m=>{p&&(p=false,a.hasPointerCapture(m.pointerId)&&a.releasePointerCapture(m.pointerId),a.classList.remove("bpp-side-resizer-active"));};a.addEventListener("pointerup",S),a.addEventListener("pointercancel",S),a.addEventListener("keydown",m=>{if(!x)return;let O=m.shiftKey?48:16,T=x.getBoundingClientRect().width;m.key==="ArrowLeft"?(Ce(T+O),m.preventDefault()):m.key==="ArrowRight"&&(Ce(T-O),m.preventDefault());});}function _e(){x||(x=l.createElement("aside"),x.className="bpp-side",x.hidden=true,x.setAttribute("aria-label","Inspector"),te=l.createElement("div"),te.className="bpp-side-tabs",te.setAttribute("role","tablist"),te.hidden=true,se=l.createElement("div"),se.className="bpp-side-body",x.append(te,se),k=l.createElement("div"),k.className="bpp-side-resizer",k.hidden=true,k.setAttribute("role","separator"),k.setAttribute("aria-orientation","vertical"),k.setAttribute("aria-label","Resize inspector panel"),k.setAttribute("aria-valuemin",String(Ye)),k.setAttribute("aria-valuemax",String(lt)),k.setAttribute("aria-valuenow",String(Ye)),k.tabIndex=0,$e(k),c(".bpp-body")?.append(k,x),R=l.createElement("button"),R.type="button",R.className="bpp-btn bpp-side-toggle",R.title="Toggle inspector panel",R.setAttribute("aria-label","Toggle inspector panel"),R.setAttribute("aria-pressed","false"),R.innerHTML=re("panel-right","bpp-icon"),V=l.createElement("span"),V.className="bpp-side-toggle-dot",V.hidden=true,R.append(V),R.addEventListener("click",()=>{D?xe():ye(Q??G[0]?.id??null);}),(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(R));}let Ue={ownerDocument:l,hostElement:i,addToolbarItem(a){(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(a);},addSidePanel({id:a,label:p,element:b,defaultOpen:v,onVisibilityChange:S}){_e();let m=l.createElement("button");m.type="button",m.className="bpp-side-tab",m.setAttribute("role","tab"),m.setAttribute("aria-selected","false");let O=l.createElement("span");O.className="bpp-side-tab-label",O.textContent=p;let T=l.createElement("span");T.className="bpp-side-tab-badge",T.hidden=true,m.append(O,T),m.addEventListener("click",()=>ye(a)),b.dataset.sidePanel=a,b.hidden=true,se.append(b);let ie={id:a,label:p,element:b,tabBtn:m,badgeEl:T,onVisibilityChange:S,badgeTone:null};return G.push(ie),G.sort((M,X)=>M.label.localeCompare(X.label,void 0,{sensitivity:"base"})),te.replaceChildren(...G.map(M=>M.tabBtn)),ze(),(o.showInspector??v)&&!D&&Q===null&&ye(a),{setVisible(M){M?ye(a):Q===a&&D&&xe();},setBadge(M,X="info"){M==null||M===""?(T.hidden=true,T.textContent="",ie.badgeTone=null):(T.hidden=false,T.textContent=M,T.className=`bpp-side-tab-badge bpp-side-tab-badge-${X}`,ie.badgeTone=X),Qe();}}},pageElement:a=>B[a]??null,overlayFor(a){let p=B[a];if(!p)return null;let b=K[a];return b||(b=l.createElement("div"),b.className="bpp-overlay",p.append(b),K[a]=b),b},scale:()=>W(),pageCount:()=>B.length,scrollToPage:a=>ae(a)};for(let a of F)try{let p=a.setup?.(Ue);p&&ke.push(p);}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" setup failed`,p);}function et(a){let p=c("[data-footer-tags]");if(!p)return;let b=[];if(o.footer?.conformance){let v=a?/^PdfA(\d)([a-z]?)$/i.exec(a.conformance.trim()):null;v&&b.push(`PDF/A-${v[1]}${v[2].toLowerCase()}`);let S=a?.accessibilityMode;(S===1||S===2)&&b.push(`PDF/UA-${S}`);}p.replaceChildren(...b.map(v=>{let S=l.createElement("span");return S.className="bpp-footer-tag",S.textContent=v,S}));}let De=F.some(a=>a.needsLayout===true),Ze=n.downloadFilename;function Te(){ue&&(URL.revokeObjectURL(ue),ue=null);}function qe(){let a=c(".bpp"),p=c("[data-error]");if(p&&(p.hidden=true),le)a?.classList.add("bpp-busy"),a?.setAttribute("aria-busy","true");else {let b=c("[data-loading]");b&&(b.hidden=false);}}function Ae(){let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-loading]");p&&(p.hidden=true);let b=c("[data-error]");b&&(b.hidden=true);}function He(a){Ae();let p=c("[data-error]");if(!p)return;p.classList.toggle("bpp-error-banner",le);let b=p.querySelector("[data-error-detail]");b&&(b.textContent=a instanceof Error?a.message:String(a)),p.hidden=false;}function Ke(a,p){if(Array.isArray(a)){if(H)return;P++;let b=p??{};h(a,{fontFaceCss:b.fontFaceCss,snapshot:b.snapshot,report:b.report,filename:b.downloadFilename??o.downloadFilename,pdf:b.pdfUrl??b.pdfProvider,legacyDownload:true});return}return Oe(a,p??{})}async function Oe(a,p){if(H)return;let b=++P,v=()=>b===P&&!H;qe();try{let S=await a;if(!v())return;let m,O=p.pdf,T;if(qt(S)){if(m=await S.generateSvgDocumentAsync({captureLayout:De}),!v())return;O??=()=>S.generateBytesAsync(),T=S.metadata?.title;}else if(Kt(S))m=S;else throw new TypeError("load() expects a BonniePDF Document, an SVG document export, or a promise of either.");T??=m.snapshot?.meta?.title,h(at(m.pages),{fontFaceCss:m.fontFaceCss,snapshot:m.snapshot,report:m.report,filename:p.downloadFilename??Ze??Xt(T)??o.downloadFilename,pdf:O});}catch(S){if(!v())return;throw He(S),i.dispatchEvent(new CustomEvent("bpp-load-error",{detail:{error:S},bubbles:true,composed:true})),S}}function h(a,p){if(H)return;Te(),N.abort(),N=new AbortController;for(let u of L)u.disconnect();L=[],Fe();let b=N.signal;Ee(p.fontFaceCss);let v=c("[data-scroll]"),S=c("[data-pages]"),m=c("[data-thumbs]"),O=c("[data-thumbs-list]"),T=u=>a[u].svg,ie=[],$=[],M=a.map((u,y)=>{let I=l.createElement("li"),z=l.createElement("button");z.type="button",z.className=`bpp-thumb${y===0?" bpp-thumb-active":""}`,z.setAttribute("aria-label",`Go to page ${y+1}`),y===0&&z.setAttribute("aria-current","page"),z.dataset.thumb=String(y+1),$.push(z);let Pe=l.createElement("span");Pe.className="bpp-thumb-canvas",Pe.setAttribute("aria-hidden","true"),Pe.style.aspectRatio=`${u.width} / ${u.height}`,ie.push(Pe);let ge=l.createElement("span");return ge.className="bpp-thumb-label",ge.textContent=String(y+1),z.append(Pe,ge),I.append(z),I}),X=[],ee=a.map((u,y)=>{let I=l.createElement("div");I.className="bpp-page",I.dataset.pageIndex=String(y),I.style.width=`${u.width}px`,I.style.height=`${u.height}px`;let z=l.createElement("div");return z.className="bpp-page-canvas",I.append(z),X.push(z),I});O.replaceChildren(...M),S.replaceChildren(...ee),Be(X,T,u=>`p${u}-`,v,jt),Be(ie,T,u=>`t${u}-`,m,Wt,true);let be=wt({root:s,ownerDocument:l,pageElements:ee,signal:b}),U=he.mode,fe=he.mode==="custom"?Ne(he.scale??1):1,Z=1,Le={width:v.clientWidth,height:v.clientHeight},pe=a.length,Ve=c(".bpp"),e=c("[data-toggle-thumbs]"),t=c("[data-prev]"),r=c("[data-next]"),f=c("[data-zoom-out]"),d=c("[data-zoom-in]"),g=c("[data-zoom-select]"),C=c("[data-custom-zoom]"),w=c("[data-current-page]"),E=c("[data-total-pages]"),q=c("[data-page-label]"),Y=c("[data-fullscreen]"),de=c("[data-download]"),J=Ve?.classList.contains("bpp-fullscreen")??false,_=null,ce=()=>{if(U==="custom")return fe;let u=a[Z-1]??a[0];if(!u||Le.width===0)return 1;let y=Math.max(Le.width-st*2,1)/u.width;return U==="fit-width"?y:Math.min(y,Math.max(Le.height-st*2,1)/u.height)},ve=(u=ce())=>{e?.classList.toggle("bpp-btn-active",ne),e?.setAttribute("aria-pressed",String(ne)),e?.setAttribute("title",ne?"Hide page thumbnails":"Show page thumbnails"),w&&(w.textContent=String(Z)),q?.setAttribute("aria-label",`Page ${Z} of ${pe}`),t&&(t.disabled=Z<=1),r&&(r.disabled=Z>=pe),f&&(f.disabled=u<=yt),d&&(d.disabled=u>=Et),Y&&(Y.classList.toggle("bpp-btn-active",J),Y.setAttribute("aria-pressed",String(J)),Y.setAttribute("aria-label",J?"Exit full screen":"Full screen"),Y.setAttribute("title",J?"Exit full screen":"Full screen")),g&&(C&&(C.textContent=`${Math.round(u*100)}%`,C.hidden=U!=="custom"),g.value=U),$.forEach((y,I)=>{let z=I+1===Z;y.classList.toggle("bpp-thumb-active",z),z?y.setAttribute("aria-current","page"):y.removeAttribute("aria-current");});},Se=()=>{let u=ce();ee.forEach((y,I)=>{let z=a[I];z&&(y.style.width=`${z.width*u}px`,y.style.height=`${z.height*u}px`);}),be.refresh(),ve(u);for(let y of F)try{y.sync?.({scale:u,currentPage:Z});}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" sync failed`,I);}},nt=()=>{he=U==="custom"?{mode:U,scale:fe}:{mode:U},J&&(_=null),Me();},kt=()=>{try{return i.matches(":popover-open")}catch{return false}},we=l.fullscreenElement===i?"native":kt()?"popover":null,ot=u=>{if(u===J)return;u?(_=U==="custom"?{mode:U,scale:fe}:{mode:U},U="fit-page"):_&&(U=_.mode,_.mode==="custom"&&(fe=Ne(_.scale??1)),_=null),J=u,J?Ut(l,i):Zt(l,i),Ve?.classList.toggle("bpp-fullscreen",J),Le={width:v.clientWidth,height:v.clientHeight},ve();let y=l.defaultView;typeof y?.requestAnimationFrame=="function"?y.requestAnimationFrame(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();}):Se();},Tt=()=>{if(we==="popover"){try{i.hidePopover?.();}catch{}i.removeAttribute("popover"),i.classList.remove("bpp-popover-host"),we=null;}else we==="native"&&l.fullscreenElement===i&&l.exitFullscreen?.().catch(()=>{});},Mt=()=>{let u=i;if(typeof u.showPopover=="function")try{i.classList.add("bpp-popover-host"),i.setAttribute("popover","manual"),u.showPopover(),we="popover";return}catch{i.removeAttribute("popover"),i.classList.remove("bpp-popover-host");}typeof i.requestFullscreen=="function"&&(we="native",i.requestFullscreen().catch(()=>{we=null;}));},rt=u=>{ot(u),u?Mt():Tt();};j=()=>{J&&rt(false);};let bt=u=>{Z=Math.min(Math.max(u,1),pe),ve();},je=u=>{let y=Math.min(Math.max(u,1),pe),I=ee[y-1];if(!I||(bt(y),typeof v.scrollTo!="function"))return;let z=I.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollTo({top:Math.max(v.scrollTop+z-st,0),behavior:"smooth"});};if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();});u.observe(v),L.push(u);}if(typeof IntersectionObserver<"u"){let u=new Map,y=new IntersectionObserver(I=>{for(let ge of I){let it=Number(ge.target.dataset.pageIndex);u.set(it,ge.isIntersecting?ge.intersectionRatio:0);}let z=-1,Pe=0;u.forEach((ge,it)=>{ge>Pe&&(z=it,Pe=ge);}),z>=0&&bt(z+1);},{root:v,threshold:[.1,.25,.5,.75,1]});ee.forEach(I=>y.observe(I)),L.push(y);}e?.addEventListener("click",()=>{ne=!ne,m&&(m.hidden=!ne),Se(),Me();},{signal:b}),t?.addEventListener("click",()=>je(Z-1),{signal:b}),r?.addEventListener("click",()=>je(Z+1),{signal:b}),$.forEach(u=>u.addEventListener("click",()=>je(Number(u.dataset.thumb)),{signal:b})),v.addEventListener("click",u=>{let y=u.target?.closest?.("[data-bp-link-page]");if(!y)return;let I=Number(y.getAttribute("data-bp-link-page"));Number.isFinite(I)&&I>=1&&je(I);},{signal:b}),f?.addEventListener("click",()=>{fe=Ne(ce()/xt),U="custom",Se(),nt();},{signal:b}),d?.addEventListener("click",()=>{fe=Ne(ce()*xt),U="custom",Se(),nt();},{signal:b}),g?.addEventListener("change",()=>{let u=g.value;u==="fit-page"||u==="fit-width"?U=u:u!=="custom"&&(fe=Ne(Number(u)),U="custom"),Se(),nt();},{signal:b}),Y?.addEventListener("click",()=>rt(!J),{signal:b}),l.addEventListener("fullscreenchange",()=>{l.fullscreenElement===i?(we="native",J||ot(true)):we==="native"&&(we=null,J&&ot(false));},{signal:b}),l.addEventListener("keydown",u=>{u.key==="Escape"&&J&&rt(false);},{signal:b});let Ct=p.filename,Ie=p.pdf,_t=P,We;if(de&&(de.disabled=Ie===void 0,p.legacyDownload||Yt(de,Ie!==void 0)),de?.addEventListener("click",async()=>{if(!We&&Ie!==void 0){de.disabled=true;try{let u=typeof Ie=="function"?await Ie():Ie;if(typeof u=="string")We=u;else {let y=URL.createObjectURL(u instanceof Blob?u:new Blob([u],{type:"application/pdf"}));if(_t!==P||H){URL.revokeObjectURL(y);return}ue=y,We=y;}}catch{}finally{de.disabled=false;}}We&&Jt(l,We,Ct);},{signal:b}),E&&(E.textContent=String(pe)),w&&(w.textContent=pe>0?"1":"0"),m&&(m.hidden=!ne),Ae(),le=true,et(p.snapshot?.meta),B=ee,K=new Array(a.length).fill(null),W=ce,ae=je,F.length>0){let u={...Ue,pages:a,snapshot:p.snapshot,report:p.report};for(let y of F)try{y.load?.(u);}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" load failed`,I);}}Se();}function Fe(){for(let a of F)try{a.teardown?.();}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" teardown failed`,p);}K=[];}function Xe(a){if(H)return false;let p=false;for(let b of F)try{b.selectSnapshotNode?.(a)&&(p=!0);}catch(v){console.error(`[bonniepdf-previewer] plugin "${b.name}" selection failed`,v);}return p}function Be(a,p,b,v,S,m=false){let O=new Map,T=($,M)=>{if($.dataset.mounted==="true")return;let X=O.get(M);if(X===void 0&&(X=gt(p(M),b(M)),O.set(M,X)),$.innerHTML=X,m){let ee=$.querySelector("svg");ee&&ee.setAttribute("aria-hidden","true");for(let be of $.querySelectorAll("a"))be.removeAttribute("href"),be.removeAttribute("xlink:href"),be.removeAttribute("target"),be.setAttribute("tabindex","-1");}$.dataset.mounted="true";},ie=$=>{$.dataset.mounted==="true"&&($.replaceChildren(),$.dataset.mounted="false");};if(a.forEach(($,M)=>{$.dataset.lazyIndex=String(M);}),a[0]&&T(a[0],0),v&&typeof IntersectionObserver<"u"){let $=new IntersectionObserver(M=>{for(let X of M){let ee=X.target,be=Number(ee.dataset.lazyIndex);X.isIntersecting?T(ee,be):ie(ee);}},{root:v,rootMargin:S});a.forEach(M=>$.observe(M)),L.push($);}else a.forEach(($,M)=>T($,M));}function Ee(a){a&&(A||(A=l.createElement("style"),A.setAttribute("data-bpp-fonts",""),l.head.appendChild(A)),A.textContent!==a&&(A.textContent=a));}function me(){if(H)return;P++,Te(),N.abort(),N=new AbortController;for(let ie of L)ie.disconnect();L=[],Fe(),le=false,c("[data-pages]")?.replaceChildren(),c("[data-thumbs-list]")?.replaceChildren();let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-error]");p&&(p.hidden=true);let b=c("[data-loading]");b&&(b.hidden=false);let v=c("[data-current-page]");v&&(v.textContent="0");let S=c("[data-total-pages]");S&&(S.textContent="0");let m=c("[data-prev]");m&&(m.disabled=true);let O=c("[data-next]");O&&(O.disabled=true);let T=c("[data-download]");T&&(T.disabled=true);}function tt(){if(!H){j?.(),j=null,H=true,Fe();for(let a of ke.splice(0))try{a();}catch{}N.abort();for(let a of L)a.disconnect();L=[],A&&(A.remove(),A=null),Te();}}return {load:Ke,selectSnapshotNode:Xe,clear:me,dispose:tt}}function qt(s){let n=s;return typeof n=="object"&&n!==null&&typeof n.generateSvgDocumentAsync=="function"&&typeof n.generateBytesAsync=="function"}function Kt(s){let n=s?.pages;return Array.isArray(n)&&n.every(o=>typeof o=="string")}function Xt(s){let n=(s??"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80).replace(/-+$/,"");return n?`${n}.pdf`:void 0}function Yt(s,n){let o=s.closest(".bpp-group");if(!o)return;o.hidden=!n;let i=o.previousElementSibling;i instanceof HTMLElement&&i.classList.contains("bpp-sep")&&(i.hidden=!n);}function Jt(s,n,o){let i=s.createElement("a");i.href=n,i.download=o,i.rel="noopener",s.body.appendChild(i),i.click(),i.remove();}var St={error:3,warning:2,info:1},ct={error:"Error",warning:"Warning",info:"Info"},Qt={error:"circle-x",warning:"triangle-alert",info:"info"},en="WCAG";function Pt(s={}){let n=s.label??"Accessibility",o=s.issuesLabel??"Issues",i=s.openByDefault??false,l=s.markIssuesOnPage??true,c=Math.max(0,s.defaultExpandDepth??1/0),N=s.preferenceKey,L=null,A=null,H=null,j=null,P=null,le=false,ue=false,F=()=>le||ue,ke=Me(N),B=ke?.onlyIssues??s.onlyIssues??false,K=ke?.showWcag??s.showWcagChecks??true,W=new Map,ae=new Map,G=new Map,Q=new Map,D=new Set,x=null,k=null,te=null,se=[],R=[],V=null,ne=null;function he(e){return x?e.id===x.id?true:e.type==="Page"&&x.children.includes(e)&&x.sourceId!==void 0&&e.sourceId===x.sourceId:false}function Me(e){if(e)try{let t=globalThis.localStorage?.getItem(e);if(!t)return;let r=JSON.parse(t);return {onlyIssues:r.onlyIssues===!0,showWcag:r.showWcag!==!1}}catch{return}}function Re(){if(N)try{globalThis.localStorage?.setItem(N,JSON.stringify({onlyIssues:B,showWcag:K}));}catch{}}function Qe(e){return e.standard.toUpperCase().startsWith(en)}function ze(){return k?K?[...k.findings]:k.findings.filter(e=>!Qe(e)):[]}function Ge(){Q.clear();for(let e of ze()){if(!e.nodeId)continue;let t=Q.get(e.nodeId);t?t.push(e):Q.set(e.nodeId,[e]);}}function xe(e){let t=Q.get(e);if(!t||t.length===0)return null;let r="info";for(let f of t)St[f.severity]>St[r]&&(r=f.severity);return r}function ye(e,t,r){e.style.left=`${t.x*r}px`,e.style.top=`${t.y*r}px`,e.style.width=`${t.width*r}px`,e.style.height=`${t.height*r}px`;}function oe(e){for(let t of e)t.element.remove();e.length=0;}function Ce(e,t,r){if(L)for(let f of t.rects){let d=L.overlayFor(f.page);if(!d)continue;let g=L.ownerDocument.createElement("div");g.className=r,ye(g,f,L.scale()),d.append(g),e.push({element:g,rect:f});}}function $e(){if(oe(se),!l||!x)return;let e=t=>{let r=xe(t.id);r&&Ce(se,t,`bpp-cv-mark bpp-cv-mark-${r}`);for(let f of t.children)e(f);};e(x);}function _e(e){oe(R);let t=xe(e.id),r=t?`bpp-cv-sel bpp-cv-sel-${t}`:"bpp-cv-sel";Ce(R,e,r);}function Ue(e,t,r){if(!x)return null;let f=null,d=-1,g=1/0,C=(w,E)=>{for(let q of w.rects){if(q.page!==e||t<q.x||t>q.x+q.width||r<q.y||r>q.y+q.height)continue;let Y=q.width*q.height;(E>d||E===d&&Y<g)&&(f=w,d=E,g=Y);}for(let q of w.children)C(q,E+1);};return C(x,0),f}function et(){if(D.clear(),!x)return;let e=(t,r)=>{let f=xe(t.id)==="error";for(let d of t.children)e(d,r+1)&&(f=true);return t.children.length>0&&(r<c||f)&&D.add(t.id),f};e(x,0),B&&De();}function De(){for(let e of Q.keys())Ze(e);}function Ze(e){let t=G.get(e);for(;t;)D.add(t.id),t=G.get(t.id);}function Te(e,t){e.children.length!==0&&(t?D.add(e.id):D.delete(e.id),qe(e.id));}function qe(e){let t=W.get(e);if(!t)return;let r=t.parentElement?.querySelector(":scope > ul");if(!r)return;let f=D.has(e);t.setAttribute("aria-expanded",String(f)),r.hidden=!f;}function Ae(e){if(x){if(D.clear(),e){let t=r=>{r.children.length>0&&D.add(r.id);for(let f of r.children)t(f);};t(x);}else x.children.length>0&&D.add(x.id);pe();}}function He(e,t=false){if(!L)return;if(he(e)){V=null;for(let f of W.values())f.setAttribute("aria-selected","false");oe(R),O(null),t&&Ke(e.id);return}V=e.id;for(let[f,d]of W)d.setAttribute("aria-selected",String(f===e.id));_e(e),O(e),t&&Ke(e.id);let r=e.rects[0];r&&L.scrollToPage(r.page+1);}function Ke(e){Ze(e);let t=G.get(e);for(;t;)qe(t.id),t=G.get(t.id);let r=W.get(e);r&&(Ee(e),typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest"}));}function Oe(e,t,r){L&&L.hostElement.dispatchEvent(new CustomEvent("bonniepdf-node-select",{bubbles:true,composed:true,detail:{nodeId:e.id,sourceId:e.sourceId,sourceNavigation:t,origin:r}}));}function h(e,t,r){let d=L.ownerDocument.createElement(e);return t&&(d.className=t),r!=null&&(d.textContent=r),d}function Fe(e){let t=e.rects[0];if(!t)return "";let r=[...new Set(e.rects.map(w=>w.page))].sort((w,E)=>w-E),f=r.length===1?`Page ${r[0]+1}`:`Pages ${r[0]+1}\u2013${r[r.length-1]+1}`,d=`${Math.round(t.width)}\xD7${Math.round(t.height)} pt`,g=`at ${Math.round(t.x)}, ${Math.round(t.y)}`,C=e.rects.length>1?` \xB7 ${e.rects.length} fragments`:"";return `${f} \xB7 ${d} ${g}${C}`}function Xe(e,t,r){let f=h("ul");f.setAttribute("role",t);for(let d of e){let g=xe(d.id),C=g!=null||p(d);if(B&&!C)continue;let w=h("li");w.setAttribute("role","none");let E=h("button","bpp-tree-row bpp-cv-row");E.type="button",E.setAttribute("role","treeitem"),E.setAttribute("aria-selected","false"),E.setAttribute("aria-level",String(r)),E.dataset.nodeId=d.id,E.tabIndex=-1;let q=d.children.length>0,Y=h("span",q?"bpp-tree-twisty":"bpp-tree-twisty bpp-tree-twisty-leaf");Y.setAttribute("aria-hidden","true"),E.append(Y);let de=d.a11y,J=de?.artifact?"Artifact":de?.role||(de?.tagged?"Tagged":"");if(J){let _=h("span","bpp-cv-role",J);J==="Artifact"?(_.classList.add("bpp-cv-role-artifact"),_.title="Artifact (outside the reading order)"):de?.tagged&&(_.classList.add("bpp-cv-role-tagged"),_.title="Tagged content",E.setAttribute("aria-description","Tagged content")),E.append(_);}if(E.append(h("span","bpp-tree-type",d.type)),g){let _=Q.get(d.id).length,ce=`${ct[g]}: ${_} ${_===1?"finding":"findings"}`,ve=h("span",`bpp-cv-issue-icon bpp-cv-issue-icon-${g}`);ve.setAttribute("role","img"),ve.setAttribute("aria-label",ce),ve.title=ce,ve.innerHTML=re(Qt[g]),E.append(ve);}if(d.name&&E.append(h("span","bpp-tree-name",d.name)),E.addEventListener("click",_=>{if(q&&_.target?.closest(".bpp-tree-twisty")){Te(d,!D.has(d.id)),Ee(d.id);return}Ee(d.id),He(d),Oe(d,he(d)||_.ctrlKey||_.metaKey,"tree");}),E.addEventListener("keydown",_=>tt(_,d)),E.addEventListener("focus",()=>Ee(d.id)),E.addEventListener("mouseenter",()=>{V!==d.id&&_e(d);}),E.addEventListener("mouseleave",()=>{if(V){let _=ae.get(V);_&&_e(_);}else oe(R);}),W.set(d.id,E),w.append(E),q){let _=Xe(d.children,"group",r+1);if(_.childElementCount>0){let ce=D.has(d.id);E.setAttribute("aria-expanded",String(ce)),_.hidden=!ce,w.append(_);}else Y.classList.add("bpp-tree-twisty-leaf");}f.append(w);}return f}function Be(){return Z?Array.from(Z.querySelectorAll(".bpp-tree-row")).filter(t=>{let r=t.parentElement;for(;r&&r!==Z;){if(r.tagName==="UL"&&r.hidden)return false;r=r.parentElement;}return true}):[]}function Ee(e){te=e;for(let[t,r]of W)r.tabIndex=t===e?0:-1;}function me(e){if(!e)return;let t=e.dataset.nodeId;t&&Ee(t),e.focus();}function tt(e,t){let r=Be(),f=W.get(t.id),d=f?r.indexOf(f):-1,g=t.children.length>0&&W.get(t.id)?.hasAttribute("aria-expanded")===true,C=D.has(t.id);switch(e.key){case "ArrowDown":e.preventDefault(),me(r[d+1]);break;case "ArrowUp":e.preventDefault(),me(r[d-1]);break;case "ArrowRight":e.preventDefault(),g&&!C?Te(t,true):g&&me(r[d+1]);break;case "ArrowLeft":{if(e.preventDefault(),g&&C){Te(t,false);break}let w=G.get(t.id);w&&me(W.get(w.id));break}case "Home":e.preventDefault(),me(r[0]);break;case "End":e.preventDefault(),me(r[r.length-1]);break;case "*":e.preventDefault(),Ae(true),me(W.get(t.id));break;}}function a(e){return /^H[1-6]$/.test(e)?"heading":e==="Figure"?"figure":e==="Artifact"?"artifact":e==="Table"||e==="TH"||e==="TD"||e==="TR"?"table":"default"}function p(e){for(let t of e.children)if(xe(t.id)||p(t))return true;return false}function b(e){for(let t of ae.values())if(e(t))return t;return null}function v(e){ae.clear(),G.clear();let t=r=>{ae.set(r.id,r);for(let f of r.children)G.set(f.id,r),t(f);};t(e);}function S(e,t){let r=h("div",`bpp-cv-finding bpp-cv-finding-${e.severity}`),f=h("div","bpp-cv-finding-head");f.append(h("span",`bpp-cv-badge bpp-cv-badge-${e.severity}`,ct[e.severity])),f.append(h("span","bpp-cv-clause",e.clause)),r.append(f);let d=e.nodeId?ae.get(e.nodeId):void 0;if(t&&d){let g=h("p","bpp-cv-finding-where");g.append(h("span","bpp-cv-finding-el",d.name?`${d.type} \u201C${d.name}\u201D`:d.type)),e.page!=null&&g.append(h("span","bpp-cv-finding-page",` \xB7 page ${e.page+1}`)),r.append(g);}if(r.append(h("p","bpp-cv-msg",e.message)),e.fixHint){let g=h("p","bpp-cv-fix");g.append(h("span","bpp-cv-fix-label","Fix: ")),g.append(L.ownerDocument.createTextNode(e.fixHint)),r.append(g);}if(t&&e.nodeId){let g=h("button","bpp-cv-jump","Go to element");g.type="button",g.addEventListener("click",C=>{let w=d??b(E=>E.id===e.nodeId);w&&(A?.setVisible(true),He(w,true),W.get(w.id)?.focus(),Oe(w,C.ctrlKey||C.metaKey,"finding"));}),r.append(g);}return r}let m=null;function O(e){if(!m)return;m.replaceChildren();let t=e?Q.get(e.id):void 0;if(!e){m.append(h("p","bpp-cv-empty","Select an element to see its accessibility details."));return}let r=h("div","bpp-cv-detail-head");r.append(h("span","bpp-cv-detail-type",e.type)),e.name&&r.append(h("span","bpp-cv-detail-name",e.name)),e.a11y?.role&&r.append(h("span",`bpp-cv-role bpp-cv-role-${a(e.a11y.role)}`,e.a11y.role)),m.append(r);let f=Fe(e);if(f&&m.append(h("p","bpp-cv-geom",f)),e.a11y?.alt&&m.append(h("p","bpp-cv-attr",`Alt: \u201C${e.a11y.alt}\u201D`)),!t||t.length===0){m.append(h("p","bpp-cv-empty",e.a11y?"No accessibility issues on this element.":"This element carries no structure role."));return}for(let d of t)m.append(S(d,false));}function T(){let e={error:0,warning:0,info:0};for(let t of ze())e[t.severity]++;return e}function ie(){if(!H)return;if(!k){H.setBadge(null);return}let{error:e,warning:t}=T();e===0&&t===0?H.setBadge("\u2713","ok"):H.setBadge(String(e+t),e>0?"error":"warning");}function $(e,t,r,f){let d=h("label","bpp-cv-filter");d.title=r;let g=L.ownerDocument.createElement("input");return g.type="checkbox",g.checked=t,g.addEventListener("change",()=>f(g.checked)),d.append(g,L.ownerDocument.createTextNode(` ${e}`)),d}let M=null;function X(){let e=h("div","bpp-cv-header");if(!k)return e.append(h("span","bpp-cv-empty","No compliance report; showing structure roles only.")),e;let t=T(),r=h("div","bpp-cv-pills"),f=(g,C,w)=>{r.append(h("span",`bpp-cv-pill bpp-cv-pill-${g}${C===0?" bpp-cv-pill-zero":""}`,`${C} ${w}`));};f("error",t.error,t.error===1?"error":"errors"),f("warning",t.warning,t.warning===1?"warning":"warnings"),f("info",t.info,"info"),e.append(r);let d=k.findings.find(g=>g.standard.startsWith("PDF/UA"))?.standard??"PDF/UA-1";return e.append(h("div",`bpp-cv-verdict ${k.passed?"bpp-cv-verdict-pass":"bpp-cv-verdict-fail"}`,k.passed?`Passes ${d} checks`:`Does not meet ${d}`)),e}function ee(){M&&M.replaceChildren(X(),be());}function be(){let e=h("div","bpp-cv-settings"),t=h("div","bpp-cv-filters");k&&(t.append($("Show only elements with issues",B,"Hide every branch of the tree with no findings in it",d=>{B=d,B&&De(),Re(),pe();})),t.append(U())),e.append(t);let r=h("div","bpp-cv-tree-actions"),f=(d,g,C)=>{let w=h("button","bpp-cv-action",d);w.type="button",w.title=g,w.addEventListener("click",C),r.append(w);};return f("Expand all","Expand every branch of the tree",()=>Ae(true)),f("Collapse all","Collapse the tree back to the document",()=>Ae(false)),e.append(r),e}function U(){return $("Include WCAG contrast checks",K,"WCAG 2.2 SC 1.4.3 text-contrast findings. PDF/UA-1 sets no numeric contrast requirement, so these are a separate standard you may be tracking separately.",e=>{K=e,Re(),Le();})}function fe(){if(!P)return;if(P.replaceChildren(),!k){P.append(h("p","bpp-cv-empty","No compliance report was supplied, so there are no findings to list."));return}let e=h("div","bpp-cv-issues-head");e.append(X()),e.append(U()),P.append(e);let t=h("div","bpp-cv-issues-list"),r=ze(),f=["error","warning","info"];for(let d of f){let g=r.filter(w=>w.severity===d);if(g.length===0)continue;let C=h("section","bpp-cv-issues-group");C.append(h("div","bpp-cv-section-title",`${ct[d]}${g.length===1?"":"s"} (${g.length})`));for(let w of g){let E=S(w,w.nodeId!=null);w.nodeId||E.prepend(h("span","bpp-cv-scope","Document")),C.append(E);}t.append(C);}t.childElementCount===0&&t.append(h("p","bpp-cv-empty",K?"No findings. This document passes every check the preflight runs.":"No findings, with contrast checks excluded. Include them to check text contrast too.")),P.append(t);}let Z=null;function Le(){Ge(),B&&De(),ee(),fe(),pe();let e=V?ae.get(V):null;O(e??null),ie(),F()&&$e(),e?_e(e):oe(R);}function pe(){if(!Z||!x)return;W.clear();let e=Xe([x],"tree",1);if(e.classList.add("bpp-tree","bpp-cv-tree"),e.setAttribute("aria-label",n),Z.replaceChildren(e),e.childElementCount===0&&Z.append(h("p","bpp-cv-empty",K?"No elements with issues. Clear the filter to see the whole document.":"No elements with issues. Contrast checks are hidden \u2014 include them, or clear the filter to see the whole document.")),V){let r=W.get(V);r&&r.setAttribute("aria-selected","true");}let t=te&&W.has(te)?te:Be()[0]?.dataset.nodeId;t&&Ee(t);}function Ve(e,t){let r=F();e==="tree"?le=t:ue=t;let f=F();f!==r&&(f?$e():(oe(se),oe(R)));}return {name:"compliance-view",needsLayout:true,setup(e){L=e;let t=e.ownerDocument;return j=t.createElement("div"),j.className="bpp-cv-host",A=e.addSidePanel({id:"compliance",label:n,element:j,defaultOpen:i,onVisibilityChange:r=>Ve("tree",r)}),P=t.createElement("div"),P.className="bpp-cv-host bpp-cv-issues",H=e.addSidePanel({id:"compliance-issues",label:o,element:P,onVisibilityChange:r=>Ve("issues",r)}),()=>{L=null,A=null,H=null,j=null,P=null;}},load(e){if(L=e,W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),oe(se),oe(R),V=null,te=null,x=null,k=e.report??null,ne?.abort(),ne=null,!j)return;if(!e.snapshot){j.textContent="No structure data for this document.",P&&(P.textContent="No structure data for this document."),H?.setBadge(null),oe(se),oe(R);return}x=e.snapshot.root,v(x),Ge(),et(),j.replaceChildren(),M=h("div","bpp-cv-summary"),j.append(M),Z=h("div","bpp-cv-tree-host"),j.append(Z);let t=h("div","bpp-cv-detail");t.append(h("div","bpp-cv-section-title","Element")),m=h("div","bpp-cv-detail-body"),t.append(m),j.append(t),ee(),fe(),pe(),O(null),ie(),ne=new AbortController;for(let r=0;r<e.pageCount();r++){let f=e.pageElement(r);if(!f)continue;let d=r;f.addEventListener("click",g=>{if(!F()&&!g.ctrlKey&&!g.metaKey||!L)return;let C=L.scale();if(C<=0)return;let w=f.getBoundingClientRect(),E=(g.clientX-w.left)/C,q=(g.clientY-w.top)/C,Y=Ue(d,E,q);Y&&(le||A?.setVisible(true),He(Y,true),Oe(Y,he(Y)||g.ctrlKey||g.metaKey,"page"));},{signal:ne.signal});}F()&&$e();},sync({scale:e}){for(let t of se)ye(t.element,t.rect,e);for(let t of R)ye(t.element,t.rect,e);},selectSnapshotNode(e){let t=ae.get(e);return t?(le||A?.setVisible(true),He(t,true),true):false},teardown(){oe(se),oe(R),W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),V=null,te=null,x=null,k=null,ne?.abort(),ne=null;}}}var ut=class extends HTMLElement{handle=null;pending=null;connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});if(!this.handle){this.handle=Lt(n,this.readOptions());let o=this.pending;this.pending=null,o?.run(this.handle);}}disconnectedCallback(){this.handle?.dispose(),this.handle=null;}load(n,o){if(this.handle)return Array.isArray(n)?this.handle.load(n,o):this.handle.load(n,o);if(this.pending?.settle(),Array.isArray(n)){this.pending={run:i=>i.load(n,o),settle:()=>{}};return}return new Promise((i,l)=>{this.pending={run:c=>{c.load(n,o).then(i,l);},settle:i};})}selectSnapshotNode(n){return this.handle?.selectSnapshotNode(n)??false}clear(){this.pending?.settle(),this.pending=null,this.handle?.clear();}readOptions(){let n=this.getAttribute("show-thumbnails"),o=this.getAttribute("show-inspector"),i=this.getAttribute("preference-key"),l=i?this.readPreferences(i):void 0,c=[];if(this.hasAttribute("compliance-view")||this.hasAttribute("structure-view")){let N=this.getAttribute("wcag-checks");c.push(Pt({showWcagChecks:N===null?void 0:N!=="false",preferenceKey:i?`${i}:a11y`:void 0}));}return {plugins:c.length>0?c:void 0,toolbar:this.readToolbarConfig(),showThumbnails:l?.showThumbnails??(n===null?void 0:n!=="false"),showInspector:l?.showInspector??(o===null?void 0:o!=="false"),initialZoom:l?.zoom,onViewStateChange:i?N=>this.writePreferences(i,N):void 0,fitMode:this.getAttribute("fit-mode")==="fit-width"?"fit-width":"fit-page",title:this.getAttribute("label")??void 0,downloadFilename:this.getAttribute("download-filename")??void 0,hideBorder:this.getAttribute("hide-border")==="true"||this.hasAttribute("hide-border")&&this.getAttribute("hide-border")!=="false",styleScrollbars:this.getAttribute("style-scrollbars")==="true",selectionColor:this.getAttribute("selection-color")??void 0,footer:this.hasAttribute("footer")&&this.getAttribute("footer")!=="false"?{text:this.getAttribute("footer-label")??void 0}:void 0}}readToolbarConfig(){let n=i=>{let l=this.getAttribute(i);return l===null?void 0:l!=="false"},o={thumbnails:n("show-thumbnails-toggle"),pageNav:n("show-page-nav"),zoom:n("show-zoom"),fullscreen:n("show-fullscreen"),download:n("show-download")};return Object.values(o).some(i=>i!==void 0)?o:void 0}readPreferences(n){try{let o=this.ownerDocument.defaultView?.localStorage.getItem(n);if(!o)return;let i=JSON.parse(o);return {showThumbnails:typeof i.showThumbnails=="boolean"?i.showThumbnails:void 0,showInspector:typeof i.showInspector=="boolean"?i.showInspector:void 0,zoom:this.readZoomPreference(i.zoom)}}catch{return}}readZoomPreference(n){if(!n||typeof n!="object")return;let o=n;if(o.mode==="fit-page"||o.mode==="fit-width")return {mode:o.mode};if(o.mode==="custom"&&typeof o.scale=="number"&&Number.isFinite(o.scale)&&o.scale>0)return {mode:"custom",scale:o.scale}}writePreferences(n,o){try{this.ownerDocument.defaultView?.localStorage.setItem(n,JSON.stringify(o));}catch{}}};function wn(s="bonnie-pdf-previewer"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,ut);}exports.a=tn;exports.b=Lt;exports.c=Pt;exports.d=ut;exports.e=wn;
|
|
@@ -660,4 +660,4 @@ var At={width:595.28,height:841.89};function Ht(s){let n=s.match(/<svg[^>]*\bwid
|
|
|
660
660
|
</div>`;}function mt(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function Nt(s){return s?`<footer class="bpp-footer" data-footer aria-label="Document conformance">
|
|
661
661
|
<span class="bpp-footer-text">${mt(s.text)}</span>
|
|
662
662
|
<div class="bpp-footer-tags" data-footer-tags></div>
|
|
663
|
-
</footer>`:""}function vt(s){return Number.isFinite(s.left)&&Number.isFinite(s.top)&&Number.isFinite(s.right)&&Number.isFinite(s.bottom)&&s.width>0&&s.height>0}function Rt(s,n){let o=s.top+s.height/2,i=n.top+n.height/2,l=Math.max(1,Math.min(s.height,n.height)*.35);return Math.abs(o-i)<=l}function zt(s){let n=s.filter(i=>i.width>0&&i.height>0).map(i=>({...i})).sort((i,l)=>i.top-l.top||i.left-l.left),o=[];for(let i of n){let l=o.at(-1);if(l&&Rt(l,i)){let c=l.left+l.width,N=i.left-c,L=Math.max(2,Math.max(l.height,i.height)*1.25);if(N<=L){let A=Math.min(l.left,i.left),H=Math.min(l.top,i.top),j=Math.max(c,i.left+i.width),P=Math.max(l.top+l.height,i.top+i.height);l.left=A,l.top=H,l.width=j-A,l.height=P-H;continue}}o.push(i);}return o}function $t(s,n){try{let o=s.createRange();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}catch{return null}}function Dt(s,n){let o=n.getSelection();if(s instanceof ShadowRoot&&o){if(typeof o.getComposedRanges=="function")try{let l=o.getComposedRanges({shadowRoots:[s]}).map(c=>$t(n,c)).filter(c=>c!==null&&!c.collapsed);if(l.length>0)return l}catch{}let i=s.getSelection?.();if(i&&!i.isCollapsed)return Array.from({length:i.rangeCount},(l,c)=>i.getRangeAt(c)).filter(l=>!l.collapsed)}return !o||o.isCollapsed?[]:Array.from({length:o.rangeCount},(i,l)=>o.getRangeAt(l)).filter(i=>!i.collapsed)}function Ot(s,n){return s.right>n.left&&s.left<n.right&&s.bottom>n.top&&s.top<n.bottom}function Ft(s,n){if(n.contains(s.commonAncestorContainer))return true;try{return s.intersectsNode(n)}catch{return false}}function Bt(s,n){let o=n.getBoundingClientRect();if(!vt(o))return [];let i=[];for(let l of s){if(!vt(l)||!Ot(l,o))continue;let c=Math.max(l.left,o.left),N=Math.max(l.top,o.top),L=Math.min(l.right,o.right),A=Math.min(l.bottom,o.bottom);L<=c||A<=N||i.push({left:c-o.left,top:N-o.top,width:L-c,height:A-N});}return zt(i)}function Vt(s){for(let n of s)n.querySelector(":scope > .bpp-selection-layer")?.remove();}function wt(s){let{root:n,ownerDocument:o,pageElements:i,signal:l}=s,c=0,N=()=>Vt(i),L=()=>{if(c=0,l.aborted)return;let H=Dt(n,o);if(H.length===0){N();return}let j=[];for(let P of H)if(!(P.toString().length===0||typeof P.getClientRects!="function"))try{j.push({range:P,rects:Array.from(P.getClientRects())});}catch{}for(let P of i){let le=j.filter(({range:B})=>Ft(B,P)).flatMap(({rects:B})=>B),ue=Bt(le,P),F=P.querySelector(":scope > .bpp-selection-layer");if(ue.length===0){F?.remove();continue}F||(F=o.createElement("div"),F.className="bpp-selection-layer",F.setAttribute("aria-hidden","true"),P.appendChild(F));let ke=ue.map(B=>{let K=o.createElement("span");return K.className="bpp-selection-rect",K.style.left=`${B.left}px`,K.style.top=`${B.top}px`,K.style.width=`${B.width}px`,K.style.height=`${B.height}px`,K});F.replaceChildren(...ke);}},A=()=>{if(l.aborted||c!==0)return;let H=o.defaultView?.requestAnimationFrame;H?c=H.call(o.defaultView,L):L();};return o.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("pointerup",A,{signal:l}),n.addEventListener("pointermove",H=>{H.buttons===1&&A();},{signal:l}),n.addEventListener("keyup",A,{signal:l}),l.addEventListener("abort",()=>{c!==0&&o.defaultView?.cancelAnimationFrame?.(c),c=0,N();},{once:true}),{refresh:A,clear:N}}var st=24,xt=1.25,yt=.1,Et=5,jt="1500px 0px",Wt="800px 0px",Ye=200,lt=640,Gt=320,Ne=s=>Math.min(Math.max(s,yt),Et),Je=new WeakMap;function pt(s,n){return {value:s.style.getPropertyValue(n),priority:s.style.getPropertyPriority(n)}}function dt(s,n,o){o.value?s.style.setProperty(n,o.value,o.priority):s.style.removeProperty(n);}function Ut(s,n){let o=Je.get(s);if(!o){let i=s.body;o={owners:new Set,documentElement:s.documentElement,documentElementOverflow:pt(s.documentElement,"overflow"),documentElementScrollbarGutter:pt(s.documentElement,"scrollbar-gutter"),body:i,bodyOverflow:i?pt(i,"overflow"):null},Je.set(s,o);}o.owners.has(n)||(o.owners.add(n),o.documentElement.style.setProperty("overflow","hidden"),o.documentElement.style.setProperty("scrollbar-gutter","auto"),o.body?.style.setProperty("overflow","hidden"));}function Zt(s,n){let o=Je.get(s);o&&(o.owners.delete(n),!(o.owners.size>0)&&(dt(o.documentElement,"overflow",o.documentElementOverflow),dt(o.documentElement,"scrollbar-gutter",o.documentElementScrollbarGutter),o.body&&o.bodyOverflow&&dt(o.body,"overflow",o.bodyOverflow),Je.delete(s)));}function Lt(s,n={}){let o={plugins:n.plugins??[],showThumbnails:n.showThumbnails??false,showInspector:n.showInspector,initialZoom:n.initialZoom,onViewStateChange:n.onViewStateChange??(()=>{}),fitMode:n.fitMode??"fit-page",title:n.title??"PDF preview",downloadFilename:n.downloadFilename??"document.pdf",hideBorder:n.hideBorder??false,styleScrollbars:n.styleScrollbars??false,selectionColor:n.selectionColor?.trim()||void 0,footer:n.footer?{text:n.footer.text??"Generated by @bonniepdf/previewer",conformance:n.footer.conformance??true}:void 0,toolbar:{thumbnails:n.toolbar?.thumbnails??true,pageNav:n.toolbar?.pageNav??true,zoom:n.toolbar?.zoom??true,fullscreen:n.toolbar?.fullscreen??true,download:n.toolbar?.download??true}};ht(s,o),o.selectionColor&&s.querySelector(".bpp")?.style.setProperty("--bpdf-selection",o.selectionColor);let i=s instanceof ShadowRoot?s.host:s,l=i.ownerDocument,c=a=>s.querySelector(a),N=new AbortController,L=[],A=null,H=false,j=null,P=0,le=false,ue=null,F=o.plugins,ke=[],B=[],K=[],W=()=>1,ae=()=>{},G=[],Q=null,D=false,x=null,k=null,te=null,se=null,R=null,V=null,ne=o.showThumbnails,he=o.initialZoom?.mode==="custom"?{mode:"custom",scale:Ne(o.initialZoom.scale??1)}:{mode:o.initialZoom?.mode??o.fitMode};function Me(){o.onViewStateChange({showThumbnails:ne,showInspector:D,zoom:{...he}});}let Re={error:3,warning:2,info:1,ok:0};function Qe(){if(!V)return;let a=null;for(let p of G)p.badgeTone&&(a===null||Re[p.badgeTone]>Re[a])&&(a=p.badgeTone);a&&a!=="ok"?(V.hidden=false,V.className=`bpp-side-toggle-dot bpp-side-toggle-dot-${a}`):V.hidden=true;}function ze(){te&&(te.hidden=G.length<2);}function Ge(){D=true,x&&(x.hidden=false),k&&(k.hidden=false),R?.setAttribute("aria-pressed","true"),R?.classList.add("bpp-btn-active"),Me();}function xe(){D=false,x&&(x.hidden=true),k&&(k.hidden=true),R?.setAttribute("aria-pressed","false"),R?.classList.remove("bpp-btn-active"),G.find(a=>a.id===Q)?.onVisibilityChange?.(false),Me();}function ye(a){if(!a)return;let p=G.find(v=>v.id===a);if(!p||D&&Q===a)return;let b=Q;if(D||Ge(),b&&b!==a){let v=G.find(S=>S.id===b);v&&(v.element.hidden=true,v.tabBtn.setAttribute("aria-selected","false"),v.tabBtn.classList.remove("bpp-side-tab-active"),v.onVisibilityChange?.(false));}Q=a,p.element.hidden=false,p.tabBtn.setAttribute("aria-selected","true"),p.tabBtn.classList.add("bpp-side-tab-active"),p.onVisibilityChange?.(true);}function oe(a){let p=c(".bpp-body")?.clientWidth??0,b=p>0?p-Gt:lt,v=Math.max(Ye,Math.min(lt,b));return Math.min(Math.max(a,Ye),v)}function Ce(a){if(!x)return;let p=oe(a);x.style.width=`${p}px`,k?.setAttribute("aria-valuenow",String(Math.round(p)));}function $e(a){let p=false,b=0,v=0;a.addEventListener("pointerdown",m=>{x&&(p=true,b=m.clientX,v=x.getBoundingClientRect().width,a.setPointerCapture(m.pointerId),a.classList.add("bpp-side-resizer-active"),m.preventDefault());}),a.addEventListener("pointermove",m=>{p&&Ce(v+(b-m.clientX));});let S=m=>{p&&(p=false,a.hasPointerCapture(m.pointerId)&&a.releasePointerCapture(m.pointerId),a.classList.remove("bpp-side-resizer-active"));};a.addEventListener("pointerup",S),a.addEventListener("pointercancel",S),a.addEventListener("keydown",m=>{if(!x)return;let O=m.shiftKey?48:16,T=x.getBoundingClientRect().width;m.key==="ArrowLeft"?(Ce(T+O),m.preventDefault()):m.key==="ArrowRight"&&(Ce(T-O),m.preventDefault());});}function _e(){x||(x=l.createElement("aside"),x.className="bpp-side",x.hidden=true,x.setAttribute("aria-label","Inspector"),te=l.createElement("div"),te.className="bpp-side-tabs",te.setAttribute("role","tablist"),te.hidden=true,se=l.createElement("div"),se.className="bpp-side-body",x.append(te,se),k=l.createElement("div"),k.className="bpp-side-resizer",k.hidden=true,k.setAttribute("role","separator"),k.setAttribute("aria-orientation","vertical"),k.setAttribute("aria-label","Resize inspector panel"),k.setAttribute("aria-valuemin",String(Ye)),k.setAttribute("aria-valuemax",String(lt)),k.setAttribute("aria-valuenow",String(Ye)),k.tabIndex=0,$e(k),c(".bpp-body")?.append(k,x),R=l.createElement("button"),R.type="button",R.className="bpp-btn bpp-side-toggle",R.title="Toggle inspector panel",R.setAttribute("aria-label","Toggle inspector panel"),R.setAttribute("aria-pressed","false"),R.innerHTML=re("panel-right","bpp-icon"),V=l.createElement("span"),V.className="bpp-side-toggle-dot",V.hidden=true,R.append(V),R.addEventListener("click",()=>{D?xe():ye(Q??G[0]?.id??null);}),(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(R));}let Ue={ownerDocument:l,hostElement:i,addToolbarItem(a){(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(a);},addSidePanel({id:a,label:p,element:b,defaultOpen:v,onVisibilityChange:S}){_e();let m=l.createElement("button");m.type="button",m.className="bpp-side-tab",m.setAttribute("role","tab"),m.setAttribute("aria-selected","false");let O=l.createElement("span");O.className="bpp-side-tab-label",O.textContent=p;let T=l.createElement("span");T.className="bpp-side-tab-badge",T.hidden=true,m.append(O,T),m.addEventListener("click",()=>ye(a)),b.dataset.sidePanel=a,b.hidden=true,se.append(b);let ie={id:a,label:p,element:b,tabBtn:m,badgeEl:T,onVisibilityChange:S,badgeTone:null};return G.push(ie),G.sort((M,X)=>M.label.localeCompare(X.label,void 0,{sensitivity:"base"})),te.replaceChildren(...G.map(M=>M.tabBtn)),ze(),(o.showInspector??v)&&!D&&Q===null&&ye(a),{setVisible(M){M?ye(a):Q===a&&D&&xe();},setBadge(M,X="info"){M==null||M===""?(T.hidden=true,T.textContent="",ie.badgeTone=null):(T.hidden=false,T.textContent=M,T.className=`bpp-side-tab-badge bpp-side-tab-badge-${X}`,ie.badgeTone=X),Qe();}}},pageElement:a=>B[a]??null,overlayFor(a){let p=B[a];if(!p)return null;let b=K[a];return b||(b=l.createElement("div"),b.className="bpp-overlay",p.append(b),K[a]=b),b},scale:()=>W(),pageCount:()=>B.length,scrollToPage:a=>ae(a)};for(let a of F)try{let p=a.setup?.(Ue);p&&ke.push(p);}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" setup failed`,p);}function et(a){let p=c("[data-footer-tags]");if(!p)return;let b=[];if(o.footer?.conformance){let v=a?/^PdfA(\d)([a-e])$/i.exec(a.conformance.trim()):null;v&&b.push(`PDF/A-${v[1]}${v[2]}`),a?.accessibilityMode===1&&b.push("PDF/UA-1");}p.replaceChildren(...b.map(v=>{let S=l.createElement("span");return S.className="bpp-footer-tag",S.textContent=v,S}));}let De=F.some(a=>a.needsLayout===true),Ze=n.downloadFilename;function Te(){ue&&(URL.revokeObjectURL(ue),ue=null);}function qe(){let a=c(".bpp"),p=c("[data-error]");if(p&&(p.hidden=true),le)a?.classList.add("bpp-busy"),a?.setAttribute("aria-busy","true");else {let b=c("[data-loading]");b&&(b.hidden=false);}}function Ae(){let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-loading]");p&&(p.hidden=true);let b=c("[data-error]");b&&(b.hidden=true);}function He(a){Ae();let p=c("[data-error]");if(!p)return;p.classList.toggle("bpp-error-banner",le);let b=p.querySelector("[data-error-detail]");b&&(b.textContent=a instanceof Error?a.message:String(a)),p.hidden=false;}function Ke(a,p){if(Array.isArray(a)){if(H)return;P++;let b=p??{};h(a,{fontFaceCss:b.fontFaceCss,snapshot:b.snapshot,report:b.report,filename:b.downloadFilename??o.downloadFilename,pdf:b.pdfUrl??b.pdfProvider,legacyDownload:true});return}return Oe(a,p??{})}async function Oe(a,p){if(H)return;let b=++P,v=()=>b===P&&!H;qe();try{let S=await a;if(!v())return;let m,O=p.pdf,T;if(qt(S)){if(m=await S.generateSvgDocumentAsync({captureLayout:De}),!v())return;O??=()=>S.generateBytesAsync(),T=S.metadata?.title;}else if(Kt(S))m=S;else throw new TypeError("load() expects a BonniePDF Document, an SVG document export, or a promise of either.");T??=m.snapshot?.meta?.title,h(at(m.pages),{fontFaceCss:m.fontFaceCss,snapshot:m.snapshot,report:m.report,filename:p.downloadFilename??Ze??Xt(T)??o.downloadFilename,pdf:O});}catch(S){if(!v())return;throw He(S),i.dispatchEvent(new CustomEvent("bpp-load-error",{detail:{error:S},bubbles:true,composed:true})),S}}function h(a,p){if(H)return;Te(),N.abort(),N=new AbortController;for(let u of L)u.disconnect();L=[],Fe();let b=N.signal;Ee(p.fontFaceCss);let v=c("[data-scroll]"),S=c("[data-pages]"),m=c("[data-thumbs]"),O=c("[data-thumbs-list]"),T=u=>a[u].svg,ie=[],$=[],M=a.map((u,y)=>{let I=l.createElement("li"),z=l.createElement("button");z.type="button",z.className=`bpp-thumb${y===0?" bpp-thumb-active":""}`,z.setAttribute("aria-label",`Go to page ${y+1}`),y===0&&z.setAttribute("aria-current","page"),z.dataset.thumb=String(y+1),$.push(z);let Pe=l.createElement("span");Pe.className="bpp-thumb-canvas",Pe.setAttribute("aria-hidden","true"),Pe.style.aspectRatio=`${u.width} / ${u.height}`,ie.push(Pe);let ge=l.createElement("span");return ge.className="bpp-thumb-label",ge.textContent=String(y+1),z.append(Pe,ge),I.append(z),I}),X=[],ee=a.map((u,y)=>{let I=l.createElement("div");I.className="bpp-page",I.dataset.pageIndex=String(y),I.style.width=`${u.width}px`,I.style.height=`${u.height}px`;let z=l.createElement("div");return z.className="bpp-page-canvas",I.append(z),X.push(z),I});O.replaceChildren(...M),S.replaceChildren(...ee),Be(X,T,u=>`p${u}-`,v,jt),Be(ie,T,u=>`t${u}-`,m,Wt,true);let be=wt({root:s,ownerDocument:l,pageElements:ee,signal:b}),U=he.mode,fe=he.mode==="custom"?Ne(he.scale??1):1,Z=1,Le={width:v.clientWidth,height:v.clientHeight},pe=a.length,Ve=c(".bpp"),e=c("[data-toggle-thumbs]"),t=c("[data-prev]"),r=c("[data-next]"),f=c("[data-zoom-out]"),d=c("[data-zoom-in]"),g=c("[data-zoom-select]"),C=c("[data-custom-zoom]"),w=c("[data-current-page]"),E=c("[data-total-pages]"),q=c("[data-page-label]"),Y=c("[data-fullscreen]"),de=c("[data-download]"),J=Ve?.classList.contains("bpp-fullscreen")??false,_=null,ce=()=>{if(U==="custom")return fe;let u=a[Z-1]??a[0];if(!u||Le.width===0)return 1;let y=Math.max(Le.width-st*2,1)/u.width;return U==="fit-width"?y:Math.min(y,Math.max(Le.height-st*2,1)/u.height)},ve=(u=ce())=>{e?.classList.toggle("bpp-btn-active",ne),e?.setAttribute("aria-pressed",String(ne)),e?.setAttribute("title",ne?"Hide page thumbnails":"Show page thumbnails"),w&&(w.textContent=String(Z)),q?.setAttribute("aria-label",`Page ${Z} of ${pe}`),t&&(t.disabled=Z<=1),r&&(r.disabled=Z>=pe),f&&(f.disabled=u<=yt),d&&(d.disabled=u>=Et),Y&&(Y.classList.toggle("bpp-btn-active",J),Y.setAttribute("aria-pressed",String(J)),Y.setAttribute("aria-label",J?"Exit full screen":"Full screen"),Y.setAttribute("title",J?"Exit full screen":"Full screen")),g&&(C&&(C.textContent=`${Math.round(u*100)}%`,C.hidden=U!=="custom"),g.value=U),$.forEach((y,I)=>{let z=I+1===Z;y.classList.toggle("bpp-thumb-active",z),z?y.setAttribute("aria-current","page"):y.removeAttribute("aria-current");});},Se=()=>{let u=ce();ee.forEach((y,I)=>{let z=a[I];z&&(y.style.width=`${z.width*u}px`,y.style.height=`${z.height*u}px`);}),be.refresh(),ve(u);for(let y of F)try{y.sync?.({scale:u,currentPage:Z});}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" sync failed`,I);}},nt=()=>{he=U==="custom"?{mode:U,scale:fe}:{mode:U},J&&(_=null),Me();},kt=()=>{try{return i.matches(":popover-open")}catch{return false}},we=l.fullscreenElement===i?"native":kt()?"popover":null,ot=u=>{if(u===J)return;u?(_=U==="custom"?{mode:U,scale:fe}:{mode:U},U="fit-page"):_&&(U=_.mode,_.mode==="custom"&&(fe=Ne(_.scale??1)),_=null),J=u,J?Ut(l,i):Zt(l,i),Ve?.classList.toggle("bpp-fullscreen",J),Le={width:v.clientWidth,height:v.clientHeight},ve();let y=l.defaultView;typeof y?.requestAnimationFrame=="function"?y.requestAnimationFrame(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();}):Se();},Tt=()=>{if(we==="popover"){try{i.hidePopover?.();}catch{}i.removeAttribute("popover"),i.classList.remove("bpp-popover-host"),we=null;}else we==="native"&&l.fullscreenElement===i&&l.exitFullscreen?.().catch(()=>{});},Mt=()=>{let u=i;if(typeof u.showPopover=="function")try{i.classList.add("bpp-popover-host"),i.setAttribute("popover","manual"),u.showPopover(),we="popover";return}catch{i.removeAttribute("popover"),i.classList.remove("bpp-popover-host");}typeof i.requestFullscreen=="function"&&(we="native",i.requestFullscreen().catch(()=>{we=null;}));},rt=u=>{ot(u),u?Mt():Tt();};j=()=>{J&&rt(false);};let bt=u=>{Z=Math.min(Math.max(u,1),pe),ve();},je=u=>{let y=Math.min(Math.max(u,1),pe),I=ee[y-1];if(!I||(bt(y),typeof v.scrollTo!="function"))return;let z=I.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollTo({top:Math.max(v.scrollTop+z-st,0),behavior:"smooth"});};if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();});u.observe(v),L.push(u);}if(typeof IntersectionObserver<"u"){let u=new Map,y=new IntersectionObserver(I=>{for(let ge of I){let it=Number(ge.target.dataset.pageIndex);u.set(it,ge.isIntersecting?ge.intersectionRatio:0);}let z=-1,Pe=0;u.forEach((ge,it)=>{ge>Pe&&(z=it,Pe=ge);}),z>=0&&bt(z+1);},{root:v,threshold:[.1,.25,.5,.75,1]});ee.forEach(I=>y.observe(I)),L.push(y);}e?.addEventListener("click",()=>{ne=!ne,m&&(m.hidden=!ne),Se(),Me();},{signal:b}),t?.addEventListener("click",()=>je(Z-1),{signal:b}),r?.addEventListener("click",()=>je(Z+1),{signal:b}),$.forEach(u=>u.addEventListener("click",()=>je(Number(u.dataset.thumb)),{signal:b})),v.addEventListener("click",u=>{let y=u.target?.closest?.("[data-bp-link-page]");if(!y)return;let I=Number(y.getAttribute("data-bp-link-page"));Number.isFinite(I)&&I>=1&&je(I);},{signal:b}),f?.addEventListener("click",()=>{fe=Ne(ce()/xt),U="custom",Se(),nt();},{signal:b}),d?.addEventListener("click",()=>{fe=Ne(ce()*xt),U="custom",Se(),nt();},{signal:b}),g?.addEventListener("change",()=>{let u=g.value;u==="fit-page"||u==="fit-width"?U=u:u!=="custom"&&(fe=Ne(Number(u)),U="custom"),Se(),nt();},{signal:b}),Y?.addEventListener("click",()=>rt(!J),{signal:b}),l.addEventListener("fullscreenchange",()=>{l.fullscreenElement===i?(we="native",J||ot(true)):we==="native"&&(we=null,J&&ot(false));},{signal:b}),l.addEventListener("keydown",u=>{u.key==="Escape"&&J&&rt(false);},{signal:b});let Ct=p.filename,Ie=p.pdf,_t=P,We;if(de&&(de.disabled=Ie===void 0,p.legacyDownload||Yt(de,Ie!==void 0)),de?.addEventListener("click",async()=>{if(!We&&Ie!==void 0){de.disabled=true;try{let u=typeof Ie=="function"?await Ie():Ie;if(typeof u=="string")We=u;else {let y=URL.createObjectURL(u instanceof Blob?u:new Blob([u],{type:"application/pdf"}));if(_t!==P||H){URL.revokeObjectURL(y);return}ue=y,We=y;}}catch{}finally{de.disabled=false;}}We&&Jt(l,We,Ct);},{signal:b}),E&&(E.textContent=String(pe)),w&&(w.textContent=pe>0?"1":"0"),m&&(m.hidden=!ne),Ae(),le=true,et(p.snapshot?.meta),B=ee,K=new Array(a.length).fill(null),W=ce,ae=je,F.length>0){let u={...Ue,pages:a,snapshot:p.snapshot,report:p.report};for(let y of F)try{y.load?.(u);}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" load failed`,I);}}Se();}function Fe(){for(let a of F)try{a.teardown?.();}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" teardown failed`,p);}K=[];}function Xe(a){if(H)return false;let p=false;for(let b of F)try{b.selectSnapshotNode?.(a)&&(p=!0);}catch(v){console.error(`[bonniepdf-previewer] plugin "${b.name}" selection failed`,v);}return p}function Be(a,p,b,v,S,m=false){let O=new Map,T=($,M)=>{if($.dataset.mounted==="true")return;let X=O.get(M);if(X===void 0&&(X=gt(p(M),b(M)),O.set(M,X)),$.innerHTML=X,m){let ee=$.querySelector("svg");ee&&ee.setAttribute("aria-hidden","true");for(let be of $.querySelectorAll("a"))be.removeAttribute("href"),be.removeAttribute("xlink:href"),be.removeAttribute("target"),be.setAttribute("tabindex","-1");}$.dataset.mounted="true";},ie=$=>{$.dataset.mounted==="true"&&($.replaceChildren(),$.dataset.mounted="false");};if(a.forEach(($,M)=>{$.dataset.lazyIndex=String(M);}),a[0]&&T(a[0],0),v&&typeof IntersectionObserver<"u"){let $=new IntersectionObserver(M=>{for(let X of M){let ee=X.target,be=Number(ee.dataset.lazyIndex);X.isIntersecting?T(ee,be):ie(ee);}},{root:v,rootMargin:S});a.forEach(M=>$.observe(M)),L.push($);}else a.forEach(($,M)=>T($,M));}function Ee(a){a&&(A||(A=l.createElement("style"),A.setAttribute("data-bpp-fonts",""),l.head.appendChild(A)),A.textContent!==a&&(A.textContent=a));}function me(){if(H)return;P++,Te(),N.abort(),N=new AbortController;for(let ie of L)ie.disconnect();L=[],Fe(),le=false,c("[data-pages]")?.replaceChildren(),c("[data-thumbs-list]")?.replaceChildren();let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-error]");p&&(p.hidden=true);let b=c("[data-loading]");b&&(b.hidden=false);let v=c("[data-current-page]");v&&(v.textContent="0");let S=c("[data-total-pages]");S&&(S.textContent="0");let m=c("[data-prev]");m&&(m.disabled=true);let O=c("[data-next]");O&&(O.disabled=true);let T=c("[data-download]");T&&(T.disabled=true);}function tt(){if(!H){j?.(),j=null,H=true,Fe();for(let a of ke.splice(0))try{a();}catch{}N.abort();for(let a of L)a.disconnect();L=[],A&&(A.remove(),A=null),Te();}}return {load:Ke,selectSnapshotNode:Xe,clear:me,dispose:tt}}function qt(s){let n=s;return typeof n=="object"&&n!==null&&typeof n.generateSvgDocumentAsync=="function"&&typeof n.generateBytesAsync=="function"}function Kt(s){let n=s?.pages;return Array.isArray(n)&&n.every(o=>typeof o=="string")}function Xt(s){let n=(s??"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80).replace(/-+$/,"");return n?`${n}.pdf`:void 0}function Yt(s,n){let o=s.closest(".bpp-group");if(!o)return;o.hidden=!n;let i=o.previousElementSibling;i instanceof HTMLElement&&i.classList.contains("bpp-sep")&&(i.hidden=!n);}function Jt(s,n,o){let i=s.createElement("a");i.href=n,i.download=o,i.rel="noopener",s.body.appendChild(i),i.click(),i.remove();}var St={error:3,warning:2,info:1},ct={error:"Error",warning:"Warning",info:"Info"},Qt={error:"circle-x",warning:"triangle-alert",info:"info"},en="WCAG";function Pt(s={}){let n=s.label??"Accessibility",o=s.issuesLabel??"Issues",i=s.openByDefault??false,l=s.markIssuesOnPage??true,c=Math.max(0,s.defaultExpandDepth??1/0),N=s.preferenceKey,L=null,A=null,H=null,j=null,P=null,le=false,ue=false,F=()=>le||ue,ke=Me(N),B=ke?.onlyIssues??s.onlyIssues??false,K=ke?.showWcag??s.showWcagChecks??true,W=new Map,ae=new Map,G=new Map,Q=new Map,D=new Set,x=null,k=null,te=null,se=[],R=[],V=null,ne=null;function he(e){return x?e.id===x.id?true:e.type==="Page"&&x.children.includes(e)&&x.sourceId!==void 0&&e.sourceId===x.sourceId:false}function Me(e){if(e)try{let t=globalThis.localStorage?.getItem(e);if(!t)return;let r=JSON.parse(t);return {onlyIssues:r.onlyIssues===!0,showWcag:r.showWcag!==!1}}catch{return}}function Re(){if(N)try{globalThis.localStorage?.setItem(N,JSON.stringify({onlyIssues:B,showWcag:K}));}catch{}}function Qe(e){return e.standard.toUpperCase().startsWith(en)}function ze(){return k?K?[...k.findings]:k.findings.filter(e=>!Qe(e)):[]}function Ge(){Q.clear();for(let e of ze()){if(!e.nodeId)continue;let t=Q.get(e.nodeId);t?t.push(e):Q.set(e.nodeId,[e]);}}function xe(e){let t=Q.get(e);if(!t||t.length===0)return null;let r="info";for(let f of t)St[f.severity]>St[r]&&(r=f.severity);return r}function ye(e,t,r){e.style.left=`${t.x*r}px`,e.style.top=`${t.y*r}px`,e.style.width=`${t.width*r}px`,e.style.height=`${t.height*r}px`;}function oe(e){for(let t of e)t.element.remove();e.length=0;}function Ce(e,t,r){if(L)for(let f of t.rects){let d=L.overlayFor(f.page);if(!d)continue;let g=L.ownerDocument.createElement("div");g.className=r,ye(g,f,L.scale()),d.append(g),e.push({element:g,rect:f});}}function $e(){if(oe(se),!l||!x)return;let e=t=>{let r=xe(t.id);r&&Ce(se,t,`bpp-cv-mark bpp-cv-mark-${r}`);for(let f of t.children)e(f);};e(x);}function _e(e){oe(R);let t=xe(e.id),r=t?`bpp-cv-sel bpp-cv-sel-${t}`:"bpp-cv-sel";Ce(R,e,r);}function Ue(e,t,r){if(!x)return null;let f=null,d=-1,g=1/0,C=(w,E)=>{for(let q of w.rects){if(q.page!==e||t<q.x||t>q.x+q.width||r<q.y||r>q.y+q.height)continue;let Y=q.width*q.height;(E>d||E===d&&Y<g)&&(f=w,d=E,g=Y);}for(let q of w.children)C(q,E+1);};return C(x,0),f}function et(){if(D.clear(),!x)return;let e=(t,r)=>{let f=xe(t.id)==="error";for(let d of t.children)e(d,r+1)&&(f=true);return t.children.length>0&&(r<c||f)&&D.add(t.id),f};e(x,0),B&&De();}function De(){for(let e of Q.keys())Ze(e);}function Ze(e){let t=G.get(e);for(;t;)D.add(t.id),t=G.get(t.id);}function Te(e,t){e.children.length!==0&&(t?D.add(e.id):D.delete(e.id),qe(e.id));}function qe(e){let t=W.get(e);if(!t)return;let r=t.parentElement?.querySelector(":scope > ul");if(!r)return;let f=D.has(e);t.setAttribute("aria-expanded",String(f)),r.hidden=!f;}function Ae(e){if(x){if(D.clear(),e){let t=r=>{r.children.length>0&&D.add(r.id);for(let f of r.children)t(f);};t(x);}else x.children.length>0&&D.add(x.id);pe();}}function He(e,t=false){if(!L)return;if(he(e)){V=null;for(let f of W.values())f.setAttribute("aria-selected","false");oe(R),O(null),t&&Ke(e.id);return}V=e.id;for(let[f,d]of W)d.setAttribute("aria-selected",String(f===e.id));_e(e),O(e),t&&Ke(e.id);let r=e.rects[0];r&&L.scrollToPage(r.page+1);}function Ke(e){Ze(e);let t=G.get(e);for(;t;)qe(t.id),t=G.get(t.id);let r=W.get(e);r&&(Ee(e),typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest"}));}function Oe(e,t,r){L&&L.hostElement.dispatchEvent(new CustomEvent("bonniepdf-node-select",{bubbles:true,composed:true,detail:{nodeId:e.id,sourceId:e.sourceId,sourceNavigation:t,origin:r}}));}function h(e,t,r){let d=L.ownerDocument.createElement(e);return t&&(d.className=t),r!=null&&(d.textContent=r),d}function Fe(e){let t=e.rects[0];if(!t)return "";let r=[...new Set(e.rects.map(w=>w.page))].sort((w,E)=>w-E),f=r.length===1?`Page ${r[0]+1}`:`Pages ${r[0]+1}\u2013${r[r.length-1]+1}`,d=`${Math.round(t.width)}\xD7${Math.round(t.height)} pt`,g=`at ${Math.round(t.x)}, ${Math.round(t.y)}`,C=e.rects.length>1?` \xB7 ${e.rects.length} fragments`:"";return `${f} \xB7 ${d} ${g}${C}`}function Xe(e,t,r){let f=h("ul");f.setAttribute("role",t);for(let d of e){let g=xe(d.id),C=g!=null||p(d);if(B&&!C)continue;let w=h("li");w.setAttribute("role","none");let E=h("button","bpp-tree-row bpp-cv-row");E.type="button",E.setAttribute("role","treeitem"),E.setAttribute("aria-selected","false"),E.setAttribute("aria-level",String(r)),E.dataset.nodeId=d.id,E.tabIndex=-1;let q=d.children.length>0,Y=h("span",q?"bpp-tree-twisty":"bpp-tree-twisty bpp-tree-twisty-leaf");Y.setAttribute("aria-hidden","true"),E.append(Y);let de=d.a11y,J=de?.artifact?"Artifact":de?.role||(de?.tagged?"Tagged":"");if(J){let _=h("span","bpp-cv-role",J);J==="Artifact"?(_.classList.add("bpp-cv-role-artifact"),_.title="Artifact (outside the reading order)"):de?.tagged&&(_.classList.add("bpp-cv-role-tagged"),_.title="Tagged content",E.setAttribute("aria-description","Tagged content")),E.append(_);}if(E.append(h("span","bpp-tree-type",d.type)),g){let _=Q.get(d.id).length,ce=`${ct[g]}: ${_} ${_===1?"finding":"findings"}`,ve=h("span",`bpp-cv-issue-icon bpp-cv-issue-icon-${g}`);ve.setAttribute("role","img"),ve.setAttribute("aria-label",ce),ve.title=ce,ve.innerHTML=re(Qt[g]),E.append(ve);}if(d.name&&E.append(h("span","bpp-tree-name",d.name)),E.addEventListener("click",_=>{if(q&&_.target?.closest(".bpp-tree-twisty")){Te(d,!D.has(d.id)),Ee(d.id);return}Ee(d.id),He(d),Oe(d,he(d)||_.ctrlKey||_.metaKey,"tree");}),E.addEventListener("keydown",_=>tt(_,d)),E.addEventListener("focus",()=>Ee(d.id)),E.addEventListener("mouseenter",()=>{V!==d.id&&_e(d);}),E.addEventListener("mouseleave",()=>{if(V){let _=ae.get(V);_&&_e(_);}else oe(R);}),W.set(d.id,E),w.append(E),q){let _=Xe(d.children,"group",r+1);if(_.childElementCount>0){let ce=D.has(d.id);E.setAttribute("aria-expanded",String(ce)),_.hidden=!ce,w.append(_);}else Y.classList.add("bpp-tree-twisty-leaf");}f.append(w);}return f}function Be(){return Z?Array.from(Z.querySelectorAll(".bpp-tree-row")).filter(t=>{let r=t.parentElement;for(;r&&r!==Z;){if(r.tagName==="UL"&&r.hidden)return false;r=r.parentElement;}return true}):[]}function Ee(e){te=e;for(let[t,r]of W)r.tabIndex=t===e?0:-1;}function me(e){if(!e)return;let t=e.dataset.nodeId;t&&Ee(t),e.focus();}function tt(e,t){let r=Be(),f=W.get(t.id),d=f?r.indexOf(f):-1,g=t.children.length>0&&W.get(t.id)?.hasAttribute("aria-expanded")===true,C=D.has(t.id);switch(e.key){case "ArrowDown":e.preventDefault(),me(r[d+1]);break;case "ArrowUp":e.preventDefault(),me(r[d-1]);break;case "ArrowRight":e.preventDefault(),g&&!C?Te(t,true):g&&me(r[d+1]);break;case "ArrowLeft":{if(e.preventDefault(),g&&C){Te(t,false);break}let w=G.get(t.id);w&&me(W.get(w.id));break}case "Home":e.preventDefault(),me(r[0]);break;case "End":e.preventDefault(),me(r[r.length-1]);break;case "*":e.preventDefault(),Ae(true),me(W.get(t.id));break;}}function a(e){return /^H[1-6]$/.test(e)?"heading":e==="Figure"?"figure":e==="Artifact"?"artifact":e==="Table"||e==="TH"||e==="TD"||e==="TR"?"table":"default"}function p(e){for(let t of e.children)if(xe(t.id)||p(t))return true;return false}function b(e){for(let t of ae.values())if(e(t))return t;return null}function v(e){ae.clear(),G.clear();let t=r=>{ae.set(r.id,r);for(let f of r.children)G.set(f.id,r),t(f);};t(e);}function S(e,t){let r=h("div",`bpp-cv-finding bpp-cv-finding-${e.severity}`),f=h("div","bpp-cv-finding-head");f.append(h("span",`bpp-cv-badge bpp-cv-badge-${e.severity}`,ct[e.severity])),f.append(h("span","bpp-cv-clause",e.clause)),r.append(f);let d=e.nodeId?ae.get(e.nodeId):void 0;if(t&&d){let g=h("p","bpp-cv-finding-where");g.append(h("span","bpp-cv-finding-el",d.name?`${d.type} \u201C${d.name}\u201D`:d.type)),e.page!=null&&g.append(h("span","bpp-cv-finding-page",` \xB7 page ${e.page+1}`)),r.append(g);}if(r.append(h("p","bpp-cv-msg",e.message)),e.fixHint){let g=h("p","bpp-cv-fix");g.append(h("span","bpp-cv-fix-label","Fix: ")),g.append(L.ownerDocument.createTextNode(e.fixHint)),r.append(g);}if(t&&e.nodeId){let g=h("button","bpp-cv-jump","Go to element");g.type="button",g.addEventListener("click",C=>{let w=d??b(E=>E.id===e.nodeId);w&&(A?.setVisible(true),He(w,true),W.get(w.id)?.focus(),Oe(w,C.ctrlKey||C.metaKey,"finding"));}),r.append(g);}return r}let m=null;function O(e){if(!m)return;m.replaceChildren();let t=e?Q.get(e.id):void 0;if(!e){m.append(h("p","bpp-cv-empty","Select an element to see its accessibility details."));return}let r=h("div","bpp-cv-detail-head");r.append(h("span","bpp-cv-detail-type",e.type)),e.name&&r.append(h("span","bpp-cv-detail-name",e.name)),e.a11y?.role&&r.append(h("span",`bpp-cv-role bpp-cv-role-${a(e.a11y.role)}`,e.a11y.role)),m.append(r);let f=Fe(e);if(f&&m.append(h("p","bpp-cv-geom",f)),e.a11y?.alt&&m.append(h("p","bpp-cv-attr",`Alt: \u201C${e.a11y.alt}\u201D`)),!t||t.length===0){m.append(h("p","bpp-cv-empty",e.a11y?"No accessibility issues on this element.":"This element carries no structure role."));return}for(let d of t)m.append(S(d,false));}function T(){let e={error:0,warning:0,info:0};for(let t of ze())e[t.severity]++;return e}function ie(){if(!H)return;if(!k){H.setBadge(null);return}let{error:e,warning:t}=T();e===0&&t===0?H.setBadge("\u2713","ok"):H.setBadge(String(e+t),e>0?"error":"warning");}function $(e,t,r,f){let d=h("label","bpp-cv-filter");d.title=r;let g=L.ownerDocument.createElement("input");return g.type="checkbox",g.checked=t,g.addEventListener("change",()=>f(g.checked)),d.append(g,L.ownerDocument.createTextNode(` ${e}`)),d}let M=null;function X(){let e=h("div","bpp-cv-header");if(!k)return e.append(h("span","bpp-cv-empty","No compliance report; showing structure roles only.")),e;let t=T(),r=h("div","bpp-cv-pills"),f=(g,C,w)=>{r.append(h("span",`bpp-cv-pill bpp-cv-pill-${g}${C===0?" bpp-cv-pill-zero":""}`,`${C} ${w}`));};f("error",t.error,t.error===1?"error":"errors"),f("warning",t.warning,t.warning===1?"warning":"warnings"),f("info",t.info,"info"),e.append(r);let d=k.findings.find(g=>g.standard.startsWith("PDF/UA"))?.standard??"PDF/UA-1";return e.append(h("div",`bpp-cv-verdict ${k.passed?"bpp-cv-verdict-pass":"bpp-cv-verdict-fail"}`,k.passed?`Passes ${d} checks`:`Does not meet ${d}`)),e}function ee(){M&&M.replaceChildren(X(),be());}function be(){let e=h("div","bpp-cv-settings"),t=h("div","bpp-cv-filters");k&&(t.append($("Show only elements with issues",B,"Hide every branch of the tree with no findings in it",d=>{B=d,B&&De(),Re(),pe();})),t.append(U())),e.append(t);let r=h("div","bpp-cv-tree-actions"),f=(d,g,C)=>{let w=h("button","bpp-cv-action",d);w.type="button",w.title=g,w.addEventListener("click",C),r.append(w);};return f("Expand all","Expand every branch of the tree",()=>Ae(true)),f("Collapse all","Collapse the tree back to the document",()=>Ae(false)),e.append(r),e}function U(){return $("Include WCAG contrast checks",K,"WCAG 2.2 SC 1.4.3 text-contrast findings. PDF/UA-1 sets no numeric contrast requirement, so these are a separate standard you may be tracking separately.",e=>{K=e,Re(),Le();})}function fe(){if(!P)return;if(P.replaceChildren(),!k){P.append(h("p","bpp-cv-empty","No compliance report was supplied, so there are no findings to list."));return}let e=h("div","bpp-cv-issues-head");e.append(X()),e.append(U()),P.append(e);let t=h("div","bpp-cv-issues-list"),r=ze(),f=["error","warning","info"];for(let d of f){let g=r.filter(w=>w.severity===d);if(g.length===0)continue;let C=h("section","bpp-cv-issues-group");C.append(h("div","bpp-cv-section-title",`${ct[d]}${g.length===1?"":"s"} (${g.length})`));for(let w of g){let E=S(w,w.nodeId!=null);w.nodeId||E.prepend(h("span","bpp-cv-scope","Document")),C.append(E);}t.append(C);}t.childElementCount===0&&t.append(h("p","bpp-cv-empty",K?"No findings. This document passes every check the preflight runs.":"No findings, with contrast checks excluded. Include them to check text contrast too.")),P.append(t);}let Z=null;function Le(){Ge(),B&&De(),ee(),fe(),pe();let e=V?ae.get(V):null;O(e??null),ie(),F()&&$e(),e?_e(e):oe(R);}function pe(){if(!Z||!x)return;W.clear();let e=Xe([x],"tree",1);if(e.classList.add("bpp-tree","bpp-cv-tree"),e.setAttribute("aria-label",n),Z.replaceChildren(e),e.childElementCount===0&&Z.append(h("p","bpp-cv-empty",K?"No elements with issues. Clear the filter to see the whole document.":"No elements with issues. Contrast checks are hidden \u2014 include them, or clear the filter to see the whole document.")),V){let r=W.get(V);r&&r.setAttribute("aria-selected","true");}let t=te&&W.has(te)?te:Be()[0]?.dataset.nodeId;t&&Ee(t);}function Ve(e,t){let r=F();e==="tree"?le=t:ue=t;let f=F();f!==r&&(f?$e():(oe(se),oe(R)));}return {name:"compliance-view",needsLayout:true,setup(e){L=e;let t=e.ownerDocument;return j=t.createElement("div"),j.className="bpp-cv-host",A=e.addSidePanel({id:"compliance",label:n,element:j,defaultOpen:i,onVisibilityChange:r=>Ve("tree",r)}),P=t.createElement("div"),P.className="bpp-cv-host bpp-cv-issues",H=e.addSidePanel({id:"compliance-issues",label:o,element:P,onVisibilityChange:r=>Ve("issues",r)}),()=>{L=null,A=null,H=null,j=null,P=null;}},load(e){if(L=e,W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),oe(se),oe(R),V=null,te=null,x=null,k=e.report??null,ne?.abort(),ne=null,!j)return;if(!e.snapshot){j.textContent="No structure data for this document.",P&&(P.textContent="No structure data for this document."),H?.setBadge(null),oe(se),oe(R);return}x=e.snapshot.root,v(x),Ge(),et(),j.replaceChildren(),M=h("div","bpp-cv-summary"),j.append(M),Z=h("div","bpp-cv-tree-host"),j.append(Z);let t=h("div","bpp-cv-detail");t.append(h("div","bpp-cv-section-title","Element")),m=h("div","bpp-cv-detail-body"),t.append(m),j.append(t),ee(),fe(),pe(),O(null),ie(),ne=new AbortController;for(let r=0;r<e.pageCount();r++){let f=e.pageElement(r);if(!f)continue;let d=r;f.addEventListener("click",g=>{if(!F()&&!g.ctrlKey&&!g.metaKey||!L)return;let C=L.scale();if(C<=0)return;let w=f.getBoundingClientRect(),E=(g.clientX-w.left)/C,q=(g.clientY-w.top)/C,Y=Ue(d,E,q);Y&&(le||A?.setVisible(true),He(Y,true),Oe(Y,he(Y)||g.ctrlKey||g.metaKey,"page"));},{signal:ne.signal});}F()&&$e();},sync({scale:e}){for(let t of se)ye(t.element,t.rect,e);for(let t of R)ye(t.element,t.rect,e);},selectSnapshotNode(e){let t=ae.get(e);return t?(le||A?.setVisible(true),He(t,true),true):false},teardown(){oe(se),oe(R),W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),V=null,te=null,x=null,k=null,ne?.abort(),ne=null;}}}var ut=class extends HTMLElement{handle=null;pending=null;connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});if(!this.handle){this.handle=Lt(n,this.readOptions());let o=this.pending;this.pending=null,o?.run(this.handle);}}disconnectedCallback(){this.handle?.dispose(),this.handle=null;}load(n,o){if(this.handle)return Array.isArray(n)?this.handle.load(n,o):this.handle.load(n,o);if(this.pending?.settle(),Array.isArray(n)){this.pending={run:i=>i.load(n,o),settle:()=>{}};return}return new Promise((i,l)=>{this.pending={run:c=>{c.load(n,o).then(i,l);},settle:i};})}selectSnapshotNode(n){return this.handle?.selectSnapshotNode(n)??false}clear(){this.pending?.settle(),this.pending=null,this.handle?.clear();}readOptions(){let n=this.getAttribute("show-thumbnails"),o=this.getAttribute("show-inspector"),i=this.getAttribute("preference-key"),l=i?this.readPreferences(i):void 0,c=[];if(this.hasAttribute("compliance-view")||this.hasAttribute("structure-view")){let N=this.getAttribute("wcag-checks");c.push(Pt({showWcagChecks:N===null?void 0:N!=="false",preferenceKey:i?`${i}:a11y`:void 0}));}return {plugins:c.length>0?c:void 0,toolbar:this.readToolbarConfig(),showThumbnails:l?.showThumbnails??(n===null?void 0:n!=="false"),showInspector:l?.showInspector??(o===null?void 0:o!=="false"),initialZoom:l?.zoom,onViewStateChange:i?N=>this.writePreferences(i,N):void 0,fitMode:this.getAttribute("fit-mode")==="fit-width"?"fit-width":"fit-page",title:this.getAttribute("label")??void 0,downloadFilename:this.getAttribute("download-filename")??void 0,hideBorder:this.getAttribute("hide-border")==="true"||this.hasAttribute("hide-border")&&this.getAttribute("hide-border")!=="false",styleScrollbars:this.getAttribute("style-scrollbars")==="true",selectionColor:this.getAttribute("selection-color")??void 0,footer:this.hasAttribute("footer")&&this.getAttribute("footer")!=="false"?{text:this.getAttribute("footer-label")??void 0}:void 0}}readToolbarConfig(){let n=i=>{let l=this.getAttribute(i);return l===null?void 0:l!=="false"},o={thumbnails:n("show-thumbnails-toggle"),pageNav:n("show-page-nav"),zoom:n("show-zoom"),fullscreen:n("show-fullscreen"),download:n("show-download")};return Object.values(o).some(i=>i!==void 0)?o:void 0}readPreferences(n){try{let o=this.ownerDocument.defaultView?.localStorage.getItem(n);if(!o)return;let i=JSON.parse(o);return {showThumbnails:typeof i.showThumbnails=="boolean"?i.showThumbnails:void 0,showInspector:typeof i.showInspector=="boolean"?i.showInspector:void 0,zoom:this.readZoomPreference(i.zoom)}}catch{return}}readZoomPreference(n){if(!n||typeof n!="object")return;let o=n;if(o.mode==="fit-page"||o.mode==="fit-width")return {mode:o.mode};if(o.mode==="custom"&&typeof o.scale=="number"&&Number.isFinite(o.scale)&&o.scale>0)return {mode:"custom",scale:o.scale}}writePreferences(n,o){try{this.ownerDocument.defaultView?.localStorage.setItem(n,JSON.stringify(o));}catch{}}};function wn(s="bonnie-pdf-previewer"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,ut);}export{tn as a,Lt as b,Pt as c,ut as d,wn as e};
|
|
663
|
+
</footer>`:""}function vt(s){return Number.isFinite(s.left)&&Number.isFinite(s.top)&&Number.isFinite(s.right)&&Number.isFinite(s.bottom)&&s.width>0&&s.height>0}function Rt(s,n){let o=s.top+s.height/2,i=n.top+n.height/2,l=Math.max(1,Math.min(s.height,n.height)*.35);return Math.abs(o-i)<=l}function zt(s){let n=s.filter(i=>i.width>0&&i.height>0).map(i=>({...i})).sort((i,l)=>i.top-l.top||i.left-l.left),o=[];for(let i of n){let l=o.at(-1);if(l&&Rt(l,i)){let c=l.left+l.width,N=i.left-c,L=Math.max(2,Math.max(l.height,i.height)*1.25);if(N<=L){let A=Math.min(l.left,i.left),H=Math.min(l.top,i.top),j=Math.max(c,i.left+i.width),P=Math.max(l.top+l.height,i.top+i.height);l.left=A,l.top=H,l.width=j-A,l.height=P-H;continue}}o.push(i);}return o}function $t(s,n){try{let o=s.createRange();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}catch{return null}}function Dt(s,n){let o=n.getSelection();if(s instanceof ShadowRoot&&o){if(typeof o.getComposedRanges=="function")try{let l=o.getComposedRanges({shadowRoots:[s]}).map(c=>$t(n,c)).filter(c=>c!==null&&!c.collapsed);if(l.length>0)return l}catch{}let i=s.getSelection?.();if(i&&!i.isCollapsed)return Array.from({length:i.rangeCount},(l,c)=>i.getRangeAt(c)).filter(l=>!l.collapsed)}return !o||o.isCollapsed?[]:Array.from({length:o.rangeCount},(i,l)=>o.getRangeAt(l)).filter(i=>!i.collapsed)}function Ot(s,n){return s.right>n.left&&s.left<n.right&&s.bottom>n.top&&s.top<n.bottom}function Ft(s,n){if(n.contains(s.commonAncestorContainer))return true;try{return s.intersectsNode(n)}catch{return false}}function Bt(s,n){let o=n.getBoundingClientRect();if(!vt(o))return [];let i=[];for(let l of s){if(!vt(l)||!Ot(l,o))continue;let c=Math.max(l.left,o.left),N=Math.max(l.top,o.top),L=Math.min(l.right,o.right),A=Math.min(l.bottom,o.bottom);L<=c||A<=N||i.push({left:c-o.left,top:N-o.top,width:L-c,height:A-N});}return zt(i)}function Vt(s){for(let n of s)n.querySelector(":scope > .bpp-selection-layer")?.remove();}function wt(s){let{root:n,ownerDocument:o,pageElements:i,signal:l}=s,c=0,N=()=>Vt(i),L=()=>{if(c=0,l.aborted)return;let H=Dt(n,o);if(H.length===0){N();return}let j=[];for(let P of H)if(!(P.toString().length===0||typeof P.getClientRects!="function"))try{j.push({range:P,rects:Array.from(P.getClientRects())});}catch{}for(let P of i){let le=j.filter(({range:B})=>Ft(B,P)).flatMap(({rects:B})=>B),ue=Bt(le,P),F=P.querySelector(":scope > .bpp-selection-layer");if(ue.length===0){F?.remove();continue}F||(F=o.createElement("div"),F.className="bpp-selection-layer",F.setAttribute("aria-hidden","true"),P.appendChild(F));let ke=ue.map(B=>{let K=o.createElement("span");return K.className="bpp-selection-rect",K.style.left=`${B.left}px`,K.style.top=`${B.top}px`,K.style.width=`${B.width}px`,K.style.height=`${B.height}px`,K});F.replaceChildren(...ke);}},A=()=>{if(l.aborted||c!==0)return;let H=o.defaultView?.requestAnimationFrame;H?c=H.call(o.defaultView,L):L();};return o.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("selectionchange",A,{signal:l}),n.addEventListener("pointerup",A,{signal:l}),n.addEventListener("pointermove",H=>{H.buttons===1&&A();},{signal:l}),n.addEventListener("keyup",A,{signal:l}),l.addEventListener("abort",()=>{c!==0&&o.defaultView?.cancelAnimationFrame?.(c),c=0,N();},{once:true}),{refresh:A,clear:N}}var st=24,xt=1.25,yt=.1,Et=5,jt="1500px 0px",Wt="800px 0px",Ye=200,lt=640,Gt=320,Ne=s=>Math.min(Math.max(s,yt),Et),Je=new WeakMap;function pt(s,n){return {value:s.style.getPropertyValue(n),priority:s.style.getPropertyPriority(n)}}function dt(s,n,o){o.value?s.style.setProperty(n,o.value,o.priority):s.style.removeProperty(n);}function Ut(s,n){let o=Je.get(s);if(!o){let i=s.body;o={owners:new Set,documentElement:s.documentElement,documentElementOverflow:pt(s.documentElement,"overflow"),documentElementScrollbarGutter:pt(s.documentElement,"scrollbar-gutter"),body:i,bodyOverflow:i?pt(i,"overflow"):null},Je.set(s,o);}o.owners.has(n)||(o.owners.add(n),o.documentElement.style.setProperty("overflow","hidden"),o.documentElement.style.setProperty("scrollbar-gutter","auto"),o.body?.style.setProperty("overflow","hidden"));}function Zt(s,n){let o=Je.get(s);o&&(o.owners.delete(n),!(o.owners.size>0)&&(dt(o.documentElement,"overflow",o.documentElementOverflow),dt(o.documentElement,"scrollbar-gutter",o.documentElementScrollbarGutter),o.body&&o.bodyOverflow&&dt(o.body,"overflow",o.bodyOverflow),Je.delete(s)));}function Lt(s,n={}){let o={plugins:n.plugins??[],showThumbnails:n.showThumbnails??false,showInspector:n.showInspector,initialZoom:n.initialZoom,onViewStateChange:n.onViewStateChange??(()=>{}),fitMode:n.fitMode??"fit-page",title:n.title??"PDF preview",downloadFilename:n.downloadFilename??"document.pdf",hideBorder:n.hideBorder??false,styleScrollbars:n.styleScrollbars??false,selectionColor:n.selectionColor?.trim()||void 0,footer:n.footer?{text:n.footer.text??"Generated by @bonniepdf/previewer",conformance:n.footer.conformance??true}:void 0,toolbar:{thumbnails:n.toolbar?.thumbnails??true,pageNav:n.toolbar?.pageNav??true,zoom:n.toolbar?.zoom??true,fullscreen:n.toolbar?.fullscreen??true,download:n.toolbar?.download??true}};ht(s,o),o.selectionColor&&s.querySelector(".bpp")?.style.setProperty("--bpdf-selection",o.selectionColor);let i=s instanceof ShadowRoot?s.host:s,l=i.ownerDocument,c=a=>s.querySelector(a),N=new AbortController,L=[],A=null,H=false,j=null,P=0,le=false,ue=null,F=o.plugins,ke=[],B=[],K=[],W=()=>1,ae=()=>{},G=[],Q=null,D=false,x=null,k=null,te=null,se=null,R=null,V=null,ne=o.showThumbnails,he=o.initialZoom?.mode==="custom"?{mode:"custom",scale:Ne(o.initialZoom.scale??1)}:{mode:o.initialZoom?.mode??o.fitMode};function Me(){o.onViewStateChange({showThumbnails:ne,showInspector:D,zoom:{...he}});}let Re={error:3,warning:2,info:1,ok:0};function Qe(){if(!V)return;let a=null;for(let p of G)p.badgeTone&&(a===null||Re[p.badgeTone]>Re[a])&&(a=p.badgeTone);a&&a!=="ok"?(V.hidden=false,V.className=`bpp-side-toggle-dot bpp-side-toggle-dot-${a}`):V.hidden=true;}function ze(){te&&(te.hidden=G.length<2);}function Ge(){D=true,x&&(x.hidden=false),k&&(k.hidden=false),R?.setAttribute("aria-pressed","true"),R?.classList.add("bpp-btn-active"),Me();}function xe(){D=false,x&&(x.hidden=true),k&&(k.hidden=true),R?.setAttribute("aria-pressed","false"),R?.classList.remove("bpp-btn-active"),G.find(a=>a.id===Q)?.onVisibilityChange?.(false),Me();}function ye(a){if(!a)return;let p=G.find(v=>v.id===a);if(!p||D&&Q===a)return;let b=Q;if(D||Ge(),b&&b!==a){let v=G.find(S=>S.id===b);v&&(v.element.hidden=true,v.tabBtn.setAttribute("aria-selected","false"),v.tabBtn.classList.remove("bpp-side-tab-active"),v.onVisibilityChange?.(false));}Q=a,p.element.hidden=false,p.tabBtn.setAttribute("aria-selected","true"),p.tabBtn.classList.add("bpp-side-tab-active"),p.onVisibilityChange?.(true);}function oe(a){let p=c(".bpp-body")?.clientWidth??0,b=p>0?p-Gt:lt,v=Math.max(Ye,Math.min(lt,b));return Math.min(Math.max(a,Ye),v)}function Ce(a){if(!x)return;let p=oe(a);x.style.width=`${p}px`,k?.setAttribute("aria-valuenow",String(Math.round(p)));}function $e(a){let p=false,b=0,v=0;a.addEventListener("pointerdown",m=>{x&&(p=true,b=m.clientX,v=x.getBoundingClientRect().width,a.setPointerCapture(m.pointerId),a.classList.add("bpp-side-resizer-active"),m.preventDefault());}),a.addEventListener("pointermove",m=>{p&&Ce(v+(b-m.clientX));});let S=m=>{p&&(p=false,a.hasPointerCapture(m.pointerId)&&a.releasePointerCapture(m.pointerId),a.classList.remove("bpp-side-resizer-active"));};a.addEventListener("pointerup",S),a.addEventListener("pointercancel",S),a.addEventListener("keydown",m=>{if(!x)return;let O=m.shiftKey?48:16,T=x.getBoundingClientRect().width;m.key==="ArrowLeft"?(Ce(T+O),m.preventDefault()):m.key==="ArrowRight"&&(Ce(T-O),m.preventDefault());});}function _e(){x||(x=l.createElement("aside"),x.className="bpp-side",x.hidden=true,x.setAttribute("aria-label","Inspector"),te=l.createElement("div"),te.className="bpp-side-tabs",te.setAttribute("role","tablist"),te.hidden=true,se=l.createElement("div"),se.className="bpp-side-body",x.append(te,se),k=l.createElement("div"),k.className="bpp-side-resizer",k.hidden=true,k.setAttribute("role","separator"),k.setAttribute("aria-orientation","vertical"),k.setAttribute("aria-label","Resize inspector panel"),k.setAttribute("aria-valuemin",String(Ye)),k.setAttribute("aria-valuemax",String(lt)),k.setAttribute("aria-valuenow",String(Ye)),k.tabIndex=0,$e(k),c(".bpp-body")?.append(k,x),R=l.createElement("button"),R.type="button",R.className="bpp-btn bpp-side-toggle",R.title="Toggle inspector panel",R.setAttribute("aria-label","Toggle inspector panel"),R.setAttribute("aria-pressed","false"),R.innerHTML=re("panel-right","bpp-icon"),V=l.createElement("span"),V.className="bpp-side-toggle-dot",V.hidden=true,R.append(V),R.addEventListener("click",()=>{D?xe():ye(Q??G[0]?.id??null);}),(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(R));}let Ue={ownerDocument:l,hostElement:i,addToolbarItem(a){(c("[data-toolbar-end]")??c(".bpp-toolbar"))?.append(a);},addSidePanel({id:a,label:p,element:b,defaultOpen:v,onVisibilityChange:S}){_e();let m=l.createElement("button");m.type="button",m.className="bpp-side-tab",m.setAttribute("role","tab"),m.setAttribute("aria-selected","false");let O=l.createElement("span");O.className="bpp-side-tab-label",O.textContent=p;let T=l.createElement("span");T.className="bpp-side-tab-badge",T.hidden=true,m.append(O,T),m.addEventListener("click",()=>ye(a)),b.dataset.sidePanel=a,b.hidden=true,se.append(b);let ie={id:a,label:p,element:b,tabBtn:m,badgeEl:T,onVisibilityChange:S,badgeTone:null};return G.push(ie),G.sort((M,X)=>M.label.localeCompare(X.label,void 0,{sensitivity:"base"})),te.replaceChildren(...G.map(M=>M.tabBtn)),ze(),(o.showInspector??v)&&!D&&Q===null&&ye(a),{setVisible(M){M?ye(a):Q===a&&D&&xe();},setBadge(M,X="info"){M==null||M===""?(T.hidden=true,T.textContent="",ie.badgeTone=null):(T.hidden=false,T.textContent=M,T.className=`bpp-side-tab-badge bpp-side-tab-badge-${X}`,ie.badgeTone=X),Qe();}}},pageElement:a=>B[a]??null,overlayFor(a){let p=B[a];if(!p)return null;let b=K[a];return b||(b=l.createElement("div"),b.className="bpp-overlay",p.append(b),K[a]=b),b},scale:()=>W(),pageCount:()=>B.length,scrollToPage:a=>ae(a)};for(let a of F)try{let p=a.setup?.(Ue);p&&ke.push(p);}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" setup failed`,p);}function et(a){let p=c("[data-footer-tags]");if(!p)return;let b=[];if(o.footer?.conformance){let v=a?/^PdfA(\d)([a-z]?)$/i.exec(a.conformance.trim()):null;v&&b.push(`PDF/A-${v[1]}${v[2].toLowerCase()}`);let S=a?.accessibilityMode;(S===1||S===2)&&b.push(`PDF/UA-${S}`);}p.replaceChildren(...b.map(v=>{let S=l.createElement("span");return S.className="bpp-footer-tag",S.textContent=v,S}));}let De=F.some(a=>a.needsLayout===true),Ze=n.downloadFilename;function Te(){ue&&(URL.revokeObjectURL(ue),ue=null);}function qe(){let a=c(".bpp"),p=c("[data-error]");if(p&&(p.hidden=true),le)a?.classList.add("bpp-busy"),a?.setAttribute("aria-busy","true");else {let b=c("[data-loading]");b&&(b.hidden=false);}}function Ae(){let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-loading]");p&&(p.hidden=true);let b=c("[data-error]");b&&(b.hidden=true);}function He(a){Ae();let p=c("[data-error]");if(!p)return;p.classList.toggle("bpp-error-banner",le);let b=p.querySelector("[data-error-detail]");b&&(b.textContent=a instanceof Error?a.message:String(a)),p.hidden=false;}function Ke(a,p){if(Array.isArray(a)){if(H)return;P++;let b=p??{};h(a,{fontFaceCss:b.fontFaceCss,snapshot:b.snapshot,report:b.report,filename:b.downloadFilename??o.downloadFilename,pdf:b.pdfUrl??b.pdfProvider,legacyDownload:true});return}return Oe(a,p??{})}async function Oe(a,p){if(H)return;let b=++P,v=()=>b===P&&!H;qe();try{let S=await a;if(!v())return;let m,O=p.pdf,T;if(qt(S)){if(m=await S.generateSvgDocumentAsync({captureLayout:De}),!v())return;O??=()=>S.generateBytesAsync(),T=S.metadata?.title;}else if(Kt(S))m=S;else throw new TypeError("load() expects a BonniePDF Document, an SVG document export, or a promise of either.");T??=m.snapshot?.meta?.title,h(at(m.pages),{fontFaceCss:m.fontFaceCss,snapshot:m.snapshot,report:m.report,filename:p.downloadFilename??Ze??Xt(T)??o.downloadFilename,pdf:O});}catch(S){if(!v())return;throw He(S),i.dispatchEvent(new CustomEvent("bpp-load-error",{detail:{error:S},bubbles:true,composed:true})),S}}function h(a,p){if(H)return;Te(),N.abort(),N=new AbortController;for(let u of L)u.disconnect();L=[],Fe();let b=N.signal;Ee(p.fontFaceCss);let v=c("[data-scroll]"),S=c("[data-pages]"),m=c("[data-thumbs]"),O=c("[data-thumbs-list]"),T=u=>a[u].svg,ie=[],$=[],M=a.map((u,y)=>{let I=l.createElement("li"),z=l.createElement("button");z.type="button",z.className=`bpp-thumb${y===0?" bpp-thumb-active":""}`,z.setAttribute("aria-label",`Go to page ${y+1}`),y===0&&z.setAttribute("aria-current","page"),z.dataset.thumb=String(y+1),$.push(z);let Pe=l.createElement("span");Pe.className="bpp-thumb-canvas",Pe.setAttribute("aria-hidden","true"),Pe.style.aspectRatio=`${u.width} / ${u.height}`,ie.push(Pe);let ge=l.createElement("span");return ge.className="bpp-thumb-label",ge.textContent=String(y+1),z.append(Pe,ge),I.append(z),I}),X=[],ee=a.map((u,y)=>{let I=l.createElement("div");I.className="bpp-page",I.dataset.pageIndex=String(y),I.style.width=`${u.width}px`,I.style.height=`${u.height}px`;let z=l.createElement("div");return z.className="bpp-page-canvas",I.append(z),X.push(z),I});O.replaceChildren(...M),S.replaceChildren(...ee),Be(X,T,u=>`p${u}-`,v,jt),Be(ie,T,u=>`t${u}-`,m,Wt,true);let be=wt({root:s,ownerDocument:l,pageElements:ee,signal:b}),U=he.mode,fe=he.mode==="custom"?Ne(he.scale??1):1,Z=1,Le={width:v.clientWidth,height:v.clientHeight},pe=a.length,Ve=c(".bpp"),e=c("[data-toggle-thumbs]"),t=c("[data-prev]"),r=c("[data-next]"),f=c("[data-zoom-out]"),d=c("[data-zoom-in]"),g=c("[data-zoom-select]"),C=c("[data-custom-zoom]"),w=c("[data-current-page]"),E=c("[data-total-pages]"),q=c("[data-page-label]"),Y=c("[data-fullscreen]"),de=c("[data-download]"),J=Ve?.classList.contains("bpp-fullscreen")??false,_=null,ce=()=>{if(U==="custom")return fe;let u=a[Z-1]??a[0];if(!u||Le.width===0)return 1;let y=Math.max(Le.width-st*2,1)/u.width;return U==="fit-width"?y:Math.min(y,Math.max(Le.height-st*2,1)/u.height)},ve=(u=ce())=>{e?.classList.toggle("bpp-btn-active",ne),e?.setAttribute("aria-pressed",String(ne)),e?.setAttribute("title",ne?"Hide page thumbnails":"Show page thumbnails"),w&&(w.textContent=String(Z)),q?.setAttribute("aria-label",`Page ${Z} of ${pe}`),t&&(t.disabled=Z<=1),r&&(r.disabled=Z>=pe),f&&(f.disabled=u<=yt),d&&(d.disabled=u>=Et),Y&&(Y.classList.toggle("bpp-btn-active",J),Y.setAttribute("aria-pressed",String(J)),Y.setAttribute("aria-label",J?"Exit full screen":"Full screen"),Y.setAttribute("title",J?"Exit full screen":"Full screen")),g&&(C&&(C.textContent=`${Math.round(u*100)}%`,C.hidden=U!=="custom"),g.value=U),$.forEach((y,I)=>{let z=I+1===Z;y.classList.toggle("bpp-thumb-active",z),z?y.setAttribute("aria-current","page"):y.removeAttribute("aria-current");});},Se=()=>{let u=ce();ee.forEach((y,I)=>{let z=a[I];z&&(y.style.width=`${z.width*u}px`,y.style.height=`${z.height*u}px`);}),be.refresh(),ve(u);for(let y of F)try{y.sync?.({scale:u,currentPage:Z});}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" sync failed`,I);}},nt=()=>{he=U==="custom"?{mode:U,scale:fe}:{mode:U},J&&(_=null),Me();},kt=()=>{try{return i.matches(":popover-open")}catch{return false}},we=l.fullscreenElement===i?"native":kt()?"popover":null,ot=u=>{if(u===J)return;u?(_=U==="custom"?{mode:U,scale:fe}:{mode:U},U="fit-page"):_&&(U=_.mode,_.mode==="custom"&&(fe=Ne(_.scale??1)),_=null),J=u,J?Ut(l,i):Zt(l,i),Ve?.classList.toggle("bpp-fullscreen",J),Le={width:v.clientWidth,height:v.clientHeight},ve();let y=l.defaultView;typeof y?.requestAnimationFrame=="function"?y.requestAnimationFrame(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();}):Se();},Tt=()=>{if(we==="popover"){try{i.hidePopover?.();}catch{}i.removeAttribute("popover"),i.classList.remove("bpp-popover-host"),we=null;}else we==="native"&&l.fullscreenElement===i&&l.exitFullscreen?.().catch(()=>{});},Mt=()=>{let u=i;if(typeof u.showPopover=="function")try{i.classList.add("bpp-popover-host"),i.setAttribute("popover","manual"),u.showPopover(),we="popover";return}catch{i.removeAttribute("popover"),i.classList.remove("bpp-popover-host");}typeof i.requestFullscreen=="function"&&(we="native",i.requestFullscreen().catch(()=>{we=null;}));},rt=u=>{ot(u),u?Mt():Tt();};j=()=>{J&&rt(false);};let bt=u=>{Z=Math.min(Math.max(u,1),pe),ve();},je=u=>{let y=Math.min(Math.max(u,1),pe),I=ee[y-1];if(!I||(bt(y),typeof v.scrollTo!="function"))return;let z=I.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollTo({top:Math.max(v.scrollTop+z-st,0),behavior:"smooth"});};if(typeof ResizeObserver<"u"){let u=new ResizeObserver(()=>{Le={width:v.clientWidth,height:v.clientHeight},Se();});u.observe(v),L.push(u);}if(typeof IntersectionObserver<"u"){let u=new Map,y=new IntersectionObserver(I=>{for(let ge of I){let it=Number(ge.target.dataset.pageIndex);u.set(it,ge.isIntersecting?ge.intersectionRatio:0);}let z=-1,Pe=0;u.forEach((ge,it)=>{ge>Pe&&(z=it,Pe=ge);}),z>=0&&bt(z+1);},{root:v,threshold:[.1,.25,.5,.75,1]});ee.forEach(I=>y.observe(I)),L.push(y);}e?.addEventListener("click",()=>{ne=!ne,m&&(m.hidden=!ne),Se(),Me();},{signal:b}),t?.addEventListener("click",()=>je(Z-1),{signal:b}),r?.addEventListener("click",()=>je(Z+1),{signal:b}),$.forEach(u=>u.addEventListener("click",()=>je(Number(u.dataset.thumb)),{signal:b})),v.addEventListener("click",u=>{let y=u.target?.closest?.("[data-bp-link-page]");if(!y)return;let I=Number(y.getAttribute("data-bp-link-page"));Number.isFinite(I)&&I>=1&&je(I);},{signal:b}),f?.addEventListener("click",()=>{fe=Ne(ce()/xt),U="custom",Se(),nt();},{signal:b}),d?.addEventListener("click",()=>{fe=Ne(ce()*xt),U="custom",Se(),nt();},{signal:b}),g?.addEventListener("change",()=>{let u=g.value;u==="fit-page"||u==="fit-width"?U=u:u!=="custom"&&(fe=Ne(Number(u)),U="custom"),Se(),nt();},{signal:b}),Y?.addEventListener("click",()=>rt(!J),{signal:b}),l.addEventListener("fullscreenchange",()=>{l.fullscreenElement===i?(we="native",J||ot(true)):we==="native"&&(we=null,J&&ot(false));},{signal:b}),l.addEventListener("keydown",u=>{u.key==="Escape"&&J&&rt(false);},{signal:b});let Ct=p.filename,Ie=p.pdf,_t=P,We;if(de&&(de.disabled=Ie===void 0,p.legacyDownload||Yt(de,Ie!==void 0)),de?.addEventListener("click",async()=>{if(!We&&Ie!==void 0){de.disabled=true;try{let u=typeof Ie=="function"?await Ie():Ie;if(typeof u=="string")We=u;else {let y=URL.createObjectURL(u instanceof Blob?u:new Blob([u],{type:"application/pdf"}));if(_t!==P||H){URL.revokeObjectURL(y);return}ue=y,We=y;}}catch{}finally{de.disabled=false;}}We&&Jt(l,We,Ct);},{signal:b}),E&&(E.textContent=String(pe)),w&&(w.textContent=pe>0?"1":"0"),m&&(m.hidden=!ne),Ae(),le=true,et(p.snapshot?.meta),B=ee,K=new Array(a.length).fill(null),W=ce,ae=je,F.length>0){let u={...Ue,pages:a,snapshot:p.snapshot,report:p.report};for(let y of F)try{y.load?.(u);}catch(I){console.error(`[bonniepdf-previewer] plugin "${y.name}" load failed`,I);}}Se();}function Fe(){for(let a of F)try{a.teardown?.();}catch(p){console.error(`[bonniepdf-previewer] plugin "${a.name}" teardown failed`,p);}K=[];}function Xe(a){if(H)return false;let p=false;for(let b of F)try{b.selectSnapshotNode?.(a)&&(p=!0);}catch(v){console.error(`[bonniepdf-previewer] plugin "${b.name}" selection failed`,v);}return p}function Be(a,p,b,v,S,m=false){let O=new Map,T=($,M)=>{if($.dataset.mounted==="true")return;let X=O.get(M);if(X===void 0&&(X=gt(p(M),b(M)),O.set(M,X)),$.innerHTML=X,m){let ee=$.querySelector("svg");ee&&ee.setAttribute("aria-hidden","true");for(let be of $.querySelectorAll("a"))be.removeAttribute("href"),be.removeAttribute("xlink:href"),be.removeAttribute("target"),be.setAttribute("tabindex","-1");}$.dataset.mounted="true";},ie=$=>{$.dataset.mounted==="true"&&($.replaceChildren(),$.dataset.mounted="false");};if(a.forEach(($,M)=>{$.dataset.lazyIndex=String(M);}),a[0]&&T(a[0],0),v&&typeof IntersectionObserver<"u"){let $=new IntersectionObserver(M=>{for(let X of M){let ee=X.target,be=Number(ee.dataset.lazyIndex);X.isIntersecting?T(ee,be):ie(ee);}},{root:v,rootMargin:S});a.forEach(M=>$.observe(M)),L.push($);}else a.forEach(($,M)=>T($,M));}function Ee(a){a&&(A||(A=l.createElement("style"),A.setAttribute("data-bpp-fonts",""),l.head.appendChild(A)),A.textContent!==a&&(A.textContent=a));}function me(){if(H)return;P++,Te(),N.abort(),N=new AbortController;for(let ie of L)ie.disconnect();L=[],Fe(),le=false,c("[data-pages]")?.replaceChildren(),c("[data-thumbs-list]")?.replaceChildren();let a=c(".bpp");a?.classList.remove("bpp-busy"),a?.removeAttribute("aria-busy");let p=c("[data-error]");p&&(p.hidden=true);let b=c("[data-loading]");b&&(b.hidden=false);let v=c("[data-current-page]");v&&(v.textContent="0");let S=c("[data-total-pages]");S&&(S.textContent="0");let m=c("[data-prev]");m&&(m.disabled=true);let O=c("[data-next]");O&&(O.disabled=true);let T=c("[data-download]");T&&(T.disabled=true);}function tt(){if(!H){j?.(),j=null,H=true,Fe();for(let a of ke.splice(0))try{a();}catch{}N.abort();for(let a of L)a.disconnect();L=[],A&&(A.remove(),A=null),Te();}}return {load:Ke,selectSnapshotNode:Xe,clear:me,dispose:tt}}function qt(s){let n=s;return typeof n=="object"&&n!==null&&typeof n.generateSvgDocumentAsync=="function"&&typeof n.generateBytesAsync=="function"}function Kt(s){let n=s?.pages;return Array.isArray(n)&&n.every(o=>typeof o=="string")}function Xt(s){let n=(s??"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80).replace(/-+$/,"");return n?`${n}.pdf`:void 0}function Yt(s,n){let o=s.closest(".bpp-group");if(!o)return;o.hidden=!n;let i=o.previousElementSibling;i instanceof HTMLElement&&i.classList.contains("bpp-sep")&&(i.hidden=!n);}function Jt(s,n,o){let i=s.createElement("a");i.href=n,i.download=o,i.rel="noopener",s.body.appendChild(i),i.click(),i.remove();}var St={error:3,warning:2,info:1},ct={error:"Error",warning:"Warning",info:"Info"},Qt={error:"circle-x",warning:"triangle-alert",info:"info"},en="WCAG";function Pt(s={}){let n=s.label??"Accessibility",o=s.issuesLabel??"Issues",i=s.openByDefault??false,l=s.markIssuesOnPage??true,c=Math.max(0,s.defaultExpandDepth??1/0),N=s.preferenceKey,L=null,A=null,H=null,j=null,P=null,le=false,ue=false,F=()=>le||ue,ke=Me(N),B=ke?.onlyIssues??s.onlyIssues??false,K=ke?.showWcag??s.showWcagChecks??true,W=new Map,ae=new Map,G=new Map,Q=new Map,D=new Set,x=null,k=null,te=null,se=[],R=[],V=null,ne=null;function he(e){return x?e.id===x.id?true:e.type==="Page"&&x.children.includes(e)&&x.sourceId!==void 0&&e.sourceId===x.sourceId:false}function Me(e){if(e)try{let t=globalThis.localStorage?.getItem(e);if(!t)return;let r=JSON.parse(t);return {onlyIssues:r.onlyIssues===!0,showWcag:r.showWcag!==!1}}catch{return}}function Re(){if(N)try{globalThis.localStorage?.setItem(N,JSON.stringify({onlyIssues:B,showWcag:K}));}catch{}}function Qe(e){return e.standard.toUpperCase().startsWith(en)}function ze(){return k?K?[...k.findings]:k.findings.filter(e=>!Qe(e)):[]}function Ge(){Q.clear();for(let e of ze()){if(!e.nodeId)continue;let t=Q.get(e.nodeId);t?t.push(e):Q.set(e.nodeId,[e]);}}function xe(e){let t=Q.get(e);if(!t||t.length===0)return null;let r="info";for(let f of t)St[f.severity]>St[r]&&(r=f.severity);return r}function ye(e,t,r){e.style.left=`${t.x*r}px`,e.style.top=`${t.y*r}px`,e.style.width=`${t.width*r}px`,e.style.height=`${t.height*r}px`;}function oe(e){for(let t of e)t.element.remove();e.length=0;}function Ce(e,t,r){if(L)for(let f of t.rects){let d=L.overlayFor(f.page);if(!d)continue;let g=L.ownerDocument.createElement("div");g.className=r,ye(g,f,L.scale()),d.append(g),e.push({element:g,rect:f});}}function $e(){if(oe(se),!l||!x)return;let e=t=>{let r=xe(t.id);r&&Ce(se,t,`bpp-cv-mark bpp-cv-mark-${r}`);for(let f of t.children)e(f);};e(x);}function _e(e){oe(R);let t=xe(e.id),r=t?`bpp-cv-sel bpp-cv-sel-${t}`:"bpp-cv-sel";Ce(R,e,r);}function Ue(e,t,r){if(!x)return null;let f=null,d=-1,g=1/0,C=(w,E)=>{for(let q of w.rects){if(q.page!==e||t<q.x||t>q.x+q.width||r<q.y||r>q.y+q.height)continue;let Y=q.width*q.height;(E>d||E===d&&Y<g)&&(f=w,d=E,g=Y);}for(let q of w.children)C(q,E+1);};return C(x,0),f}function et(){if(D.clear(),!x)return;let e=(t,r)=>{let f=xe(t.id)==="error";for(let d of t.children)e(d,r+1)&&(f=true);return t.children.length>0&&(r<c||f)&&D.add(t.id),f};e(x,0),B&&De();}function De(){for(let e of Q.keys())Ze(e);}function Ze(e){let t=G.get(e);for(;t;)D.add(t.id),t=G.get(t.id);}function Te(e,t){e.children.length!==0&&(t?D.add(e.id):D.delete(e.id),qe(e.id));}function qe(e){let t=W.get(e);if(!t)return;let r=t.parentElement?.querySelector(":scope > ul");if(!r)return;let f=D.has(e);t.setAttribute("aria-expanded",String(f)),r.hidden=!f;}function Ae(e){if(x){if(D.clear(),e){let t=r=>{r.children.length>0&&D.add(r.id);for(let f of r.children)t(f);};t(x);}else x.children.length>0&&D.add(x.id);pe();}}function He(e,t=false){if(!L)return;if(he(e)){V=null;for(let f of W.values())f.setAttribute("aria-selected","false");oe(R),O(null),t&&Ke(e.id);return}V=e.id;for(let[f,d]of W)d.setAttribute("aria-selected",String(f===e.id));_e(e),O(e),t&&Ke(e.id);let r=e.rects[0];r&&L.scrollToPage(r.page+1);}function Ke(e){Ze(e);let t=G.get(e);for(;t;)qe(t.id),t=G.get(t.id);let r=W.get(e);r&&(Ee(e),typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest"}));}function Oe(e,t,r){L&&L.hostElement.dispatchEvent(new CustomEvent("bonniepdf-node-select",{bubbles:true,composed:true,detail:{nodeId:e.id,sourceId:e.sourceId,sourceNavigation:t,origin:r}}));}function h(e,t,r){let d=L.ownerDocument.createElement(e);return t&&(d.className=t),r!=null&&(d.textContent=r),d}function Fe(e){let t=e.rects[0];if(!t)return "";let r=[...new Set(e.rects.map(w=>w.page))].sort((w,E)=>w-E),f=r.length===1?`Page ${r[0]+1}`:`Pages ${r[0]+1}\u2013${r[r.length-1]+1}`,d=`${Math.round(t.width)}\xD7${Math.round(t.height)} pt`,g=`at ${Math.round(t.x)}, ${Math.round(t.y)}`,C=e.rects.length>1?` \xB7 ${e.rects.length} fragments`:"";return `${f} \xB7 ${d} ${g}${C}`}function Xe(e,t,r){let f=h("ul");f.setAttribute("role",t);for(let d of e){let g=xe(d.id),C=g!=null||p(d);if(B&&!C)continue;let w=h("li");w.setAttribute("role","none");let E=h("button","bpp-tree-row bpp-cv-row");E.type="button",E.setAttribute("role","treeitem"),E.setAttribute("aria-selected","false"),E.setAttribute("aria-level",String(r)),E.dataset.nodeId=d.id,E.tabIndex=-1;let q=d.children.length>0,Y=h("span",q?"bpp-tree-twisty":"bpp-tree-twisty bpp-tree-twisty-leaf");Y.setAttribute("aria-hidden","true"),E.append(Y);let de=d.a11y,J=de?.artifact?"Artifact":de?.role||(de?.tagged?"Tagged":"");if(J){let _=h("span","bpp-cv-role",J);J==="Artifact"?(_.classList.add("bpp-cv-role-artifact"),_.title="Artifact (outside the reading order)"):de?.tagged&&(_.classList.add("bpp-cv-role-tagged"),_.title="Tagged content",E.setAttribute("aria-description","Tagged content")),E.append(_);}if(E.append(h("span","bpp-tree-type",d.type)),g){let _=Q.get(d.id).length,ce=`${ct[g]}: ${_} ${_===1?"finding":"findings"}`,ve=h("span",`bpp-cv-issue-icon bpp-cv-issue-icon-${g}`);ve.setAttribute("role","img"),ve.setAttribute("aria-label",ce),ve.title=ce,ve.innerHTML=re(Qt[g]),E.append(ve);}if(d.name&&E.append(h("span","bpp-tree-name",d.name)),E.addEventListener("click",_=>{if(q&&_.target?.closest(".bpp-tree-twisty")){Te(d,!D.has(d.id)),Ee(d.id);return}Ee(d.id),He(d),Oe(d,he(d)||_.ctrlKey||_.metaKey,"tree");}),E.addEventListener("keydown",_=>tt(_,d)),E.addEventListener("focus",()=>Ee(d.id)),E.addEventListener("mouseenter",()=>{V!==d.id&&_e(d);}),E.addEventListener("mouseleave",()=>{if(V){let _=ae.get(V);_&&_e(_);}else oe(R);}),W.set(d.id,E),w.append(E),q){let _=Xe(d.children,"group",r+1);if(_.childElementCount>0){let ce=D.has(d.id);E.setAttribute("aria-expanded",String(ce)),_.hidden=!ce,w.append(_);}else Y.classList.add("bpp-tree-twisty-leaf");}f.append(w);}return f}function Be(){return Z?Array.from(Z.querySelectorAll(".bpp-tree-row")).filter(t=>{let r=t.parentElement;for(;r&&r!==Z;){if(r.tagName==="UL"&&r.hidden)return false;r=r.parentElement;}return true}):[]}function Ee(e){te=e;for(let[t,r]of W)r.tabIndex=t===e?0:-1;}function me(e){if(!e)return;let t=e.dataset.nodeId;t&&Ee(t),e.focus();}function tt(e,t){let r=Be(),f=W.get(t.id),d=f?r.indexOf(f):-1,g=t.children.length>0&&W.get(t.id)?.hasAttribute("aria-expanded")===true,C=D.has(t.id);switch(e.key){case "ArrowDown":e.preventDefault(),me(r[d+1]);break;case "ArrowUp":e.preventDefault(),me(r[d-1]);break;case "ArrowRight":e.preventDefault(),g&&!C?Te(t,true):g&&me(r[d+1]);break;case "ArrowLeft":{if(e.preventDefault(),g&&C){Te(t,false);break}let w=G.get(t.id);w&&me(W.get(w.id));break}case "Home":e.preventDefault(),me(r[0]);break;case "End":e.preventDefault(),me(r[r.length-1]);break;case "*":e.preventDefault(),Ae(true),me(W.get(t.id));break;}}function a(e){return /^H[1-6]$/.test(e)?"heading":e==="Figure"?"figure":e==="Artifact"?"artifact":e==="Table"||e==="TH"||e==="TD"||e==="TR"?"table":"default"}function p(e){for(let t of e.children)if(xe(t.id)||p(t))return true;return false}function b(e){for(let t of ae.values())if(e(t))return t;return null}function v(e){ae.clear(),G.clear();let t=r=>{ae.set(r.id,r);for(let f of r.children)G.set(f.id,r),t(f);};t(e);}function S(e,t){let r=h("div",`bpp-cv-finding bpp-cv-finding-${e.severity}`),f=h("div","bpp-cv-finding-head");f.append(h("span",`bpp-cv-badge bpp-cv-badge-${e.severity}`,ct[e.severity])),f.append(h("span","bpp-cv-clause",e.clause)),r.append(f);let d=e.nodeId?ae.get(e.nodeId):void 0;if(t&&d){let g=h("p","bpp-cv-finding-where");g.append(h("span","bpp-cv-finding-el",d.name?`${d.type} \u201C${d.name}\u201D`:d.type)),e.page!=null&&g.append(h("span","bpp-cv-finding-page",` \xB7 page ${e.page+1}`)),r.append(g);}if(r.append(h("p","bpp-cv-msg",e.message)),e.fixHint){let g=h("p","bpp-cv-fix");g.append(h("span","bpp-cv-fix-label","Fix: ")),g.append(L.ownerDocument.createTextNode(e.fixHint)),r.append(g);}if(t&&e.nodeId){let g=h("button","bpp-cv-jump","Go to element");g.type="button",g.addEventListener("click",C=>{let w=d??b(E=>E.id===e.nodeId);w&&(A?.setVisible(true),He(w,true),W.get(w.id)?.focus(),Oe(w,C.ctrlKey||C.metaKey,"finding"));}),r.append(g);}return r}let m=null;function O(e){if(!m)return;m.replaceChildren();let t=e?Q.get(e.id):void 0;if(!e){m.append(h("p","bpp-cv-empty","Select an element to see its accessibility details."));return}let r=h("div","bpp-cv-detail-head");r.append(h("span","bpp-cv-detail-type",e.type)),e.name&&r.append(h("span","bpp-cv-detail-name",e.name)),e.a11y?.role&&r.append(h("span",`bpp-cv-role bpp-cv-role-${a(e.a11y.role)}`,e.a11y.role)),m.append(r);let f=Fe(e);if(f&&m.append(h("p","bpp-cv-geom",f)),e.a11y?.alt&&m.append(h("p","bpp-cv-attr",`Alt: \u201C${e.a11y.alt}\u201D`)),!t||t.length===0){m.append(h("p","bpp-cv-empty",e.a11y?"No accessibility issues on this element.":"This element carries no structure role."));return}for(let d of t)m.append(S(d,false));}function T(){let e={error:0,warning:0,info:0};for(let t of ze())e[t.severity]++;return e}function ie(){if(!H)return;if(!k){H.setBadge(null);return}let{error:e,warning:t}=T();e===0&&t===0?H.setBadge("\u2713","ok"):H.setBadge(String(e+t),e>0?"error":"warning");}function $(e,t,r,f){let d=h("label","bpp-cv-filter");d.title=r;let g=L.ownerDocument.createElement("input");return g.type="checkbox",g.checked=t,g.addEventListener("change",()=>f(g.checked)),d.append(g,L.ownerDocument.createTextNode(` ${e}`)),d}let M=null;function X(){let e=h("div","bpp-cv-header");if(!k)return e.append(h("span","bpp-cv-empty","No compliance report; showing structure roles only.")),e;let t=T(),r=h("div","bpp-cv-pills"),f=(g,C,w)=>{r.append(h("span",`bpp-cv-pill bpp-cv-pill-${g}${C===0?" bpp-cv-pill-zero":""}`,`${C} ${w}`));};f("error",t.error,t.error===1?"error":"errors"),f("warning",t.warning,t.warning===1?"warning":"warnings"),f("info",t.info,"info"),e.append(r);let d=k.findings.find(g=>g.standard.startsWith("PDF/UA"))?.standard??"PDF/UA-1";return e.append(h("div",`bpp-cv-verdict ${k.passed?"bpp-cv-verdict-pass":"bpp-cv-verdict-fail"}`,k.passed?`Passes ${d} checks`:`Does not meet ${d}`)),e}function ee(){M&&M.replaceChildren(X(),be());}function be(){let e=h("div","bpp-cv-settings"),t=h("div","bpp-cv-filters");k&&(t.append($("Show only elements with issues",B,"Hide every branch of the tree with no findings in it",d=>{B=d,B&&De(),Re(),pe();})),t.append(U())),e.append(t);let r=h("div","bpp-cv-tree-actions"),f=(d,g,C)=>{let w=h("button","bpp-cv-action",d);w.type="button",w.title=g,w.addEventListener("click",C),r.append(w);};return f("Expand all","Expand every branch of the tree",()=>Ae(true)),f("Collapse all","Collapse the tree back to the document",()=>Ae(false)),e.append(r),e}function U(){return $("Include WCAG contrast checks",K,"WCAG 2.2 SC 1.4.3 text-contrast findings. PDF/UA-1 sets no numeric contrast requirement, so these are a separate standard you may be tracking separately.",e=>{K=e,Re(),Le();})}function fe(){if(!P)return;if(P.replaceChildren(),!k){P.append(h("p","bpp-cv-empty","No compliance report was supplied, so there are no findings to list."));return}let e=h("div","bpp-cv-issues-head");e.append(X()),e.append(U()),P.append(e);let t=h("div","bpp-cv-issues-list"),r=ze(),f=["error","warning","info"];for(let d of f){let g=r.filter(w=>w.severity===d);if(g.length===0)continue;let C=h("section","bpp-cv-issues-group");C.append(h("div","bpp-cv-section-title",`${ct[d]}${g.length===1?"":"s"} (${g.length})`));for(let w of g){let E=S(w,w.nodeId!=null);w.nodeId||E.prepend(h("span","bpp-cv-scope","Document")),C.append(E);}t.append(C);}t.childElementCount===0&&t.append(h("p","bpp-cv-empty",K?"No findings. This document passes every check the preflight runs.":"No findings, with contrast checks excluded. Include them to check text contrast too.")),P.append(t);}let Z=null;function Le(){Ge(),B&&De(),ee(),fe(),pe();let e=V?ae.get(V):null;O(e??null),ie(),F()&&$e(),e?_e(e):oe(R);}function pe(){if(!Z||!x)return;W.clear();let e=Xe([x],"tree",1);if(e.classList.add("bpp-tree","bpp-cv-tree"),e.setAttribute("aria-label",n),Z.replaceChildren(e),e.childElementCount===0&&Z.append(h("p","bpp-cv-empty",K?"No elements with issues. Clear the filter to see the whole document.":"No elements with issues. Contrast checks are hidden \u2014 include them, or clear the filter to see the whole document.")),V){let r=W.get(V);r&&r.setAttribute("aria-selected","true");}let t=te&&W.has(te)?te:Be()[0]?.dataset.nodeId;t&&Ee(t);}function Ve(e,t){let r=F();e==="tree"?le=t:ue=t;let f=F();f!==r&&(f?$e():(oe(se),oe(R)));}return {name:"compliance-view",needsLayout:true,setup(e){L=e;let t=e.ownerDocument;return j=t.createElement("div"),j.className="bpp-cv-host",A=e.addSidePanel({id:"compliance",label:n,element:j,defaultOpen:i,onVisibilityChange:r=>Ve("tree",r)}),P=t.createElement("div"),P.className="bpp-cv-host bpp-cv-issues",H=e.addSidePanel({id:"compliance-issues",label:o,element:P,onVisibilityChange:r=>Ve("issues",r)}),()=>{L=null,A=null,H=null,j=null,P=null;}},load(e){if(L=e,W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),oe(se),oe(R),V=null,te=null,x=null,k=e.report??null,ne?.abort(),ne=null,!j)return;if(!e.snapshot){j.textContent="No structure data for this document.",P&&(P.textContent="No structure data for this document."),H?.setBadge(null),oe(se),oe(R);return}x=e.snapshot.root,v(x),Ge(),et(),j.replaceChildren(),M=h("div","bpp-cv-summary"),j.append(M),Z=h("div","bpp-cv-tree-host"),j.append(Z);let t=h("div","bpp-cv-detail");t.append(h("div","bpp-cv-section-title","Element")),m=h("div","bpp-cv-detail-body"),t.append(m),j.append(t),ee(),fe(),pe(),O(null),ie(),ne=new AbortController;for(let r=0;r<e.pageCount();r++){let f=e.pageElement(r);if(!f)continue;let d=r;f.addEventListener("click",g=>{if(!F()&&!g.ctrlKey&&!g.metaKey||!L)return;let C=L.scale();if(C<=0)return;let w=f.getBoundingClientRect(),E=(g.clientX-w.left)/C,q=(g.clientY-w.top)/C,Y=Ue(d,E,q);Y&&(le||A?.setVisible(true),He(Y,true),Oe(Y,he(Y)||g.ctrlKey||g.metaKey,"page"));},{signal:ne.signal});}F()&&$e();},sync({scale:e}){for(let t of se)ye(t.element,t.rect,e);for(let t of R)ye(t.element,t.rect,e);},selectSnapshotNode(e){let t=ae.get(e);return t?(le||A?.setVisible(true),He(t,true),true):false},teardown(){oe(se),oe(R),W.clear(),ae.clear(),G.clear(),Q.clear(),D.clear(),V=null,te=null,x=null,k=null,ne?.abort(),ne=null;}}}var ut=class extends HTMLElement{handle=null;pending=null;connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});if(!this.handle){this.handle=Lt(n,this.readOptions());let o=this.pending;this.pending=null,o?.run(this.handle);}}disconnectedCallback(){this.handle?.dispose(),this.handle=null;}load(n,o){if(this.handle)return Array.isArray(n)?this.handle.load(n,o):this.handle.load(n,o);if(this.pending?.settle(),Array.isArray(n)){this.pending={run:i=>i.load(n,o),settle:()=>{}};return}return new Promise((i,l)=>{this.pending={run:c=>{c.load(n,o).then(i,l);},settle:i};})}selectSnapshotNode(n){return this.handle?.selectSnapshotNode(n)??false}clear(){this.pending?.settle(),this.pending=null,this.handle?.clear();}readOptions(){let n=this.getAttribute("show-thumbnails"),o=this.getAttribute("show-inspector"),i=this.getAttribute("preference-key"),l=i?this.readPreferences(i):void 0,c=[];if(this.hasAttribute("compliance-view")||this.hasAttribute("structure-view")){let N=this.getAttribute("wcag-checks");c.push(Pt({showWcagChecks:N===null?void 0:N!=="false",preferenceKey:i?`${i}:a11y`:void 0}));}return {plugins:c.length>0?c:void 0,toolbar:this.readToolbarConfig(),showThumbnails:l?.showThumbnails??(n===null?void 0:n!=="false"),showInspector:l?.showInspector??(o===null?void 0:o!=="false"),initialZoom:l?.zoom,onViewStateChange:i?N=>this.writePreferences(i,N):void 0,fitMode:this.getAttribute("fit-mode")==="fit-width"?"fit-width":"fit-page",title:this.getAttribute("label")??void 0,downloadFilename:this.getAttribute("download-filename")??void 0,hideBorder:this.getAttribute("hide-border")==="true"||this.hasAttribute("hide-border")&&this.getAttribute("hide-border")!=="false",styleScrollbars:this.getAttribute("style-scrollbars")==="true",selectionColor:this.getAttribute("selection-color")??void 0,footer:this.hasAttribute("footer")&&this.getAttribute("footer")!=="false"?{text:this.getAttribute("footer-label")??void 0}:void 0}}readToolbarConfig(){let n=i=>{let l=this.getAttribute(i);return l===null?void 0:l!=="false"},o={thumbnails:n("show-thumbnails-toggle"),pageNav:n("show-page-nav"),zoom:n("show-zoom"),fullscreen:n("show-fullscreen"),download:n("show-download")};return Object.values(o).some(i=>i!==void 0)?o:void 0}readPreferences(n){try{let o=this.ownerDocument.defaultView?.localStorage.getItem(n);if(!o)return;let i=JSON.parse(o);return {showThumbnails:typeof i.showThumbnails=="boolean"?i.showThumbnails:void 0,showInspector:typeof i.showInspector=="boolean"?i.showInspector:void 0,zoom:this.readZoomPreference(i.zoom)}}catch{return}}readZoomPreference(n){if(!n||typeof n!="object")return;let o=n;if(o.mode==="fit-page"||o.mode==="fit-width")return {mode:o.mode};if(o.mode==="custom"&&typeof o.scale=="number"&&Number.isFinite(o.scale)&&o.scale>0)return {mode:"custom",scale:o.scale}}writePreferences(n,o){try{this.ownerDocument.defaultView?.localStorage.setItem(n,JSON.stringify(o));}catch{}}};function wn(s="bonnie-pdf-previewer"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,ut);}export{tn as a,Lt as b,Pt as c,ut as d,wn as e};
|
package/dist/element.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkF4NNJ6YM_cjs=require('./chunk-F4NNJ6YM.cjs');chunkF4NNJ6YM_cjs.e();Object.defineProperty(exports,"BonniePdfPreviewerElement",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.d}});Object.defineProperty(exports,"defineBonniePdfPreviewer",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.e}});
|
package/dist/element.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e}from'./chunk-
|
|
1
|
+
import {e}from'./chunk-NR23RQIX.js';export{d as BonniePdfPreviewerElement,e as defineBonniePdfPreviewer}from'./chunk-NR23RQIX.js';e();
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkF4NNJ6YM_cjs=require('./chunk-F4NNJ6YM.cjs');function p(r={}){return {...chunkF4NNJ6YM_cjs.c({label:r.label,openByDefault:r.openByDefault}),name:"structure-view"}}Object.defineProperty(exports,"BonniePdfPreviewerElement",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.d}});Object.defineProperty(exports,"complianceView",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.c}});Object.defineProperty(exports,"createPreviewer",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.b}});Object.defineProperty(exports,"defineBonniePdfPreviewer",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.e}});Object.defineProperty(exports,"svgStringsToPages",{enumerable:true,get:function(){return chunkF4NNJ6YM_cjs.a}});exports.structureView=p;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
1
|
+
import {c}from'./chunk-NR23RQIX.js';export{d as BonniePdfPreviewerElement,c as complianceView,b as createPreviewer,e as defineBonniePdfPreviewer,a as svgStringsToPages}from'./chunk-NR23RQIX.js';function p(r={}){return {...c({label:r.label,openByDefault:r.openByDefault}),name:"structure-view"}}export{p as structureView};
|
package/dist/types.d.cts
CHANGED
|
@@ -224,7 +224,7 @@ export interface FooterConfig {
|
|
|
224
224
|
text?: string;
|
|
225
225
|
/**
|
|
226
226
|
* Render conformance pills derived from the loaded document's
|
|
227
|
-
* `snapshot.meta`: its PDF/A conformance level and PDF/UA
|
|
227
|
+
* `snapshot.meta`: its PDF/A conformance level and PDF/UA level. Defaults
|
|
228
228
|
* to `true`. Documents loaded without a snapshot simply show no pills.
|
|
229
229
|
*/
|
|
230
230
|
conformance?: boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -224,7 +224,7 @@ export interface FooterConfig {
|
|
|
224
224
|
text?: string;
|
|
225
225
|
/**
|
|
226
226
|
* Render conformance pills derived from the loaded document's
|
|
227
|
-
* `snapshot.meta`: its PDF/A conformance level and PDF/UA
|
|
227
|
+
* `snapshot.meta`: its PDF/A conformance level and PDF/UA level. Defaults
|
|
228
228
|
* to `true`. Documents loaded without a snapshot simply show no pills.
|
|
229
229
|
*/
|
|
230
230
|
conformance?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonniepdf/previewer",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.21",
|
|
4
4
|
"description": "Framework-agnostic PDF preview component for BonniePDF — renders the SVG pages from @bonniepdf/core as a paginated, zoomable viewer with thumbnails. Ships as a Shadow-DOM web component, fully isolated from host-page CSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,13 +41,28 @@
|
|
|
41
41
|
],
|
|
42
42
|
"keywords": [
|
|
43
43
|
"pdf",
|
|
44
|
+
"pdf-viewer",
|
|
45
|
+
"pdf-preview",
|
|
44
46
|
"preview",
|
|
45
47
|
"viewer",
|
|
46
48
|
"svg",
|
|
47
49
|
"web-component",
|
|
48
50
|
"custom-element",
|
|
51
|
+
"pdf-ua",
|
|
52
|
+
"accessibility",
|
|
53
|
+
"wcag",
|
|
54
|
+
"typescript",
|
|
55
|
+
"javascript",
|
|
49
56
|
"bonniepdf"
|
|
50
57
|
],
|
|
58
|
+
"homepage": "https://www.bonniepdf.dev/features/typescript/previewer",
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "https://github.com/bonniepdf/BonniePDF-Previewer"
|
|
62
|
+
},
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/bonniepdf/BonniePDF-Previewer/issues"
|
|
65
|
+
},
|
|
51
66
|
"peerDependencies": {
|
|
52
67
|
"@bonniepdf/core": ">=2026.7.2"
|
|
53
68
|
},
|
|
@@ -61,7 +76,7 @@
|
|
|
61
76
|
"tsup": "^8.5.1",
|
|
62
77
|
"typescript": "7.0.2",
|
|
63
78
|
"vitest": "^4.1.11",
|
|
64
|
-
"@bonniepdf/core": "2026.11.
|
|
79
|
+
"@bonniepdf/core": "2026.11.21"
|
|
65
80
|
},
|
|
66
81
|
"publishConfig": {
|
|
67
82
|
"access": "public"
|