class e{static instance;iframeInstance;static resolveViewerBase(){return`${location.origin}/node_modules/pdf-web-viewer/dist/web/viewer.html`}static resolveFilePath(e){const t=e.trim().toLowerCase();return t.startsWith("http:")||t.startsWith("https:")?encodeURIComponent(e.trim()):encodeURIComponent(`${location.origin}${e.startsWith("/")?e:"/"+e}`)}static viewerUrlFor(t){return`${e.resolveViewerBase()}?file=${e.resolveFilePath(t)}`}constructor(t,r){if(!/\.pdf($|[?#])/i.test(t))throw new Error("Only PDF files are supported.");const i=r?.width||"100%",s=r?.height||"100%";this.iframeInstance=document.createElement("iframe"),this.iframeInstance.src=e.viewerUrlFor(t),this.iframeInstance.style.width=i,this.iframeInstance.style.height=s,this.iframeInstance.style.border="none",this.iframeInstance.loading="lazy",this.iframeInstance.allow="fullscreen"}static getInstance(t,r){return this.instance=new e(t,r),this.instance}mount(e){if(!e)throw new Error("Target element is required to mount the PDF viewer.");e.appendChild(this.iframeInstance)}setFile(t){if(!t)throw new Error("Source PDF URL is required.");if(!/\.pdf($|[?#])/i.test(t))throw new Error("Only PDF files are supported.");this.iframeInstance.src=e.viewerUrlFor(t)}}const t=e.getInstance;export{t as create};