import{c as A}from"./chunk-V64RYZIY.js";import{a as P,b as D,c as H,d as O,e as k,h as F}from"./chunk-O2ZDI5PH.js";import{ua as y,wa as S}from"./chunk-MXUIPT66.js";import{Fa as I,J as p,Pe as N,bg as M,if as l,kf as j,la as U,lf as g,ma as f,md as d,oa as m,od as u,pa as E,pf as L,s as R,td as T,te as b,ua as w,uf as a}from"./chunk-N6B2OJOY.js";import{a as c}from"./chunk-GHL4OFBQ.js";var G={backend:{occ:{endpoints:{userRegister:"users",userForgotPassword:"forgottenpasswordtokens",userResetPassword:"resetpassword",userUpdateLoginId:"users/${userId}/login",userUpdatePassword:"users/${userId}/password",titles:"titles"}}}},_={"Content-Type":"application/json"},C={"Content-Type":"application/x-www-form-urlencoded"},K=(()=>{let o=class o{constructor(e,t,s){this.http=e,this.occEndpoints=t,this.converter=s,this.logger=E(N),this.captchaConfig=E(y,{optional:!0}),this.injector=E(I,{optional:!0})}update(e,t){let s=this.occEndpoints.isConfigured("userUpdateProfile")?"userUpdateProfile":"user",r=this.occEndpoints.buildUrl(s,{urlParams:{userId:e}});return t=this.converter.convert(t,D),this.http.patch(r,t).pipe(p(n=>{throw a(n,this.logger)}))}register(e){let t=this.occEndpoints.buildUrl("userRegister"),s=new d(c({},_));return s=g.createHeader(l,!0,s),s=this.appendCaptchaToken(s),e=this.converter.convert(e,H),this.http.post(t,e,{headers:s}).pipe(p(r=>{throw a(r,this.logger)}),this.converter.pipeable(P))}registerGuest(e,t){let s=this.occEndpoints.buildUrl("userRegister"),r=new d(c({},C));r=g.createHeader(l,!0,r),r=this.appendCaptchaToken(r);let n=new u().set("guid",e).set("password",t);return this.http.post(s,n,{headers:r}).pipe(p(h=>{throw a(h,this.logger)}),this.converter.pipeable(P))}requestForgotPasswordEmail(e){let t=this.occEndpoints.buildUrl("userForgotPassword"),s=new u().set("userId",e),r=new d(c({},C));return r=g.createHeader(l,!0,r),this.http.post(t,s,{headers:r}).pipe(p(n=>{throw a(n,this.logger)}))}resetPassword(e,t){let s=this.occEndpoints.buildUrl("userResetPassword"),r=new d(c({},_));return r=g.createHeader(l,!0,r),this.http.post(s,{token:e,newPassword:t},{headers:r}).pipe(p(n=>{throw a(n,this.logger)}))}updateEmail(e,t,s){let r=this.occEndpoints.buildUrl("userUpdateLoginId",{urlParams:{userId:e}}),n=new u().set("password",t).set("newLogin",s),h=new d(c({},C));return this.http.put(r,n,{headers:h}).pipe(p(v=>{throw a(v,this.logger)}))}updatePassword(e,t,s){let r=this.occEndpoints.buildUrl("userUpdatePassword",{urlParams:{userId:e}}),n=new u().set("old",t).set("new",s),h=new d(c({},C));return this.http.put(r,n,{headers:h}).pipe(p(v=>{throw a(v,this.logger)}))}close(e){let t=this.occEndpoints.isConfigured("userCloseAccount")?"userCloseAccount":"user",s=this.occEndpoints.buildUrl(t,{urlParams:{userId:e}});return this.http.delete(s).pipe(p(r=>{throw a(r,this.logger)}))}loadTitles(){let e=this.occEndpoints.buildUrl("titles");return this.http.get(e).pipe(p(t=>{throw a(t,this.logger)}),R(t=>t.titles??[]),this.converter.pipeableMany(O))}appendCaptchaToken(e){if(this.injector&&this.captchaConfig?.captchaRenderer){let t=this.injector.get(this.captchaConfig.captchaRenderer),s=t.getCaptchaConfig().subscribe(r=>r.enabled);if(t?.getToken()&&s)return e.append(j,t.getToken())}return e}};o.\u0275fac=function(t){return new(t||o)(m(T),m(L),m(M))},o.\u0275prov=U({token:o,factory:o.\u0275fac});let i=o;return i})(),Z=(()=>{let o=class o{};o.\u0275fac=function(t){return new(t||o)},o.\u0275mod=w({type:o}),o.\u0275inj=f({providers:[b(G),{provide:k,useClass:K}]});let i=o;return i})();var nt=(()=>{let o=class o{};o.\u0275fac=function(t){return new(t||o)},o.\u0275mod=w({type:o}),o.\u0275inj=f({imports:[F,Z,A,S]});let i=o;return i})();export{K as a,nt as b};