1import{_ as x}from"./CfitJTxY.js";import{_ as S,o as a,c as r,e as i,al as T,i as N,b as g,f as C,t as m,n as v,aw as $,a as _,w as b,d as h,q as f,F as V,Z as I,S as y,V as q,p as U,at as A,A as F,s as j}from"./Bv6rD22K.js";import{U as B,a as O}from"./JcVb4LEC.js";const P={name:"SwitchComponent",props:{id:{type:String,required:!0},name:{type:String,required:!0},modelValue:{type:Boolean,default:!1}},computed:{currentState(){return this.modelValue?"on":"off"}},methods:{toggleValue(){this.$emit("update:modelValue",!this.modelValue)}}},G={class:"switch__name"},Q={class:"switch__container"},Y=["id","checked"],z=["for"],D=["id","checked"],M=["for"],H={class:"switch__state"};function L(s,t,n,u,l,e){const d=C;return a(),r("div",{class:v(["switch",{"switch--positive":n.modelValue}])},[i("span",G,[T(s.$slots,"default",{},void 0,!0)]),i("div",Q,[i("input",{id:`${n.id}-negative`,type:"radio",class:"switch__input",checked:!n.modelValue,value:!1},null,8,Y),i("label",{for:`${n.id}-negative`,class:"switch__label switch__label--negative",onClick:t[0]||(t[0]=N((...c)=>e.toggleValue&&e.toggleValue(...c),["prevent"]))},[g(d,{name:"x",class:"switch__label-icon",title:"Off"})],8,z),i("input",{id:`${n.id}-positive`,type:"radio",class:"switch__input",checked:n.modelValue,value:!0},null,8,D),i("label",{for:`${n.id}-positive`,class:"switch__label switch__label--positive",onClick:t[1]||(t[1]=N((...c)=>e.toggleValue&&e.toggleValue(...c),["prevent"]))},[g(d,{name:"check",class:"switch__label-icon",title:"On"})],8,M),t[2]||(t[2]=i("span",{class:"switch__toggle"},null,-1))]),i("span",H,m(e.currentState),1)],2)}const w=Object.assign(S(P,[["render",L],["__scopeId","data-v-29e614c0"]]),{__name:"SwitchComponent"}),E=$("configurationOptions",{state:()=>({openOptions:[]}),actions:{openConfigOption(s){this.openOptions.push(s)},closeConfigOption(s){this.openOptions.splice(this.openOptions.map(t=>t.id).indexOf(s),1)}}}),R={props:{setting:{type:Object,required:!0}},data(){return{emailEnabled:this.setting.emailEnabled,onSiteEnabled:this.setting.onSiteEnabled}},computed:{isParent(){return this.setting.notificationSettings&&this.setting.notificationSettings.length>0},parentToggleText(){return this.subSettingsOpen?"Close":"Customize"},subSettingsOpen(){return E().openOptions.includes(this.setting.typeId)},subSettingsId(){return`${this.setting.typeId}-sub-settings`}},methods:{onChange(){this.$emit("settingChanged",{typeId:this.setting.typeId,emailEnabled:this.emailEnabled,onSiteEnabled:this.onSiteEnabled})},bubbleSettingChanged(s){this.$emit("settingChanged",s)},toggleSubSettings(){this.subSettingsOpen?E().closeConfigOption(this.setting.typeId):E().openConfigOption(this.setting.typeId)}}},Z=["id"],J={class:"configuration-option__heading"},K={class:"configuration-option__container"},W={class:"configuration-option__description"},X={class:"configuration-option__controls"},tt=["aria-expanded","aria-controls"],et=["id"];function nt(s,t,n,u,l,e){const d=w,c=C,p=k;return a(),r("div",{id:n.setting.typeId,class:"configuration-option"},[i("h3",J,m(n.setting.name),1),i("div",K,[i("p",W,m(n.setting.description),1),i("div",X,[n.setting.hasOnSite?(a(),_(d,{key:0,id:`${n.setting.id}-on-site`,modelValue:l.onSiteEnabled,"onUpdate:modelValue":[t[0]||(t[0]=o=>l.onSiteEnabled=o),e.onChange],name:`${n.setting.name}-on-site`},{default:b(()=>[...t[3]||(t[3]=[h(" On-site ",-1)])]),_:1},8,["id","modelValue","name","onUpdate:modelValue"])):f("",!0),n.setting.hasEmail?(a(),_(d,{key:1,id:`${n.setting.id}-email`,modelValue:l.emailEnabled,"onUpdate:modelValue":[t[1]||(t[1]=o=>l.emailEnabled=o),e.onChange],name:`${n.setting.name}-email`},{default:b(()=>[...t[4]||(t[4]=[h(" Email ",-1)])]),_:1},8,["id","modelValue","name","onUpdate:modelValue"])):f("",!0),e.isParent?(a(),r("button",{key:2,class:v(["configuration-option__toggle-button text-button text-button--bold",{"configuration-option__toggle-button--open":e.subSettingsOpen}]),"aria-expanded":e.subSettingsOpen?"true":"false","aria-controls":e.subSettingsId,type:"button",onClick:t[2]||(t[2]=(...o)=>e.toggleSubSettings&&e.toggleSubSettings(...o))},[h(m(e.parentToggleText)+" ",1),g(c,{name:"caret",class:"configuration-option__toggle-button-icon"})],10,tt)):f("",!0)])]),e.isParent&&e.subSettingsOpen?(a(),r("div",{key:0,id:e.subSettingsId,class:"configuration-option__sub-settings"},[(a(!0),r(V,null,I(n.setting.notificationSettings,o=>(a(),_(p,{key:`${o.typeId}-${o.emailEnabled}-${o.onSiteEnabled}`,setting:o,onSettingChanged:e.bubbleSettingChanged},null,8,["setting","onSettingChanged"]))),128))],8,et)):f("",!0)],8,Z)}const k=Object.assign(S(R,[["render",nt],["__scopeId","data-v-2b9ae6ac"]]),{__name:"ConfigurationOption"}),it={props:{notificationSettings:{type:Array,required:!0}},data(){return{updating:!1,currentSettings:[],allNotificationsEnabled:!0}},created(){this.currentSettings=this.notificationSettings,this.allNotificationsEnabled=this.anySettingEnabled()},methods:{anySettingEnabled(){return this.currentSettings?this.currentSettings.filter(t=>t.emailEnabled||t.onSiteEnabled).length>0:!1},updateSetting(s){this.updating=!0,this.$apollo.mutate({mutation:B,variables:s,update:(t,{data:{updateNotificationSettings:n}})=>{const u=structuredClone(t.readQuery({query:O}));u.notificationSettings=n,t.writeQuery({query:O,data:u})}}).then(({data:t})=>{this.updating=!1,this.currentSettings=t.updateNotificationSettings,y().addToastNotification({toastType:"success",description:"Your notification settings were updated",type:"Notification Settings"})}).catch(()=>{this.updating=!1,y().addGenericErrorNotification()})},submitNoOp(){y().addToastNotification({toastType:"success",description:"Your notification settings were updated",type:"Notification Settings"})},updateAllNotificationsSetting(){const s={typeId:"all",emailEnabled:this.allNotificationsEnabled,onSiteEnabled:this.allNotificationsEnabled};this.updateSetting(s)}}},ot={class:"notification-settings-form__menu list-reset"},st={class:"configuration-option__container"},at={class:"configuration-option__controls"},lt={key:0};function dt(s,t,n,u,l,e){const d=w,c=k,p=q;return a(),_(p,{class:"notification-settings-form",onSubmit:N(e.submitNoOp,["prevent"])},{default:b(()=>[i("ul",ot,[i("li",null,[i("div",{id:"all-notification",class:v(["configuration-option configuration-option--all",{"configuration-option--disabled":!l.allNotificationsEnabled}])},[t[1]||(t[1]=i("h3",{class:"configuration-option__heading"},"Notifications",-1)),i("div",st,[i("div",at,[g(d,{id:"all-notifications",modelValue:l.allNotificationsEnabled,"onUpdate:modelValue":t[0]||(t[0]=o=>l.allNotificationsEnabled=o),name:"all-notifications",onInput:e.updateAllNotificationsSetting},null,8,["modelValue","onInput"])])])],2)]),l.allNotificationsEnabled?(a(),r("li",lt,[(a(!0),r(V,null,I(l.currentSettings,o=>(a(),_(c,{key:`${o.typeId}-${o.emailEnabled}-${o.onSiteEnabled}`,setting:o,onSettingChanged:e.updateSetting},null,8,["setting","onSettingChanged"]))),128))])):f("",!0)])]),_:1},8,["onSubmit"])}const ct=Object.assign(S(it,[["render",dt],["__scopeId","data-v-8bc3b297"]]),{__name:"NotificationSettingsForm"}),rt={props:{user:{type:Object,required:!0}},setup(){},data(){return{notificationSettings:[]}},computed:{restrictPrivateMessaging(){return A(this.$site,"restrict_private_messaging")}},created(){U({title:F(()=>`Notification Settings - ${this.user.username}`)})},mounted(){this.$emit("loaded")},apollo:{notificationSettings:{query:O}}},ut={class:"notifications-settings"},_t={class:"profile__header"},gt={class:"notification-settings__header"},pt={key:1,class:"profile__container"};function ft(s,t,n,u,l,e){const d=x,c=j,p=ct;return a(),r("div",ut,[i("div",_t,[i("div",gt,[g(d,{link:{name:"userNotifications"}},{default:b(()=>[...t[0]||(t[0]=[h("Notifications",-1)])]),_:1})]),t[1]||(t[1]=i("div",{class:"notification-settings__header"},[i("h1",{class:"notification-settings__heading heading--2"},"Notifications Settings")],-1))]),s.$apollo.loading?(a(),_(c,{key:0})):(a(),r("div",pt,[g(p,{"notification-settings":l.notificationSettings},null,8,["notification-settings"])]))])}const St=S(rt,[["render",ft],["__scopeId","data-v-a164ad1e"]]);export{St 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.