import{p as e}from"./nc-util.BWncs0l6.js";import{u as t}from"./nc-main-C6OeyNBF.js";import{createElementBlock as n,onMounted as r,openBlock as i,watchEffect as a}from"/vue.js";var o={id:`pdfjs-viewer-iframe`,allowfullscreen:`true`,mozallowfullscreen:`true`,webkitallowfullscreen:`true`},s=Object.assign({name:`NcPdfViewer`},{__name:`nc-pdf-viewer`,props:{src:{type:[String,Object],default:void 0},name:{type:String,default:void 0},passwordCallback:{type:Function,default:()=>{}}},setup(s){let c=s,l=null,u=!1,d=!1;function f(){let t;if(t=typeof c.src==`object`?c.src.data:c.src,!t||!(c.src.viewer_show_type===`fullpage`||c.src.viewer_show_type===`preview-full`))u&&(l.close(),u=!1);else{if(typeof t==`string`){let n=e.base64ToBinary(t,`application/pdf`);l.open(n)}else l.open(t);u=!0,setTimeout(()=>{let e=l.pdfLoadingTask;if(!e){console.warn(`PDFViewer.pdfLoadingTask does not exist`);return}let t=e.onPassword;e.onPassword=(e,n)=>{if(typeof c.passwordCallback==`function`){let t=c.passwordCallback(n);t&&e(t)}else t(e,n)}},0)}}return r(function(){function e(){let e=document.getElementById(`pdfjs-viewer-iframe`);if(!e){console.error(`PDFViewer iframe was not found`);return}e.onload=function(){l=e.contentWindow.PDFViewerApplication,l?d&&(d=!1,f()):console.error(`PDFViewer could not be opened (/pdf-viewer/web/viewer-nc.html)`)},e.src=t()+`/pdf-viewer/web/viewer-nc.html`,a(()=>{l?f():c.src&&(d=!0)})}e()}),(e,t)=>(i(),n(`iframe`,o))}});export{s as default};