1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B0wWhsKS.js","assets/index-DT3kekOa.css"])))=>i.map(i=>d[i]); 2import{aQ as e,bo as o,dI as a,bm as n,bx as l,bn as t,bA as s,a_ as r,cx as i,aV as u,aS as c,bp as d,bO as p,br as m,b1 as v,bI as f,cn as h,bv as g,bL as y,a$ as b,bs as w,aY as P,aX as k,aW as C,aZ as _,aT as x,B as E,w as S,s as V,d as R,dv as I,r as T,e as U,e6 as B,e2 as D,e7 as A,_ as j,f as M,t as L,aU as z,dz as O,dA as q,c9 as N,l as W,e8 as H,h as F,aR as Y,bJ as K,bz as G,by as $}from"./index-B0wWhsKS.js";import{P as J}from"./PInput-B4D7YZGq.js";import{P as Q}from"./PPhotoUpload-DVjlqFNj.js";import{S as X,r as Z}from"./SmsConsentCheckbox-BIurFiru.js";import{B as ee}from"./BackgroundThemePicker-DbqyCCUK.js";import{u as oe}from"./firebaseStorage-OIQM2UVN.js";import{updateStaff as ae}from"./staff-BuC2DdFn.js";import{u as ne}from"./useUnsavedChangesGuard-CDF4_DXy.js";import{f as le,i as te,g as se}from"./phone-BfEgewkX.js";import"./animalMediaOptimization-D_8RNxhq.js";import"./BaseCoachMark.vue_vue_type_style_index_0_lang-PURWAZbn.js";const re=e({name:"PPopover",components:{IonButton:o},props:{modelValue:{type:Boolean,required:!0},title:{type:String,default:""},showActions:{type:Boolean,default:!0},cancelText:{type:String,default:"Cancel"},confirmText:{type:String,default:"Save"},backdropDismiss:{type:Boolean,default:!0},width:{type:String,default:"calc(100vw - 48px)"},maxWidth:{type:String,default:"400px"},maxHeight:{type:String,default:"80vh"}},emits:["update:modelValue","cancel","confirm"],setup:(e,{emit:o})=>({handleBackdropClick:()=>{e.backdropDismiss&&(o("update:modelValue",!1),o("cancel"))},handleCancel:()=>{o("update:modelValue",!1),o("cancel")},handleConfirm:()=>{o("confirm")}})}),ie=()=>{a(e=>({v7e310385:e.width,v745534a3:e.maxWidth,v06fb342c:e.maxHeight}))},ue=re.setup;re.setup=ue?(e,o)=>(ie(),ue(e,o)):ie;const ce={key:0,class:"p-popover-header"},de={class:"p-popover-content"},pe={key:1,class:"p-popover-actions"};const me=e({name:"EditProfilePage",components:{IonPage:x,IonHeader:_,IonToolbar:C,IonButtons:k,IonBackButton:P,IonTitle:w,IonContent:b,IonGrid:y,IonLabel:g,IonButton:o,IonText:h,PInput:J,PPhotoUpload:Q,PPopover:n(re,[["render",function(e,o,a,n,f,h){const g=m("ion-button");return e.modelValue?(v(),l("div",{key:0,class:"p-popover-backdrop",onClick:o[1]||(o[1]=(...o)=>e.handleBackdropClick&&e.handleBackdropClick(...o))},[t("div",{class:"p-popover",onClick:o[0]||(o[0]=p(()=>{},["stop"]))}
2,[e.title?(v(),l("div",ce,[t("h4",null,s(e.title),1)])):r("",!0),t("div",de,[i(e.$slots,"default",{},void 0,!0)]),e.showActions?(v(),l("div",pe,[u(g,{fill:"clear",onClick:e.handleCancel},{default:c(()=>[d(s(e.cancelText),1)]),_:1},8,["onClick"]),u(g,{onClick:e.handleConfirm},{default:c(()=>[d(s(e.confirmText),1)]),_:1},8,["onClick"])])):r("",!0)])])):r("",!0)}],["__scopeId","data-v-5c9333ad"]]),SmsConsentCheckbox:X,Icon:f,BackgroundThemePicker:ee},setup(){const e=z(),o=F(),{showToast:a}=E(),n=T(!0),l=T(!1),t=T(!1),s=T({name:"",about:"",role:"",phone:"",extension:"",emergencyPhone:"",email:""}),r=T([]),i=T(""),u=T(null),c=T(""),d=T(null),p=T(!1),m=T(!1),v=T([]),f=U(()=>{if(0===v.value.length)return"";const e=v.value.map(e=>H(e));return 1===e.length?e[0]:"".concat(e[0]," +").concat(e.length-1," more")}),h=T(!1),g=T(),y=ne({isSaving:t,snapshot:()=>({profile:s.value,profilePhotos:r.value.map(e=>e instanceof File?{name:e.name,size:e.size,type:e.type,lastModified:e.lastModified}:e),selectedRoles:v.value,smsConsentChecked:p.value})}),b=T({}),w=U(()=>{var e,o,a,n,l,t;return(null==(a=null==(o=null==(e=u.value)?void 0:e.staffProfile)?void 0:o.organization)?void 0:a.name)||(null==(t=null==(l=null==(n=u.value)?void 0:n.staff)?void 0:l.organization)?void 0:t.name)||""}),P=U(()=>Z(c.value,s.value.phone,d.value));const k=e=>{var o,a,n;if(e){u.value=e;const l=e.staffProfile||e.staff||null;s.value.name=B(e)||"",s.value.email=e.email||"";const t=null==(o=null==l?void 0:l.permissions)?void 0:o.roles,i=(null==l?void 0:l.position)?l.position.split(",").map(e=>e.trim()).filter(Boolean):[];v.value=D(t&&t.length>0?t:i),s.value.phone=(null==l?void 0:l.phone)||e.phone||"",c.value=(null==l?void 0:l.phone)||e.phone||"",d.value=(null==l?void 0:l.sms_consented_at)||null,s.value.extension=(null==(a=null==l?void 0:l.permissions)?void 0:a.extension)||e.extension||"",s.value.emergencyPhone=(null==(n=null==l?void 0:l.emergency_contact)?void 0:n.phone)||e.emergencyPhone||"",s.value.about=(null==l?void 0:l.notes)||e.about||"",s.value.role=e.role||"";const p=(null==l?void 0:l.photo_url)||e.avatarUrl||e.imageUrl||"";p&&(r.value=[p]),setTimeout(()=>{y.resetDirty()},100)}};S(()=>o.user.value,k,{immediate:!0}),u.value||V.get("currentUser").then(k);async function C(){if(l.value)return;await y.confirmDiscardIfNeeded()&&(l.value=!0,setTimeout(()=>{e.replace("/home")},260))}return R(()=>{h.value=!1}),S(()=>e.currentRoute.value.path,()=>{h.value&&(h.value=!1)}),{defaultAvatar:"/assets/icons/user-circle-gray.svg",profile:s,profilePhotos:r,photoError:i,organizationName:w,requiresSmsConsent:P,smsConsentChecked:p,showSmsConsentError:m,cancel:function(){C()},handleBack:C,save:async function(){var e,o,n,l,i,c,d;if(t.value)return;if(b.value.phone&&b.value.phone.length)return void(await a("Please fix phone number","danger"));if(b.value.emergencyPhone&&b.value.emergencyPhone.length)return void(await a("Please fix emergency number","danger"));if(!(s.value.name||"").trim())return void(await a("Name is required","danger"));if(P.value&&!p.value)return m.value=!0,void(await a("SMS consent is required before saving a new mobile phone number","danger"));t.value=!0;let f=null;try{if(r.value.length>0){const e=r.value[0];if(e instanceof File)try{const o="profile-".concat(Date.now(),"-").concat(e.name),a=["profile-photos","users"];let n=null,l=null;for(const t of a)try{n=await oe(e,o,t,()=>{});break}catch(h){l=h}if(!n)throw l||new Error("Upload failed");f=n}catch(g){return void(await a("Failed to upload photo","danger"))}else"string"==typeof e&&(f=e)}const{name:t,about:p,phone:m,extension:b,emergencyPhone:k}=s.value,_=(t||"").trim(),x={notes:(p||"").trim(),phone:(m||"").trim()||null,emergency_contact:k?{phone:(k||"").trim()}:void 0,permissions:{roles:v.value,extension:(b||"").trim()||null,display_name:_},position:v.value.join(", "),photo_url:f||null};P.value&&(x.sms_consented_at=(new Date).toISOString(),x.sms_consent_method="preferences");const E=null!=(d=null!=(i=null==(o=null==(e=u.value)?void 0:e.staffProfile)?void 0:o.id)?i:null==(l=null==(n=u.value)?void 0:n.staff)?void 0:l.id)?d:null==(c=u.value)?void 0:c.staff_id;if(!E)return void(await a("No staff profile found to update","danger"));await ae(Number(E),x);try{const{getUser:e}=await j(async()=>{const{getUser:e}=await import("./index-B0wWhsKS.js").then(e=>e.fl);return{getUser:e}},__vite__mapDeps([0,1])),{auth:o}=await j(async()=>{const{auth:e}=await import("./index-B0wWhsKS.js").then(e=>e.fm);return{auth:e}},__vite__mapDeps([0,1])),{useAuth:a}=await j(async()=>{const{useAuth:e}=await import("./index-B0wWhsKS.js").then(e=>e.fn);return{useAuth:e}},__vite__mapDeps([0,1]));if(o.currentUser){const n=await e({uuid:o.currentUser.uid});if(n){await V.set("currentUser",n);a().user.value=n}}}catch(w){}await a("Profile updated"),y.markSaved(),C()}catch(w){await a("Failed to save profile","danger")}finally{t.value=!1}},onPhoneInput:function(e,o){var a,n;const l=null!=(n=null==(a=null==o?void 0:o.detail)?void 0:a.value)?n:"",t=le(l);s.value[e]=t,b.value[e]=""},onPhoneInputPInput:function(e,o){const a=le(o);s.value[e]=a,b.value[e]=""},onPhoneBlur:function(e){const o=s.value[e];b.value[e]=o?te(o)?"":se("emergencyPhone"===e?"emergency phone number":"phone number"):""},phoneErrors:b,fromSettingsEnter:n,isClosing:l,selectedRoles:v,displayRoles:f,showRoleModal:h,roleDropdownRef:g,openRoleModal:()=>{h.value=!0},closeRoleModal:()=>{h.value=!1},saveRoles:()=>{h.value=!1},toggleRole:e=>{const o=A(e);o&&(v.value.includes(o)?v.value=v.value.filter(e=>e!==o):v.value=[...v.value,o])}
2,requestAccountDeletion:async()=>{const e=await M.create({header:"Delete Account",message:"This will permanently delete your account and all associated data. This action cannot be undone.",inputs:[{name:"confirmation",type:"text",placeholder:"Type DELETE to confirm",attributes:{autocapitalize:"characters"}}],buttons:[{text:"Cancel",role:"cancel"},{text:"Delete Account",role:"destructive",handler:e=>"DELETE"!==String((null==e?void 0:e.confirmation)||"")?(L.create({message:"Type DELETE to confirm account deletion.",duration:2200,position:"top",color:"warning"}).then(e=>e.present()),!1):((async()=>{var e,o,a;const n=null==(e=u.value)?void 0:e.id;if(!n){const e=await M.create({header:"Unable to Delete Account",message:"We could not determine which account to delete. Please sign in again and try once more.",buttons:["OK"]});return void(await e.present())}const l=await O.create({message:"Deleting account...",spinner:"circles"});await l.present();try{await q(n),await l.dismiss();const e=await L.create({message:"Your account has been deleted.",duration:1800,position:"top",color:"success"});await e.present();try{await N()}catch(t){W.error("Post-deletion logout failed:",t)}window.location.href="/signin"}catch(s){await l.dismiss(),W.error("Failed to delete account:",s);const e=await M.create({header:"Unable to Delete Account",message:(null==(a=null==(o=null==s?void 0:s.response)?void 0:o.data)?void 0:a.error)||"We could not delete your account right now. Please try again.",buttons:["OK"]});await e.present()}})(),!0)}]});await e.present()},onPhoneKeydown:function(e){const o=/[0-9]/.test(e.key),a=["(",")"," ","-","+"].includes(e.key);["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)||o||a||e.preventDefault()},SHELTER_ROLES:I}}}),ve={class:"section appearance-section"},fe={class:"photo-upload-section"},he={class:"form-fields"},ge={class:"field-group"},ye={class:"field-group"},be={class:"field-group"},we={class:"role-dropdown-content"},Pe={class:"phone-row"},ke={class:"field-group phone"},Ce={key:0,class:"field-group"},_e={class:"field-group"},xe={class:"field-group"},Ee={class:"actions"},Se={class:"role-options"},Ve=["checked","onChange"];const Re=n(me,[["render",function(e,o,a,n,i,f){const h=m("ion-back-button"),g=m("ion-buttons"),y=m("ion-title"),b=m("ion-button"),w=m("ion-toolbar"),P=m("ion-header"),k=m("BackgroundThemePicker"),C=m("PPhotoUpload"),_=m("PInput"),x=m("ion-label"),E=m("Icon"),S=m("SmsConsentCheckbox"),V=m("ion-text"),R=m("ion-grid"),I=m("ion-content"),T=m("PPopover"),U=m("ion-page");return v(),Y(U,{class:K(["edit-profile-page",{"from-settings-enter":e.fromSettingsEnter,"is-closing":e.isClosing}])},{default:c(()=>[u(P,{class:"ion-no-border"},{default:c(()=>[u(w,null,{default:c(()=>[u(g,{slot:"start"},{default:c(()=>[u(h,{"default-href":"/home",text:"",onClick:p(e.handleBack,["prevent"])},null,8,["onClick"])]),_:1}),u(y,{class:"ion-text-center"},{default:c(()=>[...o[14]||(o[14]=[d("Profile",-1)])]),_:1}),u(g,{slot:"end"},{default:c(()=>[u(b,{fill:"clear",onClick:e.save},{default:c(()=>[...o[15]||(o[15]=[d(" Save ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1}),u(I,null,{default:c(()=>[u(R,{class:"content"},{default:c(()=>[t("div",ve,[u(k)]),o[18]||(o[18]=t("div",{class:"section-divider"},null,-1)),t("div",fe,[u(C,{id:"profile-photo",label:"Profile Photo",modelValue:e.profilePhotos,"onUpdate:modelValue":o[0]||(o[0]=o=>e.profilePhotos=o),"max-photos":1,"error-text":e.photoError},null,8,["modelValue","error-text"])]),t("div",he,[t("div",ge,[u(_,{id:"profile-name",label:"Name",modelValue:e.profile.name,"onUpdate:modelValue":o[1]||(o[1]=o=>e.profile.name=o),placeholder:"Your name",type:"text",variant:"grey-800",autocomplete:"name"},null,8,["modelValue"])]),t("div",ye,[u(_,{id:"profile-about",label:"About",modelValue:e.profile.about,"onUpdate:modelValue":o[2]||(o[2]=o=>e.profile.about=o),placeholder:"Share a little about yourself. This will appear on your profile.",type:"textarea",rows:4,"auto-grow":!0,variant:"grey-800",autocomplete:"off"},null,8,["modelValue"])]),t("div",be,[u(x,{class:"field-title"},{default:c(()=>[...o[16]||(o[16]=[d("Role at Organization",-1)])]),_:1}),t("div",{ref:"roleDropdownRef",class:"role-dropdown-wrapper",onClick:o[3]||(o[3]=(...o)=>e.openRoleModal&&e.openRoleModal(...o))},[t("div",we,s(e.displayRoles||"Select your roles"),1),u(E,{name:"chevron-down",class:K(["dropdown-icon",{rotated:e.showRoleModal}])},null,8,["class"])],512)]),t("div",Pe,[t("div",ke,[u(_,{id:"profile-phone",label:"Mobile Phone Number",modelValue:e.profile.phone,"onUpdate:modelValue":o[4]||(o[4]=o=>e.profile.phone=o),placeholder:"(555) 555-0120",type:"tel",helpText:"Used for text message notifications","error-text":e.phoneErrors.phone,onBlur:o[5]||(o[5]=o=>e.onPhoneBlur("phone")),variant:"grey-800",autocomplete:"tel"},null,8,["modelValue","error-text"])])]),e.requiresSmsConsent?(v(),l("div",Ce,[u(S,{modelValue:e.smsConsentChecked,"onUpdate:modelValue":o[6]||(o[6]=o=>e.smsConsentChecked=o),audience:"staff","org-name":e.organizationName,"show-error":e.showSmsConsentError&&!e.smsConsentChecked},null,8,["modelValue","org-name","show-error"])])):r("",!0),t("div",_e,[u(_,{id:"profile-emergency-phone",label:"Emergency Contact Number",modelValue:e.profile.emergencyPhone,"onUpdate:modelValue":o[7]||(o[7]=o=>e.profile.emergencyPhone=o),placeholder:"(555) 555-3456",type:"tel","error-text":e.phoneErrors.emergencyPhone,onBlur:o[8]||(o[8]=o=>e.onPhoneBlur("emergencyPhone")),variant:"grey-800",autocomplete:"tel"},null,8,["modelValue","error-text"]),u(V,{class:"helper-text"},{default:c(()=>[...o[17]||(o[17]=[d("Used only for urgent cases when your primary number can't be reached.",-1)])]),_:1})]),t("div",xe,[u(_,{id:"profile-email",label:"Email",modelValue:e.profile.email,"onUpdate:modelValue":o[9]||(o[9]=o=>e.profile.email=o),placeholder:"[email protected]",type:"email",variant:"grey-800",autocomplete:"email",disabled:!0},null,8,["modelValue"])])]),t("div",Ee,[t("button",{type:"button",class:"button-sm-tertiary",onClick:o[10]||(o[10]=(...o)=>e.cancel&&e.cancel(...o))},"Cancel"),t("button",{type:"button",class:"button-sm-primary",onClick:o[11]||(o[11]=(...o)=>e.save&&e.save(...o))},"Save")]),o[19]||(o[19]=t("div",{class:"section-divider"},null,-1)),t("button",{type:"button",class:"delete-account-link",onClick:o[12]||(o[12]=(...o)=>
2e.requestAccountDeletion&&e.requestAccountDeletion(...o))},"Delete Account")]),_:1})]),_:1}),u(T,{modelValue:e.showRoleModal,"onUpdate:modelValue":o[13]||(o[13]=o=>e.showRoleModal=o),title:"Select Your Roles",onCancel:e.closeRoleModal,onConfirm:e.saveRoles},{default:c(()=>[t("div",Se,[(v(!0),l($,null,G(e.SHELTER_ROLES,o=>(v(),l("label",{key:o.value,class:"role-option-custom"},[t("input",{type:"checkbox",checked:e.selectedRoles.includes(o.value),onChange:a=>e.toggleRole(o.value)},null,40,Ve),t("span",null,s(o.label),1)]))),128))])]),_:1},8,["modelValue","onCancel","onConfirm"])]),_:1},8,["class"])}],["__scopeId","data-v-3a53a5b9"]]);export{Re 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.