1import{G as he,u as x,af as G,aD as be,cn as ie,j as e,bo as fe,bp as xe,bq as ve,br as ye,bs as Se,v as Me,w as Ne,x as ce,bV as k,bh as Te,bi as ke,bj as Le,bk as Fe,bl as Oe,co as Re,y as de,bt as je,B as T,al as V,bg as Ue,cp as ae,aq as P,bv as W,cq as Pe,cr as Ae,cs as $e,bn as ne,bc as H,ct as Be,cu as We,bH as _e,_ as Ve,cv as le,cw as He,b5 as ze,C as U,bD as A,bG as $,b as B,b8 as K,b9 as Q,ba as z,bb as J,bf as X,bd as Z,b$ as Ye,bT as qe,m as Ge,cx as Ke,c as Qe,b7 as Je,bJ as Xe}from"./index-onZ-siV6.js";import{A as Ze}from"./AdminPageHeader-DMjmiDyT.js";import{r as g}from"./sentry-CwTBLAGw.js";import{M as et}from"./MarkdownRenderer-BzkWXdKk.js";import{o as O,d as i,h as C,_ as a,r as F,s as r,g as N,n as b,j as re,i as we,l as tt,ao as se}from"./utils-SJutkBrZ.js";import{S as De}from"./StripeProductSelect-CiCz1N9k.js";import"./posthog-C-TxGGwT.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"36665b27cc5c935a9a1384aae7c036cb424779c4"};var s=new n.Error().stack;s&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[s]="14fbbed3-7c99-44b7-a6fb-867fd80cbf3f",n._sentryDebugIdIdentifier="sentry-dbid-14fbbed3-7c99-44b7-a6fb-867fd80cbf3f")}catch{}})();const st=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],me=he("file-text",st);const nt=[["path",{d:"M13 16H8",key:"wsln4y"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z",key:"ycz6yz"}]],ue=he("receipt-text",nt),it=[{code:"en-US",label:"English",storageKey:"en"},{code:"pt-BR",label:"Português",storageKey:"pt"}],at={"en-US":"en","pt-BR":"pt"},rt=({open:n,onOpenChange:s})=>{const{t}=x("settings"),o=G(),{data:c}=be(),l=ie(),[d,h]=g.useState("privacy"),[u,w]=g.useState("en-US"),[v,y]=g.useState({"en-US":"","pt-BR":""}),[E,M]=g.useState({"en-US":"","pt-BR":""}),[D,L]=g.useState(),[R,f]=g.useState(),[p,S]=g.useState(!1);g.useEffect(()=>{if(c&&n){const m=c.privacyPolicyContent||{},I=c.termsOfServiceContent||{};y({"en-US":m.en||m["en-US"]||"","pt-BR":m.pt||m["pt-BR"]||""}),M({"en-US":I.en||I["en-US"]||"","pt-BR":I.pt||I["pt-BR"]||""}),L(c.privacyPolicyLastEdited?new Date(c.privacyPolicyLastEdited):void 0),f(c.termsOfServiceLastEdited?new Date(c.termsOfServiceLastEdited):void 0),S(!1)}},[c,n]);const ee=()=>d==="privacy"?v[u]:E[u],Y=m=>{S(!0),d==="privacy"?y(I=>({...I,[u]:m})):M(I=>({...I,[u]:m}))},te=()=>d==="privacy"?D:R,j=m=>{S(!0),d==="privacy"?L(m):f(m)},q=async()=>{try{const m={},I=_=>{const oe={};for(const[Ee,Ce]of Object.entries(_))oe[at[Ee]]=Ce;return oe};Object.values(v).some(_=>_.trim())&&(m.privacyPolicyContent=I(v),D&&(m.privacyPolicyLastEdited=D.toISOString())),Object.values(E).some(_=>_.trim())&&(m.termsOfServiceContent=I(E),R&&(m.termsOfServiceLastEdited=R.toISOString()));const Ie=await l.mutateAsync({data:m});ae(o,Ie),P(t("admin.legalDocuments.messages.saved"),{description:t("admin.legalDocuments.messages.savedDescription")}),S(!1),s(!1)}catch(m){const I=W(m,t("admin.legalDocuments.messages.errorDescription"));P(t("admin.legalDocuments.messages.error"),{description:I})}};return e.jsx(fe,{open:n,onOpenChange:s,children:e.jsxs(xe,{className:"sm:max-w-6xl h-[85vh] flex flex-col",children:[e.jsxs(ve,{children:[e.jsx(ye,{children:t("admin.legalDocuments.modalTitle")}),e.jsx(Se,{children:t("admin.legalDocuments.modalDescription")})]}),e.jsxs(Me,{value:d,onValueChange:m=>h(m),className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[e.jsxs(Ne,{children:[e.jsx(ce,{value:"privacy",children:t("admin.legalDocuments.privacyPolicy")}),e.jsx(ce,{value:"terms",children:t("admin.legalDocuments.termsOfService")})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{htmlFor:"language-select",className:"text-sm whitespace-nowrap",children:[t("admin.legalDocuments.language"),":"]}),e.jsxs(Te,{value:u,onValueChange:m=>w(m),children:[e.jsx(ke,{id:"language-select",className:"w-35",children:e.jsx(Le,{})}),e.jsx(Fe,{children:it.map(m=>e.jsx(Oe,{value:m.code,children:m.label},m.code))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{className:"text-sm whitespace-nowrap",children:[t("admin.legalDocuments.lastEdited"),":"]}),e.jsx(Re,{date:te(),onDateChange:j,placeholder:t("admin.legalDocuments.selectDate"),className:"w-45"})]})]})]}),e.jsx(de,{value:"privacy",className:"flex-1 min-h-0 mt-0",children:e.jsx(pe,{content:ee(),onChange:Y,placeholder:t("admin.legalDocuments.privacyPlaceholder")})}),e.jsx(de,{value:"terms",className:"flex-1 min-h-0 mt-0",children:e.jsx(pe,{content:ee(),onChange:Y,placeholder:t("admin.legalDocuments.termsPlaceholder")})})]}),e.jsxs(je,{children:[e.jsx(T,{variant:"outline",onClick:()=>s(!1),children:t("admin.legalDocuments.cancel")}),e.jsxs(T,{onClick:q,disabled:l.isPending||!p,children:[l.isPending&&e.jsx(V,{variant:"inline",size:"sm",hideText:!0}),l.isPending?t("admin.legalDocuments.saving"):t("admin.legalDocuments.saveChanges")]})]})]})})},pe=({content:n,onChange:s,placeholder:t})=>{const{t:o}=x("settings");return e.jsxs("div",{className:"grid grid-cols-2 gap-4 h-full min-h-0",children:[e.jsxs("div",{className:"flex flex-col min-h-0",children:[e.jsx(k,{className:"mb-2 text-sm font-medium",children:o("admin.legalDocuments.editor")}),e.jsx(Ue,{value:n,onChange:c=>s(c.target.value),placeholder:t,className:"flex-1 min-h-0 resize-none font-mono text-sm"})]}),e.jsxs("div",{className:"flex flex-col min-h-0",children:[e.jsx(k,{className:"mb-2 text-sm font-medium",children:o("admin.legalDocuments.preview")}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto border rounded-md p-4 bg-background",children:n?e.jsx(et,{markdownContent:n}):e.jsx("p",{className:"text-muted-foreground text-sm italic",children:o("admin.legalDocuments.previewPlaceholder")})})]})]})},ot=({open:n,onOpenChange:s})=>{const{t}=x("settings"),{data:o,isLoading:c}=Pe({query:{enabled:n}});return e.jsx(fe,{open:n,onOpenChange:s,children:e.jsxs(xe,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsx(ye,{children:t("admin.weoInvoice.title")}),e.jsx(Se,{children:t("admin.weoInvoice.description")})]}),c||!o?e.jsx(V,{size:"md"}):e.jsx(ct,{config:o,onDone:()=>s(!1)},`${o.weoWebhookUrl}:${o.secretHint}:${o.weoInvoiceEnabled}`)]})})};function ct({config:n,onDone:s}
1){const{t}=x("settings"),o=G(),c=Ae(),l=$e(),[d,h]=g.useState(n.weoWebhookUrl??""),[u,w]=g.useState(""),[v,y]=g.useState(n.weoInvoiceEnabled),[E,M]=g.useState(null),D=n.secretSet;async function L(){if(E!==null){M(null);return}try{const p=await l.mutateAsync();M(p.weoWebhookSecret??"")}catch(p){P.error(W(p,t("admin.weoInvoice.revealFailed")))}}async function R(){try{await c.mutateAsync({data:{weoWebhookUrl:d.trim()||null,weoInvoiceEnabled:v,...u.trim()?{weoWebhookSecret:u.trim()}:{}}}),await o.invalidateQueries({queryKey:le()}),P.success(t("admin.weoInvoice.saved")),s()}catch(p){P.error(W(p,t("admin.weoInvoice.saveFailed")))}}async function f(){try{await c.mutateAsync({data:{weoWebhookSecret:null}}),await o.invalidateQueries({queryKey:le()}),w(""),M(null),y(!1),P.success(t("admin.weoInvoice.secretCleared"))}catch(p){P.error(W(p,t("admin.weoInvoice.saveFailed")))}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(k,{htmlFor:"weo-enabled",className:"cursor-pointer",children:t("admin.weoInvoice.enabledLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(v?"admin.weoInvoice.enabledHint":"admin.weoInvoice.disabledHint")})]}),e.jsx(ne,{id:"weo-enabled",checked:v,onCheckedChange:y,disabled:!D&&!u.trim()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"weo-url",children:t("admin.weoInvoice.urlLabel")}),e.jsx(H,{id:"weo-url",value:d,onChange:p=>h(p.target.value),placeholder:"https://app.weoinvoice.com/api/stripe/...",autoComplete:"off"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"weo-secret",children:t("admin.weoInvoice.secretLabel")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(H,{id:"weo-secret",value:E??u,onChange:p=>{M(null),w(p.target.value)},type:E!==null?"text":"password",placeholder:D?t("admin.weoInvoice.secretPlaceholderSet",{hint:n?.secretHint??""}):t("admin.weoInvoice.secretPlaceholderEmpty"),autoComplete:"off",className:"font-mono"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",onClick:L,disabled:!D||l.isPending,"aria-label":t("admin.weoInvoice.reveal"),title:t("admin.weoInvoice.reveal"),children:E!==null?e.jsx(Be,{}):e.jsx(We,{})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(D?"admin.weoInvoice.secretStoredHint":"admin.weoInvoice.secretMissingHint")})]}),D&&e.jsxs("div",{className:Ve("flex items-start gap-2 rounded-md border p-3","border-destructive/30 text-xs"),children:[e.jsx(_e,{className:"size-4 shrink-0 text-destructive"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:t("admin.weoInvoice.clearWarning")}),e.jsx(T,{type:"button",variant:"destructive",size:"sm",onClick:f,disabled:c.isPending,children:t("admin.weoInvoice.clearSecret")})]})]})]}),e.jsxs(je,{children:[e.jsx(T,{type:"button",variant:"outline",onClick:s,children:t("admin.weoInvoice.cancel")}),e.jsxs(T,{type:"button",onClick:R,disabled:c.isPending,children:[c.isPending&&e.jsx(V,{variant:"inline",size:"sm",hideText:!0}),t("admin.weoInvoice.save")]})]})]})}const dt=255,lt=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),mt=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),ut=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$");O({currentYearSubscriptionProductId:i([r().max(dt),a()]).optional().describe("Stripe product ID for current year subscription sales"),acceptedDiscountMembershipIds:i([re(r()),a()]).optional().describe("List of Stripe product IDs that qualify users for discounts"),membershipPricing:b(),minimumSubscriptionPricing:b(),defaultMembershipSliderValue:b(),defaultEventPrice:i([b(),r().regex(lt),a()]),defaultMemberPrice:i([b(),r().regex(mt),a()]),defaultFirstTimePerkPrice:i([b(),r().regex(ut),a()]),associationName:i([r(),a()]),associationEmail:i([r(),a()]),associationPhone:i([r(),a()]),instagramTag:i([r(),a()]),facebookTag:i([r(),a()]),paymentsMaintenanceMode:N().optional().describe("When enabled, disables all payment transactions (event tickets, memberships)"),deferredEventPaymentsEnabled:N().optional().describe("Create new deferred event/tournament payment commitments"),privacyPolicyContent:i([F(r(),r()),a()]),termsOfServiceContent:i([F(r(),r()),a()]),privacyPolicyLastEdited:i([C({}),a()]),termsOfServiceLastEdited:i([C({}),a()]),id:we(),createdAt:C({}),updatedAt:C({})});const pt=255,gt=1500,ht=2e3,bt=6e3,ft=new RegExp("^(?!^[-+.]*$)[+-]?0
1*\\d*\\.?\\d*$"),xt=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),vt=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),yt=255,St=255,jt=50,Pt=100,wt=100,Dt=O({currentYearSubscriptionProductId:i([r().max(pt),a()]).optional().describe("Stripe product ID for current year subscription sales"),acceptedDiscountMembershipIds:i([re(r()),a()]).optional().describe("List of Stripe product IDs that qualify users for discounts"),membershipPricing:b().default(gt).describe("One-time membership fee in cents (e.g., 1500 = â¬15)"),minimumSubscriptionPricing:b().default(ht).describe("Minimum annual subscription amount in cents (e.g., 2000 = â¬20)"),defaultMembershipSliderValue:b().default(bt).describe("Default slider value for membership page in cents (e.g., 6000 = â¬60)"),defaultEventPrice:i([b(),r().regex(ft),a()]).optional().describe("Default price for events in euros"),defaultMemberPrice:i([b(),r().regex(xt),a()]).optional().describe("Default member price for events in euros"),defaultFirstTimePerkPrice:i([b(),r().regex(vt),a()]).optional().describe("Default first-time perk price for events in euros"),associationName:i([r().max(yt),a()]).optional().describe("Name of the association"),associationEmail:i([r().max(St),a()]).optional().describe("Contact email for the association"),associationPhone:i([r().max(jt),a()]).optional().describe("Contact phone number"),instagramTag:i([r().max(Pt),a()]).optional().describe("Instagram handle without @"),facebookTag:i([r().max(wt),a()]).optional().describe("Facebook page handle"),paymentsMaintenanceMode:N().optional().describe("When enabled, disables all payment transactions (event tickets, memberships)"),deferredEventPaymentsEnabled:N().optional().describe("Create new deferred event/tournament payment commitments"),privacyPolicyContent:i([F(r(),r()),a()]).optional().describe("Privacy policy content by language code"),termsOfServiceContent:i([F(r(),r()),a()]).optional().describe("Terms of service content by language code"),privacyPolicyLastEdited:i([C({}),a()]).optional().describe("Last edited timestamp for privacy policy"),termsOfServiceLastEdited:i([C({}),a()]).optional().describe("Last edited timestamp for terms of service")}),It=255,Et=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),Ct=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"),Mt=new RegExp("^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$");O({currentYearSubscriptionProductId:i([r().max(It),a()]).optional().describe("Stripe product ID for current year subscription sales"),acceptedDiscountMembershipIds:i([re(r()),a()]).optional().describe("List of Stripe product IDs that qualify users for discounts"),membershipPricing:b(),minimumSubscriptionPricing:b(),defaultMembershipSliderValue:b(),defaultEventPrice:i([b(),r().regex(Et),a()]),defaultMemberPrice:i([b(),r().regex(Ct),a()]),defaultFirstTimePerkPrice:i([b(),r().regex(Mt),a()]),associationName:i([r(),a()]),associationEmail:i([r(),a()]),associationPhone:i([r(),a()]),instagramTag:i([r(),a()]),facebookTag:i([r(),a()]),paymentsMaintenanceMode:N().optional().describe("When enabled, disables all payment transactions (event tickets, memberships)"),deferredEventPaymentsEnabled:N().optional().describe("Create new deferred event/tournament payment commitments"),privacyPolicyContent:i([F(r(),r()),a()]),termsOfServiceContent:i([F(r(),r()),a()]),privacyPolicyLastEdited:i([C({}),a()]),termsOfServiceLastEdited:i([C({}),a()]),id:we(),createdAt:C({}),updatedAt:C({})});O({privacyPolicyContent:i([F(r(),r()),a()]).optional(),termsOfServiceContent:i([F(r(),r()),a()]).optional(),privacyPolicyLastEdited:i([C({}),a()]).optional(),termsOfServiceLastEdited:i([C({}),a()]).optional()}).describe("Public schema for legal documents only - used by public pages.");O({weoInvoiceEnabled:N(),weoWebhookUrl:i([r(),a()]).optional(),secretSet:N().optional(),secretHint:i([r(),a()]).optional()}).describe(`weoInvoice configuration for the admin modal. 2 3Never carries the secret. \`secret_hint\` is the last four characters, enough 4to tell one paste from another without putting the value in every response 5the admin page makes.`);O({weoInvoiceEnabled:i([N(),a()]).optional(),weoWebhookUrl:i([r(),a()]).optional(),weoWebhookSecret:i([r(),a()]).optional()}).describe("Unset fields are left alone; explicit nulls clear.\n\nSending `weo_webhook_secret: null` wipes the credential outright, which is\nthe hard kill-switch. `weo_invoice_enabled: false` is the soft one â it\nstops invoicing but keeps the secret, so turning it back on needs no paste.");O({weoInvoiceEnabled:N(),weoWebhookUrl:i([r(),a()]).optional(),secretSet:N().optional(),secretHint:i([r(),a()]).optional()}).describe(`weoInvoice configuration for the admin modal. 6 7Never carries the secret. \`secret_hint\` is the last four characters, enough 8to tell one paste from another without putting the value in every response 9the admin page makes.`);O({weoWebhookSecret:i([r(),a()]).optional()}).describe("Answer to an explicit reveal, kept apart from the settings payload.");const Nt=Dt.pick({currentYearSubscriptionProductId:!0,acceptedDiscountMembershipIds:!0,membershipPricing:!0,minimumSubscriptionPricing:!0,defaultMembershipSliderValue:!0,defaultEventPrice:!0,defaultMemberPrice:!0,defaultFirstTimePerkPr
9ice:!0,associationName:!0,associationEmail:!0,associationPhone:!0,instagramTag:!0,facebookTag:!0}).extend({membershipPricing:se().nonnegative().optional(),minimumSubscriptionPricing:se().nonnegative().optional(),defaultMembershipSliderValue:se().nonnegative().optional()}).refine(n=>{const s=n.defaultMembershipSliderValue??0,t=n.minimumSubscriptionPricing??0;return s>=t},{message:"Default slider value must be greater than or equal to minimum subscription pricing",path:["defaultMembershipSliderValue"]}),Tt={currentYearSubscriptionProductId:"",acceptedDiscountMembershipIds:[],membershipPricing:0,minimumSubscriptionPricing:0,defaultMembershipSliderValue:0,defaultEventPrice:"",defaultMemberPrice:"",defaultFirstTimePerkPrice:"",associationName:"",associationEmail:"",associationPhone:"",instagramTag:"",facebookTag:""};function kt(){const{t:n}=x("settings"),s=G(),{data:t,isLoading:o}=be({query:{staleTime:0,refetchOnMount:"always"}}),{data:c}=He(),l=ie(),[d,h]=g.useState([]),[u,w]=g.useState(""),v=g.useMemo(()=>Object.fromEntries(d.map(f=>[f,c?.find(p=>p.productId===f)??{productId:f}])),[d,c]),y=tt({resolver:ze(Nt),defaultValues:Tt});g.useEffect(()=>{if(!t)return;const f={currentYearSubscriptionProductId:t.currentYearSubscriptionProductId??"",acceptedDiscountMembershipIds:t.acceptedDiscountMembershipIds??[],membershipPricing:(t.membershipPricing||0)/100,minimumSubscriptionPricing:(t.minimumSubscriptionPricing||0)/100,defaultMembershipSliderValue:(t.defaultMembershipSliderValue||0)/100,defaultEventPrice:t.defaultEventPrice??"",defaultMemberPrice:t.defaultMemberPrice??"",defaultFirstTimePerkPrice:t.defaultFirstTimePerkPrice??"",associationName:t.associationName??"",associationEmail:t.associationEmail??"",associationPhone:t.associationPhone??"",instagramTag:t.instagramTag??"",facebookTag:t.facebookTag??""};y.reset(f)},[t,y]);const[E,M]=g.useState(void 0);t&&t!==E&&(M(t),h(t.acceptedDiscountMembershipIds??[]));const D=g.useCallback(f=>{const p=f.productId;if(!p){P.error(n("admin.messages.invalidProduct"),{description:n("admin.messages.productIdMissing")});return}if(d.includes(p)){P.error(n("admin.messages.duplicateProduct"),{description:n("admin.messages.productAlreadyAdded")});return}h(S=>[...S,p]),w("")},[d,n]),L=g.useCallback(f=>{h(p=>p.filter(S=>S!==f))},[]),R=async f=>{try{const p=y.formState.dirtyFields,S={};[{field:"currentYearSubscriptionProductId"},{field:"defaultEventPrice"},{field:"defaultMemberPrice"},{field:"defaultFirstTimePerkPrice"},{field:"associationName"},{field:"associationEmail"},{field:"associationPhone"},{field:"instagramTag"},{field:"facebookTag"},{field:"membershipPricing",transform:j=>j?Math.round(Number(j)*100):null},{field:"minimumSubscriptionPricing",transform:j=>j?Math.round(Number(j)*100):null},{field:"defaultMembershipSliderValue",transform:j=>j?Math.round(Number(j)*100):null}].forEach(({field:j,transform:q})=>{if(p[j]){const m=f[j];S[j]=q?q(m):m||null}});const Y=t?.acceptedDiscountMembershipIds??[];if(JSON.stringify(d)!==JSON.stringify(Y)&&(S.acceptedDiscountMembershipIds=d.length>0?d:null),Object.keys(S).length===0){P(n("admin.messages.noChanges"),{description:n("admin.messages.noChangesDescription")});return}const te=await l.mutateAsync({data:S});ae(s,te),P(n("admin.messages.settingsUpdated"),{description:n("admin.messages.settingsUpdatedDescription")})}catch(p){const S=W(p,n("admin.messages.errorUpdatingSettingsDescription"));P(n("admin.messages.errorUpdatingSettings"),{description:S})}};return{form:y,settings:t,isLoading:o,isPending:l.isPending,onSubmit:y.handleSubmit(R),discountIds:d,selectedDiscountProductId:u,setSelectedDiscountProductId:w,selectedProducts:v,addDiscountProduct:D,removeDiscountProduct:L}}function Lt({form:n,discountIds:s,selectedDiscountProductId:t,setSelectedDiscountProductId:o,selectedProducts:c,addDiscountProduct:l,removeDiscountProduct:d}){const{t:h}=x("settings");return e.jsxs(U,{children:[e.jsx(A,{children:e.jsx($,{children:h("admin.membershipSettings.title")})}),e.jsxs(B,{className:"space-y-6",children:[e.jsx(K,{control:n.control,name:"currentYearSubscriptionProductId",render:({field:u})=>e.jsxs(Q,{children:[e.jsx(z,{children:h("admin.membershipSettings.currentYearSubscriptionProductId.label")}),e.jsx(J,{children:e.jsx(De,{value:u.value||"",onValueChange:u.onChange,placeholder:h("admin.membershipSettings.currentYearSubscriptionProductId.placeholder")})}),e.jsx(X,{children:h("admin.membershipSettings.currentYearSubscriptionProductId.description")}),e.jsx(Z,{})]})}),e.jsx(Ft,{discountIds:s,selectedDiscountProductId:t,setSelectedDiscountProductId:o,selectedProducts:c,addDiscountProduct:l,removeDiscountProduct:d})]})]})}function Ft({discountIds:n,selectedDiscountProductId:s,setSelectedDiscountProductId:t,selectedProducts:o,addDiscountProduct:c,removeDiscountProduct:l}){const{t:d}=x("settings");return e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{children:d("admin.membershipSettings.acceptedDiscountMembershipIds.label")}),e.jsx(X,{children:d("admin.membershipSettings.acceptedDiscountMembershipIds.description")}),e.jsx(De,{value:s||"",onValueChange:t,onProductSelect:c,placeholder:d("admin.membershipSettings.acceptedDiscountMembershipIds.placeholder")}),e.jsx("div",{className:"space-y-2 mt-2",children:n.map(h=>e.jsx(Ot,{id:h,product:o[h],onRemove:l},h))})]})}function Ot({id:n,product:s,onRemove:t}){const{t:o}=x("settings"),c=s?.name?`${s.name} - ${n}`:n,l=s?.priceCents!==void 0?` (â¬${((s.priceCents||0)/100).toFixed(2)})`:"";return e.jsxs("div",{className:"flex items-center justify-between bg-muted p-2 rounded",children:[e.jsxs("span",{className:"text-sm font-mono",children:[c,l]}),e.jsx(Ye,{tooltipContent:o("admin.membershipSettings.acceptedDiscountMembershipIds.removeButton"),type:"button",variant:"ghost",size:"icon",onClick:()=>t(n),icon:()=>e.jsx(qe,{className:"h-4 w-4"})})]})}const Rt=[{name:"membershipPricing",placeholder:"15.00"},{name:"minimumSubscriptionPricing",placeholder:"20.00"},{name:"defaultMembershipSliderValue",placeholder:"60.00"},{name:"defaultEventPrice",placeholder:"15.00"},{name:"defaultMemberPrice",placeholder:"12.00"}
9,{name:"defaultFirstTimePerkPrice",placeholder:"5.00"}];function Ut({form:n}){const{t:s}=x("settings");return e.jsxs(U,{children:[e.jsx(A,{children:e.jsx($,{children:s("admin.pricingDefaults.title")})}),e.jsx(B,{className:"space-y-4",children:Rt.map(({name:t,placeholder:o})=>e.jsx(K,{control:n.control,name:t,render:({field:c})=>e.jsxs(Q,{children:[e.jsx(z,{children:s(`admin.pricingDefaults.${t}.label`)}),e.jsx(J,{children:e.jsx(H,{...c,type:"number",step:"0.01",min:"0",startAdornment:e.jsx("span",{className:"text-muted-foreground",children:"â¬"}),placeholder:o})}),e.jsx(X,{children:s(`admin.pricingDefaults.${t}.description`)}),e.jsx(Z,{})]})},t))})]})}const At=[{name:"associationName",type:"text"},{name:"associationEmail",type:"email"},{name:"associationPhone",type:"tel"}];function $t({form:n}){const{t:s}=x("settings");return e.jsxs(U,{children:[e.jsx(A,{children:e.jsx($,{children:s("admin.associationInfo.title")})}),e.jsx(B,{className:"space-y-4",children:At.map(({name:t,type:o})=>e.jsx(K,{control:n.control,name:t,render:({field:c})=>e.jsxs(Q,{children:[e.jsx(z,{children:s(`admin.associationInfo.${t}.label`)}),e.jsx(J,{children:e.jsx(H,{...c,type:o,placeholder:s(`admin.associationInfo.${t}.placeholder`)})}),e.jsx(Z,{})]})},t))})]})}const Bt=["instagramTag","facebookTag"];function Wt({form:n}){const{t:s}=x("settings");return e.jsxs(U,{children:[e.jsx(A,{children:e.jsx($,{children:s("admin.socialMedia.title")})}),e.jsx(B,{className:"space-y-4",children:Bt.map(t=>e.jsx(K,{control:n.control,name:t,render:({field:o})=>e.jsxs(Q,{children:[e.jsx(z,{children:s(`admin.socialMedia.${t}.label`)}),e.jsx(J,{children:e.jsx(H,{...o,startAdornment:e.jsx("span",{className:"text-muted-foreground",children:"@"}),placeholder:s(`admin.socialMedia.${t}.placeholder`)})}),e.jsx(X,{children:s(`admin.socialMedia.${t}.description`)}),e.jsx(Z,{})]})},t))})]})}function _t({privacyPolicyLastEdited:n,termsOfServiceLastEdited:s,onEditClick:t}){const{t:o}=x("settings"),{formatDate:c}=Ge();return e.jsxs(U,{children:[e.jsx(A,{children:e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-5 w-5"}),o("admin.legalDocuments.title")]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("admin.legalDocuments.description")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx(ge,{label:o("admin.legalDocuments.privacyPolicy"),lastEdited:n,notConfiguredText:o("admin.legalDocuments.notConfigured"),lastEditedTemplate:l=>o("admin.legalDocuments.lastEditedDate",{date:c(new Date(l),"PPP")})}),e.jsx(ge,{label:o("admin.legalDocuments.termsOfService"),lastEdited:s,notConfiguredText:o("admin.legalDocuments.notConfigured"),lastEditedTemplate:l=>o("admin.legalDocuments.lastEditedDate",{date:c(new Date(l),"PPP")})})]}),e.jsxs(T,{type:"button",variant:"outline",onClick:t,className:"w-full",children:[e.jsx(me,{className:"h-4 w-4 mr-2"}),o("admin.legalDocuments.editButton")]})]})]})}function ge({label:n,lastEdited:s,notConfiguredText:t,lastEditedTemplate:o}){return e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[n,":"]}),e.jsx("span",{className:"text-muted-foreground",children:s?o(s):t})]})}function Vt({settings:n}){const{t:s}=x("settings"),t=G(),o=ie(),[c,l]=g.useState(!1),d=n?.paymentsMaintenanceMode??!1,h=async(u,w)=>{l(!0);try{const v=await o.mutateAsync({data:{[u]:w}});ae(t,v),P(s(u==="paymentsMaintenanceMode"?w?"admin.maintenanceMode.enabledToast":"admin.maintenanceMode.disabledToast":w?"admin.deferredPayments.enabledToast":"admin.deferredPayments.disabledToast"))}catch(v){const y=W(v,s("admin.messages.errorUpdatingSettingsDescription"));P(s("admin.messages.errorUpdatingSettings"),{description:y})}finally{l(!1)}};return e.jsxs(U,{className:"border-destructive/30",children:[e.jsxs(A,{children:[e.jsx($,{children:s("admin.maintenanceMode.title")}),e.jsx(Ke,{children:s("admin.maintenanceMode.description")})]}),e.jsxs(B,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ne,{id:"payments-maintenance-mode",checked:d,onCheckedChange:u=>h("paymentsMaintenanceMode",u),disabled:c}),e.jsx(k,{htmlFor:"payments-maintenance-mode",className:"cursor-pointer",children:s(d?"admin.maintenanceMode.enabledLabel":"admin.maintenanceMode.disabledLabel")})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ne,{id:"deferred-event-payments",checked:n?.deferredEventPaymentsEnabled??!1,onCheckedChange:u=>h("deferredEventPaymentsEnabled",u),disabled:c}),e.jsx(k,{htmlFor:"deferred-event-payments",className:"cursor-pointer",children:s("admin.deferredPayments.label")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin.deferredPayments.description")})]})]})]})}function Ht({onEditClick:n}){const{t:s}=x("settings"),{data:t}=Pe(),o=t?.weoInvoiceEnabled??!1,c=t?.secretSet??!1;return e.jsxs(U,{children:[e.jsx(A,{children:e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),s("admin.weoInvoice.title")]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("admin.weoInvoice.cardDescription")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{children:[s("admin.weoInvoice.statusLabel"),":"]}),e.jsx(Qe,{variant:o?"default":"secondary",children:s(o?"admin.weoInvoice.statusOn":"admin.weoInvoice.statusOff")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[s("admin.weoInvoice.secretLabel"),":"]}),e.jsx("span",{className:"text-muted-foreground font-mono",children:c?`â¢â¢â¢â¢${t?.secretHint??""}`:s("admin.weoInvoice.notConfigured")})]})]}),e.jsxs(T,{type:"button",variant:"outline",onClick:n,className:"w-full",children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}),s("admin.weoInvoice.editButton")]})]})]})}const zt=()=>{const{t:n}=x("settings"),[s,t]=g.useState(!1),[o,c]=g.useState(!1),{form:l,settings:d,isLoading:h,isPending:u,onSubmit:w,discountIds:v,selectedDiscountProductId:y,setSelectedDiscountProductId:E,selectedProducts:M,addDiscountProduct:D,removeDiscountProduct:L}=kt();return h?e.jsx(V,{size:"md"}):e.jsxs(Je,{...l,children:[e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(Lt,{form:l,discountIds:v,selectedDiscountProductId:y,setSelectedDiscountProductId:E,selectedProducts:M,addDiscountProduct:D,removeDiscountProduct:L}),e.jsx(Ut,{form:l}),e.jsx($t,{form:l}),e.jsx(Wt,{form:l}),e.jsx(_t,{privacyPolicyLastEdited:d?.privacyPolicyLastEdited,termsOfServiceLastEdited:d?.termsOfServiceLastEdited,onEditClick:()=>t(!0)}),e.jsx(Vt,{settings:d}),e.jsx(Ht,{onEditClick:()=>c(!0)})]}),e.jsxs(T,{type:"submit",disabled:u,children:[u&&e.jsx(V,{variant:"inline",size:"sm",hideText:!0}),n(u?"admin.membershipSettings.saving":"admin.membershipSettings.saveSettings")]})]}),e.jsx(rt,{open:s,onOpenChange:t}),e.jsx(ot,{open:o,onOpenChange:c})]})};function Yt(){const{t:n}=x("settings");return e.jsxs(Xe,{children:[e.jsx(Ze,{title:n("admin.title"),description:n("admin.description")}),e.jsx(zt,{})]})}const ss=Yt;export{ss as component};
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.