1import{j as n}from"./index-CkAxGocv.js";import{r as l}from"./i18n-vendor-Co-krN6G.js";import{X as S}from"./x-vmD7m2IU.js";import{C as U}from"./check-Dmd9WXya.js";import"./react-vendor-D5E1hOjb.js";import"./supabase-vendor-Co_IX6oM.js";import"./createLucideIcon-BPd9wT8k.js";const H=async r=>{const a=URL.createObjectURL(r),s=new Image;return s.decoding="async",s.src=a,await s.decode(),{image:s,url:a}},W=r=>new Promise((a,s)=>{r.toBlob(d=>d?a(new File([d],`iqama-selfie-${Date.now()}.webp`,{type:"image/webp"})):s(new Error("Could not save the selected portrait.")),"image/webp",.86)}),b=r=>Math.max(0,Math.min(100,r)),j=(r,a)=>{const s=Math.min(r.naturalWidth,r.naturalHeight*.8571428571428571)/a,d=s*(7/6),u=Math.max(0,r.naturalWidth-s),i=Math.max(0,r.naturalHeight-d);return{cropHeight:d,cropWidth:s,maxX:u,maxY:i}},I=(r,a,s,d,u)=>{const i=j(r,a),o=j(r,s),h=i.maxX*(d/100)+i.cropWidth/2,m=i.maxY*(u/100)+i.cropHeight/2,v=Math.max(0,Math.min(o.maxX,h-o.cropWidth/2)),p=Math.max(0,Math.min(o.maxY,m-o.cropHeight/2));return{positionX:o.maxX>0?b(v/o.maxX*100):50,positionY:o.maxY>0?b(p/o.maxY*100):50}};function T({file:r,isArabic:a,onCancel:s,onConfirm:d}){const u=l.useRef(null),i=l.useRef(null),o=l.useRef(""),h=l.useRef(null),[m,v]=l.useState(2.15),[p,R]=l.useState(20),[g,k]=l.useState(47),[M,C]=l.useState(!1),N=()=>{const e=i.current,t=u.current;if(!e||!t)return;const c=t.getContext("2d");if(!c)return;const{cropHeight:x,cropWidth:y,maxX:X,maxY:f}=j(e,m),w=X*(p/100),Y=f*(g/100);c.clearRect(0,0,t.width,t.height),c.drawImage(e,w,Y,y,x,0,0,t.width,t.height)};return l.useEffect(()=>{let e=!0;return H(r).then(({image:t,url:c})=>{if(!e){URL.revokeObjectURL(c);return}i.current=t,o.current=c,N()}),()=>{e=!1,o.current&&URL.revokeObjectURL(o.current)}},[r]),l.useEffect(N,[m,p,g]),n.jsx("div",{className:"fixed inset-0 z-[400] grid place-items-center bg-slate-950/80 p-3 backdrop-blur-sm",dir:a?"rtl":"ltr",children:n.jsxs("div",{className:"max-h-[calc(100dvh-1.5rem)] w-full max-w-lg overflow-y-auto rounded-2xl bg-white p-4 shadow-2xl dark:bg-slate-900",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-black text-slate-900 dark:text-white",children:a?"ØØ¯Ø¯ ÙØ¬Ù Ø§ÙØ±Ø§Ùب":"Select rider face"}),n.jsx("p",{className:"mt-1 text-[11px] font-semibold leading-relaxed text-red-600 dark:text-red-300",children:a?"Ø§Ø³ØØ¨ Ø§ÙØµÙرة باÙÙ
Ø§ÙØ³ ÙØ§Ø¶Ø¨Ø· Ø§ÙØªÙØ¨ÙØ± ØØªÙ ÙØ¸Ùر ÙØ¬Ù Ø§ÙØ±Ø§Ùب ÙÙØªÙØ§Ù Ø¨ÙØ¶ÙØ Ø¯Ø§Ø®Ù Ø§ÙØ¥Ø·Ø§Ø±.":"Drag the image and adjust zoom until the riderâs face and shoulders are clearly centered inside the frame."})]}),n.jsx("button",{type:"button",onClick:s,className:"rounded-full p-1.5 text-slate-400 hover:bg-slate-100",children:n.jsx(S,{size:18})})]}),n.jsx("div",{className:"mx-auto mt-3 aspect-[6/7] w-full max-w-[270px] overflow-hidden rounded-2xl border-4 border-emerald-500 bg-slate-100 shadow-inner",children:n.jsx("canvas",{ref:u,width:480,height:560,
1className:"h-full w-full cursor-grab touch-none active:cursor-grabbing",onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),h.current={x:e.clientX,y:e.clientY,positionX:p,positionY:g}},onPointerMove:e=>{const t=h.current,c=i.current;if(!t||!c)return;const x=e.currentTarget.getBoundingClientRect(),{cropHeight:y,cropWidth:X,maxX:f,maxY:w}=j(c,m),Y=f>0?(e.clientX-t.x)*X*100/(x.width*f):0,P=w>0?(e.clientY-t.y)*y*100/(x.height*w):0;R(b(t.positionX-Y)),k(b(t.positionY-P))},onPointerUp:()=>{h.current=null},onPointerCancel:()=>{h.current=null}})}),n.jsx("div",{className:"mt-4 grid gap-3 text-[11px] font-bold text-slate-600 dark:text-slate-200",children:n.jsxs("label",{children:[a?"Ø§ÙØªÙØ¨ÙØ±":"Zoom",n.jsx("input",{className:"mt-1 w-full accent-emerald-600",type:"range",min:"1",max:"5",step:"0.05",value:m,onChange:e=>{const t=Number(e.target.value),c=i.current;if(c){const x=I(c,m,t,p,g);R(x.positionX),k(x.positionY)}v(t)}})]})}),n.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:s,className:"rounded-lg bg-slate-100 px-4 py-2 text-xs font-black text-slate-600",children:a?"Ø¥ÙØºØ§Ø¡":"Cancel"}),n.jsxs("button",{type:"button",disabled:M,onClick:async()=>{if(u.current){C(!0);try{d(await W(u.current))}finally{C(!1)}}},className:"inline-flex items-center gap-1.5 rounded-lg bg-emerald-600 px-4 py-2 text-xs font-black text-white disabled:opacity-60",children:[n.jsx(U,{size:14})," ",a?"استخدÙ
ÙØ§ ÙØµÙرة Ø´Ø®ØµÙØ©":"Use as Selfie"]})]})]})})}export{T 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.