import{j as e}from"./vendor-mui-69397583.js";import{r,k as w}from"./vendor-react-ece1c85f.js";import{S as v}from"./index-b028e652.js";import"./Alert-7dfbd254.js";import{B as d}from"./index-c62ac197.js";import"./index-6b6d0f06.js";import"./index-c2088808.js";import"./Drawer-949c18c6.js";import"./FormContainer-91c2b0e4.js";import"./Switcher-c8648037.js";import"./index-36228db5.js";import"./Upload-fb34ce03.js";import{p as s}from"./Notify-bb3ce372.js";import{a as S}from"./DigitalSignature-fff42e33.js";import"./vendor-redux-a1f00e6b.js";import"./vendor-pdf-b2a5d8b1.js";import"./vendor-devex-33a39e11.js";import"./vendor-i18n-2fcb1983.js";import"./vendor-msal-9caa1ed1.js";import"./vendor-charts-eccea5d1.js";import"./useControllableState-d0909575.js";import"./useDidUpdate-25c4d4ed.js";function G(){const a=r.useRef(null),[u,g]=r.useState(!1),[p,x]=r.useState(null),[n,m]=r.useState(!1),[l]=w(),c=l.get("token"),h=l.get("type")||"signature",[j,f]=r.useState(500);r.useEffect(()=>{const t=()=>{const i=window.innerHeight*.7;f(i)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const b=()=>{var t;return(t=a.current)==null?void 0:t.clear()},y=async()=>{var i;if((i=a.current)!=null&&i.isEmpty()){s("Please sign before submitting.","Signature can't be Empty","warning");return}const t=a.current.getTrimmedCanvas().toDataURL("image/png");if(x(t),!c){s("Invalid or missing token.","Error","danger");return}try{m(!0);const o=await S(c,{signatureValue:t});o.success?(s("Signature submitted successfully.","Success","success"),g(!0)):s(o.message||"Failed to submit signature.","Error","danger")}catch{s("Something went wrong. Please try again.","Error","danger")}finally{m(!1)}};return u?e.jsxs("div",{className:"flex flex-col min-h-[85vh] bg-gray-50 px-3 items-center justify-center text-center",children:[e.jsx("div",{className:"text-4xl mb-2",children:" 🎊"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-800 mb-2",children:"Signature Saved Successfully"}),e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Thank you for confirming your signature."}),e.jsx("img",{src:p,alt:"Signature preview",className:"rounded-md bg-white p-2 max-h-64 border shadow-sm"}),e.jsx("p",{className:"text-sm text-gray-600 mt-6",children:"You may now safely close this tab."})]}):e.jsxs("div",{className:"flex flex-col items-center min-h-screen bg-gray-50 px-3 pt-4",children:[e.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-gray-800 text-center",children:h==="initials"?"Draw Your Initials":"Draw Your Signature"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3 text-center",children:"Sign inside the box below"}),e.jsx("div",{className:`\r
  bg-white border border-gray-300 rounded-md shadow-sm\r
  mx-auto \r
  w-[90%] sm:w-[90%] lg:w-[60vw]\r
  h-[65vh]                    /* <- updated from 70vh to 65vh */\r
  flex items-center justify-center\r
`,children:e.jsx(v,{ref:a,penColor:"black",minWidth:1.8,maxWidth:3.5,velocityFilterWeight:.7,canvasProps:{className:"w-full h-full rounded-md touch-none"}})}),e.jsxs("div",{className:"flex justify-center gap-4 mt-5 pb-5",children:[e.jsx(d,{onClick:b,disabled:n,size:"sm",className:"px-5 py-2 bg-gray-200 text-gray-700 rounded-md",children:"Clear"}),e.jsx(d,{onClick:y,disabled:n,variant:"solid",size:"sm",className:"px-5 py-2 text-white rounded-md",children:n?"Submitting...":"Submit"})]})]})}export{G as default};
