import{M as R}from"./MkSignin-ikEPb45Z.js";import{$ as p,i as l,y as T,M as U,bv as E,aT as j,aZ as G,A as H,x as J,n as K}from"./app-JmgyQoR0.js";import{b as O,a as h,ad as Q,D as m,g as Z,h as n,i as X,j as w,z as o,t as c,x as i,u as s,l as u,H as Y,E as t,K as v,q as x,F as ee,G as se}from"./vue-y3KLWBaS.js";import"./2fa-ubAA2qBP.js";const te={key:0},ne={class:"_content"},oe={class:"_content"},ie={class:"_content"},ce={class:"_content"},ae={class:"_content"},le=s("hr",null,null,-1),re={key:0,class:"_title"},ue={key:1,class:"_title"},_e={class:"_content"},de={class:"monospace"},pe={class:"_footer"},he={key:1,class:"signin"},me=O({__name:"oauth",props:{response_type:{},client_id:{},redirect_uri:{},scope:{},force_login:{type:Boolean},lang:{},state:{}},async setup(D){var C,B,L;let $,M;const r=D,A=(L=(B=(C=r.scope)==null?void 0:C.split(" "))==null?void 0:B.filter(e=>e.length>0))!=null?L:["read"];let a=h(null),q=h(null),f=h(null),y=h("Unknown error occurred");p&&([$,M]=Q(()=>E("v1/iceshrimp/apps/info",{client_id:r.client_id}).then(e=>{f.value=e.name}).catch(e=>{y.value=e,a.value="error"})),await $,M());const d=window.location.search.substring(1).split("&").reduce((e,_)=>{const[k,g]=_.split("=");return e[k]=decodeURIComponent(g),e},{}).redirect_uri;d!==r.redirect_uri&&console.warn(`Mismatching redirect_uris between props (${r.redirect_uri}) and getUrlParams (${d})`);function N(e){return e.startsWith("write")?"pencil-simple":e.startsWith("read")?"eye":e.startsWith("push")?"bell-ringing":e.startsWith("follow")?"users":"check-fat"}async function P(){a.value="waiting";const e=await E("v1/iceshrimp/auth/code",{client_id:r.client_id,redirect_uri:d,scopes:A}).catch(_=>{throw y.value=_,a.value="error",_});r.redirect_uri!=="urn:ietf:wg:oauth:2.0:oob"?(a.value="accepted",location.href=j(d,G({code:e.code,state:r.state}))):(q.value=e.code,a.value="accepted-oob")}function S(){a.value="denied"}async function V(e){await H(e.i)}function W(e){J({includeCurrentAccount:!0,withExtraOperation:!0,withoutProfileLink:!0},e)}return(e,_)=>{const k=m("MkLoading"),g=m("MkEllipsis"),I=m("MkAvatar"),z=m("MkSpacer"),F=Z("click-anime");return n(),X(z,{"content-max":800},{default:w(()=>[o(p)?(n(),c("div",te,[a.value=="waiting"?(n(),c("div",{key:0,class:i(["waiting _section",[e.$style.section]])},[s("div",ne,[u(k)])],2)):Y("",!0),a.value=="denied"?(n(),c("div",{key:1,class:i(["denied _section",[e.$style.section]])},[s("div",oe,[s("p",null,t(o(l).ts._auth.denied),1)])],2)):a.value=="error"?(n(),c("div",{key:2,class:i(["error _section",[e.$style.section]])},[s("div",ie,[s("p",null,t(y.value),1)])],2)):a.value=="accepted-oob"?(n(),c("div",{key:3,class:i(["accepted-oob _section",[e.$style.section]])},[s("div",ce,[s("p",null,t(o(l).ts._auth.copyAsk),1),s("pre",null,t(q.value),1)])],2)):a.value=="accepted"?(n(),c("div",{key:4,class:i(["accepted _section",[e.$style.section]])},[s("div",ae,[s("p",null,[v(t(o(l).ts._auth.callback),1),u(g)])])],2)):(n(),c("div",{key:5,class:i(["_section",[e.$style.section]])},[s("div",{class:i([e.$style.container])},[x((n(),c("button",{class:i(["item _button",[e.$style.account]]),onClick:W},[u(I,{user:o(p),class:i([e.$style.icon]),disableLink:""},null,8,["user","class"])],2)),[[F]]),s("div",{class:i([e.$style.left])},[s("div",null,t(o(l).ts._auth.signedInAs)+":",1),s("div",null,[v("@"+t(o(p).username),1),s("span",{class:i([e.$style.fade])},"@"+t(T),3)])],2)],2),le,s("h2",null,t(o(l).ts._auth.authRequired),1),f.value?(n(),c("div",re,t(o(l).t("_auth.shareAccess",{name:f.value})),1)):(n(),c("div",ue,t(o(l).ts._auth.shareAccessAsk),1)),s("div",_e,[s("p",null,t(o(l).ts._auth.permissionAsk),1),s("div",{class:i([e.$style.permissions])},[(n(!0),c(ee,null,se(o(A),b=>(n(),c("div",{key:b,class:i([e.$style.permission])},[s("i",{class:i([[`ph-${N(b)}`],"ph-bold ph-xl"]),style:{"margin-right":"0.5rem"}},null,2),s("span",de,t(b),1)],2))),128))],2)]),s("div",pe,[u(U,{inline:"",onClick:S},{default:w(()=>[v(t(o(l).ts.cancel),1)]),_:1}),u(U,{inline:"",primary:"",onClick:P},{default:w(()=>[v(t(o(l).ts.accept),1)]),_:1})])],2))])):(n(),c("div",he,[u(R,{onLogin:V})]))]),_:1})}}}),ve="_monospace_goqob_1",fe="_permissions_goqob_5",ye="_permission_goqob_5",ke="_container_goqob_22",ge="_account_goqob_28",be="_icon_goqob_32",we="_section_goqob_38",$e="_fade_goqob_46",Me="_left_goqob_50",Ae={monospace:ve,permissions:fe,permission:ye,container:ke,account:ge,icon:be,section:we,fade:$e,left:Me},qe={$style:Ae},De=K(me,[["__cssModules",qe]]);export{De as default};
