import{_ as F}from"./nxDA0OVn.js";import{B as N,e as R,z as k,r as _,c as y,o as C,b as M,a as t,s as z,C as w,k as r,m as u}from"./CGJ-iGzd.js";import{C as v}from"./C46f8uP2.js";import{_ as V}from"./DlAUqK2U.js";const A={class:"p-4 text-xs"},q={class:"max-w-sm mx-auto",dir:"rtl"},I={class:"mt-4"},S={class:"mt-4"},T={class:"mt-4"},E={class:"grid grid-cols-2 gap-2 mt-4"},H=["src"],L=["src"],P={class:"mt-4"},W={__name:"information",setup(U){const n=N(),{$CustomAlert:l}=R();k.defaults.headers.common.Authorization=n.token;const m=_(!1),b=_(null),s=_({});function f(){m.value||(m.value=!0,k.patch(`${u().public.BaseUrl}users/edit`,s.value).then(()=>{m.value=!1,l("با موفقیت ثبت شد",4),n.setMyTitle(s.value.first_name+" "+s.value.last_name)}))}function B(){const o=new FormData;o.append("image",b.value),o.append("category",0),k.patch(u().public.BaseUrl+"users/set_image",o).then(e=>{s.value.public_profile=e.data.image,l("با موفقیت ثبت شد",4),n.setMyImage(e.data.image)})}const $=async o=>{const e=o.target.files[0];if(!e)return;const i=e.name.split(".").pop().toLowerCase();try{const d=await new Promise((c,g)=>{new v(e,{quality:.6,maxWidth:1024,maxHeight:1024,success(a){c(a)},error(a){g(a)}})}),p=new File([d],`compressed.${i}`,{type:d.type,lastModified:Date.now()});if(p.size>3e5){const c=await new Promise((a,D)=>{new v(p,{quality:.4,maxWidth:800,maxHeight:800,success(x){a(x)},error(x){D(x)}})}),g=new File([c],`compressed.${i}`,{type:c.type,lastModified:Date.now()});b.value=g}else b.value=p;B()}catch(d){console.error("Error:",d)}};return(o,e)=>{const h=F;return C(),y("div",A,[M(h,{title:"ویرایش اطلاعات"}),t("div",q,[t("div",I,[e[3]||(e[3]=t("label",{for:"first_name",class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"نام",-1)),z(t("input",{type:"text",id:"first_name","onUpdate:modelValue":e[0]||(e[0]=i=>r(s).first_name=i),onChange:f,class:"bg-zinc-50 border border-zinc-300 text-zinc-950 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-1 dark:bg-zinc-700 dark:border-zinc-600 dark:placeholder-zinc-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",required:""},null,544),[[w,r(s).first_name]])]),t("div",S,[e[4]||(e[4]=t("label",{for:"last_name",class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"نام خانوادگی",-1)),z(t("input",{type:"text",id:"last_name","onUpdate:modelValue":e[1]||(e[1]=i=>r(s).last_name=i),onChange:f,class:"bg-zinc-50 border border-zinc-300 text-zinc-950 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-1 dark:bg-zinc-700 dark:border-zinc-600 dark:placeholder-zinc-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"},null,544),[[w,r(s).last_name]])]),t("div",T,[e[5]||(e[5]=t("label",{for:"abstract",class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"شرح مختصر",-1)),z(t("input",{type:"text",id:"abstract","onUpdate:modelValue":e[2]||(e[2]=i=>r(s).abstract=i),onChange:f,class:"bg-zinc-50 border border-zinc-300 text-zinc-950 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-1 dark:bg-zinc-700 dark:border-zinc-600 dark:placeholder-zinc-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"},null,544),[[w,r(s).abstract]])]),t("div",E,[t("div",null,[e[6]||(e[6]=t("label",{for:"public_image",class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"عکس عمومی",-1)),t("img",{id:"public_image",src:("useRuntimeConfig"in o?o.useRuntimeConfig:r(u))().public.MediaUrl+r(s).public_profile,class:"rounded-full size-20",alt:""},null,8,H)]),t("div",null,[e[7]||(e[7]=t("label",{for:"private_image",class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"عکس خصوصی",-1)),t("img",{id:"private_image",src:("useRuntimeConfig"in o?o.useRuntimeConfig:r(u))().public.MediaUrl+r(s).public_profile,class:"rounded-full size-20",alt:""},null,8,L)])]),t("div",P,[e[8]||(e[8]=t("label",{class:"block mb-2 text-xs font-medium text-zinc-950 dark:text-white"},"انتخاب عکس",-1)),t("input",{type:"file",accept:"image/*",onChange:$,class:"block mb-2 p-1 w-full text-zinc-950 bg-zinc-50 rounded-lg border border-zinc-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-zinc-700 dark:border-zinc-600 dark:placeholder-zinc-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"},null,32)])])])}}},j={},G={class:""};function J(U,n){const l=W;return C(),y("div",G,[M(l)])}const Y=V(j,[["render",J]]);export{Y as default};
