1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[881],{881:function(e,t,a){a.r(t),a.d(t,{default:function(){return f}});var r=a(7437),l=a(2265),s=a(2466),i=a(140),n=a.n(i);let o=null;async function c(){return o||((o=await Promise.all([a.e(651),a.e(300),a.e(385)]).then(a.t.bind(a,2009,23))).GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js"),o}async function d(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,r=(await c()).getDocument({data:e.slice(0)}),l=await r.promise,s=await l.getPage(t+1),i=s.getViewport({scale:a}),n=document.createElement("canvas");n.width=Math.floor(i.width),n.height=Math.floor(i.height);let o=n.getContext("2d");return await s.render({canvasContext:o,viewport:i}).promise,{canvas:n,width:n.width,height:n.height,scale:a}}async function h(e){let t=(await c()).getDocument({data:e.slice(0)});return(await t.promise).numPages}async function g(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.3,a=(await c()).getDocument({data:e.slice(0)}),r=await a.promise,l=[];for(let e=1;e<=r.numPages;e++){let a=await r.getPage(e),s=a.getViewport({scale:t}),i=document.createElement("canvas");i.width=Math.floor(s.width),i.height=Math.floor(s.height);let n=i.getContext("2d");await a.render({canvasContext:n,viewport:s}).promise,l.push(i.toDataURL("image/jpeg",.7))}return l}function u(e){let{sig:t,isSelected:a,onSelect:i,onChange:o}=e,[c]=n()(t.imageData),d=(0,l.useRef)(null),h=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(a&&h.current&&d.current){var e;h.current.nodes([d.current]),null===(e=h.current.getLayer())||void 0===e||e.batchDraw()}},[a]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.Ee,{ref:d,image:c,x:t.x,y:t.y,width:t.width,height:t.height,draggable:!0,onClick:i,onTap:i,onDragEnd:e=>o({x:e.target.x(),y:e.target.y()}),onTransformEnd:()=>{let e=d.current;o({x:e.x(),y:e.y(),width:Math.max(30,e.width()*e.scaleX()),height:Math.max(20,e.height()*e.scaleY())}),e.scaleX(1),e.scaleY(1)}}),a&&(0,r.jsx)(s.$T,{ref:h,boundBoxFunc:(e,t)=>({...t,width:Math.max(30,t.width),height:Math.max(20,t.height)})})]})}function x(e){let{render:t,pageIdx:a,pageSigs:l,selectedId:i,pendingSignatureData:o,onSignaturePlaced:c,onSelect:d,onDeselect:h,onUpdateSig:g}=e,[x]=n()(t.dataUrl),f=e=>{if(!o){e.target===e.target.getStage()&&h();return}let r=e.target.getStage().getPointerPosition();c({id:"sig-".concat(Date.now(),"-p").concat(a),imageData:o,page:a,x:r.x-80,y:r.y-35,width:160,height:70,pdfPageHeight:t.height})};return(0,r.jsxs)(s.Hf,{width:t.width,height:t.height,style:{cursor:o?"crosshair":"default",display:"block"},onClick:f,onTap:f,children:[(0,r.jsx)(s.mh,{children:(0,r.jsx)(s.Ee,{image:x,x:0,y:0,width:t.width,height:t.height})}),(0,r.jsx)(s.mh,{children:l.map(e=>(0,r.jsx)(u,{sig:e,isSelected:i===e.id,onSelect:()=>d(e.id),onChange:t=>g(e.id,t)},e.id))})]})}function f(e){let{pdfBytes:t,pendingSignatureData:a,onSignaturePlaced:s,signatures:i,onSignaturesChange:n,onPageCountLoaded:o}=e,[c,u]=(0,l.useState)(0),[f,m]=(0,l.useState)(0),[p,w]=(0,l.useState)([]),[b,v]=(0,l.useState)([]),[j,y]=(0,l.useState)(null),[k,N]=(0,l.useState)(!0),D=(0,l.useRef)(null),S=(0,l.useRef)(null),C=(0,l.useRef)([]);(0,l.useEffect)(()=>{let e=!1;return(async()=>{N(!0),m(0),w([]);let a=await h(t),r=await g(t,.25),l=[];for(let e=0;e<a;e++){let a=await d(t,e,1.5);l.push({dataUrl:a.canvas.toDataURL("image/png"),width:a.width,height:a.height})}e||(u(a),v(r),w(l),null==o||o(a),N(!1))})(),()=>{e=!0}},[t,o]),(0,l.useEffect)(()=>{if(!D.current||0===p.length)return;let e=new IntersectionObserver(e=>{let t={ratio:-1,page:0};if(e.forEach(e=>{var a;let r=Number(null!==(a=e.target.dataset.page)&&void 0!==a?a:0);e.intersectionRatio>t.ratio&&(t={ratio:e.intersectionRatio,page:r})}),t.ratio<0)return;m(t.page);let a=S.current,r=null==a?void 0:a.children[t.page];if(a&&r){let e=r.offsetTop+r.offsetHeight/2-a.clientHeight/2;Math.abs(a.scrollTop-e)>40&&a.scrollTo({top:e,behavior:"smooth"})}},{root:D.current,threshold:[.1,.3,.5,.75,1]});return C.current.forEach(t=>{t&&e.observe(t)}),()=>e.disconnect()},[p.length]);let E=(0,l.useCallback)(e=>{var t;null===(t=C.current[e])||void 0===t||t.scrollIntoView({behavior:"smooth",block:"start"})},[]),P=(e,t)=>n(i.map(a=>a.id===e?{...a,...t}:a));return k?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 text-slate-400 text-sm gap-2",children:[(0,r.jsx)("span",{className:"animate-spin text-2xl",children:"â³"}),"Rendering pagesâ¦"]}):(0,r.jsxs)("div",{className:"flex gap-3",style:{minHeight:0},"data-clarity-mask":"true",children:[c>1&&(0,r.jsx)("div",{ref:S,className:"flex flex-col gap-2 overflow-y-auto flex-shrink-0 pr-1",style:{width:72,maxHeight:"calc(100vh - 110px)"},children:b.map((e,t)=>(0,r.jsxs)("button",{onClick:()=>E(t),className:"border-2 rounded-lg overflow-hidden transition-colors flex-shrink-0 ".concat(t===f?"border-[#16A34A] ring-1 ring-green-200":"border-slate-200 hover:border-slate-400"),children:[(0,r.jsx)("img",{src:e,alt:"Page ".concat(t+1),className:"w-full block"}),(0,r.jsx)("span",{className:"text-[10px] text-slate-400 block text-center py-0.5",children:t+1})]},t))}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col gap-2 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between flex-shrink-0",children:[j?(0,r.jsx)("button",{onClick:()=>{j&&(n(i.filter(e=>e.id!==j)),y(null))},className:"text-xs text-red-500 hover:text-red-700 border border-red-200 px-2 py-1 rounded-lg",children:"\uD83D\uDDD1 Remove selected"}):(0,r.jsx)("div",{}),a&&(0,r.jsx)("p",{className:"text-sm text-[#16A34A] font-medium animate-pulse",children:"Click on any page to place your signature"})]}),(0,r.jsx)("div",{ref:D,className:"overflow-auto border border-slate-200 rounded-xl bg-slate-100",style:{maxHeight:"calc(100vh - 150px)"},children:(0,r.jsx)("div",{className:"flex flex-col items-center gap-6 p-4",children:p.map((e,t)=>{let l=i.filter(e=>e.page===t);return(0,r.jsxs)("div",{ref:e=>{C.current[t]=e},"data-page":t,className:"flex-shrink-0 shadow-lg rounded overflow-hidden",children:[(0,r.jsx)(x,{render:e,pageIdx:t,pageSigs:l,selectedId:j,pendingSignatureData:a,onSignaturePlaced:s,onSelect:y,onDeselect:()=>y(null),onUpdateSig:P}),(0,r.jsxs)("div",{className:"bg-slate-700/75 text-white text-[11px] text-center py-1 select-none",children:["Page ",t+1," of ",c,l.length>0&&(0,r.jsxs)("span",{className:"ml-2 text-green-300 font-semibold",children:["\xb7 ",l.length," sig",1!==l.length?"s":""]})]})]},t)})})}),c>1&&(0,r.jsxs)("div",{className:"flex items-center justify-between flex-shrink-0 mt-1",children:[(0,r.jsx)("button",{onClick:()=>E(Math.max(0,f-1)),disabled:0===f,className:"text-sm px-3 py-1.5 border border-slate-200 rounded-lg bg-white disabled:opacity-30 disabled:cursor-not-allowed hover:bg-slate-50 transition-colors",children:"â Prev"}),(0,r.jsxs)("p",{className:"text-xs text-slate-400 text-center",children:["Page ",f+1," of ",c,i.filter(e=>e.page===f).length>0&&(0,r.jsxs)("span",{className:"ml-2 text-green-600 font-medium",children:["\xb7 ",i.filter(e=>e.page===f).length," sig(s)"]})]}),(0,r.jsx)("button",{onClick:()=>E(Math.min(c-1,f+1)),disabled:f===c-1,className:"text-sm px-3 py-1.5 border border-slate-200 rounded-lg bg-white disabled:opacity-30 disabled:cursor-not-allowed hover:bg-slate-50 transition-colors",children:"Next â"})]})]})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.