"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7835],{9924:(e,t,n)=>{e.exports=n.p+"static/media/pdf.worker.min.5124e539.mjs"},67835:(e,t,n)=>{n.r(t),n.d(t,{PdfMobileViewer:()=>u});var r=n(95155),l=n(12115),s=n(50910),i=n(6296),c=n(22164),a=n(4474);let o=[1,2,3];function u({url:e}){let t=(0,l.useRef)(null),h=(0,l.useRef)(null),d=(0,l.useRef)({step:0,scale:1}),[f,p]=(0,l.useState)("loading"),m=(0,s.c)("files");return(0,l.useEffect)(()=>{let t=!1,r=null;return d.current={step:0,scale:1},h.current&&(h.current.style.width="100%"),(async()=>{try{let l=await n.e(2084).then(n.bind(n,66898));l.GlobalWorkerOptions.workerSrc=new n.U(n(9924)).toString(),r=l.getDocument({url:e});let s=await r.promise;if(t)return;let i=h.current;if(!i)return;i.replaceChildren();let c=Math.min(window.devicePixelRatio||1,2),a=Math.min(i.clientWidth||320,900);for(let e=1;e<=s.numPages;e++){if(t)return;let n=await s.getPage(e),r=n.getViewport({scale:1}),l=a/r.width*c,o=r.width*l*(r.height*l);o>4e6&&(l*=Math.sqrt(4e6/o));let u=n.getViewport({scale:l}),h=document.createElement("canvas");h.width=Math.floor(u.width),h.height=Math.floor(u.height),h.style.width="100%",h.style.height="auto",h.style.display="block",h.style.margin="0 auto 8px",h.style.background="#fff",i.appendChild(h),await n.render({canvas:h,viewport:u}).promise}t||p("ready")}catch{t||p("error")}})(),()=>{t=!0,r?.destroy().catch(()=>{})}},[e]),(0,l.useEffect)(()=>{let e=t.current;if(!e)return;let n=(e,t)=>Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY),r=(t,n,r)=>{let l=h.current;if(!l)return;let s=Math.max(1,Math.min(4,t)),i=s/d.current.scale;1!==i&&(l.style.width=`${100*s}%`,e.offsetWidth,e.scrollLeft=(e.scrollLeft+n)*i-n,e.scrollTop=(e.scrollTop+r)*i-r,d.current.scale=s)},l=0,s=0,i=0,c=!1,a=0,u=1,f=!1,p=e=>{2===e.touches.length&&(c=!0,f=!0,a=n(e.touches[0],e.touches[1])||1,u=d.current.scale)},m=t=>{if(!c||2!==t.touches.length)return;t.preventDefault();let l=e.getBoundingClientRect(),s=(t.touches[0].clientX+t.touches[1].clientX)/2-l.left,i=(t.touches[0].clientY+t.touches[1].clientY)/2-l.top;r(u*(n(t.touches[0],t.touches[1])/a),s,i)},w=t=>{if(c&&t.touches.length<2){c=!1;let e=d.current.scale;d.current.step=e<=1.01?0:e<3?1:2}if(t.touches.length>0)return;if(f){f=!1;return}if(1!==t.changedTouches.length)return;let n=t.changedTouches[0],a=t.timeStamp;if(!(a-l<300&&30>Math.abs(n.clientX-s)&&30>Math.abs(n.clientY-i))){l=a,s=n.clientX,i=n.clientY;return}l=0,t.preventDefault();let u=e.getBoundingClientRect();d.current.step=(d.current.step+1)%o.length,r(o[d.current.step],n.clientX-u.left,n.clientY-u.top)};return e.addEventListener("touchstart",p,{passive:!0}),e.addEventListener("touchmove",m,{passive:!1}),e.addEventListener("touchend",w,{passive:!1}),()=>{e.removeEventListener("touchstart",p),e.removeEventListener("touchmove",m),e.removeEventListener("touchend",w)}},[]),(0,r.jsxs)("div",{ref:t,className:"w-full h-full overflow-auto",style:{touchAction:"pan-x pan-y"},children:["loading"===f&&(0,r.jsx)("div",{className:"flex justify-center py-10",children:(0,r.jsx)(i.A,{className:"w-6 h-6 animate-spin text-muted-foreground"})}),"error"===f&&(0,r.jsx)("div",{className:"flex justify-center py-10",children:(0,r.jsxs)(a.$,{variant:"outline",size:"sm",onClick:()=>window.open(e,"_blank","noopener,noreferrer"),children:[(0,r.jsx)(c.A,{className:"w-4 h-4 me-2"}),m("open_in_new_tab")]})}),(0,r.jsx)("div",{ref:h,className:"w-full"})]})}}}]);