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{P as o,b as s}from"./test.id-DxQrYxPk.js";import{t as c}from"./diaryService-CNt2_Lb5.js";import{t as l}from"./navigationService-BNBSAd9W.js";import{t as u}from"./PageHeader-CzIJsNRF.js";import{t as d}from"./useAttachmentThumbUrl-D6z1SOlU.js";import{f,o as p}from"./route-CPr17rXr.js";import{b as m,d as h,f as g}from"./selectors-DZWoTA9D.js";import{t as _}from"./useDiaryModel-BQGj9xs8.js";import{t as v}from"./CellList-UkuVgkhN.js";import{t as y}from"./usePickNotebookImageFromAlbum-DN3QeK7W.js";import{t as b}from"./useDialog-CjsjDZgz.js";var x=e(r(),1),S=a();function C(){let{identityId:e}=f(),r=_(),a=o(c),C=o(l),w=b(),T=e?g(r,e):void 0,E=h(r,T),D=d(E?.type===`image`?E:void 0,{role:`avatar`}),O=y({notebookId:m,onSuccess:(0,x.useCallback)(t=>{e&&a.updateIdentityAvatar(e,t.id)},[a,e])});if(!T||!e)return(0,S.jsx)(p,{to:`/identities`,replace:!0});let k=!!T.archivedAt,A=()=>{a.archiveIdentity(e),C.navigate({path:`/identities`,replace:!0})};return(0,S.jsxs)(`div`,{className:n.Page.GroupedRoot,"data-test-id":s.page,children:[(0,S.jsx)(u,{title:t(`identity.editTitle`,`Identity details`),showBack:!0}),(0,S.jsxs)(`main`,{className:i(n.Page.Content,n.Cell.GroupStack),"data-test-id":s.content,children:[(0,S.jsx)(v,{items:[{label:t(`identity.name`,`Nickname`),right:{type:`value`,text:T.name},testId:s.name,onClick:()=>C.navigate({path:`/identity/${e}/name`})},{label:t(`identity.avatar`,`Avatar`),right:D?{type:`image`,url:D}:{type:`initial`,text:T.name},testId:s.avatar,disabled:O.uploading,onClick:()=>void O.pick()},{label:t(`messageColor.title`,`Message color`),testId:s.messageColor,onClick:()=>C.navigate({path:`/identity/${e}/message-color`})}]}),(0,S.jsx)(v,{title:t(`identity.messagePosition`,`Message position`),items:[{type:`option`,label:t(`identity.messagePositionLeft`,`Left`),selected:T.messagePosition===`left`,testId:s.positionLeft,onClick:()=>a.updateIdentityMessagePosition(e,`left`)},{type:`option`,label:t(`identity.messagePositionRight`,`Right`),selected:T.messagePosition===`right`,testId:s.positionRight,onClick:()=>a.updateIdentityMessagePosition(e,`right`)}]}),(0,S.jsx)(v,{items:[k?{type:`action`,label:t(`identity.unarchive`,`Unarchive`),testId:s.unarchive,onClick:()=>{a.unarchiveIdentity(e),C.navigate({path:`/identities`,replace:!0})}}:{type:`action`,label:t(`identity.archive`,`Archive`),testId:s.archive,onClick:()=>w({message:t(`identity.archiveConfirm`,`Archive this identity? It can no longer be selected in chat; existing entries are unaffected.`),confirmLabel:t(`identity.archive`,`Archive`),cancelLabel:t(`common.cancel`,`Cancel`),rootTestId:s.archiveConfirm,confirmTestId:s.archiveConfirmAction,cancelTestId:s.archiveCancel,onConfirm:A})}]})]})]})}export{C as IdentityPage};
//# sourceMappingURL=identity-Cm2_0yFb.js.map