1import{r as n,j as e,gT as o,dc as F,cm as z}from"./vendor-BOPbLW7a.js";import{S as W}from"./vendor-widgets-BxTfyYx2.js";import{V as d,m as _,q as $,b0 as K,b1 as V,b2 as G,b3 as J,b4 as Q,B as N,j as X,k as Y}from"./index-CCPRxbLk.js";import"./vendor-dates-CMWWcCEi.js";import"./vendor-voice-CjAdQv9k.js";import"./vendor-tiptap-BoiEPFyJ.js";const S=({shouldScaleBackground:r=!0,...a})=>e.jsx(o.Root,{shouldScaleBackground:r,...a});S.displayName="Drawer";const Z=o.Portal,C=n.forwardRef(({className:r,...a},l)=>e.jsx(o.Overlay,{ref:l,className:d("fixed inset-0 z-50 bg-black/80",r),...a}));C.displayName=o.Overlay.displayName;const R=n.forwardRef(({className:r,children:a,...l},c)=>e.jsxs(Z,{children:[e.jsx(C,{}),e.jsxs(o.Content,{ref:c,className:d("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",r),...l,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));R.displayName="DrawerContent";const T=n.forwardRef(({className:r,...a},l)=>e.jsx(o.Title,{ref:l,className:d("text-lg font-semibold leading-none tracking-tight",r),...a}));T.displayName=o.Title.displayName;const k=n.forwardRef(({className:r,...a},l)=>e.jsx(o.Description,{ref:l,className:d("text-sm text-muted-foreground",r),...a}));k.displayName=o.Description.displayName;const h=768;function ee(){const[r,a]=n.useState(void 0);return n.useEffect(()=>{const l=window.matchMedia(`(max-width: ${h-1}px)`),c=()=>{a(window.innerWidth<h)};return l.addEventListener("change",c),a(window.innerWidth<h),()=>l.removeEventListener("change",c)},[]),!!r}const D=["terms","privacy","signature"];function ie({open:r,onOpenChange:a,onComplete:l}){const c=ee(),[t,m]=n.useState("terms"),[E,g]=n.useState(!1),[P,b]=n.useState(!1),[A,x]=n.useState(!1),f=n.useRef(null),u=n.useRef(null);n.useEffect(()=>{r&&(m("terms"),g(!1),b(!1),x(!1),requestAnimationFrame(()=>{f.current&&(f.current.scrollTop=0)}))},[r]),n.useEffect(()=>{if(t==="signature")return;const s=f.current;s&&(s.scrollTop=0,s.scrollHeight<=s.clientHeight+8&&v())},[t]);function v(){t==="terms"?g(!0):t==="privacy"&&b(!0)}function L(s){const i=s.currentTarget;i.scrollTop+i.clientHeight>=i.scrollHeight-8&&v()}const p=D.indexOf(t),y=t==="terms"?E:P,j=t==="signature"?A:y,I=t==="terms"?"Terms of Service":t==="privacy"?"Privacy Policy":"Sign to confirm",M=t==="terms"?K:V,B=t==="signature"?"Confirm & Agree":"I Agree â Continue";function O(){t==="privacy"?m("terms"):t==="signature"?m("privacy"):a(!1)}function H(){if(t==="terms")m("privacy");else if(t==="privacy")m("signature");else{const s=u.current;if(!s||s.isEmpty())return;l({signatureData:s.getCanvas().toDataURL("image/png"),acceptedAt:new Date().toISOString()}),a(!1)}}const U=c?T:_,q=c?k:$,w=e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 space-y-2 border-b border-slate-100 px-1 pb-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-400",children:["Step ",p+1," of 3"]}),e.jsx("div",{className:"flex items-center gap-1.5",children:D.map((s,i)=>e.jsx("span",{className:d("h-1.5 rounded-full transition-all",i===p?"w-6 bg-rose-600":i<p?"w-1.5 bg-rose-300":"w-1.5 bg-slate-200")},s))})]}),e.jsx(U,{className:"text-lg font-bold text-slate-900",children:I}),t==="signature"?e.jsx(q,{className:"text-xs text-slate-500",children:"Draw your signature below to confirm you agree to the Terms of Service and Privacy Policy."}):e.jsxs("p",{className:"text-xs text-slate-500",children:["Last updated ",M]})]}),t==="signature"?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 py-5",children:[e.jsx("div",{className:"rounded-lg border border-slate-200 bg-white",children:e.jsx(W,{ref:u,penColor:"#111827",backgroundColor:"#ffffff",onEnd:()=>{var s;return x(!((s=u.current)!=null&&s.isEmpty()))},canvasProps:{className:"w-full touch-none cursor-crosshair rounded-lg",style:{height:"176px",display:"block"},"aria-label":"Signature drawing area"}})}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Use your mouse or finger to sign."}),e.jsx("button",{type:"button",onClick:()=>{var s;(s=u.current)==null||s.clear(),x(!1)},className:"text-xs font-medium text-slate-500 hover:text-slate-700",children:"Clear"})]})]}):e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:f,onScroll:L,"data-testid":"consent-scroll",tabIndex:-1,
1className:"always-visible-scroll h-full overflow-y-auto px-1 py-5 outline-none",children:e.jsx("article",{className:d(Q,"[&>*:first-child]:!mt-0"),children:t==="terms"?e.jsx(G,{}):e.jsx(J,{})})}),!y&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex items-center justify-center gap-1.5 bg-white/90 pb-2 pt-8 text-xs font-semibold text-rose-600",children:"Scroll to the bottom to continue â"})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-slate-100 px-1 pt-4",children:[e.jsx(N,{type:"button",variant:"ghost",onClick:O,className:"text-slate-600",children:t==="terms"?"Cancel":e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-4 w-4"}),"Back"]})}),e.jsxs(N,{type:"button",onClick:H,disabled:!j,className:"font-semibold",children:[j&&t==="signature"&&e.jsx(z,{className:"h-4 w-4"}),B]})]})]});return c?e.jsx(S,{open:r,onOpenChange:a,children:e.jsx(R,{className:"flex h-[88vh] flex-col px-4 pb-4",children:w})}):e.jsx(X,{open:r,onOpenChange:a,children:e.jsx(Y,{hideDefaultClose:!0,onOpenAutoFocus:s=>{s.preventDefault(),requestAnimationFrame(()=>{var i;return(i=f.current)==null?void 0:i.focus()})},className:"flex h-[85vh] max-w-2xl flex-col gap-0 p-6",children:w})})}export{ie as TermsConsentModal};
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.