import{am as I,d as M,L as N,u as X,r as U,e as z,Y,a as l,aM as $,z as j,$ as A,o as p,c as m,f as n,w as i,g as B,y as S,F as P,v as E,x as K,t as Q,aL as C,m as W,n as Z,a9 as ee,bx as se,C as ae,G as te,H as oe,_ as re,__tla as le}from"./index-8dc1e40a.js";import ne,{__tla as ie}from"./LoginFormTitle-67e9eb88.js";import{u as ce,L as H,__tla as ue}from"./useLogin-88b980a8.js";let T,pe=Promise.all([(()=>{try{return le}catch{}})(),(()=>{try{return ie}catch{}})(),(()=>{try{return ue}catch{}})()]).then(async()=>{let k,L,O;k={class:"form-cont"},L={key:0},O={key:1},T=re(M({name:"SSOLogin",__name:"SSOLogin",setup(de){const c=N(),{currentRoute:V}=X(),{getLoginState:R,setLoginState:D}=ce(),x=U({name:"",logo:""}),s=z({responseType:"",clientId:"",redirectUri:"",state:"",scopes:[]}),F=Y(()=>l(R)===H.SSO),u=z({scopes:[]}),d=U(!1),G=async()=>{if(c.query.client_id===void 0)return;if(s.responseType=c.query.response_type,s.clientId=c.query.client_id,s.redirectUri=c.query.redirect_uri,s.state=c.query.state,c.query.scope&&(s.scopes=c.query.scope.split(" ")),s.scopes.length>0){const e=await q(!0,s.scopes,[]);if(e)return void(location.href=e)}const t=await(a=s.clientId,I.get({url:"/system/oauth2/authorize?clientId="+a}));var a;let o;if(x.value=t.client,s.scopes.length>0){o=[];for(const e of t.scopes)s.scopes.indexOf(e.key)>=0&&o.push(e)}else{o=t.scopes;for(const e of o)s.scopes.push(e.key)}for(const e of o)e.value&&u.scopes.push(e.key)},b=async t=>{let a,o;t?(a=u.scopes,o=s.scopes.filter(e=>a.indexOf(e)===-1)):(a=[],o=s.scopes),d.value=!0;try{const e=await q(!1,a,o);if(!e)return;location.href=e}finally{d.value=!1}},q=(t,a,o)=>((e,y,g,f,_,h,r)=>{const v={};for(const w of h)v[w]=!0;for(const w of r)v[w]=!1;return I.post({url:"/system/oauth2/authorize",headers:{"Content-type":"application/x-www-form-urlencoded"},params:{response_type:e,client_id:y,redirect_uri:g,state:f,auto_approve:_,scope:JSON.stringify(v)}})})(s.responseType,s.clientId,s.redirectUri,s.state,t,a,o),J=t=>{switch(t){case"user.read":return"\u8BBF\u95EE\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";case"user.write":return"\u4FEE\u6539\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";default:return t}};return $(()=>V.value,t=>{t.name==="SSOLogin"&&(D(H.SSO),G())},{immediate:!0}),(t,a)=>{const o=W,e=Z,y=ee,g=se,f=ae,_=te,h=oe;return j((p(),m("div",k,[n(ne,{style:{width:"100%"}}),n(e,{class:"form",style:{float:"none"},value:"uname"},{default:i(()=>[n(o,{label:l(x).name,name:"uname"},null,8,["label"])]),_:1}),B("div",null,[n(h,{model:l(u),class:"login-form"},{default:i(()=>[S(" \u6B64\u7B2C\u4E09\u65B9\u5E94\u7528\u8BF7\u6C42\u83B7\u5F97\u4EE5\u4E0B\u6743\u9650\uFF1A "),n(f,{prop:"scopes"},{default:i(()=>[n(g,{modelValue:l(u).scopes,"onUpdate:modelValue":a[0]||(a[0]=r=>l(u).scopes=r)},{default:i(()=>[(p(!0),m(P,null,E(l(s).scopes,r=>(p(),K(y,{key:r,label:r,style:{display:"block","margin-bottom":"-10px"}},{default:i(()=>[S(Q(J(r)),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1}),n(f,{class:"w-1/1"},{default:i(()=>[n(_,{loading:l(d),class:"w-6/10",type:"primary",onClick:a[1]||(a[1]=C(r=>b(!0),["prevent"]))},{default:i(()=>[l(d)?(p(),m("span",O,"\u6388 \u6743 \u4E2D...")):(p(),m("span",L,"\u540C\u610F\u6388\u6743"))]),_:1},8,["loading"]),n(_,{class:"w-3/10",onClick:a[2]||(a[2]=C(r=>b(!1),["prevent"]))},{default:i(()=>[S("\u62D2\u7EDD")]),_:1})]),_:1})]),_:1},8,["model"])])],512)),[[A,l(F)]])}}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/Login/components/SSOLogin.vue"]])});export{pe as __tla,T as default};
