1import{_ as P,E as f,a as c,n as V,aM as K,S as h,aN as Q,e as M,an as B,am as $,Q as T,C as U,m as D}from"./portal-ab1a983f25e4.js";import{F as X}from"./chunk-4d2ASeae.js";import{P as G,U as z,A as k}from"./chunk-UJ7Y7n4m.js";import{o as d,l as u,B as i,w as b,V as C,z as R,n as E,F as A,H as p,y as g,T as v,r as Y,M as F,q as N,x as L,v as H,G as W,O as Z,Q as J,A as y,a8 as O,a9 as S,a3 as x}from"./portal-vendors-ab1a983f25e4.js";import{P as j}from"./chunk-BQVKS3Hl.js";import"./chunk-Eblin5Sv.js";const ee="Profil zostaÅ dodany",te=30,ie={name:"AddProfile",components:{AvatarList:k,UiModernSelect:z},mixins:[G],props:{selectedProfile:Object},data(){return{subscriber:this.$services.resolve(h.SUBSCRIBER),profilesResource:this.$services.resolve(h.PROFILES),profileAvatar:void 0,privacyPolicyUrl:"",NEW_PROFILE_COLOR:K,MAX_NAME_LENGTH:te}},watch:{profileName:"getNameList"},created(){const{privacyPolicyUrl:t}=V.response.document;this.privacyPolicyUrl=`${window.location.protocol}//${t}`},methods:{cancel(){this.$emit("switch-component",{componentName:"main-screen",editMode:!0})},createProfile(){if(!this.validate())return;const e={name:this.profileName,avatar:this.profileAvatar};this.profileBirthYear&&(e.birthYear=this.profileBirthYear),this.profilesResource.create(e).then(s=>{var n;f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_ADD,avatarId:(n=e.avatar)==null?void 0:n.id,profileId:s.externalUid})}),this.$emit("switch-component",{componentName:"main-screen",editMode:!0,actionMessage:ee})}}},re={class:"profile-panel"},se={class:"row-buttons"},oe={class:"privacy-policy"},ae=["href"];function ne(t,e,s,n,o,r){const m=g("avatar-list"),l=g("ui-modern-select");return d(),u("div",re,[e[5]||(e[5]=i("div",{class:"logo"},null,-1)),e[6]||(e[6]=i("div",{class:"title"},"Dodaj nowy profil:",-1)),b(m,{value:o.profileAvatar,"is-data-collector-enabled":t.isDataCollectorEnabled,"is-missing-avatar-error":t.avatarError,"onUpdate:value":e[0]||(e[0]=a=>o.profileAvatar=a)},null,8,["value","is-data-collector-enabled","is-missing-avatar-error"]),b(l,C(t.LABELS.name,{value:t.profileName,options:t.nameList,"error-message":t.nameErrorMessage,"correct-value":t.correctNameValue,"max-length":o.MAX_NAME_LENGTH,class:"brand-styled-select",required:"","onUpdate:value":e[1]||(e[1]=a=>t.profileName=a)}),null,16,["value","options","error-message","correct-value","max-length"]),t.isDataCollectorEnabled&&t.birthYearList.length?(d(),R(l,C({key:0},t.LABELS.birthYear,{value:t.profileBirthYear,options:t.birthYearList,"error-message":t.birthYearErrorMessage,"correct-value":t.correctAgeValue,message:t.birthYearMessage,required:t.isBirthYearRequired,class:"brand-styled-select",simple:"","onUpdate:value":e[2]||(e[2]=a=>t.profileBirthYear=a)}),null,16,["value","options","error-message","correct-value","message","required"])):E("",!0),i("div",se,[i("button",{type:"button",class:"btn btn-sign-up accept",onClick:e[3]||(e[3]=(...a)=>r.createProfile&&r.createProfile(...a))},"Dodaj profil"),i("button",{type:"button",class:"btn btn-transparent",onClick:e[4]||(e[4]=(...a)=>r.cancel&&r.cancel(...a))},"Anuluj")]),i("div",oe,[i("div",null,[A(p(t.$translate("PRIVACY_POLICY_START_TEXT"))+" ",1),i("a",{href:o.privacyPolicyUrl,target:"_blank"},p(t.$translate("PRIVACY_POLICY_LINK_TEXT")),9,ae),A(p(t.$translate("PRIVACY_POLICY_END_TEXT")),1)])])])}const le=P(ie,[["render",ne],["__file","add-profile.vue"]]),ce="Profil zostaÅ zaktualizowany",de=100,ue={name:"EditProfile",components:{AvatarList:k,UiModernSelect:z},mixins:[G,j],props:{selectedProfile:Object},data(){var t;return{subscriber:this.$services.resolve(h.SUBSCRIBER),profilesResource:this.$services.resolve(h.PROFILES),isMainProfile:this.selectedProfile.type===Q,color:this.selectedProfile.color,profileAvatar:(t=this.selectedProfile)==null?void 0:t.avatar,birthYearLabel:"Edytuj rok urodzenia"}},computed:{labels(){const{birthYearCollected:t}=this.selectedProfile;return t?{label:this.birthYearLabel,placeholder:this.birthYearLabel}:this.LABELS.birthYear},isVisibleBirthYearRequiredSign(){return this.isBirthYearRequired&&!this.selectedProfile.birthYearCollected}},watch:{profileName:"getNameList"},created(){this.inputDebounceValue=de},methods:{save(){var s;if(!this.validate())return;const e={...this.selectedProfile,name:this.profileName,avatar:this.profileAvatar};this.profileBirthYear&&(e.birthYear=this.profileBirthYear),f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_EDIT,avatarId:(s=e.avatar)==null?void 0:s.id,profileId:e.externalUid}),this.profilesResource.update(this.selectedProfile.id,e,{reset:!0}),this.$emit("switch-component",{componentName:"main-screen",editMode:!0,actionMessage:ce})},cancel(){this.$emit("switch-component",{componentName:"main-screen",editMode:!0})},remove(){this.$emit("switch-component",{componentName:"remove-profile"})}}},fe={class:"profile-panel"},me={class:"row-buttons single"},pe={class:"row-buttons"},ve={key:0,class:"info-text"};function he(t,e,s,n,o,r){const m=g("avatar-list"),l=g("ui-modern-select");return d(),u("div",fe,[e[6]||(e[6]=i("div",{class:"logo"},null,-1)),e[7]||(e[7]=i("div",{class:"title"},"Edytuj profil:",-1)),b(m,{value:o.profileAvatar,"selected-profile":s.selectedProfile,"is-data-collector-enabled":t.isDataCollectorEnabled,"is-missing-avatar-error":t.avatarError,"onUpdate:value":e[0]||(e[0]=a=>o.profileAvatar=a)},null,8,["value","selected-profile","is-data-collector-enabled","is-missing-avatar-error"]),b(l,C(t.LABELS.name,{value:t.profileName,options:t.nameList,"error-message":t.nameErrorMessage,"correct-value":t.correctNameValue,class:"brand-styled-select",required:"","debounce-value":t.inputDebounceValue,"onUpdate:value":e[1]||(e[1]=a=>t.profileName=a)}
1),null,16,["value","options","error-message","correct-value","debounce-value"]),t.isDataCollectorEnabled&&t.birthYearList.length?(d(),R(l,C({key:0},r.labels,{value:t.profileBirthYear,options:t.birthYearList,"correct-value":t.correctAgeValue,"error-message":t.birthYearErrorMessage,message:t.birthYearMessage,required:r.isVisibleBirthYearRequiredSign,class:"brand-styled-select",simple:"","onUpdate:value":e[2]||(e[2]=a=>t.profileBirthYear=a)}),null,16,["value","options","correct-value","error-message","message","required"])):E("",!0),i("div",me,[i("button",{type:"button",class:"btn btn-sign-up accept",onClick:e[3]||(e[3]=v((...a)=>r.save&&r.save(...a),["prevent"]))},"Zapisz zmiany")]),i("div",pe,[i("button",{type:"button",class:"btn btn-transparent",onClick:e[4]||(e[4]=v((...a)=>r.cancel&&r.cancel(...a),["prevent"]))},"Anuluj"),o.isMainProfile?(d(),u("div",ve,"Profilu gÅównego nie można usunÄ
Ä")):(d(),u("button",{key:1,type:"button",class:"btn btn-transparent",onClick:e[5]||(e[5]=v((...a)=>r.remove&&r.remove(...a),["prevent"]))},"UsuÅ profil"))])])}const be=P(ue,[["render",he],["__file","edit-profile.vue"]]),Ee={__name:"profile-avatar",props:{profile:{type:Object,default:()=>({})},clickableAvatar:{type:Boolean,default:!0},showAvatar:{type:Boolean,default:!0},newProfileColor:String,editedAvatar:Object,editAppearance:Boolean},emits:["avatar-clicked"],setup(t,{expose:e,emit:s}){e();const n=s,o=t,r=Y({...o.profile});F(()=>o.profile,_=>{Object.assign(r,_)},{deep:!0}),o.newProfileColor&&(r.color=o.newProfileColor);const m=N(()=>r.name&&r.name.charAt(0).toLocaleUpperCase()||"?"),l=N(()=>{var _,w;return((_=o.editedAvatar)==null?void 0:_.url)||((w=r.avatar)==null?void 0:w.url)}),I={emit:n,props:o,profileInstance:r,avatarLetter:m,avatarUrl:l,avatarClicked:()=>{o.clickableAvatar&&(n("avatar-clicked"),f.$emit(c.AVATAR_CLICKED))},computed:N,reactive:Y,watch:F,get eventBus(){return f},get EventType(){return c}};return Object.defineProperty(I,"__isScriptSetup",{enumerable:!1,value:!0}),I}},ge={class:"profile-avatar"},Pe={key:0,class:"avatar-item"},Ae=["src"],ye={class:"avatar-letter"},_e={key:2,class:"icon-pencil"},Le={class:"profile-name"},Me={class:"edit-tools"},Ce={class:"message"};function Re(t,e,s,n,o,r){return d(),u("div",ge,[i("button",{type:"button",class:H(["avatar-container",{clickable:s.clickableAvatar}]),onClick:n.avatarClicked},[L(t.$slots,"default",{},()=>[s.showAvatar?(d(),u("div",Pe,[n.avatarUrl?(d(),u("img",{key:0,src:n.avatarUrl,class:"avatar-image",alt:"Profile avatar"},null,8,Ae)):(d(),u("div",{key:1,class:"missing-avatar",style:W({"background-color":n.profileInstance.color})},[i("span",ye,p(n.avatarLetter),1)],4)),s.editAppearance?(d(),u("i",_e)):E("",!0)])):E("",!0)]),i("div",Le,[L(t.$slots,"profileName")])],2),i("div",Me,[L(t.$slots,"editTools")]),i("div",Ce,[L(t.$slots,"actionMessage")])])}const q=P(Ee,[["render",Re],["__file","profile-avatar.vue"]]),Ie={name:"MainScreen",components:{ProfileItem:q},mixins:[j],props:{profiles:Array,editMode:Boolean,actionMessage:String},data(){return{profilesLimit:!1}},computed:{viewTitle(){return this.editMode?"ZarzÄ
dzaj profilami":"Kto oglÄ
da?"}},methods:{addProfile(){V.fetch().then(t=>{if(this.maxProfileCount=t.data.maxProfileCount,this.profiles.length<this.maxProfileCount)return this.$emit("switch-component",{componentName:"add-profile",resetProfile:!0});this.profilesLimit=!0})},closeEditMode(){f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_EDIT}),this.$emit("switch-component",{editMode:!1})},toggleEditMode(){this.$emit("switch-component",{editMode:!this.editMode})},selectProfile(t){this.editMode?this.$emit("switch-component",{profileIndex:t,componentName:"edit-profile"}):this.switchProfile(this.profiles[t]).then(this.closeProfileManager)},logout(){return f.$emit(c.SUBSCRIBER_ACTION,{type:c.SUBSCRIBER_LOGOUT}),M.oauthApi.logout()},closeProfileManager(){f.$emit(c.PROFILE_MANAGER_CLOSE)}}},Ne={class:"view"},Oe={class:"view-content"},Se={key:0,class:"limit-exceeded"},ke={key:1},we={key:0,class:"action-message"};function Be(t,e,s,n,o,r){const m=g("profile-item");return d(),u("div",Ne,[i("div",{class:"logo",onClick:e[0]||(e[0]=(...l)=>r.closeProfileManager&&r.closeProfileManager(...l))}),i("h2",null,p(r.viewTitle),1),i("div",Oe,[(d(!0),u(Z,null,J(s.profiles,(l,a)=>(d(),R(m,{key:`profile-${a}`,"edit-appearance":s.editMode,profile:l,onAvatarClicked:I=>r.selectProfile(a)},{profileName:y(()=>[i("span",null,p(l.name),1)]),_:2},1032,["edit-appearance","profile","onAvatarClicked"]))),128)),b(m,{onAvatarClicked:r.addProfile},{profileName:y(()=>[o.profilesLimit?(d(),u("span",Se,"Maksymalna liczba profili to "+p(t.maxProfileCount)+". ",1)):(d(),u("span",ke,"Dodaj profil"))]),default:y(()=>[e[4]||(e[4]=i("div",{class:"avatar-item"},[i("div",{class:"missing-avatar"},[i("i",{class:"icon-plus"})])],-1))]),_:1},8,["onAvatarClicked"])]),O(i("button",{class:"btn btn-color-brand btn-primary",onClick:e[1]||(e[1]=v((...l)=>r.closeEditMode&&r.closeEditMode(...l),["prevent"]))},e[5]||(e[5]=[i("span",null,"Gotowe",-1)]),512),[[S,s.editMode]]),O(i("button",{class:"btn btn-primary btn-sign manage-btn",onClick:e[2]||(e[2]=v((...l)=>r.toggleEditMode&&r.toggleEditMode(...l),["prevent"]))},e[6]||(e[6]=[i("i",{class:"icon-pencil"},null,-1),i("span",null,"ZarzÄ
dzaj profilami",-1)]),512),[[S,!s.editMode]]),s.actionMessage?(d(),u("div",we,p(s.actionMessage),1)):E("",!0),O(i("button",{class:"btn btn-primary btn-sign manage-btn logout-btn",onClick:e[3]||(e[3]=v((...l)=>r.logout&&r.logout(...l),["prevent"]))},e[7]||(e[7]=[i("i",{class:"icon-logout"},null,-1),i("span",null,"Wyloguj siÄ",-1)]),512),[[S,!s.editMode]])])}
1const $e=P(Ie,[["render",Be],["__file","main-screen.vue"]]),Te="Profil zostaÅ usuniÄty",Ue={name:"RemoveProfile",components:{ProfileAvatar:q},props:{selectedProfile:Object},data(){return{subscriber:this.$services.resolve(h.SUBSCRIBER),profilesResource:this.$services.resolve(h.PROFILES)}},methods:{cancel(){this.$emit("switch-component",{componentName:"edit-profile"})},remove(){f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_REMOVE,avatarId:this.selectedProfile.avatar.id,profileId:this.selectedProfile.externalUid}),this.profilesResource.destroy(this.selectedProfile.id),this.$emit("switch-component",{componentName:"main-screen",editMode:!0,actionMessage:Te})}}},De={class:"view remove-view"},Ye={class:"view-content"},Fe={class:"horizontal-buttons"};function Ve(t,e,s,n,o,r){const m=g("profile-avatar");return d(),u("div",De,[e[5]||(e[5]=i("div",{class:"logo"},null,-1)),e[6]||(e[6]=i("h2",null,"UsuÅ profil",-1)),i("div",Ye,[b(m,{profile:s.selectedProfile},{profileName:y(()=>[i("div",null,p(s.selectedProfile.name),1)]),actionMessage:y(()=>e[2]||(e[2]=[i("div",{class:"remove-tip"},[A(" JeÅli usuniesz profil, stracisz wszystkie"),i("br"),A("zapisane w nim dane, takie jak:"),i("br"),A("rekomendacje, lista ulubionych, obejrzane. ")],-1)])),_:1},8,["profile"])]),i("div",Fe,[i("button",{class:"btn btn-color-brand btn-primary",onClick:e[0]||(e[0]=v((...l)=>r.remove&&r.remove(...l),["prevent"]))},e[3]||(e[3]=[i("span",null,"ChcÄ usunÄ
Ä profil",-1)])),i("button",{class:"btn btn-primary btn-sign",onClick:e[1]||(e[1]=v((...l)=>r.cancel&&r.cancel(...l),["prevent"]))},e[4]||(e[4]=[i("span",null,"Nie usuwaj",-1)]))])])}const Ge=P(Ue,[["render",Ve],["__file","remove-profile.vue"]]),ze={name:"ProfileManager",components:{MainScreen:$e,AddProfile:le,EditProfile:be,RemoveProfile:Ge,AvatarsList:k},data(){return{view:"main-screen",subscriber:this.$services.resolve(h.SUBSCRIBER),profilesResource:this.$services.resolve(h.PROFILES),visible:!1,avatarsListVisible:!1,selectedProfile:void 0,editMode:!1,actionMessage:void 0}},computed:{profiles(){return this.profilesResource.collection.records}},watch:{"subscriber.isLogged":"init","$route.query":"checkQuery",visible(t){t&&f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_MANAGER_SHOW})}},created(){this.init()},beforeUnmount(){this.subscriber.off("sync")},methods:{init(){this.$nextTick(this.checkQuery),this.subscriber.isLogged&&(f.$on(c.PROFILE_MANAGER_CLOSE,this.close),this.subscriber.on("sync",()=>{this.subscriber.isLogged||this.close()}))},switchComponent(t){const{profileIndex:e,componentName:s,editMode:n,resetProfile:o,actionMessage:r}=t;s&&(this.view=s),isNaN(e)||(this.selectedProfile=this.profiles[e]),o&&(this.selectedProfile=void 0),this.editMode=n,this.actionMessage=r},open(t){document.addEventListener("keyup",this.onKeyUp),document.addEventListener("keydown",this.onKeyDown),document.body.classList.add("hidden"),f.$emit(c.PROFILE_MANAGER_VISIBLE),this.visible=!0,this.editMode=t,U.set(D.PROFILE_MANAGER_DISPLAYED,1)},emitClose(){f.$emit(c.PROFILE_MANAGER_CLOSE)},close(){var t;if(document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyDown),document.body.classList.remove("hidden"),this.visible=!1,f.$emit(c.PROFILE_MANAGER_ACTION,{action:c.PROFILE_MANAGER_CLOSE}),(t=M.onboardingBoard)!=null&&t.isVisible&&M.onboardingBoard.activateOnboarding(),this.$route&&this.$route.query[T.PROFILES]){const e={...this.$route.query};delete e.profiles,this.$router.replace({query:e})}this.switchComponent({componentName:"main-screen"})},checkQuery(){this.$route&&this.$route.query[T.PROFILES]&&(this.subscriber.isLogged?this.open():U.get(D.USER_IS_LOGGED_COOKIE)||M.oauthApi.login())},onKeyUp(t){B($.ESCAPE,t)&&this.emitClose()},onKeyDown(t){if(!B($.TAB,t))return;const e=Array.from(this.$el.querySelectorAll(X)).filter(o=>o.offsetParent!==null);if(!e.length){t.preventDefault();return}const s=e[0],n=e[e.length-1];if(!e.includes(document.activeElement)){t.preventDefault(),(t.shiftKey?n:s).focus();return}!t.shiftKey&&document.activeElement===n?(t.preventDefault(),s.focus()):t.shiftKey&&document.activeElement===s&&(t.preventDefault(),n.focus())}}},je={key:0,class:"profile-manager"};function qe(t,e,s,n,o,r){return o.visible?(d(),u("div",je,[(d(),R(x(o.view),{profiles:r.profiles,"selected-profile":o.selectedProfile,"edit-mode":o.editMode,"action-message":o.actionMessage,onSwitchComponent:r.switchComponent},null,40,["profiles","selected-profile","edit-mode","action-message","onSwitchComponent"]))])):E("",!0)}const Je=P(ze,[["render",qe],["__file","index.vue"]]);export{Je as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.