1import{j as e,a8 as Ie,u as Fe,r as m,F as d,g as U,c as ce,C as ne,B as L,aM as Ge,a1 as ge,a2 as be,a3 as je,a4 as fe,a5 as Z,G as Ve,h as Ke,aN as Re,I as me,A as Qe,y as Je,x as Ze,U as Xe,N as es,al as ss,O as as,Q as rs,W as ts,Y as is,ak as ls,Z as ns}from"./index-CcpYcpQu.js";import{C as Y,a as I,b as G,c as te,d as X}from"./card-5iVPulfB.js";import{P as he,a as Pe,T as os}from"./PartnerLevelManagement-BfXlIVg2.js";import ds from"./PresetMessages-rorM0zLi.js";import{I as P}from"./input-aH8MwTjP.js";import{L as f}from"./label-DX2mxcuL.js";import{T as ve}from"./textarea-C9ZdcYJz.js";import{B as g}from"./badge-C1pwxxth.js";import{u as ee}from"./useQuery-Cntbci7B.js";import{M as Ne}from"./message-circle-BrBA7AdU.js";import{P as Ae}from"./phone-DOrDAsWn.js";import{S as ye}from"./send-Chncf5GD.js";import{U as cs}from"./upload-DY-bnKdt.js";import{B as ms}from"./building-2-C4MKuGxf.js";import{M as us}from"./mail-DEN3iwbX.js";import{F as le}from"./file-text-tUYQ1tv1.js";import{L as ze}from"./lock-BsLi491f.js";import{u as $e}from"./useMutation-CO9Apo6k.js";import{T as He,a as We,b as W,c as O}from"./tabs-CIlR5NJx.js";import{S as x}from"./skeleton-BFKsxYry.js";import{D as Le}from"./dollar-sign-DN3z5gow.js";import{C as Ee}from"./circle-arrow-up-gF3pItmF.js";import{M as Me}from"./message-square-DrZb9HSa.js";import{T as ps}from"./tag-DZgmInTH.js";import{S as xs}from"./settings-0dji14z5.js";import{C as hs}from"./calendar-HvanZCd4.js";import{D as gs}from"./download-SrNxxJwa.js";import{C as bs}from"./compass-C3fQkmKJ.js";import{R as js}from"./rocket-BzA1SwTp.js";import{W as fs}from"./wrench-D0RsMDLW.js";import{A as vs}from"./award-BsTt7_GT.js";import{S as Ns}from"./star-CVujynza.js";import{C as ys}from"./crown-Bg56LxYL.js";import"./table-DgrT1sJe.js";import"./plus-DoVS7qJF.js";import"./trending-up-CKZb2wvo.js";import"./pencil-RLCxeeA0.js";import"./palette-CRSJY_aZ.js";import"./trash-2-BtDf1qx3.js";import"./save-EXrfjSjP.js";const ws=()=>e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-20 md:pt-24",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx(x,{className:"h-9 w-64 mb-2"}),e.jsx(x,{className:"h-5 w-96 max-w-full"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2",children:[100,90,85,90,110,85].map((o,s)=>e.jsx(x,{className:"h-10 rounded-md",style:{width:`${o}px`}},s))}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[0,1,2,3].map(o=>e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(x,{className:"h-4 w-24"}),e.jsx(x,{className:"h-8 w-8 rounded-lg"})]}),e.jsx(x,{className:"h-8 w-20 mb-2"}),e.jsx(x,{className:"h-3 w-16"})]},o))}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[160,140].map((o,s)=>e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"h-9 w-9 rounded-lg"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{className:"h-5",style:{width:`${o}px`}}),e.jsx(x,{className:"h-3 w-40"})]})]})}),e.jsx("div",{className:"p-6 space-y-4",children:Array.from({length:s===0?4:3}).map((B,E)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{className:"h-4 w-28"}),e.jsx(x,{className:"h-3 w-20"})]})]}),e.jsx(x,{className:"h-6 w-16 rounded-full"})]},E))})]},s))}),e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"h-9 w-9 rounded-lg"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{className:"h-5 w-36"}),e.jsx(x,{className:"h-3 w-52"})]})]}),e.jsx(x,{className:"h-9 w-28 rounded-lg"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-4 px-6 py-3 border-b border-border bg-muted/30",children:[100,80,120,80,100].map((o,s)=>e.jsx(x,{className:"h-4",style:{width:`${o}px`}},s))}),[0,1,2,3,4].map(o=>e.jsx("div",{className:"flex gap-4 px-6 py-4 border-b border-border/50 last:border-b-0",children:[100,80,120,80,100].map((s,B)=>e.jsx(x,{className:"h-4",style:{width:`${s}px`}},B))},o))]})]})]})]})}),_s=()=>{const{toast:o}=Ie(),{language:s}=Fe(),[B,E]=m.useState(!0),[se,b]=m.useState(!1),[ie,A]=m.useState(!1),[M,N]=m.useState(!1),[q,T]=m.useState(""),[F,V]=m.useState(null),[ae,i]=m.useState(!1),[n,u]=m.useState(""),[y,w]=m.useState(""),[k,R]=m.useState(""),[p,D]=m.useState(!1),[l,j]=m.useState({company_name:"",logo_url:"",address:"",phone:"",email:"",website:"",tax_office:"",tax_number:"",auto_message_enabled:!1,auto_message_template:"",auto_message_preset_id:""}),{data:_=[]}=ee({queryKey:["preset-messages"],queryFn:async()=>{const{data:r,error:t}=await d.from("preset_messages").select("id, title, message_content").order("title");if(t)throw t;return r}});m.useEffect(()=>{z()},[]);const z=async()=>{try{const{data:{user:r}}=await d.auth.getUser();if(!r)return;const{data:t,error:v}=await d.from("partner_settings").select("*").eq("user_id",r.id).maybeSingle();if(v&&v.code!=="PGRST116")throw v;if(t&&(j({id:t.id,company_name:t.company_name||"",logo_url:t.logo_url||"",address:t.address||"",phone:t.phone||"",email:t.email||"",website:t.website||"",tax_office:t.tax_office||"",tax_number:t.tax_number||"",whatsapp_number:t.whatsapp_number||"",whatsapp_webhook_url:t.whatsapp_webhook_url||"",whatsapp_connected:t.whatsapp_connected||!1,whatsapp_connection_requested:t.whatsapp_connection_requested||!1,whatsapp_connection_requested_at:t.whatsapp_connection_requested_at||"",auto_message_enabled:t.auto_message_enabled||!1,auto_message_template:t.auto_message_template||"",auto_message_preset_id:t.auto_message_preset_id||""}),T(t.whatsapp_number||""),t.id)){const{data:C}=await d.from("partner_whatsapp_requests").select("*").eq("partner_id",t.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();C&&V(C)}}catch(r){console.error("Error loading settings:",r),o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Ayarlar yüklenemedi":"Failed to load settings",variant:"destructive"})}finally{E(!1)}},K=async r=>{const t=r.target.files?.[0];if(t){if(!t.type.startsWith("image/")){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Lütfen bir görsel dosyası seçin":"Please select an image file",variant:"destructive"});return}if(t.size>5*1024*1024){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Dosya boyutu 5MB'dan küçük olmalıdır":"File size must be less than 5MB",variant:"destructive"});return}A(!0);try{const{data:{user:v}}=await d.auth.getUser();if(!v)return;const C=t.name.split(".").pop(),a=`logo-${Date.now()}.${C}`,c=`partner-logos/${v.id}/${a}`,{error:S}=await d.storage.from("files").upload(c,t,{upsert:!0});if(S)throw S;j(Q=>({...Q,logo_url:c})),o({title:s==="tr"?"BaÅarılı":"Success",description:s==="tr"?"Logo yüklendi":"Logo uploaded"})}catch(v){console.error("Error uploading logo:",v),o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Logo yüklenemedi":"Failed to upload logo",variant:"destructive"})}finally{A(!1)}}},$=async()=>{b(!0);try{const{data:{user:r}}=await d.auth.getUser();if(!r)return;const{data:t}=await d.from("partner_settings").select("id").eq("user_id",r.id).maybeSingle(),v={company_name:l.company_name,logo_url:l.logo_url,address:l.address,phone:l.phone,email:l.email,website:l.website,tax_office:l.tax_office,tax_number:l.tax_number};let C;if(t?C=(await d.from("partner_settings").update(v).eq("user_id",r.id)).error:C=(await d.from("partner_settings").insert({user_id:r.id,...v})).error,C)throw C;o({title:s==="tr"?"BaÅarılı":"Success",description:s==="tr"?"Ayarlar kaydedildi":"Settings saved"})}catch(r){console.error("Error saving settings:",r),o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Ayarlar kaydedilemedi":"Failed to save settings",variant:"destructive"})}finally{b(!1)}},ue=async()=>
1{if(!q.trim()){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Lütfen WhatsApp numaranızı girin":"Please enter your WhatsApp number",variant:"destructive"});return}N(!0);try{const{data:{user:r}}=await d.auth.getUser();if(!r)return;let t=l.id;if(!t){const{data:c}=await d.from("partner_settings").select("id").eq("user_id",r.id).maybeSingle();if(c)t=c.id;else{const{data:S,error:Q}=await d.from("partner_settings").insert({user_id:r.id,company_name:l.company_name||"Partner"}).select("id").single();if(Q)throw Q;t=S.id}}const{error:v}=await d.from("partner_settings").update({whatsapp_number:q,whatsapp_connection_requested:!0,whatsapp_connection_requested_at:new Date().toISOString()}).eq("id",t);if(v)throw v;const{data:C,error:a}=await d.from("partner_whatsapp_requests").insert({partner_id:t,user_id:r.id,whatsapp_number:q,status:"pending"}).select().single();if(a)throw a;V(C),j(c=>({...c,id:t,whatsapp_number:q,whatsapp_connection_requested:!0,whatsapp_connection_requested_at:new Date().toISOString()})),o({title:s==="tr"?"Talep Gönderildi":"Request Sent",description:s==="tr"?"WhatsApp baÄlantı talebiniz yöneticiye iletildi.":"Your WhatsApp connection request has been sent to admin."})}catch(r){console.error("Error requesting WhatsApp connection:",r),o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Talep gönderilemedi":"Failed to send request",variant:"destructive"})}finally{N(!1)}},oe=async()=>{if(!y||!k){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Lütfen tüm alanları doldurun":"Please fill all fields",variant:"destructive"});return}if(y!==k){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Åifreler eÅleÅmiyor":"Passwords do not match",variant:"destructive"});return}if(y.length<6){o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Åifre en az 6 karakter olmalıdır":"Password must be at least 6 characters",variant:"destructive"});return}i(!0);try{const{error:r}=await d.auth.updateUser({password:y});if(r)throw r;o({title:s==="tr"?"BaÅarılı":"Success",description:s==="tr"?"Åifreniz güncellendi":"Your password has been updated"}),u(""),w(""),R("")}catch(r){console.error("Error changing password:",r),o({title:s==="tr"?"Hata":"Error",description:r.message||(s==="tr"?"Åifre deÄiÅtirilemedi":"Failed to change password"),variant:"destructive"})}finally{i(!1)}},pe=async()=>{D(!0);try{const{data:{user:r}}=await d.auth.getUser();if(!r)return;const{error:t}=await d.from("partner_settings").update({auto_message_enabled:l.auto_message_enabled,auto_message_template:l.auto_message_template||null,auto_message_preset_id:l.auto_message_preset_id||null}).eq("user_id",r.id);if(t)throw t;o({title:s==="tr"?"BaÅarılı":"Success",description:s==="tr"?"Oto mesaj ayarları kaydedildi":"Auto message settings saved"})}catch(r){console.error("Error saving auto message settings:",r),o({title:s==="tr"?"Hata":"Error",description:s==="tr"?"Oto mesaj ayarları kaydedilemedi":"Failed to save auto message settings",variant:"destructive"})}finally{D(!1)}},de=()=>l.whatsapp_connected?e.jsxs(g,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:[e.jsx(ce,{className:"h-3 w-3 mr-1"}),s==="tr"?"BaÄlı":"Connected"]}):F?.status==="pending"||l.whatsapp_connection_requested?e.jsxs(g,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20",children:[e.jsx(ne,{className:"h-3 w-3 mr-1"}),s==="tr"?"Beklemede":"Pending"]}):F?.status==="rejected"?e.jsxs(g,{className:"bg-red-500/10 text-red-600 border-red-500/20",children:[e.jsx(Ke,{className:"h-3 w-3 mr-1"}),s==="tr"?"Reddedildi":"Rejected"]}):e.jsx(g,{variant:"outline",className:"text-muted-foreground",children:s==="tr"?"BaÄlı DeÄil":"Not Connected"});return B?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(U,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{className:"border-green-500/20 bg-gradient-to-br from-background to-green-500/5",children:[e.jsxs(I,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5 text-green-500"}),e.jsx(G,{children:s==="tr"?"WhatsApp BaÄlantısı":"WhatsApp Connection"})]}),de()]}),e.jsx(te,{children:s==="tr"?"Arya'dan mesaj göndermek için WhatsApp hesabınızı baÄlayın":"Connect your WhatsApp account to send messages via Arya"})]}),e.jsx(X,{children:l.whatsapp_connected?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-green-500/10 rounded-lg border border-green-500/20",children:[e.jsx(ce,{className:"h-8 w-8 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-700 dark:text-green-400",children:s==="tr"?"WhatsApp BaÄlı":"WhatsApp Connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l.whatsapp_number})]})]})}
1):F?.status==="pending"||l.whatsapp_connection_requested?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 rounded-lg border border-yellow-500/20",children:[e.jsx(ne,{className:"h-8 w-8 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-yellow-700 dark:text-yellow-400",children:s==="tr"?"BaÄlantı Talebi Beklemede":"Connection Request Pending"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q||l.whatsapp_number})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"whatsapp_number",className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),s==="tr"?"WhatsApp Numarası":"WhatsApp Number"]}),e.jsx(P,{id:"whatsapp_number",value:q,onChange:r=>T(r.target.value),placeholder:"+90 555 123 4567"})]}),e.jsxs(L,{onClick:ue,disabled:M||!q.trim(),className:"bg-green-600 hover:bg-green-700",children:[M&&e.jsx(U,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx(Ne,{className:"h-4 w-4 mr-2"}),s==="tr"?"BaÄlantı Talebi Gönder":"Send Connection Request"]})]})})]}),l.whatsapp_connected&&e.jsxs(Y,{className:"border-blue-500/20 bg-gradient-to-br from-background to-blue-500/5",children:[e.jsxs(I,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"h-5 w-5 text-blue-500"}),e.jsx(G,{children:s==="tr"?"Otomatik KarÅılama Mesajı":"Auto Welcome Message"})]}),l.auto_message_enabled&&e.jsxs(g,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20",children:[e.jsx(ce,{className:"h-3 w-3 mr-1"}),s==="tr"?"Aktif":"Active"]})]}),e.jsx(te,{children:s==="tr"?"Yeni leadler için kendi özel karÅılama mesajınızı ayarlayın":"Set up your custom welcome message for new leads"})]}),e.jsx(X,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(f,{className:"text-base font-medium",children:s==="tr"?"Oto Mesajı EtkinleÅtir":"Enable Auto Message"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s==="tr"?"Yeni leadlere otomatik mesaj gönder":"Send automatic message to new leads"})]}),e.jsx(Ge,{checked:l.auto_message_enabled,onCheckedChange:r=>j(t=>({...t,auto_message_enabled:r}))})]}),l.auto_message_enabled&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:s==="tr"?"Hazır Mesaj Seç":"Select Preset Message"}),e.jsxs(ge,{value:l.auto_message_preset_id||"",onValueChange:r=>j(t=>({...t,auto_message_preset_id:r,auto_message_template:""})),children:[e.jsx(be,{children:e.jsx(je,{placeholder:s==="tr"?"Hazır mesaj seçin...":"Select preset..."})}),e.jsxs(fe,{children:[e.jsx(Z,{value:"",children:s==="tr"?"Ãzel mesaj kullan":"Use custom message"}),_.map(r=>e.jsx(Z,{value:r.id,children:r.title},r.id))]})]})]}),!l.auto_message_preset_id&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:s==="tr"?"Ãzel Mesaj Åablonu":"Custom Message Template"}),e.jsx(ve,{value:l.auto_message_template||"",onChange:r=>j(t=>({...t,auto_message_template:r.target.value})),placeholder:s==="tr"?"Merhaba {{firstName}}, sizinle tanıÅmak için sabırsızlanıyoruz!":"Hello {{firstName}}, we are excited to meet you!",rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s==="tr"?"DeÄiÅkenler: {{firstName}}, {{lastName}}, {{fullName}}, {{company}}, {{city}}":"Variables: {{firstName}}, {{lastName}}, {{fullName}}, {{company}}, {{city}}"})]}),l.auto_message_preset_id&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:s==="tr"?"Seçili mesaj önizlemesi:":"Selected message preview:"}),e.jsx("p",{className:"text-sm",children:_.find(r=>r.id===l.auto_message_preset_id)?.message_content||""})]})]}),e.jsxs(L,{onClick:pe,disabled:p,className:"w-full",children:[p&&e.jsx(U,{className:"h-4 w-4 mr-2 animate-spin"}),s==="tr"?"Oto Mesaj Ayarlarını Kaydet":"Save Auto Message Settings"]})]})})]}),e.jsxs(Y,{children:[e.jsxs(I,{children:[e.jsx(G,{children:s==="tr"?"Åirket Bilgileri":"Company Information"}),e.jsx(te,{children:s==="tr"?"Logo, iletiÅim ve vergi bilgilerinizi güncelleyin":"Update your logo, contact and tax details"})]}),e.jsx(X,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"logo",className:"flex items-center gap-2",children:[e.jsx(cs,{className:"h-4 w-4"}),s==="tr"?"Åirket Logosu":"Company Logo"]}),l.logo_url&&e.jsx("div",{className:"mb-2",children:e.jsx("img",{src:d.storage.from("files").getPublicUrl(l.logo_url).data.publicUrl,alt:"Logo",className:"h-20 object-contain border border-border rounded-md p-2"})}),e.jsx(P,{id:"logo",type:"file",accept:"image/*",onChange:K,disabled:ie})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"company_name",className:"flex items-center gap-2",children:[e.jsx(ms,{className:"h-4 w-4"}),s==="tr"?"Åirket Adı":"Company Name"]}),e.jsx(P,{id:"company_name",value:l.company_name,onChange:r=>j(t=>({...t,company_name:r.target.value})),placeholder:s==="tr"?"ABC Teknoloji A.Å.":"ABC Technology Inc."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"address",children:s==="tr"?"Adres":"Address"}),e.jsx(ve,{id:"address",value:l.address,onChange:r=>j(t=>({...t,address:r.target.value})),placeholder:s==="tr"?"Åirket adresi":"Company address",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"phone",className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),s==="tr"?"Telefon":"Phone"]}),e.jsx(P,{id:"phone",value:l.phone,onChange:r=>j(t=>({...t,phone:r.target.value})),placeholder:"+90 555 123 4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"email",className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4"}),s==="tr"?"E-posta":"Email"]}),e.jsx(P,{id:"email",type:"email",value:l.email,onChange:r=>j(t=>({...t,email:r.target.value})),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"website",className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Website"]}),e.jsx(P,{id:"website",value:l.website,onChange:r=>j(t=>({...t,website:r.target.value})),placeholder:"https://www.sirket.com"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"tax_office",className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),s==="tr"?"Vergi Dairesi":"Tax Office"]}),e.jsx(P,{id:"tax_office",value:l.tax_office,onChange:r=>j(t=>({...t,tax_office:r.target.value})),placeholder:s==="tr"?"Kadıköy":"Tax Office"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"tax_number",className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),s==="tr"?"Vergi Numarası":"Tax Number"]}),e.jsx(P,{id:"tax_number",value:l.tax_number,onChange:r=>j(t=>({...t,tax_number:r.target.value})),placeholder:"1234567890"})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(L,{onClick:$,disabled:se,children:[se&&e.jsx(U,{className:"h-4 w-4 mr-2 animate-spin"}),s==="tr"?"Kaydet":"Save"]})})]})})]}),e.jsxs(Y,{children:[e.jsxs(I,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-5 w-5 text-primary"}),e.jsx(G,{children:s==="tr"?"Åifre DeÄiÅtir":"Change Password"})]}),e.jsx(te,{children:s==="tr"?"Hesap Åifrenizi güncelleyin":"Update your account password"})]}),e.jsx(X,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"new_password",children:s==="tr"?"Yeni Åifre":"New Password"}),e.jsx(P,{id:"new_password",type:"password",value:y,onChange:r=>w(r.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"confirm_password",children:s==="tr"?"Åifre Tekrar":"Confirm Password"}),e.jsx(P,{id:"confirm_password",type:"password",value:k,onChange:r=>R(r.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢"})]}),e.jsxs(L,{onClick:oe,disabled:ae||!y||!k,children:[ae&&e.jsx(U,{className:"h-4 w-4 mr-2 animate-spin"}),e.jsx(ze,{className:"h-4 w-4 mr-2"}),s==="tr"?"Åifreyi Güncelle":"Update Password"]})]})})]})]})};function ks({currentType:o,currentLevel:s,partnerId:B,userId:E}){const se=Re(),{data:b,isLoading:ie}=ee({queryKey:["partner-level-configs-public"],queryFn:async()=>{const{data:i,error:n}=await d.from("partner_level_configs").select("*").order("partner_type",{ascending:!0}).order("partner_level",{ascending:!0});if(n)throw n;return(i||[]).map(u=>({...u,bonus_features:Array.isArray(u.bonus_features)?u.bonus_features:JSON.parse(u.bonus_features||"[]"),required_packages:Array.isArray(u.required_packages)?u.required_packages:JSON.parse(u.required_packages||"[]")}))}}),{data:A}=ee({queryKey:["packages-for-upgrade"],queryFn:async()=>{const{data:i,error:n}=await d.from("packages").select("id, name, monthly_price, annual_price").eq("is_active",!0);if(n)throw n;return i||[]}}),{data:M}=ee({queryKey:["partner-level-applications",E],queryFn:async()=>{const{data:i,error:n}=await d.from("partner_level_applications").select("*").eq("user_id",E).order("created_at",{ascending:!1});if(n)throw n;return i}}),N=$e({mutationFn:async i=>{const{error:n}=await d.from("partner_level_applications").insert([{partner_id:B,user_id:E,requested_type:i.requestedType,requested_level:i.requestedLevel,current_type:o,current_level:s}]);if(n)throw n},onSuccess:()=>{se.invalidateQueries({queryKey:["partner-level-applications"]}),me.success("BaÅvurunuz alındı, deÄerlendirilecektir.")},onError:i=>{me.error("Hata: "+i.message)}}),q=i=>b?.filter(n=>n.partner_type===i)||[],T=(i,n)=>M?.some(u=>u.requested_type===i&&u.requested_level===n&&u.status==="pending"),F=(i,n)=>o===i&&s===n,V=i=>({bronze:1,gold:2,platinum:3})[i]||0,ae=(i,n)=>F(i,n)||T(i,n)?!1:o===i?V(n)>V(s||"bronze"):!0;return ie?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-6",children:[M&&M.filter(i=>i.status==="pending").length>0&&e.jsxs(Y,{className:"border-yellow-500/30 bg-yellow-500/5",children:[e.jsx(I,{className:"pb-3",children:e.jsxs(G,{className:"text-lg flex items-center gap-2",children:[e.jsx(ne,{className:"h-5 w-5 text-yellow-500"}),"Bekleyen BaÅvurular"]})}),e.jsx(X,{children:e.jsx("div",{className:"space-y-2",children:M.filter(i=>i.status==="pending").map(i=>{const n=he[i.requested_type],u=Pe[i.requested_level];return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(g,{variant:"outline",className:`${n?.bgColor} ${n?.color}`,children:n?.label}),e.jsx(Qe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(g,{variant:"outline",className:`${u?.bgColor} ${u?.color}`,children:u?.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["(",new Date(i.created_at).toLocaleDateString("tr-TR"),")"]})]},i.id)})})})]}),e.jsxs(He,{defaultValue:o||"navigator",className:"space-y-6",children:[e.jsx(We,{className:"grid w-full grid-cols-4",children:Object.entries(he).map(([i,n])=>{const u=n.icon,y=o===i;return e.jsxs(W,{value:i,className:"gap-2 relative",children:[e.jsx(u,{className:`h-4 w-4 ${n.color}`}),e.jsx("span",{className:"hidden sm:inline",children:n.label.split(" ")[0]}),y&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 bg-green-500 rounded-full"})]},i)})}),Object.entries(he).map(([i,n])=>{const u=n.icon,y=q(i);return e.jsxs(O,{value:i,className:"space-y-6",children:[e.jsx(Y,{className:`${n.bgColor} ${n.borderColor} border`,children:e.jsx(I,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-3 rounded-xl ${n.bgColor}`,children:e.jsx(u,{className:`h-6 w-6 ${n.color}`})}),e.jsxs("div",{children:[e.jsx(G,{className:n.color,children:n.label}),e.jsx(te,{className:"mt-1",children:n.description})]})]})})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:["bronze","gold","platinum"].map(w=>{const k=Pe[w],R=k.icon,p=y.find(_=>_.partner_level===w),D=F(i,w),l=T(i,w),j=ae(i,w);return p?e.jsxs(Y,{className:`relative overflow-hidden transition-all ${D?"ring-2 ring-green-500 bg-green-500/5":""}`,children:[e.jsx("div",{className:`absolute top-0 left-0 right-0 h-1 ${k.bgColor.replace("/10","")}`}),D&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(g,{className:"bg-green-500 text-white",children:[e.jsx(Je,{className:"h-3 w-3 mr-1"}),"Mevcut"]})}),e.jsx(I,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`p-2 rounded-lg ${k.bgColor}`,children:e.jsx(R,{className:`h-5 w-5 ${k.color}`})}),e.jsx(G,{className:"text-lg",children:k.label})]})}),e.jsxs(X,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Gereksinimler"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[p.required_packages.length>0?e.jsxs(e.Fragment,{children:[p.required_packages.map((_,z)=>{const K=A?.find($=>
1$.id===_.package_id);return e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{children:[_.quantity,"x ",K?.name||"Paket"]})},z)}),e.jsxs("div",{className:"pt-1 border-t font-semibold text-primary",children:["âº",p.required_packages.reduce((_,z)=>{const K=A?.find($=>$.id===z.package_id);return _+(K?.annual_price||0)*z.quantity},0).toLocaleString("tr-TR"),"/yıl"]})]}):e.jsx("p",{className:"text-muted-foreground",children:"Gereksinim yok"}),p.annual_sales_target&&e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsx("span",{children:"Yıllık Hedef"}),e.jsxs("span",{className:"font-semibold",children:["âº",p.annual_sales_target.toLocaleString("tr-TR")]})]}),p.annual_sales_target&&p.target_bonus_commission&&e.jsxs("div",{className:"flex items-center justify-between text-green-600",children:[e.jsx("span",{children:"Hedef Bonusu"}),e.jsxs("span",{className:"font-semibold",children:["+%",p.target_bonus_commission]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Komisyon Oranı"}),e.jsxs("p",{className:"text-2xl font-bold text-primary",children:["%",p.commission_rate]}),p.annual_sales_target&&p.target_bonus_commission&&e.jsxs("p",{className:"text-xs text-green-600",children:["Hedef ile: %",p.commission_rate+p.target_bonus_commission]})]}),p.bonus_features.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bonus Ãzellikler"}),e.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:p.bonus_features.map((_,z)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:`h-1.5 w-1.5 rounded-full ${n.color.replace("text-","bg-")}`}),e.jsx("span",{children:_})]},z))})]}),!D&&e.jsx(L,{className:"w-full mt-4",variant:l?"outline":"default",disabled:!j||l||N.isPending,onClick:()=>N.mutate({requestedType:i,requestedLevel:w}),children:l?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-4 w-4 mr-2"}),"BaÅvuru Bekliyor"]}):"BaÅvur"})]})]},w):null})})]},i)})]})]})}const De={navigator:{label:"Navigator Partner",description:"Yeni pazarlarda rotamızı çizen çözüm ortaÄı",icon:bs,color:"text-blue-500",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30"},catalyst:{label:"Catalyst Partner",description:"Strateji, büyüme ve yayılımda hızlandırıcı",icon:js,color:"text-purple-500",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30"},architect:{label:"Architect Partner",description:"ÃzelleÅtirilmiÅ otomasyon çözümleri sunan",icon:fs,color:"text-amber-500",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30"},activator:{label:"Activator Partner",description:"MüÅterileri harekete geçiren referans ortaÄı",icon:ns,color:"text-emerald-500",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30"}},Be={bronze:{label:"Bronze",icon:vs,color:"text-amber-700",bgColor:"bg-amber-700/10",borderColor:"border-amber-700/30"},gold:{label:"Gold",icon:Ns,color:"text-yellow-500",bgColor:"bg-yellow-500/10",borderColor:"border-yellow-500/30"},platinum:{label:"Platinum",icon:ys,color:"text-slate-400",bgColor:"bg-slate-400/10",borderColor:"border-slate-400/30"}},ua=()=>{const o=Ze(),{language:s}=Fe(),B=Re(),[E,se]=m.useState(!0),[b,ie]=m.useState(null),[A,M]=m.useState(null),[N,q]=m.useState(null),[T,F]=m.useState({totalLeads:0,convertedLeads:0,totalCommission:0,pendingCommission:0}),[V,ae]=m.useState(10),[i,n]=m.useState([]),[u,y]=m.useState(!1),[w,k]=m.useState(""),[R,p]=m.useState(""),[D,l]=m.useState("normal"),[j,_]=m.useState("");m.useEffect(()=>{z()},[]);const z=async()=>{const{data:{session:a}}=await d.auth.getSession();if(!a){o("/auth");return}const{data:c}=await d.from("user_roles").select("role").eq("user_id",a.user.id).eq("role","partner").single();if(!c){o("/");return}ie(a.user.id);const{data:S}=await d.from("partner_settings").select("id, partner_type, partner_level, company_name").eq("user_id",a.user.id).single();S&&(M(S.id),q({partner_type:S.partner_type,partner_level:S.partner_level,company_name:S.company_name})),K(a.user.id)},K=async a=>{try{const{data:c,error:S}=await d.from("partner_settings").select("partner_type, partner_level").eq("user_id",a).single();if(S)throw S;let Q=10;if(c?.partner_type&&c?.partner_level){const{data:h}=await d.from("partner_level_configs").select("commission_rate").eq("partner_type",c.partner_type).eq("partner_level",c.partner_level).maybeSingle();h?.commission_rate&&(Q=h.commission_rate)}ae(Q);const{data:we,error:_e}=await d.from("leads").select("id, status").eq("created_by",a);if(_e)throw _e;const{data:ke,error:Ce}=await d.from("commission_payments").select("amount, status, month").eq("partner_id",a).order("month",{ascending:!0});if(Ce)throw Ce;const Oe=we?.filter(h=>h.status==="SatıŠYapıldı").length||0;let Se=0,qe=0;ke?.forEach(h=>{h.status==="Ãdendi"?Se+=h.amount:h.status==="Beklemede"&&(qe+=h.amount)});const xe=new Map;ke?.forEach(h=>{if(!h.month)return;const re=h.month,H=xe.get(re);if(H){H.amount+=h.amount,H.count+=1;const J=H.status.get(h.status)||0;H.status.set(h.status,J+1)}else{const J=new Map;J.set(h.status,1),xe.set(re,{amount:h.amount,status:J,count:1})}});const Ue=Array.from(xe.entries()).map(([h,re])=>{let H="Beklemede",J=0;
1return re.status.forEach((Te,Ye)=>{Te>J&&(J=Te,H=Ye)}),{month:h,amount:Math.round(re.amount),status:H,count:re.count}});n(Ue),F({totalLeads:we?.length||0,convertedLeads:Oe,totalCommission:Math.round(Se),pendingCommission:Math.round(qe)})}catch(c){console.error("Error loading partner stats:",c)}finally{se(!1)}},{data:$=[],isLoading:ue}=ee({queryKey:["partner-support-tickets",b],queryFn:async()=>{if(!b)return[];const{data:a,error:c}=await d.from("partner_support_tickets").select("*").eq("user_id",b).order("created_at",{ascending:!1});if(c)throw c;return a},enabled:!!b}),{data:oe=[],isLoading:pe}=ee({queryKey:["partner-documents"],queryFn:async()=>{const{data:a,error:c}=await d.from("partner_documents").select("*").order("created_at",{ascending:!1});if(c)throw c;return a},enabled:!!b}),{data:de=[]}=ee({queryKey:["partner-customers",b],queryFn:async()=>{if(!b)return[];const{data:a,error:c}=await d.from("customers").select("id, first_name, last_name, company_name").eq("created_by",b).order("created_at",{ascending:!1});if(c)throw c;return a||[]},enabled:!!b}),r=$e({mutationFn:async()=>{if(!b||!A)throw new Error("User not authenticated");const{error:a}=await d.from("partner_support_tickets").insert({partner_id:A,user_id:b,subject:w,message:R,priority:D,customer_id:j||null});if(a)throw a},onSuccess:()=>{B.invalidateQueries({queryKey:["partner-support-tickets"]}),y(!1),k(""),p(""),l("normal"),_(""),me.success(s==="tr"?"Destek talebiniz iletildi":"Support ticket submitted")},onError:a=>{me.error(a.message)}}),t=a=>{switch(a){case"open":return e.jsx(g,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20",children:"Açık"});case"in_progress":return e.jsx(g,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20",children:"İÅleniyor"});case"resolved":return e.jsx(g,{className:"bg-green-500/10 text-green-600 border-green-500/20",children:"Ãözüldü"});case"closed":return e.jsx(g,{className:"bg-gray-500/10 text-gray-600 border-gray-500/20",children:"Kapatıldı"});default:return e.jsx(g,{variant:"outline",children:a})}},v=a=>{switch(a){case"high":return e.jsx(g,{variant:"destructive",children:"Yüksek"});case"normal":return e.jsx(g,{variant:"secondary",children:"Normal"});case"low":return e.jsx(g,{variant:"outline",children:"DüÅük"});default:return e.jsx(g,{variant:"outline",children:a})}},C=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"-";return E?e.jsx(ws,{}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto px-4 py-8 pt-20 md:pt-24",children:[e.jsx("div",{className:"mb-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:N?.company_name||"Partner Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:s==="tr"?"SatıŠperformansınız ve hakediÅ bilgileriniz":"Your sales performance and commission information"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[N?.partner_type&&De[N.partner_type]&&(()=>{const a=De[N.partner_type],c=a.icon;return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-xl ${a.bgColor} ${a.borderColor} border`,children:[e.jsx(c,{className:`h-5 w-5 ${a.color}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:`text-sm font-semibold ${a.color}`,children:a.label}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:block",children:a.description})]})]})})(),N?.partner_level&&Be[N.partner_level]&&(()=>{const a=Be[N.partner_level],c=a.icon;return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-xl ${a.bgColor} ${a.borderColor} border`,children:[e.jsx(c,{className:`h-5 w-5 ${a.color}`}),e.jsx("span",{className:`text-sm font-semibold ${a.color}`,children:a.label})]})})()]})]})}),e.jsxs(He,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(We,{className:"grid w-full grid-cols-7 lg:w-auto lg:inline-flex",children:[e.jsxs(W,{value:"overview",className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Genel BakıÅ":"Overview"})]}),e.jsxs(W,{value:"upgrade",className:"gap-2",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Seviye Yükselt":"Upgrade"})]}),e.jsxs(W,{value:"support",className:"gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Destek":"Support"})]}),e.jsxs(W,{value:"documents",className:"gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Belgeler":"Documents"})]}),e.jsxs(W,{value:"tags",className:"gap-2",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Etiketler":"Tags"})]}),e.jsxs(W,{value:"preset-messages",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Hazır Mesajlar":"Messages"})]}),e.jsxs(W,{value:"settings",className:"gap-2",children:[e.jsx(xs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s==="tr"?"Ayarlar":"Settings"})]})]}),e.jsxs(O,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/20 to-primary/10 rounded-2xl blur opacity-0 group-hover:opacity-60 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card border border-primary/20 hover:border-primary/40 rounded-2xl overflow-hidden backdrop-blur-sm transition-shadow hover:shadow-lg group-hover:shadow-
1primary/20",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/10 via-primary/5 to-transparent opacity-50"}),e.jsx("div",{className:"relative p-4 md:p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s==="tr"?"Toplam Lead":"Total Leads"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold tracking-tight text-primary",children:T.totalLeads})]}),e.jsx("div",{className:"p-3 rounded-xl bg-primary/10",children:e.jsx(Xe,{className:"h-5 w-5 md:h-6 md:w-6 text-primary"})})]})})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-emerald-500/20 to-emerald-500/10 rounded-2xl blur opacity-0 group-hover:opacity-60 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card border border-emerald-500/20 hover:border-emerald-500/40 rounded-2xl overflow-hidden backdrop-blur-sm transition-shadow hover:shadow-lg group-hover:shadow-emerald-500/20",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent opacity-50"}),e.jsx("div",{className:"relative p-4 md:p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s==="tr"?"SatıŠYapıldı":"Sales Completed"}),e.jsx("p",{className:"text-2xl md:text-3xl font-bold tracking-tight text-emerald-600 dark:text-emerald-400",children:T.convertedLeads})]}),e.jsx("div",{className:"p-3 rounded-xl bg-emerald-500/10",children:e.jsx(ce,{className:"h-5 w-5 md:h-6 md:w-6 text-emerald-500"})})]})})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 to-blue-500/10 rounded-2xl blur opacity-0 group-hover:opacity-60 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card border border-blue-500/20 hover:border-blue-500/40 rounded-2xl overflow-hidden backdrop-blur-sm transition-shadow hover:shadow-lg group-hover:shadow-blue-500/20",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent opacity-50"}),e.jsx("div",{className:"relative p-4 md:p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s==="tr"?"Ãdenen HakediÅ":"Paid Commission"}),e.jsxs("p",{className:"text-2xl md:text-3xl font-bold tracking-tight text-blue-600 dark:text-blue-400",children:["âº",T.totalCommission.toLocaleString("tr-TR")]})]}),e.jsx("div",{className:"p-3 rounded-xl bg-blue-500/10",children:e.jsx(Le,{className:"h-5 w-5 md:h-6 md:w-6 text-blue-500"})})]})})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-orange-500/20 to-orange-500/10 rounded-2xl blur opacity-0 group-hover:opacity-60 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card border border-orange-500/20 hover:border-orange-500/40 rounded-2xl overflow-hidden backdrop-blur-sm transition-shadow hover:shadow-lg group-hover:shadow-orange-500/20",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-500/10 via-orange-500/5 to-transparent opacity-50"}),e.jsx("div",{className:"relative p-4 md:p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s==="tr"?"Bekleyen HakediÅ":"Pending Commission"}),e.jsxs("p",{className:"text-2xl md:text-3xl font-bold tracking-tight text-orange-600 dark:text-orange-400",children:["âº",T.pendingCommission.toLocaleString("tr-TR")]})]}),e.jsx("div",{className:"p-3 rounded-xl bg-orange-500/10",children:e.jsx(ne,{className:"h-5 w-5 md:h-6 md:w-6 text-orange-500"})})]})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/20 to-secondary/20 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl overflow-hidden transition-all duration-300 hover:border-primary/30",children:[e.jsx("div",{className:"px-6 py-5 border-b border-border/50 bg-gradient-to-r from-primary/5 via-trans
1parent to-secondary/5",children:e.jsx("h2",{className:"text-xl font-semibold",children:s==="tr"?"Komisyon Bilgileri":"Commission Information"})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center py-3 border-b border-border/50",children:[e.jsx("span",{className:"text-muted-foreground",children:s==="tr"?"Komisyon Oranı":"Commission Rate"}),e.jsxs("span",{className:"font-semibold text-primary",children:["%",V]})]}),e.jsxs("div",{className:"flex justify-between items-center py-3 border-b border-border/50",children:[e.jsx("span",{className:"text-muted-foreground",children:s==="tr"?"Ãdeme Dönemi":"Payment Period"}),e.jsx("span",{className:"font-semibold",children:s==="tr"?"Aylık":"Monthly"})]}),e.jsxs("div",{className:"flex justify-between items-center py-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s==="tr"?"Toplam Ãdenen":"Total Paid"}),e.jsxs("span",{className:"font-semibold text-green-500",children:["âº",T.totalCommission.toLocaleString("tr-TR")]})]})]})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/20 to-secondary/20 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl overflow-hidden transition-all duration-300 hover:border-primary/30",children:[e.jsx("div",{className:"px-6 py-5 border-b border-border/50 bg-gradient-to-r from-primary/5 via-transparent to-secondary/5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hs,{className:"h-5 w-5 text-primary"}),e.jsx("h2",{className:"text-xl font-semibold",children:s==="tr"?"Ãdeme Takvimi":"Payment Calendar"})]})}),e.jsx("div",{className:"p-6",children:i.length>0?e.jsx("div",{className:"space-y-3 max-h-[300px] overflow-y-auto",children:i.map((a,c)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/30 hover:bg-muted/50 transition-colors border border-border/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full shadow-lg ${a.status==="Ãdendi"?"bg-green-500 shadow-green-500/50":a.status==="Beklemede"?"bg-orange-500 shadow-orange-500/50":"bg-gray-500"}`}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:new Date(a.month).toLocaleDateString("tr-TR",{month:"long",year:"numeric"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.count," ödeme"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"font-semibold",children:["âº",a.amount.toLocaleString("tr-TR")]}),e.jsx(g,{variant:a.status==="Ãdendi"?"default":"secondary",className:"mt-1",children:a.status})]})]},c))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:s==="tr"?"Henüz ödeme planı bulunmamaktadır":"No payment schedule available yet"})})]})]})]})]}),e.jsx(O,{value:"upgrade",className:"space-y-6",children:e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/20 to-secondary/20 rounded-2xl blur opacity-50"}),e.jsxs(Y,{className:"relative bg-card/80 backdrop-blur-sm border border-border/50",children:[e.jsxs(I,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-5 w-5 text-primary"}),s==="tr"?"Partner Seviyeleri":"Partner Levels"]}),e.jsx(te,{children:s==="tr"?"Farklı partner tiplerini ve seviyelerini inceleyin, üst seviyeye baÅvurun":"Explore different partner types and levels, apply for upgrades"})]}),e.jsx(X,{children:A&&b&&e.jsx(ks,{currentType:N?.partner_type||null,currentLevel:N?.partner_level||null,partnerId:A,userId:b})})]})]})}),e.jsxs(O,{value:"support",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:s==="tr"?"Destek Talepleri":"Support Tickets"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s==="tr"?"Merkeze destek talebi gönderin":"Submit support requests to headquarters"})]}),e.jsxs(es,{open:u,onOpenChange:y,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),s==="tr"?"Yeni Talep":"New Ticket"]})}),e.jsxs(as,{children:[e.jsxs(rs,{children:[e.jsx(ts,{children:s==="tr"?"Yeni Destek Talebi":"New Support Ticket"}),e.jsx(is,{children:s==="tr"?"Talebinizi aÅaÄıdaki formu doldurarak iletin":"Submit your request by filling out the form below"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"subject",children:s==="tr"?"Konu":"Subject"}),e.jsx(P,{id:"subject",value:w,onChange:a=>k(a.target.value),placeholder:s==="tr"?"Talebinizin konusu":"Subject of your request"})]}),de.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"customer",children:s==="tr"?"MüÅteri (İsteÄe BaÄlı)":"Customer (Optional)"}),e.jsxs(ge,{value:j,onValueChange:_,children:[e.jsx(be,{children:e.jsx(je,{placeholder:s==="tr"?"MüÅteri seçin...":"Select customer..."})}),e.jsxs(fe,{children:[e.jsx(Z,{value:"",children:s==="tr"?"Genel Talep":"General Request"}),de.map(a=>e.jsxs(Z,{value:a.id,children:[a.first_name," ",a.last_name,a.company_name&&` - ${a.company_name}`]},a.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"priority",children:s==="tr"?"Ãncelik":"Priority"}),e.jsxs(ge,{value:D,onValueChange:l,children:[e.jsx(be,{children:e.jsx(je,{})}),e.jsxs(fe,{children:[e.jsx(Z,{value:"low",children:s==="tr"?"DüÅük":"Low"}),e.jsx(Z,{value:"normal",children:"Normal"}),e.jsx(Z,{value:"high",children:s==="tr"?"Yüksek":"High"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"message",children:s==="tr"?"Mesaj":"Message"}),e.jsx(ve,{id:"message",value:R,onChange:a=>p(a.target.value),placeholder:s==="tr"?"Talebinizi detaylı açıklayın":"Describe your request in detail",rows:4})]})]}),e.jsxs(ls,{children:[e.jsx(L,{variant:"outline",onClick:()=>y(!1),children:s==="tr"?"İptal":"Cancel"}),e.jsxs(L,{onClick:()=>r.mutate(),disabled:!w||!R||r.isPending,children:[r.isPending&&e.jsx(U,{className:"h-4 w-4 mr-2 animate-spin"}),s==="tr"?"Gönder":"Submit"]})]})]})]})]}),ue?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(U,{className:"h-6 w-6 animate-spin text-primary"})}):$.length===0?e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-8 text-center",children:[e.jsx(Me,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:s==="tr"?"Henüz destek talebiniz yok":"No support tickets yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s==="tr"?"Yeni bir destek talebi oluÅturarak merkeze ulaÅabilirsiniz":"Create a new support ticket to reach headquarters"}),e.jsxs(L,{onClick:()=>y(!0),children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),s==="tr"?"İlk Talebinizi OluÅturun":"Create Your First Ticket"]})]})]}):e.jsx("div",{className:"space-y-4",children:$.map(a=>e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-4 transition-all duration-300 hover:border-primary/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold",children:a.subject}),t(a.status),v(a.priority)]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:a.message}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(a.created_at).toLocaleDateString("tr-TR",{day:"2-digit",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"})})]}),a.admin_response&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-xl max-w-xs border border-border/30",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Merkez yanıtı:"}),e.jsx("p",{className:"text-sm",children:a.admin_response})]})]})})]},a.id))})]}),e.jsxs(O,{value:"documents",className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:s==="tr"?"Belge Deposu":"Document Repository"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s==="tr"?"Merkez tarafından paylaÅılan belgeler":"Documents shared by headquarters"})]}),pe?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(U,{className:"h-6 w-6 animate-spin text-primary"})}):oe.length===0?e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsxs("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-8 text-center",children:[e.jsx(le,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:s==="tr"?"Henüz belge yok":"No documents yet"}),e.jsx("p",{className:"text-muted-foreground",children:s==="tr"?"Merkez tarafından paylaÅılan belgeler burada görünecek":"Documents shared by headquarters will appear here"})]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:oe.map(a=>e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-4 transition-all duration-300 hover:border-primary/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 rounded-xl bg-gradient-to-br from-primary/20 to-primary/10 text-primary",children:e.jsx(le,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:a.title}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:a.description}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[e.jsx(g,{variant:"outline",children:a.category}),e.jsx("span",{children:C(a.file_size)})]}),e.jsxs(L,{variant:"outline",size:"sm",className:"w-full",onClick:()=>window.open(a.file_url,"_blank"),children:[e.jsx(gs,{className:"h-4 w-4 mr-2"}),s==="tr"?"İndir":"Download"]})]})]})})]},a.id))})]}),e.jsx(O,{value:"tags",className:"space-y-6",children:e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-6",children:e.jsx(os,{})})]})}),e.jsx(O,{value:"preset-messages",className:"space-y-6",children:e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"relative bg-card/80 backdrop-blur-sm border border-border/50 rounded-2xl p-6",children:e.jsx(ds,{})})]})}),e.jsx(O,{value:"settings",className:"space-y-6",children:e.jsx(_s,{})})]})]})})};export{ua 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.