@veevarts/design-system 2.0.0-beta.4 → 2.0.0-beta.6
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
|
@@ -13,7 +13,7 @@ ${s}${a}
|
|
|
13
13
|
`,style:{backgroundColor:r},"aria-label":`Select color ${r}`,title:r},r)})})}const Bo=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],Vo=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function qt(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const be={min:50,max:200,step:10,default:100},ys={lineHeight:24,toolbarHeight:60},Uo={bold:G.Bold,italic:G.Italic,strike:G.Strikethrough,underline:G.Underline,code:G.Code,textColor:G.Palette,highlight:G.Highlighter,link:G.Link2,paragraph:G.FileText,heading:G.Heading,bulletList:G.List,orderedList:G.ListOrdered,taskList:G.ListTodo,codeBlock:G.CodeSquare,blockquote:G.Quote,horizontalRule:G.Minus,clearMarks:G.Eraser,clearNodes:G.Eraser,undo:G.Undo2,redo:G.Redo2,hardBreak:G.CornerDownLeft,textAlign:G.AlignLeft},Ho={left:G.AlignLeft,center:G.AlignCenter,right:G.AlignRight,justify:G.AlignJustify};function Qe(e){return Uo[e]}function qo({value:e,onChange:n,onApply:s,placeholder:a="#000000"}){const[r,i]=p.useState(""),l=u=>{const f=u.target.value;n(f),r&&i("")},o=()=>{if(!e){i("Please enter a color");return}if(!qt(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),s(e)},d=u=>{u.key==="Enter"&&(u.preventDefault(),o())};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Input,{type:"text",value:e,onChange:l,onKeyDown:d,placeholder:a,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!r,errorMessage:r,startContent:t.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:qt(e)?e:"transparent"}})}),t.jsx(U,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!e||!qt(e),children:t.jsx(G.Check,{size:16})})]}),t.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function vs({editor:e,type:n,allowCustomColor:s=!0,label:a,isDisabled:r=!1}){const[i,l]=p.useState(!1),[o,d]=p.useState(""),u=n==="textColor"?Bo:Vo,f=y=>{const j=Ie[n];j&&j.execute({editor:e,config:{type:n,color:y}}),l(!1),d("")},m=y=>{f(y)},x=()=>{const y=Ie[n];y&&y.execute({editor:e,config:{type:n,color:""}}),l(!1)},h=n==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),g=n==="textColor"?G.Palette:G.Highlighter;return t.jsxs(c.Popover,{isOpen:i,onOpenChange:l,placement:"top",offset:10,showArrow:!0,children:[t.jsx(c.PopoverTrigger,{children:t.jsx(U,{size:"sm",radius:"sm",variant:h?"solid":"bordered",color:h?"primary":"default",isIconOnly:!0,isDisabled:r,"aria-label":a,children:t.jsx(g,{size:16})})}),t.jsx(c.PopoverContent,{className:"w-64",children:t.jsxs("div",{className:"px-2 py-3 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-semibold",children:a}),t.jsx(U,{size:"sm",variant:"light",isIconOnly:!0,onPress:x,"aria-label":"Clear color",children:t.jsx(G.X,{size:16})})]}),t.jsx(zo,{colors:u,onColorSelect:f}),s&&t.jsxs(t.Fragment,{children:[t.jsx(c.Divider,{}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),t.jsx(qo,{value:o,onChange:d,onApply:m})]})]})]})})]})}function Wo({zoom:e,onZoomChange:n,min:s=be.min,max:a=be.max,step:r=be.step}){const i=()=>{const m=Math.max(s,e-r);n(m)},l=()=>{const m=Math.min(a,e+r);n(m)},o=()=>{n(be.default)},d=e<=s,u=e>=a,f=e===be.default;return t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:t.jsx(U,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:i,"aria-label":"Zoom out",children:t.jsx(G.ZoomOut,{size:16})})}),t.jsx(c.Tooltip,{content:f?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:t.jsxs("button",{type:"button",onClick:o,disabled:f,className:`
|
|
14
14
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
15
15
|
${f?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
16
|
-
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),t.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:t.jsx(U,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:l,"aria-label":"Zoom in",children:t.jsx(G.ZoomIn,{size:16})})})]})}function Yo({editor:e,isDisabled:n=!1}){const[s,a]=p.useState(!1),[r,i]=p.useState(""),[l,o]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),m=h=>{if(h){const{from:g,to:y}=e.state.selection,j=e.isActive("link");let w="";if(j){const C=e.schema.marks.link,N=e.state.doc.resolve(g),S=Jn.getMarkRange(N,C);S&&(w=e.state.doc.textBetween(S.from,S.to,""))}else w=e.state.doc.textBetween(g,y,"");const v=e.getAttributes("link").href||"";i(w),o(v),u(j)}a(h)},x=()=>{if(l.trim()){const{from:h,to:g}=e.state.selection,y=e.schema.marks.link,j=e.state.doc.resolve(h),w=Jn.getMarkRange(j,y),v=w?.from??h,C=w?.to??g,N=e.state.doc.textBetween(v,C,"");r.trim()&&r!==N?e.chain().focus().setTextSelection({from:v,to:C}).deleteSelection().insertContent(`<a href="${l.trim()}">${r.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:l.trim()}).run()}a(!1)};return t.jsxs(c.Popover,{isOpen:s,onOpenChange:m,placement:"bottom",children:[t.jsx(c.PopoverTrigger,{children:t.jsx(U,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:n,"aria-label":"Link",children:t.jsx(G.Link,{size:16})})}),t.jsx(c.PopoverContent,{children:t.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:r,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:l,onChange:h=>o(h.target.value),onKeyDown:h=>h.key==="Enter"&&x(),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(U,{size:"sm",color:"primary",onPress:x,isDisabled:!l.trim(),children:d?"Update":"Apply"})]})})]})}function Go({children:e,id:n,label:s,className:a,useButtonGroup:r=!0}){return r?t.jsx(c.ButtonGroup,{size:"sm",id:n,"aria-label":s,className:a,children:e}):t.jsx("div",{id:n,role:"group","aria-label":s,className:`flex items-center gap-2 ${a||""}`,children:e})}function La(e,n){const s=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(n.map(o=>ut(o)))).forEach(o=>{const d=Ie[o];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;i[o]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${o}`,u),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,n]),[a,r]=p.useState(s);return p.useEffect(()=>{if(!e)return;const i=()=>{const l={};Array.from(new Set(n.map(d=>ut(d)))).forEach(d=>{const u=Ie[d];if(u)try{const f=u.canExecute?.(e)??!0,m=u.isActive?.(e)??!1;l[d]={isActive:m,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),l[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),r(l)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,n,s]),a}function Ia(e,n){const s=p.useCallback((l,o)=>{if(!e)return;const d=Ie[l];if(d)try{d.execute({editor:e,config:o}),n?.({type:"toggle",modifier:l})}catch(u){console.warn(`Failed to execute command for modifier: ${l}`,u)}},[e,n]),a=p.useCallback(l=>{s(l)},[s]),r=p.useCallback((l,o)=>{if(!e)return!1;const d=Ie[l];try{return d?.canExecute?.(e,o)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${l}`,u),!1}},[e]),i=p.useCallback((l,o)=>{if(!e)return!1;const d=Ie[l];try{return d?.isActive?.(e,o)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${l}`,u),!1}},[e]);return{executeCommand:s,toggleModifier:a,canExecute:r,isActive:i}}function Ko(e=be.default){const[n,s]=p.useState(e),a=p.useCallback((o=be.step)=>{s(d=>Math.min(be.max,d+o))},[]),r=p.useCallback((o=be.step)=>{s(d=>Math.max(be.min,d-o))},[]),i=p.useCallback(()=>{s(be.default)},[]),l=p.useCallback(o=>{const d=Math.max(be.min,Math.min(be.max,o));s(d)},[]);return{zoom:n,setZoom:l,zoomIn:a,zoomOut:r,resetZoom:i,isMinZoom:n<=be.min,isMaxZoom:n>=be.max,isDefaultZoom:n===be.default}}const Qo=["bold","italic","strike","underline","code"];function Zo({editor:e,modifiers:n,onToolbarAction:s}){const a=La(e,n),{toggleModifier:r}=Ia(e,s);if(!e)return null;const i=n.map(l=>ut(l)).filter(l=>Qo.includes(l));return i.length===0?null:t.jsx(Go,{id:"text-formatting",label:"Text formatting",children:i.map(l=>{const o=a[l],d=Qe(l);return t.jsx(qe,{icon:d,label:l.charAt(0).toUpperCase()+l.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(l)},l)})})}function Xo({editor:e,modifiers:n,zoom:s=100,onZoomChange:a,sticky:r=!0,className:i,onToolbarAction:l}){const o=La(e,n),{toggleModifier:d,executeCommand:u}=Ia(e,l);if(!e)return null;const f=n.map(A=>ut(A)),m=f.some(A=>["bold","italic","strike","underline","code"].includes(A)),x=f.some(A=>["textColor","highlight"].includes(A)),h=f.includes("heading"),g=f.includes("textAlign"),y=f.some(A=>["bulletList","orderedList","taskList"].includes(A)),j=f.includes("blockquote"),w=f.includes("codeBlock"),v=f.includes("link"),C=f.includes("horizontalRule"),N=f.some(A=>["undo","redo"].includes(A)),S=s!==void 0&&a!==void 0,E=r?"sticky top-0 z-10":"";return t.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${E} ${i||""}`,children:t.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx(Zo,{editor:e,modifiers:n,onToolbarAction:l}),(x||h||g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),x&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&t.jsx(vs,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),f.includes("highlight")&&t.jsx(vs,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(h||g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),h&&t.jsxs(t.Fragment,{children:[t.jsx(Oo,{editor:e}),(g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(A=>{const L=Ho[A],D=e.isActive({textAlign:A});return t.jsx(qe,{icon:L,label:`Align ${A}`,isActive:D,onClick:()=>u("textAlign",{type:"textAlign",alignment:A})},A)})}),(y||j||w||v||C||N||S)&&t.jsx(He,{})]}),y&&t.jsxs(t.Fragment,{children:[t.jsx(Ro,{editor:e,types:f.filter(A=>["bulletList","orderedList","taskList"].includes(A))}),(j||w||v||C||N||S)&&t.jsx(He,{})]}),(j||w||v||C)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[j&&t.jsx(qe,{icon:Qe("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&t.jsx(qe,{icon:Qe("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),v&&t.jsx(Yo,{editor:e,isDisabled:o.link?.isDisabled}),C&&t.jsx(qe,{icon:Qe("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(N||S)&&t.jsx(He,{})]}),N&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&t.jsx(qe,{icon:Qe("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&t.jsx(qe,{icon:Qe("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>d("redo")})]}),S&&t.jsx(He,{})]}),S&&t.jsx(Wo,{zoom:s,onZoomChange:A=>{a?.(A),l?.({type:"zoom",modifier:`${A}%`})}})]})})}const st={bold:{category:"mark",extension:Ci.Bold,priority:100},italic:{category:"mark",extension:ki.Italic,priority:100},strike:{category:"mark",extension:Si.Strike,priority:100},underline:{category:"mark",extension:Ai.Underline,priority:100},code:{category:"mark",extension:$i.Code,priority:100},textColor:{category:"mark",extension:Di.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Ei.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Fi.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Li.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ti.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:_i.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Pi.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:zi.CodeBlock,priority:100},blockquote:{category:"node",extension:Bi.Blockquote,priority:100},horizontalRule:{category:"node",extension:Vi.HorizontalRule,priority:100},hardBreak:{category:"node",extension:Ui.HardBreak,priority:100},undo:{category:"extension",extension:es.History,priority:50},redo:{category:"extension",extension:es.History,priority:50},textAlign:{category:"extension",extension:Hi.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}},Jo=[qi.Document,Wi.Text,Ii.Paragraph,Mi.TextStyle.configure({HTMLAttributes:{}}),Ri.ListItem.configure({HTMLAttributes:{}}),Oi.TaskItem.configure({nested:!0}),Yi.Dropcursor,Gi.Gapcursor];function ec(e){const n=[],s=new Set,a=new Set;Jo.forEach(o=>{o&&(n.push(o),a.add(o.name))});const r=e.map(o=>ut(o)),i=new Set;return r.forEach(o=>{const d=st[o];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(o=>{if(s.has(o))return;const d=st[o];if(!d||d.extension===null)return;const u=d.extension.name;if(a.has(u)){s.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;n.push(f),s.add(o),a.add(u)}),r.forEach(o=>{if(s.has(o))return;const d=st[o];if(!d){console.warn(`Extension config not found for modifier: ${o}`);return}if(d.extension===null){s.add(o);return}const u=d.extension.name;if(a.has(u)){s.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;n.push(f),s.add(o),a.add(u)}),n.sort((o,d)=>{const u=Object.values(st).find(h=>h?.extension?.name===o.name),f=Object.values(st).find(h=>h?.extension?.name===d.name),m=u?.priority??100;return(f?.priority??100)-m})}const Ta={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"]},tc={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: ${ge.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ce.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ce.fontFamily.mono};`,pre:`background: ${ge.neutral.gray[800]}; border-radius: ${le.sm}; color: ${ge.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 ${ge.neutral.gray[300]}; margin: ${le.lg} 0; padding-left: ${le.md}; color: ${ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${ge.neutral.gray[200]}; margin: ${le.xl} 0;`,a:`color: ${ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${ge.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;"},nc={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 sc(e){if(!e)return e;let n=e;for(const[s,a]of Object.entries(nc)){const r=new RegExp(`(<(?:ul|li)[^>]*data-type="${s}"[^>]*)>`,"gi");n=n.replace(r,(i,l)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${a}"`):`${l} style="${a}">`)}for(const[s,a]of Object.entries(tc)){const r=new RegExp(`<${s}(\\s[^>]*)?>`,"gi");n=n.replace(r,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${a}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${a}'`);{const l=i.indexOf(">");return`${i.slice(0,l)} style="${a}"${i.slice(l)}`}})}return n}const ac=({modifiers:e,zoom:n,onZoomChange:s,onToolbarAction:a})=>{const{editor:r}=yn.useCurrentEditor();return t.jsx(Xo,{editor:r,modifiers:e,zoom:n,onZoomChange:s,onToolbarAction:a})},rc=({showCharacterCount:e,showWordCount:n})=>{const{editor:s}=yn.useCurrentEditor();if(!s||!e&&!n)return null;const a=s.getText(),r=a.length,i=a.split(/\s+/).filter(l=>l.length>0).length;return t.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&t.jsxs("span",{children:[r," characters"]}),n&&t.jsxs("span",{children:[i," words"]})]})},un=p.forwardRef((e,n)=>{const{minRows:s=10,maxRows:a=30,disableAutosize:r=!1,showCharacterCount:i=!1,showWordCount:l=!1,showToolbar:o=!0,modifiers:d=Ta.full,variant:u="bordered",initialContent:f,content:m,onContentChange:x,onUpdate:h,onToolbarAction:g,isReadOnly:y=!1,isDisabled:j=!1,includeInlineStyles:w=!0,...v}=e,{zoom:C,setZoom:N}=Ko(),S=ys.lineHeight,E=s*S,A=r?void 0:a*S,L=p.useMemo(()=>ec(d),[d]),{Component:D,label:P,shouldLabelBeOutside:M,getBaseProps:$,getLabelProps:I,getInputWrapperProps:T}=c.useInput({...v,variant:u,ref:n,isMultiline:!0}),K=P?t.jsx("label",{...I(),children:P}):null,H=p.useCallback(({editor:B})=>{const X=B.getHTML(),J=w?sc(X):X,re=B.getJSON(),q=B.getText(),Z=q.length,Q=q.split(/\s+/).filter(ee=>ee.length>0).length,W={html:J,json:re,text:q,characters:Z,words:Q};if(x?.(W),h?.(W),"onChange"in v&&typeof v.onChange=="function"){const ee={target:{value:J},currentTarget:{value:J}};v.onChange(ee)}},[x,h,v,w]);return t.jsxs(D,{...$(),children:[M?K:null,t.jsx("div",{...T(),className:c.cn(T().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:A?`${A+ys.toolbarHeight}px`:void 0,overflow:A?"auto":void 0},children:t.jsx(yn.EditorProvider,{editable:!y&&!j,slotBefore:o?t.jsx(ac,{modifiers:d,zoom:C,onZoomChange:N,onToolbarAction:g}):void 0,slotAfter:t.jsx(rc,{showCharacterCount:i,showWordCount:l}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${E}px`,fontSize:`${C}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:L,content:m||f||e.defaultValue||"",onUpdate:H})})]})});un.displayName="TipTapEditor";const _a=p.forwardRef((e,n)=>{const{adapter:s="tiptap",variant:a="bordered",...r}=e;return s==="tiptap"?t.jsx(un,{...r,variant:a,ref:n}):(console.warn(`Adapter "${s}" is not supported. Using TipTap.`),t.jsx(un,{...r,variant:a,ref:n}))});_a.displayName="RichTextArea";function ic(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}const js=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],lc={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Pa=({presetAmounts:e=js,selectedDonation:n,defaultSelectedDonation:s=null,onChange:a,onAddDonation:r,currency:i="USD",locale:l="en-US",showCustomAmount:o=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:m=2,desktopColumns:x=3,isDisabled:h=!1,buttonVariant:g="bordered",buttonColor:y="default",inputVariant:j="bordered",size:w="md",className:v="",showCard:C=!0})=>{const N={...lc,...f},S=Array.isArray(e)?e:js,E={2:"grid-cols-2",3:"grid-cols-3"},A={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},L=`${E[m]} ${A[x]}`,[D,P]=Et(n,s,a),[M,$]=p.useState(""),[I,T]=p.useState(!1),[K,H]=p.useState(0),B=p.useCallback(Z=>{if(h)return;const Q={amount:Z.amount,isCustom:!1,presetId:Z.id};P(Q),$(""),T(!1),H(W=>W+1),r?.(Q)},[h,P,r]),X=p.useCallback(Z=>{if(h)return;if($(Z!==void 0?String(Z):""),r){P(null);return}if(Z===void 0||isNaN(Z)){P(null);return}P({amount:Z,isCustom:!0})},[h,P,r]),J=p.useCallback(()=>{if(h)return;const Z=M!==""?parseFloat(M):void 0;Z===void 0||isNaN(Z)||r?.({amount:Z,isCustom:!0})},[h,M,r]),re=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),q=t.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[N.title&&t.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:N.title}),S.length>0&&t.jsx("div",{className:c.cn("grid gap-3",L),"data-testid":"donation-amounts-presets",children:S.map(Z=>{const Q=D!==null&&!D.isCustom&&D.presetId===Z.id;return t.jsx(U,{color:Q?"primary":y,variant:Q?"solid":g,className:"w-full",onPress:()=>B(Z),isDisabled:h,"data-testid":`donation-amounts-preset-${Z.id}`,children:Z.label||ic(Z.amount,l,i)},Z.id)})}),o&&t.jsxs("div",{className:"flex gap-3 items-start",children:[t.jsx(c.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:r?()=>{P(null),T(!0)}:void 0,variant:j,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:re,value:M!==""?parseFloat(M):void 0,onValueChange:X,isDisabled:h,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},r?`custom-${K}`:D?.isCustom===!1?D.presetId:"custom"),r&&t.jsx(U,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:J,isDisabled:h||!I,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return C?t.jsx(c.Card,{className:c.cn("w-full",v),"data-testid":"donation-amounts-card",children:t.jsx(c.CardBody,{children:q})}):t.jsx("div",{className:c.cn("w-full",v),"data-testid":"donation-amounts-plain",children:q})};Pa.displayName="DonationAmounts";const oc=e=>{const n=Math.max(0,e),s=Math.floor(n/60).toString().padStart(2,"0"),a=(n%60).toString().padStart(2,"0");return`${s}:${a} minutes`},cc=e=>{switch(e){case"warning":return G.Clock;case"error":return G.AlertCircle;case"success":return G.CheckCircle;default:return G.Clock}},dc=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"}},Oa=p.forwardRef(({timeLeft:e,defaultTimeLeft:n=1200,onTimeChange:s,onExpire:a,variant:r="info",color:i="primary",message:l="Your cart expires in:",showIcon:o=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:m=oc,className:x,...h},g)=>{const[y,j]=Et(e!==void 0?Math.max(0,e):void 0,Math.max(0,n),s),w=p.useRef(null),v=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||y<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{j(E=>E<=1?(w.current&&(clearInterval(w.current),w.current=null),v.current||(v.current=!0,a?.()),0):E-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,y,j,a]),p.useEffect(()=>{y>0&&(v.current=!1)},[y]);const C=d||cc(r),N=dc(i),S={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return t.jsx("div",{ref:g,role:"banner","aria-live":"polite","aria-label":`${l} ${m(y)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",N,S[u],x),...h,children:t.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[o&&t.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:t.jsx(C,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),t.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:l})]}),t.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:t.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${m(y)}`,"data-testid":"expire-cart-timer-value",children:m(y)})})]})})})});Oa.displayName="ExpireCartTimer";const Wt=({icon:e,children:n,testId:s})=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":s,children:[t.jsx(R,{icon:e,width:20,className:"text-default-500"}),t.jsx("span",{children:n})]}),uc=({classes:e="",name:n,imageUrl:s,eventDate:a,eventTime:r,location:i,description:l,showImage:o=!1,compact:d=!1,imageLoading:u="eager",showMoreButtonClassName:f,labels:m})=>{const[x,h]=p.useState(!1),[g,y]=p.useState(!1),j=p.useRef(null);return p.useEffect(()=>{const w=()=>{if(j.current){const v=j.current.scrollHeight>j.current.clientHeight;y(v)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[l]),t.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[t.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:[o&&s&&t.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:u,alt:`Event image for ${n}`,className:"w-full h-full object-cover object-center",src:s,"data-testid":"event-details-image"})}),t.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:n})]}),t.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[t.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:m.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[a&&t.jsx(Wt,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:a}),r&&t.jsx(Wt,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(Wt,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:j,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&g&&t.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"})]}),(g||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(U,{onPress:()=>h(!x),variant:"light",className:c.cn("text-primary",f),size:d?"sm":"md",startContent:t.jsx(R,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:x?m.showLess||"Hide":m.showMore||"Show"})})]})]})]})};function fn(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}function fc(e){const n=e.replace(/[^\d.,-]/g,""),s=n.match(/,\d{1,2}$/);let a;s?a=n.replace(/\./g,"").replace(",","."):a=n.replace(/,/g,"");const r=parseFloat(a);return isNaN(r)?null:r}const mc={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"},Ge=e=>typeof e=="number"&&!isNaN(e),wt=({offer:e,quantity:n,defaultQuantity:s=0,onQuantityChange:a,currency:r="USD",locale:i="en-US",labels:l,slots:o,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:m=!0,showDescription:x=!0,showPeopleCount:h=!0,showPrice:g=!0,priceDisplay:y,classNames:j={},"data-testid":w,selectedColor:v="default",compact:C=!1,isSoldOut:N,isMaxReached:S,isRuleBlocked:E,statusTone:A="default",statusLabel:L,disabledReason:D,disabled:P})=>{const M=p.useMemo(()=>({...mc,...l}),[l]),[$,I]=p.useState(s),T=n!==void 0?n:$,K=!!(d||P),H=C||!!e.compact,B=p.useMemo(()=>typeof N=="boolean"?N:typeof e.isSoldOut=="boolean"?e.isSoldOut:!Ge(e.totalTicketsSold)||!Ge(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[N,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),X=p.useMemo(()=>typeof S=="boolean"?S:typeof e.isMaxReached=="boolean"?e.isMaxReached:B||!Ge(e.ticketsAllowed)?!1:T>=e.ticketsAllowed-(e.totalTicketsSold??0),[S,e.isMaxReached,B,e.ticketsAllowed,e.totalTicketsSold,T]),J=p.useMemo(()=>typeof E=="boolean"?E:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[E,e.isRuleBlocked]),re=D||e.disabledReason,q=K||B||J,Z=ne=>{if(q||ne>0&&X)return;const me=Math.max(0,T+ne);n===void 0&&I(me),a?.(e.id,me)},Q=p.useMemo(()=>{if(B)return"soldOut";if(J)return"ruleBlocked";if(K)return"disabled"},[B,J,K]),W=p.useMemo(()=>A||(B||J?"danger":X?"warning":"default"),[A,B,J,X]),ee=p.useMemo(()=>{if(Q)return Q==="ruleBlocked"?L||re||M.ruleBlocked:Q==="soldOut"?L||re||M.soldOut:Q==="disabled"?L||re||M.disabled:L||M.maxReached},[Q,L,re,M]),te={soldOut:"danger",ruleBlocked:W,disabled:"default",maxReached:"warning"},ke={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},ye=()=>o?.renderName?o.renderName(e.name,e):t.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",H&&"text-sm",j.name),children:e.name}),xe=()=>{if(!g)return null;const ne=y?.price??e.price,me=y?.originalPrice,Me=fn(ne,i,r);if(o?.renderPrice)return o.renderPrice(ne,Me,e);if(Ge(me)&&Ge(ne)&&me>ne){const pe=fn(me,i,r);return t.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",H&&"mt-0.5",j.price),children:[t.jsxs("span",{className:"sr-only",children:["Original price ",pe,", discounted price ",Me]}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",H&&"text-xs",j.originalPrice),children:pe}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",H&&"text-sm",j.discountedPrice),children:Me})]})}return t.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",H&&"text-sm mt-0.5",j.price),children:Me})},Be=()=>!x||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):t.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",H&&"mb-2 text-xs text-gray-600",j.description),children:e.description}),Te=()=>{if(!h||!Ge(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ne=e.numberOfPeople===1?M.person:M.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ne,e):t.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",H&&"mt-1 text-xs",j.peopleCount),children:[t.jsx(R,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ne]})},_e=()=>{const ne=T===0||q,me=X||q;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:T,onIncrement:()=>Z(1),onDecrement:()=>Z(-1),isDecrementDisabled:ne,isIncrementDisabled:me,isDisabled:q}):t.jsxs("div",{className:c.cn("flex items-center gap-2",j.quantitySelector),children:[t.jsx(U,{"data-testid":"offer-card-decrement-button",onPress:()=>Z(-1),isDisabled:ne,variant:u,color:T>0?v:f,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Decrease quantity",children:t.jsx(R,{icon:"gravity-ui:minus",width:16})}),t.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",H&&"text-sm"),children:T}),t.jsx(U,{"data-testid":"offer-card-increment-button",onPress:()=>Z(1),isDisabled:me,variant:u,color:T>0?v:f,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Increase quantity",children:t.jsx(R,{icon:"gravity-ui:plus",width:16})})]})},Pe=(ne,me)=>o?.renderDisabledState?o.renderDisabledState(ne,me):ne==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(me):ne==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(me):t.jsx(c.Chip,{"data-testid":ke[ne],color:te[ne],variant:ne==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",ne==="maxReached"?"h-8":"h-10",ne==="soldOut"&&j.soldOut,ne==="maxReached"&&j.maxReachedAlert,H&&"h-8"),startContent:t.jsx(R,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:t.jsx("span",{className:"font-medium text-sm",children:me})}),Ve=t.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",H?"gap-1":"gap-2"),children:[t.jsxs("div",{className:c.cn("h-full col-span-2",q||X?"opacity-50 pointer-events-none select-none":""),children:[ye(),xe(),t.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",H?"mb-1":"mb-2"),children:[Te(),Be()]})]}),t.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",H&&"space-x-1 pb-1 md:p-1",j.compactFooter),children:Q&&ee?Pe(Q,ee):_e()})]}),Ee=X&&!B&&!J&&!K?t.jsx(Ne.motion.div,{className:c.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",j.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Pe("maxReached",ee||M.maxReached)}):null;return m?t.jsxs(c.Card,{className:c.cn("w-full",H&&j.compact,j.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",H?"pb-0.5":"",j.body),children:Ve}),t.jsx(Ne.AnimatePresence,{children:Ee&&t.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",H?"pt-1":"",j.footer),children:Ee})})]}):t.jsxs("div",{className:c.cn("w-full",H&&j.compact,j.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx("div",{className:c.cn("pt-1 pb-0",H?"pb-0.5":"",j.body),children:Ve}),t.jsx(Ne.AnimatePresence,{children:Ee&&t.jsx("div",{className:c.cn("w-full mt-0 pt-0",H?"pt-1":"",j.footer),children:Ee})})]})};wt.displayName="OfferCard";const Ra=({message:e="No offers available.",icon:n="solar:ticket-sale-outline",iconSize:s=48,showCard:a=!0,classNames:r={},renderEmpty:i})=>{if(i){const o=i();return a?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:o})}const l=t.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",r.content),children:[t.jsx(R,{"data-testid":"offer-card-empty-icon",icon:n,width:s,className:c.cn("mb-4",r.icon)}),t.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",r.message),children:e})]});return a?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:l})};Ra.displayName="OfferCardEmpty";const hc={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},za=({error:e,labels:n,showCard:s=!0,color:a="danger",classNames:r={}})=>{const i={...hc,...n},l=t.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:a,title:i.title,description:e||i.description,className:r.alert});return s?t.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:l})};za.displayName="OfferCardError";const xc={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Ba=({quantity:e=2,gap:n=4,classNames:s={}})=>{const a=xc[n];return t.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(a,s.base),children:Array.from({length:e}).map((r,i)=>t.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",s.card),children:[t.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:t.jsxs("div",{className:"space-y-2 w-full",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),t.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[t.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),t.jsx("div",{className:"flex items-start justify-end",children:t.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Ba.displayName="OfferCardSkeleton";const Va={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},Ua={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"}}},pc={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},Ha=({offers:e=[],mapOffer:n,selection:s,defaultSelection:a={},onSelectionChange:r,onQuantityChange:i,currency:l="USD",locale:o="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:m="bordered",buttonColor:x="default",showCard:h=!0,animated:g=!0,gap:y=2,compact:j=!1,classNames:w={}})=>{const[v,C]=p.useState(a),N=s!==void 0?s:v,S=p.useCallback((M,$)=>{const I={...N,[M]:Math.max(0,$)};s===void 0&&C(I),r?.(I),i?.(M,I[M])},[N,s,r,i]),E=[...e].sort((M,$)=>(M.position??0)-($.position??0)),A=M=>{const $=n?n(M):M,I=(N??{})[$.id]||0;return{offer:$,quantity:I,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:x,showCard:h,compact:j}},L=pc[y],D=c.cn("grid mx-auto pt-2",L,w.base),P=M=>{const $=A(M);return t.jsx(wt,{offer:$.offer,quantity:$.quantity,onQuantityChange:$.onQuantityChange,currency:$.currency,locale:$.locale,labels:$.labels,slots:$.slots,isDisabled:$.isDisabled,buttonVariant:$.buttonVariant,buttonColor:$.buttonColor,showCard:$.showCard,compact:$.compact,classNames:w.card},$.offer.id)};return g?t.jsx(Ne.motion.div,{"data-testid":"offer-card-list",className:D,variants:Va,initial:"hidden",animate:"show",children:t.jsx(Ne.AnimatePresence,{children:E.map(M=>{const $=A(M);return t.jsx(Ne.motion.div,{"data-testid":`offer-card-list-item-${$.offer.id}`,className:w.cardWrapper,variants:Ua,exit:{opacity:0,y:-20},transition:{duration:.3},children:t.jsx(wt,{offer:$.offer,quantity:$.quantity,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:x,showCard:h,compact:j||$.offer.compact,classNames:w.card})},$.offer.id)})})}):t.jsx("div",{"data-testid":"offer-card-list",className:D,children:E.map(P)})};Ha.displayName="OfferCardList";var ft=e=>e.type==="checkbox",We=e=>e instanceof Date,Ce=e=>e==null;const qa=e=>typeof e=="object";var fe=e=>!Ce(e)&&!Array.isArray(e)&&qa(e)&&!We(e),Wa=e=>fe(e)&&e.target?ft(e.target)?e.target.checked:e.target.value:e,gc=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ya=(e,n)=>e.has(gc(n)),bc=e=>{const n=e.constructor&&e.constructor.prototype;return fe(n)&&n.hasOwnProperty("isPrototypeOf")},Fn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(e){if(e instanceof Date)return new Date(e);const n=typeof FileList<"u"&&e instanceof FileList;if(Fn&&(e instanceof Blob||n))return e;const s=Array.isArray(e);if(!s&&!(fe(e)&&bc(e)))return e;const a=s?[]:Object.create(Object.getPrototypeOf(e));for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(a[r]=de(e[r]));return a}var Mt=e=>/^\w*$/.test(e),oe=e=>e===void 0,Mn=e=>Array.isArray(e)?e.filter(Boolean):[],Ln=e=>Mn(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,n,s)=>{if(!n||!fe(e))return s;const a=(Mt(n)?[n]:Ln(n)).reduce((r,i)=>Ce(r)?r:r[i],e);return oe(a)||a===e?oe(e[n])?s:e[n]:a},Se=e=>typeof e=="boolean",we=e=>typeof e=="function",ie=(e,n,s)=>{let a=-1;const r=Mt(n)?[n]:Ln(n),i=r.length,l=i-1;for(;++a<i;){const o=r[a];let d=s;if(a!==l){const u=e[o];d=fe(u)||Array.isArray(u)?u:isNaN(+r[a+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=d,e=e[o]}};const Nt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$e={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Le={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ga=p.createContext(null);Ga.displayName="HookFormControlContext";const In=()=>p.useContext(Ga);var Ka=(e,n,s,a=!0)=>{const r={defaultValues:n._defaultValues};for(const i in e)Object.defineProperty(r,i,{get:()=>{const l=i;return n._proxyFormState[l]!==$e.all&&(n._proxyFormState[l]=!a||$e.all),s&&(s[l]=!0),e[l]}});return r};const Tn=typeof window<"u"?p.useLayoutEffect:p.useEffect;function yc(e){const n=In(),{control:s=n,disabled:a,name:r,exact:i}=e||{},[l,o]=p.useState(s._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Tn(()=>s._subscribe({name:r,formState:d.current,exact:i,callback:u=>{!a&&o({...s._formState,...u})}}),[r,a,i]),p.useEffect(()=>{d.current.isValid&&s._setValid(!0)},[s]),p.useMemo(()=>Ka(l,s,d.current,!1),[l,s])}var Ae=e=>typeof e=="string",mn=(e,n,s,a,r)=>Ae(e)?(a&&n.watch.add(e),z(s,e,r)):Array.isArray(e)?e.map(i=>(a&&n.watch.add(i),z(s,i))):(a&&(n.watchAll=!0),s),hn=e=>Ce(e)||!qa(e);function De(e,n,s=new WeakSet){if(hn(e)||hn(n))return Object.is(e,n);if(We(e)&&We(n))return Object.is(e.getTime(),n.getTime());const a=Object.keys(e),r=Object.keys(n);if(a.length!==r.length)return!1;if(s.has(e)||s.has(n))return!0;s.add(e),s.add(n);for(const i of a){const l=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=n[i];if(We(l)&&We(o)||fe(l)&&fe(o)||Array.isArray(l)&&Array.isArray(o)?!De(l,o,s):!Object.is(l,o))return!1}}return!0}function vc(e){const n=In(),{control:s=n,name:a,defaultValue:r,disabled:i,exact:l,compute:o}=e||{},d=p.useRef(r),u=p.useRef(o),f=p.useRef(void 0),m=p.useRef(s),x=p.useRef(a);u.current=o;const[h,g]=p.useState(()=>{const N=s._getWatch(a,d.current);return u.current?u.current(N):N}),y=p.useCallback(N=>{const S=mn(a,s._names,N||s._formValues,!1,d.current);return u.current?u.current(S):S},[s._formValues,s._names,a]),j=p.useCallback(N=>{if(!i){const S=mn(a,s._names,N||s._formValues,!1,d.current);if(u.current){const E=u.current(S);De(E,f.current)||(g(E),f.current=E)}else g(S)}},[s._formValues,s._names,i,a]);Tn(()=>((m.current!==s||!De(x.current,a))&&(m.current=s,x.current=a,j()),s._subscribe({name:a,formState:{values:!0},exact:l,callback:N=>{j(N.values)}})),[s,l,a,j]),p.useEffect(()=>s._removeUnmounted());const w=m.current!==s,v=x.current,C=p.useMemo(()=>{if(i)return null;const N=!w&&!De(v,a);return w||N?y():null},[i,w,a,v,y]);return C!==null?C:h}function jc(e){const n=In(),{name:s,disabled:a,control:r=n,shouldUnregister:i,defaultValue:l,exact:o=!0}=e,d=Ya(r._names.array,s),u=p.useMemo(()=>z(r._formValues,s,z(r._defaultValues,s,l)),[r,s,l]),f=vc({control:r,name:s,defaultValue:u,exact:o}),m=yc({control:r,name:s,exact:o}),x=p.useRef(e),h=p.useRef(void 0),g=p.useRef(r.register(s,{...e.rules,value:f,...Se(e.disabled)?{disabled:e.disabled}:{}}));x.current=e;const y=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(m.errors,s)},isDirty:{enumerable:!0,get:()=>!!z(m.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!z(m.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!z(m.validatingFields,s)},error:{enumerable:!0,get:()=>z(m.errors,s)}}),[m,s]),j=p.useCallback(N=>g.current.onChange({target:{value:Wa(N),name:s},type:Nt.CHANGE}),[s]),w=p.useCallback(()=>g.current.onBlur({target:{value:z(r._formValues,s),name:s},type:Nt.BLUR}),[s,r._formValues]),v=p.useCallback(N=>{const S=z(r._fields,s);S&&S._f&&N&&(S._f.ref={focus:()=>we(N.focus)&&N.focus(),select:()=>we(N.select)&&N.select(),setCustomValidity:E=>we(N.setCustomValidity)&&N.setCustomValidity(E),reportValidity:()=>we(N.reportValidity)&&N.reportValidity()})},[r._fields,s]),C=p.useMemo(()=>({name:s,value:f,...Se(a)||m.disabled?{disabled:m.disabled||a}:{},onChange:j,onBlur:w,ref:v}),[s,a,m.disabled,j,w,v,f]);return p.useEffect(()=>{const N=r._options.shouldUnregister||i,S=h.current;S&&S!==s&&!d&&r.unregister(S),r.register(s,{...x.current.rules,...Se(x.current.disabled)?{disabled:x.current.disabled}:{}});const E=(A,L)=>{const D=z(r._fields,A);D&&D._f&&(D._f.mount=L)};if(E(s,!0),N){const A=de(z(r._options.defaultValues,s,x.current.defaultValue));ie(r._defaultValues,s,A),oe(z(r._formValues,s))&&ie(r._formValues,s,A)}return!d&&r.register(s),h.current=s,()=>{(d?N&&!r._state.action:N)?r.unregister(s):E(s,!1)}},[s,r,d,i]),p.useEffect(()=>{r._setDisabledField({disabled:a,name:s})},[a,s,r]),p.useMemo(()=>({field:C,formState:m,fieldState:y}),[C,m,y])}const wc=p.createContext(null);wc.displayName="HookFormContext";var Nc=(e,n,s,a,r)=>n?{...s[e],types:{...s[e]&&s[e].types?s[e].types:{},[a]:r||!0}}:{},lt=e=>Array.isArray(e)?e:[e],ws=()=>{let e=[];return{get observers(){return e},next:r=>{for(const i of e)i.next&&i.next(r)},subscribe:r=>(e.push(r),{unsubscribe:()=>{e=e.filter(i=>i!==r)}}),unsubscribe:()=>{e=[]}}};function Qa(e,n){const s={};for(const a in e)if(e.hasOwnProperty(a)){const r=e[a],i=n[a];if(r&&fe(r)&&i){const l=Qa(r,i);fe(l)&&(s[a]=l)}else e[a]&&(s[a]=i)}return s}var je=e=>fe(e)&&!Object.keys(e).length,_n=e=>e.type==="file",Ct=e=>{if(!Fn)return!1;const n=e?e.ownerDocument:0;return e instanceof(n&&n.defaultView?n.defaultView.HTMLElement:HTMLElement)},Za=e=>e.type==="select-multiple",Pn=e=>e.type==="radio",Cc=e=>Pn(e)||ft(e),Yt=e=>Ct(e)&&e.isConnected;function kc(e,n){const s=n.slice(0,-1).length;let a=0;for(;a<s;)e=oe(e)?a++:e[n[a++]];return e}function Sc(e){for(const n in e)if(e.hasOwnProperty(n)&&!oe(e[n]))return!1;return!0}function ue(e,n){const s=Array.isArray(n)?n:Mt(n)?[n]:Ln(n),a=s.length===1?e:kc(e,s),r=s.length-1,i=s[r];return a&&delete a[i],r!==0&&(fe(a)&&je(a)||Array.isArray(a)&&Sc(a))&&ue(e,s.slice(0,-1)),e}var Ac=e=>{for(const n in e)if(we(e[n]))return!0;return!1};function Xa(e){return Array.isArray(e)||fe(e)&&!Ac(e)}function xn(e,n={}){for(const s in e){const a=e[s];Xa(a)?(n[s]=Array.isArray(a)?[]:{},xn(a,n[s])):oe(a)||(n[s]=!0)}return n}function Ze(e,n,s){s||(s=xn(n));for(const a in e){const r=e[a];if(Xa(r))oe(n)||hn(s[a])?s[a]=xn(r,Array.isArray(r)?[]:{}):Ze(r,Ce(n)?{}:n[a],s[a]);else{const i=n[a];s[a]=!De(r,i)}}return s}const Ns={value:!1,isValid:!1},Cs={value:!0,isValid:!0};var Ja=e=>{if(Array.isArray(e)){if(e.length>1){const n=e.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:n,isValid:!!n.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!oe(e[0].attributes.value)?oe(e[0].value)||e[0].value===""?Cs:{value:e[0].value,isValid:!0}:Cs:Ns}return Ns},er=(e,{valueAsNumber:n,valueAsDate:s,setValueAs:a})=>oe(e)?e:n?e===""?NaN:e&&+e:s&&Ae(e)?new Date(e):a?a(e):e;const ks={isValid:!1,value:null};var tr=e=>Array.isArray(e)?e.reduce((n,s)=>s&&s.checked&&!s.disabled?{isValid:!0,value:s.value}:n,ks):ks;function Ss(e){const n=e.ref;return _n(n)?n.files:Pn(n)?tr(e.refs).value:Za(n)?[...n.selectedOptions].map(({value:s})=>s):ft(n)?Ja(e.refs).value:er(oe(n.value)?e.ref.value:n.value,e)}var $c=(e,n,s,a)=>{const r={};for(const i of e){const l=z(n,i);l&&ie(r,i,l._f)}return{criteriaMode:s,names:[...e],fields:r,shouldUseNativeValidation:a}},kt=e=>e instanceof RegExp,at=e=>oe(e)?e:kt(e)?e.source:fe(e)?kt(e.value)?e.value.source:e.value:e,As=e=>({isOnSubmit:!e||e===$e.onSubmit,isOnBlur:e===$e.onBlur,isOnChange:e===$e.onChange,isOnAll:e===$e.all,isOnTouch:e===$e.onTouched});const $s="AsyncFunction";var Dc=e=>!!e&&!!e.validate&&!!(we(e.validate)&&e.validate.constructor.name===$s||fe(e.validate)&&Object.values(e.validate).find(n=>n.constructor.name===$s)),Ec=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ds=(e,n,s)=>!s&&(n.watchAll||n.watch.has(e)||[...n.watch].some(a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length))));const ot=(e,n,s,a)=>{for(const r of s||Object.keys(e)){const i=z(e,r);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&n(l.refs[0],r)&&!a)return!0;if(l.ref&&n(l.ref,l.name)&&!a)return!0;if(ot(o,n))break}else if(fe(o)&&ot(o,n))break}}};function Es(e,n,s){const a=z(e,s);if(a||Mt(s))return{error:a,name:s};const r=s.split(".");for(;r.length;){const i=r.join("."),l=z(n,i),o=z(e,i);if(l&&!Array.isArray(l)&&s!==i)return{name:s};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};r.pop()}return{name:s}}var Fc=(e,n,s,a)=>{s(e);const{name:r,...i}=e;return je(i)||Object.keys(i).length>=Object.keys(n).length||Object.keys(i).find(l=>n[l]===(!a||$e.all))},Mc=(e,n,s)=>!e||!n||e===n||lt(e).some(a=>a&&(s?a===n:a.startsWith(n)||n.startsWith(a))),Lc=(e,n,s,a,r)=>r.isOnAll?!1:!s&&r.isOnTouch?!(n||e):(s?a.isOnBlur:r.isOnBlur)?!e:(s?a.isOnChange:r.isOnChange)?e:!0,Ic=(e,n)=>!Mn(z(e,n)).length&&ue(e,n),Tc=(e,n,s)=>{const a=lt(z(e,s));return ie(a,"root",n[s]),ie(e,s,a),e};function Fs(e,n,s="validate"){if(Ae(e)||Array.isArray(e)&&e.every(Ae)||Se(e)&&!e)return{type:s,message:Ae(e)?e:"",ref:n}}var Ke=e=>fe(e)&&!kt(e)?e:{value:e,message:""},Ms=async(e,n,s,a,r,i)=>{const{ref:l,refs:o,required:d,maxLength:u,minLength:f,min:m,max:x,pattern:h,validate:g,name:y,valueAsNumber:j,mount:w}=e._f,v=z(s,y);if(!w||n.has(y))return{};const C=o?o[0]:l,N=$=>{r&&C.reportValidity&&(C.setCustomValidity(Se($)?"":$||""),C.reportValidity())},S={},E=Pn(l),A=ft(l),L=E||A,D=(j||_n(l))&&oe(l.value)&&oe(v)||Ct(l)&&l.value===""||v===""||Array.isArray(v)&&!v.length,P=Nc.bind(null,y,a,S),M=($,I,T,K=Le.maxLength,H=Le.minLength)=>{const B=$?I:T;S[y]={type:$?K:H,message:B,ref:l,...P($?K:H,B)}};if(i?!Array.isArray(v)||!v.length:d&&(!L&&(D||Ce(v))||Se(v)&&!v||A&&!Ja(o).isValid||E&&!tr(o).isValid)){const{value:$,message:I}=Ae(d)?{value:!!d,message:d}:Ke(d);if($&&(S[y]={type:Le.required,message:I,ref:C,...P(Le.required,I)},!a))return N(I),S}if(!D&&(!Ce(m)||!Ce(x))){let $,I;const T=Ke(x),K=Ke(m);if(!Ce(v)&&!isNaN(v)){const H=l.valueAsNumber||v&&+v;Ce(T.value)||($=H>T.value),Ce(K.value)||(I=H<K.value)}else{const H=l.valueAsDate||new Date(v),B=re=>new Date(new Date().toDateString()+" "+re),X=l.type=="time",J=l.type=="week";Ae(T.value)&&v&&($=X?B(v)>B(T.value):J?v>T.value:H>new Date(T.value)),Ae(K.value)&&v&&(I=X?B(v)<B(K.value):J?v<K.value:H<new Date(K.value))}if(($||I)&&(M(!!$,T.message,K.message,Le.max,Le.min),!a))return N(S[y].message),S}if((u||f)&&!D&&(Ae(v)||i&&Array.isArray(v))){const $=Ke(u),I=Ke(f),T=!Ce($.value)&&v.length>+$.value,K=!Ce(I.value)&&v.length<+I.value;if((T||K)&&(M(T,$.message,I.message),!a))return N(S[y].message),S}if(h&&!D&&Ae(v)){const{value:$,message:I}=Ke(h);if(kt($)&&!v.match($)&&(S[y]={type:Le.pattern,message:I,ref:l,...P(Le.pattern,I)},!a))return N(I),S}if(g){if(we(g)){const $=await g(v,s),I=Fs($,C);if(I&&(S[y]={...I,...P(Le.validate,I.message)},!a))return N(I.message),S}else if(fe(g)){let $={};for(const I in g){if(!je($)&&!a)break;const T=Fs(await g[I](v,s),C,I);T&&($={...T,...P(I,T.message)},N(T.message),a&&(S[y]=$))}if(!je($)&&(S[y]={ref:C,...$},!a))return S}}return N(!0),S};const _c={mode:$e.onSubmit,reValidateMode:$e.onChange,shouldFocusError:!0};function Pc(e={}){let n={..._c,...e},s={submitCount:0,isDirty:!1,isReady:!1,isLoading:we(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},a={},r=fe(n.defaultValues)||fe(n.values)?de(n.defaultValues||n.values)||{}:{},i=n.shouldUnregister?{}:de(r),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={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},m={...f};let x={...m};const h={array:ws(),state:ws()},g=n.criteriaMode===$e.all,y=b=>k=>{clearTimeout(u),u=setTimeout(b,k)},j=async b=>{if(!l.keepIsValid&&!n.disabled&&(m.isValid||x.isValid||b)){let k;n.resolver?(k=je((await L()).errors),w()):k=await P(a,!0),k!==s.isValid&&h.state.next({isValid:k})}},w=(b,k)=>{!n.disabled&&(m.isValidating||m.validatingFields||x.isValidating||x.validatingFields)&&((b||Array.from(o.mount)).forEach(F=>{F&&(k?ie(s.validatingFields,F,k):ue(s.validatingFields,F))}),h.state.next({validatingFields:s.validatingFields,isValidating:!je(s.validatingFields)}))},v=(b,k=[],F,V,O=!0,_=!0)=>{if(V&&F&&!n.disabled){if(l.action=!0,_&&Array.isArray(z(a,b))){const Y=F(z(a,b),V.argA,V.argB);O&&ie(a,b,Y)}if(_&&Array.isArray(z(s.errors,b))){const Y=F(z(s.errors,b),V.argA,V.argB);O&&ie(s.errors,b,Y),Ic(s.errors,b)}if((m.touchedFields||x.touchedFields)&&_&&Array.isArray(z(s.touchedFields,b))){const Y=F(z(s.touchedFields,b),V.argA,V.argB);O&&ie(s.touchedFields,b,Y)}(m.dirtyFields||x.dirtyFields)&&(s.dirtyFields=Ze(r,i)),h.state.next({name:b,isDirty:$(b,k),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else ie(i,b,k)},C=(b,k)=>{ie(s.errors,b,k),h.state.next({errors:s.errors})},N=b=>{s.errors=b,h.state.next({errors:s.errors,isValid:!1})},S=(b,k,F,V)=>{const O=z(a,b);if(O){const _=z(i,b,oe(F)?z(r,b):F);oe(_)||V&&V.defaultChecked||k?ie(i,b,k?_:Ss(O._f)):K(b,_),l.mount&&!l.action&&j()}},E=(b,k,F,V,O)=>{let _=!1,Y=!1;const se={name:b};if(!n.disabled){if(!F||V){(m.isDirty||x.isDirty)&&(Y=s.isDirty,s.isDirty=se.isDirty=$(),_=Y!==se.isDirty);const ae=De(z(r,b),k);Y=!!z(s.dirtyFields,b),ae?ue(s.dirtyFields,b):ie(s.dirtyFields,b,!0),se.dirtyFields=s.dirtyFields,_=_||(m.dirtyFields||x.dirtyFields)&&Y!==!ae}if(F){const ae=z(s.touchedFields,b);ae||(ie(s.touchedFields,b,F),se.touchedFields=s.touchedFields,_=_||(m.touchedFields||x.touchedFields)&&ae!==F)}_&&O&&h.state.next(se)}return _?se:{}},A=(b,k,F,V)=>{const O=z(s.errors,b),_=(m.isValid||x.isValid)&&Se(k)&&s.isValid!==k;if(n.delayError&&F?(d=y(()=>C(b,F)),d(n.delayError)):(clearTimeout(u),d=null,F?ie(s.errors,b,F):ue(s.errors,b)),(F?!De(O,F):O)||!je(V)||_){const Y={...V,..._&&Se(k)?{isValid:k}:{},errors:s.errors,name:b};s={...s,...Y},h.state.next(Y)}},L=async b=>(w(b,!0),await n.resolver(i,n.context,$c(b||o.mount,a,n.criteriaMode,n.shouldUseNativeValidation))),D=async b=>{const{errors:k}=await L(b);if(w(b),b)for(const F of b){const V=z(k,F);V?ie(s.errors,F,V):ue(s.errors,F)}else s.errors=k;return k},P=async(b,k,F={valid:!0})=>{for(const V in b){const O=b[V];if(O){const{_f:_,...Y}=O;if(_){const se=o.array.has(_.name),ae=O._f&&Dc(O._f);ae&&m.validatingFields&&w([_.name],!0);const ve=await Ms(O,o.disabled,i,g,n.shouldUseNativeValidation&&!k,se);if(ae&&m.validatingFields&&w([_.name]),ve[_.name]&&(F.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(z(ve,_.name)?se?Tc(s.errors,ve,_.name):ie(s.errors,_.name,ve[_.name]):ue(s.errors,_.name))}!je(Y)&&await P(Y,k,F)}}return F.valid},M=()=>{for(const b of o.unMount){const k=z(a,b);k&&(k._f.refs?k._f.refs.every(F=>!Yt(F)):!Yt(k._f.ref))&&ye(b)}o.unMount=new Set},$=(b,k)=>!n.disabled&&(b&&k&&ie(i,b,k),!De(q(),r)),I=(b,k,F)=>mn(b,o,{...l.mount?i:oe(k)?r:Ae(b)?{[b]:k}:k},F,k),T=b=>Mn(z(l.mount?i:r,b,n.shouldUnregister?z(r,b,[]):[])),K=(b,k,F={})=>{const V=z(a,b);let O=k;if(V){const _=V._f;_&&(!_.disabled&&ie(i,b,er(k,_)),O=Ct(_.ref)&&Ce(k)?"":k,Za(_.ref)?[..._.ref.options].forEach(Y=>Y.selected=O.includes(Y.value)):_.refs?ft(_.ref)?_.refs.forEach(Y=>{(!Y.defaultChecked||!Y.disabled)&&(Array.isArray(O)?Y.checked=!!O.find(se=>se===Y.value):Y.checked=O===Y.value||!!O)}):_.refs.forEach(Y=>Y.checked=Y.value===O):_n(_.ref)?_.ref.value="":(_.ref.value=O,_.ref.type||h.state.next({name:b,values:de(i)})))}(F.shouldDirty||F.shouldTouch)&&E(b,O,F.shouldTouch,F.shouldDirty,!0),F.shouldValidate&&re(b)},H=(b,k,F)=>{for(const V in k){if(!k.hasOwnProperty(V))return;const O=k[V],_=b+"."+V,Y=z(a,_);(o.array.has(b)||fe(O)||Y&&!Y._f)&&!We(O)?H(_,O,F):K(_,O,F)}},B=(b,k,F={})=>{const V=z(a,b),O=o.array.has(b),_=de(k);ie(i,b,_),O?(h.array.next({name:b,values:de(i)}),(m.isDirty||m.dirtyFields||x.isDirty||x.dirtyFields)&&F.shouldDirty&&h.state.next({name:b,dirtyFields:Ze(r,i),isDirty:$(b,_)})):V&&!V._f&&!Ce(_)?H(b,_,F):K(b,_,F),Ds(b,o)?h.state.next({...s,name:b,values:de(i)}):h.state.next({name:l.mount?b:void 0,values:de(i)})},X=async b=>{l.mount=!0;const k=b.target;let F=k.name,V=!0;const O=z(a,F),_=ae=>{V=Number.isNaN(ae)||We(ae)&&isNaN(ae.getTime())||De(ae,z(i,F,ae))},Y=As(n.mode),se=As(n.reValidateMode);if(O){let ae,ve;const Ue=k.type?Ss(O._f):Wa(b),Oe=b.type===Nt.BLUR||b.type===Nt.FOCUS_OUT,ji=!Ec(O._f)&&!n.resolver&&!z(s.errors,F)&&!O._f.deps||Lc(Oe,z(s.touchedFields,F),s.isSubmitted,se,Y),Tt=Ds(F,o,Oe);ie(i,F,Ue),Oe?(!k||!k.readOnly)&&(O._f.onBlur&&O._f.onBlur(b),d&&d(0)):O._f.onChange&&O._f.onChange(b);const _t=E(F,Ue,Oe),wi=!je(_t)||Tt;if(!Oe&&h.state.next({name:F,type:b.type,values:de(i)}),ji)return(m.isValid||x.isValid)&&(n.mode==="onBlur"?Oe&&j():Oe||j()),wi&&h.state.next({name:F,...Tt?{}:_t});if(!Oe&&Tt&&h.state.next({...s}),n.resolver){const{errors:Zn}=await L([F]);if(w([F]),_(Ue),V){const Ni=Es(s.errors,a,F),Xn=Es(Zn,a,Ni.name||F);ae=Xn.error,F=Xn.name,ve=je(Zn)}}else w([F],!0),ae=(await Ms(O,o.disabled,i,g,n.shouldUseNativeValidation))[F],w([F]),_(Ue),V&&(ae?ve=!1:(m.isValid||x.isValid)&&(ve=await P(a,!0)));V&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&re(O._f.deps),A(F,ve,ae,_t))}},J=(b,k)=>{if(z(s.errors,k)&&b.focus)return b.focus(),1},re=async(b,k={})=>{let F,V;const O=lt(b);if(n.resolver){const _=await D(oe(b)?b:O);F=je(_),V=b?!O.some(Y=>z(_,Y)):F}else b?(V=(await Promise.all(O.map(async _=>{const Y=z(a,_);return await P(Y&&Y._f?{[_]:Y}:Y)}))).every(Boolean),!(!V&&!s.isValid)&&j()):V=F=await P(a);return h.state.next({...!Ae(b)||(m.isValid||x.isValid)&&F!==s.isValid?{}:{name:b},...n.resolver||!b?{isValid:F}:{},errors:s.errors}),k.shouldFocus&&!V&&ot(a,J,b?O:o.mount),V},q=(b,k)=>{let F={...l.mount?i:r};return k&&(F=Qa(k.dirtyFields?s.dirtyFields:s.touchedFields,F)),oe(b)?F:Ae(b)?z(F,b):b.map(V=>z(F,V))},Z=(b,k)=>({invalid:!!z((k||s).errors,b),isDirty:!!z((k||s).dirtyFields,b),error:z((k||s).errors,b),isValidating:!!z(s.validatingFields,b),isTouched:!!z((k||s).touchedFields,b)}),Q=b=>{b&<(b).forEach(k=>ue(s.errors,k)),h.state.next({errors:b?s.errors:{}})},W=(b,k,F)=>{const V=(z(a,b,{_f:{}})._f||{}).ref,O=z(s.errors,b)||{},{ref:_,message:Y,type:se,...ae}=O;ie(s.errors,b,{...ae,...k,ref:V}),h.state.next({name:b,errors:s.errors,isValid:!1}),F&&F.shouldFocus&&V&&V.focus&&V.focus()},ee=(b,k)=>we(b)?h.state.subscribe({next:F=>"values"in F&&b(I(void 0,k),F)}):I(b,k,!0),te=b=>h.state.subscribe({next:k=>{Mc(b.name,k.name,b.exact)&&Fc(k,b.formState||m,Me,b.reRenderRoot)&&b.callback({values:{...i},...s,...k,defaultValues:r})}}).unsubscribe,ke=b=>(l.mount=!0,x={...x,...b.formState},te({...b,formState:{...f,...b.formState}})),ye=(b,k={})=>{for(const F of b?lt(b):o.mount)o.mount.delete(F),o.array.delete(F),k.keepValue||(ue(a,F),ue(i,F)),!k.keepError&&ue(s.errors,F),!k.keepDirty&&ue(s.dirtyFields,F),!k.keepTouched&&ue(s.touchedFields,F),!k.keepIsValidating&&ue(s.validatingFields,F),!n.shouldUnregister&&!k.keepDefaultValue&&ue(r,F);h.state.next({values:de(i)}),h.state.next({...s,...k.keepDirty?{isDirty:$()}:{}}),!k.keepIsValid&&j()},xe=({disabled:b,name:k})=>{if(Se(b)&&l.mount||b||o.disabled.has(k)){const O=o.disabled.has(k)!==!!b;b?o.disabled.add(k):o.disabled.delete(k),O&&l.mount&&!l.action&&j()}},Be=(b,k={})=>{let F=z(a,b);const V=Se(k.disabled)||Se(n.disabled);return ie(a,b,{...F||{},_f:{...F&&F._f?F._f:{ref:{name:b}},name:b,mount:!0,...k}}),o.mount.add(b),F?xe({disabled:Se(k.disabled)?k.disabled:n.disabled,name:b}):S(b,!0,k.value),{...V?{disabled:k.disabled||n.disabled}:{},...n.progressive?{required:!!k.required,min:at(k.min),max:at(k.max),minLength:at(k.minLength),maxLength:at(k.maxLength),pattern:at(k.pattern)}:{},name:b,onChange:X,onBlur:X,ref:O=>{if(O){Be(b,k),F=z(a,b);const _=oe(O.value)&&O.querySelectorAll&&O.querySelectorAll("input,select,textarea")[0]||O,Y=Cc(_),se=F._f.refs||[];if(Y?se.find(ae=>ae===_):_===F._f.ref)return;ie(a,b,{_f:{...F._f,...Y?{refs:[...se.filter(Yt),_,...Array.isArray(z(r,b))?[{}]:[]],ref:{type:_.type,name:b}}:{ref:_}}}),S(b,!1,void 0,_)}else F=z(a,b,{}),F._f&&(F._f.mount=!1),(n.shouldUnregister||k.shouldUnregister)&&!(Ya(o.array,b)&&l.action)&&o.unMount.add(b)}}},Te=()=>n.shouldFocusError&&ot(a,J,o.mount),_e=b=>{Se(b)&&(h.state.next({disabled:b}),ot(a,(k,F)=>{const V=z(a,F);V&&(k.disabled=V._f.disabled||b,Array.isArray(V._f.refs)&&V._f.refs.forEach(O=>{O.disabled=V._f.disabled||b}))},0,!1))},Pe=(b,k)=>async F=>{let V;F&&(F.preventDefault&&F.preventDefault(),F.persist&&F.persist());let O=de(i);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:_,values:Y}=await L();w(),s.errors=_,O=de(Y)}else await P(a);if(o.disabled.size)for(const _ of o.disabled)ue(O,_);if(ue(s.errors,"root"),je(s.errors)){h.state.next({errors:{}});try{await b(O,F)}catch(_){V=_}}else k&&await k({...s.errors},F),Te(),setTimeout(Te);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:je(s.errors)&&!V,submitCount:s.submitCount+1,errors:s.errors}),V)throw V},Ve=(b,k={})=>{z(a,b)&&(oe(k.defaultValue)?B(b,de(z(r,b))):(B(b,k.defaultValue),ie(r,b,de(k.defaultValue))),k.keepTouched||ue(s.touchedFields,b),k.keepDirty||(ue(s.dirtyFields,b),s.isDirty=k.defaultValue?$(b,de(z(r,b))):$()),k.keepError||(ue(s.errors,b),m.isValid&&j()),h.state.next({...s}))},Ee=(b,k={})=>{const F=b?de(b):r,V=de(F),O=je(b),_=O?r:V;if(k.keepDefaultValues||(r=F),!k.keepValues){if(k.keepDirtyValues){const Y=new Set([...o.mount,...Object.keys(Ze(r,i))]);for(const se of Array.from(Y)){const ae=z(s.dirtyFields,se),ve=z(i,se),Ue=z(_,se);ae&&!oe(ve)?ie(_,se,ve):!ae&&!oe(Ue)&&B(se,Ue)}}else{if(Fn&&oe(b))for(const Y of o.mount){const se=z(a,Y);if(se&&se._f){const ae=Array.isArray(se._f.refs)?se._f.refs[0]:se._f.ref;if(Ct(ae)){const ve=ae.closest("form");if(ve){ve.reset();break}}}}if(k.keepFieldsRef)for(const Y of o.mount)B(Y,z(_,Y));else a={}}i=n.shouldUnregister?k.keepDefaultValues?de(r):{}:de(_),h.array.next({values:{..._}}),h.state.next({values:{..._}})}o={mount:k.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!n.shouldUnregister&&!je(_),l.watch=!!n.shouldUnregister,l.keepIsValid=!!k.keepIsValid,l.action=!1,k.keepErrors||(s.errors={}),h.state.next({submitCount:k.keepSubmitCount?s.submitCount:0,isDirty:O?!1:k.keepDirty?s.isDirty:!!(k.keepDefaultValues&&!De(b,r)),isSubmitted:k.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:O?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Ze(r,i):s.dirtyFields:k.keepDefaultValues&&b?Ze(r,b):k.keepDirty?s.dirtyFields:{},touchedFields:k.keepTouched?s.touchedFields:{},errors:k.keepErrors?s.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},ne=(b,k)=>Ee(we(b)?b(i):b,{...n.resetOptions,...k}),me=(b,k={})=>{const F=z(a,b),V=F&&F._f;if(V){const O=V.refs?V.refs[0]:V.ref;O.focus&&setTimeout(()=>{O.focus(),k.shouldSelect&&we(O.select)&&O.select()})}},Me=b=>{s={...s,...b}},pe={control:{register:Be,unregister:ye,getFieldState:Z,handleSubmit:Pe,setError:W,_subscribe:te,_runSchema:L,_updateIsValidating:w,_focusError:Te,_getWatch:I,_getDirty:$,_setValid:j,_setFieldArray:v,_setDisabledField:xe,_setErrors:N,_getFieldArray:T,_reset:Ee,_resetDefaultValues:()=>we(n.defaultValues)&&n.defaultValues().then(b=>{ne(b,n.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:_e,_subjects:h,_proxyFormState:m,get _fields(){return a},get _formValues(){return i},get _state(){return l},set _state(b){l=b},get _defaultValues(){return r},get _names(){return o},set _names(b){o=b},get _formState(){return s},get _options(){return n},set _options(b){n={...n,...b}}},subscribe:ke,trigger:re,register:Be,handleSubmit:Pe,watch:ee,setValue:B,getValues:q,reset:ne,resetField:Ve,clearErrors:Q,unregister:ye,setError:W,setFocus:me,getFieldState:Z};return{...pe,formControl:pe}}function Oc(e={}){const n=p.useRef(void 0),s=p.useRef(void 0),[a,r]=p.useState({isDirty:!1,isValidating:!1,isLoading:we(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:we(e.defaultValues)?void 0:e.defaultValues});if(!n.current)if(e.formControl)n.current={...e.formControl,formState:a},e.defaultValues&&!we(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Pc(e);n.current={...o,formState:a}}const i=n.current.control;return i._options=e,Tn(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>r({...i._formState}),reRenderRoot:!0});return r(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[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 l=i._getDirty();l!==a.isDirty&&i._subjects.state.next({isDirty:l})}},[i,a.isDirty]),p.useEffect(()=>{var l;e.values&&!De(e.values,s.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),s.current=e.values,r(o=>({...o}))):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()}),n.current.formState=p.useMemo(()=>Ka(a,i),[i,a]),n.current}function Rc(e,n=3){return e%1===0?e.toString():e.toFixed(n).replace(/\.?0+$/,"")}function zc(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}function Bc(e="USD",n="en-US"){try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Vc(e){const n=e.replace(/[^\d.,-]/g,""),s=n.match(/,\d{1,2}$/);let a;s?a=n.replace(/\./g,"").replace(",","."):a=n.replace(/,/g,"");const r=parseFloat(a);return isNaN(r)?null:r}function Uc(e,n,s=.001){const a=e-n,r=Math.abs(a)<=s;return{difference:a,isBalanced:r,isUnderAllocated:!r&&a>0,isOverAllocated:!r&&a<0}}function On(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}On();const Hc={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:"$"},Gt=()=>({id:On(),amount:0,glAccount:null,isTaxDeductible:!1}),nr=({distribution:e,defaultDistribution:n,glAccounts:s=[],isLoadingGlAccounts:a=!1,onSearchGlAccounts:r,onDistributionChange:i,onAmountChange:l,onGlAccountChange:o,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:m=!0,isDisabled:x=!1,labels:h,classNames:g={},"data-testid":y,control:j,name:w,rules:v})=>{const C={...Hc,...h},N=j!==void 0&&w!==void 0,S=Oc({defaultValues:{_internal:n||Gt()}}),E=jc({control:N?j:S.control,name:N?w:"_internal",rules:N?v:void 0}),[A,L]=p.useState(n||Gt()),D=N?E.field.value??Gt():e??A,P=N&&!!E.fieldState?.error,M=N&&(E.fieldState?.isTouched??!1),$=P||M,I=$&&(!D.amount||D.amount<=0),T=$&&!D.glAccount,[K,H]=p.useState(D.glAccount?.name||""),B=p.useCallback(W=>{const ee={...D,...W};N&&E.field.onChange(ee),!N&&e===void 0&&L(ee),i?.(ee)},[D,e,i,N,E]),X=p.useCallback(W=>{const ee=W||0;B({amount:ee}),l?.(ee)},[B,l]),J=p.useCallback(W=>{H(W),r?.(W)},[r]),re=p.useCallback(W=>{if(W===null){B({glAccount:null}),o?.(null);return}const te=s.find(ke=>String(ke.id)===String(W))||null;B({glAccount:te}),o?.(te)},[s,B,o]),q=p.useCallback(()=>{H(""),B({glAccount:null}),o?.(null)},[B,o]),Z=p.useCallback(W=>{B({isTaxDeductible:W}),d?.(W)},[B,d]),Q=p.useCallback(()=>{u?.()},[u]);return t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":y||"revenue-distribution-card",className:c.cn(g.base),children:t.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",g.body),children:[t.jsx("div",{className:c.cn("shrink-0",g.amountContainer),children:t.jsx(c.NumberInput,{"data-testid":`${y||"revenue-distribution-card"}-amount-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[C.amount,t.jsx(c.Tooltip,{content:C.amountTooltip,children:t.jsx(R,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:D.amount||void 0,onValueChange:X,labelPlacement:"outside",placeholder:C.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:x,isInvalid:I,errorMessage:I?"Amount is required":void 0,minValue:0,step:.01,className:g.amountInput,startContent:t.jsx("div",{className:"pointer-events-none flex items-center",children:t.jsx("span",{className:"text-default-400 text-small",children:C.currencySymbol})})})}),t.jsx("div",{className:c.cn("grow",g.glAccountContainer),children:t.jsx(c.Autocomplete,{"data-testid":`${y||"revenue-distribution-card"}-gl-account-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[C.glAccount,t.jsx(c.Tooltip,{content:C.glAccountTooltip,children:t.jsx(R,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:a,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:s,menuTrigger:"input",inputValue:D.glAccount?.name??K,selectedKey:D.glAccount?.id??null,isDisabled:x,isInvalid:T,errorMessage:T?"GL Account is required":void 0,listboxProps:{emptyContent:a?C.searching:C.noGlAccountsFound},placeholder:C.glAccountPlaceholder,onInputChange:J,onSelectionChange:re,onClear:q,className:g.glAccountInput,children:W=>t.jsx(c.AutocompleteItem,{textValue:W.name,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:W.name}),W.code&&t.jsx("span",{className:"text-xs text-default-400",children:W.code})]})},W.id)})}),t.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",g.taxDeductibleContainer),children:t.jsx(c.Checkbox,{radius:"full","data-testid":`${y||"revenue-distribution-card"}-tax-deductible`,isSelected:D.isTaxDeductible,onValueChange:Z,isDisabled:x||!m,className:g.taxDeductibleCheckbox,children:C.taxDeductible})}),t.jsx("div",{className:c.cn("shrink-0 pt-6",g.deleteContainer),children:t.jsx(U,{"data-testid":`${y||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:x||!f,onPress:Q,startContent:t.jsx(R,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",g.deleteButton),children:C.deleteButton})})]})})};nr.displayName="RevenueDistributionCard";const sr=({message:e="No distributions configured",icon:n="solar:document-text-outline",iconSize:s=48,showCard:a=!0,classNames:r={},renderEmpty:i})=>{if(i)return t.jsx(t.Fragment,{children:i()});const l=t.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",r.content),children:[t.jsx(R,{icon:n,width:s,className:c.cn("text-default-300 mb-4",r.icon)}),t.jsx("p",{className:c.cn("text-default-500 text-sm text-center",r.message),children:e})]});return a?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:l})};sr.displayName="RevenueDistributionEmpty";const qc={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},ar=({error:e,labels:n,showCard:s=!0,color:a="danger",classNames:r={}})=>{const i={...qc,...n},l=t.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:a,title:i.title,description:e||i.description,className:r.alert});return s?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:l})};ar.displayName="RevenueDistributionError";const rr=({rows:e=1,showCard:n=!0,classNames:s={}})=>{const a=Array.from({length:e},(i,l)=>l),r=i=>t.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",s.row),children:[t.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),t.jsxs("div",{className:"grow flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),t.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[t.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),t.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),t.jsx("div",{className:"shrink-0 pb-2",children:t.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return n?t.jsx("div",{className:c.cn("flex flex-col gap-3",s.base),children:a.map(i=>t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:t.jsx(c.CardBody,{children:r(i)})},i))}):t.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",s.base),children:a.map(i=>r(i))})};rr.displayName="RevenueDistributionSkeleton";function Lt({isOpen:e,labels:n,icon:s,isConfirming:a=!1,confirmColor:r="danger",iconTone:i="danger",portalContainer:l,shouldBlockScroll:o,classNames:d,onClose:u,onConfirm:f}){return t.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:l,shouldBlockScroll:o,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:m=>!m&&u(),children:t.jsxs(c.ModalContent,{children:[t.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[s&&t.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:s}),t.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:n.title})]}),t.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:t.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:n.description})}),t.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[t.jsx(U,{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:n.cancel}),t.jsx(U,{type:"button",size:"md",color:r,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",r==="danger"?"bg-danger-600":"bg-brand"),isLoading:a,onPress:f,children:n.confirm})]})]})})}const Wc=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function pn(e){return!e.fund&&Number(e.percentage||0)<=0}function Yc({mode:e,assignments:n}){const s=n.filter(l=>!pn(l)),a=s.filter(l=>l.fund),r=a.reduce((l,o)=>l+Number(o.percentage||0),0),i=s.some(l=>!l.fund||Number(l.percentage||0)<=0);return a.length>=1&&!i&&Math.round(r*100)/100===100}const Gc={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"},ir={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={...ir,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},Kc={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"},Qc={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function Zc(){return t.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[t.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const Xc=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,Jc=e=>e.fund!==null;function ed({assignments:e,funds:n,labels:s,classNames:a,isSaving:r=!1,hasSavedAssignments:i=!1,isFundPickerOpen:l=!1,activeAssignmentId:o=null,modalPortalContainer:d,footer:u,onAssignmentsChange:f,onOpenFundPicker:m,onCloseFundPicker:x,onCollapseChange:h,onSave:g}){const[y,j]=p.useState(null),w=d??y??void 0,v={...Gc,...s},C=e.filter(W=>!pn(W)),S=C.filter(Jc).length>0,E=p.useMemo(()=>e.filter(W=>!pn(W)).reduce((W,ee)=>W+Number(ee.percentage||0),0),[e]),A=Math.round(E*100)/100,L=C.some(W=>!W.fund||Number(W.percentage||0)<=0),D=S&&(A!==100||L),P=`${v.totalError} (${v.total} ${Number(E.toFixed(2))}%)`,M=Yc({mode:"split",assignments:e}),$=S&&A>=100,[I,T]=p.useState(!1),[K,H]=p.useState(!1),B=t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Zc,{}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:v.title})]}),X=(W,ee)=>{f(e.map(te=>te.id===W?{...te,...ee}:te))},J=()=>{$||f([...e,Wc()])},re=W=>{e.length<=1||f(e.filter(ee=>ee.id!==W))},q=()=>{if(!r){if(!M){H(!0);return}if(!i){g();return}T(!0)}},Z=()=>{T(!1),g()},Q=W=>{const ee=o??e.find(te=>!te.fund)?.id??e[0]?.id;ee&&(f(e.map(te=>te.id===ee?{...te,fund:W}:te)),x())};return t.jsxs("div",{ref:j,className:c.cn("vvt-pa relative font-sans text-zinc-900",l&&!d&&"min-h-[560px]",a?.root),children:[t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:c.cn("w-full gap-0 px-0",a?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",a?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:W=>h?.(!(W==="all"||Array.from(W).length>0)),children:t.jsx(c.AccordionItem,{"aria-label":v.title,title:B,children:t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",a?.content),children:[t.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&t.jsx(c.Alert,{icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:ir,color:"default",variant:"flat",title:v.emptySplit}),S&&t.jsx(td,{assignments:e,labels:v,total:E,hasTotalError:K&&!M||D,validationMessage:P,onSelectFund:W=>m(W),onRemoveFund:re,onPercentageChange:(W,ee)=>X(W,{percentage:Xc(ee)})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx(U,{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:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),isDisabled:$,onPress:()=>S?J():m(),children:v.assignSpecificFund}),t.jsx(U,{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:r?void 0:t.jsx(R,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:r,onPress:q,children:v.saveAssignment})]})]}),u]})},"installment-fund-assignment")}),l&&t.jsx(nd,{funds:n,labels:v,selectedFundIds:e.map(W=>W.fund?.id).filter(Boolean),portalContainer:w,onSelect:Q,onClose:x}),t.jsx(Lt,{isOpen:I,labels:{title:v.modifyAssignedFundsTitle,description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:v.modifyAssignedFundsDescription}),t.jsx("p",{className:"mt-3",children:v.modifyAssignedFundsWarning})]}),cancel:v.modifyAssignedFundsCancel,confirm:v.modifyAssignedFundsConfirm},icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:w,shouldBlockScroll:!1,classNames:Qc,onClose:()=>T(!1),onConfirm:Z})]})}function td({assignments:e,labels:n,total:s,hasTotalError:a,validationMessage:r,onSelectFund:i,onRemoveFund:l,onPercentageChange:o}){return t.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>t.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:[t.jsx("div",{className:c.cn("flex min-h-11 min-w-0 flex-1 items-center","gap-4"),children:d.fund?t.jsxs(t.Fragment,{children:[t.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]}),t.jsx(U,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(d.id),children:"Replace"})]}):t.jsx(U,{type:"button",size:"lg",variant:"light",radius:"full",className:"justify-start px-4 text-lg font-normal text-zinc-900",startContent:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:n.assignSpecificFund})}),t.jsx("label",{className:"flex w-48 flex-none items-center",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>o(d.id,Number(f.target.value)),endContent:t.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:Kc})}),e.length>1&&t.jsx(U,{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:()=>l(d.id),"aria-label":n.removeFund,children:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),t.jsx(c.Alert,{icon:t.jsx(R,{icon:a?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:a?"warning":"success",variant:"flat",classNames:{...rt,base:c.cn(rt.base,a?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(rt.iconWrapper,a?"text-warning-700":"text-success-700"),alertIcon:c.cn(rt.alertIcon,a?"text-warning-700":"text-success-700"),title:c.cn(rt.title,a?"text-warning-700":"text-success-700")},title:a?r:`${n.total} ${Number(s.toFixed(2))}%`})]})}function nd({funds:e,labels:n,selectedFundIds:s,portalContainer:a,onSelect:r,onClose:i}){const[l,o]=p.useState(""),d=e.filter(u=>{if(s.includes(u.id))return!1;const f=l.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return t.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:a,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:t.jsxs(c.ModalContent,{className:"max-h-full",children:[t.jsx(c.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:n.modalTitle}),t.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[t.jsx(c.Input,{variant:"bordered","aria-label":n.searchPlaceholder,value:l,placeholder:n.searchPlaceholder,onChange:u=>o(u.target.value),startContent:t.jsx(R,{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"}}),t.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:[t.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:[t.jsx("span",{children:n.glCode}),t.jsx("span",{children:n.accountName}),t.jsx("span",{children:n.actions})]}),d.length===0&&t.jsx("div",{className:"p-4 text-sm text-zinc-500",children:n.noFunds}),d.map(u=>t.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:[t.jsx("span",{children:u.glCode}),t.jsx("span",{children:u.accountName}),t.jsx(U,{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:()=>r(u),children:n.select})]},u.id))]})]})]})})}function sd(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const ad={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function rd({totalAmount:e,remainingBalance:n,amountReceived:s,currency:a="USD",locale:r="en-US",labels:i,className:l}){const o={...ad,...i},d=new Intl.NumberFormat(r,{style:"currency",currency:a});return t.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",l),children:t.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[t.jsx(Kt,{label:o.totalAmount,value:d.format(e)}),t.jsx(Kt,{label:o.remainingBalance,value:d.format(n)}),t.jsx(Kt,{label:o.amountReceived,value:d.format(s)})]})})}function Kt({label:e,value:n}){return t.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[t.jsx("span",{className:"font-medium text-zinc-700",children:e}),t.jsx("span",{className:"font-normal text-zinc-950",children:n})]})}const id={monthly:1,quarterly:3,annual:12},lr=e=>{const[n,s,a]=e.split("-").map(Number);return{year:n,month:s,day:a}},ld=(e,n)=>new Date(e,n+1,0).getDate(),od=e=>{const n=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${n}-${s}-${a}`},cd=(e,n)=>{const{year:s,month:a,day:r}=lr(e),i=a-1+n,l=s+Math.floor(i/12),o=(i%12+12)%12,d=Math.min(r,ld(l,o));return new Date(l,o,d)},dd=(e,n)=>{const{year:s,month:a,day:r}=lr(e),i=new Date(s,a-1,r);return i.setDate(i.getDate()+n),i};function or(e,n){const s=Math.max(1,Math.floor(n.numberOfInstallments||1)),a=Math.round(e*100),r=Math.floor(a/s),i=a-r*s,l=id[n.frequency];return Array.from({length:s},(o,d)=>{const u=n.frequency==="weekly"?dd(n.firstInstallmentDate,d*7):cd(n.firstInstallmentDate,d*(l??1));return{id:crypto.randomUUID(),dueDate:od(u),amount:(r+(d===0?i:0))/100}})}function ud(e){return new Set(e.map((n,s)=>{const a=e[s+1]?.dueDate;return n.dueDate&&a&&n.dueDate>a?n.id:null}).filter(n=>!!n))}const fd={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."},md=["weekly","monthly","quarterly","annual"],hd=Array.from({length:31},(e,n)=>n+1),xd=["numberOfInstallments","frequency","firstInstallmentDate"],pd={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Ls=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),cr=e=>Math.round(e*100)/100,gd=(e,n)=>{const s=new Date(`${e}T00:00:00`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(s)},It=e=>{if(!e)return null;try{return fo(e)}catch{return null}},bd=e=>It(e)?.day??1,yd=(e,n)=>new Date(e,n,0).getDate(),vd=(e,n)=>{const s=It(e);if(!s)return e;const a=Math.min(n,yd(s.year,s.month));return s.set({day:a}).toString()},Is=e=>{const n=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${n}`};function jd({mode:e,donationAmount:n,currency:s="USD",locale:a="en-US",installments:r,automaticSettings:i,defaultTab:l="automatic",showTitle:o=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:m=xd,startDate:x,labels:h,classNames:g,isSaving:y=!1,isModeSwitchDisabled:j=!1,onModeChange:w,onAutomaticSettingsChange:v,onInstallmentsChange:C,onSave:N}){const[S,E]=p.useState(null),[A,L]=p.useState(l),D={...fd,...h},P=e??A,M=p.useMemo(()=>new Intl.NumberFormat(a,{style:"currency",currency:s}),[s,a]),$=p.useMemo(()=>({...i,firstInstallmentDate:m.includes("firstInstallmentDate")?i.firstInstallmentDate:m.includes("dayOfMonth")?i.firstInstallmentDate||x||"":x||i.firstInstallmentDate}),[i,m,x]),I=P==="automatic"?or(n,$):r,T=p.useMemo(()=>cr(I.reduce((te,ke)=>te+Number(ke.amount||0),0)),[I]),K=P==="manual"&&T-n>.009,[H,B]=p.useState(!1),X=o?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(G.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:D.title})]}):void 0,J=te=>{te!==P&&(e||L(te),w?.(te),te==="manual"&&r.length===0&&C([Ls()]))},re=(te,ke)=>{r.find(xe=>xe.id===te)?.status!=="paid"&&C(r.map(xe=>xe.id===te?{...xe,...ke}:xe))},q=()=>{C([...r,Ls()])},Z=te=>{r.find(ye=>ye.id===te)?.status!=="paid"&&C(r.filter(ye=>ye.id!==te))},Q=()=>{if(!y){if(K){B(!0);return}N?.()}},W=()=>{B(!1),N?.()},ee=t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",g?.content),children:[f||u?t.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?t.jsx(wd,{mode:P,labels:D,onModeChange:J,isDisabled:j,className:g?.tabs}):null,u?t.jsx(U,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto min-w-36",startContent:y?void 0:t.jsx(R,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:y,onPress:Q,children:D.saveInstallments}):null]}):null,t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",g?.preview),children:[P==="automatic"&&t.jsx(Nd,{settings:$,inputs:m,labels:D,className:g?.controls,onSettingsChange:v}),I.length===0&&t.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:P==="automatic"?D.emptyAutomatic:D.emptyManual}),I.length>0&&t.jsx(Cd,{mode:P,installments:I,labels:D,formatter:M,locale:a,onUpdateInstallment:re,onRemoveInstallment:Z}),P==="manual"&&t.jsx("div",{className:"flex flex-wrap gap-3",children:t.jsx(U,{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:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),onPress:q,children:D.addInstallment})}),t.jsx(Sd,{total:T,donationAmount:n,hasTotalIncreaseWarning:K,mode:P,installments:I,formatter:M,labels:D,className:g?.summary})]})]});return t.jsxs("div",{ref:E,className:c.cn("vvt-ps relative font-sans text-zinc-900",g?.root),children:[d?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",g?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",g?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":D.title,title:X,children:ee},"installment-schedule")}):ee,t.jsx(Lt,{isOpen:H,labels:{title:D.totalIncreaseConfirmationTitle,description:D.totalIncreaseConfirmationDescription,cancel:D.totalIncreaseConfirmationCancel,confirm:D.totalIncreaseConfirmationConfirm},icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",isConfirming:y,portalContainer:S??void 0,shouldBlockScroll:!1,classNames:pd,onClose:()=>B(!1),onConfirm:W})]})}function wd({mode:e,labels:n,className:s,isDisabled:a=!1,onModeChange:r}){return t.jsxs(c.Tabs,{"aria-label":n.title,selectedKey:e,isDisabled:a,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",s),onSelectionChange:i=>r(i),children:[t.jsx(c.Tab,{title:n.automaticMode},"automatic"),t.jsx(c.Tab,{title:n.manualMode},"manual")]})}function Nd({settings:e,inputs:n,labels:s,className:a,onSettingsChange:r}){const i=l=>{if(l==="numberOfInstallments")return t.jsx("div",{className:"min-w-0",children:t.jsx(c.Input,{variant:"bordered",label:s.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:o=>o.currentTarget.blur(),onChange:o=>{const d=o.target.value;r({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},l);if(l==="frequency")return t.jsx("div",{className:"min-w-0",children:t.jsx(Fe,{variant:"bordered",label:s.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:o=>{const d=Array.from(o)[0];typeof d=="string"&&r({...e,frequency:d})},children:md.map(o=>t.jsx(c.SelectItem,{textValue:s[o],children:s[o]},o))})},l);if(l==="dayOfMonth"){const o=String(bd(e.firstInstallmentDate));return t.jsx("div",{className:"min-w-0",children:t.jsx(Fe,{variant:"bordered",label:s.dayOfMonth,labelPlacement:"outside",selectedKeys:[o],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&r({...e,firstInstallmentDate:vd(e.firstInstallmentDate,u)})},children:hd.map(d=>t.jsx(c.SelectItem,{textValue:Is(d),children:Is(d)},String(d)))})},l)}return t.jsx("div",{className:"min-w-0",children:t.jsx(En,{variant:"bordered",label:s.firstInstallmentDate,labelPlacement:"outside",value:It(e.firstInstallmentDate),onChange:o=>r({...e,firstInstallmentDate:o?o.toString():""}),startContent:t.jsx(R,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},l)};return n.length===0?null:t.jsx("div",{className:c.cn("grid gap-4",a),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:n.map(i)})}function Cd({mode:e,installments:n,labels:s,formatter:a,locale:r,onUpdateInstallment:i,onRemoveInstallment:l}){const o=ud(n),d=new Set(n.map(u=>Number(u.amount||0)<=0?u.id:null).filter(u=>!!u));return e==="automatic"?t.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:t.jsx("div",{className:c.cn("flex flex-col gap-3",n.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:n.map((u,f)=>t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["#",f+1]}),t.jsx("span",{children:"▪"}),t.jsx("span",{children:gd(u.dueDate,r)}),f===0&&n.length>1&&t.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),t.jsx("span",{className:"text-zinc-950",children:a.format(u.amount)})]},u.id))})}):t.jsx("div",{className:"flex flex-col gap-2",children:n.map((u,f)=>{const m=o.has(u.id),x=d.has(u.id);return t.jsx("div",{className:"flex w-full flex-col gap-1",children:t.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[t.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:f+1}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(En,{variant:"bordered","aria-label":`${s.dueDate} ${f+1}`,isDisabled:u.status==="paid",isInvalid:m,errorMessage:m?s.dateOrderError:void 0,value:It(u.dueDate),onChange:h=>i(u.id,{dueDate:h?h.toString():""})})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:u.status==="paid",isInvalid:x,errorMessage:x?s.amountGreaterThanZeroError:void 0,value:String(u.amount||""),onChange:h=>i(u.id,{amount:cr(Number(h.target.value||0))}),startContent:t.jsx("span",{className:"text-zinc-900",children:"$"})})}),t.jsx(kd,{isDisabled:n.length<=1,isPaid:u.status==="paid",label:s.deleteInstallment,onRemove:()=>l(u.id)})]})},u.id)})})}function kd({isDisabled:e,isPaid:n,label:s,onRemove:a}){const r=t.jsx(U,{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||n,onPress:a,"aria-label":s,children:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return n?t.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:t.jsx("span",{className:"inline-flex",children:r})}):r}function Sd({total:e,donationAmount:n,hasTotalIncreaseWarning:s,mode:a,installments:r,formatter:i,labels:l,className:o}){const d=r.length,u=r[0]?.amount??0,f=r[1]?.amount??u,m=d>1&&Math.round(u*100)!==Math.round(f*100),x=Math.max(n-e,0),h=s?t.jsx("span",{children:l.totalIncreaseWarning}):a==="automatic"?m?t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records:"," ",t.jsx("strong",{children:i.format(u)})," first charge and"," ",t.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records of"," ",t.jsx("strong",{children:i.format(u)})," each."]}):t.jsxs("span",{children:["Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(n)}),"."]}),g=a==="automatic"?`Total: ${i.format(e)}`:s?`New total: ${i.format(e)}`:`${l.remaining}: ${i.format(x)}`;return t.jsx(c.Alert,{isClosable:!1,color:s?"warning":"default",variant:"flat",radius:"full",className:o,endContent:t.jsx("span",{className:"whitespace-nowrap",children:g}),title:h})}function Ad(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[t.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),t.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),t.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,n)=>t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},n))})]})}const Ts={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"},dr={paid:"Paid",schedule:"Schedule",payment_due:"Payment Due",overdue:"Overdue",failed:"Failed",refunded:"Refunded",disputed:"Disputed",canceled:"Canceled"},$d={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:t.jsxs(t.Fragment,{children:["Are you sure you want to delete this payment? ",t.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Dd={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Ed=[];function Fd({installments:e,currency:n,locale:s="en-US",showTitle:a=!0,showCard:r=!0,showEditPayment:i=!0,showDelete:l=!0,payNowHiddenStatuses:o=Ed,labels:d,isSaving:u=!1,onEditInstallments:f,onPayInstallment:m,onDeleteInstallment:x}){const[h,g]=p.useState(null),y={...$d,...d},[j,w]=p.useState(""),v=new Intl.NumberFormat(s,{style:"currency",currency:n}),C=a?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(G.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:y.title})]}):void 0,N=p.useMemo(()=>{const E=j.trim().toLowerCase();return E?e.filter(A=>{const L=A.status??"schedule";return[A.id,A.amount,A.dueDate,Qt(A.dueDate,s),L,dr[L]??L].join(" ").toLowerCase().includes(E)}):e},[s,e,j]),S=t.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[t.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[t.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:y.searchLabel}),t.jsx(c.Input,{variant:"bordered",size:"md",value:j,placeholder:y.searchPlaceholder,onChange:E=>w(E.target.value),startContent:t.jsx(R,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?t.jsx(U,{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:t.jsx(R,{icon:"solar:pen-outline",className:"size-4"}),isLoading:u,onPress:f,children:y.editInstallments}):null]}),t.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",N.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[N.map((E,A)=>{const L=E.status??"schedule";return t.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:t.jsxs(c.CardBody,{className:"gap-3 p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-xs text-default-500",children:["#",A+1]}),t.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:E.id||`PMT-${A+1}`})]}),t.jsx(_s,{status:L})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-default-500",children:y.amount}),t.jsx("p",{className:"font-medium text-foreground",children:v.format(E.amount)})]}),t.jsxs("div",{className:"text-right",children:[t.jsx("p",{className:"text-xs text-default-500",children:y.scheduledDate}),t.jsx("p",{className:"font-medium text-foreground",children:Qt(E.dueDate,s)})]})]}),t.jsx(Ps,{status:L,installment:E,labels:y,portalContainer:h??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:m,onDeleteInstallment:x})]})},E.id)}),N.length===0&&t.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:y.noInstallmentsFound})]})}),t.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:t.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-12"}),t.jsx("col",{}),t.jsx("col",{className:"w-24"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:"w-44"})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[t.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.installmentId}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.amount}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.scheduledDate}),t.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:y.status}),t.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:y.actions})]})}),t.jsxs("tbody",{children:[N.map((E,A)=>{const L=E.status??"schedule";return t.jsxs("tr",{className:"text-zinc-500",children:[t.jsx("td",{className:"px-2 py-3",children:A+1}),t.jsx("td",{className:"overflow-hidden px-2 py-3",children:t.jsx("span",{className:"block w-full truncate",children:E.id||`PMT-${A+1}`})}),t.jsx("td",{className:"px-2 py-3",children:v.format(E.amount)}),t.jsx("td",{className:"px-2 py-3",children:Qt(E.dueDate,s)}),t.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:t.jsx(_s,{status:L})}),t.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:t.jsx(Ps,{status:L,installment:E,labels:y,portalContainer:h??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:m,onDeleteInstallment:x})})]},E.id)}),N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:y.noInstallmentsFound})})]})]})})]});return t.jsx("div",{ref:g,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:r?t.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:t.jsx(c.AccordionItem,{"aria-label":y.title,title:C,children:S},"installment-table")}):S})}function _s({status:e}){return t.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",Ts[e]??Ts.schedule),startContent:t.jsx(Ld,{status:e}),children:dr[e]??e})}function Ps({status:e,installment:n,labels:s,portalContainer:a,showDelete:r,payNowHiddenStatuses:i,onPayInstallment:l,onDeleteInstallment:o}){const d=!i.includes(e);return t.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[d?t.jsx(U,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:e==="paid",startContent:t.jsx(R,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>l?.(n),children:s.payNow}):null,t.jsx(Md,{isFulfilled:e==="paid",showDelete:r,labels:s,portalContainer:a,onDelete:()=>o(n.id)})]})}function Md({isFulfilled:e,showDelete:n,labels:s,portalContainer:a,onDelete:r}){const[i,l]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[t.jsx(c.DropdownTrigger,{children:t.jsx(U,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:t.jsx(R,{icon:"solar:menu-dots-bold",className:"size-4"})})}),t.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&n&&!e&&l(!0)},children:[t.jsx(c.DropdownSection,{title:"Actions",showDivider:n,children:t.jsx(c.DropdownItem,{textValue:s.sendLink,description:s.sendLinkDescription,startContent:t.jsx(R,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:s.sendLink},"send-link")}),n?t.jsx(c.DropdownSection,{title:s.dangerZone,children:t.jsx(c.DropdownItem,{textValue:s.deleteInstallment,className:"text-danger-600",color:"danger",description:s.deleteInstallmentDescription,startContent:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:s.deleteInstallment},"delete")}):null]})]}),n?t.jsx(Lt,{isOpen:i,labels:{title:s.deleteInstallmentConfirmationTitle,description:s.deleteInstallmentConfirmationDescription,cancel:s.deleteInstallmentConfirmationCancel,confirm:s.deleteInstallmentConfirmationConfirm},icon:t.jsx(R,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:a,shouldBlockScroll:!1,classNames:Dd,onClose:()=>l(!1),onConfirm:()=>{l(!1),r()}}):null]})}function Ld({status:e}){return e==="paid"?t.jsx(R,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?t.jsx(R,{icon:"solar:close-circle-bold",className:"size-3"}):t.jsx(R,{icon:"solar:calendar-outline",className:"size-3"})}function Qt(e,n){const s=new Date(`${e}T00:00:00`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(s)}const Id={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Td=({cards:e,locale:n,currency:s,listHeightClassName:a="",labels:r,showRenewal:i=!0,defaultRenewalValue:l=!1,initialSelectedMembershipId:o=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:m=""})=>{const x=Array.isArray(e)?e:[],[h,g]=p.useState(o),[y,j]=p.useState(l),w={...Id,...r};p.useEffect(()=>{g(o)},[o]);const v=N=>{if(N===h){d&&f?.(N);return}g(N),f?.(N)},C=N=>{j(N),u?.(N)};return t.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",m),"data-testid":"membership-select-cards",children:[t.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),t.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&t.jsx(hr,{title:w.renewalTitle,description:w.renewalDescription,value:y,onValueChange:C}),t.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",a===""?"flex-1":c.cn("shrink-0",a)),"data-testid":"membership-select-cards-list",children:x.map(N=>t.jsx(ur,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:n,currency:s,isSelected:h===N.id,onSelect:v},N.id))})]})},ur=({itemKey:e,name:n,type:s,price:a,locale:r="en-US",currency:i="USD",showPrice:l=!0,isSelected:o=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:m,statusLabel:x,statusTone:h="default",className:g=""})=>{const y=new Intl.NumberFormat(r,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(a),j=!!d&&!f,w=m||x,v=()=>{j&&d?.(e)};return t.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:v,className:c.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",g),"data-testid":"item-card","data-selected":o,isDisabled:f,children:t.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[t.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[t.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:n}),s&&t.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:t.jsx("p",{className:"text-center",children:s})}),w&&t.jsx(c.Chip,{"data-testid":"item-card-status",color:h,size:"sm",variant:"flat",className:"px-2",children:w})]}),l&&t.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:y})]})})},Os="w-full bg-gray-100",Rs={variant:"light",color:"default"},fr=({id:e,title:n,media:s,imageUrl:a,imageAlt:r,imageClassName:i="",imageAspect:l="aspect-[4/3]",meta:o=[],price:d,action:u,footer:f,onPress:m,isPressable:x=!1,isDisabled:h=!1,compact:g=!1,className:y="",bodyClassName:j="",footerClassName:w="",dataTestId:v})=>{const C=!!(d&&d.value),N=!!u?.label,S=x&&!!m&&!N,E=!S,A=N?{variant:u?.variant??Rs.variant,color:u?.color??Rs.color,size:u?.size??"sm",isDisabled:h||u?.isDisabled,startContent:u?.icon?t.jsx(R,{icon:u.icon,width:16}):void 0}:null,L=s??(a?t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,Os,i),children:t.jsx(c.Image,{removeWrapper:!0,src:a,alt:r||n,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,Os,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:t.jsx(R,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return t.jsxs(c.Card,{"data-testid":v||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",y),isPressable:S,onPress:m,isDisabled:h,shadow:"sm",radius:"lg",children:[t.jsx("div",{children:L}),t.jsxs(c.CardBody,{className:c.cn("gap-3",g?"p-3":"p-4",j),children:[t.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",g?"text-sm":""),children:n}),o.length>0?t.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((D,P)=>t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(R,{icon:D.icon,className:"size-4 text-gray-400",width:16}),t.jsx("span",{children:D.label})]},`${D.label}-${P}`))}):null,(C||N)&&t.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",g?"pt-0.5":"",w),children:[C?t.jsxs("span",{className:c.cn("mr-auto text-gray-500",g?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&t.jsxs("span",{children:[d.label," "]}),t.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):t.jsx("span",{className:"ml-auto","aria-hidden":!0}),N&&E?t.jsx(U,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:A?.variant,color:A?.color,size:A?.size,startContent:A?.startContent,isDisabled:A?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?t.jsx("div",{className:"pt-1",children:f}):null]})]})};fr.displayName="CatalogItemCard";const _d={card:"gap-3 rounded-xl border border-dashed px-6 py-12",panel:"px-6 py-[72px]"},Pd={card:"size-12 rounded-2xl",panel:"size-[76px] rounded-[20px] border mb-[18px]"},Od={card:"text-base font-medium text-default-900",panel:"text-[17px] font-semibold text-acct-ink"},Rd={card:"max-w-sm text-sm text-default-600",panel:"max-w-[380px] text-sm text-acct-sub mt-1.5"},zd={card:"mt-1",panel:"mt-[22px]"},Bd="bg-acct-page border-acct-border text-acct-muted",Vd={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},Ud={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"},Hd={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"},qd={empty:"status",error:"alert",success:"status",loading:"status"},Wd={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function Yd(e,n,s,a){if(n===!1)return null;if(e==="loading"&&n===void 0)return t.jsx(c.Spinner,{size:"lg",color:"primary",className:a.spinner});if(p.isValidElement(n))return t.jsx(t.Fragment,{children:n});const r=typeof n=="string"?n:Vd[e];return r?t.jsx(R,{icon:r,width:s,height:s,"aria-hidden":"true",className:a.icon}):null}function et({variant:e="empty",surface:n="card",title:s,titleAs:a="p",description:r,icon:i,actions:l,role:o=qd[e],ariaLive:d=Wd[e],iconSize:u=24,className:f,classNames:m={},"data-testid":x="feedback-state"}){const h=Yd(e,i,u,m);return t.jsxs("div",{role:o,"aria-live":d,"data-variant":e,"data-testid":x,"data-surface":n,className:c.cn("flex flex-col items-center justify-center text-center",_d[n],n==="card"?Ud[e]:"bg-transparent",f,m.base),children:[h?t.jsx("span",{"aria-hidden":"true","data-testid":`${x}-icon`,className:c.cn("inline-flex items-center justify-center",Pd[n],e==="success"&&n==="card"&&"rounded-full",n==="panel"?Bd:Hd[e],m.iconWrapper),children:h}):null,t.jsxs("div",{className:c.cn("flex flex-col items-center",n==="card"&&"gap-1"),children:[t.jsx(a,{"data-testid":`${x}-title`,className:c.cn(Od[n],m.title),children:s}),r?t.jsx("p",{"data-testid":`${x}-description`,className:c.cn(Rd[n],m.description),children:r}):null]}),l?t.jsx("div",{"data-testid":`${x}-actions`,className:c.cn("flex flex-wrap items-center justify-center gap-2",zd[n],m.actions),children:l}):null]})}function Rn(e){return t.jsx(et,{...e,variant:"empty"})}function zn(e){return t.jsx(et,{...e,variant:"error"})}function Bn(e){return t.jsx(et,{...e,variant:"loading"})}function mr(e){return t.jsx(et,{...e,variant:"success"})}et.displayName="FeedbackState";Rn.displayName="EmptyState";zn.displayName="ErrorState";Bn.displayName="LoadingState";mr.displayName="SuccessState";const hr=({title:e,value:n,description:s,onValueChange:a,className:r=""})=>{const i=p.useId();return t.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||s?"justify-between gap-6":"justify-start",r),"data-testid":"toggle",children:[t.jsxs("div",{className:"flex flex-col items-start",children:[e&&t.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),s&&t.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:s})]}),t.jsx(c.Switch,{id:i,isSelected:n,onValueChange:a,"data-testid":"toggle-switch"})]})},Gd={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"},Kd=(e,n)=>new Intl.NumberFormat(e,{style:"currency",currency:n}),xr=e=>Object.values(e).reduce((n,s)=>n+Object.values(s).reduce((a,r)=>a+Object.values(r).reduce((i,l)=>i+l.selectedQuantity,0),0),0),Qd=e=>e.reduce((n,s)=>n+s.dates.reduce((a,r)=>a+r.tickets.reduce((i,l)=>i+l.max,0),0),0),Vn=e=>e.flatMap(n=>n.dates.flatMap(s=>s.tickets.map(a=>({exhibition:n,dateGroup:s,ticket:a})))),zs=(e,n,s)=>{const a={};let r=s?n??Qd(e):0;for(const{exhibition:i,dateGroup:l,ticket:o}of Vn(e)){a[i.id]??={},a[i.id][l.id]??={};const d=s?Math.min(o.max,r):0;a[i.id][l.id][o.id]={id:o.id,selectedQuantity:d,originalPrice:o.originalPrice,discountedPrice:o.price},r-=d}return a},Bs=(e,n,s)=>`${e}::${n}::${s}`,Zd=(e,n,s)=>{const a=xr(n);for(const{exhibition:r,dateGroup:i,ticket:l}of Vn(e)){const o=n[r.id]?.[i.id]?.[l.id]?.selectedQuantity??0,d=s===void 0?l.max:Math.min(l.max,s-(a-o));if(d>0&&o<d)return!1}return!0},Xd=({initialQuantity:e=1,minQuantity:n=1,maxQuantity:s=10,onChange:a,disabled:r=!1})=>{const i=Math.max(n,Math.min(s,e)),[l,o]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?l:String(i),m=()=>{r||i>=s||a?.(i+1)},x=()=>{r||i<=n||a?.(i-1)},h=N=>{if(r)return;o(N.target.value);const S=parseInt(N.target.value,10);isNaN(S)||a?.(Math.max(n,Math.min(s,S)))},g=N=>{const S=parseInt(N.target.value,10);if(u(!1),isNaN(S)){a?.(n);return}const E=Math.max(n,Math.min(s,S));E!==S?a?.(E):o(String(E))},y=i<=n,j=i>=s,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",v="bg-primary hover:bg-primary/80",C="bg-primary/40 cursor-not-allowed";return t.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[t.jsx("button",{type:"button",onClick:x,disabled:r||y,className:c.cn(w,r||y?C:v),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),t.jsx("input",{type:"number",value:f,onChange:h,onFocus:()=>u(!0),onBlur:g,disabled:r,min:n,max:s,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"}),t.jsx("button",{type:"button",onClick:m,disabled:r||j,className:c.cn(w,r||j?C:v),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Jd=({label:e,checked:n=!1,onChange:s,disabled:a=!1})=>{const r=()=>{a||s?.(!n)};return t.jsxs("button",{type:"button",onClick:r,disabled:a,role:"checkbox","aria-checked":n,"data-testid":"checkbox-button","data-checked":n,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",a&&"cursor-not-allowed opacity-60"),children:[t.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:()=>{},disabled:a,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),t.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",n?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:n&&t.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"})})]}),t.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},eu=({item:e,quantity:n,onChange:s,getTotalSelectedTickets:a,userMaxLimit:r,settings:i,labels:l})=>{const o=()=>{if(!a||r===void 0)return e.max;const m=a();return Math.min(e.max,r-(m-n))},d=i?.locale??"en-US",u=i?.currency??"USD",f=Kd(d,u);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[t.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?t.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.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)}),t.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?t.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:t.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,t.jsx("div",{className:"text-sm text-zinc-500",children:t.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[l.ticketsAllowedToRedeem," ",e.max]})})]}),t.jsx(Xd,{initialQuantity:n,minQuantity:0,maxQuantity:o(),onChange:s})]}),e.membershipAlert?t.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:t.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]})},tu=({exhibitionId:e,dateGroup:n,isLast:s=!1,onQuantityChange:a,getTicketQuantity:r,getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d})=>t.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!s&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[t.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:n.date}),n.tickets.map((u,f)=>t.jsxs("div",{children:[t.jsx(eu,{item:u,quantity:r(e,n.id,u.id),onChange:m=>a(e,n.id,u.id,m),getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d}),f<n.tickets.length-1?t.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),nu=({title:e,exhibition:n,onQuantityChange:s,getTicketQuantity:a,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),m=n.dates.reduce((h,g)=>h+g.tickets.reduce((y,j)=>y+a(n.id,g.id,j.id),0),0),x=n.dates.some(h=>h.tickets.length>0);return t.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[t.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-${n.id}`,"data-testid":"upgrade-ticket-header-button",children:t.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[t.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[m," ",o.ticketsSelectedToRedeem]}),t.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:t.jsx(R,{icon:"mdi:chevron-down"})})]})]})}),t.jsx("div",{id:`upgrade-items-${n.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&&t.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:x?n.dates.map((h,g)=>t.jsx(tu,{exhibitionId:n.id,dateGroup:h,isLast:g===n.dates.length-1,onQuantityChange:s,getTicketQuantity:a,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o},h.id)):t.jsx("div",{className:"px-5 py-10 text-center",children:t.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},su=({initialExpanded:e=!1,userMaxLimit:n,labels:s,settings:a,ticketSelectionData:r,className:i="",onSelectionChange:l})=>{const o=p.useMemo(()=>r??[],[r]),d={...Gd,...s},[u,f]=p.useState(()=>zs(o,n,!0)),m=p.useRef(!1),x=p.useMemo(()=>{const v=Vn(o).map(({exhibition:C,dateGroup:N,ticket:S})=>[Bs(C.id,N.id,S.id),S]);return new Map(v)},[o]),h=Zd(o,u,n),g=(v,C,N)=>u[v]?.[C]?.[N]?.selectedQuantity??0,y=()=>xr(u),j=(v,C,N,S)=>{const E=g(v,C,N),A=y()-E;if(n!==void 0&&A+S>n)return;const L=x.get(Bs(v,C,N));if(!L)return;const D={...u,[v]:{...u[v],[C]:{...u[v]?.[C],[N]:{id:N,selectedQuantity:S,originalPrice:L.originalPrice,discountedPrice:L.price}}}};f(D),l?.(D)},w=v=>{const C=zs(o,n,v);f(C),l?.(C)};return p.useEffect(()=>{!m.current&&h&&(l?.(u),m.current=!0)},[h,u,l]),t.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[t.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),t.jsx(Jd,{label:d.selectAllButtonLabel,checked:h,onChange:w})]}),o.map(v=>t.jsx(nu,{title:v.exhibitionName,exhibition:v,onQuantityChange:j,getTicketQuantity:g,getTotalSelectedTickets:y,userMaxLimit:n,settings:a,labels:d,initialExpanded:e},v.id))]})},Zt={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Xt=e=>{const n={};for(const s of e)s.type==="checkbox"?n[s.id]=[...s.selectedValues]:n[s.id]=s.selectedValue?[s.selectedValue]:[];return n},au=(e,n)=>{const s={};for(const a of n){if(a.type==="checkbox"){s[a.id]=e[a.id]??[...a.selectedValues];continue}const r=e[a.id]??[];s[a.id]=r.length>0?r[0]:null}return s},ru=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,pr=({triggerLabel:e,triggerAriaLabel:n,triggerIcon:s="solar:tuning-square-outline",triggerVariant:a="bordered",triggerColor:r="default",triggerSize:i="sm",triggerClassName:l,popoverClassName:o,className:d,sections:u,onConfirm:f,onClear:m,appliedCount:x,countAriaLabel:h,countDisplay:g="badge",confirmLabel:y=Zt.confirm,clearLabel:j=Zt.clear,isOpen:w,defaultOpen:v=!1,onOpenChange:C,isDisabled:N=!1,closeOnConfirm:S=!0,keepOpenAfterClear:E=!1})=>{const[A,L]=p.useState(v),[D,P]=p.useState(()=>Xt(u)),M=w??A,$=x??u.filter(q=>ru(q)).length,I=q=>{q&&P(Xt(u)),w||L(q),C?.(q)},T=(q,Z)=>{P(Q=>({...Q,[q.id]:Z}))},K=(q,Z)=>{P(Q=>({...Q,[q.id]:Z?[Z]:[]}))},H=async()=>{P(Xt(u.map(q=>q.type==="checkbox"?{...q,selectedValues:[]}:{...q,selectedValue:null}))),await m(),E||I(!1)},B=async()=>{const q=au(D,u);await f(q),S&&I(!1)},X=q=>{if(q.type==="checkbox")return t.jsx(c.CheckboxGroup,{label:q.label,value:D[q.id]??[],onValueChange:Q=>T(q,Q),children:q.options.map(Q=>t.jsx(c.Checkbox,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},q.id);const Z=D[q.id]?.[0]??"";return t.jsx(c.RadioGroup,{label:q.label,value:Z,onValueChange:Q=>K(q,Q||null),children:q.options.map(Q=>t.jsx(c.Radio,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},q.id)},J=p.useMemo(()=>$>0?h?.($)||`${$} filters applied`:void 0,[h,$]),re=p.useMemo(()=>$===0?e||Zt.noLabel:h?h($):`${e} (${$})`,[$,e,h]);return t.jsx("div",{className:d,children:t.jsxs(c.Popover,{isOpen:M,onOpenChange:I,placement:"bottom-end",children:[t.jsx(c.PopoverTrigger,{children:t.jsxs(U,{isDisabled:N,variant:a,color:r,size:i,className:l,"aria-label":n,"aria-haspopup":"dialog","aria-expanded":M,children:[t.jsx(R,{icon:s,width:16}),t.jsx("span",{children:e}),g==="badge"&&$>0?t.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":J,children:$}):g==="summary"&&re!==e?t.jsx("span",{className:"text-xs",children:re}):null]})}),t.jsx(c.PopoverContent,{className:o,children:t.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(q=>X(q)),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[t.jsx(U,{variant:"light",color:"default",size:"sm",onPress:H,children:j}),t.jsx(U,{color:"primary",size:"sm",onPress:B,children:y})]})]})})]})})};pr.displayName="FilterPopover";const iu="No sessions available for this date",lu=e=>e==="sold-out"||e==="closed"?"danger":"success",ou=e=>{const n=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof n=="number"?`${n} left`:"Limited":typeof n=="number"?`${n} seats available`:"Available"},Vs=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",cu=(e,n)=>n&&e.some(s=>s.date===n)?n:e[0]?.date??null,gr=({heading:e,subheading:n,days:s,selectedDate:a,onDateSelect:r,quickDates:i,selectedSessionId:l=null,onSessionSelect:o,emptyStateMessage:d=iu,statusLabel:u,statusTone:f,sessionAriaLabel:m,dayButtonClassName:x,calendarSlot:h,dayGroupAriaLabel:g,sessionGridAriaLabel:y,className:j,headingClassName:w,subheadingClassName:v})=>{const C=cu(s,a),N=s.find(D=>D.date===C),S=i??s.map(D=>({date:D.date,label:D.label})),E=N?.sessions??[],A=D=>D===C?"solid":"bordered",L=D=>{if(!Vs(D)){if(D.id===l){o(null);return}o(D.id)}};return t.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",j),"data-testid":"session-timeline-root",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),n?t.jsx("p",{className:c.cn("text-sm text-gray-700",v),children:n}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":g||"Session days",children:[S.map(D=>t.jsx(U,{size:"sm",variant:A(D.date),color:"default",className:c.cn("rounded-full",x),isDisabled:D.isDisabled,onPress:()=>{r(D.date)},children:t.jsx("span",{children:D.label})},D.date)),h?t.jsx("div",{children:h}):null]}),t.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":y||"Sessions",children:[E.length===0?t.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,E.map(D=>{const P=Vs(D),M=D.id===l;return t.jsx("li",{className:"rounded-xl",children:t.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!P,onPress:()=>{L(D)},"aria-disabled":P,"aria-pressed":P?void 0:M,className:c.cn("w-full",P?"bg-gray-100 opacity-70":"",M?"w-full ring-2 ring-gray-900":""),"aria-label":m?m(D,{isSelected:M,isUnavailable:P}):P?`${D.startTime} ${D.endTime} sold out`:`${D.startTime} ${D.endTime} available`,children:t.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[t.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[D.startTime," – ",D.endTime]}),t.jsx(c.Chip,{size:"sm",color:f?f(D):lu(D.status),variant:"flat",children:u?u(D):ou(D)})]})})},D.id)})]})]})};gr.displayName="SessionTimeline";const du=(e,n)=>typeof e=="string"?t.jsx(R,{icon:e,className:"size-5","aria-hidden":"true"}):e||n||null,br=({title:e,subtitle:n,eyebrow:s,icon:a,initials:r,actions:i,titleAs:l="h1",className:o,classNames:d={},"data-testid":u="page-header"})=>{const f=du(a,r);return t.jsxs("header",{"data-testid":u,className:c.cn("flex flex-wrap items-start justify-between gap-4",o,d.base),children:[t.jsxs("div",{className:"flex items-center gap-4",children:[f?t.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,t.jsxs("div",{children:[s?t.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:s}):null,t.jsx(l,{"data-testid":`${u}-title`,className:c.cn("text-3xl font-semibold text-gray-950",d.title),children:e}),n?t.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn("mt-1 text-sm text-gray-600",d.subtitle),children:n}):null]})]}),i?t.jsx("div",{"data-testid":`${u}-actions`,className:c.cn("flex flex-wrap items-center gap-2",d.actions),children:i}):null]})};br.displayName="PageHeader";const uu={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default"},fu={active:{fg:"#057A54",bg:"#E6F4EF"},success:{fg:"#057A54",bg:"#E6F4EF"},draft:{fg:"#B7791F",bg:"#FBF0DD"},pending:{fg:"#B7791F",bg:"#FBF0DD"},warning:{fg:"#B7791F",bg:"#FBF0DD"},danger:{fg:"#B62214",bg:"#FBEAE8"},archived:{fg:"#9CA3AF",bg:"#F1F2F4"},inactive:{fg:"#9CA3AF",bg:"#F1F2F4"},neutral:{fg:"#9CA3AF",bg:"#F1F2F4"}},yr=({status:e,label:n,variant:s="flat",size:a="sm",color:r,startContent:i,className:l,"data-testid":o="status-chip"})=>{if(s==="dot"){const d=fu[e];return t.jsxs("span",{"data-testid":o,"data-status":e,className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 py-[3px] text-[12px] font-semibold leading-[1.4]",l),style:{color:d.fg,backgroundColor:d.bg},children:[t.jsx("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:"currentColor"}}),n]})}return t.jsx(c.Chip,{color:r??uu[e],variant:s,size:a,startContent:i,"data-testid":o,"data-status":e,className:c.cn("font-medium",l),children:n})};yr.displayName="StatusChip";const mu={sm:"gap-1 rounded-md px-2 py-0.5 text-[11.5px] leading-normal",md:"gap-1.5 rounded-lg px-2.5 py-1 text-xs leading-normal"},Un=({label:e,value:n,size:s="sm",className:a,"data-testid":r="key-value-chip"})=>t.jsxs("span",{"data-testid":r,className:c.cn("inline-flex items-baseline whitespace-nowrap border border-default-200 bg-default-100",mu[s],a),children:[t.jsx("span",{className:"font-medium text-default-400",children:e}),t.jsx("span",{className:"font-semibold text-default-700",children:n})]});Un.displayName="KeyValueChip";const vr=({columns:e,rows:n=6,label:s="Loading",barHeight:a=12,alignLastRight:r=!1,className:i,classNames:l={},"data-testid":o="table-skeleton"})=>t.jsxs("div",{role:"status","aria-busy":"true","data-testid":o,className:c.cn("w-full",i,l.base),children:[t.jsx("span",{className:"sr-only",children:s}),t.jsx("div",{"aria-hidden":"true",children:Array.from({length:n}).map((d,u)=>t.jsx("div",{"data-testid":`${o}-row`,className:c.cn("flex items-center gap-3 border-t border-default-100 px-5 py-4",l.row),children:e.map((f,m)=>{const x=m===e.length-1;return t.jsx("div",{className:c.cn(f==="fill"?"flex-1":"shrink-0",r&&x&&"flex justify-end"),style:f==="fill"?void 0:{width:f},children:t.jsx("div",{className:c.cn("animate-pulse rounded bg-default-200",l.bar),style:{height:a,width:f==="fill"?"60%":f}})},m)})},u))})]});vr.displayName="TableSkeleton";const jr="text-left text-[11px] font-semibold uppercase tracking-[.04em] text-acct-sub px-4 pt-4 pb-3 whitespace-nowrap bg-transparent",wr="px-4 text-[13.5px] text-acct-ink2 align-middle",Nr="border-t border-acct-hair transition-colors duration-150 hover:bg-acct-page data-[hover=true]:bg-acct-page",Cr="w-full",kr="border-t border-acct-border px-5 py-3.5",Sr=({columns:e,children:n,emptyContent:s,footer:a,ariaLabel:r,className:i,classNames:l={},"data-testid":o="admin-table"})=>t.jsxs("div",{className:c.cn(i,l.base),"data-testid":o,children:[t.jsxs(c.Table,{"aria-label":r,removeWrapper:!0,classNames:{table:c.cn(Cr,l.table),th:c.cn(jr,l.th),tr:c.cn(Nr,l.tr),td:c.cn(wr,l.td)},children:[t.jsx(c.TableHeader,{columns:e,children:d=>t.jsx(c.TableColumn,{align:d.align==="right"?"end":"start",width:d.width,children:d.label},d.key)}),t.jsx(c.TableBody,{emptyContent:s,children:n})]}),a?t.jsx("div",{"data-testid":`${o}-footer`,className:c.cn(kr,l.footer),children:a}):null]});Sr.displayName="AdminTable";const hu={md:"w-[280px]",lg:"w-[360px]"},Ar=({searchValue:e,onSearchChange:n,searchLabel:s,searchPlaceholder:a,searchIcon:r,children:i,trailing:l,searchWidth:o="md",className:d,"data-testid":u="admin-toolbar"})=>t.jsxs("div",{role:"search","data-testid":u,className:c.cn("flex flex-wrap items-center gap-3 mb-4",d),children:[t.jsx(c.Input,{type:"search","aria-label":s,placeholder:a??s,value:e,onValueChange:n,startContent:r?t.jsx("span",{"aria-hidden":"true",className:"flex text-acct-muted",children:r}):void 0,"data-testid":`${u}-search`,variant:"bordered",radius:"none",classNames:{base:hu[o],inputWrapper:["h-10 min-h-10 !h-10 rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),input:"text-[13.5px] text-acct-ink"}}),i,l?t.jsx("div",{className:"ml-auto",children:l}):null]});Ar.displayName="AdminToolbar";const xu="ml-0.5 inline-flex min-w-[18px] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",pu="h-9 gap-1.5 rounded-full border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 hover:bg-gray-50 data-[pressed=true]:bg-gray-50",$r=p.forwardRef(function({icon:n,children:s,count:a,className:r,testId:i,...l},o){return t.jsxs(U,{ref:o,"data-testid":i,variant:"light",size:"sm",className:c.cn(pu,r),...l,children:[t.jsx(R,{icon:n,className:"size-4 text-gray-500","aria-hidden":!0}),t.jsx("span",{children:s}),a!==void 0&&a>0&&t.jsx("span",{className:xu,children:a})]})});$r.displayName="ToolbarButton";function Dr({items:e,value:n,onChange:s,ariaLabel:a,className:r,"data-testid":i="underline-tabs"}){return t.jsx(c.Tabs,{"aria-label":a,variant:"underlined",selectedKey:n,onSelectionChange:l=>s(String(l)),"data-testid":i,classNames:{base:c.cn("w-full mb-6",r),tabList:"gap-7 w-full relative rounded-none p-0 border-b border-acct-border",cursor:"w-full bg-acct-rust",tab:"max-w-fit px-0.5 h-auto pb-3",tabContent:"text-[15px] font-medium text-acct-sub group-data-[selected=true]:font-semibold group-data-[selected=true]:text-acct-rust",panel:"p-0"},children:e.map(l=>t.jsx(c.Tab,{title:l.label,"data-testid":`${i}-${l.key}`,children:l.content},l.key))})}Dr.displayName="UnderlineTabs";const Hn="text-[11px] font-semibold uppercase tracking-[.04em] text-acct-muted mb-1.5",qn="font-normal normal-case tracking-normal",Er=["h-[38px] min-h-[38px] !h-[38px] rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),Fr="text-[13.5px] text-acct-ink",Mr="bg-acct-page text-acct-muted cursor-default",Lr="mt-[5px] text-xs text-acct-sub",Ir="mt-[5px] text-xs text-acct-danger",Tr=({children:e,suffix:n,className:s,"data-testid":a="admin-field-label"})=>t.jsxs("div",{"data-testid":a,className:c.cn(Hn,s),children:[e,n?t.jsxs("span",{className:qn,children:[" ",n]}):null]});Tr.displayName="AdminFieldLabel";const _r=({label:e,labelSuffix:n,value:s,onChange:a,placeholder:r,disabled:i=!1,readOnly:l=!1,mono:o=!1,autoFocus:d=!1,hint:u,invalid:f=!1,className:m,"data-testid":x="admin-text-field"})=>t.jsx(c.Input,{labelPlacement:e?"outside":void 0,label:e&&n?t.jsxs(t.Fragment,{children:[e,t.jsxs("span",{className:qn,children:[" ",n]})]}):e,value:s,placeholder:r,isDisabled:i,isReadOnly:l,autoFocus:d,isInvalid:f,description:!f&&u?u:void 0,errorMessage:f?u:void 0,onValueChange:a,"data-testid":x,variant:"bordered",radius:"none",classNames:{base:c.cn("w-full",m),label:Hn,inputWrapper:Er,input:c.cn(Fr,(o||l)&&"font-mono",l&&Mr),description:Lr,errorMessage:Ir}});_r.displayName="AdminTextField";const gu={sm:"size-6 min-w-6",md:"size-[30px] min-w-[30px]"},Pr=({actions:e,size:n="md",className:s,"data-testid":a="row-actions"})=>t.jsx("div",{role:"presentation","data-testid":a,className:c.cn("inline-flex gap-0.5",s),onClick:r=>r.stopPropagation(),children:e.map(r=>t.jsx(U,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:r.onPress,isDisabled:r.disabled,"aria-label":r.label,title:r.label,"data-testid":`${a}-${r.key}`,className:c.cn("text-acct-sub data-[hover=true]:bg-acct-hair",gu[n]),children:r.icon},r.key))});Pr.displayName="RowActions";const Or=({children:e,placeholder:n="Select…",onOpen:s,onClear:a,ariaLabel:r,icon:i,trailingIcon:l,clearIcon:o,disabled:d=!1,className:u,"data-testid":f="picker-row"})=>{const m=e!=null;return t.jsxs("div",{"data-testid":f,className:c.cn("flex w-full min-h-10 items-center rounded-[10px] border border-acct-border bg-acct-surface px-[11px] transition-colors duration-150",d?"opacity-60":"hover:border-acct-rust-border",u),children:[t.jsxs(U,{variant:"light",radius:"none",disableAnimation:!0,onPress:s,isDisabled:d,"aria-haspopup":"dialog","aria-label":r,"data-testid":`${f}-trigger`,className:"flex h-auto min-h-0 min-w-0 flex-1 items-center justify-start gap-2.5 bg-transparent px-0 py-2 text-left text-inherit data-[hover=true]:bg-transparent",children:[i?t.jsx("span",{className:"flex shrink-0 text-acct-muted",children:i}):null,m?t.jsx("span",{className:"flex min-w-0 items-center gap-2",children:e}):t.jsx("span",{className:"text-[13.5px] font-semibold text-acct-sub",children:n}),l?t.jsx("span",{className:"ml-auto flex shrink-0 text-acct-muted",children:l}):null]}),m&&a?t.jsx(U,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:a,isDisabled:d,"aria-label":`Clear ${r}`,title:"Clear","data-testid":`${f}-clear`,className:"ml-1.5 size-6 min-w-6 shrink-0 text-acct-muted data-[hover=true]:bg-acct-hair",children:o}):null]})};Or.displayName="PickerRow";function Rr(e,n,s){if(s<=0||n<=0||e<=0)return{from:0,to:0};const a=(e-1)*n+1;return a>s?{from:0,to:0}:{from:a,to:Math.min(s,e*n)}}const zr=({page:e,pageSize:n,total:s,unit:a,announce:r=!0,className:i,classNames:l={},"data-testid":o="pagination-summary"})=>{const{from:d,to:u}=Rr(e,n,s),f=c.cn("font-semibold text-default-700",l.emphasis);return t.jsxs("p",{"data-testid":o,"aria-live":r?"polite":void 0,className:c.cn("text-sm text-default-500",i,l.base),children:["Showing"," ",t.jsx("span",{"data-testid":`${o}-range`,className:f,children:d===0?0:`${d}–${u}`})," ","of"," ",t.jsx("span",{"data-testid":`${o}-total`,className:f,children:s}),a?t.jsxs(t.Fragment,{children:[" ",a]}):null]})};zr.displayName="PaginationSummary";const Br=({isLoading:e=!1,isError:n=!1,isEmpty:s=!1,loadingTitle:a="Loading…",loadingContent:r,errorTitle:i="Something went wrong",errorDescription:l,retryLabel:o="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:m="Nothing here yet",emptyDescription:x,emptyIcon:h,emptyActions:g,emptyContent:y,children:j,className:w,classNames:v={},"data-testid":C="list-panel"})=>{const N={base:c.cn("border-0 bg-transparent py-12",v.state)};let S;return e?S=r??t.jsx(Bn,{title:a,classNames:N,"data-testid":`${C}-loading`}):n?S=f??t.jsx(zn,{title:i,description:l,classNames:N,"data-testid":`${C}-error`,actions:u??(d?t.jsx(U,{color:"primary",variant:"flat",onPress:d,children:o}):void 0)}):s?S=y??t.jsx(Rn,{title:m,description:x,icon:h,actions:g,classNames:N,"data-testid":`${C}-empty`}):S=j,t.jsx("section",{"data-testid":C,className:c.cn("rounded-xl bg-white p-2 shadow-sm",w,v.base),children:S})};Br.displayName="ListPanel";const bu=350,yu={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}"},Jt=(e,n)=>Object.entries(n).reduce((s,[a,r])=>s.replace(`{${a}}`,r),e),vu=({dueAmount:e,received:n,defaultReceived:s=null,onChange:a,locale:r="en-US",labels:i,isDisabled:l=!1,maxAmount:o,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const m={...yu,...i},x=Ft(e.currency,r),h=n!==void 0,[g,y]=p.useState(s??null),j=h?n:g,w=p.useMemo(()=>{const I=typeof j=="number"&&Number.isFinite(j)?j:0,T=dn(I,e.value,e.currency,r);return{received:I,change:T>0?T:0,isValid:I>=e.value&&I>0}},[j,e.value,e.currency,r]),v=p.useCallback(I=>{const T=I.currentTarget;requestAnimationFrame(()=>{T.isConnected&&T.select()})},[]),C=p.useCallback(I=>{if(l)return;const T=I.replace(/[^\d.,]/g,"").replace(",","."),K=T===""?null:Number.parseFloat(T),H=K===null||Number.isNaN(K)?null:K;if(H!==null&&o!==void 0&&H>o)return;h||y(H);const B=typeof H=="number"&&Number.isFinite(H)?H:0,X=dn(B,e.value,e.currency,r);a?.({received:B,change:X>0?X:0,isValid:B>=e.value&&B>0})},[h,l,e.value,e.currency,r,a,o]),N=j==null?"":String(j),S=w.isValid&&w.change>0,E=!w.isValid&&w.received>0,A=he(w.change,r,e.currency),L=he(e.value,r,e.currency),[D,P]=p.useState(""),M=p.useRef(null);p.useEffect(()=>{M.current&&clearTimeout(M.current);const I=S?Jt(m.changeMessageTemplate,{change:A}):"",T=S?bu:0;return M.current=setTimeout(()=>P(I),T),()=>{M.current&&clearTimeout(M.current)}},[S,A,m.changeMessageTemplate]);const $=`${f}-received`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[t.jsx(c.Input,{id:$,label:m.receivedLabel,labelPlacement:"outside",type:"text",inputMode:x===0?"numeric":"decimal",pattern:x===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:I=>C(I.target.value),onFocus:v,placeholder:m.receivedPlaceholder,isDisabled:l,isInvalid:E,errorMessage:E?Jt(m.insufficientMessageTemplate,{due:L}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),S&&t.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:m.changeLabel,description:Jt(m.changeMessageTemplate,{change:A}),icon:t.jsx(R,{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"}}),t.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:D})]})},ju={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Us=()=>{const e=new Date,n=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${n(e.getMonth()+1)}-${n(e.getDate())}`},Vr=({dueAmount:e,value:n,defaultValue:s,onChange:a,labels:r,hideDate:i=!1,hideBankName:l=!1,isDisabled:o=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:m,"data-testid":x="check-tender-form"})=>{const h={...ju,...r},g=n!==void 0,[y,j]=p.useState({checkNumber:s?.checkNumber??"",bankName:s?.bankName??"",date:s?.date??Us()}),[w,v]=p.useState(!!s?.checkNumber),C=p.useMemo(()=>g?{checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Us()}:y,[g,n,y]),N=p.useCallback(M=>{g||j(M);const $=M.checkNumber.trim(),I={amount:e.value,checkNumber:$,bankName:M.bankName.trim()||void 0,date:i?void 0:M.date,isValid:$.length>0&&e.value>0};a?.(I)},[g,e.value,i,a]),S=p.useCallback(M=>$=>{o||(M==="checkNumber"&&$.length>0&&v(!0),N({...C,[M]:$}))},[C,N,o]),E=p.useCallback(()=>{o||v(!0)},[o]),A=w&&C.checkNumber.trim()==="",L=`${x}-check-number`,D=`${x}-bank-name`,P=`${x}-date`;return t.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",m),"data-testid":x,children:[t.jsx(c.Input,{id:L,label:h.checkNumberLabel,labelPlacement:"outside",type:"text",value:C.checkNumber,onChange:M=>S("checkNumber")(M.target.value),onBlur:E,placeholder:h.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:A,errorMessage:A?h.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${x}-check-number-input`}),!l&&t.jsx(c.Input,{id:D,label:h.bankNameLabel,labelPlacement:"outside",type:"text",value:C.bankName,onChange:M=>S("bankName")(M.target.value),placeholder:h.bankNamePlaceholder,maxLength:u,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${x}-bank-name-input`}),!i&&t.jsx(c.Input,{id:P,label:h.dateLabel,labelPlacement:"outside",type:"date",value:C.date,onChange:M=>S("date")(M.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${x}-date-input`,className:"sm:col-span-2"})]})};Vr.displayName="CheckTenderForm";const wu={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Nu=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Ur=({dueAmount:e,methodOptions:n=Nu,value:s,defaultValue:a,onChange:r,labels:i,showReference:l=!1,isDisabled:o=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...wu,...i},m=s!==void 0,[x,h]=p.useState({method:a?.method??"",reference:a?.reference??""}),g=p.useMemo(()=>m?{method:s?.method??"",reference:s?.reference??""}:x,[m,s,x]),y=p.useCallback(S=>n.find(E=>E.value===S)?.label??"",[n]),j=p.useCallback(S=>{m||h(S);const E=y(S.method),A={amount:e.value,method:S.method,description:E,reference:S.reference.trim()||void 0,isValid:S.method!==""};r?.(A)},[m,e.value,r,y]),w=p.useCallback(S=>{if(o)return;const E=typeof S=="string"?S:Array.from(S)[0]?.toString()??"";j({...g,method:E})},[g,j,o]),v=p.useCallback(S=>{o||j({...g,reference:S})},[g,j,o]),C=`${u}-method`,N=`${u}-reference`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[t.jsx(Fe,{id:C,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:g.method?[g.method]:[],onSelectionChange:w,isDisabled:o,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:n.map(S=>t.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${S.value}`,children:S.label},S.value))}),l&&t.jsx(c.Input,{id:N,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:g.reference,onChange:S=>v(S.target.value),placeholder:f.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};Ur.displayName="OtherTenderForm";const Cu={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ku={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Su={pending:"warning",recorded:"success",failed:"danger"},Au=e=>e==="pending"||e==="recorded",$u=e=>`#${e+1}`,Hr=({total:e,tenders:n,onRemove:s,locale:a="en-US",labels:r,hideCollectedList:i=!1,className:l,"data-testid":o="split-payment-summary"})=>{const d={...Cu,...r},{collected:u,remaining:f,isComplete:m}=p.useMemo(()=>{const h=n.reduce((y,j)=>Au(j.status)?y+j.amount:y,0),g=Math.max(e.value-h,0);return{collected:h,remaining:g,isComplete:h>=e.value&&e.value>0}},[n,e.value]),x=h=>h==="pending"?d.statusPending:h==="recorded"?d.statusRecorded:d.statusFailed;return t.jsxs("div",{className:c.cn("flex flex-col gap-4",l),"data-testid":o,children:[t.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[t.jsx("div",{className:"text-sm text-default-600",children:m?d.completeLabel:d.remainingLabel}),t.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:he(m?u:f,a,e.currency)})]}),!i&&n.length>0&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[t.jsx("h3",{className:"text-base font-semibold",children:d.collectedHeading}),n.map((h,g)=>t.jsx(Du,{index:g,tender:h,locale:a,currency:e.currency,removable:!!s&&h.status!=="recorded",onRemove:s?()=>s(h.id):void 0,statusLabel:x(h.status),removeAriaLabel:d.removeAriaLabel,recordedTooltip:d.removeTooltipForRecorded,dataTestId:`${o}-row-${g}`},h.id))]})]})};Hr.displayName="SplitPaymentSummary";const Du=({index:e,tender:n,locale:s,currency:a,removable:r,onRemove:i,statusLabel:l,removeAriaLabel:o,recordedTooltip:d,dataTestId:u})=>{const f=i?t.jsx(U,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!r,"aria-label":o,"data-testid":`${u}-remove`,className:c.cn(r?"text-default-700 hover:bg-default-200":"text-default-300"),children:t.jsx(R,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return t.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:[t.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:$u(e)}),t.jsx(R,{icon:ku[n.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:n.label}),t.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:he(n.amount,s,a)}),t.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:Su[n.status],startContent:n.status==="recorded"?t.jsx(R,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):n.status==="failed"?t.jsx(R,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:l}),f&&(r?f:t.jsx(c.Tooltip,{content:d,placement:"left",children:t.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},Eu=`
|
|
16
|
+
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),t.jsx(c.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:t.jsx(U,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:l,"aria-label":"Zoom in",children:t.jsx(G.ZoomIn,{size:16})})})]})}function Yo({editor:e,isDisabled:n=!1}){const[s,a]=p.useState(!1),[r,i]=p.useState(""),[l,o]=p.useState(""),[d,u]=p.useState(!1),f=e.isActive("link"),m=h=>{if(h){const{from:g,to:y}=e.state.selection,j=e.isActive("link");let w="";if(j){const C=e.schema.marks.link,N=e.state.doc.resolve(g),S=Jn.getMarkRange(N,C);S&&(w=e.state.doc.textBetween(S.from,S.to,""))}else w=e.state.doc.textBetween(g,y,"");const v=e.getAttributes("link").href||"";i(w),o(v),u(j)}a(h)},x=()=>{if(l.trim()){const{from:h,to:g}=e.state.selection,y=e.schema.marks.link,j=e.state.doc.resolve(h),w=Jn.getMarkRange(j,y),v=w?.from??h,C=w?.to??g,N=e.state.doc.textBetween(v,C,"");r.trim()&&r!==N?e.chain().focus().setTextSelection({from:v,to:C}).deleteSelection().insertContent(`<a href="${l.trim()}">${r.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:l.trim()}).run()}a(!1)};return t.jsxs(c.Popover,{isOpen:s,onOpenChange:m,placement:"bottom",children:[t.jsx(c.PopoverTrigger,{children:t.jsx(U,{size:"sm",radius:"sm",variant:f?"solid":"bordered",color:f?"primary":"default",isIconOnly:!0,isDisabled:n,"aria-label":"Link",children:t.jsx(G.Link,{size:16})})}),t.jsx(c.PopoverContent,{children:t.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:r,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(c.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:l,onChange:h=>o(h.target.value),onKeyDown:h=>h.key==="Enter"&&x(),classNames:{inputWrapper:"focus-within:border-default-400"}}),t.jsx(U,{size:"sm",color:"primary",onPress:x,isDisabled:!l.trim(),children:d?"Update":"Apply"})]})})]})}function Go({children:e,id:n,label:s,className:a,useButtonGroup:r=!0}){return r?t.jsx(c.ButtonGroup,{size:"sm",id:n,"aria-label":s,className:a,children:e}):t.jsx("div",{id:n,role:"group","aria-label":s,className:`flex items-center gap-2 ${a||""}`,children:e})}function La(e,n){const s=p.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(n.map(o=>ut(o)))).forEach(o=>{const d=Ie[o];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;i[o]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${o}`,u),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,n]),[a,r]=p.useState(s);return p.useEffect(()=>{if(!e)return;const i=()=>{const l={};Array.from(new Set(n.map(d=>ut(d)))).forEach(d=>{const u=Ie[d];if(u)try{const f=u.canExecute?.(e)??!0,m=u.isActive?.(e)??!1;l[d]={isActive:m,isDisabled:!f,canExecute:f}}catch(f){console.warn(`Extension not available for modifier: ${d}`,f),l[d]={isActive:!1,isDisabled:!0,canExecute:!1}}}),r(l)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,n,s]),a}function Ia(e,n){const s=p.useCallback((l,o)=>{if(!e)return;const d=Ie[l];if(d)try{d.execute({editor:e,config:o}),n?.({type:"toggle",modifier:l})}catch(u){console.warn(`Failed to execute command for modifier: ${l}`,u)}},[e,n]),a=p.useCallback(l=>{s(l)},[s]),r=p.useCallback((l,o)=>{if(!e)return!1;const d=Ie[l];try{return d?.canExecute?.(e,o)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${l}`,u),!1}},[e]),i=p.useCallback((l,o)=>{if(!e)return!1;const d=Ie[l];try{return d?.isActive?.(e,o)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${l}`,u),!1}},[e]);return{executeCommand:s,toggleModifier:a,canExecute:r,isActive:i}}function Ko(e=be.default){const[n,s]=p.useState(e),a=p.useCallback((o=be.step)=>{s(d=>Math.min(be.max,d+o))},[]),r=p.useCallback((o=be.step)=>{s(d=>Math.max(be.min,d-o))},[]),i=p.useCallback(()=>{s(be.default)},[]),l=p.useCallback(o=>{const d=Math.max(be.min,Math.min(be.max,o));s(d)},[]);return{zoom:n,setZoom:l,zoomIn:a,zoomOut:r,resetZoom:i,isMinZoom:n<=be.min,isMaxZoom:n>=be.max,isDefaultZoom:n===be.default}}const Qo=["bold","italic","strike","underline","code"];function Zo({editor:e,modifiers:n,onToolbarAction:s}){const a=La(e,n),{toggleModifier:r}=Ia(e,s);if(!e)return null;const i=n.map(l=>ut(l)).filter(l=>Qo.includes(l));return i.length===0?null:t.jsx(Go,{id:"text-formatting",label:"Text formatting",children:i.map(l=>{const o=a[l],d=Qe(l);return t.jsx(qe,{icon:d,label:l.charAt(0).toUpperCase()+l.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>r(l)},l)})})}function Xo({editor:e,modifiers:n,zoom:s=100,onZoomChange:a,sticky:r=!0,className:i,onToolbarAction:l}){const o=La(e,n),{toggleModifier:d,executeCommand:u}=Ia(e,l);if(!e)return null;const f=n.map(A=>ut(A)),m=f.some(A=>["bold","italic","strike","underline","code"].includes(A)),x=f.some(A=>["textColor","highlight"].includes(A)),h=f.includes("heading"),g=f.includes("textAlign"),y=f.some(A=>["bulletList","orderedList","taskList"].includes(A)),j=f.includes("blockquote"),w=f.includes("codeBlock"),v=f.includes("link"),C=f.includes("horizontalRule"),N=f.some(A=>["undo","redo"].includes(A)),S=s!==void 0&&a!==void 0,E=r?"sticky top-0 z-10":"";return t.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${E} ${i||""}`,children:t.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx(Zo,{editor:e,modifiers:n,onToolbarAction:l}),(x||h||g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),x&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("textColor")&&t.jsx(vs,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),f.includes("highlight")&&t.jsx(vs,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(h||g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),h&&t.jsxs(t.Fragment,{children:[t.jsx(Oo,{editor:e}),(g||y||j||w||v||C||N||S)&&t.jsx(He,{})]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(A=>{const L=Ho[A],D=e.isActive({textAlign:A});return t.jsx(qe,{icon:L,label:`Align ${A}`,isActive:D,onClick:()=>u("textAlign",{type:"textAlign",alignment:A})},A)})}),(y||j||w||v||C||N||S)&&t.jsx(He,{})]}),y&&t.jsxs(t.Fragment,{children:[t.jsx(Ro,{editor:e,types:f.filter(A=>["bulletList","orderedList","taskList"].includes(A))}),(j||w||v||C||N||S)&&t.jsx(He,{})]}),(j||w||v||C)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[j&&t.jsx(qe,{icon:Qe("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>d("blockquote")}),w&&t.jsx(qe,{icon:Qe("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>d("codeBlock")}),v&&t.jsx(Yo,{editor:e,isDisabled:o.link?.isDisabled}),C&&t.jsx(qe,{icon:Qe("horizontalRule"),label:"Horizontal rule",onClick:()=>d("horizontalRule")})]}),(N||S)&&t.jsx(He,{})]}),N&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[f.includes("undo")&&t.jsx(qe,{icon:Qe("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>d("undo")}),f.includes("redo")&&t.jsx(qe,{icon:Qe("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>d("redo")})]}),S&&t.jsx(He,{})]}),S&&t.jsx(Wo,{zoom:s,onZoomChange:A=>{a?.(A),l?.({type:"zoom",modifier:`${A}%`})}})]})})}const st={bold:{category:"mark",extension:Ci.Bold,priority:100},italic:{category:"mark",extension:ki.Italic,priority:100},strike:{category:"mark",extension:Si.Strike,priority:100},underline:{category:"mark",extension:Ai.Underline,priority:100},code:{category:"mark",extension:$i.Code,priority:100},textColor:{category:"mark",extension:Di.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Ei.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Fi.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Li.Heading,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ti.BulletList,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:_i.OrderedList,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Pi.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:zi.CodeBlock,priority:100},blockquote:{category:"node",extension:Bi.Blockquote,priority:100},horizontalRule:{category:"node",extension:Vi.HorizontalRule,priority:100},hardBreak:{category:"node",extension:Ui.HardBreak,priority:100},undo:{category:"extension",extension:es.History,priority:50},redo:{category:"extension",extension:es.History,priority:50},textAlign:{category:"extension",extension:Hi.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}},Jo=[qi.Document,Wi.Text,Ii.Paragraph,Mi.TextStyle.configure({HTMLAttributes:{}}),Ri.ListItem.configure({HTMLAttributes:{}}),Oi.TaskItem.configure({nested:!0}),Yi.Dropcursor,Gi.Gapcursor];function ec(e){const n=[],s=new Set,a=new Set;Jo.forEach(o=>{o&&(n.push(o),a.add(o.name))});const r=e.map(o=>ut(o)),i=new Set;return r.forEach(o=>{const d=st[o];d?.requiredExtensions&&d.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(o=>{if(s.has(o))return;const d=st[o];if(!d||d.extension===null)return;const u=d.extension.name;if(a.has(u)){s.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;n.push(f),s.add(o),a.add(u)}),r.forEach(o=>{if(s.has(o))return;const d=st[o];if(!d){console.warn(`Extension config not found for modifier: ${o}`);return}if(d.extension===null){s.add(o);return}const u=d.extension.name;if(a.has(u)){s.add(o);return}const f=d.defaultOptions?d.extension.configure(d.defaultOptions):d.extension;n.push(f),s.add(o),a.add(u)}),n.sort((o,d)=>{const u=Object.values(st).find(h=>h?.extension?.name===o.name),f=Object.values(st).find(h=>h?.extension?.name===d.name),m=u?.priority??100;return(f?.priority??100)-m})}const Ta={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"]},tc={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: ${ge.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ce.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ce.fontFamily.mono};`,pre:`background: ${ge.neutral.gray[800]}; border-radius: ${le.sm}; color: ${ge.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 ${ge.neutral.gray[300]}; margin: ${le.lg} 0; padding-left: ${le.md}; color: ${ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${ge.neutral.gray[200]}; margin: ${le.xl} 0;`,a:`color: ${ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${ge.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;"},nc={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 sc(e){if(!e)return e;let n=e;for(const[s,a]of Object.entries(nc)){const r=new RegExp(`(<(?:ul|li)[^>]*data-type="${s}"[^>]*)>`,"gi");n=n.replace(r,(i,l)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${a}"`):`${l} style="${a}">`)}for(const[s,a]of Object.entries(tc)){const r=new RegExp(`<${s}(\\s[^>]*)?>`,"gi");n=n.replace(r,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${a}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${a}'`);{const l=i.indexOf(">");return`${i.slice(0,l)} style="${a}"${i.slice(l)}`}})}return n}const ac=({modifiers:e,zoom:n,onZoomChange:s,onToolbarAction:a})=>{const{editor:r}=yn.useCurrentEditor();return t.jsx(Xo,{editor:r,modifiers:e,zoom:n,onZoomChange:s,onToolbarAction:a})},rc=({showCharacterCount:e,showWordCount:n})=>{const{editor:s}=yn.useCurrentEditor();if(!s||!e&&!n)return null;const a=s.getText(),r=a.length,i=a.split(/\s+/).filter(l=>l.length>0).length;return t.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&t.jsxs("span",{children:[r," characters"]}),n&&t.jsxs("span",{children:[i," words"]})]})},un=p.forwardRef((e,n)=>{const{minRows:s=10,maxRows:a=30,disableAutosize:r=!1,showCharacterCount:i=!1,showWordCount:l=!1,showToolbar:o=!0,modifiers:d=Ta.full,variant:u="bordered",initialContent:f,content:m,onContentChange:x,onUpdate:h,onToolbarAction:g,isReadOnly:y=!1,isDisabled:j=!1,includeInlineStyles:w=!0,...v}=e,{zoom:C,setZoom:N}=Ko(),S=ys.lineHeight,E=s*S,A=r?void 0:a*S,L=p.useMemo(()=>ec(d),[d]),{Component:D,label:P,shouldLabelBeOutside:M,getBaseProps:$,getLabelProps:I,getInputWrapperProps:T}=c.useInput({...v,variant:u,ref:n,isMultiline:!0}),K=P?t.jsx("label",{...I(),children:P}):null,H=p.useCallback(({editor:B})=>{const X=B.getHTML(),J=w?sc(X):X,re=B.getJSON(),q=B.getText(),Z=q.length,Q=q.split(/\s+/).filter(ee=>ee.length>0).length,W={html:J,json:re,text:q,characters:Z,words:Q};if(x?.(W),h?.(W),"onChange"in v&&typeof v.onChange=="function"){const ee={target:{value:J},currentTarget:{value:J}};v.onChange(ee)}},[x,h,v,w]);return t.jsxs(D,{...$(),children:[M?K:null,t.jsx("div",{...T(),className:c.cn(T().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:A?`${A+ys.toolbarHeight}px`:void 0,overflow:A?"auto":void 0},children:t.jsx(yn.EditorProvider,{editable:!y&&!j,slotBefore:o?t.jsx(ac,{modifiers:d,zoom:C,onZoomChange:N,onToolbarAction:g}):void 0,slotAfter:t.jsx(rc,{showCharacterCount:i,showWordCount:l}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${E}px`,fontSize:`${C}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:L,content:m||f||e.defaultValue||"",onUpdate:H})})]})});un.displayName="TipTapEditor";const _a=p.forwardRef((e,n)=>{const{adapter:s="tiptap",variant:a="bordered",...r}=e;return s==="tiptap"?t.jsx(un,{...r,variant:a,ref:n}):(console.warn(`Adapter "${s}" is not supported. Using TipTap.`),t.jsx(un,{...r,variant:a,ref:n}))});_a.displayName="RichTextArea";function ic(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}const js=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],lc={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Pa=({presetAmounts:e=js,selectedDonation:n,defaultSelectedDonation:s=null,onChange:a,onAddDonation:r,currency:i="USD",locale:l="en-US",showCustomAmount:o=!0,minCustomAmount:d=.5,maxCustomAmount:u=1e6,labels:f,mobileColumns:m=2,desktopColumns:x=3,isDisabled:h=!1,buttonVariant:g="bordered",buttonColor:y="default",inputVariant:j="bordered",size:w="md",className:v="",showCard:C=!0})=>{const N={...lc,...f},S=Array.isArray(e)?e:js,E={2:"grid-cols-2",3:"grid-cols-3"},A={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},L=`${E[m]} ${A[x]}`,[D,P]=Et(n,s,a),[M,$]=p.useState(""),[I,T]=p.useState(!1),[K,H]=p.useState(0),B=p.useCallback(Z=>{if(h)return;const Q={amount:Z.amount,isCustom:!1,presetId:Z.id};P(Q),$(""),T(!1),H(W=>W+1),r?.(Q)},[h,P,r]),X=p.useCallback(Z=>{if(h)return;if($(Z!==void 0?String(Z):""),r){P(null);return}if(Z===void 0||isNaN(Z)){P(null);return}P({amount:Z,isCustom:!0})},[h,P,r]),J=p.useCallback(()=>{if(h)return;const Z=M!==""?parseFloat(M):void 0;Z===void 0||isNaN(Z)||r?.({amount:Z,isCustom:!0})},[h,M,r]),re=p.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),q=t.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[N.title&&t.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:N.title}),S.length>0&&t.jsx("div",{className:c.cn("grid gap-3",L),"data-testid":"donation-amounts-presets",children:S.map(Z=>{const Q=D!==null&&!D.isCustom&&D.presetId===Z.id;return t.jsx(U,{color:Q?"primary":y,variant:Q?"solid":g,className:"w-full",onPress:()=>B(Z),isDisabled:h,"data-testid":`donation-amounts-preset-${Z.id}`,children:Z.label||ic(Z.amount,l,i)},Z.id)})}),o&&t.jsxs("div",{className:"flex gap-3 items-start",children:[t.jsx(c.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:r?()=>{P(null),T(!0)}:void 0,variant:j,radius:"full",size:w,minValue:d,maxValue:u,step:.01,formatOptions:re,value:M!==""?parseFloat(M):void 0,onValueChange:X,isDisabled:h,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},r?`custom-${K}`:D?.isCustom===!1?D.presetId:"custom"),r&&t.jsx(U,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:J,isDisabled:h||!I,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return C?t.jsx(c.Card,{className:c.cn("w-full",v),"data-testid":"donation-amounts-card",children:t.jsx(c.CardBody,{children:q})}):t.jsx("div",{className:c.cn("w-full",v),"data-testid":"donation-amounts-plain",children:q})};Pa.displayName="DonationAmounts";const oc=e=>{const n=Math.max(0,e),s=Math.floor(n/60).toString().padStart(2,"0"),a=(n%60).toString().padStart(2,"0");return`${s}:${a} minutes`},cc=e=>{switch(e){case"warning":return G.Clock;case"error":return G.AlertCircle;case"success":return G.CheckCircle;default:return G.Clock}},dc=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"}},Oa=p.forwardRef(({timeLeft:e,defaultTimeLeft:n=1200,onTimeChange:s,onExpire:a,variant:r="info",color:i="primary",message:l="Your cart expires in:",showIcon:o=!0,icon:d,position:u="fixed",autoStart:f=!0,formatTime:m=oc,className:x,...h},g)=>{const[y,j]=Et(e!==void 0?Math.max(0,e):void 0,Math.max(0,n),s),w=p.useRef(null),v=p.useRef(!1);p.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),p.useEffect(()=>{if(!f||y<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{j(E=>E<=1?(w.current&&(clearInterval(w.current),w.current=null),v.current||(v.current=!0,a?.()),0):E-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[f,y,j,a]),p.useEffect(()=>{y>0&&(v.current=!1)},[y]);const C=d||cc(r),N=dc(i),S={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return t.jsx("div",{ref:g,role:"banner","aria-live":"polite","aria-label":`${l} ${m(y)}`,"data-testid":"expire-cart-timer",className:c.cn("w-full text-white z-50",N,S[u],x),...h,children:t.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[o&&t.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:t.jsx(C,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),t.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:l})]}),t.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:t.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${m(y)}`,"data-testid":"expire-cart-timer-value",children:m(y)})})]})})})});Oa.displayName="ExpireCartTimer";const Wt=({icon:e,children:n,testId:s})=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":s,children:[t.jsx(R,{icon:e,width:20,className:"text-default-500"}),t.jsx("span",{children:n})]}),uc=({classes:e="",name:n,imageUrl:s,eventDate:a,eventTime:r,location:i,description:l,showImage:o=!1,compact:d=!1,imageLoading:u="eager",showMoreButtonClassName:f,labels:m})=>{const[x,h]=p.useState(!1),[g,y]=p.useState(!1),j=p.useRef(null);return p.useEffect(()=>{const w=()=>{if(j.current){const v=j.current.scrollHeight>j.current.clientHeight;y(v)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[l]),t.jsxs(c.Card,{className:c.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[t.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:[o&&s&&t.jsx("div",{className:c.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:t.jsx(c.Image,{removeWrapper:!0,loading:u,alt:`Event image for ${n}`,className:"w-full h-full object-cover object-center",src:s,"data-testid":"event-details-image"})}),t.jsx("h2",{className:c.cn("font-semibold text-gray-800",d?"text-base":"text-xl"),"data-testid":"event-details-title",children:n})]}),t.jsxs(c.CardBody,{className:c.cn("space-y-3",d?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[t.jsx("h3",{className:c.cn("font-semibold text-base text-gray-700",d?"text-sm":""),"data-testid":"event-details-info-label",children:m.eventInformation}),t.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[a&&t.jsx(Wt,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:a}),r&&t.jsx(Wt,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:r}),i&&t.jsx(Wt,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),l&&t.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{ref:j,className:c.cn("text-sm text-gray-700 leading-relaxed transition-all",d?"text-xs":"",!x&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:l}}),!x&&g&&t.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"})]}),(g||x)&&t.jsx("div",{className:"flex justify-end mt-1",children:t.jsx(U,{onPress:()=>h(!x),variant:"light",className:c.cn("text-primary",f),size:d?"sm":"md",startContent:t.jsx(R,{icon:x?"solar:eye-closed-linear":"solar:eye-linear",width:d?16:20}),"data-testid":"event-details-toggle-description",children:x?m.showLess||"Hide":m.showMore||"Show"})})]})]})]})};function fn(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}function fc(e){const n=e.replace(/[^\d.,-]/g,""),s=n.match(/,\d{1,2}$/);let a;s?a=n.replace(/\./g,"").replace(",","."):a=n.replace(/,/g,"");const r=parseFloat(a);return isNaN(r)?null:r}const mc={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"},Ge=e=>typeof e=="number"&&!isNaN(e),wt=({offer:e,quantity:n,defaultQuantity:s=0,onQuantityChange:a,currency:r="USD",locale:i="en-US",labels:l,slots:o,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:m=!0,showDescription:x=!0,showPeopleCount:h=!0,showPrice:g=!0,priceDisplay:y,classNames:j={},"data-testid":w,selectedColor:v="default",compact:C=!1,isSoldOut:N,isMaxReached:S,isRuleBlocked:E,statusTone:A="default",statusLabel:L,disabledReason:D,disabled:P})=>{const M=p.useMemo(()=>({...mc,...l}),[l]),[$,I]=p.useState(s),T=n!==void 0?n:$,K=!!(d||P),H=C||!!e.compact,B=p.useMemo(()=>typeof N=="boolean"?N:typeof e.isSoldOut=="boolean"?e.isSoldOut:!Ge(e.totalTicketsSold)||!Ge(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[N,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),X=p.useMemo(()=>typeof S=="boolean"?S:typeof e.isMaxReached=="boolean"?e.isMaxReached:B||!Ge(e.ticketsAllowed)?!1:T>=e.ticketsAllowed-(e.totalTicketsSold??0),[S,e.isMaxReached,B,e.ticketsAllowed,e.totalTicketsSold,T]),J=p.useMemo(()=>typeof E=="boolean"?E:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[E,e.isRuleBlocked]),re=D||e.disabledReason,q=K||B||J,Z=ne=>{if(q||ne>0&&X)return;const me=Math.max(0,T+ne);n===void 0&&I(me),a?.(e.id,me)},Q=p.useMemo(()=>{if(B)return"soldOut";if(J)return"ruleBlocked";if(K)return"disabled"},[B,J,K]),W=p.useMemo(()=>A||(B||J?"danger":X?"warning":"default"),[A,B,J,X]),ee=p.useMemo(()=>{if(Q)return Q==="ruleBlocked"?L||re||M.ruleBlocked:Q==="soldOut"?L||re||M.soldOut:Q==="disabled"?L||re||M.disabled:L||M.maxReached},[Q,L,re,M]),te={soldOut:"danger",ruleBlocked:W,disabled:"default",maxReached:"warning"},ke={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},ye=()=>o?.renderName?o.renderName(e.name,e):t.jsx("h2",{"data-testid":"offer-card-name",className:c.cn("text-base font-medium",H&&"text-sm",j.name),children:e.name}),xe=()=>{if(!g)return null;const ne=y?.price??e.price,me=y?.originalPrice,Me=fn(ne,i,r);if(o?.renderPrice)return o.renderPrice(ne,Me,e);if(Ge(me)&&Ge(ne)&&me>ne){const pe=fn(me,i,r);return t.jsxs("div",{"data-testid":"offer-card-price",className:c.cn("flex items-center gap-2 mt-1",H&&"mt-0.5",j.price),children:[t.jsxs("span",{className:"sr-only",children:["Original price ",pe,", discounted price ",Me]}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-original-price",className:c.cn("text-gray-400 line-through text-sm",H&&"text-xs",j.originalPrice),children:pe}),t.jsx("span",{"aria-hidden":"true","data-testid":"offer-card-discounted-price",className:c.cn("text-primary text-base font-semibold",H&&"text-sm",j.discountedPrice),children:Me})]})}return t.jsx("p",{"data-testid":"offer-card-price",className:c.cn("text-primary text-base mt-1",H&&"text-sm mt-0.5",j.price),children:Me})},Be=()=>!x||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):t.jsx("p",{"data-testid":"offer-card-description",className:c.cn("mb-4 text-sm text-gray-700 leading-relaxed",H&&"mb-2 text-xs text-gray-600",j.description),children:e.description}),Te=()=>{if(!h||!Ge(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ne=e.numberOfPeople===1?M.person:M.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ne,e):t.jsxs("p",{"data-testid":"offer-card-people-count",className:c.cn("text-sm text-gray-600 flex items-center mt-2",H&&"mt-1 text-xs",j.peopleCount),children:[t.jsx(R,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ne]})},_e=()=>{const ne=T===0||q,me=X||q;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:T,onIncrement:()=>Z(1),onDecrement:()=>Z(-1),isDecrementDisabled:ne,isIncrementDisabled:me,isDisabled:q}):t.jsxs("div",{className:c.cn("flex items-center gap-2",j.quantitySelector),children:[t.jsx(U,{"data-testid":"offer-card-decrement-button",onPress:()=>Z(-1),isDisabled:ne,variant:u,color:T>0?v:f,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Decrease quantity",children:t.jsx(R,{icon:"gravity-ui:minus",width:16})}),t.jsx("span",{"data-testid":"offer-card-quantity",className:c.cn("min-w-[2rem] text-center font-medium",H&&"text-sm"),children:T}),t.jsx(U,{"data-testid":"offer-card-increment-button",onPress:()=>Z(1),isDisabled:me,variant:u,color:T>0?v:f,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Increase quantity",children:t.jsx(R,{icon:"gravity-ui:plus",width:16})})]})},Pe=(ne,me)=>o?.renderDisabledState?o.renderDisabledState(ne,me):ne==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(me):ne==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(me):t.jsx(c.Chip,{"data-testid":ke[ne],color:te[ne],variant:ne==="maxReached"?"flat":"solid",className:c.cn("gap-2 px-4",ne==="maxReached"?"h-8":"h-10",ne==="soldOut"&&j.soldOut,ne==="maxReached"&&j.maxReachedAlert,H&&"h-8"),startContent:t.jsx(R,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:t.jsx("span",{className:"font-medium text-sm",children:me})}),Ve=t.jsxs("div",{className:c.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",H?"gap-1":"gap-2"),children:[t.jsxs("div",{className:c.cn("h-full col-span-2",q||X?"opacity-50 pointer-events-none select-none":""),children:[ye(),xe(),t.jsxs("div",{className:c.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",H?"mb-1":"mb-2"),children:[Te(),Be()]})]}),t.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",H&&"space-x-1 pb-1 md:p-1",j.compactFooter),children:Q&&ee?Pe(Q,ee):_e()})]}),Ee=X&&!B&&!J&&!K?t.jsx(Ne.motion.div,{className:c.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",j.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Pe("maxReached",ee||M.maxReached)}):null;return m?t.jsxs(c.Card,{className:c.cn("w-full",H&&j.compact,j.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx(c.CardBody,{className:c.cn("pt-1 pb-0",H?"pb-0.5":"",j.body),children:Ve}),t.jsx(Ne.AnimatePresence,{children:Ee&&t.jsx(c.CardFooter,{className:c.cn("w-full mt-0 pt-0",H?"pt-1":"",j.footer),children:Ee})})]}):t.jsxs("div",{className:c.cn("w-full",H&&j.compact,j.base),"data-testid":w||`offer-card-${e.id}`,children:[t.jsx("div",{className:c.cn("pt-1 pb-0",H?"pb-0.5":"",j.body),children:Ve}),t.jsx(Ne.AnimatePresence,{children:Ee&&t.jsx("div",{className:c.cn("w-full mt-0 pt-0",H?"pt-1":"",j.footer),children:Ee})})]})};wt.displayName="OfferCard";const Ra=({message:e="No offers available.",icon:n="solar:ticket-sale-outline",iconSize:s=48,showCard:a=!0,classNames:r={},renderEmpty:i})=>{if(i){const o=i();return a?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:o})}const l=t.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",r.content),children:[t.jsx(R,{"data-testid":"offer-card-empty-icon",icon:n,width:s,className:c.cn("mb-4",r.icon)}),t.jsx("h3",{"data-testid":"offer-card-empty-message",className:c.cn("text-lg",r.message),children:e})]});return a?t.jsx(c.Card,{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-empty",className:c.cn("w-full",r.base),children:l})};Ra.displayName="OfferCardEmpty";const hc={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},za=({error:e,labels:n,showCard:s=!0,color:a="danger",classNames:r={}})=>{const i={...hc,...n},l=t.jsx(c.Alert,{"data-testid":"offer-card-error-alert",color:a,title:i.title,description:e||i.description,className:r.alert});return s?t.jsx(c.Card,{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{"data-testid":"offer-card-error-body",children:l})}):t.jsx("div",{"data-testid":"offer-card-error",className:c.cn("w-full",r.base),children:l})};za.displayName="OfferCardError";const xc={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Ba=({quantity:e=2,gap:n=4,classNames:s={}})=>{const a=xc[n];return t.jsx("div",{"data-testid":"offer-card-skeleton-container",className:c.cn(a,s.base),children:Array.from({length:e}).map((r,i)=>t.jsxs(c.Card,{"data-testid":`offer-card-skeleton-${i}`,className:c.cn("w-full",s.card),children:[t.jsx(c.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:t.jsxs("div",{className:"space-y-2 w-full",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),t.jsx(c.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[t.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:t.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),t.jsx("div",{className:"flex items-start justify-end",children:t.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),t.jsx(c.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Ba.displayName="OfferCardSkeleton";const Va={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},Ua={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"}}},pc={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},Ha=({offers:e=[],mapOffer:n,selection:s,defaultSelection:a={},onSelectionChange:r,onQuantityChange:i,currency:l="USD",locale:o="en-US",labels:d,slots:u,isDisabled:f=!1,buttonVariant:m="bordered",buttonColor:x="default",showCard:h=!0,animated:g=!0,gap:y=2,compact:j=!1,classNames:w={}})=>{const[v,C]=p.useState(a),N=s!==void 0?s:v,S=p.useCallback((M,$)=>{const I={...N,[M]:Math.max(0,$)};s===void 0&&C(I),r?.(I),i?.(M,I[M])},[N,s,r,i]),E=[...e].sort((M,$)=>(M.position??0)-($.position??0)),A=M=>{const $=n?n(M):M,I=(N??{})[$.id]||0;return{offer:$,quantity:I,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:x,showCard:h,compact:j}},L=pc[y],D=c.cn("grid mx-auto pt-2",L,w.base),P=M=>{const $=A(M);return t.jsx(wt,{offer:$.offer,quantity:$.quantity,onQuantityChange:$.onQuantityChange,currency:$.currency,locale:$.locale,labels:$.labels,slots:$.slots,isDisabled:$.isDisabled,buttonVariant:$.buttonVariant,buttonColor:$.buttonColor,showCard:$.showCard,compact:$.compact,classNames:w.card},$.offer.id)};return g?t.jsx(Ne.motion.div,{"data-testid":"offer-card-list",className:D,variants:Va,initial:"hidden",animate:"show",children:t.jsx(Ne.AnimatePresence,{children:E.map(M=>{const $=A(M);return t.jsx(Ne.motion.div,{"data-testid":`offer-card-list-item-${$.offer.id}`,className:w.cardWrapper,variants:Ua,exit:{opacity:0,y:-20},transition:{duration:.3},children:t.jsx(wt,{offer:$.offer,quantity:$.quantity,onQuantityChange:S,currency:l,locale:o,labels:d,slots:u,isDisabled:f,buttonVariant:m,buttonColor:x,showCard:h,compact:j||$.offer.compact,classNames:w.card})},$.offer.id)})})}):t.jsx("div",{"data-testid":"offer-card-list",className:D,children:E.map(P)})};Ha.displayName="OfferCardList";var ft=e=>e.type==="checkbox",We=e=>e instanceof Date,Ce=e=>e==null;const qa=e=>typeof e=="object";var fe=e=>!Ce(e)&&!Array.isArray(e)&&qa(e)&&!We(e),Wa=e=>fe(e)&&e.target?ft(e.target)?e.target.checked:e.target.value:e,gc=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ya=(e,n)=>e.has(gc(n)),bc=e=>{const n=e.constructor&&e.constructor.prototype;return fe(n)&&n.hasOwnProperty("isPrototypeOf")},Fn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function de(e){if(e instanceof Date)return new Date(e);const n=typeof FileList<"u"&&e instanceof FileList;if(Fn&&(e instanceof Blob||n))return e;const s=Array.isArray(e);if(!s&&!(fe(e)&&bc(e)))return e;const a=s?[]:Object.create(Object.getPrototypeOf(e));for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(a[r]=de(e[r]));return a}var Mt=e=>/^\w*$/.test(e),oe=e=>e===void 0,Mn=e=>Array.isArray(e)?e.filter(Boolean):[],Ln=e=>Mn(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,n,s)=>{if(!n||!fe(e))return s;const a=(Mt(n)?[n]:Ln(n)).reduce((r,i)=>Ce(r)?r:r[i],e);return oe(a)||a===e?oe(e[n])?s:e[n]:a},Se=e=>typeof e=="boolean",we=e=>typeof e=="function",ie=(e,n,s)=>{let a=-1;const r=Mt(n)?[n]:Ln(n),i=r.length,l=i-1;for(;++a<i;){const o=r[a];let d=s;if(a!==l){const u=e[o];d=fe(u)||Array.isArray(u)?u:isNaN(+r[a+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=d,e=e[o]}};const Nt={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},$e={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Le={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ga=p.createContext(null);Ga.displayName="HookFormControlContext";const In=()=>p.useContext(Ga);var Ka=(e,n,s,a=!0)=>{const r={defaultValues:n._defaultValues};for(const i in e)Object.defineProperty(r,i,{get:()=>{const l=i;return n._proxyFormState[l]!==$e.all&&(n._proxyFormState[l]=!a||$e.all),s&&(s[l]=!0),e[l]}});return r};const Tn=typeof window<"u"?p.useLayoutEffect:p.useEffect;function yc(e){const n=In(),{control:s=n,disabled:a,name:r,exact:i}=e||{},[l,o]=p.useState(s._formState),d=p.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Tn(()=>s._subscribe({name:r,formState:d.current,exact:i,callback:u=>{!a&&o({...s._formState,...u})}}),[r,a,i]),p.useEffect(()=>{d.current.isValid&&s._setValid(!0)},[s]),p.useMemo(()=>Ka(l,s,d.current,!1),[l,s])}var Ae=e=>typeof e=="string",mn=(e,n,s,a,r)=>Ae(e)?(a&&n.watch.add(e),z(s,e,r)):Array.isArray(e)?e.map(i=>(a&&n.watch.add(i),z(s,i))):(a&&(n.watchAll=!0),s),hn=e=>Ce(e)||!qa(e);function De(e,n,s=new WeakSet){if(hn(e)||hn(n))return Object.is(e,n);if(We(e)&&We(n))return Object.is(e.getTime(),n.getTime());const a=Object.keys(e),r=Object.keys(n);if(a.length!==r.length)return!1;if(s.has(e)||s.has(n))return!0;s.add(e),s.add(n);for(const i of a){const l=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=n[i];if(We(l)&&We(o)||fe(l)&&fe(o)||Array.isArray(l)&&Array.isArray(o)?!De(l,o,s):!Object.is(l,o))return!1}}return!0}function vc(e){const n=In(),{control:s=n,name:a,defaultValue:r,disabled:i,exact:l,compute:o}=e||{},d=p.useRef(r),u=p.useRef(o),f=p.useRef(void 0),m=p.useRef(s),x=p.useRef(a);u.current=o;const[h,g]=p.useState(()=>{const N=s._getWatch(a,d.current);return u.current?u.current(N):N}),y=p.useCallback(N=>{const S=mn(a,s._names,N||s._formValues,!1,d.current);return u.current?u.current(S):S},[s._formValues,s._names,a]),j=p.useCallback(N=>{if(!i){const S=mn(a,s._names,N||s._formValues,!1,d.current);if(u.current){const E=u.current(S);De(E,f.current)||(g(E),f.current=E)}else g(S)}},[s._formValues,s._names,i,a]);Tn(()=>((m.current!==s||!De(x.current,a))&&(m.current=s,x.current=a,j()),s._subscribe({name:a,formState:{values:!0},exact:l,callback:N=>{j(N.values)}})),[s,l,a,j]),p.useEffect(()=>s._removeUnmounted());const w=m.current!==s,v=x.current,C=p.useMemo(()=>{if(i)return null;const N=!w&&!De(v,a);return w||N?y():null},[i,w,a,v,y]);return C!==null?C:h}function jc(e){const n=In(),{name:s,disabled:a,control:r=n,shouldUnregister:i,defaultValue:l,exact:o=!0}=e,d=Ya(r._names.array,s),u=p.useMemo(()=>z(r._formValues,s,z(r._defaultValues,s,l)),[r,s,l]),f=vc({control:r,name:s,defaultValue:u,exact:o}),m=yc({control:r,name:s,exact:o}),x=p.useRef(e),h=p.useRef(void 0),g=p.useRef(r.register(s,{...e.rules,value:f,...Se(e.disabled)?{disabled:e.disabled}:{}}));x.current=e;const y=p.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(m.errors,s)},isDirty:{enumerable:!0,get:()=>!!z(m.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!z(m.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!z(m.validatingFields,s)},error:{enumerable:!0,get:()=>z(m.errors,s)}}),[m,s]),j=p.useCallback(N=>g.current.onChange({target:{value:Wa(N),name:s},type:Nt.CHANGE}),[s]),w=p.useCallback(()=>g.current.onBlur({target:{value:z(r._formValues,s),name:s},type:Nt.BLUR}),[s,r._formValues]),v=p.useCallback(N=>{const S=z(r._fields,s);S&&S._f&&N&&(S._f.ref={focus:()=>we(N.focus)&&N.focus(),select:()=>we(N.select)&&N.select(),setCustomValidity:E=>we(N.setCustomValidity)&&N.setCustomValidity(E),reportValidity:()=>we(N.reportValidity)&&N.reportValidity()})},[r._fields,s]),C=p.useMemo(()=>({name:s,value:f,...Se(a)||m.disabled?{disabled:m.disabled||a}:{},onChange:j,onBlur:w,ref:v}),[s,a,m.disabled,j,w,v,f]);return p.useEffect(()=>{const N=r._options.shouldUnregister||i,S=h.current;S&&S!==s&&!d&&r.unregister(S),r.register(s,{...x.current.rules,...Se(x.current.disabled)?{disabled:x.current.disabled}:{}});const E=(A,L)=>{const D=z(r._fields,A);D&&D._f&&(D._f.mount=L)};if(E(s,!0),N){const A=de(z(r._options.defaultValues,s,x.current.defaultValue));ie(r._defaultValues,s,A),oe(z(r._formValues,s))&&ie(r._formValues,s,A)}return!d&&r.register(s),h.current=s,()=>{(d?N&&!r._state.action:N)?r.unregister(s):E(s,!1)}},[s,r,d,i]),p.useEffect(()=>{r._setDisabledField({disabled:a,name:s})},[a,s,r]),p.useMemo(()=>({field:C,formState:m,fieldState:y}),[C,m,y])}const wc=p.createContext(null);wc.displayName="HookFormContext";var Nc=(e,n,s,a,r)=>n?{...s[e],types:{...s[e]&&s[e].types?s[e].types:{},[a]:r||!0}}:{},lt=e=>Array.isArray(e)?e:[e],ws=()=>{let e=[];return{get observers(){return e},next:r=>{for(const i of e)i.next&&i.next(r)},subscribe:r=>(e.push(r),{unsubscribe:()=>{e=e.filter(i=>i!==r)}}),unsubscribe:()=>{e=[]}}};function Qa(e,n){const s={};for(const a in e)if(e.hasOwnProperty(a)){const r=e[a],i=n[a];if(r&&fe(r)&&i){const l=Qa(r,i);fe(l)&&(s[a]=l)}else e[a]&&(s[a]=i)}return s}var je=e=>fe(e)&&!Object.keys(e).length,_n=e=>e.type==="file",Ct=e=>{if(!Fn)return!1;const n=e?e.ownerDocument:0;return e instanceof(n&&n.defaultView?n.defaultView.HTMLElement:HTMLElement)},Za=e=>e.type==="select-multiple",Pn=e=>e.type==="radio",Cc=e=>Pn(e)||ft(e),Yt=e=>Ct(e)&&e.isConnected;function kc(e,n){const s=n.slice(0,-1).length;let a=0;for(;a<s;)e=oe(e)?a++:e[n[a++]];return e}function Sc(e){for(const n in e)if(e.hasOwnProperty(n)&&!oe(e[n]))return!1;return!0}function ue(e,n){const s=Array.isArray(n)?n:Mt(n)?[n]:Ln(n),a=s.length===1?e:kc(e,s),r=s.length-1,i=s[r];return a&&delete a[i],r!==0&&(fe(a)&&je(a)||Array.isArray(a)&&Sc(a))&&ue(e,s.slice(0,-1)),e}var Ac=e=>{for(const n in e)if(we(e[n]))return!0;return!1};function Xa(e){return Array.isArray(e)||fe(e)&&!Ac(e)}function xn(e,n={}){for(const s in e){const a=e[s];Xa(a)?(n[s]=Array.isArray(a)?[]:{},xn(a,n[s])):oe(a)||(n[s]=!0)}return n}function Ze(e,n,s){s||(s=xn(n));for(const a in e){const r=e[a];if(Xa(r))oe(n)||hn(s[a])?s[a]=xn(r,Array.isArray(r)?[]:{}):Ze(r,Ce(n)?{}:n[a],s[a]);else{const i=n[a];s[a]=!De(r,i)}}return s}const Ns={value:!1,isValid:!1},Cs={value:!0,isValid:!0};var Ja=e=>{if(Array.isArray(e)){if(e.length>1){const n=e.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:n,isValid:!!n.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!oe(e[0].attributes.value)?oe(e[0].value)||e[0].value===""?Cs:{value:e[0].value,isValid:!0}:Cs:Ns}return Ns},er=(e,{valueAsNumber:n,valueAsDate:s,setValueAs:a})=>oe(e)?e:n?e===""?NaN:e&&+e:s&&Ae(e)?new Date(e):a?a(e):e;const ks={isValid:!1,value:null};var tr=e=>Array.isArray(e)?e.reduce((n,s)=>s&&s.checked&&!s.disabled?{isValid:!0,value:s.value}:n,ks):ks;function Ss(e){const n=e.ref;return _n(n)?n.files:Pn(n)?tr(e.refs).value:Za(n)?[...n.selectedOptions].map(({value:s})=>s):ft(n)?Ja(e.refs).value:er(oe(n.value)?e.ref.value:n.value,e)}var $c=(e,n,s,a)=>{const r={};for(const i of e){const l=z(n,i);l&&ie(r,i,l._f)}return{criteriaMode:s,names:[...e],fields:r,shouldUseNativeValidation:a}},kt=e=>e instanceof RegExp,at=e=>oe(e)?e:kt(e)?e.source:fe(e)?kt(e.value)?e.value.source:e.value:e,As=e=>({isOnSubmit:!e||e===$e.onSubmit,isOnBlur:e===$e.onBlur,isOnChange:e===$e.onChange,isOnAll:e===$e.all,isOnTouch:e===$e.onTouched});const $s="AsyncFunction";var Dc=e=>!!e&&!!e.validate&&!!(we(e.validate)&&e.validate.constructor.name===$s||fe(e.validate)&&Object.values(e.validate).find(n=>n.constructor.name===$s)),Ec=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ds=(e,n,s)=>!s&&(n.watchAll||n.watch.has(e)||[...n.watch].some(a=>e.startsWith(a)&&/^\.\w+/.test(e.slice(a.length))));const ot=(e,n,s,a)=>{for(const r of s||Object.keys(e)){const i=z(e,r);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&n(l.refs[0],r)&&!a)return!0;if(l.ref&&n(l.ref,l.name)&&!a)return!0;if(ot(o,n))break}else if(fe(o)&&ot(o,n))break}}};function Es(e,n,s){const a=z(e,s);if(a||Mt(s))return{error:a,name:s};const r=s.split(".");for(;r.length;){const i=r.join("."),l=z(n,i),o=z(e,i);if(l&&!Array.isArray(l)&&s!==i)return{name:s};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};r.pop()}return{name:s}}var Fc=(e,n,s,a)=>{s(e);const{name:r,...i}=e;return je(i)||Object.keys(i).length>=Object.keys(n).length||Object.keys(i).find(l=>n[l]===(!a||$e.all))},Mc=(e,n,s)=>!e||!n||e===n||lt(e).some(a=>a&&(s?a===n:a.startsWith(n)||n.startsWith(a))),Lc=(e,n,s,a,r)=>r.isOnAll?!1:!s&&r.isOnTouch?!(n||e):(s?a.isOnBlur:r.isOnBlur)?!e:(s?a.isOnChange:r.isOnChange)?e:!0,Ic=(e,n)=>!Mn(z(e,n)).length&&ue(e,n),Tc=(e,n,s)=>{const a=lt(z(e,s));return ie(a,"root",n[s]),ie(e,s,a),e};function Fs(e,n,s="validate"){if(Ae(e)||Array.isArray(e)&&e.every(Ae)||Se(e)&&!e)return{type:s,message:Ae(e)?e:"",ref:n}}var Ke=e=>fe(e)&&!kt(e)?e:{value:e,message:""},Ms=async(e,n,s,a,r,i)=>{const{ref:l,refs:o,required:d,maxLength:u,minLength:f,min:m,max:x,pattern:h,validate:g,name:y,valueAsNumber:j,mount:w}=e._f,v=z(s,y);if(!w||n.has(y))return{};const C=o?o[0]:l,N=$=>{r&&C.reportValidity&&(C.setCustomValidity(Se($)?"":$||""),C.reportValidity())},S={},E=Pn(l),A=ft(l),L=E||A,D=(j||_n(l))&&oe(l.value)&&oe(v)||Ct(l)&&l.value===""||v===""||Array.isArray(v)&&!v.length,P=Nc.bind(null,y,a,S),M=($,I,T,K=Le.maxLength,H=Le.minLength)=>{const B=$?I:T;S[y]={type:$?K:H,message:B,ref:l,...P($?K:H,B)}};if(i?!Array.isArray(v)||!v.length:d&&(!L&&(D||Ce(v))||Se(v)&&!v||A&&!Ja(o).isValid||E&&!tr(o).isValid)){const{value:$,message:I}=Ae(d)?{value:!!d,message:d}:Ke(d);if($&&(S[y]={type:Le.required,message:I,ref:C,...P(Le.required,I)},!a))return N(I),S}if(!D&&(!Ce(m)||!Ce(x))){let $,I;const T=Ke(x),K=Ke(m);if(!Ce(v)&&!isNaN(v)){const H=l.valueAsNumber||v&&+v;Ce(T.value)||($=H>T.value),Ce(K.value)||(I=H<K.value)}else{const H=l.valueAsDate||new Date(v),B=re=>new Date(new Date().toDateString()+" "+re),X=l.type=="time",J=l.type=="week";Ae(T.value)&&v&&($=X?B(v)>B(T.value):J?v>T.value:H>new Date(T.value)),Ae(K.value)&&v&&(I=X?B(v)<B(K.value):J?v<K.value:H<new Date(K.value))}if(($||I)&&(M(!!$,T.message,K.message,Le.max,Le.min),!a))return N(S[y].message),S}if((u||f)&&!D&&(Ae(v)||i&&Array.isArray(v))){const $=Ke(u),I=Ke(f),T=!Ce($.value)&&v.length>+$.value,K=!Ce(I.value)&&v.length<+I.value;if((T||K)&&(M(T,$.message,I.message),!a))return N(S[y].message),S}if(h&&!D&&Ae(v)){const{value:$,message:I}=Ke(h);if(kt($)&&!v.match($)&&(S[y]={type:Le.pattern,message:I,ref:l,...P(Le.pattern,I)},!a))return N(I),S}if(g){if(we(g)){const $=await g(v,s),I=Fs($,C);if(I&&(S[y]={...I,...P(Le.validate,I.message)},!a))return N(I.message),S}else if(fe(g)){let $={};for(const I in g){if(!je($)&&!a)break;const T=Fs(await g[I](v,s),C,I);T&&($={...T,...P(I,T.message)},N(T.message),a&&(S[y]=$))}if(!je($)&&(S[y]={ref:C,...$},!a))return S}}return N(!0),S};const _c={mode:$e.onSubmit,reValidateMode:$e.onChange,shouldFocusError:!0};function Pc(e={}){let n={..._c,...e},s={submitCount:0,isDirty:!1,isReady:!1,isLoading:we(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},a={},r=fe(n.defaultValues)||fe(n.values)?de(n.defaultValues||n.values)||{}:{},i=n.shouldUnregister?{}:de(r),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={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},m={...f};let x={...m};const h={array:ws(),state:ws()},g=n.criteriaMode===$e.all,y=b=>k=>{clearTimeout(u),u=setTimeout(b,k)},j=async b=>{if(!l.keepIsValid&&!n.disabled&&(m.isValid||x.isValid||b)){let k;n.resolver?(k=je((await L()).errors),w()):k=await P(a,!0),k!==s.isValid&&h.state.next({isValid:k})}},w=(b,k)=>{!n.disabled&&(m.isValidating||m.validatingFields||x.isValidating||x.validatingFields)&&((b||Array.from(o.mount)).forEach(F=>{F&&(k?ie(s.validatingFields,F,k):ue(s.validatingFields,F))}),h.state.next({validatingFields:s.validatingFields,isValidating:!je(s.validatingFields)}))},v=(b,k=[],F,V,O=!0,_=!0)=>{if(V&&F&&!n.disabled){if(l.action=!0,_&&Array.isArray(z(a,b))){const Y=F(z(a,b),V.argA,V.argB);O&&ie(a,b,Y)}if(_&&Array.isArray(z(s.errors,b))){const Y=F(z(s.errors,b),V.argA,V.argB);O&&ie(s.errors,b,Y),Ic(s.errors,b)}if((m.touchedFields||x.touchedFields)&&_&&Array.isArray(z(s.touchedFields,b))){const Y=F(z(s.touchedFields,b),V.argA,V.argB);O&&ie(s.touchedFields,b,Y)}(m.dirtyFields||x.dirtyFields)&&(s.dirtyFields=Ze(r,i)),h.state.next({name:b,isDirty:$(b,k),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else ie(i,b,k)},C=(b,k)=>{ie(s.errors,b,k),h.state.next({errors:s.errors})},N=b=>{s.errors=b,h.state.next({errors:s.errors,isValid:!1})},S=(b,k,F,V)=>{const O=z(a,b);if(O){const _=z(i,b,oe(F)?z(r,b):F);oe(_)||V&&V.defaultChecked||k?ie(i,b,k?_:Ss(O._f)):K(b,_),l.mount&&!l.action&&j()}},E=(b,k,F,V,O)=>{let _=!1,Y=!1;const se={name:b};if(!n.disabled){if(!F||V){(m.isDirty||x.isDirty)&&(Y=s.isDirty,s.isDirty=se.isDirty=$(),_=Y!==se.isDirty);const ae=De(z(r,b),k);Y=!!z(s.dirtyFields,b),ae?ue(s.dirtyFields,b):ie(s.dirtyFields,b,!0),se.dirtyFields=s.dirtyFields,_=_||(m.dirtyFields||x.dirtyFields)&&Y!==!ae}if(F){const ae=z(s.touchedFields,b);ae||(ie(s.touchedFields,b,F),se.touchedFields=s.touchedFields,_=_||(m.touchedFields||x.touchedFields)&&ae!==F)}_&&O&&h.state.next(se)}return _?se:{}},A=(b,k,F,V)=>{const O=z(s.errors,b),_=(m.isValid||x.isValid)&&Se(k)&&s.isValid!==k;if(n.delayError&&F?(d=y(()=>C(b,F)),d(n.delayError)):(clearTimeout(u),d=null,F?ie(s.errors,b,F):ue(s.errors,b)),(F?!De(O,F):O)||!je(V)||_){const Y={...V,..._&&Se(k)?{isValid:k}:{},errors:s.errors,name:b};s={...s,...Y},h.state.next(Y)}},L=async b=>(w(b,!0),await n.resolver(i,n.context,$c(b||o.mount,a,n.criteriaMode,n.shouldUseNativeValidation))),D=async b=>{const{errors:k}=await L(b);if(w(b),b)for(const F of b){const V=z(k,F);V?ie(s.errors,F,V):ue(s.errors,F)}else s.errors=k;return k},P=async(b,k,F={valid:!0})=>{for(const V in b){const O=b[V];if(O){const{_f:_,...Y}=O;if(_){const se=o.array.has(_.name),ae=O._f&&Dc(O._f);ae&&m.validatingFields&&w([_.name],!0);const ve=await Ms(O,o.disabled,i,g,n.shouldUseNativeValidation&&!k,se);if(ae&&m.validatingFields&&w([_.name]),ve[_.name]&&(F.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(z(ve,_.name)?se?Tc(s.errors,ve,_.name):ie(s.errors,_.name,ve[_.name]):ue(s.errors,_.name))}!je(Y)&&await P(Y,k,F)}}return F.valid},M=()=>{for(const b of o.unMount){const k=z(a,b);k&&(k._f.refs?k._f.refs.every(F=>!Yt(F)):!Yt(k._f.ref))&&ye(b)}o.unMount=new Set},$=(b,k)=>!n.disabled&&(b&&k&&ie(i,b,k),!De(q(),r)),I=(b,k,F)=>mn(b,o,{...l.mount?i:oe(k)?r:Ae(b)?{[b]:k}:k},F,k),T=b=>Mn(z(l.mount?i:r,b,n.shouldUnregister?z(r,b,[]):[])),K=(b,k,F={})=>{const V=z(a,b);let O=k;if(V){const _=V._f;_&&(!_.disabled&&ie(i,b,er(k,_)),O=Ct(_.ref)&&Ce(k)?"":k,Za(_.ref)?[..._.ref.options].forEach(Y=>Y.selected=O.includes(Y.value)):_.refs?ft(_.ref)?_.refs.forEach(Y=>{(!Y.defaultChecked||!Y.disabled)&&(Array.isArray(O)?Y.checked=!!O.find(se=>se===Y.value):Y.checked=O===Y.value||!!O)}):_.refs.forEach(Y=>Y.checked=Y.value===O):_n(_.ref)?_.ref.value="":(_.ref.value=O,_.ref.type||h.state.next({name:b,values:de(i)})))}(F.shouldDirty||F.shouldTouch)&&E(b,O,F.shouldTouch,F.shouldDirty,!0),F.shouldValidate&&re(b)},H=(b,k,F)=>{for(const V in k){if(!k.hasOwnProperty(V))return;const O=k[V],_=b+"."+V,Y=z(a,_);(o.array.has(b)||fe(O)||Y&&!Y._f)&&!We(O)?H(_,O,F):K(_,O,F)}},B=(b,k,F={})=>{const V=z(a,b),O=o.array.has(b),_=de(k);ie(i,b,_),O?(h.array.next({name:b,values:de(i)}),(m.isDirty||m.dirtyFields||x.isDirty||x.dirtyFields)&&F.shouldDirty&&h.state.next({name:b,dirtyFields:Ze(r,i),isDirty:$(b,_)})):V&&!V._f&&!Ce(_)?H(b,_,F):K(b,_,F),Ds(b,o)?h.state.next({...s,name:b,values:de(i)}):h.state.next({name:l.mount?b:void 0,values:de(i)})},X=async b=>{l.mount=!0;const k=b.target;let F=k.name,V=!0;const O=z(a,F),_=ae=>{V=Number.isNaN(ae)||We(ae)&&isNaN(ae.getTime())||De(ae,z(i,F,ae))},Y=As(n.mode),se=As(n.reValidateMode);if(O){let ae,ve;const Ue=k.type?Ss(O._f):Wa(b),Oe=b.type===Nt.BLUR||b.type===Nt.FOCUS_OUT,ji=!Ec(O._f)&&!n.resolver&&!z(s.errors,F)&&!O._f.deps||Lc(Oe,z(s.touchedFields,F),s.isSubmitted,se,Y),Tt=Ds(F,o,Oe);ie(i,F,Ue),Oe?(!k||!k.readOnly)&&(O._f.onBlur&&O._f.onBlur(b),d&&d(0)):O._f.onChange&&O._f.onChange(b);const _t=E(F,Ue,Oe),wi=!je(_t)||Tt;if(!Oe&&h.state.next({name:F,type:b.type,values:de(i)}),ji)return(m.isValid||x.isValid)&&(n.mode==="onBlur"?Oe&&j():Oe||j()),wi&&h.state.next({name:F,...Tt?{}:_t});if(!Oe&&Tt&&h.state.next({...s}),n.resolver){const{errors:Zn}=await L([F]);if(w([F]),_(Ue),V){const Ni=Es(s.errors,a,F),Xn=Es(Zn,a,Ni.name||F);ae=Xn.error,F=Xn.name,ve=je(Zn)}}else w([F],!0),ae=(await Ms(O,o.disabled,i,g,n.shouldUseNativeValidation))[F],w([F]),_(Ue),V&&(ae?ve=!1:(m.isValid||x.isValid)&&(ve=await P(a,!0)));V&&(O._f.deps&&(!Array.isArray(O._f.deps)||O._f.deps.length>0)&&re(O._f.deps),A(F,ve,ae,_t))}},J=(b,k)=>{if(z(s.errors,k)&&b.focus)return b.focus(),1},re=async(b,k={})=>{let F,V;const O=lt(b);if(n.resolver){const _=await D(oe(b)?b:O);F=je(_),V=b?!O.some(Y=>z(_,Y)):F}else b?(V=(await Promise.all(O.map(async _=>{const Y=z(a,_);return await P(Y&&Y._f?{[_]:Y}:Y)}))).every(Boolean),!(!V&&!s.isValid)&&j()):V=F=await P(a);return h.state.next({...!Ae(b)||(m.isValid||x.isValid)&&F!==s.isValid?{}:{name:b},...n.resolver||!b?{isValid:F}:{},errors:s.errors}),k.shouldFocus&&!V&&ot(a,J,b?O:o.mount),V},q=(b,k)=>{let F={...l.mount?i:r};return k&&(F=Qa(k.dirtyFields?s.dirtyFields:s.touchedFields,F)),oe(b)?F:Ae(b)?z(F,b):b.map(V=>z(F,V))},Z=(b,k)=>({invalid:!!z((k||s).errors,b),isDirty:!!z((k||s).dirtyFields,b),error:z((k||s).errors,b),isValidating:!!z(s.validatingFields,b),isTouched:!!z((k||s).touchedFields,b)}),Q=b=>{b&<(b).forEach(k=>ue(s.errors,k)),h.state.next({errors:b?s.errors:{}})},W=(b,k,F)=>{const V=(z(a,b,{_f:{}})._f||{}).ref,O=z(s.errors,b)||{},{ref:_,message:Y,type:se,...ae}=O;ie(s.errors,b,{...ae,...k,ref:V}),h.state.next({name:b,errors:s.errors,isValid:!1}),F&&F.shouldFocus&&V&&V.focus&&V.focus()},ee=(b,k)=>we(b)?h.state.subscribe({next:F=>"values"in F&&b(I(void 0,k),F)}):I(b,k,!0),te=b=>h.state.subscribe({next:k=>{Mc(b.name,k.name,b.exact)&&Fc(k,b.formState||m,Me,b.reRenderRoot)&&b.callback({values:{...i},...s,...k,defaultValues:r})}}).unsubscribe,ke=b=>(l.mount=!0,x={...x,...b.formState},te({...b,formState:{...f,...b.formState}})),ye=(b,k={})=>{for(const F of b?lt(b):o.mount)o.mount.delete(F),o.array.delete(F),k.keepValue||(ue(a,F),ue(i,F)),!k.keepError&&ue(s.errors,F),!k.keepDirty&&ue(s.dirtyFields,F),!k.keepTouched&&ue(s.touchedFields,F),!k.keepIsValidating&&ue(s.validatingFields,F),!n.shouldUnregister&&!k.keepDefaultValue&&ue(r,F);h.state.next({values:de(i)}),h.state.next({...s,...k.keepDirty?{isDirty:$()}:{}}),!k.keepIsValid&&j()},xe=({disabled:b,name:k})=>{if(Se(b)&&l.mount||b||o.disabled.has(k)){const O=o.disabled.has(k)!==!!b;b?o.disabled.add(k):o.disabled.delete(k),O&&l.mount&&!l.action&&j()}},Be=(b,k={})=>{let F=z(a,b);const V=Se(k.disabled)||Se(n.disabled);return ie(a,b,{...F||{},_f:{...F&&F._f?F._f:{ref:{name:b}},name:b,mount:!0,...k}}),o.mount.add(b),F?xe({disabled:Se(k.disabled)?k.disabled:n.disabled,name:b}):S(b,!0,k.value),{...V?{disabled:k.disabled||n.disabled}:{},...n.progressive?{required:!!k.required,min:at(k.min),max:at(k.max),minLength:at(k.minLength),maxLength:at(k.maxLength),pattern:at(k.pattern)}:{},name:b,onChange:X,onBlur:X,ref:O=>{if(O){Be(b,k),F=z(a,b);const _=oe(O.value)&&O.querySelectorAll&&O.querySelectorAll("input,select,textarea")[0]||O,Y=Cc(_),se=F._f.refs||[];if(Y?se.find(ae=>ae===_):_===F._f.ref)return;ie(a,b,{_f:{...F._f,...Y?{refs:[...se.filter(Yt),_,...Array.isArray(z(r,b))?[{}]:[]],ref:{type:_.type,name:b}}:{ref:_}}}),S(b,!1,void 0,_)}else F=z(a,b,{}),F._f&&(F._f.mount=!1),(n.shouldUnregister||k.shouldUnregister)&&!(Ya(o.array,b)&&l.action)&&o.unMount.add(b)}}},Te=()=>n.shouldFocusError&&ot(a,J,o.mount),_e=b=>{Se(b)&&(h.state.next({disabled:b}),ot(a,(k,F)=>{const V=z(a,F);V&&(k.disabled=V._f.disabled||b,Array.isArray(V._f.refs)&&V._f.refs.forEach(O=>{O.disabled=V._f.disabled||b}))},0,!1))},Pe=(b,k)=>async F=>{let V;F&&(F.preventDefault&&F.preventDefault(),F.persist&&F.persist());let O=de(i);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:_,values:Y}=await L();w(),s.errors=_,O=de(Y)}else await P(a);if(o.disabled.size)for(const _ of o.disabled)ue(O,_);if(ue(s.errors,"root"),je(s.errors)){h.state.next({errors:{}});try{await b(O,F)}catch(_){V=_}}else k&&await k({...s.errors},F),Te(),setTimeout(Te);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:je(s.errors)&&!V,submitCount:s.submitCount+1,errors:s.errors}),V)throw V},Ve=(b,k={})=>{z(a,b)&&(oe(k.defaultValue)?B(b,de(z(r,b))):(B(b,k.defaultValue),ie(r,b,de(k.defaultValue))),k.keepTouched||ue(s.touchedFields,b),k.keepDirty||(ue(s.dirtyFields,b),s.isDirty=k.defaultValue?$(b,de(z(r,b))):$()),k.keepError||(ue(s.errors,b),m.isValid&&j()),h.state.next({...s}))},Ee=(b,k={})=>{const F=b?de(b):r,V=de(F),O=je(b),_=O?r:V;if(k.keepDefaultValues||(r=F),!k.keepValues){if(k.keepDirtyValues){const Y=new Set([...o.mount,...Object.keys(Ze(r,i))]);for(const se of Array.from(Y)){const ae=z(s.dirtyFields,se),ve=z(i,se),Ue=z(_,se);ae&&!oe(ve)?ie(_,se,ve):!ae&&!oe(Ue)&&B(se,Ue)}}else{if(Fn&&oe(b))for(const Y of o.mount){const se=z(a,Y);if(se&&se._f){const ae=Array.isArray(se._f.refs)?se._f.refs[0]:se._f.ref;if(Ct(ae)){const ve=ae.closest("form");if(ve){ve.reset();break}}}}if(k.keepFieldsRef)for(const Y of o.mount)B(Y,z(_,Y));else a={}}i=n.shouldUnregister?k.keepDefaultValues?de(r):{}:de(_),h.array.next({values:{..._}}),h.state.next({values:{..._}})}o={mount:k.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!n.shouldUnregister&&!je(_),l.watch=!!n.shouldUnregister,l.keepIsValid=!!k.keepIsValid,l.action=!1,k.keepErrors||(s.errors={}),h.state.next({submitCount:k.keepSubmitCount?s.submitCount:0,isDirty:O?!1:k.keepDirty?s.isDirty:!!(k.keepDefaultValues&&!De(b,r)),isSubmitted:k.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:O?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Ze(r,i):s.dirtyFields:k.keepDefaultValues&&b?Ze(r,b):k.keepDirty?s.dirtyFields:{},touchedFields:k.keepTouched?s.touchedFields:{},errors:k.keepErrors?s.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},ne=(b,k)=>Ee(we(b)?b(i):b,{...n.resetOptions,...k}),me=(b,k={})=>{const F=z(a,b),V=F&&F._f;if(V){const O=V.refs?V.refs[0]:V.ref;O.focus&&setTimeout(()=>{O.focus(),k.shouldSelect&&we(O.select)&&O.select()})}},Me=b=>{s={...s,...b}},pe={control:{register:Be,unregister:ye,getFieldState:Z,handleSubmit:Pe,setError:W,_subscribe:te,_runSchema:L,_updateIsValidating:w,_focusError:Te,_getWatch:I,_getDirty:$,_setValid:j,_setFieldArray:v,_setDisabledField:xe,_setErrors:N,_getFieldArray:T,_reset:Ee,_resetDefaultValues:()=>we(n.defaultValues)&&n.defaultValues().then(b=>{ne(b,n.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:_e,_subjects:h,_proxyFormState:m,get _fields(){return a},get _formValues(){return i},get _state(){return l},set _state(b){l=b},get _defaultValues(){return r},get _names(){return o},set _names(b){o=b},get _formState(){return s},get _options(){return n},set _options(b){n={...n,...b}}},subscribe:ke,trigger:re,register:Be,handleSubmit:Pe,watch:ee,setValue:B,getValues:q,reset:ne,resetField:Ve,clearErrors:Q,unregister:ye,setError:W,setFocus:me,getFieldState:Z};return{...pe,formControl:pe}}function Oc(e={}){const n=p.useRef(void 0),s=p.useRef(void 0),[a,r]=p.useState({isDirty:!1,isValidating:!1,isLoading:we(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:we(e.defaultValues)?void 0:e.defaultValues});if(!n.current)if(e.formControl)n.current={...e.formControl,formState:a},e.defaultValues&&!we(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Pc(e);n.current={...o,formState:a}}const i=n.current.control;return i._options=e,Tn(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>r({...i._formState}),reRenderRoot:!0});return r(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[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 l=i._getDirty();l!==a.isDirty&&i._subjects.state.next({isDirty:l})}},[i,a.isDirty]),p.useEffect(()=>{var l;e.values&&!De(e.values,s.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),s.current=e.values,r(o=>({...o}))):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()}),n.current.formState=p.useMemo(()=>Ka(a,i),[i,a]),n.current}function Rc(e,n=3){return e%1===0?e.toString():e.toFixed(n).replace(/\.?0+$/,"")}function zc(e,n="en-US",s="USD"){try{return new Intl.NumberFormat(n,{style:"currency",currency:s,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(a){return console.warn(`Invalid currency formatting: ${a}`),`${s} ${e.toFixed(2)}`}}function Bc(e="USD",n="en-US"){try{return new Intl.NumberFormat(n,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Vc(e){const n=e.replace(/[^\d.,-]/g,""),s=n.match(/,\d{1,2}$/);let a;s?a=n.replace(/\./g,"").replace(",","."):a=n.replace(/,/g,"");const r=parseFloat(a);return isNaN(r)?null:r}function Uc(e,n,s=.001){const a=e-n,r=Math.abs(a)<=s;return{difference:a,isBalanced:r,isUnderAllocated:!r&&a>0,isOverAllocated:!r&&a<0}}function On(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}On();const Hc={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:"$"},Gt=()=>({id:On(),amount:0,glAccount:null,isTaxDeductible:!1}),nr=({distribution:e,defaultDistribution:n,glAccounts:s=[],isLoadingGlAccounts:a=!1,onSearchGlAccounts:r,onDistributionChange:i,onAmountChange:l,onGlAccountChange:o,onTaxDeductibleChange:d,onDelete:u,canDelete:f=!0,canEditTaxDeductible:m=!0,isDisabled:x=!1,labels:h,classNames:g={},"data-testid":y,control:j,name:w,rules:v})=>{const C={...Hc,...h},N=j!==void 0&&w!==void 0,S=Oc({defaultValues:{_internal:n||Gt()}}),E=jc({control:N?j:S.control,name:N?w:"_internal",rules:N?v:void 0}),[A,L]=p.useState(n||Gt()),D=N?E.field.value??Gt():e??A,P=N&&!!E.fieldState?.error,M=N&&(E.fieldState?.isTouched??!1),$=P||M,I=$&&(!D.amount||D.amount<=0),T=$&&!D.glAccount,[K,H]=p.useState(D.glAccount?.name||""),B=p.useCallback(W=>{const ee={...D,...W};N&&E.field.onChange(ee),!N&&e===void 0&&L(ee),i?.(ee)},[D,e,i,N,E]),X=p.useCallback(W=>{const ee=W||0;B({amount:ee}),l?.(ee)},[B,l]),J=p.useCallback(W=>{H(W),r?.(W)},[r]),re=p.useCallback(W=>{if(W===null){B({glAccount:null}),o?.(null);return}const te=s.find(ke=>String(ke.id)===String(W))||null;B({glAccount:te}),o?.(te)},[s,B,o]),q=p.useCallback(()=>{H(""),B({glAccount:null}),o?.(null)},[B,o]),Z=p.useCallback(W=>{B({isTaxDeductible:W}),d?.(W)},[B,d]),Q=p.useCallback(()=>{u?.()},[u]);return t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":y||"revenue-distribution-card",className:c.cn(g.base),children:t.jsxs(c.CardBody,{className:c.cn("flex flex-row flex-nowrap items-start gap-4",g.body),children:[t.jsx("div",{className:c.cn("shrink-0",g.amountContainer),children:t.jsx(c.NumberInput,{"data-testid":`${y||"revenue-distribution-card"}-amount-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[C.amount,t.jsx(c.Tooltip,{content:C.amountTooltip,children:t.jsx(R,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:D.amount||void 0,onValueChange:X,labelPlacement:"outside",placeholder:C.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:x,isInvalid:I,errorMessage:I?"Amount is required":void 0,minValue:0,step:.01,className:g.amountInput,startContent:t.jsx("div",{className:"pointer-events-none flex items-center",children:t.jsx("span",{className:"text-default-400 text-small",children:C.currencySymbol})})})}),t.jsx("div",{className:c.cn("grow",g.glAccountContainer),children:t.jsx(c.Autocomplete,{"data-testid":`${y||"revenue-distribution-card"}-gl-account-input`,label:t.jsxs("span",{className:"flex items-center gap-1",children:[C.glAccount,t.jsx(c.Tooltip,{content:C.glAccountTooltip,children:t.jsx(R,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:a,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:s,menuTrigger:"input",inputValue:D.glAccount?.name??K,selectedKey:D.glAccount?.id??null,isDisabled:x,isInvalid:T,errorMessage:T?"GL Account is required":void 0,listboxProps:{emptyContent:a?C.searching:C.noGlAccountsFound},placeholder:C.glAccountPlaceholder,onInputChange:J,onSelectionChange:re,onClear:q,className:g.glAccountInput,children:W=>t.jsx(c.AutocompleteItem,{textValue:W.name,children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{children:W.name}),W.code&&t.jsx("span",{className:"text-xs text-default-400",children:W.code})]})},W.id)})}),t.jsx("div",{className:c.cn("shrink-0 pt-6 flex items-center",g.taxDeductibleContainer),children:t.jsx(c.Checkbox,{radius:"full","data-testid":`${y||"revenue-distribution-card"}-tax-deductible`,isSelected:D.isTaxDeductible,onValueChange:Z,isDisabled:x||!m,className:g.taxDeductibleCheckbox,children:C.taxDeductible})}),t.jsx("div",{className:c.cn("shrink-0 pt-6",g.deleteContainer),children:t.jsx(U,{"data-testid":`${y||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:x||!f,onPress:Q,startContent:t.jsx(R,{icon:"solar:trash-bin-trash-linear",width:16}),className:c.cn("text-danger",g.deleteButton),children:C.deleteButton})})]})})};nr.displayName="RevenueDistributionCard";const sr=({message:e="No distributions configured",icon:n="solar:document-text-outline",iconSize:s=48,showCard:a=!0,classNames:r={},renderEmpty:i})=>{if(i)return t.jsx(t.Fragment,{children:i()});const l=t.jsxs("div",{className:c.cn("flex flex-col items-center justify-center py-8",r.content),children:[t.jsx(R,{icon:n,width:s,className:c.cn("text-default-300 mb-4",r.icon)}),t.jsx("p",{className:c.cn("text-default-500 text-sm text-center",r.message),children:e})]});return a?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-empty",className:c.cn("w-full",r.base),children:l})};sr.displayName="RevenueDistributionEmpty";const qc={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},ar=({error:e,labels:n,showCard:s=!0,color:a="danger",classNames:r={}})=>{const i={...qc,...n},l=t.jsx(c.Alert,{"data-testid":"revenue-distribution-error-alert",color:a,title:i.title,description:e||i.description,className:r.alert});return s?t.jsx(c.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:t.jsx(c.CardBody,{children:l})}):t.jsx("div",{"data-testid":"revenue-distribution-error",className:c.cn("w-full",r.base),children:l})};ar.displayName="RevenueDistributionError";const rr=({rows:e=1,showCard:n=!0,classNames:s={}})=>{const a=Array.from({length:e},(i,l)=>l),r=i=>t.jsxs("div",{className:c.cn("flex flex-row flex-nowrap items-end gap-4",s.row),children:[t.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-14 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),t.jsxs("div",{className:"grow flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(c.Skeleton,{className:"h-4 w-20 rounded-md"}),t.jsx(c.Skeleton,{className:"h-4 w-4 rounded-full"})]}),t.jsx(c.Skeleton,{className:"h-10 w-full rounded-lg"})]}),t.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[t.jsx(c.Skeleton,{className:"h-5 w-5 rounded-full"}),t.jsx(c.Skeleton,{className:"h-4 w-24 rounded-md"})]}),t.jsx("div",{className:"shrink-0 pb-2",children:t.jsx(c.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return n?t.jsx("div",{className:c.cn("flex flex-col gap-3",s.base),children:a.map(i=>t.jsx(c.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:t.jsx(c.CardBody,{children:r(i)})},i))}):t.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:c.cn("flex flex-col gap-3",s.base),children:a.map(i=>r(i))})};rr.displayName="RevenueDistributionSkeleton";function Lt({isOpen:e,labels:n,icon:s,isConfirming:a=!1,confirmColor:r="danger",iconTone:i="danger",portalContainer:l,shouldBlockScroll:o,classNames:d,onClose:u,onConfirm:f}){return t.jsx(c.Modal,{isOpen:e,size:"md",placement:"center",portalContainer:l,shouldBlockScroll:o,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:m=>!m&&u(),children:t.jsxs(c.ModalContent,{children:[t.jsxs(c.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[s&&t.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:s}),t.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:n.title})]}),t.jsx(c.ModalBody,{className:"px-7 pb-3 pt-4",children:t.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:n.description})}),t.jsxs(c.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[t.jsx(U,{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:n.cancel}),t.jsx(U,{type:"button",size:"md",color:r,radius:"full",className:c.cn("h-10 text-sm font-normal text-white",r==="danger"?"bg-danger-600":"bg-brand"),isLoading:a,onPress:f,children:n.confirm})]})]})})}const Wc=()=>({id:crypto.randomUUID(),fund:null,percentage:0});function pn(e){return!e.fund&&Number(e.percentage||0)<=0}function Yc({mode:e,assignments:n}){const s=n.filter(l=>!pn(l)),a=s.filter(l=>l.fund),r=a.reduce((l,o)=>l+Number(o.percentage||0),0),i=s.some(l=>!l.fund||Number(l.percentage||0)<=0);return a.length>=1&&!i&&Math.round(r*100)/100===100}const Gc={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"},ir={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={...ir,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},Kc={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"},Qc={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"};function Zc(){return t.jsxs("svg",{"aria-hidden":"true",className:"size-4 text-zinc-500",fill:"none",viewBox:"0 0 16 16",children:[t.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"3",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"}),t.jsx("rect",{x:"9",y:"9",width:"4",height:"4",rx:"1",stroke:"currentColor",strokeWidth:"1.4"})]})}const Xc=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,Jc=e=>e.fund!==null;function ed({assignments:e,funds:n,labels:s,classNames:a,isSaving:r=!1,hasSavedAssignments:i=!1,isFundPickerOpen:l=!1,activeAssignmentId:o=null,modalPortalContainer:d,footer:u,onAssignmentsChange:f,onOpenFundPicker:m,onCloseFundPicker:x,onCollapseChange:h,onSave:g}){const[y,j]=p.useState(null),w=d??y??void 0,v={...Gc,...s},C=e.filter(W=>!pn(W)),S=C.filter(Jc).length>0,E=p.useMemo(()=>e.filter(W=>!pn(W)).reduce((W,ee)=>W+Number(ee.percentage||0),0),[e]),A=Math.round(E*100)/100,L=C.some(W=>!W.fund||Number(W.percentage||0)<=0),D=S&&(A!==100||L),P=`${v.totalError} (${v.total} ${Number(E.toFixed(2))}%)`,M=Yc({mode:"split",assignments:e}),$=S&&A>=100,[I,T]=p.useState(!1),[K,H]=p.useState(!1),B=t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Zc,{}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:v.title})]}),X=(W,ee)=>{f(e.map(te=>te.id===W?{...te,...ee}:te))},J=()=>{$||f([...e,Wc()])},re=W=>{e.length<=1||f(e.filter(ee=>ee.id!==W))},q=()=>{if(!r){if(!M){H(!0);return}if(!i){g();return}T(!0)}},Z=()=>{T(!1),g()},Q=W=>{const ee=o??e.find(te=>!te.fund)?.id??e[0]?.id;ee&&(f(e.map(te=>te.id===ee?{...te,fund:W}:te)),x())};return t.jsxs("div",{ref:j,className:c.cn("vvt-pa relative font-sans text-zinc-900",l&&!d&&"min-h-[560px]",a?.root),children:[t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:c.cn("w-full gap-0 px-0",a?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",a?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},onSelectionChange:W=>h?.(!(W==="all"||Array.from(W).length>0)),children:t.jsx(c.AccordionItem,{"aria-label":v.title,title:B,children:t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",a?.content),children:[t.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&t.jsx(c.Alert,{icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:ir,color:"default",variant:"flat",title:v.emptySplit}),S&&t.jsx(td,{assignments:e,labels:v,total:E,hasTotalError:K&&!M||D,validationMessage:P,onSelectFund:W=>m(W),onRemoveFund:re,onPercentageChange:(W,ee)=>X(W,{percentage:Xc(ee)})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx(U,{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:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),isDisabled:$,onPress:()=>S?J():m(),children:v.assignSpecificFund}),t.jsx(U,{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:r?void 0:t.jsx(R,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:r,onPress:q,children:v.saveAssignment})]})]}),u]})},"installment-fund-assignment")}),l&&t.jsx(nd,{funds:n,labels:v,selectedFundIds:e.map(W=>W.fund?.id).filter(Boolean),portalContainer:w,onSelect:Q,onClose:x}),t.jsx(Lt,{isOpen:I,labels:{title:v.modifyAssignedFundsTitle,description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:v.modifyAssignedFundsDescription}),t.jsx("p",{className:"mt-3",children:v.modifyAssignedFundsWarning})]}),cancel:v.modifyAssignedFundsCancel,confirm:v.modifyAssignedFundsConfirm},icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",portalContainer:w,shouldBlockScroll:!1,classNames:Qc,onClose:()=>T(!1),onConfirm:Z})]})}function td({assignments:e,labels:n,total:s,hasTotalError:a,validationMessage:r,onSelectFund:i,onRemoveFund:l,onPercentageChange:o}){return t.jsxs("div",{className:"flex flex-col gap-3",children:[e.map((d,u)=>t.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:[t.jsx("div",{className:c.cn("flex min-h-11 min-w-0 flex-1 items-center","gap-4"),children:d.fund?t.jsxs(t.Fragment,{children:[t.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]}),t.jsx(U,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(d.id),children:"Replace"})]}):t.jsx(U,{type:"button",size:"lg",variant:"light",radius:"full",className:"justify-start px-4 text-lg font-normal text-zinc-900",startContent:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(d.id),children:n.assignSpecificFund})}),t.jsx("label",{className:"flex w-48 flex-none items-center",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(d.percentage||""),onChange:f=>o(d.id,Number(f.target.value)),endContent:t.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:Kc})}),e.length>1&&t.jsx(U,{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:()=>l(d.id),"aria-label":n.removeFund,children:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},d.id)),t.jsx(c.Alert,{icon:t.jsx(R,{icon:a?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:a?"warning":"success",variant:"flat",classNames:{...rt,base:c.cn(rt.base,a?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:c.cn(rt.iconWrapper,a?"text-warning-700":"text-success-700"),alertIcon:c.cn(rt.alertIcon,a?"text-warning-700":"text-success-700"),title:c.cn(rt.title,a?"text-warning-700":"text-success-700")},title:a?r:`${n.total} ${Number(s.toFixed(2))}%`})]})}function nd({funds:e,labels:n,selectedFundIds:s,portalContainer:a,onSelect:r,onClose:i}){const[l,o]=p.useState(""),d=e.filter(u=>{if(s.includes(u.id))return!1;const f=l.trim().toLowerCase();return f?`${u.glCode} ${u.accountName} ${u.type}`.toLowerCase().includes(f):!0});return t.jsx(c.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",shouldBlockScroll:!1,portalContainer:a,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:t.jsxs(c.ModalContent,{className:"max-h-full",children:[t.jsx(c.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:n.modalTitle}),t.jsxs(c.ModalBody,{className:"flex min-h-0 flex-1 flex-col px-6 pb-6",children:[t.jsx(c.Input,{variant:"bordered","aria-label":n.searchPlaceholder,value:l,placeholder:n.searchPlaceholder,onChange:u=>o(u.target.value),startContent:t.jsx(R,{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"}}),t.jsxs("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:[t.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:[t.jsx("span",{children:n.glCode}),t.jsx("span",{children:n.accountName}),t.jsx("span",{children:n.actions})]}),d.length===0&&t.jsx("div",{className:"p-4 text-sm text-zinc-500",children:n.noFunds}),d.map(u=>t.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:[t.jsx("span",{children:u.glCode}),t.jsx("span",{children:u.accountName}),t.jsx(U,{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:()=>r(u),children:n.select})]},u.id))]})]})]})})}function sd(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const ad={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function rd({totalAmount:e,remainingBalance:n,amountReceived:s,currency:a="USD",locale:r="en-US",labels:i,className:l}){const o={...ad,...i},d=new Intl.NumberFormat(r,{style:"currency",currency:a});return t.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",l),children:t.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[t.jsx(Kt,{label:o.totalAmount,value:d.format(e)}),t.jsx(Kt,{label:o.remainingBalance,value:d.format(n)}),t.jsx(Kt,{label:o.amountReceived,value:d.format(s)})]})})}function Kt({label:e,value:n}){return t.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[t.jsx("span",{className:"font-medium text-zinc-700",children:e}),t.jsx("span",{className:"font-normal text-zinc-950",children:n})]})}const id={monthly:1,quarterly:3,annual:12},lr=e=>{const[n,s,a]=e.split("-").map(Number);return{year:n,month:s,day:a}},ld=(e,n)=>new Date(e,n+1,0).getDate(),od=e=>{const n=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${n}-${s}-${a}`},cd=(e,n)=>{const{year:s,month:a,day:r}=lr(e),i=a-1+n,l=s+Math.floor(i/12),o=(i%12+12)%12,d=Math.min(r,ld(l,o));return new Date(l,o,d)},dd=(e,n)=>{const{year:s,month:a,day:r}=lr(e),i=new Date(s,a-1,r);return i.setDate(i.getDate()+n),i};function or(e,n){const s=Math.max(1,Math.floor(n.numberOfInstallments||1)),a=Math.round(e*100),r=Math.floor(a/s),i=a-r*s,l=id[n.frequency];return Array.from({length:s},(o,d)=>{const u=n.frequency==="weekly"?dd(n.firstInstallmentDate,d*7):cd(n.firstInstallmentDate,d*(l??1));return{id:crypto.randomUUID(),dueDate:od(u),amount:(r+(d===0?i:0))/100}})}function ud(e){return new Set(e.map((n,s)=>{const a=e[s+1]?.dueDate;return n.dueDate&&a&&n.dueDate>a?n.id:null}).filter(n=>!!n))}const fd={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."},md=["weekly","monthly","quarterly","annual"],hd=Array.from({length:31},(e,n)=>n+1),xd=["numberOfInstallments","frequency","firstInstallmentDate"],pd={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Ls=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),cr=e=>Math.round(e*100)/100,gd=(e,n)=>{const s=new Date(`${e}T00:00:00`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(s)},It=e=>{if(!e)return null;try{return fo(e)}catch{return null}},bd=e=>It(e)?.day??1,yd=(e,n)=>new Date(e,n,0).getDate(),vd=(e,n)=>{const s=It(e);if(!s)return e;const a=Math.min(n,yd(s.year,s.month));return s.set({day:a}).toString()},Is=e=>{const n=e%100>=11&&e%100<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${n}`};function jd({mode:e,donationAmount:n,currency:s="USD",locale:a="en-US",installments:r,automaticSettings:i,defaultTab:l="automatic",showTitle:o=!0,showCard:d=!0,showSavePayment:u=!0,showTabs:f=!0,inputs:m=xd,startDate:x,labels:h,classNames:g,isSaving:y=!1,isModeSwitchDisabled:j=!1,onModeChange:w,onAutomaticSettingsChange:v,onInstallmentsChange:C,onSave:N}){const[S,E]=p.useState(null),[A,L]=p.useState(l),D={...fd,...h},P=e??A,M=p.useMemo(()=>new Intl.NumberFormat(a,{style:"currency",currency:s}),[s,a]),$=p.useMemo(()=>({...i,firstInstallmentDate:m.includes("firstInstallmentDate")?i.firstInstallmentDate:m.includes("dayOfMonth")?i.firstInstallmentDate||x||"":x||i.firstInstallmentDate}),[i,m,x]),I=P==="automatic"?or(n,$):r,T=p.useMemo(()=>cr(I.reduce((te,ke)=>te+Number(ke.amount||0),0)),[I]),K=P==="manual"&&T-n>.009,[H,B]=p.useState(!1),X=o?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(G.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:D.title})]}):void 0,J=te=>{te!==P&&(e||L(te),w?.(te),te==="manual"&&r.length===0&&C([Ls()]))},re=(te,ke)=>{r.find(xe=>xe.id===te)?.status!=="paid"&&C(r.map(xe=>xe.id===te?{...xe,...ke}:xe))},q=()=>{C([...r,Ls()])},Z=te=>{r.find(ye=>ye.id===te)?.status!=="paid"&&C(r.filter(ye=>ye.id!==te))},Q=()=>{if(!y){if(K){B(!0);return}N?.()}},W=()=>{B(!1),N?.()},ee=t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",g?.content),children:[f||u?t.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[f?t.jsx(wd,{mode:P,labels:D,onModeChange:J,isDisabled:j,className:g?.tabs}):null,u?t.jsx(U,{type:"button",size:"md",color:"primary",radius:"full",className:"ml-auto min-w-36",startContent:y?void 0:t.jsx(R,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:y,onPress:Q,children:D.saveInstallments}):null]}):null,t.jsxs("div",{className:c.cn("flex w-full flex-col gap-4",g?.preview),children:[P==="automatic"&&t.jsx(Nd,{settings:$,inputs:m,labels:D,className:g?.controls,onSettingsChange:v}),I.length===0&&t.jsx(c.Alert,{isClosable:!1,color:"default",variant:"flat",radius:"full",title:P==="automatic"?D.emptyAutomatic:D.emptyManual}),I.length>0&&t.jsx(Cd,{mode:P,installments:I,labels:D,formatter:M,locale:a,onUpdateInstallment:re,onRemoveInstallment:Z}),P==="manual"&&t.jsx("div",{className:"flex flex-wrap gap-3",children:t.jsx(U,{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:t.jsx(G.Plus,{className:"size-5",strokeWidth:2}),onPress:q,children:D.addInstallment})}),t.jsx(Sd,{total:T,donationAmount:n,hasTotalIncreaseWarning:K,mode:P,installments:I,formatter:M,labels:D,className:g?.summary})]})]});return t.jsxs("div",{ref:E,className:c.cn("vvt-ps relative font-sans text-zinc-900",g?.root),children:[d?t.jsx(c.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:c.cn("w-full gap-0 px-0",g?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:c.cn("px-4 py-4",g?.header),title:"w-full",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500 [&>svg]:size-4"},children:t.jsx(c.AccordionItem,{"aria-label":D.title,title:X,children:ee},"installment-schedule")}):ee,t.jsx(Lt,{isOpen:H,labels:{title:D.totalIncreaseConfirmationTitle,description:D.totalIncreaseConfirmationDescription,cancel:D.totalIncreaseConfirmationCancel,confirm:D.totalIncreaseConfirmationConfirm},icon:t.jsx(R,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",isConfirming:y,portalContainer:S??void 0,shouldBlockScroll:!1,classNames:pd,onClose:()=>B(!1),onConfirm:W})]})}function wd({mode:e,labels:n,className:s,isDisabled:a=!1,onModeChange:r}){return t.jsxs(c.Tabs,{"aria-label":n.title,selectedKey:e,isDisabled:a,color:"primary",size:"lg",radius:"full",className:c.cn("w-fit",s),onSelectionChange:i=>r(i),children:[t.jsx(c.Tab,{title:n.automaticMode},"automatic"),t.jsx(c.Tab,{title:n.manualMode},"manual")]})}function Nd({settings:e,inputs:n,labels:s,className:a,onSettingsChange:r}){const i=l=>{if(l==="numberOfInstallments")return t.jsx("div",{className:"min-w-0",children:t.jsx(c.Input,{variant:"bordered",label:s.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:o=>o.currentTarget.blur(),onChange:o=>{const d=o.target.value;r({...e,numberOfInstallments:d===""?0:Math.max(1,Number(d))})}})},l);if(l==="frequency")return t.jsx("div",{className:"min-w-0",children:t.jsx(Fe,{variant:"bordered",label:s.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:o=>{const d=Array.from(o)[0];typeof d=="string"&&r({...e,frequency:d})},children:md.map(o=>t.jsx(c.SelectItem,{textValue:s[o],children:s[o]},o))})},l);if(l==="dayOfMonth"){const o=String(bd(e.firstInstallmentDate));return t.jsx("div",{className:"min-w-0",children:t.jsx(Fe,{variant:"bordered",label:s.dayOfMonth,labelPlacement:"outside",selectedKeys:[o],onSelectionChange:d=>{const u=Number(Array.from(d)[0]);Number.isFinite(u)&&r({...e,firstInstallmentDate:vd(e.firstInstallmentDate,u)})},children:hd.map(d=>t.jsx(c.SelectItem,{textValue:Is(d),children:Is(d)},String(d)))})},l)}return t.jsx("div",{className:"min-w-0",children:t.jsx(En,{variant:"bordered",label:s.firstInstallmentDate,labelPlacement:"outside",value:It(e.firstInstallmentDate),onChange:o=>r({...e,firstInstallmentDate:o?o.toString():""}),startContent:t.jsx(R,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"})})},l)};return n.length===0?null:t.jsx("div",{className:c.cn("grid gap-4",a),style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 14rem), 1fr))"},children:n.map(i)})}function Cd({mode:e,installments:n,labels:s,formatter:a,locale:r,onUpdateInstallment:i,onRemoveInstallment:l}){const o=ud(n),d=new Set(n.map(u=>Number(u.amount||0)<=0?u.id:null).filter(u=>!!u));return e==="automatic"?t.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:t.jsx("div",{className:c.cn("flex flex-col gap-3",n.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:n.map((u,f)=>t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["#",f+1]}),t.jsx("span",{children:"▪"}),t.jsx("span",{children:gd(u.dueDate,r)}),f===0&&n.length>1&&t.jsx(c.Chip,{size:"sm",color:"primary",variant:"solid",radius:"full",children:"First charge"})]}),t.jsx("span",{className:"text-zinc-950",children:a.format(u.amount)})]},u.id))})}):t.jsx("div",{className:"flex flex-col gap-2",children:n.map((u,f)=>{const m=o.has(u.id),x=d.has(u.id);return t.jsx("div",{className:"flex w-full flex-col gap-1",children:t.jsxs("div",{className:"grid w-full grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)_2.25rem] items-start gap-4",children:[t.jsx("span",{className:"pt-2 text-sm font-medium text-zinc-500",children:f+1}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(En,{variant:"bordered","aria-label":`${s.dueDate} ${f+1}`,isDisabled:u.status==="paid",isInvalid:m,errorMessage:m?s.dateOrderError:void 0,value:It(u.dueDate),onChange:h=>i(u.id,{dueDate:h?h.toString():""})})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(c.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:u.status==="paid",isInvalid:x,errorMessage:x?s.amountGreaterThanZeroError:void 0,value:String(u.amount||""),onChange:h=>i(u.id,{amount:cr(Number(h.target.value||0))}),startContent:t.jsx("span",{className:"text-zinc-900",children:"$"})})}),t.jsx(kd,{isDisabled:n.length<=1,isPaid:u.status==="paid",label:s.deleteInstallment,onRemove:()=>l(u.id)})]})},u.id)})})}function kd({isDisabled:e,isPaid:n,label:s,onRemove:a}){const r=t.jsx(U,{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||n,onPress:a,"aria-label":s,children:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return n?t.jsx(c.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:t.jsx("span",{className:"inline-flex",children:r})}):r}function Sd({total:e,donationAmount:n,hasTotalIncreaseWarning:s,mode:a,installments:r,formatter:i,labels:l,className:o}){const d=r.length,u=r[0]?.amount??0,f=r[1]?.amount??u,m=d>1&&Math.round(u*100)!==Math.round(f*100),x=Math.max(n-e,0),h=s?t.jsx("span",{children:l.totalIncreaseWarning}):a==="automatic"?m?t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records:"," ",t.jsx("strong",{children:i.format(u)})," first charge and"," ",t.jsx("strong",{children:i.format(f)})," for each remaining charge."]}):t.jsxs("span",{children:["Saving will create ",t.jsx("strong",{children:d})," scheduled payment records of"," ",t.jsx("strong",{children:i.format(u)})," each."]}):t.jsxs("span",{children:["Total scheduled: ",t.jsx("strong",{children:i.format(e)})," /"," ",t.jsx("strong",{children:i.format(n)}),"."]}),g=a==="automatic"?`Total: ${i.format(e)}`:s?`New total: ${i.format(e)}`:`${l.remaining}: ${i.format(x)}`;return t.jsx(c.Alert,{isClosable:!1,color:s?"warning":"default",variant:"flat",radius:"full",className:o,endContent:t.jsx("span",{className:"whitespace-nowrap",children:g}),title:h})}function Ad(){return t.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:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-7 w-56 rounded-lg"}),t.jsx(c.Skeleton,{className:"size-8 rounded-full"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(c.Skeleton,{className:"h-10 w-72 rounded-full"}),t.jsx(c.Skeleton,{className:"h-10 w-40 rounded-full"})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[t.jsx(c.Skeleton,{className:"h-4 w-36 rounded-md"}),t.jsx(c.Skeleton,{className:"h-9 w-full rounded-xl"})]}),t.jsx(c.Skeleton,{className:"h-9 w-36 rounded-full"})]}),t.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,n)=>t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[t.jsx(c.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),t.jsx(c.Skeleton,{className:"h-8 w-full rounded-xl"})]},n))})]})}const Ts={paid:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-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",processing:"bg-sky-50 text-sky-700",pending_confirmation:"bg-indigo-50 text-indigo-700"},dr={paid:"Paid",scheduled:"Scheduled",schedule:"Scheduled",payment_due:"Payment Due",overdue:"Overdue",failed:"Failed",refunded:"Refunded",disputed:"Disputed",canceled:"Canceled",processing:"Processing",pending_confirmation:"Pending Confirmation"},$d={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:t.jsxs(t.Fragment,{children:["Are you sure you want to delete this payment? ",t.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."},Dd={wrapper:"!absolute !inset-0 !z-50 !items-center !justify-center !p-4",backdrop:"!absolute !inset-0 !z-40 rounded-2xl"},Ed=[];function Fd({installments:e,currency:n,locale:s="en-US",showTitle:a=!0,showCard:r=!0,showEditPayment:i=!0,showDelete:l=!0,payNowHiddenStatuses:o=Ed,labels:d,isSaving:u=!1,onEditInstallments:f,onPayInstallment:m,onDeleteInstallment:x}){const[h,g]=p.useState(null),y={...$d,...d},[j,w]=p.useState(""),v=new Intl.NumberFormat(s,{style:"currency",currency:n}),C=a?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(G.CircleDollarSign,{className:"size-4 text-zinc-500",strokeWidth:1.75}),t.jsx("span",{className:"text-base font-medium leading-6 text-zinc-950",children:y.title})]}):void 0,N=p.useMemo(()=>{const E=j.trim().toLowerCase();return E?e.filter(A=>{const L=A.status??"scheduled";return[A.id,A.amount,A.dueDate,Qt(A.dueDate,s),L,dr[L]??L].join(" ").toLowerCase().includes(E)}):e},[s,e,j]),S=t.jsxs("div",{className:"flex min-w-0 w-full flex-col gap-4 overflow-x-hidden [container-type:inline-size]",children:[t.jsxs("div",{className:"flex min-w-0 w-full flex-wrap items-end justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 w-full max-w-[280px]",children:[t.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:y.searchLabel}),t.jsx(c.Input,{variant:"bordered",size:"md",value:j,placeholder:y.searchPlaceholder,onChange:E=>w(E.target.value),startContent:t.jsx(R,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"})})]}),i?t.jsx(U,{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:t.jsx(R,{icon:"solar:pen-outline",className:"size-4"}),isLoading:u,onPress:f,children:y.editInstallments}):null]}),t.jsx("div",{className:c.cn("hidden [@container(max-width:767px)]:block",N.length>3&&"max-h-[560px] overflow-y-auto pr-1"),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[N.map((E,A)=>{const L=E.status??"scheduled";return t.jsx(c.Card,{radius:"lg",shadow:"none",className:"border border-default-200",children:t.jsxs(c.CardBody,{className:"gap-3 p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-xs text-default-500",children:["#",A+1]}),t.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:E.id||`PMT-${A+1}`})]}),t.jsx(_s,{status:L})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-default-500",children:y.amount}),t.jsx("p",{className:"font-medium text-foreground",children:v.format(E.amount)})]}),t.jsxs("div",{className:"text-right",children:[t.jsx("p",{className:"text-xs text-default-500",children:y.scheduledDate}),t.jsx("p",{className:"font-medium text-foreground",children:Qt(E.dueDate,s)})]})]}),t.jsx(Ps,{status:L,installment:E,labels:y,portalContainer:h??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:m,onDeleteInstallment:x})]})},E.id)}),N.length===0&&t.jsx("div",{className:"rounded-lg border border-default-200 px-4 py-6 text-center text-sm text-default-500",children:y.noInstallmentsFound})]})}),t.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:t.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-12"}),t.jsx("col",{}),t.jsx("col",{className:"w-24"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:"w-36"}),t.jsx("col",{className:"w-44"})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"sticky top-0 z-10 border-b border-zinc-200 bg-white text-zinc-900",children:[t.jsx("th",{className:"px-2 py-3 font-medium",children:"#"}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.installmentId}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.amount}),t.jsx("th",{className:"px-2 py-3 font-medium",children:y.scheduledDate}),t.jsx("th",{className:"whitespace-nowrap px-2 py-3 font-medium",children:y.status}),t.jsx("th",{className:"whitespace-nowrap py-3 pl-4 pr-2 font-medium",children:y.actions})]})}),t.jsxs("tbody",{children:[N.map((E,A)=>{const L=E.status??"scheduled";return t.jsxs("tr",{className:"text-zinc-500",children:[t.jsx("td",{className:"px-2 py-3",children:A+1}),t.jsx("td",{className:"overflow-hidden px-2 py-3",children:t.jsx("span",{className:"block w-full truncate",children:E.id||`PMT-${A+1}`})}),t.jsx("td",{className:"px-2 py-3",children:v.format(E.amount)}),t.jsx("td",{className:"px-2 py-3",children:Qt(E.dueDate,s)}),t.jsx("td",{className:"whitespace-nowrap px-2 py-3",children:t.jsx(_s,{status:L})}),t.jsx("td",{className:"whitespace-nowrap py-3 pl-4 pr-2",children:t.jsx(Ps,{status:L,installment:E,labels:y,portalContainer:h??void 0,showDelete:l,payNowHiddenStatuses:o,onPayInstallment:m,onDeleteInstallment:x})})]},E.id)}),N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:y.noInstallmentsFound})})]})]})})]});return t.jsx("div",{ref:g,className:"vvt-ps relative min-w-0 w-full overflow-x-hidden [container-type:inline-size] font-sans text-zinc-900",children:r?t.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:t.jsx(c.AccordionItem,{"aria-label":y.title,title:C,children:S},"installment-table")}):S})}function _s({status:e}){return t.jsx(c.Chip,{size:"md",radius:"lg",className:c.cn("justify-center px-4",Ts[e]??Ts.scheduled),startContent:t.jsx(Ld,{status:e}),children:dr[e]??e})}function Ps({status:e,installment:n,labels:s,portalContainer:a,showDelete:r,payNowHiddenStatuses:i,onPayInstallment:l,onDeleteInstallment:o}){const d=!i.includes(e);return t.jsxs("div",{className:"flex min-w-36 items-center justify-start gap-2",children:[d?t.jsx(U,{type:"button",size:"md",color:"primary",variant:"solid",radius:"full",className:"min-w-[104px] shrink-0",isDisabled:e==="paid",startContent:t.jsx(R,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>l?.(n),children:s.payNow}):null,t.jsx(Md,{isFulfilled:e==="paid",showDelete:r,labels:s,portalContainer:a,onDelete:()=>o(n.id)})]})}function Md({isFulfilled:e,showDelete:n,labels:s,portalContainer:a,onDelete:r}){const[i,l]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs(c.Dropdown,{placement:"bottom-end",radius:"lg",children:[t.jsx(c.DropdownTrigger,{children:t.jsx(U,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:t.jsx(R,{icon:"solar:menu-dots-bold",className:"size-4"})})}),t.jsxs(c.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["send-link","delete"]:[],className:"w-72 p-2",onAction:o=>{o==="delete"&&n&&!e&&l(!0)},children:[t.jsx(c.DropdownSection,{title:"Actions",showDivider:n,children:t.jsx(c.DropdownItem,{textValue:s.sendLink,description:s.sendLinkDescription,startContent:t.jsx(R,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:s.sendLink},"send-link")}),n?t.jsx(c.DropdownSection,{title:s.dangerZone,children:t.jsx(c.DropdownItem,{textValue:s.deleteInstallment,className:"text-danger-600",color:"danger",description:s.deleteInstallmentDescription,startContent:t.jsx(R,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:s.deleteInstallment},"delete")}):null]})]}),n?t.jsx(Lt,{isOpen:i,labels:{title:s.deleteInstallmentConfirmationTitle,description:s.deleteInstallmentConfirmationDescription,cancel:s.deleteInstallmentConfirmationCancel,confirm:s.deleteInstallmentConfirmationConfirm},icon:t.jsx(R,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",portalContainer:a,shouldBlockScroll:!1,classNames:Dd,onClose:()=>l(!1),onConfirm:()=>{l(!1),r()}}):null]})}function Ld({status:e}){return e==="paid"?t.jsx(R,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?t.jsx(R,{icon:"solar:close-circle-bold",className:"size-3"}):e==="processing"?t.jsx(R,{icon:"solar:refresh-circle-bold",className:"size-3"}):e==="pending_confirmation"?t.jsx(R,{icon:"solar:clock-circle-bold",className:"size-3"}):t.jsx(R,{icon:"solar:calendar-outline",className:"size-3"})}function Qt(e,n){const s=new Date(`${e}T00:00:00`);return Number.isNaN(s.getTime())?e:new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(s)}const Id={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Td=({cards:e,locale:n,currency:s,listHeightClassName:a="",labels:r,showRenewal:i=!0,defaultRenewalValue:l=!1,initialSelectedMembershipId:o=null,allowReselect:d=!0,onRenewalChange:u,onCardSelect:f,className:m=""})=>{const x=Array.isArray(e)?e:[],[h,g]=p.useState(o),[y,j]=p.useState(l),w={...Id,...r};p.useEffect(()=>{g(o)},[o]);const v=N=>{if(N===h){d&&f?.(N);return}g(N),f?.(N)},C=N=>{j(N),u?.(N)};return t.jsxs("div",{className:c.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",m),"data-testid":"membership-select-cards",children:[t.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),t.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&t.jsx(hr,{title:w.renewalTitle,description:w.renewalDescription,value:y,onValueChange:C}),t.jsx("div",{className:c.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",a===""?"flex-1":c.cn("shrink-0",a)),"data-testid":"membership-select-cards-list",children:x.map(N=>t.jsx(ur,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:n,currency:s,isSelected:h===N.id,onSelect:v},N.id))})]})},ur=({itemKey:e,name:n,type:s,price:a,locale:r="en-US",currency:i="USD",showPrice:l=!0,isSelected:o=!1,onSelect:d,compact:u=!1,isDisabled:f=!1,disabledReason:m,statusLabel:x,statusTone:h="default",className:g=""})=>{const y=new Intl.NumberFormat(r,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(a),j=!!d&&!f,w=m||x,v=()=>{j&&d?.(e)};return t.jsx(c.Card,{shadow:"none",isPressable:!!d,onPress:v,className:c.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",f?"opacity-60":"",u?"rounded-2xl":"",g),"data-testid":"item-card","data-selected":o,isDisabled:f,children:t.jsxs("div",{className:c.cn("px-4 py-8 flex gap-6 items-center justify-between",u&&"px-3 py-3 gap-4"),children:[t.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[t.jsx("p",{className:c.cn("font-semibold text-left",u?"text-sm":"text-xl"),"data-testid":"item-card-name",children:n}),s&&t.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:t.jsx("p",{className:"text-center",children:s})}),w&&t.jsx(c.Chip,{"data-testid":"item-card-status",color:h,size:"sm",variant:"flat",className:"px-2",children:w})]}),l&&t.jsx("p",{className:c.cn("font-semibold text-right",u?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:y})]})})},Os="w-full bg-gray-100",Rs={variant:"light",color:"default"},fr=({id:e,title:n,media:s,imageUrl:a,imageAlt:r,imageClassName:i="",imageAspect:l="aspect-[4/3]",meta:o=[],price:d,action:u,footer:f,onPress:m,isPressable:x=!1,isDisabled:h=!1,compact:g=!1,className:y="",bodyClassName:j="",footerClassName:w="",dataTestId:v})=>{const C=!!(d&&d.value),N=!!u?.label,S=x&&!!m&&!N,E=!S,A=N?{variant:u?.variant??Rs.variant,color:u?.color??Rs.color,size:u?.size??"sm",isDisabled:h||u?.isDisabled,startContent:u?.icon?t.jsx(R,{icon:u.icon,width:16}):void 0}:null,L=s??(a?t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,Os,i),children:t.jsx(c.Image,{removeWrapper:!0,src:a,alt:r||n,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):t.jsx("div",{className:c.cn("relative overflow-hidden rounded-xl",l,Os,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:t.jsx(R,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return t.jsxs(c.Card,{"data-testid":v||`catalog-item-card-${e??"item"}`,className:c.cn("w-full overflow-hidden",y),isPressable:S,onPress:m,isDisabled:h,shadow:"sm",radius:"lg",children:[t.jsx("div",{children:L}),t.jsxs(c.CardBody,{className:c.cn("gap-3",g?"p-3":"p-4",j),children:[t.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:c.cn("line-clamp-2 text-base font-semibold text-gray-900",g?"text-sm":""),children:n}),o.length>0?t.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((D,P)=>t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(R,{icon:D.icon,className:"size-4 text-gray-400",width:16}),t.jsx("span",{children:D.label})]},`${D.label}-${P}`))}):null,(C||N)&&t.jsxs("div",{className:c.cn("flex items-center justify-end gap-2 pt-1 text-sm",g?"pt-0.5":"",w),children:[C?t.jsxs("span",{className:c.cn("mr-auto text-gray-500",g?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[d?.label&&t.jsxs("span",{children:[d.label," "]}),t.jsx("span",{className:"font-semibold text-brand",children:d?.value})]}):t.jsx("span",{className:"ml-auto","aria-hidden":!0}),N&&E?t.jsx(U,{className:c.cn("rounded-full",u?.className),onPress:u?.onPress,variant:A?.variant,color:A?.color,size:A?.size,startContent:A?.startContent,isDisabled:A?.isDisabled,"aria-label":u?.ariaLabel||u?.label,children:u?.label}):null]}),f?t.jsx("div",{className:"pt-1",children:f}):null]})]})};fr.displayName="CatalogItemCard";const _d={card:"gap-3 rounded-xl border border-dashed px-6 py-12",panel:"px-6 py-[72px]"},Pd={card:"size-12 rounded-2xl",panel:"size-[76px] rounded-[20px] border mb-[18px]"},Od={card:"text-base font-medium text-default-900",panel:"text-[17px] font-semibold text-acct-ink"},Rd={card:"max-w-sm text-sm text-default-600",panel:"max-w-[380px] text-sm text-acct-sub mt-1.5"},zd={card:"mt-1",panel:"mt-[22px]"},Bd="bg-acct-page border-acct-border text-acct-muted",Vd={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},Ud={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"},Hd={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"},qd={empty:"status",error:"alert",success:"status",loading:"status"},Wd={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function Yd(e,n,s,a){if(n===!1)return null;if(e==="loading"&&n===void 0)return t.jsx(c.Spinner,{size:"lg",color:"primary",className:a.spinner});if(p.isValidElement(n))return t.jsx(t.Fragment,{children:n});const r=typeof n=="string"?n:Vd[e];return r?t.jsx(R,{icon:r,width:s,height:s,"aria-hidden":"true",className:a.icon}):null}function et({variant:e="empty",surface:n="card",title:s,titleAs:a="p",description:r,icon:i,actions:l,role:o=qd[e],ariaLive:d=Wd[e],iconSize:u=24,className:f,classNames:m={},"data-testid":x="feedback-state"}){const h=Yd(e,i,u,m);return t.jsxs("div",{role:o,"aria-live":d,"data-variant":e,"data-testid":x,"data-surface":n,className:c.cn("flex flex-col items-center justify-center text-center",_d[n],n==="card"?Ud[e]:"bg-transparent",f,m.base),children:[h?t.jsx("span",{"aria-hidden":"true","data-testid":`${x}-icon`,className:c.cn("inline-flex items-center justify-center",Pd[n],e==="success"&&n==="card"&&"rounded-full",n==="panel"?Bd:Hd[e],m.iconWrapper),children:h}):null,t.jsxs("div",{className:c.cn("flex flex-col items-center",n==="card"&&"gap-1"),children:[t.jsx(a,{"data-testid":`${x}-title`,className:c.cn(Od[n],m.title),children:s}),r?t.jsx("p",{"data-testid":`${x}-description`,className:c.cn(Rd[n],m.description),children:r}):null]}),l?t.jsx("div",{"data-testid":`${x}-actions`,className:c.cn("flex flex-wrap items-center justify-center gap-2",zd[n],m.actions),children:l}):null]})}function Rn(e){return t.jsx(et,{...e,variant:"empty"})}function zn(e){return t.jsx(et,{...e,variant:"error"})}function Bn(e){return t.jsx(et,{...e,variant:"loading"})}function mr(e){return t.jsx(et,{...e,variant:"success"})}et.displayName="FeedbackState";Rn.displayName="EmptyState";zn.displayName="ErrorState";Bn.displayName="LoadingState";mr.displayName="SuccessState";const hr=({title:e,value:n,description:s,onValueChange:a,className:r=""})=>{const i=p.useId();return t.jsxs("div",{className:c.cn("w-full flex flex-row items-center",e||s?"justify-between gap-6":"justify-start",r),"data-testid":"toggle",children:[t.jsxs("div",{className:"flex flex-col items-start",children:[e&&t.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),s&&t.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:s})]}),t.jsx(c.Switch,{id:i,isSelected:n,onValueChange:a,"data-testid":"toggle-switch"})]})},Gd={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"},Kd=(e,n)=>new Intl.NumberFormat(e,{style:"currency",currency:n}),xr=e=>Object.values(e).reduce((n,s)=>n+Object.values(s).reduce((a,r)=>a+Object.values(r).reduce((i,l)=>i+l.selectedQuantity,0),0),0),Qd=e=>e.reduce((n,s)=>n+s.dates.reduce((a,r)=>a+r.tickets.reduce((i,l)=>i+l.max,0),0),0),Vn=e=>e.flatMap(n=>n.dates.flatMap(s=>s.tickets.map(a=>({exhibition:n,dateGroup:s,ticket:a})))),zs=(e,n,s)=>{const a={};let r=s?n??Qd(e):0;for(const{exhibition:i,dateGroup:l,ticket:o}of Vn(e)){a[i.id]??={},a[i.id][l.id]??={};const d=s?Math.min(o.max,r):0;a[i.id][l.id][o.id]={id:o.id,selectedQuantity:d,originalPrice:o.originalPrice,discountedPrice:o.price},r-=d}return a},Bs=(e,n,s)=>`${e}::${n}::${s}`,Zd=(e,n,s)=>{const a=xr(n);for(const{exhibition:r,dateGroup:i,ticket:l}of Vn(e)){const o=n[r.id]?.[i.id]?.[l.id]?.selectedQuantity??0,d=s===void 0?l.max:Math.min(l.max,s-(a-o));if(d>0&&o<d)return!1}return!0},Xd=({initialQuantity:e=1,minQuantity:n=1,maxQuantity:s=10,onChange:a,disabled:r=!1})=>{const i=Math.max(n,Math.min(s,e)),[l,o]=p.useState(()=>String(i)),[d,u]=p.useState(!1),f=d?l:String(i),m=()=>{r||i>=s||a?.(i+1)},x=()=>{r||i<=n||a?.(i-1)},h=N=>{if(r)return;o(N.target.value);const S=parseInt(N.target.value,10);isNaN(S)||a?.(Math.max(n,Math.min(s,S)))},g=N=>{const S=parseInt(N.target.value,10);if(u(!1),isNaN(S)){a?.(n);return}const E=Math.max(n,Math.min(s,S));E!==S?a?.(E):o(String(E))},y=i<=n,j=i>=s,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",v="bg-primary hover:bg-primary/80",C="bg-primary/40 cursor-not-allowed";return t.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[t.jsx("button",{type:"button",onClick:x,disabled:r||y,className:c.cn(w,r||y?C:v),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),t.jsx("input",{type:"number",value:f,onChange:h,onFocus:()=>u(!0),onBlur:g,disabled:r,min:n,max:s,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"}),t.jsx("button",{type:"button",onClick:m,disabled:r||j,className:c.cn(w,r||j?C:v),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Jd=({label:e,checked:n=!1,onChange:s,disabled:a=!1})=>{const r=()=>{a||s?.(!n)};return t.jsxs("button",{type:"button",onClick:r,disabled:a,role:"checkbox","aria-checked":n,"data-testid":"checkbox-button","data-checked":n,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",a&&"cursor-not-allowed opacity-60"),children:[t.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:()=>{},disabled:a,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),t.jsx("span",{className:c.cn("block w-3.5 h-3.5 rounded-sm relative",n?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:n&&t.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"})})]}),t.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},eu=({item:e,quantity:n,onChange:s,getTotalSelectedTickets:a,userMaxLimit:r,settings:i,labels:l})=>{const o=()=>{if(!a||r===void 0)return e.max;const m=a();return Math.min(e.max,r-(m-n))},d=i?.locale??"en-US",u=i?.currency??"USD",f=Kd(d,u);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[t.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?t.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.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)}),t.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:f.format(e.price)})]})]}),e.membershipName?t.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:t.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,t.jsx("div",{className:"text-sm text-zinc-500",children:t.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[l.ticketsAllowedToRedeem," ",e.max]})})]}),t.jsx(Xd,{initialQuantity:n,minQuantity:0,maxQuantity:o(),onChange:s})]}),e.membershipAlert?t.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:t.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]})},tu=({exhibitionId:e,dateGroup:n,isLast:s=!1,onQuantityChange:a,getTicketQuantity:r,getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d})=>t.jsxs("div",{className:c.cn("flex flex-col gap-2 pb-3",!s&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[t.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:n.date}),n.tickets.map((u,f)=>t.jsxs("div",{children:[t.jsx(eu,{item:u,quantity:r(e,n.id,u.id),onChange:m=>a(e,n.id,u.id,m),getTotalSelectedTickets:i,userMaxLimit:l,settings:o,labels:d}),f<n.tickets.length-1?t.jsx(c.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},u.id))]}),nu=({title:e,exhibition:n,onQuantityChange:s,getTicketQuantity:a,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o,initialExpanded:d=!1})=>{const[u,f]=p.useState(d),m=n.dates.reduce((h,g)=>h+g.tickets.reduce((y,j)=>y+a(n.id,g.id,j.id),0),0),x=n.dates.some(h=>h.tickets.length>0);return t.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[t.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-${n.id}`,"data-testid":"upgrade-ticket-header-button",children:t.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[t.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[m," ",o.ticketsSelectedToRedeem]}),t.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:t.jsx(R,{icon:"mdi:chevron-down"})})]})]})}),t.jsx("div",{id:`upgrade-items-${n.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&&t.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:x?n.dates.map((h,g)=>t.jsx(tu,{exhibitionId:n.id,dateGroup:h,isLast:g===n.dates.length-1,onQuantityChange:s,getTicketQuantity:a,getTotalSelectedTickets:r,userMaxLimit:i,settings:l,labels:o},h.id)):t.jsx("div",{className:"px-5 py-10 text-center",children:t.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},su=({initialExpanded:e=!1,userMaxLimit:n,labels:s,settings:a,ticketSelectionData:r,className:i="",onSelectionChange:l})=>{const o=p.useMemo(()=>r??[],[r]),d={...Gd,...s},[u,f]=p.useState(()=>zs(o,n,!0)),m=p.useRef(!1),x=p.useMemo(()=>{const v=Vn(o).map(({exhibition:C,dateGroup:N,ticket:S})=>[Bs(C.id,N.id,S.id),S]);return new Map(v)},[o]),h=Zd(o,u,n),g=(v,C,N)=>u[v]?.[C]?.[N]?.selectedQuantity??0,y=()=>xr(u),j=(v,C,N,S)=>{const E=g(v,C,N),A=y()-E;if(n!==void 0&&A+S>n)return;const L=x.get(Bs(v,C,N));if(!L)return;const D={...u,[v]:{...u[v],[C]:{...u[v]?.[C],[N]:{id:N,selectedQuantity:S,originalPrice:L.originalPrice,discountedPrice:L.price}}}};f(D),l?.(D)},w=v=>{const C=zs(o,n,v);f(C),l?.(C)};return p.useEffect(()=>{!m.current&&h&&(l?.(u),m.current=!0)},[h,u,l]),t.jsxs("div",{className:c.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[t.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:d.ticketSelectionTitle}),t.jsx(Jd,{label:d.selectAllButtonLabel,checked:h,onChange:w})]}),o.map(v=>t.jsx(nu,{title:v.exhibitionName,exhibition:v,onQuantityChange:j,getTicketQuantity:g,getTotalSelectedTickets:y,userMaxLimit:n,settings:a,labels:d,initialExpanded:e},v.id))]})},Zt={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},Xt=e=>{const n={};for(const s of e)s.type==="checkbox"?n[s.id]=[...s.selectedValues]:n[s.id]=s.selectedValue?[s.selectedValue]:[];return n},au=(e,n)=>{const s={};for(const a of n){if(a.type==="checkbox"){s[a.id]=e[a.id]??[...a.selectedValues];continue}const r=e[a.id]??[];s[a.id]=r.length>0?r[0]:null}return s},ru=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,pr=({triggerLabel:e,triggerAriaLabel:n,triggerIcon:s="solar:tuning-square-outline",triggerVariant:a="bordered",triggerColor:r="default",triggerSize:i="sm",triggerClassName:l,popoverClassName:o,className:d,sections:u,onConfirm:f,onClear:m,appliedCount:x,countAriaLabel:h,countDisplay:g="badge",confirmLabel:y=Zt.confirm,clearLabel:j=Zt.clear,isOpen:w,defaultOpen:v=!1,onOpenChange:C,isDisabled:N=!1,closeOnConfirm:S=!0,keepOpenAfterClear:E=!1})=>{const[A,L]=p.useState(v),[D,P]=p.useState(()=>Xt(u)),M=w??A,$=x??u.filter(q=>ru(q)).length,I=q=>{q&&P(Xt(u)),w||L(q),C?.(q)},T=(q,Z)=>{P(Q=>({...Q,[q.id]:Z}))},K=(q,Z)=>{P(Q=>({...Q,[q.id]:Z?[Z]:[]}))},H=async()=>{P(Xt(u.map(q=>q.type==="checkbox"?{...q,selectedValues:[]}:{...q,selectedValue:null}))),await m(),E||I(!1)},B=async()=>{const q=au(D,u);await f(q),S&&I(!1)},X=q=>{if(q.type==="checkbox")return t.jsx(c.CheckboxGroup,{label:q.label,value:D[q.id]??[],onValueChange:Q=>T(q,Q),children:q.options.map(Q=>t.jsx(c.Checkbox,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},q.id);const Z=D[q.id]?.[0]??"";return t.jsx(c.RadioGroup,{label:q.label,value:Z,onValueChange:Q=>K(q,Q||null),children:q.options.map(Q=>t.jsx(c.Radio,{value:Q.value,isDisabled:Q.isDisabled,children:Q.label},Q.value))},q.id)},J=p.useMemo(()=>$>0?h?.($)||`${$} filters applied`:void 0,[h,$]),re=p.useMemo(()=>$===0?e||Zt.noLabel:h?h($):`${e} (${$})`,[$,e,h]);return t.jsx("div",{className:d,children:t.jsxs(c.Popover,{isOpen:M,onOpenChange:I,placement:"bottom-end",children:[t.jsx(c.PopoverTrigger,{children:t.jsxs(U,{isDisabled:N,variant:a,color:r,size:i,className:l,"aria-label":n,"aria-haspopup":"dialog","aria-expanded":M,children:[t.jsx(R,{icon:s,width:16}),t.jsx("span",{children:e}),g==="badge"&&$>0?t.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":J,children:$}):g==="summary"&&re!==e?t.jsx("span",{className:"text-xs",children:re}):null]})}),t.jsx(c.PopoverContent,{className:o,children:t.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[u.map(q=>X(q)),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[t.jsx(U,{variant:"light",color:"default",size:"sm",onPress:H,children:j}),t.jsx(U,{color:"primary",size:"sm",onPress:B,children:y})]})]})})]})})};pr.displayName="FilterPopover";const iu="No sessions available for this date",lu=e=>e==="sold-out"||e==="closed"?"danger":"success",ou=e=>{const n=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof n=="number"?`${n} left`:"Limited":typeof n=="number"?`${n} seats available`:"Available"},Vs=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",cu=(e,n)=>n&&e.some(s=>s.date===n)?n:e[0]?.date??null,gr=({heading:e,subheading:n,days:s,selectedDate:a,onDateSelect:r,quickDates:i,selectedSessionId:l=null,onSessionSelect:o,emptyStateMessage:d=iu,statusLabel:u,statusTone:f,sessionAriaLabel:m,dayButtonClassName:x,calendarSlot:h,dayGroupAriaLabel:g,sessionGridAriaLabel:y,className:j,headingClassName:w,subheadingClassName:v})=>{const C=cu(s,a),N=s.find(D=>D.date===C),S=i??s.map(D=>({date:D.date,label:D.label})),E=N?.sessions??[],A=D=>D===C?"solid":"bordered",L=D=>{if(!Vs(D)){if(D.id===l){o(null);return}o(D.id)}};return t.jsxs("section",{className:c.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",j),"data-testid":"session-timeline-root",children:[t.jsxs("header",{className:"flex flex-col gap-1",children:[t.jsx("h2",{className:c.cn("text-base font-semibold text-gray-900",w),children:e}),n?t.jsx("p",{className:c.cn("text-sm text-gray-700",v),children:n}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":g||"Session days",children:[S.map(D=>t.jsx(U,{size:"sm",variant:A(D.date),color:"default",className:c.cn("rounded-full",x),isDisabled:D.isDisabled,onPress:()=>{r(D.date)},children:t.jsx("span",{children:D.label})},D.date)),h?t.jsx("div",{children:h}):null]}),t.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":y||"Sessions",children:[E.length===0?t.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,E.map(D=>{const P=Vs(D),M=D.id===l;return t.jsx("li",{className:"rounded-xl",children:t.jsx(c.Card,{shadow:"sm",radius:"lg",isPressable:!P,onPress:()=>{L(D)},"aria-disabled":P,"aria-pressed":P?void 0:M,className:c.cn("w-full",P?"bg-gray-100 opacity-70":"",M?"w-full ring-2 ring-gray-900":""),"aria-label":m?m(D,{isSelected:M,isUnavailable:P}):P?`${D.startTime} ${D.endTime} sold out`:`${D.startTime} ${D.endTime} available`,children:t.jsxs(c.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[t.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[D.startTime," – ",D.endTime]}),t.jsx(c.Chip,{size:"sm",color:f?f(D):lu(D.status),variant:"flat",children:u?u(D):ou(D)})]})})},D.id)})]})]})};gr.displayName="SessionTimeline";const du=(e,n)=>typeof e=="string"?t.jsx(R,{icon:e,className:"size-5","aria-hidden":"true"}):e||n||null,br=({title:e,subtitle:n,eyebrow:s,icon:a,initials:r,actions:i,titleAs:l="h1",className:o,classNames:d={},"data-testid":u="page-header"})=>{const f=du(a,r);return t.jsxs("header",{"data-testid":u,className:c.cn("flex flex-wrap items-start justify-between gap-4",o,d.base),children:[t.jsxs("div",{className:"flex items-center gap-4",children:[f?t.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,t.jsxs("div",{children:[s?t.jsx("p",{"data-testid":`${u}-eyebrow`,className:c.cn("text-brand text-sm font-medium uppercase tracking-wide",d.eyebrow),children:s}):null,t.jsx(l,{"data-testid":`${u}-title`,className:c.cn("text-3xl font-semibold text-gray-950",d.title),children:e}),n?t.jsx("p",{"data-testid":`${u}-subtitle`,className:c.cn("mt-1 text-sm text-gray-600",d.subtitle),children:n}):null]})]}),i?t.jsx("div",{"data-testid":`${u}-actions`,className:c.cn("flex flex-wrap items-center gap-2",d.actions),children:i}):null]})};br.displayName="PageHeader";const uu={active:"success",success:"success",draft:"warning",pending:"warning",warning:"warning",danger:"danger",archived:"default",inactive:"default",neutral:"default"},fu={active:{fg:"#057A54",bg:"#E6F4EF"},success:{fg:"#057A54",bg:"#E6F4EF"},draft:{fg:"#B7791F",bg:"#FBF0DD"},pending:{fg:"#B7791F",bg:"#FBF0DD"},warning:{fg:"#B7791F",bg:"#FBF0DD"},danger:{fg:"#B62214",bg:"#FBEAE8"},archived:{fg:"#9CA3AF",bg:"#F1F2F4"},inactive:{fg:"#9CA3AF",bg:"#F1F2F4"},neutral:{fg:"#9CA3AF",bg:"#F1F2F4"}},yr=({status:e,label:n,variant:s="flat",size:a="sm",color:r,startContent:i,className:l,"data-testid":o="status-chip"})=>{if(s==="dot"){const d=fu[e];return t.jsxs("span",{"data-testid":o,"data-status":e,className:c.cn("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 py-[3px] text-[12px] font-semibold leading-[1.4]",l),style:{color:d.fg,backgroundColor:d.bg},children:[t.jsx("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:"currentColor"}}),n]})}return t.jsx(c.Chip,{color:r??uu[e],variant:s,size:a,startContent:i,"data-testid":o,"data-status":e,className:c.cn("font-medium",l),children:n})};yr.displayName="StatusChip";const mu={sm:"gap-1 rounded-md px-2 py-0.5 text-[11.5px] leading-normal",md:"gap-1.5 rounded-lg px-2.5 py-1 text-xs leading-normal"},Un=({label:e,value:n,size:s="sm",className:a,"data-testid":r="key-value-chip"})=>t.jsxs("span",{"data-testid":r,className:c.cn("inline-flex items-baseline whitespace-nowrap border border-default-200 bg-default-100",mu[s],a),children:[t.jsx("span",{className:"font-medium text-default-400",children:e}),t.jsx("span",{className:"font-semibold text-default-700",children:n})]});Un.displayName="KeyValueChip";const vr=({columns:e,rows:n=6,label:s="Loading",barHeight:a=12,alignLastRight:r=!1,className:i,classNames:l={},"data-testid":o="table-skeleton"})=>t.jsxs("div",{role:"status","aria-busy":"true","data-testid":o,className:c.cn("w-full",i,l.base),children:[t.jsx("span",{className:"sr-only",children:s}),t.jsx("div",{"aria-hidden":"true",children:Array.from({length:n}).map((d,u)=>t.jsx("div",{"data-testid":`${o}-row`,className:c.cn("flex items-center gap-3 border-t border-default-100 px-5 py-4",l.row),children:e.map((f,m)=>{const x=m===e.length-1;return t.jsx("div",{className:c.cn(f==="fill"?"flex-1":"shrink-0",r&&x&&"flex justify-end"),style:f==="fill"?void 0:{width:f},children:t.jsx("div",{className:c.cn("animate-pulse rounded bg-default-200",l.bar),style:{height:a,width:f==="fill"?"60%":f}})},m)})},u))})]});vr.displayName="TableSkeleton";const jr="text-left text-[11px] font-semibold uppercase tracking-[.04em] text-acct-sub px-4 pt-4 pb-3 whitespace-nowrap bg-transparent",wr="px-4 text-[13.5px] text-acct-ink2 align-middle",Nr="border-t border-acct-hair transition-colors duration-150 hover:bg-acct-page data-[hover=true]:bg-acct-page",Cr="w-full",kr="border-t border-acct-border px-5 py-3.5",Sr=({columns:e,children:n,emptyContent:s,footer:a,ariaLabel:r,className:i,classNames:l={},"data-testid":o="admin-table"})=>t.jsxs("div",{className:c.cn(i,l.base),"data-testid":o,children:[t.jsxs(c.Table,{"aria-label":r,removeWrapper:!0,classNames:{table:c.cn(Cr,l.table),th:c.cn(jr,l.th),tr:c.cn(Nr,l.tr),td:c.cn(wr,l.td)},children:[t.jsx(c.TableHeader,{columns:e,children:d=>t.jsx(c.TableColumn,{align:d.align==="right"?"end":"start",width:d.width,children:d.label},d.key)}),t.jsx(c.TableBody,{emptyContent:s,children:n})]}),a?t.jsx("div",{"data-testid":`${o}-footer`,className:c.cn(kr,l.footer),children:a}):null]});Sr.displayName="AdminTable";const hu={md:"w-[280px]",lg:"w-[360px]"},Ar=({searchValue:e,onSearchChange:n,searchLabel:s,searchPlaceholder:a,searchIcon:r,children:i,trailing:l,searchWidth:o="md",className:d,"data-testid":u="admin-toolbar"})=>t.jsxs("div",{role:"search","data-testid":u,className:c.cn("flex flex-wrap items-center gap-3 mb-4",d),children:[t.jsx(c.Input,{type:"search","aria-label":s,placeholder:a??s,value:e,onValueChange:n,startContent:r?t.jsx("span",{"aria-hidden":"true",className:"flex text-acct-muted",children:r}):void 0,"data-testid":`${u}-search`,variant:"bordered",radius:"none",classNames:{base:hu[o],inputWrapper:["h-10 min-h-10 !h-10 rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),input:"text-[13.5px] text-acct-ink"}}),i,l?t.jsx("div",{className:"ml-auto",children:l}):null]});Ar.displayName="AdminToolbar";const xu="ml-0.5 inline-flex min-w-[18px] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground",pu="h-9 gap-1.5 rounded-full border border-gray-200 bg-white px-3.5 text-sm font-medium text-gray-700 hover:bg-gray-50 data-[pressed=true]:bg-gray-50",$r=p.forwardRef(function({icon:n,children:s,count:a,className:r,testId:i,...l},o){return t.jsxs(U,{ref:o,"data-testid":i,variant:"light",size:"sm",className:c.cn(pu,r),...l,children:[t.jsx(R,{icon:n,className:"size-4 text-gray-500","aria-hidden":!0}),t.jsx("span",{children:s}),a!==void 0&&a>0&&t.jsx("span",{className:xu,children:a})]})});$r.displayName="ToolbarButton";function Dr({items:e,value:n,onChange:s,ariaLabel:a,className:r,"data-testid":i="underline-tabs"}){return t.jsx(c.Tabs,{"aria-label":a,variant:"underlined",selectedKey:n,onSelectionChange:l=>s(String(l)),"data-testid":i,classNames:{base:c.cn("w-full mb-6",r),tabList:"gap-7 w-full relative rounded-none p-0 border-b border-acct-border",cursor:"w-full bg-acct-rust",tab:"max-w-fit px-0.5 h-auto pb-3",tabContent:"text-[15px] font-medium text-acct-sub group-data-[selected=true]:font-semibold group-data-[selected=true]:text-acct-rust",panel:"p-0"},children:e.map(l=>t.jsx(c.Tab,{title:l.label,"data-testid":`${i}-${l.key}`,children:l.content},l.key))})}Dr.displayName="UnderlineTabs";const Hn="text-[11px] font-semibold uppercase tracking-[.04em] text-acct-muted mb-1.5",qn="font-normal normal-case tracking-normal",Er=["h-[38px] min-h-[38px] !h-[38px] rounded-[11px] border border-acct-border bg-acct-surface px-3","data-[hover=true]:border-acct-rust-border","group-data-[focus=true]:border-acct-rust"].join(" "),Fr="text-[13.5px] text-acct-ink",Mr="bg-acct-page text-acct-muted cursor-default",Lr="mt-[5px] text-xs text-acct-sub",Ir="mt-[5px] text-xs text-acct-danger",Tr=({children:e,suffix:n,className:s,"data-testid":a="admin-field-label"})=>t.jsxs("div",{"data-testid":a,className:c.cn(Hn,s),children:[e,n?t.jsxs("span",{className:qn,children:[" ",n]}):null]});Tr.displayName="AdminFieldLabel";const _r=({label:e,labelSuffix:n,value:s,onChange:a,placeholder:r,disabled:i=!1,readOnly:l=!1,mono:o=!1,autoFocus:d=!1,hint:u,invalid:f=!1,className:m,"data-testid":x="admin-text-field"})=>t.jsx(c.Input,{labelPlacement:e?"outside":void 0,label:e&&n?t.jsxs(t.Fragment,{children:[e,t.jsxs("span",{className:qn,children:[" ",n]})]}):e,value:s,placeholder:r,isDisabled:i,isReadOnly:l,autoFocus:d,isInvalid:f,description:!f&&u?u:void 0,errorMessage:f?u:void 0,onValueChange:a,"data-testid":x,variant:"bordered",radius:"none",classNames:{base:c.cn("w-full",m),label:Hn,inputWrapper:Er,input:c.cn(Fr,(o||l)&&"font-mono",l&&Mr),description:Lr,errorMessage:Ir}});_r.displayName="AdminTextField";const gu={sm:"size-6 min-w-6",md:"size-[30px] min-w-[30px]"},Pr=({actions:e,size:n="md",className:s,"data-testid":a="row-actions"})=>t.jsx("div",{role:"presentation","data-testid":a,className:c.cn("inline-flex gap-0.5",s),onClick:r=>r.stopPropagation(),children:e.map(r=>t.jsx(U,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:r.onPress,isDisabled:r.disabled,"aria-label":r.label,title:r.label,"data-testid":`${a}-${r.key}`,className:c.cn("text-acct-sub data-[hover=true]:bg-acct-hair",gu[n]),children:r.icon},r.key))});Pr.displayName="RowActions";const Or=({children:e,placeholder:n="Select…",onOpen:s,onClear:a,ariaLabel:r,icon:i,trailingIcon:l,clearIcon:o,disabled:d=!1,className:u,"data-testid":f="picker-row"})=>{const m=e!=null;return t.jsxs("div",{"data-testid":f,className:c.cn("flex w-full min-h-10 items-center rounded-[10px] border border-acct-border bg-acct-surface px-[11px] transition-colors duration-150",d?"opacity-60":"hover:border-acct-rust-border",u),children:[t.jsxs(U,{variant:"light",radius:"none",disableAnimation:!0,onPress:s,isDisabled:d,"aria-haspopup":"dialog","aria-label":r,"data-testid":`${f}-trigger`,className:"flex h-auto min-h-0 min-w-0 flex-1 items-center justify-start gap-2.5 bg-transparent px-0 py-2 text-left text-inherit data-[hover=true]:bg-transparent",children:[i?t.jsx("span",{className:"flex shrink-0 text-acct-muted",children:i}):null,m?t.jsx("span",{className:"flex min-w-0 items-center gap-2",children:e}):t.jsx("span",{className:"text-[13.5px] font-semibold text-acct-sub",children:n}),l?t.jsx("span",{className:"ml-auto flex shrink-0 text-acct-muted",children:l}):null]}),m&&a?t.jsx(U,{isIconOnly:!0,variant:"light",radius:"sm",size:"sm",onPress:a,isDisabled:d,"aria-label":`Clear ${r}`,title:"Clear","data-testid":`${f}-clear`,className:"ml-1.5 size-6 min-w-6 shrink-0 text-acct-muted data-[hover=true]:bg-acct-hair",children:o}):null]})};Or.displayName="PickerRow";function Rr(e,n,s){if(s<=0||n<=0||e<=0)return{from:0,to:0};const a=(e-1)*n+1;return a>s?{from:0,to:0}:{from:a,to:Math.min(s,e*n)}}const zr=({page:e,pageSize:n,total:s,unit:a,announce:r=!0,className:i,classNames:l={},"data-testid":o="pagination-summary"})=>{const{from:d,to:u}=Rr(e,n,s),f=c.cn("font-semibold text-default-700",l.emphasis);return t.jsxs("p",{"data-testid":o,"aria-live":r?"polite":void 0,className:c.cn("text-sm text-default-500",i,l.base),children:["Showing"," ",t.jsx("span",{"data-testid":`${o}-range`,className:f,children:d===0?0:`${d}–${u}`})," ","of"," ",t.jsx("span",{"data-testid":`${o}-total`,className:f,children:s}),a?t.jsxs(t.Fragment,{children:[" ",a]}):null]})};zr.displayName="PaginationSummary";const Br=({isLoading:e=!1,isError:n=!1,isEmpty:s=!1,loadingTitle:a="Loading…",loadingContent:r,errorTitle:i="Something went wrong",errorDescription:l,retryLabel:o="Retry",onRetry:d,errorActions:u,errorContent:f,emptyTitle:m="Nothing here yet",emptyDescription:x,emptyIcon:h,emptyActions:g,emptyContent:y,children:j,className:w,classNames:v={},"data-testid":C="list-panel"})=>{const N={base:c.cn("border-0 bg-transparent py-12",v.state)};let S;return e?S=r??t.jsx(Bn,{title:a,classNames:N,"data-testid":`${C}-loading`}):n?S=f??t.jsx(zn,{title:i,description:l,classNames:N,"data-testid":`${C}-error`,actions:u??(d?t.jsx(U,{color:"primary",variant:"flat",onPress:d,children:o}):void 0)}):s?S=y??t.jsx(Rn,{title:m,description:x,icon:h,actions:g,classNames:N,"data-testid":`${C}-empty`}):S=j,t.jsx("section",{"data-testid":C,className:c.cn("rounded-xl bg-white p-2 shadow-sm",w,v.base),children:S})};Br.displayName="ListPanel";const bu=350,yu={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}"},Jt=(e,n)=>Object.entries(n).reduce((s,[a,r])=>s.replace(`{${a}}`,r),e),vu=({dueAmount:e,received:n,defaultReceived:s=null,onChange:a,locale:r="en-US",labels:i,isDisabled:l=!1,maxAmount:o,autoFocus:d=!1,className:u,"data-testid":f="cash-tender-form"})=>{const m={...yu,...i},x=Ft(e.currency,r),h=n!==void 0,[g,y]=p.useState(s??null),j=h?n:g,w=p.useMemo(()=>{const I=typeof j=="number"&&Number.isFinite(j)?j:0,T=dn(I,e.value,e.currency,r);return{received:I,change:T>0?T:0,isValid:I>=e.value&&I>0}},[j,e.value,e.currency,r]),v=p.useCallback(I=>{const T=I.currentTarget;requestAnimationFrame(()=>{T.isConnected&&T.select()})},[]),C=p.useCallback(I=>{if(l)return;const T=I.replace(/[^\d.,]/g,"").replace(",","."),K=T===""?null:Number.parseFloat(T),H=K===null||Number.isNaN(K)?null:K;if(H!==null&&o!==void 0&&H>o)return;h||y(H);const B=typeof H=="number"&&Number.isFinite(H)?H:0,X=dn(B,e.value,e.currency,r);a?.({received:B,change:X>0?X:0,isValid:B>=e.value&&B>0})},[h,l,e.value,e.currency,r,a,o]),N=j==null?"":String(j),S=w.isValid&&w.change>0,E=!w.isValid&&w.received>0,A=he(w.change,r,e.currency),L=he(e.value,r,e.currency),[D,P]=p.useState(""),M=p.useRef(null);p.useEffect(()=>{M.current&&clearTimeout(M.current);const I=S?Jt(m.changeMessageTemplate,{change:A}):"",T=S?bu:0;return M.current=setTimeout(()=>P(I),T),()=>{M.current&&clearTimeout(M.current)}},[S,A,m.changeMessageTemplate]);const $=`${f}-received`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",u),"data-testid":f,children:[t.jsx(c.Input,{id:$,label:m.receivedLabel,labelPlacement:"outside",type:"text",inputMode:x===0?"numeric":"decimal",pattern:x===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:I=>C(I.target.value),onFocus:v,placeholder:m.receivedPlaceholder,isDisabled:l,isInvalid:E,errorMessage:E?Jt(m.insufficientMessageTemplate,{due:L}):void 0,variant:"bordered",radius:"lg",autoFocus:d,"data-testid":`${f}-received-input`}),S&&t.jsx(c.Alert,{"data-testid":`${f}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:m.changeLabel,description:Jt(m.changeMessageTemplate,{change:A}),icon:t.jsx(R,{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"}}),t.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:D})]})},ju={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Us=()=>{const e=new Date,n=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${n(e.getMonth()+1)}-${n(e.getDate())}`},Vr=({dueAmount:e,value:n,defaultValue:s,onChange:a,labels:r,hideDate:i=!1,hideBankName:l=!1,isDisabled:o=!1,checkNumberMaxLength:d=34,bankNameMaxLength:u=100,autoFocus:f=!1,className:m,"data-testid":x="check-tender-form"})=>{const h={...ju,...r},g=n!==void 0,[y,j]=p.useState({checkNumber:s?.checkNumber??"",bankName:s?.bankName??"",date:s?.date??Us()}),[w,v]=p.useState(!!s?.checkNumber),C=p.useMemo(()=>g?{checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Us()}:y,[g,n,y]),N=p.useCallback(M=>{g||j(M);const $=M.checkNumber.trim(),I={amount:e.value,checkNumber:$,bankName:M.bankName.trim()||void 0,date:i?void 0:M.date,isValid:$.length>0&&e.value>0};a?.(I)},[g,e.value,i,a]),S=p.useCallback(M=>$=>{o||(M==="checkNumber"&&$.length>0&&v(!0),N({...C,[M]:$}))},[C,N,o]),E=p.useCallback(()=>{o||v(!0)},[o]),A=w&&C.checkNumber.trim()==="",L=`${x}-check-number`,D=`${x}-bank-name`,P=`${x}-date`;return t.jsxs("div",{className:c.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",m),"data-testid":x,children:[t.jsx(c.Input,{id:L,label:h.checkNumberLabel,labelPlacement:"outside",type:"text",value:C.checkNumber,onChange:M=>S("checkNumber")(M.target.value),onBlur:E,placeholder:h.checkNumberPlaceholder,maxLength:d,isRequired:!0,isInvalid:A,errorMessage:A?h.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:f,"data-testid":`${x}-check-number-input`}),!l&&t.jsx(c.Input,{id:D,label:h.bankNameLabel,labelPlacement:"outside",type:"text",value:C.bankName,onChange:M=>S("bankName")(M.target.value),placeholder:h.bankNamePlaceholder,maxLength:u,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${x}-bank-name-input`}),!i&&t.jsx(c.Input,{id:P,label:h.dateLabel,labelPlacement:"outside",type:"date",value:C.date,onChange:M=>S("date")(M.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${x}-date-input`,className:"sm:col-span-2"})]})};Vr.displayName="CheckTenderForm";const wu={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Nu=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Ur=({dueAmount:e,methodOptions:n=Nu,value:s,defaultValue:a,onChange:r,labels:i,showReference:l=!1,isDisabled:o=!1,className:d,"data-testid":u="other-tender-form"})=>{const f={...wu,...i},m=s!==void 0,[x,h]=p.useState({method:a?.method??"",reference:a?.reference??""}),g=p.useMemo(()=>m?{method:s?.method??"",reference:s?.reference??""}:x,[m,s,x]),y=p.useCallback(S=>n.find(E=>E.value===S)?.label??"",[n]),j=p.useCallback(S=>{m||h(S);const E=y(S.method),A={amount:e.value,method:S.method,description:E,reference:S.reference.trim()||void 0,isValid:S.method!==""};r?.(A)},[m,e.value,r,y]),w=p.useCallback(S=>{if(o)return;const E=typeof S=="string"?S:Array.from(S)[0]?.toString()??"";j({...g,method:E})},[g,j,o]),v=p.useCallback(S=>{o||j({...g,reference:S})},[g,j,o]),C=`${u}-method`,N=`${u}-reference`;return t.jsxs("div",{className:c.cn("flex flex-col gap-3",d),"data-testid":u,children:[t.jsx(Fe,{id:C,label:f.methodLabel,labelPlacement:"outside",placeholder:f.methodPlaceholder,selectedKeys:g.method?[g.method]:[],onSelectionChange:w,isDisabled:o,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:n.map(S=>t.jsx(c.SelectItem,{"data-testid":`${u}-method-option-${S.value}`,children:S.label},S.value))}),l&&t.jsx(c.Input,{id:N,label:f.referenceLabel,labelPlacement:"outside",type:"text",value:g.reference,onChange:S=>v(S.target.value),placeholder:f.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${u}-reference-input`})]})};Ur.displayName="OtherTenderForm";const Cu={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ku={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Su={pending:"warning",recorded:"success",failed:"danger"},Au=e=>e==="pending"||e==="recorded",$u=e=>`#${e+1}`,Hr=({total:e,tenders:n,onRemove:s,locale:a="en-US",labels:r,hideCollectedList:i=!1,className:l,"data-testid":o="split-payment-summary"})=>{const d={...Cu,...r},{collected:u,remaining:f,isComplete:m}=p.useMemo(()=>{const h=n.reduce((y,j)=>Au(j.status)?y+j.amount:y,0),g=Math.max(e.value-h,0);return{collected:h,remaining:g,isComplete:h>=e.value&&e.value>0}},[n,e.value]),x=h=>h==="pending"?d.statusPending:h==="recorded"?d.statusRecorded:d.statusFailed;return t.jsxs("div",{className:c.cn("flex flex-col gap-4",l),"data-testid":o,children:[t.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[t.jsx("div",{className:"text-sm text-default-600",children:m?d.completeLabel:d.remainingLabel}),t.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:he(m?u:f,a,e.currency)})]}),!i&&n.length>0&&t.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[t.jsx("h3",{className:"text-base font-semibold",children:d.collectedHeading}),n.map((h,g)=>t.jsx(Du,{index:g,tender:h,locale:a,currency:e.currency,removable:!!s&&h.status!=="recorded",onRemove:s?()=>s(h.id):void 0,statusLabel:x(h.status),removeAriaLabel:d.removeAriaLabel,recordedTooltip:d.removeTooltipForRecorded,dataTestId:`${o}-row-${g}`},h.id))]})]})};Hr.displayName="SplitPaymentSummary";const Du=({index:e,tender:n,locale:s,currency:a,removable:r,onRemove:i,statusLabel:l,removeAriaLabel:o,recordedTooltip:d,dataTestId:u})=>{const f=i?t.jsx(U,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!r,"aria-label":o,"data-testid":`${u}-remove`,className:c.cn(r?"text-default-700 hover:bg-default-200":"text-default-300"),children:t.jsx(R,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return t.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:[t.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:$u(e)}),t.jsx(R,{icon:ku[n.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"flex-1 truncate","data-testid":`${u}-label`,children:n.label}),t.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${u}-amount`,children:he(n.amount,s,a)}),t.jsx(c.Chip,{size:"sm",radius:"full",variant:"flat",color:Su[n.status],startContent:n.status==="recorded"?t.jsx(R,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):n.status==="failed"?t.jsx(R,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${u}-status`,children:l}),f&&(r?f:t.jsx(c.Tooltip,{content:d,placement:"left",children:t.jsx("span",{tabIndex:0,"aria-label":d,children:f})}))]})},Eu=`
|
|
17
17
|
@keyframes pp-modal-in {
|
|
18
18
|
from { opacity: 0; transform: scale(0.96); }
|
|
19
19
|
to { opacity: 1; transform: scale(1); }
|
package/dist/index.js
CHANGED
|
@@ -8255,22 +8255,30 @@ function jh() {
|
|
|
8255
8255
|
}
|
|
8256
8256
|
const ur = {
|
|
8257
8257
|
paid: "bg-emerald-50 text-emerald-700",
|
|
8258
|
+
scheduled: "bg-blue-50 text-blue-700",
|
|
8258
8259
|
schedule: "bg-blue-50 text-blue-700",
|
|
8260
|
+
// legacy spelling — see note above
|
|
8259
8261
|
payment_due: "bg-amber-50 text-amber-700",
|
|
8260
8262
|
overdue: "bg-orange-50 text-orange-700",
|
|
8261
8263
|
failed: "bg-red-50 text-red-700",
|
|
8262
8264
|
refunded: "bg-zinc-100 text-zinc-600",
|
|
8263
8265
|
disputed: "bg-purple-50 text-purple-700",
|
|
8264
|
-
canceled: "bg-zinc-100 text-zinc-600"
|
|
8266
|
+
canceled: "bg-zinc-100 text-zinc-600",
|
|
8267
|
+
processing: "bg-sky-50 text-sky-700",
|
|
8268
|
+
pending_confirmation: "bg-indigo-50 text-indigo-700"
|
|
8265
8269
|
}, Ui = {
|
|
8266
8270
|
paid: "Paid",
|
|
8267
|
-
|
|
8271
|
+
scheduled: "Scheduled",
|
|
8272
|
+
schedule: "Scheduled",
|
|
8273
|
+
// legacy spelling — see note above
|
|
8268
8274
|
payment_due: "Payment Due",
|
|
8269
8275
|
overdue: "Overdue",
|
|
8270
8276
|
failed: "Failed",
|
|
8271
8277
|
refunded: "Refunded",
|
|
8272
8278
|
disputed: "Disputed",
|
|
8273
|
-
canceled: "Canceled"
|
|
8279
|
+
canceled: "Canceled",
|
|
8280
|
+
processing: "Processing",
|
|
8281
|
+
pending_confirmation: "Pending Confirmation"
|
|
8274
8282
|
}, iu = {
|
|
8275
8283
|
title: "Payments",
|
|
8276
8284
|
searchLabel: "Search a payment",
|
|
@@ -8320,7 +8328,7 @@ function Hh({
|
|
|
8320
8328
|
] }) : void 0, k = de(() => {
|
|
8321
8329
|
const L = w.trim().toLowerCase();
|
|
8322
8330
|
return L ? e.filter((A) => {
|
|
8323
|
-
const _ = A.status ?? "
|
|
8331
|
+
const _ = A.status ?? "scheduled";
|
|
8324
8332
|
return [
|
|
8325
8333
|
A.id,
|
|
8326
8334
|
A.amount,
|
|
@@ -8376,7 +8384,7 @@ function Hh({
|
|
|
8376
8384
|
),
|
|
8377
8385
|
children: /* @__PURE__ */ u("div", { className: "flex flex-col gap-2", children: [
|
|
8378
8386
|
k.map((L, A) => {
|
|
8379
|
-
const _ = L.status ?? "
|
|
8387
|
+
const _ = L.status ?? "scheduled";
|
|
8380
8388
|
return /* @__PURE__ */ a(we, { radius: "lg", shadow: "none", className: "border border-default-200", children: /* @__PURE__ */ u(Se, { className: "gap-3 p-3", children: [
|
|
8381
8389
|
/* @__PURE__ */ u("div", { className: "flex items-start justify-between gap-2", children: [
|
|
8382
8390
|
/* @__PURE__ */ u("div", { className: "min-w-0", children: [
|
|
@@ -8443,7 +8451,7 @@ function Hh({
|
|
|
8443
8451
|
] }) }),
|
|
8444
8452
|
/* @__PURE__ */ u("tbody", { children: [
|
|
8445
8453
|
k.map((L, A) => {
|
|
8446
|
-
const _ = L.status ?? "
|
|
8454
|
+
const _ = L.status ?? "scheduled";
|
|
8447
8455
|
return /* @__PURE__ */ u("tr", { className: "text-zinc-500", children: [
|
|
8448
8456
|
/* @__PURE__ */ a("td", { className: "px-2 py-3", children: A + 1 }),
|
|
8449
8457
|
/* @__PURE__ */ a("td", { className: "overflow-hidden px-2 py-3", children: /* @__PURE__ */ a("span", { className: "block w-full truncate", children: L.id || `PMT-${A + 1}` }) }),
|
|
@@ -8510,7 +8518,7 @@ function fr({ status: e }) {
|
|
|
8510
8518
|
radius: "lg",
|
|
8511
8519
|
className: h(
|
|
8512
8520
|
"justify-center px-4",
|
|
8513
|
-
ur[e] ?? ur.
|
|
8521
|
+
ur[e] ?? ur.scheduled
|
|
8514
8522
|
),
|
|
8515
8523
|
startContent: /* @__PURE__ */ a(cu, { status: e }),
|
|
8516
8524
|
children: Ui[e] ?? e
|
|
@@ -8644,7 +8652,7 @@ function ou({
|
|
|
8644
8652
|
] });
|
|
8645
8653
|
}
|
|
8646
8654
|
function cu({ status: e }) {
|
|
8647
|
-
return e === "paid" ? /* @__PURE__ */ a(R, { icon: "solar:check-circle-bold", className: "size-3" }) : e === "failed" ? /* @__PURE__ */ a(R, { icon: "solar:close-circle-bold", className: "size-3" }) : /* @__PURE__ */ a(R, { icon: "solar:calendar-outline", className: "size-3" });
|
|
8655
|
+
return e === "paid" ? /* @__PURE__ */ a(R, { icon: "solar:check-circle-bold", className: "size-3" }) : e === "failed" ? /* @__PURE__ */ a(R, { icon: "solar:close-circle-bold", className: "size-3" }) : e === "processing" ? /* @__PURE__ */ a(R, { icon: "solar:refresh-circle-bold", className: "size-3" }) : e === "pending_confirmation" ? /* @__PURE__ */ a(R, { icon: "solar:clock-circle-bold", className: "size-3" }) : /* @__PURE__ */ a(R, { icon: "solar:calendar-outline", className: "size-3" });
|
|
8648
8656
|
}
|
|
8649
8657
|
function gn(e, t) {
|
|
8650
8658
|
const n = /* @__PURE__ */ new Date(`${e}T00:00:00`);
|
|
@@ -1,7 +1,7 @@
|
|
|
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 = '
|
|
4
|
+
export type InstallmentStatus = 'scheduled' | 'paid' | 'payment_due' | 'overdue' | 'failed' | 'refunded' | 'disputed' | 'canceled' | 'processing' | 'pending_confirmation';
|
|
5
5
|
export type ScheduledInstallment = {
|
|
6
6
|
id: string;
|
|
7
7
|
dueDate: string;
|