PageSourceSearch

https://toolbo.pages.dev/assets/index-Bx3jzlkr.js

js toolbo.pages.dev collected 2026-10-03 05:58:53 UTC 18,177 bytes, 7 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdflib-vendor-D5hwEezb.js","assets/react-vendor-DbVP0aMU.js"])))=>i.map(i=>d[i]);
2import{_ as B}from"./pdf-vendor-D7HrI6pR.js";import{f as Ie,m as Le,j as e,l as O,Q as me,B as xe,c as W,T as Xe,q as $e,U as Ae,k as Be}from"./index-C0SOoweL.js";import{r as a}from"./react-vendor-DbVP0aMU.js";import{T as Oe}from"./ToolUpload-CBkNWrrX.js";import{d as We}from"./download-DFhLbSJS.js";import{R as ze}from"./rotate-ccw-CgBd7Dcq.js";import{U as pe}from"./upload-Bu-jv82f.js";import{D as Ge}from"./download-BBPfn1tx.js";import{M as he}from"./move-Cay_IJsI.js";import"./upload-cloud-D625IgnK.js";/**
3 * @license lucide-react v0.344.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const He=Ie("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),ge=[{name:"Cursive Flow",value:'cursive, "Brush Script MT", "Caveat", cursive'},{name:"Elegant Script",value:'"Caveat", "Brush Script MT", "Segoe Script", cursive'},{name:"Formal Calligraphy",value:'"Times New Roman", Georgia, serif'},{name:"Modern Sans",value:"system-ui, -apple-system, sans-serif"}];function nt(){const{toast:R}=Le(),[f,z]=a.useState(null),[m,G]=a.useState(0),[l,F]=a.useState(1),[H,V]=a.useState([]),[J,q]=a.useState([]),[fe,Q]=a.useState(!1),[y,ye]=a.useState("draw"),[w,b]=a.useState(null),[K,Y]=a.useState(.35),[C,Z]=a.useState("#0f172a"),[_,we]=a.useState("John Doe"),[E,be]=a.useState(ge[0].value),j=a.useRef(null),k=a.useRef(!1),I=a.useRef(null),[ee,L]=a.useState(!1),[x,X]=a.useState(65),[p,$]=a.useState(80),[h,je]=a.useState(25),[v,ve]=a.useState(!0),g=a.useRef(null),N=a.useRef(!1),P=a.useRef({x:0,y:0}),[te,se]=a.useState(!1),[re,S]=a.useState(""),Ne=async t=>{const s=t[0];if(!s||!s.type.includes("pdf")){S("Please upload a valid PDF file.");return}S(""),z(s),Q(!0);try{const r=await B(()=>import("./pdfjs-vendor-TtSH7s3_.js"),[]),n=await B(()=>import("./pdf.worker.min-CWpYdfRJ.js"),[]);r.GlobalWorkerOptions.workerSrc=n.default;const o=await r.getDocument({data:await s.arrayBuffer()}).promise,i=o.numPages;G(i),F(1);const u=[],D=[];for(let M=1;M<=i;M++){const T=await o.getPage(M),c=T.getViewport({scale:1.5});D.push({width:c.width,height:c.height});const d=document.createElement("canvas");d.width=Math.round(c.width),d.height=Math.round(c.height);const U=d.getContext("2d");await T.render({canvas:d,canvasContext:U,viewport:c}).promise,u.push(d.toDataURL("image/png"))}V(u),q(D),R("success","PDF Loaded",`${s.name} with ${i} page(s).`)}catch{S("Could not read this PDF. It may be corrupted or password-protected.")}finally{Q(!1)}},ne=t=>{const s=j.current;if(!s)return{x:0,y:0};const r=s.getBoundingClientRect(),n=s.width/r.width,o=s.height/r.height,i="touches"in t?t.touches[0].clientX:t.clientX,u="touches"in t?t.touches[0].clientY:t.clientY;return{x:(i-r.left)*n,y:(u-r.top)*o}},ae=t=>{k.current=!0,I.current=ne(t)},oe=t=>{if(!k.current||!j.current)return;const s=j.current.getContext("2d"),r=ne(t),n=I.current;s.strokeStyle=C,s.lineWidth=3,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(n.x,n.y),s.lineTo(r.x,r.y),s.stroke(),I.current=r,L(!0)},A=()=>{k.current&&(k.current=!1,Pe())},Pe=()=>{const t=j.current;if(!t)return;const s=t.toDataURL("image/png");b(s),Y(t.height/t.width)},Se=()=>{const t=j.current;if(!t)return;t.getContext("2d").clearRect(0,0,t.width,t.height),L(!1),b(null)},ie=a.useCallback((t,s,r)=>{if(!t.trim()){b(null);return}const n=document.createElement("canvas");n.width=600,n.height=180;const o=n.getContext("2d");o.clearRect(0,0,n.width,n.height),o.fillStyle=r,o.font=`italic 56px ${s}`,o.textAlign="center",o.textBaseline="middle",o.fillText(t,n.width/2,n.height/2);const i=n.toDataURL("image/png");b(i),Y(n.height/n.width)},[]);a.useEffect(()=>{y==="type"&&ie(_,E,C)},[y,_,E,C,ie]);const De=t=>{var o;const s=(o=t.target.files)==null?void 0:o[0];if(!s)return;const r=new Image,n=URL.createObjectURL(s);r.onload=()=>{const i=document.createElement("canvas");
7i.width=r.naturalWidth,i.height=r.naturalHeight,i.getContext("2d").drawImage(r,0,0);const D=i.toDataURL("image/png");b(D),Y(r.naturalHeight/r.naturalWidth),URL.revokeObjectURL(n),R("success","Signature Image Loaded","Ready to position on document.")},r.src=n},Ce=t=>{t.stopPropagation(),t.preventDefault(),N.current=!0;const s=g.current;if(!s)return;const r=s.getBoundingClientRect(),n=(t.clientX-r.left)/r.width*100,o=(t.clientY-r.top)/r.height*100;P.current={x:n-x,y:o-p}},Me=t=>{if(!N.current||!g.current)return;t.preventDefault();const s=g.current.getBoundingClientRect(),r=(t.clientX-s.left)/s.width*100,n=(t.clientY-s.top)/s.height*100,o=Math.max(0,Math.min(100-h,r-P.current.x)),i=Math.max(0,Math.min(95,n-P.current.y));X(Math.round(o*10)/10),$(Math.round(i*10)/10)},Re=()=>{N.current=!1},ke=t=>{if(t.touches.length===0||!g.current)return;N.current=!0;const s=t.touches[0],r=g.current.getBoundingClientRect(),n=(s.clientX-r.left)/r.width*100,o=(s.clientY-r.top)/r.height*100;P.current={x:n-x,y:o-p}},Te=t=>{if(!N.current||t.touches.length===0||!g.current)return;const s=t.touches[0],r=g.current.getBoundingClientRect(),n=(s.clientX-r.left)/r.width*100,o=(s.clientY-r.top)/r.height*100,i=Math.max(0,Math.min(100-h,n-P.current.x)),u=Math.max(0,Math.min(95,o-P.current.y));X(Math.round(i*10)/10),$(Math.round(u*10)/10)},Ue=()=>{N.current=!1},Fe=a.useCallback(async()=>{if(!(!f||!w)){se(!0),S("");try{const{PDFDocument:t}=await B(async()=>{const{PDFDocument:c}=await import("./pdflib-vendor-D5hwEezb.js");return{PDFDocument:c}},__vite__mapDeps([0,1])),s=await t.load(await f.arrayBuffer(),{ignoreEncryption:!0}),r=s.getPages(),n=w.split(",")[1],o=atob(n),i=new Uint8Array(o.length);for(let c=0;c<o.length;c++)i[c]=o.charCodeAt(c);const u=await s.embedPng(i),D=v?Array.from({length:r.length},(c,d)=>d):[l-1];for(const c of D){const d=r[c],{width:U,height:le}=d.getSize(),de=U*(h/100),ue=de*K,_e=U*(x/100),Ee=le-le*(p/100)-ue;d.drawImage(u,{x:Math.max(0,_e),y:Math.max(0,Ee),width:de,height:ue})}const M=await s.save(),T=new Blob([M],{type:"application/pdf"});We(T,f.name.replace(/\.pdf$/i,"-signed.pdf")),R("success","PDF Signed Successfully!",v?`Signature applied to all ${r.length} pages at the exact relative location.`:`Signature applied to page ${l}.`)}catch(t){console.error("PDF signing error:",t),S("Failed to sign PDF. The file may be password-protected or corrupted.")}finally{se(!1)}}},[f,w,v,l,h,K,x,p,R]),Ye=()=>{z(null),V([]),q([]),G(0),S(""),b(null),L(!1)},ce=a.useMemo(()=>J[l-1]||{width:595,height:842},[J,l]);return e.jsx("div",{className:"mx-auto max-w-5xl space-y-6 pb-12",children:f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(me,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:f.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m," page(s) • Client-side processing (100% private)"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(xe,{variant:"outline",size:"sm",onClick:Ye,leftIcon:e.jsx(ze,{className:"h-3.5 w-3.5"}),children:"Start Over"})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-12",children:[e.jsxs("div",{className:"space-y-5 rounded-2xl border border-border bg-card p-5 lg:col-span-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"1. Provide Your Signature"}),e.jsx("div",{className:"mt-2 flex rounded-xl border border-border bg-secondary/30 p-1",children:[{id:"draw",label:"Draw",icon:me},{id:"type",label:"Type",icon:He},{id:"upload",label:"Upload",icon:pe}].map(t=>{const s=t.icon;return e.jsxs("button",{type:"button",onClick:()=>ye(t.id),className:W("flex flex-1 items-center justify-center gap-1.5 rounded-lg py-2 text-xs font-semibold transition-colors",y===t.id?"bg-primary text-primary-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:[e.jsx(s,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:t.label})]},t.id)})})]}),y==="draw"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:"Draw below:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Color:"}),["#0f172a","#1e40af","#dc2626"].map(t=>e.jsx("button",{type:"button",onClick:()=>Z(t),style:{backgroundColor:t},className:W("h-5 w-5 rounded-full border border-white shadow-xs transition-transform",C===t?"scale-110 ring-2 ring-primary ring-offset-1":""),title:`Pen color ${t}`},t))]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border-2 border-dashed border-border bg-secondary/20 p-1",children:e.jsx("canvas",{ref:j,width:480,height:160,onMouseDown:ae,onMouseMove:oe,onMouseUp:A,onMouseLeave:A,onTouchStart:ae,onTouchMove:oe,onTouchEnd:A,className:"h-36 w-full cursor-crosshair touch-none bg-white rounded-lg"})}),e.jsxs("div",{className:"flex justify-between items-center text-xs",children:[e.jsx("button",{type:"button",onClick:Se,disabled:!ee,className:"text-muted-foreground hover:text-foreground underline disabled:opacity-40",children:"Clear Pad"}),e.jsx("span",{className:"text-muted-foreground",children:ee?"✓ Signature ready":"Draw with cursor or finger"})]})]}),y==="type"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Your Name"}
7),e.jsx("input",{type:"text",value:_,onChange:t=>we(t.target.value),placeholder:"e.g. John Doe",className:"mt-1 h-10 w-full rounded-xl border border-border bg-secondary/30 px-3 text-sm text-foreground outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Font Style"}),e.jsx("select",{value:E,onChange:t=>be(t.target.value),className:"mt-1 h-10 w-full rounded-xl border border-border bg-secondary/30 px-3 text-sm text-foreground outline-none focus:border-primary",children:ge.map(t=>e.jsx("option",{value:t.value,children:t.name},t.name))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Ink Color:"}),["#0f172a","#1e40af","#dc2626"].map(t=>e.jsx("button",{type:"button",onClick:()=>Z(t),style:{backgroundColor:t},className:W("h-5 w-5 rounded-full border border-white shadow-xs transition-transform",C===t?"scale-110 ring-2 ring-primary ring-offset-1":""),title:`Ink color ${t}`},t))]})]}),y==="upload"&&e.jsx("div",{className:"space-y-3",children:e.jsxs("label",{className:"flex w-full cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed border-border bg-secondary/20 p-6 text-center transition-colors hover:border-primary hover:bg-secondary/40",children:[e.jsx(pe,{className:"h-7 w-7 text-primary"}),e.jsx("span",{className:"mt-2 text-xs font-semibold text-foreground",children:"Upload Signature Image"}),e.jsx("span",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"PNG with transparent background, JPG, or SVG"}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/svg+xml",className:"hidden",onChange:De})]})}),e.jsxs("div",{className:"space-y-3 border-t border-border pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"2. Relative Position & Size"}),e.jsxs("span",{className:"font-mono text-[11px] text-primary font-medium",children:["X: ",x,"% • Y: ",p,"%"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-medium text-foreground",children:[e.jsx("span",{children:"Signature Scale"}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:[h,"% of page width"]})]}),e.jsx("input",{type:"range",min:"10",max:"60",step:"1",value:h,onChange:t=>je(Number(t.target.value)),className:"mt-1.5 w-full accent-primary"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-medium text-foreground",children:[e.jsx("span",{children:"Horizontal Position (X)"}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:[x,"%"]})]}),e.jsx("input",{type:"range",min:"0",max:100-h,step:"1",value:x,onChange:t=>X(Number(t.target.value)),className:"mt-1.5 w-full accent-primary"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs font-medium text-foreground",children:[e.jsx("span",{children:"Vertical Position (Y)"}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:[p,"%"]})]}),e.jsx("input",{type:"range",min:"0",max:"95",step:"1",value:p,onChange:t=>$(Number(t.target.value)),className:"mt-1.5 w-full accent-primary"})]}),e.jsx("div",{className:"rounded-xl border border-primary/20 bg-primary/5 p-3.5 space-y-2",children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:t=>ve(t.target.checked),className:"mt-0.5 h-4 w-4 rounded text-primary focus:ring-primary accent-primary"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"text-xs font-bold text-foreground",children:["Apply signature to all ",m," pages"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Automatically applies the signature to every page at the exact corresponding relative percentage position, regardless of varying page sizes."})]})]})})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx(xe,{onClick:Fe,disabled:!w||te,size:"lg",className:"w-full gap-2",children:te?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Signing Document..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"h-4 w-4"}),e.jsx("span",{children:v?`Sign & Download PDF (${m} Pages)`:`Sign Page ${l} & Download`})]})}),re&&e.jsx("p",{className:"mt-2 text-xs text-destructive text-center",children:re})]})]}),e.jsxs("div",{className:"space-y-3 lg:col-span-7",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Reference Page Preview"}),m>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>F(t=>Math.max(1,t-1)),disabled:l<=1,className:"rounded-md border border-border p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",title:"Previous page",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"text-xs font-bold text-foreground",children:["Page ",l," of ",m]}),e.jsx("button",{type:"button",onClick:()=>F(t=>Math.min(m,t+1)),disabled:l>=m,className:"rounded-md border border-border p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",title:"Next page",children:e.jsx($e,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary",children:[e.jsx(Ae,{className:"h-3 w-3"}),v?`Synchronized across all ${m} pages`:"Current page only"]})]}),e.jsx("div",{className:"relative flex min-h-[460px] max-h-[640px] w-full items-center justify-center overflow-auto rounded-2xl border border-border bg-secondary/30 p-4 shadow-inner",children:H[l-1]?e.jsxs("div",{ref:g,onMouseMove:Me,onMouseUp:Re,onTouchMove:Te,onTouchEnd:Ue,className:"relative max-h-[580px] max-w-full select-none shadow-lg rounded-sm bg-white",style:{aspectRatio:`${ce.width} / ${ce.height}`},children:[e.jsx("img",{src:H[l-1],alt:`PDF Page ${l}`,className:"max-h-[580px] max-w-full rounded-sm object-contain pointer-events-none"}),w&&e.jsxs("div",{onMouseDown:Ce,onTouchStart:ke,style:{position:"absolute",left:`${x}%`,top:`${p}%`,width:`${h}%`},className:"group cursor-move select-none rounded-md border-2 border-dashed border-primary bg-primary/10 p-1 shadow-md transition-shadow hover:border-primary hover:bg-primary/15",title:"Click and drag signature to reposition",children:[e.jsx("img",{src:w,alt:"Signature Preview",className:"h-auto w-full object-contain pointer-events-none"}),e.jsxs("div",{className:"absolute -top-6 left-0 hidden items-center gap-1 rounded bg-primary px-1.5 py-0.5 text-[10px] font-bold text-primary-foreground shadow-sm group-hover:flex",children:[e.jsx(he,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:"Drag to reposition"})]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(O,{className:"h-6 w-6 animate-spin text-primary"}),e.jsx("span",{className:"text-xs",children:"Loading page preview..."})]})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(he,{className:"h-3 w-3 text-primary"})," Drag the signature box on the preview page to position it anywhere."]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-primary",children:[e.jsx(Be,{className:"h-3 w-3"}),"PDF vectors & text sharpness are 100% preserved"]})]})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Oe,{accept:"application/pdf,.pdf",onFiles:Ne,label:"Drop your PDF here or click to browse"}),fe&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-primary",children:[e.jsx(O,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Rendering PDF pages in browser..."})]})]})})}export{nt as default};

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.