1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[385,9310],{34605:(e,i,a)=>{"use strict";a.r(i),a.d(i,{default:()=>ex});var r=a(78488),n=a(58723),s=a(45738),l=a(48339),t=a(57179),o=a(81204),d=a(72788),c=a(35327),u=a(84975),_=a(68513),m=a(46498),v=a(15831),f=a(65382),p=a(63378),y=a(65754);let x=y.Ik({recordId:y.Yj().nullable().optional(),name:y.Yj().min(1,"Name is required"),override_rules:s.D6Z.omit({schema_version:!0,start_iso_date:!0,end_iso_date_inclusive:!0}).extend({priority:y.au.number().int(),start_iso_date:y.p6({required_error:"Start date is required"}),end_iso_date_inclusive:y.p6({required_error:"End date is required"})})}),h=y.Ik({recordId:y.Yj().nullable().optional(),effective_on:y.p6({required_error:"Effective date is required"}),rules:s.WzF.omit({schema_version:!0}),overrides:y.YO(x).default([])}),g=y.Ik({recordId:y.Yj().nullable().optional(),name:y.Yj().min(1,"Name is required"),override_unavailable_message:y.Yj().optional(),override_rules:y.Ik({priority:y.au.number().int(),start_iso_date:y.p6({required_error:"Start date is required"}),end_iso_date_inclusive:y.p6({required_error:"End date is required"}),rules:y.gM("frequency",[y.Ik({frequency:y.eu("DAILY"),available:y.zM()}),y.Ik({frequency:y.eu("WEEKLY")}).merge(s.dQi.partial())])})}),b=y.Ik({recordId:y.Yj().nullable().optional(),effective_on:y.p6({required_error:"Effective date is required"}),expires_on:y.p6({required_error:"Expires date is required"}),unavailable_message:y.Yj().optional(),rules:s.dQi,overrides:y.YO(g).default([])}).refine(e=>e.expires_on>e.effective_on,{message:"Expires date must be after effective date",path:["expires_on"]}),j=y.Ik({name:y.Yj().min(1,"Configuration name is required"),is_public:y.zM(),is_walk_in_only:y.zM(),max_daily_passes:y.au.number().int().min(1,"Must be at least 1"),email_callout_text:y.Yj().optional(),registration_advance_days:y.au.number().int().min(0,"Must be 0 or more"),registration_advance_time:y.p6({required_error:"Required"}),registration_cutoff_days:y.au.number().int().min(0,"Must be 0 or more"),registration_cutoff_time:y.p6({required_error:"Required"}),pricing_rules:y.YO(h).min(1,"At least one pricing rule is required"),availability_rules:y.YO(b).default([]),price_modifier_ids:y.YO(y.Yj()).default([])});function N(e){if("string"!=typeof e)return null;let[i,a]=e.split(":").map(Number);return null==i||null==a||isNaN(i)||isNaN(a)?null:new Date(1970,0,1,i,a)}function w(e){let[i,a,r]=e.split("-").map(Number);return new Date(i,a-1,r)}function S(e){return"".concat(String(e.getHours()).padStart(2,"0"),":").concat(String(e.getMinutes()).padStart(2,"0"))}function E(e){let i=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return"".concat(i,"-").concat(a,"-").concat(r)}function q(e){var i,a;return{id:null!=(i=e.recordId)?i:void 0,effective_on:E(e.effective_on),rules:{...e.rules,schema_version:s.Rks},overrides:(null!=(a=e.overrides)?a:[]).map(e=>{var i;let a=new Date(e.override_rules.end_iso_date_inclusive);return a.setDate(a.getDate()+1),{id:null!=(i=e.recordId)?i:void 0,name:e.name,expires_on:E(a),override_rules:{...e.override_rules,schema_version:s.Rks,start_iso_date:E(e.override_rules.start_iso_date),end_iso_date_inclusive:E(e.override_rules.end_iso_date_inclusive),prices:function(e){if("WEEKLY"!==e.frequency)return e;let i={frequency:"WEEKLY"};for(let a of s.j__){let r=e[a];!(null==r||"number"!=typeof r.cents||Number.isNaN(r.cents))&&r.units&&(i[a]={cents:r.cents,units:r.units})}return i}(e.override_rules.prices)}}})}}function k(e){var i;let a=null!=(i=e.override_rules)?i:{};return{recordId:e.id,name:e.name,override_rules:{...a,start_iso_date:a.start_iso_date?w(a.start_iso_date):void 0,end_iso_date_inclusive:a.end_iso_date_inclusive?w(a.end_iso_date_inclusive):void 0}}}function D(e){var i;let a=(null!=(i=e.entry_pass_pricing_overrides)?i:[]).map(k).sort((e,i)=>{var a,r,n,s,l,t;return(null!=(l=null==(r=e.override_rules)||null==(a=r.end_iso_date_inclusive)?void 0:a.getTime())?l:0)-(null!=(t=null==(s=i.override_rules)||null==(n=s.end_iso_date_inclusive)?void 0:n.getTime())?t:0)});return{recordId:e.id,effective_on:w(e.effective_on),rules:e.rules,overrides:a}}let C={cents:0,units:"PER_VEHICLE"},Y={recordId:null,effective_on:new Date,rules:{default_resident_prices:{sunday:{...C},monday:{...C},tuesday:{...C},wednesday:{...C},thursday:{...C},friday:{...C},saturday:{...C}},universal_nonresident_fee_cents:0},overrides:[]},I={recordId:null,name:"",override_rules:{priority:0,residency:"RESIDENT",start_iso_date:new Date,end_iso_date_inclusive:ne
1w Date,prices:{frequency:"DAILY",cents:0,units:"PER_PERSON"}}},z={recordId:null,effective_on:new Date,expires_on:new Date,unavailable_message:"",rules:{sunday:!0,monday:!0,tuesday:!0,wednesday:!0,thursday:!0,friday:!0,saturday:!0},overrides:[]},A={recordId:null,name:"",override_unavailable_message:"",override_rules:{priority:0,start_iso_date:new Date,end_iso_date_inclusive:new Date,rules:{frequency:"DAILY",available:!0}}};function B(e){var i,a;return{id:null!=(i=e.recordId)?i:void 0,effective_on:E(e.effective_on),expires_on:E(e.expires_on),unavailable_message:e.unavailable_message||null,rules:{...e.rules,schema_version:s.K$E},overrides:(null!=(a=e.overrides)?a:[]).map(e=>{var i;let a=new Date(e.override_rules.end_iso_date_inclusive);return a.setDate(a.getDate()+1),{id:null!=(i=e.recordId)?i:void 0,name:e.name,expires_on:E(a),override_unavailable_message:e.override_unavailable_message||null,override_rules:{schema_version:s.K$E,priority:e.override_rules.priority,start_iso_date:E(e.override_rules.start_iso_date),end_iso_date_inclusive:E(e.override_rules.end_iso_date_inclusive),rules:e.override_rules.rules}}})}}function P(e){var i,a;let r=null!=(i=e.override_rules)?i:{};return{recordId:e.id,name:e.name,override_unavailable_message:null!=(a=e.override_unavailable_message)?a:"",override_rules:{...r,start_iso_date:r.start_iso_date?w(r.start_iso_date):void 0,end_iso_date_inclusive:r.end_iso_date_inclusive?w(r.end_iso_date_inclusive):void 0}}}function T(e){var i,a;let r=(null!=(i=e.entry_pass_availability_rule_overrides)?i:[]).map(P).sort((e,i)=>{var a,r,n,s,l,t;return(null!=(l=null==(r=e.override_rules)||null==(a=r.end_iso_date_inclusive)?void 0:a.getTime())?l:0)-(null!=(t=null==(s=i.override_rules)||null==(n=s.end_iso_date_inclusive)?void 0:n.getTime())?t:0)});return{recordId:e.id,effective_on:w(e.effective_on),expires_on:w(e.expires_on),unavailable_message:null!=(a=e.unavailable_message)?a:"",rules:e.rules,overrides:r}}function R(e){let{membership:i,onSaved:a}=e,n=(0,_.hV)(),s=(0,p.qN)(),c=(0,p.xN)(),{data:u,loading:m}=(0,d.Mnm)({variables:{where:{organization_id:{_eq:n}}}}),v=i.associated_membership_forms,y=(0,o.useMemo)(()=>new Map(v.filter(e=>e.form_definition_id).map(e=>[e.form_definition_id,e])),[v]),x=(0,o.useMemo)(()=>{var e,a=null!=(e=i.soft_deleted_membership_forms)?e:[];let r=new Map;for(let e of a)e.form_definition_id&&!r.has(e.form_definition_id)&&r.set(e.form_definition_id,{id:e.id,is_required:e.is_required});return r},[i.soft_deleted_membership_forms]),h=(0,o.useMemo)(()=>{var e;return null!=(e=null==u?void 0:u.form_definitions)?e:[]},[null==u?void 0:u.form_definitions]),g=(0,o.useMemo)(()=>h.map(e=>{var i,a;let r=y.get(e.id);return{formDefinitionId:e.id,name:null!=(i=e.name)?i:"Unnamed form",type:e.type,existingJunction:null!=r?r:null,associated:null!=r,required:null!=(a=null==r?void 0:r.is_required)&&a}}),[h,y]),[b,j]=(0,o.useState)(g),[N,w]=(0,o.useState)(!1);(0,o.useEffect)(()=>{N||j(g)},[g,N]);let S=(0,o.useCallback)(()=>{j(g),w(!1)},[g]),[E,{loading:q}]=(0,d.O26)({onCompleted:()=>{c("Forms updated"),w(!1),a()},onError:()=>s(f.h1)});return m?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-4",role:"status","aria-label":"Loading forms",children:[(0,r.jsx)(t.A,{size:16,"aria-hidden":!0}),(0,r.jsx)(l.EY.BodySmall,{children:"Loading formsâ¦"})]}):0===h.length?(0,r.jsx)(l.EY.BodySmall,{className:"text-secondary",children:"No form definitions found for this organization."}):(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b text-gray-500",children:[(0,r.jsx)("th",{className:"pb-2 font-medium",children:"Form"}),(0,r.jsx)("th",{className:"pb-2 font-medium",children:"Type"}),(0,r.jsx)("th",{className:"pb-2 text-center font-medium",children:"Associated"}),(0,r.jsx)("th",{className:"pb-2 text-center font-medium",children:"Required"})]})}),(0,r.jsx)("tbody",{children:b.map(e=>(0,r.jsxs)("tr",{className:"border-b last:border-0",children:[(0,r.jsx)("td",{className:"py-2",children:e.name}),(0,r.jsx)("td",{className:"py-2 text-gray-500",children:function(e){switch(e){case d.NRE.Disclaimer:return"Disclaimer";case d.NRE.File:return"File";case d.NRE.SchemaForm:return"Custom Form";default:return e}}(e.type)}),(0,r.jsx)("td",{className:"py-2 text-center",children:(0,r.jsx)(l.Sc,{checked:e.associated,onChange:()=>{var i;return i=e.formDefinitionId,void(j(e=>e.map(e=>{if(e.formDefinitionId!==i)return e;if(e.associated)return{...e,associated:!1,required:!1};let a=x.has(i);return{...e,associated:!0,required:!1,existingJunction:a?null:e.existingJunction}})),w(!0))},inputProps:{"aria-label":"Associate ".concat(e.name)}
1,fullWidth:!1})}),(0,r.jsx)("td",{className:"py-2 text-center",children:(0,r.jsx)(l.Sc,{checked:e.required,disabled:!e.associated,onChange:()=>{var i;return i=e.formDefinitionId,void(j(e=>e.map(e=>e.formDefinitionId===i?{...e,required:!e.required}:e)),w(!0))},inputProps:{"aria-label":"Require ".concat(e.name)},fullWidth:!1})})]},e.formDefinitionId))})]}),N&&(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(l.nO.Primary,{size:"sm",onClick:function(){let{insertMembershipForms:e,updateMembershipForms:a}=function(e){let{rows:i,membershipId:a,organizationId:r,unassociatedAt:n,softDeletedJunctionByFormDefinitionId:s=new Map}=e,l=[],t=[];for(let e of i){let i=e.existingJunction,d=s.get(e.formDefinitionId);if(e.associated&&!i&&d)t.push({where:{id:{_eq:d.id}},_set:{deleted_at:null,is_required:e.required}});else if(e.associated&&!i)l.push({membership_id:a,organization_id:r,form_definition_id:e.formDefinitionId,is_required:e.required});else if(!e.associated&&i)t.push({where:{id:{_eq:i.id}},_set:{deleted_at:n.toISOString()}});else if(e.associated&&i){var o;e.required!==(null!=(o=i.is_required)&&o)&&t.push({where:{id:{_eq:i.id}},_set:{is_required:e.required}})}}return{insertMembershipForms:l,updateMembershipForms:t}}({rows:b,membershipId:i.id,organizationId:n,unassociatedAt:new Date,softDeletedJunctionByFormDefinitionId:x});E({variables:{insertMembershipForms:e,updateMembershipForms:a}})},loading:q,disabled:q,children:"Save forms"}),(0,r.jsx)(l.$n.Secondary,{size:"sm",onClick:S,disabled:q,children:"Reset"})]})]})}var L=a(63018);function F(e){var i,a;let{membership:n,onSaved:s}=e,o=(0,_.hV)(),c=(0,p.qN)(),u=(0,p.xN)(),{data:m,loading:v}=(0,d.zr)({variables:{where:{organization_id:{_eq:o},deleted_at:{_is_null:!0}}},skip:!o}),[y,{loading:x}]=(0,d.jR3)({onCompleted:()=>{u("General ledger entry updated"),s()},onError:()=>c(f.h1)}),h=[{value:"",label:"None"},...(null!=(i=null==m?void 0:m.entries)?i:[]).map(e=>{if(1!==e.current_version.length)return null;let i=e.current_version[0];return{value:e.id,label:(0,L.J)(i)}}).filter(e=>null!==e)];return v?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-4",children:[(0,r.jsx)(t.A,{size:16}),(0,r.jsx)(l.EY.BodySmall,{children:"Loading GL entriesâ¦"})]}):(0,r.jsx)("div",{className:"w-[400px]",children:(0,r.jsx)(l.pp,{name:"general_ledger_entry_id",label:"General ledger entry",searchable:!0,options:h,value:null!=(a=n.general_ledger_entry_id)?a:"",onChange:e=>{var i;return i=e.target.value,void y({variables:{membership_id:n.id,general_ledger_entry_id:i||null}})},disabled:x})})}var M=a(22585),$=a(26011),W=a(33237),O=a(1599),H=a(15410),V=a(3935),U=a(74961);let K={sunday:"Sun",monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat"},G=s.qQJ.map(e=>({label:"DAILY"===e?"Daily":"Weekly",value:e}));function J(e){return e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Z(e){let{prefix:i,day:a}=e,{setValue:n,getValues:s,watch:t}=(0,W.xW)(),d="".concat(i,".").concat(a),[c,u]=(0,o.useState)(()=>null!=s(d));return(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(l.Sc,{label:K[a],checked:c,onChange:(e,i)=>{u(i),i?n(d,!0):n(d,void 0)}}),c&&(0,r.jsx)(l.Sc,{label:"Available",checked:!0===t(d),onChange:(e,i)=>n(d,i)})]})}function Q(e){let{ruleIndex:i,overrideIndex:a}=e,{setValue:n,watch:s}=(0,W.xW)(),t="availability_rules.".concat(i,".overrides.").concat(a,".override_rules.rules.available"),o=s(t);return(0,r.jsx)(l.Sc,{label:"Available",checked:!0===o,onChange:(e,i)=>n(t,i)})}function X(e){let{ruleIndex:i,overrideIndex:a,control:n,onRemove:t,defaultCollapsed:d}=e,[c,u]=(0,o.useState)(d),_="availability_rules.".concat(i,".overrides.").concat(a),m="".concat(_,".override_rules"),v=(0,W.FH)({control:n,name:"".concat(m,".rules.frequency")}),f=(0,W.FH)({control:n,name:"".concat(_,".name")}),p=(0,W.FH)({control:n,name:"".concat(m,".end_iso_date_inclusive")}),y=new Date;y.setHours(0,0,0,0);let x=p instanceof Date&&p<y;return(0,r.jsxs)("div",{className:"rounded border border-gray-300",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between p-3",onClick:()=>u(e=>!e),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,r.jsx)(M.A,{className:"h-5 w-5 text-gray-400"}):(0,r.jsx)($.A,{className:"h-5 w-5 text-gray-400"}),(0,r.jsx)(l.EY.BodySmallSemiBold,{children:f?"".concat(f):"Override ".concat(a+1)}),x&&(0,r.jsx)(l.vw.Negative,{label:"Expired",size:"default"})]}),t&&(0,r.jsx)(l.$n.Tertiary,{className:"min-w-0 p-0",size:"sm",onClick:e=>{e.stopPropagation(),t()},children:"Remove"})]}),!c&&(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.mB,{name:"".concat(_,".name"),label:"Name",required:!0,placeholder:"e.g., Memorial Day"}),(0,r.jsx)(U.Y$,{name:"".concat(m,".priority"),label:"Priority",required:!0})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.FD,{name:"".concat(m,".start_iso_date"),label:"Start Date",required:!0}),(0,r.jsx)(U.FD,{name:"".concat(m,".end_iso_date_inclusive"),label:"End Date",required:!0})]}),(0,r.jsx)(U.mB,{name:"".concat(_,".override_unavailable_message"),label:"Unavailable Message",placeholder:"e.g., Closed for holiday",helperText:"Shown to visitors when this override blocks a date"}),(0,r.jsx)(U.$L,{name:"".concat(m,".rules.frequency"),label:"Frequency",required:!0,options:G}),"DAILY"===v&&(0,r.jsx)(Q,{ruleIndex:i,overrideIndex:a}),"WEEKLY"===v&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(l.EY.BodySmall,{color:"secondary",children:"Choose which days to override. Days left unchecked use the base rule."}),s.j__.map(e=>(0,r.jsx)(Z,{prefix:"".concat(m,".rules"),day:e},e))]})]})]})}function ee(e){let{ruleIndex:i,control:a,allowRemove:n}=e,{fields:s,append:t,remove:o}=(0,W.jz)({control:a,name:"availability_rules.".concat(i,".overrides")});return(0,r.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,r.jsx)(l.EY.BodyLargeSemiBold,{children:"Availability overrides"}),s.map((e,s)=>(0,r.jsx)(X,{ruleIndex:i,overrideIndex:s,control:a,onRemove:n?()=>o(s):void 0,defaultCollapsed:function(e){var i;let a=null==(i=e.override_rules)?void 0:i.end_iso_date_inclusive;if(!a)return!1;let r=new Date;return r.setHours(0,0,0,0),a<r}(e)},e.id)),(0,r.jsx)(l.$n.Tertiary,{size:"sm",type:"button",onClick:()=>t({...A}),children:"+ Add override"})]})}function ei(e){let{index:i,control:a,isEditing:n,canRemove:t,onRemove:d}=e,[c,u]=(0,o.useState)(!1),_=(0,W.FH)({control:a,name:"availability_rules.".concat(i,".effective_on")}),m=(0,W.FH)({control:a,name:"availability_rules.".concat(i,".expires_on")});return(0,r.jsxs)("div",{className:"rounded border border-gray-300",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between p-4",onClick:()=>u(e=>!e),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,r.jsx)(M.A,{className:"h-5 w-5 text-gray-400"}):(0,r.jsx)($.A,{className:"h-5 w-5 text-gray-400"}),(0,r.jsxs)(l.EY.BodyLargeSemiBold,{children:["Rule ",i+1]}),_ instanceof Date&&m instanceof Date&&(0,r.jsxs)(l.EY.BodySmall,{color:"secondary",children:[J(_)," â ",J(m)]})]}),t&&(0,r.jsx)(l.$n.Tertiary,{size:"sm",onClick:e=>{e.stopPropagation(),d()},children:"Remove"})]}),!c&&(0,r.jsxs)("div",{className:"space-y-3 px-4 pb-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.FD,{name:"availability_rules.".concat(i,".effective_on"),label:"Effective Date",required:!0}),(0,r.jsx)(U.FD,{name:"availability_rules.".concat(i,".expires_on"),label:"Expires Date",required:!0})]}),(0,r.jsx)(U.mB,{name:"availability_rules.".concat(i,".unavailable_message"),label:"Unavailable Message",placeholder:"e.g., Reservations are not available on this date",helperText:"Shown to visitors when a date is not available"}),(0,r.jsx)(l.EY.BodySmallSemiBold,{children:"Available days"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-4",children:s.j__.map(e=>(0,r.jsx)(ea,{index:i,day:e},e))}),(0,r.jsx)(ee,{ruleIndex:i,control:a,allowRemove:!n})]})]})}function ea(e){let{index:i,day:a}=e,{setValue:n,watch:s}=(0,W.xW)(),t=s("availability_rules.".concat(i,".rules.").concat(a));return(0,r.jsx)(l.Sc,{label:K[a],checked:!0===t,onChange:(e,r)=>n("availability_rules.".concat(i,".rules.").concat(a),r)})}
1let er={PER_PERSON:"Per Person",PER_VEHICLE:"Per Vehicle",PER_ENTRY:"Per Entry"},en=s.upy.map(e=>({label:er[e],value:e})),es=s.MIV.map(e=>({label:"NONRESIDENT"===e?"Non-Resident":"ALL"===e?"All":"Resident",value:e})),el=s.qQJ.map(e=>({label:"DAILY"===e?"Daily (flat rate)":"Weekly (per day)",value:e})),et={sunday:"Sun",monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat"};function eo(e){let{prefix:i}=e;return(0,r.jsx)("div",{className:"space-y-2",children:s.j__.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)(l.EY.BodyLargeSemiBold,{className:"pb-2",children:et[e]}),(0,r.jsx)(ed,{prefix:i,day:e})]},e))})}function ed(e){let{prefix:i,day:a}=e;return(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.l4,{name:"".concat(i,".").concat(a,".cents"),label:"Price",hideOptional:!0}),(0,r.jsx)(U.$L,{name:"".concat(i,".").concat(a,".units"),label:"Units",options:en})]})}function ec(e){let{prefix:i}=e;return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(l.EY.BodySmall,{color:"secondary",children:"Choose which days to override. Days left unchecked use the base price."}),s.j__.map(e=>(0,r.jsx)(eu,{prefix:i,day:e},e))]})}function eu(e){let{prefix:i,day:a}=e,{setValue:n,getValues:s,control:t}=(0,W.xW)(),d="".concat(i,".").concat(a),[c,u]=(0,o.useState)(()=>null!=s(d)),_=(0,W.FH)({control:t,name:d}),m=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{!m.current&&(null==_||c||u(!0))},[_,c]),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(l.Sc,{label:et[a],checked:c,onChange:(e,i)=>{m.current=!0,u(i),i?n(d,{cents:0,units:"PER_PERSON"}):(n("".concat(d,".cents"),void 0),n("".concat(d,".units"),void 0),n(d,void 0))}}),c&&(0,r.jsx)(ed,{prefix:i,day:a})]})}function e_(e){let{index:i,control:a,isEditing:n,canRemove:s,onRemove:t}=e,[d,c]=(0,o.useState)(!1),u=(0,W.FH)({control:a,name:"pricing_rules.".concat(i,".effective_on")});return(0,r.jsxs)("div",{className:"rounded border border-gray-300",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between p-4",onClick:()=>c(e=>!e),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[d?(0,r.jsx)(M.A,{className:"h-5 w-5 text-gray-400"}):(0,r.jsx)($.A,{className:"h-5 w-5 text-gray-400"}),(0,r.jsxs)(l.EY.BodyLargeSemiBold,{children:["Rule ",i+1]}),u instanceof Date&&(0,r.jsxs)(l.EY.BodySmall,{color:"secondary",children:["Effective ",u.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]})]}),s&&(0,r.jsx)(l.$n.Tertiary,{size:"sm",onClick:e=>{e.stopPropagation(),t()},children:"Remove"})]}),!d&&(0,r.jsxs)("div",{className:"space-y-3 px-4 pb-4",children:[(0,r.jsx)(U.FD,{name:"pricing_rules.".concat(i,".effective_on"),label:"Effective Date",required:!0}),(0,r.jsx)(U.l4,{name:"pricing_rules.".concat(i,".rules.universal_nonresident_fee_cents"),label:"Non-Resident Surcharge"}),(0,r.jsx)(eo,{prefix:"pricing_rules.".concat(i,".rules.default_resident_prices")}),(0,r.jsx)(em,{ruleIndex:i,control:a,allowRemove:!n})]})]})}function em(e){let{ruleIndex:i,control:a,allowRemove:n}=e,{fields:s,append:t,remove:o}=(0,W.jz)({control:a,name:"pricing_rules.".concat(i,".overrides")});return(0,r.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,r.jsx)(l.EY.BodyLargeSemiBold,{children:"Pricing overrides"}),s.map((e,s)=>(0,r.jsx)(ev,{ruleIndex:i,overrideIndex:s,control:a,onRemove:n?()=>o(s):void 0,defaultCollapsed:function(e){var i;let a=null==(i=e.override_rules)?void 0:i.end_iso_date_inclusive;if(!a)return!1;let r=new Date;return r.setHours(0,0,0,0),a<r}(e)},e.id)),(0,r.jsx)(l.$n.Tertiary,{size:"sm",type:"button",onClick:()=>t({...I}),children:"+ Add override"})]})}function ev(e){let{ruleIndex:i,overrideIndex:a,control:n,onRemove:s,defaultCollapsed:t}=e,[d,c]=(0,o.useState)(t),u="pricing_rules.".concat(i,".overrides.").concat(a),_="".concat(u,".override_rules"),m=(0,W.FH)({control:n,name:"".concat(_,".prices.frequency")}),v=(0,W.FH)({control:n,name:"".concat(u,".name")}),f=(0,W.FH)({control:n,name:"".concat(_,".end_iso_date_inclusive")}),p=new Date;p.setHours(0,0,0,0);let y=f instanceof Date&&f<p;return(0,r.jsxs)("div",{className:"rounded border border-gray-300",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between p-3",onClick:()=>c(e=>!e),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[d?(0,r.jsx)(M.A,{className:"h-5 w-5 text-gray-400"}):(0,r.jsx)($.A,{className:"h-5 w-5 text-gray-400"}),(0,r.jsx)(l.EY.BodySmallSemiBold,{children:v?"".concat(v):"Override ".concat(a+1)}),y&&(0,r.jsx)(l.vw.Negative,{label:"Expired",size:"default"})]}),s&&(0,r.jsx)(l.$n.Tertiary,{className:"min-w-0 p-0",size:"sm",onClick:e=>{e.stopPropagation(),s()},children:"Remove"})]}
1),!d&&(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.mB,{name:"".concat(u,".name"),label:"Name",required:!0,placeholder:"e.g., Memorial Day"}),(0,r.jsx)(U.Y$,{name:"".concat(_,".priority"),label:"Priority",required:!0})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.FD,{name:"".concat(_,".start_iso_date"),label:"Start Date",required:!0}),(0,r.jsx)(U.FD,{name:"".concat(_,".end_iso_date_inclusive"),label:"End Date",required:!0})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.$L,{name:"".concat(_,".residency"),label:"Residency",required:!0,options:es}),(0,r.jsx)(U.$L,{name:"".concat(_,".prices.frequency"),label:"Frequency",required:!0,options:el})]}),"DAILY"===m&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(U.l4,{name:"".concat(_,".prices.cents"),label:"Price"}),(0,r.jsx)(U.$L,{name:"".concat(_,".prices.units"),label:"Units",required:!0,options:en})]}),"WEEKLY"===m&&(0,r.jsx)(ec,{prefix:"".concat(_,".prices")})]})]})}function ef(e){var i,a;let{open:n,onClose:s,organizationId:c,facilityId:u,membershipTier:_,onSuccess:m}=e,v=null!=_,y=(0,p.qN)(),x=null==_?void 0:_.associated_entry_pass_booking_info,[h,g]=(0,o.useState)(!v||(null==x?void 0:x.registration_advance_days)!=null),[b,w]=(0,o.useState)(!v||(null==x?void 0:x.registration_cutoff_days)!=null),E=(0,W.mN)({resolver:(0,V.uG)(j),defaultValues:function(e){var i,a,r,n,s,l,t,o,d,c,u,_,m;if(!e)return{name:"",is_public:!1,is_walk_in_only:!1,max_daily_passes:100,email_callout_text:"",registration_advance_days:0,registration_advance_time:new Date(1970,0,1,8,0),registration_cutoff_days:0,registration_cutoff_time:new Date(1970,0,1,19,0),pricing_rules:[{...Y}],availability_rules:[],price_modifier_ids:[]};let v=e.associated_entry_pass_booking_info;return{name:e.name,is_public:null!=(r=null==v?void 0:v.is_public)&&r,is_walk_in_only:null!=(n=null==v?void 0:v.is_walk_in_only)&&n,max_daily_passes:null!=(s=null==v?void 0:v.max_daily_passes)?s:0,email_callout_text:null!=(l=null==v?void 0:v.email_callout_text)?l:"",registration_advance_days:null!=(t=null==v?void 0:v.registration_advance_days)?t:0,registration_advance_time:null!=(o=N(null==v?void 0:v.registration_advance_time))?o:new Date(1970,0,1,8,0),registration_cutoff_days:null!=(d=null==v?void 0:v.registration_cutoff_days)?d:0,registration_cutoff_time:null!=(c=N(null==v?void 0:v.registration_cutoff_time))?c:new Date(1970,0,1,19,0),pricing_rules:(null!=(u=null==v?void 0:v.entry_pass_pricing_rules)?u:[]).map(D).sort((e,i)=>e.effective_on.getTime()-i.effective_on.getTime()),availability_rules:(null!=(_=null==v?void 0:v.entry_pass_availability_rules)?_:[]).map(T).sort((e,i)=>e.effective_on.getTime()-i.effective_on.getTime()),price_modifier_ids:null!=(m=null==(a=e.membership_booking_info)||null==(i=a.associated_membership_booking_info_price_modifiers)?void 0:i.map(e=>e.associated_price_modifier.id))?m:[]}}(_),shouldUnregister:!1}),{handleSubmit:k,control:C}=E,I=(0,W.FH)({control:C,name:"is_public"}),A=(0,W.FH)({control:C,name:"is_walk_in_only"}),{fields:P,append:R,remove:L}=(0,W.jz)({control:C,name:"pricing_rules"}),{fields:F,append:M,remove:$}=(0,W.jz)({control:C,name:"availability_rules"}),{data:K}=(0,d.iWF)({variables:{where:{organization_id:{_eq:c},archived_at:{_is_null:!0}},orderBy:[{name:d.V47.Asc}]}}),G=(null!=(i=null==K?void 0:K.price_modifiers)?i:[]).map(e=>({label:e.name,value:e.id})),[J,{loading:Z}]=(0,d.O6T)({...O.D,onError:(0,H._r)(()=>{y(f.h1)}),onCompleted:()=>{m(),s()}}),[Q,{loading:X}]=(0,d.xwQ)({...O.D,onError:(0,H._r)(()=>{y(f.h1)}),onCompleted:()=>{m(),s()}}),ee=Z||X;async function ea(e){let i=e.pricing_rules.map(q),a=e.availability_rules.map(B);v?await Q({variables:{input:{organization_id:c,membership_tier_id:_.id,name:e.name,is_public:e.is_public,is_walk_in_only:e.is_walk_in_only,max_daily_passes:e.max_daily_passes,email_callout_text:e.email_callout_text||null,registration_window_start:h?{days_in_advance:e.registration_advance_days,time:S(e.registration_advance_time)}:null,registration_window_cutoff:b?{days_in_advance:e.registration_cutoff_days,time:S(e.registration_cutoff_time)}:null,pricing_rules:i,availability_rules:a,price_modifier_ids:e.price_modifier_ids}}}):await J({variables:{input:{organization_id:c,facility_id:u,name:e.name,is_public:e.is_public,is_
1walk_in_only:e.is_walk_in_only,max_daily_passes:e.max_daily_passes,email_callout_text:e.email_callout_text||null,registration_window_start:h?{days_in_advance:e.registration_advance_days,time:S(e.registration_advance_time)}:null,registration_window_cutoff:b?{days_in_advance:e.registration_cutoff_days,time:S(e.registration_cutoff_time)}:null,pricing_rules:i,availability_rules:a,price_modifier_ids:e.price_modifier_ids}}})}return(0,r.jsx)(l.lG,{open:n,onClose:s,maxWidth:"md",fullWidth:!0,size:"xl",headerProps:{title:v?"Edit Zone":"Create Zone",subtitle:v?"Editing ".concat(null!=(a=null==_?void 0:_.name)?a:"").concat((null==x?void 0:x.id)?" \xb7 Entry Pass ID: ".concat(x.id):""):"Add a new zone to this facility",onClose:s},contentProps:{content:(0,r.jsx)(W.Op,{...E,children:(0,r.jsxs)("form",{id:"day-use-zone-form",onSubmit:k(ea),className:"space-y-4",children:[(0,r.jsx)(U.mB,{name:"name",label:"Zone name",required:!0,placeholder:"e.g., Beach Parking"}),(0,r.jsx)(l.Sc,{label:"Published (visible to the public)",checked:I,onChange:(e,i)=>E.setValue("is_public",i)}),(0,r.jsx)(l.Sc,{label:"Walk-in only",checked:A,onChange:(e,i)=>E.setValue("is_walk_in_only",i)}),(0,r.jsx)(U.Y$,{name:"max_daily_passes",label:"Capacity",required:!0}),(0,r.jsx)(U.mB,{name:"email_callout_text",label:"Custom Email Text",placeholder:'e.g., "Please arrive no earlier than 8 AM."',helperText:"Shown in the confirmation email sent to visitors"}),(0,r.jsx)(l.EY.BodyLargeSemiBold,{className:"pt-2",children:"Registration Window"}),(0,r.jsx)(l.Sc,{label:"Set advance booking window",checked:h,onChange:(e,i)=>g(i)}),h&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(U.Y$,{name:"registration_advance_days",label:"Advance Days",required:!0,helperText:"Days before visit date registration opens"}),(0,r.jsx)(U.s2,{name:"registration_advance_time",label:"Advance Time",required:!0})]}),(0,r.jsx)(l.Sc,{label:"Set booking cutoff",checked:b,onChange:(e,i)=>w(i)}),b&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(U.Y$,{name:"registration_cutoff_days",label:"Cutoff Days",required:!0,helperText:"Days before visit date registration closes"}),(0,r.jsx)(U.s2,{name:"registration_cutoff_time",label:"Cutoff Time",required:!0})]}),(0,r.jsx)(l.EY.BodyLargeSemiBold,{className:"pt-2",children:"Price Modifiers"}),(0,r.jsx)(U._v,{name:"price_modifier_ids",label:"Price Modifiers",searchable:!0,searchPlaceholder:"Search price modifiers...",options:G,showSelectAll:!0,allSelectedText:"All modifiers selected"}),(0,r.jsx)(l.EY.BodyLargeSemiBold,{className:"pt-2",children:"Pricing rules"}),(0,r.jsx)(l.EY.BodySmall,{color:"secondary",children:"Configure the pricing rules for a zone. The effective pricing rules for a zone will be the rules with the most recent effective date that is not in the future."}),P.map((e,i)=>(0,r.jsx)(e_,{index:i,control:C,isEditing:v,canRemove:!v&&P.length>1,onRemove:()=>L(i)},e.id)),(0,r.jsx)(l.$n.Secondary,{size:"sm",type:"button",onClick:()=>R({...Y}),children:"+ Add pricing rule"}),(0,r.jsx)(l.EY.BodyLargeSemiBold,{className:"pt-2",children:"Availability rules"}),(0,r.jsx)(l.EY.BodySmall,{color:"secondary",children:"Configure which days of the week this zone accepts reservations. The effective availability rule is the one whose effective date has passed and has not yet expired."}),F.map((e,i)=>(0,r.jsx)(ei,{index:i,control:C,isEditing:v,canRemove:!v&&F.length>0,onRemove:()=>$(i)},e.id)),(0,r.jsx)(l.$n.Secondary,{size:"sm",type:"button",onClick:()=>M({...z}),children:"+ Add availability rule"})]})})},footerProps:{alignment:"between",buttons:[(0,r.jsx)(l.$n.Secondary,{size:"sm",onClick:s,children:"Cancel"},"cancel"),(0,r.jsx)(l.$n.Primary,{size:"sm",type:"submit",form:"day-use-zone-form",disabled:ee,children:ee?(0,r.jsx)(t.A,{size:16,className:"text-white"}):v?"Save Changes":"Create Zone"},"save")]}})}function ep(){var e,i,a,n,f;let p=(0,_.hV)(),{createOrgRoute:y}=(0,u.x)(),x=(0,c.k)(s.sKG.enableKaizenTools),[h,g]=(0,o.useState)(""),[b,j]=(0,o.useState)({mode:"closed"}),{data:N}=(0,d.N6V)({variables:{organization_id:p},skip:!p}),{data:w,loading:S,refetch:E}=(0,d.XsS)({variables:{organization_id:p,facility_id:h},skip:!p||!h}),q=(null!=(a=null==N?void 0:N.facilities)?a:[]).map(e=>({label:e.title,value:e.id}));if((null!=(n=null==w||null==(e=w.memberships)?void 0:e.length)?n:0)>1)throw Error("Invalid state: Multiple memberships found for facility");let k=null==w||null==(i=w.memberships)?void 0:i[0],D=null!=(f=null==k?void 0:k.membership_tiers)?f:[],C=null!=k;return x?(0,r.jsxs)("div",{className:"flex h-full flex-col p-6",children:[(0,r.jsx)(v.A,{routes:[{label:"Kaizen Tools",href:y(s.l35.toolsRoot)},{label:"Manage Day-Use Configuration",href:y(s.l35.dayUseConfiguration)}]}),(0,r.jsx)(l.EY.BodySmall,{className:"mt-4 text-secondary",children:"Select a facility to view and manage its day-use configurations."}),(0,r.jsxs)("div",{className:"mt-4 max-w-[1000px] space-y-6",children:[(0,r.jsx)("div",{className:"w-[500px]",children:(0,r.jsx)(l.pp,{name:"facility_id",label:"Facility",searchable:!0,required:!0,searchPlaceholder:"Search facilities...",options:q,value:h||void 0,onChange:e=>g(e.target.value)})}),h&&S&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(t.A,{size:16}),(0,r.jsx)(l.EY.BodySmall,{children:"Loading configuration"})]}),h&&!S&&!C&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(l.vM.Neutral,{label:"This facility hasn't been set up for day-use reservations yet. Adding the first configuration will create the underlying membership and amenity records."}),(0,r.jsx)(l.$n.Primary,{onClick:()=>j({mode:"create"}),children:"+ Add first zone"})]}),h&&!S&&C&&(0,r.jsxs)("div",{className:"space-y-4 pb-12",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(l.EY.TitleSmall,{children:"Global settings"}),(0,r.jsx)(l.EY.BodySmall,{className:"mt-2 text-secondary",children:"The settings here apply to all day-use zones for this facility."})]}),(0,r.jsxs)("div",{className:"space-y-3 rounded border p-4",children:[(0,r.jsx)(l.EY.BodySmallSemiBold,{children:"Accounting"}),(0,r.jsx)(l.EY.BodySmall,{className:"text-secondary",children:"Assign a general ledger entry for day-use revenue at this facility."}),(0,r.jsx)(F,{membership:k,onSaved:()=>E()})]}),(0,r.jsxs)("div",{className:"space-y-3 rounded border p-4",children:[(0,r.jsx)(l.EY.BodySmallSemiBold,{children:"Form associations"}),(0,r.jsx)(l.EY.BodySmall,{className:"text-secondary",children:"Assign forms to all day use zones for this facility."}),(0,r.jsx)(R,{membership:k,onSaved:()=>E()})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(l.EY.TitleSmall,{children:"Day-use zones"}),(0,r.jsx)(l.$n.Primary,{onClick:()=>j({mode:"create"}),children:"+ Add zone"})]}
1),(0,r.jsx)(m.Ay,{columns:[{title:"Zone name",cellContent:e=>{let{row:i}=e;return i.name},comparator:(0,m.VE)(e=>e.name)},{title:"Status",cellContent:e=>{var i,a;let{row:n}=e;return(0,r.jsxs)("div",{className:"flex gap-1",children:[(null==(i=n.associated_entry_pass_booking_info)?void 0:i.is_public)?(0,r.jsx)(l.vw.Positive,{label:"Published",size:"default"}):(0,r.jsx)(l.vw.Neutral,{label:"Unpublished",size:"default"}),(null==(a=n.associated_entry_pass_booking_info)?void 0:a.is_walk_in_only)&&(0,r.jsx)(l.vw.Neutral,{label:"Walk-in Only",size:"default"})]})}},{title:"Capacity",cellContent:e=>{var i,a;let{row:r}=e;return null!=(a=null==(i=r.associated_entry_pass_booking_info)?void 0:i.max_daily_passes)?a:"â"}},{title:"Advance days",cellContent:e=>{var i,a;let{row:r}=e;return null!=(a=null==(i=r.associated_entry_pass_booking_info)?void 0:i.registration_advance_days)?a:"â"}},{title:"Cutoff days",cellContent:e=>{var i,a;let{row:r}=e;return null!=(a=null==(i=r.associated_entry_pass_booking_info)?void 0:i.registration_cutoff_days)?a:"â"}},{title:"Pricing rules",cellContent:e=>{var i,a,r;let{row:n}=e;return"".concat(null!=(r=null==(a=n.associated_entry_pass_booking_info)||null==(i=a.entry_pass_pricing_rules)?void 0:i.length)?r:0," rules")}},{title:"",cellContent:e=>{let{row:i}=e;return(0,r.jsx)(l.$n.Secondary,{size:"sm",onClick:e=>{e.stopPropagation(),j({mode:"edit",membershipTier:i})},children:"Edit"})}}],rows:D,initialSortState:{comparator:(0,m.VE)(e=>e.name),activeColumnIndex:0,direction:d.V47.Asc},tableCaption:"Day-use configurations",emptyStateMessage:"No configurations configured"})]})]}),"closed"!==b.mode&&(0,r.jsx)(ef,{open:!0,onClose:()=>j({mode:"closed"}),organizationId:p,facilityId:h,membershipTier:"edit"===b.mode?b.membershipTier:void 0,onSuccess:()=>E()})]}):null}function ey(){return(0,r.jsx)(ep,{})}ey.PageLayout=n.T;let ex=ey},35327:(e,i,a)=>{"use strict";a.d(i,{k:()=>o});var r=a(17563),n=a(40367),s=a(81204),l=a(50801),t=a(49191);let o=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/manager/calendar",a=(0,r.useRouter)(),o=(0,n.Tp)(e),d=(0,t.Z5)();return(0,s.useEffect)(()=>{"boolean"==typeof o&&d.slug&&(o||a.push((0,l.PL)(d.slug,i)))},[a,d,o,i]),o}},41322:(e,i,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/[org]/manager/kaizen-tools/day-use-configuration",function(){return a(34605)}])}},e=>{e.O(0,[7643,5214,9869,3661,5799,2599,4105,320,3630,2463,4098,6055,6482,6943,9436,789,8668,7763,4543,1724,4488,2224,8385,3862,2242,3804,3310,8723,636,6593,8792],()=>e(e.s=41322)),_N_E=e.O()}]);
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.