(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{extend:()=>l});const o=flarum.core.compat["common/extenders"];var n=t.n(o);function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}const a=flarum.core.compat["common/Model"];var s=t.n(a),c=function(t){function e(){for(var e,o=arguments.length,n=new Array(o),i=0;i-1?o.client.redirect_uri().split(" "):[o.client.redirect_uri()],d().forum.attribute("foskym-oauth-center.require_exact_redirect_uri")&&-1==e.indexOf(n.redirect_uri)&&m.route.set("/"),d().forum.attribute("foskym-oauth-center.allow_implicit")||"token"!=n.response_type||m.route.set("/"),d().forum.attribute("foskym-oauth-center.enforce_state")&&null==n.enforce_state&&m.route.set("/"),d().store.find("oauth-scopes").then((function(t){o.scopes=t;var e=n.scope;null==n.scope&&(e=o.client.scope());var i=[];i=null==e?[]:e.indexOf(" ")>-1?e.split(" "):[e];var r=[];o.scopes.map((function(t){var e=i.indexOf(t.scope());e>-1?i[e]=t:i.slice(e,1),1===t.is_default()&&r.push(t)})),i=i.concat(r),o.client_scope=i.filter((function(t,e){return i.indexOf(t)===e})),console.log(o.client_scope),o.loading=!1,m.redraw()}))}})))},o.setTitle=function(){d().setTitle(z()(d().translator.trans("foskym-oauth-center.forum.page.title.authorize"))),d().setTitleCount(0)},o.view=function(){var t=this;return this.client?!this.loading&&m("div",{className:"AuthorizePage"},m("div",{className:"container"},m("div",{class:"oauth-area"},m("div",{class:"oauth-main"},m("div",{class:"oauth-box oauth-header"},m("h2",null,d().forum.attribute("title")),m("p",null,d().translator.trans("foskym-oauth-center.forum.authorize.access")," ",m("a",{href:this.client.client_home(),target:"_blank"},this.client.client_name()))),m("div",{class:"oauth-box oauth-body"},m("div",{class:"oauth-top"},m("img",{src:d().forum.attribute("faviconUrl")}),m("i",{class:"fas fa-exchange-alt fa-2x"}),m(w(),{text:this.client.client_desc()},m("img",{src:this.client.client_icon()}))),m("div",{class:"oauth-scope-area"},this.client_scope.length>0&&this.client_scope.map((function(e){var o=null;return t.scopes.map((function(t){t.scope()===e.scope()&&(o=t)})),null==o?"":m("div",{class:"oauth-scope"},m("div",{class:"oauth-scope-left"},o.scope_icon().indexOf("fa-")>-1?m("i",{class:"oauth-scope-object fa-2x "+o.scope_icon(),style:"margin-left:2px;color:#000"}):m("img",{class:"oauth-scope-object",src:o.scope_icon(),style:"width:32px"})),m("div",{class:"oauth-scope-body"},m("h6",{class:"oauth-scope-heading"},o.scope_name()),m("small",null,o.scope_desc().replace("{client_name}",t.client.client_name()).replace("{user}",d().session.user.attribute("displayName")))))}))),m("form",{class:"oauth-form",method:"post",id:"form",onsubmit:this.onsubmit.bind(this)},m("input",{type:"hidden",name:"is_authorized",value:this.is_authorized}),m("div",{style:"display: flex; margin-top: 15px",class:"oauth-form-item"},m(P(),{className:"Button",type:"submit",style:"width: 50%;",onclick:this.deny.bind(this),loading:this.submit_loading},d().translator.trans("foskym-oauth-center.forum.authorize.deny")),m(P(),{className:"Button Button--primary",type:"submit",style:"width: 50%;",onclick:this.agree.bind(this),loading:this.submit_loading},d().translator.trans("foskym-oauth-center.forum.authorize.agree"))))))))):""},o.deny=function(t){this.is_authorized=!1},o.agree=function(t){this.is_authorized=!0},o.onsubmit=function(t){t.preventDefault(),this.submit_loading=!0,d().request({method:"POST",url:"/oauth/authorize",body:{response_type:this.params.response_type,client_id:this.params.client_id,redirect_uri:this.params.redirect_uri,state:this.params.state,scope:this.params.scope,is_authorized:this.is_authorized}}).then((function(t){window.location.href=t.location}))},e}(b()),T=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var o=e.prototype;return o.oninit=function(e){t.prototype.oninit.call(this,e),this.loadUser(m.route.param("username"))},o.content=function(){return m("div",{className:"AuthorizedPage"})},e}(_());d().initializers.add("foskym/flarum-oauth-center",(function(){d().routes["oauth.authorize"]={path:"/oauth/authorize",component:j},d().routes["user.authorized"]={path:"/u/:username/authorized",component:T},(0,h.extend)(_().prototype,"navItems",(function(t){d().session.user&&(d().session.user.id(),this.user.id())}))}))})(),module.exports=e})(); //# sourceMappingURL=forum.js.map