import{M as A}from"./MkSignin-M1x-8lQg.js";import{$ as B,b as t,M as v,d as x,aN as E,aT as L,A as N,_ as q}from"./app-QjDgb7aF.js";import{b as S,E as h,j as e,g as V,i as k,u as s,p as i,q as o,k as r,H as U,D as a,J as d,x as _,F as j,G as D,a as F}from"./vue-Cm77DuTi.js";import"./2fa-C8X1mOPn.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const G={key:0},T={key:0,class:"waiting _section"},z={class:"_content"},H={key:1,class:"denied _section"},I={class:"_content"},J={key:2,class:"accepted _section"},O={class:"_content"},P={key:0},Q={key:1},R={key:3,class:"_section"},K={key:0,class:"_title"},W={key:1,class:"_title"},X={class:"_content"},Y={class:"_footer"},Z={key:1,class:"signin"},ss=S({__name:"miauth",props:{session:{},callback:{},name:{},icon:{},permission:{}},setup(p){const c=p,m=c.permission.split(",");let l=F(null);function f(n){return n.includes("write")?"pencil-simple":"eye"}async function g(){if(l.value="waiting",await x("miauth/gen-token",{session:c.session,name:c.name,iconUrl:c.icon,permission:m}),l.value="accepted",c.callback){const n=new URL(c.callback);if(["javascript:","file:","data:","mailto:","tel:"].includes(n.protocol))throw new Error("invalid url");location.href=E(c.callback,L({session:c.session}))}}function b(){l.value="denied"}function M(n){N(n.i)}return(n,y)=>{const w=h("MkLoading"),$=h("MkEllipsis"),C=h("MkSpacer");return e(),V(C,{"content-max":800},{default:k(()=>[s(B)?(e(),i("div",G,[s(l)=="waiting"?(e(),i("div",T,[o("div",z,[r(w)])])):U("",!0),s(l)=="denied"?(e(),i("div",H,[o("div",I,[o("p",null,a(s(t).ts._auth.denied),1)])])):s(l)=="accepted"?(e(),i("div",J,[o("div",O,[p.callback?(e(),i("p",P,[d(a(s(t).ts._auth.callback),1),r($)])):(e(),i("p",Q,a(s(t).ts._auth.pleaseGoBack),1))])])):(e(),i("div",R,[p.name?(e(),i("div",K,a(s(t).t("_auth.shareAccess",{name:p.name})),1)):(e(),i("div",W,a(s(t).ts._auth.shareAccessAsk),1)),o("div",X,[o("p",null,a(s(t).ts._auth.permissionAsk),1),s(m).length===32?(e(),i("div",{key:0,class:_([n.$style.permissions])},[o("div",{class:_([n.$style.permission]),style:{"background-color":"var(--error)",color:"var(--fgOnAccent)"}},[y[0]||(y[0]=o("i",{class:"ph-shield-warning ph-bold ph-xl",style:{"margin-right":"0.5rem"}},null,-1)),d(" "+a(s(t).ts._permissions.allPermissions),1)],2)],2)):(e(),i("div",{key:1,class:_([n.$style.permissions])},[(e(!0),i(j,null,D(s(m),u=>(e(),i("div",{key:u,class:_([n.$style.permission])},[o("i",{class:_([[`ph-${f(u)}`],"ph-bold ph-xl"]),style:{"margin-right":"0.5rem"}},null,2),d(" "+a(s(t).t(`_permissions.${u}`)),1)],2))),128))],2))]),o("div",Y,[r(v,{inline:"",onClick:b},{default:k(()=>[d(a(s(t).ts.cancel),1)]),_:1}),r(v,{inline:"",primary:"",onClick:g},{default:k(()=>[d(a(s(t).ts.accept),1)]),_:1})])]))])):(e(),i("div",Z,[r(A,{onLogin:M})]))]),_:1})}}}),es="_permissions_s3eqd_1",is="_permission_s3eqd_1",ns={permissions:es,permission:is},ts={$style:ns},_s=q(ss,[["__cssModules",ts]]);export{_s as default};
//# sourceMappingURL=miauth-BohVgM-J.js.map
