@veevarts/design-system 1.17.0-beta.3 → 1.17.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`,style:{backgroundColor:a},"aria-label":`Select color ${a}`,title:a},a)})})}const Pi=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],_i=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function _t(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const he={min:50,max:200,step:10,default:100},Wn={lineHeight:24,toolbarHeight:60},zi={bold:K.Bold,italic:K.Italic,strike:K.Strikethrough,underline:K.Underline,code:K.Code,textColor:K.Palette,highlight:K.Highlighter,link:K.Link2,paragraph:K.FileText,heading:K.Heading,bulletList:K.List,orderedList:K.ListOrdered,taskList:K.ListTodo,codeBlock:K.CodeSquare,blockquote:K.Quote,horizontalRule:K.Minus,clearMarks:K.Eraser,clearNodes:K.Eraser,undo:K.Undo2,redo:K.Redo2,hardBreak:K.CornerDownLeft,textAlign:K.AlignLeft},Ri={left:K.AlignLeft,center:K.AlignCenter,right:K.AlignRight,justify:K.AlignJustify};function Ge(e){return zi[e]}function Bi({value:e,onChange:t,onApply:n,placeholder:r="#000000"}){const[a,i]=p.useState(""),o=u=>{const f=u.target.value;t(f),a&&i("")},l=()=>{if(!e){i("Please enter a color");return}if(!_t(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(e)},d=u=>{u.key==="Enter"&&(u.preventDefault(),l())};return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(c.Input,{type:"text",value:e,onChange:o,onKeyDown:d,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!a,errorMessage:a,startContent:s.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:_t(e)?e:"transparent"}})}),s.jsx(W,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!e||!_t(e),children:s.jsx(K.Check,{size:16})})]}),s.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Yn({editor:e,type:t,allowCustomColor:n=!0,label:r,isDisabled:a=!1}){const[i,o]=p.useState(!1),[l,d]=p.useState(""),u=t==="textColor"?Pi:_i,f=k=>{const g=De[t];g&&g.execute({editor:e,config:{type:t,color:k}}),o(!1),d("")},h=k=>{f(k)},y=()=>{const k=De[t];k&&k.execute({editor:e,config:{type:t,color:""}}),o(!1)},m=t==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),j=t==="textColor"?K.Palette:K.Highlighter;return s.jsxs(c.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[s.jsx(c.PopoverTrigger,{children:s.jsx(W,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:a,"aria-label":r,children:s.jsx(j,{size:16})})}),s.jsx(c.PopoverContent,{className:"w-64",children:s.jsxs("div",{className:"px-2 py-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-semibold",children:r}),s.jsx(W,{size:"sm",variant:"light",isIconOnly:!0,onPress:y,"aria-label":"Clear color",children:s.jsx(K.X,{size:16})})]}),s.jsx(Oi,{colors:u,onColorSelect:f}),n&&s.jsxs(s.Fragment,{children:[s.jsx(c.Divider,{}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),s.jsx(Bi,{value:l,onChange:d,onApply:h})]})]})]})})]})}function Vi({zoom:e,onZoomChange:t,min:n=he.min,max:r=he.max,step:a=he.step}){const i=()=>{const h=Math.max(n,e-a);t(h)},o=()=>{const h=Math.min(r,e+a);t(h)},l=()=>{t(he.default)},d=e<=n,u=e>=r,f=e===he.default;return s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(c.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:s.jsx(W,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:i,"aria-label":"Zoom out",children:s.jsx(K.ZoomOut,{size:16})})}),s.jsx(c.Tooltip,{content:f?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:s.jsxs("button",{type:"button",onClick:l,disabled:f,className:`
|
|
8
8
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
9
9
|
${f?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
-
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),s.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:s.jsx(W,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:s.jsx(K.ZoomIn,{size:16})})})]})}function Ui({editor:e,isDisabled:t=!1}){const[n,r]=p.useState(!1),[a,i]=p.useState(""),[o,l]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),h=m=>{if(m){const{from:j,to:k}=e.state.selection,g=e.isActive("link");let w="";if(g){const S=e.schema.marks.link,b=e.state.doc.resolve(j),v=_n.getMarkRange(b,S);v&&(w=e.state.doc.textBetween(v.from,v.to,""))}else w=e.state.doc.textBetween(j,k,"");const N=e.getAttributes("link").href||"";i(w),l(N),u(g)}r(m)},y=()=>{if(o.trim()){const{from:m,to:j}=e.state.selection,k=e.schema.marks.link,g=e.state.doc.resolve(m),w=_n.getMarkRange(g,k),N=w?.from??m,S=w?.to??j,b=e.state.doc.textBetween(N,S,"");a.trim()&&a!==b?e.chain().focus().setTextSelection({from:N,to:S}).deleteSelection().insertContent(`<a href="${o.trim()}">${a.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:o.trim()}).run()}r(!1)};return s.jsxs(c.Popover,{isOpen:n,onOpenChange:h,placement:"bottom",children:[s.jsx(c.PopoverTrigger,{children:s.jsx(W,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:s.jsx(K.Link,{size:16})})}),s.jsx(c.PopoverContent,{children:s.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[s.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:a,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:o,onChange:m=>l(m.target.value),onKeyDown:m=>m.key==="Enter"&&y(),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(W,{size:"sm",color:"primary",onPress:y,isDisabled:!o.trim(),children:d?"Update":"Apply"})]})})]})}function Hi({children:e,id:t,label:n,className:r,useButtonGroup:a=!0}){return a?s.jsx(c.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):s.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Zs(e,t){const n=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(l=>ct(l)))).forEach(l=>{const d=De[l];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;i[l]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,a]=p.useState(n);return p.useEffect(()=>{if(!e)return;const i=()=>{const o={};Array.from(new Set(t.map(d=>ct(d)))).forEach(d=>{const u=De[d];if(u)try{const f=u.canExecute?.(e)??!0,h=u.isActive?.(e)??!1;o[d]={isActive:h,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),o[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),a(o)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Js(e,t){const n=p.useCallback((o,l)=>{if(!e)return;const d=De[o];if(d)try{d.execute({editor:e,config:l}),t?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[e,t]),r=p.useCallback(o=>{n(o)},[n]),a=p.useCallback((o,l)=>{if(!e)return!1;const d=De[o];try{return d?.canExecute?.(e,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[e]),i=p.useCallback((o,l)=>{if(!e)return!1;const d=De[o];try{return d?.isActive?.(e,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:a,isActive:i}}function qi(e=he.default){const[t,n]=p.useState(e),r=p.useCallback((l=he.step)=>{n(d=>Math.min(he.max,d+l))},[]),a=p.useCallback((l=he.step)=>{n(d=>Math.max(he.min,d-l))},[]),i=p.useCallback(()=>{n(he.default)},[]),o=p.useCallback(l=>{const d=Math.max(he.min,Math.min(he.max,l));n(d)},[]);return{zoom:t,setZoom:o,zoomIn:r,zoomOut:a,resetZoom:i,isMinZoom:t<=he.min,isMaxZoom:t>=he.max,isDefaultZoom:t===he.default}}const Wi=["bold","italic","strike","underline","code"];function Yi({editor:e,modifiers:t,onToolbarAction:n}){const r=Zs(e,t),{toggleModifier:a}=Js(e,n);if(!e)return null;const i=t.map(o=>ct(o)).filter(o=>Wi.includes(o));return i.length===0?null:s.jsx(Hi,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],d=Ge(o);return s.jsx(Be,{icon:d,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>a(o)},o)})})}function Gi({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:a=!0,className:i,onToolbarAction:o}){const l=Zs(e,t),{toggleModifier:d,executeCommand:u}=Js(e,o);if(!e)return null;const f=t.map(M=>ct(M)),h=f.some(M=>["bold","italic","strike","underline","code"].includes(M)),y=f.some(M=>["textColor","highlight"].includes(M)),m=f.includes("heading"),j=f.includes("textAlign"),k=f.some(M=>["bulletList","orderedList","taskList"].includes(M)),g=f.includes("blockquote"),w=f.includes("codeBlock"),N=f.includes("link"),S=f.includes("horizontalRule"),b=f.some(M=>["undo","redo"].includes(M)),v=n!==void 0&&r!==void 0,$=a?"sticky top-0 z-10":"";return s.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${$} ${i||""}`,children:s.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[h&&s.jsxs(s.Fragment,{children:[s.jsx(Yi,{editor:e,modifiers:t,onToolbarAction:o}),(y||m||j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&s.jsx(Yn,{editor:e,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),f.includes("highlight")&&s.jsx(Yn,{editor:e,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),m&&s.jsxs(s.Fragment,{children:[s.jsx(Ti,{editor:e}),(j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),j&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(M=>{const O=Ri[M],A=e.isActive({textAlign:M});return s.jsx(Be,{icon:O,label:`Align ${M}`,isActive:A,onClick:()=>u("textAlign",{type:"textAlign",alignment:M})},M)})}),(k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx(Li,{editor:e,types:f.filter(M=>["bulletList","orderedList","taskList"].includes(M))}),(g||w||N||S||b||v)&&s.jsx(Re,{})]}),(g||w||N||S)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[g&&s.jsx(Be,{icon:Ge("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&s.jsx(Be,{icon:Ge("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),N&&s.jsx(Ui,{editor:e,isDisabled:l.link?.isDisabled}),S&&s.jsx(Be,{icon:Ge("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(b||v)&&s.jsx(Re,{})]}),b&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&s.jsx(Be,{icon:Ge("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&s.jsx(Be,{icon:Ge("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>d("redo")})]}),v&&s.jsx(Re,{})]}),v&&s.jsx(Vi,{zoom:n,onZoomChange:M=>{r?.(M),o?.({type:"zoom",modifier:`${M}%`})}})]})})}const et={bold:{category:"mark",extension:Aa.Bold,priority:100},italic:{category:"mark",extension:$a.Italic,priority:100},strike:{category:"mark",extension:Da.Strike,priority:100},underline:{category:"mark",extension:Ea.Underline,priority:100},code:{category:"mark",extension:Ia.Code,priority:100},textColor:{category:"mark",extension:Ma.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Fa.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Ta.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Oa.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:_a.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:za.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Ra.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Ua.CodeBlock,priority:100},blockquote:{category:"node",extension:Ha.Blockquote,priority:100},horizontalRule:{category:"node",extension:qa.HorizontalRule,priority:100},hardBreak:{category:"node",extension:Wa.HardBreak,priority:100},undo:{category:"extension",extension:zn.History,priority:50},redo:{category:"extension",extension:zn.History,priority:50},textAlign:{category:"extension",extension:Ya.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},Ki=[Ga.Document,Ka.Text,Pa.Paragraph,La.TextStyle.configure({HTMLAttributes:{}}),Va.ListItem.configure({HTMLAttributes:{}}),Ba.TaskItem.configure({nested:!0}),Qa.Dropcursor,Za.Gapcursor];function Qi(e){const t=[],n=new Set,r=new Set;Ki.forEach(l=>{l&&(t.push(l),r.add(l.name))});const a=e.map(l=>ct(l)),i=new Set;return a.forEach(l=>{const d=et[l];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const d=et[l];if(!d||d.extension===null)return;const u=d.extension.name;if(r.has(u)){n.add(l);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;t.push(f),n.add(l),r.add(u)}),a.forEach(l=>{if(n.has(l))return;const d=et[l];if(!d){console.warn(`Extension config not found for modifier: ${l}`);return}if(d.extension===null){n.add(l);return}const u=d.extension.name;if(r.has(u)){n.add(l);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;t.push(f),n.add(l),r.add(u)}),t.sort((l,d)=>{const u=Object.values(et).find(m=>m?.extension?.name===l.name),f=Object.values(et).find(m=>m?.extension?.name===d.name),h=u?.priority??100;return(f?.priority??100)-h})}const Xs={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},ce={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Te={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},le={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Zi={h1:`font-size: ${ce.fontSize["4xl"]}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h2:`font-size: ${ce.fontSize["2xl"]}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h3:`font-size: ${ce.fontSize.xl}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h4:`font-size: ${ce.fontSize.lg}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h5:`font-size: ${ce.fontSize.base}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h6:`font-size: ${ce.fontSize.sm}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,p:`min-height: ${ce.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${le.xl}; margin: ${le.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${le.xl}; margin: ${le.md} 0;`,li:`display: list-item; margin: ${le.xs} 0;`,strong:`font-weight: ${ce.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Te.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ce.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ce.fontFamily.mono};`,pre:`background: ${Te.neutral.gray[800]}; border-radius: ${le.sm}; color: ${Te.neutral.gray[100]}; font-family: ${ce.fontFamily.mono}; margin: ${le.lg} 0; padding: 0.75rem ${le.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Te.neutral.gray[300]}; margin: ${le.lg} 0; padding-left: ${le.md}; color: ${Te.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Te.neutral.gray[200]}; margin: ${le.xl} 0;`,a:`color: ${Te.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Te.palettes.warning[200]}; border-radius: ${le.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${le.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Ji={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function Xi(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(Ji)){const a=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(a,(i,o)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${o} style="${r}">`)}for(const[n,r]of Object.entries(Zi)){const a=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(a,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const o=i.indexOf(">");return`${i.slice(0,o)} style="${r}"${i.slice(o)}`}})}return t}const el=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:a}=dn.useCurrentEditor();return s.jsx(Gi,{editor:a,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},tl=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=dn.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),a=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return s.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&s.jsxs("span",{children:[a," characters"]}),t&&s.jsxs("span",{children:[i," words"]})]})},Xt=p.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:a=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:d=Xs.full,variant:u="bordered",initialContent:f,content:h,onContentChange:y,onUpdate:m,onToolbarAction:j,isReadOnly:k=!1,isDisabled:g=!1,includeInlineStyles:w=!0,...N}=e,{zoom:S,setZoom:b}=qi(),v=Wn.lineHeight,$=n*v,M=a?void 0:r*v,O=p.useMemo(()=>Qi(d),[d]),{Component:A,label:_,shouldLabelBeOutside:I,getBaseProps:D,getLabelProps:F,getInputWrapperProps:L}=c.useInput({...N,variant:u,ref:t,isMultiline:!0}),Q=_?s.jsx("label",{...F(),children:_}):null,U=p.useCallback(({editor:H})=>{const J=H.getHTML(),ee=w?Xi(J):J,se=H.getJSON(),Y=H.getText(),B=Y.length,G=Y.split(/\s+/).filter(ie=>ie.length>0).length,Z={html:ee,json:se,text:Y,characters:B,words:G};if(y?.(Z),m?.(Z),"onChange"in N&&typeof N.onChange=="function"){const ie={target:{value:ee},currentTarget:{value:ee}};N.onChange(ie)}},[y,m,N,w]);return s.jsxs(A,{...D(),children:[I?Q:null,s.jsx("div",{...L(),className:c.cn(L().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:M?`${M+Wn.toolbarHeight}px`:void 0,overflow:M?"auto":void 0},children:s.jsx(dn.EditorProvider,{editable:!k&&!g,slotBefore:l?s.jsx(el,{modifiers:d,zoom:S,onZoomChange:b,onToolbarAction:j}):void 0,slotAfter:s.jsx(tl,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${$}px`,fontSize:`${S}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:O,content:h||f||e.defaultValue||"",onUpdate:U})})]})});Xt.displayName="TipTapEditor";const er=p.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...a}=e;return n==="tiptap"?s.jsx(Xt,{...a,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),s.jsx(Xt,{...a,variant:r,ref:t}))});er.displayName="RichTextArea";function nl(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const Gn=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],sl={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},tr=({presetAmounts:e=Gn,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:a,currency:i="USD",locale:o="en-US",showCustomAmount:l=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:h=2,desktopColumns:y=3,isDisabled:m=!1,buttonVariant:j="bordered",buttonColor:k="default",inputVariant:g="bordered",size:w="md",className:N="",showCard:S=!0})=>{const b={...sl,...f},v=Array.isArray(e)?e:Gn,$={2:"grid-cols-2",3:"grid-cols-3"},M={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},O=`${$[h]} ${M[y]}`,[A,_]=pn(t,n,r),[I,D]=p.useState(""),[F,L]=p.useState(!1),[Q,U]=p.useState(0),H=p.useCallback(B=>{if(m)return;const G={amount:B.amount,isCustom:!1,presetId:B.id};_(G),D(""),L(!1),U(Z=>Z+1),a?.(G)},[m,_,a]),J=p.useCallback(B=>{if(m)return;if(D(B!==void 0?String(B):""),a){_(null);return}if(B===void 0||isNaN(B)){_(null);return}_({amount:B,isCustom:!0})},[m,_,a]),ee=p.useCallback(()=>{if(m)return;const B=I!==""?parseFloat(I):void 0;B===void 0||isNaN(B)||a?.({amount:B,isCustom:!0})},[m,I,a]),se=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=s.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[b.title&&s.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:b.title}),v.length>0&&s.jsx("div",{className:c.cn("grid gap-3",O),"data-testid":"donation-amounts-presets",children:v.map(B=>{const G=A!==null&&!A.isCustom&&A.presetId===B.id;return s.jsx(W,{color:G?"primary":k,variant:G?"solid":j,className:"w-full",onPress:()=>H(B),isDisabled:m,"data-testid":`donation-amounts-preset-${B.id}`,children:B.label||nl(B.amount,o,i)},B.id)})}),l&&s.jsxs("div",{className:"flex gap-3 items-start",children:[s.jsx(c.NumberInput,{placeholder:b.customAmountPlaceholder,"aria-label":b.customAmountAriaLabel,onInput:a?()=>{_(null),L(!0)}:void 0,variant:g,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:se,value:I!==""?parseFloat(I):void 0,onValueChange:J,isDisabled:m,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},a?`custom-${Q}`:A?.isCustom===!1?A.presetId:"custom"),a&&s.jsx(W,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:ee,isDisabled:m||!F,"data-testid":"donation-amounts-add-button",children:b.addDonationButton})]})]});return S?s.jsx(c.Card,{className:c.cn("w-full",N),"data-testid":"donation-amounts-card",children:s.jsx(c.CardBody,{children:Y})}):s.jsx("div",{className:c.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};tr.displayName="DonationAmounts";const rl=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},al=e=>{switch(e){case"warning":return K.Clock;case"error":return K.AlertCircle;case"success":return K.CheckCircle;default:return K.Clock}},il=e=>{switch(e){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},nr=p.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:a="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:h=rl,className:y,...m},j)=>{const[k,g]=pn(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=p.useRef(null),N=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||k<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{g($=>$<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,r?.()),0):$-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,k,g,r]),p.useEffect(()=>{k>0&&(N.current=!1)},[k]);const S=d||al(a),b=il(i),v={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return s.jsx("div",{ref:j,role:"banner","aria-live":"polite","aria-label":`${o} ${h(k)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",b,v[u],y),...m,children:s.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&s.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:s.jsx(S,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),s.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:o})]}),s.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:s.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${h(k)}`,"data-testid":"expire-cart-timer-value",children:h(k)})})]})})})});nr.displayName="ExpireCartTimer";function ll(e,t){const n=e.icons,r=e.aliases||Object.create(null),a=Object.create(null);function i(o){if(n[o])return a[o]=[];if(!(o in a)){a[o]=null;const l=r[o]&&r[o].parent,d=l&&i(l);d&&(a[o]=[l].concat(d))}return a[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),a}const sr=Object.freeze({left:0,top:0,width:16,height:16}),bt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),bn=Object.freeze({...sr,...bt}),en=Object.freeze({...bn,body:"",hidden:!1});function ol(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Kn(e,t){const n=ol(e,t);for(const r in en)r in bt?r in e&&!(r in n)&&(n[r]=bt[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function cl(e,t,n){const r=e.icons,a=e.aliases||Object.create(null);let i={};function o(l){i=Kn(r[l]||a[l],i)}return o(t),n.forEach(o),Kn(e,i)}function rr(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(a=>{t(a,null),n.push(a)});const r=ll(e);for(const a in r){const i=r[a];i&&(t(a,cl(e,a,i)),n.push(a))}return n}const dl={provider:"",aliases:{},not_found:{},...sr};function zt(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function ar(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!zt(e,dl))return null;const n=t.icons;for(const a in n){const i=n[a];if(!a||typeof i.body!="string"||!zt(i,en))return null}const r=t.aliases||Object.create(null);for(const a in r){const i=r[a],o=i.parent;if(!a||typeof o!="string"||!n[o]&&!r[o]||!zt(i,en))return null}return t}const Qn=Object.create(null);function ul(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Ze(e,t){const n=Qn[e]||(Qn[e]=Object.create(null));return n[t]||(n[t]=ul(e,t))}function ir(e,t){return ar(t)?rr(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function fl(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const lr=/^[a-z0-9]+(-[a-z0-9]+)*$/,St=(e,t,n,r="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;r=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const l=a.pop(),d=a.pop(),u={provider:a.length>0?a[0]:r,prefix:d,name:l};return t&&!xt(u)?null:u}const i=a[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return t&&!xt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return t&&!xt(l,n)?null:l}return null},xt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let dt=!1;function or(e){return typeof e=="boolean"&&(dt=e),dt}function Zn(e){const t=typeof e=="string"?St(e,!0,dt):e;if(t){const n=Ze(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function ml(e,t){const n=St(e,!0,dt);if(!n)return!1;const r=Ze(n.provider,n.prefix);return t?fl(r,n.name,t):(r.missing.add(n.name),!0)}function hl(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),dt&&!t&&!e.prefix){let a=!1;return ar(e)&&(e.prefix="",rr(e,(i,o)=>{ml(i,o)&&(a=!0)})),a}const n=e.prefix;if(!xt({prefix:n,name:"a"}))return!1;const r=Ze(t,n);return!!ir(r,e)}const cr=Object.freeze({width:null,height:null}),dr=Object.freeze({...cr,...bt}),xl=/(-?[0-9.]*[0-9]+[0-9.]*)/g,pl=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Jn(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(xl);if(r===null||!r.length)return e;const a=[];let i=r.shift(),o=pl.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?a.push(i):a.push(Math.ceil(l*t*n)/n)}else a.push(i);if(i=r.shift(),i===void 0)return a.join("");o=!o}}function gl(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const a=e.indexOf(">",r),i=e.indexOf("</"+t);if(a===-1||i===-1)break;const o=e.indexOf(">",i);if(o===-1)break;n+=e.slice(a+1,i).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function bl(e,t){return e?"<defs>"+e+"</defs>"+t:t}function yl(e,t,n){const r=gl(e);return bl(r.defs,t+r.content+n)}const vl=e=>e==="unset"||e==="undefined"||e==="none";function jl(e,t){const n={...bn,...e},r={...dr,...t},a={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(k=>{const g=[],w=k.hFlip,N=k.vFlip;let S=k.rotate;w?N?S+=2:(g.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),g.push("scale(-1 1)"),a.top=a.left=0):N&&(g.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),g.push("scale(1 -1)"),a.top=a.left=0);let b;switch(S<0&&(S-=Math.floor(S/4)*4),S=S%4,S){case 1:b=a.height/2+a.top,g.unshift("rotate(90 "+b.toString()+" "+b.toString()+")");break;case 2:g.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:b=a.width/2+a.left,g.unshift("rotate(-90 "+b.toString()+" "+b.toString()+")");break}S%2===1&&(a.left!==a.top&&(b=a.left,a.left=a.top,a.top=b),a.width!==a.height&&(b=a.width,a.width=a.height,a.height=b)),g.length&&(i=yl(i,'<g transform="'+g.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,d=a.width,u=a.height;let f,h;o===null?(h=l===null?"1em":l==="auto"?u:l,f=Jn(h,d/u)):(f=o==="auto"?d:o,h=l===null?Jn(f,u/d):l==="auto"?u:l);const y={},m=(k,g)=>{vl(g)||(y[k]=g.toString())};m("width",f),m("height",h);const j=[a.left,a.top,d,u];return y.viewBox=j.join(" "),{attributes:y,viewBox:j,body:i}}const wl=/\sid="(\S+)"/g,Nl="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Cl=0;function kl(e,t=Nl){const n=[];let r;for(;r=wl.exec(e);)n.push(r[1]);if(!n.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const o=typeof t=="function"?t(i):t+(Cl++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const tn=Object.create(null);function Sl(e,t){tn[e]=t}function nn(e){return tn[e]||tn[""]}function yn(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const vn=Object.create(null),tt=["https://api.simplesvg.com","https://api.unisvg.com"],pt=[];for(;tt.length>0;)tt.length===1||Math.random()>.5?pt.push(tt.shift()):pt.push(tt.pop());vn[""]=yn({resources:["https://api.iconify.design"].concat(pt)});function Al(e,t){const n=yn(t);return n===null?!1:(vn[e]=n,!0)}function jn(e){return vn[e]}const $l=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Xn=$l();function Dl(e,t){const n=jn(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let a=0;n.resources.forEach(o=>{a=Math.max(a,o.length)});const i=t+".json?icons=";r=n.maxURL-a-n.path.length-i.length}return r}function El(e){return e===404}const Il=(e,t,n)=>{const r=[],a=Dl(e,t),i="icons";let o={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((d,u)=>{l+=d.length+1,l>=a&&u>0&&(r.push(o),o={type:i,provider:e,prefix:t,icons:[]},l=d.length),o.icons.push(d)}),r.push(o),r};function Ml(e){if(typeof e=="string"){const t=jn(e);if(t)return t.path}return"/"}const Fl=(e,t,n)=>{if(!Xn){n("abort",424);return}let r=Ml(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),d=new URLSearchParams({icons:l});r+=i+".json?"+d.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let a=503;Xn(e+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(El(o)?"abort":"next",o)});return}return a=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",a)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",a)})},Tl={prepare:Il,send:Fl};function ur(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(a=>a.id!==t))})}function Ll(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,a=e.prefix;t.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(d=>{if(d.prefix!==a)return!0;const u=d.name;if(e.icons[u])o.loaded.push({provider:r,prefix:a,name:u});else if(e.missing.has(u))o.missing.push({provider:r,prefix:a,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||ur([e],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let Ol=0;function Pl(e,t,n){const r=Ol++,a=ur.bind(null,n,r);if(!t.pending.length)return a;const i={id:r,icons:t,callback:e,abort:a};return n.forEach(o=>{(o.loaderCallbacks||(o.loaderCallbacks=[])).push(i)}),a}function _l(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((a,i)=>a.provider!==i.provider?a.provider.localeCompare(i.provider):a.prefix!==i.prefix?a.prefix.localeCompare(i.prefix):a.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(a=>{if(r.name===a.name&&r.prefix===a.prefix&&r.provider===a.provider)return;r=a;const i=a.provider,o=a.prefix,l=a.name,d=n[i]||(n[i]=Object.create(null)),u=d[o]||(d[o]=Ze(i,o));let f;l in u.icons?f=t.loaded:o===""||u.missing.has(l)?f=t.missing:f=t.pending;const h={provider:i,prefix:o,name:l};f.push(h)}),t}function zl(e,t=!0,n=!1){const r=[];return e.forEach(a=>{const i=typeof a=="string"?St(a,t,n):a;i&&r.push(i)}),r}const Rl={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Bl(e,t,n,r){const a=e.resources.length,i=e.random?Math.floor(Math.random()*a):e.index;let o;if(e.random){let $=e.resources.slice(0);for(o=[];$.length>1;){const M=Math.floor(Math.random()*$.length);o.push($[M]),$=$.slice(0,M).concat($.slice(M+1))}o=o.concat($)}else o=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let d="pending",u=0,f,h=null,y=[],m=[];typeof r=="function"&&m.push(r);function j(){h&&(clearTimeout(h),h=null)}function k(){d==="pending"&&(d="aborted"),j(),y.forEach($=>{$.status==="pending"&&($.status="aborted")}),y=[]}function g($,M){M&&(m=[]),typeof $=="function"&&m.push($)}function w(){return{startTime:l,payload:t,status:d,queriesSent:u,queriesPending:y.length,subscribe:g,abort:k}}function N(){d="failed",m.forEach($=>{$(void 0,f)})}function S(){y.forEach($=>{$.status==="pending"&&($.status="aborted")}),y=[]}function b($,M,O){const A=M!=="success";switch(y=y.filter(_=>_!==$),d){case"pending":break;case"failed":if(A||!e.dataAfterTimeout)return;break;default:return}if(M==="abort"){f=O,N();return}if(A){f=O,y.length||(o.length?v():N());return}if(j(),S(),!e.random){const _=e.resources.indexOf($.resource);_!==-1&&_!==e.index&&(e.index=_)}d="completed",m.forEach(_=>{_(O)})}function v(){if(d!=="pending")return;j();const $=o.shift();if($===void 0){if(y.length){h=setTimeout(()=>{j(),d==="pending"&&(S(),N())},e.timeout);return}N();return}const M={status:"pending",resource:$,callback:(O,A)=>{b(M,O,A)}};y.push(M),u++,h=setTimeout(v,e.rotate),n($,t,M.callback)}return setTimeout(v),w}function fr(e){const t={...Rl,...e};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function a(l,d,u){const f=Bl(t,l,d,(h,y)=>{r(),u&&u(h,y)});return n.push(f),f}function i(l){return n.find(d=>l(d))||null}return{query:a,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:r}}function es(){}const Rt=Object.create(null);function Vl(e){if(!Rt[e]){const t=jn(e);if(!t)return;const n=fr(t),r={config:t,redundancy:n};Rt[e]=r}return Rt[e]}function Ul(e,t,n){let r,a;if(typeof e=="string"){const i=nn(e);if(!i)return n(void 0,424),es;a=i.send;const o=Vl(e);o&&(r=o.redundancy)}else{const i=yn(e);if(i){r=fr(i);const o=e.resources?e.resources[0]:"",l=nn(o);l&&(a=l.send)}}return!r||!a?(n(void 0,424),es):r.query(t,a,n)().abort}function ts(){}function Hl(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Ll(e)}))}function ql(e){const t=[],n=[];return e.forEach(r=>{(r.match(lr)?t:n).push(r)}),{valid:t,invalid:n}}function nt(e,t,n){function r(){const a=e.pendingIcons;t.forEach(i=>{a&&a.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!ir(e,n).length){r();return}}catch(a){console.error(a)}r(),Hl(e)}function ns(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function Wl(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const i=e.loadIcon;if(e.loadIcons&&(a.length>1||!i)){ns(e.loadIcons(a,r,n),f=>{nt(e,a,f)});return}if(i){a.forEach(f=>{const h=i(f,r,n);ns(h,y=>{const m=y?{prefix:r,icons:{[f]:y}}:null;nt(e,[f],m)})});return}const{valid:o,invalid:l}=ql(a);if(l.length&&nt(e,l,null),!o.length)return;const d=r.match(lr)?nn(n):null;if(!d){nt(e,o,null);return}d.prepare(n,r,o).forEach(f=>{Ul(n,f,h=>{nt(e,f.icons,h)})})}))}const Yl=(e,t)=>{const n=zl(e,!0,or()),r=_l(n);if(!r.pending.length){let d=!0;return t&&setTimeout(()=>{d&&t(r.loaded,r.missing,r.pending,ts)}),()=>{d=!1}}const a=Object.create(null),i=[];let o,l;return r.pending.forEach(d=>{const{provider:u,prefix:f}=d;if(f===l&&u===o)return;o=u,l=f,i.push(Ze(u,f));const h=a[u]||(a[u]=Object.create(null));h[f]||(h[f]=[])}),r.pending.forEach(d=>{const{provider:u,prefix:f,name:h}=d,y=Ze(u,f),m=y.pendingIcons||(y.pendingIcons=new Set);m.has(h)||(m.add(h),a[u][f].push(h))}),i.forEach(d=>{const u=a[d.provider][d.prefix];u.length&&Wl(d,u)}),t?Pl(t,r,i):ts};function Gl(e,t){const n={...e};for(const r in t){const a=t[r],i=typeof a;r in cr?(a===null||a&&(i==="string"||i==="number"))&&(n[r]=a):i===typeof n[r]&&(n[r]=r==="rotate"?a%4:a)}return n}const Kl=/[\s,]+/;function Ql(e,t){t.split(Kl).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Zl(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(a){for(;a<0;)a+=4;return a%4}if(n===""){const a=parseInt(e);return isNaN(a)?0:r(a)}else if(n!==e){let a=0;switch(n){case"%":a=25;break;case"deg":a=90}if(a){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/a,i%1===0?r(i):0)}}return t}function Jl(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Xl(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function eo(e){return"data:image/svg+xml,"+Xl(e)}function to(e){return'url("'+eo(e)+'")'}let at;function no(){try{at=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{at=null}}function so(e){return at===void 0&&no(),at?at.createHTML(e):e}const mr={...dr,inline:!1},ro={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ao={display:"inline-block"},sn={backgroundColor:"currentColor"},hr={backgroundColor:"transparent"},ss={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},rs={WebkitMask:sn,mask:sn,background:hr};for(const e in rs){const t=rs[e];for(const n in ss)t[e+n]=ss[n]}const io={...mr,inline:!0};function as(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const lo=(e,t,n)=>{const r=t.inline?io:mr,a=Gl(r,t),i=t.mode||"svg",o={},l=t.style||{},d={...i==="svg"?ro:{}};if(n){const g=St(n,!1,!0);if(g){const w=["iconify"],N=["provider","prefix"];for(const S of N)g[S]&&w.push("iconify--"+g[S]);d.className=w.join(" ")}}for(let g in t){const w=t[g];if(w!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=w;break;case"className":d[g]=(d[g]?d[g]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":a[g]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&Ql(a,w);break;case"color":o.color=w;break;case"rotate":typeof w=="string"?a[g]=Zl(w):typeof w=="number"&&(a[g]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete d["aria-hidden"];break;default:r[g]===void 0&&(d[g]=w)}}const u=jl(e,a),f=u.attributes;if(a.inline&&(o.verticalAlign="-0.125em"),i==="svg"){d.style={...o,...l},Object.assign(d,f);let g=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:so(kl(u.body,w?()=>w+"ID"+g++:"iconifyReact"))},p.createElement("svg",d)}const{body:h,width:y,height:m}=e,j=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),k=Jl(h,{...f,width:y+"",height:m+""});return d.style={...o,"--svg":to(k),width:as(f.width),height:as(f.height),...ao,...j?sn:hr,...l},p.createElement("span",d)};or(!0);Sl("",Tl);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!hl(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const a=t[n];if(typeof a!="object"||!a||a.resources===void 0)continue;Al(n,a)||console.error(r)}catch{console.error(r)}}}}function xr(e){const[t,n]=p.useState(!!e.ssr),[r,a]=p.useState({});function i(m){if(m){const j=e.icon;if(typeof j=="object")return{name:"",data:j};const k=Zn(j);if(k)return{name:j,data:k}}return{name:""}}const[o,l]=p.useState(i(!!e.ssr));function d(){const m=r.callback;m&&(m(),a({}))}function u(m){if(JSON.stringify(o)!==JSON.stringify(m))return d(),l(m),!0}function f(){var m;const j=e.icon;if(typeof j=="object"){u({name:"",data:j});return}const k=Zn(j);if(u({name:j,data:k}))if(k===void 0){const g=Yl([j],f);a({callback:g})}else k&&((m=e.onLoad)===null||m===void 0||m.call(e,j))}p.useEffect(()=>(n(!0),d),[]),p.useEffect(()=>{t&&f()},[e.icon,t]);const{name:h,data:y}=o;return y?lo({...bn,...y},e,h):e.children?e.children:e.fallback?e.fallback:p.createElement("span",{})}const V=p.forwardRef((e,t)=>xr({...e,_ref:t}));p.forwardRef((e,t)=>xr({inline:!0,...e,_ref:t}));const Bt=({icon:e,children:t,testId:n})=>s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[s.jsx(V,{icon:e,width:20,className:"text-default-500"}),s.jsx("span",{children:t})]}),oo=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:a,location:i,description:o,showImage:l=!1,compact:d=!1,imageLoading:u="eager",showMoreButtonClassName:f,labels:h})=>{const[y,m]=p.useState(!1),[j,k]=p.useState(!1),g=p.useRef(null);return p.useEffect(()=>{const w=()=>{if(g.current){const N=g.current.scrollHeight>g.current.clientHeight;k(N)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[o]),s.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[s.jsxs(c.CardHeader,{className:c.cn("pt-2 pb-0 flex-col items-start",d?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[l&&n&&s.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:s.jsx(c.Image,{removeWrapper:!0,loading:u,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),s.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),s.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[s.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),s.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&s.jsx(Bt,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),a&&s.jsx(Bt,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:a}),i&&s.jsx(Bt,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),o&&s.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{ref:g,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!y&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!y&&j&&s.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(j||y)&&s.jsx("div",{className:"flex justify-end mt-1",children:s.jsx(W,{onPress:()=>m(!y),variant:"light",className:c.cn("text-primary",f),size:d?"sm":"md",startContent:s.jsx(V,{icon:y?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:y?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function rn(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function co(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}const uo={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached",ruleBlocked:"Unavailable for selected ticket options",disabled:"Ticket selection is unavailable"},We=e=>typeof e=="number"&&!isNaN(e),yt=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:a="USD",locale:i="en-US",labels:o,slots:l,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:h=!0,showDescription:y=!0,showPeopleCount:m=!0,showPrice:j=!0,priceDisplay:k,classNames:g={},"data-testid":w,selectedColor:N="default",compact:S=!1,isSoldOut:b,isMaxReached:v,isRuleBlocked:$,statusTone:M="default",statusLabel:O,disabledReason:A,disabled:_})=>{const I=p.useMemo(()=>({...uo,...o}),[o]),[D,F]=p.useState(n),L=t!==void 0?t:D,Q=!!(d||_),U=S||!!e.compact,H=p.useMemo(()=>typeof b=="boolean"?b:typeof e.isSoldOut=="boolean"?e.isSoldOut:!We(e.totalTicketsSold)||!We(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[b,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),J=p.useMemo(()=>typeof v=="boolean"?v:typeof e.isMaxReached=="boolean"?e.isMaxReached:H||!We(e.ticketsAllowed)?!1:L>=e.ticketsAllowed-(e.totalTicketsSold??0),[v,e.isMaxReached,H,e.ticketsAllowed,e.totalTicketsSold,L]),ee=p.useMemo(()=>typeof $=="boolean"?$:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[$,e.isRuleBlocked]),se=A||e.disabledReason,Y=Q||H||ee,B=X=>{if(Y||X>0&&J)return;const me=Math.max(0,L+X);t===void 0&&F(me),r?.(e.id,me)},G=p.useMemo(()=>{if(H)return"soldOut";if(ee)return"ruleBlocked";if(Q)return"disabled"},[H,ee,Q]),Z=p.useMemo(()=>M||(H||ee?"danger":J?"warning":"default"),[M,H,ee,J]),ie=p.useMemo(()=>{if(G)return G==="ruleBlocked"?O||se||I.ruleBlocked:G==="soldOut"?O||se||I.soldOut:G==="disabled"?O||se||I.disabled:O||I.maxReached},[G,O,se,I]),re={soldOut:"danger",ruleBlocked:Z,disabled:"default",maxReached:"warning"},Ne={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},ve=()=>l?.renderName?l.renderName(e.name,e):s.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",U&&"text-sm",g.name),children:e.name}),xe=()=>{if(!j)return null;const X=k?.price??e.price,me=k?.originalPrice,qe=rn(X,i,a);if(l?.renderPrice)return l.renderPrice(X,qe,e);if(We(me)&&We(X)&&me>X){const Xe=rn(me,i,a);return s.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",U&&"mt-0.5",g.price),children:[s.jsxs("span",{className:"sr-only",children:["Original price ",Xe,", discounted price ",qe]}),s.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",U&&"text-xs",g.originalPrice),children:Xe}),s.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",U&&"text-sm",g.discountedPrice),children:qe})]})}return s.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",U&&"text-sm mt-0.5",g.price),children:qe})},Ee=()=>!y||!e.description?null:l?.renderDescription?l.renderDescription(e.description,e):s.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",U&&"mb-2 text-xs text-gray-600",g.description),children:e.description}),Ie=()=>{if(!m||!We(e.numberOfPeople)||e.numberOfPeople<=0)return null;const X=e.numberOfPeople===1?I.person:I.people;return l?.renderPeopleCount?l.renderPeopleCount(e.numberOfPeople,X,e):s.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",U&&"mt-1 text-xs",g.peopleCount),children:[s.jsx(V,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",X]})},He=()=>{const X=L===0||Y,me=J||Y;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:L,onIncrement:()=>B(1),onDecrement:()=>B(-1),isDecrementDisabled:X,isIncrementDisabled:me,isDisabled:Y}):s.jsxs("div",{className:c.cn("flex items-center gap-2",g.quantitySelector),children:[s.jsx(W,{"data-testid":"offer-card-decrement-button",onPress:()=>B(-1),isDisabled:X,variant:u,color:L>0?N:f,radius:"full",isIconOnly:!0,size:U?"md":"sm","aria-label":"Decrease quantity",children:s.jsx(V,{icon:"gravity-ui:minus",width:16})}),s.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",U&&"text-sm"),children:L}),s.jsx(W,{"data-testid":"offer-card-increment-button",onPress:()=>B(1),isDisabled:me,variant:u,color:L>0?N:f,radius:"full",isIconOnly:!0,size:U?"md":"sm","aria-label":"Increase quantity",children:s.jsx(V,{icon:"gravity-ui:plus",width:16})})]})},Me=(X,me)=>l?.renderDisabledState?l.renderDisabledState(X,me):X==="soldOut"&&l?.renderSoldOut?l.renderSoldOut(me):X==="maxReached"&&l?.renderMaxReachedAlert?l.renderMaxReachedAlert(me):s.jsx(c.Chip,{"data-testid":Ne[X],color:re[X],variant:X==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",X==="maxReached"?"h-8":"h-10",X==="soldOut"&&g.soldOut,X==="maxReached"&&g.maxReachedAlert,U&&"h-8"),startContent:s.jsx(V,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:s.jsx("span",{className:"font-medium text-sm",children:me})}),_e=s.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",U?"gap-1":"gap-2"),children:[s.jsxs("div",{className:c.cn("h-full col-span-2",Y||J?"opacity-50 pointer-events-none select-none":""),children:[ve(),xe(),s.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",U?"mb-1":"mb-2"),children:[Ie(),Ee()]})]}),s.jsx("div",{className:c.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",U&&"space-x-1 pb-1 md:p-1",g.compactFooter),children:G&&ie?Me(G,ie):He()})]}),Ae=J&&!H&&!ee&&!Q?s.jsx(Ce.motion.div,{className:c.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",g.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Me("maxReached",ie||I.maxReached)}):null;return h?s.jsxs(c.Card,{className:c.cn("w-full",U&&g.compact,g.base),"data-testid":w||`offer-card-${e.id}`,children:[s.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",U?"pb-0.5":"",g.body),children:_e}),s.jsx(Ce.AnimatePresence,{children:Ae&&s.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",U?"pt-1":"",g.footer),children:Ae})})]}):s.jsxs("div",{className:c.cn("w-full",U&&g.compact,g.base),"data-testid":w||`offer-card-${e.id}`,children:[s.jsx("div",{className:c.cn("pt-1 pb-0",U?"pb-0.5":"",g.body),children:_e}),s.jsx(Ce.AnimatePresence,{children:Ae&&s.jsx("div",{className:c.cn("w-full mt-0 pt-0",U?"pt-1":"",g.footer),children:Ae})})]})};yt.displayName="OfferCard";const pr=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i){const l=i();return r?s.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):s.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:l})}const o=s.jsxs("div",{"data-testid":"offer-card-empty-content",className:c.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",a.content),children:[s.jsx(V,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:c.cn("mb-4",a.icon)}),s.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",a.message),children:e})]});return r?s.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):s.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:o})};pr.displayName="OfferCardEmpty";const fo={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},gr=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...fo,...t},o=s.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:o})}):s.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",a.base),children:o})};gr.displayName="OfferCardError";const mo={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},br=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=mo[t];return s.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(r,n.base),children:Array.from({length:e}).map((a,i)=>s.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",n.card),children:[s.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:s.jsxs("div",{className:"space-y-2 w-full",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),s.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[s.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),s.jsx("div",{className:"flex items-start justify-end",children:s.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};br.displayName="OfferCardSkeleton";const yr={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},vr={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},ho={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},jr=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:a,onQuantityChange:i,currency:o="USD",locale:l="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:h="bordered",buttonColor:y="default",showCard:m=!0,animated:j=!0,gap:k=2,compact:g=!1,classNames:w={}})=>{const[N,S]=p.useState(r),b=n!==void 0?n:N,v=p.useCallback((I,D)=>{const F={...b,[I]:Math.max(0,D)};n===void 0&&S(F),a?.(F),i?.(I,F[I])},[b,n,a,i]),$=[...e].sort((I,D)=>(I.position??0)-(D.position??0)),M=I=>{const D=t?t(I):I,F=(b??{})[D.id]||0;return{offer:D,quantity:F,onQuantityChange:v,currency:o,locale:l,labels:d,slots:u,isDisabled:f,buttonVariant:h,buttonColor:y,showCard:m,compact:g}},O=ho[k],A=c.cn("grid mx-auto pt-2",O,w.base),_=I=>{const D=M(I);return s.jsx(yt,{offer:D.offer,quantity:D.quantity,onQuantityChange:D.onQuantityChange,currency:D.currency,locale:D.locale,labels:D.labels,slots:D.slots,isDisabled:D.isDisabled,buttonVariant:D.buttonVariant,buttonColor:D.buttonColor,showCard:D.showCard,compact:D.compact,classNames:w.card},D.offer.id)};return j?s.jsx(Ce.motion.div,{"data-testid":"offer-card-list",className:A,variants:yr,initial:"hidden",animate:"show",children:s.jsx(Ce.AnimatePresence,{children:$.map(I=>{const D=M(I);return s.jsx(Ce.motion.div,{"data-testid":`offer-card-list-item-${D.offer.id}`,className:w.cardWrapper,variants:vr,exit:{opacity:0,y:-20},transition:{duration:.3},children:s.jsx(yt,{offer:D.offer,quantity:D.quantity,onQuantityChange:v,currency:o,locale:l,labels:d,slots:u,isDisabled:f,buttonVariant:h,buttonColor:y,showCard:m,compact:g||D.offer.compact,classNames:w.card})},D.offer.id)})})}):s.jsx("div",{"data-testid":"offer-card-list",className:A,children:$.map(_)})};jr.displayName="OfferCardList";var ut=e=>e.type==="checkbox",Ve=e=>e instanceof Date,ye=e=>e==null;const wr=e=>typeof e=="object";var fe=e=>!ye(e)&&!Array.isArray(e)&&wr(e)&&!Ve(e),Nr=e=>fe(e)&&e.target?ut(e.target)?e.target.checked:e.target.value:e,xo=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Cr=(e,t)=>e.has(xo(t)),po=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},wn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(wn&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(fe(e)&&po(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=de(e[a]));return r}var At=e=>/^\w*$/.test(e),oe=e=>e===void 0,Nn=e=>Array.isArray(e)?e.filter(Boolean):[],Cn=e=>Nn(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,t,n)=>{if(!t||!fe(e))return n;const r=(At(t)?[t]:Cn(t)).reduce((a,i)=>ye(a)?a:a[i],e);return oe(r)||r===e?oe(e[t])?n:e[t]:r},je=e=>typeof e=="boolean",be=e=>typeof e=="function",ae=(e,t,n)=>{let r=-1;const a=At(t)?[t]:Cn(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let d=n;if(r!==o){const u=e[l];d=fe(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=d,e=e[l]}};const vt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ke={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},$e={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},kr=p.createContext(null);kr.displayName="HookFormControlContext";const kn=()=>p.useContext(kr);var Sr=(e,t,n,r=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ke.all&&(t._proxyFormState[o]=!r||ke.all),n&&(n[o]=!0),e[o]}});return a};const Sn=typeof window<"u"?p.useLayoutEffect:p.useEffect;function go(e){const t=kn(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=p.useState(n._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Sn(()=>n._subscribe({name:a,formState:d.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[a,r,i]),p.useEffect(()=>{d.current.isValid&&n._setValid(!0)},[n]),p.useMemo(()=>Sr(o,n,d.current,!1),[o,n])}var we=e=>typeof e=="string",an=(e,t,n,r,a)=>we(e)?(r&&t.watch.add(e),z(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),z(n,i))):(r&&(t.watchAll=!0),n),ln=e=>ye(e)||!wr(e);function Se(e,t,n=new WeakSet){if(ln(e)||ln(t))return Object.is(e,t);if(Ve(e)&&Ve(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=t[i];if(Ve(o)&&Ve(l)||fe(o)&&fe(l)||Array.isArray(o)&&Array.isArray(l)?!Se(o,l,n):!Object.is(o,l))return!1}}return!0}function bo(e){const t=kn(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},d=p.useRef(a),u=p.useRef(l),f=p.useRef(void 0),h=p.useRef(n),y=p.useRef(r);u.current=l;const[m,j]=p.useState(()=>{const b=n._getWatch(r,d.current);return u.current?u.current(b):b}),k=p.useCallback(b=>{const v=an(r,n._names,b||n._formValues,!1,d.current);return u.current?u.current(v):v},[n._formValues,n._names,r]),g=p.useCallback(b=>{if(!i){const v=an(r,n._names,b||n._formValues,!1,d.current);if(u.current){const $=u.current(v);Se($,f.current)||(j($),f.current=$)}else j(v)}},[n._formValues,n._names,i,r]);Sn(()=>((h.current!==n||!Se(y.current,r))&&(h.current=n,y.current=r,g()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:b=>{g(b.values)}})),[n,o,r,g]),p.useEffect(()=>n._removeUnmounted());const w=h.current!==n,N=y.current,S=p.useMemo(()=>{if(i)return null;const b=!w&&!Se(N,r);return w||b?k():null},[i,w,r,N,k]);return S!==null?S:m}function yo(e){const t=kn(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,d=Cr(a._names.array,n),u=p.useMemo(()=>z(a._formValues,n,z(a._defaultValues,n,o)),[a,n,o]),f=bo({control:a,name:n,defaultValue:u,exact:l}),h=go({control:a,name:n,exact:l}),y=p.useRef(e),m=p.useRef(void 0),j=p.useRef(a.register(n,{...e.rules,value:f,...je(e.disabled)?{disabled:e.disabled}:{}}));y.current=e;const k=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(h.errors,n)},isDirty:{enumerable:!0,get:()=>!!z(h.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!z(h.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!z(h.validatingFields,n)},error:{enumerable:!0,get:()=>z(h.errors,n)}}),[h,n]),g=p.useCallback(b=>j.current.onChange({target:{value:Nr(b),name:n},type:vt.CHANGE}),[n]),w=p.useCallback(()=>j.current.onBlur({target:{value:z(a._formValues,n),name:n},type:vt.BLUR}),[n,a._formValues]),N=p.useCallback(b=>{const v=z(a._fields,n);v&&v._f&&b&&(v._f.ref={focus:()=>be(b.focus)&&b.focus(),select:()=>be(b.select)&&b.select(),setCustomValidity:$=>be(b.setCustomValidity)&&b.setCustomValidity($),reportValidity:()=>be(b.reportValidity)&&b.reportValidity()})},[a._fields,n]),S=p.useMemo(()=>({name:n,value:f,...je(r)||h.disabled?{disabled:h.disabled||r}:{},onChange:g,onBlur:w,ref:N}),[n,r,h.disabled,g,w,N,f]);return p.useEffect(()=>{const b=a._options.shouldUnregister||i,v=m.current;v&&v!==n&&!d&&a.unregister(v),a.register(n,{...y.current.rules,...je(y.current.disabled)?{disabled:y.current.disabled}:{}});const $=(M,O)=>{const A=z(a._fields,M);A&&A._f&&(A._f.mount=O)};if($(n,!0),b){const M=de(z(a._options.defaultValues,n,y.current.defaultValue));ae(a._defaultValues,n,M),oe(z(a._formValues,n))&&ae(a._formValues,n,M)}return!d&&a.register(n),m.current=n,()=>{(d?b&&!a._state.action:b)?a.unregister(n):$(n,!1)}},[n,a,d,i]),p.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),p.useMemo(()=>({field:S,formState:h,fieldState:k}),[S,h,k])}const vo=p.createContext(null);vo.displayName="HookFormContext";var jo=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},it=e=>Array.isArray(e)?e:[e],is=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function Ar(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&fe(a)&&i){const o=Ar(a,i);fe(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var ge=e=>fe(e)&&!Object.keys(e).length,An=e=>e.type==="file",jt=e=>{if(!wn)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},$r=e=>e.type==="select-multiple",$n=e=>e.type==="radio",wo=e=>$n(e)||ut(e),Vt=e=>jt(e)&&e.isConnected;function No(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=oe(e)?r++:e[t[r++]];return e}function Co(e){for(const t in e)if(e.hasOwnProperty(t)&&!oe(e[t]))return!1;return!0}function ue(e,t){const n=Array.isArray(t)?t:At(t)?[t]:Cn(t),r=n.length===1?e:No(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(fe(r)&&ge(r)||Array.isArray(r)&&Co(r))&&ue(e,n.slice(0,-1)),e}var ko=e=>{for(const t in e)if(be(e[t]))return!0;return!1};function Dr(e){return Array.isArray(e)||fe(e)&&!ko(e)}function on(e,t={}){for(const n in e){const r=e[n];Dr(r)?(t[n]=Array.isArray(r)?[]:{},on(r,t[n])):oe(r)||(t[n]=!0)}return t}function Ke(e,t,n){n||(n=on(t));for(const r in e){const a=e[r];if(Dr(a))oe(t)||ln(n[r])?n[r]=on(a,Array.isArray(a)?[]:{}):Ke(a,ye(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Se(a,i)}}return n}const ls={value:!1,isValid:!1},os={value:!0,isValid:!0};var Er=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!oe(e[0].attributes.value)?oe(e[0].value)||e[0].value===""?os:{value:e[0].value,isValid:!0}:os:ls}return ls},Ir=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>oe(e)?e:t?e===""?NaN:e&&+e:n&&we(e)?new Date(e):r?r(e):e;const cs={isValid:!1,value:null};var Mr=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,cs):cs;function ds(e){const t=e.ref;return An(t)?t.files:$n(t)?Mr(e.refs).value:$r(t)?[...t.selectedOptions].map(({value:n})=>n):ut(t)?Er(e.refs).value:Ir(oe(t.value)?e.ref.value:t.value,e)}var So=(e,t,n,r)=>{const a={};for(const i of e){const o=z(t,i);o&&ae(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},wt=e=>e instanceof RegExp,st=e=>oe(e)?e:wt(e)?e.source:fe(e)?wt(e.value)?e.value.source:e.value:e,us=e=>({isOnSubmit:!e||e===ke.onSubmit,isOnBlur:e===ke.onBlur,isOnChange:e===ke.onChange,isOnAll:e===ke.all,isOnTouch:e===ke.onTouched});const fs="AsyncFunction";var Ao=e=>!!e&&!!e.validate&&!!(be(e.validate)&&e.validate.constructor.name===fs||fe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===fs)),$o=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ms=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const lt=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=z(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(lt(l,t))break}else if(fe(l)&<(l,t))break}}};function hs(e,t,n){const r=z(e,n);if(r||At(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=z(t,i),l=z(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:n}}var Do=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return ge(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!r||ke.all))},Eo=(e,t,n)=>!e||!t||e===t||it(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Io=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,Mo=(e,t)=>!Nn(z(e,t)).length&&ue(e,t),Fo=(e,t,n)=>{const r=it(z(e,n));return ae(r,"root",t[n]),ae(e,n,r),e};function xs(e,t,n="validate"){if(we(e)||Array.isArray(e)&&e.every(we)||je(e)&&!e)return{type:n,message:we(e)?e:"",ref:t}}var Ye=e=>fe(e)&&!wt(e)?e:{value:e,message:""},ps=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:d,maxLength:u,minLength:f,min:h,max:y,pattern:m,validate:j,name:k,valueAsNumber:g,mount:w}=e._f,N=z(n,k);if(!w||t.has(k))return{};const S=l?l[0]:o,b=D=>{a&&S.reportValidity&&(S.setCustomValidity(je(D)?"":D||""),S.reportValidity())},v={},$=$n(o),M=ut(o),O=$||M,A=(g||An(o))&&oe(o.value)&&oe(N)||jt(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length,_=jo.bind(null,k,r,v),I=(D,F,L,Q=$e.maxLength,U=$e.minLength)=>{const H=D?F:L;v[k]={type:D?Q:U,message:H,ref:o,..._(D?Q:U,H)}};if(i?!Array.isArray(N)||!N.length:d&&(!O&&(A||ye(N))||je(N)&&!N||M&&!Er(l).isValid||$&&!Mr(l).isValid)){const{value:D,message:F}=we(d)?{value:!!d,message:d}:Ye(d);if(D&&(v[k]={type:$e.required,message:F,ref:S,..._($e.required,F)},!r))return b(F),v}if(!A&&(!ye(h)||!ye(y))){let D,F;const L=Ye(y),Q=Ye(h);if(!ye(N)&&!isNaN(N)){const U=o.valueAsNumber||N&&+N;ye(L.value)||(D=U>L.value),ye(Q.value)||(F=U<Q.value)}else{const U=o.valueAsDate||new Date(N),H=se=>new Date(new Date().toDateString()+" "+se),J=o.type=="time",ee=o.type=="week";we(L.value)&&N&&(D=J?H(N)>H(L.value):ee?N>L.value:U>new Date(L.value)),we(Q.value)&&N&&(F=J?H(N)<H(Q.value):ee?N<Q.value:U<new Date(Q.value))}if((D||F)&&(I(!!D,L.message,Q.message,$e.max,$e.min),!r))return b(v[k].message),v}if((u||f)&&!A&&(we(N)||i&&Array.isArray(N))){const D=Ye(u),F=Ye(f),L=!ye(D.value)&&N.length>+D.value,Q=!ye(F.value)&&N.length<+F.value;if((L||Q)&&(I(L,D.message,F.message),!r))return b(v[k].message),v}if(m&&!A&&we(N)){const{value:D,message:F}=Ye(m);if(wt(D)&&!N.match(D)&&(v[k]={type:$e.pattern,message:F,ref:o,..._($e.pattern,F)},!r))return b(F),v}if(j){if(be(j)){const D=await j(N,n),F=xs(D,S);if(F&&(v[k]={...F,..._($e.validate,F.message)},!r))return b(F.message),v}else if(fe(j)){let D={};for(const F in j){if(!ge(D)&&!r)break;const L=xs(await j[F](N,n),S,F);L&&(D={...L,..._(F,L.message)},b(L.message),r&&(v[k]=D))}if(!ge(D)&&(v[k]={ref:S,...D},!r))return v}}return b(!0),v};const To={mode:ke.onSubmit,reValidateMode:ke.onChange,shouldFocusError:!0};function Lo(e={}){let t={...To,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:be(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=fe(t.defaultValues)||fe(t.values)?de(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:de(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...f};let y={...h};const m={array:is(),state:is()},j=t.criteriaMode===ke.all,k=x=>C=>{clearTimeout(u),u=setTimeout(x,C)},g=async x=>{if(!o.keepIsValid&&!t.disabled&&(h.isValid||y.isValid||x)){let C;t.resolver?(C=ge((await O()).errors),w()):C=await _(r,!0),C!==n.isValid&&m.state.next({isValid:C})}},w=(x,C)=>{!t.disabled&&(h.isValidating||h.validatingFields||y.isValidating||y.validatingFields)&&((x||Array.from(l.mount)).forEach(E=>{E&&(C?ae(n.validatingFields,E,C):ue(n.validatingFields,E))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ge(n.validatingFields)}))},N=(x,C=[],E,R,P=!0,T=!0)=>{if(R&&E&&!t.disabled){if(o.action=!0,T&&Array.isArray(z(r,x))){const q=E(z(r,x),R.argA,R.argB);P&&ae(r,x,q)}if(T&&Array.isArray(z(n.errors,x))){const q=E(z(n.errors,x),R.argA,R.argB);P&&ae(n.errors,x,q),Mo(n.errors,x)}if((h.touchedFields||y.touchedFields)&&T&&Array.isArray(z(n.touchedFields,x))){const q=E(z(n.touchedFields,x),R.argA,R.argB);P&&ae(n.touchedFields,x,q)}(h.dirtyFields||y.dirtyFields)&&(n.dirtyFields=Ke(a,i)),m.state.next({name:x,isDirty:D(x,C),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ae(i,x,C)},S=(x,C)=>{ae(n.errors,x,C),m.state.next({errors:n.errors})},b=x=>{n.errors=x,m.state.next({errors:n.errors,isValid:!1})},v=(x,C,E,R)=>{const P=z(r,x);if(P){const T=z(i,x,oe(E)?z(a,x):E);oe(T)||R&&R.defaultChecked||C?ae(i,x,C?T:ds(P._f)):Q(x,T),o.mount&&!o.action&&g()}},$=(x,C,E,R,P)=>{let T=!1,q=!1;const te={name:x};if(!t.disabled){if(!E||R){(h.isDirty||y.isDirty)&&(q=n.isDirty,n.isDirty=te.isDirty=D(),T=q!==te.isDirty);const ne=Se(z(a,x),C);q=!!z(n.dirtyFields,x),ne?ue(n.dirtyFields,x):ae(n.dirtyFields,x,!0),te.dirtyFields=n.dirtyFields,T=T||(h.dirtyFields||y.dirtyFields)&&q!==!ne}if(E){const ne=z(n.touchedFields,x);ne||(ae(n.touchedFields,x,E),te.touchedFields=n.touchedFields,T=T||(h.touchedFields||y.touchedFields)&&ne!==E)}T&&P&&m.state.next(te)}return T?te:{}},M=(x,C,E,R)=>{const P=z(n.errors,x),T=(h.isValid||y.isValid)&&je(C)&&n.isValid!==C;if(t.delayError&&E?(d=k(()=>S(x,E)),d(t.delayError)):(clearTimeout(u),d=null,E?ae(n.errors,x,E):ue(n.errors,x)),(E?!Se(P,E):P)||!ge(R)||T){const q={...R,...T&&je(C)?{isValid:C}:{},errors:n.errors,name:x};n={...n,...q},m.state.next(q)}},O=async x=>(w(x,!0),await t.resolver(i,t.context,So(x||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),A=async x=>{const{errors:C}=await O(x);if(w(x),x)for(const E of x){const R=z(C,E);R?ae(n.errors,E,R):ue(n.errors,E)}else n.errors=C;return C},_=async(x,C,E={valid:!0})=>{for(const R in x){const P=x[R];if(P){const{_f:T,...q}=P;if(T){const te=l.array.has(T.name),ne=P._f&&Ao(P._f);ne&&h.validatingFields&&w([T.name],!0);const pe=await ps(P,l.disabled,i,j,t.shouldUseNativeValidation&&!C,te);if(ne&&h.validatingFields&&w([T.name]),pe[T.name]&&(E.valid=!1,C||e.shouldUseNativeValidation))break;!C&&(z(pe,T.name)?te?Fo(n.errors,pe,T.name):ae(n.errors,T.name,pe[T.name]):ue(n.errors,T.name))}!ge(q)&&await _(q,C,E)}}return E.valid},I=()=>{for(const x of l.unMount){const C=z(r,x);C&&(C._f.refs?C._f.refs.every(E=>!Vt(E)):!Vt(C._f.ref))&&ve(x)}l.unMount=new Set},D=(x,C)=>!t.disabled&&(x&&C&&ae(i,x,C),!Se(Y(),a)),F=(x,C,E)=>an(x,l,{...o.mount?i:oe(C)?a:we(x)?{[x]:C}:C},E,C),L=x=>Nn(z(o.mount?i:a,x,t.shouldUnregister?z(a,x,[]):[])),Q=(x,C,E={})=>{const R=z(r,x);let P=C;if(R){const T=R._f;T&&(!T.disabled&&ae(i,x,Ir(C,T)),P=jt(T.ref)&&ye(C)?"":C,$r(T.ref)?[...T.ref.options].forEach(q=>q.selected=P.includes(q.value)):T.refs?ut(T.ref)?T.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(P)?q.checked=!!P.find(te=>te===q.value):q.checked=P===q.value||!!P)}):T.refs.forEach(q=>q.checked=q.value===P):An(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||m.state.next({name:x,values:de(i)})))}(E.shouldDirty||E.shouldTouch)&&$(x,P,E.shouldTouch,E.shouldDirty,!0),E.shouldValidate&&se(x)},U=(x,C,E)=>{for(const R in C){if(!C.hasOwnProperty(R))return;const P=C[R],T=x+"."+R,q=z(r,T);(l.array.has(x)||fe(P)||q&&!q._f)&&!Ve(P)?U(T,P,E):Q(T,P,E)}},H=(x,C,E={})=>{const R=z(r,x),P=l.array.has(x),T=de(C);ae(i,x,T),P?(m.array.next({name:x,values:de(i)}),(h.isDirty||h.dirtyFields||y.isDirty||y.dirtyFields)&&E.shouldDirty&&m.state.next({name:x,dirtyFields:Ke(a,i),isDirty:D(x,T)})):R&&!R._f&&!ye(T)?U(x,T,E):Q(x,T,E),ms(x,l)?m.state.next({...n,name:x,values:de(i)}):m.state.next({name:o.mount?x:void 0,values:de(i)})},J=async x=>{o.mount=!0;const C=x.target;let E=C.name,R=!0;const P=z(r,E),T=ne=>{R=Number.isNaN(ne)||Ve(ne)&&isNaN(ne.getTime())||Se(ne,z(i,E,ne))},q=us(t.mode),te=us(t.reValidateMode);if(P){let ne,pe;const ze=C.type?ds(P._f):Nr(x),Fe=x.type===vt.BLUR||x.type===vt.FOCUS_OUT,Ca=!$o(P._f)&&!t.resolver&&!z(n.errors,E)&&!P._f.deps||Io(Fe,z(n.touchedFields,E),n.isSubmitted,te,q),Et=ms(E,l,Fe);ae(i,E,ze),Fe?(!C||!C.readOnly)&&(P._f.onBlur&&P._f.onBlur(x),d&&d(0)):P._f.onChange&&P._f.onChange(x);const It=$(E,ze,Fe),ka=!ge(It)||Et;if(!Fe&&m.state.next({name:E,type:x.type,values:de(i)}),Ca)return(h.isValid||y.isValid)&&(t.mode==="onBlur"?Fe&&g():Fe||g()),ka&&m.state.next({name:E,...Et?{}:It});if(!Fe&&Et&&m.state.next({...n}),t.resolver){const{errors:On}=await O([E]);if(w([E]),T(ze),R){const Sa=hs(n.errors,r,E),Pn=hs(On,r,Sa.name||E);ne=Pn.error,E=Pn.name,pe=ge(On)}}else w([E],!0),ne=(await ps(P,l.disabled,i,j,t.shouldUseNativeValidation))[E],w([E]),T(ze),R&&(ne?pe=!1:(h.isValid||y.isValid)&&(pe=await _(r,!0)));R&&(P._f.deps&&(!Array.isArray(P._f.deps)||P._f.deps.length>0)&&se(P._f.deps),M(E,pe,ne,It))}},ee=(x,C)=>{if(z(n.errors,C)&&x.focus)return x.focus(),1},se=async(x,C={})=>{let E,R;const P=it(x);if(t.resolver){const T=await A(oe(x)?x:P);E=ge(T),R=x?!P.some(q=>z(T,q)):E}else x?(R=(await Promise.all(P.map(async T=>{const q=z(r,T);return await _(q&&q._f?{[T]:q}:q)}))).every(Boolean),!(!R&&!n.isValid)&&g()):R=E=await _(r);return m.state.next({...!we(x)||(h.isValid||y.isValid)&&E!==n.isValid?{}:{name:x},...t.resolver||!x?{isValid:E}:{},errors:n.errors}),C.shouldFocus&&!R&<(r,ee,x?P:l.mount),R},Y=(x,C)=>{let E={...o.mount?i:a};return C&&(E=Ar(C.dirtyFields?n.dirtyFields:n.touchedFields,E)),oe(x)?E:we(x)?z(E,x):x.map(R=>z(E,R))},B=(x,C)=>({invalid:!!z((C||n).errors,x),isDirty:!!z((C||n).dirtyFields,x),error:z((C||n).errors,x),isValidating:!!z(n.validatingFields,x),isTouched:!!z((C||n).touchedFields,x)}),G=x=>{x&&it(x).forEach(C=>ue(n.errors,C)),m.state.next({errors:x?n.errors:{}})},Z=(x,C,E)=>{const R=(z(r,x,{_f:{}})._f||{}).ref,P=z(n.errors,x)||{},{ref:T,message:q,type:te,...ne}=P;ae(n.errors,x,{...ne,...C,ref:R}),m.state.next({name:x,errors:n.errors,isValid:!1}),E&&E.shouldFocus&&R&&R.focus&&R.focus()},ie=(x,C)=>be(x)?m.state.subscribe({next:E=>"values"in E&&x(F(void 0,C),E)}):F(x,C,!0),re=x=>m.state.subscribe({next:C=>{Eo(x.name,C.name,x.exact)&&Do(C,x.formState||h,qe,x.reRenderRoot)&&x.callback({values:{...i},...n,...C,defaultValues:a})}}).unsubscribe,Ne=x=>(o.mount=!0,y={...y,...x.formState},re({...x,formState:{...f,...x.formState}})),ve=(x,C={})=>{for(const E of x?it(x):l.mount)l.mount.delete(E),l.array.delete(E),C.keepValue||(ue(r,E),ue(i,E)),!C.keepError&&ue(n.errors,E),!C.keepDirty&&ue(n.dirtyFields,E),!C.keepTouched&&ue(n.touchedFields,E),!C.keepIsValidating&&ue(n.validatingFields,E),!t.shouldUnregister&&!C.keepDefaultValue&&ue(a,E);m.state.next({values:de(i)}),m.state.next({...n,...C.keepDirty?{isDirty:D()}:{}}),!C.keepIsValid&&g()},xe=({disabled:x,name:C})=>{if(je(x)&&o.mount||x||l.disabled.has(C)){const P=l.disabled.has(C)!==!!x;x?l.disabled.add(C):l.disabled.delete(C),P&&o.mount&&!o.action&&g()}},Ee=(x,C={})=>{let E=z(r,x);const R=je(C.disabled)||je(t.disabled);return ae(r,x,{...E||{},_f:{...E&&E._f?E._f:{ref:{name:x}},name:x,mount:!0,...C}}),l.mount.add(x),E?xe({disabled:je(C.disabled)?C.disabled:t.disabled,name:x}):v(x,!0,C.value),{...R?{disabled:C.disabled||t.disabled}:{},...t.progressive?{required:!!C.required,min:st(C.min),max:st(C.max),minLength:st(C.minLength),maxLength:st(C.maxLength),pattern:st(C.pattern)}:{},name:x,onChange:J,onBlur:J,ref:P=>{if(P){Ee(x,C),E=z(r,x);const T=oe(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,q=wo(T),te=E._f.refs||[];if(q?te.find(ne=>ne===T):T===E._f.ref)return;ae(r,x,{_f:{...E._f,...q?{refs:[...te.filter(Vt),T,...Array.isArray(z(a,x))?[{}]:[]],ref:{type:T.type,name:x}}:{ref:T}}}),v(x,!1,void 0,T)}else E=z(r,x,{}),E._f&&(E._f.mount=!1),(t.shouldUnregister||C.shouldUnregister)&&!(Cr(l.array,x)&&o.action)&&l.unMount.add(x)}}},Ie=()=>t.shouldFocusError&<(r,ee,l.mount),He=x=>{je(x)&&(m.state.next({disabled:x}),lt(r,(C,E)=>{const R=z(r,E);R&&(C.disabled=R._f.disabled||x,Array.isArray(R._f.refs)&&R._f.refs.forEach(P=>{P.disabled=R._f.disabled||x}))},0,!1))},Me=(x,C)=>async E=>{let R;E&&(E.preventDefault&&E.preventDefault(),E.persist&&E.persist());let P=de(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:T,values:q}=await O();w(),n.errors=T,P=de(q)}else await _(r);if(l.disabled.size)for(const T of l.disabled)ue(P,T);if(ue(n.errors,"root"),ge(n.errors)){m.state.next({errors:{}});try{await x(P,E)}catch(T){R=T}}else C&&await C({...n.errors},E),Ie(),setTimeout(Ie);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ge(n.errors)&&!R,submitCount:n.submitCount+1,errors:n.errors}),R)throw R},_e=(x,C={})=>{z(r,x)&&(oe(C.defaultValue)?H(x,de(z(a,x))):(H(x,C.defaultValue),ae(a,x,de(C.defaultValue))),C.keepTouched||ue(n.touchedFields,x),C.keepDirty||(ue(n.dirtyFields,x),n.isDirty=C.defaultValue?D(x,de(z(a,x))):D()),C.keepError||(ue(n.errors,x),h.isValid&&g()),m.state.next({...n}))},Ae=(x,C={})=>{const E=x?de(x):a,R=de(E),P=ge(x),T=P?a:R;if(C.keepDefaultValues||(a=E),!C.keepValues){if(C.keepDirtyValues){const q=new Set([...l.mount,...Object.keys(Ke(a,i))]);for(const te of Array.from(q)){const ne=z(n.dirtyFields,te),pe=z(i,te),ze=z(T,te);ne&&!oe(pe)?ae(T,te,pe):!ne&&!oe(ze)&&H(te,ze)}}else{if(wn&&oe(x))for(const q of l.mount){const te=z(r,q);if(te&&te._f){const ne=Array.isArray(te._f.refs)?te._f.refs[0]:te._f.ref;if(jt(ne)){const pe=ne.closest("form");if(pe){pe.reset();break}}}}if(C.keepFieldsRef)for(const q of l.mount)H(q,z(T,q));else r={}}i=t.shouldUnregister?C.keepDefaultValues?de(a):{}:de(T),m.array.next({values:{...T}}),m.state.next({values:{...T}})}l={mount:C.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!h.isValid||!!C.keepIsValid||!!C.keepDirtyValues||!t.shouldUnregister&&!ge(T),o.watch=!!t.shouldUnregister,o.keepIsValid=!!C.keepIsValid,o.action=!1,C.keepErrors||(n.errors={}),m.state.next({submitCount:C.keepSubmitCount?n.submitCount:0,isDirty:P?!1:C.keepDirty?n.isDirty:!!(C.keepDefaultValues&&!Se(x,a)),isSubmitted:C.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:P?{}:C.keepDirtyValues?C.keepDefaultValues&&i?Ke(a,i):n.dirtyFields:C.keepDefaultValues&&x?Ke(a,x):C.keepDirty?n.dirtyFields:{},touchedFields:C.keepTouched?n.touchedFields:{},errors:C.keepErrors?n.errors:{},isSubmitSuccessful:C.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},X=(x,C)=>Ae(be(x)?x(i):x,{...t.resetOptions,...C}),me=(x,C={})=>{const E=z(r,x),R=E&&E._f;if(R){const P=R.refs?R.refs[0]:R.ref;P.focus&&setTimeout(()=>{P.focus(),C.shouldSelect&&be(P.select)&&P.select()})}},qe=x=>{n={...n,...x}},Xe={control:{register:Ee,unregister:ve,getFieldState:B,handleSubmit:Me,setError:Z,_subscribe:re,_runSchema:O,_updateIsValidating:w,_focusError:Ie,_getWatch:F,_getDirty:D,_setValid:g,_setFieldArray:N,_setDisabledField:xe,_setErrors:b,_getFieldArray:L,_reset:Ae,_resetDefaultValues:()=>be(t.defaultValues)&&t.defaultValues().then(x=>{X(x,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:I,_disableForm:He,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(x){o=x},get _defaultValues(){return a},get _names(){return l},set _names(x){l=x},get _formState(){return n},get _options(){return t},set _options(x){t={...t,...x}}},subscribe:Ne,trigger:se,register:Ee,handleSubmit:Me,watch:ie,setValue:H,getValues:Y,reset:X,resetField:_e,clearErrors:G,unregister:ve,setError:Z,setFocus:me,getFieldState:B};return{...Xe,formControl:Xe}}function Oo(e={}){const t=p.useRef(void 0),n=p.useRef(void 0),[r,a]=p.useState({isDirty:!1,isValidating:!1,isLoading:be(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:be(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!be(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=Lo(e);t.current={...l,formState:r}}const i=t.current.control;return i._options=e,Sn(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),p.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),p.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),p.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),p.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),p.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),p.useEffect(()=>{var o;e.values&&!Se(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=e.values,a(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),p.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=p.useMemo(()=>Sr(r,i),[i,r]),t.current}function Po(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function _o(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function zo(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Ro(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}function Bo(e,t,n=.001){const r=e-t,a=Math.abs(r)<=n;return{difference:r,isBalanced:a,isUnderAllocated:!a&&r>0,isOverAllocated:!a&&r<0}}function Dn(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Dn();const Vo={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Ut=()=>({id:Dn(),amount:0,glAccount:null,isTaxDeductible:!1}),Fr=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:a,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:h=!0,isDisabled:y=!1,labels:m,classNames:j={},"data-testid":k,control:g,name:w,rules:N})=>{const S={...Vo,...m},b=g!==void 0&&w!==void 0,v=Oo({defaultValues:{_internal:t||Ut()}}),$=yo({control:b?g:v.control,name:b?w:"_internal",rules:b?N:void 0}),[M,O]=p.useState(t||Ut()),A=b?$.field.value??Ut():e??M,_=b&&!!$.fieldState?.error,I=b&&($.fieldState?.isTouched??!1),D=_||I,F=D&&(!A.amount||A.amount<=0),L=D&&!A.glAccount,[Q,U]=p.useState(A.glAccount?.name||""),H=p.useCallback(Z=>{const ie={...A,...Z};b&&$.field.onChange(ie),!b&&e===void 0&&O(ie),i?.(ie)},[A,e,i,b,$]),J=p.useCallback(Z=>{const ie=Z||0;H({amount:ie}),o?.(ie)},[H,o]),ee=p.useCallback(Z=>{U(Z),a?.(Z)},[a]),se=p.useCallback(Z=>{if(Z===null){H({glAccount:null}),l?.(null);return}const re=n.find(Ne=>String(Ne.id)===String(Z))||null;H({glAccount:re}),l?.(re)},[n,H,l]),Y=p.useCallback(()=>{U(""),H({glAccount:null}),l?.(null)},[H,l]),B=p.useCallback(Z=>{H({isTaxDeductible:Z}),d?.(Z)},[H,d]),G=p.useCallback(()=>{u?.()},[u]);return s.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":k||"revenue-distribution-card",className:c.cn(j.base),children:s.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",j.body),children:[s.jsx("div",{className:c.cn("shrink-0",j.amountContainer),children:s.jsx(c.NumberInput,{"data-testid":`${k||"revenue-distribution-card"}-amount-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[S.amount,s.jsx(c.Tooltip,{content:S.amountTooltip,children:s.jsx(V,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:A.amount||void 0,onValueChange:J,labelPlacement:"outside",placeholder:S.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:y,isInvalid:F,errorMessage:F?"Amount is required":void 0,minValue:0,step:.01,className:j.amountInput,startContent:s.jsx("div",{className:"pointer-events-none flex items-center",children:s.jsx("span",{className:"text-default-400 text-small",children:S.currencySymbol})})})}),s.jsx("div",{className:c.cn("grow",j.glAccountContainer),children:s.jsx(c.Autocomplete,{"data-testid":`${k||"revenue-distribution-card"}-gl-account-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[S.glAccount,s.jsx(c.Tooltip,{content:S.glAccountTooltip,children:s.jsx(V,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:A.glAccount?.name??Q,selectedKey:A.glAccount?.id??null,isDisabled:y,isInvalid:L,errorMessage:L?"GL Account is required":void 0,listboxProps:{emptyContent:r?S.searching:S.noGlAccountsFound},placeholder:S.glAccountPlaceholder,onInputChange:ee,onSelectionChange:se,onClear:Y,className:j.glAccountInput,children:Z=>s.jsx(c.AutocompleteItem,{textValue:Z.name,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:Z.name}),Z.code&&s.jsx("span",{className:"text-xs text-default-400",children:Z.code})]})},Z.id)})}),s.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",j.taxDeductibleContainer),children:s.jsx(c.Checkbox,{radius:"full","data-testid":`${k||"revenue-distribution-card"}-tax-deductible`,isSelected:A.isTaxDeductible,onValueChange:B,isDisabled:y||!h,className:j.taxDeductibleCheckbox,children:S.taxDeductible})}),s.jsx("div",{className:c.cn("shrink-0 pt-6",j.deleteContainer),children:s.jsx(W,{"data-testid":`${k||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:y||!f,onPress:G,startContent:s.jsx(V,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",j.deleteButton),children:S.deleteButton})})]})})};Fr.displayName="RevenueDistributionCard";const Tr=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i)return s.jsx(s.Fragment,{children:i()});const o=s.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",a.content),children:[s.jsx(V,{icon:t,width:n,className:c.cn("text-default-300 mb-4",a.icon)}),s.jsx("p",{className:c.cn("text-default-500 text-sm text-center",a.message),children:e})]});return r?s.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{children:o})}):s.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",a.base),children:o})};Tr.displayName="RevenueDistributionEmpty";const Uo={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Lr=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...Uo,...t},o=s.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{children:o})}):s.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",a.base),children:o})};Lr.displayName="RevenueDistributionError";const Or=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,o)=>o),a=i=>s.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[s.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),s.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),s.jsxs("div",{className:"grow flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),s.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),s.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[s.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),s.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),s.jsx("div",{className:"shrink-0 pb-2",children:s.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?s.jsx("div",{className:c.cn("flex flex-col gap-3",n.base),children:r.map(i=>s.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:s.jsx(c.CardBody,{children:a(i)})},i))}):s.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",n.base),children:r.map(i=>a(i))})};Or.displayName="RevenueDistributionSkeleton";function $t({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:a="danger",iconTone:i="danger",portalContainer:o,shouldBlockScroll:l,classNames:d,onClose:u,onConfirm:f}){return s.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:o,shouldBlockScroll:l,classNames:{...d,base:c.cn("max-w-[440px] rounded-3xl",d?.base),closeButton:c.cn("right-5 top-5 text-zinc-500",d?.closeButton)},onOpenChange:h=>!h&&u(),children:s.jsxs(c.ModalContent,{children:[s.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&s.jsx("span",{className:c.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),s.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),s.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:s.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),s.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[s.jsx(W,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:u,children:t.cancel}),s.jsx(W,{type:"button",size:"md",color:a,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",a==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:f,children:t.confirm})]})]})})}const Ho=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function cn(e){return!e.fund&&Number(e.percentage||0)<=0}function qo({mode:e,assignments:t}){const n=t.filter(o=>!cn(o)),r=n.filter(o=>o.fund),a=r.reduce((o,l)=>o+Number(l.percentage||0),0),i=n.some(o=>!o.fund||Number(o.percentage||0)<=0);return r.length>=1&&!i&&Math.round(a*100)/100===100}const Wo={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select a fund and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Select a fund for each row and enter percentages that total 100%.",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},Pr={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},rt={...Pr,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},Yo={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Go={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function Ko(){return s.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[s.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const Qo=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,Zo=e=>e.fund!==null;function Jo({assignments:e,funds:t,labels:n,classNames:r,isSaving:a=!1,hasSavedAssignments:i=!1,isFundPickerOpen:o=!1,activeAssignmentId:l=null,footer:d,onAssignmentsChange:u,onOpenFundPicker:f,onCloseFundPicker:h,onCollapseChange:y,onSave:m}){const[j,k]=p.useState(null),g={...Wo,...n},w=e.filter(B=>!cn(B)),S=w.filter(Zo).length>0,b=p.useMemo(()=>e.filter(B=>!cn(B)).reduce((B,G)=>B+Number(G.percentage||0),0),[e]),v=Math.round(b*100)/100,$=w.some(B=>!B.fund||Number(B.percentage||0)<=0),M=S&&(v!==100||$),O=`${g.totalError} (${g.total} ${Number(b.toFixed(2))}%)`,A=qo({mode:"split",assignments:e}),_=S&&v>=100,[I,D]=p.useState(!1),[F,L]=p.useState(!1),Q=s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Ko,{}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:g.title})]}),U=(B,G)=>{u(e.map(Z=>Z.id===B?{...Z,...G}:Z))},H=()=>{_||u([...e,Ho()])},J=B=>{e.length<=1||u(e.filter(G=>G.id!==B))},ee=()=>{if(!a){if(!A){L(!0);return}if(!i){m();return}D(!0)}},se=()=>{D(!1),m()},Y=B=>{const G=l??e.find(Z=>!Z.fund)?.id??e[0]?.id;G&&(u(e.map(Z=>Z.id===G?{...Z,fund:B}:Z)),h())};return s.jsxs("div",{ref:k,className:c.cn("vvt-pa relative font-sans text-zinc-900",o&&"min-h-[560px]",r?.root),children:[s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:c.cn("w-full gap-0 px-0",r?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",r?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:B=>y?.(!(B==="all"||Array.from(B).length>0)),children:s.jsx(c.AccordionItem,{"aria-label":g.title,title:Q,children:s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",r?.content),children:[s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&s.jsx(c.Alert,{icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Pr,color:"default",variant:"flat",title:g.emptySplit}),S&&s.jsx(Xo,{assignments:e,labels:g,total:b,hasTotalError:F&&!A||M,validationMessage:O,onSelectFund:B=>f(B),onRemoveFund:J,onPercentageChange:(B,G)=>U(B,{percentage:Qo(G)})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx(W,{type:"button",size:"lg",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-lg font-normal text-white disabled:opacity-50",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:_,onPress:()=>S?H():f(),children:g.assignSpecificFund}),s.jsx(W,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:a?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:a,onPress:ee,children:g.saveAssignment})]})]}),d]})},"installment-fund-assignment")}),o&&s.jsx(ec,{funds:t,labels:g,selectedFundIds:e.map(B=>B.fund?.id).filter(Boolean),portalContainer:j??void 0,onSelect:Y,onClose:h}),s.jsx($t,{isOpen:I,labels:{title:g.modifyAssignedFundsTitle,description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:g.modifyAssignedFundsDescription}),s.jsx("p",{className:"mt-3",children:g.modifyAssignedFundsWarning})]}),cancel:g.modifyAssignedFundsCancel,confirm:g.modifyAssignedFundsConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:j??void 0,shouldBlockScroll:!1,classNames:Go,onClose:()=>D(!1),onConfirm:se})]})}function Xo({assignments:e,labels:t,total:n,hasTotalError:r,validationMessage:a,onSelectFund:i,onRemoveFund:o,onPercentageChange:l}){return s.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>s.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[s.jsx("div",{className:c.cn("flex min-h-11 min-w-0 flex-1 items-center","gap-4"),children:d.fund?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[d.fund.glCode," - ",d.fund.accountName]}),s.jsx(W,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(d.id),children:"Replace"})]}):s.jsx(W,{type:"button",size:"lg",variant:"light",radius:"full",className:"justify-start px-4 text-lg font-normal text-zinc-900",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:t.assignSpecificFund})}),s.jsx("label",{className:"flex w-48 flex-none items-center",children:s.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>l(d.id,Number(f.target.value)),endContent:s.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:Yo})}),e.length>1&&s.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:c.cn("h-10 w-10 flex-none p-0",u===0?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:u===0,onPress:()=>o(d.id),"aria-label":t.removeFund,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),s.jsx(c.Alert,{icon:s.jsx(V,{icon:r?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:r?"warning":"success",variant:"flat",classNames:{...rt,base:c.cn(rt.base,r?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(rt.iconWrapper,r?"text-warning-700":"text-success-700"),alertIcon:c.cn(rt.alertIcon,r?"text-warning-700":"text-success-700"),title:c.cn(rt.title,r?"text-warning-700":"text-success-700")},title:r?a:`${t.total} ${Number(n.toFixed(2))}%`})]})}function ec({funds:e,labels:t,selectedFundIds:n,portalContainer:r,onSelect:a,onClose:i}){const[o,l]=p.useState(""),d=e.filter(u=>{if(n.includes(u.id))return!1;const f=o.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return s.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:r,classNames:{wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl",base:"max-h-[calc(100%-2rem)] max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:u=>!u&&i(),children:s.jsxs(c.ModalContent,{className:"max-h-full",children:[s.jsx(c.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),s.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[s.jsx(c.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:o,placeholder:t.searchPlaceholder,onChange:u=>l(u.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),s.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[s.jsx("span",{children:t.glCode}),s.jsx("span",{children:t.accountName}),s.jsx("span",{children:t.actions})]}),d.length===0&&s.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),d.map(u=>s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[s.jsx("span",{children:u.glCode}),s.jsx("span",{children:u.accountName}),s.jsx(W,{type:"button",size:"sm",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",onPress:()=>a(u),children:t.select})]},u.id))]})]})]})})}function tc(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),s.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const nc={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function sc({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:a="en-US",labels:i,className:o}){const l={...nc,...i},d=new Intl.NumberFormat(a,{style:"currency",currency:r});return s.jsx("div",{className:c.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",o),children:s.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[s.jsx(Ht,{label:l.totalAmount,value:d.format(e)}),s.jsx(Ht,{label:l.remainingBalance,value:d.format(t)}),s.jsx(Ht,{label:l.amountReceived,value:d.format(n)})]})})}function Ht({label:e,value:t}){return s.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[s.jsx("span",{className:"font-medium text-zinc-700",children:e}),s.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}const rc={monthly:1,quarterly:3,annual:12},_r=e=>{const[t,n,r]=e.split("-").map(Number);return{year:t,month:n,day:r}},ac=(e,t)=>new Date(e,t+1,0).getDate(),ic=e=>{const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},lc=(e,t)=>{const{year:n,month:r,day:a}=_r(e),i=r-1+t,o=n+Math.floor(i/12),l=(i%12+12)%12,d=Math.min(a,ac(o,l));return new Date(o,l,d)},oc=(e,t)=>{const{year:n,month:r,day:a}=_r(e),i=new Date(n,r-1,a);return i.setDate(i.getDate()+t),i};function zr(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.round(e*100),a=Math.floor(r/n),i=r-a*n,o=rc[t.frequency];return Array.from({length:n},(l,d)=>{const u=t.frequency==="weekly"?oc(t.firstInstallmentDate,d*7):lc(t.firstInstallmentDate,d*(o??1));return{id:crypto.randomUUID(),dueDate:ic(u),amount:(a+(d===0?i:0))/100}})}function cc(e){return new Set(e.map((t,n)=>{const r=e[n+1]?.dueDate;return t.dueDate&&r&&t.dueDate>r?t.id:null}).filter(t=>!!t))}const dc={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",dayOfMonth:"Day of month",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",weekly:"Weekly",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total cannot exceed donation amount",totalIncreaseWarning:"Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationTitle:"Update Donation Total",totalIncreaseConfirmationDescription:"The scheduled payments total is greater than the current donation/contribution total. Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationCancel:"Cancel",totalIncreaseConfirmationConfirm:"Save Payments",dateOrderError:"Payment date must be on or before the next payment date.",amountGreaterThanZeroError:"Payment amount must be greater than 0."},uc=["weekly","monthly","quarterly","annual"],fc=Array.from({length:31},(e,t)=>t+1),mc=["numberOfInstallments","frequency","firstInstallmentDate"],hc={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},gs=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Rr=e=>Math.round(e*100)/100,xc=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},Dt=e=>{if(!e)return null;try{return di(e)}catch{return null}},pc=e=>Dt(e)?.day??1,gc=(e,t)=>new Date(e,t,0).getDate(),bc=(e,t)=>{const n=Dt(e);if(!n)return e;const r=Math.min(t,gc(n.year,n.month));return n.set({day:r}).toString()},bs=e=>{const t=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${t}`};function yc({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:a,automaticSettings:i,defaultTab:o="automatic",showTitle:l=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:h=mc,startDate:y,labels:m,classNames:j,isSaving:k=!1,isModeSwitchDisabled:g=!1,onModeChange:w,onAutomaticSettingsChange:N,onInstallmentsChange:S,onSave:b}){const[v,$]=p.useState(null),[M,O]=p.useState(o),A={...dc,...m},_=e??M,I=p.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),D=p.useMemo(()=>({...i,firstInstallmentDate:h.includes("firstInstallmentDate")?i.firstInstallmentDate:h.includes("dayOfMonth")?i.firstInstallmentDate||y||"":y||i.firstInstallmentDate}),[i,h,y]),F=_==="automatic"?zr(t,D):a,L=p.useMemo(()=>Rr(F.reduce((re,Ne)=>re+Number(Ne.amount||0),0)),[F]),Q=_==="manual"&&L-t>.009,[U,H]=p.useState(!1),J=l?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:A.title})]}):void 0,ee=re=>{re!==_&&(e||O(re),w?.(re),re==="manual"&&a.length===0&&S([gs()]))},se=(re,Ne)=>{a.find(xe=>xe.id===re)?.status!=="fulfilled"&&S(a.map(xe=>xe.id===re?{...xe,...Ne}:xe))},Y=()=>{S([...a,gs()])},B=re=>{a.find(ve=>ve.id===re)?.status!=="fulfilled"&&S(a.filter(ve=>ve.id!==re))},G=()=>{if(!k){if(Q){H(!0);return}b?.()}},Z=()=>{H(!1),b?.()},ie=s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.content),children:[f||u?s.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?s.jsx(vc,{mode:_,labels:A,onModeChange:ee,isDisabled:g,className:j?.tabs}):null,u?s.jsx(W,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto min-w-36",startContent:k?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:k,onPress:G,children:A.saveInstallments}):null]}):null,s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.preview),children:[_==="automatic"&&s.jsx(jc,{settings:D,inputs:h,labels:A,className:j?.controls,onSettingsChange:N}),F.length===0&&s.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:_==="automatic"?A.emptyAutomatic:A.emptyManual}),F.length>0&&s.jsx(wc,{mode:_,installments:F,labels:A,formatter:I,locale:r,onUpdateInstallment:se,onRemoveInstallment:B}),_==="manual"&&s.jsx("div",{className:"flex flex-wrap gap-3",children:s.jsx(W,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:Y,children:A.addInstallment})}),s.jsx(Cc,{total:L,donationAmount:t,hasTotalIncreaseWarning:Q,mode:_,installments:F,formatter:I,labels:A,className:j?.summary})]})]});return s.jsxs("div",{ref:$,className:c.cn("vvt-ps relative font-sans text-zinc-900",j?.root),children:[d?s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",j?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",j?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:s.jsx(c.AccordionItem,{"aria-label":A.title,title:J,children:ie},"installment-schedule")}):ie,s.jsx($t,{isOpen:U,labels:{title:A.totalIncreaseConfirmationTitle,description:A.totalIncreaseConfirmationDescription,cancel:A.totalIncreaseConfirmationCancel,confirm:A.totalIncreaseConfirmationConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",isConfirming:k,portalContainer:v??void 0,shouldBlockScroll:!1,classNames:hc,onClose:()=>H(!1),onConfirm:Z})]})}function vc({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:a}){return s.jsxs(c.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",n),onSelectionChange:i=>a(i),children:[s.jsx(c.Tab,{title:t.automaticMode},"automatic"),s.jsx(c.Tab,{title:t.manualMode},"manual")]})}function jc({settings:e,inputs:t,labels:n,className:r,onSettingsChange:a}){const i=o=>{if(o==="numberOfInstallments")return s.jsx("div",{className:"min-w-0",children:s.jsx(c.Input,{variant:"bordered",label:n.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:l=>l.currentTarget.blur(),onChange:l=>{const d=l.target.value;a({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},o);if(o==="frequency")return s.jsx("div",{className:"min-w-0",children:s.jsx(Oe,{variant:"bordered",label:n.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:l=>{const d=Array.from(l)[0];typeof d=="string"&&a({...e,frequency:d})},children:uc.map(l=>s.jsx(c.SelectItem,{textValue:n[l],children:n[l]},l))})},o);if(o==="dayOfMonth"){const l=String(pc(e.firstInstallmentDate));return s.jsx("div",{className:"min-w-0",children:s.jsx(Oe,{variant:"bordered",label:n.dayOfMonth,labelPlacement:"outside",selectedKeys:[l],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&a({...e,firstInstallmentDate:bc(e.firstInstallmentDate,u)})},children:fc.map(d=>s.jsx(c.SelectItem,{textValue:bs(d),children:bs(d)},String(d)))})},o)}return s.jsx("div",{className:"min-w-0",children:s.jsx(xn,{variant:"bordered",label:n.firstInstallmentDate,labelPlacement:"outside",value:Dt(e.firstInstallmentDate),onChange:l=>a({...e,firstInstallmentDate:l?l.toString():""}),startContent:s.jsx(V,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},o)};return t.length===0?null:s.jsx("div",{className:c.cn("grid gap-4",r),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:t.map(i)})}function wc({mode:e,installments:t,labels:n,formatter:r,locale:a,onUpdateInstallment:i,onRemoveInstallment:o}){const l=cc(t),d=new Set(t.map(u=>Number(u.amount||0)<=0?u.id:null).filter(u=>!!u));return e==="automatic"?s.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:s.jsx("div",{className:c.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((u,f)=>s.jsxs("div",{className:c.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",f===0&&"border border-primary/25 bg-primary/5 text-primary"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{children:["#",f+1]}),s.jsx("span",{children:"▪"}),s.jsx("span",{children:xc(u.dueDate,a)}),f===0&&t.length>1&&s.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),s.jsx("span",{className:"text-zinc-950",children:r.format(u.amount)})]},u.id))})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.map((u,f)=>{const h=l.has(u.id),y=d.has(u.id);return s.jsx("div",{className:"flex w-full flex-col gap-1",children:s.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[s.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:f+1}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(xn,{variant:"bordered","aria-label":`${n.dueDate} ${f+1}`,isDisabled:u.status==="fulfilled",isInvalid:h,errorMessage:h?n.dateOrderError:void 0,value:Dt(u.dueDate),onChange:m=>i(u.id,{dueDate:m?m.toString():""})})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(c.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:u.status==="fulfilled",isInvalid:y,errorMessage:y?n.amountGreaterThanZeroError:void 0,value:String(u.amount||""),onChange:m=>i(u.id,{amount:Rr(Number(m.target.value||0))}),startContent:s.jsx("span",{className:"text-zinc-900",children:"$"})})}),s.jsx(Nc,{isDisabled:t.length<=1,isFulfilled:u.status==="fulfilled",label:n.deleteInstallment,onRemove:()=>o(u.id)})]})},u.id)})})}function Nc({isDisabled:e,isFulfilled:t,label:n,onRemove:r}){const a=s.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?s.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been fulfilled.",placement:"top",children:s.jsx("span",{className:"inline-flex",children:a})}):a}function Cc({total:e,donationAmount:t,hasTotalIncreaseWarning:n,mode:r,installments:a,formatter:i,labels:o,className:l}){const d=a.length,u=a[0]?.amount??0,f=a[1]?.amount??u,h=d>1&&Math.round(u*100)!==Math.round(f*100),y=Math.max(t-e,0),m=n?s.jsx("span",{children:o.totalIncreaseWarning}):r==="automatic"?h?s.jsxs("span",{children:["Saving will create ",s.jsx("strong",{children:d})," scheduled payment records:"," ",s.jsx("strong",{children:i.format(u)})," first charge and"," ",s.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):s.jsxs("span",{children:["Saving will create ",s.jsx("strong",{children:d})," scheduled payment records of"," ",s.jsx("strong",{children:i.format(u)})," each."]}):s.jsxs("span",{children:["Total scheduled: ",s.jsx("strong",{children:i.format(e)})," /"," ",s.jsx("strong",{children:i.format(t)}),"."]}),j=r==="automatic"?`Total: ${i.format(e)}`:n?`New total: ${i.format(e)}`:`${o.remaining}: ${i.format(y)}`;return s.jsx(c.Alert,{isClosable:!1,color:n?"warning":"default",variant:"flat",radius:"full",className:l,endContent:s.jsx("span",{className:"whitespace-nowrap",children:j}),title:m})}function kc(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[s.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),s.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),s.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),s.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const ys={fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",canceled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},Br={fulfilled:"Fulfilled",scheduled:"Scheduled",failed:"Failed",canceled:"Canceled",refunded:"Refunded"},Sc={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:s.jsxs(s.Fragment,{children:["Are you sure you want to delete this payment? ",s.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Ac={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function $c({installments:e,currency:t,locale:n="en-US",showTitle:r=!0,showCard:a=!0,showEditPayment:i=!0,labels:o,isSaving:l=!1,onEditInstallments:d,onPayInstallment:u,onDeleteInstallment:f}){const[h,y]=p.useState(null),m={...Sc,...o},[j,k]=p.useState(""),g=new Intl.NumberFormat(n,{style:"currency",currency:t}),w=r?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:m.title})]}):void 0,N=p.useMemo(()=>{const b=j.trim().toLowerCase();return b?e.filter(v=>{const $=v.status??"scheduled";return[v.id,v.amount,v.dueDate,qt(v.dueDate,n),$,Br[$]??$].join(" ").toLowerCase().includes(b)}):e},[n,e,j]),S=s.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[s.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[s.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:m.searchLabel}),s.jsx(c.Input,{variant:"bordered",size:"md",value:j,placeholder:m.searchPlaceholder,onChange:b=>k(b.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?s.jsx(W,{type:"button",variant:"bordered",radius:"full",size:"md",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(V,{icon:"solar:pen-outline",className:"size-4"}),isLoading:l,onPress:d,children:m.editInstallments}):null]}),s.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",N.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:s.jsxs("div",{className:"flex flex-col gap-2",children:[N.map((b,v)=>{const $=b.status??"scheduled";return s.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:s.jsxs(c.CardBody,{className:"gap-3 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-xs text-default-500",children:["#",v+1]}),s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:b.id||`PMT-${v+1}`})]}),s.jsx(vs,{status:$})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-default-500",children:m.amount}),s.jsx("p",{className:"font-medium text-foreground",children:g.format(b.amount)})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-xs text-default-500",children:m.scheduledDate}),s.jsx("p",{className:"font-medium text-foreground",children:qt(b.dueDate,n)})]})]}),s.jsx(js,{status:$,installment:b,labels:m,portalContainer:h??void 0,onPayInstallment:u,onDeleteInstallment:f})]})},b.id)}),N.length===0&&s.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:m.noInstallmentsFound})]})}),s.jsx("div",{className:c.cn("w-full overflow-x-hidden [@container(max-width:767px)]:hidden",N.length>5&&"max-h-[344px] overflow-y-auto pr-1"),children:s.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-12"}),s.jsx("col",{}),s.jsx("col",{className:"w-24"}),s.jsx("col",{className:"w-36"}),s.jsx("col",{className:"w-36"}),s.jsx("col",{className:"w-44"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[s.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.installmentId}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.amount}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.scheduledDate}),s.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:m.status}),s.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:m.actions})]})}),s.jsxs("tbody",{children:[N.map((b,v)=>{const $=b.status??"scheduled";return s.jsxs("tr",{className:"text-zinc-500",children:[s.jsx("td",{className:"px-2 py-3",children:v+1}),s.jsx("td",{className:"overflow-hidden px-2 py-3",children:s.jsx("span",{className:"block w-full truncate",children:b.id||`PMT-${v+1}`})}),s.jsx("td",{className:"px-2 py-3",children:g.format(b.amount)}),s.jsx("td",{className:"px-2 py-3",children:qt(b.dueDate,n)}),s.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:s.jsx(vs,{status:$})}),s.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:s.jsx(js,{status:$,installment:b,labels:m,portalContainer:h??void 0,onPayInstallment:u,onDeleteInstallment:f})})]},b.id)}),N.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:m.noInstallmentsFound})})]})]})})]});return s.jsx("div",{ref:y,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:a?s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"min-w-0 w-full gap-0 px-0",itemClasses:{base:"min-w-0 w-full overflow-x-hidden rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"w-full",content:"min-w-0 w-full overflow-x-hidden px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:s.jsx(c.AccordionItem,{"aria-label":m.title,title:w,children:S},"installment-table")}):S})}function vs({status:e}){return s.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",ys[e]??ys.scheduled),startContent:s.jsx(Ec,{status:e}),children:Br[e]??e})}function js({status:e,installment:t,labels:n,portalContainer:r,onPayInstallment:a,onDeleteInstallment:i}){return s.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[s.jsx(W,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:e==="fulfilled",startContent:s.jsx(V,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(t),children:n.payNow}),s.jsx(Dc,{isFulfilled:e==="fulfilled",labels:n,portalContainer:r,onDelete:()=>i(t.id)})]})}function Dc({isFulfilled:e,labels:t,portalContainer:n,onDelete:r}){const[a,i]=p.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[s.jsx(c.DropdownTrigger,{children:s.jsx(W,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:s.jsx(V,{icon:"solar:menu-dots-bold",className:"size-4"})})}),s.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&!e&&i(!0)},children:[s.jsx(c.DropdownSection,{title:"Actions",showDivider:!0,children:s.jsx(c.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:s.jsx(V,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),s.jsx(c.DropdownSection,{title:t.dangerZone,children:s.jsx(c.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),s.jsx($t,{isOpen:a,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:s.jsx(V,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:n,shouldBlockScroll:!1,classNames:Ac,onClose:()=>i(!1),onConfirm:()=>{i(!1),r()}})]})}function Ec({status:e}){return e==="fulfilled"?s.jsx(V,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?s.jsx(V,{icon:"solar:close-circle-bold",className:"size-3"}):s.jsx(V,{icon:"solar:calendar-outline",className:"size-3"})}function qt(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const Ic={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Mc=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:a,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:l=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:h=""})=>{const y=Array.isArray(e)?e:[],[m,j]=p.useState(l),[k,g]=p.useState(o),w={...Ic,...a};p.useEffect(()=>{j(l)},[l]);const N=b=>{if(b===m){d&&f?.(b);return}j(b),f?.(b)},S=b=>{g(b),u?.(b)};return s.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",h),"data-testid":"membership-select-cards",children:[s.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),s.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&s.jsx(qr,{title:w.renewalTitle,description:w.renewalDescription,value:k,onValueChange:S}),s.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":c.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:y.map(b=>s.jsx(Vr,{itemKey:b.id,name:b.name,type:b.type,price:b.price,locale:t,currency:n,isSelected:m===b.id,onSelect:N},b.id))})]})},Vr=({itemKey:e,name:t,type:n,price:r,locale:a="en-US",currency:i="USD",showPrice:o=!0,isSelected:l=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:h,statusLabel:y,statusTone:m="default",className:j=""})=>{const k=new Intl.NumberFormat(a,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),g=!!d&&!f,w=h||y,N=()=>{g&&d?.(e)};return s.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:N,className:c.cn("w-full min-h-fit border rounded-3xl",l?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",j),"data-testid":"item-card","data-selected":l,isDisabled:f,children:s.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[s.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[s.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&s.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:s.jsx("p",{className:"text-center",children:n})}),w&&s.jsx(c.Chip,{"data-testid":"item-card-status",color:m,size:"sm",variant:"flat",className:"px-2",children:w})]}),o&&s.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:k})]})})},ws="w-full bg-gray-100",Ns={variant:"light",color:"default"},Ur=({id:e,title:t,media:n,imageUrl:r,imageAlt:a,imageClassName:i="",imageAspect:o="aspect-[4/3]",meta:l=[],price:d,action:u,footer:f,onPress:h,isPressable:y=!1,isDisabled:m=!1,compact:j=!1,className:k="",bodyClassName:g="",footerClassName:w="",dataTestId:N})=>{const S=!!(d&&d.value),b=!!u?.label,v=y&&!!h&&!b,$=!v,M=b?{variant:u?.variant??Ns.variant,color:u?.color??Ns.color,size:u?.size??"sm",isDisabled:m||u?.isDisabled,startContent:u?.icon?s.jsx(V,{icon:u.icon,width:16}):void 0}:null,O=n??(r?s.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",o,ws,i),children:s.jsx(c.Image,{removeWrapper:!0,src:r,alt:a||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):s.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",o,ws,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:s.jsx(V,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return s.jsxs(c.Card,{"data-testid":N||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",k),isPressable:v,onPress:h,isDisabled:m,shadow:"sm",radius:"lg",children:[s.jsx("div",{children:O}),s.jsxs(c.CardBody,{className:c.cn("gap-3",j?"p-3":"p-4",g),children:[s.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",j?"text-sm":""),children:t}),l.length>0?s.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:l.map((A,_)=>s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(V,{icon:A.icon,className:"size-4 text-gray-400",width:16}),s.jsx("span",{children:A.label})]},`${A.label}-${_}`))}):null,(S||b)&&s.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",j?"pt-0.5":"",w),children:[S?s.jsxs("span",{className:c.cn("mr-auto text-gray-500",j?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&s.jsxs("span",{children:[d.label," "]}),s.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):s.jsx("span",{className:"ml-auto","aria-hidden":!0}),b&&$?s.jsx(W,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:M?.variant,color:M?.color,size:M?.size,startContent:M?.startContent,isDisabled:M?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?s.jsx("div",{className:"pt-1",children:f}):null]})]})};Ur.displayName="CatalogItemCard";const Fc={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},Tc={empty:"border-default-200 bg-white",error:"border-danger-200 bg-white",success:"border-success-100 bg-success-50/40",loading:"border-default-200 bg-white"},Lc={empty:"bg-default-100 text-default-400",error:"bg-danger-50 text-danger-600",success:"bg-success-100 text-success-700",loading:"bg-primary-50 text-primary"},Oc={empty:"status",error:"alert",success:"status",loading:"status"},Pc={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function _c(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return s.jsx(c.Spinner,{size:"lg",color:"primary",className:r.spinner});if(p.isValidElement(t))return s.jsx(s.Fragment,{children:t});const a=typeof t=="string"?t:Fc[e];return a?s.jsx(V,{icon:a,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function Je({variant:e="empty",title:t,titleAs:n="p",description:r,icon:a,actions:i,role:o=Oc[e],ariaLive:l=Pc[e],iconSize:d=24,className:u,classNames:f={},"data-testid":h="feedback-state"}){const y=_c(e,a,d,f);return s.jsxs("div",{role:o,"aria-live":l,"data-variant":e,"data-testid":h,className:c.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",Tc[e],u,f.base),children:[y?s.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:c.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",Lc[e],f.iconWrapper),children:y}):null,s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsx(n,{"data-testid":`${h}-title`,className:c.cn("text-base font-medium text-default-900",f.title),children:t}),r?s.jsx("p",{"data-testid":`${h}-description`,className:c.cn("max-w-sm text-sm text-default-600",f.description),children:r}):null]}),i?s.jsx("div",{"data-testid":`${h}-actions`,className:c.cn("mt-1 flex flex-wrap items-center justify-center gap-2",f.actions),children:i}):null]})}function En(e){return s.jsx(Je,{...e,variant:"empty"})}function In(e){return s.jsx(Je,{...e,variant:"error"})}function Mn(e){return s.jsx(Je,{...e,variant:"loading"})}function Hr(e){return s.jsx(Je,{...e,variant:"success"})}Je.displayName="FeedbackState";En.displayName="EmptyState";In.displayName="ErrorState";Mn.displayName="LoadingState";Hr.displayName="SuccessState";const qr=({title:e,value:t,description:n,onValueChange:r,className:a=""})=>{const i=p.useId();return s.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",a),"data-testid":"toggle",children:[s.jsxs("div",{className:"flex flex-col items-start",children:[e&&s.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&s.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),s.jsx(c.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},zc={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},Rc=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Wr=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,a)=>r+Object.values(a).reduce((i,o)=>i+o.selectedQuantity,0),0),0),Bc=e=>e.reduce((t,n)=>t+n.dates.reduce((r,a)=>r+a.tickets.reduce((i,o)=>i+o.max,0),0),0),Fn=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),Cs=(e,t,n)=>{const r={};let a=n?t??Bc(e):0;for(const{exhibition:i,dateGroup:o,ticket:l}of Fn(e)){r[i.id]??={},r[i.id][o.id]??={};const d=n?Math.min(l.max,a):0;r[i.id][o.id][l.id]={id:l.id,selectedQuantity:d,originalPrice:l.originalPrice,discountedPrice:l.price},a-=d}return r},ks=(e,t,n)=>`${e}::${t}::${n}`,Vc=(e,t,n)=>{const r=Wr(t);for(const{exhibition:a,dateGroup:i,ticket:o}of Fn(e)){const l=t[a.id]?.[i.id]?.[o.id]?.selectedQuantity??0,d=n===void 0?o.max:Math.min(o.max,n-(r-l));if(d>0&&l<d)return!1}return!0},Uc=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:a=!1})=>{const i=Math.max(t,Math.min(n,e)),[o,l]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?o:String(i),h=()=>{a||i>=n||r?.(i+1)},y=()=>{a||i<=t||r?.(i-1)},m=b=>{if(a)return;l(b.target.value);const v=parseInt(b.target.value,10);isNaN(v)||r?.(Math.max(t,Math.min(n,v)))},j=b=>{const v=parseInt(b.target.value,10);if(u(!1),isNaN(v)){r?.(t);return}const $=Math.max(t,Math.min(n,v));$!==v?r?.($):l(String($))},k=i<=t,g=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",S="bg-primary/40 cursor-not-allowed";return s.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[s.jsx("button",{type:"button",onClick:y,disabled:a||k,className:c.cn(w,a||k?S:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),s.jsx("input",{type:"number",value:f,onChange:m,onFocus:()=>u(!0),onBlur:j,disabled:a,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),s.jsx("button",{type:"button",onClick:h,disabled:a||g,className:c.cn(w,a||g?S:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Hc=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const a=()=>{r||n?.(!t)};return s.jsxs("button",{type:"button",onClick:a,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:c.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[s.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),s.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&s.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),s.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},qc=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:a,settings:i,labels:o})=>{const l=()=>{if(!r||a===void 0)return e.max;const h=r();return Math.min(e.max,a-(h-t))},d=i?.locale??"en-US",u=i?.currency??"USD",f=Rc(d,u);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?s.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:f.format(e.originalPrice)}),s.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?s.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:e.membershipName,children:s.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,s.jsx("div",{className:"text-sm text-zinc-500",children:s.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[o.ticketsAllowedToRedeem," ",e.max]})})]}),s.jsx(Uc,{initialQuantity:t,minQuantity:0,maxQuantity:l(),onChange:n})]}),e.membershipAlert?s.jsx(c.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:s.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},Wc=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:a,getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:d})=>s.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[s.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((u,f)=>s.jsxs("div",{children:[s.jsx(qc,{item:u,quantity:a(e,t.id,u.id),onChange:h=>r(e,t.id,u.id,h),getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:d}),f<t.tickets.length-1?s.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),Yc=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:o,labels:l,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),h=t.dates.reduce((m,j)=>m+j.tickets.reduce((k,g)=>k+r(t.id,j.id,g.id),0),0),y=t.dates.some(m=>m.tickets.length>0);return s.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[s.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>f(!u),"aria-expanded":u,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:s.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[s.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[h," ",l.ticketsSelectedToRedeem]}),s.jsx("span",{className:c.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:s.jsx(V,{icon:"mdi:chevron-down"})})]})]})}),s.jsx("div",{id:`upgrade-items-${t.id}`,className:c.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&s.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:y?t.dates.map((m,j)=>s.jsx(Wc,{exhibitionId:t.id,dateGroup:m,isLast:j===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:o,labels:l},m.id)):s.jsx("div",{className:"px-5 py-10 text-center",children:s.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},Gc=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:a,className:i="",onSelectionChange:o})=>{const l=p.useMemo(()=>a??[],[a]),d={...zc,...n},[u,f]=p.useState(()=>Cs(l,t,!0)),h=p.useRef(!1),y=p.useMemo(()=>{const N=Fn(l).map(({exhibition:S,dateGroup:b,ticket:v})=>[ks(S.id,b.id,v.id),v]);return new Map(N)},[l]),m=Vc(l,u,t),j=(N,S,b)=>u[N]?.[S]?.[b]?.selectedQuantity??0,k=()=>Wr(u),g=(N,S,b,v)=>{const $=j(N,S,b),M=k()-$;if(t!==void 0&&M+v>t)return;const O=y.get(ks(N,S,b));if(!O)return;const A={...u,[N]:{...u[N],[S]:{...u[N]?.[S],[b]:{id:b,selectedQuantity:v,originalPrice:O.originalPrice,discountedPrice:O.price}}}};f(A),o?.(A)},w=N=>{const S=Cs(l,t,N);f(S),o?.(S)};return p.useEffect(()=>{!h.current&&m&&(o?.(u),h.current=!0)},[m,u,o]),s.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[s.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[s.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),s.jsx(Hc,{label:d.selectAllButtonLabel,checked:m,onChange:w})]}),l.map(N=>s.jsx(Yc,{title:N.exhibitionName,exhibition:N,onQuantityChange:g,getTicketQuantity:j,getTotalSelectedTickets:k,userMaxLimit:t,settings:r,labels:d,initialExpanded:e},N.id))]})},Wt={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Yt=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},Kc=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const a=e[r.id]??[];n[r.id]=a.length>0?a[0]:null}return n},Qc=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,Yr=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:a="default",triggerSize:i="sm",triggerClassName:o,popoverClassName:l,className:d,sections:u,onConfirm:f,onClear:h,appliedCount:y,countAriaLabel:m,countDisplay:j="badge",confirmLabel:k=Wt.confirm,clearLabel:g=Wt.clear,isOpen:w,defaultOpen:N=!1,onOpenChange:S,isDisabled:b=!1,closeOnConfirm:v=!0,keepOpenAfterClear:$=!1})=>{const[M,O]=p.useState(N),[A,_]=p.useState(()=>Yt(u)),I=w??M,D=y??u.filter(Y=>Qc(Y)).length,F=Y=>{Y&&_(Yt(u)),w||O(Y),S?.(Y)},L=(Y,B)=>{_(G=>({...G,[Y.id]:B}))},Q=(Y,B)=>{_(G=>({...G,[Y.id]:B?[B]:[]}))},U=async()=>{_(Yt(u.map(Y=>Y.type==="checkbox"?{...Y,selectedValues:[]}:{...Y,selectedValue:null}))),await h(),$||F(!1)},H=async()=>{const Y=Kc(A,u);await f(Y),v&&F(!1)},J=Y=>{if(Y.type==="checkbox")return s.jsx(c.CheckboxGroup,{label:Y.label,value:A[Y.id]??[],onValueChange:G=>L(Y,G),children:Y.options.map(G=>s.jsx(c.Checkbox,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},Y.id);const B=A[Y.id]?.[0]??"";return s.jsx(c.RadioGroup,{label:Y.label,value:B,onValueChange:G=>Q(Y,G||null),children:Y.options.map(G=>s.jsx(c.Radio,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},Y.id)},ee=p.useMemo(()=>D>0?m?.(D)||`${D} filters applied`:void 0,[m,D]),se=p.useMemo(()=>D===0?e||Wt.noLabel:m?m(D):`${e} (${D})`,[D,e,m]);return s.jsx("div",{className:d,children:s.jsxs(c.Popover,{isOpen:I,onOpenChange:F,placement:"bottom-end",children:[s.jsx(c.PopoverTrigger,{children:s.jsxs(W,{isDisabled:b,variant:r,color:a,size:i,className:o,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":I,children:[s.jsx(V,{icon:n,width:16}),s.jsx("span",{children:e}),j==="badge"&&D>0?s.jsx("span",{className:"ml-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-xs font-medium text-white","aria-label":ee,children:D}):j==="summary"&&se!==e?s.jsx("span",{className:"text-xs",children:se}):null]})}),s.jsx(c.PopoverContent,{className:l,children:s.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(Y=>J(Y)),s.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[s.jsx(W,{variant:"light",color:"default",size:"sm",onPress:U,children:g}),s.jsx(W,{color:"primary",size:"sm",onPress:H,children:k})]})]})})]})})};Yr.displayName="FilterPopover";const Zc="No sessions available for this date",Jc=e=>e==="sold-out"||e==="closed"?"danger":"success",Xc=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},Ss=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",ed=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,Gr=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:a,quickDates:i,selectedSessionId:o=null,onSessionSelect:l,emptyStateMessage:d=Zc,statusLabel:u,statusTone:f,sessionAriaLabel:h,dayButtonClassName:y,calendarSlot:m,dayGroupAriaLabel:j,sessionGridAriaLabel:k,className:g,headingClassName:w,subheadingClassName:N})=>{const S=ed(n,r),b=n.find(A=>A.date===S),v=i??n.map(A=>({date:A.date,label:A.label})),$=b?.sessions??[],M=A=>A===S?"solid":"bordered",O=A=>{if(!Ss(A)){if(A.id===o){l(null);return}l(A.id)}};return s.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",g),"data-testid":"session-timeline-root",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),t?s.jsx("p",{className:c.cn("text-sm text-gray-700",N),children:t}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":j||"Session days",children:[v.map(A=>s.jsx(W,{size:"sm",variant:M(A.date),color:"default",className:c.cn("rounded-full",y),isDisabled:A.isDisabled,onPress:()=>{a(A.date)},children:s.jsx("span",{children:A.label})},A.date)),m?s.jsx("div",{children:m}):null]}),s.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":k||"Sessions",children:[$.length===0?s.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:d}):null,$.map(A=>{const _=Ss(A),I=A.id===o;return s.jsx("li",{className:"rounded-xl",children:s.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!_,onPress:()=>{O(A)},"aria-disabled":_,"aria-pressed":_?void 0:I,className:c.cn("w-full",_?"bg-gray-100 opacity-70":"",I?"w-full ring-2 ring-gray-900":""),"aria-label":h?h(A,{isSelected:I,isUnavailable:_}):_?`${A.startTime} ${A.endTime} sold out`:`${A.startTime} ${A.endTime} available`,children:s.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[s.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[A.startTime," – ",A.endTime]}),s.jsx(c.Chip,{size:"sm",color:f?f(A):Jc(A.status),variant:"flat",children:u?u(A):Xc(A)})]})})},A.id)})]})]})};Gr.displayName="SessionTimeline";const td=(e,t)=>typeof e=="string"?s.jsx(V,{icon:e,className:"size-5","aria-hidden":"true"}):e||t||null,Kr=({title:e,subtitle:t,eyebrow:n,icon:r,initials:a,actions:i,titleAs:o="h1",className:l,classNames:d={},"data-testid":u="page-header"})=>{const f=td(r,a);return s.jsxs("header",{"data-testid":u,className:c.cn("flex flex-wrap items-start justify-between gap-4",l,d.base),children:[s.jsxs("div",{className:"flex items-center gap-4",children:[f?s.jsx("div",{"aria-hidden":"true","data-testid":`${u}-icon`,className:c.cn("flex size-12 shrink-0 items-center justify-center rounded-xl bg-gray-900 text-sm font-semibold text-white",d.iconWrapper),children:f}):null,s.jsxs("div",{children:[n?s.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:n}):null,s.jsx(o,{"data-testid":`${u}-title`,className:c.cn("text-3xl font-semibold text-gray-950",d.title),children:e}),t?s.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn("mt-1 text-sm text-gray-600",d.subtitle),children:t}):null]})]}),i?s.jsx("div",{"data-testid":`${u}-actions`,className:c.cn("flex flex-wrap items-center gap-2",d.actions),children:i}):null]})};Kr.displayName="PageHeader";const nd={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default"},Qr=({status:e,label:t,variant:n="flat",size:r="sm",color:a,startContent:i,className:o,"data-testid":l="status-chip"})=>s.jsx(c.Chip,{color:a??nd[e],variant:n,size:r,startContent:i,"data-testid":l,"data-status":e,className:c.cn("font-medium",o),children:t});Qr.displayName="StatusChip";const Zr={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Jr={1:"grid-cols-1",2:"grid-cols-2"},sd=e=>typeof e=="string"?s.jsx(V,{icon:e,width:16,height:16,"aria-hidden":"true",className:"text-gray-400"}):e,Xr=({options:e,selectedKeys:t,onChange:n,heading:r,ariaLabel:a="Select options",columnsDesktop:i=2,columnsMobile:o=1,minSelected:l,hint:d,isInvalid:u,isDisabled:f=!1,className:h,classNames:y={},"data-testid":m="checkbox-card-group"})=>{const j=new Set(t),k=new Set(e.map(v=>v.key)),g=l!==void 0&&j.size<l,w=u??g,N=d??(l!==void 0?`Select at least ${l}.`:void 0),S=v=>{const $=new Set(j);$.has(v)?$.delete(v):$.add(v);const M=e.map(A=>A.key).filter(A=>$.has(A)),O=t.filter(A=>$.has(A)&&!k.has(A));n([...new Set([...M,...O])])},b=N?`${m}-hint`:void 0;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",h,y.base),"data-testid":m,children:[r&&s.jsx("h3",{className:"text-sm font-medium text-gray-700",id:`${m}-heading`,children:r}),s.jsx("div",{role:"group","aria-labelledby":r?`${m}-heading`:void 0,"aria-label":r?void 0:a,"aria-invalid":w||void 0,"aria-describedby":b,className:c.cn("grid gap-2",Jr[o],Zr[i],y.grid),children:e.map(v=>{const $=j.has(v.key),M=v.description?`${m}-${v.key}-description`:void 0;return s.jsxs(W,{variant:"bordered",radius:"lg",role:"checkbox","aria-checked":$,"aria-label":v.label,"aria-describedby":M,isDisabled:f||v.isDisabled,onPress:()=>S(v.key),"data-testid":v["data-testid"]??`${m}-${v.key}`,className:c.cn("h-auto min-h-[52px] items-start justify-start gap-2 px-3 py-2","border bg-transparent text-left transition-colors",$?"border-primary bg-primary-50":"border-gray-200 hover:bg-gray-50",w&&!$&&"border-danger-300",y.card),children:[s.jsx("span",{"aria-hidden":"true",className:c.cn("mt-0.5 flex size-[18px] shrink-0 items-center justify-center rounded-[6px] border transition-colors",$?"border-primary bg-primary text-white":"border-gray-300 bg-white text-transparent"),children:s.jsx(V,{icon:"solar:check-read-linear",className:"size-3"})}),s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[v.icon?sd(v.icon):null,s.jsx("span",{className:"text-sm font-medium text-gray-900",children:v.label})]}),v.description?s.jsx("span",{id:M,className:"text-xs leading-snug text-gray-500",children:v.description}):null]})]},v.key)})}),N?s.jsx("p",{id:b,"data-testid":`${m}-hint`,className:c.cn("text-xs",w?"text-danger":"text-gray-500",y.hint),children:N}):null]})};Xr.displayName="CheckboxCardGroup";const ea=({isLoading:e=!1,isError:t=!1,isEmpty:n=!1,loadingTitle:r="Loading…",loadingContent:a,errorTitle:i="Something went wrong",errorDescription:o,retryLabel:l="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:h="Nothing here yet",emptyDescription:y,emptyIcon:m,emptyActions:j,emptyContent:k,children:g,className:w,classNames:N={},"data-testid":S="list-panel"})=>{const b={base:c.cn("border-0 bg-transparent py-12",N.state)};let v;return e?v=a??s.jsx(Mn,{title:r,classNames:b,"data-testid":`${S}-loading`}):t?v=f??s.jsx(In,{title:i,description:o,classNames:b,"data-testid":`${S}-error`,actions:u??(d?s.jsx(W,{color:"primary",variant:"flat",onPress:d,children:l}):void 0)}):n?v=k??s.jsx(En,{title:h,description:y,icon:m,actions:j,classNames:b,"data-testid":`${S}-empty`}):v=g,s.jsx("section",{"data-testid":S,className:c.cn("rounded-xl bg-white p-2 shadow-sm",w,N.base),children:v})};ea.displayName="ListPanel";const rd=350,ad={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},Gt=(e,t)=>Object.entries(t).reduce((n,[r,a])=>n.replace(`{${r}}`,a),e),id=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:a="en-US",labels:i,isDisabled:o=!1,maxAmount:l,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const h={...ad,...i},y=gn(e.currency,a),m=t!==void 0,[j,k]=p.useState(n??null),g=m?t:j,w=p.useMemo(()=>{const F=typeof g=="number"&&Number.isFinite(g)?g:0,L=Jt(F,e.value,e.currency,a);return{received:F,change:L>0?L:0,isValid:F>=e.value&&F>0}},[g,e.value,e.currency,a]),N=p.useCallback(F=>{const L=F.currentTarget;requestAnimationFrame(()=>{L.isConnected&&L.select()})},[]),S=p.useCallback(F=>{if(o)return;const L=F.replace(/[^\d.,]/g,"").replace(",","."),Q=L===""?null:Number.parseFloat(L),U=Q===null||Number.isNaN(Q)?null:Q;if(U!==null&&l!==void 0&&U>l)return;m||k(U);const H=typeof U=="number"&&Number.isFinite(U)?U:0,J=Jt(H,e.value,e.currency,a);r?.({received:H,change:J>0?J:0,isValid:H>=e.value&&H>0})},[m,o,e.value,e.currency,a,r,l]),b=g==null?"":String(g),v=w.isValid&&w.change>0,$=!w.isValid&&w.received>0,M=Pe(w.change,a,e.currency),O=Pe(e.value,a,e.currency),[A,_]=p.useState(""),I=p.useRef(null);p.useEffect(()=>{I.current&&clearTimeout(I.current);const F=v?Gt(h.changeMessageTemplate,{change:M}):"",L=v?rd:0;return I.current=setTimeout(()=>_(F),L),()=>{I.current&&clearTimeout(I.current)}},[v,M,h.changeMessageTemplate]);const D=`${f}-received`;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[s.jsx(c.Input,{id:D,label:h.receivedLabel,labelPlacement:"outside",type:"text",inputMode:y===0?"numeric":"decimal",pattern:y===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:b,onChange:F=>S(F.target.value),onFocus:N,placeholder:h.receivedPlaceholder,isDisabled:o,isInvalid:$,errorMessage:$?Gt(h.insufficientMessageTemplate,{due:O}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),v&&s.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:h.changeLabel,description:Gt(h.changeMessageTemplate,{change:M}),icon:s.jsx(V,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),s.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:A})]})},ld={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},As=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},ta=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:a,hideDate:i=!1,hideBankName:o=!1,isDisabled:l=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:h,"data-testid":y="check-tender-form"})=>{const m={...ld,...a},j=t!==void 0,[k,g]=p.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??As()}),[w,N]=p.useState(!!n?.checkNumber),S=p.useMemo(()=>j?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??As()}:k,[j,t,k]),b=p.useCallback(I=>{j||g(I);const D=I.checkNumber.trim(),F={amount:e.value,checkNumber:D,bankName:I.bankName.trim()||void 0,date:i?void 0:I.date,isValid:D.length>0&&e.value>0};r?.(F)},[j,e.value,i,r]),v=p.useCallback(I=>D=>{l||(I==="checkNumber"&&D.length>0&&N(!0),b({...S,[I]:D}))},[S,b,l]),$=p.useCallback(()=>{l||N(!0)},[l]),M=w&&S.checkNumber.trim()==="",O=`${y}-check-number`,A=`${y}-bank-name`,_=`${y}-date`;return s.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",h),"data-testid":y,children:[s.jsx(c.Input,{id:O,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:S.checkNumber,onChange:I=>v("checkNumber")(I.target.value),onBlur:$,placeholder:m.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:M,errorMessage:M?m.checkNumberRequiredMessage:void 0,isDisabled:l,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${y}-check-number-input`}),!o&&s.jsx(c.Input,{id:A,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:S.bankName,onChange:I=>v("bankName")(I.target.value),placeholder:m.bankNamePlaceholder,maxLength:u,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${y}-bank-name-input`}),!i&&s.jsx(c.Input,{id:_,label:m.dateLabel,labelPlacement:"outside",type:"date",value:S.date,onChange:I=>v("date")(I.target.value),isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${y}-date-input`,className:"sm:col-span-2"})]})};ta.displayName="CheckTenderForm";const od={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},cd=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],na=({dueAmount:e,methodOptions:t=cd,value:n,defaultValue:r,onChange:a,labels:i,showReference:o=!1,isDisabled:l=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...od,...i},h=n!==void 0,[y,m]=p.useState({method:r?.method??"",reference:r?.reference??""}),j=p.useMemo(()=>h?{method:n?.method??"",reference:n?.reference??""}:y,[h,n,y]),k=p.useCallback(v=>t.find($=>$.value===v)?.label??"",[t]),g=p.useCallback(v=>{h||m(v);const $=k(v.method),M={amount:e.value,method:v.method,description:$,reference:v.reference.trim()||void 0,isValid:v.method!==""};a?.(M)},[h,e.value,a,k]),w=p.useCallback(v=>{if(l)return;const $=typeof v=="string"?v:Array.from(v)[0]?.toString()??"";g({...j,method:$})},[j,g,l]),N=p.useCallback(v=>{l||g({...j,reference:v})},[j,g,l]),S=`${u}-method`,b=`${u}-reference`;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[s.jsx(Oe,{id:S,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:j.method?[j.method]:[],onSelectionChange:w,isDisabled:l,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${u}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(v=>s.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${v.value}`,children:v.label},v.value))}),o&&s.jsx(c.Input,{id:b,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:j.reference,onChange:v=>N(v.target.value),placeholder:f.referencePlaceholder,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};na.displayName="OtherTenderForm";const dd={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ud={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},fd={pending:"warning",recorded:"success",failed:"danger"},md=e=>e==="pending"||e==="recorded",hd=e=>`#${e+1}`,sa=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:a,hideCollectedList:i=!1,className:o,"data-testid":l="split-payment-summary"})=>{const d={...dd,...a},{collected:u,remaining:f,isComplete:h}=p.useMemo(()=>{const m=t.reduce((k,g)=>md(g.status)?k+g.amount:k,0),j=Math.max(e.value-m,0);return{collected:m,remaining:j,isComplete:m>=e.value&&e.value>0}},[t,e.value]),y=m=>m==="pending"?d.statusPending:m==="recorded"?d.statusRecorded:d.statusFailed;return s.jsxs("div",{className:c.cn("flex flex-col gap-4",o),"data-testid":l,children:[s.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${l}-remaining-banner`,children:[s.jsx("div",{className:"text-sm text-default-600",children:h?d.completeLabel:d.remainingLabel}),s.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${l}-remaining-amount`,children:Pe(h?u:f,r,e.currency)})]}),!i&&t.length>0&&s.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${l}-collected-list`,children:[s.jsx("h3",{className:"text-base font-semibold",children:d.collectedHeading}),t.map((m,j)=>s.jsx(xd,{index:j,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:y(m.status),removeAriaLabel:d.removeAriaLabel,recordedTooltip:d.removeTooltipForRecorded,dataTestId:`${l}-row-${j}`},m.id))]})]})};sa.displayName="SplitPaymentSummary";const xd=({index:e,tender:t,locale:n,currency:r,removable:a,onRemove:i,statusLabel:o,removeAriaLabel:l,recordedTooltip:d,dataTestId:u})=>{const f=i?s.jsx(W,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!a,"aria-label":l,"data-testid":`${u}-remove`,className:c.cn(a?"text-default-700 hover:bg-default-200":"text-default-300"),children:s.jsx(V,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return s.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":u,children:[s.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:hd(e)}),s.jsx(V,{icon:ud[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:t.label}),s.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:Pe(t.amount,n,r)}),s.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:fd[t.status],startContent:t.status==="recorded"?s.jsx(V,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?s.jsx(V,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:o}),f&&(a?f:s.jsx(c.Tooltip,{content:d,placement:"left",children:s.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},pd=`
|
|
10
|
+
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),s.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:s.jsx(W,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:s.jsx(K.ZoomIn,{size:16})})})]})}function Ui({editor:e,isDisabled:t=!1}){const[n,r]=p.useState(!1),[a,i]=p.useState(""),[o,l]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),h=m=>{if(m){const{from:j,to:k}=e.state.selection,g=e.isActive("link");let w="";if(g){const S=e.schema.marks.link,b=e.state.doc.resolve(j),v=_n.getMarkRange(b,S);v&&(w=e.state.doc.textBetween(v.from,v.to,""))}else w=e.state.doc.textBetween(j,k,"");const N=e.getAttributes("link").href||"";i(w),l(N),u(g)}r(m)},y=()=>{if(o.trim()){const{from:m,to:j}=e.state.selection,k=e.schema.marks.link,g=e.state.doc.resolve(m),w=_n.getMarkRange(g,k),N=w?.from??m,S=w?.to??j,b=e.state.doc.textBetween(N,S,"");a.trim()&&a!==b?e.chain().focus().setTextSelection({from:N,to:S}).deleteSelection().insertContent(`<a href="${o.trim()}">${a.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:o.trim()}).run()}r(!1)};return s.jsxs(c.Popover,{isOpen:n,onOpenChange:h,placement:"bottom",children:[s.jsx(c.PopoverTrigger,{children:s.jsx(W,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:s.jsx(K.Link,{size:16})})}),s.jsx(c.PopoverContent,{children:s.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[s.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:a,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:o,onChange:m=>l(m.target.value),onKeyDown:m=>m.key==="Enter"&&y(),classNames:{inputWrapper:"focus-within:border-default-400"}}),s.jsx(W,{size:"sm",color:"primary",onPress:y,isDisabled:!o.trim(),children:d?"Update":"Apply"})]})})]})}function Hi({children:e,id:t,label:n,className:r,useButtonGroup:a=!0}){return a?s.jsx(c.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):s.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Zs(e,t){const n=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(l=>ct(l)))).forEach(l=>{const d=De[l];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;i[l]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,a]=p.useState(n);return p.useEffect(()=>{if(!e)return;const i=()=>{const o={};Array.from(new Set(t.map(d=>ct(d)))).forEach(d=>{const u=De[d];if(u)try{const f=u.canExecute?.(e)??!0,h=u.isActive?.(e)??!1;o[d]={isActive:h,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),o[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),a(o)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Js(e,t){const n=p.useCallback((o,l)=>{if(!e)return;const d=De[o];if(d)try{d.execute({editor:e,config:l}),t?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[e,t]),r=p.useCallback(o=>{n(o)},[n]),a=p.useCallback((o,l)=>{if(!e)return!1;const d=De[o];try{return d?.canExecute?.(e,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[e]),i=p.useCallback((o,l)=>{if(!e)return!1;const d=De[o];try{return d?.isActive?.(e,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:a,isActive:i}}function qi(e=he.default){const[t,n]=p.useState(e),r=p.useCallback((l=he.step)=>{n(d=>Math.min(he.max,d+l))},[]),a=p.useCallback((l=he.step)=>{n(d=>Math.max(he.min,d-l))},[]),i=p.useCallback(()=>{n(he.default)},[]),o=p.useCallback(l=>{const d=Math.max(he.min,Math.min(he.max,l));n(d)},[]);return{zoom:t,setZoom:o,zoomIn:r,zoomOut:a,resetZoom:i,isMinZoom:t<=he.min,isMaxZoom:t>=he.max,isDefaultZoom:t===he.default}}const Wi=["bold","italic","strike","underline","code"];function Yi({editor:e,modifiers:t,onToolbarAction:n}){const r=Zs(e,t),{toggleModifier:a}=Js(e,n);if(!e)return null;const i=t.map(o=>ct(o)).filter(o=>Wi.includes(o));return i.length===0?null:s.jsx(Hi,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],d=Ge(o);return s.jsx(Be,{icon:d,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>a(o)},o)})})}function Gi({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:a=!0,className:i,onToolbarAction:o}){const l=Zs(e,t),{toggleModifier:d,executeCommand:u}=Js(e,o);if(!e)return null;const f=t.map(M=>ct(M)),h=f.some(M=>["bold","italic","strike","underline","code"].includes(M)),y=f.some(M=>["textColor","highlight"].includes(M)),m=f.includes("heading"),j=f.includes("textAlign"),k=f.some(M=>["bulletList","orderedList","taskList"].includes(M)),g=f.includes("blockquote"),w=f.includes("codeBlock"),N=f.includes("link"),S=f.includes("horizontalRule"),b=f.some(M=>["undo","redo"].includes(M)),v=n!==void 0&&r!==void 0,$=a?"sticky top-0 z-10":"";return s.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${$} ${i||""}`,children:s.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[h&&s.jsxs(s.Fragment,{children:[s.jsx(Yi,{editor:e,modifiers:t,onToolbarAction:o}),(y||m||j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&s.jsx(Yn,{editor:e,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),f.includes("highlight")&&s.jsx(Yn,{editor:e,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),m&&s.jsxs(s.Fragment,{children:[s.jsx(Ti,{editor:e}),(j||k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),j&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(M=>{const O=Ri[M],A=e.isActive({textAlign:M});return s.jsx(Be,{icon:O,label:`Align ${M}`,isActive:A,onClick:()=>u("textAlign",{type:"textAlign",alignment:M})},M)})}),(k||g||w||N||S||b||v)&&s.jsx(Re,{})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx(Li,{editor:e,types:f.filter(M=>["bulletList","orderedList","taskList"].includes(M))}),(g||w||N||S||b||v)&&s.jsx(Re,{})]}),(g||w||N||S)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[g&&s.jsx(Be,{icon:Ge("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&s.jsx(Be,{icon:Ge("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),N&&s.jsx(Ui,{editor:e,isDisabled:l.link?.isDisabled}),S&&s.jsx(Be,{icon:Ge("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(b||v)&&s.jsx(Re,{})]}),b&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&s.jsx(Be,{icon:Ge("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&s.jsx(Be,{icon:Ge("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>d("redo")})]}),v&&s.jsx(Re,{})]}),v&&s.jsx(Vi,{zoom:n,onZoomChange:M=>{r?.(M),o?.({type:"zoom",modifier:`${M}%`})}})]})})}const et={bold:{category:"mark",extension:Aa.Bold,priority:100},italic:{category:"mark",extension:$a.Italic,priority:100},strike:{category:"mark",extension:Da.Strike,priority:100},underline:{category:"mark",extension:Ea.Underline,priority:100},code:{category:"mark",extension:Ia.Code,priority:100},textColor:{category:"mark",extension:Ma.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Fa.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Ta.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Oa.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:_a.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:za.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Ra.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Ua.CodeBlock,priority:100},blockquote:{category:"node",extension:Ha.Blockquote,priority:100},horizontalRule:{category:"node",extension:qa.HorizontalRule,priority:100},hardBreak:{category:"node",extension:Wa.HardBreak,priority:100},undo:{category:"extension",extension:zn.History,priority:50},redo:{category:"extension",extension:zn.History,priority:50},textAlign:{category:"extension",extension:Ya.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},Ki=[Ga.Document,Ka.Text,Pa.Paragraph,La.TextStyle.configure({HTMLAttributes:{}}),Va.ListItem.configure({HTMLAttributes:{}}),Ba.TaskItem.configure({nested:!0}),Qa.Dropcursor,Za.Gapcursor];function Qi(e){const t=[],n=new Set,r=new Set;Ki.forEach(l=>{l&&(t.push(l),r.add(l.name))});const a=e.map(l=>ct(l)),i=new Set;return a.forEach(l=>{const d=et[l];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const d=et[l];if(!d||d.extension===null)return;const u=d.extension.name;if(r.has(u)){n.add(l);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;t.push(f),n.add(l),r.add(u)}),a.forEach(l=>{if(n.has(l))return;const d=et[l];if(!d){console.warn(`Extension config not found for modifier: ${l}`);return}if(d.extension===null){n.add(l);return}const u=d.extension.name;if(r.has(u)){n.add(l);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;t.push(f),n.add(l),r.add(u)}),t.sort((l,d)=>{const u=Object.values(et).find(m=>m?.extension?.name===l.name),f=Object.values(et).find(m=>m?.extension?.name===d.name),h=u?.priority??100;return(f?.priority??100)-h})}const Xs={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},ce={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Te={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},le={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Zi={h1:`font-size: ${ce.fontSize["4xl"]}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h2:`font-size: ${ce.fontSize["2xl"]}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h3:`font-size: ${ce.fontSize.xl}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h4:`font-size: ${ce.fontSize.lg}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h5:`font-size: ${ce.fontSize.base}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,h6:`font-size: ${ce.fontSize.sm}; font-weight: ${ce.fontWeight.semibold}; line-height: ${ce.lineHeight.tight}; margin: ${le.md} 0 ${le.sm} 0;`,p:`min-height: ${ce.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${le.xl}; margin: ${le.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${le.xl}; margin: ${le.md} 0;`,li:`display: list-item; margin: ${le.xs} 0;`,strong:`font-weight: ${ce.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Te.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ce.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ce.fontFamily.mono};`,pre:`background: ${Te.neutral.gray[800]}; border-radius: ${le.sm}; color: ${Te.neutral.gray[100]}; font-family: ${ce.fontFamily.mono}; margin: ${le.lg} 0; padding: 0.75rem ${le.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Te.neutral.gray[300]}; margin: ${le.lg} 0; padding-left: ${le.md}; color: ${Te.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Te.neutral.gray[200]}; margin: ${le.xl} 0;`,a:`color: ${Te.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Te.palettes.warning[200]}; border-radius: ${le.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${le.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Ji={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function Xi(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(Ji)){const a=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(a,(i,o)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${o} style="${r}">`)}for(const[n,r]of Object.entries(Zi)){const a=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(a,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const o=i.indexOf(">");return`${i.slice(0,o)} style="${r}"${i.slice(o)}`}})}return t}const el=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:a}=dn.useCurrentEditor();return s.jsx(Gi,{editor:a,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},tl=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=dn.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),a=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return s.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&s.jsxs("span",{children:[a," characters"]}),t&&s.jsxs("span",{children:[i," words"]})]})},Xt=p.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:a=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:d=Xs.full,variant:u="bordered",initialContent:f,content:h,onContentChange:y,onUpdate:m,onToolbarAction:j,isReadOnly:k=!1,isDisabled:g=!1,includeInlineStyles:w=!0,...N}=e,{zoom:S,setZoom:b}=qi(),v=Wn.lineHeight,$=n*v,M=a?void 0:r*v,O=p.useMemo(()=>Qi(d),[d]),{Component:A,label:_,shouldLabelBeOutside:I,getBaseProps:D,getLabelProps:F,getInputWrapperProps:L}=c.useInput({...N,variant:u,ref:t,isMultiline:!0}),Q=_?s.jsx("label",{...F(),children:_}):null,U=p.useCallback(({editor:H})=>{const J=H.getHTML(),ee=w?Xi(J):J,se=H.getJSON(),Y=H.getText(),B=Y.length,G=Y.split(/\s+/).filter(ie=>ie.length>0).length,Z={html:ee,json:se,text:Y,characters:B,words:G};if(y?.(Z),m?.(Z),"onChange"in N&&typeof N.onChange=="function"){const ie={target:{value:ee},currentTarget:{value:ee}};N.onChange(ie)}},[y,m,N,w]);return s.jsxs(A,{...D(),children:[I?Q:null,s.jsx("div",{...L(),className:c.cn(L().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:M?`${M+Wn.toolbarHeight}px`:void 0,overflow:M?"auto":void 0},children:s.jsx(dn.EditorProvider,{editable:!k&&!g,slotBefore:l?s.jsx(el,{modifiers:d,zoom:S,onZoomChange:b,onToolbarAction:j}):void 0,slotAfter:s.jsx(tl,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${$}px`,fontSize:`${S}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:O,content:h||f||e.defaultValue||"",onUpdate:U})})]})});Xt.displayName="TipTapEditor";const er=p.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...a}=e;return n==="tiptap"?s.jsx(Xt,{...a,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),s.jsx(Xt,{...a,variant:r,ref:t}))});er.displayName="RichTextArea";function nl(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const Gn=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],sl={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},tr=({presetAmounts:e=Gn,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:a,currency:i="USD",locale:o="en-US",showCustomAmount:l=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:h=2,desktopColumns:y=3,isDisabled:m=!1,buttonVariant:j="bordered",buttonColor:k="default",inputVariant:g="bordered",size:w="md",className:N="",showCard:S=!0})=>{const b={...sl,...f},v=Array.isArray(e)?e:Gn,$={2:"grid-cols-2",3:"grid-cols-3"},M={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},O=`${$[h]} ${M[y]}`,[A,_]=pn(t,n,r),[I,D]=p.useState(""),[F,L]=p.useState(!1),[Q,U]=p.useState(0),H=p.useCallback(B=>{if(m)return;const G={amount:B.amount,isCustom:!1,presetId:B.id};_(G),D(""),L(!1),U(Z=>Z+1),a?.(G)},[m,_,a]),J=p.useCallback(B=>{if(m)return;if(D(B!==void 0?String(B):""),a){_(null);return}if(B===void 0||isNaN(B)){_(null);return}_({amount:B,isCustom:!0})},[m,_,a]),ee=p.useCallback(()=>{if(m)return;const B=I!==""?parseFloat(I):void 0;B===void 0||isNaN(B)||a?.({amount:B,isCustom:!0})},[m,I,a]),se=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=s.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[b.title&&s.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:b.title}),v.length>0&&s.jsx("div",{className:c.cn("grid gap-3",O),"data-testid":"donation-amounts-presets",children:v.map(B=>{const G=A!==null&&!A.isCustom&&A.presetId===B.id;return s.jsx(W,{color:G?"primary":k,variant:G?"solid":j,className:"w-full",onPress:()=>H(B),isDisabled:m,"data-testid":`donation-amounts-preset-${B.id}`,children:B.label||nl(B.amount,o,i)},B.id)})}),l&&s.jsxs("div",{className:"flex gap-3 items-start",children:[s.jsx(c.NumberInput,{placeholder:b.customAmountPlaceholder,"aria-label":b.customAmountAriaLabel,onInput:a?()=>{_(null),L(!0)}:void 0,variant:g,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:se,value:I!==""?parseFloat(I):void 0,onValueChange:J,isDisabled:m,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},a?`custom-${Q}`:A?.isCustom===!1?A.presetId:"custom"),a&&s.jsx(W,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:ee,isDisabled:m||!F,"data-testid":"donation-amounts-add-button",children:b.addDonationButton})]})]});return S?s.jsx(c.Card,{className:c.cn("w-full",N),"data-testid":"donation-amounts-card",children:s.jsx(c.CardBody,{children:Y})}):s.jsx("div",{className:c.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};tr.displayName="DonationAmounts";const rl=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},al=e=>{switch(e){case"warning":return K.Clock;case"error":return K.AlertCircle;case"success":return K.CheckCircle;default:return K.Clock}},il=e=>{switch(e){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},nr=p.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:a="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:h=rl,className:y,...m},j)=>{const[k,g]=pn(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=p.useRef(null),N=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||k<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{g($=>$<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,r?.()),0):$-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,k,g,r]),p.useEffect(()=>{k>0&&(N.current=!1)},[k]);const S=d||al(a),b=il(i),v={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return s.jsx("div",{ref:j,role:"banner","aria-live":"polite","aria-label":`${o} ${h(k)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",b,v[u],y),...m,children:s.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&s.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:s.jsx(S,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),s.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:o})]}),s.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:s.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${h(k)}`,"data-testid":"expire-cart-timer-value",children:h(k)})})]})})})});nr.displayName="ExpireCartTimer";function ll(e,t){const n=e.icons,r=e.aliases||Object.create(null),a=Object.create(null);function i(o){if(n[o])return a[o]=[];if(!(o in a)){a[o]=null;const l=r[o]&&r[o].parent,d=l&&i(l);d&&(a[o]=[l].concat(d))}return a[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),a}const sr=Object.freeze({left:0,top:0,width:16,height:16}),bt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),bn=Object.freeze({...sr,...bt}),en=Object.freeze({...bn,body:"",hidden:!1});function ol(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Kn(e,t){const n=ol(e,t);for(const r in en)r in bt?r in e&&!(r in n)&&(n[r]=bt[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function cl(e,t,n){const r=e.icons,a=e.aliases||Object.create(null);let i={};function o(l){i=Kn(r[l]||a[l],i)}return o(t),n.forEach(o),Kn(e,i)}function rr(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(a=>{t(a,null),n.push(a)});const r=ll(e);for(const a in r){const i=r[a];i&&(t(a,cl(e,a,i)),n.push(a))}return n}const dl={provider:"",aliases:{},not_found:{},...sr};function zt(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function ar(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!zt(e,dl))return null;const n=t.icons;for(const a in n){const i=n[a];if(!a||typeof i.body!="string"||!zt(i,en))return null}const r=t.aliases||Object.create(null);for(const a in r){const i=r[a],o=i.parent;if(!a||typeof o!="string"||!n[o]&&!r[o]||!zt(i,en))return null}return t}const Qn=Object.create(null);function ul(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Ze(e,t){const n=Qn[e]||(Qn[e]=Object.create(null));return n[t]||(n[t]=ul(e,t))}function ir(e,t){return ar(t)?rr(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function fl(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const lr=/^[a-z0-9]+(-[a-z0-9]+)*$/,St=(e,t,n,r="")=>{const a=e.split(":");if(e.slice(0,1)==="@"){if(a.length<2||a.length>3)return null;r=a.shift().slice(1)}if(a.length>3||!a.length)return null;if(a.length>1){const l=a.pop(),d=a.pop(),u={provider:a.length>0?a[0]:r,prefix:d,name:l};return t&&!xt(u)?null:u}const i=a[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return t&&!xt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return t&&!xt(l,n)?null:l}return null},xt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let dt=!1;function or(e){return typeof e=="boolean"&&(dt=e),dt}function Zn(e){const t=typeof e=="string"?St(e,!0,dt):e;if(t){const n=Ze(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function ml(e,t){const n=St(e,!0,dt);if(!n)return!1;const r=Ze(n.provider,n.prefix);return t?fl(r,n.name,t):(r.missing.add(n.name),!0)}function hl(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),dt&&!t&&!e.prefix){let a=!1;return ar(e)&&(e.prefix="",rr(e,(i,o)=>{ml(i,o)&&(a=!0)})),a}const n=e.prefix;if(!xt({prefix:n,name:"a"}))return!1;const r=Ze(t,n);return!!ir(r,e)}const cr=Object.freeze({width:null,height:null}),dr=Object.freeze({...cr,...bt}),xl=/(-?[0-9.]*[0-9]+[0-9.]*)/g,pl=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Jn(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(xl);if(r===null||!r.length)return e;const a=[];let i=r.shift(),o=pl.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?a.push(i):a.push(Math.ceil(l*t*n)/n)}else a.push(i);if(i=r.shift(),i===void 0)return a.join("");o=!o}}function gl(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const a=e.indexOf(">",r),i=e.indexOf("</"+t);if(a===-1||i===-1)break;const o=e.indexOf(">",i);if(o===-1)break;n+=e.slice(a+1,i).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function bl(e,t){return e?"<defs>"+e+"</defs>"+t:t}function yl(e,t,n){const r=gl(e);return bl(r.defs,t+r.content+n)}const vl=e=>e==="unset"||e==="undefined"||e==="none";function jl(e,t){const n={...bn,...e},r={...dr,...t},a={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(k=>{const g=[],w=k.hFlip,N=k.vFlip;let S=k.rotate;w?N?S+=2:(g.push("translate("+(a.width+a.left).toString()+" "+(0-a.top).toString()+")"),g.push("scale(-1 1)"),a.top=a.left=0):N&&(g.push("translate("+(0-a.left).toString()+" "+(a.height+a.top).toString()+")"),g.push("scale(1 -1)"),a.top=a.left=0);let b;switch(S<0&&(S-=Math.floor(S/4)*4),S=S%4,S){case 1:b=a.height/2+a.top,g.unshift("rotate(90 "+b.toString()+" "+b.toString()+")");break;case 2:g.unshift("rotate(180 "+(a.width/2+a.left).toString()+" "+(a.height/2+a.top).toString()+")");break;case 3:b=a.width/2+a.left,g.unshift("rotate(-90 "+b.toString()+" "+b.toString()+")");break}S%2===1&&(a.left!==a.top&&(b=a.left,a.left=a.top,a.top=b),a.width!==a.height&&(b=a.width,a.width=a.height,a.height=b)),g.length&&(i=yl(i,'<g transform="'+g.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,d=a.width,u=a.height;let f,h;o===null?(h=l===null?"1em":l==="auto"?u:l,f=Jn(h,d/u)):(f=o==="auto"?d:o,h=l===null?Jn(f,u/d):l==="auto"?u:l);const y={},m=(k,g)=>{vl(g)||(y[k]=g.toString())};m("width",f),m("height",h);const j=[a.left,a.top,d,u];return y.viewBox=j.join(" "),{attributes:y,viewBox:j,body:i}}const wl=/\sid="(\S+)"/g,Nl="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Cl=0;function kl(e,t=Nl){const n=[];let r;for(;r=wl.exec(e);)n.push(r[1]);if(!n.length)return e;const a="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const o=typeof t=="function"?t(i):t+(Cl++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+a+"$3")}),e=e.replace(new RegExp(a,"g"),""),e}const tn=Object.create(null);function Sl(e,t){tn[e]=t}function nn(e){return tn[e]||tn[""]}function yn(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const vn=Object.create(null),tt=["https://api.simplesvg.com","https://api.unisvg.com"],pt=[];for(;tt.length>0;)tt.length===1||Math.random()>.5?pt.push(tt.shift()):pt.push(tt.pop());vn[""]=yn({resources:["https://api.iconify.design"].concat(pt)});function Al(e,t){const n=yn(t);return n===null?!1:(vn[e]=n,!0)}function jn(e){return vn[e]}const $l=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Xn=$l();function Dl(e,t){const n=jn(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let a=0;n.resources.forEach(o=>{a=Math.max(a,o.length)});const i=t+".json?icons=";r=n.maxURL-a-n.path.length-i.length}return r}function El(e){return e===404}const Il=(e,t,n)=>{const r=[],a=Dl(e,t),i="icons";let o={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((d,u)=>{l+=d.length+1,l>=a&&u>0&&(r.push(o),o={type:i,provider:e,prefix:t,icons:[]},l=d.length),o.icons.push(d)}),r.push(o),r};function Ml(e){if(typeof e=="string"){const t=jn(e);if(t)return t.path}return"/"}const Fl=(e,t,n)=>{if(!Xn){n("abort",424);return}let r=Ml(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),d=new URLSearchParams({icons:l});r+=i+".json?"+d.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let a=503;Xn(e+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(El(o)?"abort":"next",o)});return}return a=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",a)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",a)})},Tl={prepare:Il,send:Fl};function ur(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(a=>a.id!==t))})}function Ll(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,a=e.prefix;t.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(d=>{if(d.prefix!==a)return!0;const u=d.name;if(e.icons[u])o.loaded.push({provider:r,prefix:a,name:u});else if(e.missing.has(u))o.missing.push({provider:r,prefix:a,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||ur([e],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let Ol=0;function Pl(e,t,n){const r=Ol++,a=ur.bind(null,n,r);if(!t.pending.length)return a;const i={id:r,icons:t,callback:e,abort:a};return n.forEach(o=>{(o.loaderCallbacks||(o.loaderCallbacks=[])).push(i)}),a}function _l(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((a,i)=>a.provider!==i.provider?a.provider.localeCompare(i.provider):a.prefix!==i.prefix?a.prefix.localeCompare(i.prefix):a.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(a=>{if(r.name===a.name&&r.prefix===a.prefix&&r.provider===a.provider)return;r=a;const i=a.provider,o=a.prefix,l=a.name,d=n[i]||(n[i]=Object.create(null)),u=d[o]||(d[o]=Ze(i,o));let f;l in u.icons?f=t.loaded:o===""||u.missing.has(l)?f=t.missing:f=t.pending;const h={provider:i,prefix:o,name:l};f.push(h)}),t}function zl(e,t=!0,n=!1){const r=[];return e.forEach(a=>{const i=typeof a=="string"?St(a,t,n):a;i&&r.push(i)}),r}const Rl={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Bl(e,t,n,r){const a=e.resources.length,i=e.random?Math.floor(Math.random()*a):e.index;let o;if(e.random){let $=e.resources.slice(0);for(o=[];$.length>1;){const M=Math.floor(Math.random()*$.length);o.push($[M]),$=$.slice(0,M).concat($.slice(M+1))}o=o.concat($)}else o=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let d="pending",u=0,f,h=null,y=[],m=[];typeof r=="function"&&m.push(r);function j(){h&&(clearTimeout(h),h=null)}function k(){d==="pending"&&(d="aborted"),j(),y.forEach($=>{$.status==="pending"&&($.status="aborted")}),y=[]}function g($,M){M&&(m=[]),typeof $=="function"&&m.push($)}function w(){return{startTime:l,payload:t,status:d,queriesSent:u,queriesPending:y.length,subscribe:g,abort:k}}function N(){d="failed",m.forEach($=>{$(void 0,f)})}function S(){y.forEach($=>{$.status==="pending"&&($.status="aborted")}),y=[]}function b($,M,O){const A=M!=="success";switch(y=y.filter(_=>_!==$),d){case"pending":break;case"failed":if(A||!e.dataAfterTimeout)return;break;default:return}if(M==="abort"){f=O,N();return}if(A){f=O,y.length||(o.length?v():N());return}if(j(),S(),!e.random){const _=e.resources.indexOf($.resource);_!==-1&&_!==e.index&&(e.index=_)}d="completed",m.forEach(_=>{_(O)})}function v(){if(d!=="pending")return;j();const $=o.shift();if($===void 0){if(y.length){h=setTimeout(()=>{j(),d==="pending"&&(S(),N())},e.timeout);return}N();return}const M={status:"pending",resource:$,callback:(O,A)=>{b(M,O,A)}};y.push(M),u++,h=setTimeout(v,e.rotate),n($,t,M.callback)}return setTimeout(v),w}function fr(e){const t={...Rl,...e};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function a(l,d,u){const f=Bl(t,l,d,(h,y)=>{r(),u&&u(h,y)});return n.push(f),f}function i(l){return n.find(d=>l(d))||null}return{query:a,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:r}}function es(){}const Rt=Object.create(null);function Vl(e){if(!Rt[e]){const t=jn(e);if(!t)return;const n=fr(t),r={config:t,redundancy:n};Rt[e]=r}return Rt[e]}function Ul(e,t,n){let r,a;if(typeof e=="string"){const i=nn(e);if(!i)return n(void 0,424),es;a=i.send;const o=Vl(e);o&&(r=o.redundancy)}else{const i=yn(e);if(i){r=fr(i);const o=e.resources?e.resources[0]:"",l=nn(o);l&&(a=l.send)}}return!r||!a?(n(void 0,424),es):r.query(t,a,n)().abort}function ts(){}function Hl(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Ll(e)}))}function ql(e){const t=[],n=[];return e.forEach(r=>{(r.match(lr)?t:n).push(r)}),{valid:t,invalid:n}}function nt(e,t,n){function r(){const a=e.pendingIcons;t.forEach(i=>{a&&a.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!ir(e,n).length){r();return}}catch(a){console.error(a)}r(),Hl(e)}function ns(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function Wl(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,a=e.iconsToLoad;if(delete e.iconsToLoad,!a||!a.length)return;const i=e.loadIcon;if(e.loadIcons&&(a.length>1||!i)){ns(e.loadIcons(a,r,n),f=>{nt(e,a,f)});return}if(i){a.forEach(f=>{const h=i(f,r,n);ns(h,y=>{const m=y?{prefix:r,icons:{[f]:y}}:null;nt(e,[f],m)})});return}const{valid:o,invalid:l}=ql(a);if(l.length&&nt(e,l,null),!o.length)return;const d=r.match(lr)?nn(n):null;if(!d){nt(e,o,null);return}d.prepare(n,r,o).forEach(f=>{Ul(n,f,h=>{nt(e,f.icons,h)})})}))}const Yl=(e,t)=>{const n=zl(e,!0,or()),r=_l(n);if(!r.pending.length){let d=!0;return t&&setTimeout(()=>{d&&t(r.loaded,r.missing,r.pending,ts)}),()=>{d=!1}}const a=Object.create(null),i=[];let o,l;return r.pending.forEach(d=>{const{provider:u,prefix:f}=d;if(f===l&&u===o)return;o=u,l=f,i.push(Ze(u,f));const h=a[u]||(a[u]=Object.create(null));h[f]||(h[f]=[])}),r.pending.forEach(d=>{const{provider:u,prefix:f,name:h}=d,y=Ze(u,f),m=y.pendingIcons||(y.pendingIcons=new Set);m.has(h)||(m.add(h),a[u][f].push(h))}),i.forEach(d=>{const u=a[d.provider][d.prefix];u.length&&Wl(d,u)}),t?Pl(t,r,i):ts};function Gl(e,t){const n={...e};for(const r in t){const a=t[r],i=typeof a;r in cr?(a===null||a&&(i==="string"||i==="number"))&&(n[r]=a):i===typeof n[r]&&(n[r]=r==="rotate"?a%4:a)}return n}const Kl=/[\s,]+/;function Ql(e,t){t.split(Kl).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Zl(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(a){for(;a<0;)a+=4;return a%4}if(n===""){const a=parseInt(e);return isNaN(a)?0:r(a)}else if(n!==e){let a=0;switch(n){case"%":a=25;break;case"deg":a=90}if(a){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/a,i%1===0?r(i):0)}}return t}function Jl(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Xl(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function eo(e){return"data:image/svg+xml,"+Xl(e)}function to(e){return'url("'+eo(e)+'")'}let at;function no(){try{at=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{at=null}}function so(e){return at===void 0&&no(),at?at.createHTML(e):e}const mr={...dr,inline:!1},ro={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ao={display:"inline-block"},sn={backgroundColor:"currentColor"},hr={backgroundColor:"transparent"},ss={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},rs={WebkitMask:sn,mask:sn,background:hr};for(const e in rs){const t=rs[e];for(const n in ss)t[e+n]=ss[n]}const io={...mr,inline:!0};function as(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const lo=(e,t,n)=>{const r=t.inline?io:mr,a=Gl(r,t),i=t.mode||"svg",o={},l=t.style||{},d={...i==="svg"?ro:{}};if(n){const g=St(n,!1,!0);if(g){const w=["iconify"],N=["provider","prefix"];for(const S of N)g[S]&&w.push("iconify--"+g[S]);d.className=w.join(" ")}}for(let g in t){const w=t[g];if(w!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=w;break;case"className":d[g]=(d[g]?d[g]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":a[g]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&Ql(a,w);break;case"color":o.color=w;break;case"rotate":typeof w=="string"?a[g]=Zl(w):typeof w=="number"&&(a[g]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete d["aria-hidden"];break;default:r[g]===void 0&&(d[g]=w)}}const u=jl(e,a),f=u.attributes;if(a.inline&&(o.verticalAlign="-0.125em"),i==="svg"){d.style={...o,...l},Object.assign(d,f);let g=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:so(kl(u.body,w?()=>w+"ID"+g++:"iconifyReact"))},p.createElement("svg",d)}const{body:h,width:y,height:m}=e,j=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),k=Jl(h,{...f,width:y+"",height:m+""});return d.style={...o,"--svg":to(k),width:as(f.width),height:as(f.height),...ao,...j?sn:hr,...l},p.createElement("span",d)};or(!0);Sl("",Tl);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!hl(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const a=t[n];if(typeof a!="object"||!a||a.resources===void 0)continue;Al(n,a)||console.error(r)}catch{console.error(r)}}}}function xr(e){const[t,n]=p.useState(!!e.ssr),[r,a]=p.useState({});function i(m){if(m){const j=e.icon;if(typeof j=="object")return{name:"",data:j};const k=Zn(j);if(k)return{name:j,data:k}}return{name:""}}const[o,l]=p.useState(i(!!e.ssr));function d(){const m=r.callback;m&&(m(),a({}))}function u(m){if(JSON.stringify(o)!==JSON.stringify(m))return d(),l(m),!0}function f(){var m;const j=e.icon;if(typeof j=="object"){u({name:"",data:j});return}const k=Zn(j);if(u({name:j,data:k}))if(k===void 0){const g=Yl([j],f);a({callback:g})}else k&&((m=e.onLoad)===null||m===void 0||m.call(e,j))}p.useEffect(()=>(n(!0),d),[]),p.useEffect(()=>{t&&f()},[e.icon,t]);const{name:h,data:y}=o;return y?lo({...bn,...y},e,h):e.children?e.children:e.fallback?e.fallback:p.createElement("span",{})}const V=p.forwardRef((e,t)=>xr({...e,_ref:t}));p.forwardRef((e,t)=>xr({inline:!0,...e,_ref:t}));const Bt=({icon:e,children:t,testId:n})=>s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[s.jsx(V,{icon:e,width:20,className:"text-default-500"}),s.jsx("span",{children:t})]}),oo=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:a,location:i,description:o,showImage:l=!1,compact:d=!1,imageLoading:u="eager",showMoreButtonClassName:f,labels:h})=>{const[y,m]=p.useState(!1),[j,k]=p.useState(!1),g=p.useRef(null);return p.useEffect(()=>{const w=()=>{if(g.current){const N=g.current.scrollHeight>g.current.clientHeight;k(N)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[o]),s.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[s.jsxs(c.CardHeader,{className:c.cn("pt-2 pb-0 flex-col items-start",d?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[l&&n&&s.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:s.jsx(c.Image,{removeWrapper:!0,loading:u,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),s.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),s.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[s.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),s.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&s.jsx(Bt,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),a&&s.jsx(Bt,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:a}),i&&s.jsx(Bt,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),o&&s.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{ref:g,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!y&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!y&&j&&s.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(j||y)&&s.jsx("div",{className:"flex justify-end mt-1",children:s.jsx(W,{onPress:()=>m(!y),variant:"light",className:c.cn("text-primary",f),size:d?"sm":"md",startContent:s.jsx(V,{icon:y?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:y?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function rn(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function co(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}const uo={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached",ruleBlocked:"Unavailable for selected ticket options",disabled:"Ticket selection is unavailable"},We=e=>typeof e=="number"&&!isNaN(e),yt=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:a="USD",locale:i="en-US",labels:o,slots:l,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:h=!0,showDescription:y=!0,showPeopleCount:m=!0,showPrice:j=!0,priceDisplay:k,classNames:g={},"data-testid":w,selectedColor:N="default",compact:S=!1,isSoldOut:b,isMaxReached:v,isRuleBlocked:$,statusTone:M="default",statusLabel:O,disabledReason:A,disabled:_})=>{const I=p.useMemo(()=>({...uo,...o}),[o]),[D,F]=p.useState(n),L=t!==void 0?t:D,Q=!!(d||_),U=S||!!e.compact,H=p.useMemo(()=>typeof b=="boolean"?b:typeof e.isSoldOut=="boolean"?e.isSoldOut:!We(e.totalTicketsSold)||!We(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[b,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),J=p.useMemo(()=>typeof v=="boolean"?v:typeof e.isMaxReached=="boolean"?e.isMaxReached:H||!We(e.ticketsAllowed)?!1:L>=e.ticketsAllowed-(e.totalTicketsSold??0),[v,e.isMaxReached,H,e.ticketsAllowed,e.totalTicketsSold,L]),ee=p.useMemo(()=>typeof $=="boolean"?$:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[$,e.isRuleBlocked]),se=A||e.disabledReason,Y=Q||H||ee,B=X=>{if(Y||X>0&&J)return;const me=Math.max(0,L+X);t===void 0&&F(me),r?.(e.id,me)},G=p.useMemo(()=>{if(H)return"soldOut";if(ee)return"ruleBlocked";if(Q)return"disabled"},[H,ee,Q]),Z=p.useMemo(()=>M||(H||ee?"danger":J?"warning":"default"),[M,H,ee,J]),ie=p.useMemo(()=>{if(G)return G==="ruleBlocked"?O||se||I.ruleBlocked:G==="soldOut"?O||se||I.soldOut:G==="disabled"?O||se||I.disabled:O||I.maxReached},[G,O,se,I]),re={soldOut:"danger",ruleBlocked:Z,disabled:"default",maxReached:"warning"},Ne={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},ve=()=>l?.renderName?l.renderName(e.name,e):s.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",U&&"text-sm",g.name),children:e.name}),xe=()=>{if(!j)return null;const X=k?.price??e.price,me=k?.originalPrice,qe=rn(X,i,a);if(l?.renderPrice)return l.renderPrice(X,qe,e);if(We(me)&&We(X)&&me>X){const Xe=rn(me,i,a);return s.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",U&&"mt-0.5",g.price),children:[s.jsxs("span",{className:"sr-only",children:["Original price ",Xe,", discounted price ",qe]}),s.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",U&&"text-xs",g.originalPrice),children:Xe}),s.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",U&&"text-sm",g.discountedPrice),children:qe})]})}return s.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",U&&"text-sm mt-0.5",g.price),children:qe})},Ee=()=>!y||!e.description?null:l?.renderDescription?l.renderDescription(e.description,e):s.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",U&&"mb-2 text-xs text-gray-600",g.description),children:e.description}),Ie=()=>{if(!m||!We(e.numberOfPeople)||e.numberOfPeople<=0)return null;const X=e.numberOfPeople===1?I.person:I.people;return l?.renderPeopleCount?l.renderPeopleCount(e.numberOfPeople,X,e):s.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",U&&"mt-1 text-xs",g.peopleCount),children:[s.jsx(V,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",X]})},He=()=>{const X=L===0||Y,me=J||Y;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:L,onIncrement:()=>B(1),onDecrement:()=>B(-1),isDecrementDisabled:X,isIncrementDisabled:me,isDisabled:Y}):s.jsxs("div",{className:c.cn("flex items-center gap-2",g.quantitySelector),children:[s.jsx(W,{"data-testid":"offer-card-decrement-button",onPress:()=>B(-1),isDisabled:X,variant:u,color:L>0?N:f,radius:"full",isIconOnly:!0,size:U?"md":"sm","aria-label":"Decrease quantity",children:s.jsx(V,{icon:"gravity-ui:minus",width:16})}),s.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",U&&"text-sm"),children:L}),s.jsx(W,{"data-testid":"offer-card-increment-button",onPress:()=>B(1),isDisabled:me,variant:u,color:L>0?N:f,radius:"full",isIconOnly:!0,size:U?"md":"sm","aria-label":"Increase quantity",children:s.jsx(V,{icon:"gravity-ui:plus",width:16})})]})},Me=(X,me)=>l?.renderDisabledState?l.renderDisabledState(X,me):X==="soldOut"&&l?.renderSoldOut?l.renderSoldOut(me):X==="maxReached"&&l?.renderMaxReachedAlert?l.renderMaxReachedAlert(me):s.jsx(c.Chip,{"data-testid":Ne[X],color:re[X],variant:X==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",X==="maxReached"?"h-8":"h-10",X==="soldOut"&&g.soldOut,X==="maxReached"&&g.maxReachedAlert,U&&"h-8"),startContent:s.jsx(V,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:s.jsx("span",{className:"font-medium text-sm",children:me})}),_e=s.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",U?"gap-1":"gap-2"),children:[s.jsxs("div",{className:c.cn("h-full col-span-2",Y||J?"opacity-50 pointer-events-none select-none":""),children:[ve(),xe(),s.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",U?"mb-1":"mb-2"),children:[Ie(),Ee()]})]}),s.jsx("div",{className:c.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",U&&"space-x-1 pb-1 md:p-1",g.compactFooter),children:G&&ie?Me(G,ie):He()})]}),Ae=J&&!H&&!ee&&!Q?s.jsx(Ce.motion.div,{className:c.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",g.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Me("maxReached",ie||I.maxReached)}):null;return h?s.jsxs(c.Card,{className:c.cn("w-full",U&&g.compact,g.base),"data-testid":w||`offer-card-${e.id}`,children:[s.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",U?"pb-0.5":"",g.body),children:_e}),s.jsx(Ce.AnimatePresence,{children:Ae&&s.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",U?"pt-1":"",g.footer),children:Ae})})]}):s.jsxs("div",{className:c.cn("w-full",U&&g.compact,g.base),"data-testid":w||`offer-card-${e.id}`,children:[s.jsx("div",{className:c.cn("pt-1 pb-0",U?"pb-0.5":"",g.body),children:_e}),s.jsx(Ce.AnimatePresence,{children:Ae&&s.jsx("div",{className:c.cn("w-full mt-0 pt-0",U?"pt-1":"",g.footer),children:Ae})})]})};yt.displayName="OfferCard";const pr=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i){const l=i();return r?s.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):s.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:l})}const o=s.jsxs("div",{"data-testid":"offer-card-empty-content",className:c.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",a.content),children:[s.jsx(V,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:c.cn("mb-4",a.icon)}),s.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",a.message),children:e})]});return r?s.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):s.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",a.base),children:o})};pr.displayName="OfferCardEmpty";const fo={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},gr=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...fo,...t},o=s.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:o})}):s.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",a.base),children:o})};gr.displayName="OfferCardError";const mo={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},br=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=mo[t];return s.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(r,n.base),children:Array.from({length:e}).map((a,i)=>s.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",n.card),children:[s.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:s.jsxs("div",{className:"space-y-2 w-full",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),s.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[s.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:s.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),s.jsx("div",{className:"flex items-start justify-end",children:s.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),s.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};br.displayName="OfferCardSkeleton";const yr={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},vr={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},ho={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},jr=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:a,onQuantityChange:i,currency:o="USD",locale:l="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:h="bordered",buttonColor:y="default",showCard:m=!0,animated:j=!0,gap:k=2,compact:g=!1,classNames:w={}})=>{const[N,S]=p.useState(r),b=n!==void 0?n:N,v=p.useCallback((I,D)=>{const F={...b,[I]:Math.max(0,D)};n===void 0&&S(F),a?.(F),i?.(I,F[I])},[b,n,a,i]),$=[...e].sort((I,D)=>(I.position??0)-(D.position??0)),M=I=>{const D=t?t(I):I,F=(b??{})[D.id]||0;return{offer:D,quantity:F,onQuantityChange:v,currency:o,locale:l,labels:d,slots:u,isDisabled:f,buttonVariant:h,buttonColor:y,showCard:m,compact:g}},O=ho[k],A=c.cn("grid mx-auto pt-2",O,w.base),_=I=>{const D=M(I);return s.jsx(yt,{offer:D.offer,quantity:D.quantity,onQuantityChange:D.onQuantityChange,currency:D.currency,locale:D.locale,labels:D.labels,slots:D.slots,isDisabled:D.isDisabled,buttonVariant:D.buttonVariant,buttonColor:D.buttonColor,showCard:D.showCard,compact:D.compact,classNames:w.card},D.offer.id)};return j?s.jsx(Ce.motion.div,{"data-testid":"offer-card-list",className:A,variants:yr,initial:"hidden",animate:"show",children:s.jsx(Ce.AnimatePresence,{children:$.map(I=>{const D=M(I);return s.jsx(Ce.motion.div,{"data-testid":`offer-card-list-item-${D.offer.id}`,className:w.cardWrapper,variants:vr,exit:{opacity:0,y:-20},transition:{duration:.3},children:s.jsx(yt,{offer:D.offer,quantity:D.quantity,onQuantityChange:v,currency:o,locale:l,labels:d,slots:u,isDisabled:f,buttonVariant:h,buttonColor:y,showCard:m,compact:g||D.offer.compact,classNames:w.card})},D.offer.id)})})}):s.jsx("div",{"data-testid":"offer-card-list",className:A,children:$.map(_)})};jr.displayName="OfferCardList";var ut=e=>e.type==="checkbox",Ve=e=>e instanceof Date,ye=e=>e==null;const wr=e=>typeof e=="object";var fe=e=>!ye(e)&&!Array.isArray(e)&&wr(e)&&!Ve(e),Nr=e=>fe(e)&&e.target?ut(e.target)?e.target.checked:e.target.value:e,xo=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Cr=(e,t)=>e.has(xo(t)),po=e=>{const t=e.constructor&&e.constructor.prototype;return fe(t)&&t.hasOwnProperty("isPrototypeOf")},wn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(wn&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(fe(e)&&po(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=de(e[a]));return r}var At=e=>/^\w*$/.test(e),oe=e=>e===void 0,Nn=e=>Array.isArray(e)?e.filter(Boolean):[],Cn=e=>Nn(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,t,n)=>{if(!t||!fe(e))return n;const r=(At(t)?[t]:Cn(t)).reduce((a,i)=>ye(a)?a:a[i],e);return oe(r)||r===e?oe(e[t])?n:e[t]:r},je=e=>typeof e=="boolean",be=e=>typeof e=="function",ae=(e,t,n)=>{let r=-1;const a=At(t)?[t]:Cn(t),i=a.length,o=i-1;for(;++r<i;){const l=a[r];let d=n;if(r!==o){const u=e[l];d=fe(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=d,e=e[l]}};const vt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ke={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},$e={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},kr=p.createContext(null);kr.displayName="HookFormControlContext";const kn=()=>p.useContext(kr);var Sr=(e,t,n,r=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ke.all&&(t._proxyFormState[o]=!r||ke.all),n&&(n[o]=!0),e[o]}});return a};const Sn=typeof window<"u"?p.useLayoutEffect:p.useEffect;function go(e){const t=kn(),{control:n=t,disabled:r,name:a,exact:i}=e||{},[o,l]=p.useState(n._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Sn(()=>n._subscribe({name:a,formState:d.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[a,r,i]),p.useEffect(()=>{d.current.isValid&&n._setValid(!0)},[n]),p.useMemo(()=>Sr(o,n,d.current,!1),[o,n])}var we=e=>typeof e=="string",an=(e,t,n,r,a)=>we(e)?(r&&t.watch.add(e),z(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),z(n,i))):(r&&(t.watchAll=!0),n),ln=e=>ye(e)||!wr(e);function Se(e,t,n=new WeakSet){if(ln(e)||ln(t))return Object.is(e,t);if(Ve(e)&&Ve(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=t[i];if(Ve(o)&&Ve(l)||fe(o)&&fe(l)||Array.isArray(o)&&Array.isArray(l)?!Se(o,l,n):!Object.is(o,l))return!1}}return!0}function bo(e){const t=kn(),{control:n=t,name:r,defaultValue:a,disabled:i,exact:o,compute:l}=e||{},d=p.useRef(a),u=p.useRef(l),f=p.useRef(void 0),h=p.useRef(n),y=p.useRef(r);u.current=l;const[m,j]=p.useState(()=>{const b=n._getWatch(r,d.current);return u.current?u.current(b):b}),k=p.useCallback(b=>{const v=an(r,n._names,b||n._formValues,!1,d.current);return u.current?u.current(v):v},[n._formValues,n._names,r]),g=p.useCallback(b=>{if(!i){const v=an(r,n._names,b||n._formValues,!1,d.current);if(u.current){const $=u.current(v);Se($,f.current)||(j($),f.current=$)}else j(v)}},[n._formValues,n._names,i,r]);Sn(()=>((h.current!==n||!Se(y.current,r))&&(h.current=n,y.current=r,g()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:b=>{g(b.values)}})),[n,o,r,g]),p.useEffect(()=>n._removeUnmounted());const w=h.current!==n,N=y.current,S=p.useMemo(()=>{if(i)return null;const b=!w&&!Se(N,r);return w||b?k():null},[i,w,r,N,k]);return S!==null?S:m}function yo(e){const t=kn(),{name:n,disabled:r,control:a=t,shouldUnregister:i,defaultValue:o,exact:l=!0}=e,d=Cr(a._names.array,n),u=p.useMemo(()=>z(a._formValues,n,z(a._defaultValues,n,o)),[a,n,o]),f=bo({control:a,name:n,defaultValue:u,exact:l}),h=go({control:a,name:n,exact:l}),y=p.useRef(e),m=p.useRef(void 0),j=p.useRef(a.register(n,{...e.rules,value:f,...je(e.disabled)?{disabled:e.disabled}:{}}));y.current=e;const k=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(h.errors,n)},isDirty:{enumerable:!0,get:()=>!!z(h.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!z(h.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!z(h.validatingFields,n)},error:{enumerable:!0,get:()=>z(h.errors,n)}}),[h,n]),g=p.useCallback(b=>j.current.onChange({target:{value:Nr(b),name:n},type:vt.CHANGE}),[n]),w=p.useCallback(()=>j.current.onBlur({target:{value:z(a._formValues,n),name:n},type:vt.BLUR}),[n,a._formValues]),N=p.useCallback(b=>{const v=z(a._fields,n);v&&v._f&&b&&(v._f.ref={focus:()=>be(b.focus)&&b.focus(),select:()=>be(b.select)&&b.select(),setCustomValidity:$=>be(b.setCustomValidity)&&b.setCustomValidity($),reportValidity:()=>be(b.reportValidity)&&b.reportValidity()})},[a._fields,n]),S=p.useMemo(()=>({name:n,value:f,...je(r)||h.disabled?{disabled:h.disabled||r}:{},onChange:g,onBlur:w,ref:N}),[n,r,h.disabled,g,w,N,f]);return p.useEffect(()=>{const b=a._options.shouldUnregister||i,v=m.current;v&&v!==n&&!d&&a.unregister(v),a.register(n,{...y.current.rules,...je(y.current.disabled)?{disabled:y.current.disabled}:{}});const $=(M,O)=>{const A=z(a._fields,M);A&&A._f&&(A._f.mount=O)};if($(n,!0),b){const M=de(z(a._options.defaultValues,n,y.current.defaultValue));ae(a._defaultValues,n,M),oe(z(a._formValues,n))&&ae(a._formValues,n,M)}return!d&&a.register(n),m.current=n,()=>{(d?b&&!a._state.action:b)?a.unregister(n):$(n,!1)}},[n,a,d,i]),p.useEffect(()=>{a._setDisabledField({disabled:r,name:n})},[r,n,a]),p.useMemo(()=>({field:S,formState:h,fieldState:k}),[S,h,k])}const vo=p.createContext(null);vo.displayName="HookFormContext";var jo=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},it=e=>Array.isArray(e)?e:[e],is=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function Ar(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&fe(a)&&i){const o=Ar(a,i);fe(o)&&(n[r]=o)}else e[r]&&(n[r]=i)}return n}var ge=e=>fe(e)&&!Object.keys(e).length,An=e=>e.type==="file",jt=e=>{if(!wn)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},$r=e=>e.type==="select-multiple",$n=e=>e.type==="radio",wo=e=>$n(e)||ut(e),Vt=e=>jt(e)&&e.isConnected;function No(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=oe(e)?r++:e[t[r++]];return e}function Co(e){for(const t in e)if(e.hasOwnProperty(t)&&!oe(e[t]))return!1;return!0}function ue(e,t){const n=Array.isArray(t)?t:At(t)?[t]:Cn(t),r=n.length===1?e:No(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(fe(r)&&ge(r)||Array.isArray(r)&&Co(r))&&ue(e,n.slice(0,-1)),e}var ko=e=>{for(const t in e)if(be(e[t]))return!0;return!1};function Dr(e){return Array.isArray(e)||fe(e)&&!ko(e)}function on(e,t={}){for(const n in e){const r=e[n];Dr(r)?(t[n]=Array.isArray(r)?[]:{},on(r,t[n])):oe(r)||(t[n]=!0)}return t}function Ke(e,t,n){n||(n=on(t));for(const r in e){const a=e[r];if(Dr(a))oe(t)||ln(n[r])?n[r]=on(a,Array.isArray(a)?[]:{}):Ke(a,ye(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Se(a,i)}}return n}const ls={value:!1,isValid:!1},os={value:!0,isValid:!0};var Er=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!oe(e[0].attributes.value)?oe(e[0].value)||e[0].value===""?os:{value:e[0].value,isValid:!0}:os:ls}return ls},Ir=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>oe(e)?e:t?e===""?NaN:e&&+e:n&&we(e)?new Date(e):r?r(e):e;const cs={isValid:!1,value:null};var Mr=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,cs):cs;function ds(e){const t=e.ref;return An(t)?t.files:$n(t)?Mr(e.refs).value:$r(t)?[...t.selectedOptions].map(({value:n})=>n):ut(t)?Er(e.refs).value:Ir(oe(t.value)?e.ref.value:t.value,e)}var So=(e,t,n,r)=>{const a={};for(const i of e){const o=z(t,i);o&&ae(a,i,o._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},wt=e=>e instanceof RegExp,st=e=>oe(e)?e:wt(e)?e.source:fe(e)?wt(e.value)?e.value.source:e.value:e,us=e=>({isOnSubmit:!e||e===ke.onSubmit,isOnBlur:e===ke.onBlur,isOnChange:e===ke.onChange,isOnAll:e===ke.all,isOnTouch:e===ke.onTouched});const fs="AsyncFunction";var Ao=e=>!!e&&!!e.validate&&!!(be(e.validate)&&e.validate.constructor.name===fs||fe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===fs)),$o=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ms=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const lt=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=z(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(lt(l,t))break}else if(fe(l)&<(l,t))break}}};function hs(e,t,n){const r=z(e,n);if(r||At(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),o=z(t,i),l=z(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:n}}var Do=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return ge(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!r||ke.all))},Eo=(e,t,n)=>!e||!t||e===t||it(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Io=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,Mo=(e,t)=>!Nn(z(e,t)).length&&ue(e,t),Fo=(e,t,n)=>{const r=it(z(e,n));return ae(r,"root",t[n]),ae(e,n,r),e};function xs(e,t,n="validate"){if(we(e)||Array.isArray(e)&&e.every(we)||je(e)&&!e)return{type:n,message:we(e)?e:"",ref:t}}var Ye=e=>fe(e)&&!wt(e)?e:{value:e,message:""},ps=async(e,t,n,r,a,i)=>{const{ref:o,refs:l,required:d,maxLength:u,minLength:f,min:h,max:y,pattern:m,validate:j,name:k,valueAsNumber:g,mount:w}=e._f,N=z(n,k);if(!w||t.has(k))return{};const S=l?l[0]:o,b=D=>{a&&S.reportValidity&&(S.setCustomValidity(je(D)?"":D||""),S.reportValidity())},v={},$=$n(o),M=ut(o),O=$||M,A=(g||An(o))&&oe(o.value)&&oe(N)||jt(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length,_=jo.bind(null,k,r,v),I=(D,F,L,Q=$e.maxLength,U=$e.minLength)=>{const H=D?F:L;v[k]={type:D?Q:U,message:H,ref:o,..._(D?Q:U,H)}};if(i?!Array.isArray(N)||!N.length:d&&(!O&&(A||ye(N))||je(N)&&!N||M&&!Er(l).isValid||$&&!Mr(l).isValid)){const{value:D,message:F}=we(d)?{value:!!d,message:d}:Ye(d);if(D&&(v[k]={type:$e.required,message:F,ref:S,..._($e.required,F)},!r))return b(F),v}if(!A&&(!ye(h)||!ye(y))){let D,F;const L=Ye(y),Q=Ye(h);if(!ye(N)&&!isNaN(N)){const U=o.valueAsNumber||N&&+N;ye(L.value)||(D=U>L.value),ye(Q.value)||(F=U<Q.value)}else{const U=o.valueAsDate||new Date(N),H=se=>new Date(new Date().toDateString()+" "+se),J=o.type=="time",ee=o.type=="week";we(L.value)&&N&&(D=J?H(N)>H(L.value):ee?N>L.value:U>new Date(L.value)),we(Q.value)&&N&&(F=J?H(N)<H(Q.value):ee?N<Q.value:U<new Date(Q.value))}if((D||F)&&(I(!!D,L.message,Q.message,$e.max,$e.min),!r))return b(v[k].message),v}if((u||f)&&!A&&(we(N)||i&&Array.isArray(N))){const D=Ye(u),F=Ye(f),L=!ye(D.value)&&N.length>+D.value,Q=!ye(F.value)&&N.length<+F.value;if((L||Q)&&(I(L,D.message,F.message),!r))return b(v[k].message),v}if(m&&!A&&we(N)){const{value:D,message:F}=Ye(m);if(wt(D)&&!N.match(D)&&(v[k]={type:$e.pattern,message:F,ref:o,..._($e.pattern,F)},!r))return b(F),v}if(j){if(be(j)){const D=await j(N,n),F=xs(D,S);if(F&&(v[k]={...F,..._($e.validate,F.message)},!r))return b(F.message),v}else if(fe(j)){let D={};for(const F in j){if(!ge(D)&&!r)break;const L=xs(await j[F](N,n),S,F);L&&(D={...L,..._(F,L.message)},b(L.message),r&&(v[k]=D))}if(!ge(D)&&(v[k]={ref:S,...D},!r))return v}}return b(!0),v};const To={mode:ke.onSubmit,reValidateMode:ke.onChange,shouldFocusError:!0};function Lo(e={}){let t={...To,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:be(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=fe(t.defaultValues)||fe(t.values)?de(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:de(a),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...f};let y={...h};const m={array:is(),state:is()},j=t.criteriaMode===ke.all,k=x=>C=>{clearTimeout(u),u=setTimeout(x,C)},g=async x=>{if(!o.keepIsValid&&!t.disabled&&(h.isValid||y.isValid||x)){let C;t.resolver?(C=ge((await O()).errors),w()):C=await _(r,!0),C!==n.isValid&&m.state.next({isValid:C})}},w=(x,C)=>{!t.disabled&&(h.isValidating||h.validatingFields||y.isValidating||y.validatingFields)&&((x||Array.from(l.mount)).forEach(E=>{E&&(C?ae(n.validatingFields,E,C):ue(n.validatingFields,E))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ge(n.validatingFields)}))},N=(x,C=[],E,R,P=!0,T=!0)=>{if(R&&E&&!t.disabled){if(o.action=!0,T&&Array.isArray(z(r,x))){const q=E(z(r,x),R.argA,R.argB);P&&ae(r,x,q)}if(T&&Array.isArray(z(n.errors,x))){const q=E(z(n.errors,x),R.argA,R.argB);P&&ae(n.errors,x,q),Mo(n.errors,x)}if((h.touchedFields||y.touchedFields)&&T&&Array.isArray(z(n.touchedFields,x))){const q=E(z(n.touchedFields,x),R.argA,R.argB);P&&ae(n.touchedFields,x,q)}(h.dirtyFields||y.dirtyFields)&&(n.dirtyFields=Ke(a,i)),m.state.next({name:x,isDirty:D(x,C),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ae(i,x,C)},S=(x,C)=>{ae(n.errors,x,C),m.state.next({errors:n.errors})},b=x=>{n.errors=x,m.state.next({errors:n.errors,isValid:!1})},v=(x,C,E,R)=>{const P=z(r,x);if(P){const T=z(i,x,oe(E)?z(a,x):E);oe(T)||R&&R.defaultChecked||C?ae(i,x,C?T:ds(P._f)):Q(x,T),o.mount&&!o.action&&g()}},$=(x,C,E,R,P)=>{let T=!1,q=!1;const te={name:x};if(!t.disabled){if(!E||R){(h.isDirty||y.isDirty)&&(q=n.isDirty,n.isDirty=te.isDirty=D(),T=q!==te.isDirty);const ne=Se(z(a,x),C);q=!!z(n.dirtyFields,x),ne?ue(n.dirtyFields,x):ae(n.dirtyFields,x,!0),te.dirtyFields=n.dirtyFields,T=T||(h.dirtyFields||y.dirtyFields)&&q!==!ne}if(E){const ne=z(n.touchedFields,x);ne||(ae(n.touchedFields,x,E),te.touchedFields=n.touchedFields,T=T||(h.touchedFields||y.touchedFields)&&ne!==E)}T&&P&&m.state.next(te)}return T?te:{}},M=(x,C,E,R)=>{const P=z(n.errors,x),T=(h.isValid||y.isValid)&&je(C)&&n.isValid!==C;if(t.delayError&&E?(d=k(()=>S(x,E)),d(t.delayError)):(clearTimeout(u),d=null,E?ae(n.errors,x,E):ue(n.errors,x)),(E?!Se(P,E):P)||!ge(R)||T){const q={...R,...T&&je(C)?{isValid:C}:{},errors:n.errors,name:x};n={...n,...q},m.state.next(q)}},O=async x=>(w(x,!0),await t.resolver(i,t.context,So(x||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),A=async x=>{const{errors:C}=await O(x);if(w(x),x)for(const E of x){const R=z(C,E);R?ae(n.errors,E,R):ue(n.errors,E)}else n.errors=C;return C},_=async(x,C,E={valid:!0})=>{for(const R in x){const P=x[R];if(P){const{_f:T,...q}=P;if(T){const te=l.array.has(T.name),ne=P._f&&Ao(P._f);ne&&h.validatingFields&&w([T.name],!0);const pe=await ps(P,l.disabled,i,j,t.shouldUseNativeValidation&&!C,te);if(ne&&h.validatingFields&&w([T.name]),pe[T.name]&&(E.valid=!1,C||e.shouldUseNativeValidation))break;!C&&(z(pe,T.name)?te?Fo(n.errors,pe,T.name):ae(n.errors,T.name,pe[T.name]):ue(n.errors,T.name))}!ge(q)&&await _(q,C,E)}}return E.valid},I=()=>{for(const x of l.unMount){const C=z(r,x);C&&(C._f.refs?C._f.refs.every(E=>!Vt(E)):!Vt(C._f.ref))&&ve(x)}l.unMount=new Set},D=(x,C)=>!t.disabled&&(x&&C&&ae(i,x,C),!Se(Y(),a)),F=(x,C,E)=>an(x,l,{...o.mount?i:oe(C)?a:we(x)?{[x]:C}:C},E,C),L=x=>Nn(z(o.mount?i:a,x,t.shouldUnregister?z(a,x,[]):[])),Q=(x,C,E={})=>{const R=z(r,x);let P=C;if(R){const T=R._f;T&&(!T.disabled&&ae(i,x,Ir(C,T)),P=jt(T.ref)&&ye(C)?"":C,$r(T.ref)?[...T.ref.options].forEach(q=>q.selected=P.includes(q.value)):T.refs?ut(T.ref)?T.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(P)?q.checked=!!P.find(te=>te===q.value):q.checked=P===q.value||!!P)}):T.refs.forEach(q=>q.checked=q.value===P):An(T.ref)?T.ref.value="":(T.ref.value=P,T.ref.type||m.state.next({name:x,values:de(i)})))}(E.shouldDirty||E.shouldTouch)&&$(x,P,E.shouldTouch,E.shouldDirty,!0),E.shouldValidate&&se(x)},U=(x,C,E)=>{for(const R in C){if(!C.hasOwnProperty(R))return;const P=C[R],T=x+"."+R,q=z(r,T);(l.array.has(x)||fe(P)||q&&!q._f)&&!Ve(P)?U(T,P,E):Q(T,P,E)}},H=(x,C,E={})=>{const R=z(r,x),P=l.array.has(x),T=de(C);ae(i,x,T),P?(m.array.next({name:x,values:de(i)}),(h.isDirty||h.dirtyFields||y.isDirty||y.dirtyFields)&&E.shouldDirty&&m.state.next({name:x,dirtyFields:Ke(a,i),isDirty:D(x,T)})):R&&!R._f&&!ye(T)?U(x,T,E):Q(x,T,E),ms(x,l)?m.state.next({...n,name:x,values:de(i)}):m.state.next({name:o.mount?x:void 0,values:de(i)})},J=async x=>{o.mount=!0;const C=x.target;let E=C.name,R=!0;const P=z(r,E),T=ne=>{R=Number.isNaN(ne)||Ve(ne)&&isNaN(ne.getTime())||Se(ne,z(i,E,ne))},q=us(t.mode),te=us(t.reValidateMode);if(P){let ne,pe;const ze=C.type?ds(P._f):Nr(x),Fe=x.type===vt.BLUR||x.type===vt.FOCUS_OUT,Ca=!$o(P._f)&&!t.resolver&&!z(n.errors,E)&&!P._f.deps||Io(Fe,z(n.touchedFields,E),n.isSubmitted,te,q),Et=ms(E,l,Fe);ae(i,E,ze),Fe?(!C||!C.readOnly)&&(P._f.onBlur&&P._f.onBlur(x),d&&d(0)):P._f.onChange&&P._f.onChange(x);const It=$(E,ze,Fe),ka=!ge(It)||Et;if(!Fe&&m.state.next({name:E,type:x.type,values:de(i)}),Ca)return(h.isValid||y.isValid)&&(t.mode==="onBlur"?Fe&&g():Fe||g()),ka&&m.state.next({name:E,...Et?{}:It});if(!Fe&&Et&&m.state.next({...n}),t.resolver){const{errors:On}=await O([E]);if(w([E]),T(ze),R){const Sa=hs(n.errors,r,E),Pn=hs(On,r,Sa.name||E);ne=Pn.error,E=Pn.name,pe=ge(On)}}else w([E],!0),ne=(await ps(P,l.disabled,i,j,t.shouldUseNativeValidation))[E],w([E]),T(ze),R&&(ne?pe=!1:(h.isValid||y.isValid)&&(pe=await _(r,!0)));R&&(P._f.deps&&(!Array.isArray(P._f.deps)||P._f.deps.length>0)&&se(P._f.deps),M(E,pe,ne,It))}},ee=(x,C)=>{if(z(n.errors,C)&&x.focus)return x.focus(),1},se=async(x,C={})=>{let E,R;const P=it(x);if(t.resolver){const T=await A(oe(x)?x:P);E=ge(T),R=x?!P.some(q=>z(T,q)):E}else x?(R=(await Promise.all(P.map(async T=>{const q=z(r,T);return await _(q&&q._f?{[T]:q}:q)}))).every(Boolean),!(!R&&!n.isValid)&&g()):R=E=await _(r);return m.state.next({...!we(x)||(h.isValid||y.isValid)&&E!==n.isValid?{}:{name:x},...t.resolver||!x?{isValid:E}:{},errors:n.errors}),C.shouldFocus&&!R&<(r,ee,x?P:l.mount),R},Y=(x,C)=>{let E={...o.mount?i:a};return C&&(E=Ar(C.dirtyFields?n.dirtyFields:n.touchedFields,E)),oe(x)?E:we(x)?z(E,x):x.map(R=>z(E,R))},B=(x,C)=>({invalid:!!z((C||n).errors,x),isDirty:!!z((C||n).dirtyFields,x),error:z((C||n).errors,x),isValidating:!!z(n.validatingFields,x),isTouched:!!z((C||n).touchedFields,x)}),G=x=>{x&&it(x).forEach(C=>ue(n.errors,C)),m.state.next({errors:x?n.errors:{}})},Z=(x,C,E)=>{const R=(z(r,x,{_f:{}})._f||{}).ref,P=z(n.errors,x)||{},{ref:T,message:q,type:te,...ne}=P;ae(n.errors,x,{...ne,...C,ref:R}),m.state.next({name:x,errors:n.errors,isValid:!1}),E&&E.shouldFocus&&R&&R.focus&&R.focus()},ie=(x,C)=>be(x)?m.state.subscribe({next:E=>"values"in E&&x(F(void 0,C),E)}):F(x,C,!0),re=x=>m.state.subscribe({next:C=>{Eo(x.name,C.name,x.exact)&&Do(C,x.formState||h,qe,x.reRenderRoot)&&x.callback({values:{...i},...n,...C,defaultValues:a})}}).unsubscribe,Ne=x=>(o.mount=!0,y={...y,...x.formState},re({...x,formState:{...f,...x.formState}})),ve=(x,C={})=>{for(const E of x?it(x):l.mount)l.mount.delete(E),l.array.delete(E),C.keepValue||(ue(r,E),ue(i,E)),!C.keepError&&ue(n.errors,E),!C.keepDirty&&ue(n.dirtyFields,E),!C.keepTouched&&ue(n.touchedFields,E),!C.keepIsValidating&&ue(n.validatingFields,E),!t.shouldUnregister&&!C.keepDefaultValue&&ue(a,E);m.state.next({values:de(i)}),m.state.next({...n,...C.keepDirty?{isDirty:D()}:{}}),!C.keepIsValid&&g()},xe=({disabled:x,name:C})=>{if(je(x)&&o.mount||x||l.disabled.has(C)){const P=l.disabled.has(C)!==!!x;x?l.disabled.add(C):l.disabled.delete(C),P&&o.mount&&!o.action&&g()}},Ee=(x,C={})=>{let E=z(r,x);const R=je(C.disabled)||je(t.disabled);return ae(r,x,{...E||{},_f:{...E&&E._f?E._f:{ref:{name:x}},name:x,mount:!0,...C}}),l.mount.add(x),E?xe({disabled:je(C.disabled)?C.disabled:t.disabled,name:x}):v(x,!0,C.value),{...R?{disabled:C.disabled||t.disabled}:{},...t.progressive?{required:!!C.required,min:st(C.min),max:st(C.max),minLength:st(C.minLength),maxLength:st(C.maxLength),pattern:st(C.pattern)}:{},name:x,onChange:J,onBlur:J,ref:P=>{if(P){Ee(x,C),E=z(r,x);const T=oe(P.value)&&P.querySelectorAll&&P.querySelectorAll("input,select,textarea")[0]||P,q=wo(T),te=E._f.refs||[];if(q?te.find(ne=>ne===T):T===E._f.ref)return;ae(r,x,{_f:{...E._f,...q?{refs:[...te.filter(Vt),T,...Array.isArray(z(a,x))?[{}]:[]],ref:{type:T.type,name:x}}:{ref:T}}}),v(x,!1,void 0,T)}else E=z(r,x,{}),E._f&&(E._f.mount=!1),(t.shouldUnregister||C.shouldUnregister)&&!(Cr(l.array,x)&&o.action)&&l.unMount.add(x)}}},Ie=()=>t.shouldFocusError&<(r,ee,l.mount),He=x=>{je(x)&&(m.state.next({disabled:x}),lt(r,(C,E)=>{const R=z(r,E);R&&(C.disabled=R._f.disabled||x,Array.isArray(R._f.refs)&&R._f.refs.forEach(P=>{P.disabled=R._f.disabled||x}))},0,!1))},Me=(x,C)=>async E=>{let R;E&&(E.preventDefault&&E.preventDefault(),E.persist&&E.persist());let P=de(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:T,values:q}=await O();w(),n.errors=T,P=de(q)}else await _(r);if(l.disabled.size)for(const T of l.disabled)ue(P,T);if(ue(n.errors,"root"),ge(n.errors)){m.state.next({errors:{}});try{await x(P,E)}catch(T){R=T}}else C&&await C({...n.errors},E),Ie(),setTimeout(Ie);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ge(n.errors)&&!R,submitCount:n.submitCount+1,errors:n.errors}),R)throw R},_e=(x,C={})=>{z(r,x)&&(oe(C.defaultValue)?H(x,de(z(a,x))):(H(x,C.defaultValue),ae(a,x,de(C.defaultValue))),C.keepTouched||ue(n.touchedFields,x),C.keepDirty||(ue(n.dirtyFields,x),n.isDirty=C.defaultValue?D(x,de(z(a,x))):D()),C.keepError||(ue(n.errors,x),h.isValid&&g()),m.state.next({...n}))},Ae=(x,C={})=>{const E=x?de(x):a,R=de(E),P=ge(x),T=P?a:R;if(C.keepDefaultValues||(a=E),!C.keepValues){if(C.keepDirtyValues){const q=new Set([...l.mount,...Object.keys(Ke(a,i))]);for(const te of Array.from(q)){const ne=z(n.dirtyFields,te),pe=z(i,te),ze=z(T,te);ne&&!oe(pe)?ae(T,te,pe):!ne&&!oe(ze)&&H(te,ze)}}else{if(wn&&oe(x))for(const q of l.mount){const te=z(r,q);if(te&&te._f){const ne=Array.isArray(te._f.refs)?te._f.refs[0]:te._f.ref;if(jt(ne)){const pe=ne.closest("form");if(pe){pe.reset();break}}}}if(C.keepFieldsRef)for(const q of l.mount)H(q,z(T,q));else r={}}i=t.shouldUnregister?C.keepDefaultValues?de(a):{}:de(T),m.array.next({values:{...T}}),m.state.next({values:{...T}})}l={mount:C.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!h.isValid||!!C.keepIsValid||!!C.keepDirtyValues||!t.shouldUnregister&&!ge(T),o.watch=!!t.shouldUnregister,o.keepIsValid=!!C.keepIsValid,o.action=!1,C.keepErrors||(n.errors={}),m.state.next({submitCount:C.keepSubmitCount?n.submitCount:0,isDirty:P?!1:C.keepDirty?n.isDirty:!!(C.keepDefaultValues&&!Se(x,a)),isSubmitted:C.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:P?{}:C.keepDirtyValues?C.keepDefaultValues&&i?Ke(a,i):n.dirtyFields:C.keepDefaultValues&&x?Ke(a,x):C.keepDirty?n.dirtyFields:{},touchedFields:C.keepTouched?n.touchedFields:{},errors:C.keepErrors?n.errors:{},isSubmitSuccessful:C.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},X=(x,C)=>Ae(be(x)?x(i):x,{...t.resetOptions,...C}),me=(x,C={})=>{const E=z(r,x),R=E&&E._f;if(R){const P=R.refs?R.refs[0]:R.ref;P.focus&&setTimeout(()=>{P.focus(),C.shouldSelect&&be(P.select)&&P.select()})}},qe=x=>{n={...n,...x}},Xe={control:{register:Ee,unregister:ve,getFieldState:B,handleSubmit:Me,setError:Z,_subscribe:re,_runSchema:O,_updateIsValidating:w,_focusError:Ie,_getWatch:F,_getDirty:D,_setValid:g,_setFieldArray:N,_setDisabledField:xe,_setErrors:b,_getFieldArray:L,_reset:Ae,_resetDefaultValues:()=>be(t.defaultValues)&&t.defaultValues().then(x=>{X(x,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:I,_disableForm:He,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(x){o=x},get _defaultValues(){return a},get _names(){return l},set _names(x){l=x},get _formState(){return n},get _options(){return t},set _options(x){t={...t,...x}}},subscribe:Ne,trigger:se,register:Ee,handleSubmit:Me,watch:ie,setValue:H,getValues:Y,reset:X,resetField:_e,clearErrors:G,unregister:ve,setError:Z,setFocus:me,getFieldState:B};return{...Xe,formControl:Xe}}function Oo(e={}){const t=p.useRef(void 0),n=p.useRef(void 0),[r,a]=p.useState({isDirty:!1,isValidating:!1,isLoading:be(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:be(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!be(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=Lo(e);t.current={...l,formState:r}}const i=t.current.control;return i._options=e,Sn(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),p.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),p.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),p.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),p.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),p.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),p.useEffect(()=>{var o;e.values&&!Se(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=e.values,a(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),p.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=p.useMemo(()=>Sr(r,i),[i,r]),t.current}function Po(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function _o(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function zo(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Ro(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const a=parseFloat(r);return isNaN(a)?null:a}function Bo(e,t,n=.001){const r=e-t,a=Math.abs(r)<=n;return{difference:r,isBalanced:a,isUnderAllocated:!a&&r>0,isOverAllocated:!a&&r<0}}function Dn(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Dn();const Vo={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Ut=()=>({id:Dn(),amount:0,glAccount:null,isTaxDeductible:!1}),Fr=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:a,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:h=!0,isDisabled:y=!1,labels:m,classNames:j={},"data-testid":k,control:g,name:w,rules:N})=>{const S={...Vo,...m},b=g!==void 0&&w!==void 0,v=Oo({defaultValues:{_internal:t||Ut()}}),$=yo({control:b?g:v.control,name:b?w:"_internal",rules:b?N:void 0}),[M,O]=p.useState(t||Ut()),A=b?$.field.value??Ut():e??M,_=b&&!!$.fieldState?.error,I=b&&($.fieldState?.isTouched??!1),D=_||I,F=D&&(!A.amount||A.amount<=0),L=D&&!A.glAccount,[Q,U]=p.useState(A.glAccount?.name||""),H=p.useCallback(Z=>{const ie={...A,...Z};b&&$.field.onChange(ie),!b&&e===void 0&&O(ie),i?.(ie)},[A,e,i,b,$]),J=p.useCallback(Z=>{const ie=Z||0;H({amount:ie}),o?.(ie)},[H,o]),ee=p.useCallback(Z=>{U(Z),a?.(Z)},[a]),se=p.useCallback(Z=>{if(Z===null){H({glAccount:null}),l?.(null);return}const re=n.find(Ne=>String(Ne.id)===String(Z))||null;H({glAccount:re}),l?.(re)},[n,H,l]),Y=p.useCallback(()=>{U(""),H({glAccount:null}),l?.(null)},[H,l]),B=p.useCallback(Z=>{H({isTaxDeductible:Z}),d?.(Z)},[H,d]),G=p.useCallback(()=>{u?.()},[u]);return s.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":k||"revenue-distribution-card",className:c.cn(j.base),children:s.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",j.body),children:[s.jsx("div",{className:c.cn("shrink-0",j.amountContainer),children:s.jsx(c.NumberInput,{"data-testid":`${k||"revenue-distribution-card"}-amount-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[S.amount,s.jsx(c.Tooltip,{content:S.amountTooltip,children:s.jsx(V,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:A.amount||void 0,onValueChange:J,labelPlacement:"outside",placeholder:S.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:y,isInvalid:F,errorMessage:F?"Amount is required":void 0,minValue:0,step:.01,className:j.amountInput,startContent:s.jsx("div",{className:"pointer-events-none flex items-center",children:s.jsx("span",{className:"text-default-400 text-small",children:S.currencySymbol})})})}),s.jsx("div",{className:c.cn("grow",j.glAccountContainer),children:s.jsx(c.Autocomplete,{"data-testid":`${k||"revenue-distribution-card"}-gl-account-input`,label:s.jsxs("span",{className:"flex items-center gap-1",children:[S.glAccount,s.jsx(c.Tooltip,{content:S.glAccountTooltip,children:s.jsx(V,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:A.glAccount?.name??Q,selectedKey:A.glAccount?.id??null,isDisabled:y,isInvalid:L,errorMessage:L?"GL Account is required":void 0,listboxProps:{emptyContent:r?S.searching:S.noGlAccountsFound},placeholder:S.glAccountPlaceholder,onInputChange:ee,onSelectionChange:se,onClear:Y,className:j.glAccountInput,children:Z=>s.jsx(c.AutocompleteItem,{textValue:Z.name,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:Z.name}),Z.code&&s.jsx("span",{className:"text-xs text-default-400",children:Z.code})]})},Z.id)})}),s.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",j.taxDeductibleContainer),children:s.jsx(c.Checkbox,{radius:"full","data-testid":`${k||"revenue-distribution-card"}-tax-deductible`,isSelected:A.isTaxDeductible,onValueChange:B,isDisabled:y||!h,className:j.taxDeductibleCheckbox,children:S.taxDeductible})}),s.jsx("div",{className:c.cn("shrink-0 pt-6",j.deleteContainer),children:s.jsx(W,{"data-testid":`${k||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:y||!f,onPress:G,startContent:s.jsx(V,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",j.deleteButton),children:S.deleteButton})})]})})};Fr.displayName="RevenueDistributionCard";const Tr=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:a={},renderEmpty:i})=>{if(i)return s.jsx(s.Fragment,{children:i()});const o=s.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",a.content),children:[s.jsx(V,{icon:t,width:n,className:c.cn("text-default-300 mb-4",a.icon)}),s.jsx("p",{className:c.cn("text-default-500 text-sm text-center",a.message),children:e})]});return r?s.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{children:o})}):s.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",a.base),children:o})};Tr.displayName="RevenueDistributionEmpty";const Uo={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Lr=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:a={}})=>{const i={...Uo,...t},o=s.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:a.alert});return n?s.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",a.base),children:s.jsx(c.CardBody,{children:o})}):s.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",a.base),children:o})};Lr.displayName="RevenueDistributionError";const Or=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,o)=>o),a=i=>s.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[s.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),s.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),s.jsxs("div",{className:"grow flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),s.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),s.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),s.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[s.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),s.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),s.jsx("div",{className:"shrink-0 pb-2",children:s.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?s.jsx("div",{className:c.cn("flex flex-col gap-3",n.base),children:r.map(i=>s.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:s.jsx(c.CardBody,{children:a(i)})},i))}):s.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",n.base),children:r.map(i=>a(i))})};Or.displayName="RevenueDistributionSkeleton";function $t({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:a="danger",iconTone:i="danger",portalContainer:o,shouldBlockScroll:l,classNames:d,onClose:u,onConfirm:f}){return s.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:o,shouldBlockScroll:l,classNames:{...d,base:c.cn("max-w-[440px] rounded-3xl",d?.base),closeButton:c.cn("right-5 top-5 text-zinc-500",d?.closeButton)},onOpenChange:h=>!h&&u(),children:s.jsxs(c.ModalContent,{children:[s.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&s.jsx("span",{className:c.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),s.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),s.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:s.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),s.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[s.jsx(W,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:u,children:t.cancel}),s.jsx(W,{type:"button",size:"md",color:a,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",a==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:f,children:t.confirm})]})]})})}const Ho=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function cn(e){return!e.fund&&Number(e.percentage||0)<=0}function qo({mode:e,assignments:t}){const n=t.filter(o=>!cn(o)),r=n.filter(o=>o.fund),a=r.reduce((o,l)=>o+Number(l.percentage||0),0),i=n.some(o=>!o.fund||Number(o.percentage||0)<=0);return r.length>=1&&!i&&Math.round(a*100)/100===100}const Wo={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select a fund and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Select a fund for each row and enter percentages that total 100%.",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},Pr={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},rt={...Pr,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},Yo={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Go={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function Ko(){return s.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[s.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),s.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const Qo=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,Zo=e=>e.fund!==null;function Jo({assignments:e,funds:t,labels:n,classNames:r,isSaving:a=!1,hasSavedAssignments:i=!1,isFundPickerOpen:o=!1,activeAssignmentId:l=null,footer:d,onAssignmentsChange:u,onOpenFundPicker:f,onCloseFundPicker:h,onCollapseChange:y,onSave:m}){const[j,k]=p.useState(null),g={...Wo,...n},w=e.filter(B=>!cn(B)),S=w.filter(Zo).length>0,b=p.useMemo(()=>e.filter(B=>!cn(B)).reduce((B,G)=>B+Number(G.percentage||0),0),[e]),v=Math.round(b*100)/100,$=w.some(B=>!B.fund||Number(B.percentage||0)<=0),M=S&&(v!==100||$),O=`${g.totalError} (${g.total} ${Number(b.toFixed(2))}%)`,A=qo({mode:"split",assignments:e}),_=S&&v>=100,[I,D]=p.useState(!1),[F,L]=p.useState(!1),Q=s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Ko,{}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:g.title})]}),U=(B,G)=>{u(e.map(Z=>Z.id===B?{...Z,...G}:Z))},H=()=>{_||u([...e,Ho()])},J=B=>{e.length<=1||u(e.filter(G=>G.id!==B))},ee=()=>{if(!a){if(!A){L(!0);return}if(!i){m();return}D(!0)}},se=()=>{D(!1),m()},Y=B=>{const G=l??e.find(Z=>!Z.fund)?.id??e[0]?.id;G&&(u(e.map(Z=>Z.id===G?{...Z,fund:B}:Z)),h())};return s.jsxs("div",{ref:k,className:c.cn("vvt-pa relative font-sans text-zinc-900",o&&"min-h-[560px]",r?.root),children:[s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:c.cn("w-full gap-0 px-0",r?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",r?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:B=>y?.(!(B==="all"||Array.from(B).length>0)),children:s.jsx(c.AccordionItem,{"aria-label":g.title,title:Q,children:s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",r?.content),children:[s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&s.jsx(c.Alert,{icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Pr,color:"default",variant:"flat",title:g.emptySplit}),S&&s.jsx(Xo,{assignments:e,labels:g,total:b,hasTotalError:F&&!A||M,validationMessage:O,onSelectFund:B=>f(B),onRemoveFund:J,onPercentageChange:(B,G)=>U(B,{percentage:Qo(G)})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx(W,{type:"button",size:"lg",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-lg font-normal text-white disabled:opacity-50",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),isDisabled:_,onPress:()=>S?H():f(),children:g.assignSpecificFund}),s.jsx(W,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto h-10 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:a?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:a,onPress:ee,children:g.saveAssignment})]})]}),d]})},"installment-fund-assignment")}),o&&s.jsx(ec,{funds:t,labels:g,selectedFundIds:e.map(B=>B.fund?.id).filter(Boolean),portalContainer:j??void 0,onSelect:Y,onClose:h}),s.jsx($t,{isOpen:I,labels:{title:g.modifyAssignedFundsTitle,description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:g.modifyAssignedFundsDescription}),s.jsx("p",{className:"mt-3",children:g.modifyAssignedFundsWarning})]}),cancel:g.modifyAssignedFundsCancel,confirm:g.modifyAssignedFundsConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:j??void 0,shouldBlockScroll:!1,classNames:Go,onClose:()=>D(!1),onConfirm:se})]})}function Xo({assignments:e,labels:t,total:n,hasTotalError:r,validationMessage:a,onSelectFund:i,onRemoveFund:o,onPercentageChange:l}){return s.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>s.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[s.jsx("div",{className:c.cn("flex min-h-11 min-w-0 flex-1 items-center","gap-4"),children:d.fund?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[d.fund.glCode," - ",d.fund.accountName]}),s.jsx(W,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(d.id),children:"Replace"})]}):s.jsx(W,{type:"button",size:"lg",variant:"light",radius:"full",className:"justify-start px-4 text-lg font-normal text-zinc-900",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:t.assignSpecificFund})}),s.jsx("label",{className:"flex w-48 flex-none items-center",children:s.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>l(d.id,Number(f.target.value)),endContent:s.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:Yo})}),e.length>1&&s.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:c.cn("h-10 w-10 flex-none p-0",u===0?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:u===0,onPress:()=>o(d.id),"aria-label":t.removeFund,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),s.jsx(c.Alert,{icon:s.jsx(V,{icon:r?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:r?"warning":"success",variant:"flat",classNames:{...rt,base:c.cn(rt.base,r?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(rt.iconWrapper,r?"text-warning-700":"text-success-700"),alertIcon:c.cn(rt.alertIcon,r?"text-warning-700":"text-success-700"),title:c.cn(rt.title,r?"text-warning-700":"text-success-700")},title:r?a:`${t.total} ${Number(n.toFixed(2))}%`})]})}function ec({funds:e,labels:t,selectedFundIds:n,portalContainer:r,onSelect:a,onClose:i}){const[o,l]=p.useState(""),d=e.filter(u=>{if(n.includes(u.id))return!1;const f=o.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return s.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:r,classNames:{wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl",base:"max-h-[calc(100%-2rem)] max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:u=>!u&&i(),children:s.jsxs(c.ModalContent,{className:"max-h-full",children:[s.jsx(c.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),s.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[s.jsx(c.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:o,placeholder:t.searchPlaceholder,onChange:u=>l(u.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),s.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[s.jsx("span",{children:t.glCode}),s.jsx("span",{children:t.accountName}),s.jsx("span",{children:t.actions})]}),d.length===0&&s.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),d.map(u=>s.jsxs("div",{className:"grid grid-cols-[1fr_1.3fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[s.jsx("span",{children:u.glCode}),s.jsx("span",{children:u.accountName}),s.jsx(W,{type:"button",size:"sm",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",onPress:()=>a(u),children:t.select})]},u.id))]})]})]})})}function tc(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),s.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const nc={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function sc({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:a="en-US",labels:i,className:o}){const l={...nc,...i},d=new Intl.NumberFormat(a,{style:"currency",currency:r});return s.jsx("div",{className:c.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",o),children:s.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[s.jsx(Ht,{label:l.totalAmount,value:d.format(e)}),s.jsx(Ht,{label:l.remainingBalance,value:d.format(t)}),s.jsx(Ht,{label:l.amountReceived,value:d.format(n)})]})})}function Ht({label:e,value:t}){return s.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[s.jsx("span",{className:"font-medium text-zinc-700",children:e}),s.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}const rc={monthly:1,quarterly:3,annual:12},_r=e=>{const[t,n,r]=e.split("-").map(Number);return{year:t,month:n,day:r}},ac=(e,t)=>new Date(e,t+1,0).getDate(),ic=e=>{const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`},lc=(e,t)=>{const{year:n,month:r,day:a}=_r(e),i=r-1+t,o=n+Math.floor(i/12),l=(i%12+12)%12,d=Math.min(a,ac(o,l));return new Date(o,l,d)},oc=(e,t)=>{const{year:n,month:r,day:a}=_r(e),i=new Date(n,r-1,a);return i.setDate(i.getDate()+t),i};function zr(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.round(e*100),a=Math.floor(r/n),i=r-a*n,o=rc[t.frequency];return Array.from({length:n},(l,d)=>{const u=t.frequency==="weekly"?oc(t.firstInstallmentDate,d*7):lc(t.firstInstallmentDate,d*(o??1));return{id:crypto.randomUUID(),dueDate:ic(u),amount:(a+(d===0?i:0))/100}})}function cc(e){return new Set(e.map((t,n)=>{const r=e[n+1]?.dueDate;return t.dueDate&&r&&t.dueDate>r?t.id:null}).filter(t=>!!t))}const dc={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",dayOfMonth:"Day of month",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",weekly:"Weekly",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total cannot exceed donation amount",totalIncreaseWarning:"Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationTitle:"Update Donation Total",totalIncreaseConfirmationDescription:"The scheduled payments total is greater than the current donation/contribution total. Saving will update the donation/contribution total to match the scheduled payments.",totalIncreaseConfirmationCancel:"Cancel",totalIncreaseConfirmationConfirm:"Save Payments",dateOrderError:"Payment date must be on or before the next payment date.",amountGreaterThanZeroError:"Payment amount must be greater than 0."},uc=["weekly","monthly","quarterly","annual"],fc=Array.from({length:31},(e,t)=>t+1),mc=["numberOfInstallments","frequency","firstInstallmentDate"],hc={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},gs=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Rr=e=>Math.round(e*100)/100,xc=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},Dt=e=>{if(!e)return null;try{return di(e)}catch{return null}},pc=e=>Dt(e)?.day??1,gc=(e,t)=>new Date(e,t,0).getDate(),bc=(e,t)=>{const n=Dt(e);if(!n)return e;const r=Math.min(t,gc(n.year,n.month));return n.set({day:r}).toString()},bs=e=>{const t=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${t}`};function yc({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:a,automaticSettings:i,defaultTab:o="automatic",showTitle:l=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:h=mc,startDate:y,labels:m,classNames:j,isSaving:k=!1,isModeSwitchDisabled:g=!1,onModeChange:w,onAutomaticSettingsChange:N,onInstallmentsChange:S,onSave:b}){const[v,$]=p.useState(null),[M,O]=p.useState(o),A={...dc,...m},_=e??M,I=p.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),D=p.useMemo(()=>({...i,firstInstallmentDate:h.includes("firstInstallmentDate")?i.firstInstallmentDate:h.includes("dayOfMonth")?i.firstInstallmentDate||y||"":y||i.firstInstallmentDate}),[i,h,y]),F=_==="automatic"?zr(t,D):a,L=p.useMemo(()=>Rr(F.reduce((re,Ne)=>re+Number(Ne.amount||0),0)),[F]),Q=_==="manual"&&L-t>.009,[U,H]=p.useState(!1),J=l?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:A.title})]}):void 0,ee=re=>{re!==_&&(e||O(re),w?.(re),re==="manual"&&a.length===0&&S([gs()]))},se=(re,Ne)=>{a.find(xe=>xe.id===re)?.status!=="paid"&&S(a.map(xe=>xe.id===re?{...xe,...Ne}:xe))},Y=()=>{S([...a,gs()])},B=re=>{a.find(ve=>ve.id===re)?.status!=="paid"&&S(a.filter(ve=>ve.id!==re))},G=()=>{if(!k){if(Q){H(!0);return}b?.()}},Z=()=>{H(!1),b?.()},ie=s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.content),children:[f||u?s.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?s.jsx(vc,{mode:_,labels:A,onModeChange:ee,isDisabled:g,className:j?.tabs}):null,u?s.jsx(W,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto min-w-36",startContent:k?void 0:s.jsx(V,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:k,onPress:G,children:A.saveInstallments}):null]}):null,s.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",j?.preview),children:[_==="automatic"&&s.jsx(jc,{settings:D,inputs:h,labels:A,className:j?.controls,onSettingsChange:N}),F.length===0&&s.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:_==="automatic"?A.emptyAutomatic:A.emptyManual}),F.length>0&&s.jsx(wc,{mode:_,installments:F,labels:A,formatter:I,locale:r,onUpdateInstallment:se,onRemoveInstallment:B}),_==="manual"&&s.jsx("div",{className:"flex flex-wrap gap-3",children:s.jsx(W,{type:"button",size:"md",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(K.Plus,{className:"size-5",strokeWidth:2}),onPress:Y,children:A.addInstallment})}),s.jsx(Cc,{total:L,donationAmount:t,hasTotalIncreaseWarning:Q,mode:_,installments:F,formatter:I,labels:A,className:j?.summary})]})]});return s.jsxs("div",{ref:$,className:c.cn("vvt-ps relative font-sans text-zinc-900",j?.root),children:[d?s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",j?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",j?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:s.jsx(c.AccordionItem,{"aria-label":A.title,title:J,children:ie},"installment-schedule")}):ie,s.jsx($t,{isOpen:U,labels:{title:A.totalIncreaseConfirmationTitle,description:A.totalIncreaseConfirmationDescription,cancel:A.totalIncreaseConfirmationCancel,confirm:A.totalIncreaseConfirmationConfirm},icon:s.jsx(V,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",isConfirming:k,portalContainer:v??void 0,shouldBlockScroll:!1,classNames:hc,onClose:()=>H(!1),onConfirm:Z})]})}function vc({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:a}){return s.jsxs(c.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",n),onSelectionChange:i=>a(i),children:[s.jsx(c.Tab,{title:t.automaticMode},"automatic"),s.jsx(c.Tab,{title:t.manualMode},"manual")]})}function jc({settings:e,inputs:t,labels:n,className:r,onSettingsChange:a}){const i=o=>{if(o==="numberOfInstallments")return s.jsx("div",{className:"min-w-0",children:s.jsx(c.Input,{variant:"bordered",label:n.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:l=>l.currentTarget.blur(),onChange:l=>{const d=l.target.value;a({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},o);if(o==="frequency")return s.jsx("div",{className:"min-w-0",children:s.jsx(Oe,{variant:"bordered",label:n.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:l=>{const d=Array.from(l)[0];typeof d=="string"&&a({...e,frequency:d})},children:uc.map(l=>s.jsx(c.SelectItem,{textValue:n[l],children:n[l]},l))})},o);if(o==="dayOfMonth"){const l=String(pc(e.firstInstallmentDate));return s.jsx("div",{className:"min-w-0",children:s.jsx(Oe,{variant:"bordered",label:n.dayOfMonth,labelPlacement:"outside",selectedKeys:[l],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&a({...e,firstInstallmentDate:bc(e.firstInstallmentDate,u)})},children:fc.map(d=>s.jsx(c.SelectItem,{textValue:bs(d),children:bs(d)},String(d)))})},o)}return s.jsx("div",{className:"min-w-0",children:s.jsx(xn,{variant:"bordered",label:n.firstInstallmentDate,labelPlacement:"outside",value:Dt(e.firstInstallmentDate),onChange:l=>a({...e,firstInstallmentDate:l?l.toString():""}),startContent:s.jsx(V,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},o)};return t.length===0?null:s.jsx("div",{className:c.cn("grid gap-4",r),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:t.map(i)})}function wc({mode:e,installments:t,labels:n,formatter:r,locale:a,onUpdateInstallment:i,onRemoveInstallment:o}){const l=cc(t),d=new Set(t.map(u=>Number(u.amount||0)<=0?u.id:null).filter(u=>!!u));return e==="automatic"?s.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:s.jsx("div",{className:c.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((u,f)=>s.jsxs("div",{className:c.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",f===0&&"border border-primary/25 bg-primary/5 text-primary"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{children:["#",f+1]}),s.jsx("span",{children:"▪"}),s.jsx("span",{children:xc(u.dueDate,a)}),f===0&&t.length>1&&s.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),s.jsx("span",{className:"text-zinc-950",children:r.format(u.amount)})]},u.id))})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.map((u,f)=>{const h=l.has(u.id),y=d.has(u.id);return s.jsx("div",{className:"flex w-full flex-col gap-1",children:s.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[s.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:f+1}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(xn,{variant:"bordered","aria-label":`${n.dueDate} ${f+1}`,isDisabled:u.status==="paid",isInvalid:h,errorMessage:h?n.dateOrderError:void 0,value:Dt(u.dueDate),onChange:m=>i(u.id,{dueDate:m?m.toString():""})})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(c.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:u.status==="paid",isInvalid:y,errorMessage:y?n.amountGreaterThanZeroError:void 0,value:String(u.amount||""),onChange:m=>i(u.id,{amount:Rr(Number(m.target.value||0))}),startContent:s.jsx("span",{className:"text-zinc-900",children:"$"})})}),s.jsx(Nc,{isDisabled:t.length<=1,isPaid:u.status==="paid",label:n.deleteInstallment,onRemove:()=>o(u.id)})]})},u.id)})})}function Nc({isDisabled:e,isPaid:t,label:n,onRemove:r}){const a=s.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?s.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:s.jsx("span",{className:"inline-flex",children:a})}):a}function Cc({total:e,donationAmount:t,hasTotalIncreaseWarning:n,mode:r,installments:a,formatter:i,labels:o,className:l}){const d=a.length,u=a[0]?.amount??0,f=a[1]?.amount??u,h=d>1&&Math.round(u*100)!==Math.round(f*100),y=Math.max(t-e,0),m=n?s.jsx("span",{children:o.totalIncreaseWarning}):r==="automatic"?h?s.jsxs("span",{children:["Saving will create ",s.jsx("strong",{children:d})," scheduled payment records:"," ",s.jsx("strong",{children:i.format(u)})," first charge and"," ",s.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):s.jsxs("span",{children:["Saving will create ",s.jsx("strong",{children:d})," scheduled payment records of"," ",s.jsx("strong",{children:i.format(u)})," each."]}):s.jsxs("span",{children:["Total scheduled: ",s.jsx("strong",{children:i.format(e)})," /"," ",s.jsx("strong",{children:i.format(t)}),"."]}),j=r==="automatic"?`Total: ${i.format(e)}`:n?`New total: ${i.format(e)}`:`${o.remaining}: ${i.format(y)}`;return s.jsx(c.Alert,{isClosable:!1,color:n?"warning":"default",variant:"flat",radius:"full",className:l,endContent:s.jsx("span",{className:"whitespace-nowrap",children:j}),title:m})}function kc(){return s.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),s.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),s.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[s.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),s.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),s.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),s.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[s.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),s.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const ys={paid:"bg-emerald-50 text-emerald-700",schedule:"bg-blue-50 text-blue-700",payment_due:"bg-amber-50 text-amber-700",overdue:"bg-orange-50 text-orange-700",failed:"bg-red-50 text-red-700",refunded:"bg-zinc-100 text-zinc-600",disputed:"bg-purple-50 text-purple-700",canceled:"bg-zinc-100 text-zinc-600"},Br={paid:"Paid",schedule:"Schedule",payment_due:"Payment Due",overdue:"Overdue",failed:"Failed",refunded:"Refunded",disputed:"Disputed",canceled:"Canceled"},Sc={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:s.jsxs(s.Fragment,{children:["Are you sure you want to delete this payment? ",s.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Ac={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function $c({installments:e,currency:t,locale:n="en-US",showTitle:r=!0,showCard:a=!0,showEditPayment:i=!0,labels:o,isSaving:l=!1,onEditInstallments:d,onPayInstallment:u,onDeleteInstallment:f}){const[h,y]=p.useState(null),m={...Sc,...o},[j,k]=p.useState(""),g=new Intl.NumberFormat(n,{style:"currency",currency:t}),w=r?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(K.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),s.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:m.title})]}):void 0,N=p.useMemo(()=>{const b=j.trim().toLowerCase();return b?e.filter(v=>{const $=v.status??"schedule";return[v.id,v.amount,v.dueDate,qt(v.dueDate,n),$,Br[$]??$].join(" ").toLowerCase().includes(b)}):e},[n,e,j]),S=s.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[s.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[s.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:m.searchLabel}),s.jsx(c.Input,{variant:"bordered",size:"md",value:j,placeholder:m.searchPlaceholder,onChange:b=>k(b.target.value),startContent:s.jsx(V,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?s.jsx(W,{type:"button",variant:"bordered",radius:"full",size:"md",className:"h-10 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:s.jsx(V,{icon:"solar:pen-outline",className:"size-4"}),isLoading:l,onPress:d,children:m.editInstallments}):null]}),s.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",N.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:s.jsxs("div",{className:"flex flex-col gap-2",children:[N.map((b,v)=>{const $=b.status??"schedule";return s.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:s.jsxs(c.CardBody,{className:"gap-3 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"text-xs text-default-500",children:["#",v+1]}),s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:b.id||`PMT-${v+1}`})]}),s.jsx(vs,{status:$})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-default-500",children:m.amount}),s.jsx("p",{className:"font-medium text-foreground",children:g.format(b.amount)})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"text-xs text-default-500",children:m.scheduledDate}),s.jsx("p",{className:"font-medium text-foreground",children:qt(b.dueDate,n)})]})]}),s.jsx(js,{status:$,installment:b,labels:m,portalContainer:h??void 0,onPayInstallment:u,onDeleteInstallment:f})]})},b.id)}),N.length===0&&s.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:m.noInstallmentsFound})]})}),s.jsx("div",{className:c.cn("w-full overflow-x-hidden [@container(max-width:767px)]:hidden",N.length>5&&"max-h-[344px] overflow-y-auto pr-1"),children:s.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-12"}),s.jsx("col",{}),s.jsx("col",{className:"w-24"}),s.jsx("col",{className:"w-36"}),s.jsx("col",{className:"w-36"}),s.jsx("col",{className:"w-44"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[s.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.installmentId}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.amount}),s.jsx("th",{className:"px-2 py-3 font-medium",children:m.scheduledDate}),s.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:m.status}),s.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:m.actions})]})}),s.jsxs("tbody",{children:[N.map((b,v)=>{const $=b.status??"schedule";return s.jsxs("tr",{className:"text-zinc-500",children:[s.jsx("td",{className:"px-2 py-3",children:v+1}),s.jsx("td",{className:"overflow-hidden px-2 py-3",children:s.jsx("span",{className:"block w-full truncate",children:b.id||`PMT-${v+1}`})}),s.jsx("td",{className:"px-2 py-3",children:g.format(b.amount)}),s.jsx("td",{className:"px-2 py-3",children:qt(b.dueDate,n)}),s.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:s.jsx(vs,{status:$})}),s.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:s.jsx(js,{status:$,installment:b,labels:m,portalContainer:h??void 0,onPayInstallment:u,onDeleteInstallment:f})})]},b.id)}),N.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:m.noInstallmentsFound})})]})]})})]});return s.jsx("div",{ref:y,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:a?s.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"min-w-0 w-full gap-0 px-0",itemClasses:{base:"min-w-0 w-full overflow-x-hidden rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"w-full",content:"min-w-0 w-full overflow-x-hidden px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:s.jsx(c.AccordionItem,{"aria-label":m.title,title:w,children:S},"installment-table")}):S})}function vs({status:e}){return s.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",ys[e]??ys.schedule),startContent:s.jsx(Ec,{status:e}),children:Br[e]??e})}function js({status:e,installment:t,labels:n,portalContainer:r,onPayInstallment:a,onDeleteInstallment:i}){return s.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[s.jsx(W,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:e==="paid",startContent:s.jsx(V,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(t),children:n.payNow}),s.jsx(Dc,{isFulfilled:e==="paid",labels:n,portalContainer:r,onDelete:()=>i(t.id)})]})}function Dc({isFulfilled:e,labels:t,portalContainer:n,onDelete:r}){const[a,i]=p.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[s.jsx(c.DropdownTrigger,{children:s.jsx(W,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:s.jsx(V,{icon:"solar:menu-dots-bold",className:"size-4"})})}),s.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&!e&&i(!0)},children:[s.jsx(c.DropdownSection,{title:"Actions",showDivider:!0,children:s.jsx(c.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:s.jsx(V,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),s.jsx(c.DropdownSection,{title:t.dangerZone,children:s.jsx(c.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:s.jsx(V,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),s.jsx($t,{isOpen:a,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:s.jsx(V,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:n,shouldBlockScroll:!1,classNames:Ac,onClose:()=>i(!1),onConfirm:()=>{i(!1),r()}})]})}function Ec({status:e}){return e==="paid"?s.jsx(V,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?s.jsx(V,{icon:"solar:close-circle-bold",className:"size-3"}):s.jsx(V,{icon:"solar:calendar-outline",className:"size-3"})}function qt(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const Ic={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Mc=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:a,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:l=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:h=""})=>{const y=Array.isArray(e)?e:[],[m,j]=p.useState(l),[k,g]=p.useState(o),w={...Ic,...a};p.useEffect(()=>{j(l)},[l]);const N=b=>{if(b===m){d&&f?.(b);return}j(b),f?.(b)},S=b=>{g(b),u?.(b)};return s.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",h),"data-testid":"membership-select-cards",children:[s.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),s.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&s.jsx(qr,{title:w.renewalTitle,description:w.renewalDescription,value:k,onValueChange:S}),s.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":c.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:y.map(b=>s.jsx(Vr,{itemKey:b.id,name:b.name,type:b.type,price:b.price,locale:t,currency:n,isSelected:m===b.id,onSelect:N},b.id))})]})},Vr=({itemKey:e,name:t,type:n,price:r,locale:a="en-US",currency:i="USD",showPrice:o=!0,isSelected:l=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:h,statusLabel:y,statusTone:m="default",className:j=""})=>{const k=new Intl.NumberFormat(a,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),g=!!d&&!f,w=h||y,N=()=>{g&&d?.(e)};return s.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:N,className:c.cn("w-full min-h-fit border rounded-3xl",l?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",j),"data-testid":"item-card","data-selected":l,isDisabled:f,children:s.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[s.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[s.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&s.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:s.jsx("p",{className:"text-center",children:n})}),w&&s.jsx(c.Chip,{"data-testid":"item-card-status",color:m,size:"sm",variant:"flat",className:"px-2",children:w})]}),o&&s.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:k})]})})},ws="w-full bg-gray-100",Ns={variant:"light",color:"default"},Ur=({id:e,title:t,media:n,imageUrl:r,imageAlt:a,imageClassName:i="",imageAspect:o="aspect-[4/3]",meta:l=[],price:d,action:u,footer:f,onPress:h,isPressable:y=!1,isDisabled:m=!1,compact:j=!1,className:k="",bodyClassName:g="",footerClassName:w="",dataTestId:N})=>{const S=!!(d&&d.value),b=!!u?.label,v=y&&!!h&&!b,$=!v,M=b?{variant:u?.variant??Ns.variant,color:u?.color??Ns.color,size:u?.size??"sm",isDisabled:m||u?.isDisabled,startContent:u?.icon?s.jsx(V,{icon:u.icon,width:16}):void 0}:null,O=n??(r?s.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",o,ws,i),children:s.jsx(c.Image,{removeWrapper:!0,src:r,alt:a||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):s.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",o,ws,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:s.jsx(V,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return s.jsxs(c.Card,{"data-testid":N||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",k),isPressable:v,onPress:h,isDisabled:m,shadow:"sm",radius:"lg",children:[s.jsx("div",{children:O}),s.jsxs(c.CardBody,{className:c.cn("gap-3",j?"p-3":"p-4",g),children:[s.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",j?"text-sm":""),children:t}),l.length>0?s.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:l.map((A,_)=>s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(V,{icon:A.icon,className:"size-4 text-gray-400",width:16}),s.jsx("span",{children:A.label})]},`${A.label}-${_}`))}):null,(S||b)&&s.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",j?"pt-0.5":"",w),children:[S?s.jsxs("span",{className:c.cn("mr-auto text-gray-500",j?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&s.jsxs("span",{children:[d.label," "]}),s.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):s.jsx("span",{className:"ml-auto","aria-hidden":!0}),b&&$?s.jsx(W,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:M?.variant,color:M?.color,size:M?.size,startContent:M?.startContent,isDisabled:M?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?s.jsx("div",{className:"pt-1",children:f}):null]})]})};Ur.displayName="CatalogItemCard";const Fc={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},Tc={empty:"border-default-200 bg-white",error:"border-danger-200 bg-white",success:"border-success-100 bg-success-50/40",loading:"border-default-200 bg-white"},Lc={empty:"bg-default-100 text-default-400",error:"bg-danger-50 text-danger-600",success:"bg-success-100 text-success-700",loading:"bg-primary-50 text-primary"},Oc={empty:"status",error:"alert",success:"status",loading:"status"},Pc={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function _c(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return s.jsx(c.Spinner,{size:"lg",color:"primary",className:r.spinner});if(p.isValidElement(t))return s.jsx(s.Fragment,{children:t});const a=typeof t=="string"?t:Fc[e];return a?s.jsx(V,{icon:a,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function Je({variant:e="empty",title:t,titleAs:n="p",description:r,icon:a,actions:i,role:o=Oc[e],ariaLive:l=Pc[e],iconSize:d=24,className:u,classNames:f={},"data-testid":h="feedback-state"}){const y=_c(e,a,d,f);return s.jsxs("div",{role:o,"aria-live":l,"data-variant":e,"data-testid":h,className:c.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",Tc[e],u,f.base),children:[y?s.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:c.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",Lc[e],f.iconWrapper),children:y}):null,s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsx(n,{"data-testid":`${h}-title`,className:c.cn("text-base font-medium text-default-900",f.title),children:t}),r?s.jsx("p",{"data-testid":`${h}-description`,className:c.cn("max-w-sm text-sm text-default-600",f.description),children:r}):null]}),i?s.jsx("div",{"data-testid":`${h}-actions`,className:c.cn("mt-1 flex flex-wrap items-center justify-center gap-2",f.actions),children:i}):null]})}function En(e){return s.jsx(Je,{...e,variant:"empty"})}function In(e){return s.jsx(Je,{...e,variant:"error"})}function Mn(e){return s.jsx(Je,{...e,variant:"loading"})}function Hr(e){return s.jsx(Je,{...e,variant:"success"})}Je.displayName="FeedbackState";En.displayName="EmptyState";In.displayName="ErrorState";Mn.displayName="LoadingState";Hr.displayName="SuccessState";const qr=({title:e,value:t,description:n,onValueChange:r,className:a=""})=>{const i=p.useId();return s.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",a),"data-testid":"toggle",children:[s.jsxs("div",{className:"flex flex-col items-start",children:[e&&s.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&s.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),s.jsx(c.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},zc={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},Rc=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Wr=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,a)=>r+Object.values(a).reduce((i,o)=>i+o.selectedQuantity,0),0),0),Bc=e=>e.reduce((t,n)=>t+n.dates.reduce((r,a)=>r+a.tickets.reduce((i,o)=>i+o.max,0),0),0),Fn=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),Cs=(e,t,n)=>{const r={};let a=n?t??Bc(e):0;for(const{exhibition:i,dateGroup:o,ticket:l}of Fn(e)){r[i.id]??={},r[i.id][o.id]??={};const d=n?Math.min(l.max,a):0;r[i.id][o.id][l.id]={id:l.id,selectedQuantity:d,originalPrice:l.originalPrice,discountedPrice:l.price},a-=d}return r},ks=(e,t,n)=>`${e}::${t}::${n}`,Vc=(e,t,n)=>{const r=Wr(t);for(const{exhibition:a,dateGroup:i,ticket:o}of Fn(e)){const l=t[a.id]?.[i.id]?.[o.id]?.selectedQuantity??0,d=n===void 0?o.max:Math.min(o.max,n-(r-l));if(d>0&&l<d)return!1}return!0},Uc=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:a=!1})=>{const i=Math.max(t,Math.min(n,e)),[o,l]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?o:String(i),h=()=>{a||i>=n||r?.(i+1)},y=()=>{a||i<=t||r?.(i-1)},m=b=>{if(a)return;l(b.target.value);const v=parseInt(b.target.value,10);isNaN(v)||r?.(Math.max(t,Math.min(n,v)))},j=b=>{const v=parseInt(b.target.value,10);if(u(!1),isNaN(v)){r?.(t);return}const $=Math.max(t,Math.min(n,v));$!==v?r?.($):l(String($))},k=i<=t,g=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",S="bg-primary/40 cursor-not-allowed";return s.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[s.jsx("button",{type:"button",onClick:y,disabled:a||k,className:c.cn(w,a||k?S:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),s.jsx("input",{type:"number",value:f,onChange:m,onFocus:()=>u(!0),onBlur:j,disabled:a,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),s.jsx("button",{type:"button",onClick:h,disabled:a||g,className:c.cn(w,a||g?S:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Hc=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const a=()=>{r||n?.(!t)};return s.jsxs("button",{type:"button",onClick:a,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:c.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[s.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),s.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&s.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),s.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},qc=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:a,settings:i,labels:o})=>{const l=()=>{if(!r||a===void 0)return e.max;const h=r();return Math.min(e.max,a-(h-t))},d=i?.locale??"en-US",u=i?.currency??"USD",f=Rc(d,u);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?s.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:f.format(e.originalPrice)}),s.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?s.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:e.membershipName,children:s.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,s.jsx("div",{className:"text-sm text-zinc-500",children:s.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[o.ticketsAllowedToRedeem," ",e.max]})})]}),s.jsx(Uc,{initialQuantity:t,minQuantity:0,maxQuantity:l(),onChange:n})]}),e.membershipAlert?s.jsx(c.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:s.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},Wc=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:a,getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:d})=>s.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[s.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((u,f)=>s.jsxs("div",{children:[s.jsx(qc,{item:u,quantity:a(e,t.id,u.id),onChange:h=>r(e,t.id,u.id,h),getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:d}),f<t.tickets.length-1?s.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),Yc=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:o,labels:l,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),h=t.dates.reduce((m,j)=>m+j.tickets.reduce((k,g)=>k+r(t.id,j.id,g.id),0),0),y=t.dates.some(m=>m.tickets.length>0);return s.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[s.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>f(!u),"aria-expanded":u,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:s.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[s.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[h," ",l.ticketsSelectedToRedeem]}),s.jsx("span",{className:c.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:s.jsx(V,{icon:"mdi:chevron-down"})})]})]})}),s.jsx("div",{id:`upgrade-items-${t.id}`,className:c.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&s.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:y?t.dates.map((m,j)=>s.jsx(Wc,{exhibitionId:t.id,dateGroup:m,isLast:j===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:a,userMaxLimit:i,settings:o,labels:l},m.id)):s.jsx("div",{className:"px-5 py-10 text-center",children:s.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},Gc=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:a,className:i="",onSelectionChange:o})=>{const l=p.useMemo(()=>a??[],[a]),d={...zc,...n},[u,f]=p.useState(()=>Cs(l,t,!0)),h=p.useRef(!1),y=p.useMemo(()=>{const N=Fn(l).map(({exhibition:S,dateGroup:b,ticket:v})=>[ks(S.id,b.id,v.id),v]);return new Map(N)},[l]),m=Vc(l,u,t),j=(N,S,b)=>u[N]?.[S]?.[b]?.selectedQuantity??0,k=()=>Wr(u),g=(N,S,b,v)=>{const $=j(N,S,b),M=k()-$;if(t!==void 0&&M+v>t)return;const O=y.get(ks(N,S,b));if(!O)return;const A={...u,[N]:{...u[N],[S]:{...u[N]?.[S],[b]:{id:b,selectedQuantity:v,originalPrice:O.originalPrice,discountedPrice:O.price}}}};f(A),o?.(A)},w=N=>{const S=Cs(l,t,N);f(S),o?.(S)};return p.useEffect(()=>{!h.current&&m&&(o?.(u),h.current=!0)},[m,u,o]),s.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[s.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[s.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),s.jsx(Hc,{label:d.selectAllButtonLabel,checked:m,onChange:w})]}),l.map(N=>s.jsx(Yc,{title:N.exhibitionName,exhibition:N,onQuantityChange:g,getTicketQuantity:j,getTotalSelectedTickets:k,userMaxLimit:t,settings:r,labels:d,initialExpanded:e},N.id))]})},Wt={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Yt=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},Kc=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const a=e[r.id]??[];n[r.id]=a.length>0?a[0]:null}return n},Qc=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,Yr=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:a="default",triggerSize:i="sm",triggerClassName:o,popoverClassName:l,className:d,sections:u,onConfirm:f,onClear:h,appliedCount:y,countAriaLabel:m,countDisplay:j="badge",confirmLabel:k=Wt.confirm,clearLabel:g=Wt.clear,isOpen:w,defaultOpen:N=!1,onOpenChange:S,isDisabled:b=!1,closeOnConfirm:v=!0,keepOpenAfterClear:$=!1})=>{const[M,O]=p.useState(N),[A,_]=p.useState(()=>Yt(u)),I=w??M,D=y??u.filter(Y=>Qc(Y)).length,F=Y=>{Y&&_(Yt(u)),w||O(Y),S?.(Y)},L=(Y,B)=>{_(G=>({...G,[Y.id]:B}))},Q=(Y,B)=>{_(G=>({...G,[Y.id]:B?[B]:[]}))},U=async()=>{_(Yt(u.map(Y=>Y.type==="checkbox"?{...Y,selectedValues:[]}:{...Y,selectedValue:null}))),await h(),$||F(!1)},H=async()=>{const Y=Kc(A,u);await f(Y),v&&F(!1)},J=Y=>{if(Y.type==="checkbox")return s.jsx(c.CheckboxGroup,{label:Y.label,value:A[Y.id]??[],onValueChange:G=>L(Y,G),children:Y.options.map(G=>s.jsx(c.Checkbox,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},Y.id);const B=A[Y.id]?.[0]??"";return s.jsx(c.RadioGroup,{label:Y.label,value:B,onValueChange:G=>Q(Y,G||null),children:Y.options.map(G=>s.jsx(c.Radio,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},Y.id)},ee=p.useMemo(()=>D>0?m?.(D)||`${D} filters applied`:void 0,[m,D]),se=p.useMemo(()=>D===0?e||Wt.noLabel:m?m(D):`${e} (${D})`,[D,e,m]);return s.jsx("div",{className:d,children:s.jsxs(c.Popover,{isOpen:I,onOpenChange:F,placement:"bottom-end",children:[s.jsx(c.PopoverTrigger,{children:s.jsxs(W,{isDisabled:b,variant:r,color:a,size:i,className:o,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":I,children:[s.jsx(V,{icon:n,width:16}),s.jsx("span",{children:e}),j==="badge"&&D>0?s.jsx("span",{className:"ml-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-xs font-medium text-white","aria-label":ee,children:D}):j==="summary"&&se!==e?s.jsx("span",{className:"text-xs",children:se}):null]})}),s.jsx(c.PopoverContent,{className:l,children:s.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(Y=>J(Y)),s.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[s.jsx(W,{variant:"light",color:"default",size:"sm",onPress:U,children:g}),s.jsx(W,{color:"primary",size:"sm",onPress:H,children:k})]})]})})]})})};Yr.displayName="FilterPopover";const Zc="No sessions available for this date",Jc=e=>e==="sold-out"||e==="closed"?"danger":"success",Xc=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},Ss=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",ed=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,Gr=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:a,quickDates:i,selectedSessionId:o=null,onSessionSelect:l,emptyStateMessage:d=Zc,statusLabel:u,statusTone:f,sessionAriaLabel:h,dayButtonClassName:y,calendarSlot:m,dayGroupAriaLabel:j,sessionGridAriaLabel:k,className:g,headingClassName:w,subheadingClassName:N})=>{const S=ed(n,r),b=n.find(A=>A.date===S),v=i??n.map(A=>({date:A.date,label:A.label})),$=b?.sessions??[],M=A=>A===S?"solid":"bordered",O=A=>{if(!Ss(A)){if(A.id===o){l(null);return}l(A.id)}};return s.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",g),"data-testid":"session-timeline-root",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),t?s.jsx("p",{className:c.cn("text-sm text-gray-700",N),children:t}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":j||"Session days",children:[v.map(A=>s.jsx(W,{size:"sm",variant:M(A.date),color:"default",className:c.cn("rounded-full",y),isDisabled:A.isDisabled,onPress:()=>{a(A.date)},children:s.jsx("span",{children:A.label})},A.date)),m?s.jsx("div",{children:m}):null]}),s.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":k||"Sessions",children:[$.length===0?s.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:d}):null,$.map(A=>{const _=Ss(A),I=A.id===o;return s.jsx("li",{className:"rounded-xl",children:s.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!_,onPress:()=>{O(A)},"aria-disabled":_,"aria-pressed":_?void 0:I,className:c.cn("w-full",_?"bg-gray-100 opacity-70":"",I?"w-full ring-2 ring-gray-900":""),"aria-label":h?h(A,{isSelected:I,isUnavailable:_}):_?`${A.startTime} ${A.endTime} sold out`:`${A.startTime} ${A.endTime} available`,children:s.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[s.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[A.startTime," – ",A.endTime]}),s.jsx(c.Chip,{size:"sm",color:f?f(A):Jc(A.status),variant:"flat",children:u?u(A):Xc(A)})]})})},A.id)})]})]})};Gr.displayName="SessionTimeline";const td=(e,t)=>typeof e=="string"?s.jsx(V,{icon:e,className:"size-5","aria-hidden":"true"}):e||t||null,Kr=({title:e,subtitle:t,eyebrow:n,icon:r,initials:a,actions:i,titleAs:o="h1",className:l,classNames:d={},"data-testid":u="page-header"})=>{const f=td(r,a);return s.jsxs("header",{"data-testid":u,className:c.cn("flex flex-wrap items-start justify-between gap-4",l,d.base),children:[s.jsxs("div",{className:"flex items-center gap-4",children:[f?s.jsx("div",{"aria-hidden":"true","data-testid":`${u}-icon`,className:c.cn("flex size-12 shrink-0 items-center justify-center rounded-xl bg-gray-900 text-sm font-semibold text-white",d.iconWrapper),children:f}):null,s.jsxs("div",{children:[n?s.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:n}):null,s.jsx(o,{"data-testid":`${u}-title`,className:c.cn("text-3xl font-semibold text-gray-950",d.title),children:e}),t?s.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn("mt-1 text-sm text-gray-600",d.subtitle),children:t}):null]})]}),i?s.jsx("div",{"data-testid":`${u}-actions`,className:c.cn("flex flex-wrap items-center gap-2",d.actions),children:i}):null]})};Kr.displayName="PageHeader";const nd={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default"},Qr=({status:e,label:t,variant:n="flat",size:r="sm",color:a,startContent:i,className:o,"data-testid":l="status-chip"})=>s.jsx(c.Chip,{color:a??nd[e],variant:n,size:r,startContent:i,"data-testid":l,"data-status":e,className:c.cn("font-medium",o),children:t});Qr.displayName="StatusChip";const Zr={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Jr={1:"grid-cols-1",2:"grid-cols-2"},sd=e=>typeof e=="string"?s.jsx(V,{icon:e,width:16,height:16,"aria-hidden":"true",className:"text-gray-400"}):e,Xr=({options:e,selectedKeys:t,onChange:n,heading:r,ariaLabel:a="Select options",columnsDesktop:i=2,columnsMobile:o=1,minSelected:l,hint:d,isInvalid:u,isDisabled:f=!1,className:h,classNames:y={},"data-testid":m="checkbox-card-group"})=>{const j=new Set(t),k=new Set(e.map(v=>v.key)),g=l!==void 0&&j.size<l,w=u??g,N=d??(l!==void 0?`Select at least ${l}.`:void 0),S=v=>{const $=new Set(j);$.has(v)?$.delete(v):$.add(v);const M=e.map(A=>A.key).filter(A=>$.has(A)),O=t.filter(A=>$.has(A)&&!k.has(A));n([...new Set([...M,...O])])},b=N?`${m}-hint`:void 0;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",h,y.base),"data-testid":m,children:[r&&s.jsx("h3",{className:"text-sm font-medium text-gray-700",id:`${m}-heading`,children:r}),s.jsx("div",{role:"group","aria-labelledby":r?`${m}-heading`:void 0,"aria-label":r?void 0:a,"aria-invalid":w||void 0,"aria-describedby":b,className:c.cn("grid gap-2",Jr[o],Zr[i],y.grid),children:e.map(v=>{const $=j.has(v.key),M=v.description?`${m}-${v.key}-description`:void 0;return s.jsxs(W,{variant:"bordered",radius:"lg",role:"checkbox","aria-checked":$,"aria-label":v.label,"aria-describedby":M,isDisabled:f||v.isDisabled,onPress:()=>S(v.key),"data-testid":v["data-testid"]??`${m}-${v.key}`,className:c.cn("h-auto min-h-[52px] items-start justify-start gap-2 px-3 py-2","border bg-transparent text-left transition-colors",$?"border-primary bg-primary-50":"border-gray-200 hover:bg-gray-50",w&&!$&&"border-danger-300",y.card),children:[s.jsx("span",{"aria-hidden":"true",className:c.cn("mt-0.5 flex size-[18px] shrink-0 items-center justify-center rounded-[6px] border transition-colors",$?"border-primary bg-primary text-white":"border-gray-300 bg-white text-transparent"),children:s.jsx(V,{icon:"solar:check-read-linear",className:"size-3"})}),s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[v.icon?sd(v.icon):null,s.jsx("span",{className:"text-sm font-medium text-gray-900",children:v.label})]}),v.description?s.jsx("span",{id:M,className:"text-xs leading-snug text-gray-500",children:v.description}):null]})]},v.key)})}),N?s.jsx("p",{id:b,"data-testid":`${m}-hint`,className:c.cn("text-xs",w?"text-danger":"text-gray-500",y.hint),children:N}):null]})};Xr.displayName="CheckboxCardGroup";const ea=({isLoading:e=!1,isError:t=!1,isEmpty:n=!1,loadingTitle:r="Loading…",loadingContent:a,errorTitle:i="Something went wrong",errorDescription:o,retryLabel:l="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:h="Nothing here yet",emptyDescription:y,emptyIcon:m,emptyActions:j,emptyContent:k,children:g,className:w,classNames:N={},"data-testid":S="list-panel"})=>{const b={base:c.cn("border-0 bg-transparent py-12",N.state)};let v;return e?v=a??s.jsx(Mn,{title:r,classNames:b,"data-testid":`${S}-loading`}):t?v=f??s.jsx(In,{title:i,description:o,classNames:b,"data-testid":`${S}-error`,actions:u??(d?s.jsx(W,{color:"primary",variant:"flat",onPress:d,children:l}):void 0)}):n?v=k??s.jsx(En,{title:h,description:y,icon:m,actions:j,classNames:b,"data-testid":`${S}-empty`}):v=g,s.jsx("section",{"data-testid":S,className:c.cn("rounded-xl bg-white p-2 shadow-sm",w,N.base),children:v})};ea.displayName="ListPanel";const rd=350,ad={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},Gt=(e,t)=>Object.entries(t).reduce((n,[r,a])=>n.replace(`{${r}}`,a),e),id=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:a="en-US",labels:i,isDisabled:o=!1,maxAmount:l,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const h={...ad,...i},y=gn(e.currency,a),m=t!==void 0,[j,k]=p.useState(n??null),g=m?t:j,w=p.useMemo(()=>{const F=typeof g=="number"&&Number.isFinite(g)?g:0,L=Jt(F,e.value,e.currency,a);return{received:F,change:L>0?L:0,isValid:F>=e.value&&F>0}},[g,e.value,e.currency,a]),N=p.useCallback(F=>{const L=F.currentTarget;requestAnimationFrame(()=>{L.isConnected&&L.select()})},[]),S=p.useCallback(F=>{if(o)return;const L=F.replace(/[^\d.,]/g,"").replace(",","."),Q=L===""?null:Number.parseFloat(L),U=Q===null||Number.isNaN(Q)?null:Q;if(U!==null&&l!==void 0&&U>l)return;m||k(U);const H=typeof U=="number"&&Number.isFinite(U)?U:0,J=Jt(H,e.value,e.currency,a);r?.({received:H,change:J>0?J:0,isValid:H>=e.value&&H>0})},[m,o,e.value,e.currency,a,r,l]),b=g==null?"":String(g),v=w.isValid&&w.change>0,$=!w.isValid&&w.received>0,M=Pe(w.change,a,e.currency),O=Pe(e.value,a,e.currency),[A,_]=p.useState(""),I=p.useRef(null);p.useEffect(()=>{I.current&&clearTimeout(I.current);const F=v?Gt(h.changeMessageTemplate,{change:M}):"",L=v?rd:0;return I.current=setTimeout(()=>_(F),L),()=>{I.current&&clearTimeout(I.current)}},[v,M,h.changeMessageTemplate]);const D=`${f}-received`;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[s.jsx(c.Input,{id:D,label:h.receivedLabel,labelPlacement:"outside",type:"text",inputMode:y===0?"numeric":"decimal",pattern:y===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:b,onChange:F=>S(F.target.value),onFocus:N,placeholder:h.receivedPlaceholder,isDisabled:o,isInvalid:$,errorMessage:$?Gt(h.insufficientMessageTemplate,{due:O}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),v&&s.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:h.changeLabel,description:Gt(h.changeMessageTemplate,{change:M}),icon:s.jsx(V,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),s.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:A})]})},ld={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},As=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},ta=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:a,hideDate:i=!1,hideBankName:o=!1,isDisabled:l=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:h,"data-testid":y="check-tender-form"})=>{const m={...ld,...a},j=t!==void 0,[k,g]=p.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??As()}),[w,N]=p.useState(!!n?.checkNumber),S=p.useMemo(()=>j?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??As()}:k,[j,t,k]),b=p.useCallback(I=>{j||g(I);const D=I.checkNumber.trim(),F={amount:e.value,checkNumber:D,bankName:I.bankName.trim()||void 0,date:i?void 0:I.date,isValid:D.length>0&&e.value>0};r?.(F)},[j,e.value,i,r]),v=p.useCallback(I=>D=>{l||(I==="checkNumber"&&D.length>0&&N(!0),b({...S,[I]:D}))},[S,b,l]),$=p.useCallback(()=>{l||N(!0)},[l]),M=w&&S.checkNumber.trim()==="",O=`${y}-check-number`,A=`${y}-bank-name`,_=`${y}-date`;return s.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",h),"data-testid":y,children:[s.jsx(c.Input,{id:O,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:S.checkNumber,onChange:I=>v("checkNumber")(I.target.value),onBlur:$,placeholder:m.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:M,errorMessage:M?m.checkNumberRequiredMessage:void 0,isDisabled:l,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${y}-check-number-input`}),!o&&s.jsx(c.Input,{id:A,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:S.bankName,onChange:I=>v("bankName")(I.target.value),placeholder:m.bankNamePlaceholder,maxLength:u,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${y}-bank-name-input`}),!i&&s.jsx(c.Input,{id:_,label:m.dateLabel,labelPlacement:"outside",type:"date",value:S.date,onChange:I=>v("date")(I.target.value),isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${y}-date-input`,className:"sm:col-span-2"})]})};ta.displayName="CheckTenderForm";const od={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},cd=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],na=({dueAmount:e,methodOptions:t=cd,value:n,defaultValue:r,onChange:a,labels:i,showReference:o=!1,isDisabled:l=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...od,...i},h=n!==void 0,[y,m]=p.useState({method:r?.method??"",reference:r?.reference??""}),j=p.useMemo(()=>h?{method:n?.method??"",reference:n?.reference??""}:y,[h,n,y]),k=p.useCallback(v=>t.find($=>$.value===v)?.label??"",[t]),g=p.useCallback(v=>{h||m(v);const $=k(v.method),M={amount:e.value,method:v.method,description:$,reference:v.reference.trim()||void 0,isValid:v.method!==""};a?.(M)},[h,e.value,a,k]),w=p.useCallback(v=>{if(l)return;const $=typeof v=="string"?v:Array.from(v)[0]?.toString()??"";g({...j,method:$})},[j,g,l]),N=p.useCallback(v=>{l||g({...j,reference:v})},[j,g,l]),S=`${u}-method`,b=`${u}-reference`;return s.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[s.jsx(Oe,{id:S,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:j.method?[j.method]:[],onSelectionChange:w,isDisabled:l,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${u}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(v=>s.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${v.value}`,children:v.label},v.value))}),o&&s.jsx(c.Input,{id:b,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:j.reference,onChange:v=>N(v.target.value),placeholder:f.referencePlaceholder,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};na.displayName="OtherTenderForm";const dd={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ud={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},fd={pending:"warning",recorded:"success",failed:"danger"},md=e=>e==="pending"||e==="recorded",hd=e=>`#${e+1}`,sa=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:a,hideCollectedList:i=!1,className:o,"data-testid":l="split-payment-summary"})=>{const d={...dd,...a},{collected:u,remaining:f,isComplete:h}=p.useMemo(()=>{const m=t.reduce((k,g)=>md(g.status)?k+g.amount:k,0),j=Math.max(e.value-m,0);return{collected:m,remaining:j,isComplete:m>=e.value&&e.value>0}},[t,e.value]),y=m=>m==="pending"?d.statusPending:m==="recorded"?d.statusRecorded:d.statusFailed;return s.jsxs("div",{className:c.cn("flex flex-col gap-4",o),"data-testid":l,children:[s.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${l}-remaining-banner`,children:[s.jsx("div",{className:"text-sm text-default-600",children:h?d.completeLabel:d.remainingLabel}),s.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${l}-remaining-amount`,children:Pe(h?u:f,r,e.currency)})]}),!i&&t.length>0&&s.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${l}-collected-list`,children:[s.jsx("h3",{className:"text-base font-semibold",children:d.collectedHeading}),t.map((m,j)=>s.jsx(xd,{index:j,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:y(m.status),removeAriaLabel:d.removeAriaLabel,recordedTooltip:d.removeTooltipForRecorded,dataTestId:`${l}-row-${j}`},m.id))]})]})};sa.displayName="SplitPaymentSummary";const xd=({index:e,tender:t,locale:n,currency:r,removable:a,onRemove:i,statusLabel:o,removeAriaLabel:l,recordedTooltip:d,dataTestId:u})=>{const f=i?s.jsx(W,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!a,"aria-label":l,"data-testid":`${u}-remove`,className:c.cn(a?"text-default-700 hover:bg-default-200":"text-default-300"),children:s.jsx(V,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return s.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":u,children:[s.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:hd(e)}),s.jsx(V,{icon:ud[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:t.label}),s.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:Pe(t.amount,n,r)}),s.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:fd[t.status],startContent:t.status==="recorded"?s.jsx(V,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?s.jsx(V,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:o}),f&&(a?f:s.jsx(c.Tooltip,{content:d,placement:"left",children:s.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},pd=`
|
|
11
11
|
@keyframes pp-modal-in {
|
|
12
12
|
from { opacity: 0; transform: scale(0.96); }
|
|
13
13
|
to { opacity: 1; transform: scale(1); }
|
package/dist/index.js
CHANGED
|
@@ -7389,13 +7389,13 @@ function Zf({
|
|
|
7389
7389
|
] }) : void 0, re = (le) => {
|
|
7390
7390
|
le !== z && (e || O(le), N?.(le), le === "manual" && i.length === 0 && $([Zr()]));
|
|
7391
7391
|
}, se = (le, Fe) => {
|
|
7392
|
-
i.find((Ne) => Ne.id === le)?.status !== "
|
|
7392
|
+
i.find((Ne) => Ne.id === le)?.status !== "paid" && $(
|
|
7393
7393
|
i.map((Ne) => Ne.id === le ? { ...Ne, ...Fe } : Ne)
|
|
7394
7394
|
);
|
|
7395
7395
|
}, G = () => {
|
|
7396
7396
|
$([...i, Zr()]);
|
|
7397
7397
|
}, B = (le) => {
|
|
7398
|
-
i.find((Ee) => Ee.id === le)?.status !== "
|
|
7398
|
+
i.find((Ee) => Ee.id === le)?.status !== "paid" && $(i.filter((Ee) => Ee.id !== le));
|
|
7399
7399
|
}, K = () => {
|
|
7400
7400
|
if (!S) {
|
|
7401
7401
|
if (Z) {
|
|
@@ -7717,7 +7717,7 @@ function Ad({
|
|
|
7717
7717
|
{
|
|
7718
7718
|
variant: "bordered",
|
|
7719
7719
|
"aria-label": `${n.dueDate} ${u + 1}`,
|
|
7720
|
-
isDisabled: d.status === "
|
|
7720
|
+
isDisabled: d.status === "paid",
|
|
7721
7721
|
isInvalid: h,
|
|
7722
7722
|
errorMessage: h ? n.dateOrderError : void 0,
|
|
7723
7723
|
value: Yt(d.dueDate),
|
|
@@ -7733,7 +7733,7 @@ function Ad({
|
|
|
7733
7733
|
type: "number",
|
|
7734
7734
|
min: 0,
|
|
7735
7735
|
step: 0.01,
|
|
7736
|
-
isDisabled: d.status === "
|
|
7736
|
+
isDisabled: d.status === "paid",
|
|
7737
7737
|
isInvalid: x,
|
|
7738
7738
|
errorMessage: x ? n.amountGreaterThanZeroError : void 0,
|
|
7739
7739
|
value: String(d.amount || ""),
|
|
@@ -7749,7 +7749,7 @@ function Ad({
|
|
|
7749
7749
|
Dd,
|
|
7750
7750
|
{
|
|
7751
7751
|
isDisabled: t.length <= 1,
|
|
7752
|
-
|
|
7752
|
+
isPaid: d.status === "paid",
|
|
7753
7753
|
label: n.deleteInstallment,
|
|
7754
7754
|
onRemove: () => o(d.id)
|
|
7755
7755
|
}
|
|
@@ -7759,7 +7759,7 @@ function Ad({
|
|
|
7759
7759
|
}
|
|
7760
7760
|
function Dd({
|
|
7761
7761
|
isDisabled: e,
|
|
7762
|
-
|
|
7762
|
+
isPaid: t,
|
|
7763
7763
|
label: n,
|
|
7764
7764
|
onRemove: r
|
|
7765
7765
|
}) {
|
|
@@ -7778,7 +7778,7 @@ function Dd({
|
|
|
7778
7778
|
children: /* @__PURE__ */ a(U, { icon: "solar:trash-bin-minimalistic-outline", className: "size-5" })
|
|
7779
7779
|
}
|
|
7780
7780
|
);
|
|
7781
|
-
return t ? /* @__PURE__ */ a(Oe, { content: "This payment cannot be edited or deleted because it has already been
|
|
7781
|
+
return t ? /* @__PURE__ */ a(Oe, { content: "This payment cannot be edited or deleted because it has already been paid.", placement: "top", children: /* @__PURE__ */ a("span", { className: "inline-flex", children: i }) }) : i;
|
|
7782
7782
|
}
|
|
7783
7783
|
function Ed({
|
|
7784
7784
|
total: e,
|
|
@@ -7866,17 +7866,23 @@ function Jf() {
|
|
|
7866
7866
|
);
|
|
7867
7867
|
}
|
|
7868
7868
|
const Xr = {
|
|
7869
|
-
|
|
7870
|
-
|
|
7869
|
+
paid: "bg-emerald-50 text-emerald-700",
|
|
7870
|
+
schedule: "bg-blue-50 text-blue-700",
|
|
7871
|
+
payment_due: "bg-amber-50 text-amber-700",
|
|
7872
|
+
overdue: "bg-orange-50 text-orange-700",
|
|
7871
7873
|
failed: "bg-red-50 text-red-700",
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
+
refunded: "bg-zinc-100 text-zinc-600",
|
|
7875
|
+
disputed: "bg-purple-50 text-purple-700",
|
|
7876
|
+
canceled: "bg-zinc-100 text-zinc-600"
|
|
7874
7877
|
}, wi = {
|
|
7875
|
-
|
|
7876
|
-
|
|
7878
|
+
paid: "Paid",
|
|
7879
|
+
schedule: "Schedule",
|
|
7880
|
+
payment_due: "Payment Due",
|
|
7881
|
+
overdue: "Overdue",
|
|
7877
7882
|
failed: "Failed",
|
|
7878
|
-
|
|
7879
|
-
|
|
7883
|
+
refunded: "Refunded",
|
|
7884
|
+
disputed: "Disputed",
|
|
7885
|
+
canceled: "Canceled"
|
|
7880
7886
|
}, Id = {
|
|
7881
7887
|
title: "Payments",
|
|
7882
7888
|
searchLabel: "Search a payment",
|
|
@@ -7924,7 +7930,7 @@ function Xf({
|
|
|
7924
7930
|
] }) : void 0, k = ce(() => {
|
|
7925
7931
|
const y = w.trim().toLowerCase();
|
|
7926
7932
|
return y ? e.filter((v) => {
|
|
7927
|
-
const E = v.status ?? "
|
|
7933
|
+
const E = v.status ?? "schedule";
|
|
7928
7934
|
return [
|
|
7929
7935
|
v.id,
|
|
7930
7936
|
v.amount,
|
|
@@ -7980,7 +7986,7 @@ function Xf({
|
|
|
7980
7986
|
),
|
|
7981
7987
|
children: /* @__PURE__ */ f("div", { className: "flex flex-col gap-2", children: [
|
|
7982
7988
|
k.map((y, v) => {
|
|
7983
|
-
const E = y.status ?? "
|
|
7989
|
+
const E = y.status ?? "schedule";
|
|
7984
7990
|
return /* @__PURE__ */ a(ye, { radius: "lg", shadow: "none", className: "border border-default-200", children: /* @__PURE__ */ f(we, { className: "gap-3 p-3", children: [
|
|
7985
7991
|
/* @__PURE__ */ f("div", { className: "flex items-start justify-between gap-2", children: [
|
|
7986
7992
|
/* @__PURE__ */ f("div", { className: "min-w-0", children: [
|
|
@@ -8045,7 +8051,7 @@ function Xf({
|
|
|
8045
8051
|
] }) }),
|
|
8046
8052
|
/* @__PURE__ */ f("tbody", { children: [
|
|
8047
8053
|
k.map((y, v) => {
|
|
8048
|
-
const E = y.status ?? "
|
|
8054
|
+
const E = y.status ?? "schedule";
|
|
8049
8055
|
return /* @__PURE__ */ f("tr", { className: "text-zinc-500", children: [
|
|
8050
8056
|
/* @__PURE__ */ a("td", { className: "px-2 py-3", children: v + 1 }),
|
|
8051
8057
|
/* @__PURE__ */ a("td", { className: "overflow-hidden px-2 py-3", children: /* @__PURE__ */ a("span", { className: "block w-full truncate", children: y.id || `PMT-${v + 1}` }) }),
|
|
@@ -8110,7 +8116,7 @@ function ea({ status: e }) {
|
|
|
8110
8116
|
radius: "lg",
|
|
8111
8117
|
className: g(
|
|
8112
8118
|
"justify-center px-4",
|
|
8113
|
-
Xr[e] ?? Xr.
|
|
8119
|
+
Xr[e] ?? Xr.schedule
|
|
8114
8120
|
),
|
|
8115
8121
|
startContent: /* @__PURE__ */ a(Ld, { status: e }),
|
|
8116
8122
|
children: wi[e] ?? e
|
|
@@ -8135,7 +8141,7 @@ function ta({
|
|
|
8135
8141
|
variant: "solid",
|
|
8136
8142
|
radius: "full",
|
|
8137
8143
|
className: "min-w-[104px] shrink-0",
|
|
8138
|
-
isDisabled: e === "
|
|
8144
|
+
isDisabled: e === "paid",
|
|
8139
8145
|
startContent: /* @__PURE__ */ a(
|
|
8140
8146
|
U,
|
|
8141
8147
|
{
|
|
@@ -8150,7 +8156,7 @@ function ta({
|
|
|
8150
8156
|
/* @__PURE__ */ a(
|
|
8151
8157
|
Fd,
|
|
8152
8158
|
{
|
|
8153
|
-
isFulfilled: e === "
|
|
8159
|
+
isFulfilled: e === "paid",
|
|
8154
8160
|
labels: n,
|
|
8155
8161
|
portalContainer: r,
|
|
8156
8162
|
onDelete: () => s(t.id)
|
|
@@ -8239,7 +8245,7 @@ function Fd({
|
|
|
8239
8245
|
] });
|
|
8240
8246
|
}
|
|
8241
8247
|
function Ld({ status: e }) {
|
|
8242
|
-
return e === "
|
|
8248
|
+
return e === "paid" ? /* @__PURE__ */ a(U, { icon: "solar:check-circle-bold", className: "size-3" }) : e === "failed" ? /* @__PURE__ */ a(U, { icon: "solar:close-circle-bold", className: "size-3" }) : /* @__PURE__ */ a(U, { icon: "solar:calendar-outline", className: "size-3" });
|
|
8243
8249
|
}
|
|
8244
8250
|
function dn(e, t) {
|
|
8245
8251
|
const n = /* @__PURE__ */ new Date(`${e}T00:00:00`);
|
|
@@ -2,4 +2,4 @@ export { InstallmentSchedule } from './InstallmentSchedule';
|
|
|
2
2
|
export { InstallmentScheduleSkeleton } from './InstallmentScheduleSkeleton';
|
|
3
3
|
export { InstallmentTable } from './InstallmentTable';
|
|
4
4
|
export { generateAutomaticInstallments } from './utils';
|
|
5
|
-
export type { AutomaticScheduleSettings, InstallmentFrequency, InstallmentScheduleInput, InstallmentTableLabels, InstallmentTableProps, InstallmentScheduleClassNames, InstallmentScheduleLabels, InstallmentScheduleMode, InstallmentScheduleProps, ScheduledInstallment, } from './types';
|
|
5
|
+
export type { AutomaticScheduleSettings, InstallmentFrequency, InstallmentScheduleInput, InstallmentTableLabels, InstallmentTableProps, InstallmentScheduleClassNames, InstallmentScheduleLabels, InstallmentScheduleMode, InstallmentScheduleProps, InstallmentStatus, ScheduledInstallment, } from './types';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type InstallmentScheduleMode = 'automatic' | 'manual';
|
|
3
3
|
export type InstallmentFrequency = 'weekly' | 'monthly' | 'quarterly' | 'annual';
|
|
4
|
+
export type InstallmentStatus = 'schedule' | 'paid' | 'payment_due' | 'overdue' | 'failed' | 'refunded' | 'disputed' | 'canceled';
|
|
4
5
|
export type ScheduledInstallment = {
|
|
5
6
|
id: string;
|
|
6
7
|
dueDate: string;
|
|
7
8
|
amount: number;
|
|
8
|
-
status?:
|
|
9
|
+
status?: InstallmentStatus | (string & {});
|
|
9
10
|
};
|
|
10
11
|
export type AutomaticScheduleSettings = {
|
|
11
12
|
numberOfInstallments: number;
|