1import{r as o,j as e}from"./index-kqYmxY6V.js";import{C as i}from"./card-BXRS6EyN.js";import{B as j}from"./button-2Cw4Wmda.js";import{T as H}from"./textarea-C84qXrxX.js";import{B as J}from"./badge-DQ3Bbijr.js";import{L as R}from"./loader-circle-B-w5Rips.js";import{C as v}from"./circle-x-Dh3DmP8i.js";import{C as y}from"./circle-check-D5_dRMo-.js";import{S as P}from"./shield-DWMc6-Sd.js";import{F as O}from"./file-text-BP50_VFx.js";import{U as q}from"./user-I5zvLJCz.js";import{B as z}from"./briefcase-jC_UycRt.js";import{C as A}from"./credit-card-1u1zRYuS.js";import{S as K}from"./scale-Doe-hld_.js";import{H as W}from"./house-BAeKQQCa.js";import{B as G}from"./banknote-CV9OoHGi.js";import{T as Q}from"./triangle-alert-vuRZJuY3.js";import{M as V}from"./map-pin-x1c0KsGe.js";import{P as Z}from"./pen-DLByk1IC.js";function je(){const[h,x]=o.useState(!0),[c,m]=o.useState(""),[_,E]=o.useState(null),[r,S]=o.useState(""),[k,M]=o.useState(""),[N,C]=o.useState(!1),[F,U]=o.useState(!1),[X,$]=o.useState(!1),n=o.useRef(null),u=o.useRef(null),f=window.location.pathname.split("/kyc/")[1];o.useEffect(()=>{if(!f){m("رابط ØºÙØ± ØµØ§ÙØ"),x(!1);return}fetch(`/api/kyc/view/${f}`).then(async s=>{if(!s.ok){const a=await s.json();throw new Error(a.error)}return s.json()}).then(E).catch(s=>m(s.message)).finally(()=>x(!1))},[f]),o.useEffect(()=>{if(r==="approved"&&n.current){const s=n.current,a=s.getContext("2d");a&&(a.fillStyle="#ffffff",a.fillRect(0,0,s.width,s.height),a.strokeStyle="#1a1a2e",a.lineWidth=2,a.lineCap="round",a.lineJoin="round")}},[r]);const D=s=>{const a=n.current,l=a.getBoundingClientRect(),p=a.width/l.width,g=a.height/l.height;return"touches"in s?{x:(s.touches[0].clientX-l.left)*p,y:(s.touches[0].clientY-l.top)*g}:{x:(s.clientX-l.left)*p,y:(s.clientY-l.top)*g}},L=s=>{s.preventDefault(),$(!0),u.current=D(s)},T=s=>{if(!X||!n.current||!u.current)return;s.preventDefault();const a=n.current.getContext("2d");if(!a)return;const l=D(s);a.beginPath(),a.moveTo(u.current.x,u.current.y),a.lineTo(l.x,l.y),a.stroke(),u.current=l},w=()=>{$(!1),u.current=null},I=()=>{const s=n.current;if(!s)return;const a=s.getContext("2d");a&&(a.fillStyle="#ffffff",a.fillRect(0,0,s.width,s.height))},Y=async()=>{if(r){if(r==="approved"&&n.current){const s=n.current.getContext("2d");if(s&&!s.getImageData(0,0,n.current.width,n.current.height).data.some((p,g)=>g%4!==3&&p!==255)){alert("ÙØ±Ø¬Ù Ø§ÙØªÙÙÙØ¹ Ø£ÙÙØ§Ù");return}}C(!0);try{const s={decision:r,notes:k};r==="approved"&&n.current&&(s.signature_data=n.current.toDataURL("image/png"));const a=await fetch(`/api/kyc/respond/${f}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.error)}U(!0)}catch(s){alert(s.message||"ØØ¯Ø« خطأ")}finally{C(!1)}}};if(h)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center",children:e.jsx(R,{className:"w-10 h-10 animate-spin text-slate-400"})});if(c)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(v,{className:"w-16 h-16 text-red-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold text-red-600 mb-2",children:"خطأ"}),e.jsx("p",{className:"text-muted-foreground",children:c})]})});if(F)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsx(i,{className:"max-w-md w-full p-8 text-center",children:r==="approved"?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"w-20 h-20 text-green-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-green-700 mb-2",children:"تÙ
ت اÙÙ
ÙØ§ÙÙØ© Ø¨ÙØ¬Ø§Ø"}),e.jsx("p",{className:"text-muted-foreground",children:"Ø´ÙØ±Ø§Ù ÙÙ. تÙ
تسجÙÙ Ù
ÙØ§ÙÙØªÙ ÙØªÙÙÙØ¹Ù Ø¨ÙØ¬Ø§Ø."})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{className:"w-20 h-20 text-red-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-red-600 mb-2",children:"تÙ
تسجÙÙ Ø§ÙØ±Ùض"}),e.jsx("p",{className:"text-muted-foreground",children:"Ø´ÙØ±Ø§Ù ÙÙ. تÙ
تسجÙÙ ÙØ±Ø§Ø±Ù."})]})})});if(!_)return null;const{request:t,investor:B}=_;return B.status!=="pending"?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(P,{className:"w-16 h-16 text-slate-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:"تÙ
Ø§ÙØ±Ø¯ Ù
Ø³Ø¨ÙØ§Ù"}),e.jsx("p",{className:"text-muted-foreground",children:"ÙÙØ¯ تÙ
تسجÙ٠رد٠عÙÙ ÙØ°Ø§ Ø§ÙØ·Ùب Ù
Ø³Ø¨ÙØ§Ù."})]})}):B.already_approved_by_other?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(y,{className:"w-16 h-16 text-amber-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:"تÙ
ت اÙÙ
ÙØ§ÙÙØ© Ù
٠تاجر آخر"}),e.jsx("p",{className:"text-muted-foreground",children:"ÙØ¹ØªØ°Ø±Ø تÙ
ت اÙÙ
ÙØ§ÙÙØ© عÙÙ ÙØ°Ø§ Ø§ÙØ·Ùب Ù
٠تاجر آخر."})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 py-6 px-4",dir:"rtl",children:e.jsxs("div",{className:"max-w-2xl mx-auto
1space-y-4",children:[e.jsxs(i,{className:"p-6 text-center bg-white border-0 shadow-sm",children:[e.jsx("div",{className:"w-14 h-14 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-2xl flex items-center justify-center mx-auto mb-3",children:e.jsx(O,{className:"w-7 h-7 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:"Ø·ÙØ¨ Ù
ÙØ§ÙÙØ© شراء"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"ÙØ±Ø¬Ù Ù
راجعة Ø§ÙØ¨ÙØ§ÙØ§Øª ÙØ§ØªØ®Ø§Ø° اÙÙØ±Ø§Ø±"})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(q,{className:"w-5 h-5 text-blue-500"}),"Ø¨ÙØ§Ùات اÙÙ
ØªÙØ¯Ù
"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(d,{label:"Ø§ÙØ§Ø³Ù
",value:t.applicant_name}),e.jsx(d,{label:"رÙÙ
اÙÙÙÙØ©",value:t.identity_number}),t.phone&&e.jsx(d,{label:"Ø§ÙØ¬ÙاÙ",value:t.phone,dir:"ltr"}),t.residence&&e.jsx(d,{label:"Ù
ÙØ§Ù Ø§ÙØ¥ÙاÙ
Ø©",value:t.residence})]})]}),(t.workplace||t.position)&&e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(z,{className:"w-5 h-5 text-blue-500"}),"Ø¨ÙØ§Ùات Ø§ÙØ¹Ù
Ù ÙØ§ÙدخÙ"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.workplace&&e.jsx(d,{label:"Ø¬ÙØ© Ø§ÙØ¹Ù
Ù",value:t.workplace}),t.position&&e.jsx(d,{label:"اÙÙ
ÙØµØ¨",value:t.position}),t.salary&&e.jsx(d,{label:"Ø§ÙØ±Ø§ØªØ¨ Ø§ÙØ´ÙرÙ",value:`${Number(t.salary).toLocaleString()} Ø±ÙØ§Ù`,highlight:!0}),t.obligations&&e.jsx(d,{label:"Ø§ÙØ§ÙتزاÙ
ات Ø§ÙØ´ÙØ±ÙØ©",value:`${Number(t.obligations).toLocaleString()} Ø±ÙØ§Ù`}),t.remaining_salary&&e.jsx(d,{label:"اÙÙ
تبÙÙ Ù
Ù Ø§ÙØ±Ø§ØªØ¨",value:`${Number(t.remaining_salary).toLocaleString()} Ø±ÙØ§Ù`,highlight:!0})]})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(A,{className:"w-5 h-5 text-blue-500"}),"Ø§ÙØ§ÙتزاÙ
ات اÙÙ
اÙÙØ©"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{icon:e.jsx(K,{className:"w-4 h-4"}),label:"ÙØ¶Ø§Ùا Ù
ØÙÙ
Ø© Ø³Ø§Ø¨ÙØ©",value:t.has_court_case,detail:t.court_case_details}),e.jsx(b,{icon:e.jsx(W,{className:"w-4 h-4"}),label:"ÙØ±Ø¶ Ø¹ÙØ§Ø±Ù",value:t.has_real_estate_loan,detail:t.real_estate_installment?`${Number(t.real_estate_installment).toLocaleString()} Ø±ÙØ§Ù/Ø´ÙØ±`:void 0}),e.jsx(b,{icon:e.jsx(G,{className:"w-4 h-4"}),label:"ÙØ±Ø¶ شخصÙ",value:t.has_personal_loan,detail:t.personal_loan_amount?`${Number(t.personal_loan_amount).toLocaleString()} Ø±ÙØ§Ù`:void 0}),e.jsx(b,{icon:e.jsx(Q,{className:"w-4 h-4"}),label:"Ù
دÙÙÙÙØ§Øª خارج Ø§ÙØ¨ÙÙ",value:t.has_external_debts,detail:t.external_debts_amount?`${Number(t.external_debts_amount).toLocaleString()} Ø±ÙØ§Ù`:void 0}),e.jsx(b,{icon:e.jsx(V,{className:"w-4 h-4"}),label:"Ù
ستأجر",value:t.is_renting,detail:t.rent_amount?`${Number(t.rent_amount).toLocaleString()} Ø±ÙØ§Ù/Ø´ÙØ±`:void 0})]})]}),(t.prepaid_cards_count||t.product_name)&&e.jsx(i,{className:"p-5 bg-gradient-to-r from-blue-50 to-indigo-50 border-blue-200 shadow-sm",children:e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[t.prepaid_cards_count&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-blue-600 font-medium",children:"عدد اÙÙ
ÙØªØ¬"}),e.jsx("p",{className:"text-3xl font-bold text-blue-800 mt-1",children:t.prepaid_cards_count})]}),t.product_name&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-blue-600 font-medium",children:"اسÙ
Ø§ÙØ³Ùعة"}),e.jsx("p",{className:"text-xl font-bold text-blue-800 mt-1",children:t.product_name})]})]})}),t.notes&&e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium mb-1",children:"Ù
ÙØ§ØØ¸Ø§Øª"}),e.jsx("p",{className:"text-sm",children:t.notes})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsx("h2",{className:"font-bold text-base mb-4 text-center text-slate-700",children:"اتخذ ÙØ±Ø§Ø±Ù"}),e.jsxs("div",{className:"flex gap-3 mb-4",children:[e.jsxs(j,{className:`flex-1 h-14 text-base gap-2 ${r==="approved"?"bg-green-600 hover:bg-green-700 text-white":"bg-green-50 text-green-700 hover:bg-green-100 border border-green-200"}`,variant:r==="approved"?"default":"outline",onClick:()=>S("approved"),"data-testid":"btn-kyc-approve",children:[e.jsx(y,{className:"w-5 h-5"}),"Ù
ÙØ§ÙÙØ©"]}),e.jsxs(j,{className:`flex-1 h-14 text-base gap-2 ${r==="rejected"?"bg-red-600 hover:bg-red-700 text-white":"bg-red-50 text-red-700 hover:bg-red-100 border border-red-200"}`,variant:r==="rejected"?"default":"outline",onClick:()=>S("rejected"),"data-testid":"btn-kyc-reject",children:[e.jsx(v,{className:"w-5 h-5"}),"Ø±ÙØ¶"]})]}),r&&e.jsxs("div",{className:"space-y-4 animate-in slide-in-from-top-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-600 mb-1 block",children:"Ù
ÙØ§ØØ¸Ø§Øª (Ø§Ø®ØªÙØ§Ø±Ù)"}),e.jsx(H,{value:k,onChange:s=>M(s.target.value),placeholder:"أض٠Ù
ÙØ§ØØ¸Ø§ØªÙ...",rows:2,"data-testid":"textarea-kyc-response-notes"})]}
1),r==="approved"&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium text-slate-600 mb-2 flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),"Ø§ÙØªÙÙÙØ¹ Ø§ÙØ¥ÙÙØªØ±ÙÙÙ *"]}),e.jsx("div",{className:"border-2 border-dashed border-slate-300 rounded-xl overflow-hidden bg-white",children:e.jsx("canvas",{ref:n,width:560,height:180,className:"w-full cursor-crosshair touch-none",onMouseDown:L,onMouseMove:T,onMouseUp:w,onMouseLeave:w,onTouchStart:L,onTouchMove:T,onTouchEnd:w,"data-testid":"canvas-kyc-signature"})}),e.jsx(j,{size:"sm",variant:"ghost",onClick:I,className:"mt-1 text-xs text-muted-foreground","data-testid":"btn-clear-signature",children:"Ù
Ø³Ø Ø§ÙØªÙÙÙØ¹"})]}),e.jsxs(j,{onClick:Y,disabled:N,className:`w-full h-12 text-base gap-2 ${r==="approved"?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700"}`,"data-testid":"btn-kyc-submit",children:[N?e.jsx(R,{className:"w-5 h-5 animate-spin"}):e.jsx(P,{className:"w-5 h-5"}),N?"Ø¬Ø§Ø±Ù Ø§ÙØªØ³Ø¬ÙÙ...":r==="approved"?"تأÙÙØ¯ اÙÙ
ÙØ§ÙÙØ© ÙØ§ÙتÙÙÙØ¹":"تأÙÙØ¯ Ø§ÙØ±Ùض"]})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pb-4",children:"ÙØ°Ø§ Ø§ÙØ±Ø§Ø¨Ø· ØµØ§ÙØ ÙÙ
رة ÙØ§ØØ¯Ø© ÙÙØ· ÙÙÙØªÙ٠بعد 72 ساعة"})]})})}function d({label:h,value:x,highlight:c,dir:m}){return e.jsxs("div",{className:`p-3 rounded-lg ${c?"bg-blue-50 border border-blue-100":"bg-slate-50"}`,children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:h}),e.jsx("p",{className:`text-sm font-medium mt-0.5 ${c?"text-blue-800":""}`,dir:m,children:x})]})}function b({icon:h,label:x,value:c,detail:m}){return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg ${c?"bg-amber-50 border border-amber-100":"bg-slate-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h,e.jsx("span",{className:"text-sm",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m&&c&&e.jsx("span",{className:"text-xs font-medium text-amber-700",children:m}),e.jsx(J,{className:c?"bg-amber-100 text-amber-800 text-xs":"bg-green-100 text-green-800 text-xs",children:c?"ÙØ¹Ù
":"ÙØ§"})]})]})}export{je 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.