import{r as s,d as t,h as i,e as h}from"./p-d00c3523.js";import{p as r}from"./p-42da9819.js";import"./p-b66a001a.js";r.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.5.207/pdf.worker.min.js";let e=class{constructor(i){s(this,i),this.pageRendered=t(this,"pageRendered",7),this.pageChange=t(this,"pageChange",7),this.pageNumPending=null,this.scale=.9,this.pageNum=1,this.rotation=0,this.darkMode=!1}doSrc(s,t){s!==t&&this.loadAndRender(s)}async pageNext(s){s&&s.preventDefault(),this.pageNum>=this.pdfDocument.numPages||(this.pageNum+=1,this.queueRenderPage(this.pageNum))}async pagePrev(s){s&&s.preventDefault(),this.pageNum<=1||(this.pageNum-=1,this.queueRenderPage(this.pageNum))}renderPage(s){this.isPageRendering=!0,this.pdfDocument.getPage(s).then((s=>{const t=s.getViewport({scale:this.scale,rotation:this.rotation});this.canvas.height=t.height,this.canvas.width=t.width,s.render({viewport:t,canvasContext:this.ctx}).promise.then((()=>{this.isPageRendering=!1,this.pageRendered.emit(this.pageNum),null!==this.pageNumPending&&(this.renderPage(this.pageNumPending),this.pageChange.emit(this.pageNumPending),this.pageNumPending=null)}))}))}queueRenderPage(s){this.isPageRendering?this.pageNumPending=s:this.renderPage(s)}componentDidLoad(){this.ctx=this.canvas.getContext("2d"),this.src&&this.loadAndRender(this.src)}loadAndRender(s){r.getDocument(s).promise.then((s=>{this.pdfDocument=s,this.renderPage(this.pageNum)}))}render(){return i("div",{class:this.containerClass,style:{height:`${this.height}px`}},i("button",{onClick:this.pagePrev.bind(this)},"Prev"),i("button",{onClick:this.pageNext.bind(this)},"Next"),i("canvas",{ref:s=>this.canvas=s,class:this.darkMode?"dark-mode":"light-mode"}))}get component(){return h(this)}static get watchers(){return{src:["doSrc"]}}};e.style='akord-pdf-viewer-spa{--cursor-dark:url("/assets/dark_zoom.svg"), zoom-in;--cursor-light:url("/assets/light_zoom.svg"), zoom-in}akord-pdf-viewer-spa .dark-mode{cursor:var(--cursor-dark)}akord-pdf-viewer-spa .light-mode{cursor:var(--cursor-light)}akord-pdf-viewer-spa canvas{margin:auto;display:block;width:100%;height:100%}';export{e as akord_pdf_viewer_spa}