1import{h as G,bW as y,p as v,k as q,r as I,j as e,i as t,F as _,B as z,K as u,U as F,f,n as C,S as O,a0 as Q}from"./index-BCjZt3EG.js";import{P as Y}from"./index-C3CS_OeS.js";import{P as K}from"./index-CG6ehG9D.js";import{b as N}from"./useIsCurrentUserAdmin-Dsp2KpRr.js";import{D as R,I as B,a as W}from"./index-Cb9XYQR-.js";import{u as M}from"./useMutation-5fpDe86F.js";import{C as H}from"./index-Cl1Oma0n.js";import{H as X}from"./index-gBcAvSUC.js";import{u as L}from"./useGetEventSettings-CD37Ax2G.js";import{u as J}from"./useUpdateEventSettings-Q2c8tquz.js";import{u as Z}from"./useUploadImage-BC70meIy.js";import{u as $}from"./use-disclosure-C4ezxH9Q.js";import{I as V}from"./IconPlus-C5SSWRCt.js";import{T as n}from"./Table-DCaay5iV.js";import{A as P}from"./Avatar-BJjUOJOy.js";import{B as ee}from"./Badge-BgNvir55.js";import{T as w}from"./Tooltip-DdNrIaue.js";import{A as U}from"./ActionIcon-231onH2S.js";import{I as se}from"./IconEdit-Du_IbbRr.js";import{I as te}from"./IconTrash-C_6jUgus.js";import{u as D}from"./use-form-JzVFRM7k.js";import{T as A}from"./Textarea-CxwG4elz.js";import{T}from"./TextInput-EAd0YT2n.js";import{S as oe}from"./Switch-CLtk6qb_.js";import"./index-Q7SQVUt1.js";import"./LoadingOverlay-BR9bJlAK.js";import"./use-resolved-styles-api-D1DNUn57.js";import"./get-floating-position-gPgTkdY-.js";import"./get-style-object-DUJZA7T_.js";import"./get-env-uyVen0u2.js";import"./InputBase-Da_3HsBN.js";import"./Input-7i8T04tH.js";import"./InputsGroupFieldset-D3WYnPyP.js";import"./use-uncontrolled-Cdx34M6a.js";const S="getEventContacts",re=s=>G({queryKey:[S,s],queryFn:()=>y.all(s),enabled:!!s}),ne=()=>{const s=v();return M({mutationFn:({eventId:r,data:o})=>y.create(r,o),onSuccess:(r,{eventId:o})=>s.invalidateQueries({queryKey:[S,o]})})},de=()=>{const s=v();return M({mutationFn:({eventId:r,contactId:o,data:c})=>y.update(r,o,c),onSuccess:(r,{eventId:o})=>s.invalidateQueries({queryKey:[S,o]})})},ie=()=>{const s=v();return M({mutationFn:({eventId:r,contactId:o})=>y.delete(r,o),onSuccess:(r,{eventId:o})=>s.invalidateQueries({queryKey:[S,o]})})},k=({initialValues:s,onSubmit:r,isPending:o})=>{var x,j;const c=Z(),[m,l]=I.useState(!1),i=D({initialValues:{name:(s==null?void 0:s.name)??"",email:(s==null?void 0:s.email)??"",role:(s==null?void 0:s.role)??"",photo_path:(s==null?void 0:s.photo_path)??"",bio:(s==null?void 0:s.bio)??"",website_url:(s==null?void 0:s.website_url)??"",is_visible:(s==null?void 0:s.is_visible)??!0,sort_order:(s==null?void 0:s.sort_order)??0},validate:{name:a=>a?null:t._({id:"8/brI5"}),email:a=>a&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)?t._({id:"B2Tpo0"}):null}}),p=a=>{const[g]=a;g&&(l(!0),c.mutate({image:g},{onSuccess:E=>{var b;i.setFieldValue("photo_path",((b=E.data)==null?void 0:b.url)??""),l(!1)},onError:()=>{f(t._({id:"xTFwPJ"})),l(!1)}}))},h=i.values.photo_path;return e.jsx("form",{onSubmit:i.onSubmit(r),children:e.jsxs(O,{children:[e.jsxs("div",{children:[e.jsx(u,{size:"sm",fw:500,mb:6,children:t._({id:"qa9cy4"})}),e.jsxs(_,{align:"center",gap:"md",children:[h?e.jsx(P,{src:h,size:64,radius:"xl"}):e.jsx(P,{size:64,radius:"xl",color:"blue",children:((j=(x=i.values.name)==null?void 0:x.charAt(0))==null?void 0:j.toUpperCase())||"?"}),e.jsx(R,{onDrop:p,accept:B,maxSize:5*1024*1024,disabled:m,style:{flex:1,padding:"8px 12px",cursor:"pointer"},children:e.jsxs(_,{gap:"xs",justify:"center",children:[m?e.jsx(Q,{size:"xs"}):e.jsx(W,{size:14}),e.jsx(u,{size:"xs",children:m?t._({id:"gANddk"}):t._({id:"gOm04y"})})]})})]})]}),e.jsx(T,{withAsterisk:!0,label:t._({id:"6YtxFj"}),...i.getInputProps("name")}),e.jsx(T,{label:t._({id:"Ti9Qv1"}),placeholder:t._({id:"2iT1Ga"}),...i.getInputProps("role")}),e.jsx(T,{label:t._({id:"O3oNi5"}),type:"email",placeholder:t._({id:"zzbXUp"}),...i.getInputProps("email")}),e.jsx(A,{label:t._({id:"E+oKCO"}),autosize:!0,minRows:2,...i.getInputProps("bio")}),e.jsx(T,{label:t._({id:"XYcw7G"}),placeholder:"https://...",...i.getInputProps("website_url")}),e.jsx(oe,{label:t._({id:"NfhVFP"}),...i.getInputProps("is_visible",{type:"checkbox"})}),e.jsx(z,{type:"submit",loading:o,children:t._({id:"tfDRzk"})})]})})},ce=({eventId:s})=>{const r=L(s),o=J(),c=D({initialValues:{contacts_section_message:""}});I.useEffect(()=>{r.isFetched&&r.data&&c.setValues({contacts_section_message:r.data.contacts_section_message??""})},[r.isFetched]);const m=l=>{o.mutate({eventSettings:l,eventId:s},{onSuccess:()=>
1C(t._({id:"ZgXiTP"})),onError:()=>f(t._({id:"cYGl4C"}))})};return e.jsxs(H,{children:[e.jsx(X,{heading:t._({id:"7Yj3dw"}),description:t._({id:"ATywRo"})}),e.jsx("form",{onSubmit:c.onSubmit(m),children:e.jsxs("fieldset",{disabled:r.isLoading||o.isPending,style:{border:"none",padding:0,margin:0},children:[e.jsx(A,{autosize:!0,minRows:3,placeholder:t._({id:"IWkXMb"}),...c.getInputProps("contacts_section_message")}),e.jsx(z,{loading:o.isPending,type:"submit",mt:"md",children:t._({id:"tfDRzk"})})]})})]})},Ne=()=>{const{eventId:s}=q(),r=N(),{data:o}=re(s),c=(o==null?void 0:o.data)??[],[m,{open:l,close:i}]=$(!1),[p,h]=I.useState(null),x=ne(),j=de(),a=ie(),g=d=>{x.mutate({eventId:s,data:d},{onSuccess:()=>{C(t._({id:"PS4F+Q"})),i()},onError:()=>f(t._({id:"MlG8+2"}))})},E=d=>{p&&j.mutate({eventId:s,contactId:p.id,data:d},{onSuccess:()=>{C(t._({id:"xD2f6C"})),h(null)},onError:()=>f(t._({id:"MlG8+2"}))})},b=d=>{confirm(t._({id:"M1lc/H"}))&&a.mutate({eventId:s,contactId:d},{onSuccess:()=>C(t._({id:"veWbJr"})),onError:()=>f(t._({id:"DjjYc3"}))})};return e.jsxs(Y,{children:[e.jsx(K,{children:t._({id:"gVfVfe"})}),e.jsx(ce,{eventId:s}),e.jsx(_,{justify:"flex-end",mb:"md",mt:"xl",children:!r&&e.jsx(z,{leftSection:e.jsx(V,{size:16}),onClick:l,children:t._({id:"M0FgOk"})})}),e.jsxs(n,{striped:!0,highlightOnHover:!0,children:[e.jsx(n.Thead,{children:e.jsxs(n.Tr,{children:[e.jsx(n.Th,{children:t._({id:"6YtxFj"})}),e.jsx(n.Th,{children:t._({id:"GDvlUT"})}),e.jsx(n.Th,{children:t._({id:"O3oNi5"})}),e.jsx(n.Th,{children:t._({id:"oh8+os"})}),e.jsx(n.Th,{})]})}),e.jsxs(n.Tbody,{children:[c.map(d=>e.jsxs(n.Tr,{children:[e.jsx(n.Td,{children:e.jsxs(_,{gap:"sm",children:[e.jsx(P,{src:d.photo_path||null,size:32,radius:"xl",color:"blue",children:d.name.charAt(0).toUpperCase()}),e.jsx(u,{fw:500,children:d.name})]})}),e.jsx(n.Td,{children:e.jsx(u,{size:"sm",children:d.role??"â"})}),e.jsx(n.Td,{children:e.jsx(u,{size:"sm",children:d.email??"â"})}),e.jsx(n.Td,{children:e.jsx(ee,{color:d.is_visible?"green":"gray",children:d.is_visible?t._({id:"l75CjT"}):t._({id:"1UzENP"})})}),e.jsx(n.Td,{children:!r&&e.jsxs(_,{gap:"xs",justify:"flex-end",children:[e.jsx(w,{label:t._({id:"ePK91l"}),children:e.jsx(U,{variant:"subtle",onClick:()=>h(d),children:e.jsx(se,{size:16})})}),e.jsx(w,{label:t._({id:"t/YqKh"}),children:e.jsx(U,{variant:"subtle",color:"red",onClick:()=>b(d.id),children:e.jsx(te,{size:16})})})]})})]},d.id)),c.length===0&&e.jsx(n.Tr,{children:e.jsx(n.Td,{colSpan:5,children:e.jsx(u,{ta:"center",c:"dimmed",children:t._({id:"LbaNM4"})})})})]})]}),e.jsx(F,{opened:m,onClose:i,title:t._({id:"M0FgOk"}),children:e.jsx(k,{onSubmit:g,isPending:x.isPending})}),e.jsx(F,{opened:!!p,onClose:()=>h(null),title:t._({id:"mQpWAe"}),children:p&&e.jsx(k,{initialValues:p,onSubmit:E,isPending:j.isPending})})]})};export{Ne 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.