const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dingtalkQrCode-DRgoeeOg.js","./logo_dingtalk-CyDPr22R.js","./admin-DgPvPHD7.js","./admin-Bbyck9zg.css","./dingtalkQrCode-CulsC8mV.css","./larkQrCode-D2VowKyL.js","./logo_lark-DULIW3z6.js","./wecomQrCode-DGEndxFr.js","./wecomQrCode-yBUt_167.css"])))=>i.map(i=>d[i]); import{ay as ee,aB as d,aA as j,az as ue,aQ as Y,aD as w,aE as n,aF as v,aS as ge,aG as m,aH as y,aK as de,aJ as E,aC as L,b6 as pe,bD as he,d9 as ye,cf as me,aW as b,aI as i,cF as we,aY as _e,cq as ke,cr as be,b1 as D,aX as Z,cs as W,ct as Ce,aO as Le,bF as G,b7 as xe,b8 as Ae,b2 as C,c$ as ce,cu as De,bc as Oe,da as ie,c0 as $e,cw as qe,c1 as Ie}from"./admin-DgPvPHD7.js";import{_ as Re,a as Ve,f as X,d as Pe}from"./index-s2VnG6qr.js";const Se=ee({__name:"password",setup(R){const g=d(),{chatUser:V}=j(),t=d(!1),T=ue(),M=Y(),P=()=>V.passwordAuthentication(f.value.password).then($=>{T.push({name:"chat",params:{accessToken:V.accessToken},query:M.query})}),O=($,x,o)=>{x===""?o(new Error(L("chat.passwordValidator.errorMessage1"))):P().catch(()=>{o(new Error(L("chat.passwordValidator.errorMessage2")))})},S=()=>{g.value.validate()},p={password:[{required:!0,validator:O,trigger:"manual"}]},f=d({password:""});return($,x)=>{const o=w("el-input"),K=w("el-form-item"),N=w("el-button"),B=w("el-form");return n(),v(B,{ref_key:"FormRef",ref:g,model:f.value,onSubmit:ge(S,["prevent"])},{default:m(()=>[y(K,{prop:"value",rules:p.password},{default:m(()=>[y(o,{"show-password":"",modelValue:f.value.password,"onUpdate:modelValue":x[0]||(x[0]=F=>f.value.password=F)},null,8,["modelValue"])]),_:1},8,["rules"]),y(N,{class:"w-full mt-8",type:"primary",onClick:S,loading:t.value},{default:m(()=>[de(E($.$t("common.confirm")),1)]),_:1},8,["loading"])]),_:1},8,["model"])}}}),Ee=768,Te=()=>{const{common:R}=j(),g=()=>{var t;return((t=document.body)==null?void 0:t.getBoundingClientRect()).width-1{he(()=>{g()&&R.toggleDevice(ye.Mobile)})})},Me={},Ue={class:"login-warp flex-center"},Fe={class:"login-container w-full h-full"},Qe={class:"flex-center w-full h-full"};function Be(R,g){return n(),b("div",Ue,[i("div",Fe,[i("div",Qe,[we(R.$slots,"default",{},void 0,!0)])])])}const ze=me(Me,[["render",Be],["__scopeId","data-v-e5a94abc"]]),je={key:0,class:"text-center"},Ke=ee({__name:"QrCodeTab",props:{tabs:{}},setup(R){const{chatUser:g}=j(),V=R,t=d(""),T=d([]),M=d({app_key:"",app_secret:""});async function P(){try{return await g.getQrSource()}catch{return[]}}pe(async()=>{V.tabs.length>0&&(t.value=V.tabs[0].key),T.value=await P(),O(t.value)});const O=p=>{const f=T.value.find($=>$.auth_type===p);f&&f.config&&(M.value=f.config)},S=p=>{t.value=p,O(p)};return(p,f)=>{const $=w("el-tab-pane"),x=w("el-tabs");return n(),v(x,{modelValue:t.value,"onUpdate:modelValue":f[0]||(f[0]=o=>t.value=o),onTabChange:S},{default:m(()=>[(n(!0),b(Z,null,_e(R.tabs,o=>(n(),v($,{key:o.key,label:o.value,name:o.key},{default:m(()=>[o.key===t.value?(n(),b("div",je,[(n(),v(ke(be(()=>Re(Object.assign({"./dingtalkQrCode.vue":()=>W(()=>import("./dingtalkQrCode-DRgoeeOg.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url),"./larkQrCode.vue":()=>W(()=>import("./larkQrCode-D2VowKyL.js"),__vite__mapDeps([5,6,2,3]),import.meta.url),"./wecomQrCode.vue":()=>W(()=>import("./wecomQrCode-DGEndxFr.js"),__vite__mapDeps([7,2,3,8]),import.meta.url)}),`./${o.key}QrCode.vue`,2))),{config:M.value},null,8,["config"]))])):D("",!0)]),_:2},1032,["label","name"]))),128))]),_:1},8,["modelValue"])}}}),Ne={class:"user-login-container p-24"},He={key:0,class:"flex-center",style:{"margin-bottom":"32px"}},Je=["src"],We={key:1,class:"user-login__header"},Ge={class:"flex-between"},Xe={class:"flex align-center"},Ye={class:"mr-12 ml-16 flex"},Ze=["src"],et=["title"],tt={class:"mb-24"},at={key:0,class:"mb-24"},ot={key:1},st={class:"mb-24"},lt={class:"mb-24"},nt={key:0,class:"mb-24"},rt={class:"flex-between w-full"},ct=["src"],it={key:2},ut={key:3,class:"login-gradient-divider lighter mt-24"},dt={class:"text-center mt-16"},pt=ee({__name:"index",setup(R){Te();const g=ue(),{theme:V,chatUser:t,common:T}=j(),{locale:M}=Ce({useScope:"global"}),P=d(!1),O=Y(),S=d(""),{params:{accessToken:p},query:{mode:f}}=O,$=Le(()=>{console.log(T.isMobile());let e="";return!f||f==="pc"?e=T.isMobile()?"mobile":"pc":e=f,console.log(e),e==="pc"}),x=d(),o=d({username:"",password:"",captcha:""}),K=d(1),N=d({username:[{required:!0,message:L("views.login.loginForm.username.requiredMessage"),trigger:"blur"}],password:[{required:!0,message:L("views.login.loginForm.password.requiredMessage"),trigger:"blur"}],captcha:[{required:!1,message:L("views.login.loginForm.captcha.requiredMessage"),trigger:"blur"}]}),B=()=>{var e;(e=x.value)==null||e.validate().then(()=>{var a;if(_.value==="LDAP")t.ldapLogin(o.value).then(s=>{g.push({name:"chat",params:{accessToken:t.accessToken},query:O.query})});else{const s=X.pki.publicKeyFromPem((a=t==null?void 0:t.chat_profile)==null?void 0:a.rasKey),u=JSON.stringify(o.value),q=X.util.encodeUtf8(u),h=s.encrypt(q,"RSAES-PKCS1-V1_5"),r=X.util.encode64(h);t.login({encryptedData:r,username:o.value.username}).then(A=>{g.push({name:"chat",params:{accessToken:t.accessToken},query:O.query})}).catch(()=>{F(o.value.username)})}})};function F(e){ie.getCaptcha(e,p).then(a=>{S.value=a.data.captcha})}G(()=>{M.value=t.getLanguage()});const c=d([]),H=d([""]),_=d(""),U=d(!1),te=d([]);function fe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const a=Math.random()*16|0;return(e==="x"?a:a&3|8).toString(16)})}function ae(e,a=!1){e==="LDAP"||e===""||e==="password"||ie.getAuthSetting(e,P).then(s=>{if(!s.data||!s.data.config)return;const u=s.data.config,q=new URLSearchParams(O.query).toString();let h=`${u.redirectUrl}/${p}`;q&&(h+=`?${q}`);let r;if(e==="CAS")r=u.ldpUri,r+=r.indexOf("?")!==-1?`&service=${encodeURIComponent(h)}`:`?service=${encodeURIComponent(h)}`;else if(e==="OIDC"){const A=u.scope||"openid+profile+email";r=`${u.authEndpoint}?client_id=${u.clientId}&redirect_uri=${h}&response_type=code&scope=${A}`,u.state&&(r+=`&state=${u.state}`)}else e==="OAuth2"&&(r=`${u.authEndpoint}?client_id=${u.clientId}&response_type=code&redirect_uri=${h}&state=${fe()}`,u.scope&&(r+=`&scope=${u.scope}`));r&&(a?$e(L("views.login.jump_tip"),"",{confirmButtonText:L("views.login.jump"),cancelButtonText:L("common.cancel"),confirmButtonClass:""}).then(()=>{window.location.href=r}).catch(()=>{}):(console.log("url",r),window.location.href=r))})}function J(e){var a;if(_.value=e==="LDAP"?e:"LOCAL",e!=="LOCAL"&&(_.value=e),e==="QR_CODE"){_.value=e,U.value=!0;return}U.value=!1,o.value={username:"",password:"",captcha:""},ae(e),(a=x.value)==null||a.clearValidate()}function ve(e){F(e)}return G(()=>{var e,a;(e=t.chat_profile)!=null&&e.max_attempts&&(K.value=t.chat_profile.max_attempts),(a=t.chat_profile)!=null&&a.login_value&&(c.value=t.chat_profile.login_value,c.value.includes("LOCAL")?c.value=["LOCAL",...c.value.filter(s=>s!=="LOCAL")]:c.value.includes("LDAP")&&(c.value=["LDAP",...c.value.filter(s=>s!=="LDAP")]),_.value=c.value[0]||"LOCAL",!c.value.includes("LOCAL")&&!c.value.includes("LDAP")&&(_.value=""),c.value.length==1&&["CAS","OIDC","OAuth2"].includes(c.value[0])&&ae(c.value[0]),H.value=c.value.filter(s=>!["CAS","OIDC","OAuth2","LOCAL","LDAP"].includes(s)),c.value=c.value.filter(s=>!["lark","wecom","dingtalk"].includes(s)),H.value.length>0&&(H.value.forEach(s=>{te.value.push({key:s,value:s==="wecom"?L("views.system.authentication.scanTheQRCode.wecom"):s==="dingtalk"?L("views.system.authentication.scanTheQRCode.dingtalk"):L("views.system.authentication.scanTheQRCode.lark")})}),!c.value.includes("LOCAL")&&!c.value.includes("LDAP")&&(U.value=!0),c.value=["QR_CODE",...c.value]))}),G(()=>{const e=Y(),a=d(e.fullPath),s=new URLSearchParams(a.value.split("?")[1]),u=s.get("client"),q=()=>{const r=s.get("corpId");r&&Pe.runtime.permission.requestAuthCode({corpId:r}).then(A=>{console.log("DingTalk client request success:",A),t.dingOauth2Callback(A.code,p).then(()=>{g.push({name:"chat",params:{accessToken:p},query:e.query})})})},h=()=>{const r=s.get("appId"),A=()=>{var k;(k=window.tt)==null||k.requestAuthCode({appId:r,success:I=>{t.larkCallback(I.code,p).then(()=>{g.push({name:"chat",params:{accessToken:p},query:e.query})})},fail:I=>{Ie(I)}})};qe("https://lf-scm-cn.feishucdn.com/lark/op/h5-js-sdk-1.5.44.js",{jsId:"lark-sdk",forceReload:!0}).then(()=>{var k;window.tt?(k=window.tt)==null||k.requestAccess({appID:r,scopeList:[],success:I=>{t.larkCallback(I.code,p).then(()=>{g.push({name:"chat",params:{accessToken:p},query:e.query})})},fail:I=>{const{errno:z}=I;z===103&&A()}}):A()}).catch(k=>{console.error("SDK 加载失败:",k)})};switch(u){case"dingtalk":q();break;case"lark":h();break}}),(e,a)=>{const s=w("el-avatar"),u=w("LogoIcon"),q=w("el-card"),h=w("el-input"),r=w("el-form-item"),A=w("el-form"),k=w("el-button"),I=xe("loading");return P.value?D("",!0):Ae((n(),v(ze,{key:0},{default:m(()=>{var z,oe,se,le,ne,re;return[i("div",Ne,[$.value?(n(),b("div",He,[C(ce)((z=C(t).chat_profile)==null?void 0:z.icon)?(n(),v(s,{key:0,shape:"square",size:32,class:"mr-8",style:{background:"none"}},{default:m(()=>{var l;return[i("img",{src:(l=C(t).chat_profile)==null?void 0:l.icon,alt:""},null,8,Je)]}),_:1})):(n(),v(u,{key:1,height:"32px",class:"mr-8"})),i("h1",null,E((oe=C(t).chat_profile)==null?void 0:oe.application_name),1)])):(n(),b("div",We,[i("div",Ge,[i("div",Xe,[i("div",Ye,[C(ce)((se=C(t).chat_profile)==null?void 0:se.icon)?(n(),v(s,{key:0,shape:"square",size:32,style:{background:"none"}},{default:m(()=>{var l;return[i("img",{src:(l=C(t).chat_profile)==null?void 0:l.icon,alt:""},null,8,Ze)]}),_:1})):(n(),v(u,{key:1,height:"32px"}))]),i("h4",{class:"ellipsis",style:{"max-width":"270px"},title:(le=C(t).chat_profile)==null?void 0:le.application_name},E((ne=C(t).chat_profile)==null?void 0:ne.application_name),9,et)])])])),((re=C(t).chat_profile)==null?void 0:re.authentication_type)=="password"?(n(),v(q,{key:2,class:"login-card"},{default:m(()=>[i("h2",tt,E(e.$t("views.applicationOverview.appInfo.LimitDialog.authenticationValue")),1),y(Se)]),_:1})):(n(),v(q,{key:3,class:"login-card",style:{"--el-card-padding":"0"}},{default:m(()=>[!U.value&&(_.value==="LDAP"||_.value==="LOCAL")?(n(),b("h2",at,E(_.value=="LOCAL"?e.$t("views.login.title"):_.value),1)):D("",!0),!U.value&&(_.value==="LDAP"||_.value==="LOCAL")?(n(),b("div",ot,[y(A,{class:"login-form",rules:N.value,model:o.value,ref_key:"loginFormRef",ref:x,onKeyup:De(B,["enter"])},{default:m(()=>[i("div",st,[y(r,{prop:"username"},{default:m(()=>[y(h,{size:"large",class:"input-item",modelValue:o.value.username,"onUpdate:modelValue":a[0]||(a[0]=l=>o.value.username=l),onBlur:a[1]||(a[1]=l=>ve(o.value.username)),placeholder:e.$t("views.login.loginForm.username.placeholder")},null,8,["modelValue","placeholder"])]),_:1})]),i("div",lt,[y(r,{prop:"password"},{default:m(()=>[y(h,{type:"password",size:"large",class:"input-item",modelValue:o.value.password,"onUpdate:modelValue":a[2]||(a[2]=l=>o.value.password=l),placeholder:e.$t("views.login.loginForm.password.placeholder"),"show-password":""},null,8,["modelValue","placeholder"])]),_:1})]),_.value!=="LDAP"&&S.value?(n(),b("div",nt,[y(r,{prop:"captcha"},{default:m(()=>[i("div",rt,[y(h,{size:"large",class:"input-item",modelValue:o.value.captcha,"onUpdate:modelValue":a[3]||(a[3]=l=>o.value.captcha=l),placeholder:e.$t("views.login.loginForm.captcha.placeholder")},null,8,["modelValue","placeholder"]),i("img",{src:S.value,alt:"",height:"38",class:"ml-8 cursor border border-r-6",onClick:a[4]||(a[4]=l=>F(o.value.username))},null,8,ct)])]),_:1})])):D("",!0)]),_:1},8,["rules","model"]),y(k,{size:"large",type:"primary",class:"w-full",onClick:B,loading:P.value},{default:m(()=>[de(E(e.$t("views.login.buttons.login")),1)]),_:1},8,["loading"])])):D("",!0),U.value?(n(),b("div",it,[y(Ke,{tabs:te.value},null,8,["tabs"])])):D("",!0),c.value.length>1?(n(),b("div",ut,[i("span",null,E(e.$t("views.login.moreMethod")),1)])):D("",!0),i("div",dt,[(n(!0),b(Z,null,_e(c.value,l=>(n(),b(Z,null,[l!=="LOCAL"&&_.value!==l&&l!=="QR_CODE"?(n(),v(k,{circle:"",key:l,class:"login-button-circle color-secondary",onClick:Q=>J(l)},{default:m(()=>{var Q;return[i("span",{style:Oe({"font-size":l==="OAUTH2"?"8px":"10px",color:(Q=C(V).themeInfo)==null?void 0:Q.theme})},E(l),5)]}),_:2},1032,["onClick"])):D("",!0),l==="QR_CODE"&&_.value!==l?(n(),v(k,{circle:"",key:l,class:"login-button-circle color-secondary",onClick:a[5]||(a[5]=Q=>J("QR_CODE"))},{default:m(()=>[...a[7]||(a[7]=[i("img",{src:Ve,width:"25px"},null,-1)])]),_:1})):D("",!0),l==="LOCAL"&&_.value!="LOCAL"?(n(),v(k,{circle:"",key:l,class:"login-button-circle color-secondary",style:{"font-size":"24px"},icon:"UserFilled",onClick:a[6]||(a[6]=Q=>J("LOCAL"))})):D("",!0)],64))),256))])]),_:1}))])]}),_:1})),[[I,P.value]])}}}),mt=me(pt,[["__scopeId","data-v-8913cbab"]]),vt=Object.freeze(Object.defineProperty({__proto__:null,default:mt},Symbol.toStringTag,{value:"Module"}));export{Se as _,vt as a,Te as u};