import{r as e}from"./chunk-QTnfLwEv.js";import{n as t}from"./index-7yDgay5u.js";import{i as n,o as r,r as i,t as a}from"./jsx-runtime-DHSfUA5-.js";import{O as o,P as s,R as c,z as l}from"./test.id-DxQrYxPk.js";import{t as u}from"./diaryService-CNt2_Lb5.js";import{a as d,n as f}from"./fileAssetService-gA4Q8V3n.js";import{t as p}from"./navigationService-BNBSAd9W.js";import{t as m}from"./PageHeader-CzIJsNRF.js";import{x as h}from"./selectors-DZWoTA9D.js";import{t as g}from"./useDiaryModel-BQGj9xs8.js";import{t as _}from"./CellList-UkuVgkhN.js";import{t as v}from"./useLoadingToast-BBb6RyKX.js";import{t as y}from"./useProfileAvatar-DM2sovVl.js";var b=e(r(),1),x=a();function S(){let e=s(p),r=s(u),a=s(f),S=s(c),C=v(),w=g(),{url:T}=y(),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(``),A=async()=>{if(E)return;let e;try{k(``);let n=await S.pickImageBlob(l.Photos);if(!n)return;e=C({message:t(`common.uploading`,`Uploading...`)}),D(!0);let i=d(await a.uploadImage(n,{thumbnail:!0}),h);r.addAttachment(i),r.updateProfileAvatar(i.id)}catch(e){k(e instanceof Error?e.message:String(e))}finally{e?.dispose(),D(!1)}};return(0,x.jsxs)(`div`,{className:n.Page.GroupedRoot,"data-test-id":o.page,children:[(0,x.jsx)(m,{title:t(`profile.title`,`Profile`),showBack:!0}),(0,x.jsxs)(`main`,{className:i(n.Page.Content,n.Cell.GroupStackLoose),"data-test-id":o.content,children:[(0,x.jsx)(_,{items:[{label:t(`profile.avatar`,`Avatar`),right:{type:`image`,url:T,testId:o.avatarImage},testId:o.avatar,onClick:()=>void A()},{label:t(`profile.name`,`Name`),right:w.profile.name?{type:`value`,text:w.profile.name}:void 0,testId:o.name,onClick:()=>e.navigate({path:`/settings/name`})},{label:t(`messageColor.title`,`Message color`),testId:o.messageColor,onClick:()=>e.navigate({path:`/settings/profile/message-color`})}]}),O&&(0,x.jsx)(`div`,{className:i(n.Text.Error,n.Common.PagePadding),"data-test-id":o.error,children:O})]})]})}export{S as SettingsProfilePage};
//# sourceMappingURL=profile-hpy-BydP.js.map