import{d as X,T as Z,y as ss,h as p,K as E,A as es,o as as,z as A,c as h,p as t,C as k,m as i,s as N,V as q,D as ts,O as os,v as $,b as c,I as o,f as H,n as w,e as s,t as u,S as ns,g as L,B as is,F as ls,i as D,E as rs,_ as ds}from"./index-BVYgSbCy.js";import{A as us}from"./AppPullRefresh-BouePViT.js";import{P as _s}from"./PageBar-B5feQjHI.js";import{R as hs}from"./RateStrip-t7odlsZa.js";import{p as cs}from"./filters-DRthpnLh.js";import{D as j}from"./index-DYgGqo2L.js";import"./KeyCode-Czr01NPp.js";import"./classCallCheck--kJem1-w.js";import"./raf-nDFcuFT6.js";const vs={class:"dash"},ps={key:1,class:"dash__exitSpacer","aria-hidden":"true"},fs={class:"dash__heroHead"},bs={class:"dash__heroIdentity"},ms={class:"dash__heroName"},ys={class:"dash__heroMobile"},ws={class:"dash__heroBalance"},gs={class:"dash__heroFigure"},xs={class:"dash__heroNum"},ks={class:"dash__heroDebt"},Cs={class:"dash__heroHead"},Is={class:"dash__heroIdentity"},zs={class:"dash__heroMobile"},Ss={class:"dash__heroPending"},$s=["alt"],Ls={class:"dash__bannerIcon","aria-hidden":"true"},Ds={class:"dash__bannerText"},Ts={class:"dash__bannerChevron","aria-hidden":"true"},Bs={class:"dash__bannerIcon","aria-hidden":"true"},Es={class:"dash__bannerText"},Ns={class:"dash__bannerChevron","aria-hidden":"true"},Fs={class:"dash__rowIcon","aria-hidden":"true"},Ps={class:"dash__rowChevron","aria-hidden":"true"},Rs={class:"dash__rowIcon","aria-hidden":"true"},Vs={class:"dash__rowChevron","aria-hidden":"true"},Ms={class:"dash__rowIcon","aria-hidden":"true"},Os={class:"dash__rowChevron","aria-hidden":"true"},Us={class:"dash__rowIcon","aria-hidden":"true"},As={class:"dash__rowChevron","aria-hidden":"true"},qs={class:"dash__rowIcon","aria-hidden":"true"},Hs={class:"dash__rowChevron","aria-hidden":"true"},js={class:"dash__rowIcon","aria-hidden":"true"},Gs={class:"dash__rowChevron","aria-hidden":"true"},Ks={class:"dash__rowIcon","aria-hidden":"true"},Ys={class:"dash__rowChevron","aria-hidden":"true"},Js={class:"dash__rowIcon","aria-hidden":"true"},Qs={class:"dash__rowChevron","aria-hidden":"true"},Ws={class:"dash__rowIcon","aria-hidden":"true"},Xs={class:"dash__rowChevron","aria-hidden":"true"},Zs={class:"dash__rowIcon","aria-hidden":"true"},se={class:"dash__rowChevron","aria-hidden":"true"},ee={class:"dash__choice"},ae={class:"dash__choice"},te=70,oe=X({__name:"DashboardView",setup(ne){const r=ts(),l=Z(),g=ss(),v=p(g.peek(E.profile)??null),F=p(g.peek(E.goldPrice)??null),C=p(g.peek(E.customButton)??null),f=p([]),T=p(!1),x=p(!1),G=D(()=>{const a=C.value;return!!(a!=null&&a.enabled&&a.title.trim()&&a.link.trim())});function K(){var e,y;const a=(y=(e=C.value)==null?void 0:e.link)==null?void 0:y.trim();a&&window.open(a,"_blank","noopener,noreferrer")}const P=D(()=>v.value?parseFloat(v.value.goldDebtGrams)>0:!1),Y=D(()=>v.value?Math.abs(parseFloat(v.value.goldDebtGrams)):0),J=D(()=>{const a=Y.value;return Number.isFinite(a)?a.toLocaleString("fa-IR",{maximumFractionDigits:3}):"۰"}),b=os({notify:!1,loginNotify:!1});function _(a){if(!l.isLoggedIn){b.loginNotify=!0;return}a===0&&r.push({name:"ordersList"}),a===1&&r.push({name:"transactionsList"}),a===2&&r.push({name:"profileData"}),a===3&&r.push({name:"favoritesList"}),a===4&&r.push({name:"ChildOrder"}),a===5&&r.push({name:"customerChoice"}),a===6&&r.push({name:"report"}),a===7&&(I.value=!0),a===8&&(z.value=!0)}const I=p(!1);function R(a){I.value=!1,r.push({name:a})}const z=p(!1);function V(a){z.value=!1;const e=a==="surveyFeed"?"/surveys":"/surveys/mine";A(()=>{r.push(e).catch(()=>{window.location.assign(e)})})}async function Q(){b.notify=!1;try{await $.endSharedSession()}catch{}let a=null;try{a=(await $.ssoLogoutUrl()).logout_url}catch{a=null}if(l.logout(),sessionStorage.removeItem("gb_iam_sso_checked"),a){window.location.assign(a);return}r.push({name:"home"})}async function S(){x.value=!1;const[a,e,y]=await Promise.allSettled([l.isLoggedIn?g.me({force:!0}):Promise.resolve(null),g.goldPrice({force:!0}),g.customButton({force:!0})]);if(a.status==="fulfilled"?(v.value=a.value,x.value=!1):(x.value=l.isLoggedIn&&!v.value,console.log(a.reason)),F.value=e.status==="fulfilled"?e.value:null,y.status==="fulfilled"&&(C.value=y.value),l.isLoggedIn)try{const n=await $.listOpenProductSurveys();f.value=n.majorityHits??n.rows.filter(d=>d.reachedMajority)}catch{f.value=[]}else f.value=[]}async function W(){try{await S()}finally{T.value=!1}}async function M(){if(l.isLoggedIn)try{const a=await $.getExpertIdentity();l.setSalesExpert(a.isSalesExpert)}catch{}}let O=!1;es(()=>{O&&(S(),M()),O=!0});let U=!1;const B=p(U);function m(a){return{"--reveal-delay":`${a*te}ms`}}return as(async()=>{M(),await S(),!B.value&&(await A(),requestAnimationFrame(()=>{B.value=!0,U=!0}))}),(a,e)=>{const y=rs("container");return c(),h("div",vs,[t(_s,{title:"میز کار","back-to":"home"},{trailing:k(()=>[i(l).isLoggedIn?(c(),h("button",{key:0,type:"button",class:"dash__exit","aria-label":"خروج",onClick:e[0]||(e[0]=n=>b.notify=!0)},[t(o,{icon:"vuesax-linear:logout",size:"18"})])):(c(),h("span",ps))]),_:1}),t(us,{modelValue:T.value,"onUpdate:modelValue":e[13]||(e[13]=n=>T.value=n),onRefresh:W},{default:k(()=>[t(y,{class:H(["dash__body",{"is-revealed":B.value}])},{default:k(()=>{var n;return[i(l).isLoggedIn&&v.value?(c(),h("section",{key:0,class:"dash__hero dash__reveal",style:w(m(0))},[s("header",fs,[s("div",bs,[s("span",ms,u(v.value.fullName),1),s("span",ys,u(i(l).mobile),1)]),s("span",{class:H(["dash__heroSeal",P.value?"is-debtor":"is-creditor"])},u(P.value?"بدهکار":"بستانکار"),3)]),s("div",ws,[s("div",gs,[s("span",xs,u(J.value),1),e[23]||(e[23]=s("span",{class:"dash__heroUnit"},"گرم",-1))]),e[24]||(e[24]=s("span",{class:"dash__heroEyebrow"},"موجودی طلا",-1))]),s("div",ks,[e[26]||(e[26]=s("span",{class:"dash__heroDebtLabel"},"بدهی ریالی",-1)),s("b",null,[ns(u(i(cs)(v.value.fiatDebtRial))+" ",1),e[25]||(e[25]=s("i",null,"ریال",-1))])])],4)):i(l).isLoggedIn?(c(),h("section",{key:1,class:"dash__hero dash__hero--pending dash__reveal",style:w(m(0))},[s("header",Cs,[s("div",Is,[e[27]||(e[27]=s("span",{class:"dash__heroName"},"حساب شما",-1)),s("span",zs,u(i(l).mobile),1)])]),s("p",Ss,u(x.value?"موجودی الان در دسترس نیست. دوباره تلاش کنید.":"در حال دریافت موجودی…"),1),x.value?(c(),h("button",{key:0,type:"button",class:"dash__heroRetry",onClick:S}," تلاش دوباره ")):L("",!0)],4)):(c(),h("section",{key:2,class:"dash__hero dash__invite dash__reveal",style:w(m(0))},[s("img",{class:"dash__inviteLogo",src:is,alt:i(N).name},null,8,$s),s("button",{type:"button",class:"dash__inviteCta",onClick:e[1]||(e[1]=d=>i(r).push({name:"login"}))}," ورود / ثبت‌نام ")],4)),G.value?(c(),h("button",{key:3,type:"button",class:"dash__banner dash__reveal",style:w(m(1)),onClick:K},[s("span",Ls,[t(o,{icon:"vuesax-linear:link-2",size:"18"})]),s("span",Ds,[s("b",null,u(C.value.title.trim()),1)]),s("span",Ts,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])],4)):L("",!0),i(l).isLoggedIn&&f.value.length?(c(),h("button",{key:4,type:"button",class:"dash__banner dash__banner--survey dash__reveal",style:w(m(1)),onClick:e[2]||(e[2]=d=>_(8))},[s("span",Bs,[t(o,{icon:"vuesax-linear:like-1",size:"18"})]),s("span",Es,[s("b",null,u(f.value.length)+" طرح به حد اکثریت رسید",1),s("small",null,u(((n=f.value[0])==null?void 0:n.title)||"بدون عنوان")+u(f.value.length>1?" و …":""),1)]),s("span",Ns,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])],4)):L("",!0),s("section",{class:"dash__rows dash__reveal",style:w(m(1))},[s("button",{type:"button",class:"dash__row",onClick:e[3]||(e[3]=d=>_(0))},[s("span",Fs,[t(o,{icon:"vuesax-linear:box",size:"18"})]),e[28]||(e[28]=s("span",{class:"dash__rowText"},[s("b",null,"سفارشات")],-1)),s("span",Ps,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[4]||(e[4]=d=>_(1))},[s("span",Rs,[t(o,{icon:"vuesax-linear:receipt-text",size:"18"})]),e[29]||(e[29]=s("span",{class:"dash__rowText"},[s("b",null,"اسناد")],-1)),s("span",Vs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[5]||(e[5]=d=>_(2))},[s("span",Ms,[t(o,{icon:"vuesax-linear:user",size:"18"})]),e[30]||(e[30]=s("span",{class:"dash__rowText"},[s("b",null,"پروفایل")],-1)),s("span",Os,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[6]||(e[6]=d=>_(3))},[s("span",Us,[t(o,{icon:"vuesax-linear:heart",size:"18"})]),e[31]||(e[31]=s("span",{class:"dash__rowText"},[s("b",null,"علاقمندی")],-1)),s("span",As,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[7]||(e[7]=d=>_(7))},[s("span",qs,[t(o,{icon:"vuesax-linear:3d-cube-scan",size:"18"})]),e[32]||(e[32]=s("span",{class:"dash__rowText"},[s("b",null,"سفارش ساخت")],-1)),s("span",Hs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[8]||(e[8]=d=>_(8))},[s("span",js,[t(o,{icon:"vuesax-linear:like-1",size:"18"})]),e[33]||(e[33]=s("span",{class:"dash__rowText"},[s("b",null,"نظرسنجی طرح")],-1)),s("span",Gs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[9]||(e[9]=d=>_(6))},[s("span",Ks,[t(o,{icon:"vuesax-linear:chart-2",size:"18"})]),e[34]||(e[34]=s("span",{class:"dash__rowText"},[s("b",null,"گزارش")],-1)),s("span",Ys,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[10]||(e[10]=d=>i(r).push({name:"appearanceSettings"}))},[s("span",Js,[t(o,{icon:"vuesax-linear:brush",size:"18"})]),e[35]||(e[35]=s("span",{class:"dash__rowText"},[s("b",null,"تنظیمات ظاهری")],-1)),s("span",Qs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),i(l).isSalesExpert?(c(),h(ls,{key:0},[s("button",{type:"button",class:"dash__row",onClick:e[11]||(e[11]=d=>_(4))},[s("span",Ws,[t(o,{icon:"vuesax-linear:box-tick",size:"18"})]),e[36]||(e[36]=s("span",{class:"dash__rowText"},[s("b",null,"سفارش مشتریان")],-1)),s("span",Xs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[12]||(e[12]=d=>_(5))},[s("span",Zs,[t(o,{icon:"vuesax-linear:profile-2user",size:"18"})]),e[37]||(e[37]=s("span",{class:"dash__rowText"},[s("b",null,"مشتریان من")],-1)),s("span",se,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])])],64)):L("",!0)],4),t(hs,{quote:F.value,class:"dash__rate dash__reveal",style:w(m(2))},null,8,["quote","style"])]}),_:1},8,["class"])]),_:1},8,["modelValue"]),t(q,{show:b.notify,"onUpdate:show":e[14]||(e[14]=n=>b.notify=n),art:"logout",title:"آیا می خواهید از برنامه خارج شوید؟",description:`برای استفاده دوباره از امکانات ${i(N).name}، باید دوباره وارد حساب کاربری خود شوید.`,"confirm-text":"بله","cancel-text":"بی خیال",onConfirm:Q},null,8,["show","description"]),t(q,{show:b.loginNotify,"onUpdate:show":e[15]||(e[15]=n=>b.loginNotify=n),art:"login",title:"ابتدا وارد حساب کاربری شوید",description:`برای دسترسی به تمامی امکانات نرم افزار ${i(N).name}، گزینه ورود/ثبت نام را لمس کنید و در صورت نداشتن حساب کاربری، ثبت نام نمایید.`,"confirm-text":"ورود/ثبت نام","cancel-text":"بیخیال",onConfirm:e[16]||(e[16]=n=>i(r).push({name:"login"}))},null,8,["show","description"]),t(i(j),{visible:I.value,"onUpdate:visible":e[19]||(e[19]=n=>I.value=n),placement:"bottom",height:"auto",closable:!1,"body-style":{padding:"0"}},{default:k(()=>[s("div",ee,[s("button",{type:"button",class:"dash__choiceBtn",onClick:e[17]||(e[17]=n=>R("makeOrderList"))},"ثبت سفارش"),s("button",{type:"button",class:"dash__choiceBtn is-quiet",onClick:e[18]||(e[18]=n=>R("makeOrderStatus"))},"مشاهده سفارش")])]),_:1},8,["visible"]),t(i(j),{visible:z.value,"onUpdate:visible":e[22]||(e[22]=n=>z.value=n),placement:"bottom",height:"auto",closable:!1,"body-style":{padding:"0"}},{default:k(()=>[s("div",ae,[s("button",{type:"button",class:"dash__choiceBtn",onClick:e[20]||(e[20]=n=>V("surveyFeed"))},"رأی به طرح‌ها"),s("button",{type:"button",class:"dash__choiceBtn is-quiet",onClick:e[21]||(e[21]=n=>V("surveyMine"))},"ثبت / طرح‌های من")])]),_:1},8,["visible"])])}}}),pe=ds(oe,[["__scopeId","data-v-344cd3e9"]]);export{pe as default};